chombo-discharge
CD_AdvectionDiffusionStepper.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_AdvectionDiffusionStepper
13 #define CD_AdvectionDiffusionStepper
14 
15 // Our includes
16 #include <CD_TimeStepper.H>
17 #include <CD_CdrSolver.H>
19 #include <CD_NamespaceHeader.H>
20 
21 namespace Physics {
22 
26  namespace AdvectionDiffusion {
27 
32  {
33  public:
38 
43  AdvectionDiffusionStepper(RefCountedPtr<CdrSolver>& a_solver);
44 
49 
53  void
54  initialData() override;
55 
59  void
60  allocate() override;
61 
65  void
66  postInitialize() override
67  {}
68 
69  // IO routines
70 #ifdef CH_USE_HDF5
76  void
77  writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
78 #endif
79 
80 #ifdef CH_USE_HDF5
86  void
87  readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
88 #endif
89 
94  void
95  postCheckpointSetup() override;
96 
100  int
101  getNumberOfPlotVariables() const override;
102 
106  Vector<std::string>
107  getPlotVariableNames() const override;
108 
116  void
117  writePlotData(LevelData<EBCellFAB>& a_output,
118  int& a_icomp,
119  const std::string a_outputRealm,
120  const int a_level) const override;
121 
125  Real
126  computeDt() override;
127 
134  void
135  synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
136 
141  void
142  printStepReport() override
143  {}
144 
149  void
150  parseRuntimeOptions() override;
151 
155  void
156  registerRealms() override;
157 
161  void
162  registerOperators() override;
163 
169  void
170  preRegrid(const int a_lbase, const int a_finestLevel) override;
171 
175  void
176  setupSolvers() override;
177 
183  Real
184  advance(const Real a_dt) override;
185 
192  void
193  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
194 
198  void
199  postRegrid() override
200  {}
201 
206  void
207  setCFL(const Real a_cfl);
208 
213  void
214  setInitialData(const std::function<Real(const RealVect& a_position)>& a_initData) noexcept;
215 
220  void
221  setVelocity(const std::function<RealVect(const RealVect& a_position)>& a_velocity) noexcept;
222 
227  void
228  setDiffusionCoefficient(const std::function<Real(const RealVect& a_position)>& a_diffusion) noexcept;
229 
230  protected:
235  {
236  Heun,
237  IMEX
238  };
239 
243  RefCountedPtr<CdrSolver> m_solver;
244 
248  RefCountedPtr<AdvectionDiffusionSpecies> m_species;
249 
253  std::string m_realm;
254 
258  phase::which_phase m_phase;
259 
263  std::function<RealVect(const RealVect& a_position)> m_velocity;
264 
268  std::function<Real(const RealVect& a_position)> m_diffCo;
269 
273  std::function<Real(const RealVect& a_initialData)> m_initialData;
274 
278  Real m_minDt;
279 
283  Real m_maxDt;
284 
288  Real m_cfl;
289 
294 
298  bool m_debug;
299 
303  bool m_mobile;
304 
309 
314 
318  void
319  parseIntegrator();
320  };
321  } // namespace AdvectionDiffusion
322 } // namespace Physics
323 
324 #include <CD_NamespaceFooter.H>
325 
326 #endif
Simple species for AdvectionDiffusion test problem.
Declaration of an abstract class for solving scalar convection-diffusion-reaction problems.
Declaration of main (abstract) time stepper class.
Implementation of TimeStepper which runs a single advection-diffusion-reaction solver.
Definition: CD_AdvectionDiffusionStepper.H:32
void registerOperators() override
Register all operators that will be used.
Definition: CD_AdvectionDiffusionStepper.cpp:177
RefCountedPtr< CdrSolver > m_solver
Reference to solver.
Definition: CD_AdvectionDiffusionStepper.H:243
void printStepReport() override
Print a step report if you want.
Definition: CD_AdvectionDiffusionStepper.H:142
void synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override
Synchronize solver times.
Definition: CD_AdvectionDiffusionStepper.cpp:472
void setupSolvers() override
Instantiate the solver.
Definition: CD_AdvectionDiffusionStepper.cpp:138
Integrator
Switch for different integrators.
Definition: CD_AdvectionDiffusionStepper.H:235
void postInitialize() override
Perform post-initialization routines (there are none)
Definition: CD_AdvectionDiffusionStepper.H:66
void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
Regrid method – calls regrid method for solver.
Definition: CD_AdvectionDiffusionStepper.cpp:498
void parseIntegrator()
Parse the integration method.
Definition: CD_AdvectionDiffusionStepper.cpp:113
virtual ~AdvectionDiffusionStepper()
Destructor (does nothing)
Definition: CD_AdvectionDiffusionStepper.cpp:87
void parseRuntimeOptions() override
Parse runtime options.
Definition: CD_AdvectionDiffusionStepper.cpp:93
void postRegrid() override
Perform post-regrid routines. This does nothing.
Definition: CD_AdvectionDiffusionStepper.H:199
RefCountedPtr< AdvectionDiffusionSpecies > m_species
Reference to advected species.
Definition: CD_AdvectionDiffusionStepper.H:248
int getNumberOfPlotVariables() const override
Get the number of plot variables.
Definition: CD_AdvectionDiffusionStepper.cpp:281
Real m_cfl
CFL number to use.
Definition: CD_AdvectionDiffusionStepper.H:288
Integrator m_integrator
Integrator.
Definition: CD_AdvectionDiffusionStepper.H:313
Real m_minDt
Smallest acceptable time step.
Definition: CD_AdvectionDiffusionStepper.H:278
std::string m_realm
Realm where the solver lives.
Definition: CD_AdvectionDiffusionStepper.H:253
bool m_debug
For activating debugging. This is an option.
Definition: CD_AdvectionDiffusionStepper.H:298
Vector< std::string > getPlotVariableNames() const override
Get plot variable name.
Definition: CD_AdvectionDiffusionStepper.cpp:293
Real advance(const Real a_dt) override
Advancement function – advances one time step.
Definition: CD_AdvectionDiffusionStepper.cpp:368
void initialData() override
Fill solver with initial data.
Definition: CD_AdvectionDiffusionStepper.cpp:200
void preRegrid(const int a_lbase, const int a_finestLevel) override
Perform pre-regrid operations. Calls CdrSolver::preRegrid.
Definition: CD_AdvectionDiffusionStepper.cpp:487
Real m_maxDt
Largest acceptable time step.
Definition: CD_AdvectionDiffusionStepper.H:283
void registerRealms() override
Register all realms that will be used.
Definition: CD_AdvectionDiffusionStepper.cpp:166
bool m_diffusive
Diffusive or not.
Definition: CD_AdvectionDiffusionStepper.H:308
void setVelocity(const std::function< RealVect(const RealVect &a_position)> &a_velocity) noexcept
Set the velocity field.
Definition: CD_AdvectionDiffusionStepper.cpp:541
std::function< Real(const RealVect &a_position)> m_diffCo
Diffusion coefficient.
Definition: CD_AdvectionDiffusionStepper.H:268
void setDiffusionCoefficient(const std::function< Real(const RealVect &a_position)> &a_diffusion) noexcept
Set the diffusion coeffieint.
Definition: CD_AdvectionDiffusionStepper.cpp:552
AdvectionDiffusionStepper()
Default constructor – only parses options.
Definition: CD_AdvectionDiffusionStepper.cpp:24
void setInitialData(const std::function< Real(const RealVect &a_position)> &a_initData) noexcept
Set the initial data..
Definition: CD_AdvectionDiffusionStepper.cpp:530
std::function< RealVect(const RealVect &a_position)> m_velocity
Velocity field.
Definition: CD_AdvectionDiffusionStepper.H:263
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_AdvectionDiffusionStepper.cpp:304
bool m_mobile
Mobile or not.
Definition: CD_AdvectionDiffusionStepper.H:303
void setCFL(const Real a_cfl)
Set the CFL number.
Definition: CD_AdvectionDiffusionStepper.cpp:519
std::function< Real(const RealVect &a_initialData)> m_initialData
Initial data.
Definition: CD_AdvectionDiffusionStepper.H:273
Real m_forceCFL
Forced CFL (overrides input options)
Definition: CD_AdvectionDiffusionStepper.H:293
void allocate() override
Allocate memory.
Definition: CD_AdvectionDiffusionStepper.cpp:189
void postCheckpointSetup() override
Perform post-checkpoint setup routines.
Definition: CD_AdvectionDiffusionStepper.cpp:255
Real computeDt() override
Compute a time step to be used by Driver.
Definition: CD_AdvectionDiffusionStepper.cpp:321
phase::which_phase m_phase
Phase where the solver lives.
Definition: CD_AdvectionDiffusionStepper.H:258
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