File: plot_vertexvalue_function.py

package info (click to toggle)
openturns 1.26-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,708 kB
  • sloc: cpp: 261,605; python: 67,030; ansic: 4,378; javascript: 406; sh: 185; xml: 164; makefile: 101
file content (58 lines) | stat: -rw-r--r-- 1,565 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Vertex value function
=====================
"""

# %%
#
# A vertex value function
# :math:`f_{vertexvalue}: \mathcal{D} \times \mathbb{R}^d \rightarrow \mathcal{D} \times \mathbb{R}^q` is a
# particular field function that lets invariant the mesh of a field
# and defined by a function :math:`h : \mathbb{R}^n \times \mathbb{R}^d  \rightarrow \mathbb{R}^q` such that:
#
# .. math::
#    \begin{aligned} f_{vertexvalue}(\underline{t}, \underline{x})=(\underline{t}, h(\underline{t},\underline{x}))\end{aligned}
#
# Let's note that the input dimension of :math:`f_{vertexvalue}` still design the
# dimension of :math:`\underline{x}` : :math:`d`. Its output dimension is equal to :math:`q`.
#
# The creation of the *VertexValueFunction* object requires the
# function :math:`h` and the integer :math:`n`: the dimension of the
# vertices of the mesh :math:`\mathcal{M}`.
#
# This example illustrates the creation of a field from the function
# :math:`h:\mathbb{R}\times\mathbb{R}^2` such as:
#
# .. math::
#    \begin{aligned}
#       h(\underline{t}, \underline{x})=(t+x_1^2+x_2^2)
#    \end{aligned}
#

# %%
import openturns as ot


# %%
# Create a mesh
N = 100
mesh = ot.RegularGrid(0.0, 1.0, N)

# %%
# Create the function that acts the values of the mesh
h = ot.SymbolicFunction(["t", "x1", "x2"], ["t+x1^2+x2^2"])

# %%
# Create the field function
f = ot.VertexValueFunction(h, mesh)

# %%
# Evaluate f
inF = ot.Normal(2).getSample(N)
outF = f(inF)

# print input/output at first 10 mesh nodes
txy = mesh.getVertices()
txy.stack(inF)
txy.stack(outF)
txy[:10]