dune-fem 2.12-git
Loading...
Searching...
No Matches
dirichletwrapper.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_DIRICHLETWRAPPER_HH
2#define DUNE_FEM_DIRICHLETWRAPPER_HH
3
4#include <cstddef>
5
7
11
15
17
20
21
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 >
27 >
28 >
30: public Dune::Fem::DifferentiableOperator< typename Operator::JacobianOperatorType >
31{
32 typedef typename Operator::DomainFunctionType DomainFunctionType;
33 typedef typename Operator::RangeFunctionType RangeFunctionType;
34 typedef typename Operator::ModelType ModelType;
35 typedef typename Operator::DirichletModelType DirichletModelType;
36 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainDiscreteFunctionSpaceType;
37 typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeDiscreteFunctionSpaceType;
38 typedef typename Operator::JacobianOperatorType JacobianOperatorType;
39 typedef typename DomainDiscreteFunctionSpaceType::RangeType DomainRangeType;
40 typedef Constraints ConstraintsType;
41 typedef typename ConstraintsType::DirichletBlockVector DirichletBlockVector;
42
43 template <class... Args>
44 DirichletWrapperOperator ( Args&... args )
45 : op_( std::forward<Args&>(args)... ) ,
46 constraints_( op_.model(), op_.rangeSpace() )
47 {}
48
50 {
51 // set boundary values for solution from model
52 constraints()( u );
53 }
54 void setConstraints( const DomainRangeType &value, DomainFunctionType &u ) const
55 {
56 // set values for solution to a given constant value
57 constraints()( value, u );
58 }
59 template <class GF>
60 void setConstraints( const GF &u, RangeFunctionType &w ) const
61 {
62 // set boundary values for solution from a general grid function
63 constraints()( u, w, ConstraintsType::Operation::set );
64 }
66 {
67 // set boundary values for solution from a general grid function
68 constraints().applyToOperator(lin);
69 }
70 template <class GF>
71 void subConstraints( const GF &u, RangeFunctionType &w ) const
72 {
73 // subtract boundary values from solution
74 constraints()( u, w, ConstraintsType::Operation::sub );
75 }
77 {
78 // subtract boundary values from solution
79 constraints()( w, ConstraintsType::Operation::sub );
80 }
81 template <class GF>
82 void addConstraints( const GF &u, RangeFunctionType &w ) const
83 {
84 // add boundary values to solution
85 constraints()( u, w, ConstraintsType::Operation::add );
86 }
88 {
89 // add boundary values to solution
90 constraints()( w, ConstraintsType::Operation::add );
91 }
92 const auto &dirichletBlocks() const
93 {
94 return constraints().dirichletBlocks();
95 }
96
97 // return true if operator is based on nonlinear model
98 virtual bool nonlinear () const { return op_.nonlinear(); }
99
101 virtual void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const
102 {
103 op_(u,w);
104 subConstraints( u, w );
105 }
106 template <class GF>
107 auto operator()( const GF &u, RangeFunctionType &w ) const
109 {
110 op_(u,w);
111 subConstraints( u, w );
112 }
113
115 {
116 op_.jacobian(u,jOp);
117 constraints().applyToOperator( jOp );
118 jOp.flushAssembly();
119 }
120 template <class GridFunctionType>
121 auto jacobian ( const GridFunctionType &u, JacobianOperatorType &jOp ) const
123 {
124 op_.jacobian(u,jOp);
125 constraints().applyToOperator( jOp );
126 jOp.flushAssembly();
127 }
128
130 {
131 return op_.domainSpace();
132 }
134 {
135 return op_.rangeSpace();
136 }
137
139 {
140 return op_.gridSizeInterior();
141 }
142
143 template <typename O = Operator>
144 auto setCommunicate ( const bool commuicate )
145 -> Dune::void_t< decltype( std::declval< O >().setCommunicate(true) ) >
146 {
147 op_.setCommunicate(commuicate);
148 }
149
150 template <typename O = Operator>
151 auto setQuadratureOrders(unsigned int interior, unsigned int surface)
152 -> Dune::void_t< decltype( std::declval< O >().setQuadratureOrders(0,0) ) >
153 {
154 return op_.setQuadratureOrders(interior,surface);
155 }
156
157 ModelType &model () const { return op_.model(); }
158 const ConstraintsType &constraints () const { return constraints_; }
159 const auto& impl() const { return op_.impl(); }
160
161
162private:
163 Operator op_;
164 ConstraintsType constraints_;
165};
166#endif // #ifndef DUNE_FEM_CONSTRAINTSWRAPPER_HH
typename Impl::voider< Types... >::type void_t
virtual void operator()()=0
STL namespace.
abstract differentiable operator
Definition differentiableoperator.hh:29
Definition dirichletconstraints.hh:61
Definition dirichletwrapper.hh:31
void setConstraints(const GF &u, RangeFunctionType &w) const
Definition dirichletwrapper.hh:60
DirichletWrapperOperator(Args &... args)
Definition dirichletwrapper.hh:44
auto operator()(const GF &u, RangeFunctionType &w) const -> Dune::void_t< decltype(std::declval< const Operator & >()(u, w))>
Definition dirichletwrapper.hh:107
auto jacobian(const GridFunctionType &u, JacobianOperatorType &jOp) const -> Dune::void_t< decltype(std::declval< const Operator & >().jacobian(u, jOp))>
Definition dirichletwrapper.hh:121
void setConstraints(JacobianOperatorType &lin) const
Definition dirichletwrapper.hh:65
DomainDiscreteFunctionSpaceType::RangeType DomainRangeType
Definition dirichletwrapper.hh:39
Operator::JacobianOperatorType JacobianOperatorType
Definition dirichletwrapper.hh:38
void subConstraints(const GF &u, RangeFunctionType &w) const
Definition dirichletwrapper.hh:71
Operator::DirichletModelType DirichletModelType
Definition dirichletwrapper.hh:35
RangeFunctionType::DiscreteFunctionSpaceType RangeDiscreteFunctionSpaceType
Definition dirichletwrapper.hh:37
void addConstraints(RangeFunctionType &w) const
Definition dirichletwrapper.hh:87
std::size_t gridSizeInterior() const
Definition dirichletwrapper.hh:138
const RangeDiscreteFunctionSpaceType & rangeSpace() const
Definition dirichletwrapper.hh:133
void setConstraints(const DomainRangeType &value, DomainFunctionType &u) const
Definition dirichletwrapper.hh:54
auto setCommunicate(const bool commuicate) -> Dune::void_t< decltype(std::declval< O >().setCommunicate(true)) >
Definition dirichletwrapper.hh:144
Operator::RangeFunctionType RangeFunctionType
Definition dirichletwrapper.hh:33
const ConstraintsType & constraints() const
Definition dirichletwrapper.hh:158
const DomainDiscreteFunctionSpaceType & domainSpace() const
Definition dirichletwrapper.hh:129
const auto & impl() const
Definition dirichletwrapper.hh:159
virtual bool nonlinear() const
Definition dirichletwrapper.hh:98
ConstraintsType::DirichletBlockVector DirichletBlockVector
Definition dirichletwrapper.hh:41
auto setQuadratureOrders(unsigned int interior, unsigned int surface) -> Dune::void_t< decltype(std::declval< O >().setQuadratureOrders(0, 0)) >
Definition dirichletwrapper.hh:151
ModelType & model() const
Definition dirichletwrapper.hh:157
void subConstraints(RangeFunctionType &w) const
Definition dirichletwrapper.hh:76
DomainFunctionType::DiscreteFunctionSpaceType DomainDiscreteFunctionSpaceType
Definition dirichletwrapper.hh:36
void addConstraints(const GF &u, RangeFunctionType &w) const
Definition dirichletwrapper.hh:82
Operator::ModelType ModelType
Definition dirichletwrapper.hh:34
void setConstraints(DomainFunctionType &u) const
Definition dirichletwrapper.hh:49
Constraints ConstraintsType
Definition dirichletwrapper.hh:40
void jacobian(const DomainFunctionType &u, JacobianOperatorType &jOp) const
Definition dirichletwrapper.hh:114
Operator::DomainFunctionType DomainFunctionType
Definition dirichletwrapper.hh:32
const auto & dirichletBlocks() const
Definition dirichletwrapper.hh:92
T is_same_v