OpenTURNSPythonFieldFunction

class OpenTURNSPythonFieldFunction(inputMesh, inputDim, outputMesh, outputDim)

Override FieldFunction from Python.

Parameters:
inputMeshMesh

The input mesh

inputDimint, \geq 1

Dimension d of the values of the input field

outputMeshMesh

The output mesh

outputDimint, \geq 1

Dimension d' of the values of the output field

Methods

getInputDescription()

Accessor to the description of the input field values of the function.

getInputDimension()

Accessor to the dimension of the input field values of the function.

getInputMesh()

Accessor to the mesh of the input field of the function.

getOutputDescription()

Accessor to the description of the output field values of the function.

getOutputDimension()

Accessor to the dimension of the output field values.

getOutputMesh()

Accessor to the mesh of the output field of the function.

setInputDescription(descIn)

Accessor to the description of the input field values of the function.

setOutputDescription(descOut)

Accessor to the description of the output field values of the function.

Notes

A OpenTURNSPythonFieldFunction acts 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} and \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}.

At least, you have to overload the function:

_exec(X): single evaluation, X is a Field. It returns a Field.

Examples

For example, we create the function which maps a field to another field sharing the same mesh and such that each value \vect{x} of the input field is mapped into 2\vect{x}.

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

Create the associated FieldFunction:

>>> myFunc = ot.FieldFunction(F)
__init__(inputMesh, inputDim, outputMesh, outputDim)
getInputDescription()

Accessor to the description of the input field values of the function.

Returns:
descInsequence of str

The description of the input field values of the function.

getInputDimension()

Accessor to the dimension of the input field values of the function.

Returns:
inputPointDimint

The dimension of the input field values of the function \inputDim.

getInputMesh()

Accessor to the mesh of the input field of the function.

Returns:
inputMeshint

The mesh of the input field of the function.

getOutputDescription()

Accessor to the description of the output field values of the function.

Returns:
descInsequence of str

The description of the output field values of the function.

getOutputDimension()

Accessor to the dimension of the output field values.

Returns:
outputFieldDimint

The dimension of the output field values d'.

getOutputMesh()

Accessor to the mesh of the output field of the function.

Returns:
outputMeshint

The mesh of the output field of the function.

setInputDescription(descIn)

Accessor to the description of the input field values of the function.

Parameters:
descInsequence of str

The description of the input field values of the function.

setOutputDescription(descOut)

Accessor to the description of the output field values of the function.

Parameters:
descInsequence of str

The description of the input field values of the function.

Examples using the class

Metamodel of a field function

Metamodel of a field function