chombo-discharge
Loading...
Searching...
No Matches
CD_MeshODEStepper.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_MESHODESTEPPER_H
14#define CD_MESHODESTEPPER_H
15
16// Std includes
17#include <array>
18
19// Our includes
20#include <CD_TimeStepper.H>
21#include <CD_MeshODESolver.H>
22#include <CD_NamespaceHeader.H>
23
24namespace Physics {
25namespace MeshODE {
26
31{
32 Euler,
33 RK2,
34 RK4
35};
36
47template <size_t N>
49{
50public:
55
60
65
69 virtual ~MeshODEStepper();
70
75 operator=(const MeshODEStepper<N>&) = delete;
76
81 operator=(const MeshODEStepper<N>&&) = delete;
82
86 void
87 setupSolvers() override;
88
92 void
93 allocate() override;
94
98 void
99 initialData() override;
100
104 void
105 postInitialize() override;
106
110 void
111 postCheckpointSetup() override;
112
116 void
117 registerRealms() override;
118
123 void
124 registerOperators() override;
125
129 void
130 parseOptions();
131
135 void
136 parseRuntimeOptions() override;
137
138#ifdef CH_USE_HDF5
144 virtual void
145 writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
146#endif
147
148#ifdef CH_USE_HDF5
154 virtual void
155 readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
156#endif
162 virtual int
163 getNumberOfPlotVariables() const override;
164
169 virtual Vector<std::string>
170 getPlotVariableNames() const override;
171
179 virtual void
180 writePlotData(LevelData<EBCellFAB>& a_output,
181 int& a_icomp,
182 const std::string& a_outputRealm,
183 const int a_level) const override;
184
189 virtual Real
190 computeDt() override;
191
197 virtual Real
198 advance(const Real a_dt) override;
199
206 virtual void
207 synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
208
214 virtual void
216 {}
217
223 virtual void
224 preRegrid(const int a_lmin, const int a_oldFinestLevel) override;
225
232 virtual void
233 regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
234
239 virtual void
240 postRegrid() override;
241
242protected:
247
251 Real m_dt;
252
256 std::string m_realm;
257
262
266 RefCountedPtr<MeshODESolver<N>> m_solver;
267
271 std::function<std::array<Real, N>(const std::array<Real, N> y, Real t)> m_rhsFunction;
272
276 std::function<std::array<Real, N>(const RealVect& a_position)> m_initialData;
277
281 virtual void
283
287 virtual void
289
293 virtual void
294 parseProblem();
295
300 virtual void
301 advanceEuler(const Real a_dt);
302
307 virtual void
308 advanceRK2(const Real a_dt);
309
314 virtual void
315 advanceRK4(const Real a_dt);
316};
317} // namespace MeshODE
318} // namespace Physics
319
320#include <CD_NamespaceFooter.H>
321
323
324#endif
Encapsulation of an ODE solver on the mesh.
Implementation of CD_MeshODEStepper.H.
IntegrationAlgorithm
Time integration algorithms available for advancing the ODE.
Definition CD_MeshODEStepper.H:31
@ RK2
Explicit second-order Runge-Kutta (Heun's method).
@ RK4
Explicit classical fourth-order Runge-Kutta.
Declaration of main (abstract) time stepper class.
TimeStepper for advancing a system of N coupled ODEs on an AMR mesh.
Definition CD_MeshODEStepper.H:49
virtual void advanceEuler(const Real a_dt)
Advance using the explicit Euler rule.
Definition CD_MeshODEStepperImplem.H:412
RefCountedPtr< MeshODESolver< N > > m_solver
MeshODE solver holding the solution on the AMR hierarchy.
Definition CD_MeshODEStepper.H:266
virtual Real advance(const Real a_dt) override
Advancement method. Swaps between various kernels.
Definition CD_MeshODEStepperImplem.H:280
void registerOperators() override
Register operators.
Definition CD_MeshODEStepperImplem.H:121
std::function< std::array< Real, N >(const std::array< Real, N > y, Real t)> m_rhsFunction
Right-hand side function evaluated point-wise on the mesh.
Definition CD_MeshODEStepper.H:271
void parseRuntimeOptions() override
Parse runtime options.
Definition CD_MeshODEStepperImplem.H:147
virtual Vector< std::string > getPlotVariableNames() const override
Get plot variable names.
Definition CD_MeshODEStepperImplem.H:241
MeshODEStepper(const MeshODEStepper< N > &&)=delete
Move constructor. Disallowed.
std::function< std::array< Real, N >(const RealVect &a_position)> m_initialData
Callable that returns the initial state at a given position.
Definition CD_MeshODEStepper.H:276
phase::which_phase m_phase
Phase (gas/solid) where the solver lives.
Definition CD_MeshODEStepper.H:261
virtual void advanceRK2(const Real a_dt)
Advance using a second-order Runge-Kutta method.
Definition CD_MeshODEStepperImplem.H:430
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
Time stepper regrid method.
Definition CD_MeshODEStepperImplem.H:345
std::string m_realm
Realm where solver and m_velocity lives.
Definition CD_MeshODEStepper.H:256
virtual void parseIntegrator()
Parse integrator.
Definition CD_MeshODEStepperImplem.H:370
void initialData() override
Fill problem with initial data.
Definition CD_MeshODEStepperImplem.H:74
void allocate() override
Allocate storage for solvers and time stepper.
Definition CD_MeshODEStepperImplem.H:62
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:318
virtual ~MeshODEStepper()
Destructor.
Definition CD_MeshODEStepperImplem.H:36
virtual void parseVerbosity()
Parse chattiness.
Definition CD_MeshODEStepperImplem.H:398
virtual void printStepReport() override
Print a step report.
Definition CD_MeshODEStepper.H:215
MeshODEStepper & operator=(const MeshODEStepper< N > &&)=delete
Move assignment operator. Disallowed.
virtual void parseProblem()
Parse the problem type.
Definition CD_MeshODEStepperImplem.H:162
void setupSolvers() override
Instantiate the ODE solver.
Definition CD_MeshODEStepperImplem.H:46
virtual void advanceRK4(const Real a_dt)
Advance using a fourth order Runge-Kutta method.
Definition CD_MeshODEStepperImplem.H:455
virtual void preRegrid(const int a_lmin, const int a_oldFinestLevel) override
Perform pre-regrid operations.
Definition CD_MeshODEStepperImplem.H:333
void postCheckpointSetup() override
Post checkpoint operations.
Definition CD_MeshODEStepperImplem.H:97
virtual int getNumberOfPlotVariables() const override
Get the number of plot variables for this time stepper.
Definition CD_MeshODEStepperImplem.H:229
void registerRealms() override
Register realms. Primal is the only realm we need.
Definition CD_MeshODEStepperImplem.H:109
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:253
MeshODEStepper(const MeshODEStepper< N > &)=delete
Copy constructor. Disallowed.
void parseOptions()
Parse options.
Definition CD_MeshODEStepperImplem.H:133
IntegrationAlgorithm m_algorithm
Integration algorithm.
Definition CD_MeshODEStepper.H:246
virtual void postRegrid() override
Perform post-regrid operations.
Definition CD_MeshODEStepperImplem.H:357
Real m_dt
Time step to use.
Definition CD_MeshODEStepper.H:251
void postInitialize() override
Perform any post-initialization steps.
Definition CD_MeshODEStepperImplem.H:87
MeshODEStepper & operator=(const MeshODEStepper< N > &)=delete
Copy assignment operator. Disallowed.
MeshODEStepper()
Constructor. Does nothing.
Definition CD_MeshODEStepperImplem.H:24
virtual Real computeDt() override
Compute a time step.
Definition CD_MeshODEStepperImplem.H:268
Base class for advancing equations.
Definition CD_TimeStepper.H:32
Namespace containing physics models for use with chombo-discharge.
Definition CD_AdvectionDiffusion.H:16
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38