simplify by using utils::strdup() and reorder includes

This commit is contained in:
Axel Kohlmeyer
2021-03-28 17:02:49 -04:00
parent 31726f56e6
commit b32570c15e
70 changed files with 447 additions and 1009 deletions

View File

@ -12,10 +12,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nph_asphere.h" #include "fix_nph_asphere.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -36,21 +35,15 @@ FixNPHAsphere::FixNPHAsphere(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp/asphere",id_temp));
strcpy(id_temp,tcmd.c_str());
modify->add_compute(tcmd + " all temp/asphere");
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -12,10 +12,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_npt_asphere.h" #include "fix_npt_asphere.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,21 +34,15 @@ FixNPTAsphere::FixNPTAsphere(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp/asphere",id_temp));
strcpy(id_temp,tcmd.c_str());
modify->add_compute(tcmd + " all temp/asphere");
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -16,10 +16,11 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nve_asphere.h" #include "fix_nve_asphere.h"
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec_ellipsoid.h" #include "atom_vec_ellipsoid.h"
#include "error.h" #include "error.h"
#include "math_extra.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -12,12 +12,10 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nvt_asphere.h" #include "fix_nvt_asphere.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,11 +33,8 @@ FixNVTAsphere::FixNVTAsphere(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[cmd.size()+1]; modify->add_compute(fmt::format("{} {} temp/asphere",
strcpy(id_temp,cmd.c_str()); id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp/asphere",group->names[igroup]);
modify->add_compute(cmd);
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -16,12 +16,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nph_body.h" #include "fix_nph_body.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -41,22 +41,15 @@ FixNPHBody::FixNPHBody(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp/body",id_temp));
strcpy(id_temp,tcmd.c_str());
tcmd += fmt::format(" {} temp/body",group->names[igroup]);
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -16,12 +16,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_npt_body.h" #include "fix_npt_body.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -41,22 +41,15 @@ FixNPTBody::FixNPTBody(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp/body",id_temp));
strcpy(id_temp,tcmd.c_str());
tcmd += fmt::format(" {} temp/body",group->names[igroup]);
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -16,12 +16,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nvt_body.h" #include "fix_nvt_body.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -39,11 +39,8 @@ FixNVTBody::FixNVTBody(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} {} temp/body",
strcpy(id_temp,tcmd.c_str()); id_temp,group->names[igroup]));
tcmd += fmt::format(" {} temp/body",group->names[igroup]);
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_npt_gpu.h" #include "fix_npt_gpu.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,7 +35,7 @@ FixNPTGPU::FixNPTGPU(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp"); id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style

View File

@ -11,11 +11,13 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nvt_gpu.h" #include "fix_nvt_gpu.h"
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -16,8 +16,6 @@
#include "modify.h" #include "modify.h"
#include "error.h" #include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -39,7 +37,7 @@ FixNPHKokkos<DeviceType>::FixNPHKokkos(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
this->id_temp = utils::strdup(std::string(this->id) + "_temp"); this->id_temp = utils::strdup(std::string(this->id) + "_temp");
this->modify->add_compute(std::string(this->id_temp)+" all temp/kk"); this->modify->add_compute(fmt::format("{} all temp/kk",this->id_temp));
this->tcomputeflag = 1; this->tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
@ -47,8 +45,8 @@ FixNPHKokkos<DeviceType>::FixNPHKokkos(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
this->id_press = utils::strdup(std::string(this->id) + "_press"); this->id_press = utils::strdup(std::string(this->id) + "_press");
this->modify->add_compute(std::string(this->id_press) this->modify->add_compute(fmt::format("{} all pressure {}",
+" all pressure "+this->id_temp); this->id_press, this->id_temp));
this->pcomputeflag = 1; this->pcomputeflag = 1;
} }

View File

@ -16,8 +16,6 @@
#include "modify.h" #include "modify.h"
#include "error.h" #include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -39,7 +37,7 @@ FixNPTKokkos<DeviceType>::FixNPTKokkos(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
this->id_temp = utils::strdup(std::string(this->id) + "_temp"); this->id_temp = utils::strdup(std::string(this->id) + "_temp");
this->modify->add_compute(std::string(this->id_temp)+" all temp/kk"); this->modify->add_compute(fmt::format("{} all temp/kk",this->id_temp));
this->tcomputeflag = 1; this->tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
@ -47,8 +45,8 @@ FixNPTKokkos<DeviceType>::FixNPTKokkos(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
this->id_press = utils::strdup(std::string(this->id) + "_press"); this->id_press = utils::strdup(std::string(this->id) + "_press");
this->modify->add_compute(std::string(this->id_press) this->modify->add_compute(fmt::format("{} all pressure {}",
+" all pressure "+this->id_temp); this->id_press, this->id_temp));
this->pcomputeflag = 1; this->pcomputeflag = 1;
} }

View File

@ -38,7 +38,7 @@ FixNVTKokkos<DeviceType>::FixNVTKokkos(LAMMPS *lmp, int narg, char **arg) :
// id = fix-ID + temp // id = fix-ID + temp
this->id_temp = utils::strdup(std::string(this->id)+"_temp"); this->id_temp = utils::strdup(std::string(this->id)+"_temp");
this->modify->add_compute(std::string(this->id_temp)+" all temp/kk"); this->modify->add_compute(fmt::format("{} all temp/kk",this->id_temp));
this->tcomputeflag = 1; this->tcomputeflag = 1;
} }

View File

@ -86,11 +86,8 @@ FixBondSwap::FixBondSwap(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp, compute group = fix group // id = fix-ID + temp, compute group = fix group
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[cmd.size()+1]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,cmd.c_str());
modify->add_compute(cmd + " all temp");
tflag = 1; tflag = 1;
// initialize atom list // initialize atom list

View File

@ -18,9 +18,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_nph.h" #include "fix_rigid_nph.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -56,7 +56,7 @@ FixRigidNPH::FixRigidNPH(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp"); id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style

View File

@ -18,9 +18,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_nph_small.h" #include "fix_rigid_nph_small.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -59,7 +59,7 @@ FixRigidNPHSmall::FixRigidNPHSmall(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp"); id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style

View File

@ -18,9 +18,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_npt.h" #include "fix_rigid_npt.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -66,7 +66,7 @@ FixRigidNPT::FixRigidNPT(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp"); id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style

View File

@ -18,9 +18,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_npt_small.h" #include "fix_rigid_npt_small.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -70,7 +70,7 @@ FixRigidNPTSmall::FixRigidNPTSmall(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp"); id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style

View File

@ -121,7 +121,7 @@ FixNPHug::FixNPHug(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp"); id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
@ -135,7 +135,7 @@ FixNPHug::FixNPHug(LAMMPS *lmp, int narg, char **arg) :
// create a new compute potential energy compute // create a new compute potential energy compute
id_pe = utils::strdup(std::string(id)+"_pe"); id_pe = utils::strdup(std::string(id)+"_pe");
modify->add_compute(std::string(id_pe)+" all pe"); modify->add_compute(fmt::format("{} all pe",id_pe));
peflag = 1; peflag = 1;
} }

View File

@ -59,9 +59,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr; if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr;
else { else {
int n = strlen(arg[3]) + 1; id_temp = utils::strdup(arg[3]);
id_temp = new char[n];
strcpy(id_temp,arg[3]);
int icompute = modify->find_compute(id_temp); int icompute = modify->find_compute(id_temp);
if (icompute < 0) if (icompute < 0)
@ -446,7 +444,5 @@ void ComputePressureBocs::virial_compute(int n, int ndiag)
void ComputePressureBocs::reset_extra_compute_fix(const char *id_new) void ComputePressureBocs::reset_extra_compute_fix(const char *id_new)
{ {
delete [] id_temp; delete [] id_temp;
int n = strlen(id_new) + 1; id_temp = utils::strdup(id_new);
id_temp = new char[n];
strcpy(id_temp,id_new);
} }

View File

@ -16,11 +16,6 @@
#include "fix_bocs.h" #include "fix_bocs.h"
#include <cstring>
#include <cmath>
#include <vector>
#include "atom.h" #include "atom.h"
#include "citeme.h" #include "citeme.h"
#include "comm.h" #include "comm.h"
@ -29,7 +24,6 @@
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fix_deform.h" #include "fix_deform.h"
#include "force.h" #include "force.h"
#include "group.h" #include "group.h"
#include "irregular.h" #include "irregular.h"
@ -40,6 +34,10 @@
#include "respa.h" #include "respa.h"
#include "update.h" #include "update.h"
#include <cmath>
#include <cstring>
#include <vector>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -70,7 +68,8 @@ const int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction
FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), Fix(lmp, narg, arg),
rfix(nullptr), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr), rfix(nullptr), id_dilate(nullptr), irregular(nullptr),
id_temp(nullptr), id_press(nullptr),
eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr), eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr),
eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr),
etap_mass(nullptr) etap_mass(nullptr)
@ -403,38 +402,16 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id)+"_temp");
int n = strlen(id) + 6; modify->add_compute(fmt::format("{} all temp",id_temp));
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id)+"_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all PRESSURE/BOCS {}",id_press,id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "PRESSURE/BOCS";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
/*~ MRD End of stuff copied from fix_npt.cpp~*/ /*~ MRD End of stuff copied from fix_npt.cpp~*/

View File

@ -257,7 +257,6 @@ void FixRX::post_constructor()
bool match; bool match;
char **tmpspecies = new char*[maxspecies]; char **tmpspecies = new char*[maxspecies];
int tmpmaxstrlen = 0;
for (int jj=0; jj < maxspecies; jj++) for (int jj=0; jj < maxspecies; jj++)
tmpspecies[jj] = nullptr; tmpspecies[jj] = nullptr;
@ -316,9 +315,7 @@ void FixRX::post_constructor()
if (!match) { if (!match) {
if (nUniqueSpecies+1>=maxspecies) if (nUniqueSpecies+1>=maxspecies)
error->all(FLERR,"Exceeded the maximum number of species permitted in fix rx."); error->all(FLERR,"Exceeded the maximum number of species permitted in fix rx.");
tmpspecies[nUniqueSpecies] = new char[strlen(word)+1]; tmpspecies[nUniqueSpecies] = utils::strdup(word);
strcpy(tmpspecies[nUniqueSpecies],word);
tmpmaxstrlen = MAX(tmpmaxstrlen,(int)strlen(word));
nUniqueSpecies++; nUniqueSpecies++;
} }
word = strtok(nullptr, " \t\n\r\f"); word = strtok(nullptr, " \t\n\r\f");
@ -335,61 +332,31 @@ void FixRX::post_constructor()
id_fix_species = nullptr; id_fix_species = nullptr;
id_fix_species_old = nullptr; id_fix_species_old = nullptr;
n = strlen(id) + strlen("_SPECIES") + 1; id_fix_species = utils::strdup(std::string(id)+"_SPECIES");
id_fix_species = new char[n]; id_fix_species_old = utils::strdup(std::string(id)+"_SPECIES_OLD");
n = strlen(id) + strlen("_SPECIES_OLD") + 1;
id_fix_species_old = new char[n];
strcpy(id_fix_species,id); const std::string fmtstr = "{} {} property/atom ";
strcat(id_fix_species,"_SPECIES"); auto newcmd1 = fmt::format(fmtstr,id_fix_species,group->names[igroup]);
strcpy(id_fix_species_old,id); auto newcmd2 = fmt::format(fmtstr,id_fix_species_old,group->names[igroup]);
strcat(id_fix_species_old,"_SPECIES_OLD");
char **newarg = new char*[nspecies+5];
char **newarg2 = new char*[nspecies+5];
newarg[0] = id_fix_species;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "property/atom";
newarg2[0] = id_fix_species_old;
newarg2[1] = group->names[igroup];
newarg2[2] = (char *) "property/atom";
char *str1 = new char[tmpmaxstrlen+3];
char *str2 = new char[tmpmaxstrlen+6];
for (int ii=0; ii<nspecies; ii++) { for (int ii=0; ii<nspecies; ii++) {
strcpy(str1,"d_"); newcmd1 += fmt::format(" d_{}",tmpspecies[ii]);
strcpy(str2,"d_"); newcmd2 += fmt::format(" d_{}Old",tmpspecies[ii]);
strcat(str1,tmpspecies[ii]);
strcat(str2,tmpspecies[ii]);
strcat(str2,"Old");
newarg[ii+3] = new char[strlen(str1)+1];
newarg2[ii+3] = new char[strlen(str2)+1];
strcpy(newarg[ii+3],str1);
strcpy(newarg2[ii+3],str2);
} }
delete[] str1; newcmd1 += " ghost yes";
delete[] str2; newcmd2 += " ghost yes";
newarg[nspecies+3] = (char *) "ghost";
newarg[nspecies+4] = (char *) "yes";
newarg2[nspecies+3] = (char *) "ghost";
newarg2[nspecies+4] = (char *) "yes";
modify->add_fix(nspecies+5,newarg,1); modify->add_fix(newcmd1);
fix_species = (FixPropertyAtom *) modify->fix[modify->nfix-1]; fix_species = (FixPropertyAtom *) modify->fix[modify->nfix-1];
restartFlag = modify->fix[modify->nfix-1]->restart_reset; restartFlag = modify->fix[modify->nfix-1]->restart_reset;
modify->add_fix(nspecies+5,newarg2,1); modify->add_fix(newcmd2);
fix_species_old = (FixPropertyAtom *) modify->fix[modify->nfix-1]; fix_species_old = (FixPropertyAtom *) modify->fix[modify->nfix-1];
if (nspecies==0) error->all(FLERR,"There are no rx species specified."); if (nspecies==0) error->all(FLERR,"There are no rx species specified.");
for (int jj=0;jj<nspecies;jj++) { for (int jj=0;jj<nspecies;jj++) {
delete[] tmpspecies[jj]; delete[] tmpspecies[jj];
delete[] newarg[jj+3];
delete[] newarg2[jj+3];
} }
delete[] newarg;
delete[] newarg2;
delete[] tmpspecies; delete[] tmpspecies;
read_file( kineticsFile ); read_file( kineticsFile );

View File

@ -596,9 +596,7 @@ void PairExp6rx::coeff(int narg, char **arg)
if (nspecies==0) error->all(FLERR,"There are no rx species specified."); if (nspecies==0) error->all(FLERR,"There are no rx species specified.");
read_file(arg[2]); read_file(arg[2]);
n = strlen(arg[3]) + 1; site1 = utils::strdup(arg[3]);
site1 = new char[n];
strcpy(site1,arg[3]);
int ispecies; int ispecies;
for (ispecies = 0; ispecies < nspecies; ispecies++) { for (ispecies = 0; ispecies < nspecies; ispecies++) {
@ -607,9 +605,7 @@ void PairExp6rx::coeff(int narg, char **arg)
if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) if (ispecies == nspecies && strcmp(site1,"1fluid") != 0)
error->all(FLERR,"Site1 name not recognized in pair coefficients"); error->all(FLERR,"Site1 name not recognized in pair coefficients");
n = strlen(arg[4]) + 1; site2 = utils::strdup(arg[4]);
site2 = new char[n];
strcpy(site2,arg[4]);
for (ispecies = 0; ispecies < nspecies; ispecies++) { for (ispecies = 0; ispecies < nspecies; ispecies++) {
if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break;
@ -806,17 +802,12 @@ void PairExp6rx::read_file(char *file)
params[nparams].ispecies = ispecies; params[nparams].ispecies = ispecies;
n = strlen(&atom->dname[ispecies][0]) + 1; params[nparams].name = utils::strdup(&atom->dname[ispecies][0]);
params[nparams].name = new char[n]; params[nparams].potential = utils::strdup(words[1]);
strcpy(params[nparams].name,&atom->dname[ispecies][0]);
n = strlen(words[1]) + 1;
params[nparams].potential = new char[n];
strcpy(params[nparams].potential,words[1]);
if (strcmp(params[nparams].potential,"exp6") == 0) { if (strcmp(params[nparams].potential,"exp6") == 0) {
params[nparams].alpha = atof(words[2]); params[nparams].alpha = utils::numeric(FLERR,words[2],false,lmp);
params[nparams].epsilon = atof(words[3]); params[nparams].epsilon = utils::numeric(FLERR,words[3],false,lmp);
params[nparams].rm = atof(words[4]); params[nparams].rm = utils::numeric(FLERR,words[4],false,lmp);
if (params[nparams].epsilon <= 0.0 || params[nparams].rm <= 0.0 || if (params[nparams].epsilon <= 0.0 || params[nparams].rm <= 0.0 ||
params[nparams].alpha < 0.0) params[nparams].alpha < 0.0)
error->all(FLERR,"Illegal exp6/rx parameters. Rm and Epsilon must be greater than zero. Alpha cannot be negative."); error->all(FLERR,"Illegal exp6/rx parameters. Rm and Epsilon must be greater than zero. Alpha cannot be negative.");
@ -842,11 +833,9 @@ void PairExp6rx::read_file2(char *file)
fp = nullptr; fp = nullptr;
if (comm->me == 0) { if (comm->me == 0) {
fp = fopen(file,"r"); fp = fopen(file,"r");
if (fp == nullptr) { if (fp == nullptr)
char str[128]; error->one(FLERR,fmt::format("Cannot open polynomial file {}: {}",
snprintf(str,128,"Cannot open polynomial file %s",file); file,utils::getsyserror()));
error->one(FLERR,str);
}
} }
// one set of params can span multiple lines // one set of params can span multiple lines

View File

@ -387,14 +387,9 @@ void PairMultiLucyRX::coeff(int narg, char **arg)
bcast_table(tb); bcast_table(tb);
nspecies = atom->nspecies_dpd; nspecies = atom->nspecies_dpd;
int n;
n = strlen(arg[4]) + 1;
site1 = new char[n];
strcpy(site1,arg[4]);
n = strlen(arg[5]) + 1; site1 = utils::strdup(arg[4]);
site2 = new char[n]; site2 = utils::strdup(arg[5]);
strcpy(site2,arg[5]);
// set table cutoff // set table cutoff

View File

@ -322,10 +322,8 @@ void PairTableRX::coeff(int narg, char **arg)
nspecies = atom->nspecies_dpd; nspecies = atom->nspecies_dpd;
if (nspecies==0) error->all(FLERR,"There are no rx species specified."); if (nspecies==0) error->all(FLERR,"There are no rx species specified.");
int n;
n = strlen(arg[4]) + 1; site1 = utils::strdup(arg[4]);
site1 = new char[n];
strcpy(site1,arg[4]);
int ispecies; int ispecies;
for (ispecies = 0; ispecies < nspecies; ispecies++) { for (ispecies = 0; ispecies < nspecies; ispecies++) {
@ -334,9 +332,7 @@ void PairTableRX::coeff(int narg, char **arg)
if (ispecies == nspecies && strcmp(site1,"1fluid") != 0) if (ispecies == nspecies && strcmp(site1,"1fluid") != 0)
error->all(FLERR,"Site1 name not recognized in pair coefficients"); error->all(FLERR,"Site1 name not recognized in pair coefficients");
n = strlen(arg[5]) + 1; site2 = utils::strdup(arg[5]);
site2 = new char[n];
strcpy(site2,arg[5]);
for (ispecies = 0; ispecies < nspecies; ispecies++) { for (ispecies = 0; ispecies < nspecies; ispecies++) {
if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break; if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break;

View File

@ -13,15 +13,16 @@
#include "compute_temp_drude.h" #include "compute_temp_drude.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h" #include "comm.h"
#include "force.h"
#include "modify.h"
#include "fix_drude.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "comm.h" #include "fix_drude.h"
#include "force.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -116,9 +117,7 @@ int ComputeTempDrude::modify_param(int narg, char **arg)
if (strcmp(arg[0],"temp") == 0) { if (strcmp(arg[0],"temp") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
delete [] id_temp; delete [] id_temp;
int n = strlen(arg[1]) + 1; id_temp = utils::strdup(arg[1]);
id_temp = new char[n];
strcpy(id_temp,arg[1]);
int icompute = modify->find_compute(id_temp); int icompute = modify->find_compute(id_temp);
if (icompute < 0) if (icompute < 0)

View File

@ -16,23 +16,25 @@
---------------------------------------------------------------------------------------- */ ---------------------------------------------------------------------------------------- */
#include "fix_tgnh_drude.h" #include "fix_tgnh_drude.h"
#include <cstring>
#include <cmath>
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "compute.h"
#include "domain.h"
#include "error.h"
#include "fix_deform.h"
#include "force.h" #include "force.h"
#include "group.h" #include "group.h"
#include "comm.h"
#include "neighbor.h"
#include "irregular.h" #include "irregular.h"
#include "modify.h"
#include "fix_deform.h"
#include "compute.h"
#include "kspace.h" #include "kspace.h"
#include "update.h"
#include "respa.h"
#include "domain.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "modify.h"
#include "neighbor.h"
#include "respa.h"
#include "update.h"
#include <cstring>
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -1428,9 +1430,7 @@ int FixTGNHDrude::modify_param(int narg, char **arg)
tcomputeflag = 0; tcomputeflag = 0;
} }
delete [] id_temp; delete [] id_temp;
int n = strlen(arg[1]) + 1; id_temp = utils::strdup(arg[1]);
id_temp = new char[n];
strcpy(id_temp,arg[1]);
int icompute = modify->find_compute(arg[1]); int icompute = modify->find_compute(arg[1]);
if (icompute < 0) if (icompute < 0)
@ -1462,9 +1462,7 @@ int FixTGNHDrude::modify_param(int narg, char **arg)
pcomputeflag = 0; pcomputeflag = 0;
} }
delete [] id_press; delete [] id_press;
int n = strlen(arg[1]) + 1; id_press = utils::strdup(arg[1]);
id_press = new char[n];
strcpy(id_press,arg[1]);
int icompute = modify->find_compute(arg[1]); int icompute = modify->find_compute(arg[1]);
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");

View File

@ -12,10 +12,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_tgnpt_drude.h" #include "fix_tgnpt_drude.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,23 +34,15 @@ FixTGNPTDrude::FixTGNPTDrude(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp, tcmd.c_str());
tcmd += " all temp";
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press, pcmd.c_str());
pcmd += " all pressure " + std::string(id_temp);
modify->add_compute(pcmd);
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -12,11 +12,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_tgnvt_drude.h" #include "fix_tgnvt_drude.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,11 +35,7 @@ FixTGNVTDrude::FixTGNVTDrude(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
strcpy(id_temp, tcmd.c_str());
tcmd += fmt::format(" {} temp", group->names[igroup]);
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -16,17 +16,18 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "compute_temp_region_eff.h" #include "compute_temp_region_eff.h"
#include "atom.h" #include "atom.h"
#include "update.h"
#include "force.h"
#include "domain.h" #include "domain.h"
#include "region.h" #include "error.h"
#include "force.h"
#include "group.h" #include "group.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "region.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -43,9 +44,7 @@ ComputeTempRegionEff::ComputeTempRegionEff(LAMMPS *lmp, int narg, char **arg) :
iregion = domain->find_region(arg[3]); iregion = domain->find_region(arg[3]);
if (iregion == -1) if (iregion == -1)
error->all(FLERR,"Region ID for compute temp/region/eff does not exist"); error->all(FLERR,"Region ID for compute temp/region/eff does not exist");
int n = strlen(arg[3]) + 1; idregion = utils::strdup(arg[3]);
idregion = new char[n];
strcpy(idregion,arg[3]);
scalar_flag = vector_flag = 1; scalar_flag = vector_flag = 1;
size_vector = 6; size_vector = 6;

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nph_eff.h" #include "fix_nph_eff.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,35 +34,15 @@ FixNPHEff::FixNPHEff(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/eff",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/eff";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_npt_eff.h" #include "fix_npt_eff.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,35 +34,15 @@ FixNPTEff::FixNPTEff(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/eff",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/eff";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,11 +11,13 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nvt_eff.h" #include "fix_nvt_eff.h"
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -33,17 +35,8 @@ FixNVTEff::FixNVTEff(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp/eff",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/eff";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -11,19 +11,20 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cmath>
#include <cstring>
#include "fix_nvt_sllod_eff.h" #include "fix_nvt_sllod_eff.h"
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "compute.h"
#include "domain.h" #include "domain.h"
#include "group.h" #include "error.h"
#include "modify.h"
#include "fix.h" #include "fix.h"
#include "fix_deform.h" #include "fix_deform.h"
#include "compute.h" #include "group.h"
#include "error.h" #include "math_extra.h"
#include "modify.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -45,18 +46,9 @@ FixNVTSllodEff::FixNVTSllodEff(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} tmp/deform/eff",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/deform/eff";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -15,18 +15,19 @@
Contributing author: Andres Jaramillo-Botero Contributing author: Andres Jaramillo-Botero
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include <cmath>
#include "fix_temp_rescale_eff.h" #include "fix_temp_rescale_eff.h"
#include "atom.h" #include "atom.h"
#include "force.h"
#include "group.h"
#include "update.h"
#include "comm.h" #include "comm.h"
#include "modify.h"
#include "compute.h" #include "compute.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "group.h"
#include "modify.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -56,17 +57,9 @@ FixTempRescaleEff::FixTempRescaleEff(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp/eff // create a new compute temp/eff
// id = fix-ID + temp, compute group = fix group // id = fix-ID + temp, compute group = fix group
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp/eff",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[6];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/eff";
modify->add_compute(3,newarg);
delete [] newarg;
tflag = 1; tflag = 1;
energy = 0.0; energy = 0.0;

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_npt_intel.h" #include "fix_npt_intel.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -25,44 +25,24 @@ FixNPTIntel::FixNPTIntel(LAMMPS *lmp, int narg, char **arg) :
FixNHIntel(lmp, narg, arg) FixNHIntel(lmp, narg, arg)
{ {
if (!tstat_flag) if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix npt/omp"); error->all(FLERR,"Temperature control must be used with fix npt/intel");
if (!pstat_flag) if (!pstat_flag)
error->all(FLERR,"Pressure control must be used with fix npt/omp"); error->all(FLERR,"Pressure control must be used with fix npt/intl");
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,11 +11,13 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nvt_intel.h" #include "fix_nvt_intel.h"
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -26,25 +28,15 @@ FixNVTIntel::FixNVTIntel(LAMMPS *lmp, int narg, char **arg) :
FixNHIntel(lmp, narg, arg) FixNHIntel(lmp, narg, arg)
{ {
if (!tstat_flag) if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix nvt"); error->all(FLERR,"Temperature control must be used with fix nvt/intel");
if (pstat_flag) if (pstat_flag)
error->all(FLERR,"Pressure control can not be used with fix nvt"); error->all(FLERR,"Pressure control can not be used with fix nvt/intel");
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -46,18 +46,9 @@ FixNVTSllodIntel::FixNVTSllodIntel(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp/deform",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/deform";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -17,22 +17,22 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_lb_fluid.h" #include "fix_lb_fluid.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "modify.h"
#include "random_mars.h"
#include "update.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "comm.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "atom.h"
#include "group.h"
#include "random_mars.h"
#include "update.h"
#include "force.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -131,24 +131,10 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg,
} }
// Create temperature compute: // Create temperature compute:
const char *fix_id = arg[1];
int n = strlen(fix_id)+6;
id_temp = new char[n];
strcpy(id_temp,fix_id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char*) "temp";
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(3,newarg); modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
delete [] newarg;
int icompute = modify->find_compute(id_temp); int icompute = modify->find_compute(id_temp);
if (icompute < 0) {
error->all(FLERR,"Temperature ID for fix nvt/manifold/rattle "
"does not exist");
}
temperature = modify->compute[icompute]; temperature = modify->compute[icompute];
if (temperature->tempbias) which = BIAS; if (temperature->tempbias) which = BIAS;
else which = NOBIAS; else which = NOBIAS;
@ -167,8 +153,6 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg,
for (int ich = 0; ich < mtchain; ++ich) { for (int ich = 0; ich < mtchain; ++ich) {
eta[ich] = eta_dot[ich] = eta_dotdot[ich] = 0.0; eta[ich] = eta_dot[ich] = eta_dotdot[ich] = 0.0;
} }
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -185,9 +169,6 @@ FixNVTManifoldRattle::~FixNVTManifoldRattle()
if (id_temp) delete[] id_temp; if (id_temp) delete[] id_temp;
} }
int FixNVTManifoldRattle::setmask() int FixNVTManifoldRattle::setmask()
{ {
int mask = 0; int mask = 0;
@ -198,7 +179,6 @@ int FixNVTManifoldRattle::setmask()
return mask; return mask;
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Check that force modification happens before position and velocity update. Check that force modification happens before position and velocity update.
Make sure respa is not used. Make sure respa is not used.
@ -219,8 +199,6 @@ void FixNVTManifoldRattle::init()
} }
void FixNVTManifoldRattle::setup(int /*vflag*/) void FixNVTManifoldRattle::setup(int /*vflag*/)
{ {
compute_temp_target(); compute_temp_target();
@ -359,9 +337,6 @@ void FixNVTManifoldRattle::nh_v_temp()
} }
} }
// Most of this logic is based on fix_nh: // Most of this logic is based on fix_nh:
void FixNVTManifoldRattle::initial_integrate(int /*vflag*/) void FixNVTManifoldRattle::initial_integrate(int /*vflag*/)
{ {
@ -381,8 +356,6 @@ void FixNVTManifoldRattle::final_integrate()
nhc_temp_integrate(); nhc_temp_integrate();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixNVTManifoldRattle::reset_dt() void FixNVTManifoldRattle::reset_dt()
{ {
@ -395,10 +368,6 @@ void FixNVTManifoldRattle::reset_dt()
} }
double FixNVTManifoldRattle::memory_usage() double FixNVTManifoldRattle::memory_usage()
{ {
double bytes = FixNVEManifoldRattle::memory_usage(); double bytes = FixNVEManifoldRattle::memory_usage();

View File

@ -23,14 +23,16 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_grem.h" #include "fix_grem.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "force.h"
#include "update.h"
#include "modify.h"
#include "domain.h"
#include "compute.h" #include "compute.h"
#include "domain.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -65,65 +67,28 @@ FixGrem::FixGrem(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all PRESSURE/GREM {}",
strcpy(id_press,id); id_press, id_temp));
strcat(id_press,"_press");
newarg = new char*[5];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "PRESSURE/GREM";
newarg[3] = id_temp;
newarg[4] = id;
modify->add_compute(5,newarg);
delete [] newarg;
// create a new compute ke style // create a new compute ke style
// id = fix-ID + ke // id = fix-ID + ke
n = strlen(id) + 8; id_ke = utils::strdup(std::string(id) + "_ke");
id_ke = new char[n]; modify->add_compute(fmt::format("{} all ke",id_temp));
strcpy(id_ke,id);
strcat(id_ke,"_ke");
newarg = new char*[3];
newarg[0] = id_ke;
newarg[1] = (char *) "all";
newarg[2] = (char *) "ke";
modify->add_compute(3,newarg);
delete [] newarg;
// create a new compute pe style // create a new compute pe style
// id = fix-ID + pe // id = fix-ID + pe
n = strlen(id) + 9; id_pe = utils::strdup(std::string(id) + "_pe");
id_pe = new char[n]; modify->add_compute(fmt::format("{} all pe",id_temp));
strcpy(id_pe,id);
strcat(id_pe,"_pe");
newarg = new char*[3];
newarg[0] = id_pe;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pe";
modify->add_compute(3,newarg);
delete [] newarg;
int ifix = modify->find_fix(id_nh); int ifix = modify->find_fix(id_nh);
if (ifix < 0) if (ifix < 0)

View File

@ -15,27 +15,28 @@
Contributing authors: Contributing authors:
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include <cmath>
#include "fix_npt_cauchy.h" #include "fix_npt_cauchy.h"
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "force.h"
#include "group.h"
#include "comm.h" #include "comm.h"
#include "neighbor.h" #include "compute.h"
#include "irregular.h" #include "domain.h"
#include "modify.h" #include "error.h"
#include "fix_deform.h" #include "fix_deform.h"
#include "fix_store.h" #include "fix_store.h"
#include "compute.h" #include "force.h"
#include "group.h"
#include "irregular.h"
#include "kspace.h" #include "kspace.h"
#include "update.h" #include "math_extra.h"
#include "respa.h"
#include "domain.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "modify.h"
#include "neighbor.h"
#include "respa.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -53,7 +54,8 @@ enum{ISO,ANISO,TRICLINIC};
FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), Fix(lmp, narg, arg),
rfix(nullptr), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr), rfix(nullptr), id_dilate(nullptr), irregular(nullptr),
id_temp(nullptr), id_press(nullptr),
eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr), eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr),
eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr),
etap_mass(nullptr), id_store(nullptr),init_store(nullptr) etap_mass(nullptr), id_store(nullptr),init_store(nullptr)
@ -604,36 +606,16 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nph_asphere_omp.h" #include "fix_nph_asphere_omp.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,35 +34,15 @@ FixNPHAsphereOMP::FixNPHAsphereOMP(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/asphere",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/asphere";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nph_omp.h" #include "fix_nph_omp.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,7 +35,7 @@ FixNPHOMP::FixNPHOMP(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id) + "_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
@ -43,6 +43,6 @@ FixNPHOMP::FixNPHOMP(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press"); id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(std::string(id_press)+" all pressure "+id_temp); modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nph_sphere_omp.h" #include "fix_nph_sphere_omp.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,35 +34,15 @@ FixNPHSphereOMP::FixNPHSphereOMP(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/sphere",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/sphere";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_npt_asphere_omp.h" #include "fix_npt_asphere_omp.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,35 +34,15 @@ FixNPTAsphereOMP::FixNPTAsphereOMP(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/asphere",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/asphere";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_npt_omp.h" #include "fix_npt_omp.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,7 +35,7 @@ FixNPTOMP::FixNPTOMP(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id) + "_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(std::string(id_temp)+" all temp"); modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
@ -43,6 +43,6 @@ FixNPTOMP::FixNPTOMP(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press"); id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(std::string(id_press)+" all pressure "+id_temp); modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_npt_sphere_omp.h" #include "fix_npt_sphere_omp.h"
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -34,35 +34,15 @@ FixNPTSphereOMP::FixNPTSphereOMP(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/sphere",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/sphere";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -33,17 +33,8 @@ FixNVTAsphereOMP::FixNVTAsphereOMP(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp/asphere",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/asphere";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -11,11 +11,13 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nvt_omp.h" #include "fix_nvt_omp.h"
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -15,18 +15,21 @@
Contributing author: Axel Kohlmeyer (Temple U) Contributing author: Axel Kohlmeyer (Temple U)
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "omp_compat.h"
#include "fix_nvt_sllod_omp.h" #include "fix_nvt_sllod_omp.h"
#include <cstring>
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "group.h" #include "compute.h"
#include "modify.h" #include "domain.h"
#include "error.h"
#include "fix.h" #include "fix.h"
#include "fix_deform.h" #include "fix_deform.h"
#include "compute.h" #include "group.h"
#include "error.h" #include "math_extra.h"
#include "domain.h" #include "modify.h"
#include <cstring>
#include "omp_compat.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -51,18 +54,9 @@ FixNVTSllodOMP::FixNVTSllodOMP(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp/deform",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/deform";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }
@ -82,7 +76,7 @@ void FixNVTSllodOMP::init()
int i; int i;
for (i = 0; i < modify->nfix; i++) for (i = 0; i < modify->nfix; i++)
if (strncmp(modify->fix[i]->style,"deform",6) == 0) { if (utils::strmatch(modify->fix[i]->style,"^deform")) {
if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP) if (((FixDeform *) modify->fix[i])->remapflag != Domain::V_REMAP)
error->all(FLERR,"Using fix nvt/sllod/omp with inconsistent fix " error->all(FLERR,"Using fix nvt/sllod/omp with inconsistent fix "
"deform remap option"); "deform remap option");

View File

@ -11,11 +11,11 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <cstring>
#include "fix_nvt_sphere_omp.h" #include "fix_nvt_sphere_omp.h"
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -33,17 +33,8 @@ FixNVTSphereOMP::FixNVTSphereOMP(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} {} temp/sphere",
strcpy(id_temp,id); id_temp,group->names[igroup]));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "temp/sphere";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -18,9 +18,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_nph_omp.h" #include "fix_rigid_nph_omp.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -57,34 +57,15 @@ FixRigidNPHOMP::FixRigidNPHOMP(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -18,9 +18,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_npt_omp.h" #include "fix_rigid_npt_omp.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -69,34 +69,15 @@ FixRigidNPTOMP::FixRigidNPTOMP(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -18,9 +18,6 @@
#include "fix_qbmsst.h" #include "fix_qbmsst.h"
#include <cmath>
#include <cstring>
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
@ -34,6 +31,9 @@
#include "kspace.h" #include "kspace.h"
#include "math_const.h" #include "math_const.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
using namespace MathConst; using namespace MathConst;
@ -204,45 +204,23 @@ FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
// id = fix-ID + temp // id = fix-ID + temp
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n]; id_temp = utils::strdup(std::string(id) + "_temp");
strcpy(id_temp,id); modify->add_compute(fmt::format("{} all temp",id_temp));
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = const_cast<char *>("all");
newarg[2] = const_cast<char *>("temp");
modify->add_compute(3,newarg);
delete [] newarg;
tflag = 1; tflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n]; id_press = utils::strdup(std::string(id) + "_press");
strcpy(id_press,id); modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = const_cast<char *>("all");
newarg[2] = const_cast<char *>("pressure");
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pflag = 1; pflag = 1;
// create a new compute potential energy compute // create a new compute potential energy compute
n = strlen(id) + 3;
id_pe = new char[n]; id_pe = utils::strdup(std::string(id) + "_pe");
strcpy(id_pe,id); modify->add_compute(fmt::format("{} all pe",id_temp));
strcat(id_pe,"_pe");
newarg = new char*[3];
newarg[0] = id_pe;
newarg[1] = (char*)"all";
newarg[2] = (char*)"pe";
modify->add_compute(3,newarg);
delete [] newarg;
peflag = 1; peflag = 1;
// allocate qbmsst // allocate qbmsst

View File

@ -14,24 +14,26 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nh_uef.h" #include "fix_nh_uef.h"
#include <cstring>
#include <cmath>
#include "atom.h" #include "atom.h"
#include "force.h"
#include "comm.h"
#include "citeme.h" #include "citeme.h"
#include "irregular.h" #include "comm.h"
#include "modify.h"
#include "compute.h" #include "compute.h"
#include "update.h"
#include "domain.h"
#include "error.h"
#include "output.h"
#include "timer.h"
#include "neighbor.h"
#include "compute_pressure_uef.h" #include "compute_pressure_uef.h"
#include "compute_temp_uef.h" #include "compute_temp_uef.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "irregular.h"
#include "modify.h"
#include "neighbor.h"
#include "output.h"
#include "timer.h"
#include "uef_utils.h" #include "uef_utils.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -179,29 +181,12 @@ FixNHUef::FixNHUef(LAMMPS *lmp, int narg, char **arg) :
// Create temp and pressure computes for nh/uef // Create temp and pressure computes for nh/uef
int n = strlen(id) + 6; id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[n]; modify->add_compute(fmt::format("{} all temp/uef",id_temp));
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp/uef";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1; tcomputeflag = 1;
n = strlen(id) + 7; id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[n]; modify->add_compute(fmt::format("{} all pressure/uef {}",id_press, id_temp));
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure/uef";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1; pcomputeflag = 1;
nevery = 1; nevery = 1;
@ -214,8 +199,7 @@ FixNHUef::FixNHUef(LAMMPS *lmp, int narg, char **arg) :
FixNHUef::~FixNHUef() FixNHUef::~FixNHUef()
{ {
delete uefbox; delete uefbox;
if (pcomputeflag && !pstat_flag) if (pcomputeflag && !pstat_flag) {
{
modify->delete_compute(id_press); modify->delete_compute(id_press);
delete [] id_press; delete [] id_press;
} }

View File

@ -80,9 +80,7 @@ ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) :
else if (strcmp(arg[iarg], "radius") == 0) { else if (strcmp(arg[iarg], "radius") == 0) {
if (iarg + 2 > narg || strstr(arg[iarg+1],"v_") != arg[iarg+1] ) if (iarg + 2 > narg || strstr(arg[iarg+1],"v_") != arg[iarg+1] )
error->all(FLERR,"Illegal compute voronoi/atom command"); error->all(FLERR,"Illegal compute voronoi/atom command");
int n = strlen(&arg[iarg+1][2]) + 1; radstr = utils::strdup(&arg[iarg+1][2]);
radstr = new char[n];
strcpy(radstr,&arg[iarg+1][2]);
iarg += 2; iarg += 2;
} }
else if (strcmp(arg[iarg], "surface") == 0) { else if (strcmp(arg[iarg], "surface") == 0) {

View File

@ -16,20 +16,20 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_box_relax.h" #include "fix_box_relax.h"
#include <cmath>
#include <cstring>
#include "atom.h" #include "atom.h"
#include "domain.h"
#include "update.h"
#include "comm.h" #include "comm.h"
#include "compute.h"
#include "domain.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "kspace.h" #include "kspace.h"
#include "modify.h"
#include "compute.h"
#include "error.h"
#include "math_extra.h" #include "math_extra.h"
#include "modify.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -319,24 +319,17 @@ FixBoxRelax::FixBoxRelax(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,tcmd.c_str());
tcmd += " all temp";
modify->add_compute(tcmd);
tflag = 1; tflag = 1;
// create a new compute pressure style (virial only) // create a new compute pressure style (virial only)
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {} virial",
strcpy(id_press,pcmd.c_str()); id_press, id_temp));
pcmd += " all pressure " + std::string(id_temp) + " virial";
modify->add_compute(pcmd);
pflag = 1; pflag = 1;
dimension = domain->dimension; dimension = domain->dimension;

View File

@ -12,10 +12,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nph.h" #include "fix_nph.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,23 +34,15 @@ FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,tcmd.c_str());
tcmd += " all temp";
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
pcmd += " all pressure " + std::string(id_temp);
modify->add_compute(pcmd);
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -12,10 +12,11 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nph_sphere.h" #include "fix_nph_sphere.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,21 +36,15 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp/sphere",id_temp));
strcpy(id_temp,tcmd.c_str());
modify->add_compute(tcmd + " all temp/sphere");
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -12,10 +12,9 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_npt.h" #include "fix_npt.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,23 +34,15 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,tcmd.c_str());
tcmd += " all temp";
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
pcmd += " all pressure " + std::string(id_temp);
modify->add_compute(pcmd);
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -12,10 +12,11 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_npt_sphere.h" #include "fix_npt_sphere.h"
#include <cstring>
#include "modify.h"
#include "error.h" #include "error.h"
#include "modify.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,21 +36,15 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp/sphere",id_temp));
strcpy(id_temp,tcmd.c_str());
modify->add_compute(tcmd + " all temp/sphere");
tcomputeflag = 1; tcomputeflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
pcomputeflag = 1; pcomputeflag = 1;
} }

View File

@ -12,12 +12,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nve.h" #include "fix_nve.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "force.h"
#include "update.h"
#include "respa.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "respa.h"
#include "update.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -27,7 +27,7 @@ using namespace FixConst;
FixNVE::FixNVE(LAMMPS *lmp, int narg, char **arg) : FixNVE::FixNVE(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) Fix(lmp, narg, arg)
{ {
if (strcmp(style,"nve/sphere") != 0 && narg < 3) if (!utils::strmatch(style,"^nve/sphere") && narg < 3)
error->all(FLERR,"Illegal fix nve command"); error->all(FLERR,"Illegal fix nve command");
dynamic_group_allow = 1; dynamic_group_allow = 1;
@ -53,7 +53,7 @@ void FixNVE::init()
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
if (strstr(update->integrate_style,"respa")) if (utils::strmatch(update->integrate_style,"^respa"))
step_respa = ((Respa *) update->integrate)->step; step_respa = ((Respa *) update->integrate)->step;
} }

View File

@ -12,12 +12,10 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nvt.h" #include "fix_nvt.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,11 +33,7 @@ FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
strcpy(id_temp,tcmd.c_str());
tcmd += fmt::format(" {} temp",group->names[igroup]);
modify->add_compute(tcmd);
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -16,17 +16,18 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nvt_sllod.h" #include "fix_nvt_sllod.h"
#include <cstring>
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "compute.h"
#include "domain.h" #include "domain.h"
#include "group.h" #include "error.h"
#include "modify.h"
#include "fix.h" #include "fix.h"
#include "fix_deform.h" #include "fix_deform.h"
#include "compute.h" #include "group.h"
#include "error.h" #include "math_extra.h"
#include "modify.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -49,12 +50,9 @@ FixNVTSllod::FixNVTSllod(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[cmd.size()+1]; modify->add_compute(fmt::format("{} {} temp/deform",
strcpy(id_temp,cmd.c_str()); id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp/deform",group->names[igroup]);
modify->add_compute(cmd);
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -12,12 +12,10 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_nvt_sphere.h" #include "fix_nvt_sphere.h"
#include <cstring>
#include "error.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -35,11 +33,8 @@ FixNVTSphere::FixNVTSphere(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp // id = fix-ID + temp
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[cmd.size()+1]; modify->add_compute(fmt::format("{} {} temp/sphere",
strcpy(id_temp,cmd.c_str()); id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp/sphere",group->names[igroup]);
modify->add_compute(cmd);
tcomputeflag = 1; tcomputeflag = 1;
} }

View File

@ -12,19 +12,20 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_press_berendsen.h" #include "fix_press_berendsen.h"
#include <cstring>
#include <cmath>
#include "atom.h" #include "atom.h"
#include "force.h"
#include "comm.h" #include "comm.h"
#include "modify.h"
#include "fix_deform.h"
#include "compute.h" #include "compute.h"
#include "kspace.h"
#include "update.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fix_deform.h"
#include "force.h"
#include "kspace.h"
#include "modify.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -218,24 +219,16 @@ FixPressBerendsen::FixPressBerendsen(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all) // compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all // and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = new char[tcmd.size()+1]; modify->add_compute(fmt::format("{} all temp",id_temp));
strcpy(id_temp,tcmd.c_str());
tcmd += " all temp";
modify->add_compute(tcmd);
tflag = 1; tflag = 1;
// create a new compute pressure style // create a new compute pressure style
// id = fix-ID + press, compute group = all // id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press"); id_press = utils::strdup(std::string(id) + "_press");
id_press = new char[pcmd.size()+1]; modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
strcpy(id_press,pcmd.c_str());
pcmd += " all pressure " + std::string(id_temp);
modify->add_compute(pcmd);
pflag = 1; pflag = 1;
nrigid = 0; nrigid = 0;

View File

@ -72,10 +72,8 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp, compute group = fix group // id = fix-ID + temp, compute group = fix group
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = utils::strdup(cmd); modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp",group->names[igroup]);
modify->add_compute(cmd);
tflag = 1; tflag = 1;
energy = 0; energy = 0;

View File

@ -81,10 +81,8 @@ FixTempCSLD::FixTempCSLD(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp, compute group = fix group // id = fix-ID + temp, compute group = fix group
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = utils::strdup(cmd); modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp",group->names[igroup]);
modify->add_compute(cmd);
tflag = 1; tflag = 1;
vhold = nullptr; vhold = nullptr;

View File

@ -81,10 +81,8 @@ FixTempCSVR::FixTempCSVR(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style // create a new compute temp style
// id = fix-ID + temp, compute group = fix group // id = fix-ID + temp, compute group = fix group
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = utils::strdup(cmd); modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp",group->names[igroup]);
modify->add_compute(cmd);
tflag = 1; tflag = 1;
nmax = -1; nmax = -1;

View File

@ -68,10 +68,8 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp // create a new compute temp
// id = fix-ID + temp, compute group = fix group // id = fix-ID + temp, compute group = fix group
std::string cmd = id + std::string("_temp"); id_temp = utils::strdup(std::string(id) + "_temp");
id_temp = utils::strdup(cmd); modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
cmd += fmt::format(" {} temp",group->names[igroup]);
modify->add_compute(cmd);
tflag = 1; tflag = 1;
energy = 0.0; energy = 0.0;