git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4232 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -35,19 +35,23 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
peratom_flag = 1;
|
peratom_flag = 1;
|
||||||
size_peratom_cols = 4;
|
size_peratom_cols = 4;
|
||||||
|
|
||||||
// create a new fix store/coord style
|
// create a new fix store style
|
||||||
// id = compute-ID + store_coord, fix group = compute group
|
// id = compute-ID + store, fix group = compute group
|
||||||
|
|
||||||
int n = strlen(id) + strlen("_store_coord") + 1;
|
int n = strlen(id) + strlen("_store") + 1;
|
||||||
id_fix = new char[n];
|
id_fix = new char[n];
|
||||||
strcpy(id_fix,id);
|
strcpy(id_fix,id);
|
||||||
strcat(id_fix,"_store_coord");
|
strcat(id_fix,"_store");
|
||||||
|
|
||||||
char **newarg = new char*[3];
|
char **newarg = new char*[7];
|
||||||
newarg[0] = id_fix;
|
newarg[0] = id_fix;
|
||||||
newarg[1] = group->names[igroup];
|
newarg[1] = group->names[igroup];
|
||||||
newarg[2] = (char *) "store/coord";
|
newarg[2] = (char *) "store";
|
||||||
modify->add_fix(3,newarg);
|
newarg[3] = (char *) "0";
|
||||||
|
newarg[4] = (char *) "xu";
|
||||||
|
newarg[5] = (char *) "yu";
|
||||||
|
newarg[6] = (char *) "zu";
|
||||||
|
modify->add_fix(7,newarg);
|
||||||
delete [] newarg;
|
delete [] newarg;
|
||||||
|
|
||||||
nmax = 0;
|
nmax = 0;
|
||||||
|
|||||||
@ -49,22 +49,26 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
} else error->all("Illegal compute msd command");
|
} else error->all("Illegal compute msd command");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a new fix store/coord style with or without com keyword
|
// create a new fix store style with or without com keyword
|
||||||
// id = compute-ID + store_coord, fix group = compute group
|
// id = compute-ID + store, fix group = compute group
|
||||||
|
|
||||||
int n = strlen(id) + strlen("_store_coord") + 1;
|
int n = strlen(id) + strlen("_store") + 1;
|
||||||
id_fix = new char[n];
|
id_fix = new char[n];
|
||||||
strcpy(id_fix,id);
|
strcpy(id_fix,id);
|
||||||
strcat(id_fix,"_store_coord");
|
strcat(id_fix,"_store");
|
||||||
|
|
||||||
char **newarg = new char*[5];
|
char **newarg = new char*[9];
|
||||||
newarg[0] = id_fix;
|
newarg[0] = id_fix;
|
||||||
newarg[1] = group->names[igroup];
|
newarg[1] = group->names[igroup];
|
||||||
newarg[2] = (char *) "store/coord";
|
newarg[2] = (char *) "store";
|
||||||
newarg[3] = (char *) "com";
|
newarg[3] = (char *) "0";
|
||||||
newarg[4] = (char *) "yes";
|
newarg[4] = (char *) "xu";
|
||||||
if (comflag) modify->add_fix(5,newarg);
|
newarg[5] = (char *) "yu";
|
||||||
else modify->add_fix(3,newarg);
|
newarg[6] = (char *) "zu";
|
||||||
|
newarg[7] = (char *) "com";
|
||||||
|
newarg[8] = (char *) "yes";
|
||||||
|
if (comflag) modify->add_fix(9,newarg);
|
||||||
|
else modify->add_fix(7,newarg);
|
||||||
delete [] newarg;
|
delete [] newarg;
|
||||||
|
|
||||||
vector = new double[4];
|
vector = new double[4];
|
||||||
|
|||||||
@ -21,15 +21,6 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
// customize by adding keyword
|
|
||||||
// same as in dump_custom.cpp
|
|
||||||
|
|
||||||
enum{ID,MOL,TYPE,MASS,
|
|
||||||
X,Y,Z,XS,YS,ZS,XSTRI,YSTRI,ZSTRI,XU,YU,ZU,XUTRI,YUTRI,ZUTRI,IX,IY,IZ,
|
|
||||||
VX,VY,VZ,FX,FY,FZ,
|
|
||||||
Q,MUX,MUY,MUZ,RADIUS,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ,
|
|
||||||
QUATW,QUATI,QUATJ,QUATK,TQX,TQY,TQZ};
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||||
@ -42,6 +33,9 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (nvalues == 1) size_peratom_cols = 0;
|
if (nvalues == 1) size_peratom_cols = 0;
|
||||||
else size_peratom_cols = nvalues;
|
else size_peratom_cols = nvalues;
|
||||||
|
|
||||||
|
// parse input values
|
||||||
|
// customize a new keyword by adding to if statement
|
||||||
|
|
||||||
pack_choice = new FnPtrPack[nvalues];
|
pack_choice = new FnPtrPack[nvalues];
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -249,7 +243,7 @@ void ComputePropertyAtom::compute_peratom()
|
|||||||
buf = vector;
|
buf = vector;
|
||||||
(this->*pack_choice[0])(0);
|
(this->*pack_choice[0])(0);
|
||||||
} else {
|
} else {
|
||||||
if (array) buf = &array[0][0];
|
buf = &array[0][0];
|
||||||
for (int n = 0; n < nvalues; n++)
|
for (int n = 0; n < nvalues; n++)
|
||||||
(this->*pack_choice[n])(n);
|
(this->*pack_choice[n])(n);
|
||||||
}
|
}
|
||||||
|
|||||||
1330
src/fix_store.cpp
Normal file
1330
src/fix_store.cpp
Normal file
File diff suppressed because it is too large
Load Diff
115
src/fix_store.h
Normal file
115
src/fix_store.h
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef FIX_CLASS
|
||||||
|
|
||||||
|
FixStyle(store,FixStore)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef LMP_FIX_STORE_H
|
||||||
|
#define LMP_FIX_STORE_H
|
||||||
|
|
||||||
|
#include "fix.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class FixStore : public Fix {
|
||||||
|
public:
|
||||||
|
FixStore(class LAMMPS *, int, char **);
|
||||||
|
~FixStore();
|
||||||
|
int setmask();
|
||||||
|
void init();
|
||||||
|
void setup(int);
|
||||||
|
void end_of_step();
|
||||||
|
|
||||||
|
double memory_usage();
|
||||||
|
void grow_arrays(int);
|
||||||
|
void copy_arrays(int, int);
|
||||||
|
int pack_exchange(int, double *);
|
||||||
|
int unpack_exchange(int, double *);
|
||||||
|
int pack_restart(int, double *);
|
||||||
|
void unpack_restart(int, int);
|
||||||
|
int size_restart(int);
|
||||||
|
int maxsize_restart();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int nvalues;
|
||||||
|
int *which,*argindex,*value2index;
|
||||||
|
char **ids;
|
||||||
|
double **values; // archived atom properties
|
||||||
|
double *buf; // 1d ptr to values
|
||||||
|
|
||||||
|
int comflag;
|
||||||
|
double cm[3]; // center of mass
|
||||||
|
|
||||||
|
int kflag,cfv_flag,firstflag;
|
||||||
|
int cfv_any; // 1 if any compute/fix/variable specified
|
||||||
|
|
||||||
|
typedef void (FixStore::*FnPtrPack)(int);
|
||||||
|
FnPtrPack *pack_choice; // ptrs to pack functions
|
||||||
|
|
||||||
|
void pack_id(int);
|
||||||
|
void pack_molecule(int);
|
||||||
|
void pack_type(int);
|
||||||
|
void pack_mass(int);
|
||||||
|
|
||||||
|
void pack_x(int);
|
||||||
|
void pack_y(int);
|
||||||
|
void pack_z(int);
|
||||||
|
void pack_xs(int);
|
||||||
|
void pack_ys(int);
|
||||||
|
void pack_zs(int);
|
||||||
|
void pack_xs_triclinic(int);
|
||||||
|
void pack_ys_triclinic(int);
|
||||||
|
void pack_zs_triclinic(int);
|
||||||
|
void pack_xu(int);
|
||||||
|
void pack_yu(int);
|
||||||
|
void pack_zu(int);
|
||||||
|
void pack_xu_triclinic(int);
|
||||||
|
void pack_yu_triclinic(int);
|
||||||
|
void pack_zu_triclinic(int);
|
||||||
|
void pack_ix(int);
|
||||||
|
void pack_iy(int);
|
||||||
|
void pack_iz(int);
|
||||||
|
|
||||||
|
void pack_vx(int);
|
||||||
|
void pack_vy(int);
|
||||||
|
void pack_vz(int);
|
||||||
|
void pack_fx(int);
|
||||||
|
void pack_fy(int);
|
||||||
|
void pack_fz(int);
|
||||||
|
void pack_q(int);
|
||||||
|
void pack_mux(int);
|
||||||
|
void pack_muy(int);
|
||||||
|
void pack_muz(int);
|
||||||
|
void pack_radius(int);
|
||||||
|
void pack_omegax(int);
|
||||||
|
void pack_omegay(int);
|
||||||
|
void pack_omegaz(int);
|
||||||
|
void pack_angmomx(int);
|
||||||
|
void pack_angmomy(int);
|
||||||
|
void pack_angmomz(int);
|
||||||
|
void pack_quatw(int);
|
||||||
|
void pack_quati(int);
|
||||||
|
void pack_quatj(int);
|
||||||
|
void pack_quatk(int);
|
||||||
|
void pack_tqx(int);
|
||||||
|
void pack_tqy(int);
|
||||||
|
void pack_tqz(int);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -1,212 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
|
||||||
|
|
||||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
||||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
|
||||||
certain rights in this software. This software is distributed under
|
|
||||||
the GNU General Public License.
|
|
||||||
|
|
||||||
See the README file in the top-level LAMMPS directory.
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "string.h"
|
|
||||||
#include "fix_store_coord.h"
|
|
||||||
#include "atom.h"
|
|
||||||
#include "domain.h"
|
|
||||||
#include "group.h"
|
|
||||||
#include "memory.h"
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
FixStoreCoord::FixStoreCoord(LAMMPS *lmp, int narg, char **arg) :
|
|
||||||
Fix(lmp, narg, arg)
|
|
||||||
{
|
|
||||||
if (narg < 3) error->all("Illegal fix store/coord command");
|
|
||||||
|
|
||||||
restart_peratom = 1;
|
|
||||||
peratom_flag = 1;
|
|
||||||
size_peratom_cols = 3;
|
|
||||||
peratom_freq = 1;
|
|
||||||
|
|
||||||
// optional args
|
|
||||||
|
|
||||||
int comflag = 0;
|
|
||||||
|
|
||||||
int iarg = 3;
|
|
||||||
while (iarg < narg) {
|
|
||||||
if (strcmp(arg[iarg],"com") == 0) {
|
|
||||||
if (iarg+2 > narg) error->all("Illegal fix store/coord command");
|
|
||||||
if (strcmp(arg[iarg+1],"no") == 0) comflag = 0;
|
|
||||||
else if (strcmp(arg[iarg+1],"yes") == 0) comflag = 1;
|
|
||||||
else error->all("Illegal fix store/coord command");
|
|
||||||
iarg += 2;
|
|
||||||
} else error->all("Illegal fix store/coord command");
|
|
||||||
}
|
|
||||||
|
|
||||||
// perform initial allocation of atom-based array
|
|
||||||
// register with Atom class
|
|
||||||
|
|
||||||
xoriginal = NULL;
|
|
||||||
grow_arrays(atom->nmax);
|
|
||||||
atom->add_callback(0);
|
|
||||||
atom->add_callback(1);
|
|
||||||
|
|
||||||
// cm = original center of mass
|
|
||||||
|
|
||||||
double cm[3];
|
|
||||||
if (comflag) {
|
|
||||||
double masstotal = group->mass(igroup);
|
|
||||||
group->xcm(igroup,masstotal,cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
// xoriginal = initial unwrapped positions of atoms
|
|
||||||
// relative to center of mass if comflag is set
|
|
||||||
|
|
||||||
double **x = atom->x;
|
|
||||||
int *mask = atom->mask;
|
|
||||||
int *image = atom->image;
|
|
||||||
int nlocal = atom->nlocal;
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
|
||||||
if (mask[i] & groupbit) {
|
|
||||||
domain->unmap(x[i],image[i],xoriginal[i]);
|
|
||||||
if (comflag) {
|
|
||||||
xoriginal[i][0] -= cm[0];
|
|
||||||
xoriginal[i][1] -= cm[1];
|
|
||||||
xoriginal[i][2] -= cm[2];
|
|
||||||
}
|
|
||||||
} else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
FixStoreCoord::~FixStoreCoord()
|
|
||||||
{
|
|
||||||
// unregister callbacks to this fix from Atom class
|
|
||||||
|
|
||||||
atom->delete_callback(id,0);
|
|
||||||
atom->delete_callback(id,1);
|
|
||||||
|
|
||||||
memory->destroy_2d_double_array(xoriginal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixStoreCoord::setmask()
|
|
||||||
{
|
|
||||||
int mask = 0;
|
|
||||||
return mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
memory usage of local atom-based array
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
double FixStoreCoord::memory_usage()
|
|
||||||
{
|
|
||||||
double bytes = atom->nmax*3 * sizeof(double);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
allocate atom-based array
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void FixStoreCoord::grow_arrays(int nmax)
|
|
||||||
{
|
|
||||||
xoriginal =
|
|
||||||
memory->grow_2d_double_array(xoriginal,nmax,3,"fix_msd:xoriginal");
|
|
||||||
array_atom = xoriginal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
copy values within local atom-based array
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void FixStoreCoord::copy_arrays(int i, int j)
|
|
||||||
{
|
|
||||||
xoriginal[j][0] = xoriginal[i][0];
|
|
||||||
xoriginal[j][1] = xoriginal[i][1];
|
|
||||||
xoriginal[j][2] = xoriginal[i][2];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
pack values in local atom-based array for exchange with another proc
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixStoreCoord::pack_exchange(int i, double *buf)
|
|
||||||
{
|
|
||||||
buf[0] = xoriginal[i][0];
|
|
||||||
buf[1] = xoriginal[i][1];
|
|
||||||
buf[2] = xoriginal[i][2];
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
unpack values in local atom-based array from exchange with another proc
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixStoreCoord::unpack_exchange(int nlocal, double *buf)
|
|
||||||
{
|
|
||||||
xoriginal[nlocal][0] = buf[0];
|
|
||||||
xoriginal[nlocal][1] = buf[1];
|
|
||||||
xoriginal[nlocal][2] = buf[2];
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
pack values in local atom-based arrays for restart file
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixStoreCoord::pack_restart(int i, double *buf)
|
|
||||||
{
|
|
||||||
buf[0] = 4;
|
|
||||||
buf[1] = xoriginal[i][0];
|
|
||||||
buf[2] = xoriginal[i][1];
|
|
||||||
buf[3] = xoriginal[i][2];
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
unpack values from atom->extra array to restart the fix
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void FixStoreCoord::unpack_restart(int nlocal, int nth)
|
|
||||||
{
|
|
||||||
double **extra = atom->extra;
|
|
||||||
|
|
||||||
// skip to Nth set of extra values
|
|
||||||
|
|
||||||
int m = 0;
|
|
||||||
for (int i = 0; i < nth; i++) m += static_cast<int> (extra[nlocal][m]);
|
|
||||||
m++;
|
|
||||||
|
|
||||||
xoriginal[nlocal][0] = extra[nlocal][m++];
|
|
||||||
xoriginal[nlocal][1] = extra[nlocal][m++];
|
|
||||||
xoriginal[nlocal][2] = extra[nlocal][m++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
maxsize of any atom's restart data
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixStoreCoord::maxsize_restart()
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
size of atom nlocal's restart data
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixStoreCoord::size_restart(int nlocal)
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
/* ----------------------------------------------------------------------
|
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
|
||||||
|
|
||||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
||||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
|
||||||
certain rights in this software. This software is distributed under
|
|
||||||
the GNU General Public License.
|
|
||||||
|
|
||||||
See the README file in the top-level LAMMPS directory.
|
|
||||||
------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#ifdef FIX_CLASS
|
|
||||||
|
|
||||||
FixStyle(store/coord,FixStoreCoord)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifndef LMP_FIX_STORE_COORD_H
|
|
||||||
#define LMP_FIX_STORE_COORD_H
|
|
||||||
|
|
||||||
#include "fix.h"
|
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
|
||||||
|
|
||||||
class FixStoreCoord : public Fix {
|
|
||||||
public:
|
|
||||||
FixStoreCoord(class LAMMPS *, int, char **);
|
|
||||||
~FixStoreCoord();
|
|
||||||
int setmask();
|
|
||||||
|
|
||||||
double memory_usage();
|
|
||||||
void grow_arrays(int);
|
|
||||||
void copy_arrays(int, int);
|
|
||||||
int pack_exchange(int, double *);
|
|
||||||
int unpack_exchange(int, double *);
|
|
||||||
int pack_restart(int, double *);
|
|
||||||
void unpack_restart(int, int);
|
|
||||||
int size_restart(int);
|
|
||||||
int maxsize_restart();
|
|
||||||
|
|
||||||
private:
|
|
||||||
double **xoriginal; // original coords of atoms
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user