9#include <kernel/assembly/bilinear_operator_assembler.hpp>
10#include <kernel/assembly/common_operators.hpp>
11#include <kernel/assembly/symbolic_assembler.hpp>
12#include <kernel/assembly/slip_filter_assembler.hpp>
13#include <kernel/assembly/unit_filter_assembler.hpp>
14#include <kernel/cubature/dynamic_factory.hpp>
15#include <kernel/geometry/conformal_mesh.hpp>
16#include <kernel/lafem/dense_vector_blocked.hpp>
17#include <kernel/lafem/filter_chain.hpp>
18#include <kernel/lafem/filter_sequence.hpp>
19#include <kernel/lafem/sparse_matrix_bcsr.hpp>
20#include <kernel/lafem/slip_filter.hpp>
21#include <kernel/lafem/unit_filter_blocked.hpp>
22#include <kernel/meshopt/mesh_quality_functional.hpp>
23#include <kernel/space/lagrange1/element.hpp>
46 typename DT_,
typename IT_,
typename TrafoType_,
47 template<
typename,
typename,
int,
int>
class MatrixType_ = LAFEM::SparseMatrixBCSR
65 typedef MatrixType_<DT_, IT_, MeshType::world_dim, MeshType::world_dim>
MatrixType;
69 static constexpr int BlockWidth = MatrixType::BlockWidth;
72 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
76 template <
typename DataType2_,
typename IndexType2_>
109 typedef typename Intern::TrafoFE<TrafoType>::Space
SpaceType;
124 std::map<String, std::shared_ptr<Assembly::UnitFilterAssembler<MeshType>>>
_dirichlet_asm;
126 std::map<String, std::shared_ptr<Assembly::SlipFilterAssembler<TrafoType>>>
_slip_asm;
154 const std::deque<String>& dirichlet_list,
const std::deque<String>& slip_list):
170 for(
auto& it : dirichlet_list)
173 auto new_asm = std::make_shared<Assembly::UnitFilterAssembler<MeshType>>();
180 new_asm->add_mesh_part(*mpp);
190 for(
auto& it : slip_list)
193 auto new_asm = std::make_shared<Assembly::SlipFilterAssembler<TrafoType>>(this->
_trafo);
200 new_asm->add_mesh_part(*mpp);
233 return "DuDvFunctional<"+MeshType::name()+
">";
280 for(
Index cell(0); cell < this->
get_mesh()->get_num_entities(MeshType::shape_dim); ++cell)
285 auto& dirichlet_filters = filter.template at<1>();
287 for(
auto& it : dirichlet_filters)
292 XABORTM(
"Could not find dirichlet assembler for filter with key "+it.first);
295 assembler->second->assemble(it.second,
trafo_space, vec_state);
299 auto& slip_filters = filter.template at<0>();
301 for(
auto& it : slip_filters)
303 const auto& assembler =
_slip_asm.find(it.first);
306 XABORTM(
"Could not find slip filter assembler for filter with key "+it.first);
309 assembler->second->assemble(it.second,
trafo_space);
312 for(
const auto& it:slip_filters)
388 vol_min = Math::huge<CoordType>();
391 for(
Index cell(0); cell < this->
get_mesh()->get_num_entities(ShapeType::dimension); ++cell)
393 CoordType my_vol = this->_trafo.template compute_vol<ShapeType, CoordType>(cell);
430 lambda_min = Math::huge<CoordType>();
433 for(
Index cell(0); cell < this->
get_mesh()->get_num_entities(ShapeType::dimension); ++cell)
435 size_defect +=
Math::abs(this->_trafo.template compute_vol<ShapeType, CoordType>(cell)/vol - this->_lambda(cell));
476 extern template class DuDvFunctional
483 extern template class DuDvFunctional
#define XABORTM(msg)
Abortion macro definition with custom message.
static void assemble_matrix1(Matrix_ &matrix, Operator_ &operat, const Space_ &space, const CubatureFactory_ &cubature_factory, typename Matrix_::DataType alpha=typename Matrix_::DataType(1))
Assembles a bilinear operator into a matrix.
Du:Dv operator implementation.
static void assemble_matrix_std1(MatrixType_ &matrix, const Space_ &space)
Assembles a standard matrix structure from a single space.
VTK exporter class template.
void add_cell_scalar(const String &name, const T_ *data, double scaling_factor=1.0)
Adds a scalar cell variable to the exporter.
bool adapt_by_name(const String &part_name, bool recursive=false)
Adapts this mesh node.
MeshPartType * find_mesh_part(const String &part_name)
Searches this container for a MeshPart.
Root mesh node class template.
Dense data vector class template.
DT_ * elements()
Get a pointer to the data array.
Filter Chainclass template.
Sequence of filters of the same type.
Slip Filter class template.
CSR based blocked sparse matrix.
Unit Filter Blocked class template.
Mesh optimizer based on minimization of harmonic energy.
TrafoType_ TrafoType
Type for the transformation.
DuDvFunctional(Geometry::RootMeshNode< MeshType > *rmn_, TrafoType &trafo, const std::deque< String > &dirichlet_list, const std::deque< String > &slip_list)
Constructor.
virtual void add_to_vtk_exporter(Geometry::ExportVTK< MeshType > &exporter) const override
Adds relevant quantities of this object to a VTK exporter.
virtual CoordType compute_cell_size_defect_post_sync(CoordType &lambda_min, CoordType &lambda_max, CoordType &vol_min, CoordType &vol_max, const CoordType &vol) const
Computes a quality indicator concerning the cell sizes, pre synchronization phase.
LAFEM::FilterChain< SlipFilterSequence, DirichletFilterSequence > FilterType
Combined filter.
virtual void prepare(VectorTypeR &vec_state, FilterType &filter)
Prepares the functional for evaluation.
bool empty() const
Checks if the functional is empty (= the null functional.
virtual ~DuDvFunctional()
Virtual destructor.
MatrixType_< DT_, IT_, MeshType::world_dim, MeshType::world_dim > MatrixType
Type for the system matrix.
DuDvFunctional(const DuDvFunctional &)=delete
Explicitly delete copy constructor.
LAFEM::DenseVector< DT_, IT_ > ScalarVectorType
Type for i.e. cell vectors.
LAFEM::FilterSequence< SlipFilterType > SlipFilterSequence
Sequence of Slip filters for several different boundary parts.
MeshType::CoordType CoordType
The precision of the mesh coordinates.
LAFEM::FilterSequence< DirichletFilterType > DirichletFilterSequence
Sequence of Dirichlet filters for several different boundary parts.
ScalarVectorType _lambda
Vector saving the cell sizes on the reference mesh.
Cubature::DynamicFactory _cubature_factory
Cubature factory, for P1/Q1 transformations in 2d degree 5 is enough.
static constexpr int BlockHeight
Blockheight of the system matrix.
MeshQualityFunctional< MeshType > BaseClass
Our base class.
TrafoType::MeshType MeshType
The mesh the transformation is defined on.
DT_ DataType
Our datatype.
void compute_cell_size_defect_pre_sync(CoordType &vol_min, CoordType &vol_max, CoordType &vol) const
Computes a quality indicator concerning the cell sizes, pre synchronization phase.
virtual CoordType compute_cell_size_defect(CoordType &lambda_min, CoordType &lambda_max, CoordType &vol_min, CoordType &vol_max, CoordType &vol) const override
Computes a quality indicator concerning the cell sizes.
LAFEM::UnitFilterBlocked< DT_, IT_, MeshType::world_dim > DirichletFilterType
Filter for Dirichlet boundary conditions.
VectorTypeR create_vector_r() const
Creates an R-vector for the functional and its gradient.
MatrixType matrix_sys
The system matrix.
SpaceType trafo_space
The FE space for the transformation, needed for filtering.
virtual void init() override
Performs one-time initializations.
static constexpr int BlockWidth
Blockwidth of the system matrix.
MeshType::ShapeType ShapeType
The shape type of the mesh.
std::map< String, std::shared_ptr< Assembly::UnitFilterAssembler< MeshType > > > _dirichlet_asm
Assembler for Dirichlet boundary conditions.
LAFEM::SlipFilter< DT_, IT_, MeshType::world_dim > SlipFilterType
Filter for slip boundary conditions.
std::map< String, std::shared_ptr< Assembly::SlipFilterAssembler< TrafoType > > > _slip_asm
Assembler for slip boundary conditions.
MatrixType::VectorTypeR VectorTypeR
Type for vectors from the primal space.
IT_ IndexType
Our index type.
MatrixType::VectorTypeL VectorTypeL
Type for vectors from the dual space.
Intern::TrafoFE< TrafoType >::Space SpaceType
Finite Element space for the transformation.
static String name()
The class name.
TrafoType & _trafo
The transformation defining the physical mesh.
static constexpr int _local_degree
Maximum polynomial degree.
VectorTypeL create_vector_l() const
Creates an L-vector for the functional's gradient.
BaseClass::CoordsBufferType CoordsBufferType
Type for exchanging information between state variable and mesh.
virtual void assemble_system_matrix()
Assembles the system matrix.
Baseclass for mesh optimization algorithms.
Geometry::RootMeshNode< MeshType > * _mesh_node
The mesh for the underlying transformation.
String class implementation.
Standard transformation mapping class template.
T_ abs(T_ x)
Returns the absolute value.
T_ min(T_ a, T_ b)
Returns the minimum of two values.
T_ max(T_ a, T_ b)
Returns the maximum of two values.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.