From 4c9924984db90d47adb49fa76a64eb79d2e8efea Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Apr 2024 15:58:24 -0400 Subject: [PATCH] modify access to fixes --- src/BODY/pair_body_rounded_polygon.cpp | 25 ++++++++++------------- src/BODY/pair_body_rounded_polyhedron.cpp | 24 +++++++++------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index 14f4f27582..2293f56a98 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -460,27 +460,24 @@ void PairBodyRoundedPolygon::init_style() for (i = 1; i <= ntypes; i++) maxerad[i] = merad[i] = 0; - int ipour; - for (ipour = 0; ipour < modify->nfix; ipour++) - if (strcmp(modify->fix[ipour]->style,"pour") == 0) break; - if (ipour == modify->nfix) ipour = -1; + Fix *fixpour = nullptr; + auto pours = modify->get_fix_by_style("^pour"); + if (pours.size() > 0) fixpour = pours[0]; + + Fix *fixdep = nullptr; + auto deps = modify->get_fix_by_style("^deposit"); + if (deps.size() > 0) fixdep = deps[0]; - int idep; - for (idep = 0; idep < modify->nfix; idep++) - if (strcmp(modify->fix[idep]->style,"deposit") == 0) break; - if (idep == modify->nfix) idep = -1; for (i = 1; i <= ntypes; i++) { merad[i] = 0.0; - if (ipour >= 0) { + if (fixpour) { itype = i; - merad[i] = - *((double *) modify->fix[ipour]->extract("radius",itype)); + merad[i] = *((double *) fixpour->extract("radius",itype)); } - if (idep >= 0) { + if (fixdep) { itype = i; - merad[i] = - *((double *) modify->fix[idep]->extract("radius",itype)); + merad[i] = *((double *) fixdep->extract("radius",itype)); } } diff --git a/src/BODY/pair_body_rounded_polyhedron.cpp b/src/BODY/pair_body_rounded_polyhedron.cpp index e82b1bcaef..ed83dc49e2 100644 --- a/src/BODY/pair_body_rounded_polyhedron.cpp +++ b/src/BODY/pair_body_rounded_polyhedron.cpp @@ -441,27 +441,23 @@ void PairBodyRoundedPolyhedron::init_style() for (i = 1; i <= ntypes; i++) maxerad[i] = merad[i] = 0; - int ipour; - for (ipour = 0; ipour < modify->nfix; ipour++) - if (strcmp(modify->fix[ipour]->style,"pour") == 0) break; - if (ipour == modify->nfix) ipour = -1; + Fix *fixpour = nullptr; + auto pours = modify->get_fix_by_style("^pour"); + if (pours.size() > 0) fixpour = pours[0]; - int idep; - for (idep = 0; idep < modify->nfix; idep++) - if (strcmp(modify->fix[idep]->style,"deposit") == 0) break; - if (idep == modify->nfix) idep = -1; + Fix *fixdep = nullptr; + auto deps = modify->get_fix_by_style("^deposit"); + if (deps.size() > 0) fixdep = deps[0]; for (i = 1; i <= ntypes; i++) { merad[i] = 0.0; - if (ipour >= 0) { + if (fixpour) { itype = i; - merad[i] = - *((double *) modify->fix[ipour]->extract("radius",itype)); + merad[i] = *((double *) fixpour->extract("radius",itype)); } - if (idep >= 0) { + if (fixdep) { itype = i; - merad[i] = - *((double *) modify->fix[idep]->extract("radius",itype)); + merad[i] = *((double *) fixdep->extract("radius",itype)); } }