chombo-discharge
CD_MFHelmholtzJumpBCImplem.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 
6 /*
7  @file CD_MFHelmholtzJumpBCImplem.H
8  @brief Implementation of CD_MFHelmholtzJumpBC.H
9  @author Robert Marskar
10 */
11 
12 #ifndef CD_MFHelmholtzJumpBCImplem_H
13 #define CD_MFHelmholtzJumpBCImplem_H
14 
15 // Chombo includes
16 #include <NeighborIterator.H>
17 
18 // Our includes
19 #include <CD_MFHelmholtzJumpBC.H>
20 #include <CD_NamespaceHeader.H>
21 
22 inline bool
23 MFHelmholtzJumpBC::isStencilValidCF(const VoFStencil& a_stencil, const DataIndex& a_dit) const
24 {
25  const DisjointBoxLayout& dbl = m_mflg.getGrids();
26  const ProblemDomain& domain = m_mflg.getDomain();
27 
28  // Construct boxes that contain all the valid cells for this stencil.
29  std::vector<Box> validBoxes;
30 
31  Box curBox = dbl[a_dit];
32  curBox.grow(m_ghostCF);
33  curBox &= domain;
34  validBoxes.emplace_back(curBox);
35 
36  NeighborIterator nit(dbl);
37  for (nit.begin(a_dit); nit.ok(); ++nit) {
38  Box neighBox = dbl[nit()];
39  neighBox.grow(m_ghostCF);
40  neighBox &= domain;
41 
42  validBoxes.emplace_back(neighBox);
43  }
44 
45  // Now check that the stencil if the stencil. We set valid = false
46  // if any of the stencil points reaches out of the ghosted boxes.
47  bool valid = true;
48 
49  for (int i = 0; i < a_stencil.size(); i++) {
50  const VolIndex& vof = a_stencil.vof(i);
51  const IntVect& iv = vof.gridIndex();
52 
53  bool insideOneBox = false;
54  for (const auto& b : validBoxes) {
55  if (b.contains(iv))
56  insideOneBox = true;
57  }
58 
59  if (!insideOneBox) {
60  valid = false;
61  break;
62  }
63  }
64 
65  return valid;
66 }
67 
68 inline Real
69 MFHelmholtzJumpBC::applyStencil(const VoFStencil& a_stencil, const EBCellFAB& a_phi) const
70 {
71  Real contrib = 0.0;
72  for (int i = 0; i < a_stencil.size(); i++) {
73  contrib += a_stencil.weight(i) * a_phi(a_stencil.vof(i), m_comp);
74  }
75 
76  return contrib;
77 }
78 
79 #include <CD_NamespaceFooter.H>
80 
81 #endif
Declaration of class for computing "jump interface" boundary conditions for multifluid Helmholtz code...
static constexpr int m_comp
Component where stencils are stored.
Definition: CD_MFHelmholtzJumpBC.H:189
int m_ghostCF
Number of grid cells that were filled over the CF.
Definition: CD_MFHelmholtzJumpBC.H:234
Real applyStencil(const VoFStencil &a_stencil, const EBCellFAB &a_phi) const
Apply a stencil and return the result.
Definition: CD_MFHelmholtzJumpBCImplem.H:69
bool isStencilValidCF(const VoFStencil &a_stencil, const DataIndex &a_dit) const
Check if stencil is valid.
Definition: CD_MFHelmholtzJumpBCImplem.H:23
MFLevelGrid m_mflg
Grids.
Definition: CD_MFHelmholtzJumpBC.H:204
virtual ProblemDomain getDomain() const
Get the problem domain.
Definition: CD_MFLevelGrid.cpp:72
virtual DisjointBoxLayout getGrids() const
Get the grids.
Definition: CD_MFLevelGrid.cpp:78