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

This commit is contained in:
sjplimp 2011-03-25 19:40:12 +00:00
parent 1511c8b10b
commit 50b8413fe7
19 changed files with 118 additions and 388 deletions

View File

@ -66,8 +66,8 @@ Ewald::~Ewald()
{
deallocate();
memory->destroy_2d_double_array(ek);
memory->destroy_3d_double_array(cs,-kmax_created);
memory->destroy_3d_double_array(sn,-kmax_created);
memory->destroy3d_offset(cs,-kmax_created);
memory->destroy3d_offset(sn,-kmax_created);
}
/* ---------------------------------------------------------------------- */
@ -192,12 +192,12 @@ void Ewald::setup()
allocate();
memory->destroy_2d_double_array(ek);
memory->destroy_3d_double_array(cs,-kmax_created);
memory->destroy_3d_double_array(sn,-kmax_created);
memory->destroy3d_offset(cs,-kmax_created);
memory->destroy3d_offset(sn,-kmax_created);
nmax = atom->nmax;
ek = memory->create_2d_double_array(nmax,3,"ewald:ek");
cs = memory->create_3d_double_array(-kmax,kmax,3,nmax,"ewald:cs");
sn = memory->create_3d_double_array(-kmax,kmax,3,nmax,"ewald:sn");
memory->create3d_offset(cs,-kmax,kmax,3,nmax,"ewald:cs");
memory->create3d_offset(sn,-kmax,kmax,3,nmax,"ewald:sn");
kmax_created = kmax;
}
@ -221,12 +221,12 @@ void Ewald::compute(int eflag, int vflag)
if (atom->nlocal > nmax) {
memory->destroy_2d_double_array(ek);
memory->destroy_3d_double_array(cs,-kmax_created);
memory->destroy_3d_double_array(sn,-kmax_created);
memory->destroy3d_offset(cs,-kmax_created);
memory->destroy3d_offset(sn,-kmax_created);
nmax = atom->nmax;
ek = memory->create_2d_double_array(nmax,3,"ewald:ek");
cs = memory->create_3d_double_array(-kmax,kmax,3,nmax,"ewald:cs");
sn = memory->create_3d_double_array(-kmax,kmax,3,nmax,"ewald:sn");
memory->create3d_offset(cs,-kmax,kmax,3,nmax,"ewald:cs");
memory->create3d_offset(sn,-kmax,kmax,3,nmax,"ewald:sn");
kmax_created = kmax;
}

View File

@ -730,18 +730,14 @@ void PPPM::compute(int eflag, int vflag)
void PPPM::allocate()
{
density_brick =
memory->create_3d_double_array(nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:density_brick");
vdx_brick =
memory->create_3d_double_array(nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:vdx_brick");
vdy_brick =
memory->create_3d_double_array(nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:vdy_brick");
vdz_brick =
memory->create_3d_double_array(nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:vdz_brick");
memory->create3d_offset(density_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:density_brick");
memory->create3d_offset(vdx_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:vdx_brick");
memory->create3d_offset(vdy_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:vdy_brick");
memory->create3d_offset(vdz_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out,
nxlo_out,nxhi_out,"pppm:vdz_brick");
density_fft =
(double *) memory->smalloc(nfft_both*sizeof(double),"pppm:density_fft");
@ -751,9 +747,9 @@ void PPPM::allocate()
work2 = (double *) memory->smalloc(2*nfft_both*sizeof(double),"pppm:work2");
vg = memory->create_2d_double_array(nfft_both,6,"pppm:vg");
fkx = memory->create_1d_double_array(nxlo_fft,nxhi_fft,"pppm:fkx");
fky = memory->create_1d_double_array(nylo_fft,nyhi_fft,"pppm:fky");
fkz = memory->create_1d_double_array(nzlo_fft,nzhi_fft,"pppm:fkz");
memory->create1d_offset(fkx,nxlo_fft,nxhi_fft,"pppm:fkx");
memory->create1d_offset(fky,nylo_fft,nyhi_fft,"pppm:fky");
memory->create1d_offset(fkz,nzlo_fft,nzhi_fft,"pppm:fkz");
buf1 = (double *) memory->smalloc(nbuf*sizeof(double),"pppm:buf1");
buf2 = (double *) memory->smalloc(nbuf*sizeof(double),"pppm:buf2");
@ -794,10 +790,10 @@ void PPPM::allocate()
void PPPM::deallocate()
{
memory->destroy_3d_double_array(density_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy_3d_double_array(vdx_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy_3d_double_array(vdy_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy_3d_double_array(vdz_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(density_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(vdx_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(vdy_brick,nzlo_out,nylo_out,nxlo_out);
memory->destroy3d_offset(vdz_brick,nzlo_out,nylo_out,nxlo_out);
memory->sfree(density_fft);
memory->sfree(greensfn);
@ -805,9 +801,9 @@ void PPPM::deallocate()
memory->sfree(work2);
memory->destroy_2d_double_array(vg);
memory->destroy_1d_double_array(fkx,nxlo_fft);
memory->destroy_1d_double_array(fky,nylo_fft);
memory->destroy_1d_double_array(fkz,nzlo_fft);
memory->destroy1d_offset(fkx,nxlo_fft);
memory->destroy1d_offset(fky,nylo_fft);
memory->destroy1d_offset(fkz,nzlo_fft);
memory->sfree(buf1);
memory->sfree(buf2);

View File

@ -86,7 +86,7 @@ PairComb::~PairComb()
for (int i = 0; i < nelements; i++) delete [] elements[i];
delete [] elements;
memory->sfree(params);
memory->destroy_3d_int_array(elem2param);
memory->destroy(elem2param);
memory->destroy_2d_int_array(intype);
memory->destroy_2d_double_array(fafb);
@ -741,9 +741,8 @@ void PairComb::setup()
// must be a single exact match to lines read from file
// do not allow for ACB in place of ABC
if (elem2param) memory->destroy_3d_int_array(elem2param);
elem2param = memory->create_3d_int_array(nelements,nelements,nelements,
"pair:elem2param");
memory->destroy(elem2param);
memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param");
for (i = 0; i < nelements; i++)
for (j = 0; j < nelements; j++)

View File

@ -97,7 +97,7 @@ PairEAM::~PairEAM()
delete [] setfl->mass;
memory->destroy_2d_double_array(setfl->frho);
memory->destroy_2d_double_array(setfl->rhor);
memory->destroy_3d_double_array(setfl->z2r);
memory->destroy(setfl->z2r);
delete setfl;
}
@ -106,8 +106,8 @@ PairEAM::~PairEAM()
delete [] fs->elements;
delete [] fs->mass;
memory->destroy_2d_double_array(fs->frho);
memory->destroy_3d_double_array(fs->rhor);
memory->destroy_3d_double_array(fs->z2r);
memory->destroy(fs->rhor);
memory->destroy(fs->z2r);
delete fs;
}
@ -115,9 +115,9 @@ PairEAM::~PairEAM()
memory->destroy_2d_double_array(rhor);
memory->destroy_2d_double_array(z2r);
memory->destroy_3d_double_array(frho_spline);
memory->destroy_3d_double_array(rhor_spline);
memory->destroy_3d_double_array(z2r_spline);
memory->destroy(frho_spline);
memory->destroy(rhor_spline);
memory->destroy(z2r_spline);
}
/* ---------------------------------------------------------------------- */
@ -699,13 +699,13 @@ void PairEAM::array2spline()
rdr = 1.0/dr;
rdrho = 1.0/drho;
memory->destroy_3d_double_array(frho_spline);
memory->destroy_3d_double_array(rhor_spline);
memory->destroy_3d_double_array(z2r_spline);
memory->destroy(frho_spline);
memory->destroy(rhor_spline);
memory->destroy(z2r_spline);
frho_spline = memory->create_3d_double_array(nfrho,nrho+1,7,"pair:frho");
rhor_spline = memory->create_3d_double_array(nrhor,nr+1,7,"pair:rhor");
z2r_spline = memory->create_3d_double_array(nz2r,nr+1,7,"pair:z2r");
memory->create(frho_spline,nfrho,nrho+1,7,"pair:frho");
memory->create(rhor_spline,nrhor,nr+1,7,"pair:rhor");
memory->create(z2r_spline,nz2r,nr+1,7,"pair:z2r");
for (int i = 0; i < nfrho; i++)
interpolate(nrho,drho,frho[i],frho_spline[i]);

View File

@ -62,7 +62,7 @@ void PairEAMAlloy::coeff(int narg, char **arg)
delete [] setfl->mass;
memory->destroy_2d_double_array(setfl->frho);
memory->destroy_2d_double_array(setfl->rhor);
memory->destroy_3d_double_array(setfl->z2r);
memory->destroy(setfl->z2r);
delete setfl;
}
setfl = new Setfl();
@ -178,8 +178,9 @@ void PairEAMAlloy::read_file(char *filename)
"pair:frho");
file->rhor = memory->create_2d_double_array(file->nelements,file->nr+1,
"pair:rhor");
file->z2r = memory->create_3d_double_array(file->nelements,file->nelements,
file->nr+1,"pair:z2r");
memory->create(file->z2r,file->nelements,file->nelements,
file->nr+1,"pair:z2r");
int i,j,tmp;
for (i = 0; i < file->nelements; i++) {
if (me == 0) {

View File

@ -61,8 +61,8 @@ void PairEAMFS::coeff(int narg, char **arg)
delete [] fs->elements;
delete [] fs->mass;
memory->destroy_2d_double_array(fs->frho);
memory->destroy_3d_double_array(fs->rhor);
memory->destroy_3d_double_array(fs->z2r);
memory->destroy(fs->rhor);
memory->destroy(fs->z2r);
delete fs;
}
fs = new Fs();
@ -176,10 +176,11 @@ void PairEAMFS::read_file(char *filename)
file->mass = new double[file->nelements];
file->frho = memory->create_2d_double_array(file->nelements,file->nrho+1,
"pair:frho");
file->rhor = memory->create_3d_double_array(file->nelements,file->nelements,
file->nr+1,"pair:rhor");
file->z2r = memory->create_3d_double_array(file->nelements,file->nelements,
file->nr+1,"pair:z2r");
memory->create(file->rhor,file->nelements,file->nelements,
file->nr+1,"pair:rhor");
memory->create(file->z2r,file->nelements,file->nelements,
file->nr+1,"pair:z2r");
int i,j,tmp;
for (i = 0; i < file->nelements; i++) {
if (me == 0) {

View File

@ -97,9 +97,9 @@ PairEIM::~PairEIM()
memory->destroy_2d_double_array(Gij);
memory->destroy_2d_double_array(phiij);
memory->destroy_3d_double_array(Fij_spline);
memory->destroy_3d_double_array(Gij_spline);
memory->destroy_3d_double_array(phiij_spline);
memory->destroy(Fij_spline);
memory->destroy(Gij_spline);
memory->destroy(phiij_spline);
}
/* ---------------------------------------------------------------------- */
@ -566,12 +566,10 @@ void PairEIM::read_file(char *filename)
}
}
setfl->Fij = memory->create_3d_double_array(nelements,nelements,
setfl->nr+1,"pair:Fij");
setfl->Gij = memory->create_3d_double_array(nelements,nelements,
setfl->nr+1,"pair:Gij");
setfl->phiij = memory->create_3d_double_array(nelements,nelements,
setfl->nr+1,"pair:phiij");
memory->create(setfl->Fij,nelements,nelements,setfl->nr+1,"pair:Fij");
memory->create(setfl->Gij,nelements,nelements,setfl->nr+1,"pair:Gij");
memory->create(setfl->phiij,nelements,nelements,setfl->nr+1,"pair:phiij");
for (int i = 0; i < nelements; i++)
for (int j = 0; j < nelements; j++) {
for (int k = 0; k < setfl->nr; k++) {
@ -638,9 +636,9 @@ void PairEIM::deallocate_setfl()
delete [] setfl->rs;
delete [] setfl->tp;
memory->destroy_2d_double_array(setfl->cuts);
memory->destroy_3d_double_array(setfl->Fij);
memory->destroy_3d_double_array(setfl->Gij);
memory->destroy_3d_double_array(setfl->phiij);
memory->destroy(setfl->Fij);
memory->destroy(setfl->Gij);
memory->destroy(setfl->phiij);
delete setfl;
}
@ -830,13 +828,13 @@ void PairEIM::array2spline()
{
rdr = 1.0/dr;
memory->destroy_3d_double_array(Fij_spline);
memory->destroy_3d_double_array(Gij_spline);
memory->destroy_3d_double_array(phiij_spline);
memory->destroy(Fij_spline);
memory->destroy(Gij_spline);
memory->destroy(phiij_spline);
Fij_spline = memory->create_3d_double_array(nFij,nr+1,7,"pair:Fij");
Gij_spline = memory->create_3d_double_array(nGij,nr+1,7,"pair:Gij");
phiij_spline = memory->create_3d_double_array(nphiij,nr+1,7,"pair:phiij");
memory->create(Fij_spline,nFij,nr+1,7,"pair:Fij");
memory->create(Gij_spline,nGij,nr+1,7,"pair:Gij");
memory->create(phiij_spline,nphiij,nr+1,7,"pair:phiij");
for (int i = 0; i < nFij; i++)
interpolate(nr,dr,Fij[i],Fij_spline[i],0.0);

View File

@ -60,7 +60,7 @@ PairSW::~PairSW()
for (int i = 0; i < nelements; i++) delete [] elements[i];
delete [] elements;
memory->sfree(params);
memory->destroy_3d_int_array(elem2param);
memory->destroy(elem2param);
if (allocated) {
memory->destroy_2d_int_array(setflag);
@ -455,9 +455,8 @@ void PairSW::setup()
// must be a single exact match to lines read from file
// do not allow for ACB in place of ABC
if (elem2param) memory->destroy_3d_int_array(elem2param);
elem2param = memory->create_3d_int_array(nelements,nelements,nelements,
"pair:elem2param");
memory->destroy(elem2param);
memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param");
for (i = 0; i < nelements; i++)
for (j = 0; j < nelements; j++)

View File

@ -62,7 +62,7 @@ PairTersoff::~PairTersoff()
for (int i = 0; i < nelements; i++) delete [] elements[i];
delete [] elements;
memory->sfree(params);
memory->destroy_3d_int_array(elem2param);
memory->destroy(elem2param);
if (allocated) {
memory->destroy_2d_int_array(setflag);
@ -506,9 +506,8 @@ void PairTersoff::setup()
// must be a single exact match to lines read from file
// do not allow for ACB in place of ABC
if (elem2param) memory->destroy_3d_int_array(elem2param);
elem2param = memory->create_3d_int_array(nelements,nelements,nelements,
"pair:elem2param");
memory->destroy(elem2param);
memory->create(elem2param,nelements,nelements,nelements,"pair:elem2param");
for (i = 0; i < nelements; i++)
for (j = 0; j < nelements; j++)

View File

@ -71,7 +71,7 @@ PairHbondDreidingLJ::~PairHbondDreidingLJ()
delete [] donor;
delete [] acceptor;
memory->destroy_3d_int_array(type2param);
memory->destroy(type2param);
}
}
@ -253,7 +253,7 @@ void PairHbondDreidingLJ::allocate()
donor = new int[n+1];
acceptor = new int[n+1];
type2param = memory->create_3d_int_array(n+1,n+1,n+1,"pair:type2param");
memory->create(type2param,n+1,n+1,n+1,"pair:type2param");
int i,j,k;
for (i = 1; i <= n; i++)

View File

@ -52,9 +52,8 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) :
size_array_cols = 1 + 2*npairs;
int ntypes = atom->ntypes;
rdfpair = memory->create_3d_int_array(npairs,ntypes+1,ntypes+1,
"rdf:rdfpair");
nrdfpair = memory->create_2d_int_array(ntypes+1,ntypes+1,"rdf:nrdfpair");
memory->create(rdfpair,npairs,ntypes+1,ntypes+1,"rdf:rdfpair");
memory->create(nrdfpair,ntypes+1,ntypes+1,"rdf:nrdfpair");
ilo = new int[npairs];
ihi = new int[npairs];
jlo = new int[npairs];
@ -100,7 +99,7 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) :
ComputeRDF::~ComputeRDF()
{
memory->destroy_3d_int_array(rdfpair);
memory->destroy(rdfpair);
memory->destroy_2d_int_array(nrdfpair);
delete [] ilo;
delete [] ihi;

View File

@ -407,7 +407,7 @@ FixAveSpatial::~FixAveSpatial()
memory->destroy_2d_double_array(values_many);
memory->destroy_2d_double_array(values_sum);
memory->destroy_2d_double_array(values_total);
memory->destroy_3d_double_array(values_list);
memory->destroy(values_list);
}
/* ---------------------------------------------------------------------- */
@ -912,9 +912,8 @@ void FixAveSpatial::setup_bins()
count_list =
memory->create_2d_double_array(nwindow,nbins,
"ave/spatial:count_list");
values_list =
memory->create_3d_double_array(nwindow,nbins,nvalues,
"ave/spatial:values_list");
memory->create(values_list,nwindow,nbins,nvalues,
"ave/spatial:values_list");
}
// reinitialize regrown count/values total since they accumulate

View File

@ -304,8 +304,7 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
array_total = memory->create_2d_double_array(nrows,nvalues,
"ave/time:array_total");
if (ave == WINDOW)
array_list = memory->create_3d_double_array(nwindow,nrows,nvalues,
"ave/time:array_list");
memory->create(array_list,nwindow,nrows,nvalues,"ave/time:array_list");
}
// this fix produces either a global scalar or vector or array
@ -444,7 +443,7 @@ FixAveTime::~FixAveTime()
delete [] column;
memory->destroy_2d_double_array(array);
memory->destroy_2d_double_array(array_total);
memory->destroy_3d_double_array(array_list);
memory->destroy(array_list);
}
/* ---------------------------------------------------------------------- */

View File

@ -46,7 +46,7 @@ FixRespa::~FixRespa()
// delete locally stored arrays
memory->destroy_3d_double_array(f_level);
memory->destroy(f_level);
}
/* ---------------------------------------------------------------------- */
@ -72,8 +72,7 @@ double FixRespa::memory_usage()
void FixRespa::grow_arrays(int nmax)
{
f_level =
memory->grow_3d_double_array(f_level,nmax,nlevels,3,"fix_respa:f_level");
memory->grow(f_level,nmax,nlevels,3,"fix_respa:f_level");
}
/* ----------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ FixShearHistory::~FixShearHistory()
memory->sfree(npartner);
memory->destroy_2d_int_array(partner);
memory->destroy_3d_double_array(shearpartner);
memory->destroy(shearpartner);
}
/* ---------------------------------------------------------------------- */
@ -180,9 +180,7 @@ void FixShearHistory::grow_arrays(int nmax)
"shear_history:npartner");
partner = memory->grow_2d_int_array(partner,nmax,MAXTOUCH,
"shear_history:partner");
shearpartner =
memory->grow_3d_double_array(shearpartner,nmax,MAXTOUCH,3,
"shear_history:shearpartner");
memory->grow(shearpartner,nmax,MAXTOUCH,3,"shear_history:shearpartner");
}
/* ----------------------------------------------------------------------

View File

@ -118,32 +118,20 @@ FixTTM::FixTTM(LAMMPS *lmp, int narg, char **arg) :
total_nnodes = nxnodes*nynodes*nznodes;
nsum = memory->create_3d_int_array(nxnodes,nynodes,nznodes,"ttm:nsum");
nsum_all = memory->create_3d_int_array(nxnodes,nynodes,nznodes,
"ttm:nsum_all");
T_initial_set = memory->create_3d_int_array(nxnodes,nynodes,nznodes,
"ttm:T_initial_set");
sum_vsq = memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"ttm:sum_vsq");
sum_mass_vsq =
memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"ttm:sum_mass_vsq");
sum_vsq_all = memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"ttm:sum_vsq_all");
sum_mass_vsq_all =
memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"ttm:sum_mass_vsq_all");
T_electron_old =
memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"ttm:T_electron_old");
T_electron =
memory->create_3d_double_array(nxnodes,nynodes,nznodes,"ttm:T_electron");
net_energy_transfer =
memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"TTM:net_energy_transfer");
net_energy_transfer_all =
memory->create_3d_double_array(nxnodes,nynodes,nznodes,
"TTM:net_energy_transfer_all");
memory->create(nsum,nxnodes,nynodes,nznodes,"ttm:nsum");
memory->create(nsum_all,nxnodes,nynodes,nznodes,"ttm:nsum_all");
memory->create(T_initial_set,nxnodes,nynodes,nznodes,"ttm:T_initial_set");
memory->create(sum_vsq,nxnodes,nynodes,nznodes,"ttm:sum_vsq");
memory->create(sum_mass_vsq,nxnodes,nynodes,nznodes,"ttm:sum_mass_vsq");
memory->create(sum_vsq_all,nxnodes,nynodes,nznodes,"ttm:sum_vsq_all");
memory->create(sum_mass_vsq_all,nxnodes,nynodes,nznodes,
"ttm:sum_mass_vsq_all");
memory->create(T_electron_old,nxnodes,nynodes,nznodes,"ttm:T_electron_old");
memory->create(T_electron,nxnodes,nynodes,nznodes,"ttm:T_electron");
memory->create(net_energy_transfer,nxnodes,nynodes,nznodes,
"TTM:net_energy_transfer");
memory->create(net_energy_transfer_all,nxnodes,nynodes,nznodes,
"TTM:net_energy_transfer_all");
flangevin = NULL;
grow_arrays(atom->nmax);
@ -176,18 +164,18 @@ FixTTM::~FixTTM()
delete [] gfactor1;
delete [] gfactor2;
memory->destroy_3d_int_array(nsum);
memory->destroy_3d_int_array(nsum_all);
memory->destroy_3d_int_array(T_initial_set);
memory->destroy_3d_double_array(sum_vsq);
memory->destroy_3d_double_array(sum_mass_vsq);
memory->destroy_3d_double_array(sum_vsq_all);
memory->destroy_3d_double_array(sum_mass_vsq_all);
memory->destroy_3d_double_array(T_electron_old);
memory->destroy_3d_double_array(T_electron);
memory->destroy(nsum);
memory->destroy(nsum_all);
memory->destroy(T_initial_set);
memory->destroy(sum_vsq);
memory->destroy(sum_mass_vsq);
memory->destroy(sum_vsq_all);
memory->destroy(sum_mass_vsq_all);
memory->destroy(T_electron_old);
memory->destroy(T_electron);
memory->destroy_2d_double_array(flangevin);
memory->destroy_3d_double_array(net_energy_transfer);
memory->destroy_3d_double_array(net_energy_transfer_all);
memory->destroy(net_energy_transfer);
memory->destroy(net_energy_transfer_all);
}
/* ---------------------------------------------------------------------- */

View File

@ -89,27 +89,6 @@ void Memory::fail(const char *name)
older routines, will be deprecated at some point
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
create a 1d double array with index from nlo to nhi inclusive
------------------------------------------------------------------------- */
double *Memory::create_1d_double_array(int nlo, int nhi, const char *name)
{
int n = nhi - nlo + 1;
double *array = (double *) smalloc(n*sizeof(double),name);
return array-nlo;
}
/* ----------------------------------------------------------------------
free a 1d double array with index offset
------------------------------------------------------------------------- */
void Memory::destroy_1d_double_array(double *array, int offset)
{
if (array == NULL) return;
sfree(array + offset);
}
/* ----------------------------------------------------------------------
create a 2d double array
------------------------------------------------------------------------- */
@ -251,208 +230,3 @@ void Memory::destroy_2d_double_array(double **array, int offset)
sfree(&array[0][offset]);
sfree(array);
}
/* ----------------------------------------------------------------------
create a 3d double array
------------------------------------------------------------------------- */
double ***Memory::create_3d_double_array(int n1, int n2, int n3,
const char *name)
{
int i,j;
double *data = (double *) smalloc(n1*n2*n3*sizeof(double),name);
double **plane = (double **) smalloc(n1*n2*sizeof(double *),name);
double ***array = (double ***) smalloc(n1*sizeof(double **),name);
int n = 0;
for (i = 0; i < n1; i++) {
array[i] = &plane[i*n2];
for (j = 0; j < n2; j++) {
plane[i*n2+j] = &data[n];
n += n3;
}
}
return array;
}
/* ----------------------------------------------------------------------
free a 3d double array
------------------------------------------------------------------------- */
void Memory::destroy_3d_double_array(double ***array)
{
if (array == NULL) return;
sfree(array[0][0]);
sfree(array[0]);
sfree(array);
}
/* ----------------------------------------------------------------------
grow or shrink 1st dim of a 3d double array
last 2 dims must stay the same
if any dim is 0, return NULL
------------------------------------------------------------------------- */
double ***Memory::grow_3d_double_array(double ***array,
int n1, int n2, int n3,
const char *name)
{
int i,j;
if (n1 == 0 || n2 == 0 || n3 == 0) {
destroy_3d_double_array(array);
return NULL;
}
if (array == NULL) return create_3d_double_array(n1,n2,n3,name);
double *data = (double *) srealloc(array[0][0],n1*n2*n3*sizeof(double),name);
double **plane = (double **) srealloc(array[0],n1*n2*sizeof(double *),name);
array = (double ***) srealloc(array,n1*sizeof(double **),name);
int n = 0;
for (i = 0; i < n1; i++) {
array[i] = &plane[i*n2];
for (j = 0; j < n2; j++) {
plane[i*n2+j] = &data[n];
n += n3;
}
}
return array;
}
/* ----------------------------------------------------------------------
create a 3d double array with 1st index from n1lo to n1hi inclusive
------------------------------------------------------------------------- */
double ***Memory::create_3d_double_array(int n1lo, int n1hi,
int n2, int n3, const char *name)
{
int n1 = n1hi - n1lo + 1;
double ***array = create_3d_double_array(n1,n2,n3,name);
return array-n1lo;
}
/* ----------------------------------------------------------------------
free a 3d double array with 1st index offset
------------------------------------------------------------------------- */
void Memory::destroy_3d_double_array(double ***array, int offset)
{
if (array) destroy_3d_double_array(array + offset);
}
/* ----------------------------------------------------------------------
create a 3d double array with
1st index from n1lo to n1hi inclusive,
2nd index from n2lo to n2hi inclusive,
3rd index from n3lo to n3hi inclusive
------------------------------------------------------------------------- */
double ***Memory::create_3d_double_array(int n1lo, int n1hi,
int n2lo, int n2hi,
int n3lo, int n3hi, const char *name)
{
int n1 = n1hi - n1lo + 1;
int n2 = n2hi - n2lo + 1;
int n3 = n3hi - n3lo + 1;
double ***array = create_3d_double_array(n1,n2,n3,name);
for (int i = 0; i < n1*n2; i++) array[0][i] -= n3lo;
for (int i = 0; i < n1; i++) array[i] -= n2lo;
return array-n1lo;
}
/* ----------------------------------------------------------------------
free a 3d double array with all 3 indices offset
------------------------------------------------------------------------- */
void Memory::destroy_3d_double_array(double ***array, int n1_offset,
int n2_offset, int n3_offset)
{
if (array == NULL) return;
sfree(&array[n1_offset][n2_offset][n3_offset]);
sfree(&array[n1_offset][n2_offset]);
sfree(array + n1_offset);
}
/* ----------------------------------------------------------------------
create a 3d int array
------------------------------------------------------------------------- */
int ***Memory::create_3d_int_array(int n1, int n2, int n3, const char *name)
{
int i,j;
int *data = (int *) smalloc(n1*n2*n3*sizeof(int),name);
int **plane = (int **) smalloc(n1*n2*sizeof(int *),name);
int ***array = (int ***) smalloc(n1*sizeof(int **),name);
int n = 0;
for (i = 0; i < n1; i++) {
array[i] = &plane[i*n2];
for (j = 0; j < n2; j++) {
plane[i*n2+j] = &data[n];
n += n3;
}
}
return array;
}
/* ----------------------------------------------------------------------
free a 3d int array
------------------------------------------------------------------------- */
void Memory::destroy_3d_int_array(int ***array)
{
if (array == NULL) return;
sfree(array[0][0]);
sfree(array[0]);
sfree(array);
}
/* ----------------------------------------------------------------------
create a 4d double array
------------------------------------------------------------------------- */
double ****Memory::create_4d_double_array(int n1, int n2, int n3, int n4,
const char *name)
{
int i,j,k;
double *data = (double *) smalloc(n1*n2*n3*n4*sizeof(double),name);
double **cube = (double **) smalloc(n1*n2*n3*sizeof(double *),name);
double ***plane = (double ***) smalloc(n1*n2*sizeof(double **),name);
double ****array = (double ****) smalloc(n1*sizeof(double ***),name);
int n = 0;
for (i = 0; i < n1; i++) {
array[i] = &plane[i*n2];
for (j = 0; j < n2; j++) {
plane[i*n2+j] = &cube[i*n2*n3+j*n3];
for (k = 0; k < n3; k++) {
cube[i*n2*n3+j*n3+k] = &data[n];
n += n4;
}
}
}
return array;
}
/* ----------------------------------------------------------------------
free a 4d double array
------------------------------------------------------------------------- */
void Memory::destroy_4d_double_array(double ****array)
{
if (array == NULL) return;
sfree(array[0][0][0]);
sfree(array[0][0]);
sfree(array[0]);
sfree(array);
}

View File

@ -30,9 +30,6 @@ class Memory : protected Pointers {
// older routines, will be deprecated at some point
double *create_1d_double_array(int, int, const char *);
void destroy_1d_double_array(double *, int);
double **create_2d_double_array(int, int, const char *);
void destroy_2d_double_array(double **);
double **grow_2d_double_array(double **, int, int, const char *);
@ -44,22 +41,6 @@ class Memory : protected Pointers {
double **create_2d_double_array(int, int, int, const char *);
void destroy_2d_double_array(double **, int);
double ***create_3d_double_array(int, int, int, const char *);
void destroy_3d_double_array(double ***);
double ***grow_3d_double_array(double ***, int, int, int, const char *);
double ***create_3d_double_array(int, int, int, int, const char *);
void destroy_3d_double_array(double ***, int);
double ***create_3d_double_array(int, int, int, int, int, int, const char *);
void destroy_3d_double_array(double ***, int, int, int);
int ***create_3d_int_array(int, int, int, const char *);
void destroy_3d_int_array(int ***);
double ****create_4d_double_array(int, int, int, int, const char *);
void destroy_4d_double_array(double ****);
// newer routines
/* ----------------------------------------------------------------------

View File

@ -53,7 +53,7 @@ PairHybrid::~PairHybrid()
memory->destroy_2d_double_array(cutsq);
memory->destroy_2d_double_array(cutghost);
memory->destroy_2d_int_array(nmap);
memory->destroy_3d_int_array(map);
memory->destroy(map);
}
}
@ -161,7 +161,7 @@ void PairHybrid::allocate()
cutghost = memory->create_2d_double_array(n+1,n+1,"pair:cutghost");
nmap = memory->create_2d_int_array(n+1,n+1,"pair:nmap");
map = memory->create_3d_int_array(n+1,n+1,nstyles,"pair:map");
memory->create(map,n+1,n+1,nstyles,"pair:map");
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
nmap[i][j] = 0;
@ -191,7 +191,7 @@ void PairHybrid::settings(int narg, char **arg)
memory->destroy_2d_double_array(cutsq);
memory->destroy_2d_double_array(cutghost);
memory->destroy_2d_int_array(nmap);
memory->destroy_3d_int_array(map);
memory->destroy(map);
}
allocated = 0;