DUNE-FEM (unstable)

dghelmholtz.hh
1#ifndef DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
2#define DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
3
4#include <dune/fem/operator/common/operator.hh>
5#include <dune/fem/operator/common/differentiableoperator.hh>
6
7#include <dune/fem/solver/parameter.hh>
8
9
10namespace Dune
11{
12
13 namespace Fem
14 {
15
16 // DGHelmholtzJacobianOperator
17 // ---------------------------
18
19 template< class JacobianOp >
20 class DGHelmholtzJacobianOperator
21 : public JacobianOp
22 {
23 typedef JacobianOp BaseType;
24
25 public:
26 typedef typename BaseType::DomainFunctionType DomainFunctionType;
27 typedef typename BaseType::RangeFunctionType RangeFunctionType;
28
29 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType;
30 typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType;
31
32 DGHelmholtzJacobianOperator ( const std::string &name, const DomainFunctionSpaceType &dSpace, const RangeFunctionSpaceType &rSpace,
33 const SolverParameter& param = SolverParameter() )
34 : BaseType( 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 BaseType::operator()( 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 double lambda_;
54 mutable RangeFunctionType wTmp_;
55 };
56
57
58
59 // DGHelmholtzOperator
60 // -------------------
61
62 template< class SpaceOperator >
63 class DGHelmholtzOperator
64 : public DifferentiableOperator< DGHelmholtzJacobianOperator< typename SpaceOperator::JacobianOperatorType > >
65 {
66 typedef DGHelmholtzOperator< SpaceOperator > ThisType;
67 typedef DifferentiableOperator< DGHelmholtzJacobianOperator< typename SpaceOperator::JacobianOperatorType > > BaseType;
68
69 public:
70 typedef SpaceOperator SpaceOperatorType;
71
72 typedef typename BaseType::DomainFunctionType DomainFunctionType;
73 typedef typename BaseType::RangeFunctionType RangeFunctionType;
74
75 typedef typename BaseType::JacobianOperatorType JacobianOperatorType;
76
77 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
78
79 explicit DGHelmholtzOperator ( SpaceOperatorType &spaceOp )
80 : spaceOp_( spaceOp ),
81 lambda_( 0 ),
82 wTmp_( "DGHelmholtz::tmp", space() )
83 {}
84
85 void operator() ( const DomainFunctionType &u, RangeFunctionType &w ) const
86 {
87 w.assign( u );
88 if( lambda() != 0.0 )
89 {
90 spaceOperator()( u, wTmp_ );
91 w.axpy( -lambda(), wTmp_ );
92 }
93 }
94
95 void jacobian ( const DomainFunctionType &u, JacobianOperatorType &jOp ) const
96 {
97 spaceOperator().jacobian( u, jOp );
98 jOp.setLambda( lambda() );
99 }
100
101 const double &lambda () const { return lambda_; }
102 void setLambda ( double lambda ) { lambda_ = lambda; }
103
104 void setTime ( double time ) { spaceOperator().setTime( time ); }
105
106 const DiscreteFunctionSpaceType &space () const { return spaceOperator().space(); }
107
108 void initializeTimeStepSize ( const DomainFunctionType &u ) const
109 {
110 spaceOperator()( u, wTmp_ );
111 }
112
113 double timeStepEstimate () const { return spaceOperator().timeStepEstimate(); }
114
115 const SpaceOperatorType &spaceOperator () const { return spaceOp_; }
116 SpaceOperatorType &spaceOperator () { return spaceOp_; }
117
118 protected:
119 SpaceOperator &spaceOp_;
120 double lambda_;
121 mutable RangeFunctionType wTmp_;
122 };
123
124 } // namespace Fem
125
126} // namespace Dune
127
128#endif // #ifndef DUNE_FEM_OPERATOR_DGHELMHOLTZ_HH
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
virtual void jacobian(const DomainFunctionType &u, JacobianOperatorType &jOp) const=0
obtain linearization
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)