1#ifndef _DUNE_ACFEM_BLOCKCONSTRAINTSOPERATORINTERFACE_HH_
2#define _DUNE_ACFEM_BLOCKCONSTRAINTSOPERATORINTERFACE_HH_
4#include <dune/fem/operator/common/differentiableoperator.hh>
5#include <dune/fem/misc/bartonnackmaninterface.hh>
7#include "../../common/localobjectstorage.hh"
30 template<
class LocalObjectStorage>
31 class LocalBlockConstraintsWrapper;
35 template<
class GlobalOperator,
class LocalOperator>
38 typedef GlobalOperator GlobalOperatorType;
39 typedef LocalOperator LocalOperatorType;
43 template<
class GlobalOperator,
class LocalOperator>
47 typedef GlobalOperator GlobalObjectType;
48 typedef LocalOperator LocalObjectType;
53 typedef typename LocalObjectStorageType::LocalWrapperType LocalObjectWrapperType;
55 typedef GlobalObjectType GlobalOperatorType;
56 typedef LocalObjectWrapperType LocalOperatorType;
70 template<
class DiscreteFunction,
class Traits>
72 :
public Fem::BartonNackmanInterface<BlockConstraintsOperatorInterface<DiscreteFunction, Traits>,
73 typename Traits::GlobalOperatorType>,
74 public Fem::LinearOperator<DiscreteFunction>
77 typedef Traits TraitsType;
78 typedef typename TraitsType::GlobalOperatorType ImplementationType;
79 typedef Fem::BartonNackmanInterface<ThisType, ImplementationType> BaseType;
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;
113 void operator()(
const DiscreteFunctionType& arg, DiscreteFunctionType& w)
const
131 return asImp().constrain(w);
137 return asImp().zeroConstrain(w);
144 return asImp().size();
152 return asImp().localOperator(entity);
160 return asImp().localOperator();
177 template<
class JacobianOperator,
class Traits>
180 public Fem::DifferentiableOperator<JacobianOperator>,
181 public Fem::AssembledOperator<typename JacobianOperator::DomainFunctionType>
184 typedef Traits TraitsType;
185 typedef typename TraitsType::GlobalOperatorType ImplementationType;
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;
211 void jacobian(
const DiscreteFunctionType& u, JacobianOperatorType& jOp)
const
213 asImp().jacobian(u, jOp);
216 using BaseType::operator();
224 template<
class LocalObjectStorage>
225 class LocalBlockConstraintsWrapper
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;
235 typedef typename LocalObjectType::LocalFunctionType LocalFunctionType;
236 typedef typename LocalObjectType::EntityType EntityType;
240 LocalObjectPtrType localObjectPtr_;
241 LocalObjectType& localObject_;
247 LocalBlockConstraintsWrapper(LocalObjectStorageType& storage)
248 : localObjectPtr_(storage.getObject()),
249 localObject_(*localObjectPtr_)
252 LocalBlockConstraintsWrapper(
const EntityType& entity,
253 LocalObjectStorageType& storage)
254 : localObjectPtr_(storage.getObject()),
255 localObject_(*localObjectPtr_)
257 asImp().init(entity);
261 void operator()(
const LocalFunctionType& u, LocalFunctionType& w)
const
272 template<
class LocalMatrix>
273 void jacobian(
const LocalFunctionType& u , LocalMatrix& jOpLocal)
const
275 asImp().jacobian(u, jOpLocal);
278 void init(
const EntityType& entity)
280 asImp().init(entity);
283 size_t numConstrained()
const
285 return asImp().numConstrained();
288 bool unconstrained()
const
290 return asImp().unconstrained();
293 bool totallyConstrained()
const
295 return asImp().totallyConstrained();
298 void constrain(LocalFunctionType& w)
const
300 asImp().constrain(w);
303 void zeroConstrain(LocalFunctionType& w)
const
305 asImp().zeroConstrain(w);
309 const LocalObjectType&
asImp()
const
314 LocalObjectType&
asImp()
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