dune-pdelab  2.0.0
parameter.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_MULTISTEP_PARAMETER_HH
4 #define DUNE_PDELAB_MULTISTEP_PARAMETER_HH
5 
6 #include <sstream>
7 #include <string>
8 
9 namespace Dune {
10  namespace PDELab {
11 
14 
16  //
17  // Base class
18  //
19 
21 
25  template<typename value_type_, unsigned order_>
27  {
28  public:
30  typedef value_type_ value_type;
31 
33  static const unsigned order = order_;
34 
36  virtual unsigned steps () const = 0;
37 
39 
53  virtual value_type alpha(int step, int deriv) const = 0;
54 
56  virtual std::string name () const = 0;
57 
60  };
61 
63  //
64  // Central Differences
65  //
66 
68 
71  template<typename value_type>
73  : public MultiStepParameterInterface<value_type, 2>
74  {
75  static const value_type a[3][3];
76 
77  public:
79 
82  virtual unsigned steps () const { return 2; }
83 
85 
95  virtual value_type alpha(int step, int deriv) const {
96  return a[step][deriv];
97  }
98 
100  virtual std::string name () const {
101  return "Central Differences";
102  }
103  };
104 
105  template<typename value_type>
106  const value_type CentralDifferencesParameters<value_type>::a[3][3] = {
107  {0, 0.5, 1},
108  {1, 0, -2},
109  {0, -0.5, 1}
110  };
111 
113  //
114  // Newmark-β scheme
115  //
116 
118 
121  template<typename value_type>
123  : public MultiStepParameterInterface<value_type, 2>
124  {
125  value_type a[3][3];
126  std::string name_;
127 
128  public:
130  a[0][0]=beta; a[0][1]=0.5; a[0][2]=1;
131  a[1][0]=1-2*beta; a[1][1]=0; a[1][2]=-2;
132  a[2][0]=beta; a[2][1]=0.5; a[2][2]=1;
133 
134  std::ostringstream s;
135  s << "Newmark-β (β=" << beta << ")";
136  name_ = s.str();
137  }
138 
140 
143  virtual unsigned steps () const { return 2; }
144 
146 
156  virtual value_type alpha(int step, int deriv) const {
157  return a[step][deriv];
158  }
159 
161  virtual std::string name () const {
162  return name_;
163  }
164  };
165 
167  } // namespace PDELab
168 } // namespace Dune
169 
170 #endif // DUNE_PDELAB_MULTISTEP_PARAMETER_HH
virtual unsigned steps() const
Return number of steps of the method.
Definition: parameter.hh:143
virtual unsigned steps() const =0
Return number of steps of the method.
virtual std::string name() const
Return name of the scheme.
Definition: parameter.hh:100
virtual value_type alpha(int step, int deriv) const
Return alpha coefficients.
Definition: parameter.hh:156
NewmarkBetaParameters(value_type beta)
Definition: parameter.hh:129
virtual value_type alpha(int step, int deriv) const
Return alpha coefficients.
Definition: parameter.hh:95
value_type_ value_type
export type of the parameters
Definition: parameter.hh:30
Parameter class for the Newmark-β scheme.
Definition: parameter.hh:122
virtual std::string name() const =0
Return name of the scheme.
virtual unsigned steps() const
Return number of steps of the method.
Definition: parameter.hh:82
Parameter class for the central differences scheme.
Definition: parameter.hh:72
static const unsigned order
Order of the problems this method is apropriate for.
Definition: parameter.hh:33
Base parameter class for multi step time schemes.
Definition: parameter.hh:26
virtual std::string name() const
Return name of the scheme.
Definition: parameter.hh:161
virtual value_type alpha(int step, int deriv) const =0
Return alpha coefficients.
const std::string s
Definition: function.hh:1103
virtual ~MultiStepParameterInterface()
every abstract base class has a virtual destructor
Definition: parameter.hh:59