From f8e2376d0f45e56011704c4909130c58b95d8e4e Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Fri, 24 Jan 2025 23:50:02 +0100 Subject: [PATCH] WarpX class: make do_divb_cleaning_external a private member variable (#5598) This PR changes `do_divb_cleaning_external` from a static WarpX class variable to a private member variable (renamed `m_do_divb_cleaning_external`). This is a small step towards reducing the use of static variables in the WarpX class. --- Source/Initialization/WarpXInitData.cpp | 2 +- Source/WarpX.H | 8 ++++---- Source/WarpX.cpp | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 7d7e9b5e601..98efb1f5b3f 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -590,7 +590,7 @@ WarpX::InitData () WriteUsedInputsFile(); // Run div cleaner here on loaded external fields - if (WarpX::do_divb_cleaning_external) { + if (m_do_divb_cleaning_external) { WarpX::ProjectionCleanDivB(); } diff --git a/Source/WarpX.H b/Source/WarpX.H index f40792de891..06b2d46e910 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -290,10 +290,6 @@ public: //! Solve additional Maxwell equation for G in order to control errors in magnetic Gauss' law static bool do_divb_cleaning; - //! Solve Poisson equation when loading an external magnetic field to clean divergence - //! This is useful to remove errors that could lead to non-zero B field divergence - static bool do_divb_cleaning_external; - //! Order of the particle shape factors (splines) along x static int nox; //! Order of the particle shape factors (splines) along y @@ -1582,6 +1578,10 @@ private: int noy_fft = 16; int noz_fft = 16; + //! Solve Poisson equation when loading an external magnetic field to clean divergence + //! This is useful to remove errors that could lead to non-zero B field divergence + bool m_do_divb_cleaning_external = false; + //! Domain decomposition on Level 0 amrex::IntVect numprocs{0}; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 21bf48be8e0..5896a918480 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -118,7 +118,6 @@ int WarpX::max_particle_its_in_implicit_scheme = 21; ParticleReal WarpX::particle_tol_in_implicit_scheme = 1.e-10; bool WarpX::do_dive_cleaning = false; bool WarpX::do_divb_cleaning = false; -bool WarpX::do_divb_cleaning_external = false; bool WarpX::do_single_precision_comms = false; bool WarpX::do_shared_mem_charge_deposition = false; @@ -1064,9 +1063,9 @@ WarpX::ReadParameters () || WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic) && WarpX::poisson_solver_id == PoissonSolverAlgo::Multigrid))) { - do_divb_cleaning_external = true; + m_do_divb_cleaning_external = true; } - pp_warpx.query("do_divb_cleaning_external", do_divb_cleaning_external); + pp_warpx.query("do_divb_cleaning_external", m_do_divb_cleaning_external); // If true, the current is deposited on a nodal grid and centered onto // a staggered grid. Setting warpx.do_current_centering=1 makes sense