add unique identifier to the history fix so the gran/*/history styles can be used multiple times with pair style hybrid

This commit is contained in:
Axel Kohlmeyer
2021-08-06 15:34:43 -04:00
parent e9e6cdca1d
commit 03f9ef7de9

View File

@ -68,7 +68,7 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp)
// this is so final order of Modify:fix will conform to input script // this is so final order of Modify:fix will conform to input script
fix_history = nullptr; fix_history = nullptr;
modify->add_fix("NEIGH_HISTORY_HH_DUMMY all DUMMY"); modify->add_fix("NEIGH_HISTORY_HH_DUMMY"+std::to_string(instance_me)+" all DUMMY");
fix_dummy = (FixDummy *) modify->fix[modify->nfix-1]; fix_dummy = (FixDummy *) modify->fix[modify->nfix-1];
} }
@ -80,8 +80,8 @@ PairGranHookeHistory::~PairGranHookeHistory()
delete [] svector; delete [] svector;
if (!fix_history) modify->delete_fix("NEIGH_HISTORY_HH_DUMMY"); if (!fix_history) modify->delete_fix("NEIGH_HISTORY_HH_DUMMY"+std::to_string(instance_me));
else modify->delete_fix("NEIGH_HISTORY_HH"); else modify->delete_fix("NEIGH_HISTORY_HH"+std::to_string(instance_me));
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
@ -436,10 +436,9 @@ void PairGranHookeHistory::init_style()
// this is so its order in the fix list is preserved // this is so its order in the fix list is preserved
if (history && (fix_history == nullptr)) { if (history && (fix_history == nullptr)) {
auto cmd = fmt::format("NEIGH_HISTORY_HH all NEIGH_HISTORY {}", auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history);
size_history); modify->replace_fix("NEIGH_HISTORY_HH_DUMMY"+std::to_string(instance_me),cmd,1);
modify->replace_fix("NEIGH_HISTORY_HH_DUMMY",cmd,1); int ifix = modify->find_fix("NEIGH_HISTORY_HH"+std::to_string(instance_me));
int ifix = modify->find_fix("NEIGH_HISTORY_HH");
fix_history = (FixNeighHistory *) modify->fix[ifix]; fix_history = (FixNeighHistory *) modify->fix[ifix];
fix_history->pair = this; fix_history->pair = this;
} }
@ -507,7 +506,7 @@ void PairGranHookeHistory::init_style()
// set fix which stores history info // set fix which stores history info
if (history) { if (history) {
int ifix = modify->find_fix("NEIGH_HISTORY_HH"); int ifix = modify->find_fix("NEIGH_HISTORY_HH"+std::to_string(instance_me));
if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID"); if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID");
fix_history = (FixNeighHistory *) modify->fix[ifix]; fix_history = (FixNeighHistory *) modify->fix[ifix];
} }