Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Jan 12, 2025
1 parent f45b257 commit 2003d85
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Examples/Tests/embedded_boundary_cube/inputs_base_3d
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ boundary.field_lo = pec pec pec
boundary.field_hi = pec pec pec

eb2.geom_type = box
eb2.box_lo = -0.5 -0.5 -0.5
eb2.box_hi = 0.5 0.5 0.5
eb2.box_lo = -0.501 -0.501 -0.501 # Ensures that the stair-case EB is exactly at -0.5
eb2.box_hi = 0.501 0.501 0.501 # Ensures that the stair-case EB is exactly at 0.5
eb2.box_has_fluid_inside = true
# Alternatively one could use parser to build EB
# Note that for amrex EB implicit function, >0 is covered, =0 is boundary and <0 is regular.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ warpx.abort_on_warning_threshold = medium
boundary.field_lo = pec pec
boundary.field_hi = pec pec

my_constants.xmin = -0.501
my_constants.zmin = -0.501
my_constants.xmax = 0.501
my_constants.zmax = 0.501
my_constants.xmin = -0.501 # Ensures that the stair-case EB is exactly at -0.5
my_constants.zmin = -0.501 # Ensures that the stair-case EB is exactly at -0.5
my_constants.xmax = 0.501 # Ensures that the stair-case EB is exactly at 0.5
my_constants.zmax = 0.501 # Ensures that the stair-case EB is exactly at 0.5
# Note that for amrex EB implicit function, >0 is covered, =0 is boundary and <0 is regular.
warpx.eb_implicit_function = "max(max(x+xmin,-(x+xmax)), max(z+zmin,-(z+zmax)))"

Expand Down
1 change: 1 addition & 0 deletions Source/EmbeddedBoundary/WarpXInitEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ WarpX::MarkECTUpdateBCells (
amrex::Array4<amrex::Real> const & Sx_arr = face_areas[0]->array(mfi);
amrex::Array4<amrex::Real> const & Sy_arr = face_areas[1]->array(mfi);
amrex::Array4<amrex::Real> const & Sz_arr = face_areas[2]->array(mfi);
amrex::ignore_unused(edge_lengths);
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
amrex::Array4<amrex::Real> const & Sy_arr = face_areas[1]->array(mfi);
amrex::Array4<amrex::Real> const & lx_arr = edge_lengths[0]->array(mfi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FiniteDifferenceSolver
ablastr::fields::VectorField const& Efield,
ablastr::fields::VectorField const& Bfield,
ablastr::fields::VectorField const& Jfield,
ablastr::fields::VectorField const& edge_lengths,
std::array< std::unique_ptr<amrex::iMultiFab>,3 > const& eb_update_E,
amrex::Real dt,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties);

Expand Down Expand Up @@ -313,7 +313,7 @@ class FiniteDifferenceSolver
ablastr::fields::VectorField const& Efield,
ablastr::fields::VectorField const& Bfield,
ablastr::fields::VectorField const& Jfield,
ablastr::fields::VectorField const& edge_lengths,
std::array< std::unique_ptr<amrex::iMultiFab>,3 > const& eb_update_E,
amrex::Real dt,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties);

Expand Down
44 changes: 20 additions & 24 deletions Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ void FiniteDifferenceSolver::MacroscopicEvolveE (
ablastr::fields::VectorField const& Efield,
ablastr::fields::VectorField const& Bfield,
ablastr::fields::VectorField const& Jfield,
VectorField const& edge_lengths,
std::array< std::unique_ptr<amrex::iMultiFab>,3 > const& eb_update_E,
amrex::Real const dt,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties)
{

// Select algorithm (The choice of algorithm is a runtime option,
// but we compile code for each algorithm, using templates)
#ifdef WARPX_DIM_RZ
amrex::ignore_unused(Efield, Bfield, Jfield, edge_lengths, dt, macroscopic_properties);
amrex::ignore_unused(Efield, Bfield, Jfield, eb_update_E, dt, macroscopic_properties);

WARPX_ABORT_WITH_MESSAGE("currently macro E-push does not work for RZ");
#else
Expand All @@ -61,13 +61,13 @@ void FiniteDifferenceSolver::MacroscopicEvolveE (
if (WarpX::macroscopic_solver_algo == MacroscopicSolverAlgo::LaxWendroff) {

MacroscopicEvolveECartesian <CartesianYeeAlgorithm, LaxWendroffAlgo>
( Efield, Bfield, Jfield, edge_lengths, dt, macroscopic_properties);
( Efield, Bfield, Jfield, eb_update_E, dt, macroscopic_properties);

}
if (WarpX::macroscopic_solver_algo == MacroscopicSolverAlgo::BackwardEuler) {

MacroscopicEvolveECartesian <CartesianYeeAlgorithm, BackwardEulerAlgo>
( Efield, Bfield, Jfield, edge_lengths, dt, macroscopic_properties);
( Efield, Bfield, Jfield, eb_update_E, dt, macroscopic_properties);

}

Expand All @@ -78,12 +78,12 @@ void FiniteDifferenceSolver::MacroscopicEvolveE (
if (WarpX::macroscopic_solver_algo == MacroscopicSolverAlgo::LaxWendroff) {

MacroscopicEvolveECartesian <CartesianCKCAlgorithm, LaxWendroffAlgo>
( Efield, Bfield, Jfield, edge_lengths, dt, macroscopic_properties);
( Efield, Bfield, Jfield, eb_update_E, dt, macroscopic_properties);

} else if (WarpX::macroscopic_solver_algo == MacroscopicSolverAlgo::BackwardEuler) {

MacroscopicEvolveECartesian <CartesianCKCAlgorithm, BackwardEulerAlgo>
( Efield, Bfield, Jfield, edge_lengths, dt, macroscopic_properties);
( Efield, Bfield, Jfield, eb_update_E, dt, macroscopic_properties);

}

Expand All @@ -103,7 +103,7 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian (
ablastr::fields::VectorField const& Efield,
ablastr::fields::VectorField const& Bfield,
ablastr::fields::VectorField const& Jfield,
ablastr::fields::VectorField const& edge_lengths,
std::array< std::unique_ptr<amrex::iMultiFab>,3 > const& eb_update_E,
amrex::Real const dt,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties)
{
Expand Down Expand Up @@ -141,15 +141,12 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian (
Array4<Real> const& jy = Jfield[1]->array(mfi);
Array4<Real> const& jz = Jfield[2]->array(mfi);

amrex::Array4<amrex::Real> eb_lx, eb_ly, eb_lz;
amrex::Array4<int> update_Ex_arr, update_Ey_arr, update_Ez_arr;
if (EB::enabled()) {
eb_lx = edge_lengths[0]->array(mfi);
eb_ly = edge_lengths[1]->array(mfi);
eb_lz = edge_lengths[2]->array(mfi);
update_Ex_arr = eb_update_E[0]->array(mfi);
update_Ey_arr = eb_update_E[1]->array(mfi);
update_Ez_arr = eb_update_E[2]->array(mfi);
}
#ifdef WARPX_DIM_XZ
amrex::ignore_unused(eb_ly);
#endif

// material prop //
amrex::Array4<amrex::Real> const& sigma_arr = sigma_mf.array(mfi);
Expand Down Expand Up @@ -180,8 +177,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian (
// Loop over the cells and update the fields
amrex::ParallelFor(tex, tey, tez,
[=] AMREX_GPU_DEVICE (int i, int j, int k){
// Skip field push if this cell is fully covered by embedded boundaries
if (eb_lx && eb_lx(i, j, k) <= 0) { return; }

// Skip field push in the embedded boundaries
if (update_Ex_arr && update_Ex_arr(i, j, k) == 0) { return; }

// Interpolate conductivity, sigma, to Ex position on the grid
amrex::Real const sigma_interp = ablastr::coarsen::sample::Interp(sigma_arr, sigma_stag,
Expand All @@ -198,12 +196,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian (
},

[=] AMREX_GPU_DEVICE (int i, int j, int k){
#ifdef WARPX_DIM_3D
if (eb_ly && eb_ly(i,j,k) <= 0) { return; }
#elif defined(WARPX_DIM_XZ)
//In XZ Ey is associated with a mesh node, so we need to check if the mesh node is covered
if (eb_lx && (eb_lx(i, j, k)<=0 || eb_lx(i-1, j, k)<=0 || eb_lz(i, j, k)<=0 || eb_lz(i, j-1, k)<=0)) { return; }
#endif

// Skip field push in the embedded boundaries
if (update_Ey_arr && update_Ey_arr(i, j, k) == 0) { return; }

// Interpolate conductivity, sigma, to Ey position on the grid
amrex::Real const sigma_interp = ablastr::coarsen::sample::Interp(sigma_arr, sigma_stag,
Expand All @@ -221,8 +216,9 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian (
},

[=] AMREX_GPU_DEVICE (int i, int j, int k){
// Skip field push if this cell is fully covered by embedded boundaries
if (eb_lz && eb_lz(i, j, k) <= 0) { return; }

// Skip field push in the embedded boundaries
if (update_Ez_arr && update_Ez_arr(i, j, k) == 0) { return; }

// Interpolate conductivity, sigma, to Ez position on the grid
amrex::Real const sigma_interp = ablastr::coarsen::sample::Interp(sigma_arr, sigma_stag,
Expand Down
2 changes: 1 addition & 1 deletion Source/FieldSolver/WarpXPushFieldsEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ WarpX::MacroscopicEvolveE (int lev, PatchType patch_type, amrex::Real a_dt, amre
m_fields.get_alldirs(FieldType::Efield_fp, lev),
m_fields.get_alldirs(FieldType::Bfield_fp, lev),
m_fields.get_alldirs(FieldType::current_fp, lev),
m_fields.get_alldirs(FieldType::edge_lengths, lev),
m_eb_update_E[lev],
a_dt, m_macroscopic_properties);

if (do_pml && pml[lev]->ok()) {
Expand Down

0 comments on commit 2003d85

Please sign in to comment.