add accessor to nfield, make certain field types are initialized early
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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<multitype> &get_fields() const { return field_data; }
|
||||
const std::vector<std::string> &get_keywords() const { return keyword; }
|
||||
|
||||
Reference in New Issue
Block a user