modernize calls to access the list of fixes in the Modify class

This commit is contained in:
Axel Kohlmeyer
2022-10-22 08:20:16 -04:00
parent 43e3dc7a9e
commit 01a0cb35a3

View File

@ -658,15 +658,15 @@ FixBondReact::~FixBondReact()
memory->destroy(global_mega_glove); memory->destroy(global_mega_glove);
if (stabilization_flag == 1) { if (stabilization_flag == 1) {
// check nfix in case all fixes have already been deleted // delete fixes if not already deleted
if (id_fix1 && modify->nfix) modify->delete_fix(id_fix1); if (id_fix1 && modify->get_fix_by_id(id_fix1)) modify->delete_fix(id_fix1);
delete[] id_fix1; delete[] id_fix1;
if (id_fix3 && modify->nfix) modify->delete_fix(id_fix3); if (id_fix3 && modify->get_fix_by_id(id_fix3)) modify->delete_fix(id_fix3);
delete[] id_fix3; delete[] id_fix3;
} }
if (id_fix2 && modify->nfix) modify->delete_fix(id_fix2); if (id_fix2 && modify->get_fix_by_id(id_fix2)) modify->delete_fix(id_fix2);
delete[] id_fix2; delete[] id_fix2;
delete[] statted_id; delete[] statted_id;
@ -704,8 +704,9 @@ void FixBondReact::post_constructor()
{ {
// let's add the limit_tags per-atom property fix // let's add the limit_tags per-atom property fix
id_fix2 = utils::strdup("bond_react_props_internal"); id_fix2 = utils::strdup("bond_react_props_internal");
if (modify->find_fix(id_fix2) < 0) if (!modify->get_fix_by_id(id_fix2))
modify->add_fix(std::string(id_fix2)+" all property/atom i_limit_tags i_react_tags ghost yes"); fix2 = modify->add_fix(std::string(id_fix2) +
" all property/atom i_limit_tags i_react_tags ghost yes");
// create master_group if not already existing // create master_group if not already existing
// NOTE: limit_tags and react_tags automaticaly intitialized to zero (unless read from restart) // NOTE: limit_tags and react_tags automaticaly intitialized to zero (unless read from restart)
@ -720,8 +721,9 @@ void FixBondReact::post_constructor()
// create stabilization per-atom property // create stabilization per-atom property
id_fix3 = utils::strdup("bond_react_stabilization_internal"); id_fix3 = utils::strdup("bond_react_stabilization_internal");
if (modify->find_fix(id_fix3) < 0) if (!modify->get_fix_by_id(id_fix3))
fix3 = modify->add_fix(std::string(id_fix3) + " all property/atom i_statted_tags ghost yes"); fix3 = modify->add_fix(std::string(id_fix3) +
" all property/atom i_statted_tags ghost yes");
statted_id = utils::strdup("statted_tags"); statted_id = utils::strdup("statted_tags");
@ -755,8 +757,7 @@ void FixBondReact::post_constructor()
// sleeping code, for future capabilities // sleeping code, for future capabilities
custom_exclude_flag = 1; custom_exclude_flag = 1;
// first we have to find correct fix group reference // first we have to find correct fix group reference
int ifix = modify->find_fix(std::string("GROUP_")+exclude_group); Fix *fix = modify->get_fix_by_id(std::string("GROUP_")+exclude_group);
Fix *fix = modify->fix[ifix];
// this returns names of corresponding property // this returns names of corresponding property
int unused; int unused;
@ -775,10 +776,9 @@ void FixBondReact::post_constructor()
// i_statted_tags[i] = 1; // i_statted_tags[i] = 1;
} }
// let's create a new nve/limit fix to limit newly reacted atoms // let's create a new nve/limit fix to limit newly reacted atoms
id_fix1 = utils::strdup("bond_react_MASTER_nve_limit"); id_fix1 = utils::strdup("bond_react_MASTER_nve_limit");
if (modify->find_fix(id_fix1) < 0) if (!modify->get_fix_by_id(id_fix1))
fix1 = modify->add_fix(fmt::format("{} {} nve/limit {}", fix1 = modify->add_fix(fmt::format("{} {} nve/limit {}",
id_fix1,master_group,nve_limit_xmax)); id_fix1,master_group,nve_limit_xmax));
} }