SpatialFunction¶

class SpatialFunction(*args)

Spatial function.

Available constructors:

SpatialFunction(meshDimension=1)

SpatialFunction(g, meshDimension=1)

Parameters: Function . meshDimension : int, Dimension of the vertices of the mesh . This data is required for tests on the compatibility of dimension when a composite process is created using the spatial function.

Notes

A spatial function , with , is a particular dynamical function that lets invariant the mesh of a field and defined by a function such that:

Let’s note that the input dimension of still designs the dimension of : . Its output dimension is equal to .

Examples

>>> import openturns as ot


Create a function such as:

>>> g = ot.NumericalMathFunction('x', 'x^2')


Convert into a spatial function with the dimension of the mesh of the field on which will be applied:

>>> n = 1
>>> mySpatialFunction = ot.SpatialFunction(g, n)
>>> # Create a TimeSeries
>>> tg = ot.RegularGrid(0.0, 0.2, 6)
>>> data = ot.NumericalSample(tg.getN(), g.getInputDimension())
>>> for i in range(data.getSize()):
...     for j in range(data.getDimension()):
...         data[i, j] = i * data.getDimension() + j
>>> ts = ot.TimeSeries(tg, data)
>>> print(ts)
[ t   v0  ]
0 : [ 0   0   ]
1 : [ 0.2 1   ]
2 : [ 0.4 2   ]
3 : [ 0.6 3   ]
4 : [ 0.8 4   ]
5 : [ 1   5   ]
>>> print(mySpatialFunction(ts))
[ t              outputVariable ]
0 : [  0              0             ]
1 : [  0.2            1             ]
2 : [  0.4            4             ]
3 : [  0.6            9             ]
4 : [  0.8           16             ]
5 : [  1             25             ]


Methods

 __call__(inFld) getCallsNumber() Get the number of calls of a DynamicalFunction. getClassName() Accessor to the object’s name. getEvaluation() Get the evaluation function of . getId() Accessor to the object’s id. getInputDescription() Get the description of the inputs. getInputDimension() Get the dimension of the input. getMarginal(*args) Get the marginal(s) at given indice(s). getName() Accessor to the object’s name. getOutputDescription() Get the description of the outputs. getOutputDimension() Get the dimension of the output. getOutputMesh(inputMesh) Get the mesh associated to the output process. getShadowedId() Accessor to the object’s shadowed id. getSpatialDimension() Get the dimension of the mesh. getVisibility() Accessor to the object’s visibility state. hasName() Test if the object is named. hasVisibleName() Test if the object has a distinguishable name. setInputDescription(inputDescription) Set the description of the inputs. setName(name) Accessor to the object’s name. setOutputDescription(outputDescription) Set the description of the outputs. setShadowedId(id) Accessor to the object’s shadowed id. setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)
getCallsNumber()

Get the number of calls of a DynamicalFunction.

Returns: callsNumber : int Counts the number of times the DynamicalFunction has been called since its creation.
getClassName()

Accessor to the object’s name.

Returns: class_name : str The object class name (object.__class__.__name__).
getEvaluation()

Get the evaluation function of .

Returns: Evaluation function of .

Examples

>>> import openturns as ot
>>> g = ot.NumericalMathFunction('x', 'x^2')
>>> n = 1
>>> mySpatialFunction = ot.SpatialFunction(g, n)
>>> print(mySpatialFunction.getEvaluation())
[x]->[x^2]

getId()

Accessor to the object’s id.

Returns: id : int Internal unique identifier.
getInputDescription()

Get the description of the inputs.

Returns: inputDescription : Description Describes the inputs of the dynamical function.
getInputDimension()

Get the dimension of the input.

Returns: d : int Input dimension of the dynamical function.
getMarginal(*args)

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

Parameters: i : int or list of ints, Indice(s) of the marginal(s) needed. is the dimension of the DynamicalFunction. dynamicalFunction : DynamicalFunction DynamicalFunction restricted to the concerned marginal(s) at the indice(s) of the dynamical function .
getName()

Accessor to the object’s name.

Returns: name : str The name of the object.
getOutputDescription()

Get the description of the outputs.

Returns: outputDescription : Description Describes the outputs of the dynamical function.
getOutputDimension()

Get the dimension of the output.

Returns: q : int Output dimension of the dynamical function.
getOutputMesh(inputMesh)

Get the mesh associated to the output process.

Returns: outputMesh : Mesh The mesh of the output process.
getShadowedId()

Accessor to the object’s shadowed id.

Returns: id : int Internal unique identifier.
getSpatialDimension()

Get the dimension of the mesh.

Returns: spatialDimension : int, Dimension of the mesh .
getVisibility()

Accessor to the object’s visibility state.

Returns: visible : bool Visibility flag.
hasName()

Test if the object is named.

Returns: hasName : bool True if the name is not empty.
hasVisibleName()

Test if the object has a distinguishable name.

Returns: hasVisibleName : bool True if the name is not empty and not the default one.
setInputDescription(inputDescription)

Set the description of the inputs.

Parameters: inputDescription : sequence of str Describes the inputs of the dynamical function.
setName(name)

Accessor to the object’s name.

Parameters: name : str The name of the object.
setOutputDescription(outputDescription)

Set the description of the outputs.

Parameters: outputDescription : sequence of str Describes the outputs of the dynamical function.
setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters: id : int Internal unique identifier.
setVisibility(visible)

Accessor to the object’s visibility state.

Parameters: visible : bool Visibility flag.