use symbolic constants Comm::BRICK / Comm::TILED for Comm::style

This commit is contained in:
Axel Kohlmeyer
2022-10-27 07:03:25 -04:00
parent e6b67683aa
commit 5824534ac6
16 changed files with 46 additions and 51 deletions

View File

@ -30,7 +30,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
CommTiledKokkos::CommTiledKokkos(LAMMPS *lmp) : CommTiled(lmp) {}
CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp) {}
/* ---------------------------------------------------------------------- */
//IMPORTANT: we *MUST* pass "*oldcomm" to the Comm initializer here, as
@ -39,7 +39,7 @@ CommTiledKokkos::CommTiledKokkos(LAMMPS *lmp) : CommTiled(lmp) {}
// The call to Comm::copy_arrays() then converts the shallow copy
// into a deep copy of the class with the new layout.
CommTiledKokkos::CommTiledKokkos(LAMMPS *lmp, Comm *oldcomm) : CommTiled(lmp,oldcomm) {}
CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp, Comm *oldcomm) : CommTiled(_lmp,oldcomm) {}
/* ---------------------------------------------------------------------- */

View File

@ -124,9 +124,8 @@ void MSM::init()
triclinic_check();
if (domain->dimension == 2)
error->all(FLERR,"Cannot (yet) use MSM with 2d simulation");
if (comm->style != 0)
error->universe_all(FLERR,"MSM can only currently be used with "
"comm_style brick");
if (comm->style != Comm::BRICK)
error->universe_all(FLERR,"MSM can only currently be used with comm_style brick");
if (!atom->q_flag) error->all(FLERR,"Kspace style requires atom attribute q");

View File

@ -116,14 +116,13 @@ void PPPMDipole::init()
if (domain->dimension == 2)
error->all(FLERR,"Cannot use PPPMDipole with 2d simulation");
if (comm->style != 0)
error->universe_all(FLERR,"PPPMDipole can only currently be used with "
"comm_style brick");
if (comm->style != Comm::BRICK)
error->universe_all(FLERR,"PPPMDipole can only currently be used with comm_style brick");
if (!atom->mu) error->all(FLERR,"Kspace style requires atom attribute mu");
if (atom->mu && differentiation_flag == 1) error->all(FLERR,"Cannot (yet) use kspace_modify diff"
" ad with dipoles");
if (atom->mu && differentiation_flag == 1)
error->all(FLERR,"Cannot (yet) use kspace_modify diff ad with dipoles");
if (dipoleflag && strcmp(update->unit_style,"electron") == 0)
error->all(FLERR,"Cannot (yet) use 'electron' units with dipoles");
@ -137,8 +136,7 @@ void PPPMDipole::init()
}
if (order < 2 || order > MAXORDER)
error->all(FLERR,"PPPMDipole order cannot be < 2 or > {}",
MAXORDER);
error->all(FLERR,"PPPMDipole order cannot be < 2 or > {}", MAXORDER);
// compute two charge force

View File

@ -101,14 +101,13 @@ void PPPMDipoleSpin::init()
if (domain->dimension == 2) error->all(FLERR,
"Cannot use PPPMDipoleSpin with 2d simulation");
if (comm->style != 0)
error->universe_all(FLERR,"PPPMDipoleSpin can only currently be used with "
"comm_style brick");
if (comm->style != Comm::BRICK)
error->universe_all(FLERR,"PPPMDipoleSpin can only currently be used with comm_style brick");
if (!atom->sp) error->all(FLERR,"Kspace style requires atom attribute sp");
if (atom->sp && differentiation_flag == 1) error->all(FLERR,"Cannot (yet) use"
" kspace_modify diff ad with spins");
if (atom->sp && differentiation_flag == 1)
error->all(FLERR,"Cannot (yet) use kspace_modify diff ad with spins");
if (spinflag && strcmp(update->unit_style,"metal") != 0)
error->all(FLERR,"'metal' units have to be used with spins");
@ -122,8 +121,7 @@ void PPPMDipoleSpin::init()
}
if (order < 2 || order > MAXORDER)
error->all(FLERR,"PPPMDipoleSpin order cannot be < 2 or > {}",
MAXORDER);
error->all(FLERR,"PPPMDipoleSpin order cannot be < 2 or > {}",MAXORDER);
// compute two charge force

View File

@ -266,9 +266,8 @@ void PPPMDisp::init()
if (domain->dimension == 2)
error->all(FLERR,"Cannot use PPPMDisp with 2d simulation");
if (comm->style != 0)
error->universe_all(FLERR,"PPPMDisp can only currently be used with "
"comm_style brick");
if (comm->style != Comm::BRICK)
error->universe_all(FLERR,"PPPMDisp can only currently be used with comm_style brick");
if (slabflag == 0 && domain->nonperiodic > 0)
error->all(FLERR,"Cannot use non-periodic boundaries with PPPMDisp");
@ -279,8 +278,7 @@ void PPPMDisp::init()
}
if (order > MAXORDER || order_6 > MAXORDER)
error->all(FLERR,"PPPMDisp coulomb or dispersion order cannot"
" be greater than {}",MAXORDER);
error->all(FLERR,"PPPMDisp coulomb or dispersion order cannot be greater than {}",MAXORDER);
// compute two charge force
@ -328,8 +326,7 @@ void PPPMDisp::init()
else error->all(FLERR,"Unsupported mixing rule in kspace_style pppm/disp");
break;
default:
error->all(FLERR,std::string("Unsupported order in kspace_style "
"pppm/disp, pair_style ")
error->all(FLERR,std::string("Unsupported order in kspace_style pppm/disp, pair_style ")
+ force->pair_style);
}
function[k] = 1;

View File

@ -181,9 +181,9 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) :
// we require continuous time stepping
time_depend = 1;
if (narg < 6) error->all(FLERR, "Illegal fix lb/fluid command");
if (narg < 6) utils::missing_cmd_args(FLERR, "fix lb/fluid",error);
if (comm->style != 0)
if (comm->style != Comm::BRICK)
error->universe_all(FLERR, "Fix lb/fluid can only currently be used with comm_style brick");
MPI_Comm_rank(world, &me);

View File

@ -941,7 +941,7 @@ void MDIEngine::evaluate()
output->thermo->compute(1);
} else {
if (!comm->style) {
if (comm->style == Comm::BRICK) {
if (domain->triclinic) domain->x2lamda(atom->nlocal);
domain->pbc();
domain->reset_box();

View File

@ -2774,7 +2774,7 @@ void FixBondReact::glove_ghostcheck()
int ghostly = 0;
#if !defined(MPI_STUBS)
if (comm->style == 0) {
if (comm->style == Comm::BRICK) {
if (create_atoms_flag[rxnID] == 1) {
ghostly = 1;
} else {

View File

@ -52,9 +52,8 @@ VerletSplit::VerletSplit(LAMMPS *lmp, int narg, char **arg) :
if (universe->procs_per_world[0] % universe->procs_per_world[1])
error->universe_all(FLERR,"Verlet/split requires Rspace partition "
"size be multiple of Kspace partition size");
if (comm->style != 0)
error->universe_all(FLERR,"Verlet/split can only currently be used with "
"comm_style brick");
if (comm->style != Comm::BRICK)
error->universe_all(FLERR,"Verlet/split can only currently be used with comm_style brick");
// master = 1 for Rspace procs, 0 for Kspace procs
@ -217,11 +216,10 @@ VerletSplit::~VerletSplit()
void VerletSplit::init()
{
if (comm->style != 0)
error->universe_all(FLERR,"Verlet/split can only currently be used with "
"comm_style brick");
if (comm->style != Comm::BRICK)
error->universe_all(FLERR,"Verlet/split can only currently be used with comm_style brick");
if (!force->kspace && comm->me == 0)
error->warning(FLERR,"No Kspace calculation with verlet/split");
error->warning(FLERR,"A KSpace style must be defined with verlet/split");
if (force->kspace_match("/tip4p",0)) tip4p_flag = 1;
else tip4p_flag = 0;

View File

@ -355,7 +355,7 @@ void FixSRD::init()
error->all(FLERR, "Fix srd no-slip requires atom attribute torque");
if (initflag && update->dt != dt_big)
error->all(FLERR, "Cannot change timestep once fix srd is setup");
if (comm->style != 0)
if (comm->style != Comm::BRICK)
error->universe_all(FLERR, "Fix srd can only currently be used with comm_style brick");
// orthogonal vs triclinic simulation box

View File

@ -245,7 +245,7 @@ void Balance::command(int narg, char **arg)
}
}
if (style == BISECTION && comm->style == 0)
if (style == BISECTION && comm->style == Comm::BRICK)
error->all(FLERR,"Balance rcb cannot be used with comm_style brick");
// process remaining optional args

View File

@ -20,13 +20,18 @@ namespace LAMMPS_NS {
class Comm : protected Pointers {
public:
int style; // comm pattern: 0 = 6-way stencil, 1 = irregular tiling
enum { BRICK, TILED };
int style; // BRICK = 6-way stencil communication
// TILED = irregular tiling communication
enum { LAYOUT_UNIFORM, LAYOUT_NONUNIFORM, LAYOUT_TILED };
int layout; // LAYOUT_UNIFORM = equal-sized bricks
// LAYOUT_NONUNIFORM = logical bricks, but diff sizes via LB
// LAYOUT_TILED = general tiling, due to RCB LB
enum { LAYOUT_UNIFORM, LAYOUT_NONUNIFORM, LAYOUT_TILED };
int mode; // 0 = single cutoff, 1 = multi-collection cutoff, 2 = multiold-type cutoff
enum { SINGLE, MULTI, MULTIOLD };
int mode; // SINGLE = single cutoff
// MULTI = multi-collection cutoff
// MULTIOLD = multiold-type cutoff
int me, nprocs; // proc info
int ghost_velocity; // 1 if ghost atoms have velocity, 0 if not

View File

@ -50,7 +50,7 @@ CommBrick::CommBrick(LAMMPS *lmp) :
pbc_flag(nullptr), pbc(nullptr), firstrecv(nullptr), sendlist(nullptr),
localsendlist(nullptr), maxsendlist(nullptr), buf_send(nullptr), buf_recv(nullptr)
{
style = 0;
style = Comm::BRICK;
layout = Comm::LAYOUT_UNIFORM;
pbc_flag = nullptr;
init_buffers();
@ -92,7 +92,7 @@ CommBrick::CommBrick(LAMMPS * /*lmp*/, Comm *oldcomm) : Comm(*oldcomm)
if (oldcomm->layout == Comm::LAYOUT_TILED)
error->all(FLERR,"Cannot change to comm_style brick from tiled layout");
style = 0;
style = Comm::BRICK;
layout = oldcomm->layout;
Comm::copy_arrays(oldcomm);
init_buffers();

View File

@ -47,7 +47,7 @@ using namespace LAMMPS_NS;
CommTiled::CommTiled(LAMMPS *lmp) : Comm(lmp)
{
style = 1;
style = Comm::TILED;
layout = Comm::LAYOUT_UNIFORM;
pbc_flag = nullptr;
buf_send = nullptr;
@ -68,7 +68,7 @@ CommTiled::CommTiled(LAMMPS *lmp) : Comm(lmp)
CommTiled::CommTiled(LAMMPS * /*lmp*/, Comm *oldcomm) : Comm(*oldcomm)
{
style = 1;
style = Comm::TILED;
layout = oldcomm->layout;
Comm::copy_arrays(oldcomm);
init_buffers();

View File

@ -94,7 +94,7 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) :
}
}
if (lbstyle == BISECTION && comm->style == 0)
if (lbstyle == BISECTION && comm->style == Comm::BRICK)
error->all(FLERR,"Fix balance rcb cannot be used with comm_style brick");
// create instance of Balance class

View File

@ -1429,21 +1429,21 @@ void Input::comm_modify()
void Input::comm_style()
{
if (narg < 1) error->all(FLERR,"Illegal comm_style command");
if (narg < 1) utils::missing_cmd_args(FLERR, "comm_style", error);
if (strcmp(arg[0],"brick") == 0) {
if (comm->style == 0) return;
if (comm->style == Comm::BRICK) return;
Comm *oldcomm = comm;
comm = new CommBrick(lmp,oldcomm);
delete oldcomm;
} else if (strcmp(arg[0],"tiled") == 0) {
if (comm->style == 1) return;
if (comm->style == Comm::TILED) return;
Comm *oldcomm = comm;
if (lmp->kokkos) comm = new CommTiledKokkos(lmp,oldcomm);
else comm = new CommTiled(lmp,oldcomm);
delete oldcomm;
} else error->all(FLERR,"Illegal comm_style command");
} else error->all(FLERR,"Unknown comm_style argument: {}", arg[0]);
}
/* ---------------------------------------------------------------------- */