14#include <dune/functions/backends/istlvectorbackend.hh>
17#include <Eigen/Sparse>
31template <
typename FEC,
typename DV>
38 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
39 using Basis =
typename DV::Basis;
55 constraintsBelow_.reserve(dirichletValues_->size());
57 for (
auto iv : std::ranges::iota_view{
decltype(dirichletValues_->size())(0), dirichletValues_->size()}) {
58 constraintsBelow_.emplace_back(counter);
59 if (dirichletValues_->isConstrained(iv))
62 fixedDofs_ = dirichletValues_->fixedDOFsize();
69 size_t reducedSize() {
return dirichletValues_->size() - fixedDofs_; }
75 size_t size() {
return dirichletValues_->size(); }
84 Eigen::VectorXd
createFullVector(Eigen::Ref<const Eigen::VectorXd> reducedVector);
106 [[nodiscard]]
bool isConstrained(
size_t i)
const {
return dirichletValues_->isConstrained(i); }
115 return dirichletValues_->basis().gridView().size(GridView::dimension) * 8;
121 std::vector<size_t> constraintsBelow_{};
126template <
class T,
class DirichletValuesType>
127FlatAssemblerBase(T&& fes,
const DirichletValuesType&
dirichletValues) -> FlatAssemblerBase<T, DirichletValuesType>;
137template <
typename FEC,
typename DV>
177 scal_ += calculateScalar(fe, feRequirements);
186template <
class T,
class DirichletValuesType>
187ScalarAssembler(T&& fes,
const DirichletValuesType&
dirichletValues) -> ScalarAssembler<T, DirichletValuesType>;
197template <
typename FEC,
typename DV>
227 return getRawVectorImpl(feRequirements);
247 return getReducedVectorImpl(feRequirements);
251 void assembleRawVectorImpl(
const FERequirementType& feRequirements, Eigen::VectorXd& assemblyVec);
257 Eigen::VectorXd vecRaw_{};
258 Eigen::VectorXd vec_{};
259 Eigen::VectorXd vecRed_{};
263template <
class T,
class DirichletValuesType>
264VectorFlatAssembler(T&& fes,
const DirichletValuesType&
dirichletValues) -> VectorFlatAssembler<T, DirichletValuesType>;
275template <
typename FEC,
typename DV>
306 return getRawMatrixImpl(feRequirements);
317 return getMatrixImpl(feRequirements);
328 return getReducedMatrixImpl(feRequirements);
332 void assembleRawMatrixImpl(
const FERequirementType& feRequirements, Eigen::SparseMatrix<double>& assemblyMat);
333 Eigen::SparseMatrix<double>& getRawMatrixImpl(
const FERequirementType& feRequirements);
334 Eigen::SparseMatrix<double>& getMatrixImpl(
const FERequirementType& feRequirements);
335 Eigen::SparseMatrix<double>& getReducedMatrixImpl(
const FERequirementType& feRequirements);
339 void createOccupationPattern(Eigen::SparseMatrix<double>& assemblyMat);
343 void createReducedOccupationPattern(Eigen::SparseMatrix<double>& assemblyMat);
346 void createLinearDOFsPerElement(Eigen::SparseMatrix<double>& assemblyMat);
350 void createLinearDOFsPerElementReduced(Eigen::SparseMatrix<double>& assemblyMat);
353 void preProcessSparseMatrix(Eigen::SparseMatrix<double>& assemblyMat);
356 void preProcessSparseMatrixReduced(Eigen::SparseMatrix<double>& assemblyMat);
358 Eigen::SparseMatrix<double> spMatRaw_;
359 Eigen::SparseMatrix<double> spMat_;
360 Eigen::SparseMatrix<double> spMatReduced_;
361 std::vector<std::vector<Eigen::Index>>
362 elementLinearIndices_;
363 std::vector<std::vector<Eigen::Index>>
364 elementLinearReducedIndices_;
365 std::once_flag sparsePreProcessorRaw_, sparsePreProcessor_,
366 sparsePreProcessorReduced_;
370template <
class FEC,
class DV>
371SparseFlatAssembler(FEC&& fes,
const DV&
dirichletValues) -> SparseFlatAssembler<FEC, DV>;
383template <
typename FEC,
typename DV>
412 return getRawMatrixImpl(feRequirements);
432 return getReducedMatrixImpl(feRequirements);
436 void assembleRawMatrixImpl(
const FERequirementType& feRequirements, Eigen::MatrixXd& assemblyMat);
441 Eigen::MatrixXd matRaw_{};
442 Eigen::MatrixXd mat_{};
443 Eigen::MatrixXd matRed_{};
448template <
class FEC,
class DV>
449DenseFlatAssembler(FEC&& fes,
const DV&
dirichletValues) -> DenseFlatAssembler<FEC, DV>;
Implementation of assembler functions.
Definition: simpleassemblers.hh:22
def dirichletValues(basis)
Definition: dirichlet_values.py:7
The FlatAssemblerBase takes care of common subtasks done by flat assemblers.
Definition: simpleassemblers.hh:33
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: simpleassemblers.hh:35
FlatAssemblerBase(FEContainer &&fes, const DirichletValuesType &dirichletValues)
Constructor for FlatAssemblerBase.
Definition: simpleassemblers.hh:52
FEC FEContainer
Type of the finite element container.
Definition: simpleassemblers.hh:41
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
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:37
bool isConstrained(size_t i) const
Returns true if a given degree of freedom is fixed by a Dirichlet boundary condition.
Definition: simpleassemblers.hh:106
size_t reducedSize()
Returns the size of the free degrees of freedom, which are not fixed by a Dirichlet boundary conditio...
Definition: simpleassemblers.hh:69
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: simpleassemblers.hh:38
size_t constraintsBelow(size_t i) const
Returns the number of constraints below a given degrees of freedom index.
Definition: simpleassemblers.hh:98
auto & finiteElements() const
Returns the container of finite elements.
Definition: simpleassemblers.hh:90
DV DirichletValuesType
Type of the Dirichlet values.
Definition: simpleassemblers.hh:44
typename Basis::GridView GridView
Type of the grid view.
Definition: simpleassemblers.hh:40
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:43
size_t estimateOfConnectivity() const
Coarse estimate of node connectivity, i.e., this relates to the bandwidth of a sparse matrix....
Definition: simpleassemblers.hh:114
size_t size()
Returns the size of nodes, i.e., the number of degrees of freedom.
Definition: simpleassemblers.hh:75
typename DV::Basis Basis
Type of the basis.
Definition: simpleassemblers.hh:39
ScalarAssembler assembles scalar quantities.
Definition: simpleassemblers.hh:139
const double & getScalar(const FERequirementType &feRequirements)
Calculates the scalar quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:165
FEC FEContainer
Type of the finite element container.
Definition: simpleassemblers.hh:41
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:37
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: simpleassemblers.hh:38
DV DirichletValuesType
Type of the Dirichlet values.
Definition: simpleassemblers.hh:44
ScalarAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues)
Constructor for ScalarAssembler.
Definition: simpleassemblers.hh:156
typename DV::Basis Basis
Type of the basis.
Definition: simpleassemblers.hh:39
VectorFlatAssembler assembles vector quantities using a flat basis Indexing strategy.
Definition: simpleassemblers.hh:199
const Eigen::VectorXd & getVector(const FERequirementType &feRequirements)
Calculates the vectorial quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:237
const Eigen::VectorXd & getRawVector(const FERequirementType &feRequirements)
Calculates the vectorial quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:226
FEC FEContainer
Type of the finite element container.
Definition: simpleassemblers.hh:41
const Eigen::VectorXd & getReducedVector(const FERequirementType &feRequirements)
Calculates the vectorial quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:246
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:37
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: simpleassemblers.hh:38
DV DirichletValuesType
Type of the Dirichlet values.
Definition: simpleassemblers.hh:44
VectorFlatAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues)
Constructor for VectorFlatAssembler.
Definition: simpleassemblers.hh:217
typename DV::Basis Basis
Type of the basis.
Definition: simpleassemblers.hh:39
SparseFlatAssembler assembles matrix quantities using a flat basis Indexing strategy....
Definition: simpleassemblers.hh:277
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:37
const Eigen::SparseMatrix< double > & getRawMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:305
const Eigen::SparseMatrix< double > & getReducedMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:327
SparseFlatAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues)
Constructor for SparseFlatAssembler.
Definition: simpleassemblers.hh:294
const Eigen::SparseMatrix< double > & getMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:316
DenseFlatAssembler assembles matrix quantities using a flat basis Indexing strategy....
Definition: simpleassemblers.hh:385
const Eigen::MatrixXd & getRawMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference.
Definition: simpleassemblers.hh:411
const Eigen::MatrixXd & getMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:422
const Eigen::MatrixXd & getReducedMatrix(const FERequirementType &feRequirements)
Calculates the matrix quantity requested by feRequirements and returns a reference....
Definition: simpleassemblers.hh:431
typename FEContainerRaw::value_type::FERequirementType FERequirementType
Type of the finite element requirement.
Definition: simpleassemblers.hh:37
DenseFlatAssembler(FEContainer &&fes, const DirichletValuesType &dirichletValues)
< Type of the global index.
Definition: simpleassemblers.hh:402
Definition of DirichletValues class for handling Dirichlet boundary conditions.