From d2b8e2fd2a8237f1d759bced9a5a8b554194bf53 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 21 Jul 2015 23:48:07 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13668 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/USER-DIFFRACTION/fix_saed_vtk.cpp | 54 +++++++++--------- src/USER-DIFFRACTION/fix_saed_vtk.h | 12 ++-- src/fix_ave_histo.cpp | 82 ++++++++++++++------------- 3 files changed, 76 insertions(+), 72 deletions(-) diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.cpp b/src/USER-DIFFRACTION/fix_saed_vtk.cpp index 67641e8e95..cfdaf6a5d0 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.cpp +++ b/src/USER-DIFFRACTION/fix_saed_vtk.cpp @@ -18,7 +18,7 @@ #include "stdlib.h" #include "string.h" -#include "fix_ave_time_saed.h" +#include "fix_saed_vtk.h" #include "update.h" #include "modify.h" #include "compute.h" @@ -47,10 +47,10 @@ enum{FIRST,MULTI}; /* ---------------------------------------------------------------------- */ -FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : +FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg < 7) error->all(FLERR,"Illegal fix ave/time/saed command"); + if (narg < 7) error->all(FLERR,"Illegal fix saed/vtk command"); MPI_Comm_rank(world,&me); @@ -68,7 +68,7 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : iarg++; } else break; } - if (nvalues != 1) error->all(FLERR,"Illegal fix ave/time/saed command"); + if (nvalues != 1) error->all(FLERR,"Illegal fix saed/vtk command"); options(narg,arg); @@ -87,7 +87,7 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : strcpy(suffix,&arg[iarg][2]); char *ptr = strchr(suffix,'['); - if (ptr) error->all(FLERR,"Illegal fix ave/time/saed command"); + if (ptr) error->all(FLERR,"Illegal fix saed/vtk command"); n = strlen(suffix) + 1; ids = new char[n]; @@ -96,14 +96,14 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : int icompute = modify->find_compute(ids); if (icompute < 0) - error->all(FLERR,"Compute ID for fix ave/time/saed does not exist"); + error->all(FLERR,"Compute ID for fix saed/vtk does not exist"); Compute *compute = modify->compute[icompute]; // Check that specified compute is for SAED compute_saed = (ComputeSAED*) modify->compute[icompute]; if (strcmp(compute_saed->style,"saed") != 0) - error->all(FLERR,"Fix ave/time/saed has invalid compute assigned"); + error->all(FLERR,"Fix saed/vtk has invalid compute assigned"); // Gather varialbes from specified compute_saed double *saed_var = compute_saed->saed_var; @@ -122,9 +122,9 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : // Standard error check for fix/ave/time if (compute->vector_flag == 0) - error->all(FLERR,"Fix ave/time/saed compute does not calculate a vector"); + error->all(FLERR,"Fix saed/vtk compute does not calculate a vector"); if (compute->extvector != 0) - error->all(FLERR,"Illegal fix ave/time/saed command"); + error->all(FLERR,"Illegal fix saed/vtk command"); int length = modify->compute[icompute]->size_vector; @@ -138,11 +138,11 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : // for fix inputs, check that fix frequency is acceptable if (nevery <= 0 || nrepeat <= 0 || nfreq <= 0) - error->all(FLERR,"Illegal fix ave/time/saed command"); + error->all(FLERR,"Illegal fix saed/vtk command"); if (nfreq % nevery || (nrepeat-1)*nevery >= nfreq) - error->all(FLERR,"Illegal fix ave/time/saed command"); + error->all(FLERR,"Illegal fix saed/vtk command"); if (ave != RUNNING && overwrite) - error->all(FLERR,"Illegal fix ave/time/saed command"); + error->all(FLERR,"Illegal fix saed/vtk command"); // allocate memory for averaging @@ -150,10 +150,10 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : vector_list = NULL; if (ave == WINDOW) - memory->create(vector_list,nwindow,nvalues,"ave/time/saed:vector_list"); + memory->create(vector_list,nwindow,nvalues,"saed/vtk:vector_list"); - memory->create(vector,nrows,"ave/time/saed:vector"); - memory->create(vector_total,nrows,"ave/time/saed:vector_total"); + memory->create(vector,nrows,"saed/vtk:vector"); + memory->create(vector_total,nrows,"saed/vtk:vector_total"); extlist = NULL; @@ -290,7 +290,7 @@ FixAveTimeSAED::FixAveTimeSAED(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixAveTimeSAED::~FixAveTimeSAED() +FixSAEDVTK::~FixSAEDVTK() { delete [] extlist; memory->destroy(vector); @@ -300,7 +300,7 @@ FixAveTimeSAED::~FixAveTimeSAED() /* ---------------------------------------------------------------------- */ -int FixAveTimeSAED::setmask() +int FixSAEDVTK::setmask() { int mask = 0; mask |= END_OF_STEP; @@ -309,7 +309,7 @@ int FixAveTimeSAED::setmask() /* ---------------------------------------------------------------------- */ -void FixAveTimeSAED::init() +void FixSAEDVTK::init() { // set current indices for all computes,fixes,variables @@ -331,14 +331,14 @@ void FixAveTimeSAED::init() only does something if nvalid = current timestep ------------------------------------------------------------------------- */ -void FixAveTimeSAED::setup(int vflag) +void FixSAEDVTK::setup(int vflag) { end_of_step(); } /* ---------------------------------------------------------------------- */ -void FixAveTimeSAED::end_of_step() +void FixSAEDVTK::end_of_step() { // skip if not step which requires doing something bigint ntimestep = update->ntimestep; @@ -348,12 +348,12 @@ void FixAveTimeSAED::end_of_step() /* ---------------------------------------------------------------------- */ -void FixAveTimeSAED::invoke_vector(bigint ntimestep) +void FixSAEDVTK::invoke_vector(bigint ntimestep) { // zero if first step int icompute = modify->find_compute(ids); if (icompute < 0) - error->all(FLERR,"Compute ID for fix ave/time/saed does not exist"); + error->all(FLERR,"Compute ID for fix saed/vtk does not exist"); if (irepeat == 0) for (int i = 0; i < nrows; i++) @@ -435,7 +435,7 @@ void FixAveTimeSAED::invoke_vector(bigint ntimestep) if (fp == NULL) { char str[128]; - sprintf(str,"Cannot open fix ave/time/saed file %s",nName); + sprintf(str,"Cannot open fix saed/vtk file %s",nName); error->one(FLERR,str); } } @@ -523,7 +523,7 @@ void FixAveTimeSAED::invoke_vector(bigint ntimestep) return Ith vector value ------------------------------------------------------------------------- */ -double FixAveTimeSAED::compute_vector(int i) +double FixSAEDVTK::compute_vector(int i) { if (norm) { return vector_total[i]/norm; @@ -535,7 +535,7 @@ double FixAveTimeSAED::compute_vector(int i) parse optional args ------------------------------------------------------------------------- */ -void FixAveTimeSAED::options(int narg, char **arg) +void FixSAEDVTK::options(int narg, char **arg) { // option defaults @@ -598,7 +598,7 @@ void FixAveTimeSAED::options(int narg, char **arg) startstep is lower bound on nfreq multiple ------------------------------------------------------------------------- */ -bigint FixAveTimeSAED::nextvalid() +bigint FixSAEDVTK::nextvalid() { bigint nvalid = (update->ntimestep/nfreq)*nfreq + nfreq; while (nvalid < startstep) nvalid += nfreq; @@ -612,7 +612,7 @@ bigint FixAveTimeSAED::nextvalid() /* ---------------------------------------------------------------------- */ -void FixAveTimeSAED::reset_timestep(bigint ntimestep) +void FixSAEDVTK::reset_timestep(bigint ntimestep) { if (ntimestep > nvalid) error->all(FLERR,"Fix saed/vtk missed timestep"); } diff --git a/src/USER-DIFFRACTION/fix_saed_vtk.h b/src/USER-DIFFRACTION/fix_saed_vtk.h index c626e5a262..a421112688 100644 --- a/src/USER-DIFFRACTION/fix_saed_vtk.h +++ b/src/USER-DIFFRACTION/fix_saed_vtk.h @@ -13,22 +13,22 @@ #ifdef FIX_CLASS -FixStyle(ave/time/saed,FixAveTimeSAED) +FixStyle(saed/vtk,FixSAEDVTK) #else -#ifndef LMP_FIX_AVE_TIME_SAED_H -#define LMP_FIX_AVE_TIME_SAED_H +#ifndef LMP_FIX_SAED_VTK_H +#define LMP_FIX_SAED_VTK_H #include "stdio.h" #include "fix.h" namespace LAMMPS_NS { -class FixAveTimeSAED : public Fix { +class FixSAEDVTK : public Fix { public: - FixAveTimeSAED(class LAMMPS *, int, char **); - ~FixAveTimeSAED(); + FixSAEDVTK(class LAMMPS *, int, char **); + ~FixSAEDVTK(); int setmask(); void init(); void setup(int); diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 1d2ee7e32e..6296a85ae8 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -26,9 +26,6 @@ #include "error.h" #include "force.h" -#include -using namespace std; - using namespace LAMMPS_NS; using namespace FixConst; @@ -46,6 +43,7 @@ enum{SINGLE,VALUE}; #define INVOKED_LOCAL 16 #define BIG 1.0e20 + /* ---------------------------------------------------------------------- */ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : @@ -193,7 +191,8 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : if (mode == VECTOR && which[nvalues] == COMPUTE && argindex[nvalues] == 0) { - if (weights = VALUE) error->all(FLERR,"Illegal fix ave/histo command"); + if (weights == VALUE) + error->all(FLERR,"Illegal fix ave/histo command"); int icompute = modify->find_compute(ids[nvalues]); if (icompute < 0) error->all(FLERR,"Compute ID for fix ave/histo does not exist"); @@ -214,7 +213,8 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : } else if (mode == VECTOR && which[nvalues] == FIX && argindex[nvalues] == 0) { - if (weights = VALUE) error->all(FLERR,"Illegal fix ave/histo command"); + if (weights == VALUE) + error->all(FLERR,"Illegal fix ave/histo command"); int ifix = modify->find_fix(ids[nvalues]); if (ifix < 0) error->all(FLERR,"Fix ID for fix ave/histo does not exist"); @@ -439,41 +439,45 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : } // weighted histogram number of rows must match weights - int Size[2]; - if ( weights == VALUE ) { + + int size[2]; + if (weights == VALUE) { + // NOTE: shouldn't this be one? if (nvalues != 2) error->all(FLERR,"Illegal fix ave/histo command"); for (int i = 0; i < nvalues; i++) { - if (which[i] == X || which[i] == V || which[i] == F) { - Size[i] = atom->nmax; - } else if (which[i] == COMPUTE && kind == GLOBAL && mode == SCALAR) { - int icompute = modify->find_compute(ids[i]); - Size[i] = modify->compute[icompute]->size_vector; - } else if (which[i] == COMPUTE && kind == GLOBAL && mode == VECTOR) { - int icompute = modify->find_compute(ids[i]); - Size[i] = modify->compute[icompute]->size_array_rows; - } else if (which[i] == COMPUTE && kind == PERATOM) { - int icompute = modify->find_compute(ids[i]); - Size[i] = atom->nmax; - } else if (which[i] == COMPUTE && kind == LOCAL) { - int icompute = modify->find_compute(ids[i]); - Size[i] = modify->compute[icompute]->size_local_rows; - } else if (which[i] == FIX && kind == GLOBAL && mode == SCALAR) { - int ifix = modify->find_fix(ids[i]); - Size[i] = modify->fix[ifix]->size_vector; - } else if (which[i] == FIX && kind == GLOBAL && mode == VECTOR) { - int ifix = modify->find_fix(ids[i]); - Size[i]= modify->fix[ifix]->size_array_rows; - } else if (which[i] == FIX && kind == PERATOM) { - int ifix = modify->find_fix(ids[i]); - Size[i] = atom->nmax; - } else if (which[i] == FIX && kind == LOCAL) { - int ifix = modify->find_fix(ids[i]); - Size[i] = modify->fix[ifix]->size_local_rows; - } else if (which[i] == VARIABLE && kind == PERATOM) { - Size[i] = atom->nmax; - } - } - if (Size[0] != Size[1]) error->all(FLERR,"Illegal fix ave/histo command"); + if (which[i] == X || which[i] == V || which[i] == F) { + size[i] = atom->nmax; + } else if (which[i] == COMPUTE && kind == GLOBAL && mode == SCALAR) { + int icompute = modify->find_compute(ids[i]); + size[i] = modify->compute[icompute]->size_vector; + } else if (which[i] == COMPUTE && kind == GLOBAL && mode == VECTOR) { + int icompute = modify->find_compute(ids[i]); + size[i] = modify->compute[icompute]->size_array_rows; + } else if (which[i] == COMPUTE && kind == PERATOM) { + int icompute = modify->find_compute(ids[i]); + size[i] = atom->nmax; + } else if (which[i] == COMPUTE && kind == LOCAL) { + int icompute = modify->find_compute(ids[i]); + size[i] = modify->compute[icompute]->size_local_rows; + } else if (which[i] == FIX && kind == GLOBAL && mode == SCALAR) { + int ifix = modify->find_fix(ids[i]); + size[i] = modify->fix[ifix]->size_vector; + } else if (which[i] == FIX && kind == GLOBAL && mode == VECTOR) { + int ifix = modify->find_fix(ids[i]); + size[i]= modify->fix[ifix]->size_array_rows; + } else if (which[i] == FIX && kind == PERATOM) { + int ifix = modify->find_fix(ids[i]); + size[i] = atom->nmax; + } else if (which[i] == FIX && kind == LOCAL) { + int ifix = modify->find_fix(ids[i]); + size[i] = modify->fix[ifix]->size_local_rows; + } else if (which[i] == VARIABLE && kind == PERATOM) { + size[i] = atom->nmax; + } + } + if (size[0] != size[1]) + error->all(FLERR,"Fix ave/histo value and weight vector " + "lengths do not match"); } // print file comment lines @@ -1395,7 +1399,7 @@ void FixAveHisto::options(int narg, char **arg) (strncmp(arg[iarg],"f_",2) == 0) || (strncmp(arg[iarg],"v_",2) == 0)) { iarg++; - } + } error->all(FLERR,"Illegal fix ave/histo command"); nvalues = 2; weights = VALUE; } else error->all(FLERR,"Illegal fix ave/histo command");