Merge branch 'lammps:master' into type-labels
This commit is contained in:
51
src/atom.cpp
51
src/atom.cpp
@ -36,7 +36,6 @@
|
||||
#include "library.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef LMP_INTEL
|
||||
@ -45,6 +44,7 @@
|
||||
|
||||
#ifdef LMP_GPU
|
||||
#include "fix_gpu.h"
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -275,7 +275,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
#define ATOM_CLASS
|
||||
#define AtomStyle(key,Class) \
|
||||
(*avec_map)[#key] = &avec_creator<Class>;
|
||||
#include "style_atom.h"
|
||||
#include "style_atom.h" // IWYU pragma: keep
|
||||
#undef AtomStyle
|
||||
#undef ATOM_CLASS
|
||||
}
|
||||
@ -362,7 +362,7 @@ Atom::~Atom()
|
||||
|
||||
// delete mapping data structures
|
||||
|
||||
map_delete();
|
||||
Atom::map_delete();
|
||||
|
||||
delete unique_tags;
|
||||
}
|
||||
@ -677,7 +677,7 @@ void Atom::set_atomflag_defaults()
|
||||
|
||||
void Atom::create_avec(const std::string &style, int narg, char **arg, int trysuffix)
|
||||
{
|
||||
delete [] atom_style;
|
||||
delete[] atom_style;
|
||||
if (avec) delete avec;
|
||||
atom_style = nullptr;
|
||||
avec = nullptr;
|
||||
@ -701,11 +701,9 @@ void Atom::create_avec(const std::string &style, int narg, char **arg, int trysu
|
||||
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());
|
||||
atom_style = utils::strdup(estyle);
|
||||
} else {
|
||||
atom_style = new char[style.size()+1];
|
||||
strcpy(atom_style,style.c_str());
|
||||
atom_style = utils::strdup(style);
|
||||
}
|
||||
|
||||
// if molecular system:
|
||||
@ -836,17 +834,13 @@ void Atom::modify_params(int narg, char **arg)
|
||||
if (strcmp(arg[iarg],"id") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command");
|
||||
if (domain->box_exist)
|
||||
error->all(FLERR,
|
||||
"Atom_modify id command after simulation box is defined");
|
||||
if (strcmp(arg[iarg+1],"yes") == 0) tag_enable = 1;
|
||||
else if (strcmp(arg[iarg+1],"no") == 0) tag_enable = 0;
|
||||
else error->all(FLERR,"Illegal atom_modify command");
|
||||
error->all(FLERR,"Atom_modify id command after simulation box is defined");
|
||||
tag_enable = utils::logical(FLERR,arg[iarg+1],false,lmp);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"map") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command");
|
||||
if (domain->box_exist)
|
||||
error->all(FLERR,
|
||||
"Atom_modify map command after simulation box is defined");
|
||||
error->all(FLERR,"Atom_modify map command after simulation box is defined");
|
||||
if (strcmp(arg[iarg+1],"array") == 0) map_user = 1;
|
||||
else if (strcmp(arg[iarg+1],"hash") == 0) map_user = 2;
|
||||
else if (strcmp(arg[iarg+1],"yes") == 0) map_user = 3;
|
||||
@ -2545,7 +2539,7 @@ This function is called, e.g. from :doc:`fix property/atom <fix_property_atom>`.
|
||||
*/
|
||||
int Atom::add_custom(const char *name, int flag, int cols)
|
||||
{
|
||||
int index;
|
||||
int index = -1;
|
||||
|
||||
if ((flag == 0) && (cols == 0)) {
|
||||
index = nivector;
|
||||
@ -2585,7 +2579,8 @@ int Atom::add_custom(const char *name, int flag, int cols)
|
||||
dcols = (int *) memory->srealloc(dcols,ndarray*sizeof(int),"atom:dcols");
|
||||
dcols[index] = cols;
|
||||
}
|
||||
|
||||
if (index < 0)
|
||||
error->all(FLERR,"Invalid call to Atom::add_custom()");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -2606,27 +2601,27 @@ void Atom::remove_custom(int index, int flag, int cols)
|
||||
{
|
||||
if (flag == 0 && cols == 0) {
|
||||
memory->destroy(ivector[index]);
|
||||
ivector[index] = NULL;
|
||||
ivector[index] = nullptr;
|
||||
delete [] ivname[index];
|
||||
ivname[index] = NULL;
|
||||
ivname[index] = nullptr;
|
||||
|
||||
} else if (flag == 1 && cols == 0) {
|
||||
memory->destroy(dvector[index]);
|
||||
dvector[index] = NULL;
|
||||
dvector[index] = nullptr;
|
||||
delete [] dvname[index];
|
||||
dvname[index] = NULL;
|
||||
dvname[index] = nullptr;
|
||||
|
||||
} else if (flag == 0 && cols) {
|
||||
memory->destroy(iarray[index]);
|
||||
iarray[index] = NULL;
|
||||
iarray[index] = nullptr;
|
||||
delete [] ianame[index];
|
||||
ianame[index] = NULL;
|
||||
ianame[index] = nullptr;
|
||||
|
||||
} else if (flag == 1 && cols) {
|
||||
memory->destroy(darray[index]);
|
||||
darray[index] = NULL;
|
||||
darray[index] = nullptr;
|
||||
delete [] daname[index];
|
||||
daname[index] = NULL;
|
||||
daname[index] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2859,9 +2854,9 @@ void *Atom::extract(const char *name)
|
||||
if (!array) index = find_custom(&name[2],flag,cols);
|
||||
else index = find_custom(&name[3],flag,cols);
|
||||
|
||||
if (index < 0) return NULL;
|
||||
if (which != flag) return NULL;
|
||||
if ((!array && cols) || (array && !cols)) return NULL;
|
||||
if (index < 0) return nullptr;
|
||||
if (which != flag) return nullptr;
|
||||
if ((!array && cols) || (array && !cols)) return nullptr;
|
||||
|
||||
if (!which && !array) return (void *) ivector[index];
|
||||
if (which && !array) return (void *) dvector[index];
|
||||
|
||||
Reference in New Issue
Block a user