chombo-discharge
CD_MeshODEStepper.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2022 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_MeshODEStepper_H
13 #define CD_MeshODEStepper_H
14 
15 // Std includes
16 #include <array>
17 
18 // Our includes
19 #include <CD_TimeStepper.H>
20 #include <CD_MeshODESolver.H>
21 #include <CD_NamespaceHeader.H>
22 
23 namespace Physics {
24  namespace MeshODE {
25 
30  {
31  Euler,
32  RK2,
33  RK4
34  };
35 
39  template <size_t N>
40  class MeshODEStepper : public TimeStepper
41  {
42  public:
47 
52 
56  MeshODEStepper(const MeshODEStepper<N>&&) = delete;
57 
61  virtual ~MeshODEStepper();
62 
67  operator=(const MeshODEStepper<N>&) = delete;
68 
73  operator=(const MeshODEStepper<N>&&) = delete;
74 
78  void
79  setupSolvers() override;
80 
84  void
85  allocate() override;
86 
90  void
91  initialData() override;
92 
96  void
97  postInitialize() override;
98 
102  void
103  postCheckpointSetup() override;
104 
108  void
109  registerRealms() override;
110 
115  void
116  registerOperators() override;
117 
121  void
122  parseOptions();
123 
127  void
128  parseRuntimeOptions() override;
129 
130 #ifdef CH_USE_HDF5
136  virtual void
137  writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
138 #endif
139 
140 #ifdef CH_USE_HDF5
146  virtual void
147  readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
148 #endif
154  virtual int
155  getNumberOfPlotVariables() const override;
156 
160  virtual Vector<std::string>
161  getPlotVariableNames() const override;
162 
170  virtual void
171  writePlotData(LevelData<EBCellFAB>& a_output,
172  int& a_icomp,
173  const std::string a_outputRealm,
174  const int a_level) const override;
175 
179  virtual Real
180  computeDt() override;
181 
187  virtual Real
188  advance(const Real a_dt) override;
189 
196  virtual void
197  synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
198 
203  virtual void
204  printStepReport() override
205  {}
206 
212  virtual void
213  preRegrid(const int a_lmin, const int a_oldFinestLevel) override;
214 
221  virtual void
222  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
223 
228  virtual void
229  postRegrid() override;
230 
231  protected:
236 
240  Real m_dt;
241 
245  std::string m_realm;
246 
250  phase::which_phase m_phase;
251 
255  RefCountedPtr<MeshODESolver<N>> m_solver;
256 
260  std::function<std::array<Real, N>(const std::array<Real, N> y, Real t)> m_rhsFunction;
261 
265  std::function<std::array<Real, N>(const RealVect& a_position)> m_initialData;
266 
270  virtual void
271  parseIntegrator();
272 
276  virtual void
277  parseVerbosity();
278 
282  virtual void
283  parseProblem();
284 
289  virtual void
290  advanceEuler(const Real a_dt);
291 
296  virtual void
297  advanceRK2(const Real a_dt);
298 
303  virtual void
304  advanceRK4(const Real a_dt);
305  };
306  } // namespace MeshODE
307 } // namespace Physics
308 
309 #include <CD_NamespaceFooter.H>
310 
311 #include <CD_MeshODEStepperImplem.H>
312 
313 #endif
Encapsulation of an ODE solver on the mesh.
Implementation of CD_MeshODEStepper.H.
IntegrationAlgorithm
Various supported integration algorithms.
Definition: CD_MeshODEStepper.H:30
Declaration of main (abstract) time stepper class.
Implementation of TimeStepper for solving an ODE on a mesh. N is the number of variables.
Definition: CD_MeshODEStepper.H:41
virtual void advanceEuler(const Real a_dt)
Advance using the explicit Euler rule.
Definition: CD_MeshODEStepperImplem.H:411
RefCountedPtr< MeshODESolver< N > > m_solver
Tracer particle solvers.
Definition: CD_MeshODEStepper.H:255
virtual Real advance(const Real a_dt) override
Advancement method. Swaps between various kernels.
Definition: CD_MeshODEStepperImplem.H:279
void registerOperators() override
Register operators.
Definition: CD_MeshODEStepperImplem.H:120
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string a_outputRealm, const int a_level) const override
Write plot data to output holder.
Definition: CD_MeshODEStepperImplem.H:252
void parseRuntimeOptions() override
Parse runtime options.
Definition: CD_MeshODEStepperImplem.H:146
MeshODEStepper & operator=(const MeshODEStepper< N > &&)=delete
Move assignment operator. Disallowed.
virtual Vector< std::string > getPlotVariableNames() const override
Get plot variable names.
Definition: CD_MeshODEStepperImplem.H:240
MeshODEStepper(const MeshODEStepper< N > &&)=delete
Move constructor. Disallowed.
phase::which_phase m_phase
Phase (gas/solid) where the solver lives.
Definition: CD_MeshODEStepper.H:250
std::function< std::array< Real, N >const std::array< Real, N > y, Real t)> m_rhsFunction
Encapsulation of f = f(y,t)
Definition: CD_MeshODEStepper.H:260
std::function< std::array< Real, N >const RealVect &a_position)> m_initialData
Initial data function.
Definition: CD_MeshODEStepper.H:265
virtual void advanceRK2(const Real a_dt)
Advance using a second-order Runge-Kutta method.
Definition: CD_MeshODEStepperImplem.H:429
MeshODEStepper & operator=(const MeshODEStepper< N > &)=delete
Copy assignment operator. Disallowed.
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
Time stepper regrid method.
Definition: CD_MeshODEStepperImplem.H:344
std::string m_realm
Realm where solver and m_velocity lives.
Definition: CD_MeshODEStepper.H:245
virtual void parseIntegrator()
Parse integrator.
Definition: CD_MeshODEStepperImplem.H:369
void initialData() override
Fill problem with initial data.
Definition: CD_MeshODEStepperImplem.H:73
void allocate() override
Allocate storage for solvers and time stepper.
Definition: CD_MeshODEStepperImplem.H:61
virtual void synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override
Synchronize solver times and time steps.
Definition: CD_MeshODEStepperImplem.H:317
virtual ~MeshODEStepper()
Destructor.
Definition: CD_MeshODEStepperImplem.H:35
virtual void parseVerbosity()
Parse chattiness.
Definition: CD_MeshODEStepperImplem.H:397
virtual void printStepReport() override
Print a step report.
Definition: CD_MeshODEStepper.H:204
virtual void parseProblem()
Parse the problem type.
Definition: CD_MeshODEStepperImplem.H:161
void setupSolvers() override
Instantiate the ODE solver.
Definition: CD_MeshODEStepperImplem.H:45
virtual void advanceRK4(const Real a_dt)
Advance using a fourth order Runge-Kutta method.
Definition: CD_MeshODEStepperImplem.H:454
virtual void preRegrid(const int a_lmin, const int a_oldFinestLevel) override
Perform pre-regrid operations.
Definition: CD_MeshODEStepperImplem.H:332
void postCheckpointSetup() override
Post checkpoint operations.
Definition: CD_MeshODEStepperImplem.H:96
virtual int getNumberOfPlotVariables() const override
Get the number of plot variables for this time stepper.
Definition: CD_MeshODEStepperImplem.H:228
void registerRealms() override
Register realms. Primal is the only realm we need.
Definition: CD_MeshODEStepperImplem.H:108
MeshODEStepper(const MeshODEStepper< N > &)=delete
Copy constructor. Disallowed.
void parseOptions()
Parse options.
Definition: CD_MeshODEStepperImplem.H:132
IntegrationAlgorithm m_algorithm
Integration algorithm.
Definition: CD_MeshODEStepper.H:235
virtual void postRegrid() override
Perform post-regrid operations.
Definition: CD_MeshODEStepperImplem.H:356
Real m_dt
Time step to use.
Definition: CD_MeshODEStepper.H:240
void postInitialize() override
Perform any post-initialization steps.
Definition: CD_MeshODEStepperImplem.H:86
MeshODEStepper()
Constructor. Does nothing.
Definition: CD_MeshODEStepperImplem.H:23
virtual Real computeDt() override
Compute a time step to be used by Driver.
Definition: CD_MeshODEStepperImplem.H:267
Base class for advancing equations.
Definition: CD_TimeStepper.H:30
Name containing various physics models for running chombo-discharge code.
Definition: CD_AdvectionDiffusion.H:15