diff --git a/src/compute.cpp b/src/compute.cpp index ba1d53e7c3..7200f66dc8 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -140,13 +140,10 @@ void Compute::modify_params(int narg, char **arg) void Compute::adjust_dof_fix() { - Fix **fix = modify->fix; - int nfix = modify->nfix; - fix_dof = 0; - for (int i = 0; i < nfix; i++) - if (fix[i]->dof_flag) - fix_dof += fix[i]->dof(igroup); + for (auto &ifix : modify->get_fix_list()) + if (ifix->dof_flag) + fix_dof += ifix->dof(igroup); } /* ---------------------------------------------------------------------- diff --git a/src/compute_centroid_stress_atom.cpp b/src/compute_centroid_stress_atom.cpp index 5c6e522199..4ad9a4467c 100644 --- a/src/compute_centroid_stress_atom.cpp +++ b/src/compute_centroid_stress_atom.cpp @@ -194,10 +194,9 @@ void ComputeCentroidStressAtom::init() error->all(FLERR, "KSpace style does not support compute centroid/stress/atom"); if (fixflag) { - for (int ifix = 0; ifix < modify->nfix; ifix++) - if (modify->fix[ifix]->virial_peratom_flag && - modify->fix[ifix]->centroidstressflag == CENTROID_NOTAVAIL) - error->all(FLERR, "Fix style does not support compute centroid/stress/atom"); + for (auto &ifix : modify->get_fix_list()) + if (ifix->virial_peratom_flag && (ifix->centroidstressflag == CENTROID_NOTAVAIL)) + error->all(FLERR, "Fix {} does not support compute centroid/stress/atom", ifix->style); } } @@ -308,17 +307,15 @@ void ComputeCentroidStressAtom::compute_peratom() // fix styles are CENTROID_SAME, CENTROID_AVAIL or CENTROID_NOTAVAIL if (fixflag) { - Fix **fix = modify->fix; - int nfix = modify->nfix; - for (int ifix = 0; ifix < nfix; ifix++) - if (fix[ifix]->virial_peratom_flag && fix[ifix]->thermo_virial) { - if (modify->fix[ifix]->centroidstressflag == CENTROID_AVAIL) { - double **cvatom = modify->fix[ifix]->cvatom; + for (auto &ifix : modify->get_fix_list()) + if (ifix->virial_peratom_flag && ifix->thermo_virial) { + if (ifix->centroidstressflag == CENTROID_AVAIL) { + double **cvatom = ifix->cvatom; if (cvatom) for (i = 0; i < nlocal; i++) for (j = 0; j < 9; j++) stress[i][j] += cvatom[i][j]; } else { - double **vatom = modify->fix[ifix]->vatom; + double **vatom = ifix->vatom; if (vatom) for (i = 0; i < nlocal; i++) { for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j]; diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 7409a6de78..0bcfa3265c 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -91,8 +91,7 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : if (which[i] == ArgInfo::COMPUTE) { int icompute = modify->find_compute(ids[i]); if (icompute < 0) - error->all(FLERR,"Compute ID for compute chunk/spread/atom " - "does not exist"); + error->all(FLERR,"Compute ID for compute chunk/spread/atom does not exist"); if (!utils::strmatch(modify->compute[icompute]->style,"/chunk$")) error->all(FLERR,"Compute for compute chunk/spread/atom " @@ -100,32 +99,26 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : if (argindex[i] == 0) { if (!modify->compute[icompute]->vector_flag) - error->all(FLERR,"Compute chunk/spread/atom compute " - "does not calculate global vector"); + error->all(FLERR,"Compute chunk/spread/atom compute does not calculate global vector"); } else { if (!modify->compute[icompute]->array_flag) - error->all(FLERR,"Compute chunk/spread/atom compute " - "does not calculate global array"); + error->all(FLERR,"Compute chunk/spread/atom compute does not calculate global array"); if (argindex[i] > modify->compute[icompute]->size_array_cols) - error->all(FLERR,"Compute chunk/spread/atom compute array " - "is accessed out-of-range"); + error->all(FLERR,"Compute chunk/spread/atom compute array is accessed out-of-range"); } } else if (which[i] == ArgInfo::FIX) { - int ifix = modify->find_fix(ids[i]); - if (ifix < 0) - error->all(FLERR,"Fix ID for compute chunk/spread/atom does not exist"); + auto ifix = modify->get_fix_by_id(ids[i]); + if (ifix) + error->all(FLERR,"Fix ID {} for compute chunk/spread/atom does not exist", ids[i]); if (argindex[i] == 0) { - if (!modify->fix[ifix]->vector_flag) - error->all(FLERR,"Compute chunk/spread/atom fix " - "does not calculate global vector"); + if (!ifix->vector_flag) + error->all(FLERR,"Compute chunk/spread/atom fix does not calculate global vector"); } else { - if (!modify->fix[ifix]->array_flag) - error->all(FLERR,"Compute chunk/spread/atom fix " - "does not calculate global array"); - if (argindex[i] > modify->fix[ifix]->size_array_cols) - error->all(FLERR,"Compute chunk/spread/atom fix array " - "is accessed out-of-range"); + if (!ifix->array_flag) + error->all(FLERR,"Compute chunk/spread/atom fix does not calculate global array"); + if (argindex[i] > ifix->size_array_cols) + error->all(FLERR,"Compute chunk/spread/atom fix array is accessed out-of-range"); } } } @@ -287,7 +280,7 @@ void ComputeChunkSpreadAtom::compute_peratom() // check if index exceeds fix output length/rows } else if (which[m] == ArgInfo::FIX) { - Fix *fix = modify->fix[n]; + auto &fix = modify->get_fix_list()[n]; if (update->ntimestep % fix->global_freq) error->all(FLERR,"Fix used in compute chunk/spread/atom not " "computed at compatible time"); diff --git a/src/input.cpp b/src/input.cpp index 336dfd584f..228c535e06 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1870,7 +1870,7 @@ void Input::timestep() if (respaflag) update->integrate->reset_dt(); if (force->pair) force->pair->reset_dt(); - for (int i = 0; i < modify->nfix; i++) modify->fix[i]->reset_dt(); + for (auto &ifix : modify->get_fix_list()) ifix->reset_dt(); output->reset_dt(); } diff --git a/src/irregular.cpp b/src/irregular.cpp index bc7dfe038d..3d4719aa02 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -998,18 +998,11 @@ void Irregular::destroy_data() void Irregular::init_exchange() { - int nfix = modify->nfix; - Fix **fix = modify->fix; - - int onefix; int maxexchange_fix = 0; - for (int i = 0; i < nfix; i++) { - onefix = fix[i]->maxexchange; - maxexchange_fix = MAX(maxexchange_fix,onefix); - } + for (auto &ifix : modify->get_fix_list()) + maxexchange_fix = MAX(maxexchange_fix, ifix->maxexchange); - int maxexchange = atom->avec->maxexchange + maxexchange_fix; - bufextra = maxexchange + BUFEXTRA; + bufextra = atom->avec->maxexchange + maxexchange_fix + BUFEXTRA; } /* ---------------------------------------------------------------------- diff --git a/src/library.cpp b/src/library.cpp index af5fe36dd0..ace9905451 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -4756,10 +4756,8 @@ int lammps_has_id(void *handle, const char *category, const char *name) { if (strcmp(name,dump[i]->id) == 0) return 1; } } else if (strcmp(category,"fix") == 0) { - int nfix = lmp->modify->nfix; - Fix **fix = lmp->modify->fix; - for (int i=0; i < nfix; ++i) { - if (strcmp(name,fix[i]->id) == 0) return 1; + for (auto &ifix : lmp->modify->get_fix_list()) { + if (strcmp(name,ifix->id) == 0) return 1; } } else if (strcmp(category,"group") == 0) { int ngroup = lmp->group->ngroup;