chombo-discharge
CD_EBGradient.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_EBGradient_H
13 #define CD_EBGradient_H
14 
15 // Chombo includes
16 #include <EBLevelGrid.H>
17 #include <AggStencil.H>
18 
19 // Our includes
20 #include <CD_Location.H>
21 #include <CD_NamespaceHeader.H>
22 
43 {
44 public:
49 
53  EBGradient() = delete;
54 
58  EBGradient(const EBGradient& a_other) = delete;
59 
72  EBGradient(const EBLevelGrid& a_eblg,
73  const EBLevelGrid& a_eblgFine,
74  const EBLevelGrid& a_eblgFiCo,
75  const bool a_hasFine,
76  const Real a_dx,
77  const int a_refRat,
78  const int a_order,
79  const int a_weighting,
80  const IntVect a_ghostVector) noexcept;
81 
85  virtual ~EBGradient() noexcept;
86 
99  virtual void
100  define(const EBLevelGrid& a_eblg,
101  const EBLevelGrid& a_eblgFine,
102  const EBLevelGrid& a_eblgFiCo,
103  const bool a_hasFine,
104  const Real a_dx,
105  const int a_refRat,
106  const int a_order,
107  const int a_weighting,
108  const IntVect a_ghostVector) noexcept;
109 
115  virtual void
116  computeLevelGradient(LevelData<EBCellFAB>& a_gradient, const LevelData<EBCellFAB>& a_phi) const noexcept;
117 
126  virtual void
127  computeNormalDerivative(LevelData<EBFluxFAB>& a_gradient, const LevelData<EBCellFAB>& a_phi) const noexcept;
128 
135  virtual void
136  computeAMRGradient(LevelData<EBCellFAB>& a_gradient,
137  const LevelData<EBCellFAB>& a_phi,
138  const LevelData<EBCellFAB>& a_phiFine) const noexcept;
139 
140 protected:
144  static constexpr int m_comp = 0;
145 
149  static constexpr int m_nComp = 1;
150 
155 
159  EBLevelGrid m_eblg;
160 
164  EBLevelGrid m_eblgFine;
165 
169  EBLevelGrid m_eblgFiCo;
170 
175 
179  bool m_hasFine;
180 
184  bool m_hasEBCF;
185 
189  Real m_dx;
190 
194  Real m_dxFine;
195 
199  int m_order;
200 
205 
209  int m_refRat;
210 
214  IntVect m_ghostVector;
215 
219  Copier m_copier;
220 
225  LayoutData<BaseIVFAB<VoFStencil>> m_levelStencils;
226 
230  LayoutData<BaseIVFAB<VoFStencil>> m_ebcfStencilsCoar;
231 
235  LayoutData<BaseIVFAB<VoFStencil>> m_ebcfStencilsFine;
236 
241  LayoutData<RefCountedPtr<AggStencil<EBCellFAB, EBCellFAB>>> m_aggLevelStencils[SpaceDim];
242 
247  mutable LayoutData<VoFIterator> m_levelIterator;
248 
253  mutable LayoutData<VoFIterator> m_ebcfIterator;
254 
258  virtual void
259  defineLevelStencils() noexcept;
260 
266  virtual void
267  defineMasks(LevelData<FArrayBox>& a_coarMaskCF, LevelData<FArrayBox>& a_coarMaskInvalid) noexcept;
268 
274  virtual void
275  defineIteratorsEBCF(const LevelData<FArrayBox>& a_coarMaskCF, const LevelData<FArrayBox>& a_coarMaskInvalid) noexcept;
276 
281  virtual void
282  defineStencilsEBCF(const LevelData<FArrayBox>& a_coarMaskInvalid) noexcept;
283 
287  virtual void
288  defineBuffers() noexcept;
289 
298  virtual bool
299  getFiniteDifferenceStencil(VoFStencil& a_stencil,
300  const VolIndex& a_vof,
301  const EBISBox& a_ebisBox,
302  const DenseIntVectSet& a_invalidRegion,
303  const Real a_dx) const noexcept;
304 
321  virtual bool
322  getLeastSquaresStencil(VoFStencil& a_stencilCoar,
323  VoFStencil& a_stencilFine,
324  const VolIndex& a_vofCoar,
325  const CellLocation& a_dataLocation,
326  const EBISLayout& a_ebislCoar,
327  const EBISLayout& a_ebislFine,
328  const DataIndex& a_dit,
329  const DenseIntVectSet& a_validCellsCoar,
330  const DenseIntVectSet& a_validCellsFine,
331  const Real& a_dxCoar,
332  const Real& a_dxFine,
333  const int& a_order,
334  const int& a_weight) const noexcept;
335 
343  virtual bool
344  isFiniteDifferenceStencilValid(const IntVect& a_ivCoar,
345  const EBISBox& a_ebisBox,
346  const FArrayBox& a_invalidRegion) const noexcept;
347 
351  virtual void
352  makeAggStencils() noexcept;
353 };
354 
355 #include <CD_NamespaceFooter.H>
356 
357 #endif
Declaration of cell positions.
Class for computing gradients in an EBAMR context.
Definition: CD_EBGradient.H:43
virtual ~EBGradient() noexcept
Destructor (does nothing)
Definition: CD_EBGradient.cpp:122
EBGradient(const EBGradient &a_other)=delete
Disallowed copy constructor.
virtual void makeAggStencils() noexcept
Turn raw stencils into optimized AggStencils.
Definition: CD_EBGradient.cpp:1080
virtual bool isFiniteDifferenceStencilValid(const IntVect &a_ivCoar, const EBISBox &a_ebisBox, const FArrayBox &a_invalidRegion) const noexcept
Check if a cell can produce valid finite difference stencils.
Definition: CD_EBGradient.cpp:521
bool m_hasEBCF
True if we have EBCF crossings that require special stencils.
Definition: CD_EBGradient.H:184
virtual void computeLevelGradient(LevelData< EBCellFAB > &a_gradient, const LevelData< EBCellFAB > &a_phi) const noexcept
Compute gradient using data on the input level only.
Definition: CD_EBGradient.cpp:128
EBLevelGrid m_eblgFine
Fine grids.
Definition: CD_EBGradient.H:164
virtual void define(const EBLevelGrid &a_eblg, const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgFiCo, const bool a_hasFine, const Real a_dx, const int a_refRat, const int a_order, const int a_weighting, const IntVect a_ghostVector) noexcept
Define function.
Definition: CD_EBGradient.cpp:49
EBLevelGrid m_eblgFiCo
Refined coarse grids.
Definition: CD_EBGradient.H:169
Real m_dxFine
Resolution on finer level.
Definition: CD_EBGradient.H:194
virtual void computeAMRGradient(LevelData< EBCellFAB > &a_gradient, const LevelData< EBCellFAB > &a_phi, const LevelData< EBCellFAB > &a_phiFine) const noexcept
Compute gradient using two-level stencils (matching at EBCF).
Definition: CD_EBGradient.cpp:282
bool m_isDefined
Is defined or not.
Definition: CD_EBGradient.H:174
virtual void defineStencilsEBCF(const LevelData< FArrayBox > &a_coarMaskInvalid) noexcept
Define stencils for interpolation across the EBCF refinement boundary.
Definition: CD_EBGradient.cpp:663
Real m_dx
Resolution on this level.
Definition: CD_EBGradient.H:189
virtual bool getLeastSquaresStencil(VoFStencil &a_stencilCoar, VoFStencil &a_stencilFine, const VolIndex &a_vofCoar, const CellLocation &a_dataLocation, const EBISLayout &a_ebislCoar, const EBISLayout &a_ebislFine, const DataIndex &a_dit, const DenseIntVectSet &a_validCellsCoar, const DenseIntVectSet &a_validCellsFine, const Real &a_dxCoar, const Real &a_dxFine, const int &a_order, const int &a_weight) const noexcept
Build a gradient stencil using least squares.
Definition: CD_EBGradient.cpp:864
int m_weighting
Weight (for least squares)
Definition: CD_EBGradient.H:204
LayoutData< BaseIVFAB< VoFStencil > > m_ebcfStencilsFine
Part of EBCF gradient stencil which reaches into the coarse level.
Definition: CD_EBGradient.H:235
bool m_hasFine
True if we have a finer level (m_eblgFine is defined)
Definition: CD_EBGradient.H:179
LayoutData< BaseIVFAB< VoFStencil > > m_levelStencils
Stencils for boundaries and cut-cells.
Definition: CD_EBGradient.H:225
LayoutData< RefCountedPtr< AggStencil< EBCellFAB, EBCellFAB > > > m_aggLevelStencils[SpaceDim]
AggStencils for boundaries and cut-cells. Provides faster application of m_levelStencils.
Definition: CD_EBGradient.H:241
Copier m_copier
Pre-built copier for making copying from m_eblg to m_eblgFiCo go faster.
Definition: CD_EBGradient.H:219
virtual void defineIteratorsEBCF(const LevelData< FArrayBox > &a_coarMaskCF, const LevelData< FArrayBox > &a_coarMaskInvalid) noexcept
Define iterators and cells that need modified stencils.
Definition: CD_EBGradient.cpp:566
int m_refRat
Refinement factor between fine and coarse level.
Definition: CD_EBGradient.H:209
int m_order
Desired order for least squares stencils.
Definition: CD_EBGradient.H:199
EBLevelGrid m_eblg
Grids.
Definition: CD_EBGradient.H:159
static constexpr int m_comp
Scalar component to reach into.
Definition: CD_EBGradient.H:144
IntVect m_ghostVector
Number of ghost cells in incoming data holders.
Definition: CD_EBGradient.H:214
virtual void defineBuffers() noexcept
Define buffer data.
Definition: CD_EBGradient.cpp:772
virtual void computeNormalDerivative(LevelData< EBFluxFAB > &a_gradient, const LevelData< EBCellFAB > &a_phi) const noexcept
Compute the gradient component which is normal to the face, using centered differencing.
Definition: CD_EBGradient.cpp:211
EBGradient()=delete
Disallowed constructor.
virtual void defineMasks(LevelData< FArrayBox > &a_coarMaskCF, LevelData< FArrayBox > &a_coarMaskInvalid) noexcept
Make masks.
Definition: CD_EBGradient.cpp:430
LayoutData< VoFIterator > m_ebcfIterator
Iterator for EBCF cells.
Definition: CD_EBGradient.H:253
CellLocation m_dataLocation
How to interpret data locations.
Definition: CD_EBGradient.H:154
LayoutData< BaseIVFAB< VoFStencil > > m_ebcfStencilsCoar
Part of EBCF gradient stencil which reaches into the coarse level.
Definition: CD_EBGradient.H:230
LayoutData< VoFIterator > m_levelIterator
Iterator for boundary cells (either domain or EB)
Definition: CD_EBGradient.H:247
virtual bool getFiniteDifferenceStencil(VoFStencil &a_stencil, const VolIndex &a_vof, const EBISBox &a_ebisBox, const DenseIntVectSet &a_invalidRegion, const Real a_dx) const noexcept
Get a finite difference stencil, assuming that the data is cell-centered.
Definition: CD_EBGradient.cpp:780
virtual void defineLevelStencils() noexcept
Define level stencils.
Definition: CD_EBGradient.cpp:357
static constexpr int m_nComp
Number of components that are supported.
Definition: CD_EBGradient.H:149
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30