dune-fem 2.8.0
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
6#include <dune/common/fmatrix.hh>
7
11
15
17
20
21
22template< class Operator,
24 >
26: public Dune::Fem::DifferentiableOperator< typename Operator::JacobianOperatorType >
27{
28 typedef typename Operator::DomainFunctionType DomainFunctionType;
29 typedef typename Operator::RangeFunctionType RangeFunctionType;
30 typedef typename Operator::ModelType ModelType;
31 typedef typename Operator::DirichletModelType DirichletModelType;
32 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainDiscreteFunctionSpaceType;
33 typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeDiscreteFunctionSpaceType;
34 typedef typename Operator::JacobianOperatorType JacobianOperatorType;
35 typedef typename RangeDiscreteFunctionSpaceType::RangeType DomainRangeType;
36 typedef Constraints ConstraintsType;
37 typedef typename ConstraintsType::DirichletBlockVector DirichletBlockVector;
38
39 template <class... Args>
40 DirichletWrapperOperator ( Args&... args )
41 : op_( std::forward<Args&>(args)... ) , constraints_( op_.model(), op_.rangeSpace() )
42 {}
43
45 {
46 // set boundary values for solution from model
47 constraints()( u );
48 }
49 void setConstraints( const DomainRangeType &value, DomainFunctionType &u ) const
50 {
51 // set values for solution to a given constant value
52 constraints()( value, u );
53 }
54 template <class GF>
55 void setConstraints( const GF &u, RangeFunctionType &w ) const
56 {
57 // set boundary values for solution from a general grid function
58 constraints()( u, w, ConstraintsType::Operation::set );
59 }
60 template <class GF>
61 void subConstraints( const GF &u, RangeFunctionType &w ) const
62 {
63 // subtract boundary values from solution
64 constraints()( u, w, ConstraintsType::Operation::sub );
65 }
66 const auto &dirichletBlocks() const
67 {
68 return constraints().dirichletBlocks();
69 }
70
72 virtual void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const
73 {
74 op_(u,w);
75 subConstraints( u, w );
76 }
77 template <class GF>
78 auto operator()( const GF &u, RangeFunctionType &w ) const
79 -> Dune::void_t<decltype(std::declval<const Operator&>()(u,w))>
80 {
81 op_(u,w);
82 subConstraints( u, w );
83 }
84
85 void jacobian ( const DomainFunctionType &u, JacobianOperatorType &jOp ) const
86 {
87 op_.jacobian(u,jOp);
88 constraints().applyToOperator( jOp );
89 jOp.flushAssembly();
90 }
91 template <class GridFunctionType>
92 auto jacobian ( const GridFunctionType &u, JacobianOperatorType &jOp ) const
93 -> Dune::void_t<decltype(std::declval<const Operator&>().jacobian(u,jOp))>
94 {
95 op_.jacobian(u,jOp);
96 constraints().applyToOperator( jOp );
97 jOp.flushAssembly();
98 }
99
101 {
102 return op_.domainSpace();
103 }
105 {
106 return op_.rangeSpace();
107 }
108
109 std::size_t gridSizeInterior () const
110 {
111 return op_.gridSizeInterior();
112 }
113
114 template <typename O = Operator>
115 auto setCommunicate ( const bool commuicate )
116 -> Dune::void_t< decltype( std::declval< O >().setCommunicate(true) ) >
117 {
118 op_.setCommunicate(commuicate);
119 }
120
121 template <typename O = Operator>
122 auto setQuadratureOrders(unsigned int interior, unsigned int surface)
123 -> Dune::void_t< decltype( std::declval< O >().setQuadratureOrders(0,0) ) >
124 {
125 return op_.setQuadratureOrders(interior,surface);
126 }
127
128 ModelType &model () const { return op_.model(); }
129 const ConstraintsType &constraints () const { return constraints_; }
130
131private:
132 Operator op_;
133 ConstraintsType constraints_;
134};
135#endif // #ifndef DUNE_FEM_CONSTRAINTSWRAPPER_HH
STL namespace.
abstract differentiable operator
Definition: differentiableoperator.hh:29
Definition: dirichletwrapper.hh:27
void setConstraints(const GF &u, RangeFunctionType &w) const
Definition: dirichletwrapper.hh:55
DirichletWrapperOperator(Args &... args)
Definition: dirichletwrapper.hh:40
auto operator()(const GF &u, RangeFunctionType &w) const -> Dune::void_t< decltype(std::declval< const Operator & >()(u, w))>
Definition: dirichletwrapper.hh:78
auto jacobian(const GridFunctionType &u, JacobianOperatorType &jOp) const -> Dune::void_t< decltype(std::declval< const Operator & >().jacobian(u, jOp))>
Definition: dirichletwrapper.hh:92
Operator::JacobianOperatorType JacobianOperatorType
Definition: dirichletwrapper.hh:34
void subConstraints(const GF &u, RangeFunctionType &w) const
Definition: dirichletwrapper.hh:61
Operator::DirichletModelType DirichletModelType
Definition: dirichletwrapper.hh:31
RangeFunctionType::DiscreteFunctionSpaceType RangeDiscreteFunctionSpaceType
Definition: dirichletwrapper.hh:33
std::size_t gridSizeInterior() const
Definition: dirichletwrapper.hh:109
const RangeDiscreteFunctionSpaceType & rangeSpace() const
Definition: dirichletwrapper.hh:104
void setConstraints(const DomainRangeType &value, DomainFunctionType &u) const
Definition: dirichletwrapper.hh:49
auto setCommunicate(const bool commuicate) -> Dune::void_t< decltype(std::declval< O >().setCommunicate(true)) >
Definition: dirichletwrapper.hh:115
Operator::RangeFunctionType RangeFunctionType
Definition: dirichletwrapper.hh:29
const ConstraintsType & constraints() const
Definition: dirichletwrapper.hh:129
const DomainDiscreteFunctionSpaceType & domainSpace() const
Definition: dirichletwrapper.hh:100
virtual void operator()(const DomainFunctionType &u, RangeFunctionType &w) const
application operator
Definition: dirichletwrapper.hh:72
RangeDiscreteFunctionSpaceType::RangeType DomainRangeType
Definition: dirichletwrapper.hh:35
ConstraintsType::DirichletBlockVector DirichletBlockVector
Definition: dirichletwrapper.hh:37
auto setQuadratureOrders(unsigned int interior, unsigned int surface) -> Dune::void_t< decltype(std::declval< O >().setQuadratureOrders(0, 0)) >
Definition: dirichletwrapper.hh:122
ModelType & model() const
Definition: dirichletwrapper.hh:128
DomainFunctionType::DiscreteFunctionSpaceType DomainDiscreteFunctionSpaceType
Definition: dirichletwrapper.hh:32
Operator::ModelType ModelType
Definition: dirichletwrapper.hh:30
void setConstraints(DomainFunctionType &u) const
Definition: dirichletwrapper.hh:44
Constraints ConstraintsType
Definition: dirichletwrapper.hh:36
void jacobian(const DomainFunctionType &u, JacobianOperatorType &jOp) const
Definition: dirichletwrapper.hh:85
Operator::DomainFunctionType DomainFunctionType
Definition: dirichletwrapper.hh:28
const auto & dirichletBlocks() const
Definition: dirichletwrapper.hh:66