From 726599336ab028e78378d1c295c8162a50c83e11 Mon Sep 17 00:00:00 2001 From: AMLattanzi Date: Fri, 25 Oct 2024 14:35:30 -0700 Subject: [PATCH] Backwards compatibility for chk files. --- Source/IO/ERF_Checkpoint.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Source/IO/ERF_Checkpoint.cpp b/Source/IO/ERF_Checkpoint.cpp index 5931c3402..93e19640d 100644 --- a/Source/IO/ERF_Checkpoint.cpp +++ b/Source/IO/ERF_Checkpoint.cpp @@ -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"));