Skip to content

Commit

Permalink
WarpX class: make verboncoeur_axis_correction a private member vari…
Browse files Browse the repository at this point in the history
…able (ECP-WarpX#5604)

This PR changes `verboncoeur_axis_correction` from a static WarpX class
variable to a private member variable (renamed
`m_verboncoeur_axis_correction`).
This is a small step towards reducing the use of static variables in the
WarpX class.
  • Loading branch information
lucafedeli88 authored Jan 28, 2025
1 parent 4eccf4d commit 480186a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Source/FieldSolver/WarpXPushFieldsEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ void WarpX::DampFieldsInGuards(const int lev, amrex::MultiFab* mf)
// It is faster to apply this on the grid than to do it particle by particle.
// It is put here since there isn't another nice place for it.
void
WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, MultiFab* Jz, int lev)
WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, MultiFab* Jz, int lev) const
{
const amrex::IntVect ngJ = Jx->nGrowVect();
const std::array<Real,3>& dx = WarpX::CellSize(lev);
Expand All @@ -1340,7 +1340,7 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
constexpr int NODE = amrex::IndexType::NODE;

// See Verboncoeur JCP 174, 421-427 (2001) for the modified volume factor
const amrex::Real axis_volume_factor = (verboncoeur_axis_correction ? 1._rt/3._rt : 1._rt/4._rt);
const amrex::Real axis_volume_factor = (m_verboncoeur_axis_correction ? 1._rt/3._rt : 1._rt/4._rt);

for ( MFIter mfi(*Jx, TilingIfNotGPU()); mfi.isValid(); ++mfi )
{
Expand Down Expand Up @@ -1504,7 +1504,7 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
}

void
WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev)
WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev) const
{
const amrex::IntVect ngRho = Rho->nGrowVect();
const std::array<Real,3>& dx = WarpX::CellSize(lev);
Expand All @@ -1513,7 +1513,7 @@ WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev)
constexpr int NODE = amrex::IndexType::NODE;

// See Verboncoeur JCP 174, 421-427 (2001) for the modified volume factor
const amrex::Real axis_volume_factor = (verboncoeur_axis_correction ? 1._rt/3._rt : 1._rt/4._rt);
const amrex::Real axis_volume_factor = (m_verboncoeur_axis_correction ? 1._rt/3._rt : 1._rt/4._rt);

Box tilebox;

Expand Down
12 changes: 6 additions & 6 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ public:
//! small time steps.
static bool galerkin_interpolation;

//! Flag whether the Verboncoeur correction is applied to the current and charge density
//! on the axis when using RZ.
static bool verboncoeur_axis_correction;

//! If true, a bilinear filter is used to smooth charge and currents
static bool use_filter;
//! If true, the bilinear filtering of charge and currents is done in Fourier space
Expand Down Expand Up @@ -623,10 +619,10 @@ public:
void ApplyInverseVolumeScalingToCurrentDensity(amrex::MultiFab* Jx,
amrex::MultiFab* Jy,
amrex::MultiFab* Jz,
int lev);
int lev) const;

void ApplyInverseVolumeScalingToChargeDensity(amrex::MultiFab* Rho,
int lev);
int lev) const;
#endif

/**
Expand Down Expand Up @@ -1478,6 +1474,10 @@ private:
// whether to use subcycling
bool m_do_subcycling = false;

//! Flag whether the Verboncoeur correction is applied to the current and charge density
//! on the axis when using RZ.
bool m_verboncoeur_axis_correction = true;

// Macroscopic properties
std::unique_ptr<MacroscopicProperties> m_macroscopic_properties;

Expand Down
4 changes: 1 addition & 3 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ int WarpX::current_centering_noz = 2;
bool WarpX::use_fdtd_nci_corr = false;
bool WarpX::galerkin_interpolation = true;

bool WarpX::verboncoeur_axis_correction = true;

bool WarpX::use_filter = true;
bool WarpX::use_kspace_filter = true;
bool WarpX::use_filter_compensation = false;
Expand Down Expand Up @@ -726,7 +724,7 @@ WarpX::ReadParameters ()

#ifdef WARPX_DIM_RZ
const ParmParse pp_boundary("boundary");
pp_boundary.query("verboncoeur_axis_correction", verboncoeur_axis_correction);
pp_boundary.query("verboncoeur_axis_correction", m_verboncoeur_axis_correction);
#endif

// Read timestepping options
Expand Down

0 comments on commit 480186a

Please sign in to comment.