dune-fem  2.4.1-rc
insertoperator.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_PASS_INSERTOPERATOR_HH
2 #define DUNE_FEM_PASS_INSERTOPERATOR_HH
3 
4 #include <string>
5 #include <tuple>
6 #include <type_traits>
7 
8 #include <dune/common/tupleutility.hh>
9 
12 
13 namespace Dune
14 {
15 
16  namespace Fem
17  {
18 
19 #ifndef DOXYGEN
20 
21  namespace __InsertOperatorPass
22  {
23 
24  // isOperator
25  // ----------
26 
27  template< class DomainFunction, class RangeFunction >
28  std::true_type __isOperator ( const Dune::Fem::Operator< DomainFunction, RangeFunction > & );
29 
30  std::false_type __isOperator ( ... );
31 
32  template< class Operator >
33  using isOperator = decltype( __isOperator( std::declval< Operator >() ) );
34 
35 
36 
37  template< class Operator >
38  struct DiscreteModel
39  {
40  struct Traits
41  {
42  typedef typename Operator::RangeFunctionType DestinationType;
43  };
44  };
45 
46  } // namespace __InsertOperatorPass
47 
48 #endif // #ifndef DOXYGEN
49 
50 
51 
52  // InsertOperatorPass
53  // ------------------
54 
66  template< class Operator, class PreviousPass, int id >
67  class InsertOperatorPass final
68  : public Dune::Fem::Pass< __InsertOperatorPass::DiscreteModel< Operator >, PreviousPass, id >
69  {
71 
72  static_assert( __InsertOperatorPass::isOperator< Operator >::value, "Template parameter Operator is not derived from Dune::Fem::Operator" );
73 
74  public:
76  typedef Operator OperatorType;
77 
80 
85 
87  using BaseType::passNumber;
88 
89  protected:
90  using BaseType::deleteHandler_;
91  using BaseType::destination_;
92 
93  public:
104  InsertOperatorPass ( const typename OperatorType::RangeFunctionType::DiscreteFunctionSpaceType &space,
105  const OperatorType &op, PreviousPassType &pass )
106  : BaseType( pass ),
107  space_( space ),
108  operator_( op )
109  {}
110 
113 #ifndef DOXYGEN
114 
115  ~InsertOperatorPass () {}
116 
117 #endif // #ifndef DOXYGEN
118 
125  {
126  if( destination_ )
127  return;
128  destination_ = new DestinationType( "stabilization_pass_" + std::to_string( passNumber() ), space() );
129  deleteHandler_ = &(BaseType::DeleteHandlerType::instance());
130  }
131 
133  void printTexInfo ( std::ostream & ) const
134  {
135  DUNE_THROW( NotImplemented, "Method printTexInfo() not implemented" );
136  }
137 
139  void compute ( const TotalArgumentType &arg, DestinationType &dest ) const
140  {
141  apply( arg, dest );
142  }
143 
151  const typename OperatorType::RangeFunctionType::DiscreteFunctionSpaceType &space () const
152  {
153  return space_;
154  }
155 
158  protected:
159  void apply ( const TotalArgumentType &u, DestinationType &w ) const
160  {
161  // get argument
162  typedef std::integral_constant< int, PreviousPassType::passId > Key;
163  const std::size_t position = Dune::FirstTypeIndex< typename PreviousPassType::PassIds, Key >::type::value;
164  const typename OperatorType::DomainFunctionType &v = *std::get< position >( u );
165 
166  // apply operator
167  operator_( v, w );
168  }
169 
170  private:
171  const typename OperatorType::RangeFunctionType::DiscreteFunctionSpaceType &space_;
172  const OperatorType &operator_;
173  };
174 
175  } // namespace Fem
176 
177 } // namespace Dune
178 
179 #endif // #ifndef DUNE_FEM_PASS_INSERTOPERATOR_HH
RangeFunction RangeFunctionType
type of discrete function in the operator&#39;s range
Definition: operator.hh:30
const OperatorType::RangeFunctionType::DiscreteFunctionSpaceType & space() const
return discrete function space
Definition: insertoperator.hh:151
Operator OperatorType
export operator type
Definition: insertoperator.hh:72
void apply(const TotalArgumentType &u, DestinationType &w) const
Definition: insertoperator.hh:159
include a Dune::Fem::Operator into a pass
Definition: insertoperator.hh:67
InsertOperatorPass(const typename OperatorType::RangeFunctionType::DiscreteFunctionSpaceType &space, const OperatorType &op, PreviousPassType &pass)
constructor
Definition: insertoperator.hh:104
abstract operator
Definition: operator.hh:25
void compute(const TotalArgumentType &arg, DestinationType &dest) const
Definition: insertoperator.hh:139
PreviousPassImp PreviousPassType
Type of the preceding pass.
Definition: common/pass.hh:150
Definition: coordinate.hh:4
BaseType::TotalArgumentType TotalArgumentType
Definition: insertoperator.hh:82
BaseType::PreviousPassType PreviousPassType
Type of the preceding pass.
Definition: insertoperator.hh:79
void printTexInfo(std::ostream &) const
printTex info of operator
Definition: insertoperator.hh:133
Base class for specific pass implementations.
Definition: local.hh:19
DiscreteModelImp::Traits::DestinationType DestinationType
Definition: common/pass.hh:161
BaseType::DestinationType DestinationType
Definition: insertoperator.hh:84
PushFrontTuple< LocalArgumentType, const GlobalArgumentType * >::type TotalArgumentType
Definition: common/pass.hh:177
void allocateLocalMemory()
Definition: insertoperator.hh:124
DomainFunction DomainFunctionType
type of discrete function in the operator&#39;s domain
Definition: operator.hh:28