From 7259a224257fbaca9769fe168d2610c25161040f Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 7 Feb 2024 18:02:09 -0800 Subject: [PATCH] Simplify Finalize (#524) --- src/ImpactX.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ImpactX.cpp b/src/ImpactX.cpp index 3d452cc86..d3dbad70c 100644 --- a/src/ImpactX.cpp +++ b/src/ImpactX.cpp @@ -42,23 +42,24 @@ namespace impactx { ImpactX::~ImpactX() { - if (m_grids_initialized) - { - this->finalize(); - m_grids_initialized = false; - } - + this->finalize(); } void ImpactX::finalize () { - m_lattice.clear(); + if (m_grids_initialized) + { + m_lattice.clear(); + + // this one last + amr_data.reset(); - // this one last - amr_data.reset(); + if (amrex::Initialized()) + amrex::Finalize(); - if (amrex::Initialized()) - amrex::Finalize(); + // only finalize once + m_grids_initialized = false; + } } void ImpactX::init_grids ()