update deallocate, suffix flags

This commit is contained in:
Megan J. McCarthy
2024-06-27 22:36:15 -06:00
parent 0de8192a9b
commit 9fef3b68e0
6 changed files with 64 additions and 61 deletions

View File

@ -48,14 +48,7 @@ ImproperHybrid::~ImproperHybrid()
delete[] keywords;
}
if (allocated) {
memory->destroy(setflag);
memory->destroy(map);
delete[] nimproperlist;
delete[] maximproper;
for (int i = 0; i < nstyles; i++) memory->destroy(improperlist[i]);
delete[] improperlist;
}
deallocate();
}
/* ---------------------------------------------------------------------- */
@ -172,6 +165,22 @@ void ImproperHybrid::allocate()
for (int m = 0; m < nstyles; m++) improperlist[m] = nullptr;
}
/* ---------------------------------------------------------------------- */
void ImproperHybrid::deallocate()
{
if (!allocated) return;
allocated = 0;
memory->destroy(setflag);
memory->destroy(map);
delete[] nimproperlist;
delete[] maximproper;
for (int i = 0; i < nstyles; i++) memory->destroy(improperlist[i]);
delete[] improperlist;
}
/* ----------------------------------------------------------------------
create one improper style for each arg in list
------------------------------------------------------------------------- */
@ -191,15 +200,7 @@ void ImproperHybrid::settings(int narg, char **arg)
delete[] keywords;
}
if (allocated) {
memory->destroy(setflag);
memory->destroy(map);
delete[] nimproperlist;
delete[] maximproper;
for (i = 0; i < nstyles; i++) memory->destroy(improperlist[i]);
delete[] improperlist;
}
allocated = 0;
deallocate();
// allocate list of sub-styles
@ -357,7 +358,7 @@ void ImproperHybrid::read_restart(FILE *fp)
keywords[m] = new char[n];
if (me == 0) utils::sfread(FLERR, keywords[m], sizeof(char), n, fp, nullptr, error);
MPI_Bcast(keywords[m], n, MPI_CHAR, 0, world);
styles[m] = force->new_improper(keywords[m], 0, dummy);
styles[m] = force->new_improper(keywords[m], 1, dummy);
styles[m]->read_restart_settings(fp);
}
}