Skip to content

Commit

Permalink
Clean up calculation of dV
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Jun 7, 2024
1 parent b642053 commit 5122092
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Source/Diagnostics/ReducedDiags/FieldEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ void FieldEnergy::ComputeDiags (int step)
const MultiFab & By = warpx.getField(FieldType::Bfield_aux, lev,1);
const MultiFab & Bz = warpx.getField(FieldType::Bfield_aux, lev,2);

// get cell size
// get cell volume
const std::array<Real, 3> &dx = warpx.CellSize(lev);
const amrex::Real dV = dx[0]*dx[1]*dx[2];

Geometry const & geom = warpx.Geom(lev);
const amrex::Real dV = AMREX_D_TERM(geom.CellSize(0), *geom.CellSize(1), *geom.CellSize(2));

#if defined(WARPX_DIM_RZ)
amrex::Real const tmpEx = ComputeNorm2RZ(Ex, lev);
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/ReducedDiags/FieldMomentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ void FieldMomentum::ComputeDiags (int step)
amrex::Real ExB_z = amrex::get<2>(r);
amrex::ParallelDescriptor::ReduceRealSum({ExB_x,ExB_y,ExB_z});

// Get cell size
amrex::Geometry const & geom = warpx.Geom(lev);
const amrex::Real dV = AMREX_D_TERM(geom.CellSize(0), *geom.CellSize(1), *geom.CellSize(2));
// Get cell volume
const std::array<Real, 3> &dx = warpx.CellSize(lev);
const amrex::Real dV = dx[0]*dx[1]*dx[2];

// Save data (offset: 3 values for each refinement level)
const int offset = lev*3;
Expand Down

0 comments on commit 5122092

Please sign in to comment.