move varstyle array definition to Variable class so it can be used in a more general way

This commit is contained in:
Axel Kohlmeyer
2024-05-22 23:42:56 -04:00
parent a8687b5372
commit c1538c2f78
3 changed files with 11 additions and 9 deletions

View File

@ -110,12 +110,6 @@ static const int STYLES = ATOM_STYLES | INTEGRATE_STYLES | MINIMIZE_STYLES
using namespace LAMMPS_NS;
// must match enumerator in variable.h
static const char *varstyles[] = {
"index", "loop", "world", "universe", "uloop", "string", "getenv",
"file", "atomfile", "format", "equal", "atom", "vector", "python",
"timer", "internal", "(unknown)"};
static const char *mapstyles[] = { "none", "array", "hash", "yes" };
static const char *commstyles[] = { "brick", "tiled" };
@ -1401,7 +1395,7 @@ std::string Info::get_variable_info(int num) {
std::string text;
int ndata = 1;
text = fmt::format("Variable[{:3d}]: {:16} style = {:16} def =", num,
std::string(names[num]) + ',', std::string(varstyles[style[num]]) + ',');
std::string(names[num]) + ',', Variable::varstyles[style[num]] + ',');
if (style[num] == Variable::INTERNAL) {
text += fmt::format("{:.8}\n",input->variable->dvalue[num]);
return text;

View File

@ -54,6 +54,12 @@ static constexpr int MAXLINE = 256;
static constexpr int CHUNK = 1024;
static constexpr int MAXFUNCARG = 6;
// must match enumerator in variable.h
const std::vector<std::string> Variable::varstyles = {
"index", "loop", "world", "universe", "uloop", "string", "getenv",
"file", "atomfile", "format", "equal", "atom", "vector", "python",
"timer", "internal", "(unknown)"};
static inline double MYROUND(double a) { return ((a - floor(a)) >= 0.5) ? ceil(a) : floor(a); }
enum{ARG,OP};

View File

@ -56,7 +56,7 @@ class Variable : protected Pointers {
int nvar; // # of defined variables
char **names; // name of each variable
// must match "varstyles" array in info.cpp
// must match "varstyles" array in variables.cpp, UNKNOWN must be last.
enum {
INDEX,
LOOP,
@ -73,9 +73,11 @@ class Variable : protected Pointers {
VECTOR,
PYTHON,
TIMER,
INTERNAL
INTERNAL,
UNKNOWN
};
static constexpr int VALUELENGTH = 64;
static const std::vector<std::string> varstyles;
private:
int me;