Skip to content

Commit c666e75

Browse files
lucafedeli88EZoni
andauthored
Pass gamma_boost as argument to AcceleratorLattice, LatticeElementFinder (#5541)
This PR is a small step towards the goal of reducing the usage of static variables in the WarpX class. --------- Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
1 parent a203655 commit c666e75

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

Source/AcceleratorLattice/AcceleratorLattice.H

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ public:
4242
* \brief Initialize the element finder instance at the given level of refinement
4343
*
4444
* @param[in] lev the level of refinement
45+
* @param[in] gamma_boost the Lorentz factor of the boosted frame
4546
* @param[in] ba the box array at the level of refinement
4647
* @param[in] dm the distribution map at the level of refinement
4748
*/
48-
void InitElementFinder (int lev, amrex::BoxArray const & ba, amrex::DistributionMapping const & dm);
49+
void InitElementFinder (
50+
int lev,
51+
amrex::Real gamma_boost,
52+
amrex::BoxArray const & ba,
53+
amrex::DistributionMapping const & dm);
4954

5055
/**
5156
* \brief Update the element finder, needed when the simulation frame has moved relative to the lab frame

Source/AcceleratorLattice/AcceleratorLattice.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ AcceleratorLattice::ReadLattice (std::string const & root_name, amrex::ParticleR
7676
}
7777

7878
void
79-
AcceleratorLattice::InitElementFinder (int const lev, amrex::BoxArray const & ba, amrex::DistributionMapping const & dm)
79+
AcceleratorLattice::InitElementFinder (
80+
int const lev, amrex::Real const gamma_boost,
81+
amrex::BoxArray const & ba, amrex::DistributionMapping const & dm)
8082
{
8183
if (m_lattice_defined) {
8284
m_element_finder = std::make_unique<amrex::LayoutData<LatticeElementFinder>>(ba, dm);
8385
for (amrex::MFIter mfi(*m_element_finder); mfi.isValid(); ++mfi)
8486
{
85-
(*m_element_finder)[mfi].InitElementFinder(lev, mfi, *this);
87+
(*m_element_finder)[mfi].InitElementFinder(lev, gamma_boost, mfi, *this);
8688
}
8789
}
8890
}

Source/AcceleratorLattice/LatticeElementFinder.H

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ struct LatticeElementFinder
3030
* \brief Initialize the element finder at the level and grid
3131
*
3232
* @param[in] lev the refinement level
33+
* @param[in] gamma_boost the Lorentz factor of the boosted frame
3334
* @param[in] a_mfi specifies the grid where the finder is defined
3435
* @param[in] accelerator_lattice a reference to the accelerator lattice at the refinement level
3536
*/
36-
void InitElementFinder (int lev, amrex::MFIter const& a_mfi,
37+
void InitElementFinder (int lev, amrex::Real gamma_boost,
38+
amrex::MFIter const& a_mfi,
3739
AcceleratorLattice const& accelerator_lattice);
3840

3941
/**

Source/AcceleratorLattice/LatticeElementFinder.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
using namespace amrex::literals;
1616

1717
void
18-
LatticeElementFinder::InitElementFinder (int const lev, amrex::MFIter const& a_mfi,
18+
LatticeElementFinder::InitElementFinder (int const lev, const amrex::Real gamma_boost,
19+
amrex::MFIter const& a_mfi,
1920
AcceleratorLattice const& accelerator_lattice)
2021
{
2122

@@ -26,8 +27,8 @@ LatticeElementFinder::InitElementFinder (int const lev, amrex::MFIter const& a_m
2627

2728
m_dz = WarpX::CellSize(lev)[2];
2829

29-
m_gamma_boost = WarpX::gamma_boost;
30-
m_uz_boost = std::sqrt(WarpX::gamma_boost*WarpX::gamma_boost - 1._prt)*PhysConst::c;
30+
m_gamma_boost = gamma_boost;
31+
m_uz_boost = std::sqrt(m_gamma_boost*m_gamma_boost - 1._prt)*PhysConst::c;
3132

3233
AllocateIndices(accelerator_lattice);
3334

Source/Parallelization/WarpXRegrid.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi
285285
}
286286

287287
// Re-initialize the lattice element finder with the new ba and dm.
288-
m_accelerator_lattice[lev]->InitElementFinder(lev, ba, dm);
288+
m_accelerator_lattice[lev]->InitElementFinder(lev, gamma_boost, ba, dm);
289289

290290
if (costs[lev] != nullptr)
291291
{

Source/WarpX.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d
21002100
guard_cells.ng_alloc_Rho, guard_cells.ng_alloc_F, guard_cells.ng_alloc_G, aux_is_nodal);
21012101

21022102
m_accelerator_lattice[lev] = std::make_unique<AcceleratorLattice>();
2103-
m_accelerator_lattice[lev]->InitElementFinder(lev, ba, dm);
2103+
m_accelerator_lattice[lev]->InitElementFinder(lev, gamma_boost, ba, dm);
21042104

21052105
}
21062106

0 commit comments

Comments
 (0)