dune-fem  2.6-git
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 JacobianOp
20  {
21  typedef JacobianOp BaseType;
22 
23  public:
24  typedef typename BaseType::DomainFunctionType DomainFunctionType;
25  typedef typename BaseType::RangeFunctionType RangeFunctionType;
26 
27  typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType;
28  typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType;
29 
30  DGHelmholtzJacobianOperator ( const std::string &name, const DomainFunctionSpaceType &dSpace, const RangeFunctionSpaceType &rSpace )
31  : BaseType( name, dSpace, rSpace ),
32  lambda_( 0 ),
33  wTmp_( "DGHelmholtzJacobianOperator temporary", rSpace )
34  {}
35 
37  {
38  w.assign( u );
39  if( lambda() != 0.0 )
40  {
41  BaseType::operator()( u, wTmp_ );
42  w.axpy( -lambda(), wTmp_ );
43  }
44  }
45 
46  const double &lambda () const { return lambda_; }
47  void setLambda ( double lambda ) { lambda_ = lambda; }
48 
49  protected:
50  double lambda_;
52  };
53 
54 
55 
56  // DGHelmholtzOperator
57  // -------------------
58 
59  template< class SpaceOperator >
61  : public DifferentiableOperator< DGHelmholtzJacobianOperator< typename SpaceOperator::JacobianOperatorType > >
62  {
65 
66  public:
67  typedef SpaceOperator SpaceOperatorType;
68 
71 
73 
74  typedef typename DomainFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
75 
76  explicit DGHelmholtzOperator ( SpaceOperatorType &spaceOp )
77  : spaceOp_( spaceOp ),
78  lambda_( 0 ),
79  wTmp_( "DGHelmholtzOperator temporary", space() )
80  {}
81 
83  {
84  w.assign( u );
85  if( lambda() != 0.0 )
86  {
87  spaceOperator()( u, wTmp_ );
88  w.axpy( -lambda(), wTmp_ );
89  }
90  }
91 
92  void jacobian ( const DomainFunctionType &u, JacobianOperatorType &jOp ) const
93  {
94  spaceOperator().jacobian( u, jOp );
95  jOp.setLambda( lambda() );
96  }
97 
98  const double &lambda () const { return lambda_; }
99  void setLambda ( double lambda ) { lambda_ = lambda; }
100 
101  void setTime ( double time ) { spaceOperator().setTime( time ); }
102 
103  const DiscreteFunctionSpaceType &space () const { return spaceOperator().space(); }
104 
106  {
107  spaceOperator()( u, wTmp_ );
108  }
109 
110  double timeStepEstimate () const { return spaceOperator().timeStepEstimate(); }
111 
112  const SpaceOperatorType &spaceOperator () const { return spaceOp_; }
114 
115  protected:
116  SpaceOperator &spaceOp_;
117  double lambda_;
119  };
120 
121  } // namespace Fem
122 
123 } // namespace Dune
124 
125 #endif // #ifndef DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
Definition: bindguard.hh:11
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
Definition: dghelmholtz.hh:20
BaseType::DomainFunctionType DomainFunctionType
Definition: dghelmholtz.hh:24
DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType
Definition: dghelmholtz.hh:27
BaseType::RangeFunctionType RangeFunctionType
Definition: dghelmholtz.hh:25
void operator()(const DomainFunctionType &u, RangeFunctionType &w) const
Definition: dghelmholtz.hh:36
DGHelmholtzJacobianOperator(const std::string &name, const DomainFunctionSpaceType &dSpace, const RangeFunctionSpaceType &rSpace)
Definition: dghelmholtz.hh:30
double lambda_
Definition: dghelmholtz.hh:50
void setLambda(double lambda)
Definition: dghelmholtz.hh:47
RangeFunctionType wTmp_
Definition: dghelmholtz.hh:51
RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType
Definition: dghelmholtz.hh:28
const double & lambda() const
Definition: dghelmholtz.hh:46
Definition: dghelmholtz.hh:62
SpaceOperatorType & spaceOperator()
Definition: dghelmholtz.hh:113
void operator()(const DomainFunctionType &u, RangeFunctionType &w) const
Definition: dghelmholtz.hh:82
void setLambda(double lambda)
Definition: dghelmholtz.hh:99
void setTime(double time)
Definition: dghelmholtz.hh:101
RangeFunctionType wTmp_
Definition: dghelmholtz.hh:118
SpaceOperator SpaceOperatorType
Definition: dghelmholtz.hh:67
const double & lambda() const
Definition: dghelmholtz.hh:98
void initializeTimeStepSize(const DomainFunctionType &u) const
Definition: dghelmholtz.hh:105
double timeStepEstimate() const
Definition: dghelmholtz.hh:110
BaseType::JacobianOperatorType JacobianOperatorType
Definition: dghelmholtz.hh:72
const SpaceOperatorType & spaceOperator() const
Definition: dghelmholtz.hh:112
DGHelmholtzOperator(SpaceOperatorType &spaceOp)
Definition: dghelmholtz.hh:76
double lambda_
Definition: dghelmholtz.hh:117
const DiscreteFunctionSpaceType & space() const
Definition: dghelmholtz.hh:103
DomainFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: dghelmholtz.hh:74
BaseType::DomainFunctionType DomainFunctionType
Definition: dghelmholtz.hh:69
void jacobian(const DomainFunctionType &u, JacobianOperatorType &jOp) const
Definition: dghelmholtz.hh:92
SpaceOperator & spaceOp_
Definition: dghelmholtz.hh:116
BaseType::RangeFunctionType RangeFunctionType
Definition: dghelmholtz.hh:70