Tensor Operators and Other Operators
All Expression fields supports tensor variables and operators for tensors. If you, for example, want the cross product between two vectors, simply type
directly in the Expression field. The symbol for the cross product is among the standard mathematical symbols defined by the Unicode standard. Other special symbols used by expressions are the (inner) dot product, A · B, and the nabla operator, A. The system font must support the special symbols to display them properly; otherwise, the expression might not look correct. It is always possible to copy-paste them from an editor that supports Unicode input or directly from a Unicode character map.
There are also some functions that you can use to perform tensor operations — for example, the transpose of a matrix or the inverse of a matrix.
The following table lists the operator symbols and operations that the tensor parser supports.
or cross(a,b)
or dot(a,b)
a : b
a or gradient(a)
or divergence(a)
or curl(a)
or transpose(a)
Let r = {x,y,z}
f(r.1..n)
becomes f(x,y,z)
g(r.1..2)
becomes g(x,y)
Let M be a matrix that is symmetric, M = {{u*u, u*v, u*w}, {v*u, v*v, v*w}, {w*u, w*v, w*w}}. Symmetry cannot be detected because v*u is different than u*v by string comparison. The symmetric operator forces symmetry: symmetric(M) = {{u*u, u*v, u*w} , {u*v, v*v, v*w} , {u*w, v*w, w*w}}
Let r = {r,phi,z} in 2D axial symmetry
Let r = {r,phi,z} in 2D axial symmetry
(a+b)*2*pi*r in 2D axial symmetry
(a+b)*ie1.detInvT for an infinite element domain
Let T0 be a global parameter set to 300K,
evalConst(k_B_const*T0/e_const) becomes 0.025851997154882865
evalConst(1[µm]) becomes 1e-6 if the base unit is meter.
Let u be a vector-valued dependent variable with components u, v, and w and the coordinate names x, y, and z. Then
The double dot product is a summation over two indices:
Unfortunately, there are two definitions of the double dot product, and the above is referred to the Frobenius inner product or the colon product. The other definition has flipped order for the indices in the second factor
The former definition is used by the tensor parser.
The gradient operator can be suffixed with s, m, g, or M to specify in regard to which coordinate variables (spatial, material, geometry, or mesh frame, respectively) it should take its derivatives. Example .m.u is the gradient of the variable u in the material frame.
The eval operator makes it possible to control the evaluation context locally in an expression. The operator must be preceded by one of the frame prefixes: M (mesh), g (geometry), m (material), and s (spatial). The eval operator can, for example, be used in the subnode definition of a variable declaration to provide an automatic transform for all frames but one. Assume that you have a declaration on all frames for a variable named A. The definition subnode of this declaration has the expression m.eval(A), which means that the evaluation context is locally changed to the material frame. The evaluation in that frame will always pick up the declaration in the material frame, [AX, AY, AZ] and then transform it to the frame of the evaluation context of the definition. This results in three definitions for each of the declarations, where the definitions for geometry and spatial will have an automatic transform using the material variable. The definition of the material variable, on the other hand, will have a circular reference to itself. This last definition has to be replaced with a separate Variable Definition node on the same selection with a explicit definition (for example, a shape definition).
Substitution Operator for Replacing Model Inputs
The subst operator, mat.subst can replace model inputs inside expressions of material properties. The syntax is as follows:
mat.subst(<material_property>, <model_input_1>, <replacement_1>, ..., <model_input_N>, <replacement_N>)
The first argument must be the name of a material property with or without the mat prefix. If the prefix is missing, it will be automatically added to the given name. The model input arguments are either variable names or field names of model inputs (for example, T or temperature) with or without the minput prefix. Again, the prefix will be added if missing. The replacements arguments are parsed as ordinary expressions and must match the tensor size of the model input argument it belongs to.
An example of the use of this operator:
Assume that the material property for density, rho, has the expression rho(T, pA). The statement
mat.subst(rho,T,300[K],electricfield,{1,0,0}[V/m])
will result in the final expression
rho(300[K],comp1.id.id1.minput_pressure)
where the last argument is the internal model input variable name for pressure. The temperature has been replaced, and the electric field is ignored.
Frame Operators
The following operators are available for checking variables with respect to frames:
The hasSameFrame(var1, var2, ..., varN) operator returns 1 (true) if all variables (names or expressions) are defined on equivalent frames (that is, the same frame or different frames if there is no transformation between them). Otherwise, it returns 0 (false).
The hasMovingFrame(var) operator returns 1 (true) if var has been declared in a moving frame (such as a frame driven by an ALE method). Otherwise, it returns 0 (false).