1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#! /usr/bin/env python
import openturns as ot
ot.TESTPREAMBLE()
mesh = ot.RegularGrid(0.0, 0.1, 11)
def f(X):
size = 11
Y = [ot.Point(X) * i for i in range(size)]
return Y
inputDim = 2
outputDim = 2
function = ot.PythonPointToFieldFunction(inputDim, mesh, outputDim, f)
function.setInputDescription(["u1", "u2"])
function.setOutputDescription(["v1", "v2"])
# freeze u1=5.0
parametric = ot.ParametricPointToFieldFunction(function, [0], [5.0])
# properties
print("dim=", parametric.getInputDimension(), parametric.getOutputDimension())
print(
"description=", parametric.getInputDescription(), parametric.getOutputDescription()
)
print("mesh=", parametric.getOutputMesh())
# op(Point)
x = [1.0]
y = parametric(x)
print("y=", y)
print("calls=", parametric.getCallsNumber())
# op(Sample)
X = [[1.0], [7.0]]
Y = parametric(X)
print("Y=", Y)
print("calls=", parametric.getCallsNumber())
|