Salome HOME
Redesign SALOME documentation
[modules/smesh.git] / doc / salome / gui / SMESH / input / pattern_mapping.rst
1 .. _pattern_mapping_page:
2
3 ***************
4 Pattern mapping
5 ***************
6
7 About patterns
8 ##############
9
10 The pattern describes a mesh to generate: positions of nodes within a
11 geometrical domain and nodal connectivity of elements. A
12 pattern also specifies the so-called key-points, i.e. the nodes that will be
13 located at geometrical vertices. The pattern description is stored in
14 \<pattern_name\>.smp file.
15
16 The smp file contains 4 sections:
17
18         #. The first line indicates the total number of pattern nodes (N).
19         #. The next N lines describe nodes coordinates. Each line contains 2 node coordinates for a 2D pattern or 3 node coordinates for a 3D pattern. Note, that node coordinates of a 3D pattern can be defined only by relative values in range [0;1].
20         #. The key-points line contains the indices of the nodes to be mapped on geometrical vertices (for a 2D pattern only). Index n refers to the node described on the n-th line of section 2. The index of the first node is zero. For a 3D pattern the key points are not specified.
21         #. The remaining lines describe nodal connectivity of elements, one line for each element. Each line holds indices of nodes forming an element. Index n refers to the node described on the n-th line of section 2. The first node index is zero. There must be 3 or 4 indices on each line for a 2D pattern (only liner 2d elements are allowed) and 4, 5, 6 or 8 indices for a 3D pattern (only linear 3d elements are allowed).
22
23 A 2D pattern must contain at least one element and at least one key-point. All key-points must lie on boundaries.
24
25 A 3D pattern must contain at least one element.
26
27 An example of a simple 2D pattern smp file:
28 ::
29
30         !!! SALOME 2D mesh pattern file
31         !!!
32         !!! Nb of points:
33         9
34                 200     0       !- 0
35                 100     0       !- 1
36                   0     0       !- 2
37                   0  -100       !- 3
38                   0  -200       !- 4
39                 100  -200       !- 5
40                 200  -200       !- 6
41                 200  -100       !- 7
42                 100  -100       !- 8
43         !!! Indices of 4 key-points
44          2 0 4 6
45         !!! Indices of points of 6 elements
46          0 1 8
47          8 5 6 7
48          2 3 8
49          8 3 4 5
50          8 7 0
51          8 1 2
52
53 The image below provides a preview of the above pattern:
54
55 .. image:: ../images/pattern2d.png
56         :align: center
57
58 .. centered::
59         An example of a simple 3D pattern smp file:
60       
61 ::
62
63         !!! SALOME 3D mesh pattern file
64         !!!
65         !!! Nb of points:
66         9
67                 0        0        0   !- 0
68                 1        0        0   !- 1
69                 0        1        0   !- 2
70                 1        1        0   !- 3
71                 0        0        1   !- 4
72                 1        0        1   !- 5
73                 0        1        1   !- 6
74                 1        1        1   !- 7
75               0.5      0.5      0.5   !- 8
76         !!! Indices of points of 6 elements:
77          0 1 5 4 8
78          7 5 1 3 8
79          3 2 6 7 8
80          2 0 4 6 8
81          0 2 3 1 8
82          4 5 7 6 8
83
84
85 Application of pattern mapping
86 ##############################
87
88 **To apply pattern mapping to a geometrical object or mesh elements:**
89
90 From the **Modification** menu choose the **Pattern Mapping** item or click 
91 **"Pattern mapping"** button in the toolbar.
92
93 .. image:: ../images/image98.png
94         :align: center
95
96 .. centered::
97         **"Pattern mapping" button**
98
99 The following dialog box will appear:
100
101 For a **2D pattern**
102    
103
104 .. image:: ../images/patternmapping1.png
105         :align: center
106
107 In this dialog you should specify:
108
109 * **Pattern**, which can be loaded from .smp pattern file previously created manually or generated automatically from an existing mesh or sub-mesh.
110 * **Face** with the number of vertices equal to the number of key-points in the pattern; the number of key-points on internal boundaries of the pattern must also be equal to the number of vertices on internal boundaries of the face;
111 * **Vertex** to which the first key-point should be mapped;
112
113
114 Alternatively, it is possible to select **Refine selected mesh elements** check-box and apply the pattern to 
115
116 * **Mesh Face** instead of a geometric Face
117 * and select **Node** instead of vertex.
118
119
120 Additionally it is possible to: 
121
122 * **Reverse the order of key-points**. By default, the vertices of a face are ordered counterclockwise.
123 * Enable to **Create polygons near boundary** 
124 * and **Create polyhedrons near boundary**
125
126           
127 For a **3D pattern**
128
129 .. image:: ../images/patternmapping2.png
130         :align: center
131
132 In this dialog you should specify:
133
134 * **Pattern**, which can be loaded from .smp pattern file previously created manually or generated automatically from an existing mesh or sub-mesh.
135 * A 3D block (Solid) object.
136 * Two vertices that specify the order of nodes in the resulting mesh.
137
138
139 Alternatively, it is possible to select **Refine selected mesh elements** check-box and apply the pattern to
140
141 * One or several **Mesh volumes** instead of a geometric 3D object
142 * and select two **Nodes** instead of vertices. 
143
144 Additionally it is possible to:
145
146 * Enable to **Create polygons near boundary** 
147 * and **Create polyhedrons near boundary**
148
149
150
151 Automatic Pattern Generation
152 ****************************
153
154 To generate a pattern automatically from an existing mesh or sub-mesh, click **New** button.
155
156 The following dialog box will appear:
157
158 .. image:: ../images/a-patterntype1.png
159         :align: center
160
161 In this dialog you should specify:
162
163
164 * **Mesh or Sub-mesh**, which is a meshed geometrical face (for a 2D pattern) or a meshed solid block (for a 3D pattern). Mesh nodes lying on the face vertices become key-points of the pattern. 
165 * A custom **Pattern Name** 
166 * Additionally, for a 2D pattern you may choose to **Project nodes on the face** to get node coordinates instead of using "positions on face" generated by the mesher (if there is any). The faces having a seam edge cannot be used for automatic pattern creation.
167
168
169 When a pattern is created from an existing mesh, two cases are possible:
170
171 * A sub-mesh on a face/solid is selected. The pattern is created from the 2d/3d elements bound to the face/solid by the mesher. For a 2D pattern, the node coordinates are either "positions on face" computed by the mesher, or coordinates got by node projection on a geometrical surface, according to the user choice. For a 3D pattern, the node coordinates correspond to the nodes computed by the mesher.
172 * A mesh, where the main shape is a face/solid, is selected. The pattern is created from all 2d/3d elements in a mesh. In addition, if all mesh elements of a 2D pattern are built by the mesher, the user can select how to get node coordinates, otherwise all nodes are projected on a face surface.
173
174
175 Mapping algorithm
176 #################
177
178 The mapping algorithm for a 2D case is as follows:
179
180 * The key-points are set counterclockwise in the order corresponding to their location on the pattern boundary. The first key-point is preserved.
181 * The geometrical vertices corresponding to the key-points are found on face boundary. Here, "Reverse order of key-points" flag is set. 
182
183 .. image:: ../images/image95.gif
184         :align: center
185
186 * The boundary nodes of the pattern are mapped onto the edges of the face: a node located between two key-points on the pattern boundary is mapped on the geometrical edge limited by the corresponding geometrical vertices. The node position on the edge depends on its distance from the key-points. 
187
188 .. image:: ../images/image96.gif
189         :align: center
190
191 * The coordinates of a non-boundary node in the parametric space of the face are defined in the following way. In the parametric space of the pattern, the  node lies at the intersection of two iso-lines. Both of them intersect the pattern boundary at two points at least. If the mapped positions of boundary nodes are known, it is possible to find, where the points at the intersection of iso-lines and boundaries are mapped. Then it is possible to find the direction of mapped iso-line section and, finally, the positions of two nodes on two mapped isolines. The eventual mapped position of the node is found as an average of the positions on mapped iso-lines. 
192
193 .. image:: ../images/image97.gif
194         :align: center
195
196 The 3D algorithm is similar.
197
198 **See Also** a sample TUI Script of a :ref:`tui_pattern_mapping` operation.
199
200