chombo-discharge
Loading...
Searching...
No Matches
CD_CellCentroidInterpolationImplem.H
Go to the documentation of this file.
1/* chombo-discharge
2 * Copyright © 2025 SINTEF Energy Research.
3 * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4 */
5
12#ifndef CD_CellCentroidInterpolationImplem_H
13#define CD_CellCentroidInterpolationImplem_H
14
15// Chombo includes
16#include <CH_Timer.H>
17
18// Our includes
20#include <CD_BoxLoops.H>
21#include <CD_NamespaceHeader.H>
22
23template <typename T>
24void
26 const EBCellFAB& a_cellData,
27 const DataIndex& a_din) const noexcept
28{
29 CH_TIME("CellCentroidInterpolation::interpolate<T>)");
30
31 CH_assert(m_isDefined);
32 CH_assert(a_centroidData.isDefined());
33 CH_assert(a_cellData.isDefined());
34 CH_assert(a_centroidData.nComp() == a_cellData.nComp());
35
36 const DisjointBoxLayout& dbl = m_eblg.getDBL();
37 const ProblemDomain& domain = m_eblg.getDomain();
38 const EBISLayout& ebisl = m_eblg.getEBISL();
39 const Box& domainBox = domain.domainBox();
40
41 const EBISBox& ebisBox = ebisl[a_din];
42 const Box& cellBox = dbl[a_din];
43 const BaseIVFAB<VoFStencil>& stencils = m_interpStencils[a_din];
44
45 const int nComp = a_cellData.nComp();
46
47 for (int comp = 0; comp < nComp; comp++) {
48
49 // This is the kernel that is used when the interpolation is expressable as a stencil.
50 auto stencilKernel = [&](const VolIndex& vof) -> void {
51 a_centroidData(vof, comp) = 0.0;
52
53 const VoFStencil& stencil = stencils(vof, 0);
54 for (int i = 0; i < stencil.size(); i++) {
55 const VolIndex& ivof = stencil.vof(i);
56 const Real& iweight = stencil.weight(i);
57
59 }
60 };
61
62 // Kernel used when interpolation is done with a slope limiter.
63 auto slopeKernel = [&](const VolIndex& vof) -> void {
64 const IntVect iv = vof.gridIndex();
65
67
68 for (int dir = 0; dir < SpaceDim; dir++) {
69 Real slope = 0.0;
70
71 const bool onLoSide = (iv[dir] == domainBox.smallEnd(dir));
72 const bool onHiSide = (iv[dir] == domainBox.bigEnd(dir));
73
74 const bool hasFacesLeft = (ebisBox.numFaces(vof, dir, Side::Lo) == 1) && !onLoSide;
75 const bool hasFacesRight = (ebisBox.numFaces(vof, dir, Side::Hi) == 1) && !onHiSide;
76
79
82
83 Real dwl = 0.0;
84 Real dwr = 0.0;
85
86 // Compute left and right slope
87 if (hasFacesLeft) {
88 facesLeft = ebisBox.getFaces(vof, dir, Side::Lo);
89 vofLeft = facesLeft[0].getVoF(Side::Lo);
91 }
92 if (hasFacesRight) {
93 facesRight = ebisBox.getFaces(vof, dir, Side::Hi);
94 vofRight = facesRight[0].getVoF(Side::Hi);
96 }
97
99 dwl = dwr;
100 }
101 else if (hasFacesLeft && !hasFacesRight) {
102 dwr = dwl;
103 }
104
105 // Limit the slopes.
106 switch (m_interpolationType) {
107 case Type::MinMod: {
108 slope = this->MinMod(dwl, dwr);
109
110 break;
111 }
112 case Type::MonotonizedCentral: {
113 slope = this->MonotonizedCentral(dwl, dwr);
114
115 break;
116 }
117 case Type::Superbee: {
118 slope = this->Superbee(dwl, dwr);
119
120 break;
121 }
122 default: {
123 MayDay::Abort("CD_CellCentroidInterpolation::interpolate(BaseIVFAB) - logic bust");
124
125 break;
126 }
127 }
128
129 const Real dx = ebisBox.centroid(vof)[dir];
130
132 }
133 };
134
135 switch (m_interpolationType) {
136 case Type::MinMod: {
137 BoxLoops::loop(m_vofIterator[a_din], slopeKernel);
138
139 break;
140 }
141 case Type::MonotonizedCentral: {
142 BoxLoops::loop(m_vofIterator[a_din], slopeKernel);
143
144 break;
145 }
146 case Type::Superbee: {
147 BoxLoops::loop(m_vofIterator[a_din], slopeKernel);
148
149 break;
150 }
151 default: {
152 BoxLoops::loop(m_vofIterator[a_din], stencilKernel);
153
154 break;
155 }
156 }
157 }
158}
159
160inline Real
162{
163 Real slope = 0.0;
164
165 if (a_dwl * a_dwr > 0.0) {
167 }
168
169 return slope;
170}
171
172inline Real
174{
175 Real slope = 0.0;
176
177 if (a_dwl * a_dwr > 0.0) {
178 const Real dwc = a_dwl + a_dwr;
179 const Real sgn = Real((dwc > 0.0) - (dwc < 0.0));
180
181 slope = sgn * std::min(0.5 * std::abs(dwc), 2.0 * std::min(std::abs(a_dwl), std::abs(a_dwr)));
182 }
183
184 return slope;
185}
186
187inline Real
189{
190 Real slope = 0.0;
191
192 if (a_dwl * a_dwr > 0.0) {
193 const Real s1 = this->MinMod(a_dwl, 2 * a_dwr);
194 const Real s2 = this->MinMod(a_dwr, 2 * a_dwl);
195
196 if (s1 * s2 > 0.0) {
197 slope = std::abs(s1) > std::abs(s2) ? s1 : s2;
198 }
199 }
200
201 return slope;
202}
203
204#include <CD_NamespaceFooter.H>
205
206#endif
Declaration of a namespace for proto-typing grid and EB loops.
Declaration of class for interpolating cell-centered data to cell centroids.
virtual void interpolate(LevelData< BaseIVFAB< Real > > &a_centroidData, const LevelData< EBCellFAB > &a_cellData) const noexcept
Function for interpolating data.
Definition CD_CellCentroidInterpolation.cpp:274
Real MonotonizedCentral(const Real &a_dwl, const Real &a_dwr) const noexcept
Monotonized central difference slope limiter.
Definition CD_CellCentroidInterpolationImplem.H:173
Real Superbee(const Real &a_dwl, const Real &a_dwr) const noexcept
Superbee slope limiter.
Definition CD_CellCentroidInterpolationImplem.H:188
Real MinMod(const Real &a_dwl, const Real &a_dwr) const noexcept
Minmod slope function.
Definition CD_CellCentroidInterpolationImplem.H:161
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
ALWAYS_INLINE void loop(const Box &a_computeBox, Functor &&kernel, const IntVect &a_stride=IntVect::Unit)
Launch a C++ kernel over a regular grid.
Definition CD_BoxLoopsImplem.H:20