git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10011 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2013-06-04 15:10:14 +00:00
parent 7f18289ee3
commit c886f137b0
4 changed files with 56 additions and 36 deletions

View File

@ -79,6 +79,24 @@ MSM::MSM(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg)
cg_all = cg_peratom_all = NULL;
cg = cg_peratom = NULL;
ngrid = NULL;
cg = NULL;
cg_peratom = NULL;
procneigh_levels = NULL;
world_levels = NULL;
active_flag = NULL;
alpha = betax = betay = betaz = NULL;
nx_msm = ny_msm = nz_msm = NULL;
nxlo_in = nylo_in = nzlo_in = NULL;
nxhi_in = nyhi_in = nzhi_in = NULL;
nxlo_out = nylo_out = nzlo_out = NULL;
nxhi_out = nyhi_out = nzhi_out = NULL;
delxinv = delyinv = delzinv = NULL;
qgrid = NULL;
egrid = NULL;
v0grid = v1grid = v2grid = v3grid = v4grid = v5grid = NULL;
levels = 0;
peratom_allocate_flag = 0;
@ -94,7 +112,7 @@ MSM::~MSM()
{
delete [] factors;
deallocate();
deallocate_peratom();
if (peratom_allocate_flag) deallocate_peratom();
memory->destroy(part2grid);
memory->destroy(g_direct);
memory->destroy(g_direct_top);
@ -466,7 +484,6 @@ void MSM::setup()
// don't invoke allocate_peratom(), compute() will allocate when needed
allocate();
peratom_allocate_flag = 0;
// setup commgrid
@ -505,7 +522,6 @@ void MSM::compute(int eflag, int vflag)
cg_peratom[n]->ghost_notify();
cg_peratom[n]->setup();
}
peratom_allocate_flag = 1;
}
// convert atoms from box to lamda coords
@ -696,12 +712,41 @@ void MSM::allocate()
}
}
/* ----------------------------------------------------------------------
deallocate memory that depends on # of grid points
------------------------------------------------------------------------- */
void MSM::deallocate()
{
memory->destroy2d_offset(phi1d,-order);
memory->destroy2d_offset(dphi1d,-order);
if (cg_all) delete cg_all;
for (int n=0; n<levels; n++) {
if (qgrid[n])
memory->destroy3d_offset(qgrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]);
if (egrid[n])
memory->destroy3d_offset(egrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]);
if (world_levels)
if (world_levels[n] != MPI_COMM_NULL)
MPI_Comm_free(&world_levels[n]);
if (cg)
if (cg[n]) delete cg[n];
}
}
/* ----------------------------------------------------------------------
allocate per-atom virial memory that depends on # of grid points
------------------------------------------------------------------------- */
void MSM::allocate_peratom()
{
peratom_allocate_flag = 1;
// create commgrid object for per-atom virial using all processors
int (*procneigh_all)[2] = comm->procneigh;
@ -744,39 +789,14 @@ void MSM::allocate_peratom()
}
}
/* ----------------------------------------------------------------------
deallocate memory that depends on # of grid points
------------------------------------------------------------------------- */
void MSM::deallocate()
{
memory->destroy2d_offset(phi1d,-order);
memory->destroy2d_offset(dphi1d,-order);
if (cg_all) delete cg_all;
for (int n=0; n<levels; n++) {
if (qgrid[n])
memory->destroy3d_offset(qgrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]);
if (egrid[n])
memory->destroy3d_offset(egrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]);
if (world_levels)
if (world_levels[n] != MPI_COMM_NULL)
MPI_Comm_free(&world_levels[n]);
if (cg)
if (cg[n]) delete cg[n];
}
}
/* ----------------------------------------------------------------------
deallocate per-atom virial memory that depends on # of grid points
------------------------------------------------------------------------- */
void MSM::deallocate_peratom()
{
peratom_allocate_flag = 0;
if (cg_peratom_all) delete cg_peratom_all;
for (int n=0; n<levels; n++) {
@ -1074,6 +1094,7 @@ void MSM::set_grid_global()
if (!domain->nonperiodic) levels -= 1;
deallocate_levels();
allocate_levels();
// find number of grid levels in each direction

View File

@ -89,7 +89,6 @@ void PPPMCG::compute(int eflag, int vflag)
allocate_peratom();
cg_peratom->ghost_notify();
cg_peratom->setup();
peratom_allocate_flag = 1;
}
// convert atoms from box to lamda coords

View File

@ -187,7 +187,7 @@ PPPMDisp::~PPPMDisp()
delete [] csumi;
csumi = NULL;
deallocate();
deallocate_peratom();
if (peratom_allocate_flag) deallocate_peratom();
memory->destroy(part2grid);
memory->destroy(part2grid_6);
part2grid = part2grid_6 = NULL;
@ -223,9 +223,9 @@ void PPPMDisp::init()
}
// free all arrays previously allocated
deallocate();
deallocate_peratom();
peratom_allocate_flag = 0;
if (peratom_allocate_flag) deallocate_peratom();
// set scale
@ -775,8 +775,7 @@ void PPPMDisp::setup_grid()
// free all arrays previously allocated
deallocate();
deallocate_peratom();
peratom_allocate_flag = 0;
if (peratom_allocate_flag) deallocate_peratom();
// reset portion of global grid that each proc owns

View File

@ -89,6 +89,7 @@ Domain::Domain(LAMMPS *lmp) : Pointers(lmp)
args[0] = (char *) "none";
args[1] = (char *) "1.0";
set_lattice(2,args);
delete [] args;
nregion = maxregion = 0;
regions = NULL;