MATH

The math routine operates on attributes of a mesh object(s). It performs arithmetic operations or evaluates mathematical functions on the source mesh object or objects, and places the results in the sink mesh object. The source and sink mesh objects can be the same, and there can be either one or two source objects, depending on the operation selected.

All attributes must have the same type, rank, and length.
The last parameter, value, may or may not be used according to the operation details listed below.
For the standard arithmetic operations, value can be either a constant or an attribute. These arithmetic operations work for all types of attributes.
For the mathematical functions other than floor and ceilingvalue is omitted, and the function is performed on the src_attr and stored in the sink_attr. Mathematical functions other than floor and ceiling are not implemented for attributes whose values are integers.

FORMAT:

math / operation / cmo_sink/attr_sink / range /cmo_src/attr_src / [ value ]

operation: The first parameter is one of the following keywords that indicates the type of work to perform.
plus, add, minus, sub, subtract, times,  multiply, mult, divide, min, max are arithmetic operators; the result is stored in sink_attr:
sink_attr = (src_attr) operator (value), where value can be either a numerical constant or a second mesh object attribute.
min, max
are not to be confused with the minimum or maximum value of an attribute; rather the the result is a comparison of pairs of source values.

sin, cos, tan, ln (natural log), and log10 are mathematical functions. The value parameter is omitted, and the function is performed on the src_attr and stored in the sink_attr. These functions are not implemented for integer attributes.

floor and ceiling are mathematical functions where value is used as the lower or upper limit, the value(s) of src_attr are checked against value, and the results are stored in the sink_attr. These functions work for all types of attributes.

power function uses both value parameters. The first value or src_attr is raised to the power of the second value or attribute. You cannot use two constants. At least one of the sources must be an attribute. The result is stored in the sink_attr.

exp and exp10 functions raise the constant e or the constant 10 to the power specified by src_attr and stores the result in the sink_attr.

<>integrate function computes the product of 'field_value 'times 'element volume' at each element and either saves these products or sums the products and saves the integrated result.
The syntax is: math/integrate/cmo_sink/attr_sink/range/attr_src_field<>
<>The 'field_value' for an element is either the value of attr_src (if the attr_src is an element attribute and has length 'nelements') or is the average of the values at the vertices of the element (if the attr_src is a node attribute has length 'nnodes').
If sink_attr does not exist or if it exists and has length 'nelements' and type 'VDOUBLE' the products (<> <>'field_value' times 'element_volume') are stored in sink_attr.
If sink_attr exists and has length 'scalar' and type 'REAL', then the products are summed up and the resulting sum if stored in sink_attr. (If the user requires just the integrated sum this alternative avoids having to use the pair of commands 'integrate, sum' and also avoids creating the 'nelement' long sink attribute)
It is assumed that the sink and source attributes are in the same mesh object and the second cmo name is ignored.
If range is used, it must refer to a set of elements.

sum adds all node or element values in attr_src, within the selected range and writes the result to attr_sink. The sink attribute must be of type 'REAL' or 'INT' (length='scalar') and will be created if it does not exist.


cmo_sink, attr_sink: are the sink cmo and sink attribute for the math results to be written to. These parameters are required for all math operations.

range: is the selection set of elements or nodes for the math operation and may be in one of these 3 forms:
/ifirst,ilast,istride / numbers indicating attribute set  (1,0,0 means all elements or nodes)
/pset,get, pset_name / for attributes with length = 'nnodes'  (all nodes in the named point set)
/eltset,get, eltset_name / for attributes with length = 'nelements' (all elements in the named element set)

value: is required by some math operations and can be of type constant or can be a cmo attribute. The following are possible forms:
/cmo_src2/attr_src2/ where cmo_src2 may be the same name as the source cmo, or the name of a second source cmo.
/attr_src2/ assumes attribute is a part of cmo_src
/constant/ is a numerical value


EXAMPLES:

math/multiply/sink_mo/sink_attribute/50,60,3/src_mo/src_attribute/1.0
math/add/mo/attribute/50,60,3/mo/attribute/100.0
math/sub/sink_mo/sink_attribute/50,60,3/src_mo1/src_attribute1/src_mo2/src_attribute2/
math/min/sink_mo/sink_attribute/1,0,0/src_mo1/src_attribute1/src_mo2/src_attribute2/
math/ln/sink_mo/sink_attribute/1,0,0/src_mo/src_attribute/
math/floor/sink_mo/sink_attribute/1,0,0/src_mo/src_attribute/2.0/
math/power/sink_mo/sink_attribute/1,0,0/src_mo/src_attribute/2.0/
math/power/sink_mo/sink_attribute/1,0,0/2.0/src_mo/src_attribute/
math/power/sink_mo/sink_attribute/1,0,0/base_mo/base_attribute/ power_mo/power_attr
math/exp/sink_mo/sink_attribute/1,0,0/src_mo/src_attribute/
math/exp10/sink_mo/sink_attribute/1,0,0/src_mo/src_attribute/
math/integrate/ cmotri /Vf /1,0,0/ cmotri/ Fn
math/sum/ cmotri / Vfsum /1,0,0/ cmotri / Vf
math/sum/ cmotri / area_sum /1,0,0/ cmotri / darea