diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index 1b82185c0aba6902631dbd5b1bd35fe04a0e55f1..24719646dc8259ea849cc3dafbe54a627327ce40 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -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; } diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index ad43ff312051de258697f82ae371eafc8d9f16bd..2306528fed152de1e57ce0b0e2e47430144e175f 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -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); diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 1146279875eff87473a22babeaadef893e958c63..7d462af082d3058b170f37df6e2fa6cd4b838eb9 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -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++) diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index 6a60333e688f46077799759e4a8e3350b53e0b93..02c33f6b5ad4d44e33edd66fc188cd27638a3484 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -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]); diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index 872458acaa4568deb254a4cfea89e09e35f50555..ab45bccb2d66123fffde1e5cc2e1637a26895c0d 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -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) { diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index 8c7f8f245be8447f9060090cab85d75703600b40..15059ad39a819dc6f67ec2706cf4279f2475f789 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -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) { diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index 68a83c1f520e8d0a16e48e19f51aa2eed3c33341..c8e25c31c77d151120c6c76849f5cd1940897488 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -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); diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index 3e01d069b0ddf82659c775691bcf01efbbccf4af..6c22f645a3051fce88ede048d771d29c4ee6c87c 100755 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -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++) diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index caf6f7112202ca84bc09f26dc80c85f9dff0a499..f21ff4e918e25ee6a5191b5b91b8ed60a6cc2a04 100755 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -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++) diff --git a/src/MOLECULE/pair_hbond_dreiding_lj.cpp b/src/MOLECULE/pair_hbond_dreiding_lj.cpp index 82d1d58a19a6eaa475e253bc7ef80ddfa6d562e8..c6d243837370dd068cf270b9ddc52a458730ad2a 100644 --- a/src/MOLECULE/pair_hbond_dreiding_lj.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_lj.cpp @@ -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++) diff --git a/src/compute_rdf.cpp b/src/compute_rdf.cpp index 5e5c368aba1a1aa02d2e9e2014fbb433a25cd3bf..c4fef5a6b38c1670d6cd2159c77d63acdd571222 100644 --- a/src/compute_rdf.cpp +++ b/src/compute_rdf.cpp @@ -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; diff --git a/src/fix_ave_spatial.cpp b/src/fix_ave_spatial.cpp index 734425b3abfb0cd1f11d313581c51df33a0f421d..0bb843de25d5fb283e923668bda35f2b5225bc44 100644 --- a/src/fix_ave_spatial.cpp +++ b/src/fix_ave_spatial.cpp @@ -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 diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index 8a72d054a2bda4efb3c12cfcd7243b5e9618db73..5b852750cf9276e4dd0eac3f0077847a77bc18af 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -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); } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_respa.cpp b/src/fix_respa.cpp index 24d9f13cf6a46ba20eb9f96a06f1ae702849522c..37eda1e4da7e82a6d2b408aadfbe9c380f5f3b2c 100644 --- a/src/fix_respa.cpp +++ b/src/fix_respa.cpp @@ -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"); } /* ---------------------------------------------------------------------- diff --git a/src/fix_shear_history.cpp b/src/fix_shear_history.cpp index e3f28bad756de2c6f7ec877ccfbd2d1d6c3851e1..16ed40dad2a1d0c9fe175a1ec279453ed193eafd 100644 --- a/src/fix_shear_history.cpp +++ b/src/fix_shear_history.cpp @@ -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"); } /* ---------------------------------------------------------------------- diff --git a/src/fix_ttm.cpp b/src/fix_ttm.cpp index d486cf49e61d34f8fd373f5cec05feea9a442bcd..2379730140d0ecd026da081cdc97948ba6e12150 100644 --- a/src/fix_ttm.cpp +++ b/src/fix_ttm.cpp @@ -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); } /* ---------------------------------------------------------------------- */ diff --git a/src/memory.cpp b/src/memory.cpp index 369f4b5055d348f6226ed804703bfd886fc670fb..cf8f5eb4c6c0cbc1b6ac24a04cd9b257056deb35 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -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); -} diff --git a/src/memory.h b/src/memory.h index 065f21fc3dede0a46ebf553fc832bc81d458cc0a..e523dd8a82cb59879d247ea64815a85815061264 100644 --- a/src/memory.h +++ b/src/memory.h @@ -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 /* ---------------------------------------------------------------------- diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 3e9f03ad9196ed5047a87b9fc663175e6b7c39c1..3b2e3ae9aaf3ded1a12e8ec6021ce1cfec83363e 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -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;