FieldFunction

class FieldFunction(*args)

Function mapping a field to a field.

Available constructors:
FieldFunction(spatialDim, inputDim, outputDim)
Parameters:

spatialDim : int, \geq 1

Dimension n of the domain \cD

inputDim : int, \geq 1

Dimension d of the input field values

outputDim : int, \geq 1

Dimension d' of the output field values

Notes

Field functions act on fields to produce fields:

f: \left| \begin{array}{rcl}
            \cM_N \times (\Rset^d)^N & \rightarrow & \cM_{N'} \times (\Rset^{d'})^{N'} \\
            F & \mapsto & F'
          \end{array} \right.

with \cM_N a mesh of \cD \subset \Rset^n, \cM_{N'} a mesh of \cD' \subset \Rset^{n'}.

A field is represented by a collection (\vect{t}_i, \vect{v}_i)_{1 \leq i \leq N} of elements of \cM_N \times (\Rset^d)^N where \vect{t}_i is a vertex of \cM_N and \vect{v}_i the associated value in \Rset^d.

The constructor builds an object which evaluation operator is not defined (it throws a NotYetImplementedException). The instanciation of such an object is used to extract an actual FieldFunction from a Study.

Examples

>>> import openturns as ot

Using the class OpenTURNSPythonFieldFunction allows to define a persistent state between the evaluations of the function.

>>> class FUNC(ot.OpenTURNSPythonFieldFunction):
...     def __init__(self):
...         # first argument:
...         super(FUNC, self).__init__(2, 2, 1)
...         self.setInputDescription(['R', 'S'])
...         self.setOutputDescription(['T', 'U'])
...     def _exec(self, X):
...         Y = ot.Field(X.getMesh(), X.getValues() * ([2.0]*X.getValues().getDimension()))
...         return Y
>>> F = FUNC()

Create the associated FieldFunction:

>>> myFunc = ot.FieldFunction(F)

It is also possible to create a FieldFunction from a python function as follows:

>>> def myPyFunc(X):
...     mesh = X.getMesh()
...     values = X.getValues() * ([2.0]*X.getValues().getDimension())
...     values.setDescription(ot.Description.BuildDefault(values.getDimension(), 'Y'))
...     Y = ot.Field(mesh, values)
...     return Y
>>> inputDim = 2
>>> outputDim = 2
>>> spatialDim = 1
>>> myFunc = ot.PythonFieldFunction(inputDim, outputDim, spatialDim, myPyFunc)

Evaluate the function on a field:

>>> X = ot.Field(ot.RegularGrid(0.0, 0.1, 11), ot.Normal(2).getSample(11))
>>> Y = myFunc(X)

Methods

__call__(…) <==> x(…)
getCallsNumber() Get the number of calls of the function.
getClassName() Accessor to the object’s name.
getId() Accessor to the object’s id.
getImplementation(*args) Accessor to the underlying implementation.
getInputDescription() Get the description of the input field values.
getInputDimension() Get the dimension of the input field values.
getMarginal(*args) Get the marginal(s) at given indice(s).
getName() Accessor to the object’s name.
getOutputDescription() Get the description of the output field values.
getOutputDimension() Get the dimension of the output field values.
getOutputMesh(inputMesh) Get the mesh associated to the output domain.
getSpatialDimension() Get the dimension of the input domain.
setName(name) Accessor to the object’s name.
__init__(*args)

x.__init__(…) initializes x; see help(type(x)) for signature

getCallsNumber()

Get the number of calls of the function.

Returns:

callsNumber : int

Counts the number of times the function has been called since its creation.

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getImplementation(*args)

Accessor to the underlying implementation.

Returns:

impl : Implementation

The implementation class.

getInputDescription()

Get the description of the input field values.

Returns:

inputDescription : Description

Description of the input field values.

getInputDimension()

Get the dimension of the input field values.

Returns:

d : int

Dimension d of the input field values.

getMarginal(*args)

Get the marginal(s) at given indice(s).

Parameters:

i : int or list of ints, 0 \leq i < d'

Indice(s) of the marginal(s) to be extracted.

Returns:

fieldFunction : FieldFunction

The initial function restricted to the concerned marginal(s) at the indice(s) i.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getOutputDescription()

Get the description of the output field values.

Returns:

outputDescription : Description

Description of the output field values.

getOutputDimension()

Get the dimension of the output field values.

Returns:

d’ : int

Dimension d' of the output field values.

getOutputMesh(inputMesh)

Get the mesh associated to the output domain.

Returns:

outputMesh : Mesh

The output mesh \cM_{N'}.

getSpatialDimension()

Get the dimension of the input domain.

Returns:

spatialDim : int,

Dimension n of the input domain \cD.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.