DUNE-ACFEM (2.5.1)

blockconstraintsoperator.hh
1#ifndef _DUNE_ACFEM_BLOCKCONSTRAINTSOPERATORINTERFACE_HH_
2#define _DUNE_ACFEM_BLOCKCONSTRAINTSOPERATORINTERFACE_HH_
3
4#include <dune/fem/operator/common/differentiableoperator.hh>
5#include <dune/fem/misc/bartonnackmaninterface.hh>
6
7#include "../../common/localobjectstorage.hh"
8
9namespace Dune {
10
11 namespace ACFem {
12
29 // Forward
30 template<class LocalObjectStorage>
31 class LocalBlockConstraintsWrapper;
32
35 template<class GlobalOperator, class LocalOperator>
37 {
38 typedef GlobalOperator GlobalOperatorType;
39 typedef LocalOperator LocalOperatorType;
40 };
41
43 template<class GlobalOperator, class LocalOperator>
45 : public BlockConstraintsDefaultTraits<GlobalOperator, LocalOperator>
46 {
47 typedef GlobalOperator GlobalObjectType;
48 typedef LocalOperator LocalObjectType;
50 typedef
53 typedef typename LocalObjectStorageType::LocalWrapperType LocalObjectWrapperType;
54
55 typedef GlobalObjectType GlobalOperatorType;
56 typedef LocalObjectWrapperType LocalOperatorType;
57 };
58
70 template<class DiscreteFunction, class Traits>
72 : public Fem::BartonNackmanInterface<BlockConstraintsOperatorInterface<DiscreteFunction, Traits>,
73 typename Traits::GlobalOperatorType>,
74 public Fem::LinearOperator<DiscreteFunction>
75 {
77 typedef Traits TraitsType;
78 typedef typename TraitsType::GlobalOperatorType ImplementationType;
79 typedef Fem::BartonNackmanInterface<ThisType, ImplementationType> BaseType;
80 protected:
81 using BaseType::asImp;
82 protected:
85 ThisType& operator=(const ThisType& Other) {}
86 public:
87 typedef DiscreteFunction DiscreteFunctionType;
88 typedef typename TraitsType::LocalOperatorType LocalOperatorType;
89 typedef typename DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
90 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
91 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
92
98 void rebuild() const {
99 asImp().rebuild();
100 }
101
113 void operator()(const DiscreteFunctionType& arg, DiscreteFunctionType& w) const
114 {
115 asImp()(arg, w);
116 }
117
129 void constrain(DiscreteFunctionType& w) const
130 {
131 return asImp().constrain(w);
132 }
133
135 void zeroConstrain(DiscreteFunctionType& w) const
136 {
137 return asImp().zeroConstrain(w);
138 }
139
142 size_t size() const
143 {
144 return asImp().size();
145 }
146
150 LocalOperatorType localOperator(const EntityType& entity) const
151 {
152 return asImp().localOperator(entity);
153 }
154
158 LocalOperatorType localOperator() const
159 {
160 return asImp().localOperator();
161 }
162
163 };
164
177 template<class JacobianOperator, class Traits>
179 : public BlockConstraintsOperatorInterface<typename JacobianOperator::RangeFunctionType, Traits>,
180 public Fem::DifferentiableOperator<JacobianOperator>,
181 public Fem::AssembledOperator<typename JacobianOperator::DomainFunctionType>
182 {
184 typedef Traits TraitsType;
185 typedef typename TraitsType::GlobalOperatorType ImplementationType;
186 typedef
188 BaseType;
189 protected:
190 using BaseType::asImp;
191 protected:
194 ThisType& operator=(const ThisType& Other) {}
195 public:
196 typedef JacobianOperator JacobianOperatorType;
197 typedef typename BaseType::DiscreteFunctionType DiscreteFunctionType;
198 typedef typename TraitsType::LocalOperatorType LocalOperatorType;
199 typedef typename DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
200 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
201 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
202
203 // DifferentiableOperator interface
204
211 void jacobian(const DiscreteFunctionType& u, JacobianOperatorType& jOp) const
212 {
213 asImp().jacobian(u, jOp);
214 }
215
216 using BaseType::operator();
222 };
223
224 template<class LocalObjectStorage>
225 class LocalBlockConstraintsWrapper
226 {
227 protected:
228 typedef LocalObjectStorage LocalObjectStorageType;
229 typedef typename LocalObjectStorageType::LocalObjectType LocalObjectType;
230 typedef typename LocalObjectStorageType::GlobalObjectType GlobalObjectType;
231 typedef typename LocalObjectStorageType::PointerType LocalObjectPtrType;
232 friend GlobalObjectType;
233
234 public:
235 typedef typename LocalObjectType::LocalFunctionType LocalFunctionType;
236 typedef typename LocalObjectType::EntityType EntityType;
237
238 protected:
239
240 LocalObjectPtrType localObjectPtr_;
241 LocalObjectType& localObject_;
242
243 public:
244 // public is questionable, but makes things easier for inheriting from
245 // default implementations.
246
247 LocalBlockConstraintsWrapper(LocalObjectStorageType& storage)
248 : localObjectPtr_(storage.getObject()),
249 localObject_(*localObjectPtr_)
250 {}
251
252 LocalBlockConstraintsWrapper(const EntityType& entity,
253 LocalObjectStorageType& storage)
254 : localObjectPtr_(storage.getObject()),
255 localObject_(*localObjectPtr_)
256 {
257 asImp().init(entity);
258 }
259
260 public:
261 void operator()(const LocalFunctionType& u, LocalFunctionType& w) const
262 {
263 asImp()(u, w);
264 }
265
272 template<class LocalMatrix>
273 void jacobian(const LocalFunctionType& u /* unused */, LocalMatrix& jOpLocal) const
274 {
275 asImp().jacobian(u, jOpLocal);
276 }
277
278 void init(const EntityType& entity)
279 {
280 asImp().init(entity);
281 }
282
283 size_t numConstrained() const
284 {
285 return asImp().numConstrained();
286 }
287
288 bool unconstrained() const
289 {
290 return asImp().unconstrained();
291 }
292
293 bool totallyConstrained() const
294 {
295 return asImp().totallyConstrained();
296 }
297
298 void constrain(LocalFunctionType& w) const
299 {
300 asImp().constrain(w);
301 }
302
303 void zeroConstrain(LocalFunctionType& w) const
304 {
305 asImp().zeroConstrain(w);
306 }
307
308 protected:
309 const LocalObjectType& asImp() const
310 {
311 return localObject_;
312 }
313
314 LocalObjectType& asImp()
315 {
316 return localObject_;
317 }
318 };
319
321
323
324 } // ACFem::
325
326} // Dune::
327
328#endif // _DUNE_ACFEM_BLOCKCONSTRAINTSOPERATORINTERFACE_HH_
Interface class for a block-constraints-operator.
Definition: blockconstraintsoperator.hh:75
LocalOperatorType localOperator(const EntityType &entity) const
Generate the local version of this operator from the given entitiy.
Definition: blockconstraintsoperator.hh:150
LocalOperatorType localOperator() const
Generate the local version of this operator, must later be bound to an entity by calling its init() m...
Definition: blockconstraintsoperator.hh:158
size_t size() const
Return the number of constrainted block-DoFs.
Definition: blockconstraintsoperator.hh:142
void rebuild() const
An update method which has to be called initially or after mesh-adaptation, or for time-dependent con...
Definition: blockconstraintsoperator.hh:98
void zeroConstrain(DiscreteFunctionType &w) const
Unconditionally set the values of all masked DoFs to zero.
Definition: blockconstraintsoperator.hh:135
void operator()(const DiscreteFunctionType &arg, DiscreteFunctionType &w) const
Apply the operator to the given argument.
Definition: blockconstraintsoperator.hh:113
void constrain(DiscreteFunctionType &w) const
The solution operator; unconditionally install the given constraints into the argument.
Definition: blockconstraintsoperator.hh:129
Interface class for a differentiable block-constraints-operator.
Definition: blockconstraintsoperator.hh:182
void jacobian(const DiscreteFunctionType &u, JacobianOperatorType &jOp) const
The Jacobian of the operator.
Definition: blockconstraintsoperator.hh:211
Define a factory for a "local object" which has a constructor which accepts a single argument,...
Definition: localobjectstorage.hh:21
Local object stack which (hopefully) efficiently caches local objects.
Definition: localobjectstorage.hh:50
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
Default traits for BlockConstraints which LocalObjectStack usage.
Definition: blockconstraintsoperator.hh:46
We need the type of the implementation and the local operator type.
Definition: blockconstraintsoperator.hh:37
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)