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

This commit is contained in:
sjplimp
2014-06-04 20:52:04 +00:00
parent 88a3f9d326
commit 1f667449d1
15 changed files with 172 additions and 159 deletions

View File

@ -17,6 +17,7 @@
#include "math.h"
#include "stdlib.h"
#include "string.h"
#include "atom_vec_wavepacket.h"
#include "atom.h"
#include "comm.h"
@ -37,6 +38,7 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
mass_type = 1;
molecular = 0;
forceclearflag = 1;
size_forward = 4; // coords[3]+radius[1]
size_reverse = 10; // force[3]+erforce[1]+ervelforce[1]+vforce[3]+csforce[2]
@ -108,7 +110,6 @@ void AtomVecWavepacket::grow_reset()
vforce = atom->vforce;
ervelforce = atom->ervelforce;
etag = atom->etag;
}
/* ----------------------------------------------------------------------
@ -143,6 +144,13 @@ void AtomVecWavepacket::copy(int i, int j, int delflag)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
}
/* ---------------------------------------------------------------------- */
void AtomVecWavepacket::force_clear(int n, size_t nbytes)
{
memset(&erforce[n],0,nbytes);
}
/* ---------------------------------------------------------------------- */
// this will be used as partial pack for unsplit Hartree packets (v, ervel not regarded as separate variables)

View File

@ -36,6 +36,7 @@ public:
void grow(int);
void grow_reset();
void copy(int, int, int);
void force_clear(int, size_t);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);

View File

@ -17,6 +17,7 @@
#include "math.h"
#include "stdlib.h"
#include "string.h"
#include "atom_vec_electron.h"
#include "atom.h"
#include "comm.h"
@ -51,6 +52,7 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp)
mass_type = 1;
molecular = 0;
forceclearflag = 1;
size_forward = 4;
size_reverse = 4;
@ -140,6 +142,13 @@ void AtomVecElectron::copy(int i, int j, int delflag)
/* ---------------------------------------------------------------------- */
void AtomVecElectron::force_clear(int n, size_t nbytes)
{
memset(&erforce[n],0,nbytes);
}
/* ---------------------------------------------------------------------- */
int AtomVecElectron::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{

View File

@ -31,6 +31,7 @@ class AtomVecElectron : public AtomVec {
void grow(int);
void grow_reset();
void copy(int, int, int);
void force_clear(int, size_t);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *);

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "string.h"
#include "stdlib.h"
#include "atom_vec_meso.h"
#include "atom.h"
@ -29,6 +30,7 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp)
{
molecular = 0;
mass_type = 1;
forceclearflag = 1;
comm_x_only = 0; // we communicate not only x forward but also vest ...
comm_f_only = 0; // we also communicate de and drho in reverse direction
@ -131,6 +133,14 @@ void AtomVecMeso::copy(int i, int j, int delflag) {
/* ---------------------------------------------------------------------- */
void AtomVecMeso::force_clear(int n, size_t nbytes)
{
memset(&de[n],0,nbytes);
memset(&drho[n],0,nbytes);
}
/* ---------------------------------------------------------------------- */
int AtomVecMeso::pack_comm_hybrid(int n, int *list, double *buf) {
//printf("in AtomVecMeso::pack_comm_hybrid\n");
int i, j, m;

View File

@ -31,6 +31,7 @@ class AtomVecMeso : public AtomVec {
void grow(int);
void grow_reset();
void copy(int, int, int);
void force_clear(int, size_t);
int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *);

View File

@ -79,16 +79,17 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
mu = NULL;
omega = angmom = torque = NULL;
radius = rmass = NULL;
ellipsoid = line = tri = body = NULL;
vfrac = s0 = NULL;
x0 = NULL;
ellipsoid = line = tri = body = NULL;
spin = NULL;
eradius = ervel = erforce = NULL;
cs = csforce = vforce = ervelforce = NULL;
etag = NULL;
rho = drho = NULL;
e = de = NULL;
cv = NULL;
rho = drho = e = de = cv = NULL;
vest = NULL;
bond_per_atom = extra_bond_per_atom = 0;
@ -130,14 +131,19 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
// initialize atom style and array existence flags
// customize by adding new flag
sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
peri_flag = electron_flag = 0;
sphere_flag = peri_flag = electron_flag = 0;
wavepacket_flag = sph_flag = 0;
molecule_flag = q_flag = mu_flag = 0;
rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
cs_flag = csforce_flag = vforce_flag = ervelforce_flag= etag_flag = 0;
molecule_flag = 0;
q_flag = mu_flag = 0;
omega_flag = torque_flag = angmom_flag = 0;
radius_flag = rmass_flag = 0;
ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
vfrac_flag = 0;
spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
rho_flag = e_flag = cv_flag = vest_flag = 0;
// Peridynamic scale factor
@ -200,6 +206,10 @@ Atom::~Atom()
memory->destroy(v);
memory->destroy(f);
memory->destroy(molecule);
memory->destroy(molindex);
memory->destroy(molatom);
memory->destroy(q);
memory->destroy(mu);
memory->destroy(omega);
@ -207,21 +217,31 @@ Atom::~Atom()
memory->destroy(torque);
memory->destroy(radius);
memory->destroy(rmass);
memory->destroy(vfrac);
memory->destroy(s0);
memory->destroy(x0);
memory->destroy(ellipsoid);
memory->destroy(line);
memory->destroy(tri);
memory->destroy(body);
memory->destroy(vfrac);
memory->destroy(s0);
memory->destroy(x0);
memory->destroy(spin);
memory->destroy(eradius);
memory->destroy(ervel);
memory->destroy(erforce);
memory->destroy(ervelforce);
memory->destroy(cs);
memory->destroy(csforce);
memory->destroy(vforce);
memory->destroy(etag);
memory->destroy(molecule);
memory->destroy(molindex);
memory->destroy(molatom);
memory->destroy(rho);
memory->destroy(drho);
memory->destroy(e);
memory->destroy(de);
memory->destroy(cv);
memory->destroy(vest);
memory->destroy(nspecial);
memory->destroy(special);
@ -250,11 +270,6 @@ Atom::~Atom()
memory->destroy(improper_atom3);
memory->destroy(improper_atom4);
// delete user-defined molecules
for (int i = 0; i < nmolecule; i++) delete molecules[i];
memory->sfree(molecules);
// delete custom atom arrays
for (int i = 0; i < nivector; i++) {
@ -271,6 +286,11 @@ Atom::~Atom()
memory->sfree(ivector);
memory->sfree(dvector);
// delete user-defined molecules
for (int i = 0; i < nmolecule; i++) delete molecules[i];
memory->sfree(molecules);
// delete per-type arrays
delete [] mass;
@ -320,12 +340,20 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix)
// may have been set by old avec
// customize by adding new flag
sphere_flag = ellipsoid_flag = line_flag = tri_flag = 0;
peri_flag = electron_flag = 0;
sphere_flag = peri_flag = electron_flag = 0;
wavepacket_flag = sph_flag = 0;
molecule_flag = q_flag = mu_flag = 0;
rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
molecule_flag = 0;
q_flag = mu_flag = 0;
omega_flag = torque_flag = angmom_flag = 0;
radius_flag = rmass_flag = 0;
ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
vfrac_flag = 0;
spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
rho_flag = e_flag = cv_flag = vest_flag = 0;
// create instance of AtomVec
// use grow() to initialize atom-based arrays to length 1
@ -1867,12 +1895,34 @@ void *Atom::extract(char *name)
if (strcmp(name,"q") == 0) return (void *) q;
if (strcmp(name,"mu") == 0) return (void *) mu;
if (strcmp(name,"omega") == 0) return (void *) omega;
if (strcmp(name,"amgmom") == 0) return (void *) angmom;
if (strcmp(name,"angmom") == 0) return (void *) angmom;
if (strcmp(name,"torque") == 0) return (void *) torque;
if (strcmp(name,"radius") == 0) return (void *) radius;
if (strcmp(name,"rmass") == 0) return (void *) rmass;
if (strcmp(name,"ellipsoid") == 0) return (void *) ellipsoid;
if (strcmp(name,"line") == 0) return (void *) line;
if (strcmp(name,"tri") == 0) return (void *) tri;
if (strcmp(name,"vfrac") == 0) return (void *) vfrac;
if (strcmp(name,"s0") == 0) return (void *) s0;
if (strcmp(name,"x0") == 0) return (void *) x0;
if (strcmp(name,"spin") == 0) return (void *) spin;
if (strcmp(name,"eradius") == 0) return (void *) eradius;
if (strcmp(name,"ervel") == 0) return (void *) ervel;
if (strcmp(name,"erforce") == 0) return (void *) erforce;
if (strcmp(name,"ervelforce") == 0) return (void *) ervelforce;
if (strcmp(name,"cs") == 0) return (void *) cs;
if (strcmp(name,"csforce") == 0) return (void *) csforce;
if (strcmp(name,"vforce") == 0) return (void *) vforce;
if (strcmp(name,"etag") == 0) return (void *) etag;
if (strcmp(name,"rho") == 0) return (void *) rho;
if (strcmp(name,"drho") == 0) return (void *) drho;
if (strcmp(name,"e") == 0) return (void *) e;
if (strcmp(name,"de") == 0) return (void *) de;
if (strcmp(name,"cv") == 0) return (void *) cv;
if (strcmp(name,"vest") == 0) return (void *) vest;
return NULL;
}

View File

@ -53,19 +53,28 @@ class Atom : protected Pointers {
tagint *molecule;
int *molindex,*molatom;
double *q,**mu;
double **omega,**angmom,**torque;
double *radius,*rmass,*vfrac,*s0;
double **x0;
double *radius,*rmass;
int *ellipsoid,*line,*tri,*body;
// PERI package
double *vfrac,*s0;
double **x0;
// USER-EFF and USER-AWPMD packages
int *spin;
double *eradius,*ervel,*erforce,*ervelforce;
double *cs,*csforce,*vforce;
int *etag;
double *rho,*drho;
double *e,*de;
// USER-SPH package
double *rho,*drho,*e,*de,*cv;
double **vest;
double *cv;
int **nspecial; // 0,1,2 = cummulative # of 1-2,1-3,1-4 neighs
tagint **special; // IDs of 1-2,1-3,1-4 neighs of each atom

View File

@ -39,6 +39,7 @@ class AtomVec : protected Pointers {
int size_data_bonus; // number of values in Bonus line
int xcol_data; // column (1-N) where x is in Atom line
int forceclearflag; // 1 if has forceclear() method
class Molecule **onemols; // list of molecules for style template
int nset; // # of molecules in list
@ -59,6 +60,7 @@ class AtomVec : protected Pointers {
virtual void grow_reset() = 0;
virtual void copy(int, int, int) = 0;
virtual void clear_bonus() {}
virtual void force_clear(int, size_t) {}
virtual int pack_comm(int, int *, double *, int, int *) = 0;
virtual int pack_comm_vel(int, int *, double *, int, int *) = 0;

View File

@ -24,6 +24,7 @@
#include "string.h"
#include "min.h"
#include "atom.h"
#include "atom_vec.h"
#include "domain.h"
#include "comm.h"
#include "update.h"
@ -139,17 +140,11 @@ void Min::init()
int ifix = modify->find_fix("package_omp");
if (ifix >= 0) external_force_clear = 1;
// set flags for what arrays to clear in force_clear()
// need to clear additionals arrays if they exist
// set flags for arrays to clear in force_clear()
torqueflag = 0;
torqueflag = extraflag = 0;
if (atom->torque_flag) torqueflag = 1;
erforceflag = 0;
if (atom->erforce_flag) erforceflag = 1;
e_flag = 0;
if (atom->e_flag) e_flag = 1;
rho_flag = 0;
if (atom->rho_flag) rho_flag = 1;
if (atom->avec->forceclearflag) extraflag = 1;
// allow pair and Kspace compute() to be turned off via modify flags
@ -540,7 +535,7 @@ double Min::energy_force(int resetflag)
/* ----------------------------------------------------------------------
clear force on own & ghost atoms
setup and clear other arrays as needed
clear other arrays as needed
------------------------------------------------------------------------- */
void Min::force_clear()
@ -548,20 +543,15 @@ void Min::force_clear()
if (external_force_clear) return;
// clear global force array
// nall includes ghosts only if either newton flag is set
// if either newton flag is set, also include ghosts
int nall;
if (force->newton) nall = atom->nlocal + atom->nghost;
else nall = atom->nlocal;
size_t nbytes = sizeof(double) * nall;
size_t nbytes = sizeof(double) * atom->nlocal;
if (force->newton) nbytes += sizeof(double) * atom->nghost;
if (nbytes) {
memset(&(atom->f[0][0]),0,3*nbytes);
if (torqueflag) memset(&(atom->torque[0][0]),0,3*nbytes);
if (erforceflag) memset(&(atom->erforce[0]), 0, nbytes);
if (e_flag) memset(&(atom->de[0]), 0, nbytes);
if (rho_flag) memset(&(atom->drho[0]), 0, nbytes);
memset(&atom->f[0][0],0,3*nbytes);
if (torqueflag) memset(&atom->torque[0][0],0,3*nbytes);
if (extraflag) atom->avec->force_clear(0,nbytes);
}
}

View File

@ -63,8 +63,7 @@ class Min : protected Pointers {
int triclinic; // 0 if domain is orthog, 1 if triclinic
int pairflag;
int torqueflag,erforceflag;
int e_flag,rho_flag;
int torqueflag,extraflag;
int pair_compute_flag; // 0 if pair->compute is skipped
int kspace_compute_flag; // 0 if kspace->compute is skipped

View File

@ -20,6 +20,7 @@
#include "respa.h"
#include "neighbor.h"
#include "atom.h"
#include "atom_vec.h"
#include "domain.h"
#include "comm.h"
#include "force.h"
@ -283,17 +284,11 @@ void Respa::init()
int ifix = modify->find_fix("package_omp");
if (ifix >= 0) external_force_clear = 1;
// set flags for what arrays to clear in force_clear()
// need to clear additionals arrays if they exist
// set flags for arrays to clear in force_clear()
torqueflag = 0;
torqueflag = extraflag = 0;
if (atom->torque_flag) torqueflag = 1;
erforceflag = 0;
if (atom->erforce_flag) erforceflag = 1;
e_flag = 0;
if (atom->e_flag) e_flag = 1;
rho_flag = 0;
if (atom->rho_flag) rho_flag = 1;
if (atom->avec->forceclearflag) extraflag = 1;
// step[] = timestep for each level
@ -626,6 +621,7 @@ void Respa::recurse(int ilevel)
/* ----------------------------------------------------------------------
clear force on own & ghost atoms
clear other arrays as needed
------------------------------------------------------------------------- */
void Respa::force_clear(int newtonflag)
@ -633,20 +629,15 @@ void Respa::force_clear(int newtonflag)
if (external_force_clear) return;
// clear global force array
// nall includes ghosts only if newton flag is set
// if either newton flag is set, also include ghosts
int nall;
if (newtonflag) nall = atom->nlocal + atom->nghost;
else nall = atom->nlocal;
size_t nbytes = sizeof(double) * atom->nlocal;
if (force->newton) nbytes += sizeof(double) * atom->nghost;
size_t nbytes = sizeof(double) * nall;
if (nbytes > 0 ) {
memset(&(atom->f[0][0]),0,3*nbytes);
if (torqueflag) memset(&(atom->torque[0][0]),0,3*nbytes);
if (erforceflag) memset(&(atom->erforce[0]), 0, nbytes);
if (e_flag) memset(&(atom->de[0]), 0, nbytes);
if (rho_flag) memset(&(atom->drho[0]), 0, nbytes);
if (nbytes) {
memset(&atom->f[0][0],0,3*nbytes);
if (torqueflag) memset(&atom->torque[0][0],0,3*nbytes);
if (extraflag) atom->avec->force_clear(0,nbytes);
}
}

View File

@ -53,8 +53,7 @@ class Respa : public Integrate {
protected:
int triclinic; // 0 if domain is orthog, 1 if triclinic
int torqueflag,erforceflag;
int e_flag,rho_flag;
int torqueflag,extraflag;
int *newton; // newton flag at each level
class FixRespa *fix_respa; // Fix to store the force level array

View File

@ -17,6 +17,7 @@
#include "domain.h"
#include "comm.h"
#include "atom.h"
#include "atom_vec.h"
#include "force.h"
#include "pair.h"
#include "bond.h"
@ -69,17 +70,11 @@ void Verlet::init()
int ifix = modify->find_fix("package_omp");
if (ifix >= 0) external_force_clear = 1;
// set flags for what arrays to clear in force_clear()
// need to clear additionals arrays if they exist
// set flags for arrays to clear in force_clear()
torqueflag = 0;
torqueflag = extraflag = 0;
if (atom->torque_flag) torqueflag = 1;
erforceflag = 0;
if (atom->erforce_flag) erforceflag = 1;
e_flag = 0;
if (atom->e_flag) e_flag = 1;
rho_flag = 0;
if (atom->rho_flag) rho_flag = 1;
if (atom->avec->forceclearflag) extraflag = 1;
// orthogonal vs triclinic simulation box
@ -330,6 +325,7 @@ void Verlet::cleanup()
void Verlet::force_clear()
{
int i;
size_t nbytes;
if (external_force_clear) return;
@ -337,19 +333,16 @@ void Verlet::force_clear()
// if either newton flag is set, also include ghosts
// when using threads always clear all forces.
if (neighbor->includegroup == 0) {
int nall;
if (force->newton) nall = atom->nlocal + atom->nghost;
else nall = atom->nlocal;
int nlocal = atom->nlocal;
size_t nbytes = sizeof(double) * nall;
if (neighbor->includegroup == 0) {
nbytes = sizeof(double) * nlocal;
if (force->newton) nbytes += sizeof(double) * atom->nghost;
if (nbytes) {
memset(&(atom->f[0][0]),0,3*nbytes);
if (torqueflag) memset(&(atom->torque[0][0]),0,3*nbytes);
if (erforceflag) memset(&(atom->erforce[0]), 0, nbytes);
if (e_flag) memset(&(atom->de[0]), 0, nbytes);
if (rho_flag) memset(&(atom->drho[0]), 0, nbytes);
memset(&atom->f[0][0],0,3*nbytes);
if (torqueflag) memset(&atom->torque[0][0],0,3*nbytes);
if (extraflag) atom->avec->force_clear(0,nbytes);
}
// neighbor includegroup flag is set
@ -357,70 +350,21 @@ void Verlet::force_clear()
// if either newton flag is set, also include ghosts
} else {
int nall = atom->nfirst;
nbytes = sizeof(double) * atom->nfirst;
double **f = atom->f;
for (i = 0; i < nall; i++) {
f[i][0] = 0.0;
f[i][1] = 0.0;
f[i][2] = 0.0;
}
if (torqueflag) {
double **torque = atom->torque;
for (i = 0; i < nall; i++) {
torque[i][0] = 0.0;
torque[i][1] = 0.0;
torque[i][2] = 0.0;
}
}
if (erforceflag) {
double *erforce = atom->erforce;
for (i = 0; i < nall; i++) erforce[i] = 0.0;
}
if (e_flag) {
double *de = atom->de;
for (i = 0; i < nall; i++) de[i] = 0.0;
}
if (rho_flag) {
double *drho = atom->drho;
for (i = 0; i < nall; i++) drho[i] = 0.0;
if (nbytes) {
memset(&atom->f[0][0],0,3*nbytes);
if (torqueflag) memset(&atom->torque[0][0],0,3*nbytes);
if (extraflag) atom->avec->force_clear(0,nbytes);
}
if (force->newton) {
nall = atom->nlocal + atom->nghost;
nbytes = sizeof(double) * atom->nghost;
for (i = atom->nlocal; i < nall; i++) {
f[i][0] = 0.0;
f[i][1] = 0.0;
f[i][2] = 0.0;
}
if (torqueflag) {
double **torque = atom->torque;
for (i = atom->nlocal; i < nall; i++) {
torque[i][0] = 0.0;
torque[i][1] = 0.0;
torque[i][2] = 0.0;
}
}
if (erforceflag) {
double *erforce = atom->erforce;
for (i = atom->nlocal; i < nall; i++) erforce[i] = 0.0;
}
if (e_flag) {
double *de = atom->de;
for (i = 0; i < nall; i++) de[i] = 0.0;
}
if (rho_flag) {
double *drho = atom->drho;
for (i = 0; i < nall; i++) drho[i] = 0.0;
if (nbytes) {
memset(&atom->f[nlocal][0],0,3*nbytes);
if (torqueflag) memset(&atom->torque[nlocal][0],0,3*nbytes);
if (extraflag) atom->avec->force_clear(nlocal,nbytes);
}
}
}

View File

@ -36,8 +36,7 @@ class Verlet : public Integrate {
protected:
int triclinic; // 0 if domain is orthog, 1 if triclinic
int torqueflag,erforceflag;
int e_flag,rho_flag;
int torqueflag,extraflag;
virtual void force_clear();
};