Skip to content

Commit

Permalink
Minor cleanup of RZ in collisions (#1774)
Browse files Browse the repository at this point in the history
* Minor cleanup of RZ in collisions

* Clean-up indentation

* Fix white space

* Further cleanup of warnings
  • Loading branch information
RemiLehe authored Mar 11, 2021
1 parent 0dd5474 commit b160cdd
Showing 1 changed file with 34 additions and 44 deletions.
78 changes: 34 additions & 44 deletions Source/Particles/Collision/PairWiseCoulombCollision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ void PairWiseCoulombCollision::doCoulombCollisionsWithinTile
const amrex::Real dt = WarpX::GetInstance().getdt(lev);
amrex::Geometry const& geom = WarpX::GetInstance().Geom(lev);
amrex::Box const& cbx = mfi.tilebox(amrex::IntVect::TheZeroVector()); //Cell-centered box
const auto lo = lbound(cbx);
const auto hi = ubound(cbx);
int nz = hi.y-lo.y+1;
#if defined WARPX_DIM_XZ
auto dV = geom.CellSize(0) * geom.CellSize(1);
#elif defined WARPX_DIM_RZ
const auto lo = lbound(cbx);
const auto hi = ubound(cbx);
int const nz = hi.y-lo.y+1;
auto dr = geom.CellSize(0);
auto dz = geom.CellSize(1);
#elif (AMREX_SPACEDIM == 3)
Expand All @@ -140,28 +140,23 @@ void PairWiseCoulombCollision::doCoulombCollisionsWithinTile
index_type const cell_half_1 = (cell_start_1+cell_stop_1)/2;

// Do not collide if there is only one particle in the cell
if ( cell_stop_1 - cell_start_1 >= 2 )
{
// shuffle
ShuffleFisherYates(
indices_1, cell_start_1, cell_half_1, engine );
if ( cell_stop_1 - cell_start_1 <= 1 ) return;

// shuffle
ShuffleFisherYates(
indices_1, cell_start_1, cell_half_1, engine );
#if defined WARPX_DIM_RZ
int ri = (i_cell - i_cell%nz) / nz;
auto dV = MathConst::pi*(2.0_rt*ri+1.0_rt)*dr*dr*dz;
#else
amrex::ignore_unused(nz);
int ri = (i_cell - i_cell%nz) / nz;
auto dV = MathConst::pi*(2.0_rt*ri+1.0_rt)*dr*dr*dz;
#endif

// Call the function in order to perform collisions
ElasticCollisionPerez(
cell_start_1, cell_half_1,
cell_half_1, cell_stop_1,
indices_1, indices_1,
ux_1, uy_1, uz_1, ux_1, uy_1, uz_1, w_1, w_1,
q1, q1, m1, m1, amrex::Real(-1.0), amrex::Real(-1.0),
dt*ndt, CoulombLog, dV, engine );
}
// Call the function in order to perform collisions
ElasticCollisionPerez(
cell_start_1, cell_half_1,
cell_half_1, cell_stop_1,
indices_1, indices_1,
ux_1, uy_1, uz_1, ux_1, uy_1, uz_1, w_1, w_1,
q1, q1, m1, m1, amrex::Real(-1.0), amrex::Real(-1.0),
dt*ndt, CoulombLog, dV, engine );
}
);
}
Expand Down Expand Up @@ -207,12 +202,12 @@ void PairWiseCoulombCollision::doCoulombCollisionsWithinTile
const amrex::Real dt = WarpX::GetInstance().getdt(lev);
amrex::Geometry const& geom = WarpX::GetInstance().Geom(lev);
amrex::Box const& cbx = mfi.tilebox(amrex::IntVect::TheZeroVector()); //Cell-centered box
const auto lo = lbound(cbx);
const auto hi = ubound(cbx);
int nz = hi.y-lo.y+1;
#if defined WARPX_DIM_XZ
auto dV = geom.CellSize(0) * geom.CellSize(1);
#elif defined WARPX_DIM_RZ
const auto lo = lbound(cbx);
const auto hi = ubound(cbx);
int nz = hi.y-lo.y+1;
auto dr = geom.CellSize(0);
auto dz = geom.CellSize(1);
#elif (AMREX_SPACEDIM == 3)
Expand All @@ -236,28 +231,23 @@ void PairWiseCoulombCollision::doCoulombCollisionsWithinTile
// cell_start_1 (inclusive) and cell_start_2 (exclusive)

// Do not collide if one species is missing in the cell
if ( cell_stop_1 - cell_start_1 >= 1 &&
cell_stop_2 - cell_start_2 >= 1 )
{
// shuffle
ShuffleFisherYates(indices_1, cell_start_1, cell_stop_1, engine);
ShuffleFisherYates(indices_2, cell_start_2, cell_stop_2, engine);
if ( cell_stop_1 - cell_start_1 < 1 ||
cell_stop_2 - cell_start_2 < 1 ) return;

// shuffle
ShuffleFisherYates(indices_1, cell_start_1, cell_stop_1, engine);
ShuffleFisherYates(indices_2, cell_start_2, cell_stop_2, engine);
#if defined WARPX_DIM_RZ
int ri = (i_cell - i_cell%nz) / nz;
auto dV = MathConst::pi*(2.0_rt*ri+1.0_rt)*dr*dr*dz;
#else
amrex::ignore_unused(nz);
int ri = (i_cell - i_cell%nz) / nz;
auto dV = MathConst::pi*(2.0_rt*ri+1.0_rt)*dr*dr*dz;
#endif

// Call the function in order to perform collisions
ElasticCollisionPerez(
cell_start_1, cell_stop_1, cell_start_2, cell_stop_2,
indices_1, indices_2,
ux_1, uy_1, uz_1, ux_2, uy_2, uz_2, w_1, w_2,
q1, q2, m1, m2, amrex::Real(-1.0), amrex::Real(-1.0),
dt*ndt, CoulombLog, dV, engine );
}
// Call the function in order to perform collisions
ElasticCollisionPerez(
cell_start_1, cell_stop_1, cell_start_2, cell_stop_2,
indices_1, indices_2,
ux_1, uy_1, uz_1, ux_2, uy_2, uz_2, w_1, w_2,
q1, q2, m1, m2, amrex::Real(-1.0), amrex::Real(-1.0),
dt*ndt, CoulombLog, dV, engine );
}
);
} // end if ( m_isSameSpecies)
Expand Down

0 comments on commit b160cdd

Please sign in to comment.