11#ifndef _CARTESIANGRID_H_
12#define _CARTESIANGRID_H_
17#include "../Core/Geometry.H"
18#include "../IO/ParmParser.H"
19#include "../Utils/ErrCodes.H"
20#include "../Utils/RealTensor2.H"
21#include "../Utils/Vec3.H"
77 const int nGhost_ = 1);
89 const int nGhost_ = 1);
116 const Real t)
const override;
174 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
204 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
216 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
227 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
275 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
281 assert(sComp < eComp_);
282 std::vector<Real> q(eComp_ - sComp);
284 for (ivTmp[2] = iv[2]; ivTmp[2] <= iv[2]+1; ivTmp[2]++) {
285 Real fz = (ivTmp[2] == iv[2]) ? 1.0 - f[2] : f[2];
286 for (ivTmp[1] = iv[1]; ivTmp[1] <= iv[1]+1; ivTmp[1]++) {
287 Real fy = (ivTmp[1] == iv[1]) ? 1.0 - f[1] : f[1];
288 for (ivTmp[0] = iv[0]; ivTmp[0] <= iv[0]+1; ivTmp[0]++) {
289 Real fx = (ivTmp[0] == iv[0]) ? 1.0 - f[0] : f[0];
290 for (
IdxType c = sComp; c < eComp_; c++) {
291 q[c - sComp] += fx * fy * fz * (*this)(ivTmp, c);
311 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
317 for (ivTmp[2] = iv[2]; ivTmp[2] <= iv[2]+1; ivTmp[2]++) {
318 Real fz = (ivTmp[2] == iv[2]) ? 1.0 - f[2] : f[2];
319 for (ivTmp[1] = iv[1]; ivTmp[1] <= iv[1]+1; ivTmp[1]++) {
320 Real fy = (ivTmp[1] == iv[1]) ? 1.0 - f[1] : f[1];
321 for (ivTmp[0] = iv[0]; ivTmp[0] <= iv[0]+1; ivTmp[0]++) {
322 Real fx = (ivTmp[0] == iv[0]) ? 1.0 - f[0] : f[0];
323 for (
IdxType c_ = 0; c_ < 3; c_++) {
324 q[c_] += fx * fy * fz * (*this)(ivTmp, c + c_);
340 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
345 for (
int d = 0; d < 3; d++) {
347 for (ivTmp[2] = iv[2]; ivTmp[2] <= iv[2]+1; ivTmp[2]++) {
350 fz = (ivTmp[2] == iv[2]) ? 1.0 - f[2] : f[2];
352 fz = (ivTmp[2] == iv[2]) ? -1.0 : 1.0;
354 for (ivTmp[1] = iv[1]; ivTmp[1] <= iv[1]+1; ivTmp[1]++) {
357 fy = (ivTmp[1] == iv[1]) ? 1.0 - f[1] : f[1];
359 fy = (ivTmp[1] == iv[1]) ? -1.0 : 1.0;
361 for (ivTmp[0] = iv[0]; ivTmp[0] <= iv[0]+1; ivTmp[0]++) {
364 fx = (ivTmp[0] == iv[0]) ? 1.0 - f[0] : f[0];
366 fx = (ivTmp[0] == iv[0]) ? -1.0 : 1.0;
368 q[d] += fx * fy * fz * (*this)(ivTmp, c);
384 std::enable_if_t<std::is_integral<T>::value,
bool> =
true >
389 for (
int d = 0; d < 3; d++) {
391 for (ivTmp[2] = iv[2]; ivTmp[2] <= iv[2]+1; ivTmp[2]++) {
394 fz = (ivTmp[2] == iv[2]) ? 1.0 - f[2] : f[2];
396 fz = (ivTmp[2] == iv[2]) ? -1.0 : 1.0;
398 for (ivTmp[1] = iv[1]; ivTmp[1] <= iv[1]+1; ivTmp[1]++) {
401 fy = (ivTmp[1] == iv[1]) ? 1.0 - f[1] : f[1];
403 fy = (ivTmp[1] == iv[1]) ? -1.0 : 1.0;
405 for (ivTmp[0] = iv[0]; ivTmp[0] <= iv[0]+1; ivTmp[0]++) {
408 fx = (ivTmp[0] == iv[0]) ? 1.0 - f[0] : f[0];
410 fx = (ivTmp[0] == iv[0]) ? -1.0 : 1.0;
412 for (
int c_ = 0; c_ < 3; c_++) {
413 q[3*c_ + d] += fx * fy * fz * (*this)(ivTmp, c + c_);
419 for (
int c_ = 0; c_ < 3; c_++) {
420 for (
int d = 0; d < 3; d++) {
421 q[3*c_ + d] /=
dx[d];
Interface used to describe background gas.
A class that describes the geometry of a calculation.
Definition Geometry.H:32
const RealBox & xBox() const
Return the domain bounding box.
Definition Geometry.H:59
const RealVec & xSize() const
Return size of computational domain.
Definition Geometry.H:77
const RealVec & xHi() const
Return high boundary of computational domain.
Definition Geometry.H:71
const RealVec & xLo() const
Return low boundary of computational domain.
Definition Geometry.H:65
Class to parse the criptic input deck.
Definition ParmParser.H:37
Class that represents a 3D rectangular prism.
Definition RealBox.H:30
Class that represents a rank 2 tensor.
Definition RealTensor2.H:34
T min() const
Return the value of the smallest element.
Definition Vec3.H:532
Describe a gas with properties stored on a Cartesian grid.
Definition CartesianGrid.H:38
IdxType nComponents() const
Return the number of components.
Definition CartesianGrid.H:141
gasIdxType
Convenience enum to give specify indices in gas array.
Definition CartesianGrid.H:48
@ xHep2Idx
Definition CartesianGrid.H:61
@ vyIdx
Definition CartesianGrid.H:52
@ xeIdx
Definition CartesianGrid.H:62
@ nf
Definition CartesianGrid.H:64
@ vzIdx
Definition CartesianGrid.H:53
@ xHe0Idx
Definition CartesianGrid.H:59
@ BxIdx
Definition CartesianGrid.H:54
@ xHepIdx
Definition CartesianGrid.H:60
@ ZIdx
Definition CartesianGrid.H:63
@ xHpIdx
Definition CartesianGrid.H:58
@ xH0Idx
Definition CartesianGrid.H:57
@ ionDenIdx
Definition CartesianGrid.H:50
@ ByIdx
Definition CartesianGrid.H:55
@ vxIdx
Definition CartesianGrid.H:51
@ BzIdx
Definition CartesianGrid.H:56
@ denIdx
Definition CartesianGrid.H:49
RealTensor2 interpGradVector(const Vec3< T > &iv, const RealVec &f, const IdxType c) const
Compute gradient of a vector quantity by linear interpolation.
Definition CartesianGrid.H:385
IdxType idx(const Vec3< T > &iv, IdxType n) const
Convert an ((i,j,k),n) index to a memory location.
Definition CartesianGrid.H:175
IdxType nComp
Definition CartesianGrid.H:432
RealVec interpGradScalar(const Vec3< T > &iv, const RealVec &f, const IdxType c) const
Compute gradient of a scalar quantity by linear interpolation.
Definition CartesianGrid.H:341
RealVec interpVec(const Vec3< T > &iv, const RealVec &f, const IdxType c) const
Linearly interpolate one vector component to a given point.
Definition CartesianGrid.H:312
virtual void frame(const RealVec &x, const Real t, RealVec &v, TNBBasis &tnb) const override
Compute the comoving TNB frame for the gas.
Definition CartesianGrid.cpp:661
const RealBox & xBox() const
Return the domain bounding box.
Definition CartesianGrid.H:147
const Geometry & geom
Definition CartesianGrid.H:430
virtual Real dxGhost() const override
Size of the ghost region in the gas data.
Definition CartesianGrid.H:124
const IdxVec & gridSize() const
Return the grid size.
Definition CartesianGrid.H:135
IdxType nBB
Definition CartesianGrid.H:433
RealVec dx
Definition CartesianGrid.H:435
const RealVec & xHi() const
Return high boundary of computational domain.
Definition CartesianGrid.H:159
Real & operator()(const Vec3< T > &iv, const IdxType n)
Access data by index.
Definition CartesianGrid.H:217
IdxVec nGrid
Definition CartesianGrid.H:431
const Real & operator()(const Vec3< T > &iv, const IdxType n) const
Access data by index.
Definition CartesianGrid.H:228
const RealVec & xSize() const
Return size of computational domain.
Definition CartesianGrid.H:165
const RealVec & xLo() const
Return low boundary of computational domain.
Definition CartesianGrid.H:153
std::vector< Real > data
Definition CartesianGrid.H:436
std::vector< Real > interp(const Vec3< T > &iv, const RealVec &f, const IdxType sComp=0, const IdxType eComp=maxIdx) const
Linearly interpolate grid data to specified point.
Definition CartesianGrid.H:276
Real & operator()(const SignedIdxType i, const SignedIdxType j, const SignedIdxType k, const IdxType n)
Access data by index.
Definition CartesianGrid.H:239
virtual GasData gasData(const RealVec &x, const Real t) const override
Return background gas state.
Definition CartesianGrid.cpp:683
RealVec idxToPos(const Vec3< T > &iv, const RealVec &f=zeroIdxVec) const
Convert a position in cell coordinates to a physical position.
Definition CartesianGrid.H:205
IdxType nGhost
Definition CartesianGrid.H:434
const Real & operator()(const SignedIdxType i, const SignedIdxType j, const SignedIdxType k, const IdxType n) const
Access data by index.
Definition CartesianGrid.H:254
void posToIdx(const RealVec &x, SIdxVec &iv, RealVec &f) const
Convert a physical position to cell coordinates.
Definition CartesianGrid.H:189
void applyBC()
Fill the ghost cells using the specified boundary condition.
Definition CartesianGrid.cpp:83
Trivial class to hold gas data.
Definition GasData.H:29
Interface class to describe background gas.
Definition Gas.H:44
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
constexpr IdxType maxIdx
Definition Types.H:55
Vec3< T > floor(const criptic::Vec3< T > &v)
Return the elementwise floor of a Vec3.
Definition Vec3.H:755
std::ptrdiff_t SignedIdxType
Definition Types.H:46
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38
static const IdxVec zeroIdxVec(0, 0, 0)
Structure to hold TNB basis data.
Definition RealTensor2.H:898