From 5ef9c86cb464436d137ff329bb0ffc3aced46b62 Mon Sep 17 00:00:00 2001 From: Candace Gilet Date: Tue, 3 Dec 2024 23:07:10 +0100 Subject: [PATCH] Only call setVal on defined p_nd/p_cc (#141) --- src/incflo_regrid.cpp | 14 ++++++++++---- src/prob/prob_init_fluid.cpp | 7 +++++-- src/setup/init.cpp | 7 +++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/incflo_regrid.cpp b/src/incflo_regrid.cpp index 618f1b8b..87c507d0 100644 --- a/src/incflo_regrid.cpp +++ b/src/incflo_regrid.cpp @@ -35,8 +35,11 @@ void incflo::MakeNewLevelFromCoarse (int lev, } fillcoarsepatch_gradp(lev, time, new_leveldata->gp, 0); - new_leveldata->p_cc.setVal(0.0); - new_leveldata->p_nd.setVal(0.0); + if (m_use_cc_proj) { + new_leveldata->p_cc.setVal(0.0); + } else { + new_leveldata->p_nd.setVal(0.0); + } m_leveldata[lev] = std::move(new_leveldata); m_factory[lev] = std::move(new_fact); @@ -85,8 +88,11 @@ void incflo::RemakeLevel (int lev, Real time, const BoxArray& ba, } fillpatch_gradp(lev, time, new_leveldata->gp, 0); - new_leveldata->p_cc.setVal(0.0); - new_leveldata->p_nd.setVal(0.0); + if (m_use_cc_proj) { + new_leveldata->p_cc.setVal(0.0); + } else { + new_leveldata->p_nd.setVal(0.0); + } m_leveldata[lev] = std::move(new_leveldata); m_factory[lev] = std::move(new_fact); diff --git a/src/prob/prob_init_fluid.cpp b/src/prob/prob_init_fluid.cpp index 7c2f5e09..e92288f2 100644 --- a/src/prob/prob_init_fluid.cpp +++ b/src/prob/prob_init_fluid.cpp @@ -10,8 +10,11 @@ void incflo::prob_init_fluid (int lev) auto const& problo = geom[lev].ProbLoArray(); auto const& probhi = geom[lev].ProbHiArray(); - ld.p_cc.setVal(0.0); - ld.p_nd.setVal(0.0); + if (m_use_cc_proj) { + ld.p_cc.setVal(0.0); + } else { + ld.p_nd.setVal(0.0); + } ld.gp.setVal(0.0); diff --git a/src/setup/init.cpp b/src/setup/init.cpp index 1f873dec..8af4518e 100644 --- a/src/setup/init.cpp +++ b/src/setup/init.cpp @@ -486,8 +486,11 @@ void incflo::InitialProjection() // We set p and gp back to zero (p0 may still be still non-zero) for (int lev = 0; lev <= finest_level; lev++) { - m_leveldata[lev]->p_nd.setVal(0.0); - m_leveldata[lev]->p_cc.setVal(0.0); + if (m_use_cc_proj) { + m_leveldata[lev]->p_cc.setVal(0.0); + } else { + m_leveldata[lev]->p_nd.setVal(0.0); + } m_leveldata[lev]->gp.setVal(0.0); } }