9#include <kernel/shape.hpp>
11#include <kernel/analytic/common.hpp>
12#include <kernel/geometry/mesh_node.hpp>
13#include <kernel/geometry/intern/face_index_mapping.hpp>
14#include <kernel/meshopt/rumpf_trafo.hpp>
16#include <kernel/util/property_map.hpp>
17#include <kernel/util/dist.hpp>
29 template<
typename DT_>
30 class ConcentrationFunctionDefault;
32 template<
typename DT_>
33 class ConcentrationFunctionPowOfDist;
52 template<
typename DT_,
typename ShapeType_>
54 struct AlignmentPenalty;
89 template<
typename Mesh_,
typename Dist_,
typename EdgeFreqs_>
91 const EdgeFreqs_& DOXY(edge_freqs))
118 template<
typename Mesh_,
typename Dist_>
163 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
166 const Mesh_& DOXY(mesh),
const Dist_& DOXY(dist),
const GradDist_& DOXY(grad_dist),
167 const EdgeFreqs_& DOXY(edge_freqs))
175 template<
typename DT_,
int shape_dim>
176 struct AlignmentPenalty<DT_, Shape::Simplex<shape_dim>>
181 template<
typename Mesh_,
typename Dist_,
typename EdgeFreqs_>
185 const auto& edge_idx = mesh.template get_index_set<1,0>();
186 const auto vd = dist.elements_view_r();
187 const auto vef = edge_freqs.elements_view_r();
188 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
190 constraint += vef(edge)*FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
191 eval( - vd(edge_idx(edge,0)) * vd(edge_idx(edge,1)));
197 template<
typename Mesh_,
typename Dist_>
200 XASSERT(constraint_vec !=
nullptr);
201 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 1, 0> FimType;
204 const auto& idx = mesh.template get_index_set<ShapeType::dimension,0>();
205 const auto vd = dist.elements_view_r();
209 for(
int edge(0); edge < Shape::FaceTraits<ShapeType,1>::count; ++edge)
212 int i(FimType::map(edge,0));
213 int j(FimType::map(edge,1));
214 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
215 eval(-
DataType(1)*vd(idx(cell, i)) * vd(idx(cell, j))) );
217 constraint_vec[cell] += my_constraint;
219 constraint += my_constraint;
227 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
229 Vector_&
grad,
const DataType alignment_fval,
const DataType fac,
const Mesh_& mesh,
const Dist_& dist,
const GradDist_& grad_dist,
const EdgeFreqs_& edge_freqs)
231 const auto& edge_idx = mesh.template get_index_set<1,0>();
233 typedef Tiny::Vector<DataType, Mesh_::world_dim> WorldPoint;
236 auto vg =
grad.elements_view_w();
237 const auto vd = dist.elements_view_r();
238 const auto vgd = grad_dist.elements_view_r();
239 const auto vef = edge_freqs.elements_view_r();
240 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
242 Index i(edge_idx(edge,0));
243 Index j(edge_idx(edge,1));
245 auto dist_prod = vd(i) * vd(j);
247 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
249 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
250 vg[i] += vef(edge)*grad_loc;
252 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
253 vg[j] += vef(edge)*grad_loc;
259 template<
typename DT_>
260 struct AlignmentPenalty<DT_, Shape::Hypercube<2>>
266 template<
typename Mesh_,
typename Dist_,
typename EdgeFreqs_>
270 const auto& edge_idx = mesh.template get_index_set<1,0>();
271 const auto vd = dist.elements_view_r();
272 const auto vef = edge_freqs.elements_view_r();
273 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
275 constraint += vef(edge)*FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
276 eval( - vd(edge_idx(edge,0)) * vd(edge_idx(edge,1)));
279 const auto& cell_idx = mesh.template get_index_set<ShapeType::dimension,0>();
282 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
283 eval( - vd(cell_idx(cell,0)) * vd(cell_idx(cell,3)));
284 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
285 eval( - vd(cell_idx(cell,1)) * vd(cell_idx(cell,2)));
291 template<
typename Mesh_,
typename Dist_>
294 XASSERT(constraint_vec !=
nullptr);
295 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 1, 0> FimType;
298 const auto& idx = mesh.template get_index_set<ShapeType::dimension,0>();
299 const auto vd = dist.elements_view_r();
303 for(
int edge(0); edge < Shape::FaceTraits<ShapeType,1>::count; ++edge)
306 int i(FimType::map(edge,0));
307 int j(FimType::map(edge,1));
308 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
309 eval(-
DataType(1)*vd(idx(cell, i)) * vd(idx(cell, j))) );
311 constraint_vec[cell] += my_constraint;
313 constraint += my_constraint;
316 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
317 eval( - vd(idx(cell,0)) * vd(idx(cell,3))));
318 my_constraint = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
319 eval( - vd(idx(cell,1)) * vd(idx(cell,2)));
321 constraint_vec[cell] += my_constraint;
323 constraint += my_constraint;
330 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
332 Vector_&
grad,
const DataType alignment_fval,
const DataType fac,
const Mesh_& mesh,
const Dist_& dist,
333 const GradDist_& grad_dist,
const EdgeFreqs_& edge_freqs)
335 const auto& edge_idx = mesh.template get_index_set<1,0>();
337 typedef Tiny::Vector<DataType, Mesh_::world_dim> WorldPoint;
340 const auto vd = dist.elements_view_r();
341 auto vg =
grad.elements_view_rw();
342 const auto vgd = grad_dist.elements_view_r();
343 const auto vef = edge_freqs.elements_view_r();
345 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
347 Index i(edge_idx(edge,0));
348 Index j(edge_idx(edge,1));
350 auto dist_prod = vd(i) * vd(j);
352 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
354 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
355 vg[i] += vef(edge)*grad_loc;
357 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
358 vg[j] += vef(edge)*grad_loc;
361 const auto& cell_idx = mesh.template get_index_set<ShapeType::dimension,0>();
367 auto dist_prod = vd(i) * vd(j);
369 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
371 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
374 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
377 i = cell_idx(cell,
Index(1));
378 j = cell_idx(cell,
Index(2));
380 dist_prod = vd(i) * vd(j);
382 heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
384 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
387 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
393 template<
typename DT_>
394 struct AlignmentPenalty<DT_, Shape::Hypercube<3>>
400 template<
typename Mesh_,
typename Dist_,
typename EdgeFreqs_>
404 const auto& edge_idx = mesh.template get_index_set<1,0>();
405 const auto vd = dist.elements_view_r();
406 const auto vef = edge_freqs.elements_view_r();
407 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
409 constraint += vef(edge)*FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
410 eval( - vd(edge_idx(edge,0)) * vd(edge_idx(edge,1)));
413 const auto& face_idx = mesh.template get_index_set<2,0>();
414 for(
Index face(0); face < mesh.get_num_entities(2); ++face)
416 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
417 eval( - vd(face_idx(face,0)) * vd(face_idx(face,3)));
418 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
419 eval( - vd(face_idx(face,1)) * vd(face_idx(face,2)));
422 const auto& cell_idx = mesh.template get_index_set<3,0>();
423 for(
Index cell(0); cell < mesh.get_num_entities(3); ++cell)
425 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
426 eval( - vd(cell_idx(cell,0)) * vd(cell_idx(cell,7)));
427 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
428 eval( - vd(cell_idx(cell,1)) * vd(cell_idx(cell,6)));
429 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
430 eval( - vd(cell_idx(cell,2)) * vd(cell_idx(cell,5)));
431 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
432 eval( - vd(cell_idx(cell,3)) * vd(cell_idx(cell,4)));
438 template<
typename Mesh_,
typename Dist_>
441 XASSERT(constraint_vec !=
nullptr);
442 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 1, 0> VertAtEdge;
443 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 2, 0> VertAtFace;
446 const auto vd = dist.elements_view_r();
447 const auto& idx = mesh.template get_index_set<ShapeType::dimension,0>();
452 for(
int edge(0); edge < Shape::FaceTraits<ShapeType,1>::count; ++edge)
455 int i(VertAtEdge::map(edge,0));
456 int j(VertAtEdge::map(edge,1));
457 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
460 constraint_vec[cell] += my_constraint;
462 constraint += my_constraint;
465 for(
int face(0); face < Shape::FaceTraits<ShapeType,2>::count; ++face)
468 int i0(VertAtFace::map(face,0));
469 int i1(VertAtFace::map(face,1));
470 int i2(VertAtFace::map(face,2));
471 int i3(VertAtFace::map(face,3));
474 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
476 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
479 constraint_vec[cell] += my_constraint;
481 constraint += my_constraint;
485 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
486 eval( - vd(idx(cell,0)) * vd(idx(cell,7)));
487 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
488 eval( - vd(idx(cell,1)) * vd(idx(cell,6)));
489 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
490 eval( - vd(idx(cell,2)) * vd(idx(cell,5)));
491 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
492 eval( - vd(idx(cell,3)) * vd(idx(cell,4)));
494 constraint_vec[cell] += my_constraint;
496 constraint += my_constraint;
503 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
505 Vector_&
grad,
const DataType alignment_fval,
const DataType fac,
const Mesh_& mesh,
const Dist_& dist,
506 const GradDist_& grad_dist,
const EdgeFreqs_& edge_freqs)
508 const auto& edge_idx = mesh.template get_index_set<1,0>();
510 typedef Tiny::Vector<DataType, Mesh_::world_dim> WorldPoint;
513 auto vg =
grad.elements_view_w();
514 const auto vd = dist.elements_view_r();
515 const auto vgd = grad_dist.elements_view_r();
516 const auto vef = edge_freqs.elements_view_r();
518 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
520 Index i(edge_idx(edge,0));
521 Index j(edge_idx(edge,1));
523 auto dist_prod = vd(i) * vd(j);
525 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
527 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
528 vg[i] += vef(edge)*grad_loc;
530 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
531 vg[j] += vef(edge)*grad_loc;
534 const auto& face_idx = mesh.template get_index_set<2,0>();
535 for(
Index face(0); face < mesh.get_num_entities(2); ++face)
540 auto dist_prod = vd(i) * vd(j);
542 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
544 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
547 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
550 i = face_idx(face,
Index(1));
551 j = face_idx(face,
Index(2));
553 dist_prod = vd(i) * vd(j);
555 heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
557 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j)) * vgd(i);
560 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i)) * vgd(j);
564 const auto& cell_idx = mesh.template get_index_set<3,0>();
565 for(
Index cell(0); cell < mesh.get_num_entities(2); ++cell)
570 for(
int k(0); k < 4; ++k)
573 auto dist_prod = vd(i[k]) * vd(j[k]);
575 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
577 grad_loc = (-fac * alignment_fval * heaviside_der * vd(j[k])) * vgd(i[k]);
578 vg[i[k]] += grad_loc;
580 grad_loc = (-fac * alignment_fval * heaviside_der * vd(i[k])) * vgd(j[k]);
581 vg[j[k]] += grad_loc;
613 typename RefCellTrafo_ = RumpfTrafo<Trafo_, typename Trafo_::CoordType>
842 typename ElementalFunction_,
951 if(
_func.use_derivative)
1024 if(it.starts_with(
"_halo"))
1027 for(
Index edge(0); edge < edge_ts.get_num_entities(); ++edge)
1037 return _func.use_derivative;
1053 const auto& idx =
_mesh_node->
get_mesh()->template get_index_set<ShapeType::dimension,0>();
1059 auto vc = this->_conc.elements_view_rw();
1060 const auto vd = this->_dist.elements_view_r();
1061 for(
Index cell(0); cell < ncells; ++cell)
1065 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1067 avg_dist += vd(idx(cell,j));
1072 vc[cell] =
_func.conc_val(avg_dist);
1086 if(
_func.use_derivative)
1114 template<
typename Tgrad_,
typename Tl_,
typename Tgradl_>
1121 for(
int i(0); i < Shape::FaceTraits<ShapeType,0>::count; ++i)
1123 val += dist_loc_(i);
1128 for(
int i(0); i < Shape::FaceTraits<ShapeType,0>::count; ++i)
1141 if(
_func.use_derivative)
1145 auto& idx =
_mesh_node->
get_mesh()->template get_index_set<ShapeType::dimension,0>();
1158 const auto vc = this->_conc.elements_view_r();
1159 const auto vgc = this->_grad_conc.elements_view_r();
1160 const auto vd =
_dist.elements_view_r();
1161 const auto vgd =
_grad_dist.elements_view_r();
1163 auto vgh =
_grad_h.elements_view_w();
1167 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1169 Index i(idx(cell, j));
1171 dist_loc(j) = vd(i);
1173 grad_dist_loc[j] = vgd(i);
1178 for(
int d(0); d < MeshType::world_dim; ++d)
1180 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1182 Index i(idx(cell, j));
1184 tmp(j*MeshType::world_dim +d) =
1186 *( vc(cell)*(vgsd(i)(d)*
_sum_conc + sum_det*vgc(i)(d) )
1213 auto& idx =
_mesh_node->
get_mesh()->template get_index_set<ShapeType::dimension,0>();
1216 FEAT::Tiny::Matrix <CoordType, Shape::FaceTraits<ShapeType,0>::count, MeshType::world_dim> x;
1218 FEAT::Tiny::Vector <CoordType,MeshType::world_dim> h;
1220 FEAT::Tiny::Matrix <CoordType, Shape::FaceTraits<ShapeType,0>::count, MeshType::world_dim> grad_loc;
1222 FEAT::Tiny::Vector <CoordType, Shape::FaceTraits<ShapeType,0>::count> grad_dist_loc;
1224 FEAT::Tiny::Matrix <CoordType, Shape::FaceTraits<ShapeType,0>::count, MeshType::world_dim> dist_loc;
1227 auto vc = this->_grad_conc.elements_view_rw();
1228 const auto vd =
_dist.elements_view_r();
1229 const auto vgd =
_grad_dist.elements_view_r();
1233 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1236 Index i(idx(cell, j));
1238 grad_dist_loc(j) = vd(i);
1240 dist_loc[j] = vgd(i);
1247 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1249 vc[idx(cell, j)] += grad_loc[j];
1274 XASSERT(constraint_at_vtx !=
nullptr);
1309 typename ElementalFunction_,
1311 typename RefCellTrafo_ = RumpfTrafo<Trafo_, typename Trafo_::CoordType>
1369 XASSERTM(chart_list_.size() >
size_t(0),
"Empty chart list.");
1371 for(
const auto& it:chart_list_)
1389 std::shared_ptr<BaseClass> result(
nullptr);
1390 result = std::make_shared<ChartDistanceFunction>(this->
_func, _chart_list,
_operation);
1417 auto vd = this->
_dist.elements_view_w();
1418 auto vgd = this->
_grad_dist.elements_view_w();
1427 if(chart ==
nullptr)
1428 XABORTM(
"Could not find chart "+it);
1430 my_dist +=
Math::abs(chart->signed_dist(vtx[i], tmp));
1438 if(my_norm > Math::eps<CoordType>())
1441 vgd[i] = my_dist_vec;
1455 auto vd = this->
_dist.elements_view_w();
1456 auto vgd = this->
_grad_dist.elements_view_w();
1459 CoordType my_dist(-Math::huge<CoordType>());
1465 if(chart ==
nullptr)
1466 XABORTM(
"Could not find chart "+it);
1468 CoordType this_dist = chart->signed_dist(vtx[i], tmp);
1469 if(this_dist > my_dist)
1471 my_dist = this_dist;
1478 vgd[i] = my_dist_vec;
1491 auto vd = this->
_dist.elements_view_w();
1492 auto vgd = this->
_grad_dist.elements_view_w();
1495 CoordType my_dist(Math::huge<CoordType>());
1501 if(chart ==
nullptr)
1502 XABORTM(
"Could not find chart "+it);
1504 CoordType this_dist = chart->signed_dist(vtx[i], tmp);
1507 my_dist = this_dist;
1514 vgd[i] = my_dist_vec;
1525 return "ChartDistanceFunction<"+ElementalFunction::name()+
">";
1531 const Index width(30);
1558 template<
typename Trafo_,
typename RefCellTrafo_>
1577 static std::shared_ptr<MeshConcentrationFunctionBase<Trafo_, RefCellTrafo_>>
1582 std::shared_ptr<MeshConcentrationFunctionBase<Trafo_, RefCellTrafo_>> result(
nullptr);
1586 XASSERTM(my_section !=
nullptr,
"Config is missing the referenced "+section_key+
" section.");
1588 auto type_p = my_section->query(
"type");
1589 XASSERTM(type_p.second,
"Section "+section_key+
" is missing the mandatory type key.");
1591 if(type_p.first==
"ChartDistance")
1593 auto chart_list_p = my_section->query(
"chart_list");
1594 XASSERTM(chart_list_p.second,
"Section "+section_key+
" is missing the mandatory chart_list key.");
1597 auto operation_p = my_section->query(
"operation");
1598 if(operation_p.second)
1599 operation = operation_p.first;
1603 auto function_type_p = my_section->query(
"function_type");
1604 if(function_type_p.second)
1607 if(function_type_p.first ==
"PowOfDist")
1611 bool use_derivative(
true);
1613 auto minval_p = my_section->query(
"minval");
1615 minval = std::stod(minval_p.first);
1617 auto exponent_p = my_section->query(
"exponent");
1618 if(exponent_p.second)
1619 exponent = std::stod(exponent_p.first);
1621 auto use_derivative_p = my_section->query(
"use_derivative");
1622 if(use_derivative_p.second)
1623 use_derivative = (std::stoi(use_derivative_p.first) == 1);
1626 ElementalFunction my_func(minval, exponent, use_derivative);
1628 auto real_result = std::make_shared<ChartDistanceFunction<ElementalFunction, Trafo_, RefCellTrafo_>>
1629 (my_func, chart_list, operation);
1631 result = real_result;
1637 ElementalFunction my_func;
1639 auto real_result = std::make_shared<ChartDistanceFunction<ElementalFunction, Trafo_, RefCellTrafo_>>
1640 (my_func, chart_list, operation);
1642 result = real_result;
1648 XASSERTM(result !=
nullptr,
"Unknown conc_function type!");
1661 template<
typename DT_>
1707 return "ConcentrationFunctionDefault";
1715 const Index pad_width(30);
1762 template<
typename DT_>
1823 return "ConcentrationFunctionPowOfDist";
1831 const Index pad_width(30);
#define XABORTM(msg)
Abortion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
MeshChartType * find_mesh_chart(const String &name)
Searches for a mesh chart.
MeshPartType * find_mesh_part(const String &part_name)
Searches this container for a MeshPart.
std::deque< String > get_mesh_part_names(bool no_internals=false) const
Returns the names of all mesh parts of this node.
MeshType * get_mesh()
Returns the mesh of this node.
Root mesh node class template.
const MeshAtlasType * get_atlas() const
void format()
Reset all elements of the container to a given value or zero if missing.
Blocked Dense data vector class template.
Dense data vector class template.
void component_invert(const DenseVector &x, const DT_ alpha=DT_(1))
Performs .
Class to compute a desired concentration for the mesh cell distribution base on distance to Charts.
virtual ~ChartDistanceFunction()
MeshConcentrationFunctionBase< Trafo_, RefCellTrafo_ > BaseClass
Our base class.
Tiny::Vector< CoordType, MeshType::world_dim > WorldPoint
Type for one mesh vertex.
MeshType::ShapeType ShapeType
ShapeType of said mesh.
ElementalFunction_ ElementalFunction
Type for the function mapping distance to concentration.
virtual String info() const override
Prints relevant information.
LAFEM::DenseVector< CoordType, IndexType > ScalarVectorType
Vector type for element sizes etc.
void compute_dist_max()
Computes the distance information.
ChartDistanceFunction(const ElementalFunction &func_, const std::deque< String > &chart_list_, const String &operation_)
Constructor setting the ElementalFunction_ and the list of charts.
MeshConcentrationFunction< ElementalFunction_, Trafo_, RefCellTrafo_ > DirectBaseClass
Our direct base class.
static String name()
Returns the class name as String.
Index IndexType
The index type.
Trafo_ TrafoType
Type for the transformation.
ChartDistanceFunction()=delete
Explicitly delete the empty default constructor.
void compute_dist_add()
Computes the distance information.
MeshType::CoordType CoordType
The precision of the mesh coordinates.
virtual std::shared_ptr< BaseClass > create_empty_clone() const override
Creates an empty clone of itself.
void compute_dist_min()
Computes the distance information.
TrafoType::MeshType MeshType
The mesh the transformation is defined on.
std::deque< String > _chart_list
List of charts to compute the distance to.
LAFEM::DenseVectorBlocked< CoordType, IndexType, MeshType::world_dim > VectorType
Vector type for element scales etc.
virtual void compute_dist() override
Computes the distance information.
const String _operation
How to mangle more than one distance (add, max, min)
Default elemental distance concentration function.
virtual ~ConcentrationFunctionDefault()
Empty destructor.
ConcentrationFunctionDefault(const ConcentrationFunctionDefault &other)
Copy constructor.
DT_ DataType
Floating point precision.
static String name()
Returns a descriptive String.
virtual String info() const
Prints relevant information.
DataType conc_val(DT_ dist) const
Computes the concentration according to a distance.
ConcentrationFunctionDefault()
Default constructor.
const bool use_derivative
Does this utilize the derivative of the input wrt. some other DoF?
DataType conc_der(DT_ dist) const
Computes the derivative of the concentration according to a distance.
Default elemental distance concentration function.
const bool use_derivative
Does this utilize the derivative of the input wrt. some other DoF?
virtual ~ConcentrationFunctionPowOfDist()
Empty destructor.
const DataType _exponent
beta
static String name()
Returns a descriptive String.
const DataType _minval
alpha
DT_ DataType
Floating point precision.
DataType conc_der(DataType dist) const
Computes the concentration according to a distance.
virtual String info() const
Prints relevant information.
ConcentrationFunctionPowOfDist(DataType minval_, DataType exponent_, bool use_derivative_=true)
Constructor setting alpha, beta and use_derivative.
DataType conc_val(DataType dist) const
Computes the concentration according to a distance.
Base class for mesh concentration functions.
virtual bool use_derivative() const =0
Returns whether this function make use of the derivative of h wrt. the vertex coordinates.
virtual void add_sync_vecs(std::set< VectorType * > &sync_vecs)=0
Adds pointers to vectors that need synchronising (type-0 to type-1 vectors)
Index IndexType
The index type.
virtual std::shared_ptr< MeshConcentrationFunctionBase > create_empty_clone() const =0
Creates an empty clone of itself.
virtual void compute_conc()=0
Computes the concentration for each cell according to the distance information.
virtual const VectorType & get_grad_dist() const =0
Returns a const reference to the gradient of the distance function.
MeshType::CoordType CoordType
The precision of the mesh coordinates.
virtual void add_constraint_grad(VectorType &grad, const CoordType constraint, const CoordType fac) const =0
Adds the scaled gradient of the constraint wrt. the vertex coordinates.
Trafo_ TrafoType
Type for the transformation.
LAFEM::DenseVectorBlocked< CoordType, IndexType, MeshType::world_dim > VectorType
Vector type for element scales etc.
virtual GradHType & get_grad_h()=0
Returns a reference to gradient of the optimal scales wrt. the vertex coordinates.
LAFEM::DenseVector< CoordType, IndexType > ScalarVectorType
Vector type for element sizes etc.
virtual CoordType & get_sum_conc()=0
Returns the sum of the mesh concentration over all cells.
Tiny::Vector< CoordType, MeshType::world_dim > WorldPoint
Type of a mesh vertex.
LAFEM::DenseVectorBlocked< CoordType, IndexType, MeshType::world_dim *Shape::FaceTraits< ShapeType, 0 >::count > GradHType
Vector type for the gradient of h wrt. the DoF.
virtual ~MeshConcentrationFunctionBase()
Virtual destructor.
virtual void compute_grad_h(const CoordType &sum_det)=0
Computes the local gradient of the optimal scales.
virtual const GradHType & get_grad_h() const =0
Returns a const reference to gradient of the optimal scales wrt. the vertex coordinates.
virtual const ScalarVectorType & get_conc() const =0
Returns a const reference to the concentration.
virtual void compute_grad_sum_det(const VectorType &coords)=0
Computes the gradient of the sum of all determinants of the trafo.
virtual void compute_grad_conc()=0
Computes the gradient of the mesh concentration for each cell according to the distance information.
virtual CoordType compute_constraint() const =0
Computes the surface alignment constraint.
virtual void compute_dist()=0
Computes the distance information.
virtual String info() const =0
Prints relevant information.
MeshType::ShapeType ShapeType
ShapeType of said mesh.
TrafoType::MeshType MeshType
The mesh the transformation is defined on.
virtual CoordType compute_constraint(CoordType *constraint_at_vtx) const =0
Computes the surface alignment constraint at every vertex.
virtual const ScalarVectorType & get_dist() const =0
Returns a const reference to the distance information.
virtual void set_mesh_node(const Geometry::RootMeshNode< MeshType > *mesh_node_)=0
Sets this object's mesh node.
Class to compute a desired concentration for the mesh cell distribution.
ElementalFunction _func
The scalar function mapping distance to concentration.
VectorType _grad_dist
For all vertices, this holds the gradient of the distance function.
MeshType::CoordType CoordType
The precision of the mesh coordinates.
MeshConcentrationFunction(const ElementalFunction &func_)
Constructor setting the elemantal function.
virtual void add_sync_vecs(std::set< VectorType * > &sync_vecs) override
Adds pointers to vectors that need synchronising (type-0 to type-1 vectors)
virtual const ScalarVectorType & get_conc() const override
Returns a const reference to the concentration.
VectorType _grad_sum_det
Gradient of _sum_det wrt. the mesh vertices.
virtual const ScalarVectorType & get_dist() const override
Returns a const reference to the distance information.
virtual ~MeshConcentrationFunction()
**
virtual void compute_grad_conc() override
Computes the gradient of the sum of all mesh concentrations.
MeshType::ShapeType ShapeType
ShapeType of said mesh.
virtual void compute_grad_h(const CoordType &sum_det) override
Computes the local gradient of the optimal scales.
ElementalFunction_ ElementalFunction
The scalar function that computes the concentration from something.
LAFEM::DenseVectorBlocked< CoordType, Index, MeshType::world_dim *Shape::FaceTraits< ShapeType, 0 >::count > GradHType
Vector type for the gradient of h wrt. the DoF.
virtual void add_constraint_grad(VectorType &grad, const CoordType constraint, const CoordType fac) const override
Adds the scaled gradient of the constraint wrt. the vertex coordinates.
ScalarVectorType _conc
Vector for saving the mesh concentration, one entry per cell.
const Geometry::RootMeshNode< MeshType > * _mesh_node
The mesh node this function works with.
Trafo_ TrafoType
Type for the transformation.
LAFEM::DenseVector< CoordType, IndexType > ScalarVectorType
Vector type for element sizes etc.
virtual void compute_conc() override
Computes the mesh concentration function for each cell.
TrafoType::MeshType MeshType
The mesh the transformation is defined on.
VectorType _grad_conc
Gradient of the mesh concentration wrt. the world coordinates.
virtual void set_mesh_node(const Geometry::RootMeshNode< MeshType > *mesh_node_) override
Sets this object's mesh node.
virtual bool use_derivative() const override
Returns whether this function make use of the derivative of h wrt. the vertex coordinates.
GradHType _grad_h
Gradient of the local optimal scales h wrt. the vertex coordinates.
virtual const GradHType & get_grad_h() const override
Returns a reference to gradient of the optimal scales wrt. the vertex coordinates.
ScalarVectorType _dist
For all vertices, this holds their scalar "distance" to whatever.
Index IndexType
The index type.
void compute_grad_conc_local(Tgrad_ &grad_loc_, const Tl_ &dist_loc_, const Tgradl_ &grad_dist_loc_)
Computes the local gradient of the concentration function wrt. the vertices.
virtual CoordType & get_sum_conc() override
Returns the sum of the mesh concentration over all cells.
MeshConcentrationFunctionBase< Trafo_, RefCellTrafo_ > BaseClass
Our base class.
Tiny::Vector< CoordType, MeshType::world_dim > WorldPoint
Type for one mesh vertex.
LAFEM::DenseVectorBlocked< CoordType, IndexType, MeshType::world_dim > VectorType
Vector type for element scales etc.
virtual CoordType compute_constraint(CoordType *constraint_at_vtx) const override
Computes the surface alignment constraint at every vertex.
virtual const VectorType & get_grad_dist() const override
Returns a const reference to the gradient of the distance function.
AlignmentPenalty< CoordType, ShapeType > PenaltyFunction
Surface alignment penalty function.
virtual CoordType compute_constraint() const override
Computes the surface alignment constraint.
virtual GradHType & get_grad_h() override
Returns a reference to gradient of the optimal scales wrt. the vertex coordinates.
virtual String info() const override
copydoc BaseClass::info()
virtual void compute_grad_sum_det(const VectorType &coords) override
Computes the gradient of the sum of all determinants of the trafo.
CoordType _sum_conc
The sum of all entries in _conc.
ScalarVectorType _edge_freqs
For each edge, this contains 1/(# halos it is present in)
A class organizing a tree of key-value pairs.
PropertyMap * query_section(String sec_path)
Queries a section by its section path.
String class implementation.
std::deque< String > split_by_whitespaces() const
Splits the string by white-spaces.
String pad_back(size_type len, char c=' ') const
Pads the back of the string up to a desired length.
Tiny Matrix class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the matrix.
Tiny Vector class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the vector.
CUDA_HOST_DEVICE DataType norm_euclid() const
Computes the euclid norm of this vector.
T_ abs(T_ x)
Returns the absolute value.
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
T_ sqr(T_ x)
Returns the square of a value.
T_ signum(T_ x)
Returns the sign of a value.
String stringify(const T_ &item)
Converts an item into a String.
String stringify_fp_sci(DataType_ value, int precision=0, int width=0, bool sign=false)
Prints a floating point value to a string in scientific notation.
@ grad
specifies whether the space should supply basis function gradients
std::uint64_t Index
Index data type.
Wrapper class for functionality around aligning meshes to (implicit) surfaces.
static void add_constraint_grad(Vector_ &grad, const DataType alignment_fval, const DataType fac, const Mesh_ &mesh, const Dist_ &dist, const GradDist_ &grad_dist, const EdgeFreqs_ &edge_freqs)
Adds the gradient of the constraint violation term.
DT_ DataType
The floating point type.
static DataType compute_constraint(const Mesh_ &mesh, const Dist_ &dist, const EdgeFreqs_ &edge_freqs)
Computes the constraint (violation) for a given mesh.
Shape::Simplex< shape_dim > ShapeType
The mesh's shape type.
static DataType compute_constraint(DataType *constraint_vec, const Mesh_ &mesh, const Dist_ &dist)
Computes the constraint (violation) on every cell of a given mesh.
Factory for MeshConcentrationFunctions.
MeshType::CoordType CoordType
Floating point precision of the mesh vertex coordinates.
static std::shared_ptr< MeshConcentrationFunctionBase< Trafo_, RefCellTrafo_ > > create(const String §ion_key, PropertyMap *config)
Creates a MeshConcentrationFunction according to a PropertyMap.
Trafo_::MeshType MeshType
The Meshtype.
Computes quantities associated with the transformation to Rumpf reference cells.
Face traits tag struct template.
Simplex shape tag struct template.
static constexpr int dimension
Simplex dimension.