This page described:

Variable declaration

The declaration of variables in MFront has the following syntax:

keyword type variable1, variable2, ...; 

where:

Concerning the type of a variable, MFront also introduces a few type alias, described in Section 2, and some shorcuts which are now detailled.

Integers variables in template arguments

Integer template arguments can be defined using an integer or by a formula that may contains two kind of integer variables: integer constants and constexpr integer variables.

Integer constants

All integer constants, introduced by the @IntegerConstant keyword, can be used as template arguments.

@IntegerConstant Nss = 12;
...
@LocalVariable fsarray<Nss, real> τᶜ;

constexpr integers variables defined by behaviours

By default, MFront DSLs associated with behaviours automatically defines the following constexpr integers variables:

Tensorial objects automatically imported from TFEL/Math

The following types are automatically imported from TFEL/Math:

Those types have template parameters which specifies their size and the numeric type used.

The latter can be a quantity as discussed in the next paragraph.

The following declaration:

@StateVariable tfel::math::stensor<N, strain> evp;

is thus equivalent to:

@StateVariable stensor<N, strain> evp;

i.e. the tfel::math namespace can be obmitted.

As described in Section 2, this declaration is also equivalent to:

@StateVariable StrainStensor evp;

The quantity type

Quantities are scalars with units. They are supported if the @UseQt keyword has been used with the true argument.

They are represented by the quantity class which has up to eight template parameters.

The first template argument shall designate a floatting-point number type. As discussed in Section 2, real is in reality a type alias to the floatting point actually used by the calling solver and which is selected by the solver’ interface.

The next template arguments are integers which defines the unit associated with the quantity, following the internal system of units. In this system, a unit is decomposed as follows:

\[ kg^{i_{1}}\,m^{i_{2}}\,s^{i_{3}}\,A^{i_{4}}\,K^{i_{5}}\,cd^{i_{6}}\,mol^{i_{7}} \]

In MFront, units are thus defined by the seven integers \(i_{1}, \ldots \,i_{7}\). If one of this integer is not specified in the definition of a quantity, it is defaulted to \(0\).

The following declarations are thus equivalent:

Note that many aliases, described in Section 2, are provided by MFront to avoid direct usage of the quantity type.

The derivative_type alias

derivative_type is an alias to the type of derivative a mathematical object with respect to another. For example, the derivative of a symmetric tensor with respect to a tensor can be declared as follows:

@LocalVariable derivative_type<stensor<N,stress>,tensor<N,real>> K;

See Section 2 for the meaning of the stress type.

This declaration is equivalent to:

@LocalVariable t2tost2<N, stress> K;

The inverse_type alias

inverse_type is an alias the type of the inverse of its template argument. For example:

@LocalVariable inverse_type<time> f;

The result_type alias

result_type is an alias to the result of a binary operation.

@LocalVariable result_type<strain,time,OpDiv> de0;

The available operations are OpPlus, OpMinus, OpMult, and OpDiv.

Type aliases

If quantities are not used, all scalar types are a simple alias to the numeric type used. This statement can obviously be generalised to the other mathematical objects.

Scalar types

Vector types

Matrix types

Symmetric tensor types

Tensor types

Fourth order tensor types of the st2tost2 type

Encoding types of variables in exported metadata

For most interfaces, MFront exports metadata describing the types of the tensorial variables used by a behaviour, notably for behaviours.

Those metadata can be retrieved by various methods of the ExternalLibraryManager class, such as: getGenericBehaviourInitializeFunctionInputsTypes, getGenericBehaviourPostProcessingFunctionOutputsTypes, getUMATGradientsTypes, getUMATThermodynamicForcesTypes, etc.

The types of those variables are encoded as integers.

Those integers shall be intepreted as follows:

Example

Special case of higher order tensors

Higher order tensors are defined as derivative of lower order tensors.

For example, the fourth order tensor of type t2tost2<N,real> (derivative of a symmetric tensor with respect to an unsymmetric tensor) is associated with identifier 780 as 780 = 4 + (1 << 3) + (3 << 8).

Special case for tiny vectors

Tiny vectors defined by tvector<D, value_type> are encoded as:

Special case of tiny matrices

Tiny matrices defined by tmatrix<N, M, value_type> are encoded as: