Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug where centering coefficients used in Magentostatic solver… #5289

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,14 @@ WarpX::computeVectorPotential (ablastr::fields::MultiLevelVectorField const& cur
amrex::Vector<amrex::Array<amrex::MultiFab*,3>> sorted_curr;
amrex::Vector<amrex::Array<amrex::MultiFab*,3>> sorted_A;
for (int lev = 0; lev <= finest_level; ++lev) {
sorted_curr.emplace_back(amrex::Array<amrex::MultiFab*,3> ({curr[lev][Direction{0}],
curr[lev][Direction{1}],
curr[lev][Direction{2}]}));
sorted_A.emplace_back(amrex::Array<amrex::MultiFab*,3> ({A[lev][Direction{0}],
A[lev][Direction{1}],
A[lev][Direction{2}]}));
sorted_curr.emplace_back(amrex::Array<amrex::MultiFab*,3> ({curr[lev][0],
curr[lev][1],
curr[lev][2]}));
sorted_A.emplace_back(amrex::Array<amrex::MultiFab*,3> ({A[lev][0],
A[lev][1],
A[lev][2]}));
}

#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<MagnetostaticSolver::EBCalcBfromVectorPotentialPerLevel> post_A_calculation(
{
Expand All @@ -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<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 @@ -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);
Expand Down
Loading