diff --git a/src/ORIENT/fix_orient_bcc.cpp b/src/ORIENT/fix_orient_bcc.cpp index fd5ce748d6..8a380e01a7 100644 --- a/src/ORIENT/fix_orient_bcc.cpp +++ b/src/ORIENT/fix_orient_bcc.cpp @@ -91,7 +91,6 @@ FixOrientBCC::FixOrientBCC(LAMMPS *lmp, int narg, char **arg) : // initializations - half_bcc_nn = 4; use_xismooth = false; double xicutoff = 1.57; xicutoffsq = xicutoff * xicutoff; @@ -107,7 +106,7 @@ FixOrientBCC::FixOrientBCC(LAMMPS *lmp, int narg, char **arg) : FILE *inpfile = fopen(xifilename,"r"); if (inpfile == nullptr) error->one(FLERR,"Fix orient/bcc file open failed"); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < half_bcc_nn; i++) { result = fgets(line,IMGMAX,inpfile); if (!result) error->one(FLERR,"Fix orient/bcc file read failed"); count = sscanf(line,"%lg %lg %lg",&Rxi[i][0],&Rxi[i][1],&Rxi[i][2]); @@ -117,7 +116,7 @@ FixOrientBCC::FixOrientBCC(LAMMPS *lmp, int narg, char **arg) : inpfile = fopen(chifilename,"r"); if (inpfile == nullptr) error->one(FLERR,"Fix orient/bcc file open failed"); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < half_bcc_nn; i++) { result = fgets(line,IMGMAX,inpfile); if (!result) error->one(FLERR,"Fix orient/bcc file read failed"); count = sscanf(line,"%lg %lg %lg",&Rchi[i][0],&Rchi[i][1],&Rchi[i][2]); @@ -126,12 +125,12 @@ FixOrientBCC::FixOrientBCC(LAMMPS *lmp, int narg, char **arg) : fclose(inpfile); } - MPI_Bcast(&Rxi[0][0],18,MPI_DOUBLE,0,world); - MPI_Bcast(&Rchi[0][0],18,MPI_DOUBLE,0,world); + MPI_Bcast(&Rxi[0][0],half_bcc_nn*3,MPI_DOUBLE,0,world); + MPI_Bcast(&Rchi[0][0],half_bcc_nn*3,MPI_DOUBLE,0,world); // make copy of the reference vectors - for (int i = 0; i < 4; i++) + for (int i = 0; i < half_bcc_nn; i++) for (int j = 0; j < 3; j++) { half_xi_chi_vec[0][i][j] = Rxi[i][j]; half_xi_chi_vec[1][i][j] = Rchi[i][j]; @@ -144,7 +143,7 @@ FixOrientBCC::FixOrientBCC(LAMMPS *lmp, int narg, char **arg) : double xi_sq,dxi[3],rchi[3]; xiid = 0.0; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < half_bcc_nn; i++) { rchi[0] = Rchi[i][0]; rchi[1] = Rchi[i][1]; rchi[2] = Rchi[i][2]; diff --git a/src/ORIENT/fix_orient_bcc.h b/src/ORIENT/fix_orient_bcc.h index 858b9bb1b4..82d9829397 100644 --- a/src/ORIENT/fix_orient_bcc.h +++ b/src/ORIENT/fix_orient_bcc.h @@ -69,9 +69,9 @@ class FixOrientBCC : public Fix { char *xifilename, *chifilename; // file names for 2 crystal orientations bool use_xismooth; - double Rxi[8][3] = {0}, Rchi[8][3] = {0}, half_xi_chi_vec[2][4][3] = {0}; + static constexpr int half_bcc_nn = 4; + double Rxi[half_bcc_nn][3] = {}, Rchi[half_bcc_nn][3] = {}, half_xi_chi_vec[2][half_bcc_nn][3] = {}; double xiid, xi0, xi1, xicutoffsq, cutsq, added_energy; - int half_bcc_nn; int nmax; // expose 2 per-atom quantities double **order; // order param and normalized order param diff --git a/src/ORIENT/fix_orient_fcc.cpp b/src/ORIENT/fix_orient_fcc.cpp index c5fe269e5b..30321f9145 100644 --- a/src/ORIENT/fix_orient_fcc.cpp +++ b/src/ORIENT/fix_orient_fcc.cpp @@ -89,7 +89,6 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) : // initializations - half_fcc_nn = 6; use_xismooth = false; double xicutoff = 1.57; xicutoffsq = xicutoff * xicutoff; @@ -105,7 +104,7 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) : FILE *inpfile = fopen(xifilename,"r"); if (inpfile == nullptr) error->one(FLERR,"Fix orient/fcc file open failed"); - for (int i = 0; i < 6; i++) { + for (int i = 0; i < half_fcc_nn; i++) { result = fgets(line,IMGMAX,inpfile); if (!result) error->one(FLERR,"Fix orient/fcc file read failed"); count = sscanf(line,"%lg %lg %lg",&Rxi[i][0],&Rxi[i][1],&Rxi[i][2]); @@ -115,7 +114,7 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) : inpfile = fopen(chifilename,"r"); if (inpfile == nullptr) error->one(FLERR,"Fix orient/fcc file open failed"); - for (int i = 0; i < 6; i++) { + for (int i = 0; i < half_fcc_nn; i++) { result = fgets(line,IMGMAX,inpfile); if (!result) error->one(FLERR,"Fix orient/fcc file read failed"); count = sscanf(line,"%lg %lg %lg",&Rchi[i][0],&Rchi[i][1],&Rchi[i][2]); @@ -124,12 +123,12 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) : fclose(inpfile); } - MPI_Bcast(&Rxi[0][0],18,MPI_DOUBLE,0,world); - MPI_Bcast(&Rchi[0][0],18,MPI_DOUBLE,0,world); + MPI_Bcast(&Rxi[0][0],half_fcc_nn*3,MPI_DOUBLE,0,world); + MPI_Bcast(&Rchi[0][0],half_fcc_nn*3,MPI_DOUBLE,0,world); // make copy of the reference vectors - for (int i = 0; i < 6; i++) + for (int i = 0; i < half_fcc_nn; i++) for (int j = 0; j < 3; j++) { half_xi_chi_vec[0][i][j] = Rxi[i][j]; half_xi_chi_vec[1][i][j] = Rchi[i][j]; @@ -142,7 +141,7 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) : double xi_sq,dxi[3],rchi[3]; xiid = 0.0; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < half_fcc_nn; i++) { rchi[0] = Rchi[i][0]; rchi[1] = Rchi[i][1]; rchi[2] = Rchi[i][2]; diff --git a/src/ORIENT/fix_orient_fcc.h b/src/ORIENT/fix_orient_fcc.h index 6791672326..dd36a89547 100644 --- a/src/ORIENT/fix_orient_fcc.h +++ b/src/ORIENT/fix_orient_fcc.h @@ -69,9 +69,9 @@ class FixOrientFCC : public Fix { char *xifilename, *chifilename; // file names for 2 crystal orientations bool use_xismooth; - double Rxi[8][3] = {0}, Rchi[8][3] = {0}, half_xi_chi_vec[2][4][3] = {0}; + static constexpr int half_fcc_nn = 6; + double Rxi[half_fcc_nn][3] = {}, Rchi[half_fcc_nn][3] = {}, half_xi_chi_vec[2][half_fcc_nn][3] = {}; double xiid, xi0, xi1, xicutoffsq, cutsq, added_energy; - int half_fcc_nn; int nmax; // expose 2 per-atom quantities double **order; // order param and normalized order param