Merge branch 'master' into feature-cnt

This commit is contained in:
Axel Kohlmeyer
2020-06-12 05:53:17 -04:00
572 changed files with 83637 additions and 10156 deletions

View File

@ -16,6 +16,7 @@
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include "style_atom.h"
#include "atom_vec.h"
#include "atom_vec_ellipsoid.h"
@ -47,8 +48,6 @@ using namespace MathConst;
#define DELTA_PERATOM 64
#define EPSILON 1.0e-6
enum{DOUBLE,INT,BIGINT};
/* ---------------------------------------------------------------------- */
Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
@ -699,7 +698,7 @@ void Atom::set_atomflag_defaults()
called from lammps.cpp, input script, restart file, replicate
------------------------------------------------------------------------- */
void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix)
void Atom::create_avec(const std::string &style, int narg, char **arg, int trysuffix)
{
delete [] atom_style;
if (avec) delete avec;
@ -722,16 +721,14 @@ void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix)
avec->grow(1);
if (sflag) {
char estyle[256];
if (sflag == 1) snprintf(estyle,256,"%s/%s",style,lmp->suffix);
else snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
int n = strlen(estyle) + 1;
atom_style = new char[n];
strcpy(atom_style,estyle);
std::string estyle = style + "/";
if (sflag == 1) estyle += lmp->suffix;
else estyle += lmp->suffix2;
atom_style = new char[estyle.size()+1];
strcpy(atom_style,estyle.c_str());
} else {
int n = strlen(style) + 1;
atom_style = new char[n];
strcpy(atom_style,style);
atom_style = new char[style.size()+1];
strcpy(atom_style,style.c_str());
}
// if molecular system:
@ -749,13 +746,12 @@ void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix)
generate an AtomVec class, first with suffix appended
------------------------------------------------------------------------- */
AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
AtomVec *Atom::new_avec(const std::string &style, int trysuffix, int &sflag)
{
if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) {
sflag = 1;
char estyle[256];
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
std::string estyle = style + "/" + lmp->suffix;
if (avec_map->find(estyle) != avec_map->end()) {
AtomVecCreator avec_creator = (*avec_map)[estyle];
return avec_creator(lmp);
@ -764,8 +760,7 @@ AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
if (lmp->suffix2) {
sflag = 2;
char estyle[256];
snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
std::string estyle = style + "/" + lmp->suffix2;
if (avec_map->find(estyle) != avec_map->end()) {
AtomVecCreator avec_creator = (*avec_map)[estyle];
return avec_creator(lmp);
@ -779,7 +774,7 @@ AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag)
return avec_creator(lmp);
}
error->all(FLERR,utils::check_packages_for_style("atom",style,lmp).c_str());
error->all(FLERR,utils::check_packages_for_style("atom",style,lmp));
return NULL;
}
@ -1049,56 +1044,6 @@ void Atom::bonus_check()
"atoms with enabled body flags");
}
/* ----------------------------------------------------------------------
count and return words in a single line
make copy of line before using strtok so as not to change line
trim anything from '#' onward
------------------------------------------------------------------------- */
int Atom::count_words(const char *line)
{
int n = strlen(line) + 1;
char *copy;
memory->create(copy,n,"atom:copy");
strcpy(copy,line);
char *ptr;
if ((ptr = strchr(copy,'#'))) *ptr = '\0';
if (strtok(copy," \t\n\r\f") == NULL) {
memory->destroy(copy);
return 0;
}
n = 1;
while (strtok(NULL," \t\n\r\f")) n++;
memory->destroy(copy);
return n;
}
/* ----------------------------------------------------------------------
count and return words in a single line using provided copy buf
make copy of line before using strtok so as not to change line
trim anything from '#' onward
------------------------------------------------------------------------- */
int Atom::count_words(const char *line, char *copy)
{
strcpy(copy,line);
char *ptr;
if ((ptr = strchr(copy,'#'))) *ptr = '\0';
if (strtok(copy," \t\n\r\f") == NULL) {
memory->destroy(copy);
return 0;
}
int n = 1;
while (strtok(NULL," \t\n\r\f")) n++;
return n;
}
/* ----------------------------------------------------------------------
deallocate molecular topology arrays
done before realloc with (possibly) new 2nd dimension set to
@ -1157,7 +1102,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
next = strchr(buf,'\n');
*next = '\0';
int nwords = count_words(buf);
int nwords = utils::trim_and_count_words(buf);
*next = '\n';
if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3)
@ -1307,7 +1252,7 @@ void Atom::data_vels(int n, char *buf, tagint id_offset)
next = strchr(buf,'\n');
*next = '\0';
int nwords = count_words(buf);
int nwords = utils::trim_and_count_words(buf);
*next = '\n';
if (nwords != avec->size_data_vel)
@ -1659,7 +1604,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset)
next = strchr(buf,'\n');
*next = '\0';
int nwords = count_words(buf);
int nwords = utils::trim_and_count_words(buf);
*next = '\n';
if (nwords != avec_bonus->size_data_bonus)