14#include <dune/functions/backends/istlvectorbackend.hh>
17#include <Eigen/Sparse>
30 template <
typename FEContainer_,
typename DirichletValuesType_>
36 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
37 using Basis =
typename DirichletValuesType_::Basis;
51 : feContainer{std::forward<
FEContainer>(fes)}, dirichletValues{&p_dirichletValues} {
52 constraintsBelow_.reserve(dirichletValues->size());
54 for (
auto iv : std::ranges::iota_view{
decltype(dirichletValues->size())(0), dirichletValues->size()}) {
55 constraintsBelow_.emplace_back(counter);
56 if (dirichletValues->isConstrained(iv)) ++counter;
58 fixedDofs = dirichletValues->fixedDOFsize();
65 size_t reducedSize() {
return dirichletValues->size() - fixedDofs; }
71 size_t size() {
return dirichletValues->size(); }
80 Eigen::VectorXd
createFullVector(Eigen::Ref<const Eigen::VectorXd> reducedVector);
102 [[nodiscard]]
bool isConstrained(
size_t i)
const {
return dirichletValues->isConstrained(i); }
111 return dirichletValues->basis().gridView().size(GridView::dimension) * 8;
117 std::vector<size_t> constraintsBelow_{};
122 template <
class T,
class DirichletValuesType>
123 FlatAssemblerBase(T&& fes,
const DirichletValuesType& dirichletValues_) -> FlatAssemblerBase<T, DirichletValuesType>;
133 template <
typename FEContainer_,
typename DirichletValuesType_>
172 scal += fe.calculateScalar(feRequirements);
181 template <
class T,
class DirichletValuesType>
182 ScalarAssembler(T&& fes,
const DirichletValuesType& dirichletValues_) -> ScalarAssembler<T, DirichletValuesType>;
192 template <
typename FEContainer_,
typename DirichletValuesType_>
221 return getRawVectorImpl(feRequirements);
241 return getReducedVectorImpl(feRequirements);
245 void assembleRawVectorImpl(
const FERequirementType& feRequirements, Eigen::VectorXd& assemblyVec);
251 Eigen::VectorXd vecRaw{};
252 Eigen::VectorXd vec{};
253 Eigen::VectorXd vecRed{};
257 template <
class T,
class DirichletValuesType>
258 VectorFlatAssembler(T&& fes,
const DirichletValuesType& dirichletValues_)
259 -> VectorFlatAssembler<T, DirichletValuesType>;
270 template <
typename FEContainer_,
typename DirichletValuesType_>
300 return getRawMatrixImpl(feRequirements);
311 return getMatrixImpl(feRequirements);
322 return getReducedMatrixImpl(feRequirements);
326 void assembleRawMatrixImpl(
const FERequirementType& feRequirements, Eigen::SparseMatrix<double>& assemblyMat);
327 Eigen::SparseMatrix<double>& getRawMatrixImpl(
const FERequirementType& feRequirements);
328 Eigen::SparseMatrix<double>& getMatrixImpl(
const FERequirementType& feRequirements);
329 Eigen::SparseMatrix<double>& getReducedMatrixImpl(
const FERequirementType& feRequirements);
333 void createOccupationPattern(Eigen::SparseMatrix<double>& assemblyMat);
337 void createReducedOccupationPattern(Eigen::SparseMatrix<double>& assemblyMat);
340 void createLinearDOFsPerElement(Eigen::SparseMatrix<double>& assemblyMat);
344 void createLinearDOFsPerElementReduced(Eigen::SparseMatrix<double>& assemblyMat);
347 void preProcessSparseMatrix(Eigen::SparseMatrix<double>& assemblyMat);
350 void preProcessSparseMatrixReduced(Eigen::SparseMatrix<double>& assemblyMat);
352 Eigen::SparseMatrix<double> spMatRaw;
353 Eigen::SparseMatrix<double> spMat;
354 Eigen::SparseMatrix<double> spMatReduced;
355 std::vector<std::vector<Eigen::Index>>
356 elementLinearIndices;
357 std::vector<std::vector<Eigen::Index>>
358 elementLinearReducedIndices;
359 std::once_flag sparsePreProcessorRaw, sparsePreProcessor,
360 sparsePreProcessorReduced;
364 template <
class T,
class DirichletValuesType>
365 SparseFlatAssembler(T&& fes,
const DirichletValuesType& dirichletValues_)
366 -> SparseFlatAssembler<T, DirichletValuesType>;
378 template <
typename FEContainer_,
typename DirichletValuesType_>
406 return getRawMatrixImpl(feRequirements);
426 return getReducedMatrixImpl(feRequirements);
430 void assembleRawMatrixImpl(
const FERequirementType& feRequirements, Eigen::MatrixXd& assemblyMat);
435 Eigen::MatrixXd matRaw{};
436 Eigen::MatrixXd mat{};
437 Eigen::MatrixXd matRed{};
442 template <
class T,
class DirichletValuesType>
443 DenseFlatAssembler(T&& fes,
const DirichletValuesType& dirichletValues_)
444 -> DenseFlatAssembler<T, DirichletValuesType>;
Implementation of assembler functions.
Definition: simpleassemblers.hh:21
The FlatAssemblerBase takes care of common subtasks done by flat assemblers.
Definition: simpleassemblers.hh:31
FEContainer_ FEContainer
Type of the finite element container.
Definition: simpleassemblers.hh:39
typename Basis::GridView GridView
Type of the grid view.
Definition: simpleassemblers.hh:38
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: simpleassemblers.hh:36
bool isConstrained(size_t i) const
Returns true if a given degree of freedom is fixed by a Dirichlet boundary condition.
Definition: simpleassemblers.hh:102
std::conditional_t< std::is_reference_v< FEContainer >, const FEContainer, FEContainer > FEContainerType
Type of the finite element container (reference or by value).
Definition: simpleassemblers.hh:41
size_t estimateOfConnectivity() const
Coarse estimate of node connectivity, i.e., this relates to the bandwidth of a sparse matrix....
Definition: simpleassemblers.hh:110
Eigen::VectorXd createFullVector(Eigen::Ref< const Eigen::VectorXd > reducedVector)
Creates the full-sized vector of size Dof and inserts the values of a reduced vector at the "free" de...
Definition: simpleassemblers.inl:15
size_t constraintsBelow(size_t i) const
Returns the number of constraints below a given degrees of freedom index.
Definition: simpleassemblers.hh:94
std::remove_cvref_t< FEContainer_ > FEContainerRaw
Type of the raw finite element container.
Definition: simpleassemblers.hh:33
size_t reducedSize()
Returns the size of the free degrees of freedom, which are not fixed by a Dirichlet boundary conditio...
Definition: simpleassemblers.hh:65
auto & finiteElements() const
Returns the container of finite elements.
Definition: simpleassemblers.hh:86
FlatAssemblerBase(FEContainer &&fes, const DirichletValuesType &p_dirichletValues)
Constructor for FlatAssemblerBase.
Definition: simpleassemblers.hh:50
DirichletValuesType_ DirichletValuesType
Type of the Dirichlet values.
Definition: simpleassemblers.hh:42
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:35
size_t size()
Returns the size of nodes, i.e., the number of degrees of freedom.
Definition: simpleassemblers.hh:71
typename DirichletValuesType_::Basis Basis
Type of the basis.
Definition: simpleassemblers.hh:37
ScalarAssembler assembles scalar quantities.
Definition: simpleassemblers.hh:134
FEContainer_ FEContainer
Type of the finite element container.
Definition: simpleassemblers.hh:39
const double & getScalar(const FERequirementType &feRequirements)
Calculates the scalar quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:160
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: simpleassemblers.hh:36
ScalarAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues_)
Constructor for ScalarAssembler.
Definition: simpleassemblers.hh:151
DirichletValuesType_ DirichletValuesType
Type of the Dirichlet values.
Definition: simpleassemblers.hh:42
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:35
typename DirichletValuesType_::Basis Basis
Type of the basis.
Definition: simpleassemblers.hh:37
VectorFlatAssembler assembles vector quantities using a flat basis Indexing strategy.
Definition: simpleassemblers.hh:193
FEContainer_ FEContainer
Type of the finite element container.
Definition: simpleassemblers.hh:39
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: simpleassemblers.hh:36
const Eigen::VectorXd & getRawVector(const FERequirementType &feRequirements)
Calculates the vectorial quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:220
const Eigen::VectorXd & getReducedVector(const FERequirementType &feRequirements)
Calculates the vectorial quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:240
const Eigen::VectorXd & getVector(const FERequirementType &feRequirements)
Calculates the vectorial quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:231
DirichletValuesType_ DirichletValuesType
Type of the Dirichlet values.
Definition: simpleassemblers.hh:42
VectorFlatAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues_)
Constructor for VectorFlatAssembler.
Definition: simpleassemblers.hh:211
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:35
typename DirichletValuesType_::Basis Basis
Type of the basis.
Definition: simpleassemblers.hh:37
SparseFlatAssembler assembles matrix quantities using a flat basis Indexing strategy....
Definition: simpleassemblers.hh:271
SparseFlatAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues_)
Constructor for SparseFlatAssembler.
Definition: simpleassemblers.hh:288
const Eigen::SparseMatrix< double > & getReducedMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:321
const Eigen::SparseMatrix< double > & getRawMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:299
const Eigen::SparseMatrix< double > & getMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:310
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:35
DenseFlatAssembler assembles matrix quantities using a flat basis Indexing strategy....
Definition: simpleassemblers.hh:379
const Eigen::MatrixXd & getMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:416
const Eigen::MatrixXd & getReducedMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:425
const Eigen::MatrixXd & getRawMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:405
DenseFlatAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues_)
< Type of the global index.
Definition: simpleassemblers.hh:396
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:35
typename PreBasis::GridView GridView
The type of the grid view.
Definition: utils/basis.hh:32
Definition of DirichletValues class for handling Dirichlet boundary conditions.