From 74103b141ab39e123a43b367ce553309bbbc6ab7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 19 Mar 2022 18:01:34 -0400 Subject: [PATCH] enable and apply clang-format --- src/thermo.cpp | 740 ++++++++++++++++++++++++++----------------------- 1 file changed, 396 insertions(+), 344 deletions(-) diff --git a/src/thermo.cpp b/src/thermo.cpp index 722bb90873..649b45f18b 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -69,23 +68,24 @@ using namespace MathConst; // CUSTOMIZATION: add a new thermo style by adding a constant to the enumerator, // define a new string constant with the keywords and provide default formats. -enum{ ONELINE, MULTILINE, YAMLLINE }; +enum { ONELINE, MULTILINE, YAMLLINE }; // style "one" static constexpr char ONE[] = "step temp epair emol etotal press"; -#define FORMAT_FLOAT_ONE_DEFAULT "%12.8g" -#define FORMAT_INT_ONE_DEFAULT "%10d" +#define FORMAT_FLOAT_ONE_DEFAULT "%12.8g" +#define FORMAT_INT_ONE_DEFAULT "%10d" // style "multi" -static constexpr char MULTI[] = "etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press"; -#define FORMAT_FLOAT_MULTI_DEFAULT "%14.4f" -#define FORMAT_INT_MULTI_DEFAULT "%14d" +static constexpr char MULTI[] = + "etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press"; +#define FORMAT_FLOAT_MULTI_DEFAULT "%14.4f" +#define FORMAT_INT_MULTI_DEFAULT "%14d" // style "yaml" static constexpr char YAML[] = "step temp ke pe ebond eangle edihed eimp evdwl ecoul elong press"; -#define FORMAT_FLOAT_YAML_DEFAULT "%.15g" -#define FORMAT_INT_YAML_DEFAULT "%d" +#define FORMAT_FLOAT_YAML_DEFAULT "%.15g" +#define FORMAT_INT_YAML_DEFAULT "%d" #define FORMAT_MULTI_HEADER "------------ Step {:14} ----- CPU = {:12.7g} (sec) -------------" -enum{ SCALAR, VECTOR, ARRAY }; +enum { SCALAR, VECTOR, ARRAY }; static constexpr char id_temp[] = "thermo_temp"; static constexpr char id_press[] = "thermo_press"; @@ -97,8 +97,8 @@ static char fmtbuf[512]; /* ---------------------------------------------------------------------- */ Thermo::Thermo(LAMMPS *_lmp, int narg, char **arg) : - Pointers(_lmp), style(nullptr), vtype(nullptr), field2index(nullptr), argindex1(nullptr), - argindex2(nullptr), temperature(nullptr), pressure(nullptr), pe(nullptr) + Pointers(_lmp), style(nullptr), vtype(nullptr), field2index(nullptr), argindex1(nullptr), + argindex2(nullptr), temperature(nullptr), pressure(nullptr), pe(nullptr) { style = utils::strdup(arg[0]); @@ -116,24 +116,24 @@ Thermo::Thermo(LAMMPS *_lmp, int narg, char **arg) : // CUSTOMIZATION: add a new thermo style by adding it to the if statement // set line string with default keywords if not custom style. - if (strcmp(style,"one") == 0) { + if (strcmp(style, "one") == 0) { line = ONE; lineflag = ONELINE; - } else if (strcmp(style,"multi") == 0) { + } else if (strcmp(style, "multi") == 0) { line = MULTI; lineflag = MULTILINE; - } else if (strcmp(style,"yaml") == 0) { + } else if (strcmp(style, "yaml") == 0) { line = YAML; lineflag = YAMLLINE; - } else if (strcmp(style,"custom") == 0) { - if (narg == 1) error->all(FLERR,"Illegal thermo style custom command"); + } else if (strcmp(style, "custom") == 0) { + if (narg == 1) error->all(FLERR, "Illegal thermo style custom command"); // expand args if any have wildcard character "*" int expand = 0; char **earg; - int nvalues = utils::expand_args(FLERR,narg-1,&arg[1],0,earg,lmp); + int nvalues = utils::expand_args(FLERR, narg - 1, &arg[1], 0, earg, lmp); if (earg != &arg[1]) expand = 1; line.clear(); @@ -149,7 +149,8 @@ Thermo::Thermo(LAMMPS *_lmp, int narg, char **arg) : memory->sfree(earg); } - } else error->all(FLERR,"Illegal thermo style command"); + } else + error->all(FLERR, "Illegal thermo style command"); index_temp = index_press_scalar = index_press_vector = index_pe = -1; @@ -176,16 +177,19 @@ void Thermo::init() { // set normvalue to default setting unless user has specified it - if (normuserflag) normvalue = normuser; - else if (strcmp(update->unit_style,"lj") == 0) normvalue = 1; - else normvalue = 0; + if (normuserflag) + normvalue = normuser; + else if (strcmp(update->unit_style, "lj") == 0) + normvalue = 1; + else + normvalue = 0; // add Volume field if volume changes and not style = custom // this check must come after domain init, so box_change is set nfield = nfield_initial; - if (domain->box_change && strcmp(style,"custom") != 0) - addfield("Volume",&Thermo::compute_vol,FLOAT); + if (domain->box_change && strcmp(style, "custom") != 0) + addfield("Volume", &Thermo::compute_vol, FLOAT); // set format string for each field // include keyword if lineflag = MULTILINE @@ -207,13 +211,19 @@ void Thermo::init() if ((lineflag == YAMLLINE) && (i == 0)) format[i] += " - ["; if (format_line) format_line_user_def = format_line->next_string(); - if (format_column_user[i].size()) format_this = format_column_user[i]; + if (format_column_user[i].size()) + format_this = format_column_user[i]; else if (vtype[i] == FLOAT) { - if (format_float_user.size()) format_this = format_float_user; - else if (format_line_user_def.size()) format_this = format_line_user_def; - else if (lineflag == ONELINE) format_this = FORMAT_FLOAT_ONE_DEFAULT; - else if (lineflag == MULTILINE) format_this = FORMAT_FLOAT_MULTI_DEFAULT; - else if (lineflag == YAMLLINE) format_this = FORMAT_FLOAT_YAML_DEFAULT; + if (format_float_user.size()) + format_this = format_float_user; + else if (format_line_user_def.size()) + format_this = format_line_user_def; + else if (lineflag == ONELINE) + format_this = FORMAT_FLOAT_ONE_DEFAULT; + else if (lineflag == MULTILINE) + format_this = FORMAT_FLOAT_MULTI_DEFAULT; + else if (lineflag == YAMLLINE) + format_this = FORMAT_FLOAT_YAML_DEFAULT; } else if ((vtype[i] == INT) || (vtype[i] == BIGINT)) { if (format_int_user.size()) { if (vtype[i] == INT) @@ -223,9 +233,12 @@ void Thermo::init() } else if (format_line_user_def.size()) { format_this = format_line_user_def; } else { - if (lineflag == ONELINE) format_this = FORMAT_INT_ONE_DEFAULT; - else if (lineflag == MULTILINE) format_this = FORMAT_INT_MULTI_DEFAULT; - else format_this = FORMAT_INT_YAML_DEFAULT; + if (lineflag == ONELINE) + format_this = FORMAT_INT_ONE_DEFAULT; + else if (lineflag == MULTILINE) + format_this = FORMAT_INT_MULTI_DEFAULT; + else + format_this = FORMAT_INT_YAML_DEFAULT; if (vtype[i] == BIGINT) { // replace "d" in int format with bigint format specifier auto found = format_this.find('%'); @@ -235,16 +248,22 @@ void Thermo::init() } } - if (lineflag == ONELINE) format[i] += format_this + " "; - else if (lineflag == YAMLLINE) format[i] += format_this + ", "; - else format[i] += fmt::format("{:<8} = {} ",keyword[i],format_this); + if (lineflag == ONELINE) + format[i] += format_this + " "; + else if (lineflag == YAMLLINE) + format[i] += format_this + ", "; + else + format[i] += fmt::format("{:<8} = {} ", keyword[i], format_this); } // chop off trailing blank or add closing bracket if needed and then add newline - if (lineflag == ONELINE) format[nfield-1].resize(format[nfield-1].size()-1); - else if (lineflag == MULTILINE) format[nfield-1].resize(format[nfield-1].size()-1); - else if (lineflag == YAMLLINE) format[nfield-1] += ']'; - format[nfield-1] += '\n'; + if (lineflag == ONELINE) + format[nfield - 1].resize(format[nfield - 1].size() - 1); + else if (lineflag == MULTILINE) + format[nfield - 1].resize(format[nfield - 1].size() - 1); + else if (lineflag == YAMLLINE) + format[nfield - 1] += ']'; + format[nfield - 1] += '\n'; delete format_line; @@ -252,7 +271,7 @@ void Thermo::init() for (int i = 0; i < ncompute; i++) { computes[i] = modify->get_compute_by_id(id_compute[i]); - if (!computes[i]) error->all(FLERR,"Could not find thermo compute with ID {}",id_compute[i]); + if (!computes[i]) error->all(FLERR, "Could not find thermo compute with ID {}", id_compute[i]); } // find current ptr for each Fix ID @@ -260,17 +279,17 @@ void Thermo::init() for (int i = 0; i < nfix; i++) { fixes[i] = modify->get_fix_by_id(id_fix[i]); - if (!fixes[i]) error->all(FLERR,"Could not find thermo fix ID {}",id_fix[i]); + if (!fixes[i]) error->all(FLERR, "Could not find thermo fix ID {}", id_fix[i]); if (output->thermo_every % fixes[i]->global_freq) - error->all(FLERR,"Thermo and fix {} not computed at compatible times",id_fix[i]); + error->all(FLERR, "Thermo and fix {} not computed at compatible times", id_fix[i]); } // find current ptr for each Variable ID for (int i = 0; i < nvariable; i++) { variables[i] = input->variable->find(id_variable[i]); - if (variables[i] < 0) error->all(FLERR,"Could not find thermo variable {}",id_variable[i]); + if (variables[i] < 0) error->all(FLERR, "Could not find thermo variable {}", id_variable[i]); } // set ptrs to keyword-specific Compute objects @@ -316,18 +335,18 @@ void Thermo::header() } } if (lineflag == YAMLLINE) - hdr += "]\ndata:"; + hdr += "]\ndata:"; else - hdr.resize(hdr.size()-1); // chop off trailing blank + hdr.resize(hdr.size() - 1); // chop off trailing blank - if (comm->me == 0) utils::logmesg(lmp,hdr+"\n"); + if (comm->me == 0) utils::logmesg(lmp, hdr + "\n"); } /* ---------------------------------------------------------------------- */ void Thermo::footer() { - if (lineflag == YAMLLINE) utils::logmesg(lmp,"...\n"); + if (lineflag == YAMLLINE) utils::logmesg(lmp, "...\n"); } /* ---------------------------------------------------------------------- */ @@ -343,8 +362,10 @@ void Thermo::compute(int flag) // turn off normflag if natoms = 0 to avoid divide by 0 natoms = atom->natoms = lost_check(); - if (natoms == 0) normflag = 0; - else normflag = normvalue; + if (natoms == 0) + normflag = 0; + else + normflag = normvalue; // invoke Compute methods needed for thermo keywords @@ -371,8 +392,10 @@ void Thermo::compute(int flag) line.clear(); if (lineflag == MULTILINE) { double cpu; - if (flag) cpu = timer->elapsed(Timer::TOTAL); - else cpu = 0.0; + if (flag) + cpu = timer->elapsed(Timer::TOTAL); + else + cpu = 0.0; line += fmt::format(FORMAT_MULTI_HEADER, ntimestep, cpu); } @@ -395,7 +418,7 @@ void Thermo::compute(int flag) // print line to screen and logfile if (comm->me == 0) { - utils::logmesg(lmp,line); + utils::logmesg(lmp, line); if (flushflag) utils::flush_buffers(lmp); } @@ -424,41 +447,39 @@ bigint Thermo::lost_check() { // ntotal = current # of atoms, and Error class warnings - bigint nlocal[2], ntotal[2] = {0,0}; + bigint nlocal[2], ntotal[2] = {0, 0}; nlocal[0] = atom->nlocal; nlocal[1] = error->get_numwarn(); - MPI_Allreduce(nlocal,ntotal,2,MPI_LMP_BIGINT,MPI_SUM,world); - if (ntotal[0] < 0) - error->all(FLERR,"Too many total atoms"); + MPI_Allreduce(nlocal, ntotal, 2, MPI_LMP_BIGINT, MPI_SUM, world); + if (ntotal[0] < 0) error->all(FLERR, "Too many total atoms"); // print notification, if future warnings will be ignored bigint maxwarn = error->get_maxwarn(); if ((maxwarn > 0) && (warnbefore == 0) && (ntotal[1] > maxwarn)) { warnbefore = 1; if (comm->me == 0) - error->message(FLERR,"WARNING: Too many warnings: {} vs {}. All " - "future warnings will be suppressed",ntotal[1],maxwarn); + error->message(FLERR, + "WARNING: Too many warnings: {} vs {}. All future warnings will be suppressed", + ntotal[1], maxwarn); } - error->set_allwarn(MIN(MAXSMALLINT,ntotal[1])); + error->set_allwarn(MIN(MAXSMALLINT, ntotal[1])); // no lost atoms, nothing else to do. if (ntotal[0] == atom->natoms) return ntotal[0]; // if not checking or already warned, just return if (lostflag == Thermo::IGNORE) return ntotal[0]; - if (lostflag == Thermo::WARN && lostbefore == 1) { - return ntotal[0]; - } + if (lostflag == Thermo::WARN && lostbefore == 1) { return ntotal[0]; } // error message if (lostflag == Thermo::ERROR) - error->all(FLERR,"Lost atoms: original {} current {}",atom->natoms,ntotal[0]); + error->all(FLERR, "Lost atoms: original {} current {}", atom->natoms, ntotal[0]); // warning message if (comm->me == 0) - error->warning(FLERR,"Lost atoms: original {} current {}",atom->natoms,ntotal[0]); + error->warning(FLERR, "Lost atoms: original {} current {}", atom->natoms, ntotal[0]); // reset total atom count @@ -473,26 +494,26 @@ bigint Thermo::lost_check() void Thermo::modify_params(int narg, char **arg) { - if (narg == 0) error->all(FLERR,"Illegal thermo_modify command"); + if (narg == 0) error->all(FLERR, "Illegal thermo_modify command"); modified = 1; int iarg = 0; while (iarg < narg) { - if (strcmp(arg[iarg],"temp") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (index_temp < 0) error->all(FLERR,"Thermo style does not use temp"); + if (strcmp(arg[iarg], "temp") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (index_temp < 0) error->all(FLERR, "Thermo style does not use temp"); delete[] id_compute[index_temp]; - id_compute[index_temp] = utils::strdup(arg[iarg+1]); + id_compute[index_temp] = utils::strdup(arg[iarg + 1]); - temperature = modify->get_compute_by_id(arg[iarg+1]); + temperature = modify->get_compute_by_id(arg[iarg + 1]); if (!temperature) - error->all(FLERR,"Could not find thermo_modify temperature compute {}",arg[iarg+1]); + error->all(FLERR, "Could not find thermo_modify temperature compute {}", arg[iarg + 1]); if (temperature->tempflag == 0) - error->all(FLERR,"Thermo_modify compute {} does not compute temperature",arg[iarg+1]); + error->all(FLERR, "Thermo_modify compute {} does not compute temperature", arg[iarg + 1]); if (temperature->igroup != 0 && comm->me == 0) - error->warning(FLERR,"Temperature for thermo pressure is not for group all"); + error->warning(FLERR, "Temperature for thermo pressure is not for group all"); // reset id_temp of pressure to new temperature ID // either pressure currently being used by thermo or "thermo_press" @@ -500,126 +521,144 @@ void Thermo::modify_params(int narg, char **arg) Compute *pcompute; if (index_press_scalar >= 0) { pcompute = modify->get_compute_by_id(id_compute[index_press_scalar]); - if (!pcompute) error->all(FLERR, "Pressure compute {} for thermo output does not exist", - id_compute[index_press_scalar]); + if (!pcompute) + error->all(FLERR, "Pressure compute {} for thermo output does not exist", + id_compute[index_press_scalar]); } else if (index_press_vector >= 0) { pcompute = modify->get_compute_by_id(id_compute[index_press_vector]); - if (!pcompute) error->all(FLERR,"Pressure compute {} for thermo output does not exist", - id_compute[index_press_vector]); - } else pcompute = modify->get_compute_by_id("thermo_press"); + if (!pcompute) + error->all(FLERR, "Pressure compute {} for thermo output does not exist", + id_compute[index_press_vector]); + } else + pcompute = modify->get_compute_by_id("thermo_press"); - pcompute->reset_extra_compute_fix(arg[iarg+1]); + pcompute->reset_extra_compute_fix(arg[iarg + 1]); iarg += 2; - } else if (strcmp(arg[iarg],"press") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); + } else if (strcmp(arg[iarg], "press") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); if (index_press_scalar < 0 && index_press_vector < 0) - error->all(FLERR,"Thermo style does not use press"); + error->all(FLERR, "Thermo style does not use press"); if (index_press_scalar >= 0) { delete[] id_compute[index_press_scalar]; - id_compute[index_press_scalar] = utils::strdup(arg[iarg+1]); + id_compute[index_press_scalar] = utils::strdup(arg[iarg + 1]); } if (index_press_vector >= 0) { delete[] id_compute[index_press_vector]; - id_compute[index_press_vector] = utils::strdup(arg[iarg+1]); + id_compute[index_press_vector] = utils::strdup(arg[iarg + 1]); } - pressure = modify->get_compute_by_id(arg[iarg+1]); + pressure = modify->get_compute_by_id(arg[iarg + 1]); if (!pressure) - error->all(FLERR,"Could not find thermo_modify pressure compute {}",arg[iarg+1]); + error->all(FLERR, "Could not find thermo_modify pressure compute {}", arg[iarg + 1]); if (pressure->pressflag == 0) - error->all(FLERR,"Thermo_modify compute {} does not compute pressure",arg[iarg+1]); + error->all(FLERR, "Thermo_modify compute {} does not compute pressure", arg[iarg + 1]); iarg += 2; - } else if (strcmp(arg[iarg],"lost") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"ignore") == 0) lostflag = Thermo::IGNORE; - else if (strcmp(arg[iarg+1],"warn") == 0) lostflag = Thermo::WARN; - else if (strcmp(arg[iarg+1],"error") == 0) lostflag = Thermo::ERROR; - else error->all(FLERR,"Illegal thermo_modify command"); + } else if (strcmp(arg[iarg], "lost") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (strcmp(arg[iarg + 1], "ignore") == 0) + lostflag = Thermo::IGNORE; + else if (strcmp(arg[iarg + 1], "warn") == 0) + lostflag = Thermo::WARN; + else if (strcmp(arg[iarg + 1], "error") == 0) + lostflag = Thermo::ERROR; + else + error->all(FLERR, "Illegal thermo_modify command"); iarg += 2; - } else if (strcmp(arg[iarg],"lost/bond") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"ignore") == 0) lostbond = Thermo::IGNORE; - else if (strcmp(arg[iarg+1],"warn") == 0) lostbond = Thermo::WARN; - else if (strcmp(arg[iarg+1],"error") == 0) lostbond = Thermo::ERROR; - else error->all(FLERR,"Illegal thermo_modify command"); + } else if (strcmp(arg[iarg], "lost/bond") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (strcmp(arg[iarg + 1], "ignore") == 0) + lostbond = Thermo::IGNORE; + else if (strcmp(arg[iarg + 1], "warn") == 0) + lostbond = Thermo::WARN; + else if (strcmp(arg[iarg + 1], "error") == 0) + lostbond = Thermo::ERROR; + else + error->all(FLERR, "Illegal thermo_modify command"); iarg += 2; - } else if (strcmp(arg[iarg],"warn") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"ignore") == 0) error->set_maxwarn(-1); - else if (strcmp(arg[iarg+1],"always") == 0) error->set_maxwarn(0); - else if (strcmp(arg[iarg+1],"reset") == 0) { + } else if (strcmp(arg[iarg], "warn") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (strcmp(arg[iarg + 1], "ignore") == 0) + error->set_maxwarn(-1); + else if (strcmp(arg[iarg + 1], "always") == 0) + error->set_maxwarn(0); + else if (strcmp(arg[iarg + 1], "reset") == 0) { error->set_numwarn(0); warnbefore = 0; - } else if (strcmp(arg[iarg+1],"default") == 0) { + } else if (strcmp(arg[iarg + 1], "default") == 0) { warnbefore = 0; error->set_numwarn(0); error->set_maxwarn(100); - } else error->set_maxwarn(utils::inumeric(FLERR,arg[iarg+1],false,lmp)); + } else + error->set_maxwarn(utils::inumeric(FLERR, arg[iarg + 1], false, lmp)); iarg += 2; - } else if (strcmp(arg[iarg],"norm") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); + } else if (strcmp(arg[iarg], "norm") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); normuserflag = 1; - normuser = utils::logical(FLERR,arg[iarg+1],false,lmp); + normuser = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else if (strcmp(arg[iarg],"flush") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - flushflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } else if (strcmp(arg[iarg], "flush") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + flushflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else if (strcmp(arg[iarg],"line") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"one") == 0) lineflag = ONELINE; - else if (strcmp(arg[iarg+1],"multi") == 0) lineflag = MULTILINE; - else if (strcmp(arg[iarg+1],"yaml") == 0) lineflag = YAMLLINE; - else error->all(FLERR,"Illegal thermo_modify command"); + } else if (strcmp(arg[iarg], "line") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (strcmp(arg[iarg + 1], "one") == 0) + lineflag = ONELINE; + else if (strcmp(arg[iarg + 1], "multi") == 0) + lineflag = MULTILINE; + else if (strcmp(arg[iarg + 1], "yaml") == 0) + lineflag = YAMLLINE; + else + error->all(FLERR, "Illegal thermo_modify command"); iarg += 2; - } else if (strcmp(arg[iarg],"format") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); + } else if (strcmp(arg[iarg], "format") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"none") == 0) { + if (strcmp(arg[iarg + 1], "none") == 0) { format_line_user.clear(); format_int_user.clear(); format_bigint_user.clear(); format_float_user.clear(); - for (int i = 0; i < nfield_initial+1; ++i) - format_column_user[i].clear(); + for (int i = 0; i < nfield_initial + 1; ++i) format_column_user[i].clear(); iarg += 2; continue; } - if (iarg+3 > narg) error->all(FLERR,"Illegal thermo_modify command"); + if (iarg + 3 > narg) error->all(FLERR, "Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"line") == 0) { - format_line_user = arg[iarg+2]; - } else if (strcmp(arg[iarg+1],"int") == 0) { - format_int_user = arg[iarg+2]; + if (strcmp(arg[iarg + 1], "line") == 0) { + format_line_user = arg[iarg + 2]; + } else if (strcmp(arg[iarg + 1], "int") == 0) { + format_int_user = arg[iarg + 2]; // replace "d" in format_int_user with bigint format specifier auto found = format_int_user.find('%'); found = format_int_user.find('d', found); if (found == std::string::npos) - error->all(FLERR,"Thermo_modify int format does not contain a d conversion character"); - format_bigint_user = format_int_user.replace(found, 1, std::string(BIGINT_FORMAT).substr(1)); - } else if (strcmp(arg[iarg+1],"float") == 0) { - format_float_user = arg[iarg+2]; + error->all(FLERR, "Thermo_modify int format does not contain a d conversion character"); + format_bigint_user = + format_int_user.replace(found, 1, std::string(BIGINT_FORMAT).substr(1)); + } else if (strcmp(arg[iarg + 1], "float") == 0) { + format_float_user = arg[iarg + 2]; } else { - int i = utils::inumeric(FLERR,arg[iarg+1],false,lmp) - 1; - if (i < 0 || i >= nfield_initial+1) - error->all(FLERR,"Illegal thermo_modify command"); - format_column_user[i] = arg[iarg+2]; + int i = utils::inumeric(FLERR, arg[iarg + 1], false, lmp) - 1; + if (i < 0 || i >= nfield_initial + 1) error->all(FLERR, "Illegal thermo_modify command"); + format_column_user[i] = arg[iarg + 2]; } iarg += 3; - } else error->all(FLERR,"Illegal thermo_modify command"); + } else + error->all(FLERR, "Illegal thermo_modify command"); } } @@ -652,16 +691,16 @@ void Thermo::allocate() // factor of 3 is max number of computes a single field can add ncompute = 0; - id_compute = new char*[3*n]; - compute_which = new int[3*n]; - computes = new Compute*[3*n]; + id_compute = new char *[3 * n]; + compute_which = new int[3 * n]; + computes = new Compute *[3 * n]; nfix = 0; - id_fix = new char*[n]; - fixes = new Fix*[n]; + id_fix = new char *[n]; + fixes = new Fix *[n]; nvariable = 0; - id_variable = new char*[n]; + id_variable = new char *[n]; variables = new int[n]; } @@ -708,179 +747,179 @@ void Thermo::parse_fields(const std::string &str) std::string word = keywords.next_string(); if (word == "step") { - addfield("Step",&Thermo::compute_step,BIGINT); + addfield("Step", &Thermo::compute_step, BIGINT); } else if (word == "elapsed") { - addfield("Elapsed",&Thermo::compute_elapsed,BIGINT); + addfield("Elapsed", &Thermo::compute_elapsed, BIGINT); } else if (word == "elaplong") { - addfield("Elaplong",&Thermo::compute_elapsed_long,BIGINT); + addfield("Elaplong", &Thermo::compute_elapsed_long, BIGINT); } else if (word == "dt") { - addfield("Dt",&Thermo::compute_dt,FLOAT); + addfield("Dt", &Thermo::compute_dt, FLOAT); } else if (word == "time") { - addfield("Time",&Thermo::compute_time,FLOAT); + addfield("Time", &Thermo::compute_time, FLOAT); } else if (word == "cpu") { - addfield("CPU",&Thermo::compute_cpu,FLOAT); + addfield("CPU", &Thermo::compute_cpu, FLOAT); } else if (word == "tpcpu") { - addfield("T/CPU",&Thermo::compute_tpcpu,FLOAT); + addfield("T/CPU", &Thermo::compute_tpcpu, FLOAT); } else if (word == "spcpu") { - addfield("S/CPU",&Thermo::compute_spcpu,FLOAT); + addfield("S/CPU", &Thermo::compute_spcpu, FLOAT); } else if (word == "cpuremain") { - addfield("CPULeft",&Thermo::compute_cpuremain,FLOAT); + addfield("CPULeft", &Thermo::compute_cpuremain, FLOAT); } else if (word == "part") { - addfield("Part",&Thermo::compute_part,INT); + addfield("Part", &Thermo::compute_part, INT); } else if (word == "timeremain") { - addfield("TimeoutLeft",&Thermo::compute_timeremain,FLOAT); + addfield("TimeoutLeft", &Thermo::compute_timeremain, FLOAT); } else if (word == "atoms") { - addfield("Atoms",&Thermo::compute_atoms,BIGINT); + addfield("Atoms", &Thermo::compute_atoms, BIGINT); } else if (word == "temp") { - addfield("Temp",&Thermo::compute_temp,FLOAT); - index_temp = add_compute(id_temp,SCALAR); + addfield("Temp", &Thermo::compute_temp, FLOAT); + index_temp = add_compute(id_temp, SCALAR); } else if (word == "press") { - addfield("Press",&Thermo::compute_press,FLOAT); - index_press_scalar = add_compute(id_press,SCALAR); + addfield("Press", &Thermo::compute_press, FLOAT); + index_press_scalar = add_compute(id_press, SCALAR); } else if (word == "pe") { - addfield("PotEng",&Thermo::compute_pe,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("PotEng", &Thermo::compute_pe, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "ke") { - addfield("KinEng",&Thermo::compute_ke,FLOAT); - index_temp = add_compute(id_temp,SCALAR); + addfield("KinEng", &Thermo::compute_ke, FLOAT); + index_temp = add_compute(id_temp, SCALAR); } else if (word == "etotal") { - addfield("TotEng",&Thermo::compute_etotal,FLOAT); - index_temp = add_compute(id_temp,SCALAR); - index_pe = add_compute(id_pe,SCALAR); + addfield("TotEng", &Thermo::compute_etotal, FLOAT); + index_temp = add_compute(id_temp, SCALAR); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "evdwl") { - addfield("E_vdwl",&Thermo::compute_evdwl,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_vdwl", &Thermo::compute_evdwl, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "ecoul") { - addfield("E_coul",&Thermo::compute_ecoul,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_coul", &Thermo::compute_ecoul, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "epair") { - addfield("E_pair",&Thermo::compute_epair,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_pair", &Thermo::compute_epair, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "ebond") { - addfield("E_bond",&Thermo::compute_ebond,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_bond", &Thermo::compute_ebond, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "eangle") { - addfield("E_angle",&Thermo::compute_eangle,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_angle", &Thermo::compute_eangle, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "edihed") { - addfield("E_dihed",&Thermo::compute_edihed,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_dihed", &Thermo::compute_edihed, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "eimp") { - addfield("E_impro",&Thermo::compute_eimp,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_impro", &Thermo::compute_eimp, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "emol") { - addfield("E_mol",&Thermo::compute_emol,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_mol", &Thermo::compute_emol, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "elong") { - addfield("E_long",&Thermo::compute_elong,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_long", &Thermo::compute_elong, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "etail") { - addfield("E_tail",&Thermo::compute_etail,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("E_tail", &Thermo::compute_etail, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "enthalpy") { - addfield("Enthalpy",&Thermo::compute_enthalpy,FLOAT); - index_temp = add_compute(id_temp,SCALAR); - index_press_scalar = add_compute(id_press,SCALAR); - index_pe = add_compute(id_pe,SCALAR); + addfield("Enthalpy", &Thermo::compute_enthalpy, FLOAT); + index_temp = add_compute(id_temp, SCALAR); + index_press_scalar = add_compute(id_press, SCALAR); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "ecouple") { - addfield("Ecouple",&Thermo::compute_ecouple,FLOAT); - index_pe = add_compute(id_pe,SCALAR); + addfield("Ecouple", &Thermo::compute_ecouple, FLOAT); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "econserve") { - addfield("Econserve",&Thermo::compute_econserve,FLOAT); - index_temp = add_compute(id_temp,SCALAR); - index_pe = add_compute(id_pe,SCALAR); + addfield("Econserve", &Thermo::compute_econserve, FLOAT); + index_temp = add_compute(id_temp, SCALAR); + index_pe = add_compute(id_pe, SCALAR); } else if (word == "vol") { - addfield("Volume",&Thermo::compute_vol,FLOAT); + addfield("Volume", &Thermo::compute_vol, FLOAT); } else if (word == "density") { - addfield("Density",&Thermo::compute_density,FLOAT); + addfield("Density", &Thermo::compute_density, FLOAT); } else if (word == "lx") { - addfield("Lx",&Thermo::compute_lx,FLOAT); + addfield("Lx", &Thermo::compute_lx, FLOAT); } else if (word == "ly") { - addfield("Ly",&Thermo::compute_ly,FLOAT); + addfield("Ly", &Thermo::compute_ly, FLOAT); } else if (word == "lz") { - addfield("Lz",&Thermo::compute_lz,FLOAT); + addfield("Lz", &Thermo::compute_lz, FLOAT); } else if (word == "xlo") { - addfield("Xlo",&Thermo::compute_xlo,FLOAT); + addfield("Xlo", &Thermo::compute_xlo, FLOAT); } else if (word == "xhi") { - addfield("Xhi",&Thermo::compute_xhi,FLOAT); + addfield("Xhi", &Thermo::compute_xhi, FLOAT); } else if (word == "ylo") { - addfield("Ylo",&Thermo::compute_ylo,FLOAT); + addfield("Ylo", &Thermo::compute_ylo, FLOAT); } else if (word == "yhi") { - addfield("Yhi",&Thermo::compute_yhi,FLOAT); + addfield("Yhi", &Thermo::compute_yhi, FLOAT); } else if (word == "zlo") { - addfield("Zlo",&Thermo::compute_zlo,FLOAT); + addfield("Zlo", &Thermo::compute_zlo, FLOAT); } else if (word == "zhi") { - addfield("Zhi",&Thermo::compute_zhi,FLOAT); + addfield("Zhi", &Thermo::compute_zhi, FLOAT); } else if (word == "xy") { - addfield("Xy",&Thermo::compute_xy,FLOAT); + addfield("Xy", &Thermo::compute_xy, FLOAT); } else if (word == "xz") { - addfield("Xz",&Thermo::compute_xz,FLOAT); + addfield("Xz", &Thermo::compute_xz, FLOAT); } else if (word == "yz") { - addfield("Yz",&Thermo::compute_yz,FLOAT); + addfield("Yz", &Thermo::compute_yz, FLOAT); } else if (word == "xlat") { - addfield("Xlat",&Thermo::compute_xlat,FLOAT); + addfield("Xlat", &Thermo::compute_xlat, FLOAT); } else if (word == "ylat") { - addfield("Ylat",&Thermo::compute_ylat,FLOAT); + addfield("Ylat", &Thermo::compute_ylat, FLOAT); } else if (word == "zlat") { - addfield("Zlat",&Thermo::compute_zlat,FLOAT); + addfield("Zlat", &Thermo::compute_zlat, FLOAT); } else if (word == "bonds") { - addfield("Bonds",&Thermo::compute_bonds,BIGINT); + addfield("Bonds", &Thermo::compute_bonds, BIGINT); } else if (word == "angles") { - addfield("Angles",&Thermo::compute_angles,BIGINT); + addfield("Angles", &Thermo::compute_angles, BIGINT); } else if (word == "dihedrals") { - addfield("Diheds",&Thermo::compute_dihedrals,BIGINT); + addfield("Diheds", &Thermo::compute_dihedrals, BIGINT); } else if (word == "impropers") { - addfield("Impros",&Thermo::compute_impropers,BIGINT); + addfield("Impros", &Thermo::compute_impropers, BIGINT); } else if (word == "pxx") { - addfield("Pxx",&Thermo::compute_pxx,FLOAT); - index_press_vector = add_compute(id_press,VECTOR); + addfield("Pxx", &Thermo::compute_pxx, FLOAT); + index_press_vector = add_compute(id_press, VECTOR); } else if (word == "pyy") { - addfield("Pyy",&Thermo::compute_pyy,FLOAT); - index_press_vector = add_compute(id_press,VECTOR); + addfield("Pyy", &Thermo::compute_pyy, FLOAT); + index_press_vector = add_compute(id_press, VECTOR); } else if (word == "pzz") { - addfield("Pzz",&Thermo::compute_pzz,FLOAT); - index_press_vector = add_compute(id_press,VECTOR); + addfield("Pzz", &Thermo::compute_pzz, FLOAT); + index_press_vector = add_compute(id_press, VECTOR); } else if (word == "pxy") { - addfield("Pxy",&Thermo::compute_pxy,FLOAT); - index_press_vector = add_compute(id_press,VECTOR); + addfield("Pxy", &Thermo::compute_pxy, FLOAT); + index_press_vector = add_compute(id_press, VECTOR); } else if (word == "pxz") { - addfield("Pxz",&Thermo::compute_pxz,FLOAT); - index_press_vector = add_compute(id_press,VECTOR); + addfield("Pxz", &Thermo::compute_pxz, FLOAT); + index_press_vector = add_compute(id_press, VECTOR); } else if (word == "pyz") { - addfield("Pyz",&Thermo::compute_pyz,FLOAT); - index_press_vector = add_compute(id_press,VECTOR); + addfield("Pyz", &Thermo::compute_pyz, FLOAT); + index_press_vector = add_compute(id_press, VECTOR); } else if (word == "fmax") { - addfield("Fmax",&Thermo::compute_fmax,FLOAT); + addfield("Fmax", &Thermo::compute_fmax, FLOAT); } else if (word == "fnorm") { - addfield("Fnorm",&Thermo::compute_fnorm,FLOAT); + addfield("Fnorm", &Thermo::compute_fnorm, FLOAT); } else if (word == "nbuild") { - addfield("Nbuild",&Thermo::compute_nbuild,BIGINT); + addfield("Nbuild", &Thermo::compute_nbuild, BIGINT); } else if (word == "ndanger") { - addfield("Ndanger",&Thermo::compute_ndanger,BIGINT); + addfield("Ndanger", &Thermo::compute_ndanger, BIGINT); } else if (word == "cella") { - addfield("Cella",&Thermo::compute_cella,FLOAT); + addfield("Cella", &Thermo::compute_cella, FLOAT); } else if (word == "cellb") { - addfield("Cellb",&Thermo::compute_cellb,FLOAT); + addfield("Cellb", &Thermo::compute_cellb, FLOAT); } else if (word == "cellc") { - addfield("Cellc",&Thermo::compute_cellc,FLOAT); + addfield("Cellc", &Thermo::compute_cellc, FLOAT); } else if (word == "cellalpha") { - addfield("CellAlpha",&Thermo::compute_cellalpha,FLOAT); + addfield("CellAlpha", &Thermo::compute_cellalpha, FLOAT); } else if (word == "cellbeta") { - addfield("CellBeta",&Thermo::compute_cellbeta,FLOAT); + addfield("CellBeta", &Thermo::compute_cellbeta, FLOAT); } else if (word == "cellgamma") { - addfield("CellGamma",&Thermo::compute_cellgamma,FLOAT); + addfield("CellGamma", &Thermo::compute_cellgamma, FLOAT); // compute value = c_ID, fix value = f_ID, variable value = v_ID // count trailing [] and store int arguments @@ -888,10 +927,9 @@ void Thermo::parse_fields(const std::string &str) } else { ArgInfo argi(word); - if ((argi.get_type() == ArgInfo::UNKNOWN) - || (argi.get_type() == ArgInfo::NONE) - || (argi.get_dim() > 2)) - error->all(FLERR,"Unknown keyword '{}' in thermo_style custom command",word); + if ((argi.get_type() == ArgInfo::UNKNOWN) || (argi.get_type() == ArgInfo::NONE) || + (argi.get_dim() > 2)) + error->all(FLERR, "Unknown keyword '{}' in thermo_style custom command", word); // process zero or one or two trailing brackets // argindex1,argindex2 = int inside each bracket pair, 0 if no bracket @@ -902,24 +940,22 @@ void Thermo::parse_fields(const std::string &str) if (argi.get_type() == ArgInfo::COMPUTE) { auto icompute = modify->get_compute_by_id(argi.get_name()); if (!icompute) - error->all(FLERR,"Could not find thermo custom compute ID: {}", argi.get_name()); + error->all(FLERR, "Could not find thermo custom compute ID: {}", argi.get_name()); if (argindex1[nfield] == 0 && icompute->scalar_flag == 0) - error->all(FLERR,"Thermo compute does not compute scalar"); + error->all(FLERR, "Thermo compute does not compute scalar"); if (argindex1[nfield] > 0 && argindex2[nfield] == 0) { if (icompute->vector_flag == 0) - error->all(FLERR,"Thermo compute does not compute vector"); - if (argindex1[nfield] > icompute->size_vector && - icompute->size_vector_variable == 0) - error->all(FLERR,"Thermo compute vector is accessed out-of-range"); + error->all(FLERR, "Thermo compute does not compute vector"); + if (argindex1[nfield] > icompute->size_vector && icompute->size_vector_variable == 0) + error->all(FLERR, "Thermo compute vector is accessed out-of-range"); } if (argindex1[nfield] > 0 && argindex2[nfield] > 0) { - if (icompute->array_flag == 0) - error->all(FLERR,"Thermo compute does not compute array"); + if (icompute->array_flag == 0) error->all(FLERR, "Thermo compute does not compute array"); if (argindex1[nfield] > icompute->size_array_rows && icompute->size_array_rows_variable == 0) - error->all(FLERR,"Thermo compute array is accessed out-of-range"); + error->all(FLERR, "Thermo compute array is accessed out-of-range"); if (argindex2[nfield] > icompute->size_array_cols) - error->all(FLERR,"Thermo compute array is accessed out-of-range"); + error->all(FLERR, "Thermo compute array is accessed out-of-range"); } if (argindex1[nfield] == 0) @@ -932,24 +968,20 @@ void Thermo::parse_fields(const std::string &str) } else if (argi.get_type() == ArgInfo::FIX) { auto ifix = modify->get_fix_by_id(argi.get_name()); - if (!ifix) error->all(FLERR,"Could not find thermo custom fix ID: {}", argi.get_name()); + if (!ifix) error->all(FLERR, "Could not find thermo custom fix ID: {}", argi.get_name()); if (argindex1[nfield] == 0 && ifix->scalar_flag == 0) - error->all(FLERR,"Thermo fix does not compute scalar"); + error->all(FLERR, "Thermo fix does not compute scalar"); if (argindex1[nfield] > 0 && argindex2[nfield] == 0) { - if (ifix->vector_flag == 0) - error->all(FLERR,"Thermo fix does not compute vector"); - if (argindex1[nfield] > ifix->size_vector && - ifix->size_vector_variable == 0) - error->all(FLERR,"Thermo fix vector is accessed out-of-range"); + if (ifix->vector_flag == 0) error->all(FLERR, "Thermo fix does not compute vector"); + if (argindex1[nfield] > ifix->size_vector && ifix->size_vector_variable == 0) + error->all(FLERR, "Thermo fix vector is accessed out-of-range"); } if (argindex1[nfield] > 0 && argindex2[nfield] > 0) { - if (ifix->array_flag == 0) - error->all(FLERR,"Thermo fix does not compute array"); - if (argindex1[nfield] > ifix->size_array_rows && - ifix->size_array_rows_variable == 0) - error->all(FLERR,"Thermo fix array is accessed out-of-range"); + if (ifix->array_flag == 0) error->all(FLERR, "Thermo fix does not compute array"); + if (argindex1[nfield] > ifix->size_array_rows && ifix->size_array_rows_variable == 0) + error->all(FLERR, "Thermo fix array is accessed out-of-range"); if (argindex2[nfield] > ifix->size_array_cols) - error->all(FLERR,"Thermo fix array is accessed out-of-range"); + error->all(FLERR, "Thermo fix array is accessed out-of-range"); } field2index[nfield] = add_fix(argi.get_name()); @@ -958,13 +990,12 @@ void Thermo::parse_fields(const std::string &str) } else if (argi.get_type() == ArgInfo::VARIABLE) { int n = input->variable->find(argi.get_name()); if (n < 0) - error->all(FLERR,"Could not find thermo custom variable name: {}", argi.get_name()); + error->all(FLERR, "Could not find thermo custom variable name: {}", argi.get_name()); if (argindex1[nfield] == 0 && input->variable->equalstyle(n) == 0) - error->all(FLERR,"Thermo custom variable is not equal-style variable"); + error->all(FLERR, "Thermo custom variable is not equal-style variable"); if (argindex1[nfield] && input->variable->vectorstyle(n) == 0) - error->all(FLERR,"Thermo custom variable is not vector-style variable"); - if (argindex2[nfield]) - error->all(FLERR,"Thermo custom variable cannot have two indices"); + error->all(FLERR, "Thermo custom variable is not vector-style variable"); + if (argindex2[nfield]) error->all(FLERR, "Thermo custom variable cannot have two indices"); field2index[nfield] = add_variable(argi.get_name()); addfield(word.c_str(), &Thermo::compute_variable, FLOAT); @@ -995,14 +1026,13 @@ int Thermo::add_compute(const char *id, int which) { int icompute; for (icompute = 0; icompute < ncompute; icompute++) - if ((strcmp(id,id_compute[icompute]) == 0) && - which == compute_which[icompute]) break; + if ((strcmp(id, id_compute[icompute]) == 0) && which == compute_which[icompute]) break; if (icompute < ncompute) return icompute; id_compute[ncompute] = utils::strdup(id); compute_which[ncompute] = which; ncompute++; - return ncompute-1; + return ncompute - 1; } /* ---------------------------------------------------------------------- @@ -1013,7 +1043,7 @@ int Thermo::add_fix(const char *id) { id_fix[nfix] = utils::strdup(id); nfix++; - return nfix-1; + return nfix - 1; } /* ---------------------------------------------------------------------- @@ -1024,7 +1054,8 @@ int Thermo::add_variable(const char *id) { id_variable[nvariable] = utils::strdup(id); nvariable++; - return nvariable-1; + return nvariable - 1; +} /* ---------------------------------------------------------------------- check whether temperature compute is defined, available, and current @@ -1393,18 +1424,23 @@ void Thermo::compute_compute() dvalue = compute->scalar; if (normflag && compute->extscalar) dvalue /= natoms; } else if (compute_which[m] == VECTOR) { - if (compute->size_vector_variable && argindex1[ifield] > - compute->size_vector) dvalue = 0.0; - else dvalue = compute->vector[argindex1[ifield]-1]; + if (compute->size_vector_variable && argindex1[ifield] > compute->size_vector) + dvalue = 0.0; + else + dvalue = compute->vector[argindex1[ifield] - 1]; if (normflag) { - if (compute->extvector == 0) return; - else if (compute->extvector == 1) dvalue /= natoms; - else if (compute->extlist[argindex1[ifield]-1]) dvalue /= natoms; + if (compute->extvector == 0) + return; + else if (compute->extvector == 1) + dvalue /= natoms; + else if (compute->extlist[argindex1[ifield] - 1]) + dvalue /= natoms; } } else { - if (compute->size_array_rows_variable && argindex1[ifield] > - compute->size_array_rows) dvalue = 0.0; - else dvalue = compute->array[argindex1[ifield]-1][argindex2[ifield]-1]; + if (compute->size_array_rows_variable && argindex1[ifield] > compute->size_array_rows) + dvalue = 0.0; + else + dvalue = compute->array[argindex1[ifield] - 1][argindex2[ifield] - 1]; if (normflag && compute->extarray) dvalue /= natoms; } } @@ -1420,14 +1456,17 @@ void Thermo::compute_fix() dvalue = fix->compute_scalar(); if (normflag && fix->extscalar) dvalue /= natoms; } else if (argindex2[ifield] == 0) { - dvalue = fix->compute_vector(argindex1[ifield]-1); + dvalue = fix->compute_vector(argindex1[ifield] - 1); if (normflag) { - if (fix->extvector == 0) return; - else if (fix->extvector == 1) dvalue /= natoms; - else if (fix->extlist[argindex1[ifield]-1]) dvalue /= natoms; + if (fix->extvector == 0) + return; + else if (fix->extvector == 1) + dvalue /= natoms; + else if (fix->extlist[argindex1[ifield] - 1]) + dvalue /= natoms; } } else { - dvalue = fix->compute_array(argindex1[ifield]-1,argindex2[ifield]-1); + dvalue = fix->compute_array(argindex1[ifield] - 1, argindex2[ifield] - 1); if (normflag && fix->extarray) dvalue /= natoms; } } @@ -1442,10 +1481,11 @@ void Thermo::compute_variable() dvalue = input->variable->compute_equal(variables[field2index[ifield]]); else { double *varvec; - int nvec = - input->variable->compute_vector(variables[field2index[ifield]],&varvec); - if (nvec < iarg) dvalue = 0.0; - else dvalue = varvec[iarg-1]; + int nvec = input->variable->compute_vector(variables[field2index[ifield]], &varvec); + if (nvec < iarg) + dvalue = 0.0; + else + dvalue = varvec[iarg - 1]; } } @@ -1487,15 +1527,17 @@ void Thermo::compute_dt() void Thermo::compute_time() { - dvalue = update->atime + (update->ntimestep-update->atimestep)*update->dt; + dvalue = update->atime + (update->ntimestep - update->atimestep) * update->dt; } /* ---------------------------------------------------------------------- */ void Thermo::compute_cpu() { - if (firststep == 0) dvalue = 0.0; - else dvalue = timer->elapsed(Timer::TOTAL); + if (firststep == 0) + dvalue = 0.0; + else + dvalue = timer->elapsed(Timer::TOTAL); } /* ---------------------------------------------------------------------- */ @@ -1512,8 +1554,10 @@ void Thermo::compute_tpcpu() new_cpu = timer->elapsed(Timer::TOTAL); double cpu_diff = new_cpu - last_tpcpu; double time_diff = new_time - last_time; - if (time_diff > 0.0 && cpu_diff > 0.0) dvalue = time_diff/cpu_diff; - else dvalue = 0.0; + if (time_diff > 0.0 && cpu_diff > 0.0) + dvalue = time_diff / cpu_diff; + else + dvalue = 0.0; } last_time = new_time; @@ -1534,8 +1578,10 @@ void Thermo::compute_spcpu() new_cpu = timer->elapsed(Timer::TOTAL); double cpu_diff = new_cpu - last_spcpu; int step_diff = new_step - last_step; - if (cpu_diff > 0.0) dvalue = step_diff/cpu_diff; - else dvalue = 0.0; + if (cpu_diff > 0.0) + dvalue = step_diff / cpu_diff; + else + dvalue = 0.0; } last_step = new_step; @@ -1546,10 +1592,11 @@ void Thermo::compute_spcpu() void Thermo::compute_cpuremain() { - if (firststep == 0) dvalue = 0.0; - else dvalue = timer->elapsed(Timer::TOTAL) * - (update->laststep - update->ntimestep) / - (update->ntimestep - update->firststep); + if (firststep == 0) + dvalue = 0.0; + else + dvalue = timer->elapsed(Timer::TOTAL) * (update->laststep - update->ntimestep) / + (update->ntimestep - update->firststep); } /* ---------------------------------------------------------------------- */ @@ -1637,7 +1684,7 @@ void Thermo::compute_evdwl() { double tmp = 0.0; if (force->pair) tmp += force->pair->eng_vdwl; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (force->pair && force->pair->tail_flag) { double volume = domain->xprd * domain->yprd * domain->zprd; @@ -1653,7 +1700,7 @@ void Thermo::compute_ecoul() { double tmp = 0.0; if (force->pair) tmp += force->pair->eng_coul; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (normflag) dvalue /= natoms; } @@ -1663,7 +1710,7 @@ void Thermo::compute_epair() { double tmp = 0.0; if (force->pair) tmp += force->pair->eng_vdwl + force->pair->eng_coul; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (force->kspace) dvalue += force->kspace->energy; if (force->pair && force->pair->tail_flag) { @@ -1680,9 +1727,10 @@ void Thermo::compute_ebond() { if (force->bond) { double tmp = force->bond->energy; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1691,9 +1739,10 @@ void Thermo::compute_eangle() { if (force->angle) { double tmp = force->angle->energy; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1702,9 +1751,10 @@ void Thermo::compute_edihed() { if (force->dihedral) { double tmp = force->dihedral->energy; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1713,9 +1763,10 @@ void Thermo::compute_eimp() { if (force->improper) { double tmp = force->improper->energy; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1728,9 +1779,10 @@ void Thermo::compute_emol() if (force->angle) tmp += force->angle->energy; if (force->dihedral) tmp += force->dihedral->energy; if (force->improper) tmp += force->improper->energy; - MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&tmp, &dvalue, 1, MPI_DOUBLE, MPI_SUM, world); if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1740,7 +1792,8 @@ void Thermo::compute_elong() if (force->kspace) { dvalue = force->kspace->energy; if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1751,7 +1804,8 @@ void Thermo::compute_etail() double volume = domain->xprd * domain->yprd * domain->zprd; dvalue = force->pair->etail / volume; if (normflag) dvalue /= natoms; - } else dvalue = 0.0; + } else + dvalue = 0.0; } /* ---------------------------------------------------------------------- */ @@ -1768,10 +1822,9 @@ void Thermo::compute_enthalpy() compute_press(); double ptmp = dvalue; - dvalue = etmp + ptmp*vtmp/(force->nktv2p); + dvalue = etmp + ptmp * vtmp / (force->nktv2p); } - /* ---------------------------------------------------------------------- */ void Thermo::compute_vol() @@ -1788,7 +1841,7 @@ void Thermo::compute_density() { double mass = group->mass(0); compute_vol(); - dvalue = force->mv2d * mass/dvalue; + dvalue = force->mv2d * mass / dvalue; } /* ---------------------------------------------------------------------- */ @@ -1975,12 +2028,12 @@ void Thermo::compute_fmax() double max = 0.0; for (int i = 0; i < nlocal; i++) { - max = MAX(max,fabs(f[i][0])); - max = MAX(max,fabs(f[i][1])); - max = MAX(max,fabs(f[i][2])); + max = MAX(max, fabs(f[i][0])); + max = MAX(max, fabs(f[i][1])); + max = MAX(max, fabs(f[i][2])); } double maxall; - MPI_Allreduce(&max,&maxall,1,MPI_DOUBLE,MPI_MAX,world); + MPI_Allreduce(&max, &maxall, 1, MPI_DOUBLE, MPI_MAX, world); dvalue = maxall; } @@ -1992,10 +2045,9 @@ void Thermo::compute_fnorm() int nlocal = atom->nlocal; double dot = 0.0; - for (int i = 0; i < nlocal; i++) - dot += f[i][0]*f[i][0] + f[i][1]*f[i][1] + f[i][2]*f[i][2]; + for (int i = 0; i < nlocal; i++) dot += f[i][0] * f[i][0] + f[i][1] * f[i][1] + f[i][2] * f[i][2]; double dotall; - MPI_Allreduce(&dot,&dotall,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&dot, &dotall, 1, MPI_DOUBLE, MPI_SUM, world); dvalue = sqrt(dotall); } @@ -2027,8 +2079,8 @@ void Thermo::compute_cellb() if (!domain->triclinic) dvalue = domain->yprd; else { - double* h = domain->h; - dvalue = sqrt(h[1]*h[1]+h[5]*h[5]); + double *h = domain->h; + dvalue = sqrt(h[1] * h[1] + h[5] * h[5]); } } @@ -2039,8 +2091,8 @@ void Thermo::compute_cellc() if (!domain->triclinic) dvalue = domain->zprd; else { - double* h = domain->h; - dvalue = sqrt(h[2]*h[2]+h[3]*h[3]+h[4]*h[4]); + double *h = domain->h; + dvalue = sqrt(h[2] * h[2] + h[3] * h[3] + h[4] * h[4]); } } @@ -2054,10 +2106,10 @@ void Thermo::compute_cellalpha() // Cos(alpha) = (xy.xz + ly.yz)/(b.c) - double* h = domain->h; - double cosalpha = (h[5]*h[4]+h[1]*h[3])/ - sqrt((h[1]*h[1]+h[5]*h[5])*(h[2]*h[2]+h[3]*h[3]+h[4]*h[4])); - dvalue = acos(cosalpha)*180.0/MY_PI; + double *h = domain->h; + double cosalpha = (h[5] * h[4] + h[1] * h[3]) / + sqrt((h[1] * h[1] + h[5] * h[5]) * (h[2] * h[2] + h[3] * h[3] + h[4] * h[4])); + dvalue = acos(cosalpha) * 180.0 / MY_PI; } } @@ -2071,9 +2123,9 @@ void Thermo::compute_cellbeta() // Cos(beta) = xz/c - double* h = domain->h; - double cosbeta = h[4]/sqrt(h[2]*h[2]+h[3]*h[3]+h[4]*h[4]); - dvalue = acos(cosbeta)*180.0/MY_PI; + double *h = domain->h; + double cosbeta = h[4] / sqrt(h[2] * h[2] + h[3] * h[3] + h[4] * h[4]); + dvalue = acos(cosbeta) * 180.0 / MY_PI; } } @@ -2087,8 +2139,8 @@ void Thermo::compute_cellgamma() // Cos(gamma) = xy/b - double* h = domain->h; - double cosgamma = h[5]/sqrt(h[1]*h[1]+h[5]*h[5]); - dvalue = acos(cosgamma)*180.0/MY_PI; + double *h = domain->h; + double cosgamma = h[5] / sqrt(h[1] * h[1] + h[5] * h[5]); + dvalue = acos(cosgamma) * 180.0 / MY_PI; } }