Skip to content

Commit 9f4a7ad

Browse files
correct poynting flux at r-boundaries in cylindrical geometries. (#6820)
This PR corrects the Poynting flux diagnostic at r-boundaries in cylindrical geometries to be consistent with what is needed for exact energy conservation. See Eq. 19 of https://doi.org/10.1016/j.jcp.2024.113427. This is a peel-off PR from PR #6738.
1 parent 9b08157 commit 9f4a7ad

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Source/Diagnostics/ReducedDiags/FieldPoyntingFlux.H

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ namespace Poynting {
363363
[=] AMREX_GPU_DEVICE (int i, int j, int k) -> amrex::GpuTuple<amrex::Real>
364364
{
365365

366+
using namespace amrex::literals;
366367
constexpr int comp = 0;
367368

368369
// This is needed by the GPU compilers where captured variables cannot first appear
@@ -371,7 +372,16 @@ namespace Poynting {
371372

372373
amrex::Real const af = area_factor(i,j,k);
373374
if constexpr (normal_dir == 0) {
375+
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_RCYLINDER)
376+
amrex::Real const afup1 = area_factor(i+1,j,k);
377+
amrex::Real const afdn1 = area_factor(i-1,j,k);
378+
amrex::Real const afuphalf = 0.5_rt*(af + afup1);
379+
amrex::Real const afdnhalf = 0.5_rt*(af + afdn1);
380+
return af*T_Algo::EyBz(i,j,k,comp,Ey_arr,Bz_arr)
381+
- (af == 0._rt ? 0.0_rt : Ez_arr(i,j,k,comp)*0.5_rt*(afdnhalf*By_arr(i-1,j,k,comp) + afuphalf*By_arr(i,j,k,comp)));
382+
#else
374383
return af*(T_Algo::EyBz(i,j,k,comp,Ey_arr,Bz_arr) - T_Algo::EzBy(i,j,k,comp,Ez_arr,By_arr));
384+
#endif
375385
}
376386

377387
else if constexpr (normal_dir == 1) {

0 commit comments

Comments
 (0)