SMS:Dataset Calculator VTK

From XMS Wiki
Revision as of 15:33, 14 September 2017 by Jcreer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


The Dataset Calculator allows creating new datasets using mathematical expressions. The inputs for the mathematical expressions can be user defined constants, existing datasets, data derived from the geometry, or data derived from datasets such as gradients or activity information (0/1).

The dataset calculator expressions can include:

  • standard operations: + - * / ^ .
  • build unit vectors: iHat, jHat, kHat (ie (1,0,0), (0,1,0), (0,0,1))
  • abs
  • acos
  • asin
  • atan
  • ceil
  • cos
  • cosh
  • exp
  • floor
  • log
  • mag
  • min
  • max
  • norm
  • sign
  • sin
  • sinh
  • sqrt
  • tan
  • tanh

Expressions

In the top left of the dialog, there are fields for name and expression. The name specified will become the dataset name. The expression defines the mathematical operation that will take place. Insert a predefined function into the expression field using the "Insert f(x)" combo-box. The specified function will be pasted into the current cursor location in the expression field and will include an indication of the number of values expected.

SMS maintains a list of expressions currently defined. Specifying a name and expression and clicking "Add" will add an expression to the list of expressions. If selecting an expression from the list of expressions, the name and expression fields will be populated. Make the current list of expressions the default list by saving settings (File | Save settings from the main menu). Move the expressions to another computer or user by using the save and load buttons.

Variables

When the expression field is modified, SMS will parse the expression to find variable names in the expression. A variable must start with a character but can include digits after the first character. "Var1" would be valid but "1Var" would not. The list of variables determined by SMS will appear in a spreadsheet in the top right of the dialog. Each variable has a name, type, and source information. The name is parsed from the expression field and cannot be edited in the spreadsheet. The type can be chosen from the spreadsheet. The source information defines the options used which vary by variable type and cannot be edited in the spreadsheet. Beneath the variables spreadsheet are controls to specify the source information for the currently selected variable. The controls that will be available will depend upon the variable type.

The simplest variable type is a value. While it is possible to include numeric values in the expression field, it can be more clear to name specific variables. For example, if wanting to have an expression use a variable named "gravity" that is specified as a value variable. This makes the expression more readable and helps remind people to change this if working in a different set of units or similar situation.

Another type of variable is a dataset. This will use the specified dataset anywhere the variable shows up in the expression. Note that both scalar and vector datasets can be used in an expression.

The final type of variable are "Derived" variables. Derived variables can be based upon one of three different sources. They can be based upon node geometry, cell geometry, or datasets. Derived nodal options include location (3D vector) and nodal spacing (average spacing to neighboring nodes). Derived cell options include area, centroid (3D vector), extents minimum (3D vector), extents maximum (3D vector), and perimeter. Derived dataset values include activity (0/1 for each node/cell for each timestep), directional derivative (vector representation of the gradient), and vector angle (in the cartesian coordinate system used in math).

Output Location

Datasets in VTK can be associated with nodes or cells. When using the dataset calculator, specify if the dataset created is to be associated with nodes or cells. If the use doesn't specify the output location, SMS will decide based upon the variables used in the expression. With the exception of values, each variable will have an affinity to nodes or cells. If any variable has affinity to nodes, SMS will default the output to be based upon nodes. If all the input variables have an affinity to cells, the output will be a cell based dataset. The variable affinity is generally intuitive: dataset variables use dataset, derived variables come from whether they are node, cell, or dataset derived. One exception to the intuitive rule is "directional derivative" which is derived from datasets. This variable will have an affinity opposite of the input dataset. If the input dataset is nodes, the directional derivative will be computed on cells.

Whenever input data has an affinity opposite to the output location, the data is converted before the expression is evaluated. Generally, this means that the value for each node or cell (whichever conversion is taking place) is determined by averaging the surrounding values (connected cells or nodes belong to the cell). The exception to this rule is activity which is never averaged. A node is considered active if any of the surrounding cells is active.

Working with Scalars/Vectors

As mentioned previously, an expression may contain both scalar and vector components. The result of an expression may also be either a scalar or vector dataset. Some sub-expressions can be used with either type of dataset. For example to multiply a value by either a scalar or vector dataset. Each component in the vector dataset will have the multiplication applied. Other sub-expressions only make sense when dealing with a certain type of input dataset. The "." operator can be used to compute the dot product of two vectors and doesn't make sense for scalar datasets. The identifier iHat can be used to create a unit vector in the x direction (1.0, 0.0, 0.0). Use the dot operator to extract the x component of a vector using an expression like: "myvector.iHat". jHat and kHat can be used similarly to extract y and z components. It is also possible to convert components into vectors using statements similar to: "vx*iHat + vy*jHat." The mag function extracts the magnitude of a vector and also does not apply to scalar datasets.

Output Times

By default the output dataset will have times corresponding to any time used in any of the input datasets. If all the input datasets are steady state datasets, the output dataset will be steady state. Specify specific output times for the output dataset. This can be useful to reduce the number of timesteps that would be generated or focus on a range of times. If all the input datasets are steady state and output times are specified, the resulting dataset will have multiple timesteps each with the exact same values. If an input dataset doesn't have a timestep at an output time, the data will be interpolated between the nearest timesteps. If the time occurs outside the range covered by the dataset, the nearest dataset time will be used.

Errors

If there is a problem with the expression entered, SMS will give an error message and allow correcting the problem. If the problem is with the expression itself, the message should indicate about where the problem exists. The position may be off slightly so examine the whole expression carefully if the cause isn't immediately apparent.

Related Topics