diff options
22 files changed, 152 insertions, 212 deletions
diff --git a/Regression/Checksum/benchmarks_json/galilean_2d_psatd_hybrid.json b/Regression/Checksum/benchmarks_json/galilean_2d_psatd_hybrid.json index d2a521f89..fcb480db5 100644 --- a/Regression/Checksum/benchmarks_json/galilean_2d_psatd_hybrid.json +++ b/Regression/Checksum/benchmarks_json/galilean_2d_psatd_hybrid.json @@ -2,43 +2,43 @@ "beam": { "particle_cpu": 0.0, "particle_id": 500500.0, - "particle_momentum_x": 6.97328947508489e-19, - "particle_momentum_y": 4.375009234171145e-19, - "particle_momentum_z": 6.153645142906282e-18, - "particle_position_x": 0.0016163761072375818, - "particle_position_y": 0.35892646120154137, + "particle_momentum_x": 7.005046981277183e-19, + "particle_momentum_y": 4.375209352729912e-19, + "particle_momentum_z": 6.175459223479959e-18, + "particle_position_x": 0.001602571749982411, + "particle_position_y": 0.35897924403061005, "particle_weight": 3120754537230.3823 }, "electrons": { "particle_cpu": 65968.0, "particle_id": 6088087768.0, - "particle_momentum_x": 6.188670717263122e-19, - "particle_momentum_y": 1.5815167091528533e-18, - "particle_momentum_z": 2.5068812946608423e-16, - "particle_position_x": 1.501480281140583, - "particle_position_y": 16.52376191494934, + "particle_momentum_x": 6.240989852249656e-19, + "particle_momentum_y": 1.5790301798509742e-18, + "particle_momentum_z": 2.5064352637575283e-16, + "particle_position_x": 1.501413662801212, + "particle_position_y": 16.523781706919216, "particle_weight": 1.2372401466086835e+18 }, "ions": { "particle_cpu": 65968.0, "particle_id": 6104975576.0, - "particle_momentum_x": 1.4325006334160432e-18, - "particle_momentum_y": 1.5996551431385342e-18, - "particle_momentum_z": 4.2873401613959033e-13, - "particle_position_x": 1.4911810555953569, - "particle_position_y": 16.521964995836314, + "particle_momentum_x": 1.4394968631660078e-18, + "particle_momentum_y": 1.5967458174525868e-18, + "particle_momentum_z": 4.2873406586841774e-13, + "particle_position_x": 1.4911814217840753, + "particle_position_y": 16.52196497877435, "particle_weight": 1.2372405194129536e+18 }, "lev=0": { - "Bx": 1087166.739121248, - "By": 2884112.8417617697, - "Bz": 264340.4113696969, - "Ex": 866621051267102.1, - "Ey": 392914135663207.0, - "Ez": 145965410810851.56, - "jx": 2.679310957762023e+16, - "jy": 8.630859177279523e+16, - "jz": 2.7307326582929523e+17, - "rho": 915200562.8006762 + "Bx": 1086731.2285090145, + "By": 2886537.258822082, + "Bz": 264280.80501631316, + "Ex": 867382744066315.0, + "Ey": 392669698675093.25, + "Ez": 146897949570681.72, + "jx": 2.7028852724044516e+16, + "jy": 8.615686606708202e+16, + "jz": 2.7328720244417827e+17, + "rho": 915931431.8889401 } }
\ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/restart_psatd.json b/Regression/Checksum/benchmarks_json/restart_psatd.json index e0a704155..4d02b0a76 100644 --- a/Regression/Checksum/benchmarks_json/restart_psatd.json +++ b/Regression/Checksum/benchmarks_json/restart_psatd.json @@ -14,11 +14,11 @@ "particle_cpu": 0.0, "particle_id": 500500.0, "particle_momentum_x": 4.700436405078562e+21, - "particle_momentum_y": 4.678586211309308e+21, - "particle_momentum_z": 2.999596093018443e+25, - "particle_position_x": 0.001581173031177189, - "particle_position_y": 0.001621237314969941, - "particle_position_z": 0.3041777949865339, + "particle_momentum_y": 4.6785862113093076e+21, + "particle_momentum_z": 2.9995960930184427e+25, + "particle_position_x": 0.0015811730311771888, + "particle_position_y": 0.0016212373149699414, + "particle_position_z": 0.30417779498653386, "particle_weight": 6241509074.460762 }, "driverback": { @@ -28,42 +28,42 @@ "particle_momentum_y": 5.16548074090123e+21, "particle_momentum_z": 3.005830430844926e+25, "particle_position_x": 0.001649481123084974, - "particle_position_y": 0.001617221874542843, + "particle_position_y": 0.0016172218745428432, "particle_position_z": 0.4899808854005956, "particle_weight": 6241509074.460762 }, "lev=0": { - "Bx": 114419.4530647947, - "By": 237357.3069340034, - "Bz": 61222.57415443816, - "Ex": 112951263088621.0, - "Ey": 18046643403106.45, - "Ez": 51001411566869.4, - "jx": 2.343804803356361e+16, - "jy": 260779750661908.3, - "jz": 4106706564662903.0, - "rho": 20789992.3902211 + "Bx": 116102.28415732287, + "By": 245468.57438100342, + "Bz": 65305.38781838063, + "Ex": 118565257880521.4, + "Ey": 18640027127418.004, + "Ez": 51777964618631.914, + "jx": 2.1177240176169996e+16, + "jy": 351529204246424.9, + "jz": 4573419547907262.0, + "rho": 22294773.912022192 }, "plasma_e": { "particle_cpu": 9680.0, "particle_id": 117349672.0, - "particle_momentum_x": 1.473741556000155e-19, - "particle_momentum_y": 1.017067297999503e-20, - "particle_momentum_z": 2.631914757990082e-17, - "particle_position_x": 0.4991550302254794, - "particle_position_y": 0.4991738993905907, - "particle_position_z": 0.4562707780957934, + "particle_momentum_x": 2.0912370354448323e-19, + "particle_momentum_y": 1.3510736736168866e-20, + "particle_momentum_z": 2.633607024821822e-17, + "particle_position_x": 0.4991733347875822, + "particle_position_y": 0.49919828067421096, + "particle_position_z": 0.4562416755755165, "particle_weight": 33067341227104.625 }, "plasma_p": { "particle_cpu": 9680.0, "particle_id": 128125448.0, - "particle_momentum_x": 1.477221121488074e-19, - "particle_momentum_y": 3.297815182102652e-21, - "particle_momentum_z": 4.829601024084073e-14, - "particle_position_x": 0.4991250017240317, - "particle_position_y": 0.4991249994564745, - "particle_position_z": 0.4563845474003356, + "particle_momentum_x": 2.105303160755537e-19, + "particle_momentum_y": 3.3281768098792752e-21, + "particle_momentum_z": 4.829599953650214e-14, + "particle_position_x": 0.4991250029759827, + "particle_position_y": 0.49912499825258744, + "particle_position_z": 0.4563845470979585, "particle_weight": 33067341227104.625 } }
\ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json b/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json index bd7ec8bb0..72b998774 100644 --- a/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json +++ b/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json @@ -14,11 +14,11 @@ "particle_cpu": 0.0, "particle_id": 500500.0, "particle_momentum_x": 4.700436405078562e+21, - "particle_momentum_y": 4.678586211309308e+21, - "particle_momentum_z": 2.999596093018443e+25, - "particle_position_x": 0.001581173031177189, - "particle_position_y": 0.001621237314969941, - "particle_position_z": 0.3041777949865339, + "particle_momentum_y": 4.6785862113093076e+21, + "particle_momentum_z": 2.9995960930184427e+25, + "particle_position_x": 0.0015811730311771888, + "particle_position_y": 0.0016212373149699414, + "particle_position_z": 0.30417779498653386, "particle_weight": 6241509074.460762 }, "driverback": { @@ -28,42 +28,42 @@ "particle_momentum_y": 5.16548074090123e+21, "particle_momentum_z": 3.005830430844926e+25, "particle_position_x": 0.001649481123084974, - "particle_position_y": 0.001617221874542843, + "particle_position_y": 0.0016172218745428432, "particle_position_z": 0.4899808854005956, "particle_weight": 6241509074.460762 }, "lev=0": { - "Bx": 113640.3418756688, - "By": 233876.9447488167, - "Bz": 58917.37343833208, - "Ex": 110724534784295.0, - "Ey": 17737373912585.38, - "Ez": 49992244546329.05, - "jx": 2.303285553934353e+16, - "jy": 248219033027724.7, - "jz": 4052890440175054.0, - "rho": 20554175.26636195 + "Bx": 115622.38124168929, + "By": 243405.25199746038, + "Bz": 63602.713209078014, + "Ex": 117118723119070.72, + "Ey": 18448325716024.688, + "Ez": 50821980097172.29, + "jx": 2.104451599585796e+16, + "jy": 329301545706958.4, + "jz": 4524740919108259.0, + "rho": 22129124.901803844 }, "plasma_e": { "particle_cpu": 9680.0, "particle_id": 117349672.0, - "particle_momentum_x": 1.388826001839711e-19, - "particle_momentum_y": 9.584782996406928e-21, - "particle_momentum_z": 2.631835513502191e-17, - "particle_position_x": 0.4991533519422161, - "particle_position_y": 0.4991708669676737, - "particle_position_z": 0.4562788429072069, + "particle_momentum_x": 1.9905296213155052e-19, + "particle_momentum_y": 1.2685326003720766e-20, + "particle_momentum_z": 2.6334746549552728e-17, + "particle_position_x": 0.4991702881158205, + "particle_position_y": 0.4991949977965001, + "particle_position_z": 0.45624916139143146, "particle_weight": 33067341227104.625 }, "plasma_p": { "particle_cpu": 9680.0, "particle_id": 128125448.0, - "particle_momentum_x": 1.395633447277729e-19, - "particle_momentum_y": 3.33014596181184e-21, - "particle_momentum_z": 4.829601144915125e-14, - "particle_position_x": 0.4991250015925794, - "particle_position_y": 0.4991249991800695, - "particle_position_z": 0.4563845474251499, + "particle_momentum_x": 2.0028987523417718e-19, + "particle_momentum_y": 2.875037979316222e-21, + "particle_momentum_z": 4.8296000849162443e-14, + "particle_position_x": 0.49912500259844994, + "particle_position_y": 0.4991249979476608, + "particle_position_z": 0.4563845471286154, "particle_weight": 33067341227104.625 } }
\ No newline at end of file diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp index a0414c0fc..531e044c1 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp @@ -466,8 +466,7 @@ void FieldProbe::ComputeDiags (int step) ParticleReal* const AMREX_RESTRICT part_Bz = attribs[FieldProbePIdx::Bz].dataPtr(); ParticleReal* const AMREX_RESTRICT part_S = attribs[FieldProbePIdx::S].dataPtr(); - amrex::Vector<amrex::Real> v_galilean{amrex::Vector<amrex::Real>(3, amrex::Real(0.))}; - const auto &xyzmin = WarpX::GetInstance().LowerCornerWithGalilean(box, v_galilean, lev); + const auto &xyzmin = WarpX::LowerCorner(box, lev, 0._rt); const std::array<Real, 3> &dx = WarpX::CellSize(lev); const amrex::GpuArray<amrex::Real, 3> dx_arr = {dx[0], dx[1], dx[2]}; diff --git a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp index 304f4c5a1..3658a8c16 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp @@ -399,16 +399,11 @@ void ParticleExtrema::ComputeDiags (int step) const int nox = WarpX::nox; const bool galerkin_interpolation = WarpX::galerkin_interpolation; const amrex::IntVect ngEB = warpx.getngEB(); - amrex::Vector<amrex::Real> v_galilean = myspc.get_v_galilean(); - const auto& time_of_last_gal_shift = warpx.time_of_last_gal_shift; // loop over refinement levels for (int lev = 0; lev <= level_number; ++lev) { // define variables in preparation for field gathering - const amrex::Real cur_time = WarpX::GetInstance().gett_new(lev); - const amrex::Real time_shift = (cur_time - time_of_last_gal_shift); - const amrex::Array<amrex::Real,3> galilean_shift = { v_galilean[0]*time_shift, v_galilean[1]*time_shift, v_galilean[2]*time_shift }; const std::array<amrex::Real,3>& dx = WarpX::CellSize(std::max(lev, 0)); const GpuArray<amrex::Real, 3> dx_arr = {dx[0], dx[1], dx[2]}; const MultiFab & Ex = warpx.getEfield(lev,0); @@ -434,7 +429,7 @@ void ParticleExtrema::ComputeDiags (int step) amrex::Box box = pti.tilebox(); box.grow(ngEB); const Dim3 lo = amrex::lbound(box); - const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, galilean_shift, lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); const GpuArray<amrex::Real, 3> xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; const auto& ex_arr = Ex[pti].array(); const auto& ey_arr = Ey[pti].array(); diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp index 8a228179c..e63508033 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp @@ -176,7 +176,7 @@ SpectralFieldDataRZ::SpectralFieldDataRZ (const int lev, #endif // Create the Hankel transformer for each box. - std::array<amrex::Real,3> xmax = WarpX::UpperCorner(mfi.tilebox(), lev); + std::array<amrex::Real,3> xmax = WarpX::UpperCorner(mfi.tilebox(), lev, 0._rt); multi_spectral_hankel_transformer[mfi] = SpectralHankelTransformer(grid_size[0], n_rz_azimuthal_modes, xmax[0]); } } diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index d02263325..f8e4f9762 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -976,8 +976,7 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu // Lower corner of tile box physical domain // Note that this is done before the tilebox.grow so that // these do not include the guard cells. - std::array<amrex::Real,3> galilean_shift = {0,0,0}; - const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, galilean_shift, lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, lev, 0._rt); const Real rmin = xyzmin[0]; const Real rminr = xyzmin[0] + (tbr.type(0) == NODE ? 0. : 0.5*dx[0]); const Real rmint = xyzmin[0] + (tbt.type(0) == NODE ? 0. : 0.5*dx[0]); @@ -1139,8 +1138,7 @@ WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev) // Lower corner of tile box physical domain // Note that this is done before the tilebox.grow so that // these do not include the guard cells. - std::array<amrex::Real,3> galilean_shift = {0,0,0}; - const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, galilean_shift, lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, lev, 0._rt); const Dim3 lo = lbound(tilebox); const Real rmin = xyzmin[0]; const Real rminr = xyzmin[0] + (tb.type(0) == NODE ? 0. : 0.5*dx[0]); diff --git a/Source/Particles/ElementaryProcess/Ionization.H b/Source/Particles/ElementaryProcess/Ionization.H index eeac927a9..9bf85ddf7 100644 --- a/Source/Particles/ElementaryProcess/Ionization.H +++ b/Source/Particles/ElementaryProcess/Ionization.H @@ -70,7 +70,6 @@ struct IonizationFilterFunc amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - amrex::Vector<amrex::Real> v_galilean, const amrex::Real* const AMREX_RESTRICT a_ionization_energies, const amrex::Real* const AMREX_RESTRICT a_adk_prefactor, const amrex::Real* const AMREX_RESTRICT a_adk_exp_prefactor, diff --git a/Source/Particles/ElementaryProcess/Ionization.cpp b/Source/Particles/ElementaryProcess/Ionization.cpp index 5264faf93..a4aac9d5e 100644 --- a/Source/Particles/ElementaryProcess/Ionization.cpp +++ b/Source/Particles/ElementaryProcess/Ionization.cpp @@ -24,7 +24,6 @@ IonizationFilterFunc::IonizationFilterFunc (const WarpXParIter& a_pti, int lev, amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - amrex::Vector<amrex::Real> v_galilean, const amrex::Real* const AMREX_RESTRICT a_ionization_energies, const amrex::Real* const AMREX_RESTRICT a_adk_prefactor, const amrex::Real* const AMREX_RESTRICT a_adk_exp_prefactor, @@ -33,6 +32,9 @@ IonizationFilterFunc::IonizationFilterFunc (const WarpXParIter& a_pti, int lev, int a_atomic_number, int a_offset) noexcept { + + using namespace amrex::literals; + m_ionization_energies = a_ionization_energies; m_adk_prefactor = a_adk_prefactor; m_adk_exp_prefactor = a_adk_exp_prefactor; @@ -64,11 +66,7 @@ IonizationFilterFunc::IonizationFilterFunc (const WarpXParIter& a_pti, int lev, m_dx_arr = {dx[0], dx[1], dx[2]}; // Lower corner of tile box physical domain (take into account Galilean shift) - amrex::Real cur_time = WarpX::GetInstance().gett_new(lev); - const auto& time_of_last_gal_shift = WarpX::GetInstance().time_of_last_gal_shift; - amrex::Real time_shift = (cur_time - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift = { v_galilean[0]*time_shift, v_galilean[1]*time_shift, v_galilean[2]*time_shift }; - const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, galilean_shift, lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); m_xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; m_galerkin_interpolation = WarpX::galerkin_interpolation; diff --git a/Source/Particles/ElementaryProcess/QEDPairGeneration.H b/Source/Particles/ElementaryProcess/QEDPairGeneration.H index a125ccc8b..a38d0754a 100644 --- a/Source/Particles/ElementaryProcess/QEDPairGeneration.H +++ b/Source/Particles/ElementaryProcess/QEDPairGeneration.H @@ -94,7 +94,6 @@ public: * @param[in] bxfab constant reference to the FArrayBox of the x component of the magnetic field * @param[in] byfab constant reference to the FArrayBox of the y component of the magnetic field * @param[in] bzfab constant reference to the FArrayBox of the z component of the magnetic field - * @param[in] v_galilean vector components of the Galilean velocity (used with the Galilean PSATD solver) * @param[in] a_offset offset to apply to the particle indices */ PairGenerationTransformFunc(BreitWheelerGeneratePairs const generate_functor, @@ -105,7 +104,6 @@ public: amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - amrex::Vector<amrex::Real> v_galilean, int a_offset = 0); /** diff --git a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp index 52134ca81..68475aa14 100644 --- a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp +++ b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp @@ -26,10 +26,12 @@ PairGenerationTransformFunc (BreitWheelerGeneratePairs const generate_functor, amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - amrex::Vector<amrex::Real> v_galilean, int a_offset) : m_generate_functor(generate_functor) { + + using namespace amrex::literals; + m_get_position = GetParticlePosition(a_pti, a_offset); m_get_externalEB = GetExternalEBField(a_pti, a_offset); @@ -54,11 +56,7 @@ PairGenerationTransformFunc (BreitWheelerGeneratePairs const generate_functor, m_dx_arr = {dx[0], dx[1], dx[2]}; // Lower corner of tile box physical domain (take into account Galilean shift) - amrex::Real cur_time = WarpX::GetInstance().gett_new(lev); - const auto& time_of_last_gal_shift = WarpX::GetInstance().time_of_last_gal_shift; - amrex::Real time_shift = (cur_time - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift = { v_galilean[0]*time_shift, v_galilean[1]*time_shift, v_galilean[2]*time_shift }; - const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, galilean_shift, lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); m_xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; m_galerkin_interpolation = WarpX::galerkin_interpolation; diff --git a/Source/Particles/ElementaryProcess/QEDPhotonEmission.H b/Source/Particles/ElementaryProcess/QEDPhotonEmission.H index 21cd34730..93aea3c3b 100644 --- a/Source/Particles/ElementaryProcess/QEDPhotonEmission.H +++ b/Source/Particles/ElementaryProcess/QEDPhotonEmission.H @@ -105,7 +105,6 @@ public: * @param[in] bxfab constant reference to the FArrayBox of the x component of the magnetic field * @param[in] byfab constant reference to the FArrayBox of the y component of the magnetic field * @param[in] bzfab constant reference to the FArrayBox of the z component of the magnetic field - * @param[in] v_galilean vector components of the Galilean velocity (used with the Galilean PSATD solver) * @param[in] a_offset offset to apply to the particle indices */ PhotonEmissionTransformFunc ( @@ -119,7 +118,6 @@ public: amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - amrex::Vector<amrex::Real> v_galilean, int a_offset = 0); /** diff --git a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp index 368a4ee96..2c060a30f 100644 --- a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp +++ b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp @@ -27,12 +27,14 @@ PhotonEmissionTransformFunc (QuantumSynchrotronGetOpticalDepth opt_depth_functor amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - amrex::Vector<amrex::Real> v_galilean, int a_offset) :m_opt_depth_functor{opt_depth_functor}, m_opt_depth_runtime_comp{opt_depth_runtime_comp}, m_emission_functor{emission_functor} { + + using namespace amrex::literals; + m_get_position = GetParticlePosition(a_pti, a_offset); m_get_externalEB = GetExternalEBField(a_pti, a_offset); @@ -57,11 +59,7 @@ PhotonEmissionTransformFunc (QuantumSynchrotronGetOpticalDepth opt_depth_functor m_dx_arr = {dx[0], dx[1], dx[2]}; // Lower corner of tile box physical domain (take into account Galilean shift) - amrex::Real cur_time = WarpX::GetInstance().gett_new(lev); - const auto& time_of_last_gal_shift = WarpX::GetInstance().time_of_last_gal_shift; - amrex::Real time_shift = (cur_time - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift = { v_galilean[0]*time_shift, v_galilean[1]*time_shift, v_galilean[2]*time_shift }; - const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, galilean_shift, lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); m_xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; m_galerkin_interpolation = WarpX::galerkin_interpolation; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 156f90905..78d6c7179 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -1537,8 +1537,7 @@ void MultiParticleContainer::doQedBreitWheeler (int lev, auto Transform = PairGenerationTransformFunc(pair_gen_functor, pti, lev, Ex.nGrowVect(), Ex[pti], Ey[pti], Ez[pti], - Bx[pti], By[pti], Bz[pti], - pc_source->get_v_galilean()); + Bx[pti], By[pti], Bz[pti]); auto& src_tile = pc_source->ParticlesAt(lev, pti); auto& dst_ele_tile = pc_product_ele->ParticlesAt(lev, pti); @@ -1616,8 +1615,7 @@ void MultiParticleContainer::doQedQuantumSync (int lev, m_shr_p_qs_engine->build_phot_em_functor(), pti, lev, Ex.nGrowVect(), Ex[pti], Ey[pti], Ez[pti], - Bx[pti], By[pti], Bz[pti], - pc_source->get_v_galilean()); + Bx[pti], By[pti], Bz[pti]); auto& src_tile = pc_source->ParticlesAt(lev, pti); auto& dst_tile = pc_product_phot->ParticlesAt(lev, pti); diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index cd23a238e..29a835735 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -136,14 +136,7 @@ PhotonParticleContainer::PushPX (WarpXParIter& pti, const auto getExternalEB = GetExternalEBField(pti, offset); // Lower corner of tile box physical domain (take into account Galilean shift) - amrex::Real cur_time = WarpX::GetInstance().gett_new(lev); - const auto& time_of_last_gal_shift = WarpX::GetInstance().time_of_last_gal_shift; - amrex::Real time_shift = (cur_time - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift = { - m_v_galilean[0]*time_shift, - m_v_galilean[1]*time_shift, - m_v_galilean[2]*time_shift }; - const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(box, galilean_shift, gather_lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, gather_lev, 0._rt); const Dim3 lo = lbound(box); diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 0efb6f61c..8845fb9e2 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -342,18 +342,6 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp_boundary.query("reflect_all_velocities", flag); m_boundary_conditions.Set_reflect_all_velocities(flag); - // Get Galilean velocity - ParmParse pp_psatd("psatd"); - bool use_default_v_galilean = false; - pp_psatd.query("use_default_v_galilean", use_default_v_galilean); - if (use_default_v_galilean) { - m_v_galilean[2] = -std::sqrt(1._rt - 1._rt / (WarpX::gamma_boost * WarpX::gamma_boost)); - } else { - queryArrWithParser(pp_psatd, "v_galilean", m_v_galilean, 0, 3); - } - // Scale the Galilean velocity by the speed of light - for (int i=0; i<3; i++) m_v_galilean[i] *= PhysConst::c; - } PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core) @@ -2223,7 +2211,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, const auto getExternalEB = GetExternalEBField(pti); - const auto& xyzmin = WarpX::GetInstance().LowerCornerWithGalilean(box,m_v_galilean,lev); + const std::array<amrex::Real,3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); const Dim3 lo = lbound(box); @@ -2576,14 +2564,7 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, const auto getExternalEB = GetExternalEBField(pti, offset); // Lower corner of tile box physical domain (take into account Galilean shift) - Real cur_time = WarpX::GetInstance().gett_new(lev); - const auto& time_of_last_gal_shift = WarpX::GetInstance().time_of_last_gal_shift; - Real time_shift = (cur_time - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift ={ - m_v_galilean[0]*time_shift, - m_v_galilean[1]*time_shift, - m_v_galilean[2]*time_shift }; - const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(box, galilean_shift, gather_lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, gather_lev, 0._rt); const Dim3 lo = lbound(box); @@ -2797,7 +2778,6 @@ PhysicalParticleContainer::getIonizationFunc (const WarpXParIter& pti, WARPX_PROFILE("PhysicalParticleContainer::getIonizationFunc()"); return IonizationFilterFunc(pti, lev, ngEB, Ex, Ey, Ez, Bx, By, Bz, - m_v_galilean, ionization_energies.dataPtr(), adk_prefactor.dataPtr(), adk_exp_prefactor.dataPtr(), diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index df98575c2..9ca55067e 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -356,7 +356,7 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, const auto getExternalEB = GetExternalEBField(pti); - const auto& xyzmin = WarpX::GetInstance().LowerCornerWithGalilean(box,m_v_galilean,lev); + const std::array<amrex::Real,3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); const Dim3 lo = lbound(box); diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index b17136e58..9ec893fc2 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -363,8 +363,6 @@ public: */ std::string getSpeciesTypeName () const {return species::get_name(physical_species);} - amrex::Vector<amrex::Real> get_v_galilean () {return m_v_galilean;} - /** * \brief Virtual method to resample the species. Overriden by PhysicalParticleContainer only. * Empty body is here because making the method purely virtual would mean that we need to @@ -382,7 +380,6 @@ public: void defineAllParticleTiles () noexcept; protected: - amrex::Vector<amrex::Real> m_v_galilean = amrex::Vector<amrex::Real>(3, amrex::Real(0.)); std::map<std::string, int> particle_comps; std::map<std::string, int> particle_icomps; std::map<std::string, int> particle_runtime_comps; diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index e8ad5844f..6ca49aaf3 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -415,22 +415,12 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti, // Note that this includes guard cells since it is after tilebox.ngrow const Dim3 lo = lbound(tilebox); // Take into account Galilean shift - Real cur_time = warpx.gett_new(lev); - const auto& time_of_last_gal_shift = warpx.time_of_last_gal_shift; - Real time_shift = (cur_time + 0.5_rt*dt - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift = { - m_v_galilean[0]* time_shift, - m_v_galilean[1]*time_shift, - m_v_galilean[2]*time_shift }; - const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, galilean_shift, depos_lev); + const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, depos_lev, 0.5_rt*dt); if (WarpX::current_deposition_algo == CurrentDepositionAlgo::Esirkepov) { if (WarpX::do_nodal==1) { amrex::Abort("The Esirkepov algorithm cannot be used with a nodal grid."); } - if ( (m_v_galilean[0]!=0) or (m_v_galilean[1]!=0) or (m_v_galilean[2]!=0)){ - amrex::Abort("The Esirkepov algorithm cannot be used with the Galilean algorithm."); - } if ( relative_time != -0.5_rt ) { amrex::Abort("The Esirkepov deposition cannot be performed at another time then -0.5 dt."); } @@ -623,24 +613,9 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector const& wp, // Lower corner of tile box physical domain // Note that this includes guard cells since it is after tilebox.ngrow // Take into account Galilean shift - const amrex::Real cur_time = warpx.gett_new(lev); const amrex::Real dt = warpx.getdt(lev); - const amrex::Real time_of_last_gal_shift = warpx.time_of_last_gal_shift; - const amrex::Real time_shift_rho_old = (cur_time - time_of_last_gal_shift); - const amrex::Real time_shift_rho_new = (cur_time + dt - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift; - if (icomp==0){ - galilean_shift = { - m_v_galilean[0]*time_shift_rho_old, - m_v_galilean[1]*time_shift_rho_old, - m_v_galilean[2]*time_shift_rho_old }; - } else{ - galilean_shift = { - m_v_galilean[0]*time_shift_rho_new, - m_v_galilean[1]*time_shift_rho_new, - m_v_galilean[2]*time_shift_rho_new }; - } - const auto& xyzmin = WarpX::LowerCorner(tilebox, galilean_shift, depos_lev); + const amrex::Real time_shift_delta = (icomp == 0 ? 0.0_rt : dt); + const std::array<amrex::Real,3>& xyzmin = WarpX::LowerCorner(tilebox, depos_lev, time_shift_delta); // pointer to costs data amrex::LayoutData<amrex::Real>* costs = WarpX::getCosts(lev); diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp index 14de3cf03..8919b0fa7 100644 --- a/Source/Utils/WarpXUtil.cpp +++ b/Source/Utils/WarpXUtil.cpp @@ -220,15 +220,8 @@ void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, amrex::Real zmax) for(amrex::MFIter mfi(mf, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi){ const amrex::Box& bx = mfi.tilebox(); // Get box lower and upper physical z bound, and dz -#if defined(WARPX_DIM_3D) - amrex::Array<amrex::Real,3> galilean_shift = { 0._rt, 0._rt, 0._rt, }; -#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) - amrex::Array<amrex::Real,3> galilean_shift = { 0._rt, std::numeric_limits<amrex::Real>::quiet_NaN(), 0._rt, } ; -#elif defined(WARPX_DIM_1D_Z) - amrex::Array<amrex::Real,3> galilean_shift = {std::numeric_limits<amrex::Real>::quiet_NaN(), std::numeric_limits<amrex::Real>::quiet_NaN(), 0._rt, } ; -#endif - const amrex::Real zmin_box = WarpX::LowerCorner(bx, galilean_shift, lev)[2]; - const amrex::Real zmax_box = WarpX::UpperCorner(bx, lev)[2]; + const amrex::Real zmin_box = WarpX::LowerCorner(bx, lev, 0._rt)[2]; + const amrex::Real zmax_box = WarpX::UpperCorner(bx, lev, 0._rt)[2]; amrex::Real dz = WarpX::CellSize(lev)[2]; // Get box lower index in the z direction #if defined(WARPX_DIM_3D) diff --git a/Source/WarpX.H b/Source/WarpX.H index e63e60414..1178e8fad 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -724,14 +724,25 @@ public: static std::array<amrex::Real,3> CellSize (int lev); static amrex::RealBox getRealBox(const amrex::Box& bx, int lev); - static std::array<amrex::Real,3> LowerCorner (const amrex::Box& bx, - std::array<amrex::Real,3> galilean_shift, int lev); - static std::array<amrex::Real,3> UpperCorner (const amrex::Box& bx, int lev); - /* - /brief This computes the lower of the problem domain, taking into account any shift when using the Galilean algorithm. + /** + * \brief Return the lower corner of the box in real units. + * \param bx The box + * \param lev The refinement level of the box + * \param time_shift_delta The time relative to the current time at which to calculate the position + * (when v_galilean is not zero) + * \return An array of the position coordinates + */ + static std::array<amrex::Real,3> LowerCorner (const amrex::Box& bx, const int lev, const amrex::Real time_shift_delta); + /** + * \brief Return the upper corner of the box in real units. + * \param bx The box + * \param lev The refinement level of the box + * \param time_shift_delta The time relative to the current time at which to calculate the position + * (when v_galilean is not zero) + * \return An array of the position coordinates */ - std::array<amrex::Real,3> LowerCornerWithGalilean (const amrex::Box& bx, const amrex::Vector<amrex::Real>& v_galilean, int lev); + static std::array<amrex::Real,3> UpperCorner (const amrex::Box& bx, const int lev, const amrex::Real time_shift_delta); static amrex::IntVect RefRatio (int lev); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 827f7fb1c..3d11074df 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -1224,6 +1224,9 @@ WarpX::ReadParameters () if (m_v_comoving[0] != 0. || m_v_comoving[1] != 0. || m_v_comoving[2] != 0.) { amrex::Abort("Esirkepov current deposition cannot be used with the comoving PSATD algorithm"); } + if (m_v_galilean[0] != 0. || m_v_galilean[1] != 0. || m_v_galilean[2] != 0.) { + amrex::Abort("Esirkepov current deposition cannot be used with the Galilean algorithm."); + } } if (current_deposition_algo == CurrentDepositionAlgo::Vay) { @@ -2206,12 +2209,19 @@ WarpX::getRealBox(const Box& bx, int lev) } std::array<Real,3> -WarpX::LowerCorner(const Box& bx, std::array<amrex::Real,3> galilean_shift, int lev) +WarpX::LowerCorner(const Box& bx, const int lev, const amrex::Real time_shift_delta) { + auto & warpx = GetInstance(); RealBox grid_box = getRealBox( bx, lev ); const Real* xyzmin = grid_box.lo(); + amrex::Real cur_time = warpx.gett_new(lev); + amrex::Real time_shift = (cur_time + time_shift_delta - warpx.time_of_last_gal_shift); + amrex::Array<amrex::Real,3> galilean_shift = { warpx.m_v_galilean[0]*time_shift, + warpx.m_v_galilean[1]*time_shift, + warpx.m_v_galilean[2]*time_shift }; + #if defined(WARPX_DIM_3D) return { xyzmin[0] + galilean_shift[0], xyzmin[1] + galilean_shift[1], xyzmin[2] + galilean_shift[2] }; @@ -2224,28 +2234,30 @@ WarpX::LowerCorner(const Box& bx, std::array<amrex::Real,3> galilean_shift, int } std::array<Real,3> -WarpX::UpperCorner(const Box& bx, int lev) +WarpX::UpperCorner(const Box& bx, const int lev, const amrex::Real time_shift_delta) { + auto & warpx = GetInstance(); const RealBox grid_box = getRealBox( bx, lev ); + const Real* xyzmax = grid_box.hi(); + + amrex::Real cur_time = warpx.gett_new(lev); + amrex::Real time_shift = (cur_time + time_shift_delta - warpx.time_of_last_gal_shift); + amrex::Array<amrex::Real,3> galilean_shift = { warpx.m_v_galilean[0]*time_shift, + warpx.m_v_galilean[1]*time_shift, + warpx.m_v_galilean[2]*time_shift }; + #if defined(WARPX_DIM_3D) - return { xyzmax[0], xyzmax[1], xyzmax[2] }; + return { xyzmax[0] + galilean_shift[0], xyzmax[1] + galilean_shift[1], xyzmax[2] + galilean_shift[2] }; + #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) - return { xyzmax[0], std::numeric_limits<Real>::max(), xyzmax[1] }; + return { xyzmax[0] + galilean_shift[0], std::numeric_limits<Real>::max(), xyzmax[1] + galilean_shift[1] }; + #elif defined(WARPX_DIM_1D_Z) - return { std::numeric_limits<Real>::max(), std::numeric_limits<Real>::max(), xyzmax[0] }; + return { std::numeric_limits<Real>::max(), std::numeric_limits<Real>::max(), xyzmax[0] + galilean_shift[0] }; #endif } -std::array<Real,3> -WarpX::LowerCornerWithGalilean (const Box& bx, const amrex::Vector<amrex::Real>& v_galilean, int lev) -{ - amrex::Real cur_time = gett_new(lev); - amrex::Real time_shift = (cur_time - time_of_last_gal_shift); - amrex::Array<amrex::Real,3> galilean_shift = { v_galilean[0]*time_shift, v_galilean[1]*time_shift, v_galilean[2]*time_shift }; - return WarpX::LowerCorner(bx, galilean_shift, lev); -} - IntVect WarpX::RefRatio (int lev) { |