55 const fsgrid::FsStencil& stencil,
Real reconstructionOrder) {
56 std::array<Real, Rec::N_REC_COEFFICIENTS> perturbedResult;
57 const auto ooo = stencil.ooo();
58 const auto poo = stencil.poo();
59 const auto opo = stencil.opo();
60 const auto oop = stencil.oop();
61 const std::array<Real, fsgrids::dperb::N_DPERB>& der_i1j1k1 = dperb[ooo];
62 const std::array<Real, fsgrids::bfield::N_BFIELD>& cep_i1j1k1 = perb[ooo];
64 const bool pooOk = stencil.cellExists(1, 0, 0);
65 const bool opoOk = stencil.cellExists(0, 1, 0);
66 const bool oopOk = stencil.cellExists(0, 0, 1);
67 const std::array<Real, fsgrids::bfield::N_BFIELD>& cep_i2j1k1 = pooOk ? perb[poo] : cep_i1j1k1;
68 const std::array<Real, fsgrids::bfield::N_BFIELD>& cep_i1j2k1 = opoOk ? perb[opo] : cep_i1j1k1;
69 const std::array<Real, fsgrids::bfield::N_BFIELD>& cep_i1j1k2 = oopOk ? perb[oop] : cep_i1j1k1;
71#ifndef FS_1ST_ORDER_SPACE
73 std::array<Real, fsgrids::dperb::N_DPERB> dummyDerivatives;
74 dummyDerivatives.fill(0.0);
78 const std::array<Real, fsgrids::dperb::N_DPERB>& der_i2j1k1 = pooOk ? dperb[poo] : dummyDerivatives;
79 const std::array<Real, fsgrids::dperb::N_DPERB>& der_i1j2k1 = opoOk ? dperb[opo] : dummyDerivatives;
80 const std::array<Real, fsgrids::dperb::N_DPERB>& der_i1j1k2 = oopOk ? dperb[oop] : dummyDerivatives;
83 if (reconstructionOrder == 2) {
111 }
else if (reconstructionOrder == 3) {
145 cerr << __FILE__ <<
":" << __LINE__ <<
":" <<
" Not coded yet!" << endl;
174 perturbedResult.fill(0.0);
182 return perturbedResult;
204 std::map<std::array<int, 3>, std::array<Real, Rec::N_REC_COEFFICIENTS>>& reconstructionCoefficientsCache,
cint i,
205 cint j,
cint k,
const std::array<Real, 3> x) {
206 const auto stencil =
fsgrid.makeStencil(
i,
j,
k);
208 cuint cellSysBoundaryFlag = technical[stencil.ooo()].sysBoundaryFlag;
214 std::array<Real, 3> xLocal =
fsgrid.physicalToCellFractional(x[0], x[1], x[2]);
219 if (fabs(xLocal[0]) > 0.5 || fabs(xLocal[1]) > 0.5 || fabs(xLocal[2]) > 0.5) {
220 cerr << __FILE__ <<
":" << __LINE__ <<
": Coordinate (" << xLocal[0] <<
"," << xLocal[1] <<
"," << xLocal[2] <<
") outside of this cell!" << endl;
224 const std::array<Real, Rec::N_REC_COEFFICIENTS> rc = [&stencil, &reconstructionCoefficientsCache, &perb, &dperb]() {
225 const std::array<int, 3> cellIds = {stencil.i, stencil.j, stencil.k};
231 if (reconstructionCoefficientsCache.find(cellIds) == reconstructionCoefficientsCache.end()) {
233 reconstructionCoefficientsCache.insert({cellIds, rc});
237 return reconstructionCoefficientsCache.at(cellIds);
277 std::map<std::array<int, 3>, std::array<Real, Rec::N_REC_COEFFICIENTS>>& reconstructionCoefficientsCache,
cint i,
278 cint j,
cint k,
const std::array<Real, 3> x) {
279 const auto stencil =
fsgrid.makeStencil(
i,
j,
k);
281 cuint cellSysBoundaryFlag = technical[stencil.ooo()].sysBoundaryFlag;
287 std::array<Real, 3> xLocal =
fsgrid.physicalToCellFractional(x[0], x[1], x[2]);
292 if (fabs(xLocal[0]) > 0.5 || fabs(xLocal[1]) > 0.5 || fabs(xLocal[2]) > 0.5) {
293 cerr << __FILE__ <<
":" << __LINE__ <<
": Coordinate (" << xLocal[0] <<
"," << xLocal[1] <<
"," << xLocal[2] <<
") outside of this cell!" << endl;
297 const std::array<Real, Rec::N_REC_COEFFICIENTS> rc = [&stencil, &reconstructionCoefficientsCache, &perb, &dperb]() {
298 std::array<int, 3> cellIds = {stencil.i, stencil.j, stencil.k};
306 if (reconstructionCoefficientsCache.find(cellIds) == reconstructionCoefficientsCache.end()) {
308 reconstructionCoefficientsCache.insert({cellIds, rc});
311 return reconstructionCoefficientsCache.at(cellIds);
std::array< Real, 3 > interpolateCurlB(fsgrids::perbspan perb, fsgrids::constdperbspan dperb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, std::map< std::array< int, 3 >, std::array< Real, Rec::N_REC_COEFFICIENTS > > &reconstructionCoefficientsCache, cint i, cint j, cint k, const std::array< Real, 3 > x)
std::array< Real, Rec::N_REC_COEFFICIENTS > reconstructionCoefficients(fsgrids::perbspan perb, fsgrids::constdperbspan dperb, const fsgrid::FsStencil &stencil, Real reconstructionOrder)
Low-level helper function.
std::array< Real, 3 > interpolatePerturbedB(fsgrids::perbspan perb, fsgrids::constdperbspan dperb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, std::map< std::array< int, 3 >, std::array< Real, Rec::N_REC_COEFFICIENTS > > &reconstructionCoefficientsCache, cint i, cint j, cint k, const std::array< Real, 3 > x)