From d550332397a65ebbd83c3fb783c33d89dd56603c Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 5 Mar 2024 08:57:31 -0800 Subject: [PATCH] Disable tracer particles at run time There is a runtime parameter `particles.do_nspc_particles` for disabling particles. But it was not used everywhere. This commit fixes it. --- Source/NS_setup.cpp | 26 ++++++++++++++------------ Source/NavierStokes.cpp | 4 +++- Source/NavierStokesBase.cpp | 4 +++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Source/NS_setup.cpp b/Source/NS_setup.cpp index 9019ffd5..f98bcf74 100644 --- a/Source/NS_setup.cpp +++ b/Source/NS_setup.cpp @@ -449,18 +449,20 @@ NavierStokes::variableSetUp () derive_lst.addComponent("avg_pressure",desc_lst,Press_Type,Pressure,1); #ifdef AMREX_PARTICLES - // - // The particle count at this level. - // - derive_lst.add("particle_count",IndexType::TheCellType(),1, - dernull,the_same_box); - derive_lst.addComponent("particle_count",desc_lst,State_Type,Density,1); - // - // The total # of particles at our level or above. - // - derive_lst.add("total_particle_count",IndexType::TheCellType(),1, - dernull,the_same_box); - derive_lst.addComponent("total_particle_count",desc_lst,State_Type,Density,1); + if (do_nspc) { + // + // The particle count at this level. + // + derive_lst.add("particle_count",IndexType::TheCellType(),1, + dernull,the_same_box); + derive_lst.addComponent("particle_count",desc_lst,State_Type,Density,1); + // + // The total # of particles at our level or above. + // + derive_lst.add("total_particle_count",IndexType::TheCellType(),1, + dernull,the_same_box); + derive_lst.addComponent("total_particle_count",desc_lst,State_Type,Density,1); + } #endif // diff --git a/Source/NavierStokes.cpp b/Source/NavierStokes.cpp index 215fa386..9817f9e6 100644 --- a/Source/NavierStokes.cpp +++ b/Source/NavierStokes.cpp @@ -478,7 +478,9 @@ NavierStokes::initData () } #ifdef AMREX_PARTICLES - initParticleData (); + if (do_nspc) { + initParticleData (); + } #endif } diff --git a/Source/NavierStokesBase.cpp b/Source/NavierStokesBase.cpp index 835ee33f..43a7fb40 100644 --- a/Source/NavierStokesBase.cpp +++ b/Source/NavierStokesBase.cpp @@ -623,7 +623,7 @@ NavierStokesBase::advance_setup (Real /*time*/, umac_n_grow = 1; #ifdef AMREX_PARTICLES - if (ncycle > umac_n_grow) { + if (ncycle > umac_n_grow && NSPC) { umac_n_grow = ncycle; } #endif @@ -3813,6 +3813,8 @@ NavierStokesBase::read_particle_params () void NavierStokesBase::initParticleData () { + if (!do_nspc) { return; } + if (level == 0) { if (NSPC == 0)