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