Skip to content

Commit

Permalink
Enable WarpX::ComputeEdgeLengths in RZ (#4749)
Browse files Browse the repository at this point in the history
* Enable `WarpX::ComputeEdgeLengths` in RZ

* Update exit message when using EBs in RZ with fully electromagnetic solvers.
  • Loading branch information
roelof-groenewald authored Mar 6, 2024
1 parent c4b1266 commit 766a521
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 4 additions & 8 deletions Source/EmbeddedBoundary/WarpXInitEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,15 @@ WarpX::InitEB ()
void
WarpX::ComputeEdgeLengths (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengths,
const amrex::EBFArrayBoxFactory& eb_fact) {
#ifndef WARPX_DIM_RZ
BL_PROFILE("ComputeEdgeLengths");

auto const &flags = eb_fact.getMultiEBCellFlagFab();
auto const &edge_centroid = eb_fact.getEdgeCent();
#ifdef WARPX_DIM_XZ
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
edge_lengths[1]->setVal(0.);
#endif
for (amrex::MFIter mfi(flags); mfi.isValid(); ++mfi){
#ifdef WARPX_DIM_XZ
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
for (int idim = 0; idim < 3; ++idim){
if(idim == 1) continue;
#elif defined(WARPX_DIM_3D)
Expand All @@ -148,7 +147,7 @@ WarpX::ComputeEdgeLengths (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& ed
edge_lengths_dim(i, j, k) = 0.;
});
} else {
#ifdef WARPX_DIM_XZ
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
int idim_amrex = idim;
if(idim == 2) idim_amrex = 1;
auto const &edge_cent = edge_centroid[idim_amrex]->const_array(mfi);
Expand All @@ -175,7 +174,6 @@ WarpX::ComputeEdgeLengths (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& ed
}
}
}
#endif
}


Expand Down Expand Up @@ -246,11 +244,10 @@ WarpX::ComputeFaceAreas (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& face
void
WarpX::ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengths,
const std::array<amrex::Real,3>& cell_size) {
#ifndef WARPX_DIM_RZ
BL_PROFILE("ScaleEdges");

for (amrex::MFIter mfi(*edge_lengths[0]); mfi.isValid(); ++mfi) {
#ifdef WARPX_DIM_XZ
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
for (int idim = 0; idim < 3; ++idim){
if(idim == 1) continue;
#elif defined(WARPX_DIM_3D)
Expand All @@ -267,7 +264,6 @@ WarpX::ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengt
});
}
}
#endif
}

void
Expand Down
5 changes: 3 additions & 2 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,9 @@ WarpX::ReadParameters ()

#if defined(AMREX_USE_EB) && defined(WARPX_DIM_RZ)
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
electromagnetic_solver_id==ElectromagneticSolverAlgo::None,
"Currently, the embedded boundary in RZ only works for electrostatic solvers (or no solver).");
electromagnetic_solver_id==ElectromagneticSolverAlgo::None
|| electromagnetic_solver_id==ElectromagneticSolverAlgo::HybridPIC,
"Currently, the embedded boundary in RZ only works for electrostatic solvers, the Ohm's law solver or with no solver installed.");
#endif

if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrame ||
Expand Down

0 comments on commit 766a521

Please sign in to comment.