Value function¶
A value function is a particular field 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 .
The creation of the ValueFunction object requires the function and the integer : the 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.
The use case illustrates the creation of a spatial (field) function from the function such as :
[1]:
from __future__ import print_function
import openturns as ot
import math as m
[2]:
# Create a mesh
N = 100
mesh = ot.RegularGrid(0.0, 1.0, N)
[3]:
# Create the function that acts the values of the mesh
g = ot.SymbolicFunction(['x1', 'x2'], ['x1^2', 'x1+x2'])
[4]:
# Create the field function
f = ot.ValueFunction(g, mesh)
[5]:
# Evaluate f
inF = ot.Normal(2).getSample(N)
outF = f(inF)
# print input/output at first mesh nodes
xy = inF
xy.stack(outF)
xy[:5]
[5]:
X0 | X1 | y0 | y1 | |
---|---|---|---|---|
0 | 0.6082016512187646 | -1.2661731022166567 | 0.3699092485452318 | -0.6579714509978921 |
1 | -0.43826561996041397 | 1.2054782008285756 | 0.192076753639286 | 0.7672125808681616 |
2 | -2.1813852346165143 | 0.3500420865302907 | 4.758441541802945 | -1.8313431480862237 |
3 | -0.3550070491856397 | 1.437249310140903 | 0.1260300049714952 | 1.0822422609552633 |
4 | 0.8106679824694837 | 0.79315601145977 | 0.6571825778011431 | 1.6038239939292538 |