Title | Previous | Next

defvar

Define a new variable from existing variables.

Synopsis:

defvar varname=expression

defvar varname

defvar

Arguments:

varname

The name of the new variable being defined.

expression

An expression based on the operators and functions defined in the table below. In general, variables, other defvar variables, functions, operators, and constants can be used in expression .

A variable referenced within expression can reside anywhere within the currently opened SILO file or anywhere within another SILO file. Referencing a variable by its name alone indicates it resides in the current directory of the currently opened SILO file.
The complete syntax for referencing a variable is:

silo_pathname : var_pathname

silo_pathname: is optional. If specified, it is the UNIX TM pathname to the SILO file in which the variable resides. If silo_pathname contains the " / " character, then the entire pathname must be enclosed by single quotes so that " / " is not taken to be the division operator. The pathname can be relative ( ../path , for example), and ~ username syntax is allowed.

var_pathname is the pathname of the variable within the SILO file. If var_pathname is just the name of the variable, then it is assumed to reside in the current directory of the SILO file. The current directory when silo_pathname is specified is the root or " / " directory. If var_pathname has the " / " character, then the entire pathname must be enclosed by single quotes so that " / " is not taken to be the division operator. Because this is a SILO file path, ~ username syntax is not allowed.

Function or Operator

Meaning

Usage

{}

Associate a list of expressions into a single variable. Usually used for defining a vector variable.

{ expr 1 , expr 2 [,...]}

expr i can be an expression of variables, other defvar variables, and constants that evaluate to a mesh variable.

()

Associative parenthesis.

Group mathematical operations, which are described in the table entry following this one.

+ , - , * , / , ^

Addition, subtraction, multiplication, division, and exponentiation operators.

expr op expr

expr can be an expression of variables, other defvar variables, and constants. op is one of the operators specified in the Operator column.

abs

Absolute value.

abs( expr )

expr can be an expression of variables, other defvar variables, and constants.

acos

Arccosine

acos( expr )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a scalar value.

acos returns the arccosine of the expr in radians. Note that expr must range between -1 and 1, inclusive. It is not defined outside this range.

addvf

Add a constant volume fraction to a material.

addvf( mat, num, vf )

mat can be either a valid MeshTV material variable or a defvar expression which evaluates to one.

num must be a valid material number in mat.

vf is a volume fraction (typically in the range of 0 to 1) which will be added to the given material.

This evaluates to a valid MeshTV material variable and can be used in subsequent material plots.

asin

Arcsine

asin( expr )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a scalar value.

asin returns the arcsine of the expr in radians. Note that expr must range between -1 and 1, inclusive. It is not defined outside this range.

aslice

Arbitrary slice (slice through a plane that is not necessarily orthogonal to the axes.)

aslice( expr , f f f , f f f , f f f, [i] )

expr as in oslice

The first set of three numbers defines an origin, the second set defines a normal to the plane, and the third set defines the "upaxis" vector. None of these vectors must be unit vectors. The upaxis vector is used only when the arbitrary slice is mapped to 2D, and it specifies the direction that will be at the top of the 2D visualization window after the slice is performed. The upaxis vector doesn't have to lie along the plane.

The last argument is optional, and it specifies the dimension for the slice. The only legal values are 2 and 3. The default value is 2, which means slices are mapped to 2D. If you specify 3 so that slices are left in 3D, you are duplicating the functionary of the old gslice operator.

atan

Arctangent

atan( expr )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a scalar value.

atan returns the arctangent of the expr in radians.

comp

Create a scalar variable which is a component of a vector variable.

comp( vector , component-number )

vector is the name of a valid MeshTV vector. component-number is the 0 origin number of the component to extract.

const

Create a variable which is a constant scalar or vector defined on the nodes or zones of a mesh.

const( mesh , value ,[nodal|zonal])

mesh is the name of a valid MeshTV mesh. value is either a vector of the form {x,y[,z]} or a single scalar value.

nodal puts one value at each node, and zonal centers the values in the zones. If this parameter is not specified, the default is to place scalars in the zones and vectors at the nodes.

coord0

Create a variable which is the extraction of the first coordinate array from the specified mesh. The first coordinate array is usually the x coordinate array.

coord0( mesh )

mesh is the name of a valid MeshTV mesh.

coord1

Create a variable which is the extraction of the second coordinate array from the specified mesh. The second coordinate array is usually the y coordinate array.

coord1( mesh )

mesh is the name of a valid MeshTV mesh.

coord2

Create a variable which is the extraction of the third coordinate array from the specified mesh. The third coordinate array is usually the z coordinate array.

coord2( mesh )

mesh is the name of a valid MeshTV mesh.

cos

Cosine

cos( expr )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a scalar value.

cos returns the cosine of the expr as given in radians.

dispcoord

This function displaces the coordinate arrays of the mesh specified by the first argument by the vector specified as the second argument.

dispcoord( mesh , vector )

mesh is an expression of variables, other defvar variables, and constants that evaluates to a valid MeshTV mesh. ­ vector is an expression of variables, other defvar variables, and constants that evaluates to a mesh variable defined over the mesh given as the first argument.

Example:

dispcoord( mesh , {coord0( mesh ), coord1( mesh )})

This example displaces each coordinate by the distance of the point from the origin.

gslice

This operator is included only for backward compatibility, and it will be removed in the future. To achieve the same plot, use the aslice operator described in this section. This is a general slice, which was also called a cutplane. (This was combined with the aslice operator in the 3.4 release of MeshTV.)

gslice( expr , long , lat , rad )

expr as in oslice

lat rotates the plane about the axis. It varies from -90 to +90 degrees. Specifying a positive angle rotates the plane in a clockwise fashion when looking down on the X axis. long rotates the plane about the Y axis and can vary in value from -180 to +180 degrees. Specifying a positive angle rotates the plane in a counterclockwise fashion when looking down on the Y axis. rad moves the plane in and out along the direction specified by lat and long . rad can vary from -100 to +100.

insel

Index selection (i.e., reduce the size of the variable using begin, end, skip)

insel( expr , ibeg [ : iend [ : iskip]]

[ , jbeg[ : jend[ : jskip]]]

[ , kbeg[ : kend[ : kskip]]],

[group=group | block=block])

expr can be an expression of variables, other defvar variables, and constants that evaluate to a quadmesh variable.

The options which have " beg " in their name represent the beginning index. Options with " end " represent the ending index, and options with " skip " indicate the number by which to skip. X, Y, and Z are represented by the i, j, and k prefixes. The k prefix options only work in 3D plots.

In a multiblock mesh, you may specify a block number. The indices will then be local to that block.

In a mesh with multiple groups, you may instead specify a group number. The indices will then be local to that group (and global across that group's blocks).

ln

Natural log

ln( expr ) as with abs

log

Base-10 log

log( expr ) as with abs

matsel

Material select

matsel(expr, material-numbers)

expr can be an expression of variables, other defvar variables, and constants that evaluate to a mesh variable.

material-numbers can be a comma-separated list of material numbers and/or ranges, where a range consists of a begin-end pair.

matgrow

Increase the physical size of a material

matgrow( expr, material-number, distance )

expr evaluates to a material variable.

material-number must be a single number for a material in expr.

distance specifies a distance in terms of the physical units of the problem for the size increase.

matvf

Material volume fraction

matvf( expr, material-numbers, [material-numbers . . .] )

expr evaluates to a material variable.

material-numbers can be either a a range of numbers or the word all. A range is specified in the manner beg[:end[:skip]], where beg is the lowest number, end is the highest, and skip specifies the amount by which to skip. Any quantity of material-numbers may be entered.

oslice

Orthogonal slice (slice perpendicular to one of the axes)

oslice( expr ,

ix= i | iy= j | iz = k |

ix= {i,j,k} | iy= {i,j,k} | iz = {i,j,k} |

xx= x | yy= y | zz= z |

px= xpct | py= ypct | pz= zpct,

[group=group | block= block ])

expr can be an expression of variables, other defvar variables, and constants that evaluate to a mesh variable.

Slicing can be done based on a zone index (the ix , iy , and iz options), on a coordinate value (the xx , yy , and zz options), or by a percent value (the px , py , and pz .) Only one of these options is specified at a time, with the x, y, or z indicating the axis to slice along.

In a multiblock mesh, you may specify a block number when slicing by a zone index. The index will then be local to that block.

In a mesh with multiple groups, you may instead specify in which group the zone index should be chosen. The index will then be local to that group (and global across that group's blocks).

point2ucd

Triangulates a point mesh (or point variable) into a UCD mesh (or UCD variable)

point2ucd( mesh )

mesh is an expression of variables, other defvar variables, and constants that evaluate to a two-dimensional point mesh or point variable

reflect

Reflect about one or more axes.

reflect( expr , xmin, xmax, ymin, ymax, zmin, zmax)

expr as in oslice . One or more of the xmin , xmax , etc. must be specified. zmin and zmax are only used for 3D problems.

resrad

Adjust resolution using a Monte Carlo resampling with the given radius.

resrad( expr, radius)

expr can be an expression of variables, other defvar variables, and constants that evaluate to a quadmesh variable.

The mesh over which expr is defined must be two-dimensional and rectilinear.

segment

Select a zone in the mesh, and show its neighbors. The number of neighbors to show is covered by the layers argument.

segment( exp r, zone, layer [, block] )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a mesh variable.

The mesh over which expr is defined must be three-dimensional.

zone is the zone number to use as the "seed zone." It is the zone from which neighboring zones will be calculated. layer in an integer that represents the level of zones from the seed zone. For example, if you want to see all the neighbors that share a vertex with the seed zone, layer would be 1. If you wanted to see all the neighbors that share vertices with the first layer, layer would be 2. block is an optional integer that represents which block the seed zone is in. If nothing is specified, no blocks are used.

sin

Sine

sin( expr )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a scalar value.

sin returns the sine of the expr as given in radians.

specmf

Species mass fraction

specmf( expr, material, species ) -or-

specmf(expr, material, species, use_vf)

expr evaluates to a species variable.

material and species can each be a a range of material/species numbers or the word all. A range of values is specified in the manner beg[:end[:skip]], where beg is the lowest number, end is the highest, and skip specifies the amount by which to skip.

With more than one material specified, the first form of this function will weight the mass fractions from each material by that material's volume fraction in that zone. With a single material specified, it will use the species mass fractions as-is.

For control over this decision, include the optional argument use_vf. With use_vf set to true, the function will always weight species mass fractions by their material's volume fraction in a zone. This allows correct summation of mass fractions from separate calls to specmf. To disable weighting, set this option to false.

sqrt

Square root

sqrt( expr ) as with abs

tan

Tangent

tan( expr )

expr can be an expression of variables, other defvar variables, and constants that evaluate to a scalar value.

tan returns the tangent of the expr as given in radians.

Description:

The defvar command defines new variables which can then be used in the same manner as variables from the data file. With no arguments, defvar simply lists all defined variables from the current MeshTV session. With one argument, defvar prints the current definition (if any) of the given variable to the terminal.

Examples:

defvar # Print all definitions

defvar myvar # Print the definition of myvar

defvar dnew reflect(d,xmin,ymin)

defvar pnew oslice(p,xx=10.)

defvar wow insel(reflect(oslice(d*(u^2 +
v^2),py=50.),xmin),1:150:2, 1:75)

defvar velocity {u,v}

defvar momentum {u,v}*mass

defvar momentum {u*mass,v*mass} # Same as the previous line

defvar sum a + (b - c)

defvar factor 3.1415926/180.

defvar x factor*sqrt(u^2 + v^2) + .25

defvar displace dispcoord(quadmesh2d, {coord0(quadmesh2d),
coord1(quadmesh2d)})

defvar spec1mat5 specmf(Spec,5,1)

defvar spec1and3 specmf(Spec,all,1:3:2)

defvar alloxygen specmf(Spec,5,6,true)+specmf(Spec,8,2,true)

defvar dp1 p - "/quad/p"

defvar dp2 p - "abc.silo:p"

defvar dp3 p - "/dir1/abc.silo:p"

See Also:

pickzone


Title | Previous | Next

MeshTV@viper.llnl.gov
Copyright © 1998, U.S. Department of Energy. All rights reserved.