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