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