diff --git a/src/atom.cpp b/src/atom.cpp index 7cc7f1c8ca..0574dc5465 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1754,6 +1754,19 @@ void Atom::allocate_type_labels() delete [] char_type; } +/* ---------------------------------------------------------------------- + find integer type given a type label + return -1 if type not yet defined +------------------------------------------------------------------------- */ + +int Atom::find_type(char *typelabel, char **typelabelarray, int num_types) +{ + for (int i = 0; i < num_types; i++) { + if (typelabelarray[i] && strcmp(typelabel,typelabelarray[i]) == 0) return i+1; + } + return -1; +} + /* ---------------------------------------------------------------------- set a mass and flag it as set called from reading of data file diff --git a/src/atom.h b/src/atom.h index ad2834a9f7..a4cb651d8a 100644 --- a/src/atom.h +++ b/src/atom.h @@ -310,6 +310,7 @@ class Atom : protected Pointers { virtual void allocate_type_arrays(); void allocate_type_labels(); + int find_type(char *, char **, int); void set_mass(const char *, int, const char *, int); void set_mass(const char *, int, int, double); void set_mass(const char *, int, int, char **);