.. _mesh: Mesh ==== Computer simulations work well using a discretized space, this discretization of the space is the result of the mesh generation process of a CAD model. Over-all the mesh data structure is made up of three kinds of elements : * the nodes. The nodes are points in space and are the foundations of the mesh. * the elements. The elements are geometrical shapes connecting neighboring nodes. * the groups. The groups are sets of elements and represent areas, volumes that are important for the simulation. A mesh can be either *structured* or *unstructured*. The Mesh category ----------------- In |namespec| meshes are localized in the ``/mesh`` category and can be named by whatever word authorized by HDF5, its children are mesh groups. Mesh group ^^^^^^^^^^ Meshes are gathered inside "mesh groups". In fact, meshes are often made up of independent mesh part, like hybrid meshes for instance. (An hybrid mesh is mesh composed of unstructured meshes and structured meshes). A mesh group is named HDF5 group. (see the ``data.h5:/mesh/$gmesh1`` group below) Consequently, the name of the system is rather the group's name rather than the mesh name. Example : :: data.h5/ `-- mesh/ |-- $gmesh1/ `-- $gmesh2/ Mesh ^^^^ Meshes are children of mesh groups with a mandatory attribute : ``type``. ``type`` can take the following values : * ``unstructured`` : the mesh is an unstructured mesh. * ``structured`` : the mesh is an structured mesh. Mesh's name and mesh group' name must have a length inferior to |elementlen| characters. Example of a ``/mesh`` category : :: data.h5/ `-- mesh/ |-- $gmesh1 | |-+ $mesh#5 | `-+ $mesh_6 `-- $gmesh2 |-- $mesh1[@type=unstructured]/ | |-- elementNodes | |-- elementTypes | |-- nodes | |-- group | | |-- $field-location[@type=node] | | |-- $right-wing[@type=face] | | `-- $left-wing[@type=face] | |-- groupGroup | | `-- $wings | `-- selectorOnMesh | |-- nodes | |-- elements | `-- groups |-+ $mesh-two `-- $mesh-3[@type=structured]/ |-- cartesianGrid |-- group | |-- $field-location[@type=node] | |-- $right-wing[@type=face] | `-- $left-wing[@type=face] |-- groupGroup | `-- $wings `-- selectorOnMesh |-- nodes |-- elements `-- groups In this example, ``data.h5:/mesh/$gmesh2/$mesh1`` is an *unstructured* mesh and ``data.h5:/mesh/gmesh2/$mesh-3`` is a *structured* mesh. The next section present in details ``unstructured`` mesh and ``structured`` meshes. .. include:: unstructuredmesh.rst .. include:: structuredmesh.rst Selector on mesh ---------------- In a mesh, nodes are necessary contained in the ``nodes`` dataset. However, it could be interesting to spot the middle of an edge or the center of a face... Similarly, it could nice to select a face edge without creating an edge element in ``elementTypes``. This is the role of the ``/mesh/$gmesh/$mesh/selectorOnMesh`` group localized in mesh instances : :: data.h5/ `-- mesh `-- $gmesh1 |-- $mesh1 | |-- nodes | |-- elementTypes | |-- elementNodes | |-- group | |-- groupGroup | `-- selectorOnMesh |-- $mesh-two |-- $mesh-3 | |-- nodes | |-- elementTypes | |-- elementNodes | |-- group | |-- groupGroup | `-- selectorOnMesh |-- $mesh#5 |-- $mesh_6 `-- meshLink The ``selectorOnMesh`` group offers the mean to select and label mesh points and mesh sub-element (The ``meshLink`` group will be covered in the next section). ``selectorOnMesh`` is an HDF5 group which contains two kind of children : * named tables * named integer datasets selectorOnMesh of ``pointInElement`` type ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A ``selectorOnMesh`` of ``pointInElement`` type is a named **table** which contains point definitions in element's local coordinate systems. The shape of the table depends on the ``unstructured`` | ``structured`` nature of the mesh. The table has a string attribute named ``type`` of value ``pointInElement`` : :: data.h5/ `-- mesh/ `-- $gmesh1/ `-- $mesh1/ |-- nodes |-- elementTypes |-- elementNodes |-- group/ |-- groupGroup/ `-- selectorOnMesh/ `-- $point_in_element[@type=pointInElement] Unstructured mesh ################# It is possible to spot a point in an element thanks to a local coordinate system built by one, two or three vectors (depending on the dimension of the element). Definition : :math:`\vec{e_{ij}}` is the vector starting from the node i toward the node j of an element. * if E is a one-dimensional element, only :math:`\vec{v_1}` is used and is defined by : ============= ====================== Cell :math:`\vec{v_1}` ============= ====================== bar2 :math:`\vec{e_{12}}` ------------- ---------------------- bar3 :math:`\vec{e_{12}}` ============= ====================== In the :math:`(O, \vec{v_1})` coordinate system (O is node 1), the identification of a point :math:`P` is realized by the vector :math:`\overrightarrow{OP}` using a real number :math:`\alpha` : :math:`\overrightarrow{OP} = \alpha \vec{v_1}`, :math:`P` must be in the element. * if E is a two-dimensional element, :math:`(\vec{v_1}, \vec{v_2})` are used and are defined by : ============= ====================== ====================== Cell :math:`\vec{v_1}` :math:`\vec{v_2}` ============= ====================== ====================== tri3 :math:`\vec{e_{12}}` :math:`\vec{e_{13}}` ------------- ---------------------- ---------------------- tri6 :math:`\vec{e_{12}}` :math:`\vec{e_{13}}` ------------- ---------------------- ---------------------- quad4 :math:`\vec{e_{12}}` :math:`\vec{e_{14}}` ------------- ---------------------- ---------------------- quad8 :math:`\vec{e_{12}}` :math:`\vec{e_{14}}` ============= ====================== ====================== In the :math:`(O, \vec{v_1}, \vec{v_2})` coordinate system (O is node 1), the identification of a point :math:`P` is realized by the vector :math:`\overrightarrow{OP}` using two real numbers :math:`\alpha, \beta` : :math:`\overrightarrow{OP} = \alpha \vec{v_1} + \beta \vec{v_2}`, :math:`P` must be in the element. * if E is a three-dimension cell, :math:`(\vec{v_1}, \vec{v_2}, \vec{v_3})` are used and are defined by : ============= ====================== ====================== ====================== Cell :math:`\vec{v_1}` :math:`\vec{v_2}` :math:`\vec{v_3}` ============= ====================== ====================== ====================== tetra4 :math:`\vec{e_{12}}` :math:`\vec{e_{13}}` :math:`\vec{e_{14}}` ------------- ---------------------- ---------------------- ---------------------- pyra5 :math:`\vec{e_{12}}` :math:`\vec{e_{14}}` :math:`\vec{e_{15}}` ------------- ---------------------- ---------------------- ---------------------- penta6 :math:`\vec{e_{12}}` :math:`\vec{e_{14}}` :math:`\vec{e_{13}}` ------------- ---------------------- ---------------------- ---------------------- hexa8 :math:`\vec{e_{12}}` :math:`\vec{e_{14}}` :math:`\vec{e_{15}}` ============= ====================== ====================== ====================== In the :math:`(O, \vec{v_1}, \vec{v_2}, \vec{v_3})` coordinate system (O is node 1), the identification of a point :math:`P` is realized by the vector :math:`\overrightarrow{OP}` using three real numbers :math:`\alpha, \beta, \gamma` : :math:`\overrightarrow{OP} = \alpha \vec{v_1} + \beta \vec{v_2} + \gamma \vec{v_3}`, :math:`P` must be in the element. .. note:: The default value of a v* is -1, it is the "not used" value. Therefore, ``pointInElement`` ``selectorOnMesh`` is a four columns HDF5 table. ======= ==== ==== ==== index v1 v2 v3 ======= ==== ==== ==== The four columns are : * ``index`` : the index of the element in the list of elements (``elementTypes``). ``index`` is an integer. * ``v1`` : the relative distance :math:`\alpha` along :math:`\vec{v_1}`. ``v1`` is real * ``v2`` : the relative distance :math:`\beta` along :math:`\vec{v_2}`. ``v2`` is real * ``v3`` : the relative distance :math:`\gamma` along :math:`\vec{v_3}`. ``v3`` is real .. warning:: Distances are normalized Examples for the mesh ``data.h5:/mesh/$gmesh1/mesh1`` : :: data.h5/ `-- mesh `-- $gmesh1 `-- $mesh1[@type=unstructured] |-- nodes |-- elementTypes |-- elementNodes |-- group | |-- $field-location[@type=node] | |-- $right-wing[@type=element] | `-- $left-wing[@type=element] |-- groupGroup | `-- $wings `-- selectorOnMesh `-- $points_in_elements[@type=pointInElement] ``/mesh/$gmesh1/$mesh1/elementTypes`` is (implicit index are not reported), the mesh is composed of two bar2 element. +-----+ | 1 | +-----+ | 1 | +-----+ and ``data.h5:/mesh/$gmesh1/$mesh1/selectorOnMesh/$points_in_elements`` is ======= ==== ==== ==== index v1 v2 v3 ------- ---- ---- ---- 0 0.5 -1 -1 1 0.5 -1 -1 ======= ==== ==== ==== This example defines the center of the two edges. Structured mesh ################# ``selectorOnMesh`` of ``pointInElement`` type defines named entities referenced relative to an element E. A point can be localized in the element by a local coordinate system :math:`(\vec{v_1}, \vec{v_2}, \vec{v_3})` (in the 3D case). * if E is an edge, :math:`\vec{v_1}` is used * If E is directed along :math:`\overrightarrow{Ox}`, * :math:`\vec{v_1} = \overrightarrow{dx}` * If E is directed along :math:`\overrightarrow{Oy}`, * :math:`\vec{v_1} = \overrightarrow{dy}` * If E is directed along :math:`\overrightarrow{Oz}`, * :math:`\vec{v_1} = \overrightarrow{dz}` * if E is a face, :math:`(\vec{v_1}, \vec{v_2})` are used * If E is in :math:`xOy` * :math:`\vec{v_1} = \overrightarrow{dx}` * :math:`\vec{v_2} = \overrightarrow{dy}` * If E is in :math:`xOz` * :math:`\vec{v_1} = \overrightarrow{dx}` * :math:`\vec{v_2} = \overrightarrow{dz}` * If E is in :math:`yOz` * :math:`\vec{v_1} = \overrightarrow{dy}` * :math:`\vec{v_2} = \overrightarrow{dz}` * if E is a volume, :math:`(\vec{v_1}, \vec{v_2}, \vec{v_3})` are used * :math:`\vec{v_1} = \overrightarrow{dx}` * :math:`\vec{v_2} = \overrightarrow{dy}` * :math:`\vec{v_3} = \overrightarrow{dz}` :math:`\vec{dx} (respectively \vec{dy}` and :math:`\vec{dz}`) is the oriented dimension of the cell along x-axis, (respectively y-axis z-axis). .. note:: The default value of a v* is -1, it is the "not used value". Therefore, ``pointInElement`` ``selectorOnMesh`` is a nine columns HDF5 table. ====== ====== ====== ====== ====== ====== ==== ==== ==== imin jmin kmin imax jmax kmax v1 v2 v3 ====== ====== ====== ====== ====== ====== ==== ==== ==== The nine columns are : * ``imin`` : the i index of the bottom corner node. ``imin`` is an integer. * ``jmin`` : the j index of the bottom corner node. ``jmin`` is an integer. * ``kmin`` : the k index of the bottom corner node. ``kmin`` is an integer. * ``imax`` : the i index of the top corner node. ``imax`` is an integer. * ``jmax`` : the j index of the top corner node. ``jmax`` is an integer. * ``kmax`` : the k index of the top corner node. ``kmax`` is an integer. * ``v1`` : distance in the direction x. ``v1`` is a real. * ``v2`` : distance in the direction y. ``v2`` is a real. * ``v3`` : distance in the direction z. ``v3`` is a real. .. note:: The following rules must be followed : * (``imax`` - ``imin``) = 0 or 1 * (``jmax`` - ``jmin``) = 0 or 1 * (``kmax`` - ``kmin``) = 0 or 1 One can see that if : * ``imin`` = ``imax`` or ``jmin`` = ``jmax`` or ``kmin`` = ``kmax`` E is a face * ``imin`` = ``imax`` and (``jmin`` = ``jmax`` or ``kmin`` = ``kmax``) E is an edge (and respectively for the other permutations) Examples for the mesh ``data.h5:/mesh/$gmesh1/$mesh1`` : :: data.h5/ `-- mesh/ `-- $gmesh1/ `-- $mesh1[@type=structured]/ |-- cartesianGrid |-- group/ | `-- $e-field[@type=node] |-- groupGroup/ `-- selectorOnMesh/ `-- $points_in_elements[@type=pointInElement] ``data.h5:/mesh/$gmesh1/$mesh1/selectorOnMesh/$points_in_elements`` is ====== ====== ====== ====== ====== ====== ==== ==== ==== imin jmin kmin imax jmax kmax v1 v2 v3 ====== ====== ====== ====== ====== ====== ==== ==== ==== 1 1 1 2 2 2 0.5 0.5 0.5 1 1 1 1 2 2 0.5 0.5 -1 1 1 1 1 1 2 0.5 -1 -1 ====== ====== ====== ====== ====== ====== ==== ==== ==== The first point is the center of a volume, the second the center of a face and the last is the center of an edge. ``selectorOnMesh`` of ``edge|face`` type ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A ``selectorOnMesh`` of ``edge|face`` type is a named **dataset** and defines a list of sub-elements. The dataset has a string attribute named ``type`` of value : * ``edge`` : the dataset references edges * ``face`` : the dataset references faces This kind of ``selectorOnMesh`` exists only for ``unstructured`` mesh since it is natural to select whatever entity in a ``structured`` mesh thanks the ``group`` concept. It is possible to spot a sub-element of an element (i.e. an edge, a face) thanks to a local numbering of sub-elements described in :ref:`unstructured_mesh`. The local numbering depends on the ``type`` attribute. ``edge|face`` ``selectorOnMesh`` is a two columns HDF5 integer **dataset**. The two columns are : * The index of the element in the list of elements (in ``elementTypes``). * The number of the sub-element Examples for the mesh ``data.h5:/mesh/$gmesh1/mesh1`` : :: data.h5/ `-- mesh `-- $gmesh1 `-- $mesh1[@type=unstructured] |-- nodes |-- elementTypes |-- elementNodes |-- group | |-- $field-location[@type=node] | |-- $right-wing[@type=element] | `-- $left-wing[@type=element] |-- groupGroup | `-- $wings `-- selectorOnMesh `-- $implicit_edges[@type=edge] ``/mesh/$gmesh1/$mesh1/elementTypes`` is (implicit index are not reported). Two bar2 and a tetra4 compose the mesh. +-----+ | 1 | +-----+ | 1 | +-----+ | 101 | +-----+ and ``data.h5:/mesh/$gmesh1/$mesh1/selectorOnMesh/$implicit_edges`` is +-----+-----+ | 0 | 1 | +-----+-----+ | 1 | 1 | +-----+-----+ | 2 | 3 | +-----+-----+ This example defines a two element edge group : * The first edge of a bar2, it is the bar2 itself * The third edge between node 1 and node 3 of a tetra4 cell. The meshLink group ------------------ Sometimes a mesh can be composed of several meshes or a 2D mesh is merged with a 3D mesh. In these cases, the two meshes must be linked by defining equalities between couples of entities. This is the task of the ``/mesh/$gmesh/meshLink`` category. A meshLink is a named HDF5 two dimensional integer *dataset* with three attributes : * ``type``, this is the type of the link defined by an HDF5 string attribute. The type can be ``nodes`` or ``element`` * If ``type`` is ``node``, the index in the dataset refer to the ``/mesh/$gmesh/$mesh/nodes`` * If ``type`` is ``edge``, the index in the dataset refer to edges in ``/mesh/$gmesh/$mesh/elementTypes`` * If ``type`` is ``face``, the index in the dataset refer to faces in ``/mesh/$gmesh/$mesh/elementTypes`` * If ``type`` is ``volume``, the index in the dataset refer to volumes in ``/mesh/$gmesh/$mesh/elementTypes`` * ``mesh1``, this is an HDF5 string attribute, it is the name of the first ``/mesh/$gmesh/$mesh`` implied in the link. * ``mesh2``, this is an HDF5 string attribute, it is the name of the second ``/mesh/$gmesh/$mesh`` implied in the link. The name's length must be less than |elementlen| characters. Example of ``/mesh/$gmesh1/meshLink`` : :: data.h5 `-- mesh `-- $gmesh1 |-- $mesh1[@type=unstructured] | |-- nodes | |-- elementTypes | `-- elementNodes |-- $mesh2[@type=unstructured] | |-- nodes | |-- elementTypes | `-- elementNodes |-- $mesh3[@type=structured] | `-- cartesianGrid |-- $mesh4[@type=structured] | `-- cartesianGrid `--meshLink |-- $ml1[@type=node | @mesh1=/mesh/$gmesh1/$mesh1 | @mesh2=/mesh/$gmesh1/$mesh2] |-- $ml2[@type=node | @mesh1=/mesh/$gmesh1/$mesh3 | @mesh2=/mesh/$gmesh1/$mesh4] |-- $ml3[@type=volume | @mesh1=/mesh/$gmesh1/$mesh1 | @mesh2=/mesh/$gmesh1/$mesh2] `-- $ml4[@type=volume @mesh1=/mesh/$gmesh1/$mesh3 @mesh2=/mesh/$gmesh1/$mesh4] The entity in located in the ``selectorOnMesh/nodes`` table and the ``selectorOnMesh/elements`` tables in the case of an unstructured mesh. Link between two unstructured meshes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ An element or node link between two unstructured meshes is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x two. The two columns represent : * i1 : the index i of the node in the first unstructured mesh's ``nodes`` dataset * i2 : the index i of the node in the second unstructured mesh's ``nodes`` dataset == == i1 i2 == == 0 0 1 3 2 6 == == Headers are reported for convenience Link between two structured meshes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nodes ##### A node link between two structured meshes (``/mesh/$gmesh/meshLink/$ml2``) is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x six. The six columns represent : * i1, j1, k1 : indices of the node in the first mesh * i2, j2, k2 : indices of the node in the second mesh ==== ==== ==== ==== ==== ==== i1 j1 k1 i2 j2 k2 ==== ==== ==== ==== ==== ==== 1 1 1 2 2 2 2 2 2 3 3 3 ==== ==== ==== ==== ==== ==== Headers are reported for convenience Element ####### An element link between two structured meshes (``/mesh/$gmesh/meshLink/$ml4``) is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x 12. The six columns represent : * imin1, jmin1, kmin1, imax1, jmax1, kmax1 : indices of the element in the first mesh * imin2, jmin2, kmin2, imax2, jmax2, kmax2 : indices of the element in the second mesh ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== imin1 jmin1 kmin1 imax1 jmax1 kmax1 imin2 jmin2 kmin2 imax2 jmax2 kmax2 ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== 1 1 1 2 2 2 1 1 1 2 2 2 2 2 2 1 1 1 2 2 2 3 3 3 ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== Headers are reported for convenience Link between one unstructured mesh and one structured mesh ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nodes ##### An node link between one unstructured mesh and one structured mesh is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x four. The four columns represent : * i1 : the index of the node in the unstructured mesh's ``nodes`` * i2, j2, k2 : indices of the node in the second mesh == == == == i1 i2 j2 k2 == == == == 1 1 1 1 2 2 2 2 == == == == Headers are reported for convenience Element ####### An element link between one unstructured mesh and one structured mesh is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x seven. The seven columns represent : * i1 : the indice of the node in the unstructured mesh's ``nodes`` * imin2, jmin2, kmin2, imax2, jmax2, kmax2 : indices of the element in the second mesh == ===== ===== ===== ===== ===== ===== i1 imin2 jmin2 kmin2 imax2 jmax2 kmax2 == ===== ===== ===== ===== ===== ===== 1 1 1 1 2 2 2 2 2 2 2 3 3 3 == ===== ===== ===== ===== ===== ===== Headers are reported for convenience Link between one structured mesh and one unstructured mesh ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nodes ##### An node link between one structured mesh and one unstructured mesh is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x four. The four columns represent : * i1, j1, k1 : indices of the node in the second mesh * i2 : the index of the node in the unstructured mesh's ``nodes`` == == == == i1 j1 k1 i2 == == == == 1 1 1 1 2 2 2 2 == == == == Headers are reported for convenience Element ####### An element link between one structured mesh and one unstructured mesh is defined by an HDF5 dataset with a rank of 2 and with dimensions equal number_of_entities x seven. The seven columns represent : * imin1, jmin1, kmin1, imax1, jmax1, kmax1 : indices of the element in the second mesh * i2 : the index of the node in the unstructured mesh's ``nodes`` ===== ===== ===== ===== ===== ===== == imin1 jmin1 kmin1 imax1 jmax1 kmax1 i2 ===== ===== ===== ===== ===== ===== == 1 1 1 2 2 2 1 2 2 2 3 3 3 2 ===== ===== ===== ===== ===== ===== == Headers are reported for convenience