Skip to content

Commit

Permalink
Backwards compatibility for chk files.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi committed Oct 25, 2024
1 parent 18a7086 commit 7265993
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions Source/IO/ERF_Checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,33 @@ ERF::ReadCheckpointFile ()
// ncomp is only valid after we MakeNewLevelFromScratch (asks micro how many vars)
// NOTE: Data is written over ncomp, so check that we match the header file
int ncomp_cons = vars_new[0][Vars::cons].nComp();
AMREX_ASSERT(chk_ncomp_cons == ncomp_cons);

// NOTE: QKE was removed so ths is for backward compatibility
AMREX_ASSERT((chk_ncomp_cons==ncomp_cons) || ((chk_ncomp_cons-1)==ncomp_cons));

// read in the MultiFab data
for (int lev = 0; lev <= finest_level; ++lev)
{
MultiFab cons(grids[lev],dmap[lev],ncomp_cons,0);
VisMF::Read(cons, MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "Cell"));
MultiFab::Copy(vars_new[lev][Vars::cons],cons,0,0,ncomp_cons,0);
vars_new[lev][Vars::cons].setBndry(1.0e34);
// NOTE: For backward compatibility (chk file has QKE)
if ((chk_ncomp_cons-1)==ncomp_cons) {
MultiFab cons(grids[lev],dmap[lev],chk_ncomp_cons,0);
VisMF::Read(cons, MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "Cell"));

// Copy up to RhoKE_comp
MultiFab::Copy(vars_new[lev][Vars::cons],cons,0,0,(RhoKE_comp+1),0);

// Only if we have a PBL model do we need to copy QKE is src to KE in dst
if (solverChoice.turbChoice[lev].pbl_type == PBLType::MYNN25) {
MultiFab::Copy(vars_new[lev][Vars::cons],cons,RhoKE_comp,(RhoKE_comp+1),1,0);
vars_new[lev][Vars::cons].mult(0.5,RhoKE_comp,1,0);
}
vars_new[lev][Vars::cons].setBndry(1.0e34);
} else {
MultiFab cons(grids[lev],dmap[lev],ncomp_cons,0);
VisMF::Read(cons, MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "Cell"));
MultiFab::Copy(vars_new[lev][Vars::cons],cons,0,0,ncomp_cons,0);
vars_new[lev][Vars::cons].setBndry(1.0e34);
}

MultiFab xvel(convert(grids[lev],IntVect(1,0,0)),dmap[lev],1,0);
VisMF::Read(xvel, MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "XFace"));
Expand Down

0 comments on commit 7265993

Please sign in to comment.