convert a few more styles to use ArgInfo
This commit is contained in:
@ -22,26 +22,27 @@
|
||||
Richard Berger (JKU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <cstring>
|
||||
#include "dump_vtk.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "compute.h"
|
||||
#include "domain.h"
|
||||
#include "region.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "force.h"
|
||||
#include "group.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "compute.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "modify.h"
|
||||
#include "region.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <vtkVersion.h>
|
||||
|
||||
#ifndef VTK_MAJOR_VERSION
|
||||
@ -1731,146 +1732,123 @@ int DumpVTK::parse_fields(int narg, char **arg)
|
||||
vtype[TQZ] = Dump::DOUBLE;
|
||||
name[TQZ] = arg[iarg];
|
||||
|
||||
// compute value = c_ID
|
||||
// if no trailing [], then arg is set to 0, else arg is int between []
|
||||
} else {
|
||||
|
||||
} else if (strncmp(arg[iarg],"c_",2) == 0) {
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_compute;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
int n,tmp;
|
||||
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||
argindex[ATTRIBUTES+i] = argi.get_index1();
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
switch (argi.get_type()) {
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
error->all(FLERR,"Invalid attribute in dump vtk command");
|
||||
argindex[ATTRIBUTES+i] = atoi(ptr+1);
|
||||
*ptr = '\0';
|
||||
} else argindex[ATTRIBUTES+i] = 0;
|
||||
case ArgInfo::UNKNOWN:
|
||||
error->all(FLERR,"Invalid attribute in dump vtk command");
|
||||
break;
|
||||
|
||||
n = modify->find_compute(suffix);
|
||||
if (n < 0) error->all(FLERR,"Could not find dump vtk compute ID");
|
||||
if (modify->compute[n]->peratom_flag == 0)
|
||||
error->all(FLERR,"Dump vtk compute does not compute per-atom info");
|
||||
if (argindex[ATTRIBUTES+i] == 0 && modify->compute[n]->size_peratom_cols > 0)
|
||||
error->all(FLERR,
|
||||
"Dump vtk compute does not calculate per-atom vector");
|
||||
if (argindex[ATTRIBUTES+i] > 0 && modify->compute[n]->size_peratom_cols == 0)
|
||||
error->all(FLERR,\
|
||||
"Dump vtk compute does not calculate per-atom array");
|
||||
if (argindex[ATTRIBUTES+i] > 0 &&
|
||||
argindex[ATTRIBUTES+i] > modify->compute[n]->size_peratom_cols)
|
||||
error->all(FLERR,"Dump vtk compute vector is accessed out-of-range");
|
||||
// compute value = c_ID
|
||||
// if no trailing [], then arg is set to 0, else arg is int between []
|
||||
|
||||
field2index[ATTRIBUTES+i] = add_compute(suffix);
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
delete [] suffix;
|
||||
case ArgInfo::COMPUTE:
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_compute;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
|
||||
// fix value = f_ID
|
||||
// if no trailing [], then arg is set to 0, else arg is between []
|
||||
n = modify->find_compute(argi.get_name());
|
||||
if (n < 0) error->all(FLERR,"Could not find dump vtk compute ID");
|
||||
if (modify->compute[n]->peratom_flag == 0)
|
||||
error->all(FLERR,"Dump vtk compute does not compute per-atom info");
|
||||
if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
|
||||
error->all(FLERR,
|
||||
"Dump vtk compute does not calculate per-atom vector");
|
||||
if (argi.get_dim() > 0 && modify->compute[n]->size_peratom_cols == 0)
|
||||
error->all(FLERR,
|
||||
"Dump vtk compute does not calculate per-atom array");
|
||||
if (argi.get_dim() > 0 &&
|
||||
argi.get_index1() > modify->compute[n]->size_peratom_cols)
|
||||
error->all(FLERR,"Dump vtk compute vector is accessed out-of-range");
|
||||
|
||||
} else if (strncmp(arg[iarg],"f_",2) == 0) {
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_fix;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
field2index[ATTRIBUTES+i] = add_compute(argi.get_name());
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
break;
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
// fix value = f_ID
|
||||
// if no trailing [], then arg is set to 0, else arg is between []
|
||||
|
||||
char *ptr = strchr(suffix,'[');
|
||||
if (ptr) {
|
||||
if (suffix[strlen(suffix)-1] != ']')
|
||||
error->all(FLERR,"Invalid attribute in dump vtk command");
|
||||
argindex[ATTRIBUTES+i] = atoi(ptr+1);
|
||||
*ptr = '\0';
|
||||
} else argindex[ATTRIBUTES+i] = 0;
|
||||
case ArgInfo::FIX:
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_fix;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
|
||||
n = modify->find_fix(suffix);
|
||||
if (n < 0) error->all(FLERR,"Could not find dump vtk fix ID");
|
||||
if (modify->fix[n]->peratom_flag == 0)
|
||||
error->all(FLERR,"Dump vtk fix does not compute per-atom info");
|
||||
if (argindex[ATTRIBUTES+i] == 0 && modify->fix[n]->size_peratom_cols > 0)
|
||||
error->all(FLERR,"Dump vtk fix does not compute per-atom vector");
|
||||
if (argindex[ATTRIBUTES+i] > 0 && modify->fix[n]->size_peratom_cols == 0)
|
||||
error->all(FLERR,"Dump vtk fix does not compute per-atom array");
|
||||
if (argindex[ATTRIBUTES+i] > 0 &&
|
||||
argindex[ATTRIBUTES+i] > modify->fix[n]->size_peratom_cols)
|
||||
error->all(FLERR,"Dump vtk fix vector is accessed out-of-range");
|
||||
n = modify->find_fix(argi.get_name());
|
||||
if (n < 0) error->all(FLERR,"Could not find dump vtk fix ID");
|
||||
if (modify->fix[n]->peratom_flag == 0)
|
||||
error->all(FLERR,"Dump vtk fix does not compute per-atom info");
|
||||
if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
|
||||
error->all(FLERR,"Dump vtk fix does not compute per-atom vector");
|
||||
if (argi.get_dim() > 0 && modify->fix[n]->size_peratom_cols == 0)
|
||||
error->all(FLERR,"Dump vtk fix does not compute per-atom array");
|
||||
if (argi.get_dim() > 0 &&
|
||||
argi.get_index1() > modify->fix[n]->size_peratom_cols)
|
||||
error->all(FLERR,"Dump vtk fix vector is accessed out-of-range");
|
||||
|
||||
field2index[ATTRIBUTES+i] = add_fix(suffix);
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
delete [] suffix;
|
||||
field2index[ATTRIBUTES+i] = add_fix(argi.get_name());
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
break;
|
||||
|
||||
// variable value = v_name
|
||||
// variable value = v_name
|
||||
|
||||
} else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_variable;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
case ArgInfo::VARIABLE:
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_variable;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
n = input->variable->find(argi.get_name());
|
||||
if (n < 0) error->all(FLERR,"Could not find dump vtk variable name");
|
||||
if (input->variable->atomstyle(n) == 0)
|
||||
error->all(FLERR,"Dump vtk variable is not atom-style variable");
|
||||
|
||||
argindex[ATTRIBUTES+i] = 0;
|
||||
field2index[ATTRIBUTES+i] = add_variable(argi.get_name());
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
break;
|
||||
|
||||
n = input->variable->find(suffix);
|
||||
if (n < 0) error->all(FLERR,"Could not find dump vtk variable name");
|
||||
if (input->variable->atomstyle(n) == 0)
|
||||
error->all(FLERR,"Dump vtk variable is not atom-style variable");
|
||||
// custom per-atom floating point value = d_ID
|
||||
|
||||
field2index[ATTRIBUTES+i] = add_variable(suffix);
|
||||
name[ATTRIBUTES+i] = suffix;
|
||||
delete [] suffix;
|
||||
case ArgInfo::DNAME:
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
|
||||
// custom per-atom floating point value = d_ID
|
||||
tmp = -1;
|
||||
n = atom->find_custom(argi.get_name(),tmp);
|
||||
if (n < 0)
|
||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
||||
|
||||
} else if (strncmp(arg[iarg],"d_",2) == 0) {
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||
if (tmp != 1)
|
||||
error->all(FLERR,"Custom per-atom property ID is not floating point");
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
argindex[ATTRIBUTES+i] = 0;
|
||||
field2index[ATTRIBUTES+i] = add_custom(argi.get_name(),1);
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
break;
|
||||
|
||||
int tmp = -1;
|
||||
n = atom->find_custom(suffix,tmp);
|
||||
if (n < 0)
|
||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
||||
// custom per-atom integer value = i_ID
|
||||
|
||||
if (tmp != 1)
|
||||
error->all(FLERR,"Custom per-atom property ID is not floating point");
|
||||
case ArgInfo::INAME:
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
||||
vtype[ATTRIBUTES+i] = Dump::INT;
|
||||
|
||||
field2index[ATTRIBUTES+i] = add_custom(suffix,1);
|
||||
name[ATTRIBUTES+i] = suffix;
|
||||
delete [] suffix;
|
||||
tmp = -1;
|
||||
n = atom->find_custom(argi.get_name(),tmp);
|
||||
if (n < 0)
|
||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
||||
|
||||
// custom per-atom integer value = i_ID
|
||||
if (tmp != 0)
|
||||
error->all(FLERR,"Custom per-atom property ID is not integer");
|
||||
|
||||
} else if (strncmp(arg[iarg],"i_",2) == 0) {
|
||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
||||
vtype[ATTRIBUTES+i] = Dump::INT;
|
||||
field2index[ATTRIBUTES+i] = add_custom(argi.get_name(),0);
|
||||
name[ATTRIBUTES+i] = arg[iarg];
|
||||
break;
|
||||
|
||||
int n = strlen(arg[iarg]);
|
||||
char *suffix = new char[n];
|
||||
strcpy(suffix,&arg[iarg][2]);
|
||||
argindex[ATTRIBUTES+i] = 0;
|
||||
|
||||
int tmp = -1;
|
||||
n = atom->find_custom(suffix,tmp);
|
||||
if (n < 0)
|
||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
||||
|
||||
if (tmp != 0)
|
||||
error->all(FLERR,"Custom per-atom property ID is not integer");
|
||||
|
||||
field2index[ATTRIBUTES+i] = add_custom(suffix,0);
|
||||
name[ATTRIBUTES+i] = suffix;
|
||||
delete [] suffix;
|
||||
|
||||
} else return iarg;
|
||||
default:
|
||||
return iarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
identify_vectors();
|
||||
|
||||
@ -16,28 +16,28 @@
|
||||
------------------------------------------------------------------------- */
|
||||
#include "fix_ave_histo_weight.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include "fix.h"
|
||||
#include "arg_info.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "compute.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "input.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{X,V,F,COMPUTE,FIX,VARIABLE};
|
||||
enum{ONE,RUNNING};
|
||||
enum{SCALAR,VECTOR,WINDOW};
|
||||
enum{DEFAULT,GLOBAL,PERATOM,LOCAL};
|
||||
enum{IGNORE,END,EXTRA};
|
||||
enum{SINGLE,VALUE};
|
||||
|
||||
|
||||
#define BIG 1.0e20
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -54,31 +54,31 @@ FixAveHistoWeight::FixAveHistoWeight(LAMMPS *lmp, int narg, char **arg) :
|
||||
int size[2];
|
||||
|
||||
for (int i = 0; i < nvalues; i++) {
|
||||
if (which[i] == X || which[i] == V || which[i] == F) {
|
||||
if (which[i] == ArgInfo::X || which[i] == ArgInfo::V || which[i] == ArgInfo::F) {
|
||||
size[i] = atom->nlocal;
|
||||
} else if (which[i] == COMPUTE && kind == GLOBAL && mode == SCALAR) {
|
||||
} else if (which[i] == ArgInfo::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) {
|
||||
} else if (which[i] == ArgInfo::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) {
|
||||
} else if (which[i] == ArgInfo::COMPUTE && kind == PERATOM) {
|
||||
size[i] = atom->nlocal;
|
||||
} else if (which[i] == COMPUTE && kind == LOCAL) {
|
||||
} else if (which[i] == ArgInfo::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) {
|
||||
} else if (which[i] == ArgInfo::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) {
|
||||
} else if (which[i] == ArgInfo::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) {
|
||||
} else if (which[i] == ArgInfo::FIX && kind == PERATOM) {
|
||||
size[i] = atom->nlocal;
|
||||
} else if (which[i] == FIX && kind == LOCAL) {
|
||||
} else if (which[i] == ArgInfo::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) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||
size[i] = atom->nlocal;
|
||||
}
|
||||
}
|
||||
@ -130,21 +130,21 @@ void FixAveHistoWeight::end_of_step()
|
||||
|
||||
// atom attributes
|
||||
|
||||
if (which[i] == X) {
|
||||
if (which[i] == ArgInfo::X) {
|
||||
weights = &atom->x[0][j];
|
||||
stride = 3;
|
||||
} else if (which[i] == V) {
|
||||
} else if (which[i] == ArgInfo::V) {
|
||||
weights = &atom->v[0][j];
|
||||
stride = 3;
|
||||
bin_atoms(&atom->v[0][j],3);
|
||||
} else if (which[i] == F) {
|
||||
} else if (which[i] == ArgInfo::F) {
|
||||
weights = &atom->f[0][j];
|
||||
stride = 3;
|
||||
}
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
if (which[i] == COMPUTE) {
|
||||
if (which[i] == ArgInfo::COMPUTE) {
|
||||
|
||||
Compute *compute = modify->compute[m];
|
||||
|
||||
@ -206,7 +206,7 @@ void FixAveHistoWeight::end_of_step()
|
||||
|
||||
// access fix fields, guaranteed to be ready
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
|
||||
Fix *fix = modify->fix[m];
|
||||
|
||||
@ -243,10 +243,10 @@ void FixAveHistoWeight::end_of_step()
|
||||
|
||||
// evaluate equal-style variable
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == GLOBAL) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == GLOBAL) {
|
||||
weight = input->variable->compute_equal(m);
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vector);
|
||||
maxatom = atom->nmax;
|
||||
@ -265,16 +265,16 @@ void FixAveHistoWeight::end_of_step()
|
||||
|
||||
// atom attributes
|
||||
|
||||
if (which[i] == X && weights != nullptr)
|
||||
if (which[i] == ArgInfo::X && weights != nullptr)
|
||||
bin_atoms_weights(&atom->x[0][j],3,weights,stride);
|
||||
else if (which[i] == V && weights != nullptr)
|
||||
else if (which[i] == ArgInfo::V && weights != nullptr)
|
||||
bin_atoms_weights(&atom->v[0][j],3,weights,stride);
|
||||
else if (which[i] == F && weights != nullptr)
|
||||
else if (which[i] == ArgInfo::F && weights != nullptr)
|
||||
bin_atoms_weights(&atom->f[0][j],3,weights,stride);
|
||||
|
||||
// invoke compute if not previously invoked
|
||||
|
||||
if (which[i] == COMPUTE) {
|
||||
if (which[i] == ArgInfo::COMPUTE) {
|
||||
Compute *compute = modify->compute[m];
|
||||
if (kind == GLOBAL && mode == SCALAR) {
|
||||
if (j == 0) {
|
||||
@ -335,7 +335,7 @@ void FixAveHistoWeight::end_of_step()
|
||||
|
||||
// access fix fields, guaranteed to be ready
|
||||
|
||||
} else if (which[i] == FIX) {
|
||||
} else if (which[i] == ArgInfo::FIX) {
|
||||
|
||||
Fix *fix = modify->fix[m];
|
||||
|
||||
@ -372,10 +372,10 @@ void FixAveHistoWeight::end_of_step()
|
||||
|
||||
// evaluate equal-style variable
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == GLOBAL) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == GLOBAL) {
|
||||
bin_one_weights(input->variable->compute_equal(m),weight);
|
||||
|
||||
} else if (which[i] == VARIABLE && kind == PERATOM) {
|
||||
} else if (which[i] == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||
if (atom->nmax > maxatom) {
|
||||
memory->destroy(vector);
|
||||
maxatom = atom->nmax;
|
||||
|
||||
Reference in New Issue
Block a user