## MATH

The **math** routine operates attributes of a mesh object. It performs
arithmetic operations or 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 function 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. The operation is performed as sink_attr = (src_attr) operator (value). These operations work for all types of attributes.

For the mathematical functions other than **floor** and **ceiling**,
the value is omitted, the function is performed on the src_attr and
stored in the sink_attr. These functions are not implemented for
attributes whose values are integers.

**FORMAT:**

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

operation: The keyword choices for the first parameter indicate the arithmetic, functional, or operational types of work to perform.

**plus, add, minus, sub, subtract, times, divide, multiply** or
**mult** are arithmetic operations and take the form of

sink_attr = (src_attr) operator (value)

where value can be either a numerical constant or a mesh object attribute.

**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 attributes whose values are
integers.

**floor** and **ceiling** are mathematical functions where value
parameter is used as the lower or upper limit, the value(s) of
src_attr are checked against this 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** operation is used to integrate a field value over
elements. Given a scalar function f(x,y,z), compute the integral I =
Int f dV over each element and put the result into the element array
(i.e. multiply the volume of the element by the value of the field for
that element).

The syntax is: **math/integrate**/
cmo_sink/attr_sink_face/range/attr_src_field

It is assumed that the sink and source attributes are in the same mesh object and the second cmo name is ignored for this operation. The field value for an element is either the element value (if the source attribute has length nelements) or is the average of the values at the vertices of the element (if the source attribute has length nnodes). The sink attribute will be created as a vector type nelements in length if it does not exist. If the sink attribute exists and is type REAL, then the sum of the element integrals is computed and saved in the sink attribute. If range is used, it must refer to a set of elements. idebug levels change at 1 5 and 9 with idebug greater than 9 producing the most output and 1 the least.

**sum** operation 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=1, rank=1) 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 is in the form:

/ifirst,ilast,istride / numbers indicating attribute set

**/pset,get**, pset_name / for attributes with length = ‘nnodes’

**/eltset,get**, eltset_name / for attributes with length =
‘nelements’

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** **/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