From 96ad03466cf51d3b933d777fc061f00dba559139 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 16 Oct 2023 11:42:19 -0700 Subject: [PATCH] `RemoveRealComp`/`RemoveIntComp` Add new functions to remove runtime components. --- Src/Particle/AMReX_NeighborParticles.H | 24 ++++++++++++++++++++++ Src/Particle/AMReX_ParticleContainer.H | 28 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/Src/Particle/AMReX_NeighborParticles.H b/Src/Particle/AMReX_NeighborParticles.H index 781c9ddc446..a8c87c5ab1d 100644 --- a/Src/Particle/AMReX_NeighborParticles.H +++ b/Src/Particle/AMReX_NeighborParticles.H @@ -309,6 +309,30 @@ public: calcCommSize(); } + /** Remove the last n Real components of the species + * + * @param n number of components to remove + */ + void RemoveRealComp (int n = 1) + { + ParticleContainer:: + RemoveRealComp(n); + ghost_real_comp.pop_back(); + calcCommSize(); + } + + /** Remove the last n Int components of the species + * + * @param n number of components to remove + */ + void RemoveIntComp (int n = 1) + { + ParticleContainer:: + RemoveIntComp(n); + ghost_int_comp.pop_back(); + calcCommSize(); + } + void Redistribute (int lev_min=0, int lev_max=-1, int nGrow=0, int local=0) { clearNeighbors(); diff --git a/Src/Particle/AMReX_ParticleContainer.H b/Src/Particle/AMReX_ParticleContainer.H index df71f2eeec1..ac60923fd29 100644 --- a/Src/Particle/AMReX_ParticleContainer.H +++ b/Src/Particle/AMReX_ParticleContainer.H @@ -1261,6 +1261,34 @@ public: SetParticleSize(); } + /** Remove the last n Real components of the species + * + * @param n number of components to remove + */ + void RemoveRealComp (int n = 1) + { + m_num_runtime_real--; + if (m_num_runtime_real == 0 && m_num_runtime_int == 0) + m_runtime_comps_defined = false; + for (int i = 0; i < n; ++i) + h_redistribute_real_comp.pop_back(); + SetParticleSize(); + } + + /** Remove the last n Int components of the species + * + * @param n number of components to remove + */ + void RemoveIntComp (int n = 1) + { + m_num_runtime_int--; + if (m_num_runtime_real == 0 && m_num_runtime_int == 0) + m_runtime_comps_defined = false; + for (int i = 0; i < n; ++i) + h_redistribute_int_comp.pop_back(); + SetParticleSize(); + } + int NumRuntimeRealComps () const { return m_num_runtime_real; } int NumRuntimeIntComps () const { return m_num_runtime_int; }