diff --git a/cmake/dependencies/pyAMReX.cmake b/cmake/dependencies/pyAMReX.cmake index ca42519c4..ed74a1291 100644 --- a/cmake/dependencies/pyAMReX.cmake +++ b/cmake/dependencies/pyAMReX.cmake @@ -71,10 +71,10 @@ set(ImpactX_pyamrex_src "" # Git fetcher option(ImpactX_pyamrex_internal "Download & build pyAMReX" ON) -set(ImpactX_pyamrex_repo "https://github.com/AMReX-Codes/pyamrex.git" +set(ImpactX_pyamrex_repo "https://github.com/ax3l/pyamrex.git" CACHE STRING "Repository URI to pull and build pyamrex from if(ImpactX_pyamrex_internal)") -set(ImpactX_pyamrex_branch "de24942c76ebc61ffaa184204c2491aebc357a07" +set(ImpactX_pyamrex_branch "topic-polymorphic-pc" CACHE STRING "Repository branch for ImpactX_pyamrex_repo if(ImpactX_pyamrex_internal)") diff --git a/src/elements/diagnostics/BeamMonitor.H b/src/elements/diagnostics/BeamMonitor.H index b1432288a..f3c1c2133 100644 --- a/src/elements/diagnostics/BeamMonitor.H +++ b/src/elements/diagnostics/BeamMonitor.H @@ -30,7 +30,7 @@ namespace detail { class ImpactXParticleCounter { public: - using ParticleContainer = typename ImpactXParticleContainer::ContainerLike; + using ParticleContainer = typename ImpactXParticleContainer::ContainerLike; using ParticleIter = typename ParticleContainer::ParIterType; ImpactXParticleCounter (ParticleContainer & pc); @@ -70,7 +70,7 @@ namespace detail { static constexpr auto type = "BeamMonitor"; using PType = typename ImpactXParticleContainer::ParticleType; - using PinnedContainer = typename ImpactXParticleContainer::ContainerLike; + using PinnedContainer = typename ImpactXParticleContainer::ContainerLike; /** This element writes the particle beam out to openPMD data. * diff --git a/src/elements/diagnostics/BeamMonitor.cpp b/src/elements/diagnostics/BeamMonitor.cpp index 02d9a0fc5..8242ddfa1 100644 --- a/src/elements/diagnostics/BeamMonitor.cpp +++ b/src/elements/diagnostics/BeamMonitor.cpp @@ -334,7 +334,8 @@ namespace detail { std::vector int_soa_names = pc.GetIntSoANames(); // pinned memory copy - PinnedContainer pinned_pc = pc.make_alike(); + PinnedContainer pinned_pc = pc.make_alike(); + pinned_pc.SetArena(amrex::The_Pinned_Arena()); pinned_pc.copyParticles(pc, true); // no filtering // TODO: filtering diff --git a/src/envelope/spacecharge/EnvelopeSpaceChargePush.cpp b/src/envelope/spacecharge/EnvelopeSpaceChargePush.cpp index 3c2779399..e850a06ca 100644 --- a/src/envelope/spacecharge/EnvelopeSpaceChargePush.cpp +++ b/src/envelope/spacecharge/EnvelopeSpaceChargePush.cpp @@ -41,7 +41,7 @@ namespace impactx::envelope::spacecharge // physical constants and reference quantities using ablastr::constant::SI::c; - using ablastr::constant::SI::ep0; + using ablastr::constant::SI::epsilon_0; using ablastr::constant::math::pi; amrex::ParticleReal const mass = refpart.mass; amrex::ParticleReal const charge = refpart.charge; @@ -51,7 +51,7 @@ namespace impactx::envelope::spacecharge amrex::ParticleReal const betgam3 = powi<3>(betgam); // evaluate the beam space charge perveance from current - amrex::ParticleReal const IA = 4_prt * pi * ep0 * mass * powi<3>(c) / charge; + amrex::ParticleReal const IA = 4_prt * pi * epsilon_0 * mass * powi<3>(c) / charge; amrex::ParticleReal const Kpv = std::abs(current / IA) * 2_prt / betgam3; // evaluate the linear transfer map @@ -89,7 +89,7 @@ namespace impactx::envelope::spacecharge // physical constants and reference quantities using ablastr::constant::SI::c; - using ablastr::constant::SI::ep0; + using ablastr::constant::SI::epsilon_0; using ablastr::constant::math::pi; amrex::ParticleReal const mass = refpart.mass; amrex::ParticleReal const charge = refpart.charge; @@ -97,7 +97,7 @@ namespace impactx::envelope::spacecharge amrex::ParticleReal const betgam2 = powi<2>(pt_ref) - 1_prt; // evaluate the 3D space charge intensity parameter from bunch charge - amrex::ParticleReal const rcN = std::abs(charge * bunch_charge) / (4_prt * pi * ep0 * mass * powi<2>(c)); + amrex::ParticleReal const rcN = std::abs(charge * bunch_charge) / (4_prt * pi * epsilon_0 * mass * powi<2>(c)); amrex::ParticleReal const coeff = ds * rcN / betgam2 * (1_prt/(5_prt * std::sqrt(5_prt))); // set parameters for elliptic integrals diff --git a/src/initialization/InitDistribution.cpp b/src/initialization/InitDistribution.cpp index b5c2f40e0..d8f872cac 100644 --- a/src/initialization/InitDistribution.cpp +++ b/src/initialization/InitDistribution.cpp @@ -48,13 +48,13 @@ namespace impactx amrex::ParticleReal massE; // MeV/c^2 if (particle_type == "electron") { qe = -1.0; - massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_invc2; + massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_inv_c2; } else if (particle_type == "positron") { qe = 1.0; - massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_invc2; + massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_inv_c2; } else if (particle_type == "proton") { qe = 1.0; - massE = ablastr::constant::SI::m_p / ablastr::constant::SI::MeV_invc2; + massE = ablastr::constant::SI::m_p / ablastr::constant::SI::MeV_inv_c2; } else if (particle_type == "Hminus") { qe = -1.0; massE = 939.294308; // value used in TraceWin @@ -66,7 +66,7 @@ namespace impactx ablastr::warn_manager::WarnPriority::low ); qe = -1.0; - massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_invc2; + massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_inv_c2; } // configure a new reference particle diff --git a/src/particles/ImpactXParticleContainer.H b/src/particles/ImpactXParticleContainer.H index d518b5bd6..886036b40 100644 --- a/src/particles/ImpactXParticleContainer.H +++ b/src/particles/ImpactXParticleContainer.H @@ -94,10 +94,10 @@ namespace impactx * `static` in AMReX, to `dynamic` in ImpactX. */ class ParIterSoA - : public amrex::ParIterSoA + : public amrex::ParIterSoA { public: - using amrex::ParIterSoA::ParIterSoA; + using amrex::ParIterSoA::ParIterSoA; ParIterSoA (ContainerType& pc, int level); @@ -112,10 +112,10 @@ namespace impactx * `static` in AMReX, to `dynamic` in ImpactX. */ class ParConstIterSoA - : public amrex::ParConstIterSoA + : public amrex::ParConstIterSoA { public: - using amrex::ParConstIterSoA::ParConstIterSoA; + using amrex::ParConstIterSoA::ParConstIterSoA; ParConstIterSoA (ContainerType& pc, int level); @@ -129,7 +129,7 @@ namespace impactx * This class stores particles, distributed over MPI ranks. */ class ImpactXParticleContainer - : public amrex::ParticleContainerPureSoA + : public amrex::ParticleContainerPureSoA { public: //! amrex iterator for particle boxes diff --git a/src/particles/ImpactXParticleContainer.cpp b/src/particles/ImpactXParticleContainer.cpp index bb6ce3e4a..be2804a50 100644 --- a/src/particles/ImpactXParticleContainer.cpp +++ b/src/particles/ImpactXParticleContainer.cpp @@ -45,24 +45,25 @@ namespace namespace impactx { ParIterSoA::ParIterSoA (ContainerType& pc, int level) - : amrex::ParIterSoA(pc, level, + : amrex::ParIterSoA(pc, level, amrex::MFItInfo().SetDynamic(do_omp_dynamic())) {} ParIterSoA::ParIterSoA (ContainerType& pc, int level, amrex::MFItInfo& info) - : amrex::ParIterSoA(pc, level, + : amrex::ParIterSoA(pc, level, info.SetDynamic(do_omp_dynamic())) {} ParConstIterSoA::ParConstIterSoA (ContainerType& pc, int level) - : amrex::ParConstIterSoA(pc, level, + : amrex::ParConstIterSoA(pc, level, amrex::MFItInfo().SetDynamic(do_omp_dynamic())) {} ParConstIterSoA::ParConstIterSoA (ContainerType& pc, int level, amrex::MFItInfo& info) - : amrex::ParConstIterSoA(pc, level, + : amrex::ParConstIterSoA(pc, level, info.SetDynamic(do_omp_dynamic())) {} ImpactXParticleContainer::ImpactXParticleContainer (initialization::AmrCoreData* amr_core) - : amrex::ParticleContainerPureSoA(amr_core->GetParGDB()) + : amrex::ParticleContainerPureSoA(amr_core->GetParGDB()) { + SetArena(amrex::The_Arena()); SetParticleSize(); SetSoACompileTimeNames( {RealSoA::names_s.begin(), RealSoA::names_s.end()}, diff --git a/src/particles/ReferenceParticle.H b/src/particles/ReferenceParticle.H index 1728dd27d..6b2cdc997 100644 --- a/src/particles/ReferenceParticle.H +++ b/src/particles/ReferenceParticle.H @@ -127,7 +127,7 @@ namespace impactx { using namespace amrex::literals; - constexpr amrex::ParticleReal inv_MeV_invc2 = 1.0_prt / ablastr::constant::SI::MeV_invc2; + constexpr amrex::ParticleReal inv_MeV_invc2 = 1.0_prt / ablastr::constant::SI::MeV_inv_c2; return amrex::ParticleReal(mass * inv_MeV_invc2); } @@ -145,7 +145,7 @@ namespace impactx AMREX_ASSERT_WITH_MESSAGE(massE != 0.0_prt, "set_mass_MeV: Mass cannot be zero!"); - mass = massE * ablastr::constant::SI::MeV_invc2; + mass = massE * ablastr::constant::SI::MeV_inv_c2; // re-scale pt and pz if (pt != 0.0_prt) diff --git a/src/particles/distribution/Thermal.H b/src/particles/distribution/Thermal.H index 17d655c10..5a4a59b01 100644 --- a/src/particles/distribution/Thermal.H +++ b/src/particles/distribution/Thermal.H @@ -95,11 +95,11 @@ namespace distribution m_bg = bg; // Get reference particle rest energy (eV) and charge (q_e) - amrex::ParticleReal Erest = refpart.mass_MeV()*1.0e6; + amrex::ParticleReal Erest = refpart.mass_MeV() * 1.0e6_prt; amrex::ParticleReal q_e = refpart.charge_qe(); // Set space charge intensity - m_Cintensity = q_e*bunch_charge/(powi<2>(bg)*Erest*ablastr::constant::SI::ep0); + m_Cintensity = q_e*bunch_charge/(powi<2>(bg)*Erest*ablastr::constant::SI::epsilon_0_v); // Set minimum and maximum radius amrex::ParticleReal r_scale = matched_scale_radius(); diff --git a/src/particles/spacecharge/PoissonSolve.cpp b/src/particles/spacecharge/PoissonSolve.cpp index 4d367e3d6..367162bf9 100644 --- a/src/particles/spacecharge/PoissonSolve.cpp +++ b/src/particles/spacecharge/PoissonSolve.cpp @@ -150,7 +150,7 @@ namespace impactx::particles::spacecharge // fix side effect on rho from previous call for (int lev=0; lev<=finest_level; lev++) { using namespace ablastr::constant::SI; - rho[lev].mult(-1._rt * ep0); + rho[lev].mult(-1._rt * epsilon_0); } // We may need to copy phi from phi_2d diff --git a/src/particles/wakefields/WakeConvolution.H b/src/particles/wakefields/WakeConvolution.H index 20ecae3bb..4d6138130 100644 --- a/src/particles/wakefields/WakeConvolution.H +++ b/src/particles/wakefields/WakeConvolution.H @@ -112,7 +112,7 @@ namespace impactx::particles::wakefields using namespace amrex::literals; using amrex::Math::powi; - amrex::Real const rc = powi<2>(ablastr::constant::SI::q_e) / (4_rt * amrex::Real(M_PI) * ablastr::constant::SI::ep0 * ablastr::constant::SI::m_e * powi<2>(ablastr::constant::SI::c)); + amrex::Real const rc = powi<2>(ablastr::constant::SI::q_e) / (4_rt * amrex::Real(M_PI) * ablastr::constant::SI::epsilon_0 * ablastr::constant::SI::m_e * powi<2>(ablastr::constant::SI::c)); amrex::Real const kappa = (2_rt * rc * ablastr::constant::SI::m_e * powi<2>(ablastr::constant::SI::c)) / std::pow(3_rt, 1_rt/3_rt) / std::pow(R, 2_rt/3_rt); return -3_rt/2_rt * kappa / bin_size * (unit_step(s + bin_size / 2_rt) * std::pow(std::abs(s + bin_size / 2_rt), 2_rt/3_rt) - unit_step(s - bin_size / 2_rt) * std::pow(std::abs(s - bin_size / 2_rt), 2_rt/3_rt)); diff --git a/src/python/ImpactXParticleContainer.cpp b/src/python/ImpactXParticleContainer.cpp index 93f097886..8ed3cdc17 100644 --- a/src/python/ImpactXParticleContainer.cpp +++ b/src/python/ImpactXParticleContainer.cpp @@ -31,7 +31,7 @@ void init_impactxparticlecontainer(py::module& m) py::class_< ParIterSoA, - amrex::ParIterSoA + amrex::ParIterSoA > py_pariter_soa(m, "ImpactXParIter"); py_pariter_soa .def(py::init(), @@ -42,7 +42,7 @@ void init_impactxparticlecontainer(py::module& m) py::class_< ParConstIterSoA, - amrex::ParConstIterSoA + amrex::ParConstIterSoA > py_parconstiter_soa(m, "ImpactXParConstIter"); py_parconstiter_soa .def(py::init(), @@ -53,7 +53,7 @@ void init_impactxparticlecontainer(py::module& m) py::class_< ImpactXParticleContainer, - amrex::ParticleContainerPureSoA + amrex::ParticleContainerPureSoA >(m, "ImpactXParticleContainer") //.def(py::init<>())