chombo-discharge
CD_Realm.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_Realm_H
13 #define CD_Realm_H
14 
15 // Our includes
16 #include <CD_PhaseRealm.H>
17 #include <CD_EBAMRParticleMesh.H>
19 #include <CD_MFLevelGrid.H>
20 #include <CD_LevelTiles.H>
21 #include <CD_NamespaceHeader.H>
22 
26 static const std::string s_particle_halo = "particle_halo";
27 
31 static const std::string s_particle_valid_region = "pvr";
32 
36 using AMRMask = Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>;
37 
41 class Realm
42 {
43 public:
47  const static std::string Primal;
48 
52  const static std::string primal;
53 
57  Realm();
58 
63  Realm(const Realm& a_other) = delete;
64 
69  Realm(const Realm&& a_other) = delete;
70 
75  Realm&
76  operator=(const Realm& a_other) = delete;
77 
82  Realm&
83  operator=(const Realm&& a_other) = delete;
84 
88  ~Realm();
89 
111  void
112  define(const Vector<DisjointBoxLayout>& a_grids,
113  const Vector<ProblemDomain>& a_domains,
114  const Vector<int>& a_refRat,
115  const Vector<Real>& a_dx,
116  const RealVect a_probLo,
117  const int a_finestLevel,
118  const int a_blockingFactor,
119  const int a_ebGhost,
120  const int a_numGhost,
121  const int a_lsfGhost,
122  const int a_redistRad,
123  const int a_mgInterpOrder,
124  const int a_mgInterpRadius,
125  const int a_mgInterpWeight,
126  const IrregStencil::StencilType a_centroidStencil,
127  const IrregStencil::StencilType a_ebStencil,
128  const std::map<phase::which_phase, RefCountedPtr<BaseIF>> a_baseif,
129  const RefCountedPtr<MultiFluidIndexSpace>& a_mfis);
130 
137  void
138  setGrids(const Vector<DisjointBoxLayout>& a_grids, const int a_finestLevel);
139 
143  void
144  preRegrid();
145 
151  void
152  regridBase(const int a_lmin);
153 
159  void
160  regridOperators(const int a_lmin);
161 
168  void
169  registerOperator(const std::string a_operator, const phase::which_phase a_phase);
170 
177  bool
178  queryOperator(const std::string a_operator, const phase::which_phase a_phase) const;
179 
185  void
186  registerMask(const std::string a_mask, const int a_buffer);
187 
194  bool
195  queryMask(const std::string a_mask, const int a_buffer) const;
196 
201  const Vector<int>&
202  getRefinementRatios() const;
203 
208  const Vector<Real>&
209  getDx() const;
210 
215  const Vector<DisjointBoxLayout>&
216  getGrids() const;
217 
221  const Vector<ProblemDomain>&
222  getDomains() const;
223 
227  Vector<RefCountedPtr<MFLevelGrid>>&
228  getMFLevelGrid();
229 
234  const RefCountedPtr<EBIndexSpace>&
235  getEBIndexSpace(const phase::which_phase a_phase) const;
236 
241  const Vector<EBISLayout>&
242  getEBISLayout(const phase::which_phase a_phase) const;
243 
248  const Vector<RefCountedPtr<EBLevelGrid>>&
249  getEBLevelGrid(const phase::which_phase a_phase) const;
250 
255  const Vector<RefCountedPtr<EBLevelGrid>>&
256  getEBLevelGridCoFi(const phase::which_phase a_phase) const;
257 
262  Vector<RefCountedPtr<LayoutData<VoFIterator>>>&
263  getVofIterator(const phase::which_phase a_phase) const;
264 
270  getCentroidInterpolationStencils(const phase::which_phase a_phase) const;
271 
277  getEbCentroidInterpolationStencilStencils(const phase::which_phase a_phase) const;
278 
284  getNonConservativeDivergenceStencils(const phase::which_phase a_phase) const;
285 
290  Vector<RefCountedPtr<EBCoarAve>>&
291  getCoarseAverage(const phase::which_phase a_phase);
292 
297  Vector<RefCountedPtr<EBMultigridInterpolator>>&
298  getMultigridInterpolator(const phase::which_phase a_phase);
299 
305  getParticleMesh(const phase::which_phase a_phase);
306 
312  getSurfaceDeposition(const phase::which_phase a_phase);
313 
318  const Vector<RefCountedPtr<EBGradient>>&
319  getGradientOp(const phase::which_phase a_phase) const;
320 
325  Vector<RefCountedPtr<EBGhostCellInterpolator>>&
326  getGhostCellInterpolator(const phase::which_phase a_phase);
327 
332  Vector<RefCountedPtr<EBCoarseToFineInterp>>&
333  getFineInterp(const phase::which_phase a_phase);
334 
339  Vector<RefCountedPtr<EBReflux>>&
340  getFluxRegister(const phase::which_phase a_phase);
341 
346  Vector<RefCountedPtr<EBFluxRedistribution>>&
347  getRedistributionOp(const phase::which_phase a_phase);
348 
353  const EBAMRFAB&
354  getLevelset(const phase::which_phase a_phase) const;
355 
360  const AMRMask&
361  getMask(const std::string a_mask, const int a_buffer) const;
362 
366  const AMRMask&
367  getValidCells() const;
368 
372  const Vector<RefCountedPtr<LevelTiles>>&
373  getLevelTiles() const noexcept;
374 
375 protected:
380 
385 
390 
395 
399  RealVect m_probLo;
400 
404  Vector<Real> m_dx;
405 
409  Vector<int> m_refinementRatios;
410 
414  Vector<DisjointBoxLayout> m_grids;
415 
419  Vector<ProblemDomain> m_domains;
420 
424  Vector<RefCountedPtr<MFLevelGrid>> m_mflg;
425 
429  Vector<RefCountedPtr<LevelTiles>> m_levelTiles;
430 
435 
440 
445  mutable std::map<phase::which_phase, RefCountedPtr<PhaseRealm>> m_realms;
446 
450  std::map<phase::which_phase, RefCountedPtr<BaseIF>> m_baseif;
451 
455  std::map<std::pair<std::string, int>, AMRMask> m_masks;
456 
461  void
462  defineMFLevelGrid(const int a_lmin);
463 
468  void
469  defineMasks(const int a_lmin);
470 
475  void
476  defineHaloMasks(const int a_lmin);
477 
488  void
489  defineHaloMask(LevelData<BaseFab<bool>>& a_coarMask,
490  const ProblemDomain& a_domainCoar,
491  const ProblemDomain& a_domainFine,
492  const DisjointBoxLayout& a_gridsCoar,
493  const DisjointBoxLayout& a_gridsFine,
494  const int a_buffer,
495  const int a_refRat);
496 
501  void
503 
507  void
508  defineLevelTiles() noexcept;
509 
514  PhaseRealm&
515  getRealm(const phase::which_phase a_phase);
516 };
517 
518 #include <CD_NamespaceFooter.H>
519 
520 #endif
Declaration of a class for handling particle-mesh operations with AMR.
Declaration of LevelTiles.
Declaration of a wrapper for wrapping multifluid EBLevelGrids.
Multi-fluid index space.
Declaration of the PhaseRealm class.
Vector< RefCountedPtr< LevelData< BaseFab< bool > >> > AMRMask
Alias for cutting down on the typic of booleans defined over AMR grids.
Definition: CD_Realm.H:36
Class for handling particle-mesh operations with AMR.
Definition: CD_EBAMRParticleMesh.H:47
class for handling surface deposition of particles with EB and AMR.
Definition: CD_EBAMRSurfaceDeposition.H:29
Class for holding VoFStencils on irregular cells over an entire AMR hierarchy. The template parameter...
Definition: CD_IrregAmrStencil.H:29
StencilType
Enum for identifying stencil – only meant for enhancing code visibility.
Definition: CD_IrregStencil.H:44
Class for storing the AMR hierarchy as a collection of tiles.
Definition: CD_LevelTiles.H:33
Wrapper class for holding multifluid EBLevelGrids.
Definition: CD_MFLevelGrid.H:29
Two-fluid index space.
Definition: CD_MultiFluidIndexSpace.H:42
Class that holds important things for doing AMR over a specific phase and processor distribution.
Definition: CD_PhaseRealm.H:66
Class for holding multifluid Realms, which are the Realms that we actually use.
Definition: CD_Realm.H:42
void registerMask(const std::string a_mask, const int a_buffer)
Register a mask.
Definition: CD_Realm.cpp:534
Vector< RefCountedPtr< EBReflux > > & getFluxRegister(const phase::which_phase a_phase)
Get flux register utility.
Definition: CD_Realm.cpp:691
void defineMFLevelGrid(const int a_lmin)
Define MFLevelGrid.
Definition: CD_Realm.cpp:200
Vector< RefCountedPtr< EBCoarseToFineInterp > > & getFineInterp(const phase::which_phase a_phase)
Get piecewise linear ghost cell interpolation utility.
Definition: CD_Realm.cpp:685
Realm & operator=(const Realm &a_other)=delete
Disallowed copy assignment operator.
AMRMask m_validCells
Mask which is true for all valid cells.
Definition: CD_Realm.H:439
static const std::string primal
Identifier for perimal realm.
Definition: CD_Realm.H:52
Realm(const Realm &a_other)=delete
Disallowed copy ctor.
const IrregAmrStencil< NonConservativeDivergenceStencil > & getNonConservativeDivergenceStencils(const phase::which_phase a_phase) const
Get stencils for computing "non-conservative divergences".
Definition: CD_Realm.cpp:643
bool m_isDefined
Realm defined or not.
Definition: CD_Realm.H:379
std::map< phase::which_phase, RefCountedPtr< BaseIF > > m_baseif
Implicit/signed distance functions on each phase.
Definition: CD_Realm.H:450
Vector< ProblemDomain > m_domains
Domains.
Definition: CD_Realm.H:419
Vector< int > m_refinementRatios
Refinement ratios.
Definition: CD_Realm.H:409
Vector< RefCountedPtr< EBFluxRedistribution > > & getRedistributionOp(const phase::which_phase a_phase)
Get the redistribution operators.
Definition: CD_Realm.cpp:697
Realm(const Realm &&a_other)=delete
Disallowed move ctor.
const Vector< ProblemDomain > & getDomains() const
Get problem domains.
Definition: CD_Realm.cpp:589
void defineValidCells()
Define the valid cell region mask.
Definition: CD_Realm.cpp:408
Realm & operator=(const Realm &&a_other)=delete
Disallowed move assignment operator.
void defineHaloMask(LevelData< BaseFab< bool >> &a_coarMask, const ProblemDomain &a_domainCoar, const ProblemDomain &a_domainFine, const DisjointBoxLayout &a_gridsCoar, const DisjointBoxLayout &a_gridsFine, const int a_buffer, const int a_refRat)
Define particle halo masks. This is the level-version.
Definition: CD_Realm.cpp:273
const Vector< EBISLayout > & getEBISLayout(const phase::which_phase a_phase) const
Get EBISLayout for particular phase.
Definition: CD_Realm.cpp:607
Vector< RefCountedPtr< LayoutData< VoFIterator > > > & getVofIterator(const phase::which_phase a_phase) const
Get VoFIterators for particular phase.
Definition: CD_Realm.cpp:625
Vector< RefCountedPtr< EBMultigridInterpolator > > & getMultigridInterpolator(const phase::which_phase a_phase)
Get the multigrid interpolator.
Definition: CD_Realm.cpp:667
const Vector< RefCountedPtr< EBGradient > > & getGradientOp(const phase::which_phase a_phase) const
Get gradient operator.
Definition: CD_Realm.cpp:673
bool queryOperator(const std::string a_operator, const phase::which_phase a_phase) const
Query if an AMR operator has been registered.
Definition: CD_Realm.cpp:523
const Vector< DisjointBoxLayout > & getGrids() const
Get AMR grids.
Definition: CD_Realm.cpp:583
int m_verbosity
Realm verbosity. Used for debugging.
Definition: CD_Realm.H:384
Vector< RefCountedPtr< MFLevelGrid > > m_mflg
MFLevelGrids.
Definition: CD_Realm.H:424
Vector< RefCountedPtr< EBCoarAve > > & getCoarseAverage(const phase::which_phase a_phase)
Get data coarsening utility.
Definition: CD_Realm.cpp:649
const IrregAmrStencil< EbCentroidInterpolationStencil > & getEbCentroidInterpolationStencilStencils(const phase::which_phase a_phase) const
Get stencils for interpolating from cell center to eb centroids.
Definition: CD_Realm.cpp:637
Vector< Real > m_dx
Grid resolutions.
Definition: CD_Realm.H:404
const Vector< RefCountedPtr< EBLevelGrid > > & getEBLevelGrid(const phase::which_phase a_phase) const
Get EBLevelGrid for particular phase.
Definition: CD_Realm.cpp:613
std::map< phase::which_phase, RefCountedPtr< PhaseRealm > > m_realms
Phase realms.
Definition: CD_Realm.H:445
Vector< RefCountedPtr< EBGhostCellInterpolator > > & getGhostCellInterpolator(const phase::which_phase a_phase)
Get ghost cell interpolator.
Definition: CD_Realm.cpp:679
const AMRMask & getValidCells() const
Get all valid cells.
Definition: CD_Realm.cpp:720
const Vector< int > & getRefinementRatios() const
Get refinement ratios.
Definition: CD_Realm.cpp:571
Vector< RefCountedPtr< MFLevelGrid > > & getMFLevelGrid()
Get MFLevelGrids.
Definition: CD_Realm.cpp:595
void defineLevelTiles() noexcept
Define the tiled space.
Definition: CD_Realm.cpp:497
int m_finestLevel
Finest AMR level.
Definition: CD_Realm.H:389
void registerOperator(const std::string a_operator, const phase::which_phase a_phase)
Register an AMR operator.
Definition: CD_Realm.cpp:512
const IrregAmrStencil< CentroidInterpolationStencil > & getCentroidInterpolationStencils(const phase::which_phase a_phase) const
Get stencils for interpolating from cell center to centroids (for specified phase)
Definition: CD_Realm.cpp:631
void regridOperators(const int a_lmin)
Regrid method for EBAMR operators.
Definition: CD_Realm.cpp:173
void defineMasks(const int a_lmin)
Define masks.
Definition: CD_Realm.cpp:188
Vector< RefCountedPtr< LevelTiles > > m_levelTiles
Level "tiles" – i.e. the grids viewed as constant-size boxes.
Definition: CD_Realm.H:429
std::map< std::pair< std::string, int >, AMRMask > m_masks
Masks.
Definition: CD_Realm.H:455
int m_blockingFactor
Blocking factor.
Definition: CD_Realm.H:394
bool queryMask(const std::string a_mask, const int a_buffer) const
Query if a mask has been registered.
Definition: CD_Realm.cpp:545
const Vector< RefCountedPtr< EBLevelGrid > > & getEBLevelGridCoFi(const phase::which_phase a_phase) const
Get coarsened fine EBLevelGrid for particular phase.
Definition: CD_Realm.cpp:619
EBAMRParticleMesh & getParticleMesh(const phase::which_phase a_phase)
Get the particle mesh operator.
Definition: CD_Realm.cpp:655
const Vector< RefCountedPtr< LevelTiles > > & getLevelTiles() const noexcept
Get the tiled space.
Definition: CD_Realm.cpp:726
const Vector< Real > & getDx() const
Get grid resolutions.
Definition: CD_Realm.cpp:577
void defineHaloMasks(const int a_lmin)
Define particle halo amsks.
Definition: CD_Realm.cpp:228
PhaseRealm & getRealm(const phase::which_phase a_phase)
Get a particular realm.
Definition: CD_Realm.cpp:565
void setGrids(const Vector< DisjointBoxLayout > &a_grids, const int a_finestLevel)
Set grid method.
Definition: CD_Realm.cpp:121
RefCountedPtr< MultiFluidIndexSpace > m_multifluidIndexSpace
Index spaces.
Definition: CD_Realm.H:434
const AMRMask & getMask(const std::string a_mask, const int a_buffer) const
Get AMR mask.
Definition: CD_Realm.cpp:709
const RefCountedPtr< EBIndexSpace > & getEBIndexSpace(const phase::which_phase a_phase) const
Get EBIndexSpace for particular phase.
Definition: CD_Realm.cpp:601
Realm()
Default constructor. Must subsequently call define.
Definition: CD_Realm.cpp:26
EBAMRSurfaceDeposition & getSurfaceDeposition(const phase::which_phase a_phase)
Get the particle mesh operator.
Definition: CD_Realm.cpp:661
Vector< DisjointBoxLayout > m_grids
AMR grids.
Definition: CD_Realm.H:414
static const std::string Primal
Identifier for perimal realm.
Definition: CD_Realm.H:47
void preRegrid()
Perform pre-regrid operations.
Definition: CD_Realm.cpp:134
RealVect m_probLo
Physical coordinates of lower-left corner in simulation domain.
Definition: CD_Realm.H:399
const EBAMRFAB & getLevelset(const phase::which_phase a_phase) const
Get level-set function.
Definition: CD_Realm.cpp:703
~Realm()
Destructor.
Definition: CD_Realm.cpp:40
void define(const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< int > &a_refRat, const Vector< Real > &a_dx, const RealVect a_probLo, const int a_finestLevel, const int a_blockingFactor, const int a_ebGhost, const int a_numGhost, const int a_lsfGhost, const int a_redistRad, const int a_mgInterpOrder, const int a_mgInterpRadius, const int a_mgInterpWeight, const IrregStencil::StencilType a_centroidStencil, const IrregStencil::StencilType a_ebStencil, const std::map< phase::which_phase, RefCountedPtr< BaseIF >> a_baseif, const RefCountedPtr< MultiFluidIndexSpace > &a_mfis)
Full define function.
Definition: CD_Realm.cpp:44
void regridBase(const int a_lmin)
Regrid method for EBAMR base.
Definition: CD_Realm.cpp:156
phase names
Definition: CD_MultiFluidIndexSpace.H:27