final set of styles in the src folder to be simplified

This commit is contained in:
Axel Kohlmeyer
2020-06-28 23:25:37 -04:00
parent f94eeece72
commit a1c0b78a3a
3 changed files with 21 additions and 41 deletions

View File

@ -14,6 +14,7 @@
#include "compute_msd.h" #include "compute_msd.h"
#include <mpi.h> #include <mpi.h>
#include <cstring> #include <cstring>
#include <string>
#include "atom.h" #include "atom.h"
#include "update.h" #include "update.h"
#include "group.h" #include "group.h"
@ -21,6 +22,7 @@
#include "modify.h" #include "modify.h"
#include "fix_store.h" #include "fix_store.h"
#include "error.h" #include "error.h"
#include "fmt/format.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -63,21 +65,13 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
// create a new fix STORE style for reference positions // create a new fix STORE style for reference positions
// id = compute-ID + COMPUTE_STORE, fix group = compute group // id = compute-ID + COMPUTE_STORE, fix group = compute group
int n = strlen(id) + strlen("_COMPUTE_STORE") + 1; std::string fixcmd = id + std::string("_COMPUTE_STORE");
id_fix = new char[n]; id_fix = new char[fixcmd.size()+1];
strcpy(id_fix,id); strcpy(id_fix,fixcmd.c_str());
strcat(id_fix,"_COMPUTE_STORE");
char **newarg = new char*[6]; fixcmd += fmt::format(" {} STORE peratom 1 3",group->names[igroup]);
newarg[0] = id_fix; modify->add_fix(fixcmd);
newarg[1] = group->names[igroup];
newarg[2] = (char *) "STORE";
newarg[3] = (char *) "peratom";
newarg[4] = (char *) "1";
newarg[5] = (char *) "3";
modify->add_fix(6,newarg);
fix = (FixStore *) modify->fix[modify->nfix-1]; fix = (FixStore *) modify->fix[modify->nfix-1];
delete [] newarg;
// calculate xu,yu,zu for fix store array // calculate xu,yu,zu for fix store array
// skip if reset from restart file // skip if reset from restart file

View File

@ -14,6 +14,7 @@
#include "compute_msd_chunk.h" #include "compute_msd_chunk.h"
#include <mpi.h> #include <mpi.h>
#include <cstring> #include <cstring>
#include <string>
#include "atom.h" #include "atom.h"
#include "group.h" #include "group.h"
#include "update.h" #include "update.h"
@ -23,6 +24,7 @@
#include "fix_store.h" #include "fix_store.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "fmt/format.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -56,21 +58,13 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) :
// potentially re-populate the fix array (and change it to correct size) // potentially re-populate the fix array (and change it to correct size)
// otherwise size reset and init will be done in setup() // otherwise size reset and init will be done in setup()
n = strlen(id) + strlen("_COMPUTE_STORE") + 1; std::string fixcmd = id + std::string("_COMPUTE_STORE");
id_fix = new char[n]; id_fix = new char[fixcmd.size()+1];
strcpy(id_fix,id); strcpy(id_fix,fixcmd.c_str());
strcat(id_fix,"_COMPUTE_STORE");
char **newarg = new char*[6]; fixcmd += fmt::format(" {} STORE global 1 1",group->names[igroup]);
newarg[0] = id_fix; modify->add_fix(fixcmd);
newarg[1] = group->names[igroup];
newarg[2] = (char *) "STORE";
newarg[3] = (char *) "global";
newarg[4] = (char *) "1";
newarg[5] = (char *) "1";
modify->add_fix(6,newarg);
fix = (FixStore *) modify->fix[modify->nfix-1]; fix = (FixStore *) modify->fix[modify->nfix-1];
delete [] newarg;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -14,6 +14,7 @@
#include "dump_custom.h" #include "dump_custom.h"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <string>
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "domain.h" #include "domain.h"
@ -28,6 +29,7 @@
#include "error.h" #include "error.h"
#include "update.h" #include "update.h"
#include "variable.h" #include "variable.h"
#include "fmt/format.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -1981,22 +1983,12 @@ int DumpCustom::modify_param(int narg, char **arg)
"dump:thresh_fixID"); "dump:thresh_fixID");
memory->grow(thresh_first,(nthreshlast+1),"dump:thresh_first"); memory->grow(thresh_first,(nthreshlast+1),"dump:thresh_first");
int n = strlen(id) + strlen("_DUMP_STORE") + 8; std::string threshid = fmt::format("{}{}_DUMP_STORE",id,nthreshlast);
thresh_fixID[nthreshlast] = new char[n]; thresh_fixID[nthreshlast] = new char[threshid.size()+1];
strcpy(thresh_fixID[nthreshlast],id); strcpy(thresh_fixID[nthreshlast],threshid.c_str());
sprintf(&thresh_fixID[nthreshlast][strlen(id)],"%d",nthreshlast); modify->add_fix(fmt::format("{} {} STORE peratom 1 1",threshid,
strcat(thresh_fixID[nthreshlast],"_DUMP_STORE"); group->names[igroup]));
char **newarg = new char*[6];
newarg[0] = thresh_fixID[nthreshlast];
newarg[1] = group->names[igroup];
newarg[2] = (char *) "STORE";
newarg[3] = (char *) "peratom";
newarg[4] = (char *) "1";
newarg[5] = (char *) "1";
modify->add_fix(6,newarg);
thresh_fix[nthreshlast] = (FixStore *) modify->fix[modify->nfix-1]; thresh_fix[nthreshlast] = (FixStore *) modify->fix[modify->nfix-1];
delete [] newarg;
thresh_last[nthreshlast] = nthreshlast; thresh_last[nthreshlast] = nthreshlast;
thresh_first[nthreshlast] = 1; thresh_first[nthreshlast] = 1;