diff --git a/src/thermo.cpp b/src/thermo.cpp index 31c19fbdc2..1c07da695f 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -201,6 +201,8 @@ void Thermo::init() ValueTokenizer *format_line = nullptr; if (format_line_user.size()) format_line = new ValueTokenizer(format_line_user); + field_data.clear(); + field_data.resize(nfield); std::string format_this, format_line_user_def; for (int i = 0; i < nfield; i++) { @@ -208,6 +210,14 @@ void Thermo::init() format_this.clear(); format_line_user_def.clear(); + if (vtype[i] == FLOAT) { + field_data[i] = (double) 0.0; + } else if (vtype[i] == INT) { + field_data[i] = (int) 0; + } else if (vtype[i] == BIGINT) { + field_data[i] = (bigint) 0; + } + if ((lineflag == MULTILINE) && ((i % 3) == 0)) format[i] += "\n"; if ((lineflag == YAMLLINE) && (i == 0)) format[i] += " - ["; if (format_line) format_line_user_def = format_line->next_string(); diff --git a/src/thermo.h b/src/thermo.h index 8a5cba29d7..f22f3103b0 100644 --- a/src/thermo.h +++ b/src/thermo.h @@ -43,6 +43,7 @@ class Thermo : protected Pointers { int evaluate_keyword(const std::string &, double *); // for accessing cached thermo data + int get_nfield() const { return nfield; } bigint get_timestep() const { return ntimestep; } const std::vector &get_fields() const { return field_data; } const std::vector &get_keywords() const { return keyword; }