From 35fa3960ed031fc3229481596acedadf9663ae3a Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:12:22 -0700 Subject: [PATCH 01/12] Fix typo bugs in `WarpX::InitFromCheckpoint` --- Source/Diagnostics/WarpXIO.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp index a572eaa2ed3..26e7a025ff2 100644 --- a/Source/Diagnostics/WarpXIO.cpp +++ b/Source/Diagnostics/WarpXIO.cpp @@ -339,18 +339,18 @@ WarpX::InitFromCheckpoint () if (lev > 0) { - VisMF::Read(*m_fields.get("Efield_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get("Efield_cp", Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ex_cp")); - VisMF::Read(*m_fields.get("Efield_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get("Efield_cp", Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ey_cp")); - VisMF::Read(*m_fields.get("Efield_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get("Efield_cp", Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ez_cp")); - VisMF::Read(*m_fields.get("Bfield_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get("Bfield_cp", Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bx_cp")); - VisMF::Read(*m_fields.get("Bfield_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get("Bfield_cp", Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "By_cp")); - VisMF::Read(*m_fields.get("Bfield_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get("Bfield_cp", Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bz_cp")); if (WarpX::fft_do_time_averaging) From 2687d316788cb1c5b14d5ff59ac8d88171801709 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:20:45 -0700 Subject: [PATCH 02/12] Fix typo bug in `MultiParticleContainer::Evolve` --- Source/Particles/MultiParticleContainer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index a44808195e0..472461d3317 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -472,7 +472,7 @@ MultiParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, fields.get(current_fp_string, Direction{2}, lev)->setVal(0.0); if (fields.has("current_buf", Direction{0}, lev)) { fields.get("current_buf", Direction{0}, lev)->setVal(0.0); } if (fields.has("current_buf", Direction{1}, lev)) { fields.get("current_buf", Direction{1}, lev)->setVal(0.0); } - if (fields.has("current_buf", Direction{1}, lev)) { fields.get("current_buf", Direction{2}, lev)->setVal(0.0); } + if (fields.has("current_buf", Direction{2}, lev)) { fields.get("current_buf", Direction{2}, lev)->setVal(0.0); } if (fields.has("rho_fp", lev)) { fields.get("rho_fp", lev)->setVal(0.0); } if (fields.has("rho_buf", lev)) { fields.get("rho_buf", lev)->setVal(0.0); } } From a5a9895d2e3d3ec70e52d358ea665c14b7f51227 Mon Sep 17 00:00:00 2001 From: David Grote Date: Tue, 17 Sep 2024 14:20:00 -0700 Subject: [PATCH 03/12] Fix EvolvE for F_fp --- Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp index ac18b2f7fae..60fa68ff918 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp @@ -64,7 +64,7 @@ void FiniteDifferenceSolver::EvolveE ( fields.get_alldirs("current_fp", lev) : fields.get_alldirs("current_cp", lev); amrex::MultiFab* Ffield = nullptr; - if (fields.has("F_fp", Direction{0}, lev)) { + if (fields.has("F_fp", lev)) { Ffield = patch_type == PatchType::fine ? fields.get("F_fp", lev) : fields.get("F_cp", lev); } From 006db81b6ea952eceffb5a20f0380d3088ba446f Mon Sep 17 00:00:00 2001 From: David Grote Date: Tue, 17 Sep 2024 14:20:43 -0700 Subject: [PATCH 04/12] Fix typos in HybridPICModel --- .../FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp | 2 +- Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp index b05b9ae1562..07a4935a83b 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp @@ -539,7 +539,7 @@ void HybridPICModel::FillElectronPressureMF ( void HybridPICModel::BfieldEvolveRK ( ablastr::fields::MultiLevelVectorField const& Bfield, - ablastr::fields::MultiLevelVectorField const&Efield, + ablastr::fields::MultiLevelVectorField const& Efield, ablastr::fields::MultiLevelVectorField const& Jfield, ablastr::fields::MultiLevelScalarField const& rhofield, ablastr::fields::MultiLevelVectorField const& edge_lengths, diff --git a/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp b/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp index ea5517f31aa..a8d70d8d792 100644 --- a/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp +++ b/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp @@ -107,7 +107,7 @@ void WarpX::HybridPICEvolveFields () m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level), m_fields.get_mr_levels_alldirs("Efield_fp", finest_level), current_fp_temp, rho_fp_temp, - m_fields.get_mr_levels_alldirs("edge_lenghts", finest_level), + m_fields.get_mr_levels_alldirs("edge_lengths", finest_level), 0.5_rt/sub_steps*dt[0], DtType::FirstHalf, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points @@ -134,7 +134,7 @@ void WarpX::HybridPICEvolveFields () m_fields.get_mr_levels_alldirs("Efield_fp", finest_level), m_fields.get_mr_levels_alldirs("current_fp", finest_level), rho_fp_temp, - m_fields.get_mr_levels_alldirs("edge_lenghts", finest_level), + m_fields.get_mr_levels_alldirs("edge_lengths", finest_level), 0.5_rt/sub_steps*dt[0], DtType::SecondHalf, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points From cf86694826327e75f7ec0ea82b7d77d14ed57c9f Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:39:18 -0700 Subject: [PATCH 05/12] Fix typo bugs for averaged fields --- Source/WarpX.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 4efa58b8fee..29caaced9c4 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -2259,12 +2259,12 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (fft_do_time_averaging) { m_fields.alloc_init( "Bfield_avg_fp", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_avg_fp", Direction{1}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_avg_fp", Direction{2}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init( "Bfield_avg_fp", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init( "Bfield_avg_fp", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); m_fields.alloc_init( "Efield_avg_fp", Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_avg_fp", Direction{1}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_avg_fp", Direction{2}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init( "Efield_avg_fp", Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init( "Efield_avg_fp", Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } if (EB::enabled()) { From 0615220cbbdd5dfd5bb7f746cb78f4a203e30498 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:45:18 -0700 Subject: [PATCH 06/12] Fix typo bugs for averaged fields (coarse patch) --- Source/WarpX.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 29caaced9c4..55a8e3f2033 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -2588,12 +2588,12 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (fft_do_time_averaging) { m_fields.alloc_init("Bfield_avg_cp", Direction{0}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_avg_cp", Direction{1}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_avg_cp", Direction{2}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init("Bfield_avg_cp", Direction{1}, lev, amrex::convert(cba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init("Bfield_avg_cp", Direction{2}, lev, amrex::convert(cba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); m_fields.alloc_init("Efield_avg_cp", Direction{0}, lev, amrex::convert(cba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_avg_cp", Direction{1}, lev, amrex::convert(cba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_avg_cp", Direction{2}, lev, amrex::convert(cba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init("Efield_avg_cp", Direction{1}, lev, amrex::convert(cba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init("Efield_avg_cp", Direction{2}, lev, amrex::convert(cba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } // Create the MultiFabs for the current From 020088c2b307653f92f92cd2cacb4f600249710b Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:27:32 -0700 Subject: [PATCH 07/12] Remove redundant using-directive --- Source/Particles/PhysicalParticleContainer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 1ff712538ef..4cf6345c520 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1762,7 +1762,6 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, const iMultiFab* current_masks = WarpX::CurrentBufferMasks(lev); const iMultiFab* gather_masks = WarpX::GatherBufferMasks(lev); - using ablastr::fields::Direction; const bool has_rho = fields.has("rho_fp", lev); const bool has_cjx = fields.has("current_buf", Direction{0}, lev); const bool has_cEx = fields.has("Efield_cax", Direction{0}, lev); From e0eb5bcdce2b711b80f74f88652c305b85766f21 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:32:20 -0700 Subject: [PATCH 08/12] Fix clang-tidy error --- Source/ablastr/fields/MultiFabRegister.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/ablastr/fields/MultiFabRegister.cpp b/Source/ablastr/fields/MultiFabRegister.cpp index 25b0505e197..c290266176e 100644 --- a/Source/ablastr/fields/MultiFabRegister.cpp +++ b/Source/ablastr/fields/MultiFabRegister.cpp @@ -569,10 +569,11 @@ namespace ablastr::fields // C++20: Replace with std::erase_if for (auto first = m_mf_register.begin(), last = m_mf_register.end(); first != last;) { - if (first->second.m_level == level) + if (first->second.m_level == level) { first = m_mf_register.erase(first); - else + } else { ++first; + } } } From c5571bd9d4491eb812a58bd98607b0d3d97cca59 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:35:00 -0700 Subject: [PATCH 09/12] Fix clang-tidy error --- Source/WarpX.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 55a8e3f2033..cabe71cc54f 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -2530,9 +2530,9 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm } if (mypc->m_B_ext_particle_s == "read_from_file") { // These fields will be added to the fields that the particles see, and need to match the index type - auto Bfield_aux_levl_0 = m_fields.get("Bfield_aux", Direction{0}, lev); - auto Bfield_aux_levl_1 = m_fields.get("Bfield_aux", Direction{1}, lev); - auto Bfield_aux_levl_2 = m_fields.get("Bfield_aux", Direction{2}, lev); + auto *Bfield_aux_levl_0 = m_fields.get("Bfield_aux", Direction{0}, lev); + auto *Bfield_aux_levl_1 = m_fields.get("Bfield_aux", Direction{1}, lev); + auto *Bfield_aux_levl_2 = m_fields.get("Bfield_aux", Direction{2}, lev); // Same as Bfield_fp for reading external field data m_fields.alloc_init( "B_external_particle_field", Direction{0}, lev, amrex::convert(ba, Bfield_aux_levl_0->ixType()), @@ -2553,9 +2553,9 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm } if (mypc->m_E_ext_particle_s == "read_from_file") { // These fields will be added to the fields that the particles see, and need to match the index type - auto Efield_aux_levl_0 = m_fields.get("Efield_aux", Direction{0}, lev); - auto Efield_aux_levl_1 = m_fields.get("Efield_aux", Direction{1}, lev); - auto Efield_aux_levl_2 = m_fields.get("Efield_aux", Direction{2}, lev); + auto *Efield_aux_levl_0 = m_fields.get("Efield_aux", Direction{0}, lev); + auto *Efield_aux_levl_1 = m_fields.get("Efield_aux", Direction{1}, lev); + auto *Efield_aux_levl_2 = m_fields.get("Efield_aux", Direction{2}, lev); // Same as Efield_fp for reading external field data m_fields.alloc_init( "E_external_particle_field", Direction{0}, lev, amrex::convert(ba, Efield_aux_levl_0->ixType()), From 4f499d00e29b139c85ac40b332e47b4e0c06d1c8 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Tue, 17 Sep 2024 17:50:37 -0700 Subject: [PATCH 10/12] Fix clang-tidy error --- Source/WarpX.H | 2 +- Source/WarpX.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WarpX.H b/Source/WarpX.H index 40ad6f031c3..45ffa150c3d 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -485,7 +485,7 @@ public: * Set the dotMask container */ void SetDotMask( std::unique_ptr& field_dotMask, - std::string field_name, int lev, int dir ) const; + std::string const & field_name, int lev, int dir ) const; [[nodiscard]] bool DoPML () const {return do_pml;} [[nodiscard]] bool DoFluidSpecies () const {return do_fluid_species;} diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index cabe71cc54f..84fabec29c5 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -3410,7 +3410,7 @@ WarpX::getFieldDotMaskPointer ( FieldType field_type, int lev, int dir ) const } void WarpX::SetDotMask( std::unique_ptr& field_dotMask, - std::string field_name, int lev, int dir ) const + std::string const & field_name, int lev, int dir ) const { // Define the dot mask for this field_type needed to properly compute dotProduct() // for field values that have shared locations on different MPI ranks From 1400de536c03b7289aaf81c1a13afe23c9659769 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:54:10 -0700 Subject: [PATCH 11/12] Fix clang-tidy error --- Source/WarpX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 84fabec29c5..5457b633504 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -2966,14 +2966,14 @@ WarpX::ComputeDivE(amrex::MultiFab& divE, const int lev) { if ( WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD ) { #ifdef WARPX_USE_FFT - ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev); + const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev); spectral_solver_fp[lev]->ComputeSpectralDivE(lev, Efield_aux_lev, divE); #else WARPX_ABORT_WITH_MESSAGE( "ComputeDivE: PSATD requested but not compiled"); #endif } else { - ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev); + const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev); m_fdtd_solver_fp[lev]->ComputeDivE(Efield_aux_lev, divE); } } From 1dfeb9f0ff8b104502d31bfd8aa90827de58ea7a Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:57:33 -0700 Subject: [PATCH 12/12] Fix clang-tidy error --- .../FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H index 49d187431ce..a3656142384 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H @@ -322,7 +322,7 @@ class FiniteDifferenceSolver template< typename T_Algo > void EvolveBPMLCartesian ( std::array< amrex::MultiFab*, 3 > Bfield, - ablastr::fields::VectorField const Efield, + ablastr::fields::VectorField Efield, amrex::Real dt, bool dive_cleaning);