version 0.4.1
assemblermanipulatorbuildingblocks.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
9#pragma once
10
11#include <utility>
12
13#include <dune/functions/backends/istlvectorbackend.hh>
14
21
22namespace Ikarus {
23
29template <typename Wrapper, typename Assembler>
31{
32 using WrappedAssembler = Wrapper;
33 using FEC = typename Assembler::FEContainer;
34 using DV = typename Assembler::DirichletValuesType;
35 using FERequirement = typename Assembler::FERequirement;
36 using ScalarType = typename Assembler::ScalarType;
38 friend Interface;
39
40 using FunctionType = std::function<void(const Assembler&, const FERequirement&, ScalarAffordance, ScalarType&)>;
41
47 template <typename F>
49 void bind(F&& f) {
50 sfs.emplace_back(std::forward<F>(f));
51 }
52 std::vector<FunctionType> sfs;
53
54protected:
55 ScalarType& getScalarImpl(const FERequirement& feRequirements, ScalarAffordance affordance) {
56 ScalarType& sca = underlying().base_getScalarImpl(feRequirements, affordance);
57 for (const auto& sf : sfs)
58 sf(underlying().base(), feRequirements, affordance, sca);
59 return sca;
60 }
61
62private:
63 //> CRTP
64 const auto& underlying() const { return static_cast<const WrappedAssembler&>(*this); }
65 auto& underlying() { return static_cast<WrappedAssembler&>(*this); }
66};
67
73template <typename Wrapper, typename Assembler>
75
76{
77 using WrappedAssembler = Wrapper;
78 using FEC = typename Assembler::FEContainer;
79 using DV = typename Assembler::DirichletValuesType;
80 using FERequirement = typename Assembler::FERequirement;
81
82 using VectorType = typename Assembler::VectorType;
83 using Interface = VectorAssembler<WrappedAssembler, typename Assembler::FEContainer,
84 typename Assembler::DirichletValuesType, typename Assembler::VectorType>;
85 friend Interface;
87 std::function<void(const Assembler&, const FERequirement&, VectorAffordance, DBCOption, VectorType&)>;
88
94 template <typename F>
95 requires Concepts::IsFunctorWithArgs<F, const Assembler&, const FERequirement&, VectorAffordance, DBCOption,
97 void bind(F&& f) {
98 vfs.emplace_back(std::forward<F>(f));
99 }
100 std::vector<FunctionType> vfs;
101
102protected:
103 VectorType& getRawVectorImpl(const FERequirement& feRequirements, VectorAffordance affordance) {
104 VectorType& vec = underlying().base_getRawVectorImpl(feRequirements, affordance);
105 for (const auto& vf : vfs)
106 vf(underlying().base(), feRequirements, affordance, DBCOption::Raw, vec);
107 return vec;
108 }
109
110 VectorType& getVectorImpl(const FERequirement& feRequirements, VectorAffordance affordance) {
111 VectorType& vec = underlying().base_getVectorImpl(feRequirements, affordance);
112 for (const auto& vf : vfs)
113 vf(underlying().base(), feRequirements, affordance, DBCOption::Full, vec);
114 return vec;
115 }
116
117 VectorType& getReducedVectorImpl(const FERequirement& feRequirements, VectorAffordance affordance) {
118 VectorType& vec = underlying().base_getReducedVectorImpl(feRequirements, affordance);
119 for (const auto& vf : vfs)
120 vf(underlying().base(), feRequirements, affordance, DBCOption::Reduced, vec);
121 return vec;
122 }
123
124private:
125 //> CRTP
126 const auto& underlying() const { return static_cast<const WrappedAssembler&>(*this); }
127 auto& underlying() { return static_cast<WrappedAssembler&>(*this); }
128};
129
135template <typename Wrapper, typename Assembler>
137{
138 using WrappedAssembler = Wrapper;
139 using FEC = typename Assembler::FEContainer;
140 using DV = typename Assembler::DirichletValuesType;
141 using FERequirement = typename Assembler::FERequirement;
142
143 using MatrixType = typename Assembler::MatrixType;
144 using Interface = MatrixAssembler<WrappedAssembler, typename Assembler::FEContainer,
145 typename Assembler::DirichletValuesType, typename Assembler::MatrixType>;
146 friend Interface;
148 std::function<void(const Assembler&, const FERequirement&, MatrixAffordance, DBCOption, MatrixType&)>;
149
155 template <typename F>
156 requires Concepts::IsFunctorWithArgs<F, const Assembler&, const FERequirement&, MatrixAffordance, DBCOption,
157 MatrixType&>
158 void bind(F&& f) {
159 mfs.emplace_back(std::forward<F>(f));
160 }
161 std::vector<FunctionType> mfs;
162
163protected:
164 MatrixType& getRawMatrixImpl(const FERequirement& feRequirements, MatrixAffordance affordance) {
165 MatrixType& mat = underlying().base_getRawMatrixImpl(feRequirements, affordance);
166 for (const auto& mf : mfs)
167 mf(underlying().base(), feRequirements, affordance, DBCOption::Raw, mat);
168 return mat;
169 }
170
171 MatrixType& getMatrixImpl(const FERequirement& feRequirements, MatrixAffordance affordance) {
172 MatrixType& mat = underlying().base_getMatrixImpl(feRequirements, affordance);
173 for (const auto& mf : mfs)
174 mf(underlying().base(), feRequirements, affordance, DBCOption::Full, mat);
175 return mat;
176 }
177
178 MatrixType& getReducedMatrixImpl(const FERequirement& feRequirements, MatrixAffordance affordance) {
179 MatrixType& mat = underlying().base_getReducedMatrixImpl(feRequirements, affordance);
180 for (const auto& mf : mfs)
181 mf(underlying().base(), feRequirements, affordance, DBCOption::Reduced, mat);
182 return mat;
183 }
184
185private:
186 //> CRTP
187 const auto& underlying() const { return static_cast<const WrappedAssembler&>(*this); }
188 auto& underlying() { return static_cast<WrappedAssembler&>(*this); }
189};
190} // namespace Ikarus
Several concepts.
Definition of the LinearElastic class for finite element mechanics computations.
Definition: assemblermanipulatorbuildingblocks.hh:22
MatrixAffordance
A strongly typed enum class representing the matrix affordance.
Definition: ferequirements.hh:63
DBCOption
Definition: dirichletbcenforcement.hh:7
VectorAffordance
A strongly typed enum class representing the vector affordance.
Definition: ferequirements.hh:48
ScalarAffordance
A strongly typed enum class representing the scalar affordance.
Definition: ferequirements.hh:37
Base class for a wrapper to a scalar assembler.
Definition: assemblermanipulatorbuildingblocks.hh:31
std::vector< FunctionType > sfs
Definition: assemblermanipulatorbuildingblocks.hh:52
void bind(F &&f)
A helper function to add functions that can be used to manipulate the assembled quantity.
Definition: assemblermanipulatorbuildingblocks.hh:49
typename Assembler::FERequirement FERequirement
Definition: assemblermanipulatorbuildingblocks.hh:35
typename Assembler::ScalarType ScalarType
Definition: assemblermanipulatorbuildingblocks.hh:36
std::function< void(const Assembler &, const FERequirement &, ScalarAffordance, ScalarType &)> FunctionType
Definition: assemblermanipulatorbuildingblocks.hh:40
typename Assembler::DirichletValuesType DV
Definition: assemblermanipulatorbuildingblocks.hh:34
ScalarType & getScalarImpl(const FERequirement &feRequirements, ScalarAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:55
friend Interface
Definition: assemblermanipulatorbuildingblocks.hh:38
Wrapper WrappedAssembler
Definition: assemblermanipulatorbuildingblocks.hh:32
typename Assembler::FEContainer FEC
Definition: assemblermanipulatorbuildingblocks.hh:33
Base class for a wrapper to a vector assembler.
Definition: assemblermanipulatorbuildingblocks.hh:76
typename Assembler::DirichletValuesType DV
Definition: assemblermanipulatorbuildingblocks.hh:79
Wrapper WrappedAssembler
Definition: assemblermanipulatorbuildingblocks.hh:77
typename Assembler::FEContainer FEC
Definition: assemblermanipulatorbuildingblocks.hh:78
typename Assembler::VectorType VectorType
Definition: assemblermanipulatorbuildingblocks.hh:82
std::function< void(const Assembler &, const FERequirement &, VectorAffordance, DBCOption, VectorType &)> FunctionType
Definition: assemblermanipulatorbuildingblocks.hh:87
std::vector< FunctionType > vfs
Definition: assemblermanipulatorbuildingblocks.hh:100
typename Assembler::FERequirement FERequirement
Definition: assemblermanipulatorbuildingblocks.hh:80
VectorType & getRawVectorImpl(const FERequirement &feRequirements, VectorAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:103
VectorType & getReducedVectorImpl(const FERequirement &feRequirements, VectorAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:117
VectorType & getVectorImpl(const FERequirement &feRequirements, VectorAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:110
void bind(F &&f)
A helper function to add functions that can be used to manipulate the assembled quantity.
Definition: assemblermanipulatorbuildingblocks.hh:97
friend Interface
Definition: assemblermanipulatorbuildingblocks.hh:85
Base class for a wrapper to a matrix assembler.
Definition: assemblermanipulatorbuildingblocks.hh:137
std::vector< FunctionType > mfs
Definition: assemblermanipulatorbuildingblocks.hh:161
std::function< void(const Assembler &, const FERequirement &, MatrixAffordance, DBCOption, MatrixType &)> FunctionType
Definition: assemblermanipulatorbuildingblocks.hh:148
typename Assembler::FEContainer FEC
Definition: assemblermanipulatorbuildingblocks.hh:139
MatrixType & getMatrixImpl(const FERequirement &feRequirements, MatrixAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:171
MatrixType & getReducedMatrixImpl(const FERequirement &feRequirements, MatrixAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:178
friend Interface
Definition: assemblermanipulatorbuildingblocks.hh:146
typename Assembler::MatrixType MatrixType
Definition: assemblermanipulatorbuildingblocks.hh:143
MatrixType & getRawMatrixImpl(const FERequirement &feRequirements, MatrixAffordance affordance)
Definition: assemblermanipulatorbuildingblocks.hh:164
typename Assembler::FERequirement FERequirement
Definition: assemblermanipulatorbuildingblocks.hh:141
void bind(F &&f)
A helper function to add functions that can be used to manipulate the assembled quantity.
Definition: assemblermanipulatorbuildingblocks.hh:158
Wrapper WrappedAssembler
Definition: assemblermanipulatorbuildingblocks.hh:138
typename Assembler::DirichletValuesType DV
Definition: assemblermanipulatorbuildingblocks.hh:140
The ScalarAssembler provides an interface for an assembler that assembles scalar quantities.
Definition: assembler/interface.hh:267
The VectorAssembler provides an interface for an assembler that assembles vector quantities.
Definition: assembler/interface.hh:312
The MatrixAssembler provides an interface for an assembler that assembles matrix quantities.
Definition: assembler/interface.hh:389
Concept defining the requirements for functors with arguments.
Definition: concepts.hh:347
Defines the interface for flat, scalar, vector and matrix assemblers.
Definition of DirichletValues class for handling Dirichlet boundary conditions.