Salome HOME
IMP 22264: EDF 2648 GEOM: Propagate edges automatic orientation
[modules/smesh.git] / doc / salome / gui / SMESH / input / constructing_meshes.doc
1 /*!
2
3 \page constructing_meshes_page Constructing meshes
4
5 To create a mesh on geometry, at first you create a mesh object by choosing
6 - a geometrical shape produced in the Geometry module (<em>main shape</em>);
7 - <em>meshing parameters</em>, including 
8   - \ref basic_meshing_algos_page "meshing algorithms" and
9   - \ref about_hypo_page "hypotheses" specifying constraints to be
10     taken into account by chosen meshing algorithms.
11
12 Then you already can launch mesh generation by invoking \ref
13 compute_anchor "Compute" command.
14
15 \note Sometimes \a hypotheses term is used to refer to both algorithms
16 and hypotheses.
17
18 Generation of the mesh on the geometry is performed in the bottom-up
19 flow: nodes on vertices are created first, then edges are divided into
20 segments using nodes on vertices; the segments of the edges is then
21 used while meshing faces; then the mesh of the faces is used while meshing
22 solids. This automatically assures the conformity of the mesh.
23
24 You are to choose a meshing algorithm for every dimension of
25 sub-shapes up to the highest dimension you desire to generate. Note
26 that some algorithms generate elements of several dimensions while
27 others, of only one. But it's not necessary to define meshing
28 parameters for all dimensions at once; you can start from 1D
29 meshing parameters only, compute the 1D mesh, then define 2D meshing
30 parameters and compute the 2D mesh (note that 1D mesh won't be
31 re-computed).
32
33 An algorithm of a certain dimension chosen at mesh creation is applied
34 to discretize every sub-shape of this dimension. But you can
35 specify a different algorithm or hypothesis to be applied to one or
36 a group of sub-shapes by creating a \ref constructing_submeshes_page
37 "sub-mesh". You can specify no algorithms at all at mesh object
38 creation and specify the meshing parameters on sub-meshes only; then
39 only sub-shapes for which you defined an algorithm and a needed
40 hypothesis (if any) will be discretized.
41
42 \n Construction of a mesh on some geometry includes at least two (mesh
43 creation and computing) of the following steps:
44 <ul>
45   <li> \ref create_mesh_anchor "Creation of a mesh object" where you
46   can specify meshing parameters to apply to all sub-shapes of the
47   main shape.</li>
48   <li> \ref constructing_submeshes_page "Creation of sub-meshes"
49   (optional) where you can specify meshing parameters to apply to
50   selected sub-shapes.</li>
51   <li> \ref evaluate_anchor "Evaluating mesh size" (optional) can be
52   used to know approximate number of elements before actual generation
53   of them.</li>
54   <li> \ref preview_anchor "Previewing the mesh" (optional) can be
55   used to generate mesh of only lower dimension(s) in order to
56   visually estimate it before full mesh generation, which can be much
57   longer.</li>
58   <li> \ref submesh_order_anchor "Changing sub-mesh priority"
59   (optional) can be useful if there are concurrent sub-meshes
60   defined.</li>
61   <li> \ref compute_anchor "Computing the mesh" uses defined meshing
62   parameters to generate mesh elements.</li>
63   <li> \ref edit_anchor "Editing the mesh" (optional) can be used to
64   \ref modifying_meshes_page "modify" mesh of lower dimension before
65   \ref compute_anchor "computing" elements of upper dimension.</li>
66 </ul>
67
68 \anchor create_mesh_anchor
69 <h2>Creation of a mesh object</h2>
70 <em>To construct a mesh:</em>
71 <ol>
72   <li>Select a geometrical object for meshing.</li>
73   <li>In the \b Mesh menu select <b>Create Mesh</b> or click <em>"Create
74       Mesh"</em> button in the toolbar. 
75
76     <center>
77     \image html image32.png
78     <em>"Create Mesh" button</em>
79     </center>
80
81     The following dialog box will appear: 
82
83     \image html createmesh-inv.png
84     <br>
85   </li>
86   <li> To filter off irrelevant meshing algorithms, you can
87     select <b>Mesh Type</b> in the corresponding list from <b>Any,
88       Hexahedral, Tetrahedral, Triangular </b> and \b Quadrilateral (there
89     can be less items for the geometry of lower dimensions).
90
91     Selection of a mesh type hides all meshing algorithms that cannot
92     generate elements of this type.</li>
93
94   <li>Apply \subpage basic_meshing_algos_page "meshing algorithms" and
95     \subpage about_hypo_page "hypotheses" which will be used to compute
96     this mesh.
97
98     "Create mesh" dialog box contains several tab pages titled \b 3D,
99     \b 2D, \b 1D and \b 0D. The title of each page reflects the
100     dimension of the sub-shapes the algorithms listed on
101     this page affect and the maximal dimension of elements the algorithms
102     generate. For example, \b 3D page lists the algorithms that affect
103     3D sub-shapes (solids) and generate 3D mesh elements
104     (tetrahedra, hexahedra etc.)
105
106     As soon as you have selected an algorithm, you can create (or
107     select already created) a hypothesis. A set of accessible
108     hypotheses includes only hypotheses the selected algorithm can take
109     into account.
110
111     \note
112     - Some page(s) can be disabled if the geometrical
113     object does not include shapes (sub-shapes) of the corresponding
114     dimension(s). For example, if the input object is a geometrical face,
115     \b 3D page is disabled.
116     - Some algorithms affect the geometry of several dimensions,
117     i.e. 1D+2D or 1D+2D+3D. If such an algorithm is selected, the
118     dialog box pages related to the corresponding lower dimensions are
119     disabled.
120     - \b 0D page does not refer to the 0D elements, but to 0D
121     geometry (vertices). Mesh module does not provide algorithms that
122     produce 0D elements. Currently \b 0D page provides only one
123     algorithm "Segments around vertex" that allows specifying the required
124     size of mesh edges about the selected vertex (or vertices).
125
126     For example, you need to mesh a 3D object.
127
128     First, you can change a default name of your mesh in the \b Name
129     box. Then check that a selected geometrical object, whose name is
130     shown in \b Geometry field, is that you wish to mesh; if not, click
131     the right object in the Object Browser. Click "Select" button
132     near \b Geometry field if the name of the object has not yet
133     appeared in \b Geometry field.
134     <center>
135     \image html image120.png
136     <em>"Select" button</em>
137     </center>
138
139     Now you can define 3D Algorithm and 3D Hypotheses, which will be
140     applied to discretize the solids of your geometrical object using
141     3D elements. Click the <em>"Add Hypothesis"</em> button to create
142     and add a hypothesis.
143     <center>
144     \image html image121.png
145     <em>"Add Hypothesis" button</em>
146     </center>
147     Click the <em>"Plus"</em> button to enable adding more additional hypotheses.
148
149     Click the <em>"Edit Hypothesis"</em> button to change the values for the
150     current hypothesis.
151     <center>
152     \image html image122.png
153     <em>"Edit Hypothesis" button</em>
154     </center>
155
156     Most 2D and 3D algorithms can work without hypotheses using
157     default meshing parameters. Some algorithms do not require any
158     hypotheses. After selection of an algorithm "Hypothesis" field of
159     the dialog can contain:
160     <ul>
161       <li> <em>\<Default\></em> if the algorithm can work using default
162       parameters.</li>
163       <li> <em>\<None\></em> if the algorithm requires a hypothesis defining
164       its parameters.</li>
165       <li> If the algorithm does not use hypotheses, this field is grayed.</li>
166     </ul>
167     After selection of an algorithm <b>Add. Hypothesis</b> field can contain:
168     <ul>
169       <li> <em>\<None\></em> if the algorithm can be tuned
170       using an additional hypothesis.</li>
171       <li> If the algorithm does not use additional hypotheses, this field is grayed.</li>
172     </ul>
173
174     Proceed in the same way with 2D and 1D Algorithms and Hypotheses that
175     will be used to mesh faces and edges of your geometry. (Note
176     that any object has edges, even if their existence is not
177     apparent, for example, a sphere has 4 edges). Note that the
178     choice of hypotheses and lower dimension algorithms depends on
179     the higher dimension algorithm.
180
181     If you wish you can select other algorithms and/or hypotheses
182     for meshing some sub-shapes of your CAD model by \ref constructing_submeshes_page.
183
184     Some algorithms generate mesh of several dimensions, while others
185     produce mesh of only one dimension. In the latter case there must
186     be one Algorithm and zero or several
187     Hypotheses for each dimension of your object, otherwise you will
188     not get any mesh at all. Of course, if you wish to mesh a face,
189     which is a 2D object, you do not need to define a 3D Algorithm and
190     Hypotheses.
191
192     In the <b>Object Browser</b> the structure of the new mesh will be
193     displayed as follows:
194
195     <center>
196     \image html image88.jpg
197     </center>
198
199     It contains: 
200     <ul>
201       <li>a mesh name (<em>Mesh_mechanic</em>);
202       <li>a reference to the geometrical object on the basis of
203         which the mesh has been constructed (\a mechanic);</li> 
204       <li><b>Applied hypotheses</b> folder containing the references
205         to the hypotheses chosen at the construction of the mesh;</li>
206       <li><b>Applied algorithms</b> folder containing the references
207         to the algorithms chosen at the construction of the mesh.</li> 
208     </ul>
209
210     There is an alternative way to assign Algorithms and Hypotheses by
211     clicking <b>Assign a set of hypotheses</b> button and selecting among
212     pre-defined sets of algorithms and hypotheses. In addition to the built-in
213     sets of hypotheses, it is possible to create custom sets by editing
214     CustomMeshers.xml file located in the home directory. CustomMeshers.xml
215     file must describe sets of hypotheses in the
216     same way as ${SMESH_ROOT_DIR}/share/salome/resources/smesh/StdMeshers.xml 
217     file does (sets of hypotheses are enclosed between <hypotheses-set-group>
218       tags).
219       
220       <center>
221       \image html hypo_sets.png
222       List of sets of hypotheses. Tag <em>[custom]</em> is
223       automatically added to the sets defined by the user.
224       </center>
225
226       \note 
227       - \a "Automatic" in the names of predefined sets of
228         hypotheses came from previous versions of SALOME where
229         \ref automatic_length_anchor "Automatic Length" hypothesis 
230         was included in these sets, and not that these sets are suitable for
231         meshing any geometry.
232       - The list of sets of hypotheses can be shorter than in the
233         above image depending on the geometry dimension.
234   </li>
235 </ol>
236
237 Consider trying a sample script for construction of a mesh from our 
238 \ref tui_creating_meshes_page "TUI Scripts" section.
239
240 \anchor evaluate_anchor
241 <h2>Evaluating mesh size</h2>
242
243 After the mesh object is created and all hypotheses are assigned and
244 before \ref compute_anchor "Compute" operation, it is possible to
245 calculate the eventual mesh size. For this, select the mesh in
246 the <b>Object Browser</b> and from the \b Mesh menu select \b
247 Evaluate. The result of evaluation will be displayed in the following
248 information box: 
249
250 \image html mesh_evaluation_succeed.png
251
252 \anchor preview_anchor
253 <h2>Previewing the mesh</h2>
254
255 Before \ref compute_anchor "the mesh computation", it is also possible
256 to see the mesh preview.
257
258 For this, select the mesh in the Object Browser. From the \b Mesh menu
259 select \b Preview or click "Preview" button in the toolbar or activate
260 "Preview" item from the pop-up menu.
261
262 <center>
263 \image html mesh_precompute.png
264 <em>"Preview" button</em>
265 </center>
266
267 Select <b>1D mesh</b> or <b>2D mesh</b> preview mode in the Preview dialog. 
268
269 \image html preview_mesh_1D.png "1D mesh preview shows nodes computed on geometry edges"
270 <br>
271 \image html preview_mesh_2D.png "2D mesh preview shows edge mesh elements, computed on geometry faces"
272
273 <b>Compute</b> button computes the whole mesh.
274
275 When the Preview dialog is closed, the question about the storage of temporarily
276 created mesh elements appears:
277
278 \image html preview_tmp_data.png
279
280 These elements can be kept in the mesh.
281
282
283 \anchor submesh_order_anchor
284 <h2>Changing sub-mesh priority</h2>
285
286 If the mesh contains concurrent \ref constructing_submeshes_page "sub-meshes", 
287 it is possible to change the priority of their computation, i.e. to
288 change the priority of applying algorithms to the shared sub-shapes of
289 the Mesh shape.
290
291 <em>To change sub-mesh priority:</em>
292
293 Choose "Change sub-mesh priority" from the Mesh menu or a pop-up
294 menu. The opened dialog shows a list of sub-meshes in the order of
295 their priority. 
296
297 There is an example of sub-mesh order modifications taking a Mesh created on a Box
298 shape. The main Mesh object:
299 <ul>
300   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=20</li>
301   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis<b>Max Element Area</b>
302   </li>
303 </ul>
304 The first sub-mesh <b>Submesh_1</b> created on <b>Face_1</b> is:
305 <ul>
306   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=4</li>
307   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis <b>MaxElementArea</b>=1200</li>
308 </ul>
309 The second sub-mesh <b>Submesh_2</b> created on <b>Face_2</b> is:
310 <ul>
311   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=8</li>
312   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis <b>MaxElementArea</b>=1200</li>
313 </ul>
314
315 And the last sub-mesh <b>Submesh_3</b> created on <b>Face_3</b> is:
316 <ul>
317   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=12</li>
318   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis <b>MaxElementArea</b>=1200</li>
319 </ul>
320
321 The sub-meshes become concurrent if they share sub-shapes that can be
322 meshed with different algorithms (or different hypotheses). In the
323 example, we have three sub-meshes with concurrent algorithms, because
324 they have different hypotheses.
325
326 The first mesh computation is made with:
327 <center>
328 \image html mesh_order_123.png
329 <em>"Mesh order SubMesh_1, SubMesh_2, SubMesh_3"</em></center>
330 <center>
331 \image html mesh_order_123_res.png
332 <em>"Result mesh with order SubMesh_1, SubMesh_2, SubMesh_3 "</em></center>
333
334 The next mesh computation is made with:
335 <center>
336 \image html mesh_order_213.png
337 <em>"Mesh order SubMesh_2, SubMesh_1, SubMesh_3"</em></center>
338 <center>
339 \image html mesh_order_213_res.png
340 <em>"Result mesh with order SubMesh_2, SubMesh_1, SubMesh_3 "</em></center>
341
342 And the last mesh computation is made with:
343 <center>
344 \image html mesh_order_321.png
345 <em>"Mesh order SubMesh_3, SubMesh_2, SubMesh_1"</em></center>
346 <center>\image html mesh_order_321_res.png
347 <em>"Result mesh with order SubMesh_3, SubMesh_2, SubMesh_1 "</em></center>
348
349 As we can see, each mesh computation has a different number of result
350 elements and a different mesh discretization on the shared edges (the edges 
351 that are shared between <b>Face_1</b>, <b>Face_2</b> and <b>Face_3</b>)
352
353 Additionally, sub-mesh priority (the order of applied algorithms) can
354 be modified not only in a separate dialog box, but also in
355 the <b>Preview</b>. This helps to preview different mesh results,
356 modifying the order of sub-meshes. 
357 <center>
358 \image html mesh_order_preview.png
359 <em>"Preview with sub-mesh priority list box"</em></center>
360
361 If there are no concurrent sub-meshes under the Mesh object, the user
362 will see the following information.
363 <center>
364 \image html mesh_order_no_concurrent.png
365 <em>"No concurrent submeshes detected"</em></center>
366
367
368 \anchor compute_anchor
369 <h2>Computing the mesh</h2>
370
371 It is equally possible to skip  \ref evaluate_anchor "the Evaluation"
372 and \ref preview_anchor "the Preview" and to \b Compute the mesh after
373 the hypotheses are assigned. For this, select your mesh in
374 the <b>Object Browser</b>. From the \b Mesh menu select \b Compute or
375 click "Compute" button of the toolbar.
376
377 <center>
378 \image html image28.png
379 <em>"Compute" button</em>
380 </center>
381
382 After the mesh computation finishes, the Mesh Computation information
383 box appears. If you close this box and click "Compute" button again,
384 without previously changing meshing parameters, the mesh is
385 NOT re-computed and the Mesh Computation information box with
386 the same contents is shown. (To fully re-compute the mesh, invoke \ref
387 clear_mesh_anchor "Clear Mesh Data" command before).
388
389 In case of a success, the box shows information on number of entities
390 of different types in the mesh.
391
392 \image html meshcomputationsucceed.png
393
394 \anchor meshing_failed_anchor
395 If the mesh computation failed, the information about the cause of the
396 failure is provided in \b Errors table.
397
398 \image html meshcomputationfail.png
399
400 After you select an error, <b>Show Sub-shape</b> button allows
401 visualizing in magenta the geometrical entity that causes the error.
402
403 \image html failed_computation.png 
404 <em>3D algorithm failed to compute mesh on a box shown using <b>Show
405     Sub-shape</b> button</em>
406
407 <b>Publish Sub-shape</b> button publishes the sub-shape, whose meshing
408 has failed, in the Geometry component as a child of the main shape, which
409 allows analyzing the problematic geometry and creating a sub-mesh on it in
410 order to locally tune the hypotheses.
411
412 If the failure is caused by an invalid input mesh and the algorithm has
413 found which mesh entities are bad, <b>Show bad Mesh</b> 
414 button appears in the dialog. Clicked, it shows the bad mesh entities in
415 the Viewer in magenta. Sometimes the shown mesh entities are too small
416 or/and hidden by other mesh elements. They can be seen after
417 switching the mesh to Wireframe visualization mode or switching off
418 the visualization of faces and volumes (if any).
419
420 <b>Bad Mesh to Group</b> button creates groups of bad mesh entities
421 to facilitate their analysis.
422
423 \image html show_bad_mesh.png
424 <em>Edges bounding a hole in the surface are shown in magenta using <b>Show
425     bad Mesh</b> button</em>
426
427 \note Mesh Computation Information box does not appear if you set
428 "Mesh computation/Show a computation result notification" preference 
429 to the "Never" value. This option gives the possibility to control mesh
430 computation reporting. There are the following possibilities: always
431 show the information box, show only if an error occurs or never. 
432 By default, the information box is always shown after mesh computation operation.
433
434 <p><p>
435 \anchor edit_anchor
436 <h2>Editing the mesh</h2>
437
438 It is possible to \ref modifying_meshes_page "edit the mesh" of
439 lower dimension before generation of mesh of higher dimension.
440
441 For example you can generate 2D mesh, modify it using e.g. 
442 \ref pattern_mapping_page, and then generate 3D mesh basing on the
443 modified 2D mesh. The workflow is following:
444 - Define 1D and 2D meshing algorithms.
445 - Compute the mesh. 2D mesh is generated.
446 - Apply \ref pattern_mapping_page.
447 - Define 3D meshing algorithms without modifying 1D and 2D algorithms
448 and hypotheses.
449 - Compute the mesh. 3D mesh is generated.
450
451 \note Nodes and elements added \ref adding_nodes_and_elements_page
452 "manually" can't be used in this workflow because the manually created
453 entities are not attached to any geometry and thus (usually) can't be
454 found by a mesher paving some geometry.
455
456 <b>See Also</b> a sample TUI Script demonstrates the possibility of 
457 \ref tui_editing_while_meshing "Intermediate edition while meshing"
458
459 */