From e0967af6e8e9c14a2423c7fc987245b46f342ff8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 19 Jan 2024 12:58:07 -0500 Subject: [PATCH] move fix wall style enumerator to header and import from there for consistency --- src/COLLOID/pair_brownian.cpp | 8 ++------ src/COLLOID/pair_brownian_poly.cpp | 8 ++------ src/COLLOID/pair_lubricate.cpp | 8 ++------ src/COLLOID/pair_lubricateU.cpp | 14 +++++-------- src/COLLOID/pair_lubricateU_poly.cpp | 27 +++++++------------------- src/COLLOID/pair_lubricate_poly.cpp | 8 ++------ src/OPENMP/pair_brownian_omp.cpp | 8 ++------ src/OPENMP/pair_brownian_poly_omp.cpp | 8 ++------ src/OPENMP/pair_lubricate_omp.cpp | 6 +----- src/OPENMP/pair_lubricate_poly_omp.cpp | 6 +----- src/fix_wall.cpp | 1 - src/fix_wall.h | 1 + 12 files changed, 27 insertions(+), 76 deletions(-) diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index 82be043df0..46892da1aa 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -42,10 +42,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -// same as fix_wall.cpp - -enum { EDGE, CONSTANT, VARIABLE }; - /* ---------------------------------------------------------------------- */ PairBrownian::PairBrownian(LAMMPS *lmp) : Pair(lmp) @@ -110,7 +106,7 @@ void PairBrownian::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -506,7 +502,7 @@ void PairBrownian::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index 1e04b8dc2a..95db05544a 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -42,10 +42,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairBrownianPoly::PairBrownianPoly(LAMMPS *lmp) : PairBrownian(lmp) @@ -95,7 +91,7 @@ void PairBrownianPoly::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -376,7 +372,7 @@ void PairBrownianPoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index 6f07d63bfb..067158b4bc 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -41,10 +41,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{NONE=0,EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricate::PairLubricate(LAMMPS *lmp) : Pair(lmp) @@ -169,7 +165,7 @@ void PairLubricate::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -593,7 +589,7 @@ void PairLubricate::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index ac1e62c2a2..218d1042f7 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -40,11 +40,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOL 1E-4 // tolerance for conjugate gradient - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double TOL = 1e-4; // tolerance for conjugate gradient /* ---------------------------------------------------------------------- */ @@ -595,7 +591,7 @@ void PairLubricateU::compute_Fh(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -827,7 +823,7 @@ void PairLubricateU::compute_RU() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1098,7 +1094,7 @@ void PairLubricateU::compute_RU(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1819,7 +1815,7 @@ void PairLubricateU::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 297c4e1924..af7e4d1de3 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -41,12 +41,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOL 1E-3 // tolerance for conjugate gradient - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - +static constexpr double TOL = 1e-3; // tolerance for conjugate gradient /* ---------------------------------------------------------------------- */ @@ -365,7 +360,7 @@ void PairLubricateUPoly::compute_Fh(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -640,7 +635,7 @@ void PairLubricateUPoly::compute_RU(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1161,9 +1156,7 @@ void PairLubricateUPoly::init_style() flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { if (flagwall) - error->all(FLERR, - "Cannot use multiple fix wall commands with " - "pair lubricateU"); + error->all(FLERR, "Cannot use multiple fix wall commands with pair lubricateU/poly"); flagwall = 1; // Walls exist wallfix = dynamic_cast(modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist @@ -1184,7 +1177,7 @@ void PairLubricateUPoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); @@ -1214,14 +1207,8 @@ void PairLubricateUPoly::init_style() if (!flagVF) vol_f = 0; - if (!comm->me) { - if (logfile) - fprintf(logfile, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", - vol_f,vol_P,vol_T); - if (screen) - fprintf(screen, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", - vol_f,vol_P,vol_T); - } + if (comm->me == 0) + utils::logmesg(lmp, "lubricateU: vol_f = {}, vol_p = {}, vol_T = {}\n", vol_f, vol_P, vol_T); // Set the isotropic constant diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index e6a0606e87..b989a8f04b 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -41,10 +41,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricatePoly::PairLubricatePoly(LAMMPS *lmp) : PairLubricate(lmp) @@ -151,7 +147,7 @@ void PairLubricatePoly::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -498,7 +494,7 @@ void PairLubricatePoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/OPENMP/pair_brownian_omp.cpp b/src/OPENMP/pair_brownian_omp.cpp index 45288f13dd..1506f1f35a 100644 --- a/src/OPENMP/pair_brownian_omp.cpp +++ b/src/OPENMP/pair_brownian_omp.cpp @@ -36,11 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define EPSILON 1.0e-10 - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ @@ -93,7 +89,7 @@ void PairBrownianOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_brownian_poly_omp.cpp b/src/OPENMP/pair_brownian_poly_omp.cpp index 91a496979d..ddd1af2c01 100644 --- a/src/OPENMP/pair_brownian_poly_omp.cpp +++ b/src/OPENMP/pair_brownian_poly_omp.cpp @@ -36,11 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define EPSILON 1.0e-10 - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ @@ -93,7 +89,7 @@ void PairBrownianPolyOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_lubricate_omp.cpp b/src/OPENMP/pair_lubricate_omp.cpp index 2145744a5b..5ba66ff266 100644 --- a/src/OPENMP/pair_lubricate_omp.cpp +++ b/src/OPENMP/pair_lubricate_omp.cpp @@ -32,10 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricateOMP::PairLubricateOMP(LAMMPS *lmp) : @@ -74,7 +70,7 @@ void PairLubricateOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_lubricate_poly_omp.cpp b/src/OPENMP/pair_lubricate_poly_omp.cpp index 5b98ec7b14..ebb2d65496 100644 --- a/src/OPENMP/pair_lubricate_poly_omp.cpp +++ b/src/OPENMP/pair_lubricate_poly_omp.cpp @@ -32,10 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricatePolyOMP::PairLubricatePolyOMP(LAMMPS *_lmp) : @@ -74,7 +70,7 @@ void PairLubricatePolyOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/fix_wall.cpp b/src/fix_wall.cpp index c4f3219622..50289d0f69 100644 --- a/src/fix_wall.cpp +++ b/src/fix_wall.cpp @@ -28,7 +28,6 @@ using namespace LAMMPS_NS; using namespace FixConst; enum { XLO = 0, XHI = 1, YLO = 2, YHI = 3, ZLO = 4, ZHI = 5 }; -enum { NONE = 0, EDGE, CONSTANT, VARIABLE }; static const char *wallpos[] = {"xlo", "xhi", "ylo", "yhi", "zlo", "zhi"}; diff --git a/src/fix_wall.h b/src/fix_wall.h index 12ceb17b49..81abfab8ea 100644 --- a/src/fix_wall.h +++ b/src/fix_wall.h @@ -27,6 +27,7 @@ class FixWall : public Fix { int xstyle[6]; int xindex[6]; char *xstr[6]; + enum { NONE = 0, EDGE, CONSTANT, VARIABLE }; FixWall(class LAMMPS *, int, char **); ~FixWall() override;