Skip to content

Commit

Permalink
remove call to WarpX::GetInstance() from FilterCreateTransformFromFAB…
Browse files Browse the repository at this point in the history
….H (#4873)
  • Loading branch information
lucafedeli88 authored Apr 24, 2024
1 parent 206e6d5 commit 28434e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Source/Particles/MultiParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,10 +1399,12 @@ MultiParticleContainer::doQEDSchwinger ()

const auto Transform = SchwingerTransformFunc{m_qed_schwinger_y_size, PIdx::w};

const amrex::Geometry& geom_level_zero = warpx.Geom(level_0);

const auto num_added = filterCreateTransformFromFAB<1>( *pc_product_ele, *pc_product_pos, dst_ele_tile,
dst_pos_tile, box, fieldsEB, np_ele_dst,
np_pos_dst,Filter, CreateEle, CreatePos,
Transform);
Transform, geom_level_zero);

setNewParticleIDs(dst_ele_tile, np_ele_dst, num_added);
setNewParticleIDs(dst_pos_tile, np_pos_dst, num_added);
Expand Down
38 changes: 18 additions & 20 deletions Source/Particles/ParticleCreation/FilterCreateTransformFromFAB.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define WARPX_FILTER_CREATE_TRANSFORM_FROM_FAB_H_

#include "Particles/ParticleCreation/DefaultInitialization.H"
#include "WarpX.H"

#include <AMReX_REAL.H>
#include <AMReX_TypeTraits.H>
Expand Down Expand Up @@ -40,6 +39,7 @@
* \param[in] create1 callable that defines what will be done for the create step for dst1.
* \param[in] create2 callable that defines what will be done for the create step for dst2.
* \param[in] transform callable that defines the transformation to apply on dst1 and dst2.
* \param[in] geom_lev_zero the geometry object associated to level zero
*
* \return num_added the number of particles that were written to dst1 and dst2.
*/
Expand All @@ -51,34 +51,30 @@ Index filterCreateTransformFromFAB (DstPC& pc1, DstPC& pc2,
const FAB *src_FAB, const Index* mask,
const Index dst1_index, const Index dst2_index,
CreateFunc1&& create1, CreateFunc2&& create2,
TransFunc&& transform) noexcept
TransFunc&& transform, const amrex::Geometry& geom_lev_zero) noexcept
{
using namespace amrex;

const auto ncells = box.volume();
if (ncells == 0) { return 0; }

auto & warpx = WarpX::GetInstance();
const int level_0 = 0;
Geometry const & geom = warpx.Geom(level_0);

constexpr int spacedim = AMREX_SPACEDIM;

#if defined(WARPX_DIM_1D_Z)
const Real zlo_global = geom.ProbLo(0);
const Real dz = geom.CellSize(0);
const Real zlo_global = geom_lev_zero.ProbLo(0);
const Real dz = geom_lev_zero.CellSize(0);
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
const Real xlo_global = geom.ProbLo(0);
const Real dx = geom.CellSize(0);
const Real zlo_global = geom.ProbLo(1);
const Real dz = geom.CellSize(1);
const Real xlo_global = geom_lev_zero.ProbLo(0);
const Real dx = geom_lev_zero.CellSize(0);
const Real zlo_global = geom_lev_zero.ProbLo(1);
const Real dz = geom_lev_zero.CellSize(1);
#elif defined(WARPX_DIM_3D)
const Real xlo_global = geom.ProbLo(0);
const Real dx = geom.CellSize(0);
const Real ylo_global = geom.ProbLo(1);
const Real dy = geom.CellSize(1);
const Real zlo_global = geom.ProbLo(2);
const Real dz = geom.CellSize(2);
const Real xlo_global = geom_lev_zero.ProbLo(0);
const Real dx = geom_lev_zero.CellSize(0);
const Real ylo_global = geom_lev_zero.ProbLo(1);
const Real dy = geom_lev_zero.CellSize(1);
const Real zlo_global = geom_lev_zero.ProbLo(2);
const Real dz = geom_lev_zero.CellSize(2);
#endif

const auto arrNumPartCreation = src_FAB->array();
Expand Down Expand Up @@ -199,6 +195,7 @@ Index filterCreateTransformFromFAB (DstPC& pc1, DstPC& pc2,
* \param[in] create1 callable that defines what will be done for the create step for dst1.
* \param[in] create2 callable that defines what will be done for the create step for dst2.
* \param[in] transform callable that defines the transformation to apply on dst1 and dst2.
* \param[in] geom_lev_zero the geometry object associated to level zero
*
* \return num_added the number of particles that were written to dst1 and dst2.
*/
Expand All @@ -209,7 +206,7 @@ Index filterCreateTransformFromFAB (DstPC& pc1, DstPC& pc2, DstTile& dst1, DstTi
const FABs& src_FABs, const Index dst1_index,
const Index dst2_index, FilterFunc&& filter,
CreateFunc1&& create1, CreateFunc2&& create2,
TransFunc && transform) noexcept
TransFunc && transform, const amrex::Geometry& geom_lev_zero) noexcept
{
using namespace amrex;

Expand Down Expand Up @@ -241,7 +238,8 @@ Index filterCreateTransformFromFAB (DstPC& pc1, DstPC& pc2, DstTile& dst1, DstTi
mask.dataPtr(), dst1_index, dst2_index,
std::forward<CreateFunc1>(create1),
std::forward<CreateFunc2>(create2),
std::forward<TransFunc>(transform));
std::forward<TransFunc>(transform),
geom_lev_zero);
}

#endif // WARPX_FILTER_CREATE_TRANSFORM_FROM_FAB_H_

0 comments on commit 28434e9

Please sign in to comment.