Merge branch 'fix-property-array' of github.com:lammps/lammps into fix-property-array
This commit is contained in:
@ -1532,15 +1532,12 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
||||
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||
if (argindex[iarg] == 0) {
|
||||
if (!flag || cols)
|
||||
error->all(FLERR,
|
||||
"Property double vector for dump custom does not exist");
|
||||
error->all(FLERR,"Property double vector for dump custom does not exist");
|
||||
} else {
|
||||
if (!flag || !cols)
|
||||
error->all(FLERR,
|
||||
"Property double array for dump custom does not exist");
|
||||
error->all(FLERR,"Property double array for dump custom does not exist");
|
||||
if (argindex[iarg] > atom->dcols[n])
|
||||
error->all(FLERR,
|
||||
"Dump custom property array is accessed out-of-range");
|
||||
error->all(FLERR,"Dump custom property array is accessed out-of-range");
|
||||
}
|
||||
|
||||
field2index[iarg] = add_custom(name,1);
|
||||
|
||||
@ -66,8 +66,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"q") == 0) {
|
||||
if (atom->q_flag)
|
||||
error->all(FLERR,"Fix property/atom q when atom_style "
|
||||
"already has charge attribute");
|
||||
error->all(FLERR,"Fix property/atom q when atom_style already has charge attribute");
|
||||
if (q_flag)
|
||||
error->all(FLERR,"Fix property/atom cannot specify q twice");
|
||||
style[nvalue] = CHARGE;
|
||||
@ -78,8 +77,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"rmass") == 0) {
|
||||
if (atom->rmass_flag)
|
||||
error->all(FLERR,"Fix property/atom rmass when atom_style "
|
||||
"already has rmass attribute");
|
||||
error->all(FLERR,"Fix property/atom rmass when atom_style already has rmass attribute");
|
||||
if (rmass_flag)
|
||||
error->all(FLERR,"Fix property/atom cannot specify rmass twice");
|
||||
style[nvalue] = RMASS;
|
||||
@ -93,11 +91,13 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
} else if (utils::strmatch(arg[iarg],"^i_")) {
|
||||
style[nvalue] = IVEC;
|
||||
int flag,cols;
|
||||
index[nvalue] = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||
int flag,ncols;
|
||||
index[nvalue] = atom->find_custom(&arg[iarg][2],flag,ncols);
|
||||
if (index[nvalue] >= 0)
|
||||
error->all(FLERR,"Fix property/atom vector name already exists");
|
||||
index[nvalue] = atom->add_custom(&arg[iarg][2],0,0);
|
||||
cols[nvalue] = 0;
|
||||
values_peratom++;
|
||||
nvalue++;
|
||||
iarg++;
|
||||
|
||||
@ -108,6 +108,8 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (index[nvalue] >= 0)
|
||||
error->all(FLERR,"Fix property/atom vector name already exists");
|
||||
index[nvalue] = atom->add_custom(&arg[iarg][2],1,0);
|
||||
cols[nvalue] = 0;
|
||||
values_peratom++;
|
||||
nvalue++;
|
||||
iarg++;
|
||||
|
||||
@ -252,8 +254,7 @@ void FixPropertyAtom::init()
|
||||
id_offset is applied to first atomID field if multiple data files are read
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||
tagint id_offset)
|
||||
void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, tagint id_offset)
|
||||
{
|
||||
int j,k,m,ncol;
|
||||
tagint itag;
|
||||
@ -278,14 +279,13 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||
|
||||
try {
|
||||
ValueTokenizer values(buf);
|
||||
if ((int)values.count() != nvalue+1)
|
||||
error->all(FLERR,"Incorrect format in {} section "
|
||||
"of data file: {}",keyword,buf);
|
||||
if ((int)values.count() != values_peratom+1)
|
||||
error->all(FLERR,"Incorrect format in {} section of data file: {}"
|
||||
" expected {} and got {}",keyword,buf,values_peratom+1,values.count());
|
||||
|
||||
itag = values.next_tagint() + id_offset;
|
||||
if (itag <= 0 || itag > map_tag_max)
|
||||
error->all(FLERR,"Invalid atom ID {} in {} section of "
|
||||
"data file",itag, keyword);
|
||||
error->all(FLERR,"Invalid atom ID {} in {} section of data file",itag, keyword);
|
||||
|
||||
// assign words in line to per-atom vectors
|
||||
|
||||
@ -301,7 +301,6 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||
atom->ivector[index[j]][m] = values.next_int();
|
||||
} else if (style[j] == DVEC) {
|
||||
atom->dvector[index[j]][m] = values.next_double();
|
||||
// NOTE: Axel please check these lines of array code
|
||||
} else if (style[j] == IARRAY) {
|
||||
ncol = cols[j];
|
||||
for (k = 0; k < ncol; k++)
|
||||
@ -314,8 +313,7 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException &e) {
|
||||
error->all(FLERR,"Invalid format in {} section of data "
|
||||
"file '{}': {}",keyword, buf,e.what());
|
||||
error->all(FLERR,"Invalid format in {} section of data file '{}': {}",keyword, buf,e.what());
|
||||
}
|
||||
buf = next + 1;
|
||||
}
|
||||
|
||||
@ -627,36 +627,32 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// expansion will take place
|
||||
// expansion will take place
|
||||
|
||||
if (expandflag) {
|
||||
if (expandflag) {
|
||||
|
||||
// expand wild card string to nlo/nhi numbers
|
||||
utils::bounds(file, line, wc, 1, nmax, nlo, nhi, lmp->error);
|
||||
// expand wild card string to nlo/nhi numbers
|
||||
utils::bounds(file, line, wc, 1, nmax, nlo, nhi, lmp->error);
|
||||
|
||||
if (newarg + nhi - nlo + 1 > maxarg) {
|
||||
maxarg += nhi - nlo + 1;
|
||||
earg = (char **) lmp->memory->srealloc(earg, maxarg * sizeof(char *), "input:earg");
|
||||
}
|
||||
if (newarg + nhi - nlo + 1 > maxarg) {
|
||||
maxarg += nhi - nlo + 1;
|
||||
earg = (char **) lmp->memory->srealloc(earg, maxarg * sizeof(char *), "input:earg");
|
||||
}
|
||||
|
||||
for (int index = nlo; index <= nhi; index++) {
|
||||
// assemble and duplicate expanded string
|
||||
if (word[1] == '2')
|
||||
earg[newarg] = utils::strdup(fmt::format("{}2_{}[{}]{}", word[0], id, index, tail));
|
||||
else
|
||||
earg[newarg] = utils::strdup(fmt::format("{}_{}[{}]{}", word[0], id, index, tail));
|
||||
newarg++;
|
||||
}
|
||||
} else {
|
||||
// no expansion: duplicate original string
|
||||
if (newarg == maxarg) {
|
||||
maxarg++;
|
||||
earg = (char **) lmp->memory->srealloc(earg, maxarg * sizeof(char *), "input:earg");
|
||||
}
|
||||
earg[newarg] = utils::strdup(word);
|
||||
for (int index = nlo; index <= nhi; index++) {
|
||||
earg[newarg] = utils::strdup(fmt::format("{}2_{}[{}]{}", word[0], id, index, tail));
|
||||
newarg++;
|
||||
}
|
||||
} else {
|
||||
// no expansion: duplicate original string
|
||||
if (newarg == maxarg) {
|
||||
maxarg++;
|
||||
earg = (char **) lmp->memory->srealloc(earg, maxarg * sizeof(char *), "input:earg");
|
||||
}
|
||||
earg[newarg] = utils::strdup(word);
|
||||
newarg++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4648,7 +4648,8 @@ TEST_F(AtomStyleTest, property_atom)
|
||||
command("pair_style zero 4.0");
|
||||
command("units real");
|
||||
command("atom_modify map array");
|
||||
command("fix props all property/atom i_one d_two mol d_three q rmass ghost yes");
|
||||
command("fix props all property/atom i_one d_two mol d_three q rmass "
|
||||
"i2_four 2 d2_five 3 ghost yes");
|
||||
command("read_data test_atom_styles.data fix props NULL Properties");
|
||||
command("pair_coeff * *");
|
||||
END_HIDE_OUTPUT();
|
||||
@ -4737,7 +4738,8 @@ TEST_F(AtomStyleTest, property_atom)
|
||||
command("clear");
|
||||
ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic"));
|
||||
command("read_restart test_atom_styles.restart");
|
||||
command("fix props all property/atom i_one d_two mol d_three q rmass ghost yes");
|
||||
command("fix props all property/atom i_one d_two mol d_three q rmass "
|
||||
"i2_four 2 d2_five 3 ghost yes");
|
||||
END_HIDE_OUTPUT();
|
||||
expected.natoms = 2;
|
||||
expected.nlocal = 2;
|
||||
@ -4749,7 +4751,11 @@ TEST_F(AtomStyleTest, property_atom)
|
||||
expected.has_mass_setflag = true;
|
||||
expected.has_sametag = true;
|
||||
expected.has_extra = true;
|
||||
expected.nextra_store = 7;
|
||||
expected.has_ivname = true;
|
||||
expected.has_dvname = true;
|
||||
expected.has_ianame = true;
|
||||
expected.has_daname = true;
|
||||
expected.nextra_store = 12;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
ASSERT_NE(lmp->atom->avec, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user