FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
rumpf_functional.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
9#include <kernel/util/dist.hpp>
10#include <kernel/util/math.hpp>
11#include <kernel/util/tiny_algebra.hpp>
12#include <iostream>
13
14namespace FEAT
15{
16 namespace Meshopt
17 {
27 template<typename DataType_>
29 {
30 public:
32 typedef DataType_ DataType;
33 public:
44
66 const DataType_ fac_frobenius_,
67 const DataType_ fac_det_,
68 const DataType_ fac_rec_det_,
69 const DataType_ fac_cof_,
70 const DataType_ fac_reg_) :
71 _fac_frobenius(fac_frobenius_),
72 _fac_det(fac_det_),
73 _fac_rec_det(fac_rec_det_),
74 _fac_cof(fac_cof_),
75 _fac_reg(fac_reg_)
76 {
77 XASSERTM(_fac_frobenius >= DataType_(0), "_fac_frobenius must be >= 0!\n");
78 XASSERTM(_fac_det >= DataType_(0), "_fac_det must be >= 0!\n");
79 XASSERTM(_fac_rec_det >= DataType_(0), "_fac_rec_det must be >= 0!\n");
80 XASSERTM(_fac_cof >= DataType_(0), "_fac_cof must be >= 0!\n");
81 XASSERTM(_fac_reg >= DataType_(0), "_fac_reg must be >= 0!\n");
82 }
83
86 {
87 }
88
94 static String name()
95 {
96 return "RumpfFunctionalBase";
97 }
98
100 String info() const
101 {
102 const Index pad_width(30);
103 String msg;
104 msg += String("fac_frobenius").pad_back(pad_width, '.') + String(": ") + stringify_fp_sci(_fac_frobenius) + "\n";
105 msg += String("fac_cof").pad_back(pad_width, '.') + String(": ") + stringify_fp_sci(_fac_cof) + "\n";
106 msg += String("fac_det").pad_back(pad_width, '.') + String(": ") + stringify_fp_sci(_fac_det) + "\n";
107 msg += String("fac_rec_det").pad_back(pad_width, '.') + String(": ") + stringify_fp_sci(_fac_rec_det) + "\n";
108 msg += String("fac_reg").pad_back(pad_width, '.') + String(": ") + stringify_fp_sci(_fac_reg) + "\n";
109 return msg;
110 }
111
112 };
113
178#ifndef DOXYGEN
179 template<typename DataType_, typename TrafoType_>
180 class RumpfFunctional;
181 // Note:
182 // The following block serves as an element interface documentation and is therefore only
183 // visible to doxygen. The actual functionality has to be supplied by the implementation.
184#else
185 template<typename DataType_, typename TrafoType_>
187 {
188 public:
191
193 typedef DataType_ DataType;
195 static constexpr int shape_dim = shape_dim_;
197 static constexpr int world_dim = shape_dim;
203 typedef typename Intern::TrafoFE<TrafoType>::Space TrafoSpace;
204
209
212
214 typedef typename TrafoType::template Evaluator<ShapeType, DataType>::Type TrafoEvaluator;
216 typedef typename TrafoSpace::template Evaluator<TrafoEvaluator>::Type SpaceEvaluator;
217
222
224 typedef typename TrafoEvaluator::template ConfigTraits<trafo_config>::EvalDataType TrafoEvalData;
226 typedef typename SpaceEvaluator::template ConfigTraits<space_config>::EvalDataType SpaceEvalData;
227
259 const DataType_ fac_frobenius_,
260 const DataType_ fac_det_,
261 const DataType_ fac_cof_,
262 const DataType_ fac_reg_,
263 const int exponent_det_);
264
294 void eval_fval_grad( DataType& DOXY(fval), Tx& DOXY(grad), const TgradR& DOXY(mat_tensor),
295 const TrafoEvaluator& DOXY(trafo_eval), const SpaceEvaluator& DOXY(space_eval),
296 const Tx& DOXY(x), const DataType& DOXY(h));
297
332 void eval_fval_cellwise( DataType& DOXY(fval), const TgradR& DOXY(mat_tensor),
333 const TrafoEvaluator& DOXY(trafo_eval), const SpaceEvaluator& DOXY(space_eval),
334 const Tx& DOXY(x), const DataType& DOXY(h),
335 DataType& DOXY(fval_frobenius), DataType& DOXY(fval_cof), DataType& DOXY(fval_det));
336
387 void add_grad_h_part(Tx& grad, const TgradR& mat_tensor,
388 const TrafoEvaluator& trafo_eval, const SpaceEvaluator& space_eval,
389 const Tx& DOXY(x), const DataType& h, const Tgradh& grad_h);
390
391 };
392#endif
393
395 // These functionals are kept only for debugging purposes
396 template<typename DataType_, typename TrafoType_>
397 class RumpfFunctionalUnrolled;
399 } // namespace Meshopt
400
401} // namespace FEAT
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT Kernel base header.
Base class template for Rumpf functionals.
String info() const
Print basic information.
DataType _fac_det
Factor for the det part in the mesh quality functional.
DataType _fac_cof
Factor for the cof part in the mesh quality functional.
RumpfFunctionalBase(const DataType_ fac_frobenius_, const DataType_ fac_det_, const DataType_ fac_rec_det_, const DataType_ fac_cof_, const DataType_ fac_reg_)
Constructor.
DataType _fac_frobenius
Factor for the Frobenius norm part in the mesh quality functional.
static String name()
The class name.
DataType _fac_rec_det
Factor for the 1/det part in the mesh quality functional.
DataType _fac_reg
Regularization parameter for the 1/det part in the mesh quality functional.
virtual ~RumpfFunctionalBase()
Virtual destructor.
Functionals for measuring and optimising mesh quality.
SpaceEvaluator::template ConfigTraits< space_config >::EvalDataType SpaceEvalData
Data from evaluating FE spaces.
void eval_fval_cellwise(DataType &fval, const TgradR &mat_tensor, const TrafoEvaluator &trafo_eval, const SpaceEvaluator &space_eval, const Tx &x, const DataType &h, DataType &fval_frobenius, DataType &fval_cof, DataType &fval_det)
Computes the different contributions to the functional's value on one cell.
TrafoType::template Evaluator< ShapeType, DataType >::Type TrafoEvaluator
Type for evaluating the transformation.
Tiny::Matrix< DataType_, shape_dim, world_dim > TgradR
Type for the gradient of the local reference mapping.
void eval_fval_grad(DataType &fval, Tx &grad, const TgradR &mat_tensor, const TrafoEvaluator &trafo_eval, const SpaceEvaluator &space_eval, const Tx &x, const DataType &h)
Computes the functional's value and gradient on one cell.
DataType_ DataType
Our data type.
static constexpr int world_dim
Our world dimension - only world_dim == shape_dim is supported.
RumpfFunctional(const DataType_ fac_frobenius_, const DataType_ fac_det_, const DataType_ fac_cof_, const DataType_ fac_reg_, const int exponent_det_)
Constructor.
Tiny::Matrix< DataType_, Shape::FaceTraits< ShapeType, 0 >::count, world_dim > Tx
Type for a pack of local vertex coordinates.
static constexpr int shape_dim
Our shape dimension.
static constexpr SpaceTags space_config
For the FE space, we only need the gradients on the reference cell.
Trafo::Standard::Mapping< Geometry::ConformalMesh< ShapeType, world_dim, DataType_ > > TrafoType
The transformation this functional works on.
Tiny::Vector< DataType_, Shape::FaceTraits< ShapeType, 0 >::count *world_dim > Tgradh
Type for the gradient of the local cell sizes.
Shape::Hypercube< shape_dim_ > ShapeType
Shape type of the underlying transformation.
TrafoSpace::template Evaluator< TrafoEvaluator >::Type SpaceEvaluator
Type for evaluating the FE functions.
void add_grad_h_part(Tx &grad, const TgradR &mat_tensor, const TrafoEvaluator &trafo_eval, const SpaceEvaluator &space_eval, const Tx &x, const DataType &h, const Tgradh &grad_h)
Adds the gradient h part to the local gradient.
RumpfFunctionalBase< DataType_ > BaseClass
Our baseclass.
static constexpr TrafoTags trafo_config
We need the Trafo to evaluate the image point, the Jacobian and its determinant.
TrafoEvaluator::template ConfigTraits< trafo_config >::EvalDataType TrafoEvalData
Data from evaluating the transformation.
Intern::TrafoFE< TrafoType >::Space TrafoSpace
The FE space associated with the transformation.
String class implementation.
Definition: string.hpp:46
String pad_back(size_type len, char c=' ') const
Pads the back of the string up to a desired length.
Definition: string.hpp:415
Tiny Matrix class template.
Tiny Vector class template.
Standard transformation mapping class template.
Definition: mapping.hpp:39
FEAT namespace.
Definition: adjactor.hpp:12
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.
Definition: string.hpp:1088
SpaceTags
Space configuration tags enum.
Definition: eval_tags.hpp:97
@ ref_grad
specifies whether the space should supply reference basis function gradients
@ grad
specifies whether the space should supply basis function gradients
std::uint64_t Index
Index data type.
TrafoTags
Trafo configuration tags enum.
Definition: eval_tags.hpp:22
@ img_point
specifies whether the trafo should supply image point coordinates
@ jac_mat
specifies whether the trafo should supply jacobian matrices
@ jac_det
specifies whether the trafo should supply jacobian determinants
Hypercube shape tag struct template.
Definition: shape.hpp:64