From 927934226a3cd22af851c61c7b47f15f31f76473 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 21 Sep 2024 14:30:46 -0700 Subject: [PATCH] Use `FieldType` Instead of Strings --- Source/BoundaryConditions/PML.cpp | 150 ++++---- Source/BoundaryConditions/PML_RZ.cpp | 58 ++-- Source/BoundaryConditions/WarpXEvolvePML.cpp | 37 +- .../WarpXFieldBoundaries.cpp | 60 ++-- Source/Diagnostics/BTDiagnostics.cpp | 42 +-- .../ComputeDiagFunctors/JFunctor.cpp | 6 +- .../ComputeDiagFunctors/JdispFunctor.cpp | 8 +- .../FlushFormats/FlushFormatCheckpoint.cpp | 62 ++-- .../FlushFormats/FlushFormatPlotfile.cpp | 94 ++--- Source/Diagnostics/FullDiagnostics.cpp | 92 ++--- Source/Diagnostics/ParticleIO.cpp | 4 +- .../Diagnostics/ReducedDiags/ChargeOnEB.cpp | 8 +- .../ReducedDiags/ColliderRelevant.cpp | 14 +- .../Diagnostics/ReducedDiags/FieldEnergy.cpp | 14 +- .../Diagnostics/ReducedDiags/FieldMaximum.cpp | 14 +- .../ReducedDiags/FieldMomentum.cpp | 14 +- .../Diagnostics/ReducedDiags/FieldProbe.cpp | 14 +- .../Diagnostics/ReducedDiags/FieldReduction.H | 19 +- .../ReducedDiags/LoadBalanceCosts.cpp | 4 +- .../ReducedDiags/ParticleExtrema.cpp | 14 +- Source/Diagnostics/SliceDiagnostic.cpp | 14 +- Source/Diagnostics/WarpXIO.cpp | 78 ++--- .../EmbeddedBoundary/WarpXFaceExtensions.cpp | 44 +-- Source/EmbeddedBoundary/WarpXInitEB.cpp | 20 +- Source/Evolve/WarpXEvolve.cpp | 173 +++++----- .../ElectrostaticSolver.cpp | 18 +- .../LabFrameExplicitES.cpp | 10 +- .../RelativisticExplicitES.cpp | 14 +- .../FiniteDifferenceSolver/EvolveB.cpp | 30 +- .../FiniteDifferenceSolver/EvolveBPML.cpp | 6 +- .../FiniteDifferenceSolver/EvolveE.cpp | 27 +- .../FiniteDifferenceSolver/EvolveEPML.cpp | 17 +- .../HybridPICModel/HybridPICModel.cpp | 66 ++-- .../MacroscopicProperties.cpp | 2 +- .../ImplicitSolvers/SemiImplicitEM.cpp | 2 +- .../ImplicitSolvers/ThetaImplicitEM.cpp | 26 +- .../ImplicitSolvers/WarpXImplicitOps.cpp | 12 +- .../ImplicitSolvers/WarpXSolverVec.cpp | 6 +- .../MagnetostaticSolver.cpp | 25 +- Source/FieldSolver/WarpXPushFieldsEM.cpp | 114 ++++--- .../FieldSolver/WarpXPushFieldsHybridPIC.cpp | 67 ++-- Source/FieldSolver/WarpXSolveFieldsES.cpp | 8 +- .../FieldSolver/WarpX_QED_Field_Pushers.cpp | 38 ++- Source/Fluids/WarpXFluidContainer.cpp | 31 +- .../DivCleaner/ProjectionDivCleaner.cpp | 14 +- Source/Initialization/WarpXInitData.cpp | 181 +++++----- Source/Parallelization/WarpXComm.cpp | 320 +++++++++--------- Source/Parallelization/WarpXRegrid.cpp | 8 +- Source/Particles/LaserParticleContainer.cpp | 22 +- Source/Particles/MultiParticleContainer.cpp | 24 +- .../Particles/PhysicalParticleContainer.cpp | 54 +-- Source/Particles/WarpXParticleContainer.cpp | 4 +- Source/Utils/WarpXMovingWindow.cpp | 70 ++-- Source/WarpX.H | 5 +- Source/WarpX.cpp | 315 ++++++++--------- 55 files changed, 1346 insertions(+), 1247 deletions(-) diff --git a/Source/BoundaryConditions/PML.cpp b/Source/BoundaryConditions/PML.cpp index d905bf64d1f..f1afb501ceb 100644 --- a/Source/BoundaryConditions/PML.cpp +++ b/Source/BoundaryConditions/PML.cpp @@ -57,7 +57,7 @@ #endif using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -703,33 +703,33 @@ PML::PML (const int lev, const BoxArray& grid_ba, auto& warpx = WarpX::GetInstance(); using ablastr::fields::Direction; - const amrex::BoxArray ba_Ex = amrex::convert(ba, warpx.m_fields.get("Efield_fp",Direction{0},0)->ixType().toIntVect()); - const amrex::BoxArray ba_Ey = amrex::convert(ba, warpx.m_fields.get("Efield_fp",Direction{1},0)->ixType().toIntVect()); - const amrex::BoxArray ba_Ez = amrex::convert(ba, warpx.m_fields.get("Efield_fp",Direction{2},0)->ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_E_fp", Direction{0}, lev, ba_Ex, dm, ncompe, nge, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_E_fp", Direction{1}, lev, ba_Ey, dm, ncompe, nge, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_E_fp", Direction{2}, lev, ba_Ez, dm, ncompe, nge, 0.0_rt, false, false); - - const amrex::BoxArray ba_Bx = amrex::convert(ba, warpx.m_fields.get("Bfield_fp",Direction{0},0)->ixType().toIntVect()); - const amrex::BoxArray ba_By = amrex::convert(ba, warpx.m_fields.get("Bfield_fp",Direction{1},0)->ixType().toIntVect()); - const amrex::BoxArray ba_Bz = amrex::convert(ba, warpx.m_fields.get("Bfield_fp",Direction{2},0)->ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_B_fp", Direction{0}, lev, ba_Bx, dm, ncompb, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_B_fp", Direction{1}, lev, ba_By, dm, ncompb, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_B_fp", Direction{2}, lev, ba_Bz, dm, ncompb, ngb, 0.0_rt, false, false); - - const amrex::BoxArray ba_jx = amrex::convert(ba, WarpX::GetInstance().m_fields.get("current_fp", Direction{0}, 0)->ixType().toIntVect()); - const amrex::BoxArray ba_jy = amrex::convert(ba, WarpX::GetInstance().m_fields.get("current_fp", Direction{1}, 0)->ixType().toIntVect()); - const amrex::BoxArray ba_jz = amrex::convert(ba, WarpX::GetInstance().m_fields.get("current_fp", Direction{2}, 0)->ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_j_fp", Direction{0}, lev, ba_jx, dm, 1, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_j_fp", Direction{1}, lev, ba_jy, dm, 1, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_j_fp", Direction{2}, lev, ba_jz, dm, 1, ngb, 0.0_rt, false, false); + const amrex::BoxArray ba_Ex = amrex::convert(ba, warpx.m_fields.get(FieldType::Efield_fp,Direction{0},0)->ixType().toIntVect()); + const amrex::BoxArray ba_Ey = amrex::convert(ba, warpx.m_fields.get(FieldType::Efield_fp,Direction{1},0)->ixType().toIntVect()); + const amrex::BoxArray ba_Ez = amrex::convert(ba, warpx.m_fields.get(FieldType::Efield_fp,Direction{2},0)->ixType().toIntVect()); + warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{0}, lev, ba_Ex, dm, ncompe, nge, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{1}, lev, ba_Ey, dm, ncompe, nge, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{2}, lev, ba_Ez, dm, ncompe, nge, 0.0_rt, false, false); + + const amrex::BoxArray ba_Bx = amrex::convert(ba, warpx.m_fields.get(FieldType::Bfield_fp,Direction{0},0)->ixType().toIntVect()); + const amrex::BoxArray ba_By = amrex::convert(ba, warpx.m_fields.get(FieldType::Bfield_fp,Direction{1},0)->ixType().toIntVect()); + const amrex::BoxArray ba_Bz = amrex::convert(ba, warpx.m_fields.get(FieldType::Bfield_fp,Direction{2},0)->ixType().toIntVect()); + warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{0}, lev, ba_Bx, dm, ncompb, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{1}, lev, ba_By, dm, ncompb, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{2}, lev, ba_Bz, dm, ncompb, ngb, 0.0_rt, false, false); + + const amrex::BoxArray ba_jx = amrex::convert(ba, WarpX::GetInstance().m_fields.get(FieldType::current_fp, Direction{0}, 0)->ixType().toIntVect()); + const amrex::BoxArray ba_jy = amrex::convert(ba, WarpX::GetInstance().m_fields.get(FieldType::current_fp, Direction{1}, 0)->ixType().toIntVect()); + const amrex::BoxArray ba_jz = amrex::convert(ba, WarpX::GetInstance().m_fields.get(FieldType::current_fp, Direction{2}, 0)->ixType().toIntVect()); + warpx.m_fields.alloc_init(FieldType::pml_j_fp, Direction{0}, lev, ba_jx, dm, 1, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_j_fp, Direction{1}, lev, ba_jy, dm, 1, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_j_fp, Direction{2}, lev, ba_jz, dm, 1, ngb, 0.0_rt, false, false); #ifdef AMREX_USE_EB if (eb_enabled) { const amrex::IntVect max_guard_EB_vect = amrex::IntVect(max_guard_EB); - warpx.m_fields.alloc_init("pml_edge_lengths", Direction{0}, lev, ba_Ex, dm, WarpX::ncomps, max_guard_EB_vect, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_edge_lengths", Direction{1}, lev, ba_Ey, dm, WarpX::ncomps, max_guard_EB_vect, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_edge_lengths", Direction{2}, lev, ba_Ez, dm, WarpX::ncomps, max_guard_EB_vect, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_edge_lengths, Direction{0}, lev, ba_Ex, dm, WarpX::ncomps, max_guard_EB_vect, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_edge_lengths, Direction{1}, lev, ba_Ey, dm, WarpX::ncomps, max_guard_EB_vect, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_edge_lengths, Direction{2}, lev, ba_Ez, dm, WarpX::ncomps, max_guard_EB_vect, 0.0_rt, false, false); if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::Yee || WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::CKC || @@ -737,7 +737,7 @@ PML::PML (const int lev, const BoxArray& grid_ba, auto const eb_fact = fieldEBFactory(); - ablastr::fields::VectorField t_pml_edge_lengths = warpx.m_fields.get_alldirs("pml_edge_lengths", lev); + ablastr::fields::VectorField t_pml_edge_lengths = warpx.m_fields.get_alldirs(FieldType::pml_edge_lengths, lev); WarpX::ComputeEdgeLengths(t_pml_edge_lengths, eb_fact); WarpX::ScaleEdges(t_pml_edge_lengths, WarpX::CellSize(lev)); @@ -749,7 +749,7 @@ PML::PML (const int lev, const BoxArray& grid_ba, if (m_dive_cleaning) { const amrex::BoxArray ba_F_nodal = amrex::convert(ba, amrex::IntVect::TheNodeVector()); - warpx.m_fields.alloc_init("pml_F_fp", lev, ba_F_nodal, dm, 3, ngf, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_F_fp, lev, ba_F_nodal, dm, 3, ngf, 0.0_rt, false, false); } if (m_divb_cleaning) @@ -759,7 +759,7 @@ PML::PML (const int lev, const BoxArray& grid_ba, (grid_type == GridType::Collocated) ? amrex::IntVect::TheNodeVector() : amrex::IntVect::TheCellVector(); const amrex::BoxArray ba_G_nodal = amrex::convert(ba, G_nodal_flag); - warpx.m_fields.alloc_init("pml_G_fp", lev, ba_G_nodal, dm, 3, ngf, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_G_fp, lev, ba_G_nodal, dm, 3, ngf, 0.0_rt, false, false); } Box single_domain_box = is_single_box_domain ? domain0 : Box(); @@ -841,24 +841,24 @@ PML::PML (const int lev, const BoxArray& grid_ba, cdm.define(cba); } - const amrex::BoxArray cba_Ex = amrex::convert(cba, WarpX::GetInstance().m_fields.get("Efield_cp", Direction{0}, 1)->ixType().toIntVect()); - const amrex::BoxArray cba_Ey = amrex::convert(cba, WarpX::GetInstance().m_fields.get("Efield_cp", Direction{1}, 1)->ixType().toIntVect()); - const amrex::BoxArray cba_Ez = amrex::convert(cba, WarpX::GetInstance().m_fields.get("Efield_cp", Direction{2}, 1)->ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_E_cp", Direction{0}, lev, cba_Ex, cdm, ncompe, nge, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_E_cp", Direction{1}, lev, cba_Ey, cdm, ncompe, nge, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_E_cp", Direction{2}, lev, cba_Ez, cdm, ncompe, nge, 0.0_rt, false, false); + const amrex::BoxArray cba_Ex = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Efield_cp, Direction{0}, 1)->ixType().toIntVect()); + const amrex::BoxArray cba_Ey = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Efield_cp, Direction{1}, 1)->ixType().toIntVect()); + const amrex::BoxArray cba_Ez = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Efield_cp, Direction{2}, 1)->ixType().toIntVect()); + warpx.m_fields.alloc_init(FieldType::pml_E_cp, Direction{0}, lev, cba_Ex, cdm, ncompe, nge, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_E_cp, Direction{1}, lev, cba_Ey, cdm, ncompe, nge, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_E_cp, Direction{2}, lev, cba_Ez, cdm, ncompe, nge, 0.0_rt, false, false); - const amrex::BoxArray cba_Bx = amrex::convert(cba, WarpX::GetInstance().m_fields.get("Bfield_cp", Direction{0}, 1)->ixType().toIntVect()); - const amrex::BoxArray cba_By = amrex::convert(cba, WarpX::GetInstance().m_fields.get("Bfield_cp", Direction{1}, 1)->ixType().toIntVect()); - const amrex::BoxArray cba_Bz = amrex::convert(cba, WarpX::GetInstance().m_fields.get("Bfield_cp", Direction{2}, 1)->ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_B_cp", Direction{0}, lev, cba_Bx, cdm, ncompb, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_B_cp", Direction{1}, lev, cba_By, cdm, ncompb, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_B_cp", Direction{2}, lev, cba_Bz, cdm, ncompb, ngb, 0.0_rt, false, false); + const amrex::BoxArray cba_Bx = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Bfield_cp, Direction{0}, 1)->ixType().toIntVect()); + const amrex::BoxArray cba_By = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Bfield_cp, Direction{1}, 1)->ixType().toIntVect()); + const amrex::BoxArray cba_Bz = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Bfield_cp, Direction{2}, 1)->ixType().toIntVect()); + warpx.m_fields.alloc_init(FieldType::pml_B_cp, Direction{0}, lev, cba_Bx, cdm, ncompb, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_B_cp, Direction{1}, lev, cba_By, cdm, ncompb, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_B_cp, Direction{2}, lev, cba_Bz, cdm, ncompb, ngb, 0.0_rt, false, false); if (m_dive_cleaning) { const amrex::BoxArray cba_F_nodal = amrex::convert(cba, amrex::IntVect::TheNodeVector()); - warpx.m_fields.alloc_init("pml_F_cp", lev, cba_F_nodal, cdm, 3, ngf, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_F_cp, lev, cba_F_nodal, cdm, 3, ngf, 0.0_rt, false, false); } if (m_divb_cleaning) @@ -868,15 +868,15 @@ PML::PML (const int lev, const BoxArray& grid_ba, (grid_type == GridType::Collocated) ? amrex::IntVect::TheNodeVector() : amrex::IntVect::TheCellVector(); const amrex::BoxArray cba_G_nodal = amrex::convert(cba, G_nodal_flag); - warpx.m_fields.alloc_init("pml_G_cp", lev, cba_G_nodal, cdm, 3, ngf, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_G_cp, lev, cba_G_nodal, cdm, 3, ngf, 0.0_rt, false, false); } - const amrex::BoxArray cba_jx = amrex::convert(cba, WarpX::GetInstance().m_fields.get("current_cp", Direction{0}, 1)->ixType().toIntVect()); - const amrex::BoxArray cba_jy = amrex::convert(cba, WarpX::GetInstance().m_fields.get("current_cp", Direction{1}, 1)->ixType().toIntVect()); - const amrex::BoxArray cba_jz = amrex::convert(cba, WarpX::GetInstance().m_fields.get("current_cp", Direction{2}, 1)->ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_j_cp", Direction{0}, lev, cba_jx, cdm, 1, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_j_cp", Direction{1}, lev, cba_jy, cdm, 1, ngb, 0.0_rt, false, false); - warpx.m_fields.alloc_init("pml_j_cp", Direction{2}, lev, cba_jz, cdm, 1, ngb, 0.0_rt, false, false); + const amrex::BoxArray cba_jx = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::current_cp, Direction{0}, 1)->ixType().toIntVect()); + const amrex::BoxArray cba_jy = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::current_cp, Direction{1}, 1)->ixType().toIntVect()); + const amrex::BoxArray cba_jz = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::current_cp, Direction{2}, 1)->ixType().toIntVect()); + warpx.m_fields.alloc_init(FieldType::pml_j_cp, Direction{0}, lev, cba_jx, cdm, 1, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_j_cp, Direction{1}, lev, cba_jy, cdm, 1, ngb, 0.0_rt, false, false); + warpx.m_fields.alloc_init(FieldType::pml_j_cp, Direction{2}, lev, cba_jz, cdm, 1, ngb, 0.0_rt, false, false); single_domain_box = is_single_box_domain ? cdomain : Box(); sigba_cp = std::make_unique(cba, cdm, grid_cba_reduced, cgeom->CellSize(), @@ -1060,23 +1060,23 @@ PML::CopyJtoPMLs ( { using ablastr::fields::Direction; - bool const has_j_fp = fields.has("current_fp", Direction{0}, lev); - bool const has_pml_j_fp = fields.has("pml_j_fp", Direction{0}, lev); - bool const has_j_cp = fields.has("current_cp", Direction{0}, lev); - bool const has_pml_j_cp = fields.has("pml_j_cp", Direction{0}, lev); + bool const has_j_fp = fields.has(FieldType::current_fp, Direction{0}, lev); + bool const has_pml_j_fp = fields.has(FieldType::pml_j_fp, Direction{0}, lev); + bool const has_j_cp = fields.has(FieldType::current_cp, Direction{0}, lev); + bool const has_pml_j_cp = fields.has(FieldType::pml_j_cp, Direction{0}, lev); if (patch_type == PatchType::fine && has_pml_j_fp && has_j_fp) { - ablastr::fields::VectorField pml_j_fp = fields.get_alldirs("pml_j_fp", lev); - ablastr::fields::VectorField jp = fields.get_alldirs("current_fp", lev); + ablastr::fields::VectorField pml_j_fp = fields.get_alldirs(FieldType::pml_j_fp, lev); + ablastr::fields::VectorField jp = fields.get_alldirs(FieldType::current_fp, lev); CopyToPML(*pml_j_fp[0], *jp[0], *m_geom); CopyToPML(*pml_j_fp[1], *jp[1], *m_geom); CopyToPML(*pml_j_fp[2], *jp[2], *m_geom); } else if (patch_type == PatchType::coarse && has_j_cp && has_pml_j_cp) { - ablastr::fields::VectorField pml_j_cp = fields.get_alldirs("pml_j_cp", lev); - ablastr::fields::VectorField jp = fields.get_alldirs("current_cp", lev); + ablastr::fields::VectorField pml_j_cp = fields.get_alldirs(FieldType::pml_j_cp, lev); + ablastr::fields::VectorField jp = fields.get_alldirs(FieldType::current_cp, lev); CopyToPML(*pml_j_cp[0], *jp[0], *m_cgeom); CopyToPML(*pml_j_cp[1], *jp[1], *m_cgeom); CopyToPML(*pml_j_cp[2], *jp[2], *m_cgeom); @@ -1234,10 +1234,10 @@ PML::CheckPoint ( { using ablastr::fields::Direction; - if (fields.has("pml_E_fp", Direction{0}, 0)) + if (fields.has(FieldType::pml_E_fp, Direction{0}, 0)) { - ablastr::fields::VectorField pml_E_fp = fields.get_alldirs("pml_E_fp", 0); - ablastr::fields::VectorField pml_B_fp = fields.get_alldirs("pml_B_fp", 0); + ablastr::fields::VectorField pml_E_fp = fields.get_alldirs(FieldType::pml_E_fp, 0); + ablastr::fields::VectorField pml_B_fp = fields.get_alldirs(FieldType::pml_B_fp, 0); VisMF::AsyncWrite(*pml_E_fp[0], dir+"_Ex_fp"); VisMF::AsyncWrite(*pml_E_fp[1], dir+"_Ey_fp"); VisMF::AsyncWrite(*pml_E_fp[2], dir+"_Ez_fp"); @@ -1246,10 +1246,10 @@ PML::CheckPoint ( VisMF::AsyncWrite(*pml_B_fp[2], dir+"_Bz_fp"); } - if (fields.has("pml_E_cp", Direction{0}, 0)) + if (fields.has(FieldType::pml_E_cp, Direction{0}, 0)) { - ablastr::fields::VectorField pml_E_cp = fields.get_alldirs("pml_E_cp", 0); - ablastr::fields::VectorField pml_B_cp = fields.get_alldirs("pml_B_cp", 0); + ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, 0); + ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, 0); VisMF::AsyncWrite(*pml_E_cp[0], dir+"_Ex_cp"); VisMF::AsyncWrite(*pml_E_cp[1], dir+"_Ey_cp"); VisMF::AsyncWrite(*pml_E_cp[2], dir+"_Ez_cp"); @@ -1267,10 +1267,10 @@ PML::Restart ( { using ablastr::fields::Direction; - if (fields.has("pml_E_fp", Direction{0}, 0)) + if (fields.has(FieldType::pml_E_fp, Direction{0}, 0)) { - ablastr::fields::VectorField pml_E_fp = fields.get_alldirs("pml_E_fp", 0); - ablastr::fields::VectorField pml_B_fp = fields.get_alldirs("pml_B_fp", 0); + ablastr::fields::VectorField pml_E_fp = fields.get_alldirs(FieldType::pml_E_fp, 0); + ablastr::fields::VectorField pml_B_fp = fields.get_alldirs(FieldType::pml_B_fp, 0); VisMF::Read(*pml_E_fp[0], dir+"_Ex_fp"); VisMF::Read(*pml_E_fp[1], dir+"_Ey_fp"); VisMF::Read(*pml_E_fp[2], dir+"_Ez_fp"); @@ -1279,10 +1279,10 @@ PML::Restart ( VisMF::Read(*pml_B_fp[2], dir+"_Bz_fp"); } - if (fields.has("pml_E_cp", Direction{0}, 0)) + if (fields.has(FieldType::pml_E_cp, Direction{0}, 0)) { - ablastr::fields::VectorField pml_E_cp = fields.get_alldirs("pml_E_cp", 0); - ablastr::fields::VectorField pml_B_cp = fields.get_alldirs("pml_B_cp", 0); + ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, 0); + ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, 0); VisMF::Read(*pml_E_cp[0], dir+"_Ex_cp"); VisMF::Read(*pml_E_cp[1], dir+"_Ey_cp"); VisMF::Read(*pml_E_cp[2], dir+"_Ez_cp"); @@ -1296,18 +1296,18 @@ PML::Restart ( void PML::PushPSATD (ablastr::fields::MultiFabRegister& fields, const int lev) { - ablastr::fields::VectorField pml_E_fp = fields.get_alldirs("pml_E_fp", lev); - ablastr::fields::VectorField pml_B_fp = fields.get_alldirs("pml_B_fp", lev); - ablastr::fields::ScalarField pml_F_fp = fields.get("pml_F_fp", lev); - ablastr::fields::ScalarField pml_G_fp = fields.get("pml_G_fp", lev); + ablastr::fields::VectorField pml_E_fp = fields.get_alldirs(FieldType::pml_E_fp, lev); + ablastr::fields::VectorField pml_B_fp = fields.get_alldirs(FieldType::pml_B_fp, lev); + ablastr::fields::ScalarField pml_F_fp = fields.get(FieldType::pml_F_fp, lev); + ablastr::fields::ScalarField pml_G_fp = fields.get(FieldType::pml_G_fp, lev); // Update the fields on the fine and coarse patch PushPMLPSATDSinglePatch(lev, *spectral_solver_fp, pml_E_fp, pml_B_fp, pml_F_fp, pml_G_fp, m_fill_guards_fields); if (spectral_solver_cp) { - ablastr::fields::VectorField pml_E_cp = fields.get_alldirs("pml_E_cp", lev); - ablastr::fields::VectorField pml_B_cp = fields.get_alldirs("pml_B_cp", lev); - ablastr::fields::ScalarField pml_F_cp = fields.get("pml_F_cp", lev); - ablastr::fields::ScalarField pml_G_cp = fields.get("pml_G_cp", lev); + ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, lev); + ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, lev); + ablastr::fields::ScalarField pml_F_cp = fields.get(FieldType::pml_F_cp, lev); + ablastr::fields::ScalarField pml_G_cp = fields.get(FieldType::pml_G_cp, lev); PushPMLPSATDSinglePatch(lev, *spectral_solver_cp, pml_E_cp, pml_B_cp, pml_F_cp, pml_G_cp, m_fill_guards_fields); } } diff --git a/Source/BoundaryConditions/PML_RZ.cpp b/Source/BoundaryConditions/PML_RZ.cpp index b8875be734f..dfdbdc00d98 100644 --- a/Source/BoundaryConditions/PML_RZ.cpp +++ b/Source/BoundaryConditions/PML_RZ.cpp @@ -34,7 +34,7 @@ #include using namespace amrex::literals; -using namespace warpx::fields; +using warpx::fields::FieldType; using ablastr::fields::Direction; PML_RZ::PML_RZ (int lev, amrex::BoxArray const& grid_ba, amrex::DistributionMapping const& grid_dm, @@ -48,22 +48,22 @@ PML_RZ::PML_RZ (int lev, amrex::BoxArray const& grid_ba, amrex::DistributionMapp bool const remake = false; bool const redistribute_on_remake = false; - amrex::MultiFab const& Er_fp = *warpx.m_fields.get("Efield_fp",Direction{0},lev); - amrex::MultiFab const& Et_fp = *warpx.m_fields.get("Efield_fp",Direction{1},lev); + amrex::MultiFab const& Er_fp = *warpx.m_fields.get(FieldType::Efield_fp,Direction{0},lev); + amrex::MultiFab const& Et_fp = *warpx.m_fields.get(FieldType::Efield_fp,Direction{1},lev); amrex::BoxArray const ba_Er = amrex::convert(grid_ba, Er_fp.ixType().toIntVect()); amrex::BoxArray const ba_Et = amrex::convert(grid_ba, Et_fp.ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_E_fp", Direction{0}, lev, ba_Er, grid_dm, Er_fp.nComp(), Er_fp.nGrowVect(), 0.0_rt, + warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{0}, lev, ba_Er, grid_dm, Er_fp.nComp(), Er_fp.nGrowVect(), 0.0_rt, remake, redistribute_on_remake); - warpx.m_fields.alloc_init("pml_E_fp", Direction{1}, lev, ba_Et, grid_dm, Et_fp.nComp(), Et_fp.nGrowVect(), 0.0_rt, + warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{1}, lev, ba_Et, grid_dm, Et_fp.nComp(), Et_fp.nGrowVect(), 0.0_rt, remake, redistribute_on_remake); - amrex::MultiFab const& Br_fp = *warpx.m_fields.get("Bfield_fp",Direction{0},lev); - amrex::MultiFab const& Bt_fp = *warpx.m_fields.get("Bfield_fp",Direction{1},lev); + amrex::MultiFab const& Br_fp = *warpx.m_fields.get(FieldType::Bfield_fp,Direction{0},lev); + amrex::MultiFab const& Bt_fp = *warpx.m_fields.get(FieldType::Bfield_fp,Direction{1},lev); amrex::BoxArray const ba_Br = amrex::convert(grid_ba, Br_fp.ixType().toIntVect()); amrex::BoxArray const ba_Bt = amrex::convert(grid_ba, Bt_fp.ixType().toIntVect()); - warpx.m_fields.alloc_init("pml_B_fp", Direction{0}, lev, ba_Br, grid_dm, Br_fp.nComp(), Br_fp.nGrowVect(), 0.0_rt, + warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{0}, lev, ba_Br, grid_dm, Br_fp.nComp(), Br_fp.nGrowVect(), 0.0_rt, remake, redistribute_on_remake); - warpx.m_fields.alloc_init("pml_B_fp", Direction{1}, lev, ba_Bt, grid_dm, Bt_fp.nComp(), Bt_fp.nGrowVect(), 0.0_rt, + warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{1}, lev, ba_Bt, grid_dm, Bt_fp.nComp(), Bt_fp.nGrowVect(), 0.0_rt, remake, redistribute_on_remake); } @@ -77,8 +77,8 @@ PML_RZ::ApplyDamping (amrex::MultiFab* Et_fp, amrex::MultiFab* Ez_fp, amrex::Real const dr = m_geom->CellSize(0); amrex::Real const cdt_over_dr = PhysConst::c*dt/dr; - amrex::MultiFab* pml_Et = fields.get("pml_E_fp", Direction{1}, 0); - amrex::MultiFab* pml_Bt = fields.get("pml_B_fp", Direction{1}, 0); + amrex::MultiFab* pml_Et = fields.get(FieldType::pml_E_fp, Direction{1}, 0); + amrex::MultiFab* pml_Bt = fields.get(FieldType::pml_B_fp, Direction{1}, 0); #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) @@ -132,8 +132,8 @@ PML_RZ::ApplyDamping (amrex::MultiFab* Et_fp, amrex::MultiFab* Ez_fp, void PML_RZ::FillBoundaryE (ablastr::fields::MultiFabRegister& fields, PatchType patch_type, std::optional nodal_sync) { - amrex::MultiFab * pml_Er = fields.get("pml_E_fp", Direction{0}, 0); - amrex::MultiFab * pml_Et = fields.get("pml_E_fp", Direction{1}, 0); + amrex::MultiFab * pml_Er = fields.get(FieldType::pml_E_fp, Direction{0}, 0); + amrex::MultiFab * pml_Et = fields.get(FieldType::pml_E_fp, Direction{1}, 0); if (patch_type == PatchType::fine && pml_Er->nGrowVect().max() > 0) { @@ -148,8 +148,8 @@ PML_RZ::FillBoundaryB (ablastr::fields::MultiFabRegister& fields, PatchType patc { if (patch_type == PatchType::fine) { - amrex::MultiFab * pml_Br = fields.get("pml_B_fp", Direction{0}, 0); - amrex::MultiFab * pml_Bt = fields.get("pml_B_fp", Direction{1}, 0); + amrex::MultiFab * pml_Br = fields.get(FieldType::pml_B_fp, Direction{0}, 0); + amrex::MultiFab * pml_Bt = fields.get(FieldType::pml_B_fp, Direction{1}, 0); amrex::Periodicity const& period = m_geom->periodicity(); const amrex::Vector mf = {pml_Br, pml_Bt}; @@ -160,22 +160,22 @@ PML_RZ::FillBoundaryB (ablastr::fields::MultiFabRegister& fields, PatchType patc void PML_RZ::CheckPoint (ablastr::fields::MultiFabRegister& fields, std::string const& dir) const { - if (fields.has("pml_E_fp", Direction{0}, 0)) { - amrex::VisMF::AsyncWrite(*fields.get("pml_E_fp", Direction{0}, 0), dir+"_Er_fp"); - amrex::VisMF::AsyncWrite(*fields.get("pml_E_fp", Direction{1}, 0), dir+"_Et_fp"); - amrex::VisMF::AsyncWrite(*fields.get("pml_B_fp", Direction{0}, 0), dir+"_Br_fp"); - amrex::VisMF::AsyncWrite(*fields.get("pml_B_fp", Direction{1}, 0), dir+"_Bt_fp"); + if (fields.has(FieldType::pml_E_fp, Direction{0}, 0)) { + amrex::VisMF::AsyncWrite(*fields.get(FieldType::pml_E_fp, Direction{0}, 0), dir+"_Er_fp"); + amrex::VisMF::AsyncWrite(*fields.get(FieldType::pml_E_fp, Direction{1}, 0), dir+"_Et_fp"); + amrex::VisMF::AsyncWrite(*fields.get(FieldType::pml_B_fp, Direction{0}, 0), dir+"_Br_fp"); + amrex::VisMF::AsyncWrite(*fields.get(FieldType::pml_B_fp, Direction{1}, 0), dir+"_Bt_fp"); } } void PML_RZ::Restart (ablastr::fields::MultiFabRegister& fields, std::string const& dir) { - if (fields.has("pml_E_fp", Direction{0}, 0)) { - amrex::VisMF::Read(*fields.get("pml_E_fp", Direction{0}, 0), dir+"_Er_fp"); - amrex::VisMF::Read(*fields.get("pml_E_fp", Direction{1}, 0), dir+"_Et_fp"); - amrex::VisMF::Read(*fields.get("pml_B_fp", Direction{0}, 0), dir+"_Br_fp"); - amrex::VisMF::Read(*fields.get("pml_B_fp", Direction{1}, 0), dir+"_Bt_fp"); + if (fields.has(FieldType::pml_E_fp, Direction{0}, 0)) { + amrex::VisMF::Read(*fields.get(FieldType::pml_E_fp, Direction{0}, 0), dir+"_Er_fp"); + amrex::VisMF::Read(*fields.get(FieldType::pml_E_fp, Direction{1}, 0), dir+"_Et_fp"); + amrex::VisMF::Read(*fields.get(FieldType::pml_B_fp, Direction{0}, 0), dir+"_Br_fp"); + amrex::VisMF::Read(*fields.get(FieldType::pml_B_fp, Direction{1}, 0), dir+"_Bt_fp"); } } @@ -196,10 +196,10 @@ PML_RZ::PushPMLPSATDSinglePatchRZ ( ablastr::fields::MultiFabRegister& fields) { SpectralFieldIndex const& Idx = solver.m_spectral_index; - amrex::MultiFab * pml_Er = fields.get("pml_E_fp", Direction{0}, 0); - amrex::MultiFab * pml_Et = fields.get("pml_E_fp", Direction{1}, 0); - amrex::MultiFab * pml_Br = fields.get("pml_B_fp", Direction{0}, 0); - amrex::MultiFab * pml_Bt = fields.get("pml_B_fp", Direction{1}, 0); + amrex::MultiFab * pml_Er = fields.get(FieldType::pml_E_fp, Direction{0}, 0); + amrex::MultiFab * pml_Et = fields.get(FieldType::pml_E_fp, Direction{1}, 0); + amrex::MultiFab * pml_Br = fields.get(FieldType::pml_B_fp, Direction{0}, 0); + amrex::MultiFab * pml_Bt = fields.get(FieldType::pml_B_fp, Direction{1}, 0); // Perform forward Fourier transforms solver.ForwardTransform(lev, *pml_Er, Idx.Er_pml, *pml_Et, Idx.Et_pml); diff --git a/Source/BoundaryConditions/WarpXEvolvePML.cpp b/Source/BoundaryConditions/WarpXEvolvePML.cpp index 7e8443415bb..d9d38b57a7d 100644 --- a/Source/BoundaryConditions/WarpXEvolvePML.cpp +++ b/Source/BoundaryConditions/WarpXEvolvePML.cpp @@ -12,6 +12,7 @@ # include "BoundaryConditions/PML_RZ.H" #endif #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" #include "PML_current.H" #include "Utils/WarpXProfilerWrapper.H" #include "WarpX_PML_kernels.H" @@ -66,10 +67,11 @@ WarpX::DampPML (const int lev, PatchType patch_type) #if (defined WARPX_DIM_RZ) && (defined WARPX_USE_FFT) if (pml_rz[lev]) { using ablastr::fields::Direction; - pml_rz[lev]->ApplyDamping( m_fields.get("Efield_fp",Direction{1},lev), - m_fields.get("Efield_fp",Direction{2},lev), - m_fields.get("Bfield_fp",Direction{1},lev), - m_fields.get("Bfield_fp",Direction{2},lev), + using warpx::fields::FieldType; + pml_rz[lev]->ApplyDamping( m_fields.get(FieldType::Efield_fp,Direction{1},lev), + m_fields.get(FieldType::Efield_fp,Direction{2},lev), + m_fields.get(FieldType::Bfield_fp,Direction{1},lev), + m_fields.get(FieldType::Bfield_fp,Direction{2},lev), dt[lev], m_fields); } #endif @@ -86,8 +88,10 @@ WarpX::DampPML_Cartesian (const int lev, PatchType patch_type) if (pml[lev]->ok()) { - const auto& pml_E = (patch_type == PatchType::fine) ? m_fields.get_alldirs("pml_E_fp", lev) : m_fields.get_alldirs("pml_E_cp", lev); - const auto& pml_B = (patch_type == PatchType::fine) ? m_fields.get_alldirs("pml_B_fp", lev) : m_fields.get_alldirs("pml_B_cp", lev); + using warpx::fields::FieldType; + + const auto& pml_E = (patch_type == PatchType::fine) ? m_fields.get_alldirs(FieldType::pml_E_fp, lev) : m_fields.get_alldirs(FieldType::pml_E_cp, lev); + const auto& pml_B = (patch_type == PatchType::fine) ? m_fields.get_alldirs(FieldType::pml_B_fp, lev) : m_fields.get_alldirs(FieldType::pml_B_cp, lev); const auto& sigba = (patch_type == PatchType::fine) ? pml[lev]->GetMultiSigmaBox_fp() : pml[lev]->GetMultiSigmaBox_cp(); const amrex::IntVect Ex_stag = pml_E[0]->ixType().toIntVect(); @@ -99,16 +103,16 @@ WarpX::DampPML_Cartesian (const int lev, PatchType patch_type) const amrex::IntVect Bz_stag = pml_B[2]->ixType().toIntVect(); amrex::IntVect F_stag; - if (m_fields.has("pml_F_fp", lev)) { + if (m_fields.has(FieldType::pml_F_fp, lev)) { amrex::MultiFab* pml_F = (patch_type == PatchType::fine) ? - m_fields.get("pml_F_fp", lev) : m_fields.get("pml_F_cp", lev); + m_fields.get(FieldType::pml_F_fp, lev) : m_fields.get(FieldType::pml_F_cp, lev); F_stag = pml_F->ixType().toIntVect(); } amrex::IntVect G_stag; - if (m_fields.has("pml_G_fp", lev)) { + if (m_fields.has(FieldType::pml_G_fp, lev)) { amrex::MultiFab* pml_G = (patch_type == PatchType::fine) ? - m_fields.get("pml_G_fp", lev) : m_fields.get("pml_G_cp", lev); + m_fields.get(FieldType::pml_G_fp, lev) : m_fields.get(FieldType::pml_G_cp, lev); G_stag = pml_G->ixType().toIntVect(); } @@ -199,9 +203,9 @@ WarpX::DampPML_Cartesian (const int lev, PatchType patch_type) // For warpx_damp_pml_F(), mfi.nodaltilebox is used in the ParallelFor loop and here we // use mfi.tilebox. However, it does not matter because in damp_pml, where nodaltilebox // is used, only a simple multiplication is performed. - if (m_fields.has("pml_F_fp", lev)) { + if (m_fields.has(FieldType::pml_F_fp, lev)) { amrex::MultiFab* pml_F = (patch_type == PatchType::fine) ? - m_fields.get("pml_F_fp", lev) : m_fields.get("pml_F_cp", lev); + m_fields.get(FieldType::pml_F_fp, lev) : m_fields.get(FieldType::pml_F_cp, lev); const Box& tnd = mfi.nodaltilebox(); auto const& pml_F_fab = pml_F->array(mfi); amrex::ParallelFor(tnd, [=] AMREX_GPU_DEVICE (int i, int j, int k) @@ -212,9 +216,9 @@ WarpX::DampPML_Cartesian (const int lev, PatchType patch_type) } // Damp G when WarpX::do_divb_cleaning = true - if (m_fields.has("pml_G_fp", lev)) { + if (m_fields.has(FieldType::pml_G_fp, lev)) { amrex::MultiFab* pml_G = (patch_type == PatchType::fine) ? - m_fields.get("pml_G_fp", lev) : m_fields.get("pml_G_cp", lev); + m_fields.get(FieldType::pml_G_fp, lev) : m_fields.get(FieldType::pml_G_cp, lev); const Box& tb = mfi.tilebox(G_stag); auto const& pml_G_fab = pml_G->array(mfi); @@ -254,8 +258,9 @@ WarpX::DampJPML (int lev, PatchType patch_type) if (pml[lev]->ok()) { + using warpx::fields::FieldType; - const auto& pml_j = (patch_type == PatchType::fine) ? m_fields.get_alldirs("pml_j_fp", lev) : m_fields.get_alldirs("pml_j_cp", lev); + const auto& pml_j = (patch_type == PatchType::fine) ? m_fields.get_alldirs(FieldType::pml_j_fp, lev) : m_fields.get_alldirs(FieldType::pml_j_cp, lev); const auto& sigba = (patch_type == PatchType::fine) ? pml[lev]->GetMultiSigmaBox_fp() : pml[lev]->GetMultiSigmaBox_cp(); @@ -284,7 +289,7 @@ WarpX::DampJPML (int lev, PatchType patch_type) // Skip the field update if this gridpoint is inside the embedded boundary amrex::Array4 eb_lxfab, eb_lyfab, eb_lzfab; if (EB::enabled()) { - const auto &pml_edge_lenghts = m_fields.get_alldirs("pml_edge_lengths", lev); + const auto &pml_edge_lenghts = m_fields.get_alldirs(FieldType::pml_edge_lengths, lev); eb_lxfab = pml_edge_lenghts[0]->array(mfi); eb_lyfab = pml_edge_lenghts[1]->array(mfi); diff --git a/Source/BoundaryConditions/WarpXFieldBoundaries.cpp b/Source/BoundaryConditions/WarpXFieldBoundaries.cpp index 6e4b1b451e2..fe8003aadde 100644 --- a/Source/BoundaryConditions/WarpXFieldBoundaries.cpp +++ b/Source/BoundaryConditions/WarpXFieldBoundaries.cpp @@ -18,7 +18,7 @@ using namespace amrex; using namespace amrex::literals; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -55,9 +55,9 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { if (patch_type == PatchType::fine) { PEC::ApplyPECtoEfield( - {m_fields.get("Efield_fp",Direction{0},lev), - m_fields.get("Efield_fp",Direction{1},lev), - m_fields.get("Efield_fp",Direction{2},lev)}, + {m_fields.get(FieldType::Efield_fp,Direction{0},lev), + m_fields.get(FieldType::Efield_fp,Direction{1},lev), + m_fields.get(FieldType::Efield_fp,Direction{2},lev)}, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), lev, patch_type, ref_ratio); @@ -65,7 +65,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) // apply pec on split E-fields in PML region const bool split_pml_field = true; PEC::ApplyPECtoEfield( - m_fields.get_alldirs("pml_E_fp",lev), + m_fields.get_alldirs(FieldType::pml_E_fp, lev), field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), lev, patch_type, ref_ratio, @@ -73,9 +73,9 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) } } else { PEC::ApplyPECtoEfield( - {m_fields.get("Efield_cp",Direction{0},lev), - m_fields.get("Efield_cp",Direction{1},lev), - m_fields.get("Efield_cp",Direction{2},lev)}, + {m_fields.get(FieldType::Efield_cp,Direction{0},lev), + m_fields.get(FieldType::Efield_cp,Direction{1},lev), + m_fields.get(FieldType::Efield_cp,Direction{2},lev)}, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), lev, patch_type, ref_ratio); @@ -83,7 +83,7 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) // apply pec on split E-fields in PML region const bool split_pml_field = true; PEC::ApplyPECtoEfield( - m_fields.get_alldirs("pml_E_cp",lev), + m_fields.get_alldirs(FieldType::pml_E_cp, lev), field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), lev, patch_type, ref_ratio, @@ -94,13 +94,13 @@ void WarpX::ApplyEfieldBoundary(const int lev, PatchType patch_type) #ifdef WARPX_DIM_RZ if (patch_type == PatchType::fine) { - ApplyFieldBoundaryOnAxis(m_fields.get("Efield_fp",Direction{0},lev), - m_fields.get("Efield_fp",Direction{1},lev), - m_fields.get("Efield_fp",Direction{2},lev), lev); + ApplyFieldBoundaryOnAxis(m_fields.get(FieldType::Efield_fp,Direction{0},lev), + m_fields.get(FieldType::Efield_fp,Direction{1},lev), + m_fields.get(FieldType::Efield_fp,Direction{2},lev), lev); } else { - ApplyFieldBoundaryOnAxis(m_fields.get("Efield_cp",Direction{0},lev), - m_fields.get("Efield_cp",Direction{1},lev), - m_fields.get("Efield_cp",Direction{2},lev), lev); + ApplyFieldBoundaryOnAxis(m_fields.get(FieldType::Efield_cp,Direction{0},lev), + m_fields.get(FieldType::Efield_cp,Direction{1},lev), + m_fields.get(FieldType::Efield_cp,Direction{2},lev), lev); } #endif } @@ -112,17 +112,17 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { if (patch_type == PatchType::fine) { PEC::ApplyPECtoBfield( { - m_fields.get("Bfield_fp",Direction{0},lev), - m_fields.get("Bfield_fp",Direction{1},lev), - m_fields.get("Bfield_fp",Direction{2},lev) }, + m_fields.get(FieldType::Bfield_fp,Direction{0},lev), + m_fields.get(FieldType::Bfield_fp,Direction{1},lev), + m_fields.get(FieldType::Bfield_fp,Direction{2},lev) }, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), lev, patch_type, ref_ratio); } else { PEC::ApplyPECtoBfield( { - m_fields.get("Bfield_cp",Direction{0},lev), - m_fields.get("Bfield_cp",Direction{1},lev), - m_fields.get("Bfield_cp",Direction{2},lev) }, + m_fields.get(FieldType::Bfield_cp,Direction{0},lev), + m_fields.get(FieldType::Bfield_cp,Direction{1},lev), + m_fields.get(FieldType::Bfield_cp,Direction{2},lev) }, field_boundary_lo, field_boundary_hi, get_ng_fieldgather(), Geom(lev), lev, patch_type, ref_ratio); @@ -135,8 +135,8 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d if (lev == 0) { if (a_dt_type == DtType::FirstHalf) { if(::isAnyBoundary(field_boundary_lo, field_boundary_hi)){ - auto Efield_fp = m_fields.get_mr_levels_alldirs("Efield_fp",max_level); - auto Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp",max_level); + auto Efield_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, max_level); + auto Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, max_level); m_fdtd_solver_fp[0]->ApplySilverMuellerBoundary( Efield_fp[lev], Bfield_fp[lev], Geom(lev).Domain(), dt[lev], @@ -147,13 +147,13 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d #ifdef WARPX_DIM_RZ if (patch_type == PatchType::fine) { - ApplyFieldBoundaryOnAxis(m_fields.get("Bfield_fp",Direction{0},lev), - m_fields.get("Bfield_fp",Direction{1},lev), - m_fields.get("Bfield_fp",Direction{2},lev), lev); + ApplyFieldBoundaryOnAxis(m_fields.get(FieldType::Bfield_fp,Direction{0},lev), + m_fields.get(FieldType::Bfield_fp,Direction{1},lev), + m_fields.get(FieldType::Bfield_fp,Direction{2},lev), lev); } else { - ApplyFieldBoundaryOnAxis(m_fields.get("Bfield_cp",Direction{0},lev), - m_fields.get("Bfield_cp",Direction{1},lev), - m_fields.get("Bfield_cp",Direction{2},lev), lev); + ApplyFieldBoundaryOnAxis(m_fields.get(FieldType::Bfield_cp,Direction{0},lev), + m_fields.get(FieldType::Bfield_cp,Direction{1},lev), + m_fields.get(FieldType::Bfield_cp,Direction{2},lev), lev); } #endif } @@ -274,7 +274,7 @@ void WarpX::ApplyElectronPressureBoundary (const int lev, PatchType patch_type) { if (::isAnyBoundary(field_boundary_lo, field_boundary_hi)) { if (patch_type == PatchType::fine) { - ablastr::fields::ScalarField electron_pressure_fp = m_fields.get("hybrid_electron_pressure_fp", lev); + ablastr::fields::ScalarField electron_pressure_fp = m_fields.get(FieldType::hybrid_electron_pressure_fp, lev); PEC::ApplyPECtoElectronPressure( electron_pressure_fp, field_boundary_lo, field_boundary_hi, diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index ab14dd3b86e..e00c30aa78e 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -48,7 +48,7 @@ #include using namespace amrex::literals; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -570,23 +570,23 @@ BTDiagnostics::InitializeFieldFunctors (int lev) m_cell_center_functors.at(lev).size()); for (int comp=0; comp(warpx.m_fields.get("Efield_aux", Direction{0}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "Ey" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{1}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "Ez" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{2}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "Bx" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{0}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "By" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{1}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "Bz" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{2}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "jx" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("current_fp",Direction{0}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::current_fp,Direction{0}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "jy" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("current_fp",Direction{1}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::current_fp,Direction{1}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "jz" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("current_fp",Direction{2}, lev), lev, m_crse_ratio); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::current_fp,Direction{2}, lev), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "rho" ){ m_cell_center_functors[lev][comp] = std::make_unique(lev, m_crse_ratio); } @@ -602,7 +602,7 @@ BTDiagnostics::UpdateVarnamesForRZopenPMD () #ifdef WARPX_DIM_RZ auto & warpx = WarpX::GetInstance(); using ablastr::fields::Direction; - const int ncomp_multimodefab = warpx.m_fields.get("Efield_aux", Direction{0}, 0)->nComp(); + const int ncomp_multimodefab = warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, 0)->nComp(); const int ncomp = ncomp_multimodefab; @@ -663,7 +663,7 @@ BTDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) using ablastr::fields::Direction; auto & warpx = WarpX::GetInstance(); - const int ncomp_multimodefab = warpx.m_fields.get("Efield_aux", Direction{0}, 0)->nComp(); + const int ncomp_multimodefab = warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, 0)->nComp(); const int ncomp = ncomp_multimodefab; // Clear any pre-existing vector to release stored data // This ensures that when domain is load-balanced, the functors point @@ -689,23 +689,23 @@ BTDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) const auto m_cell_center_functors_at_lev_size = static_cast(m_cell_center_functors.at(lev).size()); for (int comp=0; comp(warpx.m_fields.get("Efield_aux", Direction{0}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "Et" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{1}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "Ez" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{2}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "Br" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{0}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "Bt" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{1}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "Bz" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{2}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "jr" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("current_fp", Direction{0}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::current_fp, Direction{0}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "jt" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("current_fp", Direction{1}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::current_fp, Direction{1}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "jz" ){ - m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get("current_fp", Direction{2}, lev), lev, m_crse_ratio, false, ncomp); + m_cell_center_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::current_fp, Direction{2}, lev), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "rho" ){ m_cell_center_functors[lev][comp] = std::make_unique(lev, m_crse_ratio, false, -1, false, ncomp); } diff --git a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp index 7f532c79e13..df25bf7ff03 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp @@ -17,7 +17,7 @@ #include #include -using namespace warpx::fields; +using warpx::fields::FieldType; JFunctor::JFunctor (const int dir, int lev, amrex::IntVect crse_ratio, @@ -35,14 +35,14 @@ JFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buffer*/ auto& warpx = WarpX::GetInstance(); /** pointer to source multifab (can be multi-component) */ - amrex::MultiFab* m_mf_src = warpx.m_fields.get("current_fp",Direction{m_dir},m_lev); + amrex::MultiFab* m_mf_src = warpx.m_fields.get(FieldType::current_fp,Direction{m_dir},m_lev); // Deposit current if no solver or the electrostatic solver is being used if (m_deposit_current) { // allocate temporary multifab to deposit current density into ablastr::fields::MultiLevelVectorField current_fp_temp { - warpx.m_fields.get_alldirs("current_fp", m_lev) + warpx.m_fields.get_alldirs(FieldType::current_fp, m_lev) }; auto& mypc = warpx.GetPartContainer(); diff --git a/Source/Diagnostics/ComputeDiagFunctors/JdispFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/JdispFunctor.cpp index 0e4a405c499..b4f286506a8 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/JdispFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/JdispFunctor.cpp @@ -16,7 +16,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; JdispFunctor::JdispFunctor (int dir, int lev, amrex::IntVect crse_ratio, bool convertRZmodes2cartesian, int ncomp) @@ -33,14 +33,14 @@ JdispFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buff auto* hybrid_pic_model = warpx.get_pointer_HybridPICModel(); /** pointer to total simulation current (J) multifab */ - amrex::MultiFab* mf_j = warpx.m_fields.get("current_fp", Direction{m_dir}, m_lev); + amrex::MultiFab* mf_j = warpx.m_fields.get(FieldType::current_fp, Direction{m_dir}, m_lev); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(hybrid_pic_model, "Displacement current diagnostic is only implemented for the HybridPICModel."); AMREX_ASSUME(hybrid_pic_model != nullptr); /** pointer to current calculated from Ampere's Law (Jamp) multifab */ - amrex::MultiFab* mf_curlB = warpx.m_fields.get("hybrid_current_fp_ampere", Direction{m_dir}, m_lev); + amrex::MultiFab* mf_curlB = warpx.m_fields.get(FieldType::hybrid_current_fp_ampere, Direction{m_dir}, m_lev); //if (!hybrid_pic_model) { // To finish this implementation, we need to implement a method to @@ -66,7 +66,7 @@ JdispFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buff if (hybrid_pic_model) { // Subtract the interpolated j_external value from j_displacement. /** pointer to external currents (Jext) multifab */ - amrex::MultiFab* mf_j_external = warpx.m_fields.get("hybrid_current_fp_external", Direction{m_dir}, m_lev); + amrex::MultiFab* mf_j_external = warpx.m_fields.get(FieldType::hybrid_current_fp_external, Direction{m_dir}, m_lev); // Index type required for interpolating Jext from their respective // staggering (nodal) to the Jx_displacement, Jy_displacement, Jz_displacement diff --git a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp index 2020be2d4b7..4d721dd6abe 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp @@ -22,7 +22,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -68,85 +68,85 @@ FlushFormatCheckpoint::WriteToFile ( for (int lev = 0; lev < nlev; ++lev) { - VisMF::Write(*warpx.m_fields.get("Efield_fp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ex_fp")); - VisMF::Write(*warpx.m_fields.get("Efield_fp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ey_fp")); - VisMF::Write(*warpx.m_fields.get("Efield_fp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ez_fp")); - VisMF::Write(*warpx.m_fields.get("Bfield_fp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bx_fp")); - VisMF::Write(*warpx.m_fields.get("Bfield_fp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "By_fp")); - VisMF::Write(*warpx.m_fields.get("Bfield_fp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bz_fp")); if (WarpX::fft_do_time_averaging) { - VisMF::Write(*warpx.m_fields.get("Efield_avg_fp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_avg_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ex_avg_fp")); - VisMF::Write(*warpx.m_fields.get("Efield_avg_fp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_avg_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ey_avg_fp")); - VisMF::Write(*warpx.m_fields.get("Efield_avg_fp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_avg_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ez_avg_fp")); - VisMF::Write(*warpx.m_fields.get("Bfield_avg_fp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_avg_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bx_avg_fp")); - VisMF::Write(*warpx.m_fields.get("Bfield_avg_fp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_avg_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "By_avg_fp")); - VisMF::Write(*warpx.m_fields.get("Bfield_avg_fp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_avg_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bz_avg_fp")); } if (warpx.getis_synchronized()) { // Need to save j if synchronized because after restart we need j to evolve E by dt/2. - VisMF::Write(*warpx.m_fields.get("current_fp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::current_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "jx_fp")); - VisMF::Write(*warpx.m_fields.get("current_fp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::current_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "jy_fp")); - VisMF::Write(*warpx.m_fields.get("current_fp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::current_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "jz_fp")); } if (lev > 0) { - VisMF::Write(*warpx.m_fields.get("Efield_cp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ex_cp")); - VisMF::Write(*warpx.m_fields.get("Efield_cp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ey_cp")); - VisMF::Write(*warpx.m_fields.get("Efield_cp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ez_cp")); - VisMF::Write(*warpx.m_fields.get("Bfield_cp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bx_cp")); - VisMF::Write(*warpx.m_fields.get("Bfield_cp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "By_cp")); - VisMF::Write(*warpx.m_fields.get("Bfield_cp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bz_cp")); if (WarpX::fft_do_time_averaging) { - VisMF::Write(*warpx.m_fields.get("Efield_avg_cp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_avg_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ex_avg_cp")); - VisMF::Write(*warpx.m_fields.get("Efield_avg_cp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_avg_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ey_avg_cp")); - VisMF::Write(*warpx.m_fields.get("Efield_avg_cp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Efield_avg_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Ez_avg_cp")); - VisMF::Write(*warpx.m_fields.get("Bfield_avg_cp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_avg_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bx_avg_cp")); - VisMF::Write(*warpx.m_fields.get("Bfield_avg_cp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_avg_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "By_avg_cp")); - VisMF::Write(*warpx.m_fields.get("Bfield_avg_cp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::Bfield_avg_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "Bz_avg_cp")); } if (warpx.getis_synchronized()) { // Need to save j if synchronized because after restart we need j to evolve E by dt/2. - VisMF::Write(*warpx.m_fields.get("current_cp", Direction{0}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::current_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "jx_cp")); - VisMF::Write(*warpx.m_fields.get("current_cp", Direction{1}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::current_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "jy_cp")); - VisMF::Write(*warpx.m_fields.get("current_cp", Direction{2}, lev), + VisMF::Write(*warpx.m_fields.get(FieldType::current_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, checkpointname, default_level_prefix, "jz_cp")); } } diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp index 1731851dc3b..0f05496e4c0 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp @@ -50,7 +50,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -568,103 +568,103 @@ FlushFormatPlotfile::WriteAllRawFields( // Auxiliary patch - WriteRawMF( *warpx.m_fields.get("Efield_aux", Direction{0}, lev), dm, raw_pltname, default_level_prefix, "Ex_aux", lev, plot_raw_fields_guards); - WriteRawMF( *warpx.m_fields.get("Efield_aux", Direction{1}, lev), dm, raw_pltname, default_level_prefix, "Ey_aux", lev, plot_raw_fields_guards); - WriteRawMF( *warpx.m_fields.get("Efield_aux", Direction{2}, lev), dm, raw_pltname, default_level_prefix, "Ez_aux", lev, plot_raw_fields_guards); - WriteRawMF( *warpx.m_fields.get("Bfield_aux", Direction{0}, lev), dm, raw_pltname, default_level_prefix, "Bx_aux", lev, plot_raw_fields_guards); - WriteRawMF( *warpx.m_fields.get("Bfield_aux", Direction{1}, lev), dm, raw_pltname, default_level_prefix, "By_aux", lev, plot_raw_fields_guards); - WriteRawMF( *warpx.m_fields.get("Bfield_aux", Direction{2}, lev), dm, raw_pltname, default_level_prefix, "Bz_aux", lev, plot_raw_fields_guards); + WriteRawMF( *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev), dm, raw_pltname, default_level_prefix, "Ex_aux", lev, plot_raw_fields_guards); + WriteRawMF( *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev), dm, raw_pltname, default_level_prefix, "Ey_aux", lev, plot_raw_fields_guards); + WriteRawMF( *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev), dm, raw_pltname, default_level_prefix, "Ez_aux", lev, plot_raw_fields_guards); + WriteRawMF( *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), dm, raw_pltname, default_level_prefix, "Bx_aux", lev, plot_raw_fields_guards); + WriteRawMF( *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), dm, raw_pltname, default_level_prefix, "By_aux", lev, plot_raw_fields_guards); + WriteRawMF( *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev), dm, raw_pltname, default_level_prefix, "Bz_aux", lev, plot_raw_fields_guards); // fine patch - WriteRawMF( *warpx.m_fields.get("Efield_fp", Direction{0}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev), dm, raw_pltname, default_level_prefix, "Ex_fp", lev, plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("Efield_fp", Direction{1}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, lev), dm, raw_pltname, default_level_prefix, "Ey_fp", lev, plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("Efield_fp", Direction{2}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev), dm, raw_pltname, default_level_prefix, "Ez_fp", lev, plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("current_fp",Direction{0}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::current_fp,Direction{0}, lev), dm, raw_pltname, default_level_prefix, "jx_fp", lev,plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("current_fp",Direction{1}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::current_fp,Direction{1}, lev), dm, raw_pltname, default_level_prefix, "jy_fp", lev,plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("current_fp",Direction{2}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::current_fp,Direction{2}, lev), dm, raw_pltname, default_level_prefix, "jz_fp", lev,plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("Bfield_fp", Direction{0}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::Bfield_fp, Direction{0}, lev), dm, raw_pltname, default_level_prefix, "Bx_fp", lev, plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("Bfield_fp", Direction{1}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::Bfield_fp, Direction{1}, lev), dm, raw_pltname, default_level_prefix, "By_fp", lev, plot_raw_fields_guards ); - WriteRawMF( *warpx.m_fields.get("Bfield_fp", Direction{2}, lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::Bfield_fp, Direction{2}, lev), dm, raw_pltname, default_level_prefix, "Bz_fp", lev, plot_raw_fields_guards ); - if (warpx.m_fields.has("F_fp", lev)) + if (warpx.m_fields.has(FieldType::F_fp, lev)) { - WriteRawMF( *warpx.m_fields.get("F_fp", lev), dm, raw_pltname, + WriteRawMF( *warpx.m_fields.get(FieldType::F_fp, lev), dm, raw_pltname, default_level_prefix, "F_fp", lev, plot_raw_fields_guards ); } - if (warpx.m_fields.has("rho_fp", lev)) + if (warpx.m_fields.has(FieldType::rho_fp, lev)) { // rho_fp will have either ncomps or 2*ncomps (2 being the old and new). When 2, return the new so // there is time synchronization. - const int nstart = warpx.m_fields.get("rho_fp", lev)->nComp() - WarpX::ncomps; - const MultiFab rho_new(*warpx.m_fields.get("rho_fp", lev), amrex::make_alias, nstart, WarpX::ncomps); + const int nstart = warpx.m_fields.get(FieldType::rho_fp, lev)->nComp() - WarpX::ncomps; + const MultiFab rho_new(*warpx.m_fields.get(FieldType::rho_fp, lev), amrex::make_alias, nstart, WarpX::ncomps); WriteRawMF(rho_new, dm, raw_pltname, default_level_prefix, "rho_fp", lev, plot_raw_fields_guards); } - if (warpx.m_fields.has("phi_fp", lev)) { - WriteRawMF( *warpx.m_fields.get("phi_fp", lev), dm, raw_pltname, + if (warpx.m_fields.has(FieldType::phi_fp, lev)) { + WriteRawMF( *warpx.m_fields.get(FieldType::phi_fp, lev), dm, raw_pltname, default_level_prefix, "phi_fp", lev, plot_raw_fields_guards ); } // Averaged fields on fine patch if (WarpX::fft_do_time_averaging) { - WriteRawMF(*warpx.m_fields.get("Efield_avg_fp", Direction{0}, lev) , dm, raw_pltname, default_level_prefix, + WriteRawMF(*warpx.m_fields.get(FieldType::Efield_avg_fp, Direction{0}, lev) , dm, raw_pltname, default_level_prefix, "Ex_avg_fp", lev, plot_raw_fields_guards); - WriteRawMF(*warpx.m_fields.get("Efield_avg_fp", Direction{1}, lev) , dm, raw_pltname, default_level_prefix, + WriteRawMF(*warpx.m_fields.get(FieldType::Efield_avg_fp, Direction{1}, lev) , dm, raw_pltname, default_level_prefix, "Ey_avg_fp", lev, plot_raw_fields_guards); - WriteRawMF(*warpx.m_fields.get("Efield_avg_fp", Direction{2}, lev) , dm, raw_pltname, default_level_prefix, + WriteRawMF(*warpx.m_fields.get(FieldType::Efield_avg_fp, Direction{2}, lev) , dm, raw_pltname, default_level_prefix, "Ez_avg_fp", lev, plot_raw_fields_guards); - WriteRawMF(*warpx.m_fields.get("Bfield_avg_fp", Direction{0}, lev) , dm, raw_pltname, default_level_prefix, + WriteRawMF(*warpx.m_fields.get(FieldType::Bfield_avg_fp, Direction{0}, lev) , dm, raw_pltname, default_level_prefix, "Bx_avg_fp", lev, plot_raw_fields_guards); - WriteRawMF(*warpx.m_fields.get("Bfield_avg_fp", Direction{1}, lev) , dm, raw_pltname, default_level_prefix, + WriteRawMF(*warpx.m_fields.get(FieldType::Bfield_avg_fp, Direction{1}, lev) , dm, raw_pltname, default_level_prefix, "By_avg_fp", lev, plot_raw_fields_guards); - WriteRawMF(*warpx.m_fields.get("Bfield_avg_fp", Direction{2}, lev) , dm, raw_pltname, default_level_prefix, + WriteRawMF(*warpx.m_fields.get(FieldType::Bfield_avg_fp, Direction{2}, lev) , dm, raw_pltname, default_level_prefix, "Bz_avg_fp", lev, plot_raw_fields_guards); } // Coarse path if (lev > 0) { WriteCoarseVector( "E", - warpx.m_fields.get("Efield_cp", Direction{0}, lev), - warpx.m_fields.get("Efield_cp", Direction{1}, lev), - warpx.m_fields.get("Efield_cp", Direction{2}, lev), - warpx.m_fields.get("Efield_fp", Direction{0}, lev), - warpx.m_fields.get("Efield_fp", Direction{1}, lev), - warpx.m_fields.get("Efield_fp", Direction{2}, lev), + warpx.m_fields.get(FieldType::Efield_cp, Direction{0}, lev), + warpx.m_fields.get(FieldType::Efield_cp, Direction{1}, lev), + warpx.m_fields.get(FieldType::Efield_cp, Direction{2}, lev), + warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev), + warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, lev), + warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev), dm, raw_pltname, default_level_prefix, lev, plot_raw_fields_guards); WriteCoarseVector( "B", - warpx.m_fields.get("Bfield_cp", Direction{0}, lev), - warpx.m_fields.get("Bfield_cp", Direction{1}, lev), - warpx.m_fields.get("Bfield_cp", Direction{2}, lev), - warpx.m_fields.get("Bfield_fp", Direction{0}, lev), - warpx.m_fields.get("Bfield_fp", Direction{1}, lev), - warpx.m_fields.get("Bfield_fp", Direction{2}, lev), + warpx.m_fields.get(FieldType::Bfield_cp, Direction{0}, lev), + warpx.m_fields.get(FieldType::Bfield_cp, Direction{1}, lev), + warpx.m_fields.get(FieldType::Bfield_cp, Direction{2}, lev), + warpx.m_fields.get(FieldType::Bfield_fp, Direction{0}, lev), + warpx.m_fields.get(FieldType::Bfield_fp, Direction{1}, lev), + warpx.m_fields.get(FieldType::Bfield_fp, Direction{2}, lev), dm, raw_pltname, default_level_prefix, lev, plot_raw_fields_guards); WriteCoarseVector( "j", - warpx.m_fields.get("current_cp", Direction{0}, lev), warpx.m_fields.get("current_cp", Direction{1}, lev), warpx.m_fields.get("current_cp", Direction{2}, lev), - warpx.m_fields.get("current_fp", Direction{0}, lev), warpx.m_fields.get("current_fp", Direction{1}, lev), warpx.m_fields.get("current_fp", Direction{2}, lev), + warpx.m_fields.get(FieldType::current_cp, Direction{0}, lev), warpx.m_fields.get(FieldType::current_cp, Direction{1}, lev), warpx.m_fields.get(FieldType::current_cp, Direction{2}, lev), + warpx.m_fields.get(FieldType::current_fp, Direction{0}, lev), warpx.m_fields.get(FieldType::current_fp, Direction{1}, lev), warpx.m_fields.get(FieldType::current_fp, Direction{2}, lev), dm, raw_pltname, default_level_prefix, lev, plot_raw_fields_guards); - if (warpx.m_fields.has("F_fp", lev) && warpx.m_fields.has("F_cp", lev)) + if (warpx.m_fields.has(FieldType::F_fp, lev) && warpx.m_fields.has(FieldType::F_cp, lev)) { - WriteCoarseScalar("F", warpx.m_fields.get("F_cp", lev), warpx.m_fields.get("F_fp", lev), + WriteCoarseScalar("F", warpx.m_fields.get(FieldType::F_cp, lev), warpx.m_fields.get(FieldType::F_fp, lev), dm, raw_pltname, default_level_prefix, lev, plot_raw_fields_guards, 0); } - if (warpx.m_fields.has("rho_fp", lev) && warpx.m_fields.has("rho_cp", lev)) + if (warpx.m_fields.has(FieldType::rho_fp, lev) && warpx.m_fields.has(FieldType::rho_cp, lev)) { // Use the component 1 of `rho_cp`, i.e. rho_new for time synchronization - WriteCoarseScalar("rho", warpx.m_fields.get("rho_cp", lev), warpx.m_fields.get("rho_fp", lev), + WriteCoarseScalar("rho", warpx.m_fields.get(FieldType::rho_cp, lev), warpx.m_fields.get(FieldType::rho_fp, lev), dm, raw_pltname, default_level_prefix, lev, plot_raw_fields_guards, 1); } } diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp index 2b4c63880a8..e5eefc82de5 100644 --- a/Source/Diagnostics/FullDiagnostics.cpp +++ b/Source/Diagnostics/FullDiagnostics.cpp @@ -45,7 +45,7 @@ #include using namespace amrex::literals; -using namespace warpx::fields; +using warpx::fields::FieldType; FullDiagnostics::FullDiagnostics (int i, const std::string& name): Diagnostics{i, name}, @@ -177,15 +177,15 @@ FullDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) using ablastr::fields::Direction; auto & warpx = WarpX::GetInstance(); - const int ncomp_multimodefab = warpx.m_fields.get("Efield_aux", Direction{0}, 0)->nComp(); + const int ncomp_multimodefab = warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, 0)->nComp(); // Make sure all multifabs have the same number of components for (int dim=0; dim<3; dim++){ AMREX_ALWAYS_ASSERT( - warpx.m_fields.get("Efield_aux", Direction{dim}, lev)->nComp() == ncomp_multimodefab ); + warpx.m_fields.get(FieldType::Efield_aux, Direction{dim}, lev)->nComp() == ncomp_multimodefab ); AMREX_ALWAYS_ASSERT( - warpx.m_fields.get("Bfield_aux", Direction{dim}, lev)->nComp() == ncomp_multimodefab ); + warpx.m_fields.get(FieldType::Bfield_aux, Direction{dim}, lev)->nComp() == ncomp_multimodefab ); AMREX_ALWAYS_ASSERT( - warpx.m_fields.get("current_fp", Direction{dim}, lev)->nComp() == ncomp_multimodefab ); + warpx.m_fields.get(FieldType::current_fp, Direction{dim}, lev)->nComp() == ncomp_multimodefab ); } // Species index to loop over species that dump rho per species @@ -220,37 +220,37 @@ FullDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) const auto m_varname_fields_size = static_cast(m_varnames_fields.size()); for (int comp=0; comp(warpx.m_fields.get("Efield_aux", Direction{0}, lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("Er"), ncomp); } } else if ( m_varnames_fields[comp] == "Et" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{1}, lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("Et"), ncomp); } } else if ( m_varnames_fields[comp] == "Ez" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{2}, lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("Ez"), ncomp); } } else if ( m_varnames_fields[comp] == "Br" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{0}, lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("Br"), ncomp); } } else if ( m_varnames_fields[comp] == "Bt" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{1}, lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("Bt"), ncomp); } } else if ( m_varnames_fields[comp] == "Bz" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{2}, lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("Bz"), ncomp); @@ -317,19 +317,19 @@ FullDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) } i_T_species++; } else if ( m_varnames_fields[comp] == "F" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("F_fp", lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::F_fp, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("F"), ncomp); } } else if ( m_varnames_fields[comp] == "G" ){ - m_all_field_functors[lev][comp] = std::make_unique( warpx.m_fields.get("G_fp", lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique( warpx.m_fields.get(FieldType::G_fp, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("G"), ncomp); } } else if ( m_varnames_fields[comp] == "phi" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("phi_fp", lev), lev, m_crse_ratio, + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::phi_fp, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("phi"), ncomp); @@ -346,14 +346,14 @@ FullDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) } } else if ( m_varnames_fields[comp] == "divB" ){ m_all_field_functors[lev][comp] = std::make_unique( - warpx.m_fields.get_alldirs("Bfield_aux", lev), + warpx.m_fields.get_alldirs(FieldType::Bfield_aux, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("divB"), ncomp); } } else if ( m_varnames_fields[comp] == "divE" ){ m_all_field_functors[lev][comp] = std::make_unique( - warpx.m_fields.get_alldirs("Efield_aux", lev), + warpx.m_fields.get_alldirs(FieldType::Efield_aux, lev), lev, m_crse_ratio, false, ncomp); if (update_varnames) { AddRZModesToOutputNames(std::string("divE"), ncomp); @@ -401,15 +401,15 @@ FullDiagnostics::AddRZModesToDiags (int lev) if (!m_dump_rz_modes) { return; } auto & warpx = WarpX::GetInstance(); - const int ncomp_multimodefab = warpx.m_fields.get("Efield_aux", Direction{0}, 0)->nComp(); + const int ncomp_multimodefab = warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, 0)->nComp(); // Make sure all multifabs have the same number of components for (int dim=0; dim<3; dim++){ AMREX_ALWAYS_ASSERT( - warpx.m_fields.get("Efield_aux", Direction{dim}, lev)->nComp() == ncomp_multimodefab ); + warpx.m_fields.get(FieldType::Efield_aux, Direction{dim}, lev)->nComp() == ncomp_multimodefab ); AMREX_ALWAYS_ASSERT( - warpx.m_fields.get("Bfield_aux", Direction{dim}, lev)->nComp() == ncomp_multimodefab ); + warpx.m_fields.get(FieldType::Bfield_aux, Direction{dim}, lev)->nComp() == ncomp_multimodefab ); AMREX_ALWAYS_ASSERT( - warpx.m_fields.get("current_fp", Direction{dim}, lev)->nComp() == ncomp_multimodefab ); + warpx.m_fields.get(FieldType::current_fp, Direction{dim}, lev)->nComp() == ncomp_multimodefab ); } // Check if divE is requested @@ -444,19 +444,19 @@ FullDiagnostics::AddRZModesToDiags (int lev) for (int dim=0; dim<3; dim++){ // 3 components, r theta z m_all_field_functors[lev].push_back(std::make_unique( - warpx.m_fields.get("Efield_aux", Direction{dim}, lev), lev, + warpx.m_fields.get(FieldType::Efield_aux, Direction{dim}, lev), lev, m_crse_ratio, false, ncomp_multimodefab)); AddRZModesToOutputNames(std::string("E") + coord[dim], - warpx.m_fields.get("Efield_aux", Direction{0}, 0)->nComp()); + warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, 0)->nComp()); } // B for (int dim=0; dim<3; dim++){ // 3 components, r theta z m_all_field_functors[lev].push_back(std::make_unique( - warpx.m_fields.get("Bfield_aux", Direction{dim}, lev), lev, + warpx.m_fields.get(FieldType::Bfield_aux, Direction{dim}, lev), lev, m_crse_ratio, false, ncomp_multimodefab)); AddRZModesToOutputNames(std::string("B") + coord[dim], - warpx.m_fields.get("Bfield_aux", Direction{0}, 0)->nComp()); + warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, 0)->nComp()); } // j for (int dim=0; dim<3; dim++){ @@ -465,12 +465,12 @@ FullDiagnostics::AddRZModesToDiags (int lev) dim, lev, m_crse_ratio, false, deposit_current, ncomp_multimodefab)); deposit_current = false; AddRZModesToOutputNames(std::string("J") + coord[dim], - warpx.m_fields.get("current_fp",Direction{0},0)->nComp()); + warpx.m_fields.get(FieldType::current_fp,Direction{0},0)->nComp()); } // divE if (divE_requested) { m_all_field_functors[lev].push_back(std::make_unique( - warpx.m_fields.get_alldirs("Efield_aux", lev), + warpx.m_fields.get_alldirs(FieldType::Efield_aux, lev), lev, m_crse_ratio, false, ncomp_multimodefab)); AddRZModesToOutputNames(std::string("divE"), ncomp_multimodefab); } @@ -668,16 +668,16 @@ FullDiagnostics::InitializeFieldFunctors (int lev) // Fill vector of functors for all components except individual cylindrical modes. for (int comp=0; comp(warpx.m_fields.get("Efield_aux", Direction{2}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Bz" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{2}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "jz" ){ m_all_field_functors[lev][comp] = std::make_unique(2, lev, m_crse_ratio, true, deposit_current); deposit_current = false; } else if ( m_varnames[comp] == "jz_displacement" ) { m_all_field_functors[lev][comp] = std::make_unique(2, lev, m_crse_ratio, true); } else if ( m_varnames[comp] == "Az" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("vector_potential_fp_nodal", Direction{2}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::vector_potential_fp_nodal, Direction{2}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "rho" ){ // Initialize rho functor to dump total rho m_all_field_functors[lev][comp] = std::make_unique(lev, m_crse_ratio, true); @@ -690,31 +690,31 @@ FullDiagnostics::InitializeFieldFunctors (int lev) m_all_field_functors[lev][comp] = std::make_unique(lev, m_crse_ratio, m_T_per_species_index[i_T_species]); i_T_species++; } else if ( m_varnames[comp] == "F" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("F_fp", lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::F_fp, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "G" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("G_fp", lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::G_fp, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "phi" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("phi_fp", lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::phi_fp, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "part_per_cell" ){ m_all_field_functors[lev][comp] = std::make_unique(nullptr, lev, m_crse_ratio); } else if ( m_varnames[comp] == "part_per_grid" ){ m_all_field_functors[lev][comp] = std::make_unique(nullptr, lev, m_crse_ratio); } else if ( m_varnames[comp] == "divB" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get_alldirs("Bfield_aux", lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get_alldirs(FieldType::Bfield_aux, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "divE" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get_alldirs("Efield_aux", lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get_alldirs(FieldType::Efield_aux, lev), lev, m_crse_ratio); } else { #ifdef WARPX_DIM_RZ if ( m_varnames[comp] == "Er" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{0}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Et" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{1}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Br" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{0}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Bt" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{1}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "jr" ){ m_all_field_functors[lev][comp] = std::make_unique(0, lev, m_crse_ratio, true, deposit_current); deposit_current = false; @@ -726,22 +726,22 @@ FullDiagnostics::InitializeFieldFunctors (int lev) } else if (m_varnames[comp] == "jt_displacement" ){ m_all_field_functors[lev][comp] = std::make_unique(1, lev, m_crse_ratio, true); } else if ( m_varnames[comp] == "Ar" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("vector_potential_fp_nodal", Direction{0}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::vector_potential_fp_nodal, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "At" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("vector_potential_fp_nodal", Direction{1}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::vector_potential_fp_nodal, Direction{1}, lev), lev, m_crse_ratio); } else { WARPX_ABORT_WITH_MESSAGE(m_varnames[comp] + " is not a known field output type for RZ geometry"); } #else // Valid transverse fields in Cartesian coordinates if ( m_varnames[comp] == "Ex" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{0}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Ey" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Efield_aux", Direction{1}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Bx" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{0}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "By" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("Bfield_aux", Direction{1}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "jx" ){ m_all_field_functors[lev][comp] = std::make_unique(0, lev, m_crse_ratio, true, deposit_current); deposit_current = false; @@ -753,9 +753,9 @@ FullDiagnostics::InitializeFieldFunctors (int lev) } else if ( m_varnames[comp] == "jy_displacement" ){ m_all_field_functors[lev][comp] = std::make_unique(1, lev, m_crse_ratio); } else if ( m_varnames[comp] == "Ax" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("vector_potential_fp_nodal", Direction{0}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::vector_potential_fp_nodal, Direction{0}, lev), lev, m_crse_ratio); } else if ( m_varnames[comp] == "Ay" ){ - m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get("vector_potential_fp_nodal", Direction{1}, lev), lev, m_crse_ratio); + m_all_field_functors[lev][comp] = std::make_unique(warpx.m_fields.get(FieldType::vector_potential_fp_nodal, Direction{1}, lev), lev, m_crse_ratio); } else { std::cout << "Error on component " << m_varnames[comp] << std::endl; WARPX_ABORT_WITH_MESSAGE(m_varnames[comp] + " is not a known field output type for this geometry"); diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index 51b28bc9a10..e94039ec079 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -43,7 +43,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; void LaserParticleContainer::ReadHeader (std::istream& is) @@ -268,7 +268,7 @@ storePhiOnParticles ( PinnedMemoryParticleContainer& tmp, const amrex::Geometry& geom = warpx.Geom(lev); auto plo = geom.ProbLoArray(); auto dxi = geom.InvCellSizeArray(); - amrex::MultiFab const& phi = *warpx.m_fields.get("phi_fp", lev); + amrex::MultiFab const& phi = *warpx.m_fields.get(FieldType::phi_fp, lev); for (PinnedParIter pti(tmp, lev); pti.isValid(); ++pti) { diff --git a/Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp b/Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp index d5cf391a254..d3592c6c6f2 100644 --- a/Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp +++ b/Source/Diagnostics/ReducedDiags/ChargeOnEB.cpp @@ -29,7 +29,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; // constructor @@ -106,9 +106,9 @@ void ChargeOnEB::ComputeDiags (const int step) int const lev = 0; // get MultiFab data at lev - const amrex::MultiFab & Ex = *warpx.m_fields.get("Efield_fp",Direction{0},lev); - const amrex::MultiFab & Ey = *warpx.m_fields.get("Efield_fp",Direction{1},lev); - const amrex::MultiFab & Ez = *warpx.m_fields.get("Efield_fp",Direction{2},lev); + const amrex::MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev); + const amrex::MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, lev); + const amrex::MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev); // get EB structures amrex::EBFArrayBoxFactory const& eb_box_factory = warpx.fieldEBFactory(lev); diff --git a/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp b/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp index 463e6e160cd..c0532163232 100644 --- a/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp +++ b/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp @@ -59,7 +59,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; ColliderRelevant::ColliderRelevant (const std::string& rd_name) : ReducedDiags{rd_name} @@ -444,12 +444,12 @@ void ColliderRelevant::ComputeDiags (int step) // define variables in preparation for field gathering const amrex::XDim3 dinv = WarpX::InvCellSize(std::max(lev, 0)); - const amrex::MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const amrex::MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const amrex::MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const amrex::MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const amrex::MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const amrex::MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); + const amrex::MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const amrex::MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const amrex::MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const amrex::MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const amrex::MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const amrex::MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); // declare reduce_op ReduceOps reduce_op; diff --git a/Source/Diagnostics/ReducedDiags/FieldEnergy.cpp b/Source/Diagnostics/ReducedDiags/FieldEnergy.cpp index 84b6df87af8..1a984368b4e 100644 --- a/Source/Diagnostics/ReducedDiags/FieldEnergy.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldEnergy.cpp @@ -31,7 +31,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; // constructor FieldEnergy::FieldEnergy (const std::string& rd_name) @@ -95,12 +95,12 @@ void FieldEnergy::ComputeDiags (int step) for (int lev = 0; lev < nLevel; ++lev) { // get MultiFab data at lev - const MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); + const MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); // get cell volume const std::array &dx = WarpX::CellSize(lev); diff --git a/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp b/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp index 276c7928b43..8c7eb6b4dec 100644 --- a/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldMaximum.cpp @@ -40,7 +40,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; // constructor FieldMaximum::FieldMaximum (const std::string& rd_name) @@ -119,12 +119,12 @@ void FieldMaximum::ComputeDiags (int step) for (int lev = 0; lev < nLevel; ++lev) { // get MultiFab data at lev - const MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); + const MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); constexpr int noutputs = 8; // max of Ex,Ey,Ez,|E|,Bx,By,Bz and |B| constexpr int index_Ex = 0; diff --git a/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp b/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp index f1857155457..764e9874c39 100644 --- a/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldMomentum.cpp @@ -39,7 +39,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; FieldMomentum::FieldMomentum (const std::string& rd_name) : ReducedDiags{rd_name} @@ -111,12 +111,12 @@ void FieldMomentum::ComputeDiags (int step) for (int lev = 0; lev < nLevel; ++lev) { // Get MultiFab data at given refinement level - const amrex::MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const amrex::MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const amrex::MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const amrex::MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const amrex::MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const amrex::MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); + const amrex::MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const amrex::MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const amrex::MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const amrex::MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const amrex::MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const amrex::MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); // Cell-centered index type const amrex::GpuArray cc{0,0,0}; diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp index bf5c68c9d83..923ae727d08 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp @@ -46,7 +46,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; // constructor @@ -401,12 +401,12 @@ void FieldProbe::ComputeDiags (int step) } // get MultiFab data at lev - const amrex::MultiFab &Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const amrex::MultiFab &Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const amrex::MultiFab &Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const amrex::MultiFab &Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const amrex::MultiFab &By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const amrex::MultiFab &Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); + const amrex::MultiFab &Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const amrex::MultiFab &Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const amrex::MultiFab &Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const amrex::MultiFab &Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const amrex::MultiFab &By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const amrex::MultiFab &Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); /* * Prepare interpolation of field components to probe_position diff --git a/Source/Diagnostics/ReducedDiags/FieldReduction.H b/Source/Diagnostics/ReducedDiags/FieldReduction.H index 65455039394..d2c6dc6f6da 100644 --- a/Source/Diagnostics/ReducedDiags/FieldReduction.H +++ b/Source/Diagnostics/ReducedDiags/FieldReduction.H @@ -89,6 +89,7 @@ public: { using ablastr::fields::Direction; using namespace amrex::literals; + using warpx::fields::FieldType; // get a reference to WarpX instance auto & warpx = WarpX::GetInstance(); @@ -100,15 +101,15 @@ public: const auto dx = geom.CellSizeArray(); // get MultiFab data - const amrex::MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const amrex::MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const amrex::MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const amrex::MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const amrex::MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const amrex::MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); - const amrex::MultiFab & jx = *warpx.m_fields.get("current_fp",Direction{0},lev); - const amrex::MultiFab & jy = *warpx.m_fields.get("current_fp",Direction{1},lev); - const amrex::MultiFab & jz = *warpx.m_fields.get("current_fp",Direction{2},lev); + const amrex::MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const amrex::MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const amrex::MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const amrex::MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const amrex::MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const amrex::MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); + const amrex::MultiFab & jx = *warpx.m_fields.get(FieldType::current_fp, Direction{0},lev); + const amrex::MultiFab & jy = *warpx.m_fields.get(FieldType::current_fp, Direction{1},lev); + const amrex::MultiFab & jz = *warpx.m_fields.get(FieldType::current_fp, Direction{2},lev); // General preparation of interpolation and reduction operations diff --git a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp index 8ed3d21efc0..c496300c54e 100644 --- a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp +++ b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp @@ -38,7 +38,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -131,7 +131,7 @@ void LoadBalanceCosts::ComputeDiags (int step) for (int lev = 0; lev < nLevels; ++lev) { const amrex::DistributionMapping& dm = warpx.DistributionMap(lev); - const MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); + const MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); for (MFIter mfi(Ex, false); mfi.isValid(); ++mfi) { const Box& tbx = mfi.tilebox(); diff --git a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp index 5b4ff2908a9..c82b060b67c 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp @@ -54,7 +54,7 @@ #include using namespace amrex::literals; -using namespace warpx::fields; +using warpx::fields::FieldType; // constructor ParticleExtrema::ParticleExtrema (const std::string& rd_name) @@ -270,12 +270,12 @@ void ParticleExtrema::ComputeDiags (int step) // define variables in preparation for field gathering const amrex::XDim3 dinv = WarpX::InvCellSize(std::max(lev, 0)); - const amrex::MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, lev); - const amrex::MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, lev); - const amrex::MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, lev); - const amrex::MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, lev); - const amrex::MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, lev); - const amrex::MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, lev); + const amrex::MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, lev); + const amrex::MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + const amrex::MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, lev); + const amrex::MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, lev); + const amrex::MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + const amrex::MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, lev); // declare reduce_op amrex::ReduceOps reduce_op; diff --git a/Source/Diagnostics/SliceDiagnostic.cpp b/Source/Diagnostics/SliceDiagnostic.cpp index a9ebe4bf661..bcb6070abdf 100644 --- a/Source/Diagnostics/SliceDiagnostic.cpp +++ b/Source/Diagnostics/SliceDiagnostic.cpp @@ -42,7 +42,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; /* \brief * The functions creates the slice for diagnostics based on the user-input. @@ -201,27 +201,27 @@ CreateSlice( const MultiFab& mf, const Vector &dom_geom, amrex::amrex_avgdown_nodes(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio); } - if( SliceType == warpx.m_fields.get("Efield_aux", Direction{0}, 0)->ixType().toIntVect() ) { + if( SliceType == warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, 0)->ixType().toIntVect() ) { amrex::amrex_avgdown_edges(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio, 0); } - if( SliceType == warpx.m_fields.get("Efield_aux", Direction{1}, 0)->ixType().toIntVect() ) { + if( SliceType == warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, 0)->ixType().toIntVect() ) { amrex::amrex_avgdown_edges(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio, 1); } - if( SliceType == warpx.m_fields.get("Efield_aux", Direction{2}, 0)->ixType().toIntVect() ) { + if( SliceType == warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, 0)->ixType().toIntVect() ) { amrex::amrex_avgdown_edges(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio, 2); } - if( SliceType == warpx.m_fields.get("Bfield_aux", Direction{0}, 0)->ixType().toIntVect() ) { + if( SliceType == warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, 0)->ixType().toIntVect() ) { amrex::amrex_avgdown_faces(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio, 0); } - if( SliceType == warpx.m_fields.get("Bfield_aux", Direction{1}, 0)->ixType().toIntVect() ) { + if( SliceType == warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, 0)->ixType().toIntVect() ) { amrex::amrex_avgdown_faces(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio, 1); } - if( SliceType == warpx.m_fields.get("Bfield_aux", Direction{2}, 0)->ixType().toIntVect() ) { + if( SliceType == warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, 0)->ixType().toIntVect() ) { amrex::amrex_avgdown_faces(Dst_bx, Dst_fabox, Src_fabox, dcomp, scomp, ncomp, slice_cr_ratio, 2); } diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp index 26e7a025ff2..43415daf151 100644 --- a/Source/Diagnostics/WarpXIO.cpp +++ b/Source/Diagnostics/WarpXIO.cpp @@ -12,6 +12,7 @@ # include "BoundaryConditions/PML_RZ.H" #endif #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" #include "FieldIO.H" #include "Particles/MultiParticleContainer.H" #include "Utils/TextMsg.H" @@ -89,6 +90,7 @@ void WarpX::InitFromCheckpoint () { using ablastr::fields::Direction; + using warpx::fields::FieldType; WARPX_PROFILE("WarpX::InitFromCheckpoint()"); @@ -281,101 +283,101 @@ WarpX::InitFromCheckpoint () for (int lev = 0; lev < nlevs; ++lev) { for (int i = 0; i < 3; ++i) { - m_fields.get("current_fp",Direction{i},lev)->setVal(0.0); - m_fields.get("Efield_fp",Direction{i},lev)->setVal(0.0); - m_fields.get("Bfield_fp",Direction{i},lev)->setVal(0.0); + m_fields.get(FieldType::current_fp, Direction{i}, lev)->setVal(0.0); + m_fields.get(FieldType::Efield_fp, Direction{i}, lev)->setVal(0.0); + m_fields.get(FieldType::Bfield_fp, Direction{i}, lev)->setVal(0.0); } if (lev > 0) { for (int i = 0; i < 3; ++i) { - m_fields.get("Efield_aux", Direction{i}, lev)->setVal(0.0); - m_fields.get("Bfield_aux", Direction{i}, lev)->setVal(0.0); + m_fields.get(FieldType::Efield_aux, Direction{i}, lev)->setVal(0.0); + m_fields.get(FieldType::Bfield_aux, Direction{i}, lev)->setVal(0.0); - m_fields.get("current_cp",Direction{i},lev)->setVal(0.0); - m_fields.get("Efield_cp",Direction{i},lev)->setVal(0.0); - m_fields.get("Bfield_cp",Direction{i},lev)->setVal(0.0); + m_fields.get(FieldType::current_cp, Direction{i}, lev)->setVal(0.0); + m_fields.get(FieldType::Efield_cp, Direction{i}, lev)->setVal(0.0); + m_fields.get(FieldType::Bfield_cp, Direction{i}, lev)->setVal(0.0); } } - VisMF::Read(*m_fields.get("Efield_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ex_fp")); - VisMF::Read(*m_fields.get("Efield_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ey_fp")); - VisMF::Read(*m_fields.get("Efield_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ez_fp")); - VisMF::Read(*m_fields.get("Bfield_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bx_fp")); - VisMF::Read(*m_fields.get("Bfield_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "By_fp")); - VisMF::Read(*m_fields.get("Bfield_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bz_fp")); if (WarpX::fft_do_time_averaging) { - VisMF::Read(*m_fields.get("Efield_avg_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_avg_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ex_avg_fp")); - VisMF::Read(*m_fields.get("Efield_avg_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_avg_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ey_avg_fp")); - VisMF::Read(*m_fields.get("Efield_avg_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_avg_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ez_avg_fp")); - VisMF::Read(*m_fields.get("Bfield_avg_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_avg_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bx_avg_fp")); - VisMF::Read(*m_fields.get("Bfield_avg_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_avg_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "By_avg_fp")); - VisMF::Read(*m_fields.get("Bfield_avg_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_avg_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bz_avg_fp")); } if (is_synchronized) { - VisMF::Read(*m_fields.get("current_fp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::current_fp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "jx_fp")); - VisMF::Read(*m_fields.get("current_fp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::current_fp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "jy_fp")); - VisMF::Read(*m_fields.get("current_fp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::current_fp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "jz_fp")); } if (lev > 0) { - VisMF::Read(*m_fields.get("Efield_cp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ex_cp")); - VisMF::Read(*m_fields.get("Efield_cp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ey_cp")); - VisMF::Read(*m_fields.get("Efield_cp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ez_cp")); - VisMF::Read(*m_fields.get("Bfield_cp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bx_cp")); - VisMF::Read(*m_fields.get("Bfield_cp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "By_cp")); - VisMF::Read(*m_fields.get("Bfield_cp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bz_cp")); if (WarpX::fft_do_time_averaging) { - VisMF::Read(*m_fields.get("Efield_avg_cp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_avg_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ex_avg_cp")); - VisMF::Read(*m_fields.get("Efield_avg_cp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_avg_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ey_avg_cp")); - VisMF::Read(*m_fields.get("Efield_avg_cp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Efield_avg_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Ez_avg_cp")); - VisMF::Read(*m_fields.get("Bfield_avg_cp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_avg_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bx_avg_cp")); - VisMF::Read(*m_fields.get("Bfield_avg_cp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_avg_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "By_avg_cp")); - VisMF::Read(*m_fields.get("Bfield_avg_cp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::Bfield_avg_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "Bz_avg_cp")); } if (is_synchronized) { - VisMF::Read(*m_fields.get("current_cp", Direction{0}, lev), + VisMF::Read(*m_fields.get(FieldType::current_cp, Direction{0}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "jx_cp")); - VisMF::Read(*m_fields.get("current_cp", Direction{1}, lev), + VisMF::Read(*m_fields.get(FieldType::current_cp, Direction{1}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "jy_cp")); - VisMF::Read(*m_fields.get("current_cp", Direction{2}, lev), + VisMF::Read(*m_fields.get(FieldType::current_cp, Direction{2}, lev), amrex::MultiFabFileFullPrefix(lev, restart_chkfile, level_prefix, "jz_cp")); } } diff --git a/Source/EmbeddedBoundary/WarpXFaceExtensions.cpp b/Source/EmbeddedBoundary/WarpXFaceExtensions.cpp index b52ac88d289..61009fb46e0 100644 --- a/Source/EmbeddedBoundary/WarpXFaceExtensions.cpp +++ b/Source/EmbeddedBoundary/WarpXFaceExtensions.cpp @@ -7,6 +7,7 @@ #include "WarpXFaceInfoBox.H" #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" #include "Utils/TextMsg.H" #include "WarpX.H" @@ -18,6 +19,7 @@ #include using namespace ablastr::fields; +using warpx::fields::FieldType; /** * \brief Get the value of arr in the neighbor (i_n, j_n) on the plane with normal 'dim'. @@ -286,7 +288,7 @@ WarpX::ComputeFaceExtensions () void WarpX::InitBorrowing() { int idim = 0; - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { amrex::Box const &box = mfi.validbox(); auto &borrowing_x = (*m_borrowing[maxLevel()][idim])[mfi]; borrowing_x.inds_pointer.resize(box); @@ -302,7 +304,7 @@ WarpX::InitBorrowing() { } idim = 1; - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { amrex::Box const &box = mfi.validbox(); auto &borrowing_y = (*m_borrowing[maxLevel()][idim])[mfi]; borrowing_y.inds_pointer.resize(box); @@ -315,7 +317,7 @@ WarpX::InitBorrowing() { } idim = 2; - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { amrex::Box const &box = mfi.validbox(); auto &borrowing_z = (*m_borrowing[maxLevel()][idim])[mfi]; borrowing_z.inds_pointer.resize(box); @@ -456,10 +458,10 @@ WarpX::ComputeOneWayExtensions () WARPX_ABORT_WITH_MESSAGE( "ComputeOneWayExtensions: Only implemented in 2D3V and 3D3V"); #endif - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { amrex::Box const &box = mfi.validbox(); - auto const &S = m_fields.get("face_areas", Direction{idim}, maxLevel())->array(mfi); + auto const &S = m_fields.get(FieldType::face_areas, Direction{idim}, maxLevel())->array(mfi); auto const &flag_ext_face = m_flag_ext_face[maxLevel()][idim]->array(mfi); auto const &flag_info_face = m_flag_info_face[maxLevel()][idim]->array(mfi); auto &borrowing = (*m_borrowing[maxLevel()][idim])[mfi]; @@ -471,11 +473,11 @@ WarpX::ComputeOneWayExtensions () amrex::Real* borrowing_area = borrowing.area.data(); int& vecs_size = borrowing.vecs_size; - auto const &S_mod = m_fields.get("area_mod", Direction{idim}, maxLevel())->array(mfi); + auto const &S_mod = m_fields.get(FieldType::area_mod, Direction{idim}, maxLevel())->array(mfi); - const auto &lx = m_fields.get("edge_lengths", Direction{0}, maxLevel())->array(mfi); - const auto &ly = m_fields.get("edge_lengths", Direction{1}, maxLevel())->array(mfi); - const auto &lz = m_fields.get("edge_lengths", Direction{2}, maxLevel())->array(mfi); + const auto &lx = m_fields.get(FieldType::edge_lengths, Direction{0}, maxLevel())->array(mfi); + const auto &ly = m_fields.get(FieldType::edge_lengths, Direction{1}, maxLevel())->array(mfi); + const auto &lz = m_fields.get(FieldType::edge_lengths, Direction{2}, maxLevel())->array(mfi); vecs_size = amrex::Scan::PrefixSum(ncells, [=] AMREX_GPU_DEVICE (int icell) { @@ -583,11 +585,11 @@ WarpX::ComputeEightWaysExtensions () WARPX_ABORT_WITH_MESSAGE( "ComputeEightWaysExtensions: Only implemented in 2D3V and 3D3V"); #endif - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { amrex::Box const &box = mfi.validbox(); - auto const &S = m_fields.get("face_areas", Direction{idim}, maxLevel())->array(mfi); + auto const &S = m_fields.get(FieldType::face_areas, Direction{idim}, maxLevel())->array(mfi); auto const &flag_ext_face = m_flag_ext_face[maxLevel()][idim]->array(mfi); auto const &flag_info_face = m_flag_info_face[maxLevel()][idim]->array(mfi); auto &borrowing = (*m_borrowing[maxLevel()][idim])[mfi]; @@ -599,11 +601,11 @@ WarpX::ComputeEightWaysExtensions () amrex::Real* borrowing_area = borrowing.area.data(); int& vecs_size = borrowing.vecs_size; - auto const &S_mod = m_fields.get("area_mod", Direction{idim}, maxLevel())->array(mfi); + auto const &S_mod = m_fields.get(FieldType::area_mod, Direction{idim}, maxLevel())->array(mfi); - const auto &lx = m_fields.get("edge_lengths", Direction{0}, maxLevel())->array(mfi); - const auto &ly = m_fields.get("edge_lengths", Direction{1}, maxLevel())->array(mfi); - const auto &lz = m_fields.get("edge_lengths", Direction{2}, maxLevel())->array(mfi); + const auto &lx = m_fields.get(FieldType::edge_lengths, Direction{0}, maxLevel())->array(mfi); + const auto &ly = m_fields.get(FieldType::edge_lengths, Direction{1}, maxLevel())->array(mfi); + const auto &lz = m_fields.get(FieldType::edge_lengths, Direction{2}, maxLevel())->array(mfi); vecs_size += amrex::Scan::PrefixSum(ncells, [=] AMREX_GPU_DEVICE (int icell){ @@ -735,15 +737,15 @@ WarpX::ApplyBCKCorrection (const int idim) const amrex::Real dy = cell_size[1]; const amrex::Real dz = cell_size[2]; - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel()), amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel()), amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi) { const amrex::Box &box = mfi.tilebox(); const amrex::Array4 &flag_ext_face = m_flag_ext_face[maxLevel()][idim]->array(mfi); const amrex::Array4 &flag_info_face = m_flag_info_face[maxLevel()][idim]->array(mfi); - const amrex::Array4 &S = m_fields.get("face_areas", Direction{idim}, maxLevel())->array(mfi); - const amrex::Array4 &lx = m_fields.get("face_areas", Direction{0}, maxLevel())->array(mfi);; - const amrex::Array4 &ly = m_fields.get("face_areas", Direction{1}, maxLevel())->array(mfi);; - const amrex::Array4 &lz = m_fields.get("face_areas", Direction{2}, maxLevel())->array(mfi);; + const amrex::Array4 &S = m_fields.get(FieldType::face_areas, Direction{idim}, maxLevel())->array(mfi); + const amrex::Array4 &lx = m_fields.get(FieldType::face_areas, Direction{0}, maxLevel())->array(mfi);; + const amrex::Array4 &ly = m_fields.get(FieldType::face_areas, Direction{1}, maxLevel())->array(mfi);; + const amrex::Array4 &lz = m_fields.get(FieldType::face_areas, Direction{2}, maxLevel())->array(mfi);; amrex::ParallelFor(box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { if (flag_ext_face(i, j, k)) { @@ -763,7 +765,7 @@ void WarpX::ShrinkBorrowing () { for(int idim = 0; idim < AMREX_SPACEDIM; idim++) { - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp", Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { auto &borrowing = (*m_borrowing[maxLevel()][idim])[mfi]; borrowing.inds.resize(borrowing.vecs_size); borrowing.neigh_faces.resize(borrowing.vecs_size); diff --git a/Source/EmbeddedBoundary/WarpXInitEB.cpp b/Source/EmbeddedBoundary/WarpXInitEB.cpp index 0b98e13b5ab..edbc97a8efe 100644 --- a/Source/EmbeddedBoundary/WarpXInitEB.cpp +++ b/Source/EmbeddedBoundary/WarpXInitEB.cpp @@ -9,6 +9,7 @@ #include "EmbeddedBoundary/Enabled.H" #ifdef AMREX_USE_EB +# include "Fields.H" # include "Utils/Parser/ParserUtils.H" # include "Utils/TextMsg.H" @@ -292,8 +293,10 @@ WarpX::ScaleAreas (ablastr::fields::VectorField& face_areas, void -WarpX::MarkCells (){ +WarpX::MarkCells () +{ using ablastr::fields::Direction; + using warpx::fields::FieldType; #ifndef WARPX_DIM_RZ auto const &cell_size = CellSize(maxLevel()); @@ -310,9 +313,9 @@ WarpX::MarkCells (){ continue; } #endif - for (amrex::MFIter mfi(*m_fields.get("Bfield_fp",Direction{idim},maxLevel())); mfi.isValid(); ++mfi) { + for (amrex::MFIter mfi(*m_fields.get(FieldType::Bfield_fp, Direction{idim}, maxLevel())); mfi.isValid(); ++mfi) { auto* face_areas_idim_max_lev = - m_fields.get("face_areas", Direction{idim}, maxLevel()); + m_fields.get(FieldType::face_areas, Direction{idim}, maxLevel()); const amrex::Box& box = mfi.tilebox(face_areas_idim_max_lev->ixType().toIntVect(), face_areas_idim_max_lev->nGrowVect() ); @@ -320,10 +323,10 @@ WarpX::MarkCells (){ auto const &S = face_areas_idim_max_lev->array(mfi); auto const &flag_info_face = m_flag_info_face[maxLevel()][idim]->array(mfi); auto const &flag_ext_face = m_flag_ext_face[maxLevel()][idim]->array(mfi); - const auto &lx = m_fields.get("edge_lengths", Direction{0}, maxLevel())->array(mfi); - const auto &ly = m_fields.get("edge_lengths", Direction{1}, maxLevel())->array(mfi); - const auto &lz = m_fields.get("edge_lengths", Direction{2}, maxLevel())->array(mfi); - auto const &mod_areas_dim = m_fields.get("area_mod", Direction{idim}, maxLevel())->array(mfi); + const auto &lx = m_fields.get(FieldType::edge_lengths, Direction{0}, maxLevel())->array(mfi); + const auto &ly = m_fields.get(FieldType::edge_lengths, Direction{1}, maxLevel())->array(mfi); + const auto &lz = m_fields.get(FieldType::edge_lengths, Direction{2}, maxLevel())->array(mfi); + auto const &mod_areas_dim = m_fields.get(FieldType::area_mod, Direction{idim}, maxLevel())->array(mfi); const amrex::Real dx = cell_size[0]; const amrex::Real dy = cell_size[1]; @@ -387,11 +390,12 @@ WarpX::ComputeDistanceToEB () } #ifdef AMREX_USE_EB BL_PROFILE("ComputeDistanceToEB"); + using warpx::fields::FieldType; const amrex::EB2::IndexSpace& eb_is = amrex::EB2::IndexSpace::top(); for (int lev=0; lev<=maxLevel(); lev++) { const amrex::EB2::Level& eb_level = eb_is.getLevel(Geom(lev)); auto const eb_fact = fieldEBFactory(lev); - amrex::FillSignedDistance(*m_fields.get("distance_to_eb", lev), eb_level, eb_fact, 1); + amrex::FillSignedDistance(*m_fields.get(FieldType::distance_to_eb, lev), eb_level, eb_fact, 1); } #endif } diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp index dc684fc39ed..93d265d598f 100644 --- a/Source/Evolve/WarpXEvolve.cpp +++ b/Source/Evolve/WarpXEvolve.cpp @@ -15,6 +15,7 @@ #include "Diagnostics/ReducedDiags/MultiReducedDiags.H" #include "EmbeddedBoundary/Enabled.H" #include "Evolve/WarpXDtType.H" +#include "Fields.H" #include "FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H" #ifdef WARPX_USE_FFT # ifdef WARPX_DIM_RZ @@ -63,6 +64,8 @@ using ablastr::utils::SignalHandling; void WarpX::Synchronize () { using ablastr::fields::Direction; + using warpx::fields::FieldType; + FillBoundaryE(guard_cells.ng_FieldGather); FillBoundaryB(guard_cells.ng_FieldGather); if (fft_do_time_averaging) @@ -76,12 +79,12 @@ WarpX::Synchronize () { mypc->PushP( lev, 0.5_rt*dt[lev], - *m_fields.get("Efield_aux", Direction{0}, lev), - *m_fields.get("Efield_aux", Direction{1}, lev), - *m_fields.get("Efield_aux", Direction{2}, lev), - *m_fields.get("Bfield_aux", Direction{0}, lev), - *m_fields.get("Bfield_aux", Direction{1}, lev), - *m_fields.get("Bfield_aux", Direction{2}, lev) + *m_fields.get(FieldType::Efield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{2}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{2}, lev) ); } is_synchronized = true; @@ -473,6 +476,7 @@ void WarpX::ExplicitFillBoundaryEBUpdateAux () "Cannot call WarpX::ExplicitFillBoundaryEBUpdateAux without Explicit evolve scheme set!"); using ablastr::fields::Direction; + using warpx::fields::FieldType; // At the beginning, we have B^{n} and E^{n}. // Particles have p^{n} and x^{n}. @@ -491,12 +495,12 @@ void WarpX::ExplicitFillBoundaryEBUpdateAux () mypc->PushP( lev, -0.5_rt*dt[lev], - *m_fields.get("Efield_aux", Direction{0}, lev), - *m_fields.get("Efield_aux", Direction{1}, lev), - *m_fields.get("Efield_aux", Direction{2}, lev), - *m_fields.get("Bfield_aux", Direction{0}, lev), - *m_fields.get("Bfield_aux", Direction{1}, lev), - *m_fields.get("Bfield_aux", Direction{2}, lev) + *m_fields.get(FieldType::Efield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{2}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{2}, lev) ); } is_synchronized = false; @@ -561,9 +565,10 @@ void WarpX::HandleParticlesAtBoundaries (int step, amrex::Real cur_time, int num // interact the particles with EB walls (if present) if (EB::enabled()) { - mypc->ScrapeParticlesAtEB(m_fields.get_mr_levels("distance_to_eb", finest_level)); + using warpx::fields::FieldType; + mypc->ScrapeParticlesAtEB(m_fields.get_mr_levels(FieldType::distance_to_eb, finest_level)); m_particle_boundary_buffer->gatherParticlesFromEmbeddedBoundaries( - *mypc, m_fields.get_mr_levels("distance_to_eb", finest_level)); + *mypc, m_fields.get_mr_levels(FieldType::distance_to_eb, finest_level)); mypc->deleteInvalidParticles(); } @@ -578,6 +583,7 @@ void WarpX::HandleParticlesAtBoundaries (int step, amrex::Real cur_time, int num void WarpX::SyncCurrentAndRho () { using ablastr::fields::Direction; + using warpx::fields::FieldType; if (electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD) { @@ -610,7 +616,7 @@ void WarpX::SyncCurrentAndRho () // TODO This works only without mesh refinement const int lev = 0; if (use_filter) { - ApplyFilterJ(m_fields.get_mr_levels_alldirs("current_fp_vay", finest_level), lev); + ApplyFilterJ(m_fields.get_mr_levels_alldirs(FieldType::current_fp_vay, finest_level), lev); } } } @@ -624,22 +630,22 @@ void WarpX::SyncCurrentAndRho () // Reflect charge and current density over PEC boundaries, if needed. for (int lev = 0; lev <= finest_level; ++lev) { - if (m_fields.has("rho_fp", lev)) { - ApplyRhofieldBoundary(lev, m_fields.get("rho_fp",lev), PatchType::fine); + if (m_fields.has(FieldType::rho_fp, lev)) { + ApplyRhofieldBoundary(lev, m_fields.get(FieldType::rho_fp,lev), PatchType::fine); } ApplyJfieldBoundary(lev, - m_fields.get("current_fp",Direction{0},lev), - m_fields.get("current_fp",Direction{1},lev), - m_fields.get("current_fp",Direction{2},lev), + m_fields.get(FieldType::current_fp, Direction{0}, lev), + m_fields.get(FieldType::current_fp, Direction{1}, lev), + m_fields.get(FieldType::current_fp, Direction{2}, lev), PatchType::fine); if (lev > 0) { - if (m_fields.has("rho_cp", lev)) { - ApplyRhofieldBoundary(lev, m_fields.get("rho_cp",lev), PatchType::coarse); + if (m_fields.has(FieldType::rho_cp, lev)) { + ApplyRhofieldBoundary(lev, m_fields.get(FieldType::rho_cp,lev), PatchType::coarse); } ApplyJfieldBoundary(lev, - m_fields.get("current_cp",Direction{0},lev), - m_fields.get("current_cp",Direction{1},lev), - m_fields.get("current_cp",Direction{2},lev), + m_fields.get(FieldType::current_cp, Direction{0}, lev), + m_fields.get(FieldType::current_cp, Direction{1}, lev), + m_fields.get(FieldType::current_cp, Direction{2}, lev), PatchType::coarse); } } @@ -655,6 +661,8 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) "multi-J algorithm not implemented for FDTD" ); + using warpx::fields::FieldType; + const int rho_mid = spectral_solver_fp[0]->m_spectral_index.rho_mid; const int rho_new = spectral_solver_fp[0]->m_spectral_index.rho_new; @@ -675,9 +683,9 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) // 3) Deposit rho (in rho_new, since it will be moved during the loop) // (after checking that pointer to rho_fp on MR level 0 is not null) - if (m_fields.has("rho_fp", 0) && rho_in_time == RhoInTime::Linear) + if (m_fields.has(FieldType::rho_fp, 0) && rho_in_time == RhoInTime::Linear) { - ablastr::fields::MultiLevelScalarField const rho_fp = m_fields.get_mr_levels("rho_fp", finest_level); + ablastr::fields::MultiLevelScalarField const rho_fp = m_fields.get_mr_levels(FieldType::rho_fp, finest_level); std::string const rho_fp_string = "rho_fp"; std::string const rho_cp_string = "rho_cp"; @@ -742,9 +750,9 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) // Deposit new rho // (after checking that pointer to rho_fp on MR level 0 is not null) - if (m_fields.has("rho_fp", 0)) + if (m_fields.has(FieldType::rho_fp, 0)) { - ablastr::fields::MultiLevelScalarField const rho_fp = m_fields.get_mr_levels("rho_fp", finest_level); + ablastr::fields::MultiLevelScalarField const rho_fp = m_fields.get_mr_levels(FieldType::rho_fp, finest_level); std::string const rho_fp_string = "rho_fp"; std::string const rho_cp_string = "rho_cp"; @@ -786,10 +794,10 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) // We summed the integral of the field over 2*dt PSATDScaleAverageFields(1._rt / (2._rt*dt[0])); PSATDBackwardTransformEBavg( - m_fields.get_mr_levels_alldirs("Efield_avg_fp", finest_level), - m_fields.get_mr_levels_alldirs("Bfield_avg_fp", finest_level), - m_fields.get_mr_levels_alldirs("Efield_avg_cp", finest_level), - m_fields.get_mr_levels_alldirs("Bfield_avg_cp", finest_level) + m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_cp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_cp, finest_level) ); } @@ -858,22 +866,24 @@ WarpX::OneStep_sub1 (Real cur_time) const int fine_lev = 1; const int coarse_lev = 0; + using warpx::fields::FieldType; + // i) Push particles and fields on the fine patch (first fine step) PushParticlesandDeposit(fine_lev, cur_time, DtType::FirstHalf); RestrictCurrentFromFineToCoarsePatch( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), - m_fields.get_mr_levels_alldirs("current_cp", finest_level), fine_lev); + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_cp, finest_level), fine_lev); RestrictRhoFromFineToCoarsePatch(fine_lev); if (use_filter) { - ApplyFilterJ( m_fields.get_mr_levels_alldirs("current_fp", finest_level), fine_lev); + ApplyFilterJ( m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), fine_lev); } SumBoundaryJ( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), fine_lev, Geom(fine_lev).periodicity()); ApplyFilterandSumBoundaryRho( - m_fields.get_mr_levels("rho_fp", finest_level), - m_fields.get_mr_levels("rho_cp", finest_level), + m_fields.get_mr_levels(FieldType::rho_fp, finest_level), + m_fields.get_mr_levels(FieldType::rho_cp, finest_level), fine_lev, PatchType::fine, 0, 2*ncomps); EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf); @@ -903,13 +913,13 @@ WarpX::OneStep_sub1 (Real cur_time) PushParticlesandDeposit(coarse_lev, cur_time, DtType::Full); StoreCurrent(coarse_lev); AddCurrentFromFineLevelandSumBoundary( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), - m_fields.get_mr_levels_alldirs("current_cp", finest_level), - m_fields.get_mr_levels_alldirs("current_buf", finest_level), coarse_lev); + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_cp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_buf, finest_level), coarse_lev); AddRhoFromFineLevelandSumBoundary( - m_fields.get_mr_levels("rho_fp", finest_level), - m_fields.get_mr_levels("rho_cp", finest_level), - m_fields.get_mr_levels("rho_buf", finest_level), + m_fields.get_mr_levels(FieldType::rho_fp, finest_level), + m_fields.get_mr_levels(FieldType::rho_cp, finest_level), + m_fields.get_mr_levels(FieldType::rho_buf, finest_level), coarse_lev, 0, ncomps); EvolveB(fine_lev, PatchType::coarse, dt[fine_lev], DtType::FirstHalf); @@ -939,16 +949,16 @@ WarpX::OneStep_sub1 (Real cur_time) // iv) Push particles and fields on the fine patch (second fine step) PushParticlesandDeposit(fine_lev, cur_time + dt[fine_lev], DtType::SecondHalf); RestrictCurrentFromFineToCoarsePatch( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), - m_fields.get_mr_levels_alldirs("current_cp", finest_level), fine_lev); + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_cp, finest_level), fine_lev); RestrictRhoFromFineToCoarsePatch(fine_lev); if (use_filter) { - ApplyFilterJ( m_fields.get_mr_levels_alldirs("current_fp", finest_level), fine_lev); + ApplyFilterJ( m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), fine_lev); } - SumBoundaryJ( m_fields.get_mr_levels_alldirs("current_fp", finest_level), fine_lev, Geom(fine_lev).periodicity()); + SumBoundaryJ( m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), fine_lev, Geom(fine_lev).periodicity()); ApplyFilterandSumBoundaryRho( - m_fields.get_mr_levels("rho_fp", finest_level), - m_fields.get_mr_levels("rho_cp", finest_level), + m_fields.get_mr_levels(FieldType::rho_fp, finest_level), + m_fields.get_mr_levels(FieldType::rho_cp, finest_level), fine_lev, PatchType::fine, 0, ncomps); EvolveB(fine_lev, PatchType::fine, 0.5_rt*dt[fine_lev], DtType::FirstHalf); @@ -977,14 +987,14 @@ WarpX::OneStep_sub1 (Real cur_time) // by only half a coarse step (second half) RestoreCurrent(coarse_lev); AddCurrentFromFineLevelandSumBoundary( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), - m_fields.get_mr_levels_alldirs("current_cp", finest_level), - m_fields.get_mr_levels_alldirs("current_buf", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_cp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_buf, finest_level), coarse_lev); AddRhoFromFineLevelandSumBoundary( - m_fields.get_mr_levels("rho_fp", finest_level), - m_fields.get_mr_levels("rho_cp", finest_level), - m_fields.get_mr_levels("rho_buf", finest_level), + m_fields.get_mr_levels(FieldType::rho_fp, finest_level), + m_fields.get_mr_levels(FieldType::rho_cp, finest_level), + m_fields.get_mr_levels(FieldType::rho_buf, finest_level), coarse_lev, ncomps, ncomps); EvolveE(fine_lev, PatchType::coarse, dt[fine_lev]); @@ -1047,15 +1057,16 @@ void WarpX::doFieldIonization (int lev) { using ablastr::fields::Direction; + using warpx::fields::FieldType; mypc->doFieldIonization( lev, - *m_fields.get("Efield_aux", Direction{0}, lev), - *m_fields.get("Efield_aux", Direction{1}, lev), - *m_fields.get("Efield_aux", Direction{2}, lev), - *m_fields.get("Bfield_aux", Direction{0}, lev), - *m_fields.get("Bfield_aux", Direction{1}, lev), - *m_fields.get("Bfield_aux", Direction{2}, lev) + *m_fields.get(FieldType::Efield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{2}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{2}, lev) ); } @@ -1072,15 +1083,16 @@ void WarpX::doQEDEvents (int lev) { using ablastr::fields::Direction; + using warpx::fields::FieldType; mypc->doQedEvents( lev, - *m_fields.get("Efield_aux", Direction{0}, lev), - *m_fields.get("Efield_aux", Direction{1}, lev), - *m_fields.get("Efield_aux", Direction{2}, lev), - *m_fields.get("Bfield_aux", Direction{0}, lev), - *m_fields.get("Bfield_aux", Direction{1}, lev), - *m_fields.get("Bfield_aux", Direction{2}, lev) + *m_fields.get(FieldType::Efield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Efield_aux, Direction{2}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), + *m_fields.get(FieldType::Bfield_aux, Direction{2}, lev) ); } #endif @@ -1100,6 +1112,7 @@ WarpX::PushParticlesandDeposit (int lev, amrex::Real cur_time, DtType a_dt_type, PushType push_type) { using ablastr::fields::Direction; + using warpx::fields::FieldType; std::string current_fp_string; @@ -1130,21 +1143,21 @@ WarpX::PushParticlesandDeposit (int lev, amrex::Real cur_time, DtType a_dt_type, #ifdef WARPX_DIM_RZ // This is called after all particles have deposited their current and charge. ApplyInverseVolumeScalingToCurrentDensity( - m_fields.get("current_fp", Direction{0}, lev), - m_fields.get("current_fp", Direction{1}, lev), - m_fields.get("current_fp", Direction{2}, lev), + m_fields.get(FieldType::current_fp, Direction{0}, lev), + m_fields.get(FieldType::current_fp, Direction{1}, lev), + m_fields.get(FieldType::current_fp, Direction{2}, lev), lev); - if (m_fields.has("current_buf", Direction{0}, lev)) { + if (m_fields.has(FieldType::current_buf, Direction{0}, lev)) { ApplyInverseVolumeScalingToCurrentDensity( - m_fields.get("current_buf", Direction{0}, lev), - m_fields.get("current_buf", Direction{1}, lev), - m_fields.get("current_buf", Direction{2}, lev), + m_fields.get(FieldType::current_buf, Direction{0}, lev), + m_fields.get(FieldType::current_buf, Direction{1}, lev), + m_fields.get(FieldType::current_buf, Direction{2}, lev), lev-1); } - if (m_fields.has("rho_fp", lev)) { - ApplyInverseVolumeScalingToChargeDensity(m_fields.get("rho_fp", lev), lev); - if (m_fields.has("rho_buf", lev)) { - ApplyInverseVolumeScalingToChargeDensity(m_fields.get("rho_buf", lev), lev-1); + if (m_fields.has(FieldType::rho_fp, lev)) { + ApplyInverseVolumeScalingToChargeDensity(m_fields.get(FieldType::rho_fp, lev), lev); + if (m_fields.has(FieldType::rho_buf, lev)) { + ApplyInverseVolumeScalingToChargeDensity(m_fields.get(FieldType::rho_buf, lev), lev-1); } } // #else diff --git a/Source/FieldSolver/ElectrostaticSolvers/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolvers/ElectrostaticSolver.cpp index 50a9aab4980..1ced0a07152 100644 --- a/Source/FieldSolver/ElectrostaticSolvers/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolvers/ElectrostaticSolver.cpp @@ -8,10 +8,14 @@ */ #include "ElectrostaticSolver.H" -#include #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" + +#include + using namespace amrex; +using warpx::fields::FieldType; ElectrostaticSolver::ElectrostaticSolver (int nlevs_max) : num_levels{nlevs_max} { @@ -153,18 +157,18 @@ ElectrostaticSolver::computePhi ( e_field.push_back( #if defined(WARPX_DIM_1D_Z) amrex::Array{ - warpx.m_fields.get("Efield_fp", Direction{2}, lev) + warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev) } #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) amrex::Array{ - warpx.m_fields.get("Efield_fp", Direction{0}, lev), - warpx.m_fields.get("Efield_fp", Direction{2}, lev) + warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev), + warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev) } #elif defined(WARPX_DIM_3D) amrex::Array{ - warpx.m_fields.get("Efield_fp", Direction{0}, lev), - warpx.m_fields.get("Efield_fp", Direction{1}, lev), - warpx.m_fields.get("Efield_fp", Direction{2}, lev) + warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev), + warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, lev), + warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, lev) } #endif ); diff --git a/Source/FieldSolver/ElectrostaticSolvers/LabFrameExplicitES.cpp b/Source/FieldSolver/ElectrostaticSolvers/LabFrameExplicitES.cpp index eec5dce8f0e..e973ae66975 100644 --- a/Source/FieldSolver/ElectrostaticSolvers/LabFrameExplicitES.cpp +++ b/Source/FieldSolver/ElectrostaticSolvers/LabFrameExplicitES.cpp @@ -9,6 +9,7 @@ #include "LabFrameExplicitES.H" #include "Fluids/MultiFluidContainer_fwd.H" #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" #include "Particles/MultiParticleContainer_fwd.H" #include "Python/callbacks.H" #include "WarpX.H" @@ -28,11 +29,12 @@ void LabFrameExplicitES::ComputeSpaceChargeField ( { using ablastr::fields::MultiLevelScalarField; using ablastr::fields::MultiLevelVectorField; + using warpx::fields::FieldType; - const MultiLevelScalarField rho_fp = fields.get_mr_levels("rho_fp", max_level); - const MultiLevelScalarField rho_cp = fields.get_mr_levels("rho_cp", max_level); - const MultiLevelScalarField phi_fp = fields.get_mr_levels("phi_fp", max_level); - const MultiLevelVectorField Efield_fp = fields.get_mr_levels_alldirs("Efield_fp", max_level); + const MultiLevelScalarField rho_fp = fields.get_mr_levels(FieldType::rho_fp, max_level); + const MultiLevelScalarField rho_cp = fields.get_mr_levels(FieldType::rho_cp, max_level); + const MultiLevelScalarField phi_fp = fields.get_mr_levels(FieldType::phi_fp, max_level); + const MultiLevelVectorField Efield_fp = fields.get_mr_levels_alldirs(FieldType::Efield_fp, max_level); mpc.DepositCharge(rho_fp, 0.0_rt); if (mfl) { diff --git a/Source/FieldSolver/ElectrostaticSolvers/RelativisticExplicitES.cpp b/Source/FieldSolver/ElectrostaticSolvers/RelativisticExplicitES.cpp index ae4006c2782..69647da1702 100644 --- a/Source/FieldSolver/ElectrostaticSolvers/RelativisticExplicitES.cpp +++ b/Source/FieldSolver/ElectrostaticSolvers/RelativisticExplicitES.cpp @@ -6,12 +6,13 @@ * * License: BSD-3-Clause-LBNL */ -#include "WarpX.H" - #include "RelativisticExplicitES.H" +#include "Fields.H" #include "Particles/MultiParticleContainer.H" #include "Particles/WarpXParticleContainer.H" +#include "WarpX.H" + using namespace amrex; @@ -35,14 +36,15 @@ void RelativisticExplicitES::ComputeSpaceChargeField ( [[maybe_unused]] MultiFluidContainer* mfl, int max_level) { - using ablastr::fields::MultiLevelVectorField; - WARPX_PROFILE("RelativisticExplicitES::ComputeSpaceChargeField"); + using ablastr::fields::MultiLevelVectorField; + using warpx::fields::FieldType; + const bool always_run_solve = (WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::Relativistic); - MultiLevelVectorField Efield_fp = fields.get_mr_levels_alldirs("Efield_fp", max_level); - MultiLevelVectorField Bfield_fp = fields.get_mr_levels_alldirs("Bfield_fp", max_level); + MultiLevelVectorField Efield_fp = fields.get_mr_levels_alldirs(FieldType::Efield_fp, max_level); + MultiLevelVectorField Bfield_fp = fields.get_mr_levels_alldirs(FieldType::Bfield_fp, max_level); // Loop over the species and add their space-charge contribution to E and B. // Note that the fields calculated here does not include the E field diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp index a5b85f7fbd7..63b51cb8416 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp @@ -7,6 +7,7 @@ #include "FiniteDifferenceSolver.H" #include "EmbeddedBoundary/WarpXFaceInfoBox.H" +#include "Fields.H" #ifndef WARPX_DIM_RZ # include "FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H" # include "FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H" @@ -53,13 +54,16 @@ void FiniteDifferenceSolver::EvolveB ( PatchType patch_type, [[maybe_unused]] std::array< std::unique_ptr, 3 >& flag_info_cell, [[maybe_unused]] std::array< std::unique_ptr >, 3 >& borrowing, - [[maybe_unused]] amrex::Real const dt ) { + [[maybe_unused]] amrex::Real const dt ) +{ using ablastr::fields::Direction; + using warpx::fields::FieldType; + const ablastr::fields::VectorField Bfield = patch_type == PatchType::fine ? - fields.get_alldirs("Bfield_fp", lev) : fields.get_alldirs("Bfield_cp", lev); + fields.get_alldirs(FieldType::Bfield_fp, lev) : fields.get_alldirs(FieldType::Bfield_cp, lev); const ablastr::fields::VectorField Efield = patch_type == PatchType::fine ? - fields.get_alldirs("Efield_fp", lev) : fields.get_alldirs("Efield_cp", lev); + fields.get_alldirs(FieldType::Efield_fp, lev) : fields.get_alldirs(FieldType::Efield_cp, lev); // Select algorithm (The choice of algorithm is a runtime option, // but we compile code for each algorithm, using templates) @@ -70,25 +74,25 @@ void FiniteDifferenceSolver::EvolveB ( #else amrex::MultiFab const * Gfield = nullptr; - if (fields.has("G_fp", lev)) { + if (fields.has(FieldType::G_fp, lev)) { Gfield = patch_type == PatchType::fine ? - fields.get("G_fp", lev) : fields.get("G_cp", lev); + fields.get(FieldType::G_fp, lev) : fields.get(FieldType::G_cp, lev); } ablastr::fields::VectorField face_areas; - if (fields.has("face_areas", Direction{0}, lev)) { - face_areas = fields.get_alldirs("face_areas", lev); + if (fields.has(FieldType::face_areas, Direction{0}, lev)) { + face_areas = fields.get_alldirs(FieldType::face_areas, lev); } ablastr::fields::VectorField area_mod; - if (fields.has("area_mod", Direction{0}, lev)) { - area_mod = fields.get_alldirs("area_mod", lev); + if (fields.has(FieldType::area_mod, Direction{0}, lev)) { + area_mod = fields.get_alldirs(FieldType::area_mod, lev); } ablastr::fields::VectorField ECTRhofield; - if (fields.has("ECTRhofield", Direction{0}, lev)) { - ECTRhofield = fields.get_alldirs("ECTRhofield", lev); + if (fields.has(FieldType::ECTRhofield, Direction{0}, lev)) { + ECTRhofield = fields.get_alldirs(FieldType::ECTRhofield, lev); } ablastr::fields::VectorField Venl; - if (fields.has("Venl", Direction{0}, lev)) { - Venl = fields.get_alldirs("Venl", lev); + if (fields.has(FieldType::Venl, Direction{0}, lev)) { + Venl = fields.get_alldirs(FieldType::Venl, lev); } if (m_grid_type == GridType::Collocated) { diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp index 5d46d18ff4e..e3289d52cfe 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp @@ -7,6 +7,7 @@ #include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H" #include "BoundaryConditions/PMLComponent.H" +#include "Fields.H" #ifndef WARPX_DIM_RZ # include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H" @@ -48,6 +49,7 @@ void FiniteDifferenceSolver::EvolveBPML ( const bool dive_cleaning ) { + using warpx::fields::FieldType; // Select algorithm (The choice of algorithm is a runtime option, // but we compile code for each algorithm, using templates) @@ -57,9 +59,9 @@ void FiniteDifferenceSolver::EvolveBPML ( "PML are not implemented in cylindrical geometry."); #else const ablastr::fields::VectorField Bfield = (patch_type == PatchType::fine) ? - fields.get_alldirs("pml_B_fp", level) : fields.get_alldirs("pml_B_cp", level); + fields.get_alldirs(FieldType::pml_B_fp, level) : fields.get_alldirs(FieldType::pml_B_cp, level); const ablastr::fields::VectorField Efield = (patch_type == PatchType::fine) ? - fields.get_alldirs("pml_E_fp", level) : fields.get_alldirs("pml_E_cp", level); + fields.get_alldirs(FieldType::pml_E_fp, level) : fields.get_alldirs(FieldType::pml_E_cp, level); if (m_grid_type == ablastr::utils::enums::GridType::Collocated) { diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp index e9877c63f87..db8e80cc972 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp @@ -6,6 +6,7 @@ */ #include "FiniteDifferenceSolver.H" +#include "Fields.H" #ifndef WARPX_DIM_RZ # include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H" # include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H" @@ -58,32 +59,34 @@ void FiniteDifferenceSolver::EvolveE ( ) { using ablastr::fields::Direction; + using warpx::fields::FieldType; + const ablastr::fields::VectorField Bfield = patch_type == PatchType::fine ? - fields.get_alldirs("Bfield_fp", lev) : fields.get_alldirs("Bfield_cp", lev); + fields.get_alldirs(FieldType::Bfield_fp, lev) : fields.get_alldirs(FieldType::Bfield_cp, lev); const ablastr::fields::VectorField Jfield = patch_type == PatchType::fine ? - fields.get_alldirs("current_fp", lev) : fields.get_alldirs("current_cp", lev); + fields.get_alldirs(FieldType::current_fp, lev) : fields.get_alldirs(FieldType::current_cp, lev); amrex::MultiFab* Ffield = nullptr; - if (fields.has("F_fp", lev)) { + if (fields.has(FieldType::F_fp, lev)) { Ffield = patch_type == PatchType::fine ? - fields.get("F_fp", lev) : fields.get("F_cp", lev); + fields.get(FieldType::F_fp, lev) : fields.get(FieldType::F_cp, lev); } ablastr::fields::VectorField edge_lengths; - if (fields.has("edge_lengths", Direction{0}, lev)) { - edge_lengths = fields.get_alldirs("edge_lengths", lev); + if (fields.has(FieldType::edge_lengths, Direction{0}, lev)) { + edge_lengths = fields.get_alldirs(FieldType::edge_lengths, lev); } ablastr::fields::VectorField face_areas; - if (fields.has("face_areas", Direction{0}, lev)) { - face_areas = fields.get_alldirs("face_areas", lev); + if (fields.has(FieldType::face_areas, Direction{0}, lev)) { + face_areas = fields.get_alldirs(FieldType::face_areas, lev); } ablastr::fields::VectorField area_mod; - if (fields.has("area_mod", Direction{0}, lev)) { - area_mod = fields.get_alldirs("area_mod", lev); + if (fields.has(FieldType::area_mod, Direction{0}, lev)) { + area_mod = fields.get_alldirs(FieldType::area_mod, lev); } ablastr::fields::VectorField ECTRhofield; - if (fields.has("ECTRhofield", Direction{0}, lev)) { - ECTRhofield = fields.get_alldirs("ECTRhofield", lev); + if (fields.has(FieldType::ECTRhofield, Direction{0}, lev)) { + ECTRhofield = fields.get_alldirs(FieldType::ECTRhofield, lev); } // Select algorithm (The choice of algorithm is a runtime option, diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp index d678bed3b01..9ecae05516d 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp @@ -17,6 +17,7 @@ # include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H" #endif #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" #include "Utils/TextMsg.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXConst.H" @@ -59,20 +60,22 @@ void FiniteDifferenceSolver::EvolveEPML ( "PML are not implemented in cylindrical geometry."); #else using ablastr::fields::Direction; + using warpx::fields::FieldType; + const ablastr::fields::VectorField Efield = (patch_type == PatchType::fine) ? - fields.get_alldirs("pml_E_fp", level) : fields.get_alldirs("pml_E_cp", level); + fields.get_alldirs(FieldType::pml_E_fp, level) : fields.get_alldirs(FieldType::pml_E_cp, level); const ablastr::fields::VectorField Bfield = (patch_type == PatchType::fine) ? - fields.get_alldirs("pml_B_fp", level) : fields.get_alldirs("pml_B_cp", level); + fields.get_alldirs(FieldType::pml_B_fp, level) : fields.get_alldirs(FieldType::pml_B_cp, level); const ablastr::fields::VectorField Jfield = (patch_type == PatchType::fine) ? - fields.get_alldirs("pml_j_fp", level) : fields.get_alldirs("pml_j_cp", level); + fields.get_alldirs(FieldType::pml_j_fp, level) : fields.get_alldirs(FieldType::pml_j_cp, level); ablastr::fields::VectorField edge_lengths; - if (fields.has("pml_edge_lengths", Direction{0}, level)) { - edge_lengths = fields.get_alldirs("pml_edge_lengths", level); + if (fields.has(FieldType::pml_edge_lengths, Direction{0}, level)) { + edge_lengths = fields.get_alldirs(FieldType::pml_edge_lengths, level); } amrex::MultiFab * Ffield = nullptr; - if (fields.has("pml_F_fp", level)) { + if (fields.has(FieldType::pml_F_fp, level)) { Ffield = (patch_type == PatchType::fine) ? - fields.get("pml_F_fp", level) : fields.get("pml_F_cp", level); + fields.get(FieldType::pml_F_fp, level) : fields.get(FieldType::pml_F_cp, level); } if (m_grid_type == GridType::Collocated) { diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp index dba8a7de3f9..dbf56a0e899 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp @@ -14,7 +14,7 @@ #include "WarpX.H" using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; HybridPICModel::HybridPICModel () { @@ -73,42 +73,42 @@ void HybridPICModel::AllocateLevelMFs (ablastr::fields::MultiFabRegister & field // interpolated or extrapolated to appropriate timesteps. // The "hybrid_current_fp_ampere" multifab stores the total current calculated as // the curl of B. - fields.alloc_init("hybrid_electron_pressure_fp", + fields.alloc_init(FieldType::hybrid_electron_pressure_fp, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); - fields.alloc_init("hybrid_rho_fp_temp", + fields.alloc_init(FieldType::hybrid_rho_fp_temp, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); - fields.alloc_init("hybrid_current_fp_temp", Direction{0}, + fields.alloc_init(FieldType::hybrid_current_fp_temp, Direction{0}, lev, amrex::convert(ba, jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - fields.alloc_init("hybrid_current_fp_temp", Direction{1}, + fields.alloc_init(FieldType::hybrid_current_fp_temp, Direction{1}, lev, amrex::convert(ba, jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - fields.alloc_init("hybrid_current_fp_temp", Direction{2}, + fields.alloc_init(FieldType::hybrid_current_fp_temp, Direction{2}, lev, amrex::convert(ba, jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - fields.alloc_init("hybrid_current_fp_ampere", Direction{0}, + fields.alloc_init(FieldType::hybrid_current_fp_ampere, Direction{0}, lev, amrex::convert(ba, jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - fields.alloc_init("hybrid_current_fp_ampere", Direction{1}, + fields.alloc_init(FieldType::hybrid_current_fp_ampere, Direction{1}, lev, amrex::convert(ba, jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - fields.alloc_init("hybrid_current_fp_ampere", Direction{2}, + fields.alloc_init(FieldType::hybrid_current_fp_ampere, Direction{2}, lev, amrex::convert(ba, jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); // the external current density multifab is made nodal to avoid needing to interpolate // to a nodal grid as has to be done for the ion and total current density multifabs // this also allows the external current multifab to not have any ghost cells - fields.alloc_init("hybrid_current_fp_external", Direction{0}, + fields.alloc_init(FieldType::hybrid_current_fp_external, Direction{0}, lev, amrex::convert(ba, IntVect(AMREX_D_DECL(1,1,1))), dm, ncomps, IntVect(AMREX_D_DECL(0,0,0)), 0.0_rt); - fields.alloc_init("hybrid_current_fp_external", Direction{1}, + fields.alloc_init(FieldType::hybrid_current_fp_external, Direction{1}, lev, amrex::convert(ba, IntVect(AMREX_D_DECL(1,1,1))), dm, ncomps, IntVect(AMREX_D_DECL(0,0,0)), 0.0_rt); - fields.alloc_init("hybrid_current_fp_external", Direction{2}, + fields.alloc_init(FieldType::hybrid_current_fp_external, Direction{2}, lev, amrex::convert(ba, IntVect(AMREX_D_DECL(1,1,1))), dm, ncomps, IntVect(AMREX_D_DECL(0,0,0)), 0.0_rt); @@ -147,15 +147,15 @@ void HybridPICModel::InitData () using ablastr::fields::Direction; // Get the grid staggering of the fields involved in calculating E - amrex::IntVect Jx_stag = warpx.m_fields.get("current_fp",Direction{0},0)->ixType().toIntVect(); - amrex::IntVect Jy_stag = warpx.m_fields.get("current_fp",Direction{1},0)->ixType().toIntVect(); - amrex::IntVect Jz_stag = warpx.m_fields.get("current_fp",Direction{2},0)->ixType().toIntVect(); - amrex::IntVect Bx_stag = warpx.m_fields.get("Bfield_fp",Direction{0},0)->ixType().toIntVect(); - amrex::IntVect By_stag = warpx.m_fields.get("Bfield_fp",Direction{1},0)->ixType().toIntVect(); - amrex::IntVect Bz_stag = warpx.m_fields.get("Bfield_fp",Direction{2},0)->ixType().toIntVect(); - amrex::IntVect Ex_stag = warpx.m_fields.get("Efield_fp",Direction{0},0)->ixType().toIntVect(); - amrex::IntVect Ey_stag = warpx.m_fields.get("Efield_fp",Direction{1},0)->ixType().toIntVect(); - amrex::IntVect Ez_stag = warpx.m_fields.get("Efield_fp",Direction{2},0)->ixType().toIntVect(); + amrex::IntVect Jx_stag = warpx.m_fields.get(FieldType::current_fp, Direction{0}, 0)->ixType().toIntVect(); + amrex::IntVect Jy_stag = warpx.m_fields.get(FieldType::current_fp, Direction{1}, 0)->ixType().toIntVect(); + amrex::IntVect Jz_stag = warpx.m_fields.get(FieldType::current_fp, Direction{2}, 0)->ixType().toIntVect(); + amrex::IntVect Bx_stag = warpx.m_fields.get(FieldType::Bfield_fp, Direction{0}, 0)->ixType().toIntVect(); + amrex::IntVect By_stag = warpx.m_fields.get(FieldType::Bfield_fp, Direction{1}, 0)->ixType().toIntVect(); + amrex::IntVect Bz_stag = warpx.m_fields.get(FieldType::Bfield_fp, Direction{2}, 0)->ixType().toIntVect(); + amrex::IntVect Ex_stag = warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, 0)->ixType().toIntVect(); + amrex::IntVect Ey_stag = warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, 0)->ixType().toIntVect(); + amrex::IntVect Ez_stag = warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, 0)->ixType().toIntVect(); // Check that the grid types are appropriate const bool appropriate_grids = ( @@ -224,9 +224,9 @@ void HybridPICModel::InitData () #ifdef AMREX_USE_EB if (EB::enabled()) { using ablastr::fields::Direction; - auto const & edge_lengths_x = *warpx.m_fields.get("edge_lengths", Direction{0}, lev); - auto const & edge_lengths_y = *warpx.m_fields.get("edge_lengths", Direction{1}, lev); - auto const & edge_lengths_z = *warpx.m_fields.get("edge_lengths", Direction{2}, lev); + auto const & edge_lengths_x = *warpx.m_fields.get(FieldType::edge_lengths, Direction{0}, lev); + auto const & edge_lengths_y = *warpx.m_fields.get(FieldType::edge_lengths, Direction{1}, lev); + auto const & edge_lengths_z = *warpx.m_fields.get(FieldType::edge_lengths, Direction{2}, lev); edge_lengths = std::array< std::unique_ptr, 3 >{ std::make_unique( @@ -269,9 +269,9 @@ void HybridPICModel::GetCurrentExternal ( const RealBox& real_box = warpx.Geom(lev).ProbDomain(); using ablastr::fields::Direction; - amrex::MultiFab * mfx = warpx.m_fields.get("hybrid_current_fp_external", Direction{0}, lev); - amrex::MultiFab * mfy = warpx.m_fields.get("hybrid_current_fp_external", Direction{1}, lev); - amrex::MultiFab * mfz = warpx.m_fields.get("hybrid_current_fp_external", Direction{2}, lev); + amrex::MultiFab * mfx = warpx.m_fields.get(FieldType::hybrid_current_fp_external, Direction{0}, lev); + amrex::MultiFab * mfy = warpx.m_fields.get(FieldType::hybrid_current_fp_external, Direction{1}, lev); + amrex::MultiFab * mfz = warpx.m_fields.get(FieldType::hybrid_current_fp_external, Direction{2}, lev); const amrex::IntVect x_nodal_flag = mfx->ixType().toIntVect(); const amrex::IntVect y_nodal_flag = mfy->ixType().toIntVect(); @@ -403,7 +403,7 @@ void HybridPICModel::CalculateCurrentAmpere ( WARPX_PROFILE("WarpX::CalculateCurrentAmpere()"); auto& warpx = WarpX::GetInstance(); - ablastr::fields::VectorField current_fp_ampere = warpx.m_fields.get_alldirs("hybrid_current_fp_ampere", lev); + ablastr::fields::VectorField current_fp_ampere = warpx.m_fields.get_alldirs(FieldType::hybrid_current_fp_ampere, lev); warpx.get_pointer_fdtd_solver_fp(lev)->CalculateCurrentAmpere( current_fp_ampere, Bfield, edge_lengths, lev ); @@ -466,9 +466,9 @@ void HybridPICModel::HybridPICSolveE ( auto& warpx = WarpX::GetInstance(); - ablastr::fields::VectorField current_fp_ampere = warpx.m_fields.get_alldirs("hybrid_current_fp_ampere", lev); - const ablastr::fields::VectorField current_fp_external = warpx.m_fields.get_alldirs("hybrid_current_fp_external", lev); - const ablastr::fields::ScalarField electron_pressure_fp = warpx.m_fields.get("hybrid_electron_pressure_fp", lev); + ablastr::fields::VectorField current_fp_ampere = warpx.m_fields.get_alldirs(FieldType::hybrid_current_fp_ampere, lev); + const ablastr::fields::VectorField current_fp_external = warpx.m_fields.get_alldirs(FieldType::hybrid_current_fp_external, lev); + const ablastr::fields::ScalarField electron_pressure_fp = warpx.m_fields.get(FieldType::hybrid_electron_pressure_fp, lev); // Solve E field in regular cells warpx.get_pointer_fdtd_solver_fp(lev)->HybridPICSolveE( @@ -494,8 +494,8 @@ void HybridPICModel::CalculateElectronPressure(const int lev) const WARPX_PROFILE("WarpX::CalculateElectronPressure()"); auto& warpx = WarpX::GetInstance(); - ablastr::fields::ScalarField electron_pressure_fp = warpx.m_fields.get("hybrid_electron_pressure_fp", lev); - ablastr::fields::ScalarField rho_fp = warpx.m_fields.get("rho_fp", lev); + ablastr::fields::ScalarField electron_pressure_fp = warpx.m_fields.get(FieldType::hybrid_electron_pressure_fp, lev); + ablastr::fields::ScalarField rho_fp = warpx.m_fields.get(FieldType::rho_fp, lev); // Calculate the electron pressure using rho^{n+1}. FillElectronPressureMF( diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index ea1432dd1f9..583e0a43903 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -23,7 +23,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; MacroscopicProperties::MacroscopicProperties () { diff --git a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp index e43fe058c90..2236118a30c 100644 --- a/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/SemiImplicitEM.cpp @@ -7,7 +7,7 @@ #include "SemiImplicitEM.H" #include "WarpX.H" -using namespace warpx::fields; +using warpx::fields::FieldType; using namespace amrex::literals; void SemiImplicitEM::Define ( WarpX* a_WarpX ) diff --git a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp index 42d016bb34a..e62ced29f6d 100644 --- a/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp +++ b/Source/FieldSolver/ImplicitSolvers/ThetaImplicitEM.cpp @@ -8,7 +8,7 @@ #include "ThetaImplicitEM.H" #include "WarpX.H" -using namespace warpx::fields; +using warpx::fields::FieldType; using namespace amrex::literals; void ThetaImplicitEM::Define ( WarpX* const a_WarpX ) @@ -28,14 +28,14 @@ void ThetaImplicitEM::Define ( WarpX* const a_WarpX ) using ablastr::fields::Direction; const int num_levels = 1; for (int lev = 0; lev < num_levels; ++lev) { - const auto& ba_Bx = m_WarpX->m_fields.get("Bfield_fp",Direction{0},lev)->boxArray(); - const auto& ba_By = m_WarpX->m_fields.get("Bfield_fp",Direction{1},lev)->boxArray(); - const auto& ba_Bz = m_WarpX->m_fields.get("Bfield_fp",Direction{2},lev)->boxArray(); - const auto& dm = m_WarpX->m_fields.get("Bfield_fp",Direction{0},lev)->DistributionMap(); - const amrex::IntVect ngb = m_WarpX->m_fields.get("Bfield_fp",Direction{0},lev)->nGrowVect(); - m_WarpX->m_fields.alloc_init("Bold", Direction{0}, lev, ba_Bx, dm, 1, ngb, 0.0_rt); - m_WarpX->m_fields.alloc_init("Bold", Direction{1}, lev, ba_By, dm, 1, ngb, 0.0_rt); - m_WarpX->m_fields.alloc_init("Bold", Direction{2}, lev, ba_Bz, dm, 1, ngb, 0.0_rt); + const auto& ba_Bx = m_WarpX->m_fields.get(FieldType::Bfield_fp, Direction{0}, lev)->boxArray(); + const auto& ba_By = m_WarpX->m_fields.get(FieldType::Bfield_fp, Direction{1}, lev)->boxArray(); + const auto& ba_Bz = m_WarpX->m_fields.get(FieldType::Bfield_fp, Direction{2}, lev)->boxArray(); + const auto& dm = m_WarpX->m_fields.get(FieldType::Bfield_fp, Direction{0}, lev)->DistributionMap(); + const amrex::IntVect ngb = m_WarpX->m_fields.get(FieldType::Bfield_fp, Direction{0}, lev)->nGrowVect(); + m_WarpX->m_fields.alloc_init(FieldType::Bold, Direction{0}, lev, ba_Bx, dm, 1, ngb, 0.0_rt); + m_WarpX->m_fields.alloc_init(FieldType::Bold, Direction{1}, lev, ba_By, dm, 1, ngb, 0.0_rt); + m_WarpX->m_fields.alloc_init(FieldType::Bold, Direction{2}, lev, ba_Bz, dm, 1, ngb, 0.0_rt); } // Parse theta-implicit solver specific parameters @@ -91,8 +91,8 @@ void ThetaImplicitEM::OneStep ( const amrex::Real a_time, const int num_levels = 1; for (int lev = 0; lev < num_levels; ++lev) { - const ablastr::fields::VectorField Bfp = m_WarpX->m_fields.get_alldirs("Bfield_fp",lev); - ablastr::fields::VectorField Bold = m_WarpX->m_fields.get_alldirs("Bold",lev); + const ablastr::fields::VectorField Bfp = m_WarpX->m_fields.get_alldirs(FieldType::Bfield_fp, lev); + ablastr::fields::VectorField Bold = m_WarpX->m_fields.get_alldirs(FieldType::Bold, lev); for (int n = 0; n < 3; ++n) { amrex::MultiFab::Copy( *Bold[n], *Bfp[n], 0, 0, Bold[n]->nComp(), Bold[n]->nGrowVect() ); @@ -147,7 +147,7 @@ void ThetaImplicitEM::UpdateWarpXFields ( const WarpXSolverVec& a_E, m_WarpX->SetElectricFieldAndApplyBCs( a_E ); // Update Bfield_fp owned by WarpX - ablastr::fields::MultiLevelVectorField const& Bold = m_WarpX->m_fields.get_mr_levels_alldirs("Bold",0); + ablastr::fields::MultiLevelVectorField const& Bold = m_WarpX->m_fields.get_mr_levels_alldirs(FieldType::Bold, 0); m_WarpX->UpdateMagneticFieldAndApplyBCs( Bold, m_theta*a_dt ); } @@ -163,7 +163,7 @@ void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real a_new_time ) const amrex::Real c1 = 1._rt - c0; m_E.linComb( c0, m_E, c1, m_Eold ); m_WarpX->SetElectricFieldAndApplyBCs( m_E ); - ablastr::fields::MultiLevelVectorField const & Bold = m_WarpX->m_fields.get_mr_levels_alldirs("Bold",0); + ablastr::fields::MultiLevelVectorField const & Bold = m_WarpX->m_fields.get_mr_levels_alldirs(FieldType::Bold, 0); m_WarpX->FinishMagneticFieldAndApplyBCs( Bold, m_theta ); } diff --git a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp index a393bae0eaf..806c3412990 100644 --- a/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp +++ b/Source/FieldSolver/ImplicitSolvers/WarpXImplicitOps.cpp @@ -73,7 +73,9 @@ WarpX::SetElectricFieldAndApplyBCs ( const WarpXSolverVec& a_E ) a_E.getArrayVecType()==warpx::fields::FieldType::Efield_fp, "WarpX::SetElectricFieldAndApplyBCs() must be called with Efield_fp type"); - ablastr::fields::MultiLevelVectorField Efield_fp = m_fields.get_mr_levels_alldirs("Efield_fp",finest_level); + using warpx::fields::FieldType; + + ablastr::fields::MultiLevelVectorField Efield_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, finest_level); const ablastr::fields::MultiLevelVectorField& Evec = a_E.getArrayVec(); amrex::MultiFab::Copy(*Efield_fp[0][0], *Evec[0][0], 0, 0, ncomps, Evec[0][0]->nGrowVect()); amrex::MultiFab::Copy(*Efield_fp[0][1], *Evec[0][1], 0, 0, ncomps, Evec[0][1]->nGrowVect()); @@ -87,8 +89,10 @@ WarpX::UpdateMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField co amrex::Real a_thetadt ) { using ablastr::fields::Direction; + using warpx::fields::FieldType; + for (int lev = 0; lev <= finest_level; ++lev) { - ablastr::fields::VectorField Bfp = m_fields.get_alldirs("Bfield_fp",lev); + ablastr::fields::VectorField Bfp = m_fields.get_alldirs(FieldType::Bfield_fp, lev); amrex::MultiFab::Copy(*Bfp[0], *a_Bn[lev][0], 0, 0, ncomps, a_Bn[lev][0]->nGrowVect()); amrex::MultiFab::Copy(*Bfp[1], *a_Bn[lev][1], 0, 0, ncomps, a_Bn[lev][1]->nGrowVect()); amrex::MultiFab::Copy(*Bfp[2], *a_Bn[lev][2], 0, 0, ncomps, a_Bn[lev][2]->nGrowVect()); @@ -101,7 +105,9 @@ void WarpX::FinishMagneticFieldAndApplyBCs( ablastr::fields::MultiLevelVectorField const& a_Bn, amrex::Real a_theta ) { - FinishImplicitField(m_fields.get_mr_levels_alldirs("Bfield_fp", 0), a_Bn, a_theta); + using warpx::fields::FieldType; + + FinishImplicitField(m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, 0), a_Bn, a_theta); ApplyMagneticFieldBCs(); } diff --git a/Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.cpp b/Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.cpp index 10673704759..6a0e6bb8a91 100644 --- a/Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.cpp +++ b/Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.cpp @@ -7,7 +7,7 @@ #include "FieldSolver/ImplicitSolvers/WarpXSolverVec.H" #include "WarpX.H" -using namespace warpx::fields; +using warpx::fields::FieldType; WarpXSolverVec::~WarpXSolverVec () { @@ -73,7 +73,7 @@ void WarpXSolverVec::Define ( WarpX* a_WarpX, "WarpXSolverVec::Define() called with array_type not an array field"); for (int lev = 0; lev < m_num_amr_levels; ++lev) { - const ablastr::fields::VectorField this_array = m_WarpX->m_fields.get_alldirs(m_vector_type_name,lev); + const ablastr::fields::VectorField this_array = m_WarpX->m_fields.get_alldirs(m_vector_type_name, lev); for (int n = 0; n < 3; n++) { m_array_vec[lev][n] = new amrex::MultiFab( this_array[n]->boxArray(), this_array[n]->DistributionMap(), @@ -122,7 +122,7 @@ void WarpXSolverVec::Copy ( FieldType a_array_type, for (int lev = 0; lev < m_num_amr_levels; ++lev) { if (m_array_type != FieldType::None) { - const ablastr::fields::VectorField this_array = m_WarpX->m_fields.get_alldirs(m_vector_type_name,lev); + const ablastr::fields::VectorField this_array = m_WarpX->m_fields.get_alldirs(m_vector_type_name, lev); for (int n = 0; n < 3; ++n) { amrex::MultiFab::Copy( *m_array_vec[lev][n], *this_array[n], 0, 0, m_ncomp, amrex::IntVect::TheZeroVector() ); diff --git a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp index a8266f54135..84efe8bf45a 100644 --- a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp +++ b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp @@ -6,6 +6,7 @@ */ #include "WarpX.H" +#include "Fields.H" #include "FieldSolver/MagnetostaticSolver/MagnetostaticSolver.H" #include "EmbeddedBoundary/Enabled.H" #include "Parallelization/GuardCellManager.H" @@ -73,6 +74,7 @@ void WarpX::AddMagnetostaticFieldLabFrame() { using ablastr::fields::Direction; + using warpx::fields::FieldType; WARPX_PROFILE("WarpX::AddMagnetostaticFieldLabFrame"); @@ -90,7 +92,7 @@ WarpX::AddMagnetostaticFieldLabFrame() // reset current_fp before depositing current density for this step for (int lev = 0; lev <= max_level; lev++) { for (int dim=0; dim < 3; dim++) { - m_fields.get("current_fp", Direction{dim}, lev)->setVal(0.); + m_fields.get(FieldType::current_fp, Direction{dim}, lev)->setVal(0.); } } @@ -99,7 +101,7 @@ WarpX::AddMagnetostaticFieldLabFrame() WarpXParticleContainer& species = mypc->GetParticleContainer(ispecies); if (!species.do_not_deposit) { species.DepositCurrent( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), dt[0], 0.); } } @@ -107,9 +109,9 @@ WarpX::AddMagnetostaticFieldLabFrame() #ifdef WARPX_DIM_RZ for (int lev = 0; lev <= max_level; lev++) { ApplyInverseVolumeScalingToCurrentDensity( - m_fields.get("current_fp", Direction{0}, lev), - m_fields.get("current_fp", Direction{1}, lev), - m_fields.get("current_fp", Direction{2}, lev), + m_fields.get(FieldType::current_fp, Direction{0}, lev), + m_fields.get(FieldType::current_fp, Direction{1}, lev), + m_fields.get(FieldType::current_fp, Direction{2}, lev), lev ); } #endif @@ -117,7 +119,7 @@ WarpX::AddMagnetostaticFieldLabFrame() SyncCurrent("current_fp"); // set the boundary and current density potentials - setVectorPotentialBC(m_fields.get_mr_levels_alldirs("vector_potential_fp_nodal", finest_level)); + setVectorPotentialBC(m_fields.get_mr_levels_alldirs(FieldType::vector_potential_fp_nodal, finest_level)); // Compute the vector potential A, by solving the Poisson equation WARPX_ALWAYS_ASSERT_WITH_MESSAGE( !IsPythonCallbackInstalled("poissonsolver"), @@ -131,8 +133,8 @@ WarpX::AddMagnetostaticFieldLabFrame() const int self_fields_verbosity = 2; computeVectorPotential( - m_fields.get_mr_levels_alldirs("current_fp", finest_level), - m_fields.get_mr_levels_alldirs("vector_potential_fp_nodal", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::vector_potential_fp_nodal, finest_level), self_fields_required_precision, magnetostatic_absolute_tolerance, self_fields_max_iters, self_fields_verbosity); } @@ -162,6 +164,7 @@ WarpX::computeVectorPotential (ablastr::fields::MultiLevelVectorField const& cur int const verbosity) // const // This breaks non-const m_fields.get_mr_levels_alldirs { using ablastr::fields::Direction; + using warpx::fields::FieldType; // create a vector to our fields, sorted by level amrex::Vector> sorted_curr; @@ -176,12 +179,12 @@ WarpX::computeVectorPotential (ablastr::fields::MultiLevelVectorField const& cur } #if defined(AMREX_USE_EB) - const ablastr::fields::MultiLevelVectorField Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level); + const ablastr::fields::MultiLevelVectorField Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); const std::optional post_A_calculation( { Bfield_fp, - m_fields.get_mr_levels_alldirs("vector_potential_grad_buf_e_stag", finest_level), - m_fields.get_mr_levels_alldirs("vector_potential_grad_buf_b_stag", finest_level) + m_fields.get_mr_levels_alldirs(FieldType::vector_potential_grad_buf_e_stag, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::vector_potential_grad_buf_b_stag, finest_level) }); amrex::Vector factories; diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index fd1f55142f2..db2dcea65ac 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -10,6 +10,7 @@ #include "BoundaryConditions/PML.H" #include "Evolve/WarpXDtType.H" +#include "Fields.H" #include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H" #if defined(WARPX_USE_FFT) # include "FieldSolver/SpectralSolver/SpectralFieldData.H" @@ -53,6 +54,7 @@ #include using namespace amrex; +using warpx::fields::FieldType; #ifdef WARPX_USE_FFT namespace { @@ -214,14 +216,14 @@ WarpX::PSATDForwardTransformF () for (int lev = 0; lev <= finest_level; ++lev) { - if (m_fields.has("F_fp", lev)) { - spectral_solver_fp[lev]->ForwardTransform(lev, *m_fields.get("F_fp", lev), Idx.F); + if (m_fields.has(FieldType::F_fp, lev)) { + spectral_solver_fp[lev]->ForwardTransform(lev, *m_fields.get(FieldType::F_fp, lev), Idx.F); } if (spectral_solver_cp[lev]) { - if (m_fields.has("F_cp", lev)) { - spectral_solver_cp[lev]->ForwardTransform(lev, *m_fields.get("F_cp", lev), Idx.F); + if (m_fields.has(FieldType::F_cp, lev)) { + spectral_solver_cp[lev]->ForwardTransform(lev, *m_fields.get(FieldType::F_cp, lev), Idx.F); } } } @@ -235,17 +237,17 @@ WarpX::PSATDBackwardTransformF () for (int lev = 0; lev <= finest_level; ++lev) { #ifdef WARPX_DIM_RZ - if (m_fields.has("F_fp", lev)) { spectral_solver_fp[lev]->BackwardTransform(lev, *m_fields.get("F_fp", lev), Idx.F); } + if (m_fields.has(FieldType::F_fp, lev)) { spectral_solver_fp[lev]->BackwardTransform(lev, *m_fields.get(FieldType::F_fp, lev), Idx.F); } #else - if (m_fields.has("F_fp", lev)) { spectral_solver_fp[lev]->BackwardTransform(lev, *m_fields.get("F_fp", lev), Idx.F, m_fill_guards_fields); } + if (m_fields.has(FieldType::F_fp, lev)) { spectral_solver_fp[lev]->BackwardTransform(lev, *m_fields.get(FieldType::F_fp, lev), Idx.F, m_fill_guards_fields); } #endif if (spectral_solver_cp[lev]) { #ifdef WARPX_DIM_RZ - if (m_fields.has("F_cp", lev)) { spectral_solver_cp[lev]->BackwardTransform(lev, *m_fields.get("F_cp", lev), Idx.F); } + if (m_fields.has(FieldType::F_cp, lev)) { spectral_solver_cp[lev]->BackwardTransform(lev, *m_fields.get(FieldType::F_cp, lev), Idx.F); } #else - if (m_fields.has("F_cp", lev)) { spectral_solver_cp[lev]->BackwardTransform(lev, *m_fields.get("F_cp", lev), Idx.F, m_fill_guards_fields); } + if (m_fields.has(FieldType::F_cp, lev)) { spectral_solver_cp[lev]->BackwardTransform(lev, *m_fields.get(FieldType::F_cp, lev), Idx.F, m_fill_guards_fields); } #endif } } @@ -253,7 +255,7 @@ WarpX::PSATDBackwardTransformF () // Damp the field in the guard cells for (int lev = 0; lev <= finest_level; ++lev) { - DampFieldsInGuards(lev, m_fields.get("F_fp", lev)); + DampFieldsInGuards(lev, m_fields.get(FieldType::F_fp, lev)); } } @@ -264,14 +266,14 @@ WarpX::PSATDForwardTransformG () for (int lev = 0; lev <= finest_level; ++lev) { - if (m_fields.has("G_fp", lev)) { - spectral_solver_fp[lev]->ForwardTransform(lev, *m_fields.get("G_fp", lev), Idx.G); + if (m_fields.has(FieldType::G_fp, lev)) { + spectral_solver_fp[lev]->ForwardTransform(lev, *m_fields.get(FieldType::G_fp, lev), Idx.G); } if (spectral_solver_cp[lev]) { - if (m_fields.has("G_cp", lev)) { - spectral_solver_fp[lev]->ForwardTransform(lev, *m_fields.get("G_cp", lev), Idx.G); + if (m_fields.has(FieldType::G_cp, lev)) { + spectral_solver_fp[lev]->ForwardTransform(lev, *m_fields.get(FieldType::G_cp, lev), Idx.G); } } } @@ -284,8 +286,8 @@ WarpX::PSATDBackwardTransformG () for (int lev = 0; lev <= finest_level; ++lev) { - if (m_fields.has("G_fp", lev)) { - MultiFab* G_fp = m_fields.get("G_fp", lev); + if (m_fields.has(FieldType::G_fp, lev)) { + MultiFab* G_fp = m_fields.get(FieldType::G_fp, lev); #ifdef WARPX_DIM_RZ spectral_solver_fp[lev]->BackwardTransform(lev, *G_fp, Idx.G); #else @@ -297,8 +299,8 @@ WarpX::PSATDBackwardTransformG () if (spectral_solver_cp[lev]) { - if (m_fields.has("G_cp", lev)) { - MultiFab* G_cp = m_fields.get("G_cp", lev); + if (m_fields.has(FieldType::G_cp, lev)) { + MultiFab* G_cp = m_fields.get(FieldType::G_cp, lev); #ifdef WARPX_DIM_RZ spectral_solver_fp[lev]->BackwardTransform(lev, *G_cp, Idx.G); #else @@ -505,15 +507,15 @@ void WarpX::PSATDSubtractCurrentPartialSumsAvg () { const std::array& dx = WarpX::CellSize(lev); - amrex::MultiFab const& Dx = *m_fields.get("current_fp_vay", Direction{0}, lev); - amrex::MultiFab const& Dy = *m_fields.get("current_fp_vay", Direction{1}, lev); - amrex::MultiFab const& Dz = *m_fields.get("current_fp_vay", Direction{2}, lev); + amrex::MultiFab const& Dx = *m_fields.get(FieldType::current_fp_vay, Direction{0}, lev); + amrex::MultiFab const& Dy = *m_fields.get(FieldType::current_fp_vay, Direction{1}, lev); + amrex::MultiFab const& Dz = *m_fields.get(FieldType::current_fp_vay, Direction{2}, lev); #if defined (WARPX_DIM_XZ) amrex::ignore_unused(Dy); #endif - amrex::MultiFab& Jx = *m_fields.get("current_fp", Direction{0}, lev); + amrex::MultiFab& Jx = *m_fields.get(FieldType::current_fp, Direction{0}, lev); #ifdef AMREX_USE_OMP @@ -544,7 +546,7 @@ void WarpX::PSATDSubtractCurrentPartialSumsAvg () #if defined (WARPX_DIM_3D) // Subtract average of cumulative sum from Jy - amrex::MultiFab& Jy = *m_fields.get("current_fp", Direction{1}, lev);; + amrex::MultiFab& Jy = *m_fields.get(FieldType::current_fp, Direction{1}, lev);; for (amrex::MFIter mfi(Jy); mfi.isValid(); ++mfi) { const amrex::Box& bx = mfi.fabbox(); @@ -569,7 +571,7 @@ void WarpX::PSATDSubtractCurrentPartialSumsAvg () #endif // Subtract average of cumulative sum from Jz - amrex::MultiFab& Jz = *m_fields.get("current_fp", Direction{2}, lev); + amrex::MultiFab& Jz = *m_fields.get(FieldType::current_fp, Direction{2}, lev); for (amrex::MFIter mfi(Jz); mfi.isValid(); ++mfi) { const amrex::Box& bx = mfi.fabbox(); @@ -725,7 +727,7 @@ WarpX::PushPSATD () std::string const rho_fp_string = "rho_fp"; std::string const rho_cp_string = "rho_cp"; - const ablastr::fields::MultiLevelVectorField current_fp = m_fields.get_mr_levels_alldirs("current_fp", finest_level); + const ablastr::fields::MultiLevelVectorField current_fp = m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level); std::string current_fp_string = "current_fp"; std::string const current_cp_string = "current_cp"; @@ -848,10 +850,10 @@ WarpX::PushPSATD () // Inverse FFT of E, B, F, and G PSATDBackwardTransformEB(); if (WarpX::fft_do_time_averaging) { - auto Efield_avg_fp = m_fields.get_mr_levels_alldirs("Efield_avg_fp", finest_level); - auto Bfield_avg_fp = m_fields.get_mr_levels_alldirs("Bfield_avg_fp", finest_level); - auto Efield_avg_cp = m_fields.get_mr_levels_alldirs("Efield_avg_cp", finest_level); - auto Bfield_avg_cp = m_fields.get_mr_levels_alldirs("Bfield_avg_cp", finest_level); + auto Efield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_fp, finest_level); + auto Bfield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_fp, finest_level); + auto Efield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_cp, finest_level); + auto Bfield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_cp, finest_level); PSATDBackwardTransformEBavg(Efield_avg_fp, Bfield_avg_fp, Efield_avg_cp, Bfield_avg_cp); } if (WarpX::do_dive_cleaning) { PSATDBackwardTransformF(); } @@ -956,13 +958,13 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt) m_fdtd_solver_fp[lev]->EvolveE( m_fields, lev, patch_type, - m_fields.get_alldirs("Efield_fp",lev), + m_fields.get_alldirs(FieldType::Efield_fp, lev), a_dt ); } else { m_fdtd_solver_cp[lev]->EvolveE( m_fields, lev, patch_type, - m_fields.get_alldirs("Efield_cp",lev), + m_fields.get_alldirs(FieldType::Efield_cp, lev), a_dt ); } @@ -992,16 +994,16 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real a_dt) #ifdef AMREX_USE_EB if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) { if (patch_type == PatchType::fine) { - m_fdtd_solver_fp[lev]->EvolveECTRho( m_fields.get_alldirs("Efield_fp",lev), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), - m_fields.get_alldirs("ECTRhofield", lev), + m_fdtd_solver_fp[lev]->EvolveECTRho( m_fields.get_alldirs(FieldType::Efield_fp, lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), + m_fields.get_alldirs(FieldType::ECTRhofield, lev), lev ); } else { - m_fdtd_solver_cp[lev]->EvolveECTRho( m_fields.get_alldirs("Efield_cp",lev), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), - m_fields.get_alldirs("ECTRhofield", lev), + m_fdtd_solver_cp[lev]->EvolveECTRho( m_fields.get_alldirs(FieldType::Efield_cp, lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), + m_fields.get_alldirs(FieldType::ECTRhofield, lev), lev); } } @@ -1040,26 +1042,26 @@ WarpX::EvolveF (int lev, PatchType patch_type, amrex::Real a_dt, DtType a_dt_typ // Evolve F field in regular cells if (patch_type == PatchType::fine) { - m_fdtd_solver_fp[lev]->EvolveF( m_fields.get("F_fp", lev), - m_fields.get_alldirs("Efield_fp", lev), - m_fields.get("rho_fp",lev), rhocomp, a_dt ); + m_fdtd_solver_fp[lev]->EvolveF( m_fields.get(FieldType::F_fp, lev), + m_fields.get_alldirs(FieldType::Efield_fp, lev), + m_fields.get(FieldType::rho_fp,lev), rhocomp, a_dt ); } else { - m_fdtd_solver_cp[lev]->EvolveF( m_fields.get("F_cp", lev), - m_fields.get_alldirs("Efield_cp", lev), - m_fields.get("rho_cp",lev), rhocomp, a_dt ); + m_fdtd_solver_cp[lev]->EvolveF( m_fields.get(FieldType::F_cp, lev), + m_fields.get_alldirs(FieldType::Efield_cp, lev), + m_fields.get(FieldType::rho_cp,lev), rhocomp, a_dt ); } // Evolve F field in PML cells if (do_pml && pml[lev]->ok()) { if (patch_type == PatchType::fine) { m_fdtd_solver_fp[lev]->EvolveFPML( - m_fields.get("pml_F_fp", lev), - m_fields.get_alldirs("pml_E_fp", lev), + m_fields.get(FieldType::pml_F_fp, lev), + m_fields.get_alldirs(FieldType::pml_E_fp, lev), a_dt ); } else { m_fdtd_solver_cp[lev]->EvolveFPML( - m_fields.get("pml_F_cp", lev), - m_fields.get_alldirs("pml_E_cp", lev), + m_fields.get(FieldType::pml_F_cp, lev), + m_fields.get_alldirs(FieldType::pml_E_cp, lev), a_dt ); } } @@ -1099,16 +1101,16 @@ WarpX::EvolveG (int lev, PatchType patch_type, amrex::Real a_dt, DtType /*a_dt_t // Evolve G field in regular cells if (patch_type == PatchType::fine) { - ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level); + ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); m_fdtd_solver_fp[lev]->EvolveG( - m_fields.get("G_fp", lev), + m_fields.get(FieldType::G_fp, lev), Bfield_fp[lev], a_dt); } else // coarse patch { - ablastr::fields::MultiLevelVectorField const& Bfield_cp_new = m_fields.get_mr_levels_alldirs("Bfield_cp", finest_level); + ablastr::fields::MultiLevelVectorField const& Bfield_cp_new = m_fields.get_mr_levels_alldirs(FieldType::Bfield_cp, finest_level); m_fdtd_solver_cp[lev]->EvolveG( - m_fields.get("G_cp", lev), + m_fields.get(FieldType::G_cp, lev), Bfield_cp_new[lev], a_dt); } @@ -1145,10 +1147,10 @@ WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt) { ); m_fdtd_solver_fp[lev]->MacroscopicEvolveE( - m_fields.get_alldirs("Efield_fp", lev), - m_fields.get_alldirs("Bfield_fp", lev), - m_fields.get_alldirs("current_fp", lev), - m_fields.get_alldirs("edge_lengths", lev), + m_fields.get_alldirs(FieldType::Efield_fp, lev), + m_fields.get_alldirs(FieldType::Bfield_fp, lev), + m_fields.get_alldirs(FieldType::current_fp, lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), a_dt, m_macroscopic_properties); if (do_pml && pml[lev]->ok()) { diff --git a/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp b/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp index 13752458b9e..556b8f8fca4 100644 --- a/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp +++ b/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp @@ -7,6 +7,7 @@ * License: BSD-3-Clause-LBNL */ #include "Evolve/WarpXDtType.H" +#include "Fields.H" #include "FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H" #include "Particles/MultiParticleContainer.H" #include "Utils/TextMsg.H" @@ -17,11 +18,13 @@ #include + using namespace amrex; void WarpX::HybridPICEvolveFields () { using ablastr::fields::Direction; + using warpx::fields::FieldType; WARPX_PROFILE("WarpX::HybridPICEvolveFields()"); @@ -32,18 +35,18 @@ void WarpX::HybridPICEvolveFields () // The particles have now been pushed to their t_{n+1} positions. // Perform charge deposition in component 0 of rho_fp at t_{n+1}. - mypc->DepositCharge(m_fields.get_mr_levels("rho_fp", finest_level), 0._rt); + mypc->DepositCharge(m_fields.get_mr_levels(FieldType::rho_fp, finest_level), 0._rt); // Perform current deposition at t_{n+1/2}. - mypc->DepositCurrent(m_fields.get_mr_levels_alldirs("current_fp", finest_level), dt[0], -0.5_rt * dt[0]); + mypc->DepositCurrent(m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), dt[0], -0.5_rt * dt[0]); // Deposit cold-relativistic fluid charge and current if (do_fluid_species) { int const lev = 0; - myfl->DepositCharge(m_fields, *m_fields.get("rho_fp", lev), lev); + myfl->DepositCharge(m_fields, *m_fields.get(FieldType::rho_fp, lev), lev); myfl->DepositCurrent(m_fields, - *m_fields.get("current_fp", Direction{0}, lev), - *m_fields.get("current_fp", Direction{1}, lev), - *m_fields.get("current_fp", Direction{2}, lev), + *m_fields.get(FieldType::current_fp, Direction{0}, lev), + *m_fields.get(FieldType::current_fp, Direction{1}, lev), + *m_fields.get(FieldType::current_fp, Direction{2}, lev), lev); } @@ -57,7 +60,7 @@ void WarpX::HybridPICEvolveFields () // a nodal grid for (int lev = 0; lev <= finest_level; ++lev) { for (int idim = 0; idim < 3; ++idim) { - m_fields.get("current_fp", Direction{idim}, lev)->FillBoundary(Geom(lev).periodicity()); + m_fields.get(FieldType::current_fp, Direction{idim}, lev)->FillBoundary(Geom(lev).periodicity()); } } @@ -66,11 +69,11 @@ void WarpX::HybridPICEvolveFields () // Get the external current m_hybrid_pic_model->GetCurrentExternal( - m_fields.get_mr_levels_alldirs("edge_lengths", finest_level)); + m_fields.get_mr_levels_alldirs(FieldType::edge_lengths, finest_level)); // Reference hybrid-PIC multifabs - ablastr::fields::MultiLevelScalarField rho_fp_temp = m_fields.get_mr_levels("hybrid_rho_fp_temp", finest_level); - ablastr::fields::MultiLevelVectorField current_fp_temp = m_fields.get_mr_levels_alldirs("hybrid_current_fp_temp", finest_level); + ablastr::fields::MultiLevelScalarField rho_fp_temp = m_fields.get_mr_levels(FieldType::hybrid_rho_fp_temp, finest_level); + ablastr::fields::MultiLevelVectorField current_fp_temp = m_fields.get_mr_levels_alldirs(FieldType::hybrid_current_fp_temp, finest_level); // During the above deposition the charge and current density were updated // so that, at this time, we have rho^{n} in rho_fp_temp, rho{n+1} in the @@ -91,7 +94,7 @@ void WarpX::HybridPICEvolveFields () MultiFab::LinComb( *current_fp_temp[lev][idim], 0.5_rt, *current_fp_temp[lev][idim], 0, - 0.5_rt, *m_fields.get("current_fp", Direction{idim}, lev), 0, + 0.5_rt, *m_fields.get(FieldType::current_fp, Direction{idim}, lev), 0, 0, 1, current_fp_temp[lev][idim]->nGrowVect() ); } @@ -103,10 +106,10 @@ void WarpX::HybridPICEvolveFields () for (int sub_step = 0; sub_step < sub_steps; sub_step++) { m_hybrid_pic_model->BfieldEvolveRK( - m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level), - m_fields.get_mr_levels_alldirs("Efield_fp", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, finest_level), current_fp_temp, rho_fp_temp, - m_fields.get_mr_levels_alldirs("edge_lengths", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::edge_lengths, finest_level), 0.5_rt/sub_steps*dt[0], DtType::FirstHalf, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points @@ -121,7 +124,7 @@ void WarpX::HybridPICEvolveFields () // the result into the 0'th index of `rho_fp_temp[lev]` MultiFab::LinComb( *rho_fp_temp[lev], 0.5_rt, *rho_fp_temp[lev], 0, - 0.5_rt, *m_fields.get("rho_fp", lev), 0, 0, 1, rho_fp_temp[lev]->nGrowVect() + 0.5_rt, *m_fields.get(FieldType::rho_fp, lev), 0, 0, 1, rho_fp_temp[lev]->nGrowVect() ); } @@ -129,11 +132,11 @@ void WarpX::HybridPICEvolveFields () for (int sub_step = 0; sub_step < sub_steps; sub_step++) { m_hybrid_pic_model->BfieldEvolveRK( - m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level), - m_fields.get_mr_levels_alldirs("Efield_fp", finest_level), - m_fields.get_mr_levels_alldirs("current_fp", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), rho_fp_temp, - m_fields.get_mr_levels_alldirs("edge_lengths", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::edge_lengths, finest_level), 0.5_rt/sub_steps*dt[0], DtType::SecondHalf, guard_cells.ng_FieldSolver, WarpX::sync_nodal_points @@ -152,7 +155,7 @@ void WarpX::HybridPICEvolveFields () MultiFab::LinComb( *current_fp_temp[lev][idim], -1._rt, *current_fp_temp[lev][idim], 0, - 2._rt, *m_fields.get("current_fp", Direction{idim}, lev), 0, + 2._rt, *m_fields.get(FieldType::current_fp, Direction{idim}, lev), 0, 0, 1, current_fp_temp[lev][idim]->nGrowVect() ); } @@ -163,14 +166,14 @@ void WarpX::HybridPICEvolveFields () // Update the E field to t=n+1 using the extrapolated J_i^n+1 value m_hybrid_pic_model->CalculateCurrentAmpere( - m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level), - m_fields.get_mr_levels_alldirs("edge_lengths", finest_level)); + m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::edge_lengths, finest_level)); m_hybrid_pic_model->HybridPICSolveE( - m_fields.get_mr_levels_alldirs("Efield_fp", finest_level), + m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, finest_level), current_fp_temp, - m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level), - m_fields.get_mr_levels("rho_fp", finest_level), - m_fields.get_mr_levels_alldirs("edge_lengths", finest_level), false + m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level), + m_fields.get_mr_levels(FieldType::rho_fp, finest_level), + m_fields.get_mr_levels_alldirs(FieldType::edge_lengths, finest_level), false ); FillBoundaryE(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); @@ -180,10 +183,10 @@ void WarpX::HybridPICEvolveFields () for (int lev = 0; lev <= finest_level; ++lev) { // copy 1 component value starting at index 0 to index 0 - MultiFab::Copy(*rho_fp_temp[lev], *m_fields.get("rho_fp", lev), + MultiFab::Copy(*rho_fp_temp[lev], *m_fields.get(FieldType::rho_fp, lev), 0, 0, 1, rho_fp_temp[lev]->nGrowVect()); for (int idim = 0; idim < 3; ++idim) { - MultiFab::Copy(*current_fp_temp[lev][idim], *m_fields.get("current_fp", Direction{idim}, lev), + MultiFab::Copy(*current_fp_temp[lev][idim], *m_fields.get(FieldType::current_fp, Direction{idim}, lev), 0, 0, 1, current_fp_temp[lev][idim]->nGrowVect()); } } @@ -191,11 +194,13 @@ void WarpX::HybridPICEvolveFields () void WarpX::HybridPICDepositInitialRhoAndJ () { - ablastr::fields::MultiLevelScalarField rho_fp_temp = m_fields.get_mr_levels("hybrid_rho_fp_temp", finest_level); - ablastr::fields::MultiLevelVectorField current_fp_temp = m_fields.get_mr_levels_alldirs("hybrid_current_fp_temp", finest_level); + using warpx::fields::FieldType; + + ablastr::fields::MultiLevelScalarField rho_fp_temp = m_fields.get_mr_levels(FieldType::hybrid_rho_fp_temp, finest_level); + ablastr::fields::MultiLevelVectorField current_fp_temp = m_fields.get_mr_levels_alldirs(FieldType::hybrid_current_fp_temp, finest_level); mypc->DepositCharge(rho_fp_temp, 0._rt); mypc->DepositCurrent(current_fp_temp, dt[0], 0._rt); - SyncRho(rho_fp_temp, m_fields.get_mr_levels("rho_cp", finest_level), m_fields.get_mr_levels("rho_buf", finest_level)); + SyncRho(rho_fp_temp, m_fields.get_mr_levels(FieldType::rho_cp, finest_level), m_fields.get_mr_levels(FieldType::rho_buf, finest_level)); SyncCurrent("hybrid_current_fp_temp"); for (int lev=0; lev <= finest_level; ++lev) { // SyncCurrent does not include a call to FillBoundary, but it is needed diff --git a/Source/FieldSolver/WarpXSolveFieldsES.cpp b/Source/FieldSolver/WarpXSolveFieldsES.cpp index 32362204b4a..6194570cd2d 100644 --- a/Source/FieldSolver/WarpXSolveFieldsES.cpp +++ b/Source/FieldSolver/WarpXSolveFieldsES.cpp @@ -7,21 +7,25 @@ * License: BSD-3-Clause-LBNL */ #include "FieldSolver/ElectrostaticSolvers/ElectrostaticSolver.H" + +#include "Fields.H" #include "Utils/WarpXProfilerWrapper.H" #include "WarpX.H" + void WarpX::ComputeSpaceChargeField (bool const reset_fields) { WARPX_PROFILE("WarpX::ComputeSpaceChargeField"); using ablastr::fields::Direction; + using warpx::fields::FieldType; if (reset_fields) { // Reset all E and B fields to 0, before calculating space-charge fields WARPX_PROFILE("WarpX::ComputeSpaceChargeField::reset_fields"); for (int lev = 0; lev <= max_level; lev++) { for (int comp=0; comp<3; comp++) { - m_fields.get("Efield_fp",Direction{comp},lev)->setVal(0); - m_fields.get("Bfield_fp",Direction{comp},lev)->setVal(0); + m_fields.get(FieldType::Efield_fp, Direction{comp}, lev)->setVal(0); + m_fields.get(FieldType::Bfield_fp, Direction{comp}, lev)->setVal(0); } } } diff --git a/Source/FieldSolver/WarpX_QED_Field_Pushers.cpp b/Source/FieldSolver/WarpX_QED_Field_Pushers.cpp index b95fb938a39..1ff1d1f866d 100644 --- a/Source/FieldSolver/WarpX_QED_Field_Pushers.cpp +++ b/Source/FieldSolver/WarpX_QED_Field_Pushers.cpp @@ -6,6 +6,7 @@ */ #include "WarpX.H" +#include "Fields.H" #include "Utils/TextMsg.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXProfilerWrapper.H" @@ -70,6 +71,7 @@ void WarpX::Hybrid_QED_Push (int lev, PatchType patch_type, amrex::Real a_dt) { using ablastr::fields::Direction; + using warpx::fields::FieldType; const int patch_level = (patch_type == PatchType::fine) ? lev : lev-1; const std::array& dx_vec= WarpX::CellSize(patch_level); @@ -82,27 +84,27 @@ WarpX::Hybrid_QED_Push (int lev, PatchType patch_type, amrex::Real a_dt) MultiFab *Ex, *Ey, *Ez, *Bx, *By, *Bz, *Jx, *Jy, *Jz; if (patch_type == PatchType::fine) { - Ex = m_fields.get("Efield_fp",Direction{0},lev); - Ey = m_fields.get("Efield_fp",Direction{1},lev); - Ez = m_fields.get("Efield_fp",Direction{2},lev); - Bx = m_fields.get("Bfield_fp",Direction{0},lev); - By = m_fields.get("Bfield_fp",Direction{1},lev); - Bz = m_fields.get("Bfield_fp",Direction{2},lev); - Jx = m_fields.get("current_fp", Direction{0}, lev); - Jy = m_fields.get("current_fp", Direction{1}, lev); - Jz = m_fields.get("current_fp", Direction{2}, lev); + Ex = m_fields.get(FieldType::Efield_fp, Direction{0}, lev); + Ey = m_fields.get(FieldType::Efield_fp, Direction{1}, lev); + Ez = m_fields.get(FieldType::Efield_fp, Direction{2}, lev); + Bx = m_fields.get(FieldType::Bfield_fp, Direction{0}, lev); + By = m_fields.get(FieldType::Bfield_fp, Direction{1}, lev); + Bz = m_fields.get(FieldType::Bfield_fp, Direction{2}, lev); + Jx = m_fields.get(FieldType::current_fp, Direction{0}, lev); + Jy = m_fields.get(FieldType::current_fp, Direction{1}, lev); + Jz = m_fields.get(FieldType::current_fp, Direction{2}, lev); } else { - Ex = m_fields.get("Efield_cp",Direction{0},lev); - Ey = m_fields.get("Efield_cp",Direction{1},lev); - Ez = m_fields.get("Efield_cp",Direction{2},lev); - Bx = m_fields.get("Bfield_cp",Direction{0},lev); - By = m_fields.get("Bfield_cp",Direction{1},lev); - Bz = m_fields.get("Bfield_cp",Direction{2},lev); - Jx = m_fields.get("current_cp", Direction{0}, lev); - Jy = m_fields.get("current_cp", Direction{1}, lev); - Jz = m_fields.get("current_cp", Direction{2}, lev); + Ex = m_fields.get(FieldType::Efield_cp, Direction{0}, lev); + Ey = m_fields.get(FieldType::Efield_cp, Direction{1}, lev); + Ez = m_fields.get(FieldType::Efield_cp, Direction{2}, lev); + Bx = m_fields.get(FieldType::Bfield_cp, Direction{0}, lev); + By = m_fields.get(FieldType::Bfield_cp, Direction{1}, lev); + Bz = m_fields.get(FieldType::Bfield_cp, Direction{2}, lev); + Jx = m_fields.get(FieldType::current_cp, Direction{0}, lev); + Jy = m_fields.get(FieldType::current_cp, Direction{1}, lev); + Jz = m_fields.get(FieldType::current_cp, Direction{2}, lev); } amrex::LayoutData* cost = WarpX::getCosts(lev); diff --git a/Source/Fluids/WarpXFluidContainer.cpp b/Source/Fluids/WarpXFluidContainer.cpp index cc4c8777b18..326ce30c844 100644 --- a/Source/Fluids/WarpXFluidContainer.cpp +++ b/Source/Fluids/WarpXFluidContainer.cpp @@ -4,21 +4,24 @@ * * License: BSD-3-Clause-LBNL */ -#include "ablastr/coarsen/sample.H" +#include "Fields.H" #include "Particles/Pusher/UpdateMomentumHigueraCary.H" #include "Utils/WarpXProfilerWrapper.H" #include "MusclHancockUtils.H" #include "Fluids/WarpXFluidContainer.H" -#include "WarpX.H" -#include #include "Utils/Parser/ParserUtils.H" #include "Utils/WarpXUtil.H" #include "Utils/SpeciesUtils.H" +#include "WarpX.H" + +#include +#include using namespace ablastr::utils::communication; using namespace amrex; + WarpXFluidContainer::WarpXFluidContainer(int ispecies, const std::string &name): species_id{ispecies}, species_name{name} @@ -259,22 +262,24 @@ void WarpXFluidContainer::Evolve( bool skip_deposition) { using ablastr::fields::Direction; + using warpx::fields::FieldType; + WARPX_PROFILE("WarpXFluidContainer::Evolve"); - if (fields.has("rho_fp",lev) && ! skip_deposition && ! do_not_deposit) { + if (fields.has(FieldType::rho_fp,lev) && ! skip_deposition && ! do_not_deposit) { // Deposit charge before particle push, in component 0 of MultiFab rho. - DepositCharge(fields, *fields.get("rho_fp",lev), lev, 0); + DepositCharge(fields, *fields.get(FieldType::rho_fp,lev), lev, 0); } // Step the Lorentz Term if(!do_not_gather){ GatherAndPush(fields, - *fields.get("Efield_aux", Direction{0}, lev), - *fields.get("Efield_aux", Direction{1}, lev), - *fields.get("Efield_aux", Direction{2}, lev), - *fields.get("Bfield_aux", Direction{0}, lev), - *fields.get("Bfield_aux", Direction{1}, lev), - *fields.get("Bfield_aux", Direction{2}, lev), + *fields.get(FieldType::Efield_aux, Direction{0}, lev), + *fields.get(FieldType::Efield_aux, Direction{1}, lev), + *fields.get(FieldType::Efield_aux, Direction{2}, lev), + *fields.get(FieldType::Bfield_aux, Direction{0}, lev), + *fields.get(FieldType::Bfield_aux, Direction{1}, lev), + *fields.get(FieldType::Bfield_aux, Direction{2}, lev), cur_time, lev); } @@ -294,8 +299,8 @@ void WarpXFluidContainer::Evolve( // Deposit rho to the simulation mesh // Deposit charge (end of the step) - if (fields.has("rho_fp",lev) && ! skip_deposition && ! do_not_deposit) { - DepositCharge(fields, *fields.get("rho_fp",lev), lev, 1); + if (fields.has(FieldType::rho_fp,lev) && ! skip_deposition && ! do_not_deposit) { + DepositCharge(fields, *fields.get(FieldType::rho_fp,lev), lev, 1); } // Deposit J to the simulation mesh diff --git a/Source/Initialization/DivCleaner/ProjectionDivCleaner.cpp b/Source/Initialization/DivCleaner/ProjectionDivCleaner.cpp index ee8fcf40b9c..670f962f7c3 100644 --- a/Source/Initialization/DivCleaner/ProjectionDivCleaner.cpp +++ b/Source/Initialization/DivCleaner/ProjectionDivCleaner.cpp @@ -49,7 +49,7 @@ ProjectionDivCleaner::ProjectionDivCleaner(std::string const& a_field_name) : m_source.resize(m_levels); const int ncomps = WarpX::ncomps; - auto const& ng = warpx.m_fields.get(m_field_name,Direction{0},0)->nGrowVect(); + auto const& ng = warpx.m_fields.get(m_field_name, Direction{0}, 0)->nGrowVect(); for (int lev = 0; lev < m_levels; ++lev) { @@ -214,9 +214,9 @@ ProjectionDivCleaner::setSourceFromBfield () WarpX::ComputeDivB( *m_source[ilev], 0, - {warpx.m_fields.get(m_field_name,Direction{0},ilev), - warpx.m_fields.get(m_field_name,Direction{1},ilev), - warpx.m_fields.get(m_field_name,Direction{2},ilev)}, + {warpx.m_fields.get(m_field_name, Direction{0}, ilev), + warpx.m_fields.get(m_field_name, Direction{1}, ilev), + warpx.m_fields.get(m_field_name, Direction{2}, ilev)}, WarpX::CellSize(0) ); @@ -243,9 +243,9 @@ ProjectionDivCleaner::correctBfield () for (int ilev = 0; ilev < m_levels; ++ilev) { // Grab B-field multifabs at this level - amrex::MultiFab* Bx = warpx.m_fields.get(m_field_name,Direction{0},ilev); - amrex::MultiFab* By = warpx.m_fields.get(m_field_name,Direction{1},ilev); - amrex::MultiFab* Bz = warpx.m_fields.get(m_field_name,Direction{2},ilev); + amrex::MultiFab* Bx = warpx.m_fields.get(m_field_name, Direction{0}, ilev); + amrex::MultiFab* By = warpx.m_fields.get(m_field_name, Direction{1}, ilev); + amrex::MultiFab* Bz = warpx.m_fields.get(m_field_name, Direction{2}, ilev); #ifdef AMREX_USE_OMP #pragma omp parallel if (Gpu::notInLaunchRegion()) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 0f950b3959d..70bf20d0905 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -503,8 +503,11 @@ void WarpX::InitData () { WARPX_PROFILE("WarpX::InitData()"); - ablastr::parallelization::check_mpi_thread_level(); + using ablastr::fields::Direction; + using warpx::fields::FieldType; + + ablastr::parallelization::check_mpi_thread_level(); #ifdef WARPX_QED Print() << "PICSAR (" << WarpX::PicsarVersion() << ")\n"; @@ -555,9 +558,9 @@ WarpX::InitData () const int lev_zero = 0; m_macroscopic_properties->InitData( Geom(lev_zero), - m_fields.get("Efield_fp",Direction{0},lev_zero)->ixType().toIntVect(), - m_fields.get("Efield_fp",Direction{1},lev_zero)->ixType().toIntVect(), - m_fields.get("Efield_fp",Direction{2},lev_zero)->ixType().toIntVect() + m_fields.get(FieldType::Efield_fp, Direction{0}, lev_zero)->ixType().toIntVect(), + m_fields.get(FieldType::Efield_fp, Direction{1}, lev_zero)->ixType().toIntVect(), + m_fields.get(FieldType::Efield_fp, Direction{2}, lev_zero)->ixType().toIntVect() ); } @@ -629,34 +632,36 @@ WarpX::InitData () } void -WarpX::AddExternalFields (int const lev) { +WarpX::AddExternalFields (int const lev) +{ using ablastr::fields::Direction; + using warpx::fields::FieldType; // FIXME: RZ multimode has more than one component for all these if (m_p_ext_field_params->E_ext_grid_type != ExternalFieldType::default_zero) { - ablastr::fields::MultiLevelVectorField Efield_fp = m_fields.get_mr_levels_alldirs("Efield_fp",max_level); + ablastr::fields::MultiLevelVectorField Efield_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, max_level); if (m_p_ext_field_params->E_ext_grid_type == ExternalFieldType::constant) { Efield_fp[lev][0]->plus(m_p_ext_field_params->E_external_grid[0], guard_cells.ng_alloc_EB.min()); Efield_fp[lev][1]->plus(m_p_ext_field_params->E_external_grid[1], guard_cells.ng_alloc_EB.min()); Efield_fp[lev][2]->plus(m_p_ext_field_params->E_external_grid[2], guard_cells.ng_alloc_EB.min()); } else { - amrex::MultiFab::Add(*Efield_fp[lev][0], *m_fields.get("Efield_fp_external",Direction{0},lev), 0, 0, 1, guard_cells.ng_alloc_EB); - amrex::MultiFab::Add(*Efield_fp[lev][1], *m_fields.get("Efield_fp_external",Direction{1},lev), 0, 0, 1, guard_cells.ng_alloc_EB); - amrex::MultiFab::Add(*Efield_fp[lev][2], *m_fields.get("Efield_fp_external",Direction{2},lev), 0, 0, 1, guard_cells.ng_alloc_EB); + amrex::MultiFab::Add(*Efield_fp[lev][0], *m_fields.get(FieldType::Efield_fp_external, Direction{0}, lev), 0, 0, 1, guard_cells.ng_alloc_EB); + amrex::MultiFab::Add(*Efield_fp[lev][1], *m_fields.get(FieldType::Efield_fp_external, Direction{1}, lev), 0, 0, 1, guard_cells.ng_alloc_EB); + amrex::MultiFab::Add(*Efield_fp[lev][2], *m_fields.get(FieldType::Efield_fp_external, Direction{2}, lev), 0, 0, 1, guard_cells.ng_alloc_EB); } } if (m_p_ext_field_params->B_ext_grid_type != ExternalFieldType::default_zero) { - ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", max_level); + ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, max_level); if (m_p_ext_field_params->B_ext_grid_type == ExternalFieldType::constant) { Bfield_fp[lev][0]->plus(m_p_ext_field_params->B_external_grid[0], guard_cells.ng_alloc_EB.min()); Bfield_fp[lev][1]->plus(m_p_ext_field_params->B_external_grid[1], guard_cells.ng_alloc_EB.min()); Bfield_fp[lev][2]->plus(m_p_ext_field_params->B_external_grid[2], guard_cells.ng_alloc_EB.min()); } else { - amrex::MultiFab::Add(*Bfield_fp[lev][0], *m_fields.get("Bfield_fp_external",Direction{0},lev), 0, 0, 1, guard_cells.ng_alloc_EB); - amrex::MultiFab::Add(*Bfield_fp[lev][1], *m_fields.get("Bfield_fp_external",Direction{1},lev), 0, 0, 1, guard_cells.ng_alloc_EB); - amrex::MultiFab::Add(*Bfield_fp[lev][2], *m_fields.get("Bfield_fp_external",Direction{2},lev), 0, 0, 1, guard_cells.ng_alloc_EB); + amrex::MultiFab::Add(*Bfield_fp[lev][0], *m_fields.get(FieldType::Bfield_fp_external, Direction{0}, lev), 0, 0, 1, guard_cells.ng_alloc_EB); + amrex::MultiFab::Add(*Bfield_fp[lev][1], *m_fields.get(FieldType::Bfield_fp_external, Direction{1}, lev), 0, 0, 1, guard_cells.ng_alloc_EB); + amrex::MultiFab::Add(*Bfield_fp[lev][2], *m_fields.get(FieldType::Bfield_fp_external, Direction{2}, lev), 0, 0, 1, guard_cells.ng_alloc_EB); } } } @@ -906,6 +911,7 @@ void WarpX::InitLevelData (int lev, Real /*time*/) { using ablastr::fields::Direction; + using warpx::fields::FieldType; // initialize the averaged fields only if the averaged algorithm // is activated ('psatd.do_time_averaging=1') @@ -922,14 +928,14 @@ WarpX::InitLevelData (int lev, Real /*time*/) if ( is_B_ext_const && (lev <= maxlevel_extEMfield_init) ) { if (fft_do_time_averaging) { - m_fields.get("Bfield_avg_fp", Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); + m_fields.get(FieldType::Bfield_avg_fp, Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); } if (lev > 0) { - m_fields.get("Bfield_aux", Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); - m_fields.get("Bfield_cp", Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); + m_fields.get(FieldType::Bfield_aux, Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); + m_fields.get(FieldType::Bfield_cp, Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); if (fft_do_time_averaging) { - m_fields.get("Bfield_avg_cp", Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); + m_fields.get(FieldType::Bfield_avg_cp, Direction{i}, lev)->setVal(m_p_ext_field_params->B_external_grid[i]); } } } @@ -942,13 +948,13 @@ WarpX::InitLevelData (int lev, Real /*time*/) if ( is_E_ext_const && (lev <= maxlevel_extEMfield_init) ) { if (fft_do_time_averaging) { - m_fields.get("Efield_avg_fp", Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); + m_fields.get(FieldType::Efield_avg_fp, Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); } if (lev > 0) { - m_fields.get("Efield_aux", Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); - m_fields.get("Efield_cp", Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); + m_fields.get(FieldType::Efield_aux, Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); + m_fields.get(FieldType::Efield_cp, Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); if (fft_do_time_averaging) { - m_fields.get("Efield_avg_cp", Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); + m_fields.get(FieldType::Efield_avg_cp, Direction{i}, lev)->setVal(m_p_ext_field_params->E_external_grid[i]); } } } @@ -968,26 +974,26 @@ WarpX::InitLevelData (int lev, Real /*time*/) && (lev > 0) && (lev <= maxlevel_extEMfield_init)) { InitializeExternalFieldsOnGridUsingParser( - m_fields.get("Bfield_aux", Direction{0}, lev), - m_fields.get("Bfield_aux", Direction{1}, lev), - m_fields.get("Bfield_aux", Direction{2}, lev), + m_fields.get(FieldType::Bfield_aux, Direction{0}, lev), + m_fields.get(FieldType::Bfield_aux, Direction{1}, lev), + m_fields.get(FieldType::Bfield_aux, Direction{2}, lev), m_p_ext_field_params->Bxfield_parser->compile<3>(), m_p_ext_field_params->Byfield_parser->compile<3>(), m_p_ext_field_params->Bzfield_parser->compile<3>(), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), 'B', lev, PatchType::fine); InitializeExternalFieldsOnGridUsingParser( - m_fields.get("Bfield_cp", Direction{0}, lev), - m_fields.get("Bfield_cp", Direction{1}, lev), - m_fields.get("Bfield_cp", Direction{2}, lev), + m_fields.get(FieldType::Bfield_cp, Direction{0}, lev), + m_fields.get(FieldType::Bfield_cp, Direction{1}, lev), + m_fields.get(FieldType::Bfield_cp, Direction{2}, lev), m_p_ext_field_params->Bxfield_parser->compile<3>(), m_p_ext_field_params->Byfield_parser->compile<3>(), m_p_ext_field_params->Bzfield_parser->compile<3>(), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_mr_levels_alldirs("face_areas", max_level)[lev], + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_mr_levels_alldirs(FieldType::face_areas, max_level)[lev], 'B', lev, PatchType::coarse); } @@ -1005,10 +1011,10 @@ WarpX::InitLevelData (int lev, Real /*time*/) // We initialize ECTRhofield consistently with the Efield if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) { m_fdtd_solver_fp[lev]->EvolveECTRho( - m_fields.get_alldirs("Efield_fp",lev), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_mr_levels_alldirs("face_areas", max_level)[lev], - m_fields.get_alldirs("ECTRhofield", lev), + m_fields.get_alldirs(FieldType::Efield_fp, lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_mr_levels_alldirs(FieldType::face_areas, max_level)[lev], + m_fields.get_alldirs(FieldType::ECTRhofield, lev), lev); } } @@ -1016,26 +1022,26 @@ WarpX::InitLevelData (int lev, Real /*time*/) if (lev > 0) { InitializeExternalFieldsOnGridUsingParser( - m_fields.get("Efield_aux", Direction{0}, lev), - m_fields.get("Efield_aux", Direction{1}, lev), - m_fields.get("Efield_aux", Direction{2}, lev), + m_fields.get(FieldType::Efield_aux, Direction{0}, lev), + m_fields.get(FieldType::Efield_aux, Direction{1}, lev), + m_fields.get(FieldType::Efield_aux, Direction{2}, lev), m_p_ext_field_params->Exfield_parser->compile<3>(), m_p_ext_field_params->Eyfield_parser->compile<3>(), m_p_ext_field_params->Ezfield_parser->compile<3>(), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), 'E', lev, PatchType::fine); InitializeExternalFieldsOnGridUsingParser( - m_fields.get("Efield_cp", Direction{0}, lev), - m_fields.get("Efield_cp", Direction{1}, lev), - m_fields.get("Efield_cp", Direction{2}, lev), + m_fields.get(FieldType::Efield_cp, Direction{0}, lev), + m_fields.get(FieldType::Efield_cp, Direction{1}, lev), + m_fields.get(FieldType::Efield_cp, Direction{2}, lev), m_p_ext_field_params->Exfield_parser->compile<3>(), m_p_ext_field_params->Eyfield_parser->compile<3>(), m_p_ext_field_params->Ezfield_parser->compile<3>(), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), 'E', lev, PatchType::coarse); #ifdef AMREX_USE_EB @@ -1043,10 +1049,10 @@ WarpX::InitLevelData (int lev, Real /*time*/) if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) { // We initialize ECTRhofield consistently with the Efield m_fdtd_solver_cp[lev]->EvolveECTRho( - m_fields.get_alldirs("Efield_cp",lev), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_mr_levels_alldirs("face_areas", max_level)[lev], - m_fields.get_alldirs("ECTRhofield", lev), + m_fields.get_alldirs(FieldType::Efield_cp, lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_mr_levels_alldirs(FieldType::face_areas, max_level)[lev], + m_fields.get_alldirs(FieldType::ECTRhofield, lev), lev); } } @@ -1284,15 +1290,17 @@ void WarpX::InitializeEBGridData (int lev) "particles are close to embedded boundaries"); } - if (WarpX::electromagnetic_solver_id != ElectromagneticSolverAlgo::PSATD ) { + if (WarpX::electromagnetic_solver_id != ElectromagneticSolverAlgo::PSATD ) + { + using warpx::fields::FieldType; auto const eb_fact = fieldEBFactory(lev); - auto edge_lengths_lev = m_fields.get_alldirs("edge_lengths", lev); + auto edge_lengths_lev = m_fields.get_alldirs(FieldType::edge_lengths, lev); ComputeEdgeLengths(edge_lengths_lev, eb_fact); ScaleEdges(edge_lengths_lev, CellSize(lev)); - auto face_areas_lev = m_fields.get_alldirs("face_areas", lev); + auto face_areas_lev = m_fields.get_alldirs(FieldType::face_areas, lev); ComputeFaceAreas(face_areas_lev, eb_fact); ScaleAreas(face_areas_lev, CellSize(lev)); @@ -1360,6 +1368,7 @@ void WarpX::LoadExternalFields (int const lev) { using ablastr::fields::Direction; + using warpx::fields::FieldType; // External fields from file are currently not compatible with the moving window // In order to support the moving window, the MultiFab containing the external @@ -1378,14 +1387,14 @@ WarpX::LoadExternalFields (int const lev) if (m_p_ext_field_params->B_ext_grid_type == ExternalFieldType::parse_ext_grid_function) { // Initialize Bfield_fp_external with external function InitializeExternalFieldsOnGridUsingParser( - m_fields.get("Bfield_fp_external",Direction{0},lev), - m_fields.get("Bfield_fp_external",Direction{1},lev), - m_fields.get("Bfield_fp_external",Direction{2},lev), + m_fields.get(FieldType::Bfield_fp_external, Direction{0}, lev), + m_fields.get(FieldType::Bfield_fp_external, Direction{1}, lev), + m_fields.get(FieldType::Bfield_fp_external, Direction{2}, lev), m_p_ext_field_params->Bxfield_parser->compile<3>(), m_p_ext_field_params->Byfield_parser->compile<3>(), m_p_ext_field_params->Bzfield_parser->compile<3>(), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), 'B', lev, PatchType::fine); } @@ -1393,27 +1402,27 @@ WarpX::LoadExternalFields (int const lev) #if defined(WARPX_DIM_RZ) WARPX_ALWAYS_ASSERT_WITH_MESSAGE(n_rz_azimuthal_modes == 1, "External field reading is not implemented for more than one RZ mode (see #3829)"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Bfield_fp_external",Direction{0},lev), "B", "r"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Bfield_fp_external",Direction{1},lev), "B", "t"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Bfield_fp_external",Direction{2},lev), "B", "z"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Bfield_fp_external,Direction{0},lev), "B", "r"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Bfield_fp_external,Direction{1},lev), "B", "t"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Bfield_fp_external,Direction{2},lev), "B", "z"); #else - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Bfield_fp_external",Direction{0},lev), "B", "x"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Bfield_fp_external",Direction{1},lev), "B", "y"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Bfield_fp_external",Direction{2},lev), "B", "z"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Bfield_fp_external, Direction{0}, lev), "B", "x"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Bfield_fp_external, Direction{1}, lev), "B", "y"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Bfield_fp_external, Direction{2}, lev), "B", "z"); #endif } if (m_p_ext_field_params->E_ext_grid_type == ExternalFieldType::parse_ext_grid_function) { // Initialize Efield_fp_external with external function InitializeExternalFieldsOnGridUsingParser( - m_fields.get("Efield_fp_external",Direction{0},lev), - m_fields.get("Efield_fp_external",Direction{1},lev), - m_fields.get("Efield_fp_external",Direction{2},lev), + m_fields.get(FieldType::Efield_fp_external, Direction{0}, lev), + m_fields.get(FieldType::Efield_fp_external, Direction{1}, lev), + m_fields.get(FieldType::Efield_fp_external, Direction{2}, lev), m_p_ext_field_params->Exfield_parser->compile<3>(), m_p_ext_field_params->Eyfield_parser->compile<3>(), m_p_ext_field_params->Ezfield_parser->compile<3>(), - m_fields.get_alldirs("edge_lengths", lev), - m_fields.get_alldirs("face_areas", lev), + m_fields.get_alldirs(FieldType::edge_lengths, lev), + m_fields.get_alldirs(FieldType::face_areas, lev), 'E', lev, PatchType::fine); } @@ -1421,13 +1430,13 @@ WarpX::LoadExternalFields (int const lev) #if defined(WARPX_DIM_RZ) WARPX_ALWAYS_ASSERT_WITH_MESSAGE(n_rz_azimuthal_modes == 1, "External field reading is not implemented for more than one RZ mode (see #3829)"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Efield_fp_external",Direction{0},lev), "E", "r"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Efield_fp_external",Direction{1},lev), "E", "t"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Efield_fp_external",Direction{2},lev), "E", "z"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Efield_fp_external,Direction{0},lev), "E", "r"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Efield_fp_external,Direction{1},lev), "E", "t"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Efield_fp_external,Direction{2},lev), "E", "z"); #else - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Efield_fp_external",Direction{0},lev), "E", "x"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Efield_fp_external",Direction{1},lev), "E", "y"); - ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get("Efield_fp_external",Direction{2},lev), "E", "z"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Efield_fp_external, Direction{0}, lev), "E", "x"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Efield_fp_external, Direction{1}, lev), "E", "y"); + ReadExternalFieldFromFile(m_p_ext_field_params->external_fields_path, m_fields.get(FieldType::Efield_fp_external, Direction{2}, lev), "E", "z"); #endif } @@ -1445,23 +1454,23 @@ WarpX::LoadExternalFields (int const lev) WARPX_ALWAYS_ASSERT_WITH_MESSAGE(n_rz_azimuthal_modes == 1, "External field reading is not implemented for more than one RZ mode (see #3829)"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("B_external_particle_field", Direction{0}, lev), + m_fields.get(FieldType::B_external_particle_field, Direction{0}, lev), "B", "r"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("B_external_particle_field", Direction{1}, lev), + m_fields.get(FieldType::B_external_particle_field, Direction{1}, lev), "B", "t"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("B_external_particle_field", Direction{2}, lev), + m_fields.get(FieldType::B_external_particle_field, Direction{2}, lev), "B", "z"); #else ReadExternalFieldFromFile(external_fields_path, - m_fields.get("B_external_particle_field", Direction{0}, lev), + m_fields.get(FieldType::B_external_particle_field, Direction{0}, lev), "B", "x"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("B_external_particle_field", Direction{1}, lev), + m_fields.get(FieldType::B_external_particle_field, Direction{1}, lev), "B", "y"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("B_external_particle_field", Direction{2}, lev), + m_fields.get(FieldType::B_external_particle_field, Direction{2}, lev), "B", "z"); #endif } @@ -1473,23 +1482,23 @@ WarpX::LoadExternalFields (int const lev) WARPX_ALWAYS_ASSERT_WITH_MESSAGE(n_rz_azimuthal_modes == 1, "External field reading is not implemented for more than one RZ mode (see #3829)"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("E_external_particle_field", Direction{0}, lev), + m_fields.get(FieldType::E_external_particle_field, Direction{0}, lev), "E", "r"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("E_external_particle_field", Direction{1}, lev), + m_fields.get(FieldType::E_external_particle_field, Direction{1}, lev), "E", "t"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("E_external_particle_field", Direction{2}, lev), + m_fields.get(FieldType::E_external_particle_field, Direction{2}, lev), "E", "z"); #else ReadExternalFieldFromFile(external_fields_path, - m_fields.get("E_external_particle_field", Direction{0}, lev), + m_fields.get(FieldType::E_external_particle_field, Direction{0}, lev), "E", "x"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("E_external_particle_field", Direction{1}, lev), + m_fields.get(FieldType::E_external_particle_field, Direction{1}, lev), "E", "y"); ReadExternalFieldFromFile(external_fields_path, - m_fields.get("E_external_particle_field", Direction{2}, lev), + m_fields.get(FieldType::E_external_particle_field, Direction{2}, lev), "E", "z"); #endif } diff --git a/Source/Parallelization/WarpXComm.cpp b/Source/Parallelization/WarpXComm.cpp index 34a2fb18095..ac797d1e706 100644 --- a/Source/Parallelization/WarpXComm.cpp +++ b/Source/Parallelization/WarpXComm.cpp @@ -12,6 +12,7 @@ #if (defined WARPX_DIM_RZ) && (defined WARPX_USE_FFT) # include "BoundaryConditions/PML_RZ.H" #endif +#include "Fields.H" #include "Filter/BilinearFilter.H" #include "Utils/TextMsg.H" #include "Utils/WarpXAlgorithmSelection.H" @@ -50,6 +51,7 @@ #include using namespace amrex; +using warpx::fields::FieldType; void WarpX::UpdateAuxilaryData () @@ -58,9 +60,9 @@ WarpX::UpdateAuxilaryData () using ablastr::fields::Direction; - amrex::MultiFab *Bfield_aux_lvl0_0 = m_fields.get("Bfield_aux", Direction{0}, 0); + amrex::MultiFab *Bfield_aux_lvl0_0 = m_fields.get(FieldType::Bfield_aux, Direction{0}, 0); - ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level); + ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); if (Bfield_aux_lvl0_0->ixType() == Bfield_fp[0][0]->ixType()) { UpdateAuxilaryDataSameType(); @@ -71,15 +73,15 @@ WarpX::UpdateAuxilaryData () // When loading particle fields from file: add the external fields: for (int lev = 0; lev <= finest_level; ++lev) { if (mypc->m_E_ext_particle_s == "read_from_file") { - ablastr::fields::VectorField Efield_aux = m_fields.get_alldirs("Efield_aux", lev); - const auto& E_ext_lev = m_fields.get_alldirs("E_external_particle_field", lev); + ablastr::fields::VectorField Efield_aux = m_fields.get_alldirs(FieldType::Efield_aux, lev); + const auto& E_ext_lev = m_fields.get_alldirs(FieldType::E_external_particle_field, lev); amrex::MultiFab::Add(*Efield_aux[0], *E_ext_lev[0], 0, 0, E_ext_lev[0]->nComp(), guard_cells.ng_FieldGather); amrex::MultiFab::Add(*Efield_aux[1], *E_ext_lev[1], 0, 0, E_ext_lev[1]->nComp(), guard_cells.ng_FieldGather); amrex::MultiFab::Add(*Efield_aux[2], *E_ext_lev[2], 0, 0, E_ext_lev[2]->nComp(), guard_cells.ng_FieldGather); } if (mypc->m_B_ext_particle_s == "read_from_file") { - ablastr::fields::VectorField Bfield_aux = m_fields.get_alldirs("Bfield_aux", lev); - const auto& B_ext_lev = m_fields.get_alldirs("B_external_particle_field", lev); + ablastr::fields::VectorField Bfield_aux = m_fields.get_alldirs(FieldType::Bfield_aux, lev); + const auto& B_ext_lev = m_fields.get_alldirs(FieldType::B_external_particle_field, lev); amrex::MultiFab::Add(*Bfield_aux[0], *B_ext_lev[0], 0, 0, B_ext_lev[0]->nComp(), guard_cells.ng_FieldGather); amrex::MultiFab::Add(*Bfield_aux[1], *B_ext_lev[1], 0, 0, B_ext_lev[1]->nComp(), guard_cells.ng_FieldGather); amrex::MultiFab::Add(*Bfield_aux[2], *B_ext_lev[2], 0, 0, B_ext_lev[2]->nComp(), guard_cells.ng_FieldGather); @@ -100,18 +102,18 @@ WarpX::UpdateAuxilaryDataStagToNodal () #endif using ablastr::fields::Direction; - ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level); - ablastr::fields::MultiLevelVectorField const& Efield_fp = m_fields.get_mr_levels_alldirs("Efield_fp", finest_level); - ablastr::fields::MultiLevelVectorField const& Efield_aux = m_fields.get_mr_levels_alldirs("Efield_aux", finest_level); - ablastr::fields::MultiLevelVectorField const& Bfield_aux = m_fields.get_mr_levels_alldirs("Bfield_aux", finest_level); + ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); + ablastr::fields::MultiLevelVectorField const& Efield_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, finest_level); + ablastr::fields::MultiLevelVectorField const& Efield_aux = m_fields.get_mr_levels_alldirs(FieldType::Efield_aux, finest_level); + ablastr::fields::MultiLevelVectorField const& Bfield_aux = m_fields.get_mr_levels_alldirs(FieldType::Bfield_aux, finest_level); ablastr::fields::MultiLevelVectorField const & Bmf = WarpX::fft_do_time_averaging ? - m_fields.get_mr_levels_alldirs("Bfield_avg_fp", finest_level) : + m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_fp, finest_level) : Bfield_fp; ablastr::fields::MultiLevelVectorField const & Emf = WarpX::fft_do_time_averaging ? - m_fields.get_mr_levels_alldirs("Efield_avg_fp", finest_level) : + m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_fp, finest_level) : Efield_fp; const amrex::IntVect& Bx_stag = Bmf[0][0]->ixType().toIntVect(); @@ -194,10 +196,10 @@ WarpX::UpdateAuxilaryDataStagToNodal () { if (electromagnetic_solver_id != ElectromagneticSolverAlgo::None) { Array,3> Btmp; - if (m_fields.has("Bfield_cax", Direction{0}, lev)) { + if (m_fields.has(FieldType::Bfield_cax, Direction{0}, lev)) { for (int i = 0; i < 3; ++i) { Btmp[i] = std::make_unique( - *m_fields.get("Bfield_cax", Direction{i}, lev), amrex::make_alias, 0, 1); + *m_fields.get(FieldType::Bfield_cax, Direction{i}, lev), amrex::make_alias, 0, 1); } } else { const IntVect ngtmp = Bfield_aux[lev-1][0]->nGrowVect(); @@ -221,13 +223,13 @@ WarpX::UpdateAuxilaryDataStagToNodal () const amrex::IntVect& refinement_ratio = refRatio(lev-1); - const amrex::IntVect& Bx_fp_stag = m_fields.get("Bfield_fp",Direction{0},lev)->ixType().toIntVect(); - const amrex::IntVect& By_fp_stag = m_fields.get("Bfield_fp",Direction{1},lev)->ixType().toIntVect(); - const amrex::IntVect& Bz_fp_stag = m_fields.get("Bfield_fp",Direction{2},lev)->ixType().toIntVect(); + const amrex::IntVect& Bx_fp_stag = m_fields.get(FieldType::Bfield_fp, Direction{0}, lev)->ixType().toIntVect(); + const amrex::IntVect& By_fp_stag = m_fields.get(FieldType::Bfield_fp, Direction{1}, lev)->ixType().toIntVect(); + const amrex::IntVect& Bz_fp_stag = m_fields.get(FieldType::Bfield_fp, Direction{2}, lev)->ixType().toIntVect(); - const amrex::IntVect& Bx_cp_stag = m_fields.get("Bfield_cp",Direction{0},lev)->ixType().toIntVect(); - const amrex::IntVect& By_cp_stag = m_fields.get("Bfield_cp",Direction{1},lev)->ixType().toIntVect(); - const amrex::IntVect& Bz_cp_stag = m_fields.get("Bfield_cp",Direction{2},lev)->ixType().toIntVect(); + const amrex::IntVect& Bx_cp_stag = m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->ixType().toIntVect(); + const amrex::IntVect& By_cp_stag = m_fields.get(FieldType::Bfield_cp, Direction{1}, lev)->ixType().toIntVect(); + const amrex::IntVect& Bz_cp_stag = m_fields.get(FieldType::Bfield_cp, Direction{2}, lev)->ixType().toIntVect(); #ifdef AMREX_USE_OMP #pragma omp parallel if (Gpu::notInLaunchRegion()) @@ -237,12 +239,12 @@ WarpX::UpdateAuxilaryDataStagToNodal () Array4 const& bx_aux = Bfield_aux[lev][0]->array(mfi); Array4 const& by_aux = Bfield_aux[lev][1]->array(mfi); Array4 const& bz_aux = Bfield_aux[lev][2]->array(mfi); - Array4 const& bx_fp = m_fields.get("Bfield_fp",Direction{0},lev)->const_array(mfi); - Array4 const& by_fp = m_fields.get("Bfield_fp",Direction{1},lev)->const_array(mfi); - Array4 const& bz_fp = m_fields.get("Bfield_fp",Direction{2},lev)->const_array(mfi); - Array4 const& bx_cp = m_fields.get("Bfield_cp",Direction{0},lev)->const_array(mfi); - Array4 const& by_cp = m_fields.get("Bfield_cp",Direction{1},lev)->const_array(mfi); - Array4 const& bz_cp = m_fields.get("Bfield_cp",Direction{2},lev)->const_array(mfi); + Array4 const& bx_fp = m_fields.get(FieldType::Bfield_fp, Direction{0}, lev)->const_array(mfi); + Array4 const& by_fp = m_fields.get(FieldType::Bfield_fp, Direction{1}, lev)->const_array(mfi); + Array4 const& bz_fp = m_fields.get(FieldType::Bfield_fp, Direction{2}, lev)->const_array(mfi); + Array4 const& bx_cp = m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->const_array(mfi); + Array4 const& by_cp = m_fields.get(FieldType::Bfield_cp, Direction{1}, lev)->const_array(mfi); + Array4 const& bz_cp = m_fields.get(FieldType::Bfield_cp, Direction{2}, lev)->const_array(mfi); Array4 const& bx_c = Btmp[0]->const_array(mfi); Array4 const& by_c = Btmp[1]->const_array(mfi); Array4 const& bz_c = Btmp[2]->const_array(mfi); @@ -288,10 +290,10 @@ WarpX::UpdateAuxilaryDataStagToNodal () { if (electromagnetic_solver_id != ElectromagneticSolverAlgo::None) { Array,3> Etmp; - if (m_fields.has("Efield_cax", Direction{0}, lev)) { + if (m_fields.has(FieldType::Efield_cax, Direction{0}, lev)) { for (int i = 0; i < 3; ++i) { Etmp[i] = std::make_unique( - *m_fields.get("Efield_cax", Direction{i}, lev), amrex::make_alias, 0, 1); + *m_fields.get(FieldType::Efield_cax, Direction{i}, lev), amrex::make_alias, 0, 1); } } else { const IntVect ngtmp = Efield_aux[lev-1][0]->nGrowVect(); @@ -316,13 +318,13 @@ WarpX::UpdateAuxilaryDataStagToNodal () const amrex::IntVect& refinement_ratio = refRatio(lev-1); - const amrex::IntVect& Ex_fp_stag = m_fields.get("Efield_fp",Direction{0},lev)->ixType().toIntVect(); - const amrex::IntVect& Ey_fp_stag = m_fields.get("Efield_fp",Direction{1},lev)->ixType().toIntVect(); - const amrex::IntVect& Ez_fp_stag = m_fields.get("Efield_fp",Direction{2},lev)->ixType().toIntVect(); + const amrex::IntVect& Ex_fp_stag = m_fields.get(FieldType::Efield_fp, Direction{0}, lev)->ixType().toIntVect(); + const amrex::IntVect& Ey_fp_stag = m_fields.get(FieldType::Efield_fp, Direction{1}, lev)->ixType().toIntVect(); + const amrex::IntVect& Ez_fp_stag = m_fields.get(FieldType::Efield_fp, Direction{2}, lev)->ixType().toIntVect(); - const amrex::IntVect& Ex_cp_stag = m_fields.get("Efield_cp",Direction{0},lev)->ixType().toIntVect(); - const amrex::IntVect& Ey_cp_stag = m_fields.get("Efield_cp",Direction{1},lev)->ixType().toIntVect(); - const amrex::IntVect& Ez_cp_stag = m_fields.get("Efield_cp",Direction{2},lev)->ixType().toIntVect(); + const amrex::IntVect& Ex_cp_stag = m_fields.get(FieldType::Efield_cp, Direction{0}, lev)->ixType().toIntVect(); + const amrex::IntVect& Ey_cp_stag = m_fields.get(FieldType::Efield_cp, Direction{1}, lev)->ixType().toIntVect(); + const amrex::IntVect& Ez_cp_stag = m_fields.get(FieldType::Efield_cp, Direction{2}, lev)->ixType().toIntVect(); #ifdef AMREX_USE_OMP #pragma omp parallel if (Gpu::notInLaunchRegion()) @@ -332,12 +334,12 @@ WarpX::UpdateAuxilaryDataStagToNodal () Array4 const& ex_aux = Efield_aux[lev][0]->array(mfi); Array4 const& ey_aux = Efield_aux[lev][1]->array(mfi); Array4 const& ez_aux = Efield_aux[lev][2]->array(mfi); - Array4 const& ex_fp = m_fields.get("Efield_fp",Direction{0},lev)->const_array(mfi); - Array4 const& ey_fp = m_fields.get("Efield_fp",Direction{1},lev)->const_array(mfi); - Array4 const& ez_fp = m_fields.get("Efield_fp",Direction{2},lev)->const_array(mfi); - Array4 const& ex_cp = m_fields.get("Efield_cp",Direction{0},lev)->const_array(mfi); - Array4 const& ey_cp = m_fields.get("Efield_cp",Direction{1},lev)->const_array(mfi); - Array4 const& ez_cp = m_fields.get("Efield_cp",Direction{2},lev)->const_array(mfi); + Array4 const& ex_fp = m_fields.get(FieldType::Efield_fp, Direction{0}, lev)->const_array(mfi); + Array4 const& ey_fp = m_fields.get(FieldType::Efield_fp, Direction{1}, lev)->const_array(mfi); + Array4 const& ez_fp = m_fields.get(FieldType::Efield_fp, Direction{2}, lev)->const_array(mfi); + Array4 const& ex_cp = m_fields.get(FieldType::Efield_cp, Direction{0}, lev)->const_array(mfi); + Array4 const& ey_cp = m_fields.get(FieldType::Efield_cp, Direction{1}, lev)->const_array(mfi); + Array4 const& ez_cp = m_fields.get(FieldType::Efield_cp, Direction{2}, lev)->const_array(mfi); Array4 const& ex_c = Etmp[0]->const_array(mfi); Array4 const& ey_c = Etmp[1]->const_array(mfi); Array4 const& ez_c = Etmp[2]->const_array(mfi); @@ -353,9 +355,9 @@ WarpX::UpdateAuxilaryDataStagToNodal () } } else { // electrostatic - const amrex::IntVect& Ex_fp_stag = m_fields.get("Efield_fp",Direction{0},lev)->ixType().toIntVect(); - const amrex::IntVect& Ey_fp_stag = m_fields.get("Efield_fp",Direction{1},lev)->ixType().toIntVect(); - const amrex::IntVect& Ez_fp_stag = m_fields.get("Efield_fp",Direction{2},lev)->ixType().toIntVect(); + const amrex::IntVect& Ex_fp_stag = m_fields.get(FieldType::Efield_fp, Direction{0}, lev)->ixType().toIntVect(); + const amrex::IntVect& Ey_fp_stag = m_fields.get(FieldType::Efield_fp, Direction{1}, lev)->ixType().toIntVect(); + const amrex::IntVect& Ez_fp_stag = m_fields.get(FieldType::Efield_fp, Direction{2}, lev)->ixType().toIntVect(); #ifdef AMREX_USE_OMP #pragma omp parallel if (Gpu::notInLaunchRegion()) #endif @@ -364,9 +366,9 @@ WarpX::UpdateAuxilaryDataStagToNodal () Array4 const& ex_aux = Efield_aux[lev][0]->array(mfi); Array4 const& ey_aux = Efield_aux[lev][1]->array(mfi); Array4 const& ez_aux = Efield_aux[lev][2]->array(mfi); - Array4 const& ex_fp = m_fields.get("Efield_fp",Direction{0},lev)->const_array(mfi); - Array4 const& ey_fp = m_fields.get("Efield_fp",Direction{1},lev)->const_array(mfi); - Array4 const& ez_fp = m_fields.get("Efield_fp",Direction{2},lev)->const_array(mfi); + Array4 const& ex_fp = m_fields.get(FieldType::Efield_fp, Direction{0}, lev)->const_array(mfi); + Array4 const& ey_fp = m_fields.get(FieldType::Efield_fp, Direction{1}, lev)->const_array(mfi); + Array4 const& ez_fp = m_fields.get(FieldType::Efield_fp, Direction{2}, lev)->const_array(mfi); const Box& bx = mfi.growntilebox(); amrex::ParallelFor(bx, @@ -389,22 +391,22 @@ WarpX::UpdateAuxilaryDataSameType () const amrex::IntVect& ng_src = guard_cells.ng_FieldGather; using ablastr::fields::Direction; - ablastr::fields::MultiLevelVectorField Efield_fp = m_fields.get_mr_levels_alldirs("Efield_fp", finest_level); - ablastr::fields::MultiLevelVectorField Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level); - ablastr::fields::MultiLevelVectorField Efield_aux = m_fields.get_mr_levels_alldirs("Efield_aux", finest_level); - ablastr::fields::MultiLevelVectorField Bfield_aux = m_fields.get_mr_levels_alldirs("Bfield_aux", finest_level); + ablastr::fields::MultiLevelVectorField Efield_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_fp, finest_level); + ablastr::fields::MultiLevelVectorField Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); + ablastr::fields::MultiLevelVectorField Efield_aux = m_fields.get_mr_levels_alldirs(FieldType::Efield_aux, finest_level); + ablastr::fields::MultiLevelVectorField Bfield_aux = m_fields.get_mr_levels_alldirs(FieldType::Bfield_aux, finest_level); // Level 0: Copy from fine to aux // Note: in some configurations, Efield_aux/Bfield_aux and Efield_fp/Bfield_fp are simply aliases to the // same MultiFab object. MultiFab::Copy operation automatically detects this and does nothing in this case. if (WarpX::fft_do_time_averaging) { - MultiFab::Copy(*Efield_aux[0][0], *m_fields.get("Efield_avg_fp", Direction{0}, 0), 0, 0, Efield_aux[0][0]->nComp(), ng_src); - MultiFab::Copy(*Efield_aux[0][1], *m_fields.get("Efield_avg_fp", Direction{1}, 0), 0, 0, Efield_aux[0][1]->nComp(), ng_src); - MultiFab::Copy(*Efield_aux[0][2], *m_fields.get("Efield_avg_fp", Direction{2}, 0), 0, 0, Efield_aux[0][2]->nComp(), ng_src); - MultiFab::Copy(*Bfield_aux[0][0], *m_fields.get("Bfield_avg_fp", Direction{0}, 0), 0, 0, Bfield_aux[0][0]->nComp(), ng_src); - MultiFab::Copy(*Bfield_aux[0][1], *m_fields.get("Bfield_avg_fp", Direction{1}, 0), 0, 0, Bfield_aux[0][1]->nComp(), ng_src); - MultiFab::Copy(*Bfield_aux[0][2], *m_fields.get("Bfield_avg_fp", Direction{2}, 0), 0, 0, Bfield_aux[0][2]->nComp(), ng_src); + MultiFab::Copy(*Efield_aux[0][0], *m_fields.get(FieldType::Efield_avg_fp, Direction{0}, 0), 0, 0, Efield_aux[0][0]->nComp(), ng_src); + MultiFab::Copy(*Efield_aux[0][1], *m_fields.get(FieldType::Efield_avg_fp, Direction{1}, 0), 0, 0, Efield_aux[0][1]->nComp(), ng_src); + MultiFab::Copy(*Efield_aux[0][2], *m_fields.get(FieldType::Efield_avg_fp, Direction{2}, 0), 0, 0, Efield_aux[0][2]->nComp(), ng_src); + MultiFab::Copy(*Bfield_aux[0][0], *m_fields.get(FieldType::Bfield_avg_fp, Direction{0}, 0), 0, 0, Bfield_aux[0][0]->nComp(), ng_src); + MultiFab::Copy(*Bfield_aux[0][1], *m_fields.get(FieldType::Bfield_avg_fp, Direction{1}, 0), 0, 0, Bfield_aux[0][1]->nComp(), ng_src); + MultiFab::Copy(*Bfield_aux[0][2], *m_fields.get(FieldType::Bfield_avg_fp, Direction{2}, 0), 0, 0, Bfield_aux[0][2]->nComp(), ng_src); } else { @@ -418,19 +420,19 @@ WarpX::UpdateAuxilaryDataSameType () for (int lev = 1; lev <= finest_level; ++lev) { const amrex::Periodicity& crse_period = Geom(lev-1).periodicity(); - const IntVect& ng = m_fields.get("Bfield_cp", Direction{0}, lev)->nGrowVect(); - const DistributionMapping& dm = m_fields.get("Bfield_cp", Direction{0}, lev)->DistributionMap(); + const IntVect& ng = m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->nGrowVect(); + const DistributionMapping& dm = m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->DistributionMap(); // B field { if (electromagnetic_solver_id != ElectromagneticSolverAlgo::None) { - MultiFab dBx(m_fields.get("Bfield_cp",Direction{0},lev)->boxArray(), dm, - m_fields.get("Bfield_cp",Direction{0},lev)->nComp(), ng); - MultiFab dBy(m_fields.get("Bfield_cp",Direction{1},lev)->boxArray(), dm, - m_fields.get("Bfield_cp",Direction{1},lev)->nComp(), ng); - MultiFab dBz(m_fields.get("Bfield_cp",Direction{2},lev)->boxArray(), dm, - m_fields.get("Bfield_cp",Direction{2},lev)->nComp(), ng); + MultiFab dBx(m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->boxArray(), dm, + m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->nComp(), ng); + MultiFab dBy(m_fields.get(FieldType::Bfield_cp, Direction{1}, lev)->boxArray(), dm, + m_fields.get(FieldType::Bfield_cp, Direction{1}, lev)->nComp(), ng); + MultiFab dBz(m_fields.get(FieldType::Bfield_cp, Direction{2}, lev)->boxArray(), dm, + m_fields.get(FieldType::Bfield_cp, Direction{2}, lev)->nComp(), ng); dBx.setVal(0.0); dBy.setVal(0.0); dBz.setVal(0.0); @@ -448,18 +450,18 @@ WarpX::UpdateAuxilaryDataSameType () Bfield_aux[lev - 1][2]->nComp(), ng_src, ng, WarpX::do_single_precision_comms, crse_period); - if (m_fields.has("Bfield_cax", Direction{0}, lev)) + if (m_fields.has(FieldType::Bfield_cax, Direction{0}, lev)) { - MultiFab::Copy(*m_fields.get("Bfield_cax", Direction{0}, lev), dBx, 0, 0, m_fields.get("Bfield_cax", Direction{0}, lev)->nComp(), ng); - MultiFab::Copy(*m_fields.get("Bfield_cax", Direction{1}, lev), dBy, 0, 0, m_fields.get("Bfield_cax", Direction{1}, lev)->nComp(), ng); - MultiFab::Copy(*m_fields.get("Bfield_cax", Direction{2}, lev), dBz, 0, 0, m_fields.get("Bfield_cax", Direction{2}, lev)->nComp(), ng); + MultiFab::Copy(*m_fields.get(FieldType::Bfield_cax, Direction{0}, lev), dBx, 0, 0, m_fields.get(FieldType::Bfield_cax, Direction{0}, lev)->nComp(), ng); + MultiFab::Copy(*m_fields.get(FieldType::Bfield_cax, Direction{1}, lev), dBy, 0, 0, m_fields.get(FieldType::Bfield_cax, Direction{1}, lev)->nComp(), ng); + MultiFab::Copy(*m_fields.get(FieldType::Bfield_cax, Direction{2}, lev), dBz, 0, 0, m_fields.get(FieldType::Bfield_cax, Direction{2}, lev)->nComp(), ng); } - MultiFab::Subtract(dBx, *m_fields.get("Bfield_cp",Direction{0},lev), - 0, 0, m_fields.get("Bfield_cp",Direction{0},lev)->nComp(), ng); - MultiFab::Subtract(dBy, *m_fields.get("Bfield_cp",Direction{1},lev), - 0, 0, m_fields.get("Bfield_cp",Direction{1},lev)->nComp(), ng); - MultiFab::Subtract(dBz, *m_fields.get("Bfield_cp",Direction{2},lev), - 0, 0, m_fields.get("Bfield_cp",Direction{2},lev)->nComp(), ng); + MultiFab::Subtract(dBx, *m_fields.get(FieldType::Bfield_cp, Direction{0}, lev), + 0, 0, m_fields.get(FieldType::Bfield_cp, Direction{0}, lev)->nComp(), ng); + MultiFab::Subtract(dBy, *m_fields.get(FieldType::Bfield_cp, Direction{1}, lev), + 0, 0, m_fields.get(FieldType::Bfield_cp, Direction{1}, lev)->nComp(), ng); + MultiFab::Subtract(dBz, *m_fields.get(FieldType::Bfield_cp, Direction{2}, lev), + 0, 0, m_fields.get(FieldType::Bfield_cp, Direction{2}, lev)->nComp(), ng); const amrex::IntVect& refinement_ratio = refRatio(lev-1); @@ -508,12 +510,12 @@ WarpX::UpdateAuxilaryDataSameType () { if (electromagnetic_solver_id != ElectromagneticSolverAlgo::None) { - MultiFab dEx(m_fields.get("Efield_cp",Direction{0},lev)->boxArray(), dm, - m_fields.get("Efield_cp",Direction{0},lev)->nComp(), ng); - MultiFab dEy(m_fields.get("Efield_cp",Direction{1},lev)->boxArray(), dm, - m_fields.get("Efield_cp",Direction{1},lev)->nComp(), ng); - MultiFab dEz(m_fields.get("Efield_cp",Direction{2},lev)->boxArray(), dm, - m_fields.get("Efield_cp",Direction{2},lev)->nComp(), ng); + MultiFab dEx(m_fields.get(FieldType::Efield_cp, Direction{0}, lev)->boxArray(), dm, + m_fields.get(FieldType::Efield_cp, Direction{0}, lev)->nComp(), ng); + MultiFab dEy(m_fields.get(FieldType::Efield_cp, Direction{1}, lev)->boxArray(), dm, + m_fields.get(FieldType::Efield_cp, Direction{1}, lev)->nComp(), ng); + MultiFab dEz(m_fields.get(FieldType::Efield_cp, Direction{2}, lev)->boxArray(), dm, + m_fields.get(FieldType::Efield_cp, Direction{2}, lev)->nComp(), ng); dEx.setVal(0.0); dEy.setVal(0.0); dEz.setVal(0.0); @@ -533,18 +535,18 @@ WarpX::UpdateAuxilaryDataSameType () WarpX::do_single_precision_comms, crse_period); - if (m_fields.has("Efield_cax", Direction{0}, lev)) + if (m_fields.has(FieldType::Efield_cax, Direction{0}, lev)) { - MultiFab::Copy(*m_fields.get("Efield_cax", Direction{0}, lev), dEx, 0, 0, m_fields.get("Efield_cax", Direction{0}, lev)->nComp(), ng); - MultiFab::Copy(*m_fields.get("Efield_cax", Direction{1}, lev), dEy, 0, 0, m_fields.get("Efield_cax", Direction{1}, lev)->nComp(), ng); - MultiFab::Copy(*m_fields.get("Efield_cax", Direction{2}, lev), dEz, 0, 0, m_fields.get("Efield_cax", Direction{2}, lev)->nComp(), ng); + MultiFab::Copy(*m_fields.get(FieldType::Efield_cax, Direction{0}, lev), dEx, 0, 0, m_fields.get(FieldType::Efield_cax, Direction{0}, lev)->nComp(), ng); + MultiFab::Copy(*m_fields.get(FieldType::Efield_cax, Direction{1}, lev), dEy, 0, 0, m_fields.get(FieldType::Efield_cax, Direction{1}, lev)->nComp(), ng); + MultiFab::Copy(*m_fields.get(FieldType::Efield_cax, Direction{2}, lev), dEz, 0, 0, m_fields.get(FieldType::Efield_cax, Direction{2}, lev)->nComp(), ng); } - MultiFab::Subtract(dEx, *m_fields.get("Efield_cp",Direction{0},lev), - 0, 0, m_fields.get("Efield_cp",Direction{0},lev)->nComp(), ng); - MultiFab::Subtract(dEy, *m_fields.get("Efield_cp",Direction{1},lev), - 0, 0, m_fields.get("Efield_cp",Direction{1},lev)->nComp(), ng); - MultiFab::Subtract(dEz, *m_fields.get("Efield_cp",Direction{2},lev), - 0, 0, m_fields.get("Efield_cp",Direction{2},lev)->nComp(), ng); + MultiFab::Subtract(dEx, *m_fields.get(FieldType::Efield_cp, Direction{0}, lev), + 0, 0, m_fields.get(FieldType::Efield_cp, Direction{0}, lev)->nComp(), ng); + MultiFab::Subtract(dEy, *m_fields.get(FieldType::Efield_cp, Direction{1}, lev), + 0, 0, m_fields.get(FieldType::Efield_cp, Direction{1}, lev)->nComp(), ng); + MultiFab::Subtract(dEz, *m_fields.get(FieldType::Efield_cp, Direction{2}, lev), + 0, 0, m_fields.get(FieldType::Efield_cp, Direction{2}, lev)->nComp(), ng); const amrex::IntVect& refinement_ratio = refRatio(lev-1); @@ -560,9 +562,9 @@ WarpX::UpdateAuxilaryDataSameType () Array4 const& ex_aux = Efield_aux[lev][0]->array(mfi); Array4 const& ey_aux = Efield_aux[lev][1]->array(mfi); Array4 const& ez_aux = Efield_aux[lev][2]->array(mfi); - Array4 const& ex_fp = m_fields.get("Efield_fp",Direction{0},lev)->const_array(mfi); - Array4 const& ey_fp = m_fields.get("Efield_fp",Direction{1},lev)->const_array(mfi); - Array4 const& ez_fp = m_fields.get("Efield_fp",Direction{2},lev)->const_array(mfi); + Array4 const& ex_fp = m_fields.get(FieldType::Efield_fp, Direction{0}, lev)->const_array(mfi); + Array4 const& ey_fp = m_fields.get(FieldType::Efield_fp, Direction{1}, lev)->const_array(mfi); + Array4 const& ez_fp = m_fields.get(FieldType::Efield_fp, Direction{2}, lev)->const_array(mfi); Array4 const& ex_c = dEx.const_array(mfi); Array4 const& ey_c = dEy.const_array(mfi); Array4 const& ez_c = dEz.const_array(mfi); @@ -584,9 +586,9 @@ WarpX::UpdateAuxilaryDataSameType () } else // electrostatic { - MultiFab::Copy(*Efield_aux[lev][0], *m_fields.get("Efield_fp",Direction{0},lev), 0, 0, Efield_aux[lev][0]->nComp(), Efield_aux[lev][0]->nGrowVect()); - MultiFab::Copy(*Efield_aux[lev][1], *m_fields.get("Efield_fp",Direction{1},lev), 0, 0, Efield_aux[lev][1]->nComp(), Efield_aux[lev][1]->nGrowVect()); - MultiFab::Copy(*Efield_aux[lev][2], *m_fields.get("Efield_fp",Direction{2},lev), 0, 0, Efield_aux[lev][2]->nComp(), Efield_aux[lev][2]->nGrowVect()); + MultiFab::Copy(*Efield_aux[lev][0], *m_fields.get(FieldType::Efield_fp, Direction{0}, lev), 0, 0, Efield_aux[lev][0]->nComp(), Efield_aux[lev][0]->nGrowVect()); + MultiFab::Copy(*Efield_aux[lev][1], *m_fields.get(FieldType::Efield_fp, Direction{1}, lev), 0, 0, Efield_aux[lev][1]->nComp(), Efield_aux[lev][1]->nGrowVect()); + MultiFab::Copy(*Efield_aux[lev][2], *m_fields.get(FieldType::Efield_fp, Direction{2}, lev), 0, 0, Efield_aux[lev][2]->nComp(), Efield_aux[lev][2]->nGrowVect()); } } } @@ -711,16 +713,16 @@ WarpX::FillBoundaryE (const int lev, const PatchType patch_type, const amrex::In if (patch_type == PatchType::fine) { - mf = {m_fields.get("Efield_fp",Direction{0},lev), - m_fields.get("Efield_fp",Direction{1},lev), - m_fields.get("Efield_fp",Direction{2},lev)}; + mf = {m_fields.get(FieldType::Efield_fp, Direction{0}, lev), + m_fields.get(FieldType::Efield_fp, Direction{1}, lev), + m_fields.get(FieldType::Efield_fp, Direction{2}, lev)}; period = Geom(lev).periodicity(); } else // coarse patch { - mf = {m_fields.get("Efield_cp",Direction{0},lev), - m_fields.get("Efield_cp",Direction{1},lev), - m_fields.get("Efield_cp",Direction{2},lev)}; + mf = {m_fields.get(FieldType::Efield_cp, Direction{0}, lev), + m_fields.get(FieldType::Efield_cp, Direction{1}, lev), + m_fields.get(FieldType::Efield_cp, Direction{2}, lev)}; period = Geom(lev-1).periodicity(); } @@ -732,8 +734,8 @@ WarpX::FillBoundaryE (const int lev, const PatchType patch_type, const amrex::In { const std::array mf_pml = (patch_type == PatchType::fine) ? - m_fields.get_alldirs("pml_E_fp", lev) : - m_fields.get_alldirs("pml_E_cp", lev); + m_fields.get_alldirs(FieldType::pml_E_fp, lev) : + m_fields.get_alldirs(FieldType::pml_E_cp, lev); pml[lev]->Exchange(mf_pml, mf, patch_type, do_pml_in_domain); pml[lev]->FillBoundary(mf_pml, patch_type, nodal_sync); @@ -776,16 +778,16 @@ WarpX::FillBoundaryB (const int lev, const PatchType patch_type, const amrex::In if (patch_type == PatchType::fine) { - mf = {m_fields.get("Bfield_fp",Direction{0},lev), - m_fields.get("Bfield_fp",Direction{1},lev), - m_fields.get("Bfield_fp",Direction{2},lev)}; + mf = {m_fields.get(FieldType::Bfield_fp, Direction{0}, lev), + m_fields.get(FieldType::Bfield_fp, Direction{1}, lev), + m_fields.get(FieldType::Bfield_fp, Direction{2}, lev)}; period = Geom(lev).periodicity(); } else // coarse patch { - mf = {m_fields.get("Bfield_cp",Direction{0},lev), - m_fields.get("Bfield_cp",Direction{1},lev), - m_fields.get("Bfield_cp",Direction{2},lev)}; + mf = {m_fields.get(FieldType::Bfield_cp, Direction{0}, lev), + m_fields.get(FieldType::Bfield_cp, Direction{1}, lev), + m_fields.get(FieldType::Bfield_cp, Direction{2}, lev)}; period = Geom(lev-1).periodicity(); } @@ -797,8 +799,8 @@ WarpX::FillBoundaryB (const int lev, const PatchType patch_type, const amrex::In { const std::array mf_pml = (patch_type == PatchType::fine) ? - m_fields.get_alldirs("pml_B_fp", lev) : - m_fields.get_alldirs("pml_B_cp", lev); + m_fields.get_alldirs(FieldType::pml_B_fp, lev) : + m_fields.get_alldirs(FieldType::pml_B_cp, lev); pml[lev]->Exchange(mf_pml, mf, patch_type, do_pml_in_domain); pml[lev]->FillBoundary(mf_pml, patch_type, nodal_sync); @@ -841,7 +843,7 @@ WarpX::FillBoundaryE_avg (int lev, PatchType patch_type, IntVect ng) WARPX_ABORT_WITH_MESSAGE("Averaged Galilean PSATD with PML is not yet implemented"); } - ablastr::fields::MultiLevelVectorField Efield_avg_fp = m_fields.get_mr_levels_alldirs("Efield_avg_fp", finest_level); + ablastr::fields::MultiLevelVectorField Efield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_fp, finest_level); const amrex::Periodicity& period = Geom(lev).periodicity(); if ( safe_guard_cells ){ @@ -863,7 +865,7 @@ WarpX::FillBoundaryE_avg (int lev, PatchType patch_type, IntVect ng) WARPX_ABORT_WITH_MESSAGE("Averaged Galilean PSATD with PML is not yet implemented"); } - ablastr::fields::MultiLevelVectorField Efield_avg_cp = m_fields.get_mr_levels_alldirs("Efield_avg_cp", finest_level); + ablastr::fields::MultiLevelVectorField Efield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_cp, finest_level); const amrex::Periodicity& cperiod = Geom(lev-1).periodicity(); if ( safe_guard_cells ) { @@ -901,7 +903,7 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng) WARPX_ABORT_WITH_MESSAGE("Averaged Galilean PSATD with PML is not yet implemented"); } - ablastr::fields::MultiLevelVectorField Bfield_avg_fp = m_fields.get_mr_levels_alldirs("Bfield_avg_fp", finest_level); + ablastr::fields::MultiLevelVectorField Bfield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_fp, finest_level); const amrex::Periodicity& period = Geom(lev).periodicity(); if ( safe_guard_cells ) { @@ -909,7 +911,7 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng) ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period); } else { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - ng.allLE(m_fields.get("Bfield_fp",Direction{0},lev)->nGrowVect()), + ng.allLE(m_fields.get(FieldType::Bfield_fp, Direction{0}, lev)->nGrowVect()), "Error: in FillBoundaryB, requested more guard cells than allocated"); ablastr::utils::communication::FillBoundary(*Bfield_avg_fp[lev][0], ng, WarpX::do_single_precision_comms, period); ablastr::utils::communication::FillBoundary(*Bfield_avg_fp[lev][1], ng, WarpX::do_single_precision_comms, period); @@ -923,7 +925,7 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng) WARPX_ABORT_WITH_MESSAGE("Averaged Galilean PSATD with PML is not yet implemented"); } - ablastr::fields::MultiLevelVectorField Bfield_avg_cp = m_fields.get_mr_levels_alldirs("Bfield_avg_cp", finest_level); + ablastr::fields::MultiLevelVectorField Bfield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_cp, finest_level); const amrex::Periodicity& cperiod = Geom(lev-1).periodicity(); if ( safe_guard_cells ){ @@ -954,38 +956,38 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng, std::optionalok()) { - if (m_fields.has("pml_F_fp", lev) && m_fields.has("F_fp", lev)) { - pml[lev]->Exchange(m_fields.get("pml_F_fp", lev), m_fields.get("F_fp", lev), patch_type, do_pml_in_domain); + if (m_fields.has(FieldType::pml_F_fp, lev) && m_fields.has(FieldType::F_fp, lev)) { + pml[lev]->Exchange(m_fields.get(FieldType::pml_F_fp, lev), m_fields.get(FieldType::F_fp, lev), patch_type, do_pml_in_domain); } - if (m_fields.has("pml_F_fp", lev)) { - pml[lev]->FillBoundary(*m_fields.get("pml_F_fp", lev), patch_type, nodal_sync); + if (m_fields.has(FieldType::pml_F_fp, lev)) { + pml[lev]->FillBoundary(*m_fields.get(FieldType::pml_F_fp, lev), patch_type, nodal_sync); } } - if (m_fields.has("F_fp", lev)) + if (m_fields.has(FieldType::F_fp, lev)) { const amrex::Periodicity& period = Geom(lev).periodicity(); - const amrex::IntVect& nghost = (safe_guard_cells) ? m_fields.get("F_fp", lev)->nGrowVect() : ng; - ablastr::utils::communication::FillBoundary(*m_fields.get("F_fp", lev), nghost, WarpX::do_single_precision_comms, period, nodal_sync); + const amrex::IntVect& nghost = (safe_guard_cells) ? m_fields.get(FieldType::F_fp, lev)->nGrowVect() : ng; + ablastr::utils::communication::FillBoundary(*m_fields.get(FieldType::F_fp, lev), nghost, WarpX::do_single_precision_comms, period, nodal_sync); } } else if (patch_type == PatchType::coarse) { if (do_pml && pml[lev] && pml[lev]->ok()) { - if (m_fields.has("pml_F_cp", lev) && m_fields.has("F_cp", lev)) { - pml[lev]->Exchange(m_fields.get("pml_F_cp", lev), m_fields.get("F_cp", lev), patch_type, do_pml_in_domain); + if (m_fields.has(FieldType::pml_F_cp, lev) && m_fields.has(FieldType::F_cp, lev)) { + pml[lev]->Exchange(m_fields.get(FieldType::pml_F_cp, lev), m_fields.get(FieldType::F_cp, lev), patch_type, do_pml_in_domain); } - if (m_fields.has("pml_F_cp", lev)) { - pml[lev]->FillBoundary(*m_fields.get("pml_F_cp", lev), patch_type, nodal_sync); + if (m_fields.has(FieldType::pml_F_cp, lev)) { + pml[lev]->FillBoundary(*m_fields.get(FieldType::pml_F_cp, lev), patch_type, nodal_sync); } } - if (m_fields.has("F_cp", lev)) + if (m_fields.has(FieldType::F_cp, lev)) { const amrex::Periodicity& period = Geom(lev-1).periodicity(); - const amrex::IntVect& nghost = (safe_guard_cells) ? m_fields.get("F_cp", lev)->nGrowVect() : ng; - ablastr::utils::communication::FillBoundary(*m_fields.get("F_cp", lev), nghost, WarpX::do_single_precision_comms, period, nodal_sync); + const amrex::IntVect& nghost = (safe_guard_cells) ? m_fields.get(FieldType::F_cp, lev)->nGrowVect() : ng; + ablastr::utils::communication::FillBoundary(*m_fields.get(FieldType::F_cp, lev), nghost, WarpX::do_single_precision_comms, period, nodal_sync); } } } @@ -1006,18 +1008,18 @@ void WarpX::FillBoundaryG (int lev, PatchType patch_type, IntVect ng, std::optio { if (do_pml && pml[lev] && pml[lev]->ok()) { - if (m_fields.has("pml_G_fp",lev) && m_fields.has("G_fp",lev)) { - pml[lev]->Exchange(m_fields.get("pml_G_fp", lev), m_fields.get("G_fp", lev), patch_type, do_pml_in_domain); + if (m_fields.has(FieldType::pml_G_fp,lev) && m_fields.has(FieldType::G_fp,lev)) { + pml[lev]->Exchange(m_fields.get(FieldType::pml_G_fp, lev), m_fields.get(FieldType::G_fp, lev), patch_type, do_pml_in_domain); } - if (m_fields.has("pml_G_fp",lev)) { - pml[lev]->FillBoundary(*m_fields.get("pml_G_fp", lev), patch_type, nodal_sync); + if (m_fields.has(FieldType::pml_G_fp,lev)) { + pml[lev]->FillBoundary(*m_fields.get(FieldType::pml_G_fp, lev), patch_type, nodal_sync); } } - if (m_fields.has("G_fp",lev)) + if (m_fields.has(FieldType::G_fp,lev)) { const amrex::Periodicity& period = Geom(lev).periodicity(); - MultiFab* G_fp = m_fields.get("G_fp",lev); + MultiFab* G_fp = m_fields.get(FieldType::G_fp,lev); const amrex::IntVect& nghost = (safe_guard_cells) ? G_fp->nGrowVect() : ng; ablastr::utils::communication::FillBoundary(*G_fp, nghost, WarpX::do_single_precision_comms, period, nodal_sync); } @@ -1026,18 +1028,18 @@ void WarpX::FillBoundaryG (int lev, PatchType patch_type, IntVect ng, std::optio { if (do_pml && pml[lev] && pml[lev]->ok()) { - if (m_fields.has("pml_G_cp",lev) && m_fields.has("G_cp",lev)) { - pml[lev]->Exchange(m_fields.get("pml_G_cp", lev), m_fields.get("G_cp", lev), patch_type, do_pml_in_domain); + if (m_fields.has(FieldType::pml_G_cp,lev) && m_fields.has(FieldType::G_cp,lev)) { + pml[lev]->Exchange(m_fields.get(FieldType::pml_G_cp, lev), m_fields.get(FieldType::G_cp, lev), patch_type, do_pml_in_domain); } - if (m_fields.has("pml_G_cp", lev)) { - pml[lev]->FillBoundary(*m_fields.get("pml_G_cp", lev), patch_type, nodal_sync); + if (m_fields.has(FieldType::pml_G_cp, lev)) { + pml[lev]->FillBoundary(*m_fields.get(FieldType::pml_G_cp, lev), patch_type, nodal_sync); } } - if (m_fields.has("G_cp",lev)) + if (m_fields.has(FieldType::G_cp,lev)) { const amrex::Periodicity& period = Geom(lev-1).periodicity(); - MultiFab* G_cp = m_fields.get("G_cp",lev); + MultiFab* G_cp = m_fields.get(FieldType::G_cp,lev); const amrex::IntVect& nghost = (safe_guard_cells) ? G_cp->nGrowVect() : ng; ablastr::utils::communication::FillBoundary(*G_cp, nghost, WarpX::do_single_precision_comms, period, nodal_sync); } @@ -1056,8 +1058,8 @@ WarpX::FillBoundaryAux (IntVect ng) void WarpX::FillBoundaryAux (int lev, IntVect ng) { - ablastr::fields::MultiLevelVectorField Efield_aux = m_fields.get_mr_levels_alldirs("Efield_aux", finest_level); - ablastr::fields::MultiLevelVectorField Bfield_aux = m_fields.get_mr_levels_alldirs("Bfield_aux", finest_level); + ablastr::fields::MultiLevelVectorField Efield_aux = m_fields.get_mr_levels_alldirs(FieldType::Efield_aux, finest_level); + ablastr::fields::MultiLevelVectorField Bfield_aux = m_fields.get_mr_levels_alldirs(FieldType::Bfield_aux, finest_level); const amrex::Periodicity& period = Geom(lev).periodicity(); ablastr::utils::communication::FillBoundary(*Efield_aux[lev][0], ng, WarpX::do_single_precision_comms, period); @@ -1080,7 +1082,7 @@ WarpX::SyncCurrent (const std::string& current_fp_string) // If warpx.do_current_centering = 1, center currents from nodal grid to staggered grid if (do_current_centering) { - ablastr::fields::MultiLevelVectorField const& J_fp_nodal = m_fields.get_mr_levels_alldirs("current_fp_nodal", finest_level+1); + ablastr::fields::MultiLevelVectorField const& J_fp_nodal = m_fields.get_mr_levels_alldirs(FieldType::current_fp_nodal, finest_level+1); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(finest_level <= 1, "warpx.do_current_centering=1 not supported with more than one fine levels"); @@ -1190,7 +1192,7 @@ WarpX::SyncCurrent (const std::string& current_fp_string) } }); // Now it's safe to apply filter and sumboundary on J_cp - ablastr::fields::MultiLevelVectorField const& J_cp = m_fields.get_mr_levels_alldirs("current_cp", finest_level); + ablastr::fields::MultiLevelVectorField const& J_cp = m_fields.get_mr_levels_alldirs(FieldType::current_cp, finest_level); if (use_filter) { ApplyFilterJ(J_cp, lev+1, idim); @@ -1205,14 +1207,14 @@ WarpX::SyncCurrent (const std::string& current_fp_string) // filtering depends on the level. This is also done before any // same-level communication because it's easier this way to // avoid double counting. - ablastr::fields::MultiLevelVectorField const& J_cp = m_fields.get_mr_levels_alldirs("current_cp", finest_level); + ablastr::fields::MultiLevelVectorField const& J_cp = m_fields.get_mr_levels_alldirs(FieldType::current_cp, finest_level); J_cp[lev][Direction{idim}]->setVal(0.0); ablastr::coarsen::average::Coarsen(*J_cp[lev][Direction{idim}], *J_fp[lev][Direction{idim}], refRatio(lev-1)); - if (m_fields.has("current_buf", Direction{idim}, lev)) + if (m_fields.has(FieldType::current_buf, Direction{idim}, lev)) { - ablastr::fields::MultiLevelVectorField const& J_buffer = m_fields.get_mr_levels_alldirs("current_buf", finest_level); + ablastr::fields::MultiLevelVectorField const& J_buffer = m_fields.get_mr_levels_alldirs(FieldType::current_buf, finest_level); IntVect const& ng = J_cp[lev][Direction{idim}]->nGrowVect(); AMREX_ASSERT(ng.allLE(J_buffer[lev][Direction{idim}]->nGrowVect())); @@ -1239,14 +1241,14 @@ WarpX::SyncCurrent (const std::string& current_fp_string) void WarpX::SyncRho () { - const ablastr::fields::MultiLevelScalarField rho_fp = m_fields.has("rho_fp", 0) ? - m_fields.get_mr_levels("rho_fp", finest_level) : + const ablastr::fields::MultiLevelScalarField rho_fp = m_fields.has(FieldType::rho_fp, 0) ? + m_fields.get_mr_levels(FieldType::rho_fp, finest_level) : ablastr::fields::MultiLevelScalarField{static_cast(finest_level+1)}; - const ablastr::fields::MultiLevelScalarField rho_cp = m_fields.has("rho_cp", 1) ? - m_fields.get_mr_levels("rho_cp", finest_level) : + const ablastr::fields::MultiLevelScalarField rho_cp = m_fields.has(FieldType::rho_cp, 1) ? + m_fields.get_mr_levels(FieldType::rho_cp, finest_level) : ablastr::fields::MultiLevelScalarField{static_cast(finest_level+1)}; - const ablastr::fields::MultiLevelScalarField rho_buf = m_fields.has("rho_buf", 1) ? - m_fields.get_mr_levels("rho_buf", finest_level) : + const ablastr::fields::MultiLevelScalarField rho_buf = m_fields.has(FieldType::rho_buf, 1) ? + m_fields.get_mr_levels(FieldType::rho_buf, finest_level) : ablastr::fields::MultiLevelScalarField{static_cast(finest_level+1)}; SyncRho(rho_fp, rho_cp, rho_buf); @@ -1525,10 +1527,10 @@ void WarpX::AddCurrentFromFineLevelandSumBoundary ( void WarpX::RestrictRhoFromFineToCoarsePatch ( const int lev ) { - if (m_fields.has("rho_fp", lev)) { - m_fields.get("rho_cp", lev)->setVal(0.0); + if (m_fields.has(FieldType::rho_fp, lev)) { + m_fields.get(FieldType::rho_cp, lev)->setVal(0.0); const IntVect& refinement_ratio = refRatio(lev-1); - ablastr::coarsen::average::Coarsen(*m_fields.get("rho_cp", lev), *m_fields.get("rho_fp", lev), refinement_ratio ); + ablastr::coarsen::average::Coarsen(*m_fields.get(FieldType::rho_cp, lev), *m_fields.get(FieldType::rho_fp, lev), refinement_ratio ); } } diff --git a/Source/Parallelization/WarpXRegrid.cpp b/Source/Parallelization/WarpXRegrid.cpp index b4deed06b4b..a0a2d4929df 100644 --- a/Source/Parallelization/WarpXRegrid.cpp +++ b/Source/Parallelization/WarpXRegrid.cpp @@ -12,6 +12,7 @@ #include "Diagnostics/ReducedDiags/MultiReducedDiags.H" #include "EmbeddedBoundary/Enabled.H" #include "EmbeddedBoundary/WarpXFaceInfoBox.H" +#include "Fields.H" #include "FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H" #include "Initialization/ExternalField.H" #include "Particles/MultiParticleContainer.H" @@ -170,8 +171,8 @@ WarpX::LoadBalance () void WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const DistributionMapping& dm) { - using ablastr::fields::Direction; + using warpx::fields::FieldType; bool const eb_enabled = EB::enabled(); if (ba == boxArray(lev)) @@ -181,7 +182,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi m_fields.remake_level(lev, dm); // Fine patch - ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs("Bfield_fp", finest_level); + ablastr::fields::MultiLevelVectorField const& Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); for (int idim=0; idim < 3; ++idim) { if (eb_enabled) { @@ -315,6 +316,7 @@ void WarpX::ComputeCostsHeuristic (amrex::Vector > >& a_costs) { using ablastr::fields::Direction; + using warpx::fields::FieldType; for (int lev = 0; lev <= finest_level; ++lev) { @@ -334,7 +336,7 @@ WarpX::ComputeCostsHeuristic (amrex::Vectorupdate(t_lab); - BL_ASSERT(OnSameGrids(lev, *fields.get("current_fp", Direction{0}, lev))); + BL_ASSERT(OnSameGrids(lev, *fields.get(FieldType::current_fp, Direction{0}, lev))); amrex::LayoutData* cost = WarpX::getCosts(lev); - const bool has_rho = fields.has("rho_fp", lev); - const bool has_buffer = fields.has("current_buf", lev); + const bool has_rho = fields.has(FieldType::rho_fp, lev); + const bool has_buffer = fields.has(FieldType::current_buf, lev); #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) @@ -626,11 +628,11 @@ LaserParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, if (has_rho && ! skip_deposition && ! do_not_deposit) { int* AMREX_RESTRICT ion_lev = nullptr; - amrex::MultiFab* rho = fields.get("rho_fp", lev); + amrex::MultiFab* rho = fields.get(FieldType::rho_fp, lev); DepositCharge(pti, wp, ion_lev, rho, 0, 0, np_current, thread_num, lev, lev); if (has_buffer) { - amrex::MultiFab* crho = fields.get("rho_buf", lev); + amrex::MultiFab* crho = fields.get(FieldType::rho_buf, lev); DepositCharge(pti, wp, ion_lev, crho, 0, np_current, np-np_current, thread_num, lev, lev-1); } @@ -676,9 +678,9 @@ LaserParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, if (has_buffer) { // Deposit in buffers - amrex::MultiFab * cjx = fields.get("current_buf", Direction{0}, lev); - amrex::MultiFab * cjy = fields.get("current_buf", Direction{1}, lev); - amrex::MultiFab * cjz = fields.get("current_buf", Direction{2}, lev); + amrex::MultiFab * cjx = fields.get(FieldType::current_buf, Direction{0}, lev); + amrex::MultiFab * cjy = fields.get(FieldType::current_buf, Direction{1}, lev); + amrex::MultiFab * cjz = fields.get(FieldType::current_buf, Direction{2}, lev); DepositCurrent(pti, wp, uxp, uyp, uzp, ion_lev, cjx, cjy, cjz, np_current, np-np_current, thread_num, lev, lev-1, dt, relative_time, push_type); @@ -688,11 +690,11 @@ LaserParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, if (has_rho && ! skip_deposition && ! do_not_deposit) { int* AMREX_RESTRICT ion_lev = nullptr; - amrex::MultiFab* rho = fields.get("rho_fp", lev); + amrex::MultiFab* rho = fields.get(FieldType::rho_fp, lev); DepositCharge(pti, wp, ion_lev, rho, 1, 0, np_current, thread_num, lev, lev); if (has_buffer) { - amrex::MultiFab* crho = fields.get("rho_buf", lev); + amrex::MultiFab* crho = fields.get(FieldType::rho_buf, lev); DepositCharge(pti, wp, ion_lev, crho, 1, np_current, np-np_current, thread_num, lev, lev-1); } diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 533ee574aba..619b54ed7ad 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -81,7 +81,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; namespace { @@ -470,11 +470,11 @@ MultiParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, fields.get(current_fp_string, Direction{0}, lev)->setVal(0.0); fields.get(current_fp_string, Direction{1}, lev)->setVal(0.0); 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{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); } + if (fields.has(FieldType::current_buf, Direction{0}, lev)) { fields.get(FieldType::current_buf, Direction{0}, lev)->setVal(0.0); } + if (fields.has(FieldType::current_buf, Direction{1}, lev)) { fields.get(FieldType::current_buf, Direction{1}, lev)->setVal(0.0); } + if (fields.has(FieldType::current_buf, Direction{2}, lev)) { fields.get(FieldType::current_buf, Direction{2}, lev)->setVal(0.0); } + if (fields.has(FieldType::rho_fp, lev)) { fields.get(FieldType::rho_fp, lev)->setVal(0.0); } + if (fields.has(FieldType::rho_buf, lev)) { fields.get(FieldType::rho_buf, lev)->setVal(0.0); } } for (auto& pc : allcontainers) { pc->Evolve(fields, lev, current_fp_string, t, dt, a_dt_type, skip_deposition, push_type); @@ -1357,12 +1357,12 @@ MultiParticleContainer::doQEDSchwinger () pc_product_pos->defineAllParticleTiles(); using ablastr::fields::Direction; - const MultiFab & Ex = *warpx.m_fields.get("Efield_aux", Direction{0}, level_0); - const MultiFab & Ey = *warpx.m_fields.get("Efield_aux", Direction{1}, level_0); - const MultiFab & Ez = *warpx.m_fields.get("Efield_aux", Direction{2}, level_0); - const MultiFab & Bx = *warpx.m_fields.get("Bfield_aux", Direction{0}, level_0); - const MultiFab & By = *warpx.m_fields.get("Bfield_aux", Direction{1}, level_0); - const MultiFab & Bz = *warpx.m_fields.get("Bfield_aux", Direction{2}, level_0); + const MultiFab & Ex = *warpx.m_fields.get(FieldType::Efield_aux, Direction{0}, level_0); + const MultiFab & Ey = *warpx.m_fields.get(FieldType::Efield_aux, Direction{1}, level_0); + const MultiFab & Ez = *warpx.m_fields.get(FieldType::Efield_aux, Direction{2}, level_0); + const MultiFab & Bx = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{0}, level_0); + const MultiFab & By = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{1}, level_0); + const MultiFab & Bz = *warpx.m_fields.get(FieldType::Bfield_aux, Direction{2}, level_0); #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d86daed4dc6..07997a61f0c 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -10,6 +10,7 @@ */ #include "PhysicalParticleContainer.H" +#include "Fields.H" #include "Filter/NCIGodfreyFilter.H" #include "Initialization/InjectorDensity.H" #include "Initialization/InjectorMomentum.H" @@ -1342,10 +1343,11 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int #ifdef AMREX_USE_EB if (EB::enabled()) { + using warpx::fields::FieldType; auto & warpx = WarpX::GetInstance(); scrapeParticlesAtEB( *this, - warpx.m_fields.get_mr_levels("distance_to_eb", warpx.finestLevel()), + warpx.m_fields.get_mr_levels(FieldType::distance_to_eb, warpx.finestLevel()), ParticleBoundaryProcess::Absorb()); } #endif @@ -1712,10 +1714,11 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector, #ifdef AMREX_USE_EB if (EB::enabled()) { + using warpx::fields::FieldType; auto & warpx = WarpX::GetInstance(); scrapeParticlesAtEB( tmp_pc, - warpx.m_fields.get_mr_levels("distance_to_eb", warpx.finestLevel()), + warpx.m_fields.get_mr_levels(FieldType::distance_to_eb, warpx.finestLevel()), ParticleBoundaryProcess::Absorb()); } #endif @@ -1737,28 +1740,29 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, PushType push_type) { using ablastr::fields::Direction; + using warpx::fields::FieldType; WARPX_PROFILE("PhysicalParticleContainer::Evolve()"); WARPX_PROFILE_VAR_NS("PhysicalParticleContainer::Evolve::GatherAndPush", blp_fg); - BL_ASSERT(OnSameGrids(lev, *fields.get("current_fp", Direction{0}, lev))); + BL_ASSERT(OnSameGrids(lev, *fields.get(FieldType::current_fp, Direction{0}, lev))); amrex::LayoutData* cost = WarpX::getCosts(lev); const iMultiFab* current_masks = WarpX::CurrentBufferMasks(lev); const iMultiFab* gather_masks = WarpX::GatherBufferMasks(lev); - 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); + const bool has_rho = fields.has(FieldType::rho_fp, lev); + const bool has_cjx = fields.has(FieldType::current_buf, Direction{0}, lev); + const bool has_cEx = fields.has(FieldType::Efield_cax, Direction{0}, lev); const bool has_buffer = has_cEx || has_cjx; - amrex::MultiFab & Ex = *fields.get("Efield_aux", Direction{0}, lev); - amrex::MultiFab & Ey = *fields.get("Efield_aux", Direction{1}, lev); - amrex::MultiFab & Ez = *fields.get("Efield_aux", Direction{2}, lev); - amrex::MultiFab & Bx = *fields.get("Bfield_aux", Direction{0}, lev); - amrex::MultiFab & By = *fields.get("Bfield_aux", Direction{1}, lev); - amrex::MultiFab & Bz = *fields.get("Bfield_aux", Direction{2}, lev); + amrex::MultiFab & Ex = *fields.get(FieldType::Efield_aux, Direction{0}, lev); + amrex::MultiFab & Ey = *fields.get(FieldType::Efield_aux, Direction{1}, lev); + amrex::MultiFab & Ez = *fields.get(FieldType::Efield_aux, Direction{2}, lev); + amrex::MultiFab & Bx = *fields.get(FieldType::Bfield_aux, Direction{0}, lev); + amrex::MultiFab & By = *fields.get(FieldType::Bfield_aux, Direction{1}, lev); + amrex::MultiFab & Bz = *fields.get(FieldType::Bfield_aux, Direction{2}, lev); if (m_do_back_transformed_particles) { @@ -1854,11 +1858,11 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, const int* const AMREX_RESTRICT ion_lev = (do_field_ionization)? pti.GetiAttribs(particle_icomps["ionizationLevel"]).dataPtr():nullptr; - amrex::MultiFab* rho = fields.get("rho_fp", lev); + amrex::MultiFab* rho = fields.get(FieldType::rho_fp, lev); DepositCharge(pti, wp, ion_lev, rho, 0, 0, np_current, thread_num, lev, lev); if (has_buffer){ - amrex::MultiFab* crho = fields.get("rho_buf", lev); + amrex::MultiFab* crho = fields.get(FieldType::rho_buf, lev); DepositCharge(pti, wp, ion_lev, crho, 0, np_current, np-np_current, thread_num, lev, lev-1); } @@ -1893,12 +1897,12 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, const IntVect& ref_ratio = WarpX::RefRatio(lev-1); const Box& cbox = amrex::coarsen(box,ref_ratio); - amrex::MultiFab & cEx = *fields.get("Efield_cax", Direction{0}, lev); - amrex::MultiFab & cEy = *fields.get("Efield_cax", Direction{1}, lev); - amrex::MultiFab & cEz = *fields.get("Efield_cax", Direction{2}, lev); - amrex::MultiFab & cBx = *fields.get("Bfield_cax", Direction{0}, lev); - amrex::MultiFab & cBy = *fields.get("Bfield_cax", Direction{1}, lev); - amrex::MultiFab & cBz = *fields.get("Bfield_cax", Direction{2}, lev); + amrex::MultiFab & cEx = *fields.get(FieldType::Efield_cax, Direction{0}, lev); + amrex::MultiFab & cEy = *fields.get(FieldType::Efield_cax, Direction{1}, lev); + amrex::MultiFab & cEz = *fields.get(FieldType::Efield_cax, Direction{2}, lev); + amrex::MultiFab & cBx = *fields.get(FieldType::Bfield_cax, Direction{0}, lev); + amrex::MultiFab & cBy = *fields.get(FieldType::Bfield_cax, Direction{1}, lev); + amrex::MultiFab & cBz = *fields.get(FieldType::Bfield_cax, Direction{2}, lev); // Data on the grid FArrayBox const* cexfab = &cEx[pti]; @@ -1961,9 +1965,9 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, if (has_buffer) { // Deposit in buffers - amrex::MultiFab * cjx = fields.get("current_buf", Direction{0}, lev); - amrex::MultiFab * cjy = fields.get("current_buf", Direction{1}, lev); - amrex::MultiFab * cjz = fields.get("current_buf", Direction{2}, lev); + amrex::MultiFab * cjx = fields.get(FieldType::current_buf, Direction{0}, lev); + amrex::MultiFab * cjy = fields.get(FieldType::current_buf, Direction{1}, lev); + amrex::MultiFab * cjz = fields.get(FieldType::current_buf, Direction{2}, lev); DepositCurrent(pti, wp, uxp, uyp, uzp, ion_lev, cjx, cjy, cjz, np_current, np-np_current, thread_num, lev, lev-1, dt, relative_time, push_type); @@ -1975,7 +1979,7 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, // Deposit charge after particle push, in component 1 of MultiFab rho. // (Skipped for electrostatic solver, as this may lead to out-of-bounds) if (WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::None) { - amrex::MultiFab* rho = fields.get("rho_fp", lev); + amrex::MultiFab* rho = fields.get(FieldType::rho_fp, lev); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(rho->nComp() >= 2, "Cannot deposit charge in rho component 1: only component 0 is allocated!"); @@ -1985,7 +1989,7 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields, DepositCharge(pti, wp, ion_lev, rho, 1, 0, np_current, thread_num, lev, lev); if (has_buffer){ - amrex::MultiFab* crho = fields.get("rho_buf", lev); + amrex::MultiFab* crho = fields.get(FieldType::rho_buf, lev); DepositCharge(pti, wp, ion_lev, crho, 1, np_current, np-np_current, thread_num, lev, lev-1); } diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index b3e41f0d04e..36793c8619b 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -14,6 +14,7 @@ #include "Deposition/CurrentDeposition.H" #include "Deposition/SharedDepositionUtils.H" #include "EmbeddedBoundary/Enabled.H" +#include "Fields.H" #include "Pusher/GetAndSetPosition.H" #include "Pusher/UpdatePosition.H" #include "ParticleBoundaries_K.H" @@ -173,6 +174,7 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, long n, int uniqueparticles, amrex::Long id) { using namespace amrex::literals; + using warpx::fields::FieldType; WARPX_ALWAYS_ASSERT_WITH_MESSAGE((PIdx::nattribs + nattr_real - 1) <= NumRealComps(), "Too many real attributes specified"); @@ -305,7 +307,7 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, long n, auto & warpx = WarpX::GetInstance(); scrapeParticlesAtEB( *this, - warpx.m_fields.get_mr_levels("distance_to_eb", warpx.finestLevel()), + warpx.m_fields.get_mr_levels(FieldType::distance_to_eb, warpx.finestLevel()), ParticleBoundaryProcess::Absorb()); deleteInvalidParticles(); } diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index e6cabd4aa65..a35e142e3ee 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -14,6 +14,7 @@ #endif #include "Initialization/ExternalField.H" #include "Particles/MultiParticleContainer.H" +#include "Fields.H" #include "Fluids/MultiFluidContainer.H" #include "Fluids/WarpXFluidContainer.H" #include "Utils/TextMsg.H" @@ -140,6 +141,7 @@ WarpX::MoveWindow (const int step, bool move_j) WARPX_PROFILE("WarpX::MoveWindow"); using ablastr::fields::Direction; + using warpx::fields::FieldType; if (step == start_moving_window_step) { amrex::Print() << Utils::TextMsg::Info("Starting moving window"); @@ -236,57 +238,57 @@ WarpX::MoveWindow (const int step, bool move_j) if (dim == 1) { Efield_parser = m_p_ext_field_params->Eyfield_parser->compile<3>(); } if (dim == 2) { Efield_parser = m_p_ext_field_params->Ezfield_parser->compile<3>(); } } - shiftMF(*m_fields.get("Bfield_fp", Direction{dim}, lev), geom[lev], num_shift, dir, lev, do_update_cost, + shiftMF(*m_fields.get(FieldType::Bfield_fp, Direction{dim}, lev), geom[lev], num_shift, dir, lev, do_update_cost, m_p_ext_field_params->B_external_grid[dim], use_Bparser, Bfield_parser); - shiftMF(*m_fields.get("Efield_fp",Direction{dim},lev), geom[lev], num_shift, dir, lev, do_update_cost, + shiftMF(*m_fields.get(FieldType::Efield_fp,Direction{dim},lev), geom[lev], num_shift, dir, lev, do_update_cost, m_p_ext_field_params->E_external_grid[dim], use_Eparser, Efield_parser); if (fft_do_time_averaging) { - ablastr::fields::MultiLevelVectorField Efield_avg_fp = m_fields.get_mr_levels_alldirs("Efield_avg_fp", finest_level); - ablastr::fields::MultiLevelVectorField Bfield_avg_fp = m_fields.get_mr_levels_alldirs("Bfield_avg_fp", finest_level); + ablastr::fields::MultiLevelVectorField Efield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_fp, finest_level); + ablastr::fields::MultiLevelVectorField Bfield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_fp, finest_level); shiftMF(*Bfield_avg_fp[lev][dim], geom[lev], num_shift, dir, lev, do_update_cost, m_p_ext_field_params->B_external_grid[dim], use_Bparser, Bfield_parser); shiftMF(*Efield_avg_fp[lev][dim], geom[lev], num_shift, dir, lev, do_update_cost, m_p_ext_field_params-> E_external_grid[dim], use_Eparser, Efield_parser); } if (move_j) { - shiftMF(*m_fields.get("current_fp", Direction{dim}, lev), geom[lev], num_shift, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::current_fp, Direction{dim}, lev), geom[lev], num_shift, dir, lev, do_update_cost); } if (pml[lev] && pml[lev]->ok()) { - amrex::MultiFab* pml_B = m_fields.get("pml_B_fp", Direction{dim}, lev); - amrex::MultiFab* pml_E = m_fields.get("pml_E_fp", Direction{dim}, lev); + amrex::MultiFab* pml_B = m_fields.get(FieldType::pml_B_fp, Direction{dim}, lev); + amrex::MultiFab* pml_E = m_fields.get(FieldType::pml_E_fp, Direction{dim}, lev); shiftMF(*pml_B, geom[lev], num_shift, dir, lev, dont_update_cost); shiftMF(*pml_E, geom[lev], num_shift, dir, lev, dont_update_cost); } #if (defined WARPX_DIM_RZ) && (defined WARPX_USE_FFT) if (pml_rz[lev] && dim < 2) { - amrex::MultiFab* pml_rz_B = m_fields.get("pml_B_fp", Direction{dim}, lev); - amrex::MultiFab* pml_rz_E = m_fields.get("pml_E_fp", Direction{dim}, lev); + amrex::MultiFab* pml_rz_B = m_fields.get(FieldType::pml_B_fp, Direction{dim}, lev); + amrex::MultiFab* pml_rz_E = m_fields.get(FieldType::pml_E_fp, Direction{dim}, lev); shiftMF(*pml_rz_B, geom[lev], num_shift, dir, lev, dont_update_cost); shiftMF(*pml_rz_E, geom[lev], num_shift, dir, lev, dont_update_cost); } #endif if (lev > 0) { // coarse grid - shiftMF(*m_fields.get("Bfield_cp",Direction{dim},lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost, + shiftMF(*m_fields.get(FieldType::Bfield_cp, Direction{dim}, lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost, m_p_ext_field_params->B_external_grid[dim], use_Bparser, Bfield_parser); - shiftMF(*m_fields.get("Efield_cp",Direction{dim},lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost, + shiftMF(*m_fields.get(FieldType::Efield_cp, Direction{dim}, lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost, m_p_ext_field_params->E_external_grid[dim], use_Eparser, Efield_parser); - shiftMF(*m_fields.get("Bfield_aux",Direction{dim},lev), geom[lev], num_shift, dir, lev, do_update_cost); - shiftMF(*m_fields.get("Efield_aux",Direction{dim},lev), geom[lev], num_shift, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::Bfield_aux, Direction{dim}, lev), geom[lev], num_shift, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::Efield_aux, Direction{dim}, lev), geom[lev], num_shift, dir, lev, do_update_cost); if (fft_do_time_averaging) { - ablastr::fields::MultiLevelVectorField Efield_avg_cp = m_fields.get_mr_levels_alldirs("Efield_avg_cp", finest_level); - ablastr::fields::MultiLevelVectorField Bfield_avg_cp = m_fields.get_mr_levels_alldirs("Bfield_avg_cp", finest_level); + ablastr::fields::MultiLevelVectorField Efield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_cp, finest_level); + ablastr::fields::MultiLevelVectorField Bfield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_cp, finest_level); shiftMF(*Bfield_avg_cp[lev][dim], geom[lev-1], num_shift_crse, dir, lev, do_update_cost, m_p_ext_field_params->B_external_grid[dim], use_Bparser, Bfield_parser); shiftMF(*Efield_avg_cp[lev][dim], geom[lev-1], num_shift_crse, dir, lev, do_update_cost, m_p_ext_field_params->E_external_grid[dim], use_Eparser, Efield_parser); } if (move_j) { - shiftMF(*m_fields.get("current_cp", Direction{dim}, lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::current_cp, Direction{dim}, lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); } if (do_pml && pml[lev]->ok()) { - amrex::MultiFab* pml_B_cp = m_fields.get("pml_B_cp", Direction{dim}, lev); - amrex::MultiFab* pml_E_cp = m_fields.get("pml_E_cp", Direction{dim}, lev); + amrex::MultiFab* pml_B_cp = m_fields.get(FieldType::pml_B_cp, Direction{dim}, lev); + amrex::MultiFab* pml_E_cp = m_fields.get(FieldType::pml_E_cp, Direction{dim}, lev); shiftMF(*pml_B_cp, geom[lev-1], num_shift_crse, dir, lev, dont_update_cost); shiftMF(*pml_E_cp, geom[lev-1], num_shift_crse, dir, lev, dont_update_cost); } @@ -295,14 +297,14 @@ WarpX::MoveWindow (const int step, bool move_j) // Shift scalar field F with div(E) cleaning in valid domain // TODO: shift F from pml_rz for RZ geometry with PSATD, once implemented - if (m_fields.has("F_fp", lev)) + if (m_fields.has(FieldType::F_fp, lev)) { // Fine grid - shiftMF(*m_fields.get("F_fp", lev), geom[lev], num_shift, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::F_fp, lev), geom[lev], num_shift, dir, lev, do_update_cost); if (lev > 0) { // Coarse grid - shiftMF(*m_fields.get("F_cp", lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::F_cp, lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); } } @@ -312,7 +314,7 @@ WarpX::MoveWindow (const int step, bool move_j) // Fine grid if (do_pml && pml[lev]->ok()) { - amrex::MultiFab* pml_F = m_fields.get("pml_F_fp", lev); + amrex::MultiFab* pml_F = m_fields.get(FieldType::pml_F_fp, lev); shiftMF(*pml_F, geom[lev], num_shift, dir, lev, dont_update_cost); } if (lev > 0) @@ -320,7 +322,7 @@ WarpX::MoveWindow (const int step, bool move_j) // Coarse grid if (do_pml && pml[lev]->ok()) { - amrex::MultiFab* pml_F = m_fields.get("pml_F_cp", lev); + amrex::MultiFab* pml_F = m_fields.get(FieldType::pml_F_cp, lev); shiftMF(*pml_F, geom[lev-1], num_shift_crse, dir, lev, dont_update_cost); } } @@ -328,14 +330,14 @@ WarpX::MoveWindow (const int step, bool move_j) // Shift scalar field G with div(B) cleaning in valid domain // TODO: shift G from pml_rz for RZ geometry with PSATD, once implemented - if (m_fields.has("G_fp", lev)) + if (m_fields.has(FieldType::G_fp, lev)) { // Fine grid - shiftMF(*m_fields.get("G_fp", lev), geom[lev], num_shift, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::G_fp, lev), geom[lev], num_shift, dir, lev, do_update_cost); if (lev > 0) { // Coarse grid - shiftMF(*m_fields.get("G_cp", lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::G_cp, lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); } } @@ -345,7 +347,7 @@ WarpX::MoveWindow (const int step, bool move_j) // Fine grid if (do_pml && pml[lev]->ok()) { - amrex::MultiFab* pml_G = m_fields.get("pml_G_fp", lev); + amrex::MultiFab* pml_G = m_fields.get(FieldType::pml_G_fp, lev); shiftMF(*pml_G, geom[lev], num_shift, dir, lev, dont_update_cost); } if (lev > 0) @@ -353,7 +355,7 @@ WarpX::MoveWindow (const int step, bool move_j) // Coarse grid if (do_pml && pml[lev]->ok()) { - amrex::MultiFab* pml_G = m_fields.get("pml_G_cp", lev); + amrex::MultiFab* pml_G = m_fields.get(FieldType::pml_G_cp, lev); shiftMF(*pml_G, geom[lev-1], num_shift_crse, dir, lev, dont_update_cost); } } @@ -361,12 +363,12 @@ WarpX::MoveWindow (const int step, bool move_j) // Shift scalar component rho if (move_j) { - if (m_fields.has("rho_fp", lev)) { + if (m_fields.has(FieldType::rho_fp, lev)) { // Fine grid - shiftMF(*m_fields.get("rho_fp",lev), geom[lev], num_shift, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::rho_fp,lev), geom[lev], num_shift, dir, lev, do_update_cost); if (lev > 0){ // Coarse grid - shiftMF(*m_fields.get("rho_cp",lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); + shiftMF(*m_fields.get(FieldType::rho_cp,lev), geom[lev-1], num_shift_crse, dir, lev, do_update_cost); } } } @@ -464,9 +466,9 @@ WarpX::MoveWindow (const int step, bool move_j) const int lev_zero = 0; m_macroscopic_properties->InitData( Geom(lev_zero), - m_fields.get("Efield_fp",Direction{0},lev_zero)->ixType().toIntVect(), - m_fields.get("Efield_fp",Direction{1},lev_zero)->ixType().toIntVect(), - m_fields.get("Efield_fp",Direction{2},lev_zero)->ixType().toIntVect() + m_fields.get(FieldType::Efield_fp, Direction{0}, lev_zero)->ixType().toIntVect(), + m_fields.get(FieldType::Efield_fp, Direction{1}, lev_zero)->ixType().toIntVect(), + m_fields.get(FieldType::Efield_fp, Direction{2}, lev_zero)->ixType().toIntVect() ); } diff --git a/Source/WarpX.H b/Source/WarpX.H index 5575ea2036f..83b1880f2b1 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -153,8 +153,9 @@ public: MultiDiagnostics& GetMultiDiags () {return *multi_diags;} #ifdef AMREX_USE_EB ablastr::fields::MultiLevelScalarField GetDistanceToEB () { - return m_fields.get_mr_levels("distance_to_eb", finestLevel()); - } + using warpx::fields::FieldType; + return m_fields.get_mr_levels(FieldType::distance_to_eb, finestLevel()); + } #endif ParticleBoundaryBuffer& GetParticleBoundaryBuffer () { return *m_particle_boundary_buffer; } diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index fdff1bbc2b2..9a6a0dd65a8 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -92,7 +92,7 @@ #include using namespace amrex; -using namespace warpx::fields; +using warpx::fields::FieldType; int WarpX::do_moving_window = 0; int WarpX::start_moving_window_step = 0; @@ -2194,48 +2194,48 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm // const std::array dx = CellSize(lev); - m_fields.alloc_init( "Bfield_fp", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_fp", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_fp", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_fp, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_fp, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_fp, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_fp", Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_fp", Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_fp", Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_fp, Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_fp, Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_fp, Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "current_fp", Direction{0}, lev, amrex::convert(ba, jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_fp", Direction{1}, lev, amrex::convert(ba, jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_fp", Direction{2}, lev, amrex::convert(ba, jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp, Direction{0}, lev, amrex::convert(ba, jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp, Direction{1}, lev, amrex::convert(ba, jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp, Direction{2}, lev, amrex::convert(ba, jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); if (do_current_centering) { amrex::BoxArray const& nodal_ba = amrex::convert(ba, amrex::IntVect::TheNodeVector()); - m_fields.alloc_init( "current_fp_nodal", Direction{0}, lev, nodal_ba, dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_fp_nodal", Direction{1}, lev, nodal_ba, dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_fp_nodal", Direction{2}, lev, nodal_ba, dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp_nodal, Direction{0}, lev, nodal_ba, dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp_nodal, Direction{1}, lev, nodal_ba, dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp_nodal, Direction{2}, lev, nodal_ba, dm, ncomps, ngJ, 0.0_rt); } if (WarpX::current_deposition_algo == CurrentDepositionAlgo::Vay) { - m_fields.alloc_init( "current_fp_vay", Direction{0}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_fp_vay", Direction{1}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_fp_vay", Direction{2}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp_vay, Direction{0}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp_vay, Direction{1}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_fp_vay, Direction{2}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngJ, 0.0_rt); } if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic) { - m_fields.alloc_init("vector_potential_fp_nodal", Direction{0}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); - m_fields.alloc_init("vector_potential_fp_nodal", Direction{1}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); - m_fields.alloc_init("vector_potential_fp_nodal", Direction{2}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_fp_nodal, Direction{0}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_fp_nodal, Direction{1}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_fp_nodal, Direction{2}, lev, amrex::convert(ba, rho_nodal_flag), dm, ncomps, ngRho, 0.0_rt); // Memory buffers for computing magnetostatic fields // Vector Potential A and previous step. Time buffer needed for computing dA/dt to first order - m_fields.alloc_init("vector_potential_grad_buf_e_stag", Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("vector_potential_grad_buf_e_stag", Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("vector_potential_grad_buf_e_stag", Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_grad_buf_e_stag, Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_grad_buf_e_stag, Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_grad_buf_e_stag, Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("vector_potential_grad_buf_b_stag", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("vector_potential_grad_buf_b_stag", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("vector_potential_grad_buf_b_stag", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_grad_buf_b_stag, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_grad_buf_b_stag, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::vector_potential_grad_buf_b_stag, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } // Allocate extra multifabs needed by the kinetic-fluid hybrid algorithm. @@ -2265,38 +2265,38 @@ 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, 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(FieldType::Bfield_avg_fp, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_avg_fp, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::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, 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); + m_fields.alloc_init(FieldType::Efield_avg_fp, Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_avg_fp, Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_avg_fp, Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } if (EB::enabled()) { constexpr int nc_ls = 1; amrex::IntVect const ng_ls(2); //EB level set - m_fields.alloc_init("distance_to_eb", lev, amrex::convert(ba, IntVect::TheNodeVector()), dm, nc_ls, ng_ls, 0.0_rt); + m_fields.alloc_init(FieldType::distance_to_eb, lev, amrex::convert(ba, IntVect::TheNodeVector()), dm, nc_ls, ng_ls, 0.0_rt); // EB info are needed only at the finest level if (lev == maxLevel()) { if (WarpX::electromagnetic_solver_id != ElectromagneticSolverAlgo::PSATD) { //! EB: Lengths of the mesh edges - m_fields.alloc_init( "edge_lengths", Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), + m_fields.alloc_init(FieldType::edge_lengths, Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "edge_lengths", Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), + m_fields.alloc_init(FieldType::edge_lengths, Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "edge_lengths", Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), + m_fields.alloc_init(FieldType::edge_lengths, Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); //! EB: Areas of the mesh faces - m_fields.alloc_init( "face_areas", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), + m_fields.alloc_init(FieldType::face_areas, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "face_areas", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), + m_fields.alloc_init(FieldType::face_areas, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "face_areas", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), + m_fields.alloc_init(FieldType::face_areas, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); } if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) { @@ -2316,11 +2316,11 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm /** EB: area_mod contains the modified areas of the mesh faces, i.e. if a face is enlarged it * contains the area of the enlarged face * This is only used for the ECT solver.*/ - m_fields.alloc_init( "area_mod", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), + m_fields.alloc_init(FieldType::area_mod, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "area_mod", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), + m_fields.alloc_init(FieldType::area_mod, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "area_mod", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), + m_fields.alloc_init(FieldType::area_mod, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); m_borrowing[lev][0] = std::make_unique>( @@ -2333,11 +2333,11 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm /** Venl contains the electromotive force for every mesh face, i.e. every entry is * the corresponding entry in ECTRhofield multiplied by the total area (possibly with enlargement) * This is only used for the ECT solver.*/ - m_fields.alloc_init( "Venl", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), + m_fields.alloc_init(FieldType::Venl, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "Venl", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), + m_fields.alloc_init(FieldType::Venl, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "Venl", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), + m_fields.alloc_init(FieldType::Venl, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); /** ECTRhofield is needed only by the ect @@ -2347,11 +2347,11 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm * and below). * Although it's called rho it has nothing to do with the charge density! * This is only used for the ECT solver.*/ - m_fields.alloc_init( "ECTRhofield", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), + m_fields.alloc_init(FieldType::ECTRhofield, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "ECTRhofield", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), + m_fields.alloc_init(FieldType::ECTRhofield, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); - m_fields.alloc_init( "ECTRhofield", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), + m_fields.alloc_init(FieldType::ECTRhofield, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, guard_cells.ng_FieldSolver, 0.0_rt); } } @@ -2374,8 +2374,8 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm } if (rho_ncomps > 0) { - m_fields.alloc_init( - "rho_fp", lev, amrex::convert(ba, rho_nodal_flag), dm, + m_fields.alloc_init(FieldType::rho_fp, + lev, amrex::convert(ba, rho_nodal_flag), dm, rho_ncomps, ngRho, 0.0_rt); } @@ -2383,28 +2383,28 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic) { const IntVect ngPhi = IntVect( AMREX_D_DECL(1,1,1) ); - m_fields.alloc_init( "phi_fp", lev, amrex::convert(ba, phi_nodal_flag), dm, + m_fields.alloc_init(FieldType::phi_fp, lev, amrex::convert(ba, phi_nodal_flag), dm, ncomps, ngPhi, 0.0_rt ); } if (do_subcycling && lev == 0) { - m_fields.alloc_init("current_store", Direction{0}, lev, amrex::convert(ba,jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init("current_store", Direction{1}, lev, amrex::convert(ba,jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init("current_store", Direction{2}, lev, amrex::convert(ba,jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_store, Direction{0}, lev, amrex::convert(ba,jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_store, Direction{1}, lev, amrex::convert(ba,jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_store, Direction{2}, lev, amrex::convert(ba,jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); } if (do_dive_cleaning) { - m_fields.alloc_init( - "F_fp", lev, amrex::convert(ba, F_nodal_flag), dm, + m_fields.alloc_init(FieldType::F_fp, + lev, amrex::convert(ba, F_nodal_flag), dm, ncomps, ngF, 0.0_rt); } if (do_divb_cleaning) { - m_fields.alloc_init( - "G_fp", lev, amrex::convert(ba, G_nodal_flag), dm, + m_fields.alloc_init(FieldType::G_fp, + lev, amrex::convert(ba, G_nodal_flag), dm, ncomps, ngG, 0.0_rt); } @@ -2474,102 +2474,102 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm // Create aux multifabs on Nodal Box Array BoxArray const nba = amrex::convert(ba,IntVect::TheNodeVector()); - m_fields.alloc_init("Bfield_aux", Direction{0}, lev, nba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_aux", Direction{1}, lev, nba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_aux", Direction{2}, lev, nba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{0}, lev, nba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{1}, lev, nba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{2}, lev, nba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{0}, lev, nba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{1}, lev, nba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{2}, lev, nba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{0}, lev, nba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{1}, lev, nba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{2}, lev, nba, dm, ncomps, ngEB, 0.0_rt); } else if (lev == 0) { if (WarpX::fft_do_time_averaging) { - m_fields.alias_init("Bfield_aux", "Bfield_avg_fp", Direction{0}, lev, 0.0_rt); - m_fields.alias_init("Bfield_aux", "Bfield_avg_fp", Direction{1}, lev, 0.0_rt); - m_fields.alias_init("Bfield_aux", "Bfield_avg_fp", Direction{2}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Bfield_aux, FieldType::Bfield_avg_fp, Direction{0}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Bfield_aux, FieldType::Bfield_avg_fp, Direction{1}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Bfield_aux, FieldType::Bfield_avg_fp, Direction{2}, lev, 0.0_rt); - m_fields.alias_init("Efield_aux", "Efield_avg_fp", Direction{0}, lev, 0.0_rt); - m_fields.alias_init("Efield_aux", "Efield_avg_fp", Direction{1}, lev, 0.0_rt); - m_fields.alias_init("Efield_aux", "Efield_avg_fp", Direction{2}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Efield_aux, FieldType::Efield_avg_fp, Direction{0}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Efield_aux, FieldType::Efield_avg_fp, Direction{1}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Efield_aux, FieldType::Efield_avg_fp, Direction{2}, lev, 0.0_rt); } else { if (mypc->m_B_ext_particle_s == "read_from_file") { - m_fields.alloc_init("Bfield_aux", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_aux", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_aux", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } else { // In this case, the aux grid is simply an alias of the fp grid (most common case in WarpX) - m_fields.alias_init("Bfield_aux", "Bfield_fp", Direction{0}, lev, 0.0_rt); - m_fields.alias_init("Bfield_aux", "Bfield_fp", Direction{1}, lev, 0.0_rt); - m_fields.alias_init("Bfield_aux", "Bfield_fp", Direction{2}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Bfield_aux, FieldType::Bfield_fp, Direction{0}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Bfield_aux, FieldType::Bfield_fp, Direction{1}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Bfield_aux, FieldType::Bfield_fp, Direction{2}, lev, 0.0_rt); } if (mypc->m_E_ext_particle_s == "read_from_file") { - m_fields.alloc_init("Efield_aux", Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } else { // In this case, the aux grid is simply an alias of the fp grid (most common case in WarpX) - m_fields.alias_init("Efield_aux", "Efield_fp", Direction{0}, lev, 0.0_rt); - m_fields.alias_init("Efield_aux", "Efield_fp", Direction{1}, lev, 0.0_rt); - m_fields.alias_init("Efield_aux", "Efield_fp", Direction{2}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Efield_aux, FieldType::Efield_fp, Direction{0}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Efield_aux, FieldType::Efield_fp, Direction{1}, lev, 0.0_rt); + m_fields.alias_init(FieldType::Efield_aux, FieldType::Efield_fp, Direction{2}, lev, 0.0_rt); } } } else { - m_fields.alloc_init("Bfield_aux", Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_aux", Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_aux", Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{0}, lev, amrex::convert(ba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{1}, lev, amrex::convert(ba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_aux, Direction{2}, lev, amrex::convert(ba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_aux", Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{0}, lev, amrex::convert(ba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{1}, lev, amrex::convert(ba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_aux, Direction{2}, lev, amrex::convert(ba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } // The external fields that are read from file if (m_p_ext_field_params->B_ext_grid_type != ExternalFieldType::default_zero && m_p_ext_field_params->B_ext_grid_type != ExternalFieldType::constant) { // These fields will be added directly to the grid, i.e. to fp, and need to match the index type - m_fields.alloc_init( "Bfield_fp_external", Direction{0}, lev, - amrex::convert(ba, m_fields.get("Bfield_fp",Direction{0},lev)->ixType()), + m_fields.alloc_init(FieldType::Bfield_fp_external, Direction{0}, lev, + amrex::convert(ba, m_fields.get(FieldType::Bfield_fp,Direction{0},lev)->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_fp_external", Direction{1}, lev, - amrex::convert(ba, m_fields.get("Bfield_fp",Direction{1},lev)->ixType()), + m_fields.alloc_init(FieldType::Bfield_fp_external, Direction{1}, lev, + amrex::convert(ba, m_fields.get(FieldType::Bfield_fp,Direction{1},lev)->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_fp_external", Direction{2}, lev, - amrex::convert(ba, m_fields.get("Bfield_fp",Direction{2},lev)->ixType()), + m_fields.alloc_init(FieldType::Bfield_fp_external, Direction{2}, lev, + amrex::convert(ba, m_fields.get(FieldType::Bfield_fp,Direction{2},lev)->ixType()), dm, ncomps, ngEB, 0.0_rt); } 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(FieldType::Bfield_aux, Direction{0}, lev); + auto *Bfield_aux_levl_1 = m_fields.get(FieldType::Bfield_aux, Direction{1}, lev); + auto *Bfield_aux_levl_2 = m_fields.get(FieldType::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()), + m_fields.alloc_init(FieldType::B_external_particle_field, Direction{0}, lev, amrex::convert(ba, Bfield_aux_levl_0->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "B_external_particle_field", Direction{1}, lev, amrex::convert(ba, Bfield_aux_levl_1->ixType()), + m_fields.alloc_init(FieldType::B_external_particle_field, Direction{1}, lev, amrex::convert(ba, Bfield_aux_levl_1->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "B_external_particle_field", Direction{2}, lev, amrex::convert(ba, Bfield_aux_levl_2->ixType()), + m_fields.alloc_init(FieldType::B_external_particle_field, Direction{2}, lev, amrex::convert(ba, Bfield_aux_levl_2->ixType()), dm, ncomps, ngEB, 0.0_rt); } if (m_p_ext_field_params->E_ext_grid_type != ExternalFieldType::default_zero && m_p_ext_field_params->E_ext_grid_type != ExternalFieldType::constant) { // These fields will be added directly to the grid, i.e. to fp, and need to match the index type - m_fields.alloc_init( "Efield_fp_external", Direction{0}, lev, amrex::convert(ba, m_fields.get("Efield_fp",Direction{0},lev)->ixType()), + m_fields.alloc_init(FieldType::Efield_fp_external, Direction{0}, lev, amrex::convert(ba, m_fields.get(FieldType::Efield_fp,Direction{0},lev)->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_fp_external", Direction{1}, lev, amrex::convert(ba, m_fields.get("Efield_fp",Direction{1},lev)->ixType()), + m_fields.alloc_init(FieldType::Efield_fp_external, Direction{1}, lev, amrex::convert(ba, m_fields.get(FieldType::Efield_fp,Direction{1},lev)->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_fp_external", Direction{2}, lev, amrex::convert(ba, m_fields.get("Efield_fp",Direction{2},lev)->ixType()), + m_fields.alloc_init(FieldType::Efield_fp_external, Direction{2}, lev, amrex::convert(ba, m_fields.get(FieldType::Efield_fp,Direction{2},lev)->ixType()), dm, ncomps, ngEB, 0.0_rt); } 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(FieldType::Efield_aux, Direction{0}, lev); + auto *Efield_aux_levl_1 = m_fields.get(FieldType::Efield_aux, Direction{1}, lev); + auto *Efield_aux_levl_2 = m_fields.get(FieldType::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()), + m_fields.alloc_init(FieldType::E_external_particle_field, Direction{0}, lev, amrex::convert(ba, Efield_aux_levl_0->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "E_external_particle_field", Direction{1}, lev, amrex::convert(ba, Efield_aux_levl_1->ixType()), + m_fields.alloc_init(FieldType::E_external_particle_field, Direction{1}, lev, amrex::convert(ba, Efield_aux_levl_1->ixType()), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "E_external_particle_field", Direction{2}, lev, amrex::convert(ba, Efield_aux_levl_2->ixType()), + m_fields.alloc_init(FieldType::E_external_particle_field, Direction{2}, lev, amrex::convert(ba, Efield_aux_levl_2->ixType()), dm, ncomps, ngEB, 0.0_rt); } @@ -2583,41 +2583,41 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm const std::array cdx = CellSize(lev-1); // Create the MultiFabs for B - m_fields.alloc_init( "Bfield_cp", Direction{0}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_cp", Direction{1}, lev, amrex::convert(cba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Bfield_cp", Direction{2}, lev, amrex::convert(cba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cp, Direction{0}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cp, Direction{1}, lev, amrex::convert(cba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cp, Direction{2}, lev, amrex::convert(cba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); // Create the MultiFabs for E - m_fields.alloc_init( "Efield_cp", Direction{0}, lev, amrex::convert(cba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_cp", Direction{1}, lev, amrex::convert(cba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init( "Efield_cp", Direction{2}, lev, amrex::convert(cba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cp, Direction{0}, lev, amrex::convert(cba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cp, Direction{1}, lev, amrex::convert(cba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cp, Direction{2}, lev, amrex::convert(cba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); 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, 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(FieldType::Bfield_avg_cp, Direction{0}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_avg_cp, Direction{1}, lev, amrex::convert(cba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::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, 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); + m_fields.alloc_init(FieldType::Efield_avg_cp, Direction{0}, lev, amrex::convert(cba, Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_avg_cp, Direction{1}, lev, amrex::convert(cba, Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_avg_cp, Direction{2}, lev, amrex::convert(cba, Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } // Create the MultiFabs for the current - m_fields.alloc_init( "current_cp", Direction{0}, lev, amrex::convert(cba, jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_cp", Direction{1}, lev, amrex::convert(cba, jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init( "current_cp", Direction{2}, lev, amrex::convert(cba, jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_cp, Direction{0}, lev, amrex::convert(cba, jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_cp, Direction{1}, lev, amrex::convert(cba, jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_cp, Direction{2}, lev, amrex::convert(cba, jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); if (rho_ncomps > 0) { - m_fields.alloc_init( - "rho_cp", lev, amrex::convert(cba, rho_nodal_flag), dm, + m_fields.alloc_init(FieldType::rho_cp, + lev, amrex::convert(cba, rho_nodal_flag), dm, rho_ncomps, ngRho, 0.0_rt); } if (do_dive_cleaning) { - m_fields.alloc_init( - "F_cp", lev, amrex::convert(cba, IntVect::TheUnitVector()), dm, + m_fields.alloc_init(FieldType::F_cp, + lev, amrex::convert(cba, IntVect::TheUnitVector()), dm, ncomps, ngF, 0.0_rt); } @@ -2625,14 +2625,14 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm { if (grid_type == GridType::Collocated) { - m_fields.alloc_init( - "G_cp", lev, amrex::convert(ba, IntVect::TheUnitVector()), dm, + m_fields.alloc_init(FieldType::G_cp, + lev, amrex::convert(ba, IntVect::TheUnitVector()), dm, ncomps, ngG, 0.0_rt); } else // grid_type=staggered or grid_type=hybrid { - m_fields.alloc_init( - "G_cp", lev, amrex::convert(ba, IntVect::TheZeroVector()), dm, + m_fields.alloc_init(FieldType::G_cp, + lev, amrex::convert(ba, IntVect::TheZeroVector()), dm, ncomps, ngG, 0.0_rt); } } @@ -2692,24 +2692,24 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (aux_is_nodal) { BoxArray const& cnba = amrex::convert(cba,IntVect::TheNodeVector()); // Create the MultiFabs for B - m_fields.alloc_init("Bfield_cax", Direction{0}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_cax", Direction{1}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_cax", Direction{2}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cax, Direction{0}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cax, Direction{1}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cax, Direction{2}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); // Create the MultiFabs for E - m_fields.alloc_init("Efield_cax", Direction{0}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_cax", Direction{1}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_cax", Direction{2}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cax, Direction{0}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cax, Direction{1}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cax, Direction{2}, lev, cnba, dm, ncomps, ngEB, 0.0_rt); } else { // Create the MultiFabs for B - m_fields.alloc_init("Bfield_cax", Direction{0}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_cax", Direction{1}, lev, amrex::convert(cba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Bfield_cax", Direction{2}, lev, amrex::convert(cba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cax, Direction{0}, lev, amrex::convert(cba, Bx_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cax, Direction{1}, lev, amrex::convert(cba, By_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Bfield_cax, Direction{2}, lev, amrex::convert(cba, Bz_nodal_flag), dm, ncomps, ngEB, 0.0_rt); // Create the MultiFabs for E - m_fields.alloc_init("Efield_cax", Direction{0}, lev, amrex::convert(cba,Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_cax", Direction{1}, lev, amrex::convert(cba,Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); - m_fields.alloc_init("Efield_cax", Direction{2}, lev, amrex::convert(cba,Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cax, Direction{0}, lev, amrex::convert(cba,Ex_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cax, Direction{1}, lev, amrex::convert(cba,Ey_nodal_flag), dm, ncomps, ngEB, 0.0_rt); + m_fields.alloc_init(FieldType::Efield_cax, Direction{2}, lev, amrex::convert(cba,Ez_nodal_flag), dm, ncomps, ngEB, 0.0_rt); } AllocInitMultiFab(gather_buffer_masks[lev], ba, dm, ncomps, amrex::IntVect(1), lev, "gather_buffer_masks"); @@ -2718,11 +2718,11 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm } if (n_current_deposition_buffer > 0) { - m_fields.alloc_init("current_buf", Direction{0}, lev, amrex::convert(cba,jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init("current_buf", Direction{1}, lev, amrex::convert(cba,jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - m_fields.alloc_init("current_buf", Direction{2}, lev, amrex::convert(cba,jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); - if (m_fields.has("rho_cp", lev)) { - m_fields.alloc_init("rho_buf", lev, amrex::convert(cba,rho_nodal_flag), dm, 2*ncomps, ngRho, 0.0_rt); + m_fields.alloc_init(FieldType::current_buf, Direction{0}, lev, amrex::convert(cba,jx_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_buf, Direction{1}, lev, amrex::convert(cba,jy_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + m_fields.alloc_init(FieldType::current_buf, Direction{2}, lev, amrex::convert(cba,jz_nodal_flag), dm, ncomps, ngJ, 0.0_rt); + if (m_fields.has(FieldType::rho_cp, lev)) { + m_fields.alloc_init(FieldType::rho_buf, lev, amrex::convert(cba,rho_nodal_flag), dm, 2*ncomps, ngRho, 0.0_rt); } AllocInitMultiFab(current_buffer_masks[lev], ba, dm, ncomps, amrex::IntVect(1), lev, "current_buffer_masks"); // Current buffer masks have 1 ghost cell, because of the fact @@ -2973,14 +2973,14 @@ WarpX::ComputeDivE(amrex::MultiFab& divE, const int lev) { if ( WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD ) { #ifdef WARPX_USE_FFT - const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev); + const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs(FieldType::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 { - const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev); + const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs(FieldType::Efield_aux, lev); m_fdtd_solver_fp[lev]->ComputeDivE(Efield_aux_lev, divE); } } @@ -3258,10 +3258,10 @@ WarpX::StoreCurrent (int lev) { using ablastr::fields::Direction; for (int idim = 0; idim < 3; ++idim) { - if (m_fields.has("current_store", Direction{idim},lev)) { - MultiFab::Copy(*m_fields.get("current_store", Direction{idim}, lev), - *m_fields.get("current_fp", Direction{idim}, lev), - 0, 0, 1, m_fields.get("current_store", Direction{idim}, lev)->nGrowVect()); + if (m_fields.has(FieldType::current_store, Direction{idim},lev)) { + MultiFab::Copy(*m_fields.get(FieldType::current_store, Direction{idim}, lev), + *m_fields.get(FieldType::current_fp, Direction{idim}, lev), + 0, 0, 1, m_fields.get(FieldType::current_store, Direction{idim}, lev)->nGrowVect()); } } } @@ -3270,12 +3270,13 @@ void WarpX::RestoreCurrent (int lev) { using ablastr::fields::Direction; + using warpx::fields::FieldType; for (int idim = 0; idim < 3; ++idim) { - if (m_fields.has("current_store", Direction{idim}, lev)) { + if (m_fields.has(FieldType::current_store, Direction{idim}, lev)) { std::swap( - *m_fields.get("current_fp", Direction{idim}, lev), - *m_fields.get("current_store", Direction{idim}, lev) + *m_fields.get(FieldType::current_fp, Direction{idim}, lev), + *m_fields.get(FieldType::current_store, Direction{idim}, lev) ); } }