chombo-discharge
CD_CdrPlasmaGodunovStepper.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_CdrPlasmaGodunovStepper_H
13 #define CD_CdrPlasmaGodunovStepper_H
14 
15 // Std includes
16 #include <memory>
17 
18 // Our includes
19 #include <CD_AmrMesh.H>
20 #include <CD_CdrPlasmaStepper.H>
21 #include <CD_CdrIterator.H>
22 #include <CD_RtIterator.H>
23 #include <CD_Timer.H>
24 #include <CD_NamespaceHeader.H>
25 
26 namespace Physics {
27  namespace CdrPlasma {
28 
34  {
35  public:
36  // Forward declared utility classes for handling the extra memory when advancing the solvers.
37  class CdrStorage;
38  class FieldStorage;
39  class RtStorage;
40  class SigmaStorage;
41 
46 
51  CdrPlasmaGodunovStepper(RefCountedPtr<CdrPlasmaPhysics>& a_physics);
52 
56  virtual ~CdrPlasmaGodunovStepper();
57 
61  void
62  parseOptions() override;
63 
67  void
68  parseRuntimeOptions() override;
69 
76  Real
77  advance(const Real a_dt) override;
78 
85  void
86  preRegrid(const int a_lbase, const int a_oldFinestLevel) override;
87 
95  void
96  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
97 
102  void
103  postRegrid() override;
104 
108  Real
109  computeDt() override;
110 
116  void
117  postCheckpointSetup() override;
118 
119  protected:
123  enum class FieldCoupling
124  {
125  Explicit,
126  SemiImplicit
127  };
128 
132  enum class AdvectionSolver
133  {
134  Euler,
135  RK2,
136  MUSCL
137  };
138 
143  {
144  Explicit,
145  Implicit,
146  Automatic,
147  };
148 
153 
158 
163 
167  std::unique_ptr<Timer> m_timer;
168 
172  Vector<RefCountedPtr<CdrStorage>> m_cdrScratch;
173 
177  Vector<RefCountedPtr<RtStorage>> m_rteScratch;
178 
182  RefCountedPtr<FieldStorage> m_fieldScratch;
183 
187  RefCountedPtr<SigmaStorage> m_sigmaScratch;
188 
194 
199 
204 
209 
214 
219 
224 
228  bool m_debug;
229 
233  bool m_profile;
234 
238  bool m_floor;
239 
243  bool m_fhd;
244 
249 
254 
259 
264 
269 
273  std::vector<bool> m_useImplicitDiffusion;
274 
280  RefCountedPtr<CdrStorage>&
281  getCdrStorage(const CdrIterator<CdrSolver>& a_solverIt);
282 
288  RefCountedPtr<RtStorage>&
289  getRtStorage(const RtIterator<RtSolver>& a_solverIt);
290 
297  void
298  regridInternals(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
299 
304  void
305  allocateInternals() override;
306 
311  void
312  allocateScratch();
313 
317  void
318  deallocateInternals() override;
319 
324  void
326 
331  void
333 
337  void
339 
345  void
346  extrapolateWithSourceTerm(const Real a_dt);
347 
351  void
353 
358  void
360 
364  void
366 
371  void
373 
377  void
379 
385  void
386  advanceTransport(const Real a_dt);
387 
392  void
393  advanceTransportExplicitField(const Real a_dt);
394 
400  void
401  advanceTransportSemiImplicit(const Real a_dt);
402 
408  void
409  advanceCdrReactions(const Real a_dt);
410 
416  void
417  advanceRadiativeTransfer(const Real a_dt);
418 
426  void
427  floorMass(EBAMRCellData& a_data, const std::string a_message, const RefCountedPtr<CdrSolver>& a_solver) const;
428 
432  void
433  postStep();
434 
440  void
441  computeCdrDriftVelocities(const Real a_time);
442 
448  void
449  computeCdrDiffusionCoefficients(const Real a_time);
450 
455  void
456  computeSourceTerms(const Real a_dt);
457 
461  void
462  parseAdvection();
463 
467  void
468  parseDiffusion();
469 
473  void
474  parseField();
475 
479  void
480  parseFloor();
481 
485  void
486  parseDebug();
487 
491  void
492  parseProfile();
493 
497  void
498  parseFHD();
499 
503  void
505 
509  void
510  parseFiltering();
511 
517  bool
519 
520 #ifdef CH_USE_HDF5
527  virtual void
528  writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
529 #endif
530 
531 #ifdef CH_USE_HDF5
538  virtual void
539  readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
540 #endif
541  };
542  } // namespace CdrPlasma
543 } // namespace Physics
544 
545 #include <CD_NamespaceFooter.H>
546 
547 #endif
Declaration of core class for handling AMR-related operations (with embedded boundaries)
Declaration of an iterator class for CdrLayout (for iterating through subsets of solvers).
Declaration of a CdrPlasmaStepper, an abstract class for evolving cdr plasma equations in time.
Iterator class for RtLayout.
Implementation of CD_Timer.H.
Iterator class for CdrLayout. This allows iteration through solvers (or subsets of solvers).
Definition: CD_CdrIterator.H:27
Utility class for memory handling in CdrPlasmaStepper.
Definition: CD_CdrPlasmaGodunovStorage.H:28
Utility class for memory handling in CdrPlasmaStepper.
Definition: CD_CdrPlasmaGodunovStorage.H:249
Utility class for memory handling in CdrPlasmaStepper.
Definition: CD_CdrPlasmaGodunovStorage.H:345
Utility class for memory handling in CdrPlasmaStepper.
Definition: CD_CdrPlasmaGodunovStorage.H:427
Class for evolving plasma equations using a split step Godunov method.
Definition: CD_CdrPlasmaGodunovStepper.H:34
void deallocateInternals() override
Deallocate transient memory.
Definition: CD_CdrPlasmaGodunovStepper.cpp:695
bool m_debug
Enable for debugging this class.
Definition: CD_CdrPlasmaGodunovStepper.H:228
void computeElectricFieldIntoScratch()
Compute electric field into scratch storage.
Definition: CD_CdrPlasmaGodunovStepper.cpp:773
EBAMRCellData m_conductivityFactorCell
Used for storing conductivity*dt/eps0 on the cell center.
Definition: CD_CdrPlasmaGodunovStepper.H:198
RefCountedPtr< CdrStorage > & getCdrStorage(const CdrIterator< CdrSolver > &a_solverIt)
Function for getting the transient storage assocaited with a particular CDR solver.
Definition: CD_CdrPlasmaGodunovStepper.cpp:294
void extrapolateCdrToEB()
Extrapolate the cell-centered states to the EB.
Definition: CD_CdrPlasmaGodunovStepper.cpp:855
DiffusionAlgorithm
Enum for distinguishing various ways we handle diffusion.
Definition: CD_CdrPlasmaGodunovStepper.H:143
bool m_fhd
If true, add a stochastic diffusion flux.
Definition: CD_CdrPlasmaGodunovStepper.H:243
FieldCoupling
Enum for representing the coupling between the electric field and charge transport.
Definition: CD_CdrPlasmaGodunovStepper.H:124
AdvectionSolver m_advectionSolver
Advection solver.
Definition: CD_CdrPlasmaGodunovStepper.H:162
Real computeDt() override
Compute the time step – this will be different for the different supported algorithms.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1515
void parseOptions() override
Parse startup options.
Definition: CD_CdrPlasmaGodunovStepper.cpp:53
void extrapolateWithSourceTerm(const Real a_dt)
Extrapolate cell-centered states with the source term.
Definition: CD_CdrPlasmaGodunovStepper.cpp:826
void parseField()
Parse the transport algorithm.
Definition: CD_CdrPlasmaGodunovStepper.cpp:164
void advanceRadiativeTransfer(const Real a_dt)
Advance the radiative transfer problem.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1432
void computeCdrDomainFluxes()
Compute the CDR boundary condition fluxes on the domain faces.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1035
std::unique_ptr< Timer > m_timer
Timer for run-time profiling.
Definition: CD_CdrPlasmaGodunovStepper.H:167
int m_diffusionOrder
Integration order for diffusion equations.
Definition: CD_CdrPlasmaGodunovStepper.H:263
void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
Regrid method.
Definition: CD_CdrPlasmaGodunovStepper.cpp:415
RefCountedPtr< FieldStorage > m_fieldScratch
Scratch storage for the field solver.
Definition: CD_CdrPlasmaGodunovStepper.H:182
AdvectionSolver
Enum for switching between various advection solvers.
Definition: CD_CdrPlasmaGodunovStepper.H:133
Real m_implicitDiffusionThreshold
Diffusion threshold factor.
Definition: CD_CdrPlasmaGodunovStepper.H:258
FieldCoupling m_fieldCoupling
For figuring out which transport algorithm we use.
Definition: CD_CdrPlasmaGodunovStepper.H:152
void extrapolateCdrToDomain()
Extrapolate the CDR cell-centered densities to domain edges/face.
Definition: CD_CdrPlasmaGodunovStepper.cpp:989
void advanceCdrReactions(const Real a_dt)
Advance the reactive problem over a time step dt.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1394
void postRegrid() override
Perform post-regrid operations.
Definition: CD_CdrPlasmaGodunovStepper.cpp:506
void parseRuntimeOptions() override
Parse run-time adjustable parameters.
Definition: CD_CdrPlasmaGodunovStepper.cpp:82
DiffusionAlgorithm m_diffusionAlgorithm
For figuring out how we handle diffusion.
Definition: CD_CdrPlasmaGodunovStepper.H:157
Real advance(const Real a_dt) override
Implementation of the advance method.
Definition: CD_CdrPlasmaGodunovStepper.cpp:306
Vector< RefCountedPtr< RtStorage > > m_rteScratch
Scratch storage for the RTE solvers.
Definition: CD_CdrPlasmaGodunovStepper.H:177
bool m_regridSlopes
Regrid slopes or not.
Definition: CD_CdrPlasmaGodunovStepper.H:248
void parseFHD()
Parse inclusion of random diffusion flux.
Definition: CD_CdrPlasmaGodunovStepper.cpp:254
bool m_extrapAdvect
A special flag for letting the CDR solvers know that we want to compute advective derivatives at half...
Definition: CD_CdrPlasmaGodunovStepper.H:223
void postStep()
Perform post-step operations.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1687
bool m_filterCompensate
Use compensation step in filter or not.
Definition: CD_CdrPlasmaGodunovStepper.H:253
void advanceTransportSemiImplicit(const Real a_dt)
Advance the transport problem using a semi-implicit formulation for the electric field.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1318
void parseAdvection()
Parse centering for the advective integrator.
Definition: CD_CdrPlasmaGodunovStepper.cpp:187
Vector< RefCountedPtr< CdrStorage > > m_cdrScratch
Scratch storage for the CDR solvers.
Definition: CD_CdrPlasmaGodunovStepper.H:172
void allocateScratch()
Allocate internal storage.
Definition: CD_CdrPlasmaGodunovStepper.cpp:656
EBAMRCellData m_scratchConductivity
Scratch storage for storing m_conductivityFactorCell on the old grids during regrid operations.
Definition: CD_CdrPlasmaGodunovStepper.H:218
int m_numFilterRho
Number of filterings for space charge.
Definition: CD_CdrPlasmaGodunovStepper.H:268
void parseFloor()
Parse whether or not we should floor the mass.
Definition: CD_CdrPlasmaGodunovStepper.cpp:214
virtual ~CdrPlasmaGodunovStepper()
Destructor.
Definition: CD_CdrPlasmaGodunovStepper.cpp:44
void computeCdrDiffusionCoefficients(const Real a_time)
Compute CDR diffusion coefficients.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1463
EBAMRFluxData m_conductivityFactorFace
Used for storing conductivity*dt/eps0 on the face centers.
Definition: CD_CdrPlasmaGodunovStepper.H:203
void advanceTransport(const Real a_dt)
Advance the transport problem.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1145
void floorMass(EBAMRCellData &a_data, const std::string a_message, const RefCountedPtr< CdrSolver > &a_solver) const
Print how much mass was injected into the system.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1658
void computeSigmaFlux()
Compute the surface flux for the surface charge solver.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1115
void deallocateScratch()
Allocate internal storage.
Definition: CD_CdrPlasmaGodunovStepper.cpp:737
void preRegrid(const int a_lbase, const int a_oldFinestLevel) override
Pre-regrid method. Used for storing important variables for the solvers.
Definition: CD_CdrPlasmaGodunovStepper.cpp:388
bool m_floor
True if we floor the CDR densities. Due to reactions/EBs, they are not generally non-negative.
Definition: CD_CdrPlasmaGodunovStepper.H:238
void advanceTransportExplicitField(const Real a_dt)
Advance the transport problem using the explicit or explicit-implicit Euler rule.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1172
std::vector< bool > m_useImplicitDiffusion
If true, we are using implicit diffusion. Otherwise it's explicit diffusion.
Definition: CD_CdrPlasmaGodunovStepper.H:273
EBAMRIVData m_conductivityFactorEB
Used for storing conductivity*dt/eps0 on the EB centers.
Definition: CD_CdrPlasmaGodunovStepper.H:208
bool solveSemiImplicitPoisson()
Solve the semi-implicit Poisson equation.
Definition: CD_CdrPlasmaGodunovStepper.cpp:584
void computeCdrFluxesEB()
Compute the CDR boundary condition fluxes on the EBs.
Definition: CD_CdrPlasmaGodunovStepper.cpp:912
CdrPlasmaGodunovStepper()=delete
Disallowed constructor – use strong construction.
void parseRegridSlopes()
Parse whether or not to use slopes when regridding.
Definition: CD_CdrPlasmaGodunovStepper.cpp:267
void postCheckpointSetup() override
Run post-checkpoint setup operations.
Definition: CD_CdrPlasmaGodunovStepper.cpp:523
void computeSourceTerms(const Real a_dt)
Compute source terms for the CDR and RTE equations.
Definition: CD_CdrPlasmaGodunovStepper.cpp:1476
void parseDiffusion()
Parse how we handle diffusion.
Definition: CD_CdrPlasmaGodunovStepper.cpp:119
RefCountedPtr< RtStorage > & getRtStorage(const RtIterator< RtSolver > &a_solverIt)
Function for getting the transient storage assocaited with a particular RTE solver.
Definition: CD_CdrPlasmaGodunovStepper.cpp:300
void parseDebug()
Parse debug mode.
Definition: CD_CdrPlasmaGodunovStepper.cpp:228
EBAMRCellData m_scratchSemiImplicitRho
Scratch storage for storing m_semiImplicitRho on the old grids during regrid operations.
Definition: CD_CdrPlasmaGodunovStepper.H:213
bool m_profile
Enable performance profiling.
Definition: CD_CdrPlasmaGodunovStepper.H:233
void allocateInternals() override
Allocate internal storage.
Definition: CD_CdrPlasmaGodunovStepper.cpp:631
void parseProfile()
Parse profiling mode.
Definition: CD_CdrPlasmaGodunovStepper.cpp:241
RefCountedPtr< SigmaStorage > m_sigmaScratch
Scratch storage for the surface charge solver.
Definition: CD_CdrPlasmaGodunovStepper.H:187
void regridInternals(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
For regridding internal storage. Does nothing.
Definition: CD_CdrPlasmaGodunovStepper.cpp:575
void parseFiltering()
Parse filtering settings.
Definition: CD_CdrPlasmaGodunovStepper.cpp:280
EBAMRCellData m_semiImplicitRho
Use for holding the "space charge" when doing semi-implicit solves.
Definition: CD_CdrPlasmaGodunovStepper.H:193
void computeCdrGradients()
Compute gradients of the CDR densities into scratch storage.
Definition: CD_CdrPlasmaGodunovStepper.cpp:796
Abstract class for evolving the minimal plasma model in time.
Definition: CD_CdrPlasmaStepper.H:39
virtual void computeCdrDriftVelocities()
Compute the CDR drift velocities.
Definition: CD_CdrPlasmaStepper.cpp:2018
Iterator class for RtLayout.
Definition: CD_RtIterator.H:24
Name containing various physics models for running chombo-discharge code.
Definition: CD_AdvectionDiffusion.H:15