chombo-discharge
CD_RtSolver.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_RtSolver_H
13 #define CD_RtSolver_H
14 
15 // Std includes
16 #include <functional>
17 
18 // Our includes
20 #include <CD_AmrMesh.H>
21 #include <CD_RtSpecies.H>
22 #include <CD_Location.H>
23 #include <CD_NamespaceHeader.H>
24 
29 class RtSolver
30 {
31 public:
35  RtSolver();
36 
40  virtual ~RtSolver();
41 
45  virtual std::string
46  getName();
47 
51  virtual const std::string
52  getRealm() const;
53 
57  virtual void
58  parseOptions() = 0;
59 
63  virtual void
65 
71  virtual bool
72  advance(const Real a_dt, const bool a_zeroPhi = false);
73 
80  virtual bool
81  advance(const Real a_dt, EBAMRCellData& a_phi, const bool a_zeroPhi = false);
82 
90  virtual bool
91  advance(const Real a_dt, EBAMRCellData& a_phi, const EBAMRCellData& a_source, const bool a_zeroPhi = false) = 0;
92 
97  virtual void
98  setRealm(const std::string a_realm);
99 
104  virtual void
105  setRtSpecies(const RefCountedPtr<RtSpecies>& a_species);
106 
111  virtual void
112  setComputationalGeometry(const RefCountedPtr<ComputationalGeometry> a_computationalGeometry);
113 
123  virtual void
124  computeLoads(Vector<long long>& a_loads, const DisjointBoxLayout& a_dbl, const int a_level) const noexcept;
125 
130  virtual void
131  setAmr(const RefCountedPtr<AmrMesh>& a_amr);
132 
138  virtual void
139  setPhase(phase::which_phase a_phase = phase::gas);
140 
145  virtual void
146  setVerbosity(const int a_verbosity);
147 
155  virtual void
156  setTime(const int a_step, const Real a_time, const Real a_dt);
157 
162  virtual void
163  setStationary(const bool a_stationary);
164 
168  virtual void
169  sanityCheck();
170 
174  virtual bool
175  isStationary();
176 
182  virtual void
183  computeBoundaryFlux(EBAMRIVData& a_ebFlux, const EBAMRCellData& a_phi) = 0;
184 
190  virtual void
191  computeDomainFlux(EBAMRIFData& a_domainflux, const EBAMRCellData& a_phi) = 0;
192 
200  virtual void
201  computeFlux(EBAMRCellData& a_flux, const EBAMRCellData& a_phi) = 0;
202 
209  virtual void
210  computeDensity(EBAMRCellData& a_isotropic, const EBAMRCellData& a_phi) = 0;
211 
215  virtual void
216  allocate() = 0;
217 
221  virtual void
222  deallocate() = 0;
223 
229  virtual void
230  preRegrid(const int a_lbase, const int a_oldFinestLevel) = 0;
231 
238  virtual void
239  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) = 0;
240 
244  virtual void
246 
251  virtual void
252  initialData();
253 
258  virtual void
259  setSource(const EBAMRCellData& a_source);
260 
265  virtual void
266  setSource(const Real a_source);
267 
272  virtual void
273  setSource(const std::function<Real(const RealVect a_pos)> a_source);
274 
278  virtual void
280 
285  virtual int
286  getNumberOfPlotVariables() const;
287 
291  virtual Vector<std::string>
292  getPlotVariableNames() const;
293 
302  virtual void
303  writePlotData(LevelData<EBCellFAB>& a_output,
304  int& a_comp,
305  const std::string a_outputRealm,
306  const int a_level) const noexcept;
307 
308 #ifdef CH_USE_HDF5
314  virtual void
315  writeCheckpointLevel(HDF5Handle& a_handle, const int a_level) const = 0;
316 #endif
317 
318 #ifdef CH_USE_HDF5
324  virtual void
325  readCheckpointLevel(HDF5Handle& a_handle, const int a_level) = 0;
326 #endif
327 
332  virtual Real
333  getTime() const;
334 
339  virtual phase::which_phase
340  getPhase();
341 
346  virtual EBAMRCellData&
347  getPhi();
348 
353  virtual EBAMRCellData&
354  getSource();
355 
360  virtual EBAMRFluxData&
361  getKappa();
362 
367  virtual EBAMRIVData&
368  getKappaEb();
369 
373  virtual RefCountedPtr<RtSpecies>&
374  getSpecies();
375 
376 protected:
380  static constexpr int m_comp = 0;
381 
385  static constexpr int m_nComp = 1;
386 
391 
395  std::string m_realm;
396 
400  RefCountedPtr<EBIndexSpace> m_ebis;
401 
405  RefCountedPtr<RtSpecies> m_rtSpecies;
406 
410  RefCountedPtr<ComputationalGeometry> m_computationalGeometry;
411 
415  RefCountedPtr<AmrMesh> m_amr;
416 
420  phase::which_phase m_phase;
421 
425  std::string m_name;
426 
430  std::string m_className;
431 
436 
443 
450 
455 
460 
464  Real m_time;
465 
469  Real m_dt;
470 
475 
479  bool m_plotPhi;
480 
485 
489  int m_verbosity;
490 
495 
499  void
500  setEbIndexSpace(const RefCountedPtr<EBIndexSpace>& a_ebis);
501 
505  void
506  parseVerbosity() noexcept;
507 
518  virtual void
519  writeData(LevelData<EBCellFAB>& a_output,
520  int& a_comp,
521  const EBAMRCellData& a_data,
522  const std::string a_outputRealm,
523  const int a_level,
524  const bool a_interpToCentroids,
525  const bool a_interpGhost) const noexcept;
526 };
527 
528 #include <CD_NamespaceFooter.H>
529 
530 #endif
Declaration of core class for handling AMR-related operations (with embedded boundaries)
Declaration of base class for defining geometries.
Declaration of cell positions.
Declaration of a class which supplies a user interface to radiative transfer code.
Abstract RTE solver class for doing various kinds of radiative transfer equations....
Definition: CD_RtSolver.H:30
virtual void setRtSpecies(const RefCountedPtr< RtSpecies > &a_species)
Set the radiative transfer species (RtSpecies)
Definition: CD_RtSolver.cpp:95
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amr)
Set the amr object.
Definition: CD_RtSolver.cpp:158
EBAMRFluxData m_kappa
Absorption coefficient.
Definition: CD_RtSolver.H:454
void setEbIndexSpace(const RefCountedPtr< EBIndexSpace > &a_ebis)
Set ebis.
Definition: CD_RtSolver.cpp:147
virtual void computeDensity(EBAMRCellData &a_isotropic, const EBAMRCellData &a_phi)=0
Get isotropic part.
virtual Real getTime() const
Get current time.
Definition: CD_RtSolver.cpp:392
virtual phase::which_phase getPhase()
Get the RTE phase.
Definition: CD_RtSolver.cpp:403
RtSolver()
Constructor.
Definition: CD_RtSolver.cpp:24
virtual EBAMRCellData & getPhi()
Get solver state.
Definition: CD_RtSolver.cpp:414
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_RtSolver.cpp:296
virtual void computeLoads(Vector< long long > &a_loads, const DisjointBoxLayout &a_dbl, const int a_level) const noexcept
Get computational loads for a specific grid level.
Definition: CD_RtSolver.cpp:457
virtual void deallocate()=0
Deallocate internal storage.
static constexpr int m_nComp
Default number of components.
Definition: CD_RtSolver.H:385
EBAMRCellData m_source
Source term.
Definition: CD_RtSolver.H:449
std::string m_realm
Realm where this solver lives.
Definition: CD_RtSolver.H:395
void parseVerbosity() noexcept
Parse verbosity.
Definition: CD_RtSolver.cpp:444
virtual RefCountedPtr< RtSpecies > & getSpecies()
Get species.
Definition: CD_RtSolver.cpp:438
virtual void computeDomainFlux(EBAMRIFData &a_domainflux, const EBAMRCellData &a_phi)=0
Compute the domain flux given a state (a_phi will be different for different RTE approximations)
RefCountedPtr< AmrMesh > m_amr
AMR; needed for grid stuff.
Definition: CD_RtSolver.H:415
EBAMRIVData m_kappaEB
Absorption coefficient on EB faces.
Definition: CD_RtSolver.H:459
virtual bool advance(const Real a_dt, EBAMRCellData &a_phi, const EBAMRCellData &a_source, const bool a_zeroPhi=false)=0
Advance method. Advances one time step.
virtual void setPhase(phase::which_phase a_phase=phase::gas)
Set phase.
Definition: CD_RtSolver.cpp:107
virtual void allocate()=0
Allocate internal storage.
virtual int getNumberOfPlotVariables() const
Get number of output fields.
Definition: CD_RtSolver.cpp:256
virtual void setVerbosity(const int a_verbosity)
Set verbosity.
Definition: CD_RtSolver.cpp:193
Real m_dt
Time increment.
Definition: CD_RtSolver.H:469
virtual EBAMRIVData & getKappaEb()
Get the absorption coefficient on irregular EB faces.
Definition: CD_RtSolver.cpp:432
virtual void computeFlux(EBAMRCellData &a_flux, const EBAMRCellData &a_phi)=0
Compute the flux.
virtual EBAMRFluxData & getKappa()
Get the absorption length.
Definition: CD_RtSolver.cpp:426
bool m_plotSource
Output source term.
Definition: CD_RtSolver.H:484
virtual void sanityCheck()
Sanity check.
Definition: CD_RtSolver.cpp:118
virtual void setTime(const int a_step, const Real a_time, const Real a_dt)
Set the time for this solver.
Definition: CD_RtSolver.cpp:169
virtual void computeBoundaryFlux(EBAMRIVData &a_ebFlux, const EBAMRCellData &a_phi)=0
Compute the boundary flux given a state (a_phi will be different for different RTE approximations)
virtual void parseOptions()=0
Parse options.
virtual ~RtSolver()
Constructor (does nothing)
Definition: CD_RtSolver.cpp:34
virtual Vector< std::string > getPlotVariableNames() const
Get output plot names.
Definition: CD_RtSolver.cpp:276
EBAMRCellData m_phi
Internal state.
Definition: CD_RtSolver.H:442
std::string m_name
Name for this solver.
Definition: CD_RtSolver.H:425
RefCountedPtr< ComputationalGeometry > m_computationalGeometry
Computational geometry.
Definition: CD_RtSolver.H:410
virtual void writePlotFile()=0
Write plot file.
phase::which_phase m_phase
Phase.
Definition: CD_RtSolver.H:420
bool m_plotPhi
Output state.
Definition: CD_RtSolver.H:479
virtual void initialData()
Fill solver with initial data. By default, this sets internal data to zero.
Definition: CD_RtSolver.cpp:245
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel)=0
Perform pre-regrid operations.
virtual EBAMRCellData & getSource()
Get multifluid source.
Definition: CD_RtSolver.cpp:420
EBAMRCellData m_cachePhi
Cached state used for regridding.
Definition: CD_RtSolver.H:435
virtual bool isStationary()
Check if solver is stationary.
Definition: CD_RtSolver.cpp:52
virtual void registerOperators()=0
Register operators.
std::string m_className
Class name – needed because inherited classes will be named different.
Definition: CD_RtSolver.H:430
virtual void setComputationalGeometry(const RefCountedPtr< ComputationalGeometry > a_computationalGeometry)
Set computational geometry.
Definition: CD_RtSolver.cpp:132
virtual void setRealm(const std::string a_realm)
Set realm where this solver lives.
Definition: CD_RtSolver.cpp:84
virtual void setStationary(const bool a_stationary)
Set stationary solver or not.
Definition: CD_RtSolver.cpp:182
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel)=0
Regrid this solver.
Real m_time
Time.
Definition: CD_RtSolver.H:464
RefCountedPtr< EBIndexSpace > m_ebis
EBIndexSpace for this solver.
Definition: CD_RtSolver.H:400
virtual const std::string getRealm() const
Get the realm where the solver lives.
Definition: CD_RtSolver.cpp:46
Location::Cell m_dataLocation
Data location.
Definition: CD_RtSolver.H:390
virtual void writeData(LevelData< EBCellFAB > &a_output, int &a_comp, const EBAMRCellData &a_data, const std::string a_outputRealm, const int a_level, const bool a_interpToCentroids, const bool a_interpGhost) const noexcept
Write data to output. Convenience function.
Definition: CD_RtSolver.cpp:318
virtual void setSource(const EBAMRCellData &a_source)
Set source term.
Definition: CD_RtSolver.cpp:204
static constexpr int m_comp
Default component that we solve for.
Definition: CD_RtSolver.H:380
virtual void parseRuntimeOptions()=0
Parse runtime options.
RefCountedPtr< RtSpecies > m_rtSpecies
Radiative transfer species (contains meta-information like initial conditions)
Definition: CD_RtSolver.H:405
virtual std::string getName()
Get solver name.
Definition: CD_RtSolver.cpp:40
int m_timeStep
Time step.
Definition: CD_RtSolver.H:494
bool m_stationary
Stationary solver or not.
Definition: CD_RtSolver.H:474
virtual bool advance(const Real a_dt, const bool a_zeroPhi=false)
Advance equation one time step.
Definition: CD_RtSolver.cpp:58
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30