From 45357791bde686c23945cd8c9ca7b1a244fbb4db Mon Sep 17 00:00:00 2001 From: "S. Eric Clark" <25495882+clarkse@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:51:21 -0700 Subject: [PATCH] Fixed a bug where centering coefficients used in Magentostatic solver were not being initialized when doing an energy-conserving field gather. Signed-off-by: S. Eric Clark <25495882+clarkse@users.noreply.github.com> --- .../MagnetostaticSolver/MagnetostaticSolver.cpp | 15 +++++++-------- Source/WarpX.cpp | 5 +++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp index 84efe8bf45a..622565848e1 100644 --- a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp +++ b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp @@ -170,15 +170,14 @@ WarpX::computeVectorPotential (ablastr::fields::MultiLevelVectorField const& cur amrex::Vector> sorted_curr; amrex::Vector> sorted_A; for (int lev = 0; lev <= finest_level; ++lev) { - sorted_curr.emplace_back(amrex::Array ({curr[lev][Direction{0}], - curr[lev][Direction{1}], - curr[lev][Direction{2}]})); - sorted_A.emplace_back(amrex::Array ({A[lev][Direction{0}], - A[lev][Direction{1}], - A[lev][Direction{2}]})); + sorted_curr.emplace_back(amrex::Array ({curr[lev][0].get(), + curr[lev][1].get(), + curr[lev][2].get()})); + sorted_A.emplace_back(amrex::Array ({A[lev][0].get(), + A[lev][1].get(), + A[lev][2].get()})); } -#if defined(AMREX_USE_EB) const ablastr::fields::MultiLevelVectorField Bfield_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_fp, finest_level); const std::optional post_A_calculation( { @@ -187,13 +186,13 @@ WarpX::computeVectorPotential (ablastr::fields::MultiLevelVectorField const& cur m_fields.get_mr_levels_alldirs(FieldType::vector_potential_grad_buf_b_stag, finest_level) }); +#if defined(AMREX_USE_EB) amrex::Vector factories; for (int lev = 0; lev <= finest_level; ++lev) { factories.push_back(&WarpX::fieldEBFactory(lev)); } const std::optional > eb_farray_box_factory({factories}); #else - const std::optional post_A_calculation; const std::optional > eb_farray_box_factory; #endif diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 60374133a52..db2f0c0b146 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -1388,8 +1388,9 @@ WarpX::ReadParameters () // Instead, if warpx.grid_type=collocated, the momentum-conserving and // energy conserving field gathering algorithms are equivalent (forces // gathered from the collocated grid) and no fields centering occurs. - if (WarpX::field_gathering_algo == GatheringAlgo::MomentumConserving && - WarpX::grid_type != GridType::Collocated) + if ((WarpX::field_gathering_algo == GatheringAlgo::MomentumConserving + && WarpX::grid_type != GridType::Collocated) + || WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic) { utils::parser::queryWithParser( pp_warpx, "field_centering_nox", field_centering_nox);