42 static_assert(std::is_base_of<Gas, T>::value,
43 "Template class of TimeInterp must be derived from Gas");
61 std::vector<Real> TBB_ = {},
62 std::vector<Real> WBB_ = {}) {
68 std::string dirName, tempName;
69 if (pp.
query(
"gas.slice_dir", dirName) &&
70 pp.
query(
"gas.slice_filename", tempName)) {
71 std::regex reg(tempName);
76 for (
auto const& file : std::filesystem::directory_iterator(dirName)) {
77 if (!file.is_regular_file())
continue;
78 std::string fname = file.path().filename().string();
79 if (std::regex_search(fname, reg))
81 snapFiles.push_back(file.path().string());
95 if (pp.
query(
"gas.dt", dt) && pp.
query(
"gas.nSlice", nSlice)) {
101 for (
int i=0; i < nSlice; i++)
tSlice[i] = i*dt;
117 bool t0_supplied = pp.
query(
"gas.slice_t0", slice_t0);
126 MPIUtil::haltRun(
"TimeInterp: gas.slice_t0 exceeds the time of the final snapshot file",
132 if (
tSlice[i] < slice_t0) {
150 if (!t0_supplied &&
tSlice[0] != 0.0)
156 "monotonically increasing",
163 pp.
query(
"dt_init", dt);
166 "time step must be < time of second slice",
173 if (TBB_.size() != WBB_.size()) {
175 "dilution factors must be vectors of the same size",
216 const Real t)
const override {
220 GasData gd_interp = (1 - w) * gdOld + w * gdNew;
252 "exceeded time of last time slice",
267 std::cout <<
"TimeInterp: loading file " <<
snapFiles[
tPtr] <<
274 std::cout <<
"TimeInterp: loading file " <<
snapFiles[
tPtr+1] <<
294 std::cout <<
"TimeInterp: loading file " <<
snapFiles[
tPtr] <<
311 static std::vector<std::string>
sortSnapFiles(std::vector<std::string> files,
312 std::vector<Real> times) {
314 std::vector<std::pair<double, IdxType>> indexedTimes;
315 for (
IdxType i=0; i<times.size(); i++) {
316 indexedTimes.emplace_back(times[i], i);
318 std::sort(indexedTimes.begin(), indexedTimes.end());
319 std::vector<std::string> sortedFiles(files.size());
320 for (
IdxType i=0; i<files.size(); i++) {
321 sortedFiles[i] = files[indexedTimes[i].second];
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.
Gas class which describes a GIZMO snapshot file.
A class that describes the geometry of a calculation.
Definition Geometry.H:32
Class to parse the criptic input deck.
Definition ParmParser.H:37
bool query(const std::string &name, T &val) const
Return a keyword, or return false if not available.
Definition ParmParser.cpp:299
Trivial class to hold gas data.
Definition GasData.H:29
std::vector< Real > WBB
Definition GasData.H:58
std::vector< Real > TBB
Definition GasData.H:57
Interface class to describe background gas.
Definition Gas.H:44
Gas model stored with snapshots.
Definition TimeInterp.H:40
int leafSize
Definition TimeInterp.H:332
std::vector< Real > WBB
Definition TimeInterp.H:336
std::vector< Real > TBB
Definition TimeInterp.H:335
virtual Real dxGhost() const override
Size of the ghost region in the gas data.
Definition TimeInterp.H:234
bool uniformRadField
Definition TimeInterp.H:334
T * gasNew
Definition TimeInterp.H:342
std::vector< std::string > snapFiles
Definition TimeInterp.H:329
int verbosity
Definition TimeInterp.H:340
virtual ~TimeInterp()
Destructor.
Definition TimeInterp.H:201
Real hLim
Definition TimeInterp.H:331
bool dataLoaded
Definition TimeInterp.H:343
virtual GasData gasData(const RealVec &x, const Real t) const override
Return background gas state.
Definition TimeInterp.H:215
static std::vector< std::string > sortSnapFiles(std::vector< std::string > files, std::vector< Real > times)
Sort snapshot files by their associated times.
Definition TimeInterp.H:311
std::vector< Real > tSlice
Definition TimeInterp.H:328
void updateState(const Real t, Real &tNext)
Update the gas data.
Definition TimeInterp.H:247
TimeInterp(const ParmParser &pp, const Geometry &geom_, const IdxType nBB, const int nGhost, std::vector< Real > TBB_={}, std::vector< Real > WBB_={})
Constructor.
Definition TimeInterp.H:57
IdxType tPtr
Definition TimeInterp.H:330
T * gasOld
Definition TimeInterp.H:341
void haltRun(std::string msg, errCodes errcode)
Halt a run because an error has occurred.
Definition MPIUtil.cpp:287
bool IOProc
Definition MPIUtil.cpp:18
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
@ errBadInputFile
Definition ErrCodes.H:25
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38