chombo-discharge
Loading...
Searching...
No Matches
CD_MeshODESolver.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_MESHODESOLVER_H
14#define CD_MESHODESOLVER_H
15
16// Std includes
17#include <array>
18
19// Our includes
20#include <CD_AmrMesh.H>
21#include <CD_NamespaceHeader.H>
22
27template <size_t N = 1>
29{
30public:
34 using RHSFunction = std::function<std::array<Real, N>(const std::array<Real, N>&, const Real)>;
35
40
45 MeshODESolver(const RefCountedPtr<AmrMesh>& a_amr) noexcept;
46
50 MeshODESolver(const MeshODESolver&) = delete;
51
55 MeshODESolver(const MeshODESolver&&) = delete;
56
60 virtual ~MeshODESolver();
61
66 operator=(const MeshODESolver&) = delete;
67
72 operator=(const MeshODESolver&&) = delete;
73
78 virtual void
79 setAmr(const RefCountedPtr<AmrMesh>& a_amrMesh) noexcept;
80
84 virtual void
85 parseOptions() noexcept;
86
90 virtual void
91 parseRuntimeOptions() noexcept;
92
96 virtual void
97 allocate() noexcept;
98
104 virtual void
105 setPhi(const std::function<Real(const RealVect& a_pos)>& a_phiFunc, size_t a_comp) noexcept;
106
111 virtual void
112 setPhi(const std::function<std::array<Real, N>(const RealVect& a_pos)>& a_phiFunc) noexcept;
113
119 virtual void
120 setRHS(const std::function<Real(const RealVect& a_pos)>& a_srcFunc, size_t a_comp) noexcept;
121
126 virtual void
127 computeRHS(const RHSFunction& a_rhsFunction) noexcept;
128
134 virtual void
135 computeRHS(EBAMRCellData& a_rhs, const RHSFunction& a_rhsFunction) const noexcept;
136
141 EBAMRCellData&
142 getPhi() noexcept;
143
148 const EBAMRCellData&
149 getPhi() const noexcept;
150
155 EBAMRCellData&
156 getRHS() noexcept;
157
162 const EBAMRCellData&
163 getRHS() const noexcept;
164
171 virtual void
172 preRegrid(int a_lbase, int a_oldFinestLevel) noexcept;
173
181 virtual void
182 regrid(int a_lmin, int a_oldFinestLevel, int a_newFinestLevel) noexcept;
183
188 virtual std::string
189 getRealm() const noexcept;
190
196 virtual std::string
197 getName() const noexcept;
198
203 virtual void
204 setName(const std::string& a_name) noexcept;
205
211 virtual void
212 registerOperators() const noexcept;
213
218 virtual void
219 setRealm(const std::string& a_realm) noexcept;
220
225 virtual void
226 setPhase(phase::which_phase a_phase) noexcept;
227
232 virtual void
233 setVerbosity(int a_verbosity) noexcept;
234
242 virtual void
243 setTime(int a_step, Real a_time, Real a_dt) noexcept;
244
250 virtual void
251 writePlotFile() const noexcept;
252
257 virtual int
258 getNumberOfPlotVariables() const noexcept;
259
264 virtual Vector<std::string>
265 getPlotVariableNames() const noexcept;
266
274 virtual void
275 writePlotData(LevelData<EBCellFAB>& a_output,
276 int& a_icomp,
277 const std::string& a_outputRealm,
278 int a_level) const noexcept;
279
285#ifdef CH_USE_HDF5
286 virtual void
287 writeCheckpointLevel(HDF5Handle& a_handle, int a_level) const noexcept;
288#endif
289
295#ifdef CH_USE_HDF5
296 virtual void
297 readCheckpointLevel(HDF5Handle& a_handle, int a_level) noexcept;
298#endif
299
300protected:
304 RefCountedPtr<AmrMesh> m_amr;
305
310
315
319 Real m_time;
320
324 Real m_dt;
325
330
335
340
344 std::string m_name;
345
350 std::string m_className;
351
355 std::string m_realm;
356
361
365 EBAMRCellData m_phi;
366
370 EBAMRCellData m_rhs;
371
375 EBAMRCellData m_cache;
376
388 virtual void
389 writeData(LevelData<EBCellFAB>& a_output,
390 int& a_comp,
391 const EBAMRCellData& a_data,
392 std::string a_outputRealm,
393 int a_level,
394 bool a_interpToCentroids,
395 bool a_interpGhost) const noexcept;
396
400 virtual void
401 parsePlotVariables() noexcept;
402};
403
404#include <CD_NamespaceFooter.H>
405
407
408#endif
Declaration of core class for handling AMR-related operations (with embedded boundaries)
Implementation of CD_MeshODESolver.H.
Class for solving dy/dt = f on an AMR hierarchy.
Definition CD_MeshODESolver.H:29
MeshODESolver(const MeshODESolver &&)=delete
Disallowed move constructor.
virtual std::string getRealm() const noexcept
Get the realm where this solver is registered.
Definition CD_MeshODESolverImplem.H:441
virtual void setRHS(const std::function< Real(const RealVect &a_pos)> &a_srcFunc, size_t a_comp) noexcept
Set right-hand side for specified component.
Definition CD_MeshODESolverImplem.H:269
int m_verbosity
Chattiness.
Definition CD_MeshODESolver.H:309
virtual Vector< std::string > getPlotVariableNames() const noexcept
Get output plot names.
Definition CD_MeshODESolverImplem.H:614
virtual void writePlotFile() const noexcept
Write plot file.
Definition CD_MeshODESolverImplem.H:543
bool m_regridSlopes
Use slopes when regridding.
Definition CD_MeshODESolver.H:339
std::function< std::array< Real, N >(const std::array< Real, N > &, const Real)> RHSFunction
Alias for right-hand side.
Definition CD_MeshODESolver.H:34
bool m_plotPhi
Plot solution vector or not.
Definition CD_MeshODESolver.H:329
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string &a_outputRealm, int a_level) const noexcept
Write plot data to output holder.
Definition CD_MeshODESolverImplem.H:640
virtual void setName(const std::string &a_name) noexcept
Set solver name.
Definition CD_MeshODESolverImplem.H:465
MeshODESolver(const MeshODESolver &)=delete
Disallowed copy constructor.
virtual void writeData(LevelData< EBCellFAB > &a_output, int &a_comp, const EBAMRCellData &a_data, std::string a_outputRealm, int a_level, bool a_interpToCentroids, bool a_interpGhost) const noexcept
Write data to output. Convenience function.
Definition CD_MeshODESolverImplem.H:661
bool m_plotRHS
Plot source term or not.
Definition CD_MeshODESolver.H:334
virtual void parseRuntimeOptions() noexcept
Parse run-time configurable class options.
Definition CD_MeshODESolverImplem.H:82
MeshODESolver()
Default constructor. Must subsequently set everything through public member functions.
Definition CD_MeshODESolverImplem.H:28
EBAMRCellData m_cache
Cache storage when doing regrids.
Definition CD_MeshODESolver.H:375
virtual void setPhi(const std::function< Real(const RealVect &a_pos)> &a_phiFunc, size_t a_comp) noexcept
Set phi for a specific component.
Definition CD_MeshODESolverImplem.H:177
virtual void registerOperators() const noexcept
Register operators for AMR operations.
Definition CD_MeshODESolverImplem.H:477
std::string m_name
Solver name.
Definition CD_MeshODESolver.H:344
std::string m_className
Class name.
Definition CD_MeshODESolver.H:350
Real m_dt
Last time step increment.
Definition CD_MeshODESolver.H:324
RefCountedPtr< AmrMesh > m_amr
Write checkpoint data into HDF5 file.
Definition CD_MeshODESolver.H:304
MeshODESolver & operator=(const MeshODESolver &&)=delete
Disallowed move assignment operator.
EBAMRCellData & getPhi() noexcept
Get the solution vector (left-hand side of equation).
Definition CD_MeshODESolverImplem.H:129
EBAMRCellData m_rhs
Source term (right-hand side of equation).
Definition CD_MeshODESolver.H:370
virtual ~MeshODESolver()
Destructor.
Definition CD_MeshODESolverImplem.H:45
std::string m_realm
Realm where solver is registered.
Definition CD_MeshODESolver.H:355
virtual void setRealm(const std::string &a_realm) noexcept
Set the realm for this solver.
Definition CD_MeshODESolverImplem.H:493
virtual int getNumberOfPlotVariables() const noexcept
Get number of output fields.
Definition CD_MeshODESolverImplem.H:592
virtual void preRegrid(int a_lbase, int a_oldFinestLevel) noexcept
Perform pre-regrid operations.
Definition CD_MeshODESolverImplem.H:404
virtual void parseOptions() noexcept
Parse class options.
Definition CD_MeshODESolverImplem.H:64
Real m_time
Current time.
Definition CD_MeshODESolver.H:319
int m_timeStep
Time step.
Definition CD_MeshODESolver.H:314
virtual void parsePlotVariables() noexcept
Parse plot variables.
Definition CD_MeshODESolverImplem.H:99
MeshODESolver & operator=(const MeshODESolver &)=delete
Disallowed assignment operator.
EBAMRCellData & getRHS() noexcept
Get the right-hand side vector.
Definition CD_MeshODESolverImplem.H:153
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amrMesh) noexcept
Set AmrMesh.
Definition CD_MeshODESolverImplem.H:52
EBAMRCellData m_phi
Solution vector (left hand side of equation).
Definition CD_MeshODESolver.H:365
virtual void setVerbosity(int a_verbosity) noexcept
Set verbosity.
Definition CD_MeshODESolverImplem.H:517
virtual void setPhase(phase::which_phase a_phase) noexcept
Set phase.
Definition CD_MeshODESolverImplem.H:505
virtual void allocate() noexcept
Allocate internal storage.
Definition CD_MeshODESolverImplem.H:391
phase::which_phase m_phase
Phase where solver data lives.
Definition CD_MeshODESolver.H:360
virtual void regrid(int a_lmin, int a_oldFinestLevel, int a_newFinestLevel) noexcept
Regrid this solver.
Definition CD_MeshODESolverImplem.H:419
virtual std::string getName() const noexcept
Get solver name.
Definition CD_MeshODESolverImplem.H:453
virtual void setTime(int a_step, Real a_time, Real a_dt) noexcept
Set the time for this solver.
Definition CD_MeshODESolverImplem.H:529
virtual void computeRHS(const RHSFunction &a_rhsFunction) noexcept
Compute right-hand side from left-hand side. I.e. compute f = f(y,t).
Definition CD_MeshODESolverImplem.H:286
Phase names namespace.
Definition CD_MultiFluidIndexSpace.H:28
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38