chombo-discharge
Loading...
Searching...
No Matches
CD_FieldStepper.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_FIELDSTEPPER_H
14#define CD_FIELDSTEPPER_H
15
16// Our includes
17#include <CD_TimeStepper.H>
18#include <CD_SurfaceODESolver.H>
19#include <CD_FieldSolver.H>
20#include <CD_NamespaceHeader.H>
21
22namespace Physics {
23namespace Electrostatics {
24
37template <class T>
39{
40public:
45
49 virtual ~FieldStepper();
50
54 void
55 setupSolvers() override;
56
60 void
61 initialData() override;
62
66 void
67 postInitialize() override;
68
72 void
73 allocate() override;
74
79 MFAMRCellData&
81
82#ifdef CH_USE_HDF5
89 void
90 writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
91#endif
92
93#ifdef CH_USE_HDF5
99 void
100 readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
101#endif
102
106 void
108 {}
109
114 int
115 getNumberOfPlotVariables() const override;
116
121 Vector<std::string>
122 getPlotVariableNames() const override;
123
131 void
132 writePlotData(LevelData<EBCellFAB>& a_output,
133 int& a_icomp,
134 const std::string& a_outputRealm,
135 const int a_level) const override;
136
142 Real
143 computeDt() override
144 {
145 return 0.0;
146 }
147
153 Real
154 advance(const Real a_dt) override;
155
162 void
163 synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
164
168 void
169 printStepReport() override {};
170
174 void
175 registerRealms() override;
176
180 void
181 registerOperators() override;
182
188 void
189 preRegrid(const int a_lbase, const int a_finestLevel) override;
190
197 bool
198 loadBalanceThisRealm(const std::string& a_realm) const override;
199
214 void
215 loadBalanceBoxes(Vector<Vector<int>>& a_procs,
216 Vector<Vector<Box>>& a_boxes,
217 const std::string& a_realm,
218 const Vector<DisjointBoxLayout>& a_grids,
219 const int a_lmin,
220 const int a_finestLevel) override;
221
229 void
230 regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
231
236 void
237 postRegrid() override;
238
244 void
245 setRho(const std::function<Real(const RealVect& a_pos)>& a_rho, const phase::which_phase a_phase) noexcept;
246
251 void
252 setSigma(const std::function<Real(const RealVect& a_pos)>& a_sigma) noexcept;
253
254protected:
259
264
268 RefCountedPtr<FieldSolver> m_fieldSolver;
269
273 RefCountedPtr<SurfaceODESolver<1>> m_sigma;
274
278 std::string m_realm;
279
283 std::function<Real(const RealVect& a_pos)> m_rhoGas;
284
288 std::function<Real(const RealVect& a_pos)> m_rhoDielectric;
289
293 std::function<Real(const RealVect& a_pos)> m_surfaceChargeDensity;
294
299 void
300 solvePoisson();
301};
302} // namespace Electrostatics
303} // namespace Physics
304
305#include <CD_NamespaceFooter.H>
306
308
309#endif
BoxSorting
Enum for sorting boxes.
Definition CD_BoxSorting.H:22
Contains declaration of a base electrostatics solver class.
Implementation of CD_FieldStepper.H.
Declaration of a cut-cell ODE solver.
Declaration of main (abstract) time stepper class.
TimeStepper for solving the electrostatic Poisson equation, optionally with surface charge.
Definition CD_FieldStepper.H:39
std::string m_realm
Realm where the solver lives.
Definition CD_FieldStepper.H:278
void setRho(const std::function< Real(const RealVect &a_pos)> &a_rho, const phase::which_phase a_phase) noexcept
Set the space charge distribution.
Definition CD_FieldStepperImplem.H:453
Real computeDt() override
Compute time step.
Definition CD_FieldStepper.H:143
void preRegrid(const int a_lbase, const int a_finestLevel) override
Perform pre-regrid operations.
Definition CD_FieldStepperImplem.H:355
Vector< std::string > getPlotVariableNames() const override
Get plot variable names.
Definition CD_FieldStepperImplem.H:302
void initialData() override
Set initial data – this sets the space and surface charges.
Definition CD_FieldStepperImplem.H:182
void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
Regrid method – regrids the potential distribution in FieldSolver (but does not solve the Poisson equ...
Definition CD_FieldStepperImplem.H:368
std::function< Real(const RealVect &a_pos)> m_rhoDielectric
Space charge inside dielectric.
Definition CD_FieldStepper.H:288
void setSigma(const std::function< Real(const RealVect &a_pos)> &a_sigma) noexcept
Set the surface charge distribution.
Definition CD_FieldStepperImplem.H:471
void solvePoisson()
Solve the Poisson equation and compute the electric field.
Definition CD_FieldStepperImplem.H:192
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_FieldStepperImplem.H:319
void postCheckpointSetup() override
Post-initialize operations to be performed – does nothing.
Definition CD_FieldStepper.H:107
void postInitialize() override
Post-initialization routine. This solves the Poisson equation.
Definition CD_FieldStepperImplem.H:217
int getNumberOfPlotVariables() const override
Get number of plot variables contributed by this TimeStepper.
Definition CD_FieldStepperImplem.H:285
void loadBalanceBoxes(Vector< Vector< int > > &a_procs, Vector< Vector< Box > > &a_boxes, const std::string &a_realm, const Vector< DisjointBoxLayout > &a_grids, const int a_lmin, const int a_finestLevel) override
Load balance grid boxes for a specified realm.
Definition CD_FieldStepperImplem.H:408
void registerRealms() override
Register simulation realms to be used for this simulation module.
Definition CD_FieldStepperImplem.H:145
std::function< Real(const RealVect &a_pos)> m_rhoGas
Space charge inside gas phase.
Definition CD_FieldStepper.H:283
void allocate() override
Allocation method – allocates memory and internal data for solvers.
Definition CD_FieldStepperImplem.H:157
bool m_loadBalance
If true, the simulation will be introspectively load balanced.
Definition CD_FieldStepper.H:258
void registerOperators() override
Register operators for this simulation module.
Definition CD_FieldStepperImplem.H:132
std::function< Real(const RealVect &a_pos)> m_surfaceChargeDensity
Surface charge distribution.
Definition CD_FieldStepper.H:293
void synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override
Synchronize solver times and time steps.
Definition CD_FieldStepperImplem.H:339
virtual ~FieldStepper()
Destructor (does nothing)
Definition CD_FieldStepperImplem.H:91
void postRegrid() override
Perform post-regrid operations – this will resolve the Poisson equation.
Definition CD_FieldStepperImplem.H:384
void printStepReport() override
Print step report – this does nothing.
Definition CD_FieldStepper.H:169
MFAMRCellData & getPotential()
Get the electrostatic potential.
Definition CD_FieldStepperImplem.H:170
bool loadBalanceThisRealm(const std::string &a_realm) const override
Load balancing query for a specified realm. If this returns true for a_realm, load balancing routines...
Definition CD_FieldStepperImplem.H:396
FieldStepper()
Constructor – parses some input options.
Definition CD_FieldStepperImplem.H:32
RefCountedPtr< SurfaceODESolver< 1 > > m_sigma
Reference to the surface charge solver.
Definition CD_FieldStepper.H:273
BoxSorting m_boxSort
If using load balancing, this specifies how boxes will be sorted (in space) before load balancing.
Definition CD_FieldStepper.H:263
RefCountedPtr< FieldSolver > m_fieldSolver
Reference to the FieldSolver.
Definition CD_FieldStepper.H:268
Real advance(const Real a_dt) override
Perform a single time step with step a_dt.
Definition CD_FieldStepperImplem.H:245
void setupSolvers() override
Solver setup routine. This instantiates the FieldSolver and parses input options.
Definition CD_FieldStepperImplem.H:98
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