dune-fem  2.4.1-rc
dghelmholtz.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
2 #define DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
3 
6 
7 
8 namespace Dune
9 {
10 
11  namespace Fem
12  {
13 
14  // DGHelmholtzJacobianOperator
15  // ---------------------------
16 
17  template< class JacobianOp >
19  : public Operator< typename JacobianOp::DomainFunctionType, typename JacobianOp::RangeFunctionType >
20  {
23 
24  template< class > friend class DGHelmholtzOperator;
25 
26  public:
29 
30  typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType;
31  typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType;
32 
33  DGHelmholtzJacobianOperator ( const std::string &name, const DomainFunctionSpaceType &dSpace, const RangeFunctionSpaceType &rSpace )
34  : jacobianOp_( name, dSpace, rSpace ),
35  lambda_( 0 ),
36  wTmp_( "DGHelmholtzJacobianOperator temporary", rSpace )
37  {}
38 
39  void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const
40  {
41  w.assign( u );
42  if( lambda() != 0.0 )
43  {
44  jacobianOp_( u, wTmp_ );
45  w.axpy( -lambda(), wTmp_ );
46  }
47  }
48 
49  const double &lambda () const { return lambda_; }
50  void setLambda ( double lambda ) { lambda_ = lambda; }
51 
52  protected:
53  JacobianOp jacobianOp_;
54  double lambda_;
55  mutable RangeFunctionType wTmp_;
56  };
57 
58 
59 
60  // DGHelmholtzOperator
61  // -------------------
62 
63  template< class SpaceOperator >
65  : public DifferentiableOperator< DGHelmholtzJacobianOperator< typename SpaceOperator::JacobianOperatorType > >
66  {
69 
70  public:
71  typedef SpaceOperator SpaceOperatorType;
72 
75 
77 
78  typedef typename DomainFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
79 
80  explicit DGHelmholtzOperator ( SpaceOperatorType &spaceOp )
81  : spaceOp_( spaceOp ),
82  lambda_( 0 ),
83  wTmp_( "DGHelmholtzOperator temporary", space() )
84  {}
85 
86  void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const
87  {
88  w.assign( u );
89  if( lambda() != 0.0 )
90  {
91  spaceOperator()( u, wTmp_ );
92  w.axpy( -lambda(), wTmp_ );
93  }
94  }
95 
96  void jacobian ( const DomainFunctionType &u, JacobianOperatorType &jOp ) const
97  {
98  spaceOperator().jacobian( u, jOp.jacobianOp_ );
99  jOp.setLambda( lambda() );
100  }
101 
102  const double &lambda () const { return lambda_; }
103  void setLambda ( double lambda ) { lambda_ = lambda; }
104 
105  void setTime ( double time ) { spaceOperator().setTime( time ); }
106 
107  const DiscreteFunctionSpaceType &space () const { return spaceOperator().space(); }
108 
109  void initializeTimeStepSize ( const DomainFunctionType &u ) const
110  {
111  spaceOperator()( u, wTmp_ );
112  }
113 
114  double timeStepEstimate () const { return spaceOperator().timeStepEstimate(); }
115 
116  const SpaceOperatorType &spaceOperator () const { return spaceOp_; }
117  SpaceOperatorType &spaceOperator () { return spaceOp_; }
118 
119  protected:
120  SpaceOperator &spaceOp_;
121  double lambda_;
122  mutable RangeFunctionType wTmp_;
123  };
124 
125  } // namespace Fem
126 
127 } // namespace Dune
128 
129 #endif // #ifndef DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
BaseType::RangeFunctionType RangeFunctionType
Definition: dghelmholtz.hh:74
RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType
Definition: dghelmholtz.hh:31
RangeFunction RangeFunctionType
type of discrete function in the operator&#39;s range
Definition: operator.hh:30
BaseType::DomainFunctionType DomainFunctionType
type of discrete function in the operator&#39;s domain
Definition: differentiableoperator.hh:38
void operator()(const DomainFunctionType &u, RangeFunctionType &w) const
Definition: dghelmholtz.hh:39
void setTime(double time)
Definition: dghelmholtz.hh:105
const SpaceOperatorType & spaceOperator() const
Definition: dghelmholtz.hh:116
BaseType::DomainFunctionType DomainFunctionType
Definition: dghelmholtz.hh:27
DGHelmholtzJacobianOperator(const std::string &name, const DomainFunctionSpaceType &dSpace, const RangeFunctionSpaceType &rSpace)
Definition: dghelmholtz.hh:33
const DiscreteFunctionSpaceType & space() const
Definition: dghelmholtz.hh:107
double timeStepEstimate() const
Definition: dghelmholtz.hh:114
DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType
Definition: dghelmholtz.hh:30
SpaceOperator & spaceOp_
Definition: dghelmholtz.hh:120
abstract operator
Definition: operator.hh:25
void setLambda(double lambda)
Definition: dghelmholtz.hh:50
Definition: coordinate.hh:4
Definition: dghelmholtz.hh:64
DGHelmholtzOperator(SpaceOperatorType &spaceOp)
Definition: dghelmholtz.hh:80
double lambda_
Definition: dghelmholtz.hh:54
RangeFunctionType wTmp_
Definition: dghelmholtz.hh:122
const double & lambda() const
Definition: dghelmholtz.hh:102
const double & lambda() const
Definition: dghelmholtz.hh:49
BaseType::RangeFunctionType RangeFunctionType
type of discrete function in the operator&#39;s range
Definition: differentiableoperator.hh:40
double lambda_
Definition: dghelmholtz.hh:121
SpaceOperator SpaceOperatorType
Definition: dghelmholtz.hh:71
RangeFunctionType wTmp_
Definition: dghelmholtz.hh:55
void setLambda(double lambda)
Definition: dghelmholtz.hh:103
Definition: dghelmholtz.hh:18
BaseType::JacobianOperatorType JacobianOperatorType
Definition: dghelmholtz.hh:76
void jacobian(const DomainFunctionType &u, JacobianOperatorType &jOp) const
Definition: dghelmholtz.hh:96
abstract differentiable operator
Definition: differentiableoperator.hh:26
BaseType::DomainFunctionType DomainFunctionType
Definition: dghelmholtz.hh:73
JacobianOperator JacobianOperatorType
type of linear operator modelling the operator&#39;s Jacobian
Definition: differentiableoperator.hh:35
JacobianOp jacobianOp_
Definition: dghelmholtz.hh:53
BaseType::RangeFunctionType RangeFunctionType
Definition: dghelmholtz.hh:28
SpaceOperatorType & spaceOperator()
Definition: dghelmholtz.hh:117
void initializeTimeStepSize(const DomainFunctionType &u) const
Definition: dghelmholtz.hh:109
DomainFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: dghelmholtz.hh:78
DomainFunction DomainFunctionType
type of discrete function in the operator&#39;s domain
Definition: operator.hh:28