Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass gamma_boost as an argument to AcceleratorLattice and LatticeElementFinder #5541

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Source/AcceleratorLattice/AcceleratorLattice.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ public:
* \brief Initialize the element finder instance at the given level of refinement
*
* @param[in] lev the level of refinement
* @param[in] gamma_boost the Lorentz factor of the boosted frame
* @param[in] ba the box array at the level of refinement
* @param[in] dm the distribution map at the level of refinement
*/
void InitElementFinder (int lev, amrex::BoxArray const & ba, amrex::DistributionMapping const & dm);
void InitElementFinder (
int lev,
amrex::Real gamma_boost,
EZoni marked this conversation as resolved.
Show resolved Hide resolved
amrex::BoxArray const & ba,
amrex::DistributionMapping const & dm);

/**
* \brief Update the element finder, needed when the simulation frame has moved relative to the lab frame
Expand Down
6 changes: 4 additions & 2 deletions Source/AcceleratorLattice/AcceleratorLattice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ AcceleratorLattice::ReadLattice (std::string const & root_name, amrex::ParticleR
}

void
AcceleratorLattice::InitElementFinder (int const lev, amrex::BoxArray const & ba, amrex::DistributionMapping const & dm)
AcceleratorLattice::InitElementFinder (
int const lev, amrex::Real const gamma_boost,
amrex::BoxArray const & ba, amrex::DistributionMapping const & dm)
{
if (m_lattice_defined) {
m_element_finder = std::make_unique<amrex::LayoutData<LatticeElementFinder>>(ba, dm);
for (amrex::MFIter mfi(*m_element_finder); mfi.isValid(); ++mfi)
{
(*m_element_finder)[mfi].InitElementFinder(lev, mfi, *this);
(*m_element_finder)[mfi].InitElementFinder(lev, gamma_boost, mfi, *this);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Source/AcceleratorLattice/LatticeElementFinder.H
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ struct LatticeElementFinder
* \brief Initialize the element finder at the level and grid
*
* @param[in] lev the refinement level
* @param[in] gamma_boost the Lorentz factor of the boosted frame
* @param[in] a_mfi specifies the grid where the finder is defined
* @param[in] accelerator_lattice a reference to the accelerator lattice at the refinement level
*/
void InitElementFinder (int lev, amrex::MFIter const& a_mfi,
void InitElementFinder (int lev, amrex::Real gamma_boost,
EZoni marked this conversation as resolved.
Show resolved Hide resolved
amrex::MFIter const& a_mfi,
AcceleratorLattice const& accelerator_lattice);

/**
Expand Down
7 changes: 4 additions & 3 deletions Source/AcceleratorLattice/LatticeElementFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
using namespace amrex::literals;

void
LatticeElementFinder::InitElementFinder (int const lev, amrex::MFIter const& a_mfi,
LatticeElementFinder::InitElementFinder (int const lev, const amrex::Real gamma_boost,
amrex::MFIter const& a_mfi,
AcceleratorLattice const& accelerator_lattice)
{

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

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

m_gamma_boost = WarpX::gamma_boost;
m_uz_boost = std::sqrt(WarpX::gamma_boost*WarpX::gamma_boost - 1._prt)*PhysConst::c;
m_gamma_boost = gamma_boost;
m_uz_boost = std::sqrt(m_gamma_boost*m_gamma_boost - 1._prt)*PhysConst::c;

AllocateIndices(accelerator_lattice);

Expand Down
2 changes: 1 addition & 1 deletion Source/Parallelization/WarpXRegrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi
}

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

if (costs[lev] != nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d
guard_cells.ng_alloc_Rho, guard_cells.ng_alloc_F, guard_cells.ng_alloc_G, aux_is_nodal);

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

}

Expand Down
Loading