explicit_timesteppers.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 // Header functions for classes that represent explicit time-stepping schemes
27 
28 // Include guards to prevent multiple inclusion of this header
29 #ifndef OOMPH_EXPLICIT_TIMESTEPPERS
30 #define OOMPH_EXPLICIT_TIMESTEPPERS
31 
32 // Config header generated by autoconfig
33 #ifdef HAVE_CONFIG_H
34 #include <oomph-lib-config.h>
35 #endif
36 
37 
38 #ifdef OOMPH_HAS_MPI
39 #include "mpi.h"
40 #endif
41 
42 #include "Vector.h"
43 #include "double_vector.h"
44 #include "oomph_utilities.h"
45 
46 namespace oomph
47 {
48  class Time;
49 
50  //===============================================================
63  //===============================================================
65  {
66  // Dummy double value for time
67  static double Dummy_time_value;
68 
69  public:
72 
75 
77  void operator=(const ExplicitTimeSteppableObject&) = delete;
78 
81 
84  virtual void get_dvaluesdt(DoubleVector& minv_res);
85 
87  virtual void get_dofs(DoubleVector& dofs) const;
88 
90  virtual void get_dofs(const unsigned& t, DoubleVector& dofs) const;
91 
93  virtual void set_dofs(const DoubleVector& dofs);
94 
96  virtual void add_to_dofs(const double& lambda,
97  const DoubleVector& increment_dofs);
98 
103 
109 
113 
117 
120  virtual double& time();
121 
124  virtual Time* time_pt() const;
125  };
126 
127 
128  //=====================================================================
130  //=====================================================================
132  {
133  protected:
137 
138  public:
141 
144 
146  void operator=(const ExplicitTimeStepper&) = delete;
147 
149  virtual ~ExplicitTimeStepper() {}
150 
152  // referenced by object_pt by an amount dt
153  virtual void timestep(ExplicitTimeSteppableObject* const& object_pt,
154  const double& dt) = 0;
155  };
156 
157 
160  //============================================================
161  class Euler : public ExplicitTimeStepper
162  {
163  public:
166  {
167  Type = "Euler";
168  }
169 
171  Euler(const Euler&) = delete;
172 
174  void operator=(const Euler&) = delete;
175 
178  void timestep(ExplicitTimeSteppableObject* const& object_pt,
179  const double& dt);
180  };
181 
184  //============================================================
185  template<unsigned ORDER>
187  {
188  public:
191  {
192  Type = "RungeKutta";
193  }
194 
196  RungeKutta(const RungeKutta&) = delete;
197 
199  void operator=(const RungeKutta&) = delete;
200 
202  // reference by object_pt by an amount dt
203  void timestep(ExplicitTimeSteppableObject* const& object_pt,
204  const double& dt);
205  };
206 
207 
210  //============================================================
211  template<unsigned ORDER>
213  {
214  // Storage for the coefficients
216 
217  public:
220 
223 
225  void operator=(const LowStorageRungeKutta&) = delete;
226 
228  void timestep(ExplicitTimeSteppableObject* const& object_pt,
229  const double& dt);
230  };
231 
232 
238  //============================================================
239  class EBDF3 : public ExplicitTimeStepper
240  {
241  double Yn_weight;
242  double Ynm1_weight;
243  double Ynm2_weight;
244  double Fn_weight;
245 
246  public:
248  EBDF3() {}
249 
251  EBDF3(const EBDF3&) = delete;
252 
254  void operator=(const EBDF3&) = delete;
255 
256  void set_weights(const double& dtn,
257  const double& dtnm1,
258  const double& dtnm2);
259 
261  void timestep(ExplicitTimeSteppableObject* const& object_pt,
262  const double& dt);
263  };
264 
265 } // namespace oomph
266 
267 #endif
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
Definition: ComplexEigenSolver_compute.cpp:9
Allows for timing the algorithms; accurate up to 0.01 sec.
Definition: MercuryTime.h:25
Definition: double_vector.h:58
Definition: explicit_timesteppers.h:240
double Yn_weight
Definition: explicit_timesteppers.h:241
void timestep(ExplicitTimeSteppableObject *const &object_pt, const double &dt)
Function that is used to advance the solution by time dt.
Definition: explicit_timesteppers.cc:427
EBDF3()
Constructor, set the type.
Definition: explicit_timesteppers.h:248
void operator=(const EBDF3 &)=delete
Broken assignment operator.
double Ynm2_weight
Definition: explicit_timesteppers.h:243
void set_weights(const double &dtn, const double &dtnm1, const double &dtnm2)
Calculate the weights for this set of step sizes.
Definition: explicit_timesteppers.cc:494
double Ynm1_weight
Definition: explicit_timesteppers.h:242
double Fn_weight
Definition: explicit_timesteppers.h:244
EBDF3(const EBDF3 &)=delete
Broken copy constructor.
Definition: explicit_timesteppers.h:162
void operator=(const Euler &)=delete
Broken assignment operator.
Euler()
Constructor, set the type.
Definition: explicit_timesteppers.h:165
Euler(const Euler &)=delete
Broken copy constructor.
void timestep(ExplicitTimeSteppableObject *const &object_pt, const double &dt)
Euler timestepping x^{t+1} = x^{t} + dt M^{-1} L(x^{t})
Definition: explicit_timesteppers.cc:163
Definition: explicit_timesteppers.h:65
virtual void add_to_dofs(const double &lambda, const DoubleVector &increment_dofs)
Function that adds the values to the dofs.
Definition: explicit_timesteppers.cc:112
ExplicitTimeSteppableObject()
Empty constructor.
Definition: explicit_timesteppers.h:71
virtual ~ExplicitTimeSteppableObject()
Empty destructor.
Definition: explicit_timesteppers.h:80
virtual void get_dofs(DoubleVector &dofs) const
Function that gets the values of the dofs in the object.
Definition: explicit_timesteppers.cc:60
virtual void actions_after_explicit_timestep()
Definition: explicit_timesteppers.h:116
virtual double & time()
Definition: explicit_timesteppers.cc:132
virtual Time * time_pt() const
Definition: explicit_timesteppers.cc:147
virtual void actions_before_explicit_stage()
Definition: explicit_timesteppers.h:102
virtual void set_dofs(const DoubleVector &dofs)
Function that sets the values of the dofs in the object.
Definition: explicit_timesteppers.cc:95
void operator=(const ExplicitTimeSteppableObject &)=delete
Broken assignment operator.
virtual void get_dvaluesdt(DoubleVector &minv_res)
Definition: explicit_timesteppers.cc:41
virtual void actions_after_explicit_stage()
Definition: explicit_timesteppers.h:108
virtual void actions_before_explicit_timestep()
Definition: explicit_timesteppers.h:112
static double Dummy_time_value
Dummy value of time always set to zero.
Definition: explicit_timesteppers.h:67
ExplicitTimeSteppableObject(const ExplicitTimeSteppableObject &)=delete
Broken copy constructor.
A Base class for explicit timesteppers.
Definition: explicit_timesteppers.h:132
ExplicitTimeStepper(const ExplicitTimeStepper &)=delete
Broken copy constructor.
ExplicitTimeStepper()
Empty Constructor.
Definition: explicit_timesteppers.h:140
virtual ~ExplicitTimeStepper()
Empty virtual destructor — no memory is allocated in this class.
Definition: explicit_timesteppers.h:149
std::string Type
Definition: explicit_timesteppers.h:136
virtual void timestep(ExplicitTimeSteppableObject *const &object_pt, const double &dt)=0
Pure virtual function that is used to advance time in the object.
void operator=(const ExplicitTimeStepper &)=delete
Broken assignment operator.
Definition: explicit_timesteppers.h:213
Vector< double > C
Definition: explicit_timesteppers.h:215
LowStorageRungeKutta(const LowStorageRungeKutta &)=delete
Broken copy constructor.
void operator=(const LowStorageRungeKutta &)=delete
Broken assignment operator.
Vector< double > A
Definition: explicit_timesteppers.h:215
LowStorageRungeKutta()
Constructor, set the type.
Definition: explicit_timesteppers.cc:327
Vector< double > B
Definition: explicit_timesteppers.h:215
void timestep(ExplicitTimeSteppableObject *const &object_pt, const double &dt)
Function that is used to advance the solution by time dt.
Definition: explicit_timesteppers.cc:336
Definition: explicit_timesteppers.h:187
RungeKutta(const RungeKutta &)=delete
Broken copy constructor.
void operator=(const RungeKutta &)=delete
Broken assignment operator.
RungeKutta()
Constructor, set the type.
Definition: explicit_timesteppers.h:190
void timestep(ExplicitTimeSteppableObject *const &object_pt, const double &dt)
Function that is used to advance time in the object.
Definition: explicit_timesteppers.cc:190
Definition: timesteppers.h:63
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
t
Definition: plotPSD.py:36