Skip to content

Commit

Permalink
Merge branch 'development' into cleanup_deposition_gather
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Jun 10, 2024
2 parents 6d67a67 + e80ca98 commit 810c249
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 273 deletions.
54 changes: 8 additions & 46 deletions Source/Diagnostics/ReducedDiags/BeamRelevant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,6 @@ void BeamRelevant::ComputeDiags (int step)
// inverse of speed of light squared
Real constexpr inv_c2 = 1.0_rt / (PhysConst::c * PhysConst::c);

// If 2D-XZ, p.pos(1) is z, rather than p.pos(2).
#if (defined WARPX_DIM_3D)
int const index_z = 2;
#elif (defined WARPX_DIM_XZ || defined WARPX_DIM_RZ)
int const index_z = 1;
#elif (defined WARPX_DIM_1D_Z)
int const index_z = 0;
#endif

// loop over species
for (int i_s = 0; i_s < nSpecies; ++i_s)
{
Expand Down Expand Up @@ -212,26 +203,14 @@ void BeamRelevant::ComputeDiags (int step)
const ParticleReal p_uy = p.rdata(PIdx::uy);
const ParticleReal p_uz = p.rdata(PIdx::uz);
const ParticleReal p_us = p_ux*p_ux + p_uy*p_uy + p_uz*p_uz;
const ParticleReal p_pos0 = p.pos(0);
const ParticleReal p_w = p.rdata(PIdx::w);

#if defined(WARPX_DIM_3D)
const ParticleReal p_pos1 = p.pos(1);
const ParticleReal p_x_mean = p_pos0*p_w;
const ParticleReal p_y_mean = p_pos1*p_w;
#elif defined(WARPX_DIM_RZ)
const ParticleReal p_theta = p.rdata(PIdx::theta);
const ParticleReal p_x_mean = p_pos0*std::cos(p_theta)*p_w;
const ParticleReal p_y_mean = p_pos0*std::sin(p_theta)*p_w;
#elif defined(WARPX_DIM_XZ)
const ParticleReal p_x_mean = p_pos0*p_w;
const ParticleReal p_y_mean = 0;
#elif defined(WARPX_DIM_1D_Z)
amrex::ignore_unused(p_pos0);
const ParticleReal p_x_mean = 0;
const ParticleReal p_y_mean = 0;
#endif
const ParticleReal p_z_mean = p.pos(index_z)*p_w;
ParticleReal p_x, p_y, p_z;
get_particle_position(p, p_x, p_y, p_z);

const ParticleReal p_x_mean = p_x*p_w;
const ParticleReal p_y_mean = p_y*p_w;
const ParticleReal p_z_mean = p_z*p_w;

const ParticleReal p_ux_mean = p_ux*p_w;
const ParticleReal p_uy_mean = p_uy*p_w;
Expand Down Expand Up @@ -292,25 +271,8 @@ void BeamRelevant::ComputeDiags (int step)
const ParticleReal p_gm = std::sqrt(1.0_rt+p_us*inv_c2);
const ParticleReal p_w = p.rdata(PIdx::w);

#if (defined WARPX_DIM_1D_Z)
const ParticleReal p_x = 0.0;
const ParticleReal p_y = 0.0;
#elif (defined WARPX_DIM_RZ)
const ParticleReal p_pos0 = p.pos(0);
const ParticleReal p_theta = p.rdata(PIdx::theta);
const ParticleReal p_x = p_pos0*std::cos(p_theta);
const ParticleReal p_y = p_pos0*std::sin(p_theta);
#elif (defined WARPX_DIM_XZ)
const ParticleReal p_pos0 = p.pos(0);
const ParticleReal p_x = p_pos0;
const ParticleReal p_y = 0.0;
#else
const ParticleReal p_pos0 = p.pos(0);
const ParticleReal p_pos1 = p.pos(1);
const ParticleReal p_x = p_pos0;
const ParticleReal p_y = p_pos1;
#endif
const ParticleReal p_z = p.pos(index_z);
ParticleReal p_x, p_y, p_z;
get_particle_position(p, p_x, p_y, p_z);

const ParticleReal p_x_ms = (p_x-x_mean)*(p_x-x_mean)*p_w;
const ParticleReal p_y_ms = (p_y-y_mean)*(p_y-y_mean)*p_w;
Expand Down
14 changes: 5 additions & 9 deletions Source/Diagnostics/ReducedDiags/FieldEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,9 @@ 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
Geometry const & geom = warpx.Geom(lev);
#if defined(WARPX_DIM_1D_Z)
auto dV = geom.CellSize(0);
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
auto dV = geom.CellSize(0) * geom.CellSize(1);
#elif defined(WARPX_DIM_3D)
auto dV = geom.CellSize(0) * geom.CellSize(1) * geom.CellSize(2);
#endif
// get cell volume
const std::array<Real, 3> &dx = WarpX::CellSize(lev);
const amrex::Real dV = dx[0]*dx[1]*dx[2];

#if defined(WARPX_DIM_RZ)
amrex::Real const tmpEx = ComputeNorm2RZ(Ex, lev);
Expand All @@ -119,6 +113,8 @@ void FieldEnergy::ComputeDiags (int step)
amrex::Real const tmpBz = ComputeNorm2RZ(Bz, lev);
amrex::Real const Bs = tmpBx + tmpBy + tmpBz;
#else
Geometry const & geom = warpx.Geom(lev);

// compute E squared
Real const tmpEx = Ex.norm2(0,geom.periodicity());
Real const tmpEy = Ey.norm2(0,geom.periodicity());
Expand Down
12 changes: 3 additions & 9 deletions Source/Diagnostics/ReducedDiags/FieldMomentum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +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);
#if defined(WARPX_DIM_1D_Z)
auto dV = geom.CellSize(0);
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
auto dV = geom.CellSize(0) * geom.CellSize(1);
#elif defined(WARPX_DIM_3D)
auto dV = geom.CellSize(0) * geom.CellSize(1) * geom.CellSize(2);
#endif
// 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
Loading

0 comments on commit 810c249

Please sign in to comment.