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