From dd2ff737f1b485d3f1e1e29cbacbd60f33204ada Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 18 Oct 2021 06:50:28 -0400 Subject: [PATCH] port mdi/engine command to new fix accessor API --- src/MDI/mdi_engine.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/MDI/mdi_engine.cpp b/src/MDI/mdi_engine.cpp index 4be739d187..4f9302c4d5 100644 --- a/src/MDI/mdi_engine.cpp +++ b/src/MDI/mdi_engine.cpp @@ -20,8 +20,8 @@ #include "atom.h" #include "error.h" -#include "integrate.h" #include "fix_mdi_engine.h" +#include "integrate.h" #include "mdi.h" #include "min.h" #include "modify.h" @@ -176,17 +176,13 @@ void MDIEngine::command(int narg, char ** /*arg*/) // if the mdi/engine fix is not already present, add it now - int ifix = modify->find_fix_by_style("mdi/engine"); bool added_mdi_engine_fix = false; - if (ifix < 0) { - modify->add_fix("MDI_ENGINE_INTERNAL all mdi/engine"); + auto fixes = modify->get_fix_by_style("mdi/engine"); + if (fixes.size() == 0) { added_mdi_engine_fix = true; - } - - // identify the mdi_engine fix - - ifix = modify->find_fix_by_style("mdi/engine"); - mdi_fix = static_cast(modify->fix[ifix]); + mdi_fix = (FixMDIEngine *) modify->add_fix("MDI_ENGINE_INTERNAL all mdi/engine"); + } else + mdi_fix = (FixMDIEngine *) fixes.front(); // check that LAMMPS is setup as a compatible MDI engine @@ -224,7 +220,7 @@ void MDIEngine::command(int narg, char ** /*arg*/) error->all(FLERR, "MDI node exited with invalid command: {}", command); } - // remove mdi/engine fix that mdi/engine instantiated + // remove mdi/engine fix if instantiated here by mdi/engine if (added_mdi_engine_fix) modify->delete_fix("MDI_ENGINE_INTERNAL"); }