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 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
188 constraint += edge_freqs(edge)*FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
189 eval( - dist(edge_idx(edge,0)) * dist(edge_idx(edge,1)));
195 template<
typename Mesh_,
typename Dist_>
198 XASSERT(constraint_vec !=
nullptr);
199 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 1, 0> FimType;
202 const auto& idx = mesh.template get_index_set<ShapeType::dimension,0>();
206 for(
int edge(0); edge < Shape::FaceTraits<ShapeType,1>::count; ++edge)
209 int i(FimType::map(edge,0));
210 int j(FimType::map(edge,1));
211 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
212 eval(-
DataType(1)*dist(idx(cell, i)) * dist(idx(cell, j))) );
214 constraint_vec[cell] += my_constraint;
216 constraint += my_constraint;
224 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
226 Vector_&
grad,
const DataType alignment_fval,
const DataType fac,
const Mesh_& mesh,
const Dist_& dist,
const GradDist_& grad_dist,
const EdgeFreqs_& edge_freqs)
228 const auto& edge_idx = mesh.template get_index_set<1,0>();
230 typedef Tiny::Vector<DataType, Mesh_::world_dim> WorldPoint;
234 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
236 Index i(edge_idx(edge,0));
237 Index j(edge_idx(edge,1));
239 auto dist_prod = dist(i) * dist(j);
241 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
243 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
244 grad(i,
grad(i) + edge_freqs(edge)*grad_loc);
246 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
247 grad(j,
grad(j) + edge_freqs(edge)*grad_loc);
253 template<
typename DT_>
254 struct AlignmentPenalty<DT_, Shape::Hypercube<2>>
260 template<
typename Mesh_,
typename Dist_,
typename EdgeFreqs_>
264 const auto& edge_idx = mesh.template get_index_set<1,0>();
265 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
267 constraint += edge_freqs(edge)*FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
268 eval( - dist(edge_idx(edge,0)) * dist(edge_idx(edge,1)));
271 const auto& cell_idx = mesh.template get_index_set<ShapeType::dimension,0>();
274 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
275 eval( - dist(cell_idx(cell,0)) * dist(cell_idx(cell,3)));
276 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
277 eval( - dist(cell_idx(cell,1)) * dist(cell_idx(cell,2)));
283 template<
typename Mesh_,
typename Dist_>
286 XASSERT(constraint_vec !=
nullptr);
287 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 1, 0> FimType;
290 const auto& idx = mesh.template get_index_set<ShapeType::dimension,0>();
294 for(
int edge(0); edge < Shape::FaceTraits<ShapeType,1>::count; ++edge)
297 int i(FimType::map(edge,0));
298 int j(FimType::map(edge,1));
299 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
300 eval(-
DataType(1)*dist(idx(cell, i)) * dist(idx(cell, j))) );
302 constraint_vec[cell] += my_constraint;
304 constraint += my_constraint;
307 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
308 eval( - dist(idx(cell,0)) * dist(idx(cell,3))));
309 my_constraint = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
310 eval( - dist(idx(cell,1)) * dist(idx(cell,2)));
312 constraint_vec[cell] += my_constraint;
314 constraint += my_constraint;
321 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
323 Vector_&
grad,
const DataType alignment_fval,
const DataType fac,
const Mesh_& mesh,
const Dist_& dist,
324 const GradDist_& grad_dist,
const EdgeFreqs_& edge_freqs)
326 const auto& edge_idx = mesh.template get_index_set<1,0>();
328 typedef Tiny::Vector<DataType, Mesh_::world_dim> WorldPoint;
332 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
334 Index i(edge_idx(edge,0));
335 Index j(edge_idx(edge,1));
337 auto dist_prod = dist(i) * dist(j);
339 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
341 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
342 grad(i,
grad(i) + edge_freqs(edge)*grad_loc);
344 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
345 grad(j,
grad(j) + edge_freqs(edge)*grad_loc);
348 const auto& cell_idx = mesh.template get_index_set<ShapeType::dimension,0>();
354 auto dist_prod = dist(i) * dist(j);
356 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
358 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
361 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
364 i = cell_idx(cell,
Index(1));
365 j = cell_idx(cell,
Index(2));
367 dist_prod = dist(i) * dist(j);
369 heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
371 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
374 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
380 template<
typename DT_>
381 struct AlignmentPenalty<DT_, Shape::Hypercube<3>>
387 template<
typename Mesh_,
typename Dist_,
typename EdgeFreqs_>
391 const auto& edge_idx = mesh.template get_index_set<1,0>();
392 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
394 constraint += edge_freqs(edge)*FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
395 eval( - dist(edge_idx(edge,0)) * dist(edge_idx(edge,1)));
398 const auto& face_idx = mesh.template get_index_set<2,0>();
399 for(
Index face(0); face < mesh.get_num_entities(2); ++face)
401 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
402 eval( - dist(face_idx(face,0)) * dist(face_idx(face,3)));
403 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
404 eval( - dist(face_idx(face,1)) * dist(face_idx(face,2)));
407 const auto& cell_idx = mesh.template get_index_set<3,0>();
408 for(
Index cell(0); cell < mesh.get_num_entities(3); ++cell)
410 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
411 eval( - dist(cell_idx(cell,0)) * dist(cell_idx(cell,7)));
412 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
413 eval( - dist(cell_idx(cell,1)) * dist(cell_idx(cell,6)));
414 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
415 eval( - dist(cell_idx(cell,2)) * dist(cell_idx(cell,5)));
416 constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
417 eval( - dist(cell_idx(cell,3)) * dist(cell_idx(cell,4)));
423 template<
typename Mesh_,
typename Dist_>
426 XASSERT(constraint_vec !=
nullptr);
427 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 1, 0> VertAtEdge;
428 typedef Geometry::Intern::FaceIndexMapping<ShapeType, 2, 0> VertAtFace;
431 const auto& idx = mesh.template get_index_set<ShapeType::dimension,0>();
436 for(
int edge(0); edge < Shape::FaceTraits<ShapeType,1>::count; ++edge)
439 int i(VertAtEdge::map(edge,0));
440 int j(VertAtEdge::map(edge,1));
441 DataType my_constraint(FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
444 constraint_vec[cell] += my_constraint;
446 constraint += my_constraint;
449 for(
int face(0); face < Shape::FaceTraits<ShapeType,2>::count; ++face)
452 int i0(VertAtFace::map(face,0));
453 int i1(VertAtFace::map(face,1));
454 int i2(VertAtFace::map(face,2));
455 int i3(VertAtFace::map(face,3));
458 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
460 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
463 constraint_vec[cell] += my_constraint;
465 constraint += my_constraint;
469 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
470 eval( - dist(idx(cell,0)) * dist(idx(cell,7)));
471 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
472 eval( - dist(idx(cell,1)) * dist(idx(cell,6)));
473 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
474 eval( - dist(idx(cell,2)) * dist(idx(cell,5)));
475 my_constraint += FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::
476 eval( - dist(idx(cell,3)) * dist(idx(cell,4)));
478 constraint_vec[cell] += my_constraint;
480 constraint += my_constraint;
487 template<
typename Vector_,
typename Mesh_,
typename Dist_,
typename GradDist_,
typename EdgeFreqs_>
489 Vector_&
grad,
const DataType alignment_fval,
const DataType fac,
const Mesh_& mesh,
const Dist_& dist,
490 const GradDist_& grad_dist,
const EdgeFreqs_& edge_freqs)
492 const auto& edge_idx = mesh.template get_index_set<1,0>();
494 typedef Tiny::Vector<DataType, Mesh_::world_dim> WorldPoint;
498 for(
Index edge(0); edge < mesh.get_num_entities(1); ++edge)
500 Index i(edge_idx(edge,0));
501 Index j(edge_idx(edge,1));
503 auto dist_prod = dist(i) * dist(j);
505 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
507 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
508 grad(i,
grad(i) + edge_freqs(edge)*grad_loc);
510 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
511 grad(j,
grad(j) + edge_freqs(edge)*grad_loc);
514 const auto& face_idx = mesh.template get_index_set<2,0>();
515 for(
Index face(0); face < mesh.get_num_entities(2); ++face)
520 auto dist_prod = dist(i) * dist(j);
522 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
524 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
527 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
530 i = face_idx(face,
Index(1));
531 j = face_idx(face,
Index(2));
533 dist_prod = dist(i) * dist(j);
535 heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
537 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j)) * grad_dist(i);
540 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i)) * grad_dist(j);
544 const auto& cell_idx = mesh.template get_index_set<3,0>();
545 for(
Index cell(0); cell < mesh.get_num_entities(2); ++cell)
550 for(
int k(0); k < 4; ++k)
553 auto dist_prod = dist(i[k]) * dist(j[k]);
555 auto heaviside_der = FEAT::Analytic::Common::template HeavisideRegStatic<DataType>::der_x(-dist_prod);
557 grad_loc = (-fac * alignment_fval * heaviside_der * dist(j[k])) * grad_dist(i[k]);
560 grad_loc = (-fac * alignment_fval * heaviside_der * dist(i[k])) * grad_dist(j[k]);
593 typename RefCellTrafo_ = RumpfTrafo<Trafo_, typename Trafo_::CoordType>
822 typename ElementalFunction_,
931 if(
_func.use_derivative)
1003 if(it.starts_with(
"_halo"))
1006 for(
Index edge(0); edge < edge_ts.get_num_entities(); ++edge)
1016 return _func.use_derivative;
1032 const auto& idx =
_mesh_node->
get_mesh()->template get_index_set<ShapeType::dimension,0>();
1038 for(
Index cell(0); cell < ncells; ++cell)
1042 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1044 avg_dist += this->
_dist(idx(cell,j));
1063 if(
_func.use_derivative)
1091 template<
typename Tgrad_,
typename Tl_,
typename Tgradl_>
1098 for(
int i(0); i < Shape::FaceTraits<ShapeType,0>::count; ++i)
1100 val += dist_loc_(i);
1105 for(
int i(0); i < Shape::FaceTraits<ShapeType,0>::count; ++i)
1118 if(
_func.use_derivative)
1122 auto& idx =
_mesh_node->
get_mesh()->template get_index_set<ShapeType::dimension,0>();
1138 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1140 Index i(idx(cell, j));
1142 dist_loc(j) =
_dist(i);
1149 for(
int d(0); d < MeshType::world_dim; ++d)
1151 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1153 Index i(idx(cell, j));
1155 tmp(j*MeshType::world_dim +d) =
1184 auto& idx =
_mesh_node->
get_mesh()->template get_index_set<ShapeType::dimension,0>();
1187 FEAT::Tiny::Matrix <CoordType, Shape::FaceTraits<ShapeType,0>::count, MeshType::world_dim> x;
1189 FEAT::Tiny::Vector <CoordType,MeshType::world_dim> h;
1191 FEAT::Tiny::Matrix <CoordType, Shape::FaceTraits<ShapeType,0>::count, MeshType::world_dim> grad_loc;
1193 FEAT::Tiny::Vector <CoordType, Shape::FaceTraits<ShapeType,0>::count> grad_dist_loc;
1195 FEAT::Tiny::Matrix <CoordType, Shape::FaceTraits<ShapeType,0>::count, MeshType::world_dim> dist_loc;
1201 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1204 Index i(idx(cell, j));
1206 grad_dist_loc(j) =
_dist(i);
1215 for(
int j(0); j < Shape::FaceTraits<ShapeType,0>::count; ++j)
1217 Index i(idx(cell, j));
1243 XASSERT(constraint_at_vtx !=
nullptr);
1278 typename ElementalFunction_,
1280 typename RefCellTrafo_ = RumpfTrafo<Trafo_, typename Trafo_::CoordType>
1338 XASSERTM(chart_list_.size() >
size_t(0),
"Empty chart list.");
1340 for(
const auto& it:chart_list_)
1358 std::shared_ptr<BaseClass> result(
nullptr);
1359 result = std::make_shared<ChartDistanceFunction>(this->
_func, _chart_list,
_operation);
1394 if(chart ==
nullptr)
1395 XABORTM(
"Could not find chart "+it);
1397 my_dist +=
Math::abs(chart->signed_dist(vtx[i], tmp));
1401 this->
_dist(i, my_dist);
1405 if(my_norm > Math::eps<CoordType>())
1424 CoordType my_dist(-Math::huge<CoordType>());
1430 if(chart ==
nullptr)
1431 XABORTM(
"Could not find chart "+it);
1433 CoordType this_dist = chart->signed_dist(vtx[i], tmp);
1434 if(this_dist > my_dist)
1436 my_dist = this_dist;
1442 this->
_dist(i, my_dist);
1458 CoordType my_dist(Math::huge<CoordType>());
1464 if(chart ==
nullptr)
1465 XABORTM(
"Could not find chart "+it);
1467 CoordType this_dist = chart->signed_dist(vtx[i], tmp);
1470 my_dist = this_dist;
1476 this->
_dist(i, my_dist);
1488 return "ChartDistanceFunction<"+ElementalFunction::name()+
">";
1494 const Index width(30);
1521 template<
typename Trafo_,
typename RefCellTrafo_>
1540 static std::shared_ptr<MeshConcentrationFunctionBase<Trafo_, RefCellTrafo_>>
1545 std::shared_ptr<MeshConcentrationFunctionBase<Trafo_, RefCellTrafo_>> result(
nullptr);
1549 XASSERTM(my_section !=
nullptr,
"Config is missing the referenced "+section_key+
" section.");
1551 auto type_p = my_section->query(
"type");
1552 XASSERTM(type_p.second,
"Section "+section_key+
" is missing the mandatory type key.");
1554 if(type_p.first==
"ChartDistance")
1556 auto chart_list_p = my_section->query(
"chart_list");
1557 XASSERTM(chart_list_p.second,
"Section "+section_key+
" is missing the mandatory chart_list key.");
1560 auto operation_p = my_section->query(
"operation");
1561 if(operation_p.second)
1562 operation = operation_p.first;
1566 auto function_type_p = my_section->query(
"function_type");
1567 if(function_type_p.second)
1570 if(function_type_p.first ==
"PowOfDist")
1574 bool use_derivative(
true);
1576 auto minval_p = my_section->query(
"minval");
1578 minval = std::stod(minval_p.first);
1580 auto exponent_p = my_section->query(
"exponent");
1581 if(exponent_p.second)
1582 exponent = std::stod(exponent_p.first);
1584 auto use_derivative_p = my_section->query(
"use_derivative");
1585 if(use_derivative_p.second)
1586 use_derivative = (std::stoi(use_derivative_p.first) == 1);
1589 ElementalFunction my_func(minval, exponent, use_derivative);
1591 auto real_result = std::make_shared<ChartDistanceFunction<ElementalFunction, Trafo_, RefCellTrafo_>>
1592 (my_func, chart_list, operation);
1594 result = real_result;
1600 ElementalFunction my_func;
1602 auto real_result = std::make_shared<ChartDistanceFunction<ElementalFunction, Trafo_, RefCellTrafo_>>
1603 (my_func, chart_list, operation);
1605 result = real_result;
1611 XASSERTM(result !=
nullptr,
"Unknown conc_function type!");
1624 template<
typename DT_>
1670 return "ConcentrationFunctionDefault";
1678 const Index pad_width(30);
1725 template<
typename DT_>
1786 return "ConcentrationFunctionPowOfDist";
1794 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(DT_ value=DT_(0))
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.