chombo-discharge
CD_FieldStepper.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_FieldStepper_H
13 #define CD_FieldStepper_H
14 
15 // Our includes
16 #include <CD_TimeStepper.H>
17 #include <CD_SurfaceODESolver.H>
18 #include <CD_FieldSolver.H>
19 #include <CD_NamespaceHeader.H>
20 
21 namespace Physics {
22  namespace Electrostatics {
23 
34  template <class T>
35  class FieldStepper : public TimeStepper
36  {
37  public:
41  FieldStepper();
42 
46  virtual ~FieldStepper();
47 
51  void
52  setupSolvers() override;
53 
57  void
58  initialData() override;
59 
63  void
64  postInitialize() override;
65 
69  void
70  allocate() override;
71 
76  getPotential();
77 
78 #ifdef CH_USE_HDF5
84  void
85  writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
86 #endif
87 
88 #ifdef CH_USE_HDF5
94  void
95  readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
96 #endif
97 
101  void
103  {}
104 
109  int
110  getNumberOfPlotVariables() const override;
111 
115  Vector<std::string>
116  getPlotVariableNames() const override;
117 
125  void
126  writePlotData(LevelData<EBCellFAB>& a_output,
127  int& a_icomp,
128  const std::string a_outputRealm,
129  const int a_level) const override;
130 
135  Real
136  computeDt() override
137  {
138  return 0.0;
139  }
140 
146  Real
147  advance(const Real a_dt) override;
148 
155  void
156  synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
157 
161  void
162  printStepReport() override{};
163 
167  void
168  registerRealms() override;
169 
173  void
174  registerOperators() override;
175 
181  void
182  preRegrid(const int a_lbase, const int a_finestLevel) override;
183 
188  bool
189  loadBalanceThisRealm(const std::string a_realm) const override;
190 
204  void
205  loadBalanceBoxes(Vector<Vector<int>>& a_procs,
206  Vector<Vector<Box>>& a_boxes,
207  const std::string a_realm,
208  const Vector<DisjointBoxLayout>& a_grids,
209  const int a_lmin,
210  const int a_finestLevel) override;
211 
218  void
219  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
220 
225  void
226  postRegrid() override;
227 
232  void
233  setRho(const std::function<Real(const RealVect& a_pos)>& a_rho, const phase::which_phase a_phase) noexcept;
234 
239  void
240  setSigma(const std::function<Real(const RealVect& a_pos)>& a_sigma) noexcept;
241 
242  protected:
247 
252 
256  RefCountedPtr<FieldSolver> m_fieldSolver;
257 
261  RefCountedPtr<SurfaceODESolver<1>> m_sigma;
262 
266  std::string m_realm;
267 
271  std::function<Real(const RealVect& a_pos)> m_rhoGas;
272 
276  std::function<Real(const RealVect& a_pos)> m_rhoDielectric;
277 
281  std::function<Real(const RealVect& a_pos)> m_surfaceChargeDensity;
282 
286  void
287  solvePoisson();
288  };
289  } // namespace Electrostatics
290 } // namespace Physics
291 
292 #include <CD_NamespaceFooter.H>
293 
294 #include <CD_FieldStepperImplem.H>
295 
296 #endif
BoxSorting
Enum for sorting boxes.
Definition: CD_BoxSorting.H:21
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.
Implementation of TimeStepper for solving electrostatic problems. The template parameter is the Field...
Definition: CD_FieldStepper.H:36
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:399
std::string m_realm
Realm where the solver lives.
Definition: CD_FieldStepper.H:266
void setRho(const std::function< Real(const RealVect &a_pos)> &a_rho, const phase::which_phase a_phase) noexcept
Set space charge.
Definition: CD_FieldStepperImplem.H:441
void writePlotData(LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string a_outputRealm, const int a_level) const override
Write plot data to file.
Definition: CD_FieldStepperImplem.H:310
Real computeDt() override
Compute time step.
Definition: CD_FieldStepper.H:136
void preRegrid(const int a_lbase, const int a_finestLevel) override
Perform pre-regrid operations.
Definition: CD_FieldStepperImplem.H:346
Vector< std::string > getPlotVariableNames() const override
Get plot variable names.
Definition: CD_FieldStepperImplem.H:293
void initialData() override
Set initial data – this sets the space and surface charges.
Definition: CD_FieldStepperImplem.H:178
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:359
std::function< Real(const RealVect &a_pos)> m_rhoDielectric
Space charge inside dielectric.
Definition: CD_FieldStepper.H:276
void setSigma(const std::function< Real(const RealVect &a_pos)> &a_sigma) noexcept
Set surface charge.
Definition: CD_FieldStepperImplem.H:459
void solvePoisson()
Internal routine for solving the Poisson equation.
Definition: CD_FieldStepperImplem.H:188
void postCheckpointSetup() override
Post-initialize operations to be performed – does nothing.
Definition: CD_FieldStepper.H:102
void postInitialize() override
Post-initialization routine. This solves the Poisson equation.
Definition: CD_FieldStepperImplem.H:213
int getNumberOfPlotVariables() const override
Get number of plot variables.
Definition: CD_FieldStepperImplem.H:276
void registerRealms() override
Register simulation realms to be used for this simulation module.
Definition: CD_FieldStepperImplem.H:141
std::function< Real(const RealVect &a_pos)> m_rhoGas
Space charge inside gas phase.
Definition: CD_FieldStepper.H:271
void allocate() override
Allocation method – allocates memory and internal data for solvers.
Definition: CD_FieldStepperImplem.H:153
bool m_loadBalance
If true, the simulation will be introspectively load balanced.
Definition: CD_FieldStepper.H:246
void registerOperators() override
Register operators for this simulation module.
Definition: CD_FieldStepperImplem.H:128
std::function< Real(const RealVect &a_pos)> m_surfaceChargeDensity
Surface charge distribution.
Definition: CD_FieldStepper.H:281
void synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override
Synchronzie solver times and time steps.
Definition: CD_FieldStepperImplem.H:330
virtual ~FieldStepper()
Destructor (does nothing)
Definition: CD_FieldStepperImplem.H:87
void postRegrid() override
Perform post-regrid operations – this will resolve the Poisson equation.
Definition: CD_FieldStepperImplem.H:375
void printStepReport() override
Print step report – this does nothing.
Definition: CD_FieldStepper.H:162
MFAMRCellData & getPotential()
Get the potential.
Definition: CD_FieldStepperImplem.H:166
FieldStepper()
Constructor – parses some input options.
Definition: CD_FieldStepperImplem.H:31
RefCountedPtr< SurfaceODESolver< 1 > > m_sigma
Reference to the surface charge solver.
Definition: CD_FieldStepper.H:261
BoxSorting m_boxSort
If using load balancing, this specifies how boxes will be sorted (in space) before load balancing.
Definition: CD_FieldStepper.H:251
RefCountedPtr< FieldSolver > m_fieldSolver
Reference to the FieldSolver.
Definition: CD_FieldStepper.H:256
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:387
Real advance(const Real a_dt) override
Perform a single time step with step a_dt.
Definition: CD_FieldStepperImplem.H:236
void setupSolvers() override
Solver setup routine. This instantiates the FieldSolver and parses input options.
Definition: CD_FieldStepperImplem.H:94
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