G+Smo
25.01.0
Geometry + Simulation Modules
|
In this example we show how to read a geometry from a file, and how to analyze its properties and perform some basic operations.
First we include the library and use the gismo namespace.
Then we define our command line options. For example, we use the option -f
to set the path to the file that contains our geometry.
Then we read the input from the file that contains the geometry. In this example, we use the function gsFileData::getFirst() to read the first gsGeometry contained in the input xml
file.
We can then video-print the the geometry, together with its basis and coefficients:
as well its properties. Among others, we show here how to print the dimenstion of the parameter space, the dimension of the geometry, and the geometry support.
Moreover, we can evaluate the geometry and its 1st and 2nd derivaties at \(N\) given points \(\mathbf{u}_i\in\mathbb{R}^n\) for \(i = 1, \ldots, N\), and print the results. Let \(f: \mathbb{R}^n \to \mathbb{R}^m\), and \(f^{(j)}\) be the \(j\)-th component of function \(f\), for \(j = 1, \ldots, m\).
The function evaluation format is:
\[ \left[ \begin{array}{ccccc} f^{(1)}(\mathbf{u}_1) & f^{(1)}(\mathbf{u}_2) & \ldots & f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots\\ f^{(m)}(\mathbf{u}_1) & f^{(m)}(\mathbf{u}_2) & \ldots & f^{(m)}(\mathbf{u}_N)\\ \end{array} \right]. \]
The first derivative format is:
\[ \left[ \begin{array}{ccccc} \partial_{1}f^{(1)}(\mathbf{u}_1) & \partial_{1}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{1}f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots\\ \partial_{n}f^{(1)}(\mathbf{u}_1) & \partial_{n}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{n}f^{(1)}(\mathbf{u}_N)\\ \partial_{1}f^{(2)}(\mathbf{u}_1) & \partial_{1}f^{(2)}(\mathbf{u}_2) & \ldots & \partial_{1}f^{(2)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots\\ \partial_{n}f^{(2)}(\mathbf{u}_1) & \partial_{n}f^{(2)}(\mathbf{u}_2) & \ldots & \partial_{n}f^{(2)}(\mathbf{u}_N)\\ \partial_{1}f^{(m)}(\mathbf{u}_1) & \partial_{1}f^{(m)}(\mathbf{u}_2) & \ldots & \partial_{1}f^{(m)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots\\ \partial_{n}f^{(m)}(\mathbf{u}_1) & \partial_{n}f^{(m)}(\mathbf{u}_2) & \ldots & \partial_{n}f^{(m)}(\mathbf{u}_N) \end{array} \right]. \]
The second derivative format is:
\[ \left[ \begin{array}{ccccc} \partial_{1}\partial_{1}f^{(1)}(\mathbf{u}_1) & \partial_{1}\partial_{1}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{1}\partial_{1}f^{(1)}(\mathbf{u}_N)\\ \partial_{2}\partial_{2}f^{(1)}(\mathbf{u}_1) & \partial_{2}\partial_{2}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{2}\partial_{2}f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots \\ \partial_{n}\partial_{n}f^{(1)}(\mathbf{u}_1) & \partial_{n}\partial_{n}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{n}\partial_{n}f^{(1)}(\mathbf{u}_N)\\ \partial_{1}\partial_{2}f^{(1)}(\mathbf{u}_1) & \partial_{1}\partial_{2}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{1}\partial_{2}f^{(1)}(\mathbf{u}_N)\\ \partial_{1}\partial_{3}f^{(1)}(\mathbf{u}_1) & \partial_{1}\partial_{3}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{1}\partial_{3}f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots \\ \partial_{1}\partial_{n}f^{(1)}(\mathbf{u}_1) & \partial_{1}\partial_{n}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{1}\partial_{n}f^{(1)}(\mathbf{u}_N)\\ \partial_{2}\partial_{3}f^{(1)}(\mathbf{u}_1) & \partial_{2}\partial_{3}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{2}\partial_{3}f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots\\ \partial_{2}\partial_{n}f^{(1)}(\mathbf{u}_1) & \partial_{2}\partial_{n}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{2}\partial_{n}f^{(1)}(\mathbf{u}_N)\\ \partial_{3}\partial_{4}f^{(1)}(\mathbf{u}_1) & \partial_{3}\partial_{4}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{3}\partial_{4}f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots \\ \partial_{n-1}\partial_{n}f^{(1)}(\mathbf{u}_1) & \partial_{n-1}\partial_{n}f^{(1)}(\mathbf{u}_2) & \ldots & \partial_{n-1}\partial_{n}f^{(1)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots \\ \partial_{1}\partial_{1}f^{(m)}(\mathbf{u}_1) & \partial_{1}\partial_{1}f^{(m)}(\mathbf{u}_2) & \ldots & \partial_{1}\partial_{1}f^{(m)}(\mathbf{u}_N)\\ \vdots & \vdots & & \vdots \\ \partial_{n-1}\partial_{n}f^{(m)}(\mathbf{u}_1) & \partial_{n-1}\partial_{n}f^{(m)}(\mathbf{u}_2) & \ldots & \partial_{n-1}\partial_{n}f^{(m)}(\mathbf{u}_N)\\ \end{array} \right]. \]
Finally, we can export tesselations (meshes) as files for visualization in Paraview
and print the files in Paraview.
Here is the full file examples/geometry_example.cpp
. Clicking on a function or class name will lead you to its reference documentation.