Note
Click here to download the full example code
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 :
from __future__ import print_function
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
import math as m
ot.Log.Show(ot.Log.NONE)
Create a mesh
N = 100
mesh = ot.RegularGrid(0.0, 1.0, N)
Create the function that acts the values of the mesh
g = ot.SymbolicFunction(['x1', 'x2'], ['x1^2', 'x1+x2'])
Create the field function
f = ot.ValueFunction(g, mesh)
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]
X0 | X1 | y0 | y1 | |
---|---|---|---|---|
0 | 0.595711 | 0.479533 | 0.3548715 | 1.075244 |
1 | -1.916242 | 0.8543916 | 3.671985 | -1.061851 |
2 | -0.750542 | -0.04730826 | 0.5633132 | -0.7978502 |
3 | -1.220656 | -0.2129773 | 1.49 | -1.433633 |
4 | -0.09821222 | 0.5049109 | 0.009645641 | 0.4066986 |
Total running time of the script: ( 0 minutes 0.002 seconds)