Automatically add mdiengine fix

This commit is contained in:
taylor-a-barnes
2021-04-26 12:18:57 -04:00
parent 738fdc2901
commit e465205c05

View File

@ -175,9 +175,16 @@ void CommandMDIEngine::command(int narg, char **arg)
MDI_Register_Command("@COORDS", "@PRE-FORCES");
MDI_Register_Command("@COORDS", "EXIT");
// 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("_mdiengine_ all mdi/engine");
added_mdi_engine_fix = true;
}
// identify the mdi_engine fix
int ifix = modify->find_fix_by_style("mdi/engine");
ifix = modify->find_fix_by_style("mdi/engine");
if (ifix < 0) error->all(FLERR,"The mdi_engine command requires the mdi/engine fix");
mdi_fix = static_cast<FixMDIEngine*>(modify->fix[ifix]);
@ -222,6 +229,9 @@ void CommandMDIEngine::command(int narg, char **arg)
}
}
// remove the mdi/engine fix
if (added_mdi_engine_fix) modify->delete_fix("_mdiengine_");
return;
}