Salome HOME
22364: EDF SMESH: Create Mesh dialog box improvement: hide inapplicable algorithms...
[modules/smesh.git] / doc / salome / gui / SMESH / input / constructing_meshes.doc
1 /*!
2
3 \page constructing_meshes_page Constructing meshes
4
5 \n Construction of a mesh on some geometry consists of:
6 <ul>
7   <li> \ref create_mesh_anchor "Creating of a mesh object"</li>
8   <li> \ref evaluate_anchor "Evaluating mesh size" (optional)</li>
9   <li> \ref preview_anchor "Previewing the mesh" (optional)</li>
10   <li> \ref submesh_order_anchor "Changing sub-mesh priority" (optional)</li>
11   <li> \ref compute_anchor "Computing the mesh"</li>
12 </ul>
13 Mesh can be \ref use_existing_anchor "computed using your own meshing algorithms" 
14 written in Python.
15
16
17 \anchor create_mesh_anchor
18 <h2>Creation of a mesh object</h2>
19 <em>To construct a mesh:</em>
20 <ol>
21   <li>Select a geometrical object for meshing.</li>
22   <li>In the \b Mesh menu select <b>Create Mesh</b> or click <em>"Create
23       Mesh"</em> button in the toolbar. 
24
25     <center>
26     \image html image32.png
27     <em>"Create Mesh" button</em>
28     </center>
29
30     The following dialog box will appear: 
31
32     \image html createmesh-inv.png
33     <br>
34   </li>
35   <li>Apply \subpage basic_meshing_algos_page "meshing algorithms" and
36     \subpage about_hypo_page "hypotheses" which will be used to compute
37     this mesh.
38
39     "Create mesh" dialog box contains several tab pages titled \b 3D,
40     \b 2D, \b 1D and \b 0D. The title of each page reflects the
41     dimension of the CAD model (geometry) the algorithms listed on
42     this page affect and the maximal dimension of elements the algorithms
43     generate. For example, \b 3D page lists the algorithms that affect
44     3D geometrical objects (solids).
45
46     \note
47     - Some page(s) can be disabled if the source geometrical
48     object does not include shapes (sub-shapes) of the corresponding
49     dimension(s). For example, if the input object is a geometrical face,
50     \b 3D page is disabled.
51     - Some algorithms affect the geometry of several dimensions,
52     i.e. "1D-2D" or "1D-2D-3D". If such an algorithm is selected by the
53     user, the dialog box pages related to the corresponding lower level
54     dimensions are disabled.
55     - \b 0D page does not refer to the 0D elements, but to 0D
56     geometry (vertices). Mesh module does not provide algorithms that
57     produce 0D elements. Currently \b 0D page provides only one
58     algorithm "Segments around vertex" that allows specyfying the required
59     size of mesh edges about the selected vertex (or vertices).
60
61     For example, you need to mesh a 3D object.
62
63     First, type the name of your mesh in the \b Name box, by default,
64     it is "Mesh_1". Then select the geometrical object you wish to
65     mesh in the Object Browser and click "Select" button near \b Geometry
66     field (if the name of the object has not yet appeared in \b Geometry field).
67
68     <center>
69     \image html image120.png
70     <em>"Select" button</em>
71     </center>
72
73     Now you can define 3D Algorithm and 3D Hypotheses, which will be
74     applied to the solids of your geometrical object. Click the <em>"Add
75       Hypothesis"</em>  button to add a hypothesis.
76
77     <center>
78     \image html image121.png
79     <em>"Add Hypothesis" button</em>
80     </center>
81
82     Click the <em>"Edit Hypothesis"</em> button to change the values for the
83     current hypothesis.
84
85     <center>
86     \image html image122.png
87     <em>"Edit Hypothesis" button</em>
88     </center>
89
90     Most 2D and 3D algorithms can work without hypotheses using some
91     default meshing parameters. Some algorithms does not require any
92     hypothesis. After selection of an algorithm "Hypothesis" field of
93     the dialog can contain:
94     <ul>
95       <li> <em>\<Default\></em> if the algorithm can work using default
96       parameters.</li>
97       <li> <em>\<None\></em> if the algorithm requires a hypothesis defining
98       its parameters.</li>
99       <li> Nothing if the algorithm has no parameters to tune.</li>
100     </ul>
101     After selection of an algorithm "Add. Hypothesis" field of
102     the dialog can contain:
103     <ul>
104       <li> <em>\<None\></em> if the algorithm can be additionally tuned
105       using an additional hypothesis.</li>
106       <li> Nothing if the algorithm has no additional parameters to tune.</li>
107     </ul>
108
109     Proceed in the same way with 2D and 1D Algorithms and Hypotheses that
110     will be used to mesh faces and edges of your geometry. (Note
111     that any object has edges, even if their existence is not
112     apparent, for example, a sphere has 4 edges). Note that the
113     choice of hypotheses and lower dimension algorithms depends on
114     the higher dimension algorithm. 
115
116     Some algorithms generate mesh of several dimensions, while others
117     produce mesh of only one dimension. In the latter case there must
118     be one Algorithm and zero or several
119     Hypotheses for each dimension of your object, otherwise you will
120     not get any mesh at all. Of course, if you wish to mesh a face,
121     which is a 2D object, you do not need to define a 3D Algorithm and
122     Hypotheses.
123
124     In the <b>Object Browser</b> the structure of the new mesh will be
125     displayed as follows:
126
127     <center>
128     \image html image88.jpg
129     </center>
130
131     It contains: 
132     <ul>
133       <li>a reference to the geometrical object on the basis of
134         which the mesh has been constructed;</li> 
135       <li><b>Applied hypotheses</b> folder containing the references
136         to the hypotheses applied at the construction of the mesh;</li>
137       <li><b>Applied algorithms</b> folder containing the references
138         to the algorithms applied at the construction of the mesh.</li> 
139     </ul>
140
141     There is an alternative way to assign Algorithms and Hypotheses by
142     clicking <b>Assign a set of hypotheses</b> button and selecting among
143     pre-defined sets of hypotheses. In addition to the standard
144     sets of hypotheses, it is possible to create custom sets by editing
145     CustomMeshers.xml file located in the home directory. CustomMeshers.xml
146     file must describe sets of hypotheses in the
147     same way as ${SMESH_ROOT_DIR}/share/salome/resources/smesh/StdMeshers.xml 
148     file does (sets of hypotheses are enclosed between <hypotheses-set-group>
149       tags).
150
151       \image html hypo_sets.png
152       List of sets of hypotheses. Tag <em>[custom]</em> is
153       automatically added to the sets defined by the user
154   </li>
155 </ol>
156
157 Consider trying a sample script for construction of a mesh from our 
158 \ref tui_creating_meshes_page "TUI Scripts" section.
159
160 \anchor evaluate_anchor
161 <h2>Evaluating mesh size</h2>
162
163 After the mesh object is created and all hypotheses are assigned and
164 before \ref compute_anchor "Compute" operation, it is possible to
165 calculate the eventual mesh size. For this, select the mesh in
166 the <b>Object Browser</b> and from the \b Mesh menu select \b
167 Evaluate. The result of evaluation will be displayed in the following
168 information box: 
169
170 \image html mesh_evaluation_succeed.png
171
172 \anchor preview_anchor
173 <h2>Previewing the mesh</h2>
174
175 Before \ref compute_anchor "the mesh computation", it is also possible
176 to see the mesh preview.
177
178 For this, select the mesh in the Object Browser. From the \b Mesh menu
179 select \b Preview or click "Preview" button in the toolbar or activate
180 "Preview" item from the pop-up menu.
181
182 <center>
183 \image html mesh_precompute.png
184 <em>"Preview" button</em>
185 </center>
186
187 Select <b>1D mesh</b> or <b>2D mesh</b> preview mode in the Preview dialog. 
188
189 \image html preview_mesh_1D.png "1D mesh preview shows nodes computed on geometry edges"
190 <br>
191 \image html preview_mesh_2D.png "2D mesh preview shows edge mesh elements, computed on geometry faces"
192
193 <b>Compute</b> button computes the whole mesh.
194
195 When the Preview dialog is closed, the question about the storage of temporarily
196 created mesh elements appears:
197
198 \image html preview_tmp_data.png
199
200 These elements can be kept in the mesh.
201
202
203 \anchor submesh_order_anchor
204 <h2>Changing sub-mesh priority</h2>
205
206 If the mesh contains concurrent \ref constructing_submeshes_page "sub-meshes", 
207 it is possible to change the priority of their computation, i.e. to
208 change the priority of applying algorithms to the shared sub-shapes of
209 the Mesh shape.
210
211 <em>To change submesh priority:</em>
212
213 Choose "Change submesh priority" from the Mesh menu or a pop-up
214 menu. The opened dialog shows a list of submeshes in the order of
215 their priority. 
216
217 There is an example of submesh order modifications taking a Mesh created on a Box
218 shape. The main Mesh object:
219 <ul>
220   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=20</li>
221   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis<b>Max Element Area</b>
222   </li>
223 </ul>
224 The first submesh object <b>Submesh_1</b> created on <b>Face_1</b> is:
225 <ul>
226   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=4</li>
227   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis <b>MaxElementArea</b>=1200</li>
228 </ul>
229 The second submesh object <b>Submesh_2</b> created on <b>Face_2</b> is:
230 <ul>
231   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=8</li>
232   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis <b>MaxElementArea</b>=1200</li>
233 </ul>
234
235 And the last submesh object <b>Submesh_3</b> created on <b>Face_3</b> is:
236 <ul>
237   <li><i>1D</i> <b>Wire discretisation</b> with <b>Number of Segments</b>=12</li>
238   <li><i>2D</i> <b>Triangle (Mefisto)</b> with Hypothesis <b>MaxElementArea</b>=1200</li>
239 </ul>
240
241 The sub-meshes become concurrent if they share sub-shapes that can be
242 meshed with different algorithms (or different hypotheses). In the
243 example, we have three submeshes with concurrent algorithms, because
244 they have different hypotheses.
245
246 The first mesh computation is made with:
247 <center>
248 \image html mesh_order_123.png
249 <em>"Mesh order SubMesh_1, SubMesh_2, SubMesh_3"</em></center>
250 <center>
251 \image html mesh_order_123_res.png
252 <em>"Result mesh with order SubMesh_1, SubMesh_2, SubMesh_3 "</em></center>
253
254 The next mesh computation is made with:
255 <center>
256 \image html mesh_order_213.png
257 <em>"Mesh order SubMesh_2, SubMesh_1, SubMesh_3"</em></center>
258 <center>
259 \image html mesh_order_213_res.png
260 <em>"Result mesh with order SubMesh_2, SubMesh_1, SubMesh_3 "</em></center>
261
262 And the last mesh computation is made with:
263 <center>
264 \image html mesh_order_321.png
265 <em>"Mesh order SubMesh_3, SubMesh_2, SubMesh_1"</em></center>
266 <center>\image html mesh_order_321_res.png
267 <em>"Result mesh with order SubMesh_3, SubMesh_2, SubMesh_1 "</em></center>
268
269 As we can see, each mesh computation has a different number of result
270 elements and a different mesh discretization on the shared edges (the edges 
271 that are shared between <b>Face_1</b>, <b>Face_2</b> and <b>Face_3</b>)
272
273 Additionally, submesh priority (the order of applied algorithms) can
274 be modified not only in a separate dialog box, but also in
275 the <b>Preview</b>. This helps to preview different mesh results,
276 modifying the order of submeshes. 
277 <center>
278 \image html mesh_order_preview.png
279 <em>"Preview with submesh priority list box"</em></center>
280
281 If there are no concurrent submeshes under the Mesh object, the user
282 will see the following information.
283 <center>
284 \image html mesh_order_no_concurrent.png
285 <em>"No concurrent submeshes detected"</em></center>
286
287
288 \anchor compute_anchor
289 <h2>Computing the mesh</h2>
290
291 It is equally possible to skip  \ref evaluate_anchor "the Evaluation"
292 and \ref preview_anchor "the Preview" and to \b Compute the mesh after
293 the hypotheses are assigned. For this, select your mesh in
294 the <b>Object Browser</b>. From the \b Mesh menu select \b Compute or
295 click "Compute" button of the toolbar.
296
297 <center>
298 \image html image28.png
299 <em>"Compute" button</em>
300 </center>
301
302 After the mesh computation finishes, the Mesh Computation information
303 box appears. In case of a success, the box shows
304 information on number of entities of different types in the mesh.
305
306 \image html meshcomputationsucceed.png
307
308 If the mesh computation failed, the information about the cause of the
309 failure is provided in \b Errors table.
310
311 \image html meshcomputationfail.png
312
313 After you select the error, <b>Show Sub-shape</b> button allows
314 visualizing in magenta the geometrical entity that causes the error.
315
316 \image html failed_computation.png 
317 <em>3D algorithm failed to compute mesh on a box shown using <b>Show
318     Sub-shape</b> button</em>
319
320 <b>Publish Sub-shape</b> button publishes the sub-shape, whose meshing
321 has failed, in GEOM component as a child of the mesh geometry, which
322 allows analyzing the problem geometry and creating a submesh on it in
323 order to locally tune the hypotheses.
324
325 If the failure is caused by an invalid input mesh and the algorithm has
326 found which mesh entities are bad, <b>Show bad Mesh</b> 
327 button appears in the dialog. Clicked, it shows the bad mesh entities in
328 the Viewer in magenta. Sometimes the shown mesh entities are too small
329 or/and hidden by other mesh elements. They can be seen after
330 switching the mesh to Wireframe visualization mode or switching off
331 the visualization of faces and volumes (if any).
332
333 <b>Bad Mesh to Group</b> button creates groups of bad mesh entities
334 to facilitate their analysis.
335
336 \image html show_bad_mesh.png
337 <em>Edges bounding a hole in the surface are shown in magenta using <b>Show
338     bad Mesh</b> button</em>
339
340 \note Mesh Computation Information box does not appear if you set
341 "Mesh computation/Show a computation result notification" preference 
342 to the "Never" value. This option gives the possibility to control mesh
343 computation reporting. There are the following possibilities: always
344 show the information box, show only if an error occurs or never. 
345 By default, the information box is always shown after mesh computation operation.
346
347 <br><br>
348
349 \anchor use_existing_anchor
350 <h2>"Use existing edges" and "Use existing faces" algorithms</h2>
351
352 It is possible to create a 1D or a 2D mesh in a python script
353 (using <em>AddNode, AddEdge</em> and <em>AddFace</em> commands) and
354 then use such sub-meshes in the construction of a 2D or a 3D mesh. For
355 this, there exist two algorithms: <b>Use existing edges</b> and <b>Use
356   existing faces</b>.
357 For example, you want to use standard algorithms to generate 1D and 3D
358 meshes and to create 2D mesh by your python code. Then you
359 <ol>
360   <li> create a mesh object, assign a 1D algorithm,</li>
361   <li> invoke \b Compute command, which computes a 1D mesh,</li>
362   <li> assign <b>Use existing faces</b> and a 3D algorithm,</li>
363   <li> run your python code, which creates a 2D mesh,</li>
364   <li> invoke \b Compute command, which computes a 3D mesh.</li>
365 </ol>
366
367 Consider trying a sample script demonstrating the usage of 
368 \ref tui_use_existing_faces "Use existing faces" algorithm for
369 construction of a 2D mesh using Python commands.
370
371 \image html use_existing_face_sample_mesh.png
372 <em> Mesh computed by \ref tui_use_existing_faces "the sample script"
373   shown in a Shrink mode.</em>
374
375 */