diff --git a/src_analysis/StructFact.H b/src_analysis/StructFact.H index b651e52a..41c281ec 100644 --- a/src_analysis/StructFact.H +++ b/src_analysis/StructFact.H @@ -153,6 +153,12 @@ public: const amrex::Real& time, std::string checkfile_base); + void ReadCheckPoint(const int& step, + const amrex::Real& time, + std::string checkfile_base, + BoxArray& ba, + DistributionMapping& dmap); + const decltype(cov_names)& get_names() const { return cov_names; } }; diff --git a/src_analysis/StructFact.cpp b/src_analysis/StructFact.cpp index 59269f36..5b0568b9 100644 --- a/src_analysis/StructFact.cpp +++ b/src_analysis/StructFact.cpp @@ -1937,10 +1937,10 @@ void StructFact::GetDecompVel(MultiFab& vel_decomp, const Geometry& geom) void StructFact::WriteCheckPoint(const int& step, const amrex::Real& time, - std::string plotfile_base) + std::string checkfile_base) { // checkpoint file name, e.g., chk_SF0000010 (digits is how many digits...) - const std::string& checkpointname = amrex::Concatenate(plotfile_base,step,9); + const std::string& checkpointname = amrex::Concatenate(checkfile_base,step,9); amrex::Print() << "Writing structure factor checkpoint " << checkpointname << "\n"; @@ -2019,3 +2019,90 @@ void StructFact::WriteCheckPoint(const int& step, amrex::MultiFabFileFullPrefix(0, checkpointname, "Level_", "cov_mag")); } + +namespace { + void GotoNextLine (std::istream& is) + { + constexpr std::streamsize bl_ignore_max { 100000 }; + is.ignore(bl_ignore_max, '\n'); + } +} + +void StructFact::ReadCheckPoint(const int& step, + const amrex::Real& time, + std::string checkfile_base, + BoxArray& ba_in, + DistributionMapping& dmap_in) +{ + const std::string& checkpointname = amrex::Concatenate(checkfile_base,restart,9); + + amrex::Print() << "Restart from checkpoint " << checkpointname << "\n"; + + VisMF::IO_Buffer io_buffer(VisMF::GetIOBufferSize()); + + std::string line, word; + + // Header + { + std::string File(checkpointname + "/Header"); + Vector fileCharPtr; + ParallelDescriptor::ReadAndBcastFile(File, fileCharPtr); + std::string fileCharPtrString(fileCharPtr.dataPtr()); + std::istringstream is(fileCharPtrString, std::istringstream::in); + + // read in title line + std::getline(is, line); + + // read in time step number + is >> step; + GotoNextLine(is); + ++step; + + // read in time + is >> time; + GotoNextLine(is); + + // write out misc structure factor member objects + is >> NVAR << "\n"; + is >> NVARU << "\n"; + is >> NCOV << "\n"; + is >> nsamples << "\n"; + + scaling.resize(NCOV); + cov_names.resize(NCOV); + s_pairA.resize(NCOV); + s_pairB.resize(NCOV); + var_u.resize(NVARU); + + for (int i=0; i> scaling[i] << "\n"; + } + for (int i=0; i> cov_names[i] << "\n"; + } + for (int i=0; i> s_pairA[i] << "\n"; + } + for (int i=0; i> s_pairB[i] << "\n"; + } + for (int i=0; i> var_u[i] << "\n"; + } + + // read in level 'lev' BoxArray from Header + ba.readFrom(is); + GotoNextLine(is); + + // build MultiFab data + cov_real.define(ba_in, dmap_in, NCOV, 0); + cov_imag.define(ba_in, dmap_in, NCOV, 0); + cov_mag.define( ba_in, dmap_in, NCOV, 0); + } + + // read in the MultiFab data + VisMF::Read(cov_real[0], + amrex::MultiFabFileFullPrefix(0, checkpointname, "Level_", "cov_real")); + + +}