From 3a0ae83c96a192268eb6be50b3e49217f699113a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 29 Jun 2020 00:06:28 -0400 Subject: [PATCH] apply simplifications to standard packages --- src/ASPHERE/fix_nph_asphere.cpp | 31 +++++++----------------- src/ASPHERE/fix_npt_asphere.cpp | 31 +++++++----------------- src/ASPHERE/fix_nvt_asphere.cpp | 18 ++++++-------- src/BODY/fix_nph_body.cpp | 31 +++++++----------------- src/BODY/fix_npt_body.cpp | 31 +++++++----------------- src/BODY/fix_nvt_body.cpp | 16 ++++-------- src/CORESHELL/compute_temp_cs.cpp | 20 ++++++--------- src/GRANULAR/pair_gran_hooke_history.cpp | 9 ++----- src/GRANULAR/pair_granular.cpp | 9 ++----- src/KIM/kim_init.cpp | 6 +---- src/MC/fix_bond_swap.cpp | 14 +++-------- src/PERI/pair_peri_eps.cpp | 10 ++------ src/PERI/pair_peri_lps.cpp | 10 ++------ src/PERI/pair_peri_pmb.cpp | 10 ++------ src/PERI/pair_peri_ves.cpp | 10 ++------ src/REPLICA/fix_neb.cpp | 16 ++++-------- src/REPLICA/hyper.cpp | 8 ++---- src/REPLICA/prd.cpp | 14 +++-------- src/fix_nph_sphere.cpp | 6 ++--- src/fix_npt_sphere.cpp | 6 ++--- src/fix_nvt_sphere.cpp | 1 + 21 files changed, 88 insertions(+), 219 deletions(-) diff --git a/src/ASPHERE/fix_nph_asphere.cpp b/src/ASPHERE/fix_nph_asphere.cpp index 70880701ca..0501ea1e8a 100644 --- a/src/ASPHERE/fix_nph_asphere.cpp +++ b/src/ASPHERE/fix_nph_asphere.cpp @@ -13,6 +13,7 @@ #include "fix_nph_asphere.h" #include +#include #include "modify.h" #include "error.h" @@ -35,35 +36,21 @@ FixNPHAsphere::FixNPHAsphere(LAMMPS *lmp, int narg, char **arg) : // compute group = all since pressure is always global (group all) // and thus its KE/temperature contribution should use group all - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp,tcmd.c_str()); - 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; + modify->add_compute(tcmd + " all temp/asphere"); tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all // pass id_temp as 4th arg to pressure constructor - n = strlen(id) + 7; - id_press = new char[n]; - strcpy(id_press,id); - strcat(id_press,"_press"); + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press,pcmd.c_str()); - 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; + modify->add_compute(pcmd + " all pressure " + std::string(id_temp)); pcomputeflag = 1; } diff --git a/src/ASPHERE/fix_npt_asphere.cpp b/src/ASPHERE/fix_npt_asphere.cpp index 26d4fff81d..f7f253f40b 100644 --- a/src/ASPHERE/fix_npt_asphere.cpp +++ b/src/ASPHERE/fix_npt_asphere.cpp @@ -13,6 +13,7 @@ #include "fix_npt_asphere.h" #include +#include #include "modify.h" #include "error.h" @@ -34,35 +35,21 @@ FixNPTAsphere::FixNPTAsphere(LAMMPS *lmp, int narg, char **arg) : // compute group = all since pressure is always global (group all) // and thus its KE/temperature contribution should use group all - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp,tcmd.c_str()); - 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; + modify->add_compute(tcmd + " all temp/asphere"); tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all // pass id_temp as 4th arg to pressure constructor - n = strlen(id) + 7; - id_press = new char[n]; - strcpy(id_press,id); - strcat(id_press,"_press"); + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press,pcmd.c_str()); - 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; + modify->add_compute(pcmd + " all pressure " + std::string(id_temp)); pcomputeflag = 1; } diff --git a/src/ASPHERE/fix_nvt_asphere.cpp b/src/ASPHERE/fix_nvt_asphere.cpp index 597fb03514..e0275d4acf 100644 --- a/src/ASPHERE/fix_nvt_asphere.cpp +++ b/src/ASPHERE/fix_nvt_asphere.cpp @@ -13,9 +13,11 @@ #include "fix_nvt_asphere.h" #include +#include #include "group.h" #include "modify.h" #include "error.h" +#include "fmt/format.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -33,17 +35,11 @@ FixNVTAsphere::FixNVTAsphere(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string cmd = id + std::string("_temp"); + id_temp = new char[cmd.size()+1]; + strcpy(id_temp,cmd.c_str()); - 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; + cmd += fmt::format(" {} temp/asphere",group->names[igroup]); + modify->add_compute(cmd); tcomputeflag = 1; } diff --git a/src/BODY/fix_nph_body.cpp b/src/BODY/fix_nph_body.cpp index a65c951c96..8dc1b568da 100644 --- a/src/BODY/fix_nph_body.cpp +++ b/src/BODY/fix_nph_body.cpp @@ -17,6 +17,7 @@ #include "fix_nph_body.h" #include +#include #include "modify.h" #include "error.h" @@ -38,35 +39,21 @@ FixNPHBody::FixNPHBody(LAMMPS *lmp, int narg, char **arg) : // compute group = all since pressure is always global (group all) // and thus its KE/temperature contribution should use group all - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp,tcmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp/body"; - - modify->add_compute(3,newarg); - delete [] newarg; + modify->add_compute(tcmd + " all temp/body"); tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all // pass id_temp as 4th arg to pressure constructor - n = strlen(id) + 7; - id_press = new char[n]; - strcpy(id_press,id); - strcat(id_press,"_press"); + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press,pcmd.c_str()); - 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; + modify->add_compute(pcmd + " all pressure " + std::string(id_temp)); pcomputeflag = 1; } diff --git a/src/BODY/fix_npt_body.cpp b/src/BODY/fix_npt_body.cpp index 7e8097486e..a4b6b2263c 100644 --- a/src/BODY/fix_npt_body.cpp +++ b/src/BODY/fix_npt_body.cpp @@ -17,6 +17,7 @@ #include "fix_npt_body.h" #include +#include #include "modify.h" #include "error.h" @@ -38,35 +39,21 @@ FixNPTBody::FixNPTBody(LAMMPS *lmp, int narg, char **arg) : // compute group = all since pressure is always global (group all) // and thus its KE/temperature contribution should use group all - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp,tcmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp/body"; - - modify->add_compute(3,newarg); - delete [] newarg; + modify->add_compute(tcmd + " all temp/body"); tcomputeflag = 1; // create a new compute pressure style // id = fix-ID + press, compute group = all // pass id_temp as 4th arg to pressure constructor - n = strlen(id) + 7; - id_press = new char[n]; - strcpy(id_press,id); - strcat(id_press,"_press"); + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press,pcmd.c_str()); - 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; + modify->add_compute(pcmd + " all pressure " + std::string(id_temp)); pcomputeflag = 1; } diff --git a/src/BODY/fix_nvt_body.cpp b/src/BODY/fix_nvt_body.cpp index efb05143a1..10da2d6f42 100644 --- a/src/BODY/fix_nvt_body.cpp +++ b/src/BODY/fix_nvt_body.cpp @@ -17,6 +17,7 @@ #include "fix_nvt_body.h" #include +#include #include "group.h" #include "modify.h" #include "error.h" @@ -37,17 +38,10 @@ FixNVTBody::FixNVTBody(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp,tcmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "temp/body"; - - modify->add_compute(3,newarg); - delete [] newarg; + modify->add_compute(tcmd + " all temp/body"); tcomputeflag = 1; } diff --git a/src/CORESHELL/compute_temp_cs.cpp b/src/CORESHELL/compute_temp_cs.cpp index 0dc03e47f2..84b6a0ceda 100644 --- a/src/CORESHELL/compute_temp_cs.cpp +++ b/src/CORESHELL/compute_temp_cs.cpp @@ -19,6 +19,7 @@ #include "compute_temp_cs.h" #include #include +#include #include "atom.h" #include "atom_vec.h" #include "domain.h" @@ -30,6 +31,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "fmt/format.h" using namespace LAMMPS_NS; @@ -66,21 +68,13 @@ ComputeTempCS::ComputeTempCS(LAMMPS *lmp, int narg, char **arg) : // create a new fix STORE style // id = compute-ID + COMPUTE_STORE, fix group = compute group - int n = strlen(id) + strlen("_COMPUTE_STORE") + 1; - id_fix = new char[n]; - strcpy(id_fix,id); - strcat(id_fix,"_COMPUTE_STORE"); + std::string fixcmd = id + std::string("_COMPUTE_STORE"); + id_fix = new char[fixcmd.size()+1]; + strcpy(id_fix,fix_cmd.c_str()); - char **newarg = new char*[6]; - newarg[0] = id_fix; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "STORE"; - newarg[3] = (char *) "peratom"; - newarg[4] = (char *) "0"; - newarg[5] = (char *) "1"; - modify->add_fix(6,newarg); + fixcmd += fmt::format(" {} STORE peratom 0 1", group->names[igroup]); + modify->add_fix(fixcmd); fix = (FixStore *) modify->fix[modify->nfix-1]; - delete [] newarg; // set fix store values = 0 for now // fill them in via setup() once Comm::borders() has been called diff --git a/src/GRANULAR/pair_gran_hooke_history.cpp b/src/GRANULAR/pair_gran_hooke_history.cpp index 29ca53d361..af46d813ca 100644 --- a/src/GRANULAR/pair_gran_hooke_history.cpp +++ b/src/GRANULAR/pair_gran_hooke_history.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "atom.h" #include "force.h" #include "update.h" @@ -65,13 +66,7 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp) // this is so final order of Modify:fix will conform to input script fix_history = NULL; - - char **fixarg = new char*[3]; - fixarg[0] = (char *) "NEIGH_HISTORY_HH_DUMMY"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "DUMMY"; - modify->add_fix(3,fixarg,1); - delete [] fixarg; + modify->add_fix("NEIGH_HISTORY_HH_DUMMY all DUMMY"); fix_dummy = (FixDummy *) modify->fix[modify->nfix-1]; } diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index fef8ded5f7..1784f4562c 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "atom.h" #include "force.h" #include "update.h" @@ -96,13 +97,7 @@ PairGranular::PairGranular(LAMMPS *lmp) : Pair(lmp) // this is so final order of Modify:fix will conform to input script fix_history = NULL; - - char **fixarg = new char*[3]; - fixarg[0] = (char *) "NEIGH_HISTORY_GRANULAR_DUMMY"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "DUMMY"; - modify->add_fix(3,fixarg,1); - delete [] fixarg; + modify->add_fix("NEIGH_HISTORY_GRANULAR_DUMMY all DUMMY"); fix_dummy = (FixDummy *) modify->fix[modify->nfix-1]; } diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 57112997ab..f90db79aa7 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -291,11 +291,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units, KIM int ifix = modify->find_fix("KIM_MODEL_STORE"); if (ifix >= 0) modify->delete_fix(ifix); - char *fixarg[3]; - fixarg[0] = (char *)"KIM_MODEL_STORE"; - fixarg[1] = (char *)"all"; - fixarg[2] = (char *)"STORE/KIM"; - modify->add_fix(3,fixarg); + modify->add_fix("KIM_MODEL_STORE all STORE/KIM"); ifix = modify->find_fix("KIM_MODEL_STORE"); FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix]; diff --git a/src/MC/fix_bond_swap.cpp b/src/MC/fix_bond_swap.cpp index 187c552416..8d3ff14f48 100644 --- a/src/MC/fix_bond_swap.cpp +++ b/src/MC/fix_bond_swap.cpp @@ -86,17 +86,11 @@ FixBondSwap::FixBondSwap(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp, compute group = fix group - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string cmd = id + std::string("_temp"); + id_temp = new char[cmd.size()+1]; + strcpy(id_temp,cmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + modify->add_compute(cmd + " all temp"); tflag = 1; // initialize atom list diff --git a/src/PERI/pair_peri_eps.cpp b/src/PERI/pair_peri_eps.cpp index ff79320fc3..cae33fe580 100644 --- a/src/PERI/pair_peri_eps.cpp +++ b/src/PERI/pair_peri_eps.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "atom.h" #include "domain.h" #include "lattice.h" @@ -515,14 +516,7 @@ void PairPeriEPS::init_style() // if first init, create Fix needed for storing fixed neighbors - if (ifix_peri == -1) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) "PERI_NEIGH"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "PERI_NEIGH"; - modify->add_fix(3,fixarg); - delete [] fixarg; - } + if (ifix_peri == -1) modify->add_fix("PERI_NEIGH all PERI_NEIGH"); // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created diff --git a/src/PERI/pair_peri_lps.cpp b/src/PERI/pair_peri_lps.cpp index 0ad6a7b0d2..65c6c30e19 100644 --- a/src/PERI/pair_peri_lps.cpp +++ b/src/PERI/pair_peri_lps.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "atom.h" #include "domain.h" #include "lattice.h" @@ -439,14 +440,7 @@ void PairPeriLPS::init_style() // if first init, create Fix needed for storing fixed neighbors - if (ifix_peri == -1) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) "PERI_NEIGH"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "PERI_NEIGH"; - modify->add_fix(3,fixarg); - delete [] fixarg; - } + if (ifix_peri == -1) modify->add_fix("PERI_NEIGH all PERI_NEIGH"); // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created diff --git a/src/PERI/pair_peri_pmb.cpp b/src/PERI/pair_peri_pmb.cpp index 88aca99efb..7c900b5c4e 100644 --- a/src/PERI/pair_peri_pmb.cpp +++ b/src/PERI/pair_peri_pmb.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "atom.h" #include "domain.h" #include "lattice.h" @@ -369,14 +370,7 @@ void PairPeriPMB::init_style() // if first init, create Fix needed for storing fixed neighbors - if (ifix_peri == -1) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) "PERI_NEIGH"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "PERI_NEIGH"; - modify->add_fix(3,fixarg); - delete [] fixarg; - } + if (ifix_peri == -1) modify->add_fix("PERI_NEIGH all PERI_NEIGH"); // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created diff --git a/src/PERI/pair_peri_ves.cpp b/src/PERI/pair_peri_ves.cpp index 1d9f3819ff..ed9babf5ed 100644 --- a/src/PERI/pair_peri_ves.cpp +++ b/src/PERI/pair_peri_ves.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "atom.h" #include "domain.h" #include "lattice.h" @@ -495,14 +496,7 @@ void PairPeriVES::init_style() // if first init, create Fix needed for storing fixed neighbors - if (ifix_peri == -1) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) "PERI_NEIGH"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "PERI_NEIGH"; - modify->add_fix(3,fixarg); - delete [] fixarg; - } + if (ifix_peri == -1) modify->add_fix("PERI_NEIGH all PERI_NEIGH"); // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created diff --git a/src/REPLICA/fix_neb.cpp b/src/REPLICA/fix_neb.cpp index 7b377ae9ec..b3af01fda4 100644 --- a/src/REPLICA/fix_neb.cpp +++ b/src/REPLICA/fix_neb.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "universe.h" #include "update.h" #include "atom.h" @@ -148,17 +149,10 @@ FixNEB::FixNEB(LAMMPS *lmp, int narg, char **arg) : // create a new compute pe style // id = fix-ID + pe, compute group = all - int n = strlen(id) + 4; - id_pe = new char[n]; - strcpy(id_pe,id); - strcat(id_pe,"_pe"); - - char **newarg = new char*[3]; - newarg[0] = id_pe; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pe"; - modify->add_compute(3,newarg); - delete [] newarg; + std::string cmd = id + std::string("_pe"); + id_pe = new char[cmd.size()+1]; + strcpy(id_pe,cmd.c_str()); + modify->add_compute(cmd + " all pe"); // initialize local storage diff --git a/src/REPLICA/hyper.cpp b/src/REPLICA/hyper.cpp index 54b865108e..aab4cd9d0f 100644 --- a/src/REPLICA/hyper.cpp +++ b/src/REPLICA/hyper.cpp @@ -14,6 +14,7 @@ #include "hyper.h" #include #include +#include #include "update.h" #include "domain.h" #include "region.h" @@ -100,13 +101,8 @@ void Hyper::command(int narg, char **arg) // create FixEventHyper class to store event and pre-quench states - char **args = new char*[3]; - args[0] = (char *) "hyper_event"; - args[1] = (char *) "all"; - args[2] = (char *) "EVENT/HYPER"; - modify->add_fix(3,args); + modify->add_fix("hyper_event all EVENT/HYPER"); fix_event = (FixEventHyper *) modify->fix[modify->nfix-1]; - delete [] args; // create Finish for timing output diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 63e569d0c2..14f261fc15 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -18,6 +18,7 @@ #include "prd.h" #include #include +#include #include "universe.h" #include "update.h" #include "atom.h" @@ -146,11 +147,7 @@ void PRD::command(int narg, char **arg) // create ComputeTemp class to monitor temperature - char **args = new char*[3]; - args[0] = (char *) "prd_temp"; - args[1] = (char *) "all"; - args[2] = (char *) "temp"; - modify->add_compute(3,args); + modify->add_compute("prd_temp all temp"); temperature = modify->compute[modify->ncompute-1]; // create Velocity class for velocity creation in dephasing @@ -160,6 +157,7 @@ void PRD::command(int narg, char **arg) velocity = new Velocity(lmp); velocity->init_external("all"); + char *args[2]; args[0] = (char *) "temp"; args[1] = (char *) "prd_temp"; velocity->options(2,args); @@ -172,10 +170,7 @@ void PRD::command(int narg, char **arg) // create FixEventPRD class to store event and pre-quench states - args[0] = (char *) "prd_event"; - args[1] = (char *) "all"; - args[2] = (char *) "EVENT/PRD"; - modify->add_fix(3,args); + modify->add_fix("prd_event all EVENT/PRD"); fix_event = (FixEventPRD *) modify->fix[modify->nfix-1]; // create Finish for timing output @@ -184,7 +179,6 @@ void PRD::command(int narg, char **arg) // string clean-up - delete [] args; delete [] loop_setting; delete [] dist_setting; diff --git a/src/fix_nph_sphere.cpp b/src/fix_nph_sphere.cpp index 25cff4a645..cf2298f5f8 100644 --- a/src/fix_nph_sphere.cpp +++ b/src/fix_nph_sphere.cpp @@ -39,8 +39,7 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) : id_temp = new char[tcmd.size()+1]; strcpy(id_temp,tcmd.c_str()); - tcmd += " all temp/sphere"; - modify->add_compute(tcmd); + modify->add_compute(tcmd + " all temp/sphere"); tcomputeflag = 1; // create a new compute pressure style @@ -51,7 +50,6 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) : id_press = new char[pcmd.size()+1]; strcpy(id_press,pcmd.c_str()); - pcmd += " all pressure " + std::string(id_temp); - modify->add_compute(pcmd); + modify->add_compute(pcmd + " all pressure " + std::string(id_temp)); pcomputeflag = 1; } diff --git a/src/fix_npt_sphere.cpp b/src/fix_npt_sphere.cpp index d1ff82baba..e38d88fadd 100644 --- a/src/fix_npt_sphere.cpp +++ b/src/fix_npt_sphere.cpp @@ -39,8 +39,7 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) : id_temp = new char[tcmd.size()+1]; strcpy(id_temp,tcmd.c_str()); - tcmd += " all temp/sphere"; - modify->add_compute(tcmd); + modify->add_compute(tcmd + " all temp/sphere"); tcomputeflag = 1; // create a new compute pressure style @@ -51,7 +50,6 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) : id_press = new char[pcmd.size()+1]; strcpy(id_press,pcmd.c_str()); - pcmd += " all pressure " + std::string(id_temp); - modify->add_compute(pcmd); + modify->add_compute(pcmd + " all pressure " + std::string(id_temp)); pcomputeflag = 1; } diff --git a/src/fix_nvt_sphere.cpp b/src/fix_nvt_sphere.cpp index 8773721850..40c3ba19e3 100644 --- a/src/fix_nvt_sphere.cpp +++ b/src/fix_nvt_sphere.cpp @@ -13,6 +13,7 @@ #include "fix_nvt_sphere.h" #include +#include #include "group.h" #include "modify.h" #include "error.h"