version 0.4.1
assemblermanipulatorfuser.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
11
12namespace Ikarus {
13
14namespace Impl {
15 template <template <typename, typename, typename, typename> typename AInterface,
16 template <typename Wrapper, typename Assembler> typename AImplementation>
17 struct AssemblerInterfaceHelper
18 {
19 template <typename WA, typename A, typename ReturnValueType>
20 using Interface = AInterface<WA, typename A::FEContainer, typename A::DirichletValuesType, ReturnValueType>;
21 template <typename WA, typename A>
22 using Implementation = AImplementation<WA, A>;
23 };
24
25} // namespace Impl
35template <Concepts::FlatAssembler A, typename... Ass>
37
38#define BASECLASSMEMBERFUNCTION(func, A) \
39 template <typename... Args> \
40 decltype(auto) base_##func(Args... args) { \
41 return A::func(std::forward<Args>(args)...); \
42 }
43
52template <Concepts::FlatAssembler A, typename ScalarAss>
53class AssemblerManipulator<A, ScalarAss>
54 : public ScalarAss::template Interface<AssemblerManipulator<A, ScalarAss>, A, typename A::ScalarType>,
55 public ScalarAss::template Implementation<AssemblerManipulator<A, ScalarAss>, A>,
56 private A
57{
58public:
60
61protected:
62 using ScalarAssemblerImpl = ScalarAss::template Implementation<AssemblerManipulator, WrappedAssembler>;
63 using ScalarAssemblerInterface = ScalarAss::template Interface<AssemblerManipulator, A, typename A::ScalarType>;
64
67
68public:
69 // typdefs from FlatAssemblerBase
70 using typename WrappedAssembler::AffordanceCollectionType;
71 using typename WrappedAssembler::Basis;
72 using typename WrappedAssembler::DirichletValuesType;
73 using typename WrappedAssembler::FEContainer;
74 using typename WrappedAssembler::FERequirement;
75 using typename WrappedAssembler::ScalarType;
76 using typename WrappedAssembler::SizeType;
77
78 // functions from FlatAssemblerBase
79 using WrappedAssembler::bind;
80 using WrappedAssembler::bound;
81 using WrappedAssembler::boundToAffordanceCollection;
82 using WrappedAssembler::boundToDBCOption;
83 using WrappedAssembler::boundToRequirement;
84 using WrappedAssembler::createFullVector;
85
86 using WrappedAssembler::affordanceCollection;
87 using WrappedAssembler::constraintsBelow;
88 using WrappedAssembler::dBCOption;
89 using WrappedAssembler::estimateOfConnectivity;
90 using WrappedAssembler::gridView;
91 using WrappedAssembler::isConstrained;
92 using WrappedAssembler::reducedSize;
93 using WrappedAssembler::requirement;
94 using WrappedAssembler::size;
95
96 // functions from implementations
97 using ScalarAssemblerImpl::bind;
98
99private:
100 using ScalarAssemblerImpl::getScalarImpl;
101
102public:
103 // functions from interfaces of the new manipulator assembler
104 using ScalarAssemblerInterface::scalar;
105
107 std::tuple<typename ScalarAss::template Implementation<AssemblerManipulator<A, ScalarAss>, A>::FunctionType>;
108
115 template <typename... Args>
116 requires(not std::is_same_v<std::remove_cvref_t<std::tuple_element_t<0, std::tuple<Args...>>>, AssemblerManipulator>)
117 explicit AssemblerManipulator(Args&&... args)
118 : WrappedAssembler(std::forward<Args>(args)...) {}
119
120private:
121 BASECLASSMEMBERFUNCTION(getScalarImpl, A)
122
123 A& base() { return *this; }
124 const A& base() const { return *this; }
125};
126
136template <Concepts::FlatAssembler A, typename ScalarAss, typename VectorAss>
137class AssemblerManipulator<A, ScalarAss, VectorAss>
138 : public ScalarAss::template Interface<AssemblerManipulator<A, ScalarAss, VectorAss>, A, typename A::ScalarType>,
139 public ScalarAss::template Implementation<AssemblerManipulator<A, ScalarAss, VectorAss>, A>,
140 public VectorAss::template Interface<AssemblerManipulator<A, ScalarAss, VectorAss>, A, typename A::VectorType>,
141 public VectorAss::template Implementation<AssemblerManipulator<A, ScalarAss, VectorAss>, A>,
142 private A
143{
144public:
146
147protected:
148 using ScalarAssemblerImpl = ScalarAss::template Implementation<AssemblerManipulator, WrappedAssembler>;
149 using VectorAssemblerImpl = VectorAss::template Implementation<AssemblerManipulator, WrappedAssembler>;
150 using ScalarAssemblerInterface = ScalarAss::template Interface<AssemblerManipulator, A, typename A::ScalarType>;
151 using VectorAssemblerInterface = VectorAss::template Interface<AssemblerManipulator, A, typename A::VectorType>;
152
157
158public:
159 // typdefs from FlatAssemblerBase
160 using typename WrappedAssembler::AffordanceCollectionType;
161 using typename WrappedAssembler::Basis;
162 using typename WrappedAssembler::DirichletValuesType;
163 using typename WrappedAssembler::FEContainer;
164 using typename WrappedAssembler::FERequirement;
165 using typename WrappedAssembler::ScalarType;
166 using typename WrappedAssembler::SizeType;
167 using typename WrappedAssembler::VectorType;
168
169 // functions from FlatAssemblerBase
170 using WrappedAssembler::bind;
171 using WrappedAssembler::bound;
172 using WrappedAssembler::boundToAffordanceCollection;
173 using WrappedAssembler::boundToDBCOption;
174 using WrappedAssembler::boundToRequirement;
175 using WrappedAssembler::createFullVector;
176
177 using WrappedAssembler::affordanceCollection;
178 using WrappedAssembler::constraintsBelow;
179 using WrappedAssembler::dBCOption;
180 using WrappedAssembler::estimateOfConnectivity;
181 using WrappedAssembler::gridView;
182 using WrappedAssembler::isConstrained;
183 using WrappedAssembler::reducedSize;
184 using WrappedAssembler::requirement;
185 using WrappedAssembler::size;
186
187 // functions from implementations
188 using ScalarAssemblerImpl::bind;
189 using VectorAssemblerImpl::bind;
190
191private:
192 using ScalarAssemblerImpl::getScalarImpl;
193 using VectorAssemblerImpl::getRawVectorImpl;
194 using VectorAssemblerImpl::getReducedVectorImpl;
195 using VectorAssemblerImpl::getVectorImpl;
196
197public:
198 // functions from interfaces of the new manipulator assembler
199 using ScalarAssemblerInterface::scalar;
200 using VectorAssemblerInterface::vector;
201
203 std::tuple<typename ScalarAssemblerImpl::FunctionType, typename VectorAssemblerImpl::FunctionType>;
204
211 template <typename... Args>
212 requires(not std::is_same_v<std::remove_cvref_t<std::tuple_element_t<0, std::tuple<Args...>>>, AssemblerManipulator>)
213 explicit AssemblerManipulator(Args&&... args)
214 : WrappedAssembler(std::forward<Args>(args)...) {}
215
216private:
217 BASECLASSMEMBERFUNCTION(getScalarImpl, WrappedAssembler)
218 BASECLASSMEMBERFUNCTION(getRawVectorImpl, WrappedAssembler)
219 BASECLASSMEMBERFUNCTION(getReducedVectorImpl, WrappedAssembler)
220 BASECLASSMEMBERFUNCTION(getVectorImpl, WrappedAssembler)
221
222 WrappedAssembler& base() { return *this; }
223 const WrappedAssembler& base() const { return *this; }
224};
225
236template <Concepts::FlatAssembler A, typename ScalarAss, typename VectorAss, typename MatrixAss>
237class AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>
238 : public ScalarAss::template Interface<AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>, A,
239 typename A::ScalarType>,
240 public ScalarAss::template Implementation<AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>, A>,
241 public VectorAss::template Interface<AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>, A,
242 typename A::VectorType>,
243 public VectorAss::template Implementation<AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>, A>,
244 public MatrixAss::template Interface<AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>, A,
245 typename A::MatrixType>,
246 public MatrixAss::template Implementation<AssemblerManipulator<A, ScalarAss, VectorAss, MatrixAss>, A>,
247 private A
248{
249public:
251
252protected:
253 using ScalarAssemblerImpl = ScalarAss::template Implementation<AssemblerManipulator, A>;
254 using VectorAssemblerImpl = VectorAss::template Implementation<AssemblerManipulator, A>;
255 using MatrixAssemblerImpl = MatrixAss::template Implementation<AssemblerManipulator, A>;
256 using ScalarAssemblerInterface = ScalarAss::template Interface<AssemblerManipulator, A, typename A::ScalarType>;
257 using VectorAssemblerInterface = VectorAss::template Interface<AssemblerManipulator, A, typename A::VectorType>;
258 using MatrixAssemblerInterface = MatrixAss::template Interface<AssemblerManipulator, A, typename A::MatrixType>;
259
266
267public:
268 // typdefs from FlatAssemblerBase
269 using typename WrappedAssembler::AffordanceCollectionType;
270 using typename WrappedAssembler::Basis;
271 using typename WrappedAssembler::DirichletValuesType;
272 using typename WrappedAssembler::FEContainer;
273 using typename WrappedAssembler::FERequirement;
274 using typename WrappedAssembler::MatrixType;
275 using typename WrappedAssembler::ScalarType;
276 using typename WrappedAssembler::SizeType;
277 using typename WrappedAssembler::VectorType;
278
279 // functions from FlatAssemblerBase
280 using WrappedAssembler::bind;
281 using WrappedAssembler::bound;
282 using WrappedAssembler::boundToAffordanceCollection;
283 using WrappedAssembler::boundToDBCOption;
284 using WrappedAssembler::boundToRequirement;
285 using WrappedAssembler::createFullVector;
286
287 using WrappedAssembler::affordanceCollection;
288 using WrappedAssembler::constraintsBelow;
289 using WrappedAssembler::dBCOption;
290 using WrappedAssembler::estimateOfConnectivity;
291 using WrappedAssembler::gridView;
292 using WrappedAssembler::isConstrained;
293 using WrappedAssembler::reducedSize;
294 using WrappedAssembler::requirement;
295 using WrappedAssembler::size;
296
297 // functions from implementations
298 using MatrixAssemblerImpl::bind;
299 using ScalarAssemblerImpl::bind;
300 using VectorAssemblerImpl::bind;
301
302private:
303 using MatrixAssemblerImpl::getMatrixImpl;
304 using MatrixAssemblerImpl::getRawMatrixImpl;
305 using MatrixAssemblerImpl::getReducedMatrixImpl;
306 using ScalarAssemblerImpl::getScalarImpl;
307 using VectorAssemblerImpl::getRawVectorImpl;
308 using VectorAssemblerImpl::getReducedVectorImpl;
309 using VectorAssemblerImpl::getVectorImpl;
310
311public:
312 // functions from interfaces of the new manipulator assembler
313 using MatrixAssemblerInterface::matrix;
314 using ScalarAssemblerInterface::scalar;
315 using VectorAssemblerInterface::vector;
316
318 std::tuple<typename ScalarAssemblerImpl::FunctionType, typename VectorAssemblerImpl::FunctionType,
319 typename MatrixAssemblerImpl::FunctionType>;
320
327 template <typename... Args>
328 requires(not std::is_same_v<std::remove_cvref_t<std::tuple_element_t<0, std::tuple<Args...>>>, AssemblerManipulator>)
329 explicit AssemblerManipulator(Args&&... args)
330 : WrappedAssembler(std::forward<Args>(args)...) {}
331
332private:
333 BASECLASSMEMBERFUNCTION(getScalarImpl, A)
334 BASECLASSMEMBERFUNCTION(getRawVectorImpl, A)
335 BASECLASSMEMBERFUNCTION(getReducedVectorImpl, A)
336 BASECLASSMEMBERFUNCTION(getVectorImpl, A)
337 BASECLASSMEMBERFUNCTION(getRawMatrixImpl, A)
338
339 BASECLASSMEMBERFUNCTION(getReducedMatrixImpl, A)
340
341 BASECLASSMEMBERFUNCTION(getMatrixImpl, A)
342
343 A& base() { return *this; }
344 const A& base() const { return *this; }
345};
346
357template <typename A>
362 if constexpr (scal && vec && mat)
363 return std::make_shared<
364 AssemblerManipulator<std::remove_cvref_t<A>, Impl::AssemblerInterfaceHelper<ScalarAssembler, ScalarManipulator>,
365 Impl::AssemblerInterfaceHelper<VectorAssembler, VectorManipulator>,
366 Impl::AssemblerInterfaceHelper<MatrixAssembler, MatrixManipulator>>>(std::forward<A>(a));
367 else if constexpr (scal && vec)
368 return std::make_shared<
369 AssemblerManipulator<std::remove_cvref_t<A>, Impl::AssemblerInterfaceHelper<ScalarAssembler, ScalarManipulator>,
370 Impl::AssemblerInterfaceHelper<VectorAssembler, VectorManipulator>>>(std::forward<A>(a));
371 else if constexpr (scal)
372 return std::make_shared<AssemblerManipulator<std::remove_cvref_t<A>,
373 Impl::AssemblerInterfaceHelper<ScalarAssembler, ScalarManipulator>>>(
374 std::forward<A>(a));
375}
376} // namespace Ikarus
#define BASECLASSMEMBERFUNCTION(func, A)
Definition: assemblermanipulatorfuser.hh:38
Definition: assemblermanipulatorbuildingblocks.hh:22
auto makeAssemblerManipulator(A &&a)
Creates an AssemblerManipulator instance based on the type of the provided assembler.
Definition: assemblermanipulatorfuser.hh:358
The AssemblerManipulator defines a decorator for the assemblers that helps to manipulate the assemble...
Definition: assemblermanipulatorfuser.hh:36
ScalarAss::template Interface< AssemblerManipulator, A, typename A::ScalarType > ScalarAssemblerInterface
Definition: assemblermanipulatorfuser.hh:63
AssemblerManipulator(Args &&... args)
Constructor that forwards arguments to the base assembler.
Definition: assemblermanipulatorfuser.hh:117
std::tuple< typename ScalarAss::template Implementation< AssemblerManipulator< A, ScalarAss >, A >::FunctionType > CallBackTypes
Definition: assemblermanipulatorfuser.hh:107
friend ScalarAssemblerImpl
Definition: assemblermanipulatorfuser.hh:65
friend ScalarAssemblerInterface
Definition: assemblermanipulatorfuser.hh:66
ScalarAss::template Implementation< AssemblerManipulator, WrappedAssembler > ScalarAssemblerImpl
Definition: assemblermanipulatorfuser.hh:62
A WrappedAssembler
Definition: assemblermanipulatorfuser.hh:59
friend ScalarAssemblerInterface
Definition: assemblermanipulatorfuser.hh:155
friend ScalarAssemblerImpl
Definition: assemblermanipulatorfuser.hh:153
VectorAss::template Interface< AssemblerManipulator, A, typename A::VectorType > VectorAssemblerInterface
Definition: assemblermanipulatorfuser.hh:151
A WrappedAssembler
Definition: assemblermanipulatorfuser.hh:145
VectorAss::template Implementation< AssemblerManipulator, WrappedAssembler > VectorAssemblerImpl
Definition: assemblermanipulatorfuser.hh:149
std::tuple< typename ScalarAssemblerImpl::FunctionType, typename VectorAssemblerImpl::FunctionType > CallBackTypes
Definition: assemblermanipulatorfuser.hh:203
friend VectorAssemblerImpl
Definition: assemblermanipulatorfuser.hh:154
AssemblerManipulator(Args &&... args)
Constructor that forwards arguments to the base assembler.
Definition: assemblermanipulatorfuser.hh:213
ScalarAss::template Interface< AssemblerManipulator, A, typename A::ScalarType > ScalarAssemblerInterface
Definition: assemblermanipulatorfuser.hh:150
ScalarAss::template Implementation< AssemblerManipulator, WrappedAssembler > ScalarAssemblerImpl
Definition: assemblermanipulatorfuser.hh:148
friend VectorAssemblerInterface
Definition: assemblermanipulatorfuser.hh:156
std::tuple< typename ScalarAssemblerImpl::FunctionType, typename VectorAssemblerImpl::FunctionType, typename MatrixAssemblerImpl::FunctionType > CallBackTypes
Definition: assemblermanipulatorfuser.hh:319
ScalarAss::template Interface< AssemblerManipulator, A, typename A::ScalarType > ScalarAssemblerInterface
Definition: assemblermanipulatorfuser.hh:256
MatrixAss::template Implementation< AssemblerManipulator, A > MatrixAssemblerImpl
Definition: assemblermanipulatorfuser.hh:255
friend VectorAssemblerImpl
Definition: assemblermanipulatorfuser.hh:261
A WrappedAssembler
Definition: assemblermanipulatorfuser.hh:250
MatrixAss::template Interface< AssemblerManipulator, A, typename A::MatrixType > MatrixAssemblerInterface
Definition: assemblermanipulatorfuser.hh:258
VectorAss::template Interface< AssemblerManipulator, A, typename A::VectorType > VectorAssemblerInterface
Definition: assemblermanipulatorfuser.hh:257
friend VectorAssemblerInterface
Definition: assemblermanipulatorfuser.hh:265
friend ScalarAssemblerImpl
Definition: assemblermanipulatorfuser.hh:260
friend MatrixAssemblerInterface
Definition: assemblermanipulatorfuser.hh:263
friend MatrixAssemblerImpl
Definition: assemblermanipulatorfuser.hh:262
AssemblerManipulator(Args &&... args)
Constructor that forwards arguments to the base assembler.
Definition: assemblermanipulatorfuser.hh:329
ScalarAss::template Implementation< AssemblerManipulator, A > ScalarAssemblerImpl
Definition: assemblermanipulatorfuser.hh:253
VectorAss::template Implementation< AssemblerManipulator, A > VectorAssemblerImpl
Definition: assemblermanipulatorfuser.hh:254
friend ScalarAssemblerInterface
Definition: assemblermanipulatorfuser.hh:264
Concept representing the requirements for a ScalarFlatAssembler.A type T satisfies ScalarFlatAssemble...
Definition: concepts.hh:531
Concept representing the requirements for a VectorFlatAssembler.A type T satisfies VectorFlatAssemble...
Definition: concepts.hh:545
Concept representing the requirements for a MatrixFlatAssembler.A type T satisfies MatrixFlatAssemble...
Definition: concepts.hh:562