git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13008 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2015-01-30 18:51:56 +00:00
parent 18b5c363c2
commit e1cd500a21
7 changed files with 45 additions and 26 deletions

View File

@ -68,6 +68,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
scalar_flag = vector_flag = array_flag = 0; scalar_flag = vector_flag = array_flag = 0;
peratom_flag = local_flag = 0; peratom_flag = local_flag = 0;
size_vector_variable = size_array_rows_variable = 0;
tempflag = pressflag = peflag = 0; tempflag = pressflag = peflag = 0;
pressatomflag = peatomflag = 0; pressatomflag = peatomflag = 0;

View File

@ -39,6 +39,8 @@ class Compute : protected Pointers {
int size_vector; // length of global vector int size_vector; // length of global vector
int size_array_rows; // rows in global array int size_array_rows; // rows in global array
int size_array_cols; // columns in global array int size_array_cols; // columns in global array
int size_vector_variable; // 1 if vec length is unknown in advance
int size_array_rows_variable; // 1 if array rows is unknown in advance
int peratom_flag; // 0/1 if compute_peratom() function exists int peratom_flag; // 0/1 if compute_peratom() function exists
int size_peratom_cols; // 0 = vector, N = columns in peratom array int size_peratom_cols; // 0 = vector, N = columns in peratom array

View File

@ -471,7 +471,7 @@ void Domain::reset_box()
MAX is important since coord - prd < lo can happen when coord = hi MAX is important since coord - prd < lo can happen when coord = hi
if fix deform, remap velocity of fix group atoms by box edge velocities if fix deform, remap velocity of fix group atoms by box edge velocities
for triclinic, atoms must be in lamda coords (0-1) before pbc is called for triclinic, atoms must be in lamda coords (0-1) before pbc is called
image = 10 bits for each dimension image = 10 or 20 bits for each dimension depending on sizeof(imageint)
increment/decrement in wrap-around fashion increment/decrement in wrap-around fashion
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -69,7 +69,7 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
scalar_flag = vector_flag = array_flag = 0; scalar_flag = vector_flag = array_flag = 0;
peratom_flag = local_flag = 0; peratom_flag = local_flag = 0;
size_array_rows_variable = 0; size_vector_variable = size_array_rows_variable = 0;
comm_forward = comm_reverse = comm_border = 0; comm_forward = comm_reverse = comm_border = 0;
restart_reset = 0; restart_reset = 0;

View File

@ -57,7 +57,8 @@ class Fix : protected Pointers {
int size_vector; // length of global vector int size_vector; // length of global vector
int size_array_rows; // rows in global array int size_array_rows; // rows in global array
int size_array_cols; // columns in global array int size_array_cols; // columns in global array
int size_array_rows_variable; // 1 if row count is unknown in advance int size_vector_variable; // 1 if vec length is unknown in advance
int size_array_rows_variable; // 1 if array rows is unknown in advance
int global_freq; // frequency s/v data is available at int global_freq; // frequency s/v data is available at
int peratom_flag; // 0/1 if per-atom data is stored int peratom_flag; // 0/1 if per-atom data is stored

View File

@ -860,14 +860,17 @@ void Thermo::parse_fields(char *str)
if (argindex1[nfield] > 0 && argindex2[nfield] == 0) { if (argindex1[nfield] > 0 && argindex2[nfield] == 0) {
if (modify->compute[n]->vector_flag == 0) if (modify->compute[n]->vector_flag == 0)
error->all(FLERR,"Thermo compute does not compute vector"); error->all(FLERR,"Thermo compute does not compute vector");
if (argindex1[nfield] > modify->compute[n]->size_vector) if (argindex1[nfield] > modify->compute[n]->size_vector &&
modify->compute[n]->size_vector_variable == 0)
error->all(FLERR,"Thermo compute vector is accessed out-of-range"); error->all(FLERR,"Thermo compute vector is accessed out-of-range");
} }
if (argindex1[nfield] > 0 && argindex2[nfield] > 0) { if (argindex1[nfield] > 0 && argindex2[nfield] > 0) {
if (modify->compute[n]->array_flag == 0) if (modify->compute[n]->array_flag == 0)
error->all(FLERR,"Thermo compute does not compute array"); error->all(FLERR,"Thermo compute does not compute array");
if (argindex1[nfield] > modify->compute[n]->size_array_rows || if (argindex1[nfield] > modify->compute[n]->size_array_rows &&
argindex2[nfield] > modify->compute[n]->size_array_cols) modify->compute[n]->size_array_rows_variable == 0)
error->all(FLERR,"Thermo compute array is accessed out-of-range");
if (argindex2[nfield] > modify->compute[n]->size_array_cols)
error->all(FLERR,"Thermo compute array is accessed out-of-range"); error->all(FLERR,"Thermo compute array is accessed out-of-range");
} }
@ -887,16 +890,16 @@ void Thermo::parse_fields(char *str)
if (argindex1[nfield] > 0 && argindex2[nfield] == 0) { if (argindex1[nfield] > 0 && argindex2[nfield] == 0) {
if (modify->fix[n]->vector_flag == 0) if (modify->fix[n]->vector_flag == 0)
error->all(FLERR,"Thermo fix does not compute vector"); error->all(FLERR,"Thermo fix does not compute vector");
if (argindex1[nfield] > modify->fix[n]->size_vector) if (argindex1[nfield] > modify->fix[n]->size_vector &&
modify->fix[n]->size_vector_variable == 0)
error->all(FLERR,"Thermo fix vector is accessed out-of-range"); error->all(FLERR,"Thermo fix vector is accessed out-of-range");
} }
if (argindex1[nfield] > 0 && argindex2[nfield] > 0) { if (argindex1[nfield] > 0 && argindex2[nfield] > 0) {
if (modify->fix[n]->array_flag == 0) if (modify->fix[n]->array_flag == 0)
error->all(FLERR,"Thermo fix does not compute array"); error->all(FLERR,"Thermo fix does not compute array");
if (argindex1[nfield] > modify->fix[n]->size_array_rows) { if (argindex1[nfield] > modify->fix[n]->size_array_rows &&
if (modify->fix[n]->size_array_rows_variable == 0) modify->fix[n]->size_array_rows_variable == 0)
error->all(FLERR,"Thermo fix array is accessed out-of-range"); error->all(FLERR,"Thermo fix array is accessed out-of-range");
}
if (argindex2[nfield] > modify->fix[n]->size_array_cols) if (argindex2[nfield] > modify->fix[n]->size_array_cols)
error->all(FLERR,"Thermo fix array is accessed out-of-range"); error->all(FLERR,"Thermo fix array is accessed out-of-range");
} }
@ -1422,18 +1425,24 @@ void Thermo::compute_compute()
int m = field2index[ifield]; int m = field2index[ifield];
Compute *compute = computes[m]; Compute *compute = computes[m];
// check for out-of-range access if vector/array is variable length
if (compute_which[m] == SCALAR) { if (compute_which[m] == SCALAR) {
dvalue = compute->scalar; dvalue = compute->scalar;
if (normflag && compute->extscalar) dvalue /= natoms; if (normflag && compute->extscalar) dvalue /= natoms;
} else if (compute_which[m] == VECTOR) { } else if (compute_which[m] == VECTOR) {
dvalue = compute->vector[argindex1[ifield]-1]; if (compute->size_vector_variable && argindex1[ifield] >
compute->size_vector) dvalue = 0.0;
else dvalue = compute->vector[argindex1[ifield]-1];
if (normflag) { if (normflag) {
if (compute->extvector == 0) return; if (compute->extvector == 0) return;
else if (compute->extvector == 1) dvalue /= natoms; else if (compute->extvector == 1) dvalue /= natoms;
else if (compute->extlist[argindex1[ifield]-1]) dvalue /= natoms; else if (compute->extlist[argindex1[ifield]-1]) dvalue /= natoms;
} }
} else { } else {
dvalue = compute->array[argindex1[ifield]-1][argindex2[ifield]-1]; if (compute->size_array_rows_variable && argindex1[ifield] >
compute->size_array_rows) dvalue = 0.0;
else dvalue = compute->array[argindex1[ifield]-1][argindex2[ifield]-1];
if (normflag && compute->extarray) dvalue /= natoms; if (normflag && compute->extarray) dvalue /= natoms;
} }
} }

View File

@ -1081,7 +1081,8 @@ double Variable::evaluate(char *str, Tree **tree)
} else if (nbracket == 1 && compute->vector_flag) { } else if (nbracket == 1 && compute->vector_flag) {
if (index1 > compute->size_vector) if (index1 > compute->size_vector &&
compute->size_vector_variable == 0)
error->all(FLERR,"Variable formula compute vector " error->all(FLERR,"Variable formula compute vector "
"is accessed out-of-range"); "is accessed out-of-range");
if (update->whichflag == 0) { if (update->whichflag == 0) {
@ -1093,7 +1094,9 @@ double Variable::evaluate(char *str, Tree **tree)
compute->invoked_flag |= INVOKED_VECTOR; compute->invoked_flag |= INVOKED_VECTOR;
} }
value1 = compute->vector[index1-1]; if (compute->size_vector_variable &&
index1 > compute->size_vector) value1 = 0.0;
else value1 = compute->vector[index1-1];
if (tree) { if (tree) {
Tree *newtree = new Tree(); Tree *newtree = new Tree();
newtree->type = VALUE; newtree->type = VALUE;
@ -1107,7 +1110,8 @@ double Variable::evaluate(char *str, Tree **tree)
} else if (nbracket == 2 && compute->array_flag) { } else if (nbracket == 2 && compute->array_flag) {
if (index1 > compute->size_array_rows) if (index1 > compute->size_array_rows &&
compute->size_array_rows_variable == 0)
error->all(FLERR,"Variable formula compute array " error->all(FLERR,"Variable formula compute array "
"is accessed out-of-range"); "is accessed out-of-range");
if (index2 > compute->size_array_cols) if (index2 > compute->size_array_cols)
@ -1122,7 +1126,9 @@ double Variable::evaluate(char *str, Tree **tree)
compute->invoked_flag |= INVOKED_ARRAY; compute->invoked_flag |= INVOKED_ARRAY;
} }
value1 = compute->array[index1-1][index2-1]; if (compute->size_array_rows_variable &&
index1 > compute->size_array_rows) value1 = 0.0;
else value1 = compute->array[index1-1][index2-1];
if (tree) { if (tree) {
Tree *newtree = new Tree(); Tree *newtree = new Tree();
newtree->type = VALUE; newtree->type = VALUE;
@ -1295,12 +1301,13 @@ double Variable::evaluate(char *str, Tree **tree)
} else if (nbracket == 1 && fix->vector_flag) { } else if (nbracket == 1 && fix->vector_flag) {
if (index1 > fix->size_vector) if (index1 > fix->size_vector &&
error->all(FLERR, fix->size_vector_variable == 0)
"Variable formula fix vector is accessed out-of-range"); error->all(FLERR,"Variable formula fix vector is "
"accessed out-of-range");
if (update->whichflag > 0 && update->ntimestep % fix->global_freq) if (update->whichflag > 0 && update->ntimestep % fix->global_freq)
error->all(FLERR,"Fix in variable not computed at compatible time"); error->all(FLERR,"Fix in variable not computed at compatible time");
value1 = fix->compute_vector(index1-1); value1 = fix->compute_vector(index1-1);
if (tree) { if (tree) {
Tree *newtree = new Tree(); Tree *newtree = new Tree();
@ -1315,11 +1322,10 @@ double Variable::evaluate(char *str, Tree **tree)
} else if (nbracket == 2 && fix->array_flag) { } else if (nbracket == 2 && fix->array_flag) {
if (index1 > fix->size_array_rows) { if (index1 > fix->size_array_rows &&
if (fix->size_array_rows_variable == 0) fix->size_array_rows_variable == 0)
error->all(FLERR, error->all(FLERR,
"Variable formula fix array is accessed out-of-range"); "Variable formula fix array is accessed out-of-range");
}
if (index2 > fix->size_array_cols) if (index2 > fix->size_array_cols)
error->all(FLERR, error->all(FLERR,
"Variable formula fix array is accessed out-of-range"); "Variable formula fix array is accessed out-of-range");