|
FEAT 3
Finite Element Analysis Toolbox
|
The Meshopt namespace contains all tools for mesh optimization (sometimes also called mesh smoothing ). These two terms are used synonymously. The baseclass is FEAT::Meshopt::MeshQualityFunctional and shall be used for illustrational purposes in this section.
A MeshQualityFunctional measures the quality of a mesh in some sense and can be used in conjuction with a (non-)linear solver to optimize the mesh by minimising the functional value. It always refers to exactly one mesh (through a FEAT::Geometry::RootMeshNode), contains a pointer to it and can modify exactly this mesh and nothing more. The main use cases are:
The mesh is moving, where only the boundary movement is known (i.e. decoupled fluid-structure interactions, Navier Stokes with free capillary boundary etc.).
Then this movement has to be continued to the interiour of the computational domain. In finite element and math terminology: If the boundary movement is a function with "enough regularity", then it is the trace of a function on the whole domain and we can find one possible preimage by constructing an inverse trace operator.
The most simple example for this to solve
\[ - \Delta u = 0 ~ \mathrm{in} ~ \Omega, u = u_D ~\mathrm{on}~ \partial \Omega \]
with finite element tools on the FE space the transformation is from, where \( u_D \) are the new boundary coordinates. The solution then contains the new vertex coordinates in the interiour.
This is also called Laplacian smoothing and is nothing more than minimising the harmonic energy of the transformation which satisfies the appropriate boundary conditions. This is implemented in FEAT::Meshopt::LaplaceFunctional. The boundary coordinates \( u_D \) are then the trace of the FE function \( u \) on \( \partial \Omega \) and the solving of the above problem was the application of one possible inverse trace operator. The solution is also the minimizer of the harmonic energy on the space with the appropriate boundary values.
A given mesh is to be improved according to some quality measure.
This quality measure needs to be a functional defined in terms geometric quantities. There are some regularity assumptions that need to hold, i.e. we need to be able to compute the first order derivatives with regard to the mesh vertices.
One example is r-adaptivity, where mesh vertices are moved so that the mesh's cells are smaller in a region of interest (also called mesh condensation). This is implemented in the FEAT::Meshopt::HyperelasticityFunctional class, which makes use of the FEAT::Meshopt::MeshConcentrationFunction class for describing the desired cell size distribution over the domain. At the moment, this can be done by adding charts derived FEAT::Geometry::Atlas::ChartBase to the FEAT::Geometry::Atlas that is contained in the FEAT::Geometry::RootMeshNode in the quality functional, and using those to describe surfaces or boundaries. The distance to those boundaries can then be used in the FEAT::Meshopt::MeshConcentrationFunction to govern the desired cell size distribution.
For a given mesh and an implicitly defined surface, mesh vertices/edges/faces are to be aligned to the surface
This is usually used in conjunction with a quality measure that makes sure the alignment does not lead to a deterioration of the mesh. This functionality is implemented i.e. in the class FEAT::Meshopt::HyperelasticityFunctional. How well this works depends on the shape type (FEAT::Shape) of the mesh. Due to topological reasons, alignment to facets is possible for FEAT::Shape::Simplex, but not for FEAT::Shape::Hypercube, although alignment to mesh vertices is possible in that case.
These use cases are in no way disjoint: There are cases of moving meshes with an implicitly defined surface, to which the mesh needs to be aligned and also condensated near the surface, all while ensuring that the mesh does not deteriorate.
It is recommended to use all classes derived from MeshQualityFunctional through their respective control classes from the FEAT::Control::Meshopt namespace, namely FEAT::Control::Meshopt::DuDvFunctionalControl and FEAT::Control::Meshopt::HyperelasticityFunctionalControl. The easiest way to configure and use them is through configuration files which can be read at startup time to create FEAT::PropertyMap s, which can be used in the FEAT::Control::Meshopt::ControlFactory to create these objects at runtime. Their basic interface is made available through a FEAT::Control::Meshopt::MeshoptControlBase base class pointer and should be sufficient to access and use the underlying object. Examples of this can be found in the applications folder (i.e. meshopt_r_adapt-app, meshopt_boundary-app, meshopt_refinement-app), while the (more primitive) meshopt_hyperelasticity_resize-app uses the FEAT::Meshopt::HyperelasticityFunctional directly. The solver used by these objects are created using the FEAT::Control::MeshoptSolverFactory and the FEAT::Control::Meshopt::MeshoptPrecondFactory. Note that this makes heavy use of the classes from the FEAT::Control::Domain namespace.
After creating a control object meshopt_ctrl from a Control::DomainControl, its prepare() function needs to be called before optimising the mesh by calling meshopt_ctrl->optimize(). One can write the current mesh coordinates to the object's buffer using meshopt_ctrl->mesh_to_buffer() and get a reference to the buffer by meshopt_ctrl->get_coords(). One can call auto new_coords = meshopt_ctrl->get_coords().clone(LAFEM::CloneMode::Deep) to obtain a deep copy of the mesh's vertex coordinates, manipulate them, and then call meshopt_ctrl->prepare(old_coords) to prepare the functional.
If we have a FEAT::Geometry::ExportVTK object for writing the date to a .vtu file, we can simply call meshopt_ctrl->add_to_vtk_exporter to add the relevant data to it. Refer to the class documentation for details.
Currently there are two main classes of MeshQualityFunctionals:
For more information on mesh optimization, refer to [HR11].