multi-data-file support for bond, angles, diheddral, impropers
This commit is contained in:
13
src/atom.cpp
13
src/atom.cpp
@ -611,6 +611,7 @@ void Atom::set_atomflag_defaults()
|
||||
// 3rd customization section: customize by adding new flag
|
||||
// identical list as 2nd customization in atom.h
|
||||
|
||||
labelmapflag = 0;
|
||||
sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
|
||||
peri_flag = electron_flag = 0;
|
||||
wavepacket_flag = sph_flag = 0;
|
||||
@ -1247,7 +1248,7 @@ void Atom::data_vels(int n, char *buf, tagint id_offset)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
|
||||
int type_offset)
|
||||
int type_offset, int labelflag, int *ilabel)
|
||||
{
|
||||
int m,tmp,itype,rv;
|
||||
tagint atom1,atom2;
|
||||
@ -1265,6 +1266,7 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
|
||||
atom1 += id_offset;
|
||||
atom2 += id_offset;
|
||||
}
|
||||
if (labelflag) itype = ilabel[itype-1];
|
||||
itype += type_offset;
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
@ -1302,7 +1304,7 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
||||
int type_offset)
|
||||
int type_offset, int labelflag, int *ilabel)
|
||||
{
|
||||
int m,tmp,itype,rv;
|
||||
tagint atom1,atom2,atom3;
|
||||
@ -1321,6 +1323,7 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
||||
atom2 += id_offset;
|
||||
atom3 += id_offset;
|
||||
}
|
||||
if (labelflag) itype = ilabel[itype-1];
|
||||
itype += type_offset;
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
@ -1374,7 +1377,7 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
||||
int type_offset)
|
||||
int type_offset, int labelflag, int *ilabel)
|
||||
{
|
||||
int m,tmp,itype,rv;
|
||||
tagint atom1,atom2,atom3,atom4;
|
||||
@ -1395,6 +1398,7 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
||||
atom3 += id_offset;
|
||||
atom4 += id_offset;
|
||||
}
|
||||
if (labelflag) itype = ilabel[itype-1];
|
||||
itype += type_offset;
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
@ -1465,7 +1469,7 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
|
||||
int type_offset)
|
||||
int type_offset, int labelflag, int *ilabel)
|
||||
{
|
||||
int m,tmp,itype,rv;
|
||||
tagint atom1,atom2,atom3,atom4;
|
||||
@ -1486,6 +1490,7 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
|
||||
atom3 += id_offset;
|
||||
atom4 += id_offset;
|
||||
}
|
||||
if (labelflag) itype = ilabel[itype-1];
|
||||
itype += type_offset;
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
|
||||
@ -166,6 +166,7 @@ class Atom : protected Pointers {
|
||||
// most are existence flags for per-atom vectors and arrays
|
||||
// 1 if variable is used, 0 if not
|
||||
|
||||
int labelmapflag; // type labels
|
||||
int sphere_flag,ellipsoid_flag,line_flag,tri_flag,body_flag;
|
||||
int peri_flag,electron_flag;
|
||||
int wavepacket_flag,sph_flag;
|
||||
@ -304,10 +305,10 @@ class Atom : protected Pointers {
|
||||
void data_atoms(int, char *, tagint, tagint, int, int, double *,
|
||||
int, int *);
|
||||
void data_vels(int, char *, tagint);
|
||||
void data_bonds(int, char *, int *, tagint, int);
|
||||
void data_angles(int, char *, int *, tagint, int);
|
||||
void data_dihedrals(int, char *, int *, tagint, int);
|
||||
void data_impropers(int, char *, int *, tagint, int);
|
||||
void data_bonds(int, char *, int *, tagint, int, int, int *);
|
||||
void data_angles(int, char *, int *, tagint, int, int, int *);
|
||||
void data_dihedrals(int, char *, int *, tagint, int, int, int *);
|
||||
void data_impropers(int, char *, int *, tagint, int, int, int *);
|
||||
void data_bonus(int, char *, AtomVec *, tagint);
|
||||
void data_bodies(int, char *, AtomVec *, tagint);
|
||||
void data_fix_compute_variable(int, int);
|
||||
|
||||
@ -124,7 +124,7 @@ void ReadData::command(int narg, char **arg)
|
||||
addflag = NONE;
|
||||
coeffflag = 1;
|
||||
id_offset = mol_offset = 0;
|
||||
offsetflag = shiftflag = labelflag = 0;
|
||||
offsetflag = shiftflag = settypeflag = labelflag = 0;
|
||||
toffset = boffset = aoffset = doffset = ioffset = 0;
|
||||
shift[0] = shift[1] = shift[2] = 0.0;
|
||||
extra_atom_types = extra_bond_types = extra_angle_types =
|
||||
@ -1379,7 +1379,8 @@ void ReadData::bonds(int firstpass)
|
||||
nchunk = MIN(nbonds-nread,CHUNK);
|
||||
eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer);
|
||||
if (eof) error->all(FLERR,"Unexpected end of data file");
|
||||
atom->data_bonds(nchunk,buffer,count,id_offset,boffset);
|
||||
atom->data_bonds(nchunk,buffer,count,id_offset,boffset,
|
||||
labelflag,lmap->lmap2lmap.bond);
|
||||
nread += nchunk;
|
||||
}
|
||||
|
||||
@ -1453,7 +1454,8 @@ void ReadData::angles(int firstpass)
|
||||
nchunk = MIN(nangles-nread,CHUNK);
|
||||
eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer);
|
||||
if (eof) error->all(FLERR,"Unexpected end of data file");
|
||||
atom->data_angles(nchunk,buffer,count,id_offset,aoffset);
|
||||
atom->data_angles(nchunk,buffer,count,id_offset,aoffset,
|
||||
labelflag,lmap->lmap2lmap.angle);
|
||||
nread += nchunk;
|
||||
}
|
||||
|
||||
@ -1527,7 +1529,8 @@ void ReadData::dihedrals(int firstpass)
|
||||
nchunk = MIN(ndihedrals-nread,CHUNK);
|
||||
eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer);
|
||||
if (eof) error->all(FLERR,"Unexpected end of data file");
|
||||
atom->data_dihedrals(nchunk,buffer,count,id_offset,doffset);
|
||||
atom->data_dihedrals(nchunk,buffer,count,id_offset,doffset,
|
||||
labelflag,lmap->lmap2lmap.dihedral);
|
||||
nread += nchunk;
|
||||
}
|
||||
|
||||
@ -1601,7 +1604,8 @@ void ReadData::impropers(int firstpass)
|
||||
nchunk = MIN(nimpropers-nread,CHUNK);
|
||||
eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer);
|
||||
if (eof) error->all(FLERR,"Unexpected end of data file");
|
||||
atom->data_impropers(nchunk,buffer,count,id_offset,ioffset);
|
||||
atom->data_impropers(nchunk,buffer,count,id_offset,ioffset,
|
||||
labelflag,lmap->lmap2lmap.improper);
|
||||
nread += nchunk;
|
||||
}
|
||||
|
||||
@ -1789,6 +1793,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr)
|
||||
|
||||
void ReadData::mass()
|
||||
{
|
||||
settypeflag = 1;
|
||||
char *next;
|
||||
char *buf = new char[ntypes*MAXLINE];
|
||||
|
||||
@ -1965,11 +1970,13 @@ void ReadData::impropercoeffs(int which)
|
||||
|
||||
void ReadData::typelabels(std::vector<std::string> &mytypelabel, int myntypes, int mode)
|
||||
{
|
||||
if (settypeflag) error->all(FLERR,"Must read Type Labels before any section involving types");
|
||||
int n;
|
||||
char *next;
|
||||
char *buf = new char[myntypes*MAXLINE];
|
||||
|
||||
labelflag = 1;
|
||||
atom->labelmapflag = 1;
|
||||
|
||||
int eof = comm->read_lines_from_file(fp,myntypes,MAXLINE,buf);
|
||||
if (eof) error->all(FLERR,"Unexpected end of data file");
|
||||
@ -2158,6 +2165,7 @@ void ReadData::skip_lines(bigint n)
|
||||
void ReadData::parse_coeffs(char *line, const char *addstr, int dupflag,
|
||||
int noffset, int offset, int *ilabel)
|
||||
{
|
||||
settypeflag = 1;
|
||||
char *ptr;
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class ReadData : protected Pointers {
|
||||
|
||||
// optional args
|
||||
|
||||
int addflag,offsetflag,shiftflag,coeffflag,labelflag;
|
||||
int addflag,offsetflag,shiftflag,coeffflag,settypeflag,labelflag;
|
||||
tagint addvalue;
|
||||
int toffset,boffset,aoffset,doffset,ioffset;
|
||||
double shift[3];
|
||||
@ -264,6 +264,11 @@ E: Must read Atoms before Bodies
|
||||
|
||||
The Atoms section of a data file must come before a Bodies section.
|
||||
|
||||
E: Must read Type Labels before any section involving types
|
||||
|
||||
All Type Labels sections of a data file must come before any
|
||||
section that uses per-type values (Masses, Coeffs, etc.).
|
||||
|
||||
E: Must define pair_style before Pair Coeffs
|
||||
|
||||
Must use a pair_style command before reading a data file that defines
|
||||
|
||||
@ -186,7 +186,7 @@ void WriteData::write(const std::string &file)
|
||||
|
||||
if (me == 0) {
|
||||
header();
|
||||
atom->lmap->write_data(fp); // NOTE: always write for now, for testing
|
||||
if (atom->labelmapflag) atom->lmap->write_data(fp);
|
||||
type_arrays();
|
||||
if (coeffflag) force_fields();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user