chombo-discharge
CD_EBCoarseToFineInterp.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_EBCoarseToFineInterp_H
13 #define CD_EBCoarseToFineInterp_H
14 
15 // Chombo includes
16 #include <EBLevelGrid.H>
17 #include <LevelData.H>
18 #include <EBCellFAB.H>
19 #include <BaseIVFAB.H>
20 
21 // Our includes
22 #include <CD_NamespaceHeader.H>
23 
32 {
33 public:
41  enum Type
42  {
43  PWC,
44  ConservativePWC,
45  ConservativeMinMod,
46  ConservativeMonotonizedCentral,
47  ConservativeSuperbee,
48  };
49 
53  EBCoarseToFineInterp() noexcept;
54 
64  EBCoarseToFineInterp(const EBLevelGrid& a_eblgFine,
65  const EBLevelGrid& a_eblgCoFi,
66  const EBLevelGrid& a_eblgCoar,
67  const int& a_refRat) noexcept;
68 
73 
78 
82  virtual ~EBCoarseToFineInterp() noexcept;
83 
88  operator=(const EBCoarseToFineInterp&) = delete;
89 
94  operator=(const EBCoarseToFineInterp&&) = delete;
95 
105  virtual void
106  define(const EBLevelGrid& a_eblgFine,
107  const EBLevelGrid& a_eblgCoFi,
108  const EBLevelGrid& a_eblgCoar,
109  const int& a_refRat) noexcept;
110 
118  virtual void
119  interpolate(LevelData<EBCellFAB>& a_fineData,
120  const LevelData<EBCellFAB>& a_coarData,
121  const Interval& a_variables,
122  const EBCoarseToFineInterp::Type& a_interpType) const noexcept;
123 
131  virtual void
132  interpolate(LevelData<BaseIVFAB<Real>>& a_fineData,
133  const LevelData<BaseIVFAB<Real>>& a_coarData,
134  const Interval& a_variables,
135  const EBCoarseToFineInterp::Type& a_interpType) const noexcept;
136 
137 protected:
141  enum class SlopeLimiter
142  {
143  MinMod,
144  MonotonizedCentral,
145  Superbee
146  };
147 
152 
156  int m_refRat;
157 
161  mutable Copier m_ebCopier;
162 
166  mutable std::map<IntVect, Copier> m_cellCopiers;
167 
171  EBLevelGrid m_eblgFine;
172 
176  EBLevelGrid m_eblgCoar;
177 
181  EBLevelGrid m_eblgCoFi;
182 
187  LevelData<BaseIVFAB<Real>> m_volumeWeights;
188 
193  LevelData<BaseIVFAB<Real>> m_areaWeights;
194 
199  mutable LevelData<BaseIVFAB<Real>> m_irregCoFi;
200 
205  mutable LayoutData<VoFIterator> m_fineVoFs;
206 
210  mutable LayoutData<VoFIterator> m_coarVoFs;
211 
215  virtual void
216  defineWeights() noexcept;
217 
227  virtual void
228  interpolatePWC(EBCellFAB& a_fineData,
229  const EBCellFAB& a_coarData,
230  const DataIndex& a_dit,
231  const int& a_fineVar,
232  const int& a_coarVar) const noexcept;
233 
242  virtual void
243  interpolateConservativePWC(EBCellFAB& a_fineData,
244  const EBCellFAB& a_coarData,
245  const DataIndex& a_dit,
246  const int& a_fineVar,
247  const int& a_coarVar) const noexcept;
248 
258  virtual void
259  interpolateConservativeSlope(EBCellFAB& a_fineData,
260  const EBCellFAB& a_coarData,
261  const DataIndex& a_dit,
262  const int& a_fineVar,
263  const int& a_coarVar,
264  const SlopeLimiter& a_limiter) const noexcept;
265 
275  virtual void
276  interpolatePWC(BaseIVFAB<Real>& a_fineData,
277  const BaseIVFAB<Real>& a_coarData,
278  const DataIndex& a_dit,
279  const int& a_fineVar,
280  const int& a_coarVar) const noexcept;
281 
291  virtual void
292  interpolateConservativePWC(BaseIVFAB<Real>& a_fineData,
293  const BaseIVFAB<Real>& a_coarData,
294  const DataIndex& a_dit,
295  const int& a_fineVar,
296  const int& a_coarVar) const noexcept;
297 
306  virtual void
307  checkConservation(const EBCellFAB& a_fineData,
308  const EBCellFAB& a_coarData,
309  const DataIndex& a_dit,
310  const int a_fineVar,
311  const int a_coarVar) const noexcept;
312 
321  virtual void
322  checkConservation(const BaseIVFAB<Real>& a_fineData,
323  const BaseIVFAB<Real>& a_coarData,
324  const DataIndex& a_dit,
325  const int a_fineVar,
326  const int a_coarVar) const noexcept;
327 };
328 
329 #include <CD_NamespaceFooter.H>
330 
331 #endif
Class for interpolating data to fine grids. Can use constant interpolation or include limiters.
Definition: CD_EBCoarseToFineInterp.H:32
virtual void defineWeights() noexcept
Define weights for cut-cell conservative regridding.
Definition: CD_EBCoarseToFineInterp.cpp:106
EBLevelGrid m_eblgCoar
Coarse grid.
Definition: CD_EBCoarseToFineInterp.H:176
LevelData< BaseIVFAB< Real > > m_irregCoFi
Data holder for holding data on the coarsened fine grids.
Definition: CD_EBCoarseToFineInterp.H:199
virtual void checkConservation(const EBCellFAB &a_fineData, const EBCellFAB &a_coarData, const DataIndex &a_dit, const int a_fineVar, const int a_coarVar) const noexcept
Check if the interpolation conserved. This will print an error message if it didn't.
Definition: CD_EBCoarseToFineInterp.cpp:657
LayoutData< VoFIterator > m_coarVoFs
Iterator for coarse grid cells.
Definition: CD_EBCoarseToFineInterp.H:210
LayoutData< VoFIterator > m_fineVoFs
Iterator for valid cut-cells.
Definition: CD_EBCoarseToFineInterp.H:205
bool m_isDefined
Is defined or not.
Definition: CD_EBCoarseToFineInterp.H:151
std::map< IntVect, Copier > m_cellCopiers
Map of Copiers that we need for going from valid+ghost -> valid+ghost.
Definition: CD_EBCoarseToFineInterp.H:166
LevelData< BaseIVFAB< Real > > m_volumeWeights
Weights in cut-cells when regridding conservatively.
Definition: CD_EBCoarseToFineInterp.H:187
EBLevelGrid m_eblgCoFi
Coarsened fine grid (i.e., has same ProblemDomain as m_eblgCoar);.
Definition: CD_EBCoarseToFineInterp.H:181
virtual void interpolateConservativeSlope(EBCellFAB &a_fineData, const EBCellFAB &a_coarData, const DataIndex &a_dit, const int &a_fineVar, const int &a_coarVar, const SlopeLimiter &a_limiter) const noexcept
Sloped interpolation of an EBCellFAB. Uses specified input slope.
Definition: CD_EBCoarseToFineInterp.cpp:409
virtual void interpolatePWC(EBCellFAB &a_fineData, const EBCellFAB &a_coarData, const DataIndex &a_dit, const int &a_fineVar, const int &a_coarVar) const noexcept
Piecewise constant interpolation of an EBCellFAB. This ignores the volume fraction....
Definition: CD_EBCoarseToFineInterp.cpp:291
Copier m_ebCopier
Copier for making copying from m_eblg to m_eblgCoFi go faster.
Definition: CD_EBCoarseToFineInterp.H:161
EBLevelGrid m_eblgFine
Fine grid.
Definition: CD_EBCoarseToFineInterp.H:171
virtual void interpolate(LevelData< EBCellFAB > &a_fineData, const LevelData< EBCellFAB > &a_coarData, const Interval &a_variables, const EBCoarseToFineInterp::Type &a_interpType) const noexcept
Interpolate to the fine grid using the specified method.
Definition: CD_EBCoarseToFineInterp.cpp:165
Type
Type of interpolation methods supported. PWC = Piecewise constant, ignoring the embedded boundary....
Definition: CD_EBCoarseToFineInterp.H:42
virtual void define(const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgCoFi, const EBLevelGrid &a_eblgCoar, const int &a_refRat) noexcept
Define operation. Puts object in usable state.
Definition: CD_EBCoarseToFineInterp.cpp:46
virtual void interpolateConservativePWC(EBCellFAB &a_fineData, const EBCellFAB &a_coarData, const DataIndex &a_dit, const int &a_fineVar, const int &a_coarVar) const noexcept
Piecewise constant interpolation of an EBCellFAB. Does not use slopes.
Definition: CD_EBCoarseToFineInterp.cpp:351
LevelData< BaseIVFAB< Real > > m_areaWeights
Weights in cut-cells when regridding conservatively.
Definition: CD_EBCoarseToFineInterp.H:193
int m_refRat
Refinement factor.
Definition: CD_EBCoarseToFineInterp.H:156
SlopeLimiter
Supported slope limiters for conservative interpolation with slopes.
Definition: CD_EBCoarseToFineInterp.H:142
EBCoarseToFineInterp() noexcept
Default constructor. Must subsequently call the define method.
Definition: CD_EBCoarseToFineInterp.cpp:25