criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
CartesianTimeInterp.H
Go to the documentation of this file.
1
12#ifndef _CARTESIAN_TIMEINTERP_H_
13#define _CARTESIAN_TIMEINTERP_H_
14
15#include <vector>
16#include "CartesianGrid.H"
17#include "Gas.H"
18#include "GasData.H"
19
20namespace criptic {
21 namespace gas {
22
34 class CartesianTimeInterp : public Gas {
35
36 public:
37
46 const Geometry& geom_,
47 const IdxType nBB,
48 const int nGhost = 1);
49
53 virtual ~CartesianTimeInterp();
54
65 virtual void frame(const RealVec &x,
66 const Real t,
67 RealVec& v,
68 TNBBasis& tnb) const override {
69 // Convert position to cell coordinates
70 SIdxVec iv;
71 RealVec f;
72 gasOld->posToIdx(x, iv, f);
73
74 // Get weight factor
75 Real w = (t - tSlice[tPtr-1]) / (tSlice[tPtr] - tSlice[tPtr-1]);
76
77 // Interpolate v, B, and grad B in space and time
78 v = (1 - w) * gasOld->interpVec(iv, f, CartesianGrid::vxIdx) +
80 RealVec B = (1 - w) * gasOld->interpVec(iv, f, CartesianGrid::BxIdx) +
82 RealTensor2 gradB =
85
86 // Compute TNB basis vectors
87 tnb = TNBVectors(B, gradB);
88 }
89
99 virtual GasData gasData(const RealVec &x,
100 const Real t) const override {
101 GasData gdOld = gasOld->gasData(x, t);
102 GasData gdNew = gasNew->gasData(x, t);
103 Real w = (t - tSlice[tPtr-1]) / (tSlice[tPtr] - tSlice[tPtr-1]);
104 return (1 - w) * gdOld + w * gdNew;
105 }
106
113 virtual Real dxGhost() const override {
114 return gasOld->dxGhost();
115 }
116
126 virtual void updateState(const Real t,
127 Real& tNext) override;
128
139 virtual void loadData(const IdxType idx,
140 CartesianGrid *g) = 0;
141
142 protected:
143
144 // Data
145 std::vector<Real> tSlice;
148 private:
149
150 // Data
156 };
157 }
158}
159
160
161#endif
162// _CARTESIAN_TIMEINTERP_H_
A class to describe a gas with properties stored on a Cartesian grid.
Interface used to describe background gas.
Class to describe the background gas at a single point.
A class that describes the geometry of a calculation.
Definition Geometry.H:32
Class to parse the criptic input deck.
Definition ParmParser.H:37
Class that represents a rank 2 tensor.
Definition RealTensor2.H:34
Describe a gas with properties stored on a Cartesian grid.
Definition CartesianGrid.H:38
@ BxIdx
Definition CartesianGrid.H:54
@ vxIdx
Definition CartesianGrid.H:51
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
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 Real dxGhost() const override
Size of the ghost region in the gas data.
Definition CartesianGrid.H:124
virtual GasData gasData(const RealVec &x, const Real t) const override
Return background gas state.
Definition CartesianGrid.cpp:683
void posToIdx(const RealVec &x, SIdxVec &iv, RealVec &f) const
Convert a physical position to cell coordinates.
Definition CartesianGrid.H:189
Gas model stored as snapshots on a Cartesian grid.
Definition CartesianTimeInterp.H:34
virtual void frame(const RealVec &x, const Real t, RealVec &v, TNBBasis &tnb) const override
Compute the comoving TNB frame for the gas.
Definition CartesianTimeInterp.H:65
bool dataLoaded
Definition CartesianTimeInterp.H:154
virtual ~CartesianTimeInterp()
Destructor.
Definition CartesianTimeInterp.cpp:62
virtual void updateState(const Real t, Real &tNext) override
Update the gas data.
Definition CartesianTimeInterp.cpp:68
CartesianGrid * gasOld
Definition CartesianTimeInterp.H:152
int verbosity
Definition CartesianTimeInterp.H:151
IdxType tPtr
Definition CartesianTimeInterp.H:146
std::vector< Real > tSlice
Definition CartesianTimeInterp.H:145
virtual void loadData(const IdxType idx, CartesianGrid *g)=0
Load a new snapshot into memory.
CartesianGrid * gasNew
Definition CartesianTimeInterp.H:153
virtual Real dxGhost() const override
Size of the ghost region in the gas data.
Definition CartesianTimeInterp.H:113
virtual GasData gasData(const RealVec &x, const Real t) const override
Return background gas state.
Definition CartesianTimeInterp.H:99
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
TNBBasis TNBVectors(const RealVec &v, const RealTensor2 &vGrad)
Compute tangent, normal, and binormal vectors.
Definition RealTensor2.H:913
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38
Structure to hold TNB basis data.
Definition RealTensor2.H:898