add support for wildcards in variable vectors
This commit is contained in:
@ -25,7 +25,7 @@ Syntax
|
|||||||
f_ID = global scalar calculated by a fix with ID
|
f_ID = global scalar calculated by a fix with ID
|
||||||
f_ID[I] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below)
|
f_ID[I] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below)
|
||||||
v_name = global value calculated by an equal-style variable with name
|
v_name = global value calculated by an equal-style variable with name
|
||||||
v_name[I] = Ith component of a vector-style variable with name
|
v_name[I] = Ith component of a vector-style variable with name, I can include wildcard (see below)
|
||||||
|
|
||||||
* zero or more keyword/arg pairs may be appended
|
* zero or more keyword/arg pairs may be appended
|
||||||
* keyword = *type* or *ave* or *start* or *prefactor* or *file* or *overwrite* or *title1* or *title2* or *title3*
|
* keyword = *type* or *ave* or *start* or *prefactor* or *file* or *overwrite* or *title1* or *title2* or *title3*
|
||||||
@ -105,15 +105,17 @@ individual fixes for info on which ones produce such values.
|
|||||||
ones that can be used with this fix. Variables of style *atom* cannot
|
ones that can be used with this fix. Variables of style *atom* cannot
|
||||||
be used, since they produce per-atom values.
|
be used, since they produce per-atom values.
|
||||||
|
|
||||||
Note that for values from a compute or fix, the bracketed index I can
|
----------
|
||||||
be specified using a wildcard asterisk with the index to effectively
|
|
||||||
specify multiple values. This takes the form "\*" or "\*n" or "n\*" or
|
For input values from a compute or fix or variable , the bracketed
|
||||||
"m\*n". If N = the size of the vector (for *mode* = scalar) or the
|
index I can be specified using a wildcard asterisk with the index to
|
||||||
number of columns in the array (for *mode* = vector), then an asterisk
|
effectively specify multiple values. This takes the form "\*" or
|
||||||
with no numeric values means all indices from 1 to N. A leading
|
"\*n" or "n\*" or "m\*n". If N = the size of the vector (for *mode* =
|
||||||
asterisk means all indices from 1 to n (inclusive). A trailing
|
scalar) or the number of columns in the array (for *mode* = vector),
|
||||||
asterisk means all indices from n to N (inclusive). A middle asterisk
|
then an asterisk with no numeric values means all indices from 1 to N.
|
||||||
means all indices from m to n (inclusive).
|
A leading asterisk means all indices from 1 to n (inclusive). A
|
||||||
|
trailing asterisk means all indices from n to N (inclusive). A middle
|
||||||
|
asterisk means all indices from m to n (inclusive).
|
||||||
|
|
||||||
Using a wildcard is the same as if the individual elements of the
|
Using a wildcard is the same as if the individual elements of the
|
||||||
vector had been listed one by one. E.g. these 2 fix ave/correlate
|
vector had been listed one by one. E.g. these 2 fix ave/correlate
|
||||||
@ -128,6 +130,14 @@ values.
|
|||||||
c_myPress[1] c_myPress[2] c_myPress[3] &
|
c_myPress[1] c_myPress[2] c_myPress[3] &
|
||||||
c_myPress[4] c_myPress[5] c_myPress[6]
|
c_myPress[4] c_myPress[5] c_myPress[6]
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
For a vector-style variable, only the wildcard forms "\*n" or
|
||||||
|
"m\*n" are allowed. You must specify the upper bound, because
|
||||||
|
vector-style variable lengths are not determined until the variable
|
||||||
|
is evaluated. If n is specified larger than the vector length
|
||||||
|
turns out to be, zeroes are output for missing vector values.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
The *Nevery*, *Nrepeat*, and *Nfreq* arguments specify on what
|
The *Nevery*, *Nrepeat*, and *Nfreq* arguments specify on what
|
||||||
|
|||||||
@ -32,7 +32,7 @@ Syntax
|
|||||||
f_ID = scalar or vector calculated by a fix with ID
|
f_ID = scalar or vector calculated by a fix with ID
|
||||||
f_ID[I] = Ith component of vector or Ith column of array calculated by a fix with ID, I can include wildcard (see below)
|
f_ID[I] = Ith component of vector or Ith column of array calculated by a fix with ID, I can include wildcard (see below)
|
||||||
v_name = value(s) calculated by an equal-style or vector-style or atom-style variable with name
|
v_name = value(s) calculated by an equal-style or vector-style or atom-style variable with name
|
||||||
v_name[I] = value calculated by a vector-style variable with name
|
v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below)
|
||||||
|
|
||||||
* zero or more keyword/arg pairs may be appended
|
* zero or more keyword/arg pairs may be appended
|
||||||
* keyword = *mode* or *file* or *ave* or *start* or *beyond* or *overwrite* or *title1* or *title2* or *title3*
|
* keyword = *mode* or *file* or *ave* or *start* or *beyond* or *overwrite* or *title1* or *title2* or *title3*
|
||||||
@ -120,15 +120,27 @@ If *mode* = vector, then the input values must be vectors, or arrays
|
|||||||
with a bracketed term appended, indicating the Ith column of the array
|
with a bracketed term appended, indicating the Ith column of the array
|
||||||
is used.
|
is used.
|
||||||
|
|
||||||
Note that for values from a compute or fix, the bracketed index I can
|
If the fix ave/histo/weight command is used, exactly two values must
|
||||||
be specified using a wildcard asterisk with the index to effectively
|
be specified. If the values are vectors, they must be the same
|
||||||
specify multiple values. This takes the form "\*" or "\*n" or "n\*" or
|
length. The first value (a scalar or vector) is what is histogrammed
|
||||||
"m\*n". If N = the size of the vector (for *mode* = scalar) or the
|
into bins, in the same manner the fix ave/histo command operates. The
|
||||||
number of columns in the array (for *mode* = vector), then an asterisk
|
second value (a scalar or vector) is used as a "weight". This means
|
||||||
with no numeric values means all indices from 1 to N. A leading
|
that instead of each value tallying a "1" to its bin, the
|
||||||
asterisk means all indices from 1 to n (inclusive). A trailing
|
corresponding weight is tallied. E.g. The Nth entry (weight) in the
|
||||||
asterisk means all indices from n to N (inclusive). A middle asterisk
|
second vector is tallied to the bin corresponding to the Nth entry in
|
||||||
means all indices from m to n (inclusive).
|
the first vector.
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
For input values from a compute or fix or variable, the bracketed
|
||||||
|
index I can be specified using a wildcard asterisk with the index to
|
||||||
|
effectively specify multiple values. This takes the form "\*" or
|
||||||
|
"\*n" or "n\*" or "m\*n". If N = the size of the vector (for *mode* =
|
||||||
|
scalar) or the number of columns in the array (for *mode* = vector),
|
||||||
|
then an asterisk with no numeric values means all indices from 1 to N.
|
||||||
|
A leading asterisk means all indices from 1 to n (inclusive). A
|
||||||
|
trailing asterisk means all indices from n to N (inclusive). A middle
|
||||||
|
asterisk means all indices from m to n (inclusive).
|
||||||
|
|
||||||
Using a wildcard is the same as if the individual elements of the
|
Using a wildcard is the same as if the individual elements of the
|
||||||
vector or columns of the array had been listed one by one. E.g. these
|
vector or columns of the array had been listed one by one. E.g. these
|
||||||
@ -141,15 +153,14 @@ vector or columns of the array had been listed one by one. E.g. these
|
|||||||
fix 1 all ave/histo 100 1 100 -10.0 10.0 100 c_myCOM[*] file tmp1.com mode vector
|
fix 1 all ave/histo 100 1 100 -10.0 10.0 100 c_myCOM[*] file tmp1.com mode vector
|
||||||
fix 2 all ave/histo 100 1 100 -10.0 10.0 100 c_myCOM[1] c_myCOM[2] c_myCOM[3] file tmp2.com mode vector
|
fix 2 all ave/histo 100 1 100 -10.0 10.0 100 c_myCOM[1] c_myCOM[2] c_myCOM[3] file tmp2.com mode vector
|
||||||
|
|
||||||
If the fix ave/histo/weight command is used, exactly two values must
|
.. note::
|
||||||
be specified. If the values are vectors, they must be the same
|
|
||||||
length. The first value (a scalar or vector) is what is histogrammed
|
For a vector-style variable, only the wildcard forms "\*n" or
|
||||||
into bins, in the same manner the fix ave/histo command operates. The
|
"m\*n" are allowed. You must specify the upper bound, because
|
||||||
second value (a scalar or vector) is used as a "weight". This means
|
vector-style variable lengths are not determined until the variable
|
||||||
that instead of each value tallying a "1" to its bin, the
|
is evaluated. If n is specified larger than the vector length"\*n"
|
||||||
corresponding weight is tallied. E.g. The Nth entry (weight) in the
|
or "n\*" or "m\*n". turns out to be, zeroes are output for missing
|
||||||
second vector is tallied to the bin corresponding to the Nth entry in
|
vector values.
|
||||||
the first vector.
|
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ Syntax
|
|||||||
f_ID = global scalar or vector calculated by a fix with ID
|
f_ID = global scalar or vector calculated by a fix with ID
|
||||||
f_ID[I] = Ith component of global vector or Ith column of global array calculated by a fix with ID, I can include wildcard (see below)
|
f_ID[I] = Ith component of global vector or Ith column of global array calculated by a fix with ID, I can include wildcard (see below)
|
||||||
v_name = value(s) calculated by an equal-style or vector-style variable with name
|
v_name = value(s) calculated by an equal-style or vector-style variable with name
|
||||||
v_name[I] = value calculated by a vector-style variable with name
|
v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below)
|
||||||
|
|
||||||
* zero or more keyword/arg pairs may be appended
|
* zero or more keyword/arg pairs may be appended
|
||||||
* keyword = *mode* or *file* or *ave* or *start* or *off* or *overwrite* or *title1* or *title2* or *title3*
|
* keyword = *mode* or *file* or *ave* or *start* or *off* or *overwrite* or *title1* or *title2* or *title3*
|
||||||
@ -113,15 +113,17 @@ with a bracketed term appended, indicating the Ith column of the array
|
|||||||
is used. All vectors must be the same length, which is the length of
|
is used. All vectors must be the same length, which is the length of
|
||||||
the vector or number of rows in the array.
|
the vector or number of rows in the array.
|
||||||
|
|
||||||
Note that for values from a compute or fix, the bracketed index I can
|
----------
|
||||||
be specified using a wildcard asterisk with the index to effectively
|
|
||||||
specify multiple values. This takes the form "\*" or "\*n" or "n\*" or
|
For input values from a compute or fix or variable, the bracketed
|
||||||
"m\*n". If N = the size of the vector (for *mode* = scalar) or the
|
index I can be specified using a wildcard asterisk with the index to
|
||||||
number of columns in the array (for *mode* = vector), then an asterisk
|
effectively specify multiple values. This takes the form "\*" or
|
||||||
with no numeric values means all indices from 1 to N. A leading
|
"\*n" or "n\*" or "m\*n". If N = the size of the vector (for *mode* =
|
||||||
asterisk means all indices from 1 to n (inclusive). A trailing
|
scalar) or the number of columns in the array (for *mode* = vector),
|
||||||
asterisk means all indices from n to N (inclusive). A middle asterisk
|
then an asterisk with no numeric values means all indices from 1 to N.
|
||||||
means all indices from m to n (inclusive).
|
A leading asterisk means all indices from 1 to n (inclusive). A
|
||||||
|
trailing asterisk means all indices from n to N (inclusive). A middle
|
||||||
|
asterisk means all indices from m to n (inclusive).
|
||||||
|
|
||||||
Using a wildcard is the same as if the individual elements of the
|
Using a wildcard is the same as if the individual elements of the
|
||||||
vector or columns of the array had been listed one by one. E.g. these
|
vector or columns of the array had been listed one by one. E.g. these
|
||||||
@ -134,6 +136,15 @@ with 3 columns, each of length 50:
|
|||||||
fix 1 all ave/time 100 1 100 c_myRDF[*] file tmp1.rdf mode vector
|
fix 1 all ave/time 100 1 100 c_myRDF[*] file tmp1.rdf mode vector
|
||||||
fix 2 all ave/time 100 1 100 c_myRDF[1] c_myRDF[2] c_myRDF[3] file tmp2.rdf mode vector
|
fix 2 all ave/time 100 1 100 c_myRDF[1] c_myRDF[2] c_myRDF[3] file tmp2.rdf mode vector
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
For a vector-style variable, only the wildcard forms "\*n" or
|
||||||
|
"m\*n" are allowed. You must specify the upper bound, because
|
||||||
|
vector-style variable lengths are not determined until the variable
|
||||||
|
is evaluated. If n is specified larger than the vector length"\*n"
|
||||||
|
or "n\*" or "m\*n". turns out to be, zeroes are output for missing
|
||||||
|
vector values.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
The *Nevery*, *Nrepeat*, and *Nfreq* arguments specify on what
|
The *Nevery*, *Nrepeat*, and *Nfreq* arguments specify on what
|
||||||
|
|||||||
@ -85,7 +85,7 @@ Syntax
|
|||||||
f_ID[I] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below)
|
f_ID[I] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below)
|
||||||
f_ID[I][J] = I,J component of global array calculated by a fix with ID
|
f_ID[I][J] = I,J component of global array calculated by a fix with ID
|
||||||
v_name = value calculated by an equal-style variable with name
|
v_name = value calculated by an equal-style variable with name
|
||||||
v_name[I] = value calculated by a vector-style variable with name
|
v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below)
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
""""""""
|
""""""""
|
||||||
@ -348,16 +348,16 @@ dimensions *lx*, *ly*, *lz*, *yz*, *xz*, *xy*\ .
|
|||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
For output values from a compute or fix, the bracketed index I used to
|
For output values from a compute or fix or variable, the bracketed
|
||||||
index a vector, as in *c_ID[I]* or *f_ID[I]*, can be specified
|
index I used to index a vector, as in *c_ID[I]* or *f_ID[I]* or
|
||||||
using a wildcard asterisk with the index to effectively specify
|
*v_name[I]*, can be specified using a wildcard asterisk with the index
|
||||||
multiple values. This takes the form "\*" or "\*n" or "n\*" or "m\*n".
|
to effectively specify multiple values. This takes the form "\*" or
|
||||||
If N = the size of the vector (for *mode* = scalar) or the number of
|
"\*n" or "n\*" or "m\*n". If N = the size of the vector (for *mode* =
|
||||||
columns in the array (for *mode* = vector), then an asterisk with no
|
scalar) or the number of columns in the array (for *mode* = vector),
|
||||||
numeric values means all indices from 1 to N. A leading asterisk
|
then an asterisk with no numeric values means all indices from 1 to N.
|
||||||
means all indices from 1 to n (inclusive). A trailing asterisk means
|
A leading asterisk means all indices from 1 to n (inclusive). A
|
||||||
all indices from n to N (inclusive). A middle asterisk means all
|
trailing asterisk means all indices from n to N (inclusive). A middle
|
||||||
indices from m to n (inclusive).
|
asterisk means all indices from m to n (inclusive).
|
||||||
|
|
||||||
Using a wildcard is the same as if the individual elements of the
|
Using a wildcard is the same as if the individual elements of the
|
||||||
vector had been listed one by one. E.g. these 2 thermo_style commands
|
vector had been listed one by one. E.g. these 2 thermo_style commands
|
||||||
@ -372,6 +372,15 @@ creates a global vector with 6 values.
|
|||||||
c_myTemp[1] c_myTemp[2] c_myTemp[3] &
|
c_myTemp[1] c_myTemp[2] c_myTemp[3] &
|
||||||
c_myTemp[4] c_myTemp[5] c_myTemp[6]
|
c_myTemp[4] c_myTemp[5] c_myTemp[6]
|
||||||
|
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
For a vector-style variable, only the wildcard forms "\*n" or
|
||||||
|
"m\*n" are allowed. You must specify the upper bound, because
|
||||||
|
vector-style variable lengths are not determined until the variable
|
||||||
|
is evaluated. If n is specified larger than the vector length
|
||||||
|
turns out to be, zeroes are output for missing vector values.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
The *c_ID* and *c_ID[I]* and *c_ID[I][J]* keywords allow global values
|
The *c_ID* and *c_ID[I]* and *c_ID[I][J]* keywords allow global values
|
||||||
|
|||||||
@ -136,5 +136,6 @@ variable C46 equal v_F46+v_B[20]
|
|||||||
variable C56 equal v_F56+v_B[21]
|
variable C56 equal v_F56+v_B[21]
|
||||||
|
|
||||||
thermo ${nthermo}
|
thermo ${nthermo}
|
||||||
thermo_style custom step temp pe press density f_avt f_avp f_avpe v_F11 v_F22 v_F33 v_F44 v_F55 v_F66 v_F12 v_F13 v_F23 v_B[1] v_B[2] v_B[3] v_B[4] v_B[5] v_B[6] v_B[7] v_B[8] v_B[12]
|
thermo_style custom step temp pe press density f_avt f_avp f_avpe v_F11 v_F22 v_F33 v_F44 v_F55 v_F66 v_F12 v_F13 v_F23 v_B[*8] v_B[12]
|
||||||
|
|
||||||
thermo_modify norm no
|
thermo_modify norm no
|
||||||
|
|||||||
@ -19,11 +19,13 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
#include "fmt/chrono.h"
|
#include "fmt/chrono.h"
|
||||||
|
#include "input.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "text_file_reader.h"
|
#include "text_file_reader.h"
|
||||||
#include "universe.h"
|
#include "universe.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
#include "variable.h"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@ -631,7 +633,7 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
|||||||
// match compute, fix, or custom property array reference with a '*' wildcard
|
// match compute, fix, or custom property array reference with a '*' wildcard
|
||||||
// number range in the first pair of square brackets
|
// number range in the first pair of square brackets
|
||||||
|
|
||||||
if (strmatch(word, "^[cf]_\\w+\\[\\d*\\*\\d*\\]") ||
|
if (strmatch(word, "^[cfv]_\\w+\\[\\d*\\*\\d*\\]") ||
|
||||||
strmatch(word, "^[id]2_\\w+\\[\\d*\\*\\d*\\]")) {
|
strmatch(word, "^[id]2_\\w+\\[\\d*\\*\\d*\\]")) {
|
||||||
|
|
||||||
// split off the compute/fix/property ID, the wildcard and trailing text
|
// split off the compute/fix/property ID, the wildcard and trailing text
|
||||||
@ -692,6 +694,23 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vector variable
|
||||||
|
|
||||||
|
} else if (word[0] == 'v') {
|
||||||
|
int index = lmp->input->variable->find(id.c_str());
|
||||||
|
|
||||||
|
// check for global vector/array, peratom array, local array
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
if (mode == 0 && lmp->input->variable->vectorstyle(index)) {
|
||||||
|
utils::bounds(file, line, wc, 1, MAXSMALLINT, nlo, nhi, lmp->error);
|
||||||
|
if (nhi < MAXSMALLINT) {
|
||||||
|
nmax = nhi;
|
||||||
|
expandflag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// only match custom array reference with a '*' wildcard
|
// only match custom array reference with a '*' wildcard
|
||||||
// number range in the first pair of square brackets
|
// number range in the first pair of square brackets
|
||||||
|
|
||||||
@ -716,6 +735,7 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
|||||||
if (expandflag) {
|
if (expandflag) {
|
||||||
|
|
||||||
// expand wild card string to nlo/nhi numbers
|
// expand wild card string to nlo/nhi numbers
|
||||||
|
|
||||||
utils::bounds(file, line, wc, 1, nmax, nlo, nhi, lmp->error);
|
utils::bounds(file, line, wc, 1, nmax, nlo, nhi, lmp->error);
|
||||||
|
|
||||||
if (newarg + nhi - nlo + 1 > maxarg) {
|
if (newarg + nhi - nlo + 1 > maxarg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user