chombo-discharge
CD_EBMGLeastSquaresInterpolator.H
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 
13 #ifndef CD_EBMultigridInterpolator_H
14 #define CD_EBMultigridInterpolator_H
15 
16 // Std includes
17 #include <map>
18 
19 // Chombo includes
20 #include <EBLevelGrid.H>
21 #include <QuadCFInterp.H>
22 #include <AggStencil.H>
23 
24 // Our includes
25 #include <CD_Location.H>
26 #include <CD_NamespaceHeader.H>
27 
48 {
49 public:
54 
58  EBMultigridInterpolator() = delete;
59 
64 
76  EBMultigridInterpolator(const EBLevelGrid& a_eblgFine,
77  const EBLevelGrid& a_eblgCoar,
78  const CellLocation a_dataLocation,
79  const IntVect& a_ghostVector,
80  const int a_refRat,
81  const int a_ghostCF,
82  const int a_order,
83  const int a_weighting = 0);
84 
89 
93  int
94  getGhostCF() const;
95 
102  void
103  coarseFineInterp(LevelData<EBCellFAB>& a_phiFine, const LevelData<EBCellFAB>& a_phiCoar, const Interval a_variables);
104 
114  void
115  slowCoarseFineInterp(LevelData<EBCellFAB>& a_phiFine,
116  const LevelData<EBCellFAB>& a_phiCoar,
117  const Interval a_variables);
118 
124  void
125  coarseFineInterpH(LevelData<EBCellFAB>& a_phiFine, const Interval a_variables) const;
126 
135  void
136  slowCoarseFineInterpH(LevelData<EBCellFAB>& a_phiFine, const Interval a_variables) const;
137 
147  void
148  coarseFineInterpH(EBCellFAB& a_phiFine, const Interval a_variables, const DataIndex& a_dit) const;
149 
160  void
161  slowCoarseFineInterpH(EBCellFAB& a_phiFine, const Interval a_variables, const DataIndex& a_dit) const;
162 
163 protected:
167  static constexpr int m_stenComp = 0;
168 
172  static constexpr int m_numStenComp = 1;
173 
177  static constexpr int m_comp = 0;
178 
182  RefCountedPtr<QuadCFInterp> m_scalarInterpolator;
183 
187  RefCountedPtr<QuadCFInterp> m_vectorInterpolator;
188 
193 
197  EBLevelGrid m_eblgFine;
198 
202  EBLevelGrid m_eblgCoar;
203 
207  EBLevelGrid m_eblgCoFi;
208 
213 
217  mutable BoxLayoutData<EBCellFAB> m_grownCoarData;
218 
222  mutable LayoutData<VoFIterator> m_vofIterFine;
223 
227  IntVect m_ghostVector;
228 
232  int m_refRat;
233 
239 
243  int m_order;
244 
248  int m_weight;
249 
254  LayoutData<IntVectSet> m_ghostCells;
255 
259  LayoutData<BaseIVFAB<VoFStencil>> m_fineStencils;
260 
264  LayoutData<BaseIVFAB<VoFStencil>> m_coarStencils;
265 
272  LayoutData<RefCountedPtr<AggStencil<EBCellFAB, EBCellFAB>>> m_aggFineStencils;
273 
279  LayoutData<RefCountedPtr<AggStencil<EBCellFAB, EBCellFAB>>> m_aggCoarStencils;
280 
286  LayoutData<std::map<std::pair<int, Side::LoHiSide>, Box>> m_cfivs;
287 
291  void
293 
299  void
300  defineGrids(const EBLevelGrid& a_eblgFine, const EBLevelGrid& a_eblgCoar);
301 
305  void
307 
311  void
313 
317  void
319 
337  bool
338  getStencil(VoFStencil& a_stencilFine,
339  VoFStencil& a_stencilCoar,
340  const CellLocation& a_dataLocation,
341  const VolIndex& a_ghostVofFine,
342  const VolIndex& a_ghostVofCoar,
343  const EBISBox& a_ebisboxFine,
344  const EBISBox& a_ebisboxCoar,
345  const DenseIntVectSet& a_validFineCells,
346  const DenseIntVectSet& a_validCoarCells,
347  const Real& a_dxFine,
348  const Real& a_dxCoar,
349  const int& a_order,
350  const int& a_weight);
351 };
352 
353 #include <CD_NamespaceFooter.H>
354 
355 #endif
Declaration of cell positions.
Multigrid interpolator class.
Definition: CD_EBMGLeastSquaresInterpolator.H:48
void slowCoarseFineInterpH(EBCellFAB &a_phiFine, const Interval a_variables, const DataIndex &a_dit) const
Do homogeneous coarse-fine interpolation on a grid patch.
RefCountedPtr< QuadCFInterp > m_scalarInterpolator
For regular interpolation of scalar quantities.
Definition: CD_EBMGLeastSquaresInterpolator.H:182
void defineStencilsEBCF()
Define stencils for interpolation across the EBCF refinement boundary.
void coarseFineInterpH(LevelData< EBCellFAB > &a_phiFine, const Interval a_variables) const
Do homogeneous interpolation.
BoxLayoutData< EBCellFAB > m_grownCoarData
Coarsened data.
Definition: CD_EBMGLeastSquaresInterpolator.H:217
void makeAggStencils()
Build the AggStencil objects for faster stencil aggregation.
void coarseFineInterpH(EBCellFAB &a_phiFine, const Interval a_variables, const DataIndex &a_dit) const
Do homogeneous coarse-fine interpolation on a grid patch.
EBLevelGrid m_eblgFine
Fine grids.
Definition: CD_EBMGLeastSquaresInterpolator.H:197
static constexpr int m_comp
Component number. Used for setting interval when data is copied into EBMultigridInterpolator's buffer...
Definition: CD_EBMGLeastSquaresInterpolator.H:177
EBMultigridInterpolator(const EBMultigridInterpolator &a_other)=delete
Disallowed copy constructor.
void defineGhostRegions()
Define ghost cells to be filled in range m_ghostCF from each cut-cell.
static constexpr int m_stenComp
Component that interpolation stencil is stored at.
Definition: CD_EBMGLeastSquaresInterpolator.H:167
EBLevelGrid m_eblgCoFi
Refined coarse grids.
Definition: CD_EBMGLeastSquaresInterpolator.H:207
void slowCoarseFineInterp(LevelData< EBCellFAB > &a_phiFine, const LevelData< EBCellFAB > &a_phiCoar, const Interval a_variables)
Do inhomogeneous interpolation.
void slowCoarseFineInterpH(LevelData< EBCellFAB > &a_phiFine, const Interval a_variables) const
Do homogeneous interpolation.
int getGhostCF() const
Return number of ghost cells across CF interface.
void defineGrids(const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgCoar)
Define grids.
LayoutData< RefCountedPtr< AggStencil< EBCellFAB, EBCellFAB > > > m_aggFineStencils
Fine grid interpolation stencils.
Definition: CD_EBMGLeastSquaresInterpolator.H:272
static constexpr int m_numStenComp
Number of variables in stencil data layouts.
Definition: CD_EBMGLeastSquaresInterpolator.H:172
~EBMultigridInterpolator()
Destructor (does nothing)
Definition: CD_EBMultigridInterpolator.cpp:24
EBMultigridInterpolator(const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgCoar, const CellLocation a_dataLocation, const IntVect &a_ghostVector, const int a_refRat, const int a_ghostCF, const int a_order, const int a_weighting=0)
Full constructor.
void defineBuffers()
Define data holders.
CellLocation m_dataLocation
How to interpret data locations.
Definition: CD_EBMGLeastSquaresInterpolator.H:192
IntVect m_ghostVector
Minimum number of ghost cells in input data.
Definition: CD_EBMGLeastSquaresInterpolator.H:227
BoxLayout m_grownCoarBoxesLayout
Grown box layout on the coarse level.
Definition: CD_EBMGLeastSquaresInterpolator.H:212
LayoutData< BaseIVFAB< VoFStencil > > m_fineStencils
Fine-grid interpolation stencils.
Definition: CD_EBMGLeastSquaresInterpolator.H:259
int m_ghostCF
Number of ghost cells to fill across coarse-fine interface.
Definition: CD_EBMGLeastSquaresInterpolator.H:238
LayoutData< BaseIVFAB< VoFStencil > > m_coarStencils
Coarse-grid interpolation stencils.
Definition: CD_EBMGLeastSquaresInterpolator.H:264
LayoutData< VoFIterator > m_vofIterFine
Iterator over ghost cells.
Definition: CD_EBMGLeastSquaresInterpolator.H:222
int m_weight
Least squares weighting factor.
Definition: CD_EBMGLeastSquaresInterpolator.H:248
LayoutData< RefCountedPtr< AggStencil< EBCellFAB, EBCellFAB > > > m_aggCoarStencils
Coarse-grid interpolation stencils.
Definition: CD_EBMGLeastSquaresInterpolator.H:279
RefCountedPtr< QuadCFInterp > m_vectorInterpolator
For regular interpolation of vector quantities.
Definition: CD_EBMGLeastSquaresInterpolator.H:187
EBLevelGrid m_eblgCoar
Coarse grids.
Definition: CD_EBMGLeastSquaresInterpolator.H:202
int m_refRat
Refinement factor between fine and coarse level.
Definition: CD_EBMGLeastSquaresInterpolator.H:232
LayoutData< std::map< std::pair< int, Side::LoHiSide >, Box > > m_cfivs
Regular coarse-fine interface boxes.
Definition: CD_EBMGLeastSquaresInterpolator.H:286
EBMultigridInterpolator()=delete
Disallowed constructor.
Definition: CD_EBMultigridInterpolator.cpp:19
int m_order
Interpolation order.
Definition: CD_EBMGLeastSquaresInterpolator.H:243
bool getStencil(VoFStencil &a_stencilFine, VoFStencil &a_stencilCoar, const CellLocation &a_dataLocation, const VolIndex &a_ghostVofFine, const VolIndex &a_ghostVofCoar, const EBISBox &a_ebisboxFine, const EBISBox &a_ebisboxCoar, const DenseIntVectSet &a_validFineCells, const DenseIntVectSet &a_validCoarCells, const Real &a_dxFine, const Real &a_dxCoar, const int &a_order, const int &a_weight)
Build an interpolation stencil.
LayoutData< IntVectSet > m_ghostCells
Ghost cells that will be interpolated near the cut-cells.
Definition: CD_EBMGLeastSquaresInterpolator.H:254
void coarseFineInterp(LevelData< EBCellFAB > &a_phiFine, const LevelData< EBCellFAB > &a_phiCoar, const Interval a_variables)
Do inhomogeneous interpolation.
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30