Field

(Source code, png)

../../_images/Field.png
class Field(*args)

Base class for Fields.

Available constructors:

Field(mesh, dim)

Field(mesh, values)

Parameters:
meshMesh

Each vertice of the mesh is in \cD a domain of \Rset^n.

dimint

Dimension d of the values.

values2-d sequence of float of dimension d

The values associated to the vertices of the mesh. The size of values is equal to the number of vertices in the associated mesh. So we must have the equality between values.getSize() and mesh.getVerticesNumber().

Notes

A field F is an association between vertices and values:

F = (\vect{t}_i, \vect{v}_i)_{1 \leq i \leq N}

where the (\vect{t}_i)_{1 \leq i \leq N} are the vertices of a mesh of the domain \cD and (\vect{v}_i)_{1 \leq i \leq N} are the associated values.

Mathematically speaking, F is an element \cM_N \times (\Rset^d)^N where N is the number of vertices of the mesh \cM_N of the domain \cD \subset \Rset^n.

Examples

Create a field:

>>> import openturns as ot
>>> myVertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0], [2.0, 1.5], [0.5, 1.5]]
>>> mySimplicies = [[0,1,2], [1,2,3], [2,3,4], [2,4,5], [0,2,5]]
>>> myMesh = ot.Mesh(myVertices, mySimplicies)
>>> myValues = [[2.0],[2.5],[4.0], [4.5], [6.0], [7.0]]
>>> myField = ot.Field(myMesh, myValues)

Draw the field:

>>> myGraph = myField.draw()

Methods

asDeformedMesh(*args)

Get the mesh deformed according to the values of the field.

draw()

Draw the first marginal of the field if the input dimension is less than 2.

drawMarginal([index, interpolate])

Draw one marginal field if the input dimension is less than 2.

exportToVTKFile(fileName)

Create the VTK format file of the field.

getClassName()

Accessor to the object's name.

getDescription()

Get the description of the field values.

getId()

Accessor to the object's id.

getImplementation()

Accessor to the underlying implementation.

getInputDimension()

Get the dimension of the domain \cD.

getInputMean()

Get the input weighted mean of the values of the field.

getMarginal(*args)

Marginal accessor.

getMesh()

Get the mesh on which the field is defined.

getName()

Accessor to the object's name.

getOutputDimension()

Get the dimension d of the values.

getSize()

Get the number of values inside the field.

getTimeGrid()

Get the mesh as a time grid if it is 1D and regular.

getValueAtIndex(index)

Get the value of the field at the vertex of the given index.

getValues()

Get the values of the field.

norm()

Compute the (L^2) norm.

setDescription(description)

Set the description of the vertices and values of the field.

setName(name)

Accessor to the object's name.

setValueAtIndex(index, val)

Assign the value of the field to the vertex at the given index.

setValues(values)

Assign values to a field.

__init__(*args)
asDeformedMesh(*args)

Get the mesh deformed according to the values of the field.

Parameters:
verticesPaddingsequence of int

The positions at which the coordinates of vertices are set to zero when extending the vertices dimension. By default the sequence is empty.

valuesPaddingsequence of int

The positions at which the components of values are set to zero when extending the values dimension. By default the sequence is empty.

Returns:
deformedMeshMesh

The initial mesh is deformed as follows: each vertex of the mesh is translated by the value of the field at this vertex. Only works when the input dimension n: is equal to the dimension of the field d after extension.

draw()

Draw the first marginal of the field if the input dimension is less than 2.

Returns:
graphGraph

Calls drawMarginal(0, False).

See also

drawMarginal
drawMarginal(index=0, interpolate=True)

Draw one marginal field if the input dimension is less than 2.

Parameters:
indexint

The selected marginal.

interpolatebool

Indicates whether the values at the vertices are linearly interpolated.

Returns:
graphGraph
  • If the dimension of the mesh is n=1 and interpolate=True: it draws the graph of the piecewise linear function based on the selected marginal values of the field and the vertices coordinates (in \Rset).

  • If the dimension of the mesh is n=1 and interpolate=False: it draws the cloud of points which coordinates are (vertex, value of the marginal index).

  • If the dimension of the mesh is n=2 and interpolate=True: it draws several iso-values curves of the selected marginal, based on a piecewise linear interpolation within the simplices (triangles) of the mesh. You get an empty graph if the vertices are not connected through simplicies.

  • If the dimension of the mesh is n=2 and interpolate=False: if the vertices are connected through simplicies, each simplex is drawn with a color defined by the mean of the values of the vertices of the simplex. In the other case, it draws each vertex colored by its value.

exportToVTKFile(fileName)

Create the VTK format file of the field.

Parameters:
myVTKFilestr

Name of the output file. No extension is append to the filename.

Notes

Creates the VTK format file that contains the mesh and the associated values that can be visualised with the open source software Paraview .

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getDescription()

Get the description of the field values.

Returns:
descriptionDescription

Description of the vertices and values of the field, size n+d.

getId()

Accessor to the object’s id.

Returns:
idint

Internal unique identifier.

getImplementation()

Accessor to the underlying implementation.

Returns:
implImplementation

A copy of the underlying implementation object.

getInputDimension()

Get the dimension of the domain \cD.

Returns:
nint

Dimension of the domain \cD: n.

getInputMean()

Get the input weighted mean of the values of the field.

Returns:
inputMeanPoint

Weighted mean of the values of the field, weighted by the volume of each simplex.

Notes

The input mean of the field is defined by:

\displaystyle \frac{1}{V} \sum_{S_i \in \cM} \left( \frac{1}{n+1}\sum_{k=0}^{n} \vect{v}_{i_k}\right) |S_i|

where S_i is the simplex of index i of the mesh, |S_i| its volume and (\vect{v}_{i_0}, \dots, \vect{v}_{i_n}) the values of the field associated to the vertices of S_i, and \displaystyle V=\sum_{S_i \in \cD} |S_i|.

getMarginal(*args)

Marginal accessor.

Parameters:
iint or sequence of int

Index of the marginal.

Returns:
valueField.

Marginal field.

getMesh()

Get the mesh on which the field is defined.

Returns:
meshMesh

Mesh over which the domain \cD is discretized.

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getOutputDimension()

Get the dimension d of the values.

Returns:
dint

Dimension of the field values: d.

getSize()

Get the number of values inside the field.

Returns:
sizeint

Number N of vertices in the mesh.

getTimeGrid()

Get the mesh as a time grid if it is 1D and regular.

Returns:
timeGridRegularGrid

Mesh of the field when it can be interpreted as a RegularGrid. We check if the vertices of the mesh are scalar and are regularly spaced in \Rset but we don’t check if the connectivity of the mesh is conform to the one of a regular grid (without any hole and composed of ordered instants).

getValueAtIndex(index)

Get the value of the field at the vertex of the given index.

Parameters:
indexint

Vertex of the mesh of index index.

Returns:
valuePoint

The value of the field associated to the selected vertex, in \Rset^d.

getValues()

Get the values of the field.

Returns:
valuesSample

Values associated to the mesh. The size of the sample is the number of vertices of the mesh and the dimension is the dimension of the values (d).

norm()

Compute the (L^2) norm.

Returns:
normfloat

The field’s norm computed using the mesh weights.

setDescription(description)

Set the description of the vertices and values of the field.

Parameters:
myDescriptionDescription

Description of the field values. Must be of size n+d and give the description of the vertices and the values.

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setValueAtIndex(index, val)

Assign the value of the field to the vertex at the given index.

Parameters:
indexint

Index that characterizes one vertex of the mesh.

valuePoint in \Rset^d.

New value assigned to the selected vertex.

setValues(values)

Assign values to a field.

Parameters:
values2-d sequence of float

Values assigned to the mesh. The size of the values is the number of vertices of the mesh and the dimension is d.

Examples using the class

Estimate a spectral density function

Estimate a spectral density function

Estimate a stationary covariance function

Estimate a stationary covariance function

Export a field to VTK

Export a field to VTK

Create a white noise process

Create a white noise process

Manipulate a time series

Manipulate a time series

Use the Box-Cox transformation

Use the Box-Cox transformation

Draw a field

Draw a field

Sample trajectories from a Gaussian Process with correlated outputs

Sample trajectories from a Gaussian Process with correlated outputs

Draw fields

Draw fields

Create a discrete Markov chain process

Create a discrete Markov chain process

Create and manipulate an ARMA process

Create and manipulate an ARMA process

Trend computation

Trend computation

Validation of a Karhunen-Loeve decomposition

Validation of a Karhunen-Loeve decomposition

Estimate Sobol indices on a field to point function

Estimate Sobol indices on a field to point function