From b160cdd66d0ffe679d9e4755cd98e399d8ebc5dd Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Wed, 10 Mar 2021 16:54:16 -0800 Subject: [PATCH] Minor cleanup of RZ in collisions (#1774) * Minor cleanup of RZ in collisions * Clean-up indentation * Fix white space * Further cleanup of warnings --- .../Collision/PairWiseCoulombCollision.cpp | 78 ++++++++----------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/Source/Particles/Collision/PairWiseCoulombCollision.cpp b/Source/Particles/Collision/PairWiseCoulombCollision.cpp index bb85402e06b..ee1d92b9a2b 100644 --- a/Source/Particles/Collision/PairWiseCoulombCollision.cpp +++ b/Source/Particles/Collision/PairWiseCoulombCollision.cpp @@ -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) @@ -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 ); } ); } @@ -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) @@ -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)