MFront
This page described:
MFront
.MFront
.The declaration of variables in MFront
has the following
syntax:
, variable2, ...; keyword type variable1
where:
keyword
allows to specify the kind of variables
declared. The keywords associated with type declaration may depend on
the domain specific language used. For example, most DSLs associated
with behaviours, allow the @MaterialProperty
,
@Parameter
, @LocalVariable
,
@StateVariable
, @AuxiliaryStateVariable
keywords to introduce a new variable.type
declares the type of the (C++
)
variable. Any C++
type may be used, although there may be
limitations specifics to the kind of variables being treated or the
interfaces used:
variable1
,
variable2
, etc…) are restricted to be valid
C++
variables names, although unicode symbols may be used
as described on this page.Concerning the type of a variable, MFront
also
introduces a few type alias, described in Section 2, and some shorcuts
which are now detailled.
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.
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 behavioursBy default, MFront
DSLs associated with behaviours
automatically defines the following constexpr
integers
variables:
N
: the space dimensionTVectorSize
: the natural size of a tiny vector, equal
to the space dimension.StensorSize
: the natural size of a symmetric tensor for
the space dimension N
, i.e.:
1D
.2D
.3D
.TensorSize
: the natural size of a tensor for the space
dimension N
, i.e.:
1D
.2D
.3D
.TFEL/Math
The following types are automatically imported from
TFEL/Math
:
fsarray
: a generic fixed size container.tvector
: a class which represents fixed size
vectors.tmatrix
: a class which represents fixed size
matrices.stensor
: a class which represents symmetric
tensors.tensor
: a class which represents unsymmetric
tensors.st2tost2
: a class which represents linear operations
between symmetric tensors.t2tot2
: a class which represents linear operations
between unsymmetric tensors.t2tost2
: a class which represents linear operations
transforming an unsymmetric tensor in a symmetric tensor.st2tot2
: a class which represents linear operations
transforming a symmetric tensor in an unsymmetric tensor.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;
quantity
typeQuantities 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:
@LocalVariable length l;
(see Section 2)@LocalVariable quantity<real,0,1> l;
Note that many aliases, described in Section 2, are provided by
MFront
to avoid direct usage of the quantity
type.
derivative_type
aliasderivative_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;
inverse_type
aliasinverse_type
is an alias the type of the inverse of its
template argument. For example:
@LocalVariable inverse_type<time> f;
result_type
aliasresult_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
.
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.
real
: the numeric type used.time
: a scalar with the dimension of a time.frequency
: a scalar with the dimension of a
frequency.length
: a scalar with the dimension of a lenght.inv_length
: a scalar with the dimension of the inverse
of a length.displacement
: a scalar with the dimension of a
lenght.strain
: a scalar without dimension.strainrate
: a scalar with the dimension of a
frequency.force
: a scalar with the dimension of a force.stress
: a scalar with the dimension of a stress.stressrate
: a scalar with the dimension of a stress
divided by a time.temperature
: a scalar with the dimension of a
temperature.thermalexpansion
: a scalar representing a thermal
expansion coefficient with the dimension of the inverse of a
temperature.massdensity
: a scalar with the dimension of a mass
divided by a volume.energydensity
: a scalar with the dimension of an energy
divided by a volume.speed
: a scalar with the dimension of an length divided
by a time.thermalconductivity
: a scalar with the dimension of
power divided by a length, a time and a temperature. In the
International System of Units, the thermalconductiviy is measured in
watts per meter-kelvin (\(W/(m\,K)\)).TVector
:ForceTVector
:DisplacementTVector
:HeatFlux
:ThermalConductivityMatrix
:Stensor
:FrequencyStensor
:StressStensor
:StressRateStensor
:StrainStensor
:StrainRateStensor
:ThermalExpansionCoefficientTensor
:Tensor
:FrequencyTensor
:StressTensor
:DeformationGradientTensor
:DeformationGradientRateTensor
:st2tost2
typeStensor4
: fourth order tensor type for the current
modelling hypothesis holding the current numeric type (no unit).StiffnessTensor
: fourth order tensor type for the
current modelling hypothesis holding stress values.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:
0
denotes a scalar1
denotes a symmetric tensor2
denotes a vector3
denotes an unsymmetric tensor4
denotes a derivative function5
denotes an array of objects0
indicates that the space dimension depends on the
modelling hypothesis considered.1
indicates that the object has a space dimension of
1
, indepently of the modelling hypothesis considered.2
indicates that the object has a space dimension of
2
, indepently of the modelling hypothesis considered.3
indicates that the object has a space dimension of
3
, indepently of the modelling hypothesis considered.0
denotes a scalar17
denotes a two-dimensional symmetric tensorHigher 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)
.
Tiny vectors defined by tvector<D, value_type>
are
encoded as:
D
is compatible with the size of
a tensorial object (i.e. D
has the value N
or
if D
has an integer value in the range [1;3]
)
and if value_type
is a scalar type.Tiny matrices defined by tmatrix<N, M, value_type>
are encoded as:
N
and M
can represent the size of a tensorial object and if
value_type
is a scalar type.