FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
mesh_quality_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/geometry/export_vtk.hpp>
10#include <kernel/geometry/mesh_node.hpp>
11#include <kernel/lafem/dense_vector_blocked.hpp>
12#include <kernel/meshopt/base.hpp>
13#include <kernel/space/lagrange1/element.hpp>
14#include <kernel/trafo/standard/mapping.hpp>
15
16namespace FEAT
17{
18 namespace Meshopt
19 {
20
33 template<typename MeshType_>
35 {
36 public:
38 typedef MeshType_ MeshType;
40 typedef typename MeshType::CoordType CoordType;
42 typedef typename MeshType::ShapeType ShapeType;
45
46 public:
51
52 protected:
59
60 public:
69 _mesh_node(mesh_node_),
70 _coords_buffer(mesh_node_->get_mesh()->get_num_entities(0), CoordType(0)),
74 {
75 XASSERTM(mesh_node_ != nullptr, "MeshNode must not be nullptr.");
76
78 }
79
88 _mesh_node(nullptr),
93 {
94 }
95
98 {
99 // Just set it to nullptr since we did not allocate the memory for this
100 _mesh_node = nullptr;
102 }
103
109 static String name()
110 {
111 return "MeshQualityFunctional<"+MeshType_::name()+">";
112 }
113
121 virtual void add_to_vtk_exporter(Geometry::ExportVTK<MeshType>& DOXY(exporter)) const
122 {
123 }
124
127 {
128 XASSERT(_mesh_node != nullptr);
129 return _mesh_node->get_mesh();
130 }
131
133 const MeshType* get_mesh() const
134 {
135 XASSERT(_mesh_node != nullptr);
136 return _mesh_node->get_mesh();
137 }
138
141 {
142 return _mesh_node;
143 }
144
146 virtual void mesh_to_buffer()
147 {
148 const typename MeshType::VertexSetType& vertex_set = get_mesh()->get_vertex_set();
149
150 for(Index i(0); i < get_mesh()->get_num_entities(0); ++i)
151 _coords_buffer(i, vertex_set[i]);
152 }
153
155 virtual void buffer_to_mesh()
156 {
157 typename MeshType::VertexSetType& vertex_set = get_mesh()->get_vertex_set();
158
159 for(Index i(0); i < get_mesh()->get_num_entities(0); ++i)
160 vertex_set[i] = _coords_buffer(i);
161 }
162
169 {
170 return _coords_buffer;
171 }
172
179 {
180 return _coords_buffer;
181 }
182
187 {
188 return _num_func_evals;
189 }
190
195 {
196 return _num_grad_evals;
197 }
198
203 {
204 return _num_hess_evals;
205 }
206
211 {
215 }
216
223 virtual void init() = 0;
224
226 //virtual void prepare(VectorTypeR&) = 0;
227
260 virtual CoordType compute_cell_size_defect(CoordType& DOXY(lambda_min), CoordType& DOXY(lambda_max),
261 CoordType& DOXY(vol_min), CoordType& DOXY(vol_max), CoordType& DOXY(vol)) const = 0;
262
263 }; // class MeshQualityFunctional
264
265 } // namespace Meshopt
266} // namespace FEAT
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT Kernel base header.
VTK exporter class template.
Definition: export_vtk.hpp:119
MeshType * get_mesh()
Returns the mesh of this node.
Definition: mesh_node.hpp:225
Root mesh node class template.
Definition: mesh_node.hpp:748
virtual void clear()
Free all allocated arrays.
Definition: container.hpp:875
Blocked Dense data vector class template.
Baseclass for mesh optimization algorithms.
virtual ~MeshQualityFunctional()
Virtual destructor.
const CoordsBufferType & get_coords() const
Gets the coords buffer.
virtual void init()=0
Performs one-time initializations.
virtual void mesh_to_buffer()
Gets the coordinates from the underlying mesh and saves them in _coords_buffer.
MeshType::CoordType CoordType
Our datatype.
Geometry::RootMeshNode< MeshType > * _mesh_node
The mesh for the underlying transformation.
Index _num_func_evals
Counter for number of function evaluations.
MeshType::ShapeType ShapeType
The shape type.
CoordsBufferType & get_coords()
Gets the coords buffer.
LAFEM::DenseVectorBlocked< CoordType, Index, MeshType::world_dim > CoordsBufferType
Type for the vectors to hold coordinates etc.
MeshQualityFunctional(Geometry::RootMeshNode< MeshType > *mesh_node_)
Constructor.
MeshQualityFunctional()
Empty standard constructor.
Geometry::RootMeshNode< MeshType > * get_mesh_node() const
MeshType_ MeshType
Type of the mesh to optimize.
Index _num_grad_evals
Counter for number of gradient evaluations.
void reset_num_evals()
Resets all evaluation counts.
virtual CoordType compute_cell_size_defect(CoordType &lambda_min, CoordType &lambda_max, CoordType &vol_min, CoordType &vol_max, CoordType &vol) const =0
Computes a quality indicator concerning the cell sizes.
virtual void buffer_to_mesh()
Sets the coordinates in the underlying mesh to _coords_buffer.
virtual void add_to_vtk_exporter(Geometry::ExportVTK< MeshType > &exporter) const
Adds relevant quantities of this object to a VTK exporter.
CoordsBufferType _coords_buffer
Coordinates, used for setting new boundary values etc.
Index _num_hess_evals
Counter for number of hessian evaluations.
String class implementation.
Definition: string.hpp:46
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.