update deallocate, suffix flags
This commit is contained in:
@ -48,14 +48,7 @@ AngleHybrid::~AngleHybrid()
|
||||
delete[] keywords;
|
||||
}
|
||||
|
||||
if (allocated) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(map);
|
||||
delete[] nanglelist;
|
||||
delete[] maxangle;
|
||||
for (int i = 0; i < nstyles; i++) memory->destroy(anglelist[i]);
|
||||
delete[] anglelist;
|
||||
}
|
||||
deallocate();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -171,6 +164,22 @@ void AngleHybrid::allocate()
|
||||
for (int m = 0; m < nstyles; m++) anglelist[m] = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AngleHybrid::deallocate()
|
||||
{
|
||||
if (!allocated) return;
|
||||
|
||||
allocated = 0;
|
||||
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(map);
|
||||
delete[] nanglelist;
|
||||
delete[] maxangle;
|
||||
for (int i = 0; i < nstyles; i++) memory->destroy(anglelist[i]);
|
||||
delete[] anglelist;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one angle style for each arg in list
|
||||
------------------------------------------------------------------------- */
|
||||
@ -190,15 +199,7 @@ void AngleHybrid::settings(int narg, char **arg)
|
||||
delete[] keywords;
|
||||
}
|
||||
|
||||
if (allocated) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(map);
|
||||
delete[] nanglelist;
|
||||
delete[] maxangle;
|
||||
for (i = 0; i < nstyles; i++) memory->destroy(anglelist[i]);
|
||||
delete[] anglelist;
|
||||
}
|
||||
allocated = 0;
|
||||
deallocate();
|
||||
|
||||
// allocate list of sub-styles
|
||||
|
||||
@ -367,7 +368,7 @@ void AngleHybrid::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_angle(keywords[m], 0, dummy);
|
||||
styles[m] = force->new_angle(keywords[m], 1, dummy);
|
||||
styles[m]->read_restart_settings(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,14 +42,14 @@ class AngleHybrid : public Angle {
|
||||
double single(int, int, int, int) override;
|
||||
double memory_usage() override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
int *map; // which style each angle type points to
|
||||
|
||||
int *nanglelist; // # of angles in sub-style anglelists
|
||||
int *maxangle; // max # of angles sub-style lists can store
|
||||
int ***anglelist; // anglelist for each sub-style
|
||||
|
||||
void allocate();
|
||||
virtual void allocate();
|
||||
virtual void deallocate();
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -48,14 +48,7 @@ DihedralHybrid::~DihedralHybrid()
|
||||
delete[] keywords;
|
||||
}
|
||||
|
||||
if (allocated) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(map);
|
||||
delete[] ndihedrallist;
|
||||
delete[] maxdihedral;
|
||||
for (int i = 0; i < nstyles; i++) memory->destroy(dihedrallist[i]);
|
||||
delete[] dihedrallist;
|
||||
}
|
||||
deallocate();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -172,6 +165,20 @@ void DihedralHybrid::allocate()
|
||||
for (int m = 0; m < nstyles; m++) dihedrallist[m] = nullptr;
|
||||
}
|
||||
|
||||
void DihedralHybrid::deallocate()
|
||||
{
|
||||
if (!allocated) return;
|
||||
|
||||
allocated = 0;
|
||||
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(map);
|
||||
delete[] ndihedrallist;
|
||||
delete[] maxdihedral;
|
||||
for (int i = 0; i < nstyles; i++) memory->destroy(dihedrallist[i]);
|
||||
delete[] dihedrallist;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one dihedral style for each arg in list
|
||||
------------------------------------------------------------------------- */
|
||||
@ -191,15 +198,7 @@ void DihedralHybrid::settings(int narg, char **arg)
|
||||
delete[] keywords;
|
||||
}
|
||||
|
||||
if (allocated) {
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(map);
|
||||
delete[] ndihedrallist;
|
||||
delete[] maxdihedral;
|
||||
for (i = 0; i < nstyles; i++) memory->destroy(dihedrallist[i]);
|
||||
delete[] dihedrallist;
|
||||
}
|
||||
allocated = 0;
|
||||
deallocate();
|
||||
|
||||
// allocate list of sub-styles
|
||||
|
||||
@ -365,7 +364,7 @@ void DihedralHybrid::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_dihedral(keywords[m], 0, dummy);
|
||||
styles[m] = force->new_dihedral(keywords[m], 1, dummy);
|
||||
styles[m]->read_restart_settings(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,14 +40,15 @@ class DihedralHybrid : public Dihedral {
|
||||
void read_restart(FILE *) override;
|
||||
double memory_usage() override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
int *map; // which style each dihedral type points to
|
||||
|
||||
int *ndihedrallist; // # of dihedrals in sub-style dihedrallists
|
||||
int *maxdihedral; // max # of dihedrals sub-style lists can store
|
||||
int ***dihedrallist; // dihedrallist for each sub-style
|
||||
|
||||
void allocate();
|
||||
virtual void allocate();
|
||||
virtual void deallocate();
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,14 +40,15 @@ class ImproperHybrid : public Improper {
|
||||
void read_restart(FILE *) override;
|
||||
double memory_usage() override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
int *map; // which style each improper type points to
|
||||
|
||||
int *nimproperlist; // # of impropers in sub-style improperlists
|
||||
int *maximproper; // max # of impropers sub-style lists can store
|
||||
int ***improperlist; // improperlist for each sub-style
|
||||
|
||||
void allocate();
|
||||
virtual void allocate();
|
||||
virtual void deallocate();
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
Reference in New Issue
Block a user