chombo-discharge
CD_MFHelmholtzJumpBC.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_MFHelmholtzJumpBC_H
13 #define CD_MFHelmholtzJumpBC_H
14 
15 // Chombo includes
16 #include <MFCellFAB.H>
17 #include <EBISBox.H>
18 #include <LayoutData.H>
19 #include <Stencils.H>
20 #include <AggStencil.H>
21 #include <EBCellFAB.H>
22 #include <BaseIVFAB.H>
23 
24 // Our includes
25 #include <CD_Location.H>
26 #include <CD_MFLevelGrid.H>
27 #include <CD_VofUtils.H>
28 #include <CD_MFInterfaceFAB.H>
29 #include <CD_MFBaseIVFAB.H>
30 #include <CD_NamespaceHeader.H>
31 
42 {
43 public:
47  using BcoefPtr = RefCountedPtr<LevelData<MFBaseIVFAB>>;
48 
52  MFHelmholtzJumpBC() = delete;
53 
66  MFHelmholtzJumpBC(const Location::Cell a_dataLocation,
67  const MFLevelGrid& a_mflg,
68  const BcoefPtr& a_Bcoef,
69  const Real a_dx,
70  const int a_order,
71  const int a_weight,
72  const int a_radius,
73  const int a_ghostCF,
74  const IntVect a_ghostPhi);
75 
79  MFHelmholtzJumpBC(const MFHelmholtzJumpBC& a_other) = delete;
80 
84  virtual ~MFHelmholtzJumpBC();
85 
90  operator=(const MFHelmholtzJumpBC& a_other) = delete;
91 
96  void
97  setBco(const RefCountedPtr<LevelData<MFBaseIVFAB>>& a_Bcoef);
98 
103  bool
104  isMultiPhase() const noexcept;
105 
109  int
110  getOrder() const;
111 
115  int
116  getWeight() const;
117 
121  int
122  getRadius() const;
123 
130  virtual void
131  matchBC(LevelData<BaseIVFAB<Real>>& a_jump, const LevelData<MFCellFAB>& a_phi, const bool a_homogeneousPhysBC) const;
132 
140  virtual void
141  matchBC(BaseIVFAB<Real>& a_jump,
142  const MFCellFAB& a_phi,
143  const bool a_homogeneousPhysBC,
144  const DataIndex& a_dit) const;
145 
152  virtual const BaseIVFAB<Real>&
153  getBndryPhi(const int a_phase, const DataIndex& a_dit) const;
154 
158  virtual VoFIterator&
159  getSinglePhaseVofs(const int a_phase, const DataIndex& a_dit) const;
160 
164  virtual VoFIterator&
165  getMultiPhaseVofs(const int a_phase, const DataIndex& a_dit) const;
166 
170  virtual const LayoutData<MFInterfaceFAB<VoFStencil>>&
171  getGradPhiStencils() const noexcept;
172 
176  virtual const LayoutData<MFInterfaceFAB<Real>>&
177  getGradPhiWeights() const noexcept;
178 
182  virtual void
183  resetBC() const;
184 
185 protected:
189  static constexpr int m_comp = 0;
190 
194  static constexpr int m_nComp = 1;
195 
200 
205 
209  RefCountedPtr<LevelData<MFBaseIVFAB>> m_Bcoef;
210 
214  Real m_dx;
215 
219  int m_order;
220 
224  int m_weight;
225 
229  int m_radius;
230 
235 
240 
244  IntVect m_ghostPhi;
245 
250 
254  mutable LayoutData<MFInterfaceFAB<Real>> m_boundaryPhi;
255 
259  mutable std::map<int, std::shared_ptr<LayoutData<VoFIterator>>> m_singlePhaseVofs;
260 
264  mutable std::map<int, std::shared_ptr<LayoutData<VoFIterator>>> m_multiPhaseVofs;
265 
269  LayoutData<IntVectSet> m_ivs;
270 
274  LayoutData<MFInterfaceFAB<VoFStencil>> m_gradPhiStencils;
275 
279  LayoutData<MFInterfaceFAB<Real>> m_gradPhiWeights;
280 
284  LayoutData<MFInterfaceFAB<VoFStencil>> m_avgStencils;
285 
289  LayoutData<MFInterfaceFAB<Vector<VolIndex>>> m_avgVoFs;
290 
294  LayoutData<MFInterfaceFAB<Real>> m_denom;
295 
299  LayoutData<MFInterfaceFAB<Real>> m_avgWeights;
300 
304  LayoutData<RefCountedPtr<AggStencil<EBCellFAB, BaseIVFAB<Real>>>> m_aggStencils[2];
305 
309  void
310  defineStencils();
311 
315  void
316  defineIterators();
317 
321  void
323 
334  virtual bool
335  getLeastSquaresBoundaryGradStencil(std::pair<Real, VoFStencil>& a_stencil,
336  const VolIndex& a_vof,
337  const EBISBox& a_ebisbox,
338  const VofUtils::Neighborhood a_neighborhood,
339  const int a_order) const;
340 
347  inline bool
348  isStencilValidCF(const VoFStencil& a_stencil, const DataIndex& a_dit) const;
349 
356  inline Real
357  applyStencil(const VoFStencil& a_stencil, const EBCellFAB& a_phi) const;
358 };
359 
360 #include <CD_NamespaceFooter.H>
361 
362 #include <CD_MFHelmholtzJumpBCImplem.H>
363 
364 #endif
Declaration of cell positions.
Declaration of a multiphase BaseIVFAB<Real>
Declaration of a class that allocates irregular data holders over the interface between two phases.
Declaration of a wrapper for wrapping multifluid EBLevelGrids.
Various functions for getting Vofs near cut-cells.
Multiphase BaseIVFAB<Real>.
Definition: CD_MFBaseIVFAB.H:29
Class for computing "jump interface" boundary conditions for multifluid code.
Definition: CD_MFHelmholtzJumpBC.H:42
virtual VoFIterator & getSinglePhaseVofs(const int a_phase, const DataIndex &a_dit) const
Return vof iterator which iterates over single-phase cells on a specific phase and box.
Definition: CD_MFHelmholtzJumpBC.cpp:88
static constexpr int m_comp
Component where stencils are stored.
Definition: CD_MFHelmholtzJumpBC.H:189
Real m_dx
Grid resolution.
Definition: CD_MFHelmholtzJumpBC.H:214
MFHelmholtzJumpBC & operator=(const MFHelmholtzJumpBC &a_other)=delete
Disallowed assignment constructor.
LayoutData< MFInterfaceFAB< VoFStencil > > m_avgStencils
Average stencil.
Definition: CD_MFHelmholtzJumpBC.H:284
LayoutData< MFInterfaceFAB< Real > > m_boundaryPhi
Value of phi on the boundary.
Definition: CD_MFHelmholtzJumpBC.H:254
LayoutData< MFInterfaceFAB< Real > > m_denom
Denominator 1/(bp*wp + bq*wq) for all interface cells.
Definition: CD_MFHelmholtzJumpBC.H:294
int m_ghostCF
Number of grid cells that were filled over the CF.
Definition: CD_MFHelmholtzJumpBC.H:234
virtual const LayoutData< MFInterfaceFAB< Real > > & getGradPhiWeights() const noexcept
Get constant weights involved when computing dphi/dn at the boundary.
Definition: CD_MFHelmholtzJumpBC.cpp:106
LayoutData< MFInterfaceFAB< Real > > m_gradPhiWeights
Raw weights for dphi/dn.
Definition: CD_MFHelmholtzJumpBC.H:279
Real applyStencil(const VoFStencil &a_stencil, const EBCellFAB &a_phi) const
Apply a stencil and return the result.
Definition: CD_MFHelmholtzJumpBCImplem.H:69
RefCountedPtr< LevelData< MFBaseIVFAB > > m_Bcoef
B-coefficient.
Definition: CD_MFHelmholtzJumpBC.H:209
virtual void matchBC(LevelData< BaseIVFAB< Real >> &a_jump, const LevelData< MFCellFAB > &a_phi, const bool a_homogeneousPhysBC) const
Match the BC.
Definition: CD_MFHelmholtzJumpBC.cpp:535
virtual bool getLeastSquaresBoundaryGradStencil(std::pair< Real, VoFStencil > &a_stencil, const VolIndex &a_vof, const EBISBox &a_ebisbox, const VofUtils::Neighborhood a_neighborhood, const int a_order) const
Get stencil with specified order.
Definition: CD_MFHelmholtzJumpBC.cpp:476
bool isMultiPhase() const noexcept
Is multiphase or not.
Definition: CD_MFHelmholtzJumpBC.cpp:123
int m_numPhases
Number of phases.
Definition: CD_MFHelmholtzJumpBC.H:239
int m_order
Stencil order.
Definition: CD_MFHelmholtzJumpBC.H:219
LayoutData< RefCountedPtr< AggStencil< EBCellFAB, BaseIVFAB< Real > > > > m_aggStencils[2]
Agg stencils for making matching go faster.
Definition: CD_MFHelmholtzJumpBC.H:304
virtual const LayoutData< MFInterfaceFAB< VoFStencil > > & getGradPhiStencils() const noexcept
Get stencils for computing dphi/dn at the boundary.
Definition: CD_MFHelmholtzJumpBC.cpp:100
int m_radius
Stencil order.
Definition: CD_MFHelmholtzJumpBC.H:229
int getWeight() const
Return stencil weight (for least squares)
Definition: CD_MFHelmholtzJumpBC.cpp:70
RefCountedPtr< LevelData< MFBaseIVFAB > > BcoefPtr
Alias to cut down on typing.
Definition: CD_MFHelmholtzJumpBC.H:47
MFHelmholtzJumpBC(const MFHelmholtzJumpBC &a_other)=delete
Disallowed copy constructor.
LayoutData< MFInterfaceFAB< Real > > m_avgWeights
Average weights.
Definition: CD_MFHelmholtzJumpBC.H:299
Location::Cell m_dataLocation
Data centering.
Definition: CD_MFHelmholtzJumpBC.H:199
MFHelmholtzJumpBC()=delete
Disallowed weak construction.
IntVect m_ghostPhi
Number of ghost cells in phi (must be exact match in order to use AggStencil)
Definition: CD_MFHelmholtzJumpBC.H:244
void defineIterators()
Define function. Builds stencils.
Definition: CD_MFHelmholtzJumpBC.cpp:421
bool isStencilValidCF(const VoFStencil &a_stencil, const DataIndex &a_dit) const
Check if stencil is valid.
Definition: CD_MFHelmholtzJumpBCImplem.H:23
void defineStencils()
Define function. Builds stencils.
Definition: CD_MFHelmholtzJumpBC.cpp:131
void buildAverageStencils()
Brief the average stencils.
Definition: CD_MFHelmholtzJumpBC.cpp:279
virtual void resetBC() const
Set everything to zero. This is a debugging function.
Definition: CD_MFHelmholtzJumpBC.cpp:516
static constexpr int m_nComp
Number of components in stencil.
Definition: CD_MFHelmholtzJumpBC.H:194
void setBco(const RefCountedPtr< LevelData< MFBaseIVFAB >> &a_Bcoef)
Set B-coefficient. This updates the stencils.
Definition: CD_MFHelmholtzJumpBC.cpp:112
int getRadius() const
Return stencil radius (for least squares)
Definition: CD_MFHelmholtzJumpBC.cpp:76
LayoutData< IntVectSet > m_ivs
IntVectSet over which we run the "averaging".
Definition: CD_MFHelmholtzJumpBC.H:269
MFLevelGrid m_mflg
Grids.
Definition: CD_MFHelmholtzJumpBC.H:204
LayoutData< MFInterfaceFAB< VoFStencil > > m_gradPhiStencils
Raw stencils for dphi/dn.
Definition: CD_MFHelmholtzJumpBC.H:274
virtual ~MFHelmholtzJumpBC()
Destructor. Does nothing.
Definition: CD_MFHelmholtzJumpBC.cpp:58
std::map< int, std::shared_ptr< LayoutData< VoFIterator > > > m_multiPhaseVofs
Iterators for multi-phase cells. The integer index is the phase.
Definition: CD_MFHelmholtzJumpBC.H:264
int getOrder() const
Return stencil order.
Definition: CD_MFHelmholtzJumpBC.cpp:64
LayoutData< MFInterfaceFAB< Vector< VolIndex > > > m_avgVoFs
Target vofs for average stencils.
Definition: CD_MFHelmholtzJumpBC.H:289
virtual VoFIterator & getMultiPhaseVofs(const int a_phase, const DataIndex &a_dit) const
Return vof iterator which iterates over multi-phase cells on a specified phase and box.
Definition: CD_MFHelmholtzJumpBC.cpp:94
virtual const BaseIVFAB< Real > & getBndryPhi(const int a_phase, const DataIndex &a_dit) const
Get phi on the boundary.
Definition: CD_MFHelmholtzJumpBC.cpp:82
bool m_multiPhase
Multiphase or not.
Definition: CD_MFHelmholtzJumpBC.H:249
int m_weight
Stencil order.
Definition: CD_MFHelmholtzJumpBC.H:224
std::map< int, std::shared_ptr< LayoutData< VoFIterator > > > m_singlePhaseVofs
Iterators for single-phase cells. The integer index is the phase.
Definition: CD_MFHelmholtzJumpBC.H:259
Class for holding BaseIVFAB<T> on the interface between two phases.
Definition: CD_MFInterfaceFAB.H:30
Wrapper class for holding multifluid EBLevelGrids.
Definition: CD_MFLevelGrid.H:29
Static class which contains some routines for fetching VoFs using various algorithms....
Definition: CD_VofUtils.H:33
Namespace for encapsulating various data centerings.
Definition: CD_Location.H:24
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30