apply simplifications to standard packages

This commit is contained in:
Axel Kohlmeyer
2020-06-29 00:06:28 -04:00
parent a1c0b78a3a
commit 3a0ae83c96
21 changed files with 88 additions and 219 deletions

View File

@ -13,6 +13,7 @@
#include "fix_nph_asphere.h"
#include <cstring>
#include <string>
#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;
}

View File

@ -13,6 +13,7 @@
#include "fix_npt_asphere.h"
#include <cstring>
#include <string>
#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;
}

View File

@ -13,9 +13,11 @@
#include "fix_nvt_asphere.h"
#include <cstring>
#include <string>
#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;
}

View File

@ -17,6 +17,7 @@
#include "fix_nph_body.h"
#include <cstring>
#include <string>
#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;
}

View File

@ -17,6 +17,7 @@
#include "fix_npt_body.h"
#include <cstring>
#include <string>
#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;
}

View File

@ -17,6 +17,7 @@
#include "fix_nvt_body.h"
#include <cstring>
#include <string>
#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;
}

View File

@ -19,6 +19,7 @@
#include "compute_temp_cs.h"
#include <mpi.h>
#include <cstring>
#include <string>
#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

View File

@ -19,6 +19,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#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];
}

View File

@ -21,6 +21,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#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];
}

View File

@ -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];

View File

@ -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

View File

@ -19,6 +19,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#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

View File

@ -19,6 +19,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#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

View File

@ -20,6 +20,7 @@
#include <cmath>
#include <cfloat>
#include <cstring>
#include <string>
#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

View File

@ -19,6 +19,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#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

View File

@ -20,6 +20,7 @@
#include <mpi.h>
#include <cmath>
#include <cstring>
#include <string>
#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

View File

@ -14,6 +14,7 @@
#include "hyper.h"
#include <mpi.h>
#include <cstring>
#include <string>
#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

View File

@ -18,6 +18,7 @@
#include "prd.h"
#include <mpi.h>
#include <cstring>
#include <string>
#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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -13,6 +13,7 @@
#include "fix_nvt_sphere.h"
#include <cstring>
#include <string>
#include "group.h"
#include "modify.h"
#include "error.h"