.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_functional_modeling_field_functions_plot_vertexvalue_function.py:
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}
.. code-block:: default
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
.. code-block:: default
N = 100
mesh = ot.RegularGrid(0.0, 1.0, N)
Create the function that acts the values of the mesh
.. code-block:: default
h = ot.SymbolicFunction(['t', 'x1', 'x2'], ['t+x1^2+x2^2'])
Create the field function
.. code-block:: default
f = ot.VertexValueFunction(h, mesh)
Evaluate f
.. code-block:: default
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]
.. raw:: html
| t | X0 | X1 | y0 |
0 | 0 | 0.9387123 | 0.3737019 | 1.020834 |
1 | 1 | -0.450642 | -0.02880025 | 1.203908 |
2 | 2 | -0.5263226 | 0.5003629 | 2.527378 |
3 | 3 | -1.794296 | 0.6534551 | 6.646503 |
4 | 4 | 0.257082 | -0.5985328 | 4.424333 |
5 | 5 | 1.538375 | -2.040349 | 11.52962 |
6 | 6 | -0.3003127 | -0.3696585 | 6.226835 |
7 | 7 | 0.4155438 | -0.06083329 | 7.176377 |
8 | 8 | 1.205391 | -1.452755 | 11.56346 |
9 | 9 | -1.157649 | -0.9877864 | 11.31587 |
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 0.002 seconds)
.. _sphx_glr_download_auto_functional_modeling_field_functions_plot_vertexvalue_function.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_vertexvalue_function.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_vertexvalue_function.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_