1#ifndef DUNE_FEM_DIRICHLETWRAPPER_HH
2#define DUNE_FEM_DIRICHLETWRAPPER_HH
8#include <dune/fem/quadrature/cachingquadrature.hh>
9#include <dune/fem/operator/common/operator.hh>
10#include <dune/fem/operator/common/stencil.hh>
12#include <dune/fem/common/bindguard.hh>
13#include <dune/fem/function/common/localcontribution.hh>
14#include <dune/fem/function/localfunction/const.hh>
16#include <dune/fem/operator/common/differentiableoperator.hh>
18#include <dune/fem/schemes/dirichletconstraints.hh>
19#include <dune/fem/io/parameter.hh>
22template<
class Operator,
23 class Constraints = Dune::DirichletConstraints<
typename Operator::ModelType,
24 typename Operator::RangeDiscreteFunctionSpaceType,
25 std::is_same_v<
typename Operator::DomainFunctionType::DiscreteFunctionSpaceType,
26 typename Operator::RangeFunctionType::DiscreteFunctionSpaceType >
29struct DirichletWrapperOperator
34 typedef typename Operator::ModelType ModelType;
35 typedef typename Operator::DirichletModelType DirichletModelType;
36 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainDiscreteFunctionSpaceType;
37 typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeDiscreteFunctionSpaceType;
39 typedef typename DomainDiscreteFunctionSpaceType::RangeType DomainRangeType;
40 typedef Constraints ConstraintsType;
41 typedef typename ConstraintsType::DirichletBlockVector DirichletBlockVector;
43 template <
class... Args>
44 DirichletWrapperOperator ( Args&... args )
45 : op_(
std::forward<Args&>(args)... ) ,
46 constraints_( op_.model(), op_.rangeSpace() )
49 void setConstraints( DomainFunctionType &u )
const
54 void setConstraints(
const DomainRangeType &value, DomainFunctionType &u )
const
57 constraints()( value, u );
60 void setConstraints(
const GF &u, RangeFunctionType &w )
const
63 constraints()( u, w, ConstraintsType::Operation::set );
66 void subConstraints(
const GF &u, RangeFunctionType &w )
const
69 constraints()( u, w, ConstraintsType::Operation::sub );
71 void subConstraints( RangeFunctionType &w )
const
74 constraints()( w, ConstraintsType::Operation::sub );
77 void addConstraints(
const GF &u, RangeFunctionType &w )
const
80 constraints()( u, w, ConstraintsType::Operation::add );
82 void addConstraints( RangeFunctionType &w )
const
85 constraints()( w, ConstraintsType::Operation::add );
87 const auto &dirichletBlocks()
const
89 return constraints().dirichletBlocks();
93 virtual bool nonlinear ()
const {
return op_.nonlinear(); }
96 virtual void operator() (
const DomainFunctionType &u, RangeFunctionType &w )
const
99 subConstraints( u, w );
102 auto operator()(
const GF &u, RangeFunctionType &w )
const
106 subConstraints( u, w );
109 void jacobian (
const DomainFunctionType &u, JacobianOperatorType &jOp )
const
112 constraints().applyToOperator( jOp );
115 template <
class Gr
idFunctionType>
116 auto jacobian (
const GridFunctionType &u, JacobianOperatorType &jOp )
const
120 constraints().applyToOperator( jOp );
124 const DomainDiscreteFunctionSpaceType& domainSpace()
const
126 return op_.domainSpace();
128 const RangeDiscreteFunctionSpaceType& rangeSpace()
const
130 return op_.rangeSpace();
133 std::size_t gridSizeInterior ()
const
135 return op_.gridSizeInterior();
138 template <
typename O = Operator>
139 auto setCommunicate (
const bool commuicate )
142 op_.setCommunicate(commuicate);
145 template <
typename O = Operator>
146 auto setQuadratureOrders(
unsigned int interior,
unsigned int surface)
149 return op_.setQuadratureOrders(interior,surface);
152 ModelType &model ()
const {
return op_.model(); }
153 const ConstraintsType &constraints ()
const {
return constraints_; }
154 const auto& impl()
const {
return op_.impl(); }
159 ConstraintsType constraints_;
abstract differentiable operator
Definition: differentiableoperator.hh:29
BaseType::RangeFunctionType RangeFunctionType
type of discrete function in the operator's range
Definition: differentiableoperator.hh:40
JacobianOperator JacobianOperatorType
type of linear operator modelling the operator's Jacobian
Definition: differentiableoperator.hh:35
BaseType::DomainFunctionType DomainFunctionType
type of discrete function in the operator's domain
Definition: differentiableoperator.hh:38
virtual void jacobian(const DomainFunctionType &u, JacobianOperatorType &jOp) const =0
obtain linearization
Implements a matrix constructed from a given type representing a field and compile-time given number ...
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
virtual bool nonlinear() const
Definition: operator.hh:64
virtual void operator()(const DomainFunctionType &u, RangeFunctionType &w) const=0
application operator