chombo-discharge
Loading...
Searching...
No Matches
CD_EBHelmholtzEBBCImplem.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_EBHelmholtzEBBCImplem.H
8 @brief Implementation of CD_EBHelmholtzEBBC.H
9 @author Robert Marskar
10*/
11
12#ifndef CD_EBHelmholtzEBBCImplem_H
13#define CD_EBHelmholtzEBBCImplem_H
14
15// Chombo includes
16#include <NeighborIterator.H>
17
18// Our includes
19#include <CD_EBHelmholtzEBBC.H>
20#include <CD_NamespaceHeader.H>
21
22inline RealVect
24{
25
26 // TLDR: Return the physical coordinates on the EB centroid.
27
28 const EBISBox& ebisbox = m_eblg.getEBISL()[a_dit];
29 const RealVect& ebCentroid = ebisbox.bndryCentroid(a_vof);
30
31 RealVect position = m_probLo + (0.5 * RealVect::Unit + RealVect(a_vof.gridIndex()) + ebCentroid) * m_dx;
32
33 return position;
34}
35
36inline Real
38{
39
40 // TLDR: We just apply a stencil here.
41 Real ret = 0.0;
42 for (int i = 0; i < a_stencil.size(); i++) {
43 ret += a_stencil.weight(i) * a_phi(a_stencil.vof(i), m_comp);
44 }
45
46 return ret;
47}
48
49inline bool
51{
52
53 // TLDR: In this routine we check if the input stencil has a range that reaches into ghost cells
54 // that will not be filled by interpolator. We just get the neighboring boxes around the
55 // input grid patch with index a_dit. We then check that each vof in the input stencil reaches
56 // either into valid cells, or ghost cells up to a specified range.
57
58 CH_assert(m_ghostCF >= 0);
59
60 const DisjointBoxLayout& dbl = m_eblg.getDBL();
61 const ProblemDomain& domain = m_eblg.getDomain();
62
63 // Construct boxes that contain all the valid cells for this stencil.
65
67 curBox.grow(m_ghostCF);
68 curBox &= domain;
69 validBoxes.emplace_back(curBox);
70
72 for (nit.begin(a_dit); nit.ok(); ++nit) {
73 Box neighBox = dbl[nit()];
74 neighBox.grow(m_ghostCF);
76
77 validBoxes.emplace_back(neighBox);
78 }
79
80 // Now check that the stencil if the stencil. We set valid = false
81 // if any of the stencil points reaches out of the ghosted boxes.
82 bool valid = true;
83
84 for (int i = 0; i < a_stencil.size(); i++) {
85 const VolIndex& vof = a_stencil.vof(i);
86 const IntVect& iv = vof.gridIndex();
87
88 bool insideOneBox = false;
89 for (const auto& b : validBoxes) {
90 if (b.contains(iv))
91 insideOneBox = true;
92 }
93
94 if (!insideOneBox) {
95 valid = false;
96 break;
97 }
98 }
99
100 return valid;
101}
102
103#include <CD_NamespaceFooter.H>
104
105#endif
Real applyStencil(const VoFStencil &a_stencil, const EBCellFAB &a_phi) const
Apply stencil to data holder and return result.
Definition CD_EBHelmholtzEBBCImplem.H:37
EBLevelGrid m_eblg
Level grid.
Definition CD_EBHelmholtzEBBC.H:137
int m_ghostCF
Number of ghost cells that were filled across CF interface.
Definition CD_EBHelmholtzEBBC.H:122
RealVect getBoundaryPosition(const VolIndex &a_vof, const DataIndex &a_dit) const
Returns physical position at the boundary.
Definition CD_EBHelmholtzEBBCImplem.H:23
RealVect m_probLo
Lower-left corner of computational domain.
Definition CD_EBHelmholtzEBBC.H:132
bool isStencilValidCF(const VoFStencil &a_stencil, const DataIndex &a_dit) const
Check if stencil is valid.
Definition CD_EBHelmholtzEBBCImplem.H:50
static constexpr int m_comp
Component that everything is defined for. Always have m_comp = 0.
Definition CD_EBHelmholtzEBBC.H:107
Real m_dx
Grid resolution.
Definition CD_EBHelmholtzEBBC.H:127
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:25