Skip to content

Commit

Permalink
further work towards compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Jan 31, 2025
1 parent 68d8937 commit 74c9db2
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 66 deletions.
2 changes: 0 additions & 2 deletions Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ FlushFormatCheckpoint::CheckpointParticles (
write_real_comps.push_back(1);
}

int const compile_time_comps = static_cast<int>(real_names.size());

// get the names of the real comps
// note: skips the mandatory AMREX_SPACEDIM positions for pure SoA
real_names.resize(pc->NumRealComps() - AMREX_SPACEDIM);
Expand Down
11 changes: 2 additions & 9 deletions Source/Diagnostics/ParticleDiag/ParticleDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,17 @@ ParticleDiag::ParticleDiag (
std::fill(m_plot_flags.begin(), m_plot_flags.end(), 0);
bool contains_positions = false;
if (variables[0] != "none"){
std::map<std::string, int> existing_variable_names = pc->GetRealSoANames();
#ifdef WARPX_DIM_RZ
// we reconstruct to Cartesian x,y,z for RZ particle output
existing_variable_names["y"] = PIdx::theta;
#endif
for (const auto& var : variables){
if (var == "phi") {
// User requests phi on particle. This is *not* part of the variables that
// the particle container carries, and is only added to particles during output.
// Therefore, this case needs to be treated specifically.
m_plot_phi = true;
} else {
const auto search = existing_variable_names.find(var);
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
search != existing_variable_names.end(),
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(pc->HasRealComp(var),
"variables argument '" + var
+"' is not an existing attribute for this species");
m_plot_flags[existing_variable_names.at(var)] = 1;
m_plot_flags[pc->GetRealCompIndex(var)] = 1;

if (var == "x" || var == "y" || var == "z") {
contains_positions = true;
Expand Down
24 changes: 12 additions & 12 deletions Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ WarpX::SaveParticlesAtImplicitStepStart ( )
amrex::ParticleReal* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr();

#if (AMREX_SPACEDIM >= 2)
amrex::ParticleReal* x_n = pti.GetAttribs(particle_comps["x_n"]).dataPtr();
amrex::ParticleReal* x_n = pti.GetAttribs("x_n").dataPtr();
#endif
#if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
amrex::ParticleReal* y_n = pti.GetAttribs(particle_comps["y_n"]).dataPtr();
amrex::ParticleReal* y_n = pti.GetAttribs("y_n").dataPtr();
#endif
amrex::ParticleReal* z_n = pti.GetAttribs(particle_comps["z_n"]).dataPtr();
amrex::ParticleReal* ux_n = pti.GetAttribs(particle_comps["ux_n"]).dataPtr();
amrex::ParticleReal* uy_n = pti.GetAttribs(particle_comps["uy_n"]).dataPtr();
amrex::ParticleReal* uz_n = pti.GetAttribs(particle_comps["uz_n"]).dataPtr();
amrex::ParticleReal* z_n = pti.GetAttribs("z_n").dataPtr();
amrex::ParticleReal* ux_n = pti.GetAttribs("ux_n").dataPtr();
amrex::ParticleReal* uy_n = pti.GetAttribs("uy_n").dataPtr();
amrex::ParticleReal* uz_n = pti.GetAttribs("uz_n").dataPtr();

const long np = pti.numParticles();

Expand Down Expand Up @@ -252,15 +252,15 @@ WarpX::FinishImplicitParticleUpdate ()
amrex::ParticleReal* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr();

#if (AMREX_SPACEDIM >= 2)
amrex::ParticleReal* x_n = pti.GetAttribs(particle_comps["x_n"]).dataPtr();
amrex::ParticleReal* x_n = pti.GetAttribs("x_n").dataPtr();
#endif
#if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
amrex::ParticleReal* y_n = pti.GetAttribs(particle_comps["y_n"]).dataPtr();
amrex::ParticleReal* y_n = pti.GetAttribs("y_n").dataPtr();
#endif
amrex::ParticleReal* z_n = pti.GetAttribs(particle_comps["z_n"]).dataPtr();
amrex::ParticleReal* ux_n = pti.GetAttribs(particle_comps["ux_n"]).dataPtr();
amrex::ParticleReal* uy_n = pti.GetAttribs(particle_comps["uy_n"]).dataPtr();
amrex::ParticleReal* uz_n = pti.GetAttribs(particle_comps["uz_n"]).dataPtr();
amrex::ParticleReal* z_n = pti.GetAttribs("z_n").dataPtr();
amrex::ParticleReal* ux_n = pti.GetAttribs("ux_n").dataPtr();
amrex::ParticleReal* uy_n = pti.GetAttribs("uy_n").dataPtr();
amrex::ParticleReal* uz_n = pti.GetAttribs("uz_n").dataPtr();

const long np = pti.numParticles();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public:
ParticleCreation::DefaultInitializeRuntimeAttributes(*tile_products[i],
0, 0,
pc_products[i]->getUserRealAttribs(), pc_products[i]->getUserIntAttribs(),
pc_products[i]->GetRealSoANames(), pc_products[i]->getParticleiComps(),
pc_products[i]->GetRealSoANames(), pc_products[i]->GetIntSoANames(),
pc_products[i]->getUserRealAttribParser(),
pc_products[i]->getUserIntAttribParser(),
#ifdef WARPX_QED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public:
ParticleCreation::DefaultInitializeRuntimeAttributes(*tile_products[i],
0, 0,
pc_products[i]->getUserRealAttribs(), pc_products[i]->getUserIntAttribs(),
pc_products[i]->GetRealSoANames(), pc_products[i]->getParticleiComps(),
pc_products[i]->GetRealSoANames(), pc_products[i]->GetIntSoANames(),
pc_products[i]->getUserRealAttribParser(),
pc_products[i]->getUserIntAttribParser(),
#ifdef WARPX_QED
Expand Down
6 changes: 3 additions & 3 deletions Source/Particles/LaserParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,18 +873,18 @@ LaserParticleContainer::update_laser_particle (WarpXParIter& pti,
#if (AMREX_SPACEDIM >= 2)
ParticleReal* x_n = nullptr;
if (push_type == PushType::Implicit) {
x_n = pti.GetAttribs(particle_comps["x_n"]).dataPtr();
x_n = pti.GetAttribs("x_n").dataPtr();
}
#endif
#if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
ParticleReal* y_n = nullptr;
if (push_type == PushType::Implicit) {
y_n = pti.GetAttribs(particle_comps["y_n"]).dataPtr();
y_n = pti.GetAttribs("y_n").dataPtr();
}
#endif
ParticleReal* z_n = nullptr;
if (push_type == PushType::Implicit) {
z_n = pti.GetAttribs(particle_comps["z_n"]).dataPtr();
z_n = pti.GetAttribs("z_n").dataPtr();
}

// Copy member variables to tmp copies for GPU runs.
Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/MultiParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ void MultiParticleContainer::doQedQuantumSync (int lev,

auto Transform = PhotonEmissionTransformFunc(
m_shr_p_qs_engine->build_optical_depth_functor(),
pc_source->particle_runtime_comps["opticalDepthQSR"],
pc_source->GetRealCompIndex("opticalDepthQSR"),
m_shr_p_qs_engine->build_phot_em_functor(),
pti, lev, Ex.nGrowVect(),
Ex[pti], Ey[pti], Ez[pti],
Expand Down
6 changes: 3 additions & 3 deletions Source/Particles/ParticleCreation/FilterCopyTransform.H
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Index filterCopyTransformParticles (DstPC& pc, DstTile& dst, SrcTile& src,
ParticleCreation::DefaultInitializeRuntimeAttributes(dst,
0, 0,
pc.getUserRealAttribs(), pc.getUserIntAttribs(),
pc.GetRealSoANames(), pc.getParticleiComps(),
pc.GetRealSoANames(), pc.GetIntSoANames(),
pc.getUserRealAttribParser(),
pc.getUserIntAttribParser(),
#ifdef WARPX_QED
Expand Down Expand Up @@ -258,7 +258,7 @@ Index filterCopyTransformParticles (DstPC& pc1, DstPC& pc2, DstTile& dst1, DstTi
ParticleCreation::DefaultInitializeRuntimeAttributes(dst1,
0, 0,
pc1.getUserRealAttribs(), pc1.getUserIntAttribs(),
pc1.GetRealSoANames(), pc1.getParticleiComps(),
pc1.GetRealSoANames(), pc1.GetIntSoANames(),
pc1.getUserRealAttribParser(),
pc1.getUserIntAttribParser(),
#ifdef WARPX_QED
Expand All @@ -272,7 +272,7 @@ Index filterCopyTransformParticles (DstPC& pc1, DstPC& pc2, DstTile& dst1, DstTi
ParticleCreation::DefaultInitializeRuntimeAttributes(dst2,
0, 0,
pc2.getUserRealAttribs(), pc2.getUserIntAttribs(),
pc2.GetRealSoANames(), pc2.getParticleiComps(),
pc2.GetRealSoANames(), pc2.GetIntSoANames(),
pc2.getUserRealAttribParser(),
pc2.getUserIntAttribParser(),
#ifdef WARPX_QED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Index filterCreateTransformFromFAB (DstPC& pc1, DstPC& pc2,
ParticleCreation::DefaultInitializeRuntimeAttributes(dst1,
0, 0,
pc1.getUserRealAttribs(), pc1.getUserIntAttribs(),
pc1.GetRealSoANames(), pc1.getParticleiComps(),
pc1.GetRealSoANames(), pc1.GetIntSoANames(),
pc1.getUserRealAttribParser(),
pc1.getUserIntAttribParser(),
#ifdef WARPX_QED
Expand All @@ -150,7 +150,7 @@ Index filterCreateTransformFromFAB (DstPC& pc1, DstPC& pc2,
ParticleCreation::DefaultInitializeRuntimeAttributes(dst2,
0, 0,
pc2.getUserRealAttribs(), pc2.getUserIntAttribs(),
pc2.GetRealSoANames(), pc2.getParticleiComps(),
pc2.GetRealSoANames(), pc2.GetIntSoANames(),
pc2.getUserRealAttribParser(),
pc2.getUserIntAttribParser(),
#ifdef WARPX_QED
Expand Down
4 changes: 2 additions & 2 deletions Source/Particles/ParticleCreation/SmartCopy.H
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public:
template <class SrcPC, class DstPC>
SmartCopyFactory (const SrcPC& src, const DstPC& dst) noexcept :
m_tag_real{getSmartCopyTag(src.GetRealSoANames(), dst.GetRealSoANames())},
m_tag_int{getSmartCopyTag(src.getParticleiComps(), dst.getParticleiComps())},
m_tag_int{getSmartCopyTag(src.GetIntSoANames(), dst.GetIntSoANames())},
m_policy_real{getPolicies(dst.GetRealSoANames())},
m_policy_int{getPolicies(dst.getParticleiComps())},
m_policy_int{getPolicies(dst.GetIntSoANames())},
m_defined{true}
{}

Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/ParticleCreation/SmartCreate.H
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public:
template <class PartTileData>
SmartCreateFactory (const PartTileData& part) noexcept:
m_policy_real{getPolicies(part.GetRealSoANames())},
m_policy_int{getPolicies(part.getParticleiComps())},
m_policy_int{getPolicies(part.GetIntSoANames())},
m_defined{true}
{}

Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/PhotonParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ PhotonParticleContainer::PushPX (WarpXParIter& pti,
const bool local_has_breit_wheeler = has_breit_wheeler();
if (local_has_breit_wheeler) {
evolve_opt = m_shr_p_bw_engine->build_evolve_functor();
p_optical_depth_BW = pti.GetAttribs(particle_comps["opticalDepthBW"]).dataPtr() + offset;
p_optical_depth_BW = pti.GetAttribs("opticalDepthBW").dataPtr() + offset;
}
#endif

Expand Down
22 changes: 11 additions & 11 deletions Source/Particles/PhysicalParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2629,12 +2629,12 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti,
ParticleReal* z_old = nullptr;
if (save_previous_position) {
#if (AMREX_SPACEDIM >= 2)
x_old = pti.GetAttribs(particle_comps["prev_x"]).dataPtr() + offset;
x_old = pti.GetAttribs("prev_x").dataPtr() + offset;
#endif
#if defined(WARPX_DIM_3D)
y_old = pti.GetAttribs(particle_comps["prev_y"]).dataPtr() + offset;
y_old = pti.GetAttribs("prev_y").dataPtr() + offset;
#endif
z_old = pti.GetAttribs(particle_comps["prev_z"]).dataPtr() + offset;
z_old = pti.GetAttribs("prev_z").dataPtr() + offset;
amrex::ignore_unused(x_old, y_old);
}

Expand All @@ -2654,7 +2654,7 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti,
const bool local_has_quantum_sync = has_quantum_sync();
if (local_has_quantum_sync) {
evolve_opt = m_shr_p_qs_engine->build_evolve_functor();
p_optical_depth_QSR = pti.GetAttribs(particle_comps["opticalDepthQSR"]).dataPtr() + offset;
p_optical_depth_QSR = pti.GetAttribs("opticalDepthQSR").dataPtr() + offset;
}
#endif

Expand Down Expand Up @@ -2859,15 +2859,15 @@ PhysicalParticleContainer::ImplicitPushXP (WarpXParIter& pti,
ParticleReal* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr() + offset;

#if (AMREX_SPACEDIM >= 2)
ParticleReal* x_n = pti.GetAttribs(particle_comps["x_n"]).dataPtr();
ParticleReal* x_n = pti.GetAttribs("x_n").dataPtr();
#endif
#if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
ParticleReal* y_n = pti.GetAttribs(particle_comps["y_n"]).dataPtr();
ParticleReal* y_n = pti.GetAttribs("y_n").dataPtr();
#endif
ParticleReal* z_n = pti.GetAttribs(particle_comps["z_n"]).dataPtr();
ParticleReal* ux_n = pti.GetAttribs(particle_comps["ux_n"]).dataPtr();
ParticleReal* uy_n = pti.GetAttribs(particle_comps["uy_n"]).dataPtr();
ParticleReal* uz_n = pti.GetAttribs(particle_comps["uz_n"]).dataPtr();
ParticleReal* z_n = pti.GetAttribs("z_n").dataPtr();
ParticleReal* ux_n = pti.GetAttribs("ux_n").dataPtr();
ParticleReal* uy_n = pti.GetAttribs("uy_n").dataPtr();
ParticleReal* uz_n = pti.GetAttribs("uz_n").dataPtr();

const int do_copy = (m_do_back_transformed_particles && (a_dt_type!=DtType::SecondHalf) );
CopyParticleAttribs copyAttribs;
Expand Down Expand Up @@ -2896,7 +2896,7 @@ PhysicalParticleContainer::ImplicitPushXP (WarpXParIter& pti,
const bool local_has_quantum_sync = has_quantum_sync();
if (local_has_quantum_sync) {
evolve_opt = m_shr_p_qs_engine->build_evolve_functor();
p_optical_depth_QSR = pti.GetAttribs(particle_comps["opticalDepthQSR"]).dataPtr() + offset;
p_optical_depth_QSR = pti.GetAttribs("opticalDepthQSR").dataPtr() + offset;
}
#endif

Expand Down
25 changes: 25 additions & 0 deletions Source/Particles/WarpXParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,35 @@ public:
return GetStructOfArrays().GetRealData(comp);
}

[[nodiscard]] const IntVector& GetiAttribs (int comp) const
{
return GetStructOfArrays().GetIntData(comp);
}

[[nodiscard]] IntVector& GetiAttribs (int comp)
{
return GetStructOfArrays().GetIntData(comp);
}

[[nodiscard]] const RealVector& GetAttribs (const std::string& name) const
{
return GetStructOfArrays().GetRealData(name);
}

[[nodiscard]] RealVector& GetAttribs (const std::string& name)
{
return GetStructOfArrays().GetRealData(name);
}

[[nodiscard]] const IntVector& GetiAttribs (const std::string& name) const
{
return GetStructOfArrays().GetIntData(name);
}

[[nodiscard]] IntVector& GetiAttribs (const std::string& name)
{
return GetStructOfArrays().GetIntData(name);
}
};

/**
Expand Down
30 changes: 15 additions & 15 deletions Source/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,22 +631,22 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti,

} else if (push_type == PushType::Implicit) {
#if (AMREX_SPACEDIM >= 2)
auto& xp_n = pti.GetAttribs(particle_comps["x_n"]);
auto& xp_n = pti.GetAttribs("x_n");
const ParticleReal* xp_n_data = xp_n.dataPtr() + offset;
#else
const ParticleReal* xp_n_data = nullptr;
#endif
#if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
auto& yp_n = pti.GetAttribs(particle_comps["y_n"]);
auto& yp_n = pti.GetAttribs("y_n");
const ParticleReal* yp_n_data = yp_n.dataPtr() + offset;
#else
const ParticleReal* yp_n_data = nullptr;
#endif
auto& zp_n = pti.GetAttribs(particle_comps["z_n"]);
auto& zp_n = pti.GetAttribs("z_n");
const ParticleReal* zp_n_data = zp_n.dataPtr() + offset;
auto& uxp_n = pti.GetAttribs(particle_comps["ux_n"]);
auto& uyp_n = pti.GetAttribs(particle_comps["uy_n"]);
auto& uzp_n = pti.GetAttribs(particle_comps["uz_n"]);
auto& uxp_n = pti.GetAttribs("ux_n");
auto& uyp_n = pti.GetAttribs("uy_n");
auto& uzp_n = pti.GetAttribs("uz_n");
if (WarpX::nox == 1){
doChargeConservingDepositionShapeNImplicit<1>(
xp_n_data, yp_n_data, zp_n_data,
Expand Down Expand Up @@ -684,22 +684,22 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti,
} else if (WarpX::current_deposition_algo == CurrentDepositionAlgo::Villasenor) {
if (push_type == PushType::Implicit) {
#if (AMREX_SPACEDIM >= 2)
auto& xp_n = pti.GetAttribs(particle_comps["x_n"]);
auto& xp_n = pti.GetAttribs("x_n");
const ParticleReal* xp_n_data = xp_n.dataPtr() + offset;
#else
const ParticleReal* xp_n_data = nullptr;
#endif
#if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
auto& yp_n = pti.GetAttribs(particle_comps["y_n"]);
auto& yp_n = pti.GetAttribs("y_n");
const ParticleReal* yp_n_data = yp_n.dataPtr() + offset;
#else
const ParticleReal* yp_n_data = nullptr;
#endif
auto& zp_n = pti.GetAttribs(particle_comps["z_n"]);
auto& zp_n = pti.GetAttribs("z_n");
const ParticleReal* zp_n_data = zp_n.dataPtr() + offset;
auto& uxp_n = pti.GetAttribs(particle_comps["ux_n"]);
auto& uyp_n = pti.GetAttribs(particle_comps["uy_n"]);
auto& uzp_n = pti.GetAttribs(particle_comps["uz_n"]);
auto& uxp_n = pti.GetAttribs("ux_n");
auto& uyp_n = pti.GetAttribs("uy_n");
auto& uzp_n = pti.GetAttribs("uz_n");
if (WarpX::nox == 1){
doVillasenorDepositionShapeNImplicit<1>(
xp_n_data, yp_n_data, zp_n_data,
Expand Down Expand Up @@ -794,9 +794,9 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti,
xyzmin, lo, q, WarpX::n_rz_azimuthal_modes);
}
} else if (push_type == PushType::Implicit) {
auto& uxp_n = pti.GetAttribs(particle_comps["ux_n"]);
auto& uyp_n = pti.GetAttribs(particle_comps["uy_n"]);
auto& uzp_n = pti.GetAttribs(particle_comps["uz_n"]);
auto& uxp_n = pti.GetAttribs("ux_n");
auto& uyp_n = pti.GetAttribs("uy_n");
auto& uzp_n = pti.GetAttribs("uz_n");
if (WarpX::nox == 1){
doDepositionShapeNImplicit<1>(
GetPosition, wp.dataPtr() + offset,
Expand Down
2 changes: 1 addition & 1 deletion Source/Python/Particles/PinnedMemoryParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void init_PinnedMemoryParticleContainer (py::module& m)
.def_property_readonly("int_comp_names",
[](PinnedMemoryParticleContainer& pc)
{
return pc.getParticleiComps();
return pc.GetIntSoANames();
}
);
}
2 changes: 1 addition & 1 deletion Source/Python/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void init_WarpXParticleContainer (py::module& m)
.def("get_icomp_index",
[](WarpXParticleContainer& pc, std::string comp_name)
{
auto particle_comps = pc.getParticleiComps();
auto particle_comps = pc.GetIntSoANames();
return particle_comps.at(comp_name);
},
py::arg("comp_name")
Expand Down

0 comments on commit 74c9db2

Please sign in to comment.