From 045f22b541752b9940aae91b5b6031870c13e7c3 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Tue, 17 Sep 2019 11:45:40 +0200 Subject: Enabled selection of Boris+RR, bugfixing --- Source/Particles/PhysicalParticleContainer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 4bc0ee16e..95f2243b3 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace amrex; @@ -1584,6 +1585,19 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, ux[i], uy[i], uz[i], dt ); } ); + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::BorisRR) { + amrex::ParallelFor( + pti.numParticles(), + [=] AMREX_GPU_DEVICE (long i) { + Real qp = q; + if (ion_lev){ qp *= ion_lev[i]; } + UpdateMomentumBorisWithRadiationReaction( ux[i], uy[i], uz[i], + Ex[i], Ey[i], Ez[i], Bx[i], + By[i], Bz[i], qp, m, dt); + UpdatePosition( x[i], y[i], z[i], + ux[i], uy[i], uz[i], dt ); + } + ); } else { amrex::Abort("Unknown particle pusher"); }; -- cgit v1.2.3 From 389d96a9225dfeb03d351e6726b7b52c72476626 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 24 Sep 2019 20:11:13 +0200 Subject: bugfix --- Examples/Tests/RadiationReaction/test_RR.3d | 1 + Source/Particles/PhysicalParticleContainer.cpp | 8 ++++++++ Source/Utils/WarpXAlgorithmSelection.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Examples/Tests/RadiationReaction/test_RR.3d b/Examples/Tests/RadiationReaction/test_RR.3d index 40cd651b4..9bf25198e 100644 --- a/Examples/Tests/RadiationReaction/test_RR.3d +++ b/Examples/Tests/RadiationReaction/test_RR.3d @@ -25,6 +25,7 @@ warpx.B_external = 0.0 0.0 1.0e5 warpx.verbose = 1 # Algorithms +algo.particle_pusher = "boris_rr" # CFL warpx.cfl = 1.0 diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 8d0c988b4..3d727af84 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1567,6 +1567,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, // Loop over the particles and update their momentum const Real q = this->charge; const Real m = this-> mass; + if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ amrex::ParallelFor( pti.numParticles(), @@ -1701,6 +1702,13 @@ PhysicalParticleContainer::PushP (int lev, Real dt, Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); } ); + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::BorisRR) { + amrex::ParallelFor( pti.numParticles(), + [=] AMREX_GPU_DEVICE (long i) { + UpdateMomentumBorisWithRadiationReaction( ux[i], uy[i], uz[i], + Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + } + ); } else { amrex::Abort("Unknown particle pusher"); }; diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp index 45f94f52f..8e65cb8d0 100644 --- a/Source/Utils/WarpXAlgorithmSelection.cpp +++ b/Source/Utils/WarpXAlgorithmSelection.cpp @@ -18,7 +18,7 @@ const std::map maxwell_solver_algo_to_int = { const std::map particle_pusher_algo_to_int = { {"boris", ParticlePusherAlgo::Boris }, {"vay", ParticlePusherAlgo::Vay }, - {"borisRR", ParticlePusherAlgo::BorisRR }, + {"boris_rr", ParticlePusherAlgo::BorisRR }, {"default", ParticlePusherAlgo::Boris } }; -- cgit v1.2.3 From 8f375c0c07f17b27115b61b95d21cf9bb8f554e7 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 30 Sep 2019 09:50:03 +0200 Subject: merged with dev --- Source/Particles/PhysicalParticleContainer.H | 6 +++++ Source/Particles/PhysicalParticleContainer.cpp | 31 +++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index ace1ec7f8..d789c7a79 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -145,6 +145,12 @@ protected: // Inject particles during the whole simulation void ContinuousInjection (const amrex::RealBox& injection_box) override; +private: + + //This function return true if the PhysicalParticleContainer contains electrons + //or positrons, false otherwise + bool AmIALepton(); + }; #endif diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 3d727af84..f3b1bdce7 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1568,7 +1568,13 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, const Real q = this->charge; const Real m = this-> mass; - if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ + + // Boris + RR is enabled only for leptons + auto algo = WarpX::particle_pusher_algo; + if (!AmIALepton() && algo == ParticlePusherAlgo::BorisRR) + algo = ParticlePusherAlgo::Boris; + + if (algo == ParticlePusherAlgo::Boris){ amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { @@ -1581,7 +1587,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, ux[i], uy[i], uz[i], dt ); } ); - } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Vay) { + } else if (algo == ParticlePusherAlgo::Vay) { amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { @@ -1594,7 +1600,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, ux[i], uy[i], uz[i], dt ); } ); - } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::BorisRR) { + } else if (algo == ParticlePusherAlgo::BorisRR) { amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { @@ -1688,21 +1694,27 @@ PhysicalParticleContainer::PushP (int lev, Real dt, // Loop over the particles and update their momentum const Real q = this->charge; const Real m = this-> mass; - if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ + + // Boris + RR is enabled only for leptons + auto algo = WarpX::particle_pusher_algo; + if (!AmIALepton() && algo == ParticlePusherAlgo::BorisRR) + algo = ParticlePusherAlgo::Boris; + + if (algo == ParticlePusherAlgo::Boris){ amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { UpdateMomentumBoris( ux[i], uy[i], uz[i], Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); } ); - } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Vay) { + } else if (algo == ParticlePusherAlgo::Vay) { amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { UpdateMomentumVay( ux[i], uy[i], uz[i], Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); } ); - } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::BorisRR) { + } else if (algo == ParticlePusherAlgo::BorisRR) { amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { UpdateMomentumBorisWithRadiationReaction( ux[i], uy[i], uz[i], @@ -2149,3 +2161,10 @@ PhysicalParticleContainer::buildIonizationMask (const amrex::MFIter& mfi, const } ); } + +//This function return true if the PhysicalParticleContainer contains electrons +//or positrons, false otherwise +bool +PhysicalParticleContainer::AmIALepton(){ + return (this-> mass == PhysConst::m_e); +} -- cgit v1.2.3 From 4c62803f740dc7f9eebe1861103096e73d0a1eaf Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 30 Sep 2019 13:46:39 +0200 Subject: Do radiation reaction is now a species property --- Examples/Tests/RadiationReaction/test_RR.3d | 61 -------------- Source/Particles/PhysicalParticleContainer.H | 6 +- Source/Particles/PhysicalParticleContainer.cpp | 92 ++++++++++++++-------- .../Particles/RigidInjectedParticleContainer.cpp | 30 ++++--- Source/Utils/WarpXAlgorithmSelection.H | 3 +- Source/Utils/WarpXAlgorithmSelection.cpp | 1 - 6 files changed, 85 insertions(+), 108 deletions(-) delete mode 100644 Examples/Tests/RadiationReaction/test_RR.3d (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Examples/Tests/RadiationReaction/test_RR.3d b/Examples/Tests/RadiationReaction/test_RR.3d deleted file mode 100644 index 9bf25198e..000000000 --- a/Examples/Tests/RadiationReaction/test_RR.3d +++ /dev/null @@ -1,61 +0,0 @@ -max_step = 200 -amr.n_cell = 64 64 64 -amr.blocking_factor = 16 -amr.max_grid_size = 64 -amr.max_level = 0 - -warpx.fine_tag_lo = -0.8 -0.8 -0.8 -warpx.fine_tag_hi = 0.8 0.8 0.8 - -amr.plot_int = 1 # How often to write plotfiles. "<= 0" means no plotfiles. - -warpx.plot_raw_fields = 0 -warpx.plot_finepatch = 0 -warpx.plot_crsepatch = 0 - -# Geometry -geometry.coord_sys = 0 # 0: Cartesian -geometry.is_periodic = 1 1 1 # Is periodic? -geometry.prob_lo = -5.0e-6 -5.0e-6 -5.0e-6 # physical domain -geometry.prob_hi = 5.0e-6 5.0e-6 5.0e-6 # physical domain - -warpx.B_external = 0.0 0.0 1.0e5 - -# Verbosity -warpx.verbose = 1 - -# Algorithms -algo.particle_pusher = "boris_rr" - -# CFL -warpx.cfl = 1.0 - -# particles -particles.nspecies = 2 -particles.species_names = electron positron - - -electron.charge = -q_e -electron.mass = m_e -electron.injection_style = "SingleParticle" -electron.single_particle_pos = 0.0 0.0 0.0 -electron.single_particle_vel = 100.0 0.0 0.0 # gamma*beta - -positron.charge = q_e -positron.mass = m_e -positron.injection_style = "SingleParticle" -positron.single_particle_pos = 0.0 0.0 0.0 -positron.single_particle_vel = 100.0 0.0 0.0 # gamma*beta - -electron.single_particle_weight = 1.6e-19 -positron.single_particle_weight = 1.6e-19 - -# interpolation -interpolation.nox = 3 -interpolation.noy = 3 -interpolation.noz = 3 - -# Moving window -warpx.do_moving_window = 0 - -warpx.do_dive_cleaning = 1 diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index ed95cffb9..9541a3652 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -186,12 +186,14 @@ protected: // Inject particles during the whole simulation void ContinuousInjection (const amrex::RealBox& injection_box) override; -private: - //This function return true if the PhysicalParticleContainer contains electrons //or positrons, false otherwise bool AmIALepton(); + //When true PhysicalParticleContainer tries to use a pusher including + //radiation reaction + bool do_classical_radiation_reaction = false; + }; #endif diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 89953120d..e5553bdf3 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -43,6 +43,22 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_boosted_frame_diags", do_boosted_frame_diags); pp.query("do_field_ionization", do_field_ionization); + + //check if Radiation Reaction is enabled and do consistency checks + pp.query("do_classical_radiation_reaction", do_classical_radiation_reaction); + //if the species is not a lepton, do_classical_radiation_reaction + //should be false + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + AmIALepton() || !do_classical_radiation_reaction, + "Can't enable classical radiation reaction for non lepton species. " ); + + //Only Boris pusher is compatible with radiation reaction + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris, + "Radiation reaction can be enabled only if Boris pusher is used"); + //_____________________________ + + #ifdef AMREX_USE_GPU AMREX_ALWAYS_ASSERT_WITH_MESSAGE( do_field_ionization == 0, @@ -1489,44 +1505,40 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, const Real m = this-> mass; - // Boris + RR is enabled only for leptons - auto algo = WarpX::particle_pusher_algo; - if (!AmIALepton() && algo == ParticlePusherAlgo::BorisRR) - algo = ParticlePusherAlgo::Boris; - - if (algo == ParticlePusherAlgo::Boris){ + //Assumes that all consistency checks have been done at initialization + if(do_classical_radiation_reaction){ amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { Real qp = q; if (ion_lev){ qp *= ion_lev[i]; } - UpdateMomentumBoris( ux[i], uy[i], uz[i], - Ex[i], Ey[i], Ez[i], Bx[i], - By[i], Bz[i], qp, m, dt); + UpdateMomentumBorisWithRadiationReaction( ux[i], uy[i], uz[i], + Ex[i], Ey[i], Ez[i], Bx[i], + By[i], Bz[i], qp, m, dt); UpdatePosition( x[i], y[i], z[i], - ux[i], uy[i], uz[i], dt ); + ux[i], uy[i], uz[i], dt ); } ); - } else if (algo == ParticlePusherAlgo::Vay) { + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { Real qp = q; if (ion_lev){ qp *= ion_lev[i]; } - UpdateMomentumVay( ux[i], uy[i], uz[i], - Ex[i], Ey[i], Ez[i], Bx[i], - By[i], Bz[i], qp, m, dt); + UpdateMomentumBoris( ux[i], uy[i], uz[i], + Ex[i], Ey[i], Ez[i], Bx[i], + By[i], Bz[i], qp, m, dt); UpdatePosition( x[i], y[i], z[i], - ux[i], uy[i], uz[i], dt ); + ux[i], uy[i], uz[i], dt ); } ); - } else if (algo == ParticlePusherAlgo::BorisRR) { + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Vay) { amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { Real qp = q; if (ion_lev){ qp *= ion_lev[i]; } - UpdateMomentumBorisWithRadiationReaction( ux[i], uy[i], uz[i], + UpdateMomentumVay( ux[i], uy[i], uz[i], Ex[i], Ey[i], Ez[i], Bx[i], By[i], Bz[i], qp, m, dt); UpdatePosition( x[i], y[i], z[i], @@ -1615,30 +1627,48 @@ PhysicalParticleContainer::PushP (int lev, Real dt, const Real q = this->charge; const Real m = this-> mass; - // Boris + RR is enabled only for leptons - auto algo = WarpX::particle_pusher_algo; - if (!AmIALepton() && algo == ParticlePusherAlgo::BorisRR) - algo = ParticlePusherAlgo::Boris; + int* AMREX_RESTRICT ion_lev = nullptr; + if (do_field_ionization){ + ion_lev = pti.GetiAttribs(particle_icomps["ionization_level"]).dataPtr(); + } - if (algo == ParticlePusherAlgo::Boris){ - amrex::ParallelFor( pti.numParticles(), + + //Assumes that all consistency checks have been done at initialization + if(do_classical_radiation_reaction){ + amrex::ParallelFor( + pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { - UpdateMomentumBoris( ux[i], uy[i], uz[i], - Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + Real qp = q; + if (ion_lev){ qp *= ion_lev[i]; } + UpdateMomentumBorisWithRadiationReaction( + ux[i], uy[i], uz[i], + Expp[i], Eypp[i], Ezpp[i], + Bxpp[i], Bypp[i], Bzpp[i], + qp, m, dt); } ); - } else if (algo == ParticlePusherAlgo::Vay) { + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { - UpdateMomentumVay( ux[i], uy[i], uz[i], - Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + Real qp = q; + if (ion_lev){ qp *= ion_lev[i]; } + UpdateMomentumBoris( + ux[i], uy[i], uz[i], + Expp[i], Eypp[i], Ezpp[i], + Bxpp[i], Bypp[i], Bzpp[i], + qp, m, dt); } ); - } else if (algo == ParticlePusherAlgo::BorisRR) { + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Vay) { amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { - UpdateMomentumBorisWithRadiationReaction( ux[i], uy[i], uz[i], - Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + Real qp = q; + if (ion_lev){ qp *= ion_lev[i]; } + UpdateMomentumVay( + ux[i], uy[i], uz[i], + Expp[i], Eypp[i], Ezpp[i], + Bxpp[i], Bypp[i], Bzpp[i], + qp, m, dt); } ); } else { diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index a3ae5f4e8..24d4ac24c 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -430,25 +430,33 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, // Loop over the particles and update their momentum const Real q = this->charge; const Real m = this->mass; - if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ - amrex::ParallelFor( pti.numParticles(), + + //Assumes that all consistency checks have been done at initialization + if(do_classical_radiation_reaction){ + amrex::ParallelFor( + pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { - UpdateMomentumBoris( uxpp[i], uypp[i], uzpp[i], - Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + UpdateMomentumBorisWithRadiationReaction( + uxpp[i], uypp[i], uzpp[i], + Expp[i], Eypp[i], Ezpp[i], + Bxpp[i], Bypp[i], Bzpp[i], + q, m, dt); } ); - } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Vay) { + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris){ amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { - UpdateMomentumVay( uxpp[i], uypp[i], uzpp[i], - Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + UpdateMomentumBoris( + uxpp[i], uypp[i], uzpp[i], + Expp[i], Eypp[i], Ezpp[i], + Bxpp[i], Bypp[i], Bzpp[i], + q, m, dt); } ); - } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::BorisRR) { - amrex::ParallelFor( - pti.numParticles(), + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::Vay) { + amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { - UpdateMomentumBorisWithRadiationReaction( + UpdateMomentumVay( uxpp[i], uypp[i], uzpp[i], Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], diff --git a/Source/Utils/WarpXAlgorithmSelection.H b/Source/Utils/WarpXAlgorithmSelection.H index 35a15c6fd..54c721abf 100644 --- a/Source/Utils/WarpXAlgorithmSelection.H +++ b/Source/Utils/WarpXAlgorithmSelection.H @@ -14,8 +14,7 @@ struct MaxwellSolverAlgo { struct ParticlePusherAlgo { enum { Boris = 0, - Vay = 1, - BorisRR = 2 + Vay = 1 }; }; diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp index 8e65cb8d0..8a6ff6dbf 100644 --- a/Source/Utils/WarpXAlgorithmSelection.cpp +++ b/Source/Utils/WarpXAlgorithmSelection.cpp @@ -18,7 +18,6 @@ const std::map maxwell_solver_algo_to_int = { const std::map particle_pusher_algo_to_int = { {"boris", ParticlePusherAlgo::Boris }, {"vay", ParticlePusherAlgo::Vay }, - {"boris_rr", ParticlePusherAlgo::BorisRR }, {"default", ParticlePusherAlgo::Boris } }; -- cgit v1.2.3 From 43bb052cc31a019e69d3cde5676f59a2c25806a2 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 10 Oct 2019 16:58:29 +0200 Subject: Fixed bug --- Source/Particles/PhysicalParticleContainer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 283be4e1c..07cef4277 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -48,14 +48,15 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_classical_radiation_reaction", do_classical_radiation_reaction); //if the species is not a lepton, do_classical_radiation_reaction //should be false - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - AmIALepton() || !do_classical_radiation_reaction, + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + !(do_classical_radiation_reaction && !AmIALepton()), "Can't enable classical radiation reaction for non lepton species. " ); //Only Boris pusher is compatible with radiation reaction AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - WarpX::particle_pusher_algo == ParticlePusherAlgo::Boris, - "Radiation reaction can be enabled only if Boris pusher is used"); + !(do_classical_radiation_reaction && + WarpX::particle_pusher_algo != ParticlePusherAlgo::Boris), + "Radiation reaction can be enabled only if Boris pusher is used"); //_____________________________ -- cgit v1.2.3 From 12768748673bb89375b97566f29949ab1c9a2d85 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 10 Oct 2019 17:00:27 +0200 Subject: Style change --- Source/Particles/PhysicalParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 07cef4277..db969e58f 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -54,7 +54,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp //Only Boris pusher is compatible with radiation reaction AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - !(do_classical_radiation_reaction && + !(do_classical_radiation_reaction && WarpX::particle_pusher_algo != ParticlePusherAlgo::Boris), "Radiation reaction can be enabled only if Boris pusher is used"); //_____________________________ -- cgit v1.2.3 From df30827050883f879ab09560ec1d82a04ac3e0f3 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 10 Oct 2019 17:02:15 +0200 Subject: Style change --- Source/Particles/PhysicalParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index db969e58f..22ece03f7 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -48,7 +48,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_classical_radiation_reaction", do_classical_radiation_reaction); //if the species is not a lepton, do_classical_radiation_reaction //should be false - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( !(do_classical_radiation_reaction && !AmIALepton()), "Can't enable classical radiation reaction for non lepton species. " ); -- cgit v1.2.3 From 3e3670639e3f57cdc9f1a43a6c69d7e8308f100d Mon Sep 17 00:00:00 2001 From: lucafedeli88 Date: Fri, 11 Oct 2019 19:14:03 -0500 Subject: Removed merge conflict from file --- Source/Particles/PhysicalParticleContainer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 7f6b2daa9..c3ea3b763 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -2205,14 +2205,13 @@ PhysicalParticleContainer::buildIonizationMask (const amrex::MFIter& mfi, const ); } -<<<<<<< HEAD //This function return true if the PhysicalParticleContainer contains electrons //or positrons, false otherwise bool PhysicalParticleContainer::AmIALepton(){ return (this-> mass == PhysConst::m_e); } -======= + #ifdef WARPX_QED bool PhysicalParticleContainer::has_quantum_sync() @@ -2239,4 +2238,3 @@ set_quantum_sync_engine_ptr(std::shared_ptr ptr) shr_ptr_qs_engine = ptr; } #endif ->>>>>>> upstream/dev -- cgit v1.2.3 From 8e2ecfe27b9d464dcd40031ae5ebc4e3781963e2 Mon Sep 17 00:00:00 2001 From: Yin-YinjianZhao Date: Mon, 14 Oct 2019 10:28:20 -0700 Subject: Add Higuera-Cary pusher --- Source/Particles/PhysicalParticleContainer.cpp | 21 ++++++++ Source/Particles/Pusher/Make.package | 1 + .../Particles/Pusher/UpdateMomentumHigueraCary.H | 56 ++++++++++++++++++++++ .../Particles/RigidInjectedParticleContainer.cpp | 8 ++++ Source/Utils/WarpXAlgorithmSelection.H | 3 +- Source/Utils/WarpXAlgorithmSelection.cpp | 1 + 6 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Source/Particles/Pusher/UpdateMomentumHigueraCary.H (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d10803320..82aacbda8 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -17,6 +17,7 @@ #include #include #include +#include using namespace amrex; @@ -1604,6 +1605,19 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, ux[i], uy[i], uz[i], dt ); } ); + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::HigueraCary) { + amrex::ParallelFor( + pti.numParticles(), + [=] AMREX_GPU_DEVICE (long i) { + Real qp = q; + if (ion_lev){ qp *= ion_lev[i]; } + UpdateMomentumHigueraCary( ux[i], uy[i], uz[i], + Ex[i], Ey[i], Ez[i], Bx[i], + By[i], Bz[i], qp, m, dt); + UpdatePosition( x[i], y[i], z[i], + ux[i], uy[i], uz[i], dt ); + } + ); } else { amrex::Abort("Unknown particle pusher"); }; @@ -1699,6 +1713,13 @@ PhysicalParticleContainer::PushP (int lev, Real dt, Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); } ); + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::HigueraCary) { + amrex::ParallelFor( pti.numParticles(), + [=] AMREX_GPU_DEVICE (long i) { + UpdateMomentumHigueraCary( ux[i], uy[i], uz[i], + Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + } + ); } else { amrex::Abort("Unknown particle pusher"); }; diff --git a/Source/Particles/Pusher/Make.package b/Source/Particles/Pusher/Make.package index 45886702e..b033bfb57 100644 --- a/Source/Particles/Pusher/Make.package +++ b/Source/Particles/Pusher/Make.package @@ -2,6 +2,7 @@ CEXE_headers += GetAndSetPosition.H CEXE_headers += UpdatePosition.H CEXE_headers += UpdateMomentumBoris.H CEXE_headers += UpdateMomentumVay.H +CEXE_headers += UpdateMomentumHigueraCary.H CEXE_headers += UpdatePositionPhoton.H INCLUDE_LOCATIONS += $(WARPX_HOME)/Source/Particles/Pusher VPATH_LOCATIONS += $(WARPX_HOME)/Source/Particles/Pusher diff --git a/Source/Particles/Pusher/UpdateMomentumHigueraCary.H b/Source/Particles/Pusher/UpdateMomentumHigueraCary.H new file mode 100644 index 000000000..11bd1d233 --- /dev/null +++ b/Source/Particles/Pusher/UpdateMomentumHigueraCary.H @@ -0,0 +1,56 @@ +#ifndef WARPX_PARTICLES_PUSHER_UPDATEMOMENTUM_HIGUERACARY_H_ +#define WARPX_PARTICLES_PUSHER_UPDATEMOMENTUM_HIGUERACARY_H_ + +#include +#include +#include + +/* \brief Push the particle's positions over one timestep, + * given the value of its momenta `ux`, `uy`, `uz` */ +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void UpdateMomentumHigueraCary( + amrex::ParticleReal& ux, amrex::ParticleReal& uy, amrex::ParticleReal& uz, + const amrex::ParticleReal Ex, const amrex::ParticleReal Ey, const amrex::ParticleReal Ez, + const amrex::ParticleReal Bx, const amrex::ParticleReal By, const amrex::ParticleReal Bz, + const amrex::Real q, const amrex::Real m, const amrex::Real dt ) +{ + // Constants + const amrex::Real qmt = 0.5*q*dt/m; + constexpr amrex::Real invclight = 1./PhysConst::c; + constexpr amrex::Real invclightsq = 1./(PhysConst::c*PhysConst::c); + // Compute u_minus + const amrex::Real umx = ux + qmt*Ex; + const amrex::Real umy = uy + qmt*Ey; + const amrex::Real umz = uz + qmt*Ez; + // Compute gamma squared of u_minus + const amrex::Real gamma = 1. + (umx*umx + umy*umy + umz*umz)*invclightsq; + // Compute beta and betam squared + const amrex::Real betax = qmt*Bx; + const amrex::Real betay = qmt*By; + const amrex::Real betaz = qmt*Bz; + const amrex::Real betam = betax*betax + betay*betay + betaz*betaz; + // Compute sigma + const amrex::Real sigma = gamma - betam; + // Get u* + const amrex::Real ust = (umx*betax + umy*betay + umz*betaz)*invclight; + // Get new gamma inversed + gamma = 1./std::sqrt(0.5*(sigma + std::sqrt(sigma*sigma + 4.*(betam + ust*ust)) )); + // Compute t + const amrex::Real tx = gamma*betax; + const amrex::Real ty = gamma*betay; + const amrex::Real tz = gamma*betaz; + // Compute s + const amrex::Real s = 1./(1.+(tx*tx + ty*ty + tz*tz)); + // Compute um dot t + const amrex::Real umt = umx*tx + umy*ty + umz*tz; + // Compute u_plus + const amrex::Real upx = s*( umx + umt*tx + umy*tz - umz*ty ); + const amrex::Real upy = s*( umy + umt*ty + umz*tx - umx*tz ); + const amrex::Real upz = s*( umz + umt*tz + umx*ty - umy*tx ); + // Get new u + ux = upx + qmt*Ex + upy*tz - upz*ty; + uy = upy + qmt*Ey + upz*tx - upx*tz; + uz = upz + qmt*Ez + upx*ty - upy*tx; +} + +#endif // WARPX_PARTICLES_PUSHER_UPDATEMOMENTUM_HIGUERACARY_H_ diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index 891ade76d..aeaac7194 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -13,6 +13,7 @@ #include #include #include +#include using namespace amrex; @@ -443,6 +444,13 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); } ); + } else if (WarpX::particle_pusher_algo == ParticlePusherAlgo::HigueraCary) { + amrex::ParallelFor( pti.numParticles(), + [=] AMREX_GPU_DEVICE (long i) { + UpdateMomentumHigueraCary( uxpp[i], uypp[i], uzpp[i], + Expp[i], Eypp[i], Ezpp[i], Bxpp[i], Bypp[i], Bzpp[i], q, m, dt); + } + ); } else { amrex::Abort("Unknown particle pusher"); }; diff --git a/Source/Utils/WarpXAlgorithmSelection.H b/Source/Utils/WarpXAlgorithmSelection.H index 54c721abf..c29cb7224 100644 --- a/Source/Utils/WarpXAlgorithmSelection.H +++ b/Source/Utils/WarpXAlgorithmSelection.H @@ -14,7 +14,8 @@ struct MaxwellSolverAlgo { struct ParticlePusherAlgo { enum { Boris = 0, - Vay = 1 + Vay = 1, + HigueraCary = 0 }; }; diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp index 8a6ff6dbf..4ad07f4f1 100644 --- a/Source/Utils/WarpXAlgorithmSelection.cpp +++ b/Source/Utils/WarpXAlgorithmSelection.cpp @@ -18,6 +18,7 @@ const std::map maxwell_solver_algo_to_int = { const std::map particle_pusher_algo_to_int = { {"boris", ParticlePusherAlgo::Boris }, {"vay", ParticlePusherAlgo::Vay }, + {"hc", ParticlePusherAlgo::HigueraCary }, {"default", ParticlePusherAlgo::Boris } }; -- cgit v1.2.3 From a8e92c5b1098957368561609c0d9e08dd6ee8b94 Mon Sep 17 00:00:00 2001 From: Yin-YinjianZhao Date: Tue, 15 Oct 2019 16:55:09 -0700 Subject: Add E_external --- Source/Particles/PhysicalParticleContainer.cpp | 12 ++++++------ Source/Particles/RigidInjectedParticleContainer.cpp | 6 +++--- Source/WarpX.H | 1 + Source/WarpX.cpp | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 82aacbda8..7c8c4024e 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1130,9 +1130,9 @@ PhysicalParticleContainer::Evolve (int lev, exfab, eyfab, ezfab, bxfab, byfab, bzfab); } - Exp.assign(np,0.0); - Eyp.assign(np,0.0); - Ezp.assign(np,0.0); + Exp.assign(np,WarpX::E_external[0]); + Eyp.assign(np,WarpX::E_external[1]); + Ezp.assign(np,WarpX::E_external[2]); Bxp.assign(np,WarpX::B_external[0]); Byp.assign(np,WarpX::B_external[1]); Bzp.assign(np,WarpX::B_external[2]); @@ -1666,9 +1666,9 @@ PhysicalParticleContainer::PushP (int lev, Real dt, const FArrayBox& byfab = By[pti]; const FArrayBox& bzfab = Bz[pti]; - Exp.assign(np,0.0); - Eyp.assign(np,0.0); - Ezp.assign(np,0.0); + Exp.assign(np,WarpX::E_external[0]); + Eyp.assign(np,WarpX::E_external[1]); + Ezp.assign(np,WarpX::E_external[2]); Bxp.assign(np,WarpX::B_external[0]); Byp.assign(np,WarpX::B_external[1]); Bzp.assign(np,WarpX::B_external[2]); diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index aeaac7194..2ef833151 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -391,9 +391,9 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, const FArrayBox& byfab = By[pti]; const FArrayBox& bzfab = Bz[pti]; - Exp.assign(np,0.0); - Eyp.assign(np,0.0); - Ezp.assign(np,0.0); + Exp.assign(np,WarpX::E_external[0]); + Eyp.assign(np,WarpX::E_external[1]); + Ezp.assign(np,WarpX::E_external[2]); Bxp.assign(np,WarpX::B_external[0]); Byp.assign(np,WarpX::B_external[1]); Bzp.assign(np,WarpX::B_external[2]); diff --git a/Source/WarpX.H b/Source/WarpX.H index 0da1cf350..15676f0e3 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -75,6 +75,7 @@ public: // External fields static amrex::Vector B_external; + static amrex::Vector E_external; // Algorithms static long current_deposition_algo; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 5a51d7d13..14d0e7a2e 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -25,6 +25,7 @@ using namespace amrex; Vector WarpX::B_external(3, 0.0); +Vector WarpX::E_external(3, 0.0); int WarpX::do_moving_window = 0; int WarpX::moving_window_dir = -1; @@ -291,6 +292,7 @@ WarpX::ReadParameters () zmax_plasma_to_compute_max_step); pp.queryarr("B_external", B_external); + pp.queryarr("E_external", E_external); pp.query("do_moving_window", do_moving_window); if (do_moving_window) -- cgit v1.2.3 From e133d2202685d6e478b42f9b554b00d5fa722801 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 25 Oct 2019 11:56:10 -0700 Subject: replace 'boosted frame diags' with 'back-transformed diags' --- Docs/source/running_cpp/parameters.rst | 18 ++--- .../Modules/RigidInjection/inputs.BoostedFrame | 2 +- Examples/Modules/boosted_diags/inputs.2d | 2 +- Examples/Modules/boosted_diags/inputs.3d | 2 +- Examples/Modules/boosted_diags/inputs.3d.slice | 6 +- .../laser_acceleration/inputs.2d.boost | 2 +- .../plasma_acceleration/inputs.2d.boost | 2 +- .../plasma_acceleration/inputs.3d.boost | 2 +- Python/pywarpx/picmi.py | 8 +-- Source/Diagnostics/BoostedFrameDiagnostic.H | 12 ++-- Source/Diagnostics/BoostedFrameDiagnostic.cpp | 76 +++++++++++----------- Source/Diagnostics/Make.package | 4 +- Source/Evolve/WarpXEvolveEM.cpp | 6 +- Source/Initialization/WarpXInitData.cpp | 4 +- Source/Laser/LaserParticleContainer.cpp | 2 +- Source/Particles/MultiParticleContainer.H | 18 ++--- Source/Particles/MultiParticleContainer.cpp | 24 +++---- Source/Particles/PhotonParticleContainer.cpp | 2 +- Source/Particles/PhysicalParticleContainer.cpp | 10 +-- Source/Particles/WarpXParticleContainer.H | 4 +- Source/WarpX.H | 10 +-- Source/WarpX.cpp | 16 ++--- .../automated_test_4_labdiags_2ppc | 2 +- 23 files changed, 117 insertions(+), 117 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Docs/source/running_cpp/parameters.rst b/Docs/source/running_cpp/parameters.rst index 59bfbb14e..a2de46b03 100644 --- a/Docs/source/running_cpp/parameters.rst +++ b/Docs/source/running_cpp/parameters.rst @@ -349,8 +349,8 @@ Particle initialization ``.plot_vars = none`` to plot no particle data, except particle position. -* ``.do_boosted_frame_diags`` (`0` or `1` optional, default `1`) - Only used when ``warpx.do_boosted_frame_diagnostic=1``. When running in a +* ``.do_back_transformed_diagnostics`` (`0` or `1` optional, default `1`) + Only used when ``warpx.do_back_transformed_diagnostics=1``. When running in a boosted frame, whether or not to plot back-transformed diagnostics for this species. @@ -765,7 +765,7 @@ Diagnostics and output When WarpX is compiled with openPMD support, this is ``h5`` by default. ``json`` only works with serial/single-rank jobs. -* ``warpx.do_boosted_frame_diagnostic`` (`0` or `1`) +* ``warpx.do_back_transformed_diagnostics`` (`0` or `1`) Whether to use the **back-transformed diagnostics** (i.e. diagnostics that perform on-the-fly conversion to the laboratory frame, when running boosted-frame simulations) @@ -776,22 +776,22 @@ Diagnostics and output is `lab_frame_data`. * ``warpx.num_snapshots_lab`` (`integer`) - Only used when ``warpx.do_boosted_frame_diagnostic`` is ``1``. + Only used when ``warpx.do_back_transformed_diagnostics`` is ``1``. The number of lab-frame snapshots that will be written. * ``warpx.dt_snapshots_lab`` (`float`, in seconds) - Only used when ``warpx.do_boosted_frame_diagnostic`` is ``1``. + Only used when ``warpx.do_back_transformed_diagnostics`` is ``1``. The time interval inbetween the lab-frame snapshots (where this time interval is expressed in the laboratory frame). * ``warpx.dz_snapshots_lab`` (`float`, in meters) - Only used when ``warpx.do_boosted_frame_diagnostic`` is ``1``. + Only used when ``warpx.do_back_transformed_diagnostics`` is ``1``. Distance between the lab-frame snapshots (expressed in the laboratory frame). ``dt_snapshots_lab`` is then computed by ``dt_snapshots_lab = dz_snapshots_lab/c``. Either `dt_snapshots_lab` or `dz_snapshot_lab` is required. -* ``warpx.do_boosted_frame_fields`` (`0 or 1`) +* ``warpx.do_back_transformed_fields`` (`0 or 1`) Whether to use the **back-transformed diagnostics** for the fields. * ``warpx.boosted_frame_diag_fields`` (space-separated list of `string`) @@ -850,7 +850,7 @@ Diagnostics and output negative number to disable slice generation and slice data dumping. * ``slice.num_slice_snapshots_lab`` (`integer`) - Only used when ``warpx.do_boosted_frame_diagnostic`` is ``1``. + Only used when ``warpx.do_back_transformed_diagnostics`` is ``1``. The number of back-transformed field and particle data that will be written for the reduced domain defined by ``slice.dom_lo`` and ``slice.dom_hi``. Note that the 'slice' is a reduced @@ -860,7 +860,7 @@ Diagnostics and output for further details. * ``slice.dt_slice_snapshots_lab`` (`float`, in seconds) - Only used when ``warpx.do_boosted_frame_diagnostic`` is ``1``. + Only used when ``warpx.do_back_transformed_diagnostics`` is ``1``. The time interval between the back-transformed reduced diagnostics (where this time interval is expressed in the laboratory frame). diff --git a/Examples/Modules/RigidInjection/inputs.BoostedFrame b/Examples/Modules/RigidInjection/inputs.BoostedFrame index c7a60f14f..456df363d 100644 --- a/Examples/Modules/RigidInjection/inputs.BoostedFrame +++ b/Examples/Modules/RigidInjection/inputs.BoostedFrame @@ -3,7 +3,7 @@ warpx.zmax_plasma_to_compute_max_step = 50.e-6 warpx.gamma_boost = 5. warpx.boost_direction = z -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 2 warpx.dt_snapshots_lab = 1.8679589331096515e-13 diff --git a/Examples/Modules/boosted_diags/inputs.2d b/Examples/Modules/boosted_diags/inputs.2d index 6afe6977d..7b2270f90 100644 --- a/Examples/Modules/boosted_diags/inputs.2d +++ b/Examples/Modules/boosted_diags/inputs.2d @@ -44,7 +44,7 @@ warpx.gamma_boost = 15. warpx.boost_direction = z # Diagnostics -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 20 warpx.dt_snapshots_lab = 7.0e-14 diff --git a/Examples/Modules/boosted_diags/inputs.3d b/Examples/Modules/boosted_diags/inputs.3d index 528eb6cd9..b700a52fb 100644 --- a/Examples/Modules/boosted_diags/inputs.3d +++ b/Examples/Modules/boosted_diags/inputs.3d @@ -44,7 +44,7 @@ warpx.gamma_boost = 15. warpx.boost_direction = z # Diagnostics -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 20; warpx.dt_snapshots_lab = 7.0e-14; diff --git a/Examples/Modules/boosted_diags/inputs.3d.slice b/Examples/Modules/boosted_diags/inputs.3d.slice index ca745f347..08f2310cd 100644 --- a/Examples/Modules/boosted_diags/inputs.3d.slice +++ b/Examples/Modules/boosted_diags/inputs.3d.slice @@ -30,7 +30,7 @@ warpx.serialize_ics = 1 warpx.gamma_boost = 10. warpx.boost_direction = z -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 4 warpx.dz_snapshots_lab = 0.001 warpx.boosted_frame_diag_fields= Ex Ey Ez By rho @@ -53,7 +53,7 @@ electrons.zmax = .003 electrons.profile = constant electrons.density = 3.5e24 electrons.do_continuous_injection = 1 -electrons.do_boosted_frame_diags = 1 +electrons.do_back_transformed_diagnostics = 1 ions.charge = q_e ions.mass = m_p @@ -69,7 +69,7 @@ ions.zmax = .003 ions.profile = constant ions.density = 3.5e24 ions.do_continuous_injection = 1 -ions.do_boosted_frame_diags = 1 +ions.do_back_transformed_diagnostics = 1 beam.charge = -q_e beam.mass = m_e diff --git a/Examples/Physics_applications/laser_acceleration/inputs.2d.boost b/Examples/Physics_applications/laser_acceleration/inputs.2d.boost index 89bded6c0..a50b5164a 100644 --- a/Examples/Physics_applications/laser_acceleration/inputs.2d.boost +++ b/Examples/Physics_applications/laser_acceleration/inputs.2d.boost @@ -41,7 +41,7 @@ warpx.serialize_ics = 1 ################################# warpx.gamma_boost = 10. warpx.boost_direction = z -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 7 warpx.dt_snapshots_lab = 1.6678204759907604e-12 diff --git a/Examples/Physics_applications/plasma_acceleration/inputs.2d.boost b/Examples/Physics_applications/plasma_acceleration/inputs.2d.boost index d711815eb..af4556e25 100644 --- a/Examples/Physics_applications/plasma_acceleration/inputs.2d.boost +++ b/Examples/Physics_applications/plasma_acceleration/inputs.2d.boost @@ -39,7 +39,7 @@ interpolation.noz = 3 ################################# warpx.gamma_boost = 10.0 warpx.boost_direction = z -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 22 warpx.dt_snapshots_lab = 3.335640951981521e-11 diff --git a/Examples/Physics_applications/plasma_acceleration/inputs.3d.boost b/Examples/Physics_applications/plasma_acceleration/inputs.3d.boost index 42446a9ac..79480c97f 100644 --- a/Examples/Physics_applications/plasma_acceleration/inputs.3d.boost +++ b/Examples/Physics_applications/plasma_acceleration/inputs.3d.boost @@ -38,7 +38,7 @@ interpolation.noz = 3 ################################# warpx.gamma_boost = 10.0 warpx.boost_direction = z -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 22 warpx.dt_snapshots_lab = 3.335640951981521e-11 diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index c33700278..c4e6803d5 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -671,10 +671,10 @@ class LabFrameFieldDiagnostic(picmistandard.PICMI_LabFrameFieldDiagnostic): pywarpx.warpx.check_consistency('dt_snapshots_lab', self.dt_snapshots, 'The time between snapshots must be the same in all lab frame diagnostics') pywarpx.warpx.check_consistency('lab_data_directory', self.write_dir, 'The write directory must be the same in all lab frame diagnostics') - pywarpx.warpx.do_boosted_frame_diagnostic = 1 + pywarpx.warpx.do_back_transformed_diagnostics = 1 pywarpx.warpx.num_snapshots_lab = self.num_snapshots pywarpx.warpx.dt_snapshots_lab = self.dt_snapshots - pywarpx.warpx.do_boosted_frame_fields = 1 + pywarpx.warpx.do_back_transformed_fields = 1 pywarpx.warpx.lab_data_directory = self.write_dir @@ -685,8 +685,8 @@ class LabFrameParticleDiagnostic(picmistandard.PICMI_LabFrameParticleDiagnostic) pywarpx.warpx.check_consistency('dt_snapshots_lab', self.dt_snapshots, 'The time between snapshots must be the same in all lab frame diagnostics') pywarpx.warpx.check_consistency('lab_data_directory', self.write_dir, 'The write directory must be the same in all lab frame diagnostics') - pywarpx.warpx.do_boosted_frame_diagnostic = 1 + pywarpx.warpx.do_back_transformed_diagnostics = 1 pywarpx.warpx.num_snapshots_lab = self.num_snapshots pywarpx.warpx.dt_snapshots_lab = self.dt_snapshots - pywarpx.warpx.do_boosted_frame_particles = 1 + pywarpx.warpx.do_back_transformed_particles = 1 pywarpx.warpx.lab_data_directory = self.write_dir diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.H b/Source/Diagnostics/BoostedFrameDiagnostic.H index 5d95aaf7d..9e24caa1b 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.H +++ b/Source/Diagnostics/BoostedFrameDiagnostic.H @@ -1,5 +1,5 @@ -#ifndef WARPX_BoostedFrameDiagnostic_H_ -#define WARPX_BoostedFrameDiagnostic_H_ +#ifndef WARPX_BackTransformedDiagnostic_H_ +#define WARPX_BackTransformedDiagnostic_H_ #include #include @@ -150,7 +150,7 @@ class LabFrameSlice : public LabFrameDiag { }; /** \brief - * BoostedFrameDiagnostic class handles the back-transformation of data when + * BackTransformedDiagnostic class handles the back-transformation of data when * running simulations in a boosted frame of reference to the lab-frame. * Because of the relativity of simultaneity, events that are synchronized * in the simulation boosted frame are not @@ -163,13 +163,13 @@ class LabFrameSlice : public LabFrameDiag { * to the output directory. The functions Flush() and writeLabFrameData() * are called at the end of the simulation and when the * the buffer for data storage is full, respectively. The particle data - * is collected and written only if particle.do_boosted_frame_diagnostic = 1. + * is collected and written only if particle.do_back_transformed_diagnostics = 1. */ -class BoostedFrameDiagnostic { +class BackTransformedDiagnostic { public: - BoostedFrameDiagnostic(amrex::Real zmin_lab, amrex::Real zmax_lab, + BackTransformedDiagnostic(amrex::Real zmin_lab, amrex::Real zmax_lab, amrex::Real v_window_lab, amrex::Real dt_snapshots_lab, int N_snapshots, amrex::Real dt_slice_snapshots_lab, int N_slice_snapshots, amrex::Real gamma_boost, diff --git a/Source/Diagnostics/BoostedFrameDiagnostic.cpp b/Source/Diagnostics/BoostedFrameDiagnostic.cpp index 297b4f5be..2880b37b1 100644 --- a/Source/Diagnostics/BoostedFrameDiagnostic.cpp +++ b/Source/Diagnostics/BoostedFrameDiagnostic.cpp @@ -1,7 +1,7 @@ #include #include -#include "BoostedFrameDiagnostic.H" +#include "BackTransformedDiagnostic.H" #include "SliceDiagnostic.H" #include "WarpX_f.H" #include "WarpX.H" @@ -514,8 +514,8 @@ LorentzTransformZ(MultiFab& data, Real gamma_boost, Real beta_boost, int ncomp) } } -BoostedFrameDiagnostic:: -BoostedFrameDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, +BackTransformedDiagnostic:: +BackTransformedDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, Real dt_snapshots_lab, int N_snapshots, Real dt_slice_snapshots_lab, int N_slice_snapshots, Real gamma_boost, Real t_boost, Real dt_boost, @@ -531,10 +531,10 @@ BoostedFrameDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, { - BL_PROFILE("BoostedFrameDiagnostic::BoostedFrameDiagnostic"); + BL_PROFILE("BackTransformedDiagnostic::BackTransformedDiagnostic"); - AMREX_ALWAYS_ASSERT(WarpX::do_boosted_frame_fields or - WarpX::do_boosted_frame_particles); + AMREX_ALWAYS_ASSERT(WarpX::do_back_transformed_fields or + WarpX::do_back_transformed_particles); inv_gamma_boost_ = 1.0 / gamma_boost_; beta_boost_ = std::sqrt(1.0 - inv_gamma_boost_*inv_gamma_boost_); @@ -679,9 +679,9 @@ BoostedFrameDiagnostic(Real zmin_lab, Real zmax_lab, Real v_window_lab, AMREX_ALWAYS_ASSERT(max_box_size_ >= num_buffer_); } -void BoostedFrameDiagnostic::Flush(const Geometry& geom) +void BackTransformedDiagnostic::Flush(const Geometry& geom) { - BL_PROFILE("BoostedFrameDiagnostic::Flush"); + BL_PROFILE("BackTransformedDiagnostic::Flush"); VisMF::Header::Version current_version = VisMF::GetHeaderVersion(); VisMF::SetHeaderVersion(amrex::VisMF::Header::NoFabHeader_v1); @@ -696,7 +696,7 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) int i_lab = (LabFrameDiags_[i]->current_z_lab - zmin_lab) / dz_lab_; if (LabFrameDiags_[i]->buff_counter_ != 0) { - if (WarpX::do_boosted_frame_fields) { + if (WarpX::do_back_transformed_fields) { const BoxArray& ba = LabFrameDiags_[i]->data_buffer_->boxArray(); const int hi = ba[0].bigEnd(boost_direction_); const int lo = hi - LabFrameDiags_[i]->buff_counter_ + 1; @@ -731,12 +731,12 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) #endif } - if (WarpX::do_boosted_frame_particles) { + if (WarpX::do_back_transformed_particles) { // Loop over species to be dumped to BFD - for (int j = 0; j < mypc.nSpeciesBoostedFrameDiags(); ++j) { + for (int j = 0; j < mypc.nSpeciesBackTransformedDiagnostics(); ++j) { // Get species name std::string species_name = - species_names[mypc.mapSpeciesBoostedFrameDiags(j)]; + species_names[mypc.mapSpeciesBackTransformedDiagnostics(j)]; #ifdef WARPX_USE_HDF5 // Dump species data writeParticleDataHDF5(LabFrameDiags_[i]->particles_buffer_[j], @@ -765,12 +765,12 @@ void BoostedFrameDiagnostic::Flush(const Geometry& geom) void -BoostedFrameDiagnostic:: +BackTransformedDiagnostic:: writeLabFrameData(const MultiFab* cell_centered_data, const MultiParticleContainer& mypc, const Geometry& geom, const Real t_boost, const Real dt) { - BL_PROFILE("BoostedFrameDiagnostic::writeLabFrameData"); + BL_PROFILE("BackTransformedDiagnostic::writeLabFrameData"); VisMF::Header::Version current_version = VisMF::GetHeaderVersion(); VisMF::SetHeaderVersion(amrex::VisMF::Header::NoFabHeader_v1); @@ -808,7 +808,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, // If buffer of snapshot i is empty... if ( LabFrameDiags_[i]->buff_counter_ == 0) { // ... reset fields buffer data_buffer_ - if (WarpX::do_boosted_frame_fields) { + if (WarpX::do_back_transformed_fields) { LabFrameDiags_[i]->buff_box_.setSmall(boost_direction_, i_lab - num_buffer_ + 1); LabFrameDiags_[i]->buff_box_.setBig(boost_direction_, i_lab); @@ -820,12 +820,12 @@ writeLabFrameData(const MultiFab* cell_centered_data, buff_dm, ncomp_to_dump, 0) ); } // ... reset particle buffer particles_buffer_[i] - if (WarpX::do_boosted_frame_particles) + if (WarpX::do_back_transformed_particles) LabFrameDiags_[i]->particles_buffer_.resize( - mypc.nSpeciesBoostedFrameDiags()); + mypc.nSpeciesBackTransformedDiagnostics()); } - if (WarpX::do_boosted_frame_fields) { + if (WarpX::do_back_transformed_fields) { const int ncomp = cell_centered_data->nComp(); const int start_comp = 0; const bool interpolate = true; @@ -873,7 +873,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, tmp_slice_ptr.reset(nullptr); } - if (WarpX::do_boosted_frame_particles) { + if (WarpX::do_back_transformed_particles) { if (LabFrameDiags_[i]->t_lab != prev_t_lab ) { if (tmp_particle_buffer.size()>0) @@ -881,7 +881,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, tmp_particle_buffer.clear(); tmp_particle_buffer.shrink_to_fit(); } - tmp_particle_buffer.resize(mypc.nSpeciesBoostedFrameDiags()); + tmp_particle_buffer.resize(mypc.nSpeciesBackTransformedDiagnostics()); mypc.GetLabFrameData( LabFrameDiags_[i]->file_name, i_lab, boost_direction_, old_z_boost, LabFrameDiags_[i]->current_z_boost, @@ -889,7 +889,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, tmp_particle_buffer); } LabFrameDiags_[i]->AddPartDataToParticleBuffer(tmp_particle_buffer, - mypc.nSpeciesBoostedFrameDiags()); + mypc.nSpeciesBackTransformedDiagnostics()); } ++LabFrameDiags_[i]->buff_counter_; @@ -898,7 +898,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, // If buffer full, write to disk. if ( LabFrameDiags_[i]->buff_counter_ == num_buffer_) { - if (WarpX::do_boosted_frame_fields) { + if (WarpX::do_back_transformed_fields) { #ifdef WARPX_USE_HDF5 Box buff_box = LabFrameDiags_[i]->buff_box_; @@ -916,12 +916,12 @@ writeLabFrameData(const MultiFab* cell_centered_data, #endif } - if (WarpX::do_boosted_frame_particles) { + if (WarpX::do_back_transformed_particles) { // Loop over species to be dumped to BFD - for (int j = 0; j < mypc.nSpeciesBoostedFrameDiags(); ++j) { + for (int j = 0; j < mypc.nSpeciesBackTransformedDiagnostics(); ++j) { // Get species name const std::string species_name = species_names[ - mypc.mapSpeciesBoostedFrameDiags(j)]; + mypc.mapSpeciesBackTransformedDiagnostics(j)]; #ifdef WARPX_USE_HDF5 // Write data to disk (HDF5) writeParticleDataHDF5(LabFrameDiags_[i]->particles_buffer_[j], @@ -949,7 +949,7 @@ writeLabFrameData(const MultiFab* cell_centered_data, #ifdef WARPX_USE_HDF5 void -BoostedFrameDiagnostic:: +BackTransformedDiagnostic:: writeParticleDataHDF5(const WarpXParticleContainer::DiagnosticParticleData& pdata, const std::string& name, const std::string& species_name) { @@ -997,11 +997,11 @@ writeParticleDataHDF5(const WarpXParticleContainer::DiagnosticParticleData& pdat #endif void -BoostedFrameDiagnostic:: +BackTransformedDiagnostic:: writeParticleData(const WarpXParticleContainer::DiagnosticParticleData& pdata, const std::string& name, const int i_lab) { - BL_PROFILE("BoostedFrameDiagnostic::writeParticleData"); + BL_PROFILE("BackTransformedDiagnostic::writeParticleData"); std::string field_name; std::ofstream ofs; @@ -1047,10 +1047,10 @@ writeParticleData(const WarpXParticleContainer::DiagnosticParticleData& pdata, } void -BoostedFrameDiagnostic:: +BackTransformedDiagnostic:: writeMetaData () { - BL_PROFILE("BoostedFrameDiagnostic::writeMetaData"); + BL_PROFILE("BackTransformedDiagnostic::writeMetaData"); if (ParallelDescriptor::IOProcessor()) { const std::string fullpath = WarpX::lab_data_directory + "/snapshots"; @@ -1134,7 +1134,7 @@ LabFrameSnapShot(Real t_lab_in, Real t_boost, Real inv_gamma_boost_in, file_num, 5); createLabFrameDirectories(); buff_counter_ = 0; - if (WarpX::do_boosted_frame_fields) data_buffer_.reset(nullptr); + if (WarpX::do_back_transformed_fields) data_buffer_.reset(nullptr); } void @@ -1158,7 +1158,7 @@ createLabFrameDirectories() { if (ParallelDescriptor::IOProcessor()) { - if (WarpX::do_boosted_frame_fields) + if (WarpX::do_back_transformed_fields) { const auto lo = lbound(buff_box_); for (int comp = 0; comp < ncomp_to_dump_; ++comp) { @@ -1176,15 +1176,15 @@ createLabFrameDirectories() { ParallelDescriptor::Barrier(); - if (WarpX::do_boosted_frame_particles){ + if (WarpX::do_back_transformed_particles){ auto & mypc = WarpX::GetInstance().GetPartContainer(); const std::vector species_names = mypc.GetSpeciesNames(); // Loop over species to be dumped to BFD - for (int j = 0; j < mypc.nSpeciesBoostedFrameDiags(); ++j) + for (int j = 0; j < mypc.nSpeciesBackTransformedDiagnostics(); ++j) { // Loop over species to be dumped to BFD std::string species_name = - species_names[mypc.mapSpeciesBoostedFrameDiags(j)]; + species_names[mypc.mapSpeciesBackTransformedDiagnostics(j)]; output_create_species_group(file_name, species_name); for (int k = 0; k < static_cast(particle_field_names.size()); ++k) { @@ -1211,10 +1211,10 @@ createLabFrameDirectories() { const std::string particles_prefix = "particle"; // Loop over species to be dumped to BFD - for(int i = 0; i < mypc.nSpeciesBoostedFrameDiags(); ++i) { + for(int i = 0; i < mypc.nSpeciesBackTransformedDiagnostics(); ++i) { // Get species name std::string species_name = - species_names[mypc.mapSpeciesBoostedFrameDiags(i)]; + species_names[mypc.mapSpeciesBackTransformedDiagnostics(i)]; const std::string fullpath = file_name + "/" + species_name; if (!UtilCreateDirectory(fullpath, 0755)) CreateDirectoryFailed(fullpath); @@ -1302,7 +1302,7 @@ LabFrameSlice(Real t_lab_in, Real t_boost, Real inv_gamma_boost_in, dx_ = cell_dx; dy_ = cell_dy; - if (WarpX::do_boosted_frame_fields) data_buffer_.reset(nullptr); + if (WarpX::do_back_transformed_fields) data_buffer_.reset(nullptr); } void diff --git a/Source/Diagnostics/Make.package b/Source/Diagnostics/Make.package index dfd947d53..b624d6ebe 100644 --- a/Source/Diagnostics/Make.package +++ b/Source/Diagnostics/Make.package @@ -1,9 +1,9 @@ CEXE_sources += WarpXIO.cpp -CEXE_sources += BoostedFrameDiagnostic.cpp +CEXE_sources += BackTransformedDiagnostic.cpp CEXE_sources += ParticleIO.cpp CEXE_sources += FieldIO.cpp CEXE_headers += FieldIO.H -CEXE_headers += BoostedFrameDiagnostic.H +CEXE_headers += BackTransformedDiagnostic.H CEXE_headers += ElectrostaticIO.cpp CEXE_headers += SliceDiagnostic.H CEXE_sources += SliceDiagnostic.cpp diff --git a/Source/Evolve/WarpXEvolveEM.cpp b/Source/Evolve/WarpXEvolveEM.cpp index 7a3262703..b5fd52bdc 100644 --- a/Source/Evolve/WarpXEvolveEM.cpp +++ b/Source/Evolve/WarpXEvolveEM.cpp @@ -141,9 +141,9 @@ WarpX::EvolveEM (int numsteps) bool do_insitu = ((step+1) >= insitu_start) && (insitu_int > 0) && ((step+1) % insitu_int == 0); - if (do_boosted_frame_diagnostic) { + if (do_back_transformed_diagnostics) { std::unique_ptr cell_centered_data = nullptr; - if (WarpX::do_boosted_frame_fields) { + if (WarpX::do_back_transformed_fields) { cell_centered_data = GetCellCenteredData(); } myBFD->writeLabFrameData(cell_centered_data.get(), *mypc, geom[0], cur_time, dt[0]); @@ -261,7 +261,7 @@ WarpX::EvolveEM (int numsteps) WriteCheckPointFile(); } - if (do_boosted_frame_diagnostic) { + if (do_back_transformed_diagnostics) { myBFD->Flush(geom[0]); } diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 78eaebfc5..6224d5348 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -82,14 +82,14 @@ WarpX::InitData () void WarpX::InitDiagnostics () { - if (do_boosted_frame_diagnostic) { + if (do_back_transformed_diagnostics) { const Real* current_lo = geom[0].ProbLo(); const Real* current_hi = geom[0].ProbHi(); Real dt_boost = dt[0]; // Find the positions of the lab-frame box that corresponds to the boosted-frame box at t=0 Real zmin_lab = current_lo[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); Real zmax_lab = current_hi[moving_window_dir]/( (1.+beta_boost)*gamma_boost ); - myBFD.reset(new BoostedFrameDiagnostic(zmin_lab, + myBFD.reset(new BackTransformedDiagnostic(zmin_lab, zmax_lab, moving_window_v, dt_snapshots_lab, num_snapshots_lab, diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp index 8571c74ad..b9ab20197 100644 --- a/Source/Laser/LaserParticleContainer.cpp +++ b/Source/Laser/LaserParticleContainer.cpp @@ -26,7 +26,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, { charge = 1.0; mass = std::numeric_limits::max(); - do_boosted_frame_diags = 0; + do_back_transformed_diagnostics = 0; ParmParse pp(laser_name); diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 949173052..30f7354d0 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -162,9 +162,9 @@ public: int nSpecies() const {return nspecies;} - int nSpeciesBoostedFrameDiags() const {return nspecies_boosted_frame_diags;} - int mapSpeciesBoostedFrameDiags(int i) const {return map_species_boosted_frame_diags[i];} - int doBoostedFrameDiags() const {return do_boosted_frame_diags;} + int nSpeciesBackTransformedDiagnostics() const {return nspecies_back_transformed_diagnostics;} + int mapSpeciesBackTransformedDiagnostics(int i) const {return map_species_back_transformed_diagnostics[i];} + int doBackTransformedDiagnostics() const {return do_back_transformed_diagnostics;} int nSpeciesDepositOnMainGrid () const { bool const onMainGrid = true; @@ -236,12 +236,12 @@ private: void mapSpeciesProduct (); int getSpeciesID (std::string product_str); - // Number of species dumped in BoostedFrameDiagnostics - int nspecies_boosted_frame_diags = 0; - // map_species_boosted_frame_diags[i] is the species ID in - // MultiParticleContainer for 0 map_species_boosted_frame_diags; - int do_boosted_frame_diags = 0; + // Number of species dumped in BackTransformedDiagnostics + int nspecies_back_transformed_diagnostics = 0; + // map_species_back_transformed_diagnostics[i] is the species ID in + // MultiParticleContainer for 0 map_species_back_transformed_diagnostics; + int do_back_transformed_diagnostics = 0; // runtime parameters int nlasers = 0; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index f4c00404b..63aa500e9 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -38,14 +38,14 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) // Compute the number of species for which lab-frame data is dumped // nspecies_lab_frame_diags, and map their ID to MultiParticleContainer // particle IDs in map_species_lab_diags. - map_species_boosted_frame_diags.resize(nspecies); - nspecies_boosted_frame_diags = 0; + map_species_back_transformed_diagnostics.resize(nspecies); + nspecies_back_transformed_diagnostics = 0; for (int i=0; ido_boosted_frame_diags){ - map_species_boosted_frame_diags[nspecies_boosted_frame_diags] = i; - do_boosted_frame_diags = 1; - nspecies_boosted_frame_diags += 1; + if (pc->do_back_transformed_diagnostics){ + map_species_back_transformed_diagnostics[nspecies_back_transformed_diagnostics] = i; + do_back_transformed_diagnostics = 1; + nspecies_back_transformed_diagnostics += 1; } } } @@ -387,8 +387,8 @@ MultiParticleContainer BL_PROFILE("MultiParticleContainer::GetLabFrameData"); // Loop over particle species - for (int i = 0; i < nspecies_boosted_frame_diags; ++i){ - int isp = map_species_boosted_frame_diags[i]; + for (int i = 0; i < nspecies_back_transformed_diagnostics; ++i){ + int isp = map_species_back_transformed_diagnostics[i]; WarpXParticleContainer* pc = allcontainers[isp].get(); WarpXParticleContainer::DiagnosticParticles diagnostic_particles; pc->GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); @@ -603,9 +603,9 @@ namespace } // --- product runtime attribs GpuArray runtime_attribs_product; - bool do_boosted_product = WarpX::do_boosted_frame_diagnostic - && pc_product->DoBoostedFrameDiags(); - if (do_boosted_product) { + bool do_back_transformed_product = WarpX::do_back_transformed_diagnostics + && pc_product->doBackTransformedDiagnostics(); + if (do_back_transformed_product) { std::map comps_product = pc_product->getParticleComps(); runtime_attribs_product[0] = soa_product.GetRealData(comps_product[ "xold"]).data() + np_product_old; runtime_attribs_product[1] = soa_product.GetRealData(comps_product[ "yold"]).data() + np_product_old; @@ -652,7 +652,7 @@ namespace // Update xold etc. if boosted frame diagnostics required // for product species. Fill runtime attribs with a copy of // current properties (xold = x etc.). - if (do_boosted_product) { + if (do_back_transformed_product) { runtime_attribs_product[0][ip] = p_source.pos(0); runtime_attribs_product[1][ip] = p_source.pos(1); runtime_attribs_product[2][ip] = p_source.pos(2); diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index cf2ffbec4..612da01ca 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -73,7 +73,7 @@ PhotonParticleContainer::PushPX(WarpXParIter& pti, const ParticleReal* const AMREX_RESTRICT By = attribs[PIdx::By].dataPtr(); const ParticleReal* const AMREX_RESTRICT Bz = attribs[PIdx::Bz].dataPtr(); - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_back_transformed_diagnostics && do_back_transformed_diagnostics) { copy_attribs(pti, x, y, z); } diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d12a4dbff..d451ed32b 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -43,7 +43,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_continuous_injection", do_continuous_injection); // Whether to plot back-transformed (lab-frame) diagnostics // for this species. - pp.query("do_boosted_frame_diags", do_boosted_frame_diags); + pp.query("do_back_transformed_diagnostics", do_back_transformed_diagnostics); pp.query("do_field_ionization", do_field_ionization); @@ -86,7 +86,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp //variable to set plot_flags size int plot_flag_size = PIdx::nattribs; - if(WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if(WarpX::do_back_transformed_diagnostics && do_back_transformed_diagnostics) plot_flag_size += 6; #ifdef WARPX_QED @@ -1078,7 +1078,7 @@ PhysicalParticleContainer::Evolve (int lev, bool has_buffer = cEx || cjx; - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + if (WarpX::do_back_transformed_diagnostics && do_back_transformed_diagnostics) { for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) { @@ -1585,7 +1585,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, const ParticleReal* const AMREX_RESTRICT By = attribs[PIdx::By].dataPtr(); const ParticleReal* const AMREX_RESTRICT Bz = attribs[PIdx::Bz].dataPtr(); - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags && (a_dt_type!=DtType::SecondHalf)) + if (WarpX::do_back_transformed_diagnostics && do_back_transformed_diagnostics && (a_dt_type!=DtType::SecondHalf)) { copy_attribs(pti, x, y, z); } @@ -1842,7 +1842,7 @@ void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real // Note the the slice should always move in the negative boost direction. AMREX_ALWAYS_ASSERT(z_new < z_old); - AMREX_ALWAYS_ASSERT(do_boosted_frame_diags == 1); + AMREX_ALWAYS_ASSERT(do_back_transformed_diagnostics == 1); const int nlevs = std::max(0, finestLevel()+1); diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 879f4782e..8930cb176 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -273,7 +273,7 @@ public: AddIntComp(comm); } - int DoBoostedFrameDiags () const { return do_boosted_frame_diags; } + int doBackTransformedDiagnostics () const { return do_back_transformed_diagnostics; } virtual void buildIonizationMask (const amrex::MFIter& mfi, const int lev, amrex::Gpu::ManagedDeviceVector& ionization_mask) @@ -316,7 +316,7 @@ protected: amrex::Gpu::ManagedVector adk_exp_prefactor; std::string physical_element; - int do_boosted_frame_diags = 1; + int do_back_transformed_diagnostics = 1; #ifdef WARPX_QED bool do_qed = false; diff --git a/Source/WarpX.H b/Source/WarpX.H index 6ecc584a2..0084ba64c 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -4,7 +4,7 @@ #include "WarpXDtType.H" #include #include -#include +#include #include #include @@ -100,12 +100,12 @@ public: static bool serialize_ics; // Back transformation diagnostic - static bool do_boosted_frame_diagnostic; + static bool do_back_transformed_diagnostics; static std::string lab_data_directory; static int num_snapshots_lab; static amrex::Real dt_snapshots_lab; - static bool do_boosted_frame_fields; - static bool do_boosted_frame_particles; + static bool do_back_transformed_fields; + static bool do_back_transformed_particles; // Boosted frame parameters static amrex::Real gamma_boost; @@ -478,7 +478,7 @@ private: std::unique_ptr mypc; // Boosted Frame Diagnostics - std::unique_ptr myBFD; + std::unique_ptr myBFD; // // Fields: First array for level, second for direction diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 9ba0741bb..b329f5252 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -61,12 +61,12 @@ int WarpX::num_mirrors = 0; int WarpX::sort_int = -1; -bool WarpX::do_boosted_frame_diagnostic = false; +bool WarpX::do_back_transformed_diagnostics = false; std::string WarpX::lab_data_directory = "lab_frame_data"; int WarpX::num_snapshots_lab = std::numeric_limits::lowest(); Real WarpX::dt_snapshots_lab = std::numeric_limits::lowest(); -bool WarpX::do_boosted_frame_fields = true; -bool WarpX::do_boosted_frame_particles = true; +bool WarpX::do_back_transformed_fields = true; +bool WarpX::do_back_transformed_particles = true; int WarpX::num_slice_snapshots_lab = 0; Real WarpX::dt_slice_snapshots_lab; @@ -168,7 +168,7 @@ WarpX::WarpX () current_injection_position = geom[0].ProbLo(moving_window_dir); } } - do_boosted_frame_particles = mypc->doBoostedFrameDiags(); + do_back_transformed_particles = mypc->doBackTransformedDiagnostics(); Efield_aux.resize(nlevs_max); Bfield_aux.resize(nlevs_max); @@ -324,8 +324,8 @@ WarpX::ReadParameters () moving_window_v *= PhysConst::c; } - pp.query("do_boosted_frame_diagnostic", do_boosted_frame_diagnostic); - if (do_boosted_frame_diagnostic) { + pp.query("do_back_transformed_diagnostics", do_back_transformed_diagnostics); + if (do_back_transformed_diagnostics) { AMREX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0, "gamma_boost must be > 1 to use the boosted frame diagnostic."); @@ -353,7 +353,7 @@ WarpX::ReadParameters () pp.get("gamma_boost", gamma_boost); - pp.query("do_boosted_frame_fields", do_boosted_frame_fields); + pp.query("do_back_transformed_fields", do_back_transformed_fields); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(do_moving_window, "The moving window should be on if using the boosted frame diagnostic."); @@ -600,7 +600,7 @@ WarpX::ReadParameters () } } - if (do_boosted_frame_diagnostic) { + if (do_back_transformed_diagnostics) { AMREX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0, "gamma_boost must be > 1 to use the boost frame diagnostic"); pp.query("num_slice_snapshots_lab", num_slice_snapshots_lab); diff --git a/Tools/performance_tests/automated_test_4_labdiags_2ppc b/Tools/performance_tests/automated_test_4_labdiags_2ppc index 282c93331..bac071f63 100644 --- a/Tools/performance_tests/automated_test_4_labdiags_2ppc +++ b/Tools/performance_tests/automated_test_4_labdiags_2ppc @@ -35,7 +35,7 @@ warpx.gamma_boost = 15. warpx.boost_direction = z # Diagnostics -warpx.do_boosted_frame_diagnostic = 1 +warpx.do_back_transformed_diagnostics = 1 warpx.num_snapshots_lab = 20 warpx.dt_snapshots_lab = 7.0e-14 -- cgit v1.2.3 From 0574904bb3d280611f66c6ba9bafb50f9f2f76ed Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 30 Sep 2019 18:38:14 -0700 Subject: Consts and Real Literals Start to modernize const correctness in interfaces and replace real literals with proper type. --- Source/Initialization/InjectorPosition.H | 28 +++-- Source/Laser/LaserParticleContainer.cpp | 32 +++--- Source/Laser/LaserProfiles.cpp | 14 +-- .../InterpolateCurrentFineToCoarse.H | 56 +++++----- Source/Parallelization/WarpXComm_K.H | 92 ++++++++-------- Source/Particles/Deposition/CurrentDeposition.H | 121 +++++++++++---------- Source/Particles/PhysicalParticleContainer.cpp | 10 +- Source/Utils/WarpXTagging.cpp | 6 +- 8 files changed, 185 insertions(+), 174 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Initialization/InjectorPosition.H b/Source/Initialization/InjectorPosition.H index 6ecae93e0..4ab2fa022 100644 --- a/Source/Initialization/InjectorPosition.H +++ b/Source/Initialization/InjectorPosition.H @@ -29,21 +29,25 @@ struct InjectorPositionRegular // is a_ppc*(ref_fac**AMREX_SPACEDIM). AMREX_GPU_HOST_DEVICE amrex::XDim3 - getPositionUnitBox (int i_part, int ref_fac=1) const noexcept + getPositionUnitBox (int const i_part, int const ref_fac=1) const noexcept { - int nx = ref_fac*ppc.x; - int ny = ref_fac*ppc.y; + using namespace amrex; + + int const nx = ref_fac*ppc.x; + int const ny = ref_fac*ppc.y; #if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ) - int nz = ref_fac*ppc.z; + int const nz = ref_fac*ppc.z; #else - int nz = 1; + int const nz = 1; #endif - int ix_part = i_part/(ny*nz); // written this way backward compatibility - int iz_part = (i_part-ix_part*(ny*nz)) / ny; - int iy_part = (i_part-ix_part*(ny*nz)) - ny*iz_part; - return amrex::XDim3{(amrex::Real(0.5)+ix_part)/nx, - (amrex::Real(0.5)+iy_part)/ny, - (amrex::Real(0.5)+iz_part) / nz}; + int const ix_part = i_part / (ny*nz); // written this way backward compatibility + int const iz_part = (i_part-ix_part*(ny*nz)) / ny; + int const iy_part = (i_part-ix_part*(ny*nz)) - ny*iz_part; + return XDim3{ + (0.5_rt + ix_part) / nx, + (0.5_rt + iy_part) / ny, + (0.5_rt + iz_part) / nz + }; } private: amrex::Dim3 ppc; @@ -100,7 +104,7 @@ struct InjectorPosition // (the union is called Object, and the instance is called object). AMREX_GPU_HOST_DEVICE amrex::XDim3 - getPositionUnitBox (int i_part, int ref_fac=1) const noexcept + getPositionUnitBox (int const i_part, int const ref_fac=1) const noexcept { switch (type) { diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp index 8571c74ad..ea86ba559 100644 --- a/Source/Laser/LaserParticleContainer.cpp +++ b/Source/Laser/LaserParticleContainer.cpp @@ -100,7 +100,7 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, } // Plane normal - Real s = 1.0/std::sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1] + nvec[2]*nvec[2]); + Real s = 1.0_rt / std::sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1] + nvec[2]*nvec[2]); nvec = { nvec[0]*s, nvec[1]*s, nvec[2]*s }; if (WarpX::gamma_boost > 1.) { @@ -119,19 +119,19 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, } // The first polarization vector - s = 1.0/std::sqrt(p_X[0]*p_X[0] + p_X[1]*p_X[1] + p_X[2]*p_X[2]); + s = 1.0_rt / std::sqrt(p_X[0]*p_X[0] + p_X[1]*p_X[1] + p_X[2]*p_X[2]); p_X = { p_X[0]*s, p_X[1]*s, p_X[2]*s }; - Real dp = std::inner_product(nvec.begin(), nvec.end(), p_X.begin(), 0.0); + Real const dp = std::inner_product(nvec.begin(), nvec.end(), p_X.begin(), 0.0); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, "Laser plane vector is not perpendicular to the main polarization vector"); p_Y = CrossProduct(nvec, p_X); // The second polarization vector - s = 1.0/std::sqrt(stc_direction[0]*stc_direction[0] + stc_direction[1]*stc_direction[1] + stc_direction[2]*stc_direction[2]); + s = 1.0_rt / std::sqrt(stc_direction[0]*stc_direction[0] + stc_direction[1]*stc_direction[1] + stc_direction[2]*stc_direction[2]); stc_direction = { stc_direction[0]*s, stc_direction[1]*s, stc_direction[2]*s }; - dp = std::inner_product(nvec.begin(), nvec.end(), stc_direction.begin(), 0.0); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, + Real const dp2 = std::inner_product(nvec.begin(), nvec.end(), stc_direction.begin(), 0.0); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp2) < 1.0e-14, "stc_direction is not perpendicular to the laser plane vector"); // Get angle between p_X and stc_direction @@ -266,20 +266,20 @@ LaserParticleContainer::InitData (int lev) position = updated_position; } - auto Transform = [&](int i, int j) -> Vector{ + auto Transform = [&](int const i, int const j) -> Vector{ #if (AMREX_SPACEDIM == 3) - return { position[0] + (S_X*(i+0.5))*u_X[0] + (S_Y*(j+0.5))*u_Y[0], - position[1] + (S_X*(i+0.5))*u_X[1] + (S_Y*(j+0.5))*u_Y[1], - position[2] + (S_X*(i+0.5))*u_X[2] + (S_Y*(j+0.5))*u_Y[2] }; + return { position[0] + (S_X*(Real(i)+0.5_rt))*u_X[0] + (S_Y*(Real(j)+0.5_rt))*u_Y[0], + position[1] + (S_X*(Real(i)+0.5_rt))*u_X[1] + (S_Y*(Real(j)+0.5_rt))*u_Y[1], + position[2] + (S_X*(Real(i)+0.5_rt))*u_X[2] + (S_Y*(Real(j)+0.5_rt))*u_Y[2] }; #else # if (defined WARPX_DIM_RZ) - return { position[0] + (S_X*(i+0.5)), + return { position[0] + (S_X*(Real(i)+0.5)), 0.0, position[2]}; # else - return { position[0] + (S_X*(i+0.5))*u_X[0], + return { position[0] + (S_X*(Real(i)+0.5))*u_X[0], 0.0, - position[2] + (S_X*(i+0.5))*u_X[2] }; + position[2] + (S_X*(Real(i)+0.5))*u_X[2] }; # endif #endif }; @@ -449,9 +449,9 @@ LaserParticleContainer::Evolve (int lev, #endif { #ifdef _OPENMP - int thread_num = omp_get_thread_num(); + int const thread_num = omp_get_thread_num(); #else - int thread_num = 0; + int const thread_num = 0; #endif Cuda::ManagedDeviceVector plane_Xp, plane_Yp, amplitude_E; @@ -610,7 +610,7 @@ void LaserParticleContainer::ComputeWeightMobility (Real Sx, Real Sy) { constexpr Real eps = 0.01; - constexpr Real fac = 1.0/(2.0*MathConst::pi*PhysConst::mu0*PhysConst::c*PhysConst::c*eps); + constexpr Real fac = 1.0_rt / (2.0_rt * MathConst::pi * PhysConst::mu0 * PhysConst::c * PhysConst::c * eps); weight = fac * wavelength * Sx * Sy / std::min(Sx,Sy) * e_max; // The mobility is the constant of proportionality between the field to diff --git a/Source/Laser/LaserProfiles.cpp b/Source/Laser/LaserProfiles.cpp index 281ab2101..44411cedf 100644 --- a/Source/Laser/LaserProfiles.cpp +++ b/Source/Laser/LaserProfiles.cpp @@ -28,16 +28,16 @@ LaserParticleContainer::gaussian_laser_profile ( const Real oscillation_phase = k0 * PhysConst::c * ( t - profile_t_peak ); // The coefficients below contain info about Gouy phase, // laser diffraction, and phase front curvature - const Complex diffract_factor = Real(1.) + I * profile_focal_distance - * Real(2.)/( k0 * profile_waist * profile_waist ); - const Complex inv_complex_waist_2 = Real(1.)/( profile_waist*profile_waist * diffract_factor ); + const Complex diffract_factor = 1._rt + I * profile_focal_distance + * 2._rt/( k0 * profile_waist * profile_waist ); + const Complex inv_complex_waist_2 = 1._rt / ( profile_waist*profile_waist * diffract_factor ); // Time stretching due to STCs and phi2 complex envelope // (1 if zeta=0, beta=0, phi2=0) - const Complex stretch_factor = Real(1.) + Real(4.) * + const Complex stretch_factor = 1._rt + 4._rt * (zeta+beta*profile_focal_distance) * (zeta+beta*profile_focal_distance) * (inv_tau2*inv_complex_waist_2) + - Real(2.)*I*(phi2 - beta*beta*k0*profile_focal_distance) * inv_tau2; + 2._rt *I*(phi2 - beta*beta*k0*profile_focal_distance) * inv_tau2; // Amplitude and monochromatic oscillations Complex prefactor = e_max * MathFunc::exp( I * oscillation_phase ); @@ -61,10 +61,10 @@ LaserParticleContainer::gaussian_laser_profile ( amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (int i) { - const Complex stc_exponent = Real(1.)/stretch_factor * inv_tau2 * + const Complex stc_exponent = 1._rt / stretch_factor * inv_tau2 * MathFunc::pow((t - tmp_profile_t_peak - tmp_beta*k0*(Xp[i]*std::cos(tmp_theta_stc) + Yp[i]*std::sin(tmp_theta_stc)) - - Real(2.)*I*(Xp[i]*std::cos(tmp_theta_stc) + Yp[i]*std::sin(tmp_theta_stc)) + 2._rt *I*(Xp[i]*std::cos(tmp_theta_stc) + Yp[i]*std::sin(tmp_theta_stc)) *( tmp_zeta - tmp_beta*tmp_profile_focal_distance ) * inv_complex_waist_2),2); // stcfactor = everything but complex transverse envelope const Complex stcfactor = prefactor * MathFunc::exp( - stc_exponent ); diff --git a/Source/Parallelization/InterpolateCurrentFineToCoarse.H b/Source/Parallelization/InterpolateCurrentFineToCoarse.H index 148b725d0..cbbcdfab5 100644 --- a/Source/Parallelization/InterpolateCurrentFineToCoarse.H +++ b/Source/Parallelization/InterpolateCurrentFineToCoarse.H @@ -56,6 +56,8 @@ public: int const k ) const noexcept { + using namespace amrex; + auto const & fine_unsafe = m_fine; // out-of-bounds access not secured with zero-values yet auto const & coarse = m_coarse; // out-of-bounds access not secured but will also not occur @@ -71,29 +73,29 @@ public: int const kk = k * m_refinement_ratio; #if AMREX_SPACEDIM == 2 if (IDim == 0) { - coarse(i, j, k) = 0.25 * ( + coarse(i, j, k) = 0.25_rt * ( fine(ii, jj, kk) + fine(ii + 1, jj, kk) + - 0.5 * ( + 0.5_rt * ( fine(ii, jj - 1, kk) + fine(ii + 1, jj - 1, kk) + fine(ii, jj + 1, kk) + fine(ii + 1, jj + 1, kk) ) ); } else if (IDim == 2) { - coarse(i, j, k) = 0.25 * ( + coarse(i, j, k) = 0.25_rt * ( fine(ii, jj, kk) + fine(ii, jj + 1, kk) + - 0.5 * ( + 0.5_rt * ( fine(ii - 1, jj, kk) + fine(ii - 1, jj + 1, kk) + fine(ii + 1, jj, kk) + fine(ii + 1, jj + 1, kk) ) ); } else { - coarse(i, j, k) = 0.25 * ( + coarse(i, j, k) = 0.25_rt * ( fine(ii, jj, kk) + - 0.5 * ( + 0.5_rt * ( fine(ii - 1, jj , kk) + fine(ii + 1, jj , kk) + fine(ii , jj - 1, kk) + fine(ii , jj + 1, kk) ) + - 0.25 * ( + 0.25_rt * ( fine(ii - 1, jj - 1, kk) + fine(ii + 1, jj - 1, kk) + fine(ii - 1, jj + 1, kk) + fine(ii + 1, jj + 1, kk) ) @@ -101,64 +103,64 @@ public: } #elif AMREX_SPACEDIM == 3 if (IDim == 0) { - coarse(i,j,k) = 0.125 * ( + coarse(i,j,k) = 0.125_rt * ( fine(ii , jj, kk) + - 0.5 * ( + 0.5_rt * ( fine(ii , jj-1, kk ) + fine(ii , jj+1, kk ) + fine(ii , jj , kk-1) + fine(ii , jj , kk+1) ) + - 0.25 * ( + 0.25_rt * ( fine(ii , jj-1, kk-1) + fine(ii , jj+1, kk-1) + fine(ii , jj-1, kk+1) + fine(ii , jj+1, kk+1) ) + fine(ii+1, jj, kk) + - 0.5 * ( + 0.5_rt * ( fine(ii+1, jj-1, kk ) + fine(ii+1, jj+1, kk ) + fine(ii+1, jj , kk-1) + fine(ii+1, jj , kk+1) ) + - 0.25 * ( + 0.25_rt * ( fine(ii+1, jj-1, kk-1) + fine(ii+1, jj+1, kk-1) + fine(ii+1, jj-1, kk+1) + fine(ii+1, jj+1, kk+1) ) ); } else if (IDim == 1) { - coarse(i, j, k) = 0.125 * ( + coarse(i, j, k) = 0.125_rt * ( fine(ii, jj , kk) + - 0.5 * ( + 0.5_rt * ( fine(ii-1, jj , kk ) + fine(ii+1, jj , kk ) + fine(ii , jj , kk-1) + fine(ii , jj , kk+1) - ) + - 0.25 * ( + ) + + 0.25_rt * ( fine(ii-1, jj , kk-1) + fine(ii+1, jj , kk-1) + fine(ii-1, jj , kk+1) + fine(ii+1, jj , kk+1) - ) + - fine(ii, jj+1, kk) + - 0.5 * ( + ) + + fine(ii, jj+1, kk) + + 0.5_rt * ( fine(ii-1, jj+1, kk ) + fine(ii+1, jj+1, kk ) + fine(ii , jj+1, kk-1) + fine(ii , jj+1, kk+1) - ) + - 0.25 * ( + ) + + 0.25_rt * ( fine(ii-1, jj+1, kk-1) + fine(ii+1, jj+1, kk-1) + fine(ii-1, jj+1, kk+1) + fine(ii+1, jj+1, kk+1) - ) + ) ); } else { - coarse(i, j, k) = 0.125 * ( + coarse(i, j, k) = 0.125_rt * ( fine(ii, jj, kk ) + - 0.5 * ( + 0.5_rt * ( fine(ii-1, jj , kk ) + fine(ii+1, jj , kk ) + fine(ii , jj-1, kk ) + fine(ii , jj+1, kk ) ) + - 0.25 * ( + 0.25_rt * ( fine(ii-1, jj-1, kk ) + fine(ii+1, jj-1, kk ) + fine(ii-1, jj+1, kk ) + fine(ii+1, jj+1, kk ) ) + fine(ii, jj, kk+1) + - 0.5 * ( + 0.5_rt * ( fine(ii-1, jj , kk+1) + fine(ii+1, jj , kk+1) + fine(ii , jj-1, kk+1) + fine(ii , jj+1, kk+1) ) + - 0.25 * ( + 0.25_rt * ( fine(ii-1, jj-1, kk+1) + fine(ii+1, jj-1, kk+1) + fine(ii-1, jj+1, kk+1) + fine(ii+1, jj+1, kk+1) ) diff --git a/Source/Parallelization/WarpXComm_K.H b/Source/Parallelization/WarpXComm_K.H index 5da867c9f..169cd0ee1 100644 --- a/Source/Parallelization/WarpXComm_K.H +++ b/Source/Parallelization/WarpXComm_K.H @@ -5,38 +5,38 @@ AMREX_GPU_DEVICE AMREX_FORCE_INLINE void warpx_interp_bfield_x (int j, int k, int l, - amrex::Array4 const& Bxa, + amrex::Array4 const& Bxa, amrex::Array4 const& Bxf, amrex::Array4 const& Bxc) { using namespace amrex; - int lg = amrex::coarsen(l,2); - int kg = amrex::coarsen(k,2); - int jg = amrex::coarsen(j,2); + int const lg = amrex::coarsen(l,2); + int const kg = amrex::coarsen(k,2); + int const jg = amrex::coarsen(j,2); - Real wx = (j == jg*2) ? 0.0 : 0.5; - Real owx = 1.0-wx; + Real const wx = (j == jg*2) ? 0.0_rt : 0.5_rt; + Real const owx = 1.0_rt - wx; Bxa(j,k,l) = owx * Bxc(jg,kg,lg) + wx * Bxc(jg+1,kg,lg) + Bxf(j,k,l); } AMREX_GPU_DEVICE AMREX_FORCE_INLINE void warpx_interp_bfield_y (int j, int k, int l, - amrex::Array4 const& Bya, + amrex::Array4 const& Bya, amrex::Array4 const& Byf, amrex::Array4 const& Byc) { using namespace amrex; - int lg = amrex::coarsen(l,2); - int kg = amrex::coarsen(k,2); - int jg = amrex::coarsen(j,2); + int const lg = amrex::coarsen(l,2); + int const kg = amrex::coarsen(k,2); + int const jg = amrex::coarsen(j,2); // Note that for 2d, l=0, because the amrex convention is used here. #if (AMREX_SPACEDIM == 3) - Real wy = (k == kg*2) ? 0.0 : 0.5; - Real owy = 1.0-wy; + Real const wy = (k == kg*2) ? 0.0_rt : 0.5_rt; + Real const owy = 1.0_rt - wy; Bya(j,k,l) = owy * Byc(jg,kg,lg) + wy * Byc(jg,kg+1,lg) + Byf(j,k,l); #else Bya(j,k,l) = Byc(jg,kg,lg) + Byf(j,k,l); @@ -45,47 +45,47 @@ void warpx_interp_bfield_y (int j, int k, int l, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void warpx_interp_bfield_z (int j, int k, int l, - amrex::Array4 const& Bza, + amrex::Array4 const& Bza, amrex::Array4 const& Bzf, amrex::Array4 const& Bzc) { using namespace amrex; - int lg = amrex::coarsen(l,2); - int kg = amrex::coarsen(k,2); - int jg = amrex::coarsen(j,2); + int const lg = amrex::coarsen(l,2); + int const kg = amrex::coarsen(k,2); + int const jg = amrex::coarsen(j,2); // Note that for 2d, l=0, because the amrex convention is used here. #if (AMREX_SPACEDIM == 3) - Real wz = (l == lg*2) ? 0.0 : 0.5; - Real owz = 1.0-wz; + Real const wz = (l == lg*2) ? 0.0_rt : 0.5_rt; + Real const owz = 1.0_rt - wz; Bza(j,k,l) = owz * Bzc(jg,kg,lg) + owz * Bzc(jg,kg,lg+1) + Bzf(j,k,l); #else - Real wy = (k == kg*2) ? 0.0 : 0.5; - Real owy = 1.0-wy; + Real const wy = (k == kg*2) ? 0.0_rt : 0.5_rt; + Real const owy = 1.0_rt - wy; Bza(j,k,l) = owy * Bzc(jg,kg,lg) + owy * Bzc(jg,kg+1,lg) + Bzf(j,k,l); #endif } AMREX_GPU_DEVICE AMREX_FORCE_INLINE void warpx_interp_efield_x (int j, int k, int l, - amrex::Array4 const& Exa, + amrex::Array4 const& Exa, amrex::Array4 const& Exf, amrex::Array4 const& Exc) { using namespace amrex; - int lg = amrex::coarsen(l,2); - int kg = amrex::coarsen(k,2); - int jg = amrex::coarsen(j,2); + int const lg = amrex::coarsen(l,2); + int const kg = amrex::coarsen(k,2); + int const jg = amrex::coarsen(j,2); - Real wy = (k == kg*2) ? 0.0 : 0.5; - Real owy = 1.0-wy; + Real const wy = (k == kg*2) ? 0.0_rt : 0.5_rt; + Real const owy = 1.0_rt - wy; #if (AMREX_SPACEDIM == 3) - Real wz = (l == lg*2) ? 0.0 : 0.5; - Real owz = 1.0-wz; + Real const wz = (l == lg*2) ? 0.0_rt : 0.5_rt; + Real const owz = 1.0_rt - wz; Exa(j,k,l) = owy * owz * Exc(jg ,kg ,lg ) + wy * owz * Exc(jg ,kg+1,lg ) + owy * wz * Exc(jg ,kg ,lg+1) @@ -98,30 +98,30 @@ void warpx_interp_efield_x (int j, int k, int l, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void warpx_interp_efield_y (int j, int k, int l, - amrex::Array4 const& Eya, + amrex::Array4 const& Eya, amrex::Array4 const& Eyf, amrex::Array4 const& Eyc) { using namespace amrex; - int lg = amrex::coarsen(l,2); - int kg = amrex::coarsen(k,2); - int jg = amrex::coarsen(j,2); + int const lg = amrex::coarsen(l,2); + int const kg = amrex::coarsen(k,2); + int const jg = amrex::coarsen(j,2); - Real wx = (j == jg*2) ? 0.0 : 0.5; - Real owx = 1.0-wx; + Real const wx = (j == jg*2) ? 0.0_rt : 0.5_rt; + Real const owx = 1.0_rt - wx; #if (AMREX_SPACEDIM == 3) - Real wz = (l == lg*2) ? 0.0 : 0.5; - Real owz = 1.0-wz; + Real const wz = (l == lg*2) ? 0.0_rt : 0.5_rt; + Real const owz = 1.0_rt - wz; Eya(j,k,l) = owx * owz * Eyc(jg ,kg ,lg ) + wx * owz * Eyc(jg+1,kg ,lg ) + owx * wz * Eyc(jg ,kg ,lg+1) + wx * wz * Eyc(jg+1,kg ,lg+1) + Eyf(j,k,l); #else - Real wy = (k == kg*2) ? 0.0 : 0.5; - Real owy = 1.0-wy; + Real const wy = (k == kg*2) ? 0.0_rt : 0.5_rt; + Real const owy = 1.0_rt - wy; Eya(j,k,l) = owx * owy * Eyc(jg ,kg ,lg) + wx * owy * Eyc(jg+1,kg ,lg) + owx * wy * Eyc(jg ,kg+1,lg) @@ -132,22 +132,22 @@ void warpx_interp_efield_y (int j, int k, int l, AMREX_GPU_DEVICE AMREX_FORCE_INLINE void warpx_interp_efield_z (int j, int k, int l, - amrex::Array4 const& Eza, + amrex::Array4 const& Eza, amrex::Array4 const& Ezf, amrex::Array4 const& Ezc) { using namespace amrex; - int lg = amrex::coarsen(l,2); - int kg = amrex::coarsen(k,2); - int jg = amrex::coarsen(j,2); + int const lg = amrex::coarsen(l,2); + int const kg = amrex::coarsen(k,2); + int const jg = amrex::coarsen(j,2); - Real wx = (j == jg*2) ? 0.0 : 0.5; - Real owx = 1.0-wx; + Real const wx = (j == jg*2) ? 0.0_rt : 0.5_rt; + Real const owx = 1.0_rt - wx; #if (AMREX_SPACEDIM == 3) - Real wy = (k == kg*2) ? 0.0 : 0.5; - Real owy = 1.0-wy; + Real wy = (k == kg*2) ? 0.0_rt : 0.5_rt; + Real owy = 1.0_rt - wy; Eza(j,k,l) = owx * owy * Ezc(jg ,kg ,lg ) + wx * owy * Ezc(jg+1,kg ,lg ) + owx * wy * Ezc(jg ,kg+1,lg ) diff --git a/Source/Particles/Deposition/CurrentDeposition.H b/Source/Particles/Deposition/CurrentDeposition.H index 6da0f1155..2737eb008 100644 --- a/Source/Particles/Deposition/CurrentDeposition.H +++ b/Source/Particles/Deposition/CurrentDeposition.H @@ -4,6 +4,9 @@ #include "ShapeFactors.H" #include +#include +#include + /* \brief Current Deposition for thread thread_num * /param xp, yp, zp : Pointer to arrays of particle positions. * \param wp : Pointer to array of particle weights. @@ -208,69 +211,71 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, const amrex::Real q, const long n_rz_azimuthal_modes) { + using namespace amrex; + // Whether ion_lev is a null pointer (do_ionization=0) or a real pointer // (do_ionization=1) - const bool do_ionization = ion_lev; - const amrex::Real dxi = 1.0/dx[0]; - const amrex::Real dtsdx0 = dt*dxi; - const amrex::Real xmin = xyzmin[0]; + bool const do_ionization = ion_lev; + Real const dxi = 1.0_rt / dx[0]; + Real const dtsdx0 = dt*dxi; + Real const xmin = xyzmin[0]; #if (defined WARPX_DIM_3D) - const amrex::Real dyi = 1.0/dx[1]; - const amrex::Real dtsdy0 = dt*dyi; - const amrex::Real ymin = xyzmin[1]; + Real const dyi = 1.0_rt / dx[1]; + Real const dtsdy0 = dt*dyi; + Real const ymin = xyzmin[1]; #endif - const amrex::Real dzi = 1.0/dx[2]; - const amrex::Real dtsdz0 = dt*dzi; - const amrex::Real zmin = xyzmin[2]; + Real const dzi = 1.0_rt / dx[2]; + Real const dtsdz0 = dt*dzi; + Real const zmin = xyzmin[2]; #if (defined WARPX_DIM_3D) - const amrex::Real invdtdx = 1.0/(dt*dx[1]*dx[2]); - const amrex::Real invdtdy = 1.0/(dt*dx[0]*dx[2]); - const amrex::Real invdtdz = 1.0/(dt*dx[0]*dx[1]); + Real const invdtdx = 1.0_rt / (dt*dx[1]*dx[2]); + Real const invdtdy = 1.0_rt / (dt*dx[0]*dx[2]); + Real const invdtdz = 1.0_rt / (dt*dx[0]*dx[1]); #elif (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) - const amrex::Real invdtdx = 1.0/(dt*dx[2]); - const amrex::Real invdtdz = 1.0/(dt*dx[0]); - const amrex::Real invvol = 1.0/(dx[0]*dx[2]); + Real const invdtdx = 1.0_rt / (dt*dx[2]); + Real const invdtdz = 1.0_rt / (dt*dx[0]); + Real const invvol = 1.0_rt / (dx[0]*dx[2]); #endif #if (defined WARPX_DIM_RZ) - const Complex I = Complex{0., 1.}; + Complex const I = Complex{0., 1.}; #endif - const amrex::Real clightsq = 1.0/PhysConst::c/PhysConst::c; + Real const clightsq = 1.0_rt / ( PhysConst::c * PhysConst::c ); // Loop over particles and deposit into Jx_arr, Jy_arr and Jz_arr amrex::ParallelFor( np_to_depose, - [=] AMREX_GPU_DEVICE (long ip) { + [=] AMREX_GPU_DEVICE (long const ip) { // --- Get particle quantities - const amrex::Real gaminv = 1.0/std::sqrt(1.0 + uxp[ip]*uxp[ip]*clightsq + Real const gaminv = 1.0/std::sqrt(1.0 + uxp[ip]*uxp[ip]*clightsq + uyp[ip]*uyp[ip]*clightsq + uzp[ip]*uzp[ip]*clightsq); // wqx, wqy wqz are particle current in each direction - amrex::Real wq = q*wp[ip]; + Real wq = q*wp[ip]; if (do_ionization){ wq *= ion_lev[ip]; } - const amrex::Real wqx = wq*invdtdx; + Real const wqx = wq*invdtdx; #if (defined WARPX_DIM_3D) - const amrex::Real wqy = wq*invdtdy; + Real const wqy = wq*invdtdy; #endif - const amrex::Real wqz = wq*invdtdz; + Real const wqz = wq*invdtdz; // computes current and old position in grid units #if (defined WARPX_DIM_RZ) - const amrex::Real xp_mid = xp[ip] - 0.5*dt*uxp[ip]*gaminv; - const amrex::Real yp_mid = yp[ip] - 0.5*dt*uyp[ip]*gaminv; - const amrex::Real xp_old = xp[ip] - dt*uxp[ip]*gaminv; - const amrex::Real yp_old = yp[ip] - dt*uyp[ip]*gaminv; - const amrex::Real rp_new = std::sqrt(xp[ip]*xp[ip] + yp[ip]*yp[ip]); - const amrex::Real rp_mid = std::sqrt(xp_mid*xp_mid + yp_mid*yp_mid); - const amrex::Real rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old); - amrex::Real costheta_new, sintheta_new; - if (rp_new > 0.) { + Real const xp_mid = xp[ip] - 0.5_rt * dt*uxp[ip]*gaminv; + Real const yp_mid = yp[ip] - 0.5_rt * dt*uyp[ip]*gaminv; + Real const xp_old = xp[ip] - dt*uxp[ip]*gaminv; + Real const yp_old = yp[ip] - dt*uyp[ip]*gaminv; + Real const rp_new = std::sqrt(xp[ip]*xp[ip] + yp[ip]*yp[ip]); + Real const rp_mid = std::sqrt(xp_mid*xp_mid + yp_mid*yp_mid); + Real const rp_old = std::sqrt(xp_old*xp_old + yp_old*yp_old); + Real costheta_new, sintheta_new; + if (rp_new > 0._rt) { costheta_new = xp[ip]/rp_new; sintheta_new = yp[ip]/rp_new; } else { @@ -278,7 +283,7 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, sintheta_new = 0.; } amrex::Real costheta_mid, sintheta_mid; - if (rp_mid > 0.) { + if (rp_mid > 0._rt) { costheta_mid = xp_mid/rp_mid; sintheta_mid = yp_mid/rp_mid; } else { @@ -286,7 +291,7 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, sintheta_mid = 0.; } amrex::Real costheta_old, sintheta_old; - if (rp_old > 0.) { + if (rp_old > 0._rt) { costheta_old = xp_old/rp_old; sintheta_old = yp_old/rp_old; } else { @@ -296,37 +301,37 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, const Complex xy_new0 = Complex{costheta_new, sintheta_new}; const Complex xy_mid0 = Complex{costheta_mid, sintheta_mid}; const Complex xy_old0 = Complex{costheta_old, sintheta_old}; - const amrex::Real x_new = (rp_new - xmin)*dxi; - const amrex::Real x_old = (rp_old - xmin)*dxi; + Real const x_new = (rp_new - xmin)*dxi; + Real const x_old = (rp_old - xmin)*dxi; #else - const amrex::Real x_new = (xp[ip] - xmin)*dxi; - const amrex::Real x_old = x_new - dtsdx0*uxp[ip]*gaminv; + Real const x_new = (xp[ip] - xmin)*dxi; + Real const x_old = x_new - dtsdx0*uxp[ip]*gaminv; #endif #if (defined WARPX_DIM_3D) - const amrex::Real y_new = (yp[ip] - ymin)*dyi; - const amrex::Real y_old = y_new - dtsdy0*uyp[ip]*gaminv; + Real const y_new = (yp[ip] - ymin)*dyi; + Real const y_old = y_new - dtsdy0*uyp[ip]*gaminv; #endif - const amrex::Real z_new = (zp[ip] - zmin)*dzi; - const amrex::Real z_old = z_new - dtsdz0*uzp[ip]*gaminv; + Real const z_new = (zp[ip] - zmin)*dzi; + Real const z_old = z_new - dtsdz0*uzp[ip]*gaminv; #if (defined WARPX_DIM_RZ) - const amrex::Real vy = (-uxp[ip]*sintheta_mid + uyp[ip]*costheta_mid)*gaminv; + Real const vy = (-uxp[ip]*sintheta_mid + uyp[ip]*costheta_mid)*gaminv; #elif (defined WARPX_DIM_XZ) - const amrex::Real vy = uyp[ip]*gaminv; + Real const vy = uyp[ip]*gaminv; #endif // Shape factor arrays // Note that there are extra values above and below // to possibly hold the factor for the old particle // which can be at a different grid location. - amrex::Real sx_new[depos_order + 3] = {0.}; - amrex::Real sx_old[depos_order + 3] = {0.}; + Real sx_new[depos_order + 3] = {0.}; + Real sx_old[depos_order + 3] = {0.}; #if (defined WARPX_DIM_3D) - amrex::Real sy_new[depos_order + 3] = {0.}; - amrex::Real sy_old[depos_order + 3] = {0.}; + Real sy_new[depos_order + 3] = {0.}; + Real sy_old[depos_order + 3] = {0.}; #endif - amrex::Real sz_new[depos_order + 3] = {0.}; - amrex::Real sz_old[depos_order + 3] = {0.}; + Real sz_new[depos_order + 3] = {0.}; + Real sz_old[depos_order + 3] = {0.}; // --- Compute shape factors // Compute shape factors for position as they are now and at old positions @@ -397,7 +402,7 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, Complex xy_mid = xy_mid0; // Throughout the following loop, xy_mid takes the value e^{i m theta} for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 comes from the normalization of the modes - const Complex djr_cmplx = amrex::Real(2.)*sdxi*xy_mid; + const Complex djr_cmplx = 2._rt *sdxi*xy_mid; amrex::Gpu::Atomic::Add( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djr_cmplx.real()); amrex::Gpu::Atomic::Add( &Jx_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djr_cmplx.imag()); xy_mid = xy_mid*xy_mid0; @@ -407,8 +412,8 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, } for (int k=dkl; k<=depos_order+2-dku; k++) { for (int i=dil; i<=depos_order+2-diu; i++) { - const amrex::Real sdyj = wq*vy*invvol*((sz_new[k] + 0.5*(sz_old[k] - sz_new[k]))*sx_new[i] + - (0.5*sz_new[k] + 1./3.*(sz_old[k] - sz_new[k]))*(sx_old[i] - sx_new[i])); + Real const sdyj = wq*vy*invvol*((sz_new[k] + 0.5_rt * (sz_old[k] - sz_new[k]))*sx_new[i] + + (0.5_rt * sz_new[k] + 1._rt / 3._rt *(sz_old[k] - sz_new[k]))*(sx_old[i] - sx_new[i])); amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdyj); #if (defined WARPX_DIM_RZ) Complex xy_new = xy_new0; @@ -418,7 +423,7 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 comes from the normalization of the modes // The minus sign comes from the different convention with respect to Davidson et al. - const Complex djt_cmplx = -amrex::Real(2.)*I*(i_new-1 + i + xmin*dxi)*wq*invdtdx/(amrex::Real)imode* + const Complex djt_cmplx = -2._rt * I*(i_new-1 + i + xmin*dxi)*wq*invdtdx/(amrex::Real)imode* (sx_new[i]*sz_new[k]*(xy_new - xy_mid) + sx_old[i]*sz_old[k]*(xy_mid - xy_old)); amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djt_cmplx.real()); amrex::Gpu::Atomic::Add( &Jy_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djt_cmplx.imag()); @@ -430,15 +435,15 @@ void doEsirkepovDepositionShapeN (const amrex::ParticleReal * const xp, } } for (int i=dil; i<=depos_order+2-diu; i++) { - amrex::Real sdzk = 0.; + Real sdzk = 0.; for (int k=dkl; k<=depos_order+1-dku; k++) { - sdzk += wqz*(sz_old[k] - sz_new[k])*(sx_new[i] + 0.5*(sx_old[i] - sx_new[i])); + sdzk += wqz*(sz_old[k] - sz_new[k])*(sx_new[i] + 0.5_rt * (sx_old[i] - sx_new[i])); amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 0), sdzk); #if (defined WARPX_DIM_RZ) Complex xy_mid = xy_mid0; // Throughout the following loop, xy_mid takes the value e^{i m theta} for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { // The factor 2 comes from the normalization of the modes - const Complex djz_cmplx = amrex::Real(2.)*sdzk*xy_mid; + const Complex djz_cmplx = 2._rt * sdzk * xy_mid; amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode-1), djz_cmplx.real()); amrex::Gpu::Atomic::Add( &Jz_arr(lo.x+i_new-1+i, lo.y+k_new-1+k, 0, 2*imode), djz_cmplx.imag()); xy_mid = xy_mid*xy_mid0; diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d12a4dbff..2f445984e 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -441,13 +441,13 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox) for (int dir=0; dir= part_realbox.lo(dir) ) { Real ncells_adjust = std::floor( (part_realbox.hi(dir) - tile_realbox.hi(dir))/dx[dir] ); - overlap_realbox.setHi( dir, part_realbox.hi(dir) - std::max(ncells_adjust, Real(0.)) * dx[dir]); + overlap_realbox.setHi( dir, part_realbox.hi(dir) - std::max(ncells_adjust, 0._rt) * dx[dir]); } else { no_overlap = true; break; } @@ -1427,9 +1427,9 @@ PhysicalParticleContainer::SplitParticles(int lev) // before splitting results in a uniform distribution after splitting const amrex::Vector ppc_nd = plasma_injector->num_particles_per_cell_each_dim; const std::array& dx = WarpX::CellSize(lev); - amrex::Vector split_offset = {dx[0]/2./ppc_nd[0], - dx[1]/2./ppc_nd[1], - dx[2]/2./ppc_nd[2]}; + amrex::Vector split_offset = {dx[0]/2._rt/ppc_nd[0], + dx[1]/2._rt/ppc_nd[1], + dx[2]/2._rt/ppc_nd[2]}; // particle Array Of Structs data auto& particles = pti.GetArrayOfStructs(); diff --git a/Source/Utils/WarpXTagging.cpp b/Source/Utils/WarpXTagging.cpp index 8ea3211a3..91bb802e8 100644 --- a/Source/Utils/WarpXTagging.cpp +++ b/Source/Utils/WarpXTagging.cpp @@ -22,9 +22,9 @@ WarpX::ErrorEst (int lev, TagBoxArray& tags, Real time, int /*ngrow*/) for (BoxIterator bi(bx); bi.ok(); ++bi) { const IntVect& cell = bi(); - RealVect pos {AMREX_D_DECL((cell[0]+0.5)*dx[0]+problo[0], - (cell[1]+0.5)*dx[1]+problo[1], - (cell[2]+0.5)*dx[2]+problo[2])}; + RealVect pos {AMREX_D_DECL((cell[0]+0.5_rt)*dx[0]+problo[0], + (cell[1]+0.5_rt)*dx[1]+problo[1], + (cell[2]+0.5_rt)*dx[2]+problo[2])}; if (pos > fine_tag_lo && pos < fine_tag_hi) { fab(cell) = TagBox::SET; } -- cgit v1.2.3