Skip to content

Commit

Permalink
use amrex::MLNodeLaplacian if EB support is OFF
Browse files Browse the repository at this point in the history
  • Loading branch information
roelof-groenewald committed Aug 14, 2024
1 parent 75d4226 commit 6e702a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
31 changes: 2 additions & 29 deletions Source/FieldSolver/ElectrostaticSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ WarpX::computePhi (const amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rho,
sorted_phi.emplace_back(phi[lev].get());
}

#if defined(AMREX_USE_EB)
std::optional<ElectrostaticSolver::EBCalcEfromPhiPerLevel> post_phi_calculation;

#if defined(AMREX_USE_EB)
// EB: use AMReX to directly calculate the electric field since with EB's the
// simple finite difference scheme in WarpX::computeE sometimes fails
if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrame ||
Expand Down Expand Up @@ -383,34 +383,7 @@ WarpX::computePhi (const amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rho,
}
eb_farray_box_factory = factories;
#else
if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameSemiImplicit)
{
// TODO: maybe make this a helper function or pass Efield_fp directly
amrex::Vector<
amrex::Array<amrex::MultiFab *, AMREX_SPACEDIM>
> e_field;
for (int lev = 0; lev <= finest_level; ++lev) {
e_field.push_back(
# if defined(WARPX_DIM_1D_Z)
amrex::Array<amrex::MultiFab*, 1>{
getFieldPointer(FieldType::Efield_fp, lev, 2)
}
# elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
amrex::Array<amrex::MultiFab*, 2>{
getFieldPointer(FieldType::Efield_fp, lev, 0),
getFieldPointer(FieldType::Efield_fp, lev, 2)
}
# elif defined(WARPX_DIM_3D)
amrex::Array<amrex::MultiFab *, 3>{
getFieldPointer(FieldType::Efield_fp, lev, 0),
getFieldPointer(FieldType::Efield_fp, lev, 1),
getFieldPointer(FieldType::Efield_fp, lev, 2)
}
# endif
);
}
post_phi_calculation = ElectrostaticSolver::EBCalcEfromPhiPerLevel(e_field);
}
const std::optional<ElectrostaticSolver::EBCalcEfromPhiPerLevel> post_phi_calculation;
const std::optional<amrex::Vector<amrex::FArrayBoxFactory const *> > eb_farray_box_factory;
#endif

Expand Down
4 changes: 4 additions & 0 deletions Source/ablastr/fields/SemiImplicitPoissonSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ computeSemiImplicitPhi (amrex::Vector<amrex::MultiFab*> const & rho,
using namespace ablastr::constant::SI;
rho[lev]->mult(-1._rt/ep0); // TODO: when do we "un-multiply" this? We need to document this side-effect!

#if defined(AMREX_USE_EB) || defined(WARPX_DIM_RZ)
// Use the EB enabled solver.
amrex::MLEBNodeFDLaplacian linop( {geom[lev]}, {grids[lev]}, {dmap[lev]}, info
#if defined(AMREX_USE_EB)
, {eb_farray_box_factory.value()[lev]}
#endif
);
#else
amrex::MLNodeLaplacian linop( {geom[lev]}, {grids[lev]}, {dmap[lev]}, info);
#endif

#if defined(AMREX_USE_EB)
// if the EB potential only depends on time, the potential can be passed
Expand Down

0 comments on commit 6e702a5

Please sign in to comment.