chombo-discharge
CD_SurfaceODESolver.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2022 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_SurfaceODESolver_H
13 #define CD_SurfaceODESolver_H
14 
15 // Std includes
16 #include <array>
17 
18 // Our includes
19 #include <CD_AmrMesh.H>
20 #include <CD_NamespaceHeader.H>
21 
26 template <int N = 1>
28 {
29 public:
30  static_assert(N > 0, "SurfaceODESolver<N> must have N > 0");
31 
37 
43  SurfaceODESolver(const RefCountedPtr<AmrMesh>& a_amr);
44 
49 
54 
58  virtual ~SurfaceODESolver();
59 
64  operator=(const SurfaceODESolver&) = delete;
65 
70  operator=(const SurfaceODESolver&&) = delete;
71 
75  virtual void
76  parseOptions() noexcept;
77 
81  virtual void
82  parseRuntimeOptions() noexcept;
83 
88  virtual void
89  setAmr(const RefCountedPtr<AmrMesh>& a_amrMesh) noexcept;
90 
95  virtual void
96  setRealm(const std::string a_realm) noexcept;
97 
102  virtual void
103  setName(const std::string a_name) noexcept;
104 
109  std::string
110  getRealm() const noexcept;
111 
116  virtual void
117  setPhase(const phase::which_phase a_phase) noexcept;
118 
123  virtual phase::which_phase
124  getPhase() const noexcept;
125 
130  virtual void
131  setVerbosity(const int a_verbosity) noexcept;
132 
137  virtual int
138  getVerbosity() const noexcept;
139 
147  virtual void
148  setTime(const int a_step, const Real a_time, const Real a_dt) noexcept;
149 
155  virtual Real
156  computeMass(const int a_comp = 0) const noexcept;
157 
164  virtual Real
165  computeMass(const EBAMRIVData& a_data, const int a_comp = 0) const noexcept;
166 
171  virtual int
172  getStep() const noexcept;
173 
178  virtual Real
179  getTime() const noexcept;
180 
185  virtual Real
186  getDt() const noexcept;
187 
192  virtual void
193  setPhi(const Real a_phi);
194 
199  virtual void
200  setPhi(const std::array<Real, N>& a_phi);
201 
207  virtual void
208  setPhi(const EBAMRIVData& a_phi);
209 
214  virtual EBAMRIVData&
215  getPhi() noexcept;
216 
221  virtual const EBAMRIVData&
222  getPhi() const noexcept;
223 
228  virtual void
229  setRHS(const Real a_rhs);
230 
235  virtual void
236  setRHS(const std::array<Real, N>& a_rhs);
237 
243  virtual void
244  setRHS(const EBAMRIVData& a_rhs);
245 
250  virtual EBAMRIVData&
251  getRHS();
252 
257  virtual const EBAMRIVData&
258  getRHS() const noexcept;
259 
264  virtual void
265  allocate() noexcept;
266 
270  virtual void
271  deallocate() noexcept;
272 
276  virtual void
277  registerOperators() noexcept;
278 
285  virtual void
286  preRegrid(const int a_lbase, const int a_oldFinestLevel) noexcept;
287 
295  virtual void
296  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept;
297 
304  virtual void
305  resetElectrodes(const Real a_value) noexcept;
306 
314  virtual void
315  resetElectrodes(EBAMRIVData& a_phi, const Real a_value) const noexcept;
316 
323  virtual void
324  resetDielectrics(const Real a_value) noexcept;
325 
333  virtual void
334  resetDielectrics(EBAMRIVData& a_phi, const Real a_value) const noexcept;
335 
336 #ifdef CH_USE_HDF5
342  virtual void
343  writeCheckpointLevel(HDF5Handle& a_handle, const int a_level) const noexcept;
344 #endif
345 
346 #ifdef CH_USE_HDF5
352  virtual void
353  readCheckpointLevel(HDF5Handle& a_handle, const int a_level) noexcept;
354 #endif
355 
360  virtual void
361  writePlotFile() const noexcept;
362 
366  virtual int
367  getNumberOfPlotVariables() const noexcept;
368 
373  virtual Vector<std::string>
374  getPlotVariableNames() const noexcept;
375 
385  virtual void
386  writePlotData(LevelData<EBCellFAB>& a_output,
387  int& a_comp,
388  const std::string a_outputRealm,
389  const int a_level) const noexcept;
390 
391 protected:
395  std::string m_realm;
396 
400  std::string m_className;
401 
405  std::string m_name;
406 
410  phase::which_phase m_phase;
411 
416 
420  bool m_plotPhi;
421 
425  bool m_plotRHS;
426 
430  RefCountedPtr<MultiFluidIndexSpace> m_mfis;
431 
435  RefCountedPtr<AmrMesh> m_amr;
436 
441  Vector<RefCountedPtr<LayoutData<VoFIterator>>> m_electrodeVoFs;
442 
446  Vector<RefCountedPtr<LayoutData<VoFIterator>>> m_dielectricVoFs;
447 
452 
457 
462 
467 
471  int m_step;
472 
476  Real m_time;
477 
481  Real m_dt;
482 
486  void
487  parseVerbosity() noexcept;
488 
492  void
493  parseRegrid() noexcept;
494 
498  void
499  parsePlotVariables() noexcept;
500 
504  void
505  defineVoFIterators() noexcept;
506 };
507 
508 #include <CD_NamespaceFooter.H>
509 
511 
512 #endif
Declaration of core class for handling AMR-related operations (with embedded boundaries)
Implementation of CD_SurfaceODESolver.H.
Class for handling spatial operations.
Definition: CD_AmrMesh.H:44
Two-fluid index space.
Definition: CD_MultiFluidIndexSpace.H:42
Surface ODE solver.
Definition: CD_SurfaceODESolver.H:28
virtual void setName(const std::string a_name) noexcept
Set the solver name.
Definition: CD_SurfaceODESolverImplem.H:187
Real m_dt
Time increment.
Definition: CD_SurfaceODESolver.H:481
virtual int getVerbosity() const noexcept
Get verbosity.
Definition: CD_SurfaceODESolverImplem.H:247
virtual EBAMRIVData & getRHS()
Get internal state.
Definition: CD_SurfaceODESolverImplem.H:468
void parseVerbosity() noexcept
Parse verbosity.
Definition: CD_SurfaceODESolverImplem.H:90
SurfaceODESolver & operator=(const SurfaceODESolver &)=delete
Disallowed assignment operator.
virtual EBAMRIVData & getPhi() noexcept
Get internal state.
Definition: CD_SurfaceODESolverImplem.H:406
virtual void setRHS(const Real a_rhs)
Convenience function for setting m_rhs.
Definition: CD_SurfaceODESolverImplem.H:430
virtual phase::which_phase getPhase() const noexcept
Get phase.
Definition: CD_SurfaceODESolverImplem.H:223
virtual void setRealm(const std::string a_realm) noexcept
Set the realm.
Definition: CD_SurfaceODESolverImplem.H:175
std::string m_name
Solver name.
Definition: CD_SurfaceODESolver.H:405
virtual void resetElectrodes(const Real a_value) noexcept
Reset m_phi on electrode cells.
Definition: CD_SurfaceODESolverImplem.H:622
virtual int getStep() const noexcept
Get current time step.
Definition: CD_SurfaceODESolverImplem.H:332
virtual void parseOptions() noexcept
Parse solver options.
Definition: CD_SurfaceODESolverImplem.H:62
void parsePlotVariables() noexcept
Parse plot variables.
Definition: CD_SurfaceODESolverImplem.H:130
virtual void setPhase(const phase::which_phase a_phase) noexcept
Set phase.
Definition: CD_SurfaceODESolverImplem.H:211
SurfaceODESolver(const SurfaceODESolver &)=delete
Disallowed copy constructor.
EBAMRIVData m_cache
Cached state used during regridding.
Definition: CD_SurfaceODESolver.H:456
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amrMesh) noexcept
Set the amr object.
Definition: CD_SurfaceODESolverImplem.H:161
SurfaceODESolver()
Default constructor. Must subsequently set AmrMesh.
Definition: CD_SurfaceODESolverImplem.H:25
void parseRegrid() noexcept
Parse regrid method.
Definition: CD_SurfaceODESolverImplem.H:104
virtual void allocate() noexcept
Allocate internal storage for this class.
Definition: CD_SurfaceODESolverImplem.H:492
virtual Real getDt() const noexcept
Get last time step.
Definition: CD_SurfaceODESolverImplem.H:356
std::string getRealm() const noexcept
Get the realm where the solver is registered.
Definition: CD_SurfaceODESolverImplem.H:199
int m_step
Time step.
Definition: CD_SurfaceODESolver.H:471
Real m_time
Current time.
Definition: CD_SurfaceODESolver.H:476
bool m_plotRHS
Plot rhs or not.
Definition: CD_SurfaceODESolver.H:425
RefCountedPtr< AmrMesh > m_amr
AMR; needed for grid stuff.
Definition: CD_SurfaceODESolver.H:435
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel) noexcept
Pre-regrid function.
Definition: CD_SurfaceODESolverImplem.H:585
std::string m_className
Class name.
Definition: CD_SurfaceODESolver.H:400
SurfaceODESolver & operator=(const SurfaceODESolver &&)=delete
Disallowed assignment operator.
bool m_plotPhi
Plot phi or not.
Definition: CD_SurfaceODESolver.H:420
virtual ~SurfaceODESolver()
Destructor (does nothing).
Definition: CD_SurfaceODESolverImplem.H:52
virtual Real getTime() const noexcept
Get current time.
Definition: CD_SurfaceODESolverImplem.H:344
virtual void setVerbosity(const int a_verbosity) noexcept
Set verbosity.
Definition: CD_SurfaceODESolverImplem.H:235
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_comp, const std::string a_outputRealm, const int a_level) const noexcept
Write output data to a_output.
Definition: CD_SurfaceODESolverImplem.H:819
virtual void setPhi(const Real a_phi)
Convenience function for setting m_phi.
Definition: CD_SurfaceODESolverImplem.H:368
EBAMRIVData m_phi
State. Stored on cut-cells.
Definition: CD_SurfaceODESolver.H:451
bool m_conservativeRegrid
Conservative regrid or not.
Definition: CD_SurfaceODESolver.H:415
std::string m_realm
Realm where this solver is registered.
Definition: CD_SurfaceODESolver.H:395
RefCountedPtr< MultiFluidIndexSpace > m_mfis
Index spaces.
Definition: CD_SurfaceODESolver.H:430
virtual Real computeMass(const int a_comp=0) const noexcept
Compute the total mass for component a_comp in m_phi.
Definition: CD_SurfaceODESolverImplem.H:273
virtual Vector< std::string > getPlotVariableNames() const noexcept
Get output plot names.
Definition: CD_SurfaceODESolverImplem.H:892
Vector< RefCountedPtr< LayoutData< VoFIterator > > > m_dielectricVoFs
Cut-cells that are also dielectric cells. This does not include ghost cells.
Definition: CD_SurfaceODESolver.H:446
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept
Regrid function.
Definition: CD_SurfaceODESolverImplem.H:603
virtual void registerOperators() noexcept
Register operators.
Definition: CD_SurfaceODESolverImplem.H:571
EBAMRIVData m_rhs
Right-hand side.
Definition: CD_SurfaceODESolver.H:461
int m_verbosity
Solver verbosity.
Definition: CD_SurfaceODESolver.H:466
virtual void deallocate() noexcept
Deallocate internal storage.
Definition: CD_SurfaceODESolverImplem.H:509
virtual void parseRuntimeOptions() noexcept
Parse runtime solver options.
Definition: CD_SurfaceODESolverImplem.H:76
SurfaceODESolver(const SurfaceODESolver &&)=delete
Disallowed move constructor.
virtual void writePlotFile() const noexcept
Write a plot file.
Definition: CD_SurfaceODESolverImplem.H:766
phase::which_phase m_phase
Phase where the data lives.
Definition: CD_SurfaceODESolver.H:410
virtual void setTime(const int a_step, const Real a_time, const Real a_dt) noexcept
Set the time.
Definition: CD_SurfaceODESolverImplem.H:259
void defineVoFIterators() noexcept
Define iterators for iterating over cell subsets.
Definition: CD_SurfaceODESolverImplem.H:522
virtual int getNumberOfPlotVariables() const noexcept
Get number of variables to be plotted.
Definition: CD_SurfaceODESolverImplem.H:870
Vector< RefCountedPtr< LayoutData< VoFIterator > > > m_electrodeVoFs
Cut-cells that are electrode cells. This does not include ghost cells.
Definition: CD_SurfaceODESolver.H:441
virtual void resetDielectrics(const Real a_value) noexcept
Reset m_phi on dielectric cells.
Definition: CD_SurfaceODESolverImplem.H:667
phase names
Definition: CD_MultiFluidIndexSpace.H:27