Skip to content

Commit

Permalink
Fixed a bug where centering coefficients used in Magentostatic solver…
Browse files Browse the repository at this point in the history
… were not being initialized when doing an energy-conserving field gather.

Signed-off-by: S. Eric Clark <[email protected]>
  • Loading branch information
clarkse committed Sep 18, 2024
1 parent 091c8d6 commit f245f22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,17 @@ WarpX::computeVectorPotential (const amrex::Vector<amrex::Array<std::unique_ptr<
A[lev][2].get()}));
}

#if defined(AMREX_USE_EB)
const std::optional<MagnetostaticSolver::EBCalcBfromVectorPotentialPerLevel> post_A_calculation({Bfield_fp,
vector_potential_grad_buf_e_stag,
vector_potential_grad_buf_b_stag});

#if defined(AMREX_USE_EB)
amrex::Vector<amrex::EBFArrayBoxFactory const *> factories;
for (int lev = 0; lev <= finest_level; ++lev) {
factories.push_back(&WarpX::fieldEBFactory(lev));
}
const std::optional<amrex::Vector<amrex::EBFArrayBoxFactory const *> > eb_farray_box_factory({factories});
#else
const std::optional<MagnetostaticSolver::EBCalcBfromVectorPotentialPerLevel> post_A_calculation;
const std::optional<amrex::Vector<amrex::FArrayBoxFactory const *> > eb_farray_box_factory;
#endif

Expand Down
5 changes: 3 additions & 2 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,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);
Expand Down

0 comments on commit f245f22

Please sign in to comment.