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

This commit is contained in:
sjplimp 2013-06-04 14:41:29 +00:00
parent d56c38d62d
commit a6e871f0a5
1 changed files with 64 additions and 60 deletions

View File

@ -109,6 +109,9 @@ PPPM::PPPM(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg)
nmax = 0;
part2grid = NULL;
peratom_allocate_flag = 0;
group_allocate_flag = 0;
// define acons coefficients for estimation of kspace errors
// see JCP 109, pg 7698 for derivation of coefficients
// higher order coefficients may be computed if needed
@ -152,8 +155,8 @@ PPPM::~PPPM()
{
delete [] factors;
deallocate();
deallocate_peratom();
deallocate_groups();
if (peratom_allocate_flag) deallocate_peratom();
if (group_allocate_flag) deallocate_groups();
memory->destroy(part2grid);
memory->destroy(acons);
}
@ -275,10 +278,8 @@ void PPPM::init()
// free all arrays previously allocated
deallocate();
deallocate_peratom();
peratom_allocate_flag = 0;
deallocate_groups();
group_allocate_flag = 0;
if (peratom_allocate_flag) deallocate_peratom();
if (group_allocate_flag) deallocate_groups();
// setup FFT grid resolution and g_ewald
// normally one iteration thru while loop is all that is required
@ -368,7 +369,7 @@ void PPPM::init()
}
// allocate K-space dependent memory
// don't invoke allocate_peratom(), compute() will allocate when needed
// don't invoke allocate peratom() or group(), will be allocated when needed
allocate();
cg->ghost_notify();
@ -563,10 +564,8 @@ void PPPM::setup_grid()
// free all arrays previously allocated
deallocate();
deallocate_peratom();
peratom_allocate_flag = 0;
deallocate_groups();
group_allocate_flag = 0;
if (peratom_allocate_flag) deallocate_peratom();
if (group_allocate_flag) deallocate_groups();
// reset portion of global grid that each proc owns
@ -574,7 +573,7 @@ void PPPM::setup_grid()
// reallocate K-space dependent memory
// check if grid communication is now overlapping if not allowed
// don't invoke allocate_peratom(), compute() will allocate when needed
// don't invoke allocate peratom() or group(), will be allocated when needed
allocate();
@ -615,7 +614,6 @@ void PPPM::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
@ -825,49 +823,6 @@ void PPPM::allocate()
procneigh[1][1],procneigh[2][0],procneigh[2][1]);
}
/* ----------------------------------------------------------------------
allocate per-atom memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */
void PPPM::allocate_peratom()
{
if (differentiation_flag != 1)
memory->create3d_offset(u_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:u_brick");
memory->create3d_offset(v0_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v0_brick");
memory->create3d_offset(v1_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v1_brick");
memory->create3d_offset(v2_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v2_brick");
memory->create3d_offset(v3_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v3_brick");
memory->create3d_offset(v4_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v4_brick");
memory->create3d_offset(v5_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v5_brick");
// create ghost grid object for rho and electric field communication
int (*procneigh)[2] = comm->procneigh;
if (differentiation_flag == 1)
cg_peratom =
new CommGrid(lmp,world,6,1,
nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out,
procneigh[0][0],procneigh[0][1],procneigh[1][0],
procneigh[1][1],procneigh[2][0],procneigh[2][1]);
else
cg_peratom =
new CommGrid(lmp,world,7,1,
nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out,
procneigh[0][0],procneigh[0][1],procneigh[1][0],
procneigh[1][1],procneigh[2][0],procneigh[2][1]);
}
/* ----------------------------------------------------------------------
deallocate memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */
@ -918,12 +873,60 @@ void PPPM::deallocate()
delete cg;
}
/* ----------------------------------------------------------------------
allocate per-atom memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */
void PPPM::allocate_peratom()
{
peratom_allocate_flag = 1;
if (differentiation_flag != 1)
memory->create3d_offset(u_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:u_brick");
memory->create3d_offset(v0_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v0_brick");
memory->create3d_offset(v1_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v1_brick");
memory->create3d_offset(v2_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v2_brick");
memory->create3d_offset(v3_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v3_brick");
memory->create3d_offset(v4_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v4_brick");
memory->create3d_offset(v5_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:v5_brick");
// create ghost grid object for rho and electric field communication
int (*procneigh)[2] = comm->procneigh;
if (differentiation_flag == 1)
cg_peratom =
new CommGrid(lmp,world,6,1,
nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out,
procneigh[0][0],procneigh[0][1],procneigh[1][0],
procneigh[1][1],procneigh[2][0],procneigh[2][1]);
else
cg_peratom =
new CommGrid(lmp,world,7,1,
nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out,
procneigh[0][0],procneigh[0][1],procneigh[1][0],
procneigh[1][1],procneigh[2][0],procneigh[2][1]);
}
/* ----------------------------------------------------------------------
deallocate per-atom memory that depends on # of K-vectors and order
------------------------------------------------------------------------- */
void PPPM::deallocate_peratom()
{
peratom_allocate_flag = 0;
memory->destroy3d_offset(v0_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(v1_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(v2_brick,nzlo_out,nylo_out,nxlo_out);
@ -3049,10 +3052,7 @@ void PPPM::compute_group_group(int groupbit_A, int groupbit_B, int BA_flag)
error->all(FLERR,"Cannot (yet) use 'kspace_modify "
"diff ad' with compute group/group");
if (!group_allocate_flag) {
allocate_groups();
group_allocate_flag = 1;
}
if (!group_allocate_flag) allocate_groups();
// convert atoms from box to lamda coords
@ -3137,6 +3137,8 @@ void PPPM::compute_group_group(int groupbit_A, int groupbit_B, int BA_flag)
void PPPM::allocate_groups()
{
group_allocate_flag = 1;
memory->create3d_offset(density_A_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:density_A_brick");
memory->create3d_offset(density_B_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
@ -3151,6 +3153,8 @@ void PPPM::allocate_groups()
void PPPM::deallocate_groups()
{
group_allocate_flag = 0;
memory->destroy3d_offset(density_A_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(density_B_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy(density_A_fft);