Salome HOME
ca895c64011386dedf875c9e645ce89a82007e7f
[modules/smesh.git] / doc / salome / gui / SMESH / constructing_meshes.htm
1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">\r
2 \r
3 <html>\r
4 \r
5 <head>\r
6 <title>Constructing Meshes</title>\r
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">\r
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style type="text/css">\r
9 <!--\r
10 p.whs1 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }\r
11 p.whs2 { margin-top:0pt; margin-bottom:0pt; }\r
12 p.whs3 { font-family:'Lucida Console' , monospace; margin-top:0px; margin-bottom:0px; }\r
13 p.whs4 { margin-top:0px; margin-bottom:0px; }\r
14 p.whs5 { margin-top:0px; margin-bottom:0px; font-family:'Times New Roman' , serif; }\r
15 -->\r
16 </style><script type="text/javascript" language="JavaScript">\r
17 <!--\r
18 if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))\r
19 {\r
20   var strNSS = "<style type='text/css'>";\r
21   strNSS += "p.whs1 {margin-top:1pt;margin-bottom:1pt; }";\r
22   strNSS += "p.whs2 {margin-top:1pt;margin-bottom:1pt; }";\r
23   strNSS += "p.whs3 {margin-top:1pt;margin-bottom:1pt; }";\r
24   strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";\r
25   strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";\r
26   strNSS +="</style>";\r
27   document.write(strNSS);\r
28 }\r
29 //-->\r
30 </script>\r
31 <script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">\r
32 <!--\r
33 function reDo() {\r
34   if (innerWidth != origWidth || innerHeight != origHeight)\r
35      location.reload();\r
36 }\r
37 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {\r
38         origWidth = innerWidth;\r
39         origHeight = innerHeight;\r
40         onresize = reDo;\r
41 }\r
42 onerror = null; \r
43 //-->\r
44 </script>\r
45 <style type="text/css">\r
46 <!--\r
47 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }\r
48 p.WebHelpNavBar { text-align:right; }\r
49 -->\r
50 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>\r
51 <script type="text/javascript" language="javascript" src="whver.js"></script>\r
52 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>\r
53 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>\r
54 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>\r
55 <script type="text/javascript" language="javascript1.2">\r
56 <!--\r
57 if (window.gbWhTopic)\r
58 {\r
59         if (window.setRelStartPage)\r
60         {\r
61         addTocInfo("MESH module\nTUI Scripts\nCreating Meshes");\r
62 addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");\r
63 addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");\r
64 \r
65         }\r
66 \r
67 \r
68         if (window.setRelStartPage)\r
69         {\r
70         setRelStartPage("index.htm");\r
71 \r
72                 autoSync(1);\r
73                 sendSyncInfo();\r
74                 sendAveInfoOut();\r
75         }\r
76 \r
77 }\r
78 else\r
79         if (window.gbIE4)\r
80                 document.location.reload();\r
81 //-->\r
82 </script>\r
83 </head>\r
84 <body><script type="text/javascript" language="javascript1.2">\r
85 <!--\r
86 if (window.writeIntopicBar)\r
87         writeIntopicBar(4);\r
88 //-->\r
89 </script>\r
90 <h1>Creating Meshes</h1>\r
91 \r
92 <h3><a name=bookmark>Construction of a Mesh</a></h3>\r
93 \r
94 <p class="whs1">import salome</p>\r
95 \r
96 <p class="whs1">import geompy</p>\r
97 \r
98 <p class="whs1">import StdMeshers</p>\r
99 \r
100 <p class="whs1">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;, \r
101  &quot;SMESH&quot;)</p>\r
102 \r
103 <p class="whs1">smeshgui = salome.ImportComponentGUI(&quot;SMESH&quot;)</p>\r
104 \r
105 <p class="whs1">smeshgui.Init(salome.myStudyId);</p>\r
106 \r
107 <p class="whs2">&nbsp;</p>\r
108 \r
109 <p class="whs2"># create a box</p>\r
110 \r
111 <p class="whs1">box = geompy.MakeBox(0., \r
112  0., 0., 100., 200., 300.)</p>\r
113 \r
114 <p class="whs2">&nbsp;</p>\r
115 \r
116 <p class="whs2"># add box to the study</p>\r
117 \r
118 <p class="whs1">idbox = geompy.addToStudy(box, \r
119  &quot;box&quot;)</p>\r
120 \r
121 <p class="whs2">&nbsp;</p>\r
122 \r
123 <p class="whs2"># create a hypothesis</p>\r
124 \r
125 <p class="whs1">print &quot;-------------------------- \r
126  create Hypothesis&quot;</p>\r
127 \r
128 <p class="whs1">print &quot;-------------------------- \r
129  NumberOfSegments&quot;</p>\r
130 \r
131 <p class="whs1">numberOfSegments \r
132  = 7</p>\r
133 \r
134 <p class="whs1">hypNbSeg = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, \r
135  &quot;libStdMeshersEngine.so&quot;)</p>\r
136 \r
137 <p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>\r
138 \r
139 <p class="whs1">print hypNbSeg.GetName()</p>\r
140 \r
141 <p class="whs1">print hypNbSeg.GetId()</p>\r
142 \r
143 <p class="whs1">print hypNbSeg.GetNumberOfSegments()</p>\r
144 \r
145 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypNbSeg), \r
146  &quot;NumberOfSegments_10&quot;)</p>\r
147 \r
148 <p class="whs1">print &quot;-------------------------- \r
149  MaxElementArea&quot;</p>\r
150 \r
151 <p class="whs1">maxElementArea = \r
152  800</p>\r
153 \r
154 <p class="whs1">hypArea = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, \r
155  &quot;libStdMeshersEngine.so&quot;)</p>\r
156 \r
157 <p class="whs1">hypArea.SetMaxElementArea(maxElementArea)</p>\r
158 \r
159 <p class="whs1">print hypArea.GetName()</p>\r
160 \r
161 <p class="whs1">print hypArea.GetId()</p>\r
162 \r
163 <p class="whs1">print hypArea.GetMaxElementArea()</p>\r
164 \r
165 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypArea), \r
166  &quot;MaxElementArea_500&quot;)</p>\r
167 \r
168 <p class="whs1">print &quot;-------------------------- \r
169  MaxElementVolume&quot;</p>\r
170 \r
171 <p class="whs1">maxElementVolume \r
172  = 900</p>\r
173 \r
174 <p class="whs1">hypVolume = smesh.CreateHypothesis(&quot;MaxElementVolume&quot;, \r
175  &quot;libStdMeshersEngine.so&quot;)</p>\r
176 \r
177 <p class="whs1">hypVolume.SetMaxElementVolume(maxElementVolume)</p>\r
178 \r
179 <p class="whs1">print hypVolume.GetName()</p>\r
180 \r
181 <p class="whs1">print hypVolume.GetId()</p>\r
182 \r
183 <p class="whs1">print hypVolume.GetMaxElementVolume()</p>\r
184 \r
185 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypVolume), \r
186  &quot;MaxElementVolume_500&quot;)</p>\r
187 \r
188 <p class="whs2">&nbsp;</p>\r
189 \r
190 <p class="whs2"># create algorithms</p>\r
191 \r
192 <p class="whs1">print &quot;-------------------------- \r
193  create Algorithms&quot;</p>\r
194 \r
195 <p class="whs1">print &quot;-------------------------- \r
196  Regular_1D&quot;</p>\r
197 \r
198 <p class="whs1">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;, \r
199  &quot;libStdMeshersEngine.so&quot;)</p>\r
200 \r
201 <p class="whs1">smeshgui.SetName(salome.ObjectToID(regular1D), \r
202  &quot;Wire Discretisation&quot;)</p>\r
203 \r
204 <p class="whs1">print &quot;-------------------------- \r
205  MEFISTO_2D&quot;</p>\r
206 \r
207 <p class="whs1">mefisto2D = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, \r
208  &quot;libStdMeshersEngine.so&quot;)</p>\r
209 \r
210 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mefisto2D), \r
211  &quot;MEFISTO_2D&quot;)</p>\r
212 \r
213 <p class="whs2">&nbsp;</p>\r
214 \r
215 <p class="whs2"># initialize a mesh with \r
216  the box</p>\r
217 \r
218 <p class="whs1">mesh = smesh.CreateMesh(box)</p>\r
219 \r
220 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mesh), \r
221  &quot;MeshBox&quot;)</p>\r
222 \r
223 <p class="whs2">&nbsp;</p>\r
224 \r
225 <p class="whs2"># add the hypothesis to \r
226  the box</p>\r
227 \r
228 <p class="whs1">print &quot;-------------------------- \r
229  add hypothesis to the box&quot;</p>\r
230 \r
231 <p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>\r
232 \r
233 <p class="whs1">mesh.AddHypothesis(box,hypArea)</p>\r
234 \r
235 <p class="whs1">mesh.AddHypothesis(box,hypVolume)</p>\r
236 \r
237 <p class="whs1">mesh.AddHypothesis(box,regular1D)</p>\r
238 \r
239 <p class="whs1">mesh.AddHypothesis(box,mefisto2D)</p>\r
240 \r
241 <p class="whs2">&nbsp;</p>\r
242 \r
243 <p class="whs2"># compute the mesh</p>\r
244 \r
245 <p class="whs1">print &quot;-------------------------- \r
246  compute the mesh of the box&quot;</p>\r
247 \r
248 <p class="whs1">ret = smesh.Compute(mesh,box)</p>\r
249 \r
250 <p class="whs1">print ret</p>\r
251 \r
252 <p class="whs1">if ret == 0:</p>\r
253 \r
254 <p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;print \r
255  &quot;probleme when computing the mesh&quot;</p>\r
256 \r
257 <p class="whs1">salome.sg.updateObjBrowser(1)</p>\r
258 \r
259 <p class="whs1">&nbsp;</p>\r
260 \r
261 <h3><a name=bookmark1>Construction of a Submesh</a></h3>\r
262 \r
263 <p class="whs3">&nbsp;</p>\r
264 \r
265 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">from \r
266  geompy import *</span></p>\r
267 \r
268 <p class="whs3">import smesh</p>\r
269 \r
270 <p class="whs4">&nbsp;</p>\r
271 \r
272 <p class="whs4"># create vertices</p>\r
273 \r
274 <p class="whs3">Point111 = MakeVertex( 0, &nbsp;0, \r
275  &nbsp;0)</p>\r
276 \r
277 <p class="whs3">Point211 = MakeVertex(10, &nbsp;0, \r
278  &nbsp;0)</p>\r
279 \r
280 <p class="whs3">Point121 = MakeVertex( 0, 10, &nbsp;0)</p>\r
281 \r
282 <p class="whs3">Point221 = MakeVertex(10, 10, &nbsp;0)</p>\r
283 \r
284 <p class="whs3">Point112 = MakeVertex( 0, &nbsp;0, \r
285  10)</p>\r
286 \r
287 <p class="whs3">Point212 = MakeVertex(10, &nbsp;0, \r
288  10)</p>\r
289 \r
290 <p class="whs3">Point122 = MakeVertex( 0, 10, 10)</p>\r
291 \r
292 <p class="whs3">Point222 = MakeVertex(10, 10, 10)</p>\r
293 \r
294 <p class="whs4">&nbsp;</p>\r
295 \r
296 <p class="whs4"># create edges</p>\r
297 \r
298 <p class="whs3">EdgeX111 = MakeEdge(Point111, Point211)</p>\r
299 \r
300 <p class="whs3">EdgeX121 = MakeEdge(Point121, Point221)</p>\r
301 \r
302 <p class="whs3">EdgeX112 = MakeEdge(Point112, Point212)</p>\r
303 \r
304 <p class="whs3">EdgeX122 = MakeEdge(Point122, Point222)</p>\r
305 \r
306 <p class="whs3">EdgeY11 = MakeEdge(Point111, Point121)</p>\r
307 \r
308 <p class="whs3">EdgeY21 = MakeEdge(Point211, Point221)</p>\r
309 \r
310 <p class="whs3">EdgeY12 = MakeEdge(Point112, Point122)</p>\r
311 \r
312 <p class="whs3">EdgeY22 = MakeEdge(Point212, Point222)</p>\r
313 \r
314 <p class="whs3">EdgeZ111 = MakeEdge(Point111, Point112)</p>\r
315 \r
316 <p class="whs3">EdgeZ211 = MakeEdge(Point211, Point212)</p>\r
317 \r
318 <p class="whs3">EdgeZ121 = MakeEdge(Point121, Point122)</p>\r
319 \r
320 <p class="whs3">EdgeZ221 = MakeEdge(Point221, Point222)</p>\r
321 \r
322 <p class="whs4">&nbsp;</p>\r
323 \r
324 <p class="whs4"># create faces</p>\r
325 \r
326 <p class="whs3">FaceX11 = MakeQuad(EdgeY11, EdgeZ111, \r
327  EdgeY12, EdgeZ121)</p>\r
328 \r
329 <p class="whs3">FaceX21 = MakeQuad(EdgeY21, EdgeZ211, \r
330  EdgeY22, EdgeZ221)</p>\r
331 \r
332 <p class="whs3">FaceY111 = MakeQuad(EdgeX111, EdgeZ111, \r
333  EdgeX112, EdgeZ211)</p>\r
334 \r
335 <p class="whs3">FaceY121 = MakeQuad(EdgeX121, EdgeZ121, \r
336  EdgeX122, EdgeZ221)</p>\r
337 \r
338 <p class="whs3">FaceZ11 = MakeQuad(EdgeX111, EdgeY11, \r
339  EdgeX121, EdgeY21)</p>\r
340 \r
341 <p class="whs3">FaceZ12 = MakeQuad(EdgeX112, EdgeY12, \r
342  EdgeX122, EdgeY22)</p>\r
343 \r
344 <p class="whs4">&nbsp;</p>\r
345 \r
346 <p class="whs4"># create a solid</p>\r
347 \r
348 <p class="whs3">Block = MakeHexa(FaceX11, FaceX21, FaceY111, \r
349  FaceY121, FaceZ11, FaceZ12)</p>\r
350 \r
351 <p class="whs4">&nbsp;</p>\r
352 \r
353 <p class="whs4"># create a compound</p>\r
354 \r
355 <p class="whs3">box = MakeCompound([Block])</p>\r
356 \r
357 <p class="whs4">&nbsp;</p>\r
358 \r
359 <p class="whs4"># add in the study</p>\r
360 \r
361 <p class="whs3">box_id = addToStudy(box, &quot;Box compound&quot;)</p>\r
362 \r
363 <p class="whs4">&nbsp;</p>\r
364 \r
365 <p class="whs4"># create hexahedral mesh \r
366  on the box</p>\r
367 \r
368 <p class="whs3">hexa = smesh.Mesh(box, &quot;Box compound \r
369  : hexahedrical mesh&quot;)</p>\r
370 \r
371 <p class="whs3">algo = hexa.Segment()</p>\r
372 \r
373 <p class="whs4">&nbsp;</p>\r
374 \r
375 <p class="whs4"># define &quot;NumberOfSegments&quot; \r
376  hypothesis to cut the edge in a fixed number of segments</p>\r
377 \r
378 <p class="whs3">algo.NumberOfSegments(4)</p>\r
379 \r
380 <p class="whs4">&nbsp;</p>\r
381 \r
382 <p class="whs4"># creates a quadrangle \r
383  2D algorithm for the faces</p>\r
384 \r
385 <p class="whs3">hexa.Quadrangle()</p>\r
386 \r
387 <p class="whs4">&nbsp;</p>\r
388 \r
389 <p class="whs4"># construct a submesh with \r
390  a local hypothesis</p>\r
391 \r
392 <p class="whs3">algo = hexa.Segment(EdgeX111)</p>\r
393 \r
394 <p class="whs4">&nbsp;</p>\r
395 \r
396 <p class="whs4"># define &quot;Arithmetic1D&quot; \r
397  hypothesis to cut an edge in several segments with increasing arithmetic \r
398  length </p>\r
399 \r
400 <p class="whs3">algo.Arithmetic1D(1, 4)</p>\r
401 \r
402 <p class="whs4">&nbsp;</p>\r
403 \r
404 <p class="whs4"># define &quot;Propagation&quot; \r
405  hypothesis that propagates all other hypothesis on all edges on the opposite \r
406  side in case of quadrangular faces</p>\r
407 \r
408 <p class="whs3">algo.Propagation()</p>\r
409 \r
410 <p class="whs4">&nbsp;</p>\r
411 \r
412 <p class="whs4"># compute the mesh</p>\r
413 \r
414 <p class="whs3">hexa.Compute() </p>\r
415 \r
416 <p class="whs3">&nbsp;</p>\r
417 \r
418 <h3><a name=bookmark2>Editing of a mesh</a></h3>\r
419 \r
420 <p class="whs3">&nbsp;</p>\r
421 \r
422 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">import \r
423  salome</span></p>\r
424 \r
425 <p class="whs3">import geompy</p>\r
426 \r
427 <p class="whs3">import SMESH</p>\r
428 \r
429 <p class="whs3">import StdMeshers</p>\r
430 \r
431 <p class="whs3">&nbsp;</p>\r
432 \r
433 <p class="whs3">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;, \r
434  &quot;SMESH&quot;)</p>\r
435 \r
436 <p class="whs3">smesh.SetCurrentStudy(salome.myStudy)</p>\r
437 \r
438 <p class="whs3">&nbsp;</p>\r
439 \r
440 <p class="whs3">box &nbsp;&nbsp;= \r
441  geompy.MakeBox(0., 0., 0., 20., 20., 20.)</p>\r
442 \r
443 <p class="whs3">idbox = geompy.addToStudy(box, &quot;box&quot;)</p>\r
444 \r
445 <p class="whs3">&nbsp;</p>\r
446 \r
447 <p class="whs3">subShapeList = geompy.SubShapeAll(box, \r
448  geompy.ShapeType[&quot;EDGE&quot;])</p>\r
449 \r
450 <p class="whs3">edge &nbsp;&nbsp;= \r
451  subShapeList[0]</p>\r
452 \r
453 <p class="whs3">name &nbsp;&nbsp;= \r
454  geompy.SubShapeName(edge, box)</p>\r
455 \r
456 <p class="whs3">idedge = geompy.addToStudyInFather(box, \r
457  edge, name)</p>\r
458 \r
459 <p class="whs3">&nbsp;</p>\r
460 \r
461 <p class="whs3">box &nbsp;= \r
462  salome.IDToObject(idbox)</p>\r
463 \r
464 <p class="whs3">edge = salome.IDToObject(idedge)</p>\r
465 \r
466 <p class="whs3">&nbsp;</p>\r
467 \r
468 <p class="whs3">hyp1 = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, \r
469  &quot;libStdMeshersEngine.so&quot;)</p>\r
470 \r
471 <p class="whs3">hyp1.SetNumberOfSegments(3)</p>\r
472 \r
473 <p class="whs3">hyp2 = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, \r
474  &quot;libStdMeshersEngine.so&quot;)</p>\r
475 \r
476 <p class="whs3">hyp2.SetMaxElementArea(10)</p>\r
477 \r
478 <p class="whs3">hyp3 = smesh.CreateHypothesis(&quot;Arithmetic1D&quot;, \r
479  &quot;libStdMeshersEngine.so&quot;)</p>\r
480 \r
481 <p class="whs3">hyp3.SetLength(1,1)</p>\r
482 \r
483 <p class="whs3">hyp3.SetLength(6,0)</p>\r
484 \r
485 <p class="whs3">hyp4 = smesh.CreateHypothesis(&quot;Propagation&quot;, \r
486  &quot;libStdMeshersEngine.so&quot;)</p>\r
487 \r
488 <p class="whs3">&nbsp;</p>\r
489 \r
490 <p class="whs3">algo1 = smesh.CreateHypothesis(&quot;Regular_1D&quot;, \r
491  &quot;libStdMeshersEngine.so&quot;)</p>\r
492 \r
493 <p class="whs3">algo2 = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, \r
494  &quot;libStdMeshersEngine.so&quot;)</p>\r
495 \r
496 <p class="whs3">&nbsp;</p>\r
497 \r
498 <p class="whs3">mesh = smesh.CreateMesh(box)</p>\r
499 \r
500 <p class="whs3">mesh.AddHypothesis(box,hyp1)</p>\r
501 \r
502 <p class="whs3">mesh.AddHypothesis(box,hyp2)</p>\r
503 \r
504 <p class="whs3">mesh.AddHypothesis(box,algo1)</p>\r
505 \r
506 <p class="whs3">mesh.AddHypothesis(box,algo2)</p>\r
507 \r
508 <p class="whs3">mesh.AddHypothesis(edge,hyp3)</p>\r
509 \r
510 <p class="whs3">mesh.AddHypothesis(edge,hyp4)</p>\r
511 \r
512 <p class="whs3">mesh.AddHypothesis(edge,algo1)</p>\r
513 \r
514 <p class="whs3">&nbsp;</p>\r
515 \r
516 <p class="whs3">smesh.Compute(mesh,box)</p>\r
517 \r
518 <p class="whs3">salome.sg.updateObjBrowser(1)</p>\r
519 \r
520 <p class="whs3">&nbsp;</p>\r
521 \r
522 <p class="whs5"># remove a hypothesis</p>\r
523 \r
524 <p class="whs3">mesh.RemoveHypothesis(edge,hyp4)</p>\r
525 \r
526 <p class="whs3">&nbsp;</p>\r
527 \r
528 <p class="whs3">smesh.Compute(mesh,box)</p>\r
529 \r
530 <p class="whs3">salome.sg.updateObjBrowser(1)</p>\r
531 \r
532 <p class="whs3">&nbsp;</p>\r
533 \r
534 <p class="whs5"># change the value \r
535  of the hypothesis</p>\r
536 \r
537 <p class="whs3">hyp2.SetMaxElementArea(2)</p>\r
538 \r
539 <p class="whs3">mesh.AddHypothesis(box,hyp2)</p>\r
540 \r
541 <p class="whs3">&nbsp;</p>\r
542 \r
543 <p class="whs3">smesh.Compute(mesh,box)</p>\r
544 \r
545 <p class="whs3">salome.sg.updateObjBrowser(1) </p>\r
546 \r
547 <p class="whs4">&nbsp;</p>\r
548 \r
549 <h3><a name=bookmark3>Export of a Mesh</a></h3>\r
550 \r
551 <p class="whs4">&nbsp;</p>\r
552 \r
553 <p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import \r
554  salome</span></p>\r
555 \r
556 <p class="whs1">import geompy</p>\r
557 \r
558 <p class="whs1">import StdMeshers</p>\r
559 \r
560 <p class="whs1">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;, \r
561  &quot;SMESH&quot;)</p>\r
562 \r
563 <p class="whs1">smeshgui = salome.ImportComponentGUI(&quot;SMESH&quot;)</p>\r
564 \r
565 <p class="whs1">smeshgui.Init(salome.myStudyId);</p>\r
566 \r
567 <p class="whs2">&nbsp;</p>\r
568 \r
569 <p class="whs2"># create a box</p>\r
570 \r
571 <p class="whs1">box = geompy.MakeBox(0., \r
572  0., 0., 100., 200., 300.)</p>\r
573 \r
574 <p class="whs2">&nbsp;</p>\r
575 \r
576 <p class="whs2"># add the box to the study</p>\r
577 \r
578 <p class="whs1">idbox = geompy.addToStudy(box, \r
579  &quot;box&quot;)</p>\r
580 \r
581 <p class="whs2">&nbsp;</p>\r
582 \r
583 <p class="whs2"># create a hypothesis</p>\r
584 \r
585 <p class="whs1">print &quot;-------------------------- \r
586  create Hypothesis&quot;</p>\r
587 \r
588 <p class="whs1">print &quot;-------------------------- \r
589  NumberOfSegments&quot;</p>\r
590 \r
591 <p class="whs1">numberOfSegments \r
592  = 7</p>\r
593 \r
594 <p class="whs1">hypNbSeg = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, \r
595  &quot;libStdMeshersEngine.so&quot;)</p>\r
596 \r
597 <p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>\r
598 \r
599 <p class="whs1">print hypNbSeg.GetName()</p>\r
600 \r
601 <p class="whs1">print hypNbSeg.GetId()</p>\r
602 \r
603 <p class="whs1">print hypNbSeg.GetNumberOfSegments()</p>\r
604 \r
605 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypNbSeg), \r
606  &quot;NumberOfSegments_10&quot;)</p>\r
607 \r
608 <p class="whs1">print &quot;-------------------------- \r
609  MaxElementArea&quot;</p>\r
610 \r
611 <p class="whs1">maxElementArea = \r
612  800</p>\r
613 \r
614 <p class="whs1">hypArea = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, \r
615  &quot;libStdMeshersEngine.so&quot;)</p>\r
616 \r
617 <p class="whs1">hypArea.SetMaxElementArea(maxElementArea)</p>\r
618 \r
619 <p class="whs1">print hypArea.GetName()</p>\r
620 \r
621 <p class="whs1">print hypArea.GetId()</p>\r
622 \r
623 <p class="whs1">print hypArea.GetMaxElementArea()</p>\r
624 \r
625 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypArea), \r
626  &quot;MaxElementArea_500&quot;)</p>\r
627 \r
628 <p class="whs1">print &quot;-------------------------- \r
629  MaxElementVolume&quot;</p>\r
630 \r
631 <p class="whs1">maxElementVolume \r
632  = 900</p>\r
633 \r
634 <p class="whs1">hypVolume = smesh.CreateHypothesis(&quot;MaxElementVolume&quot;, \r
635  &quot;libStdMeshersEngine.so&quot;)</p>\r
636 \r
637 <p class="whs1">hypVolume.SetMaxElementVolume(maxElementVolume)</p>\r
638 \r
639 <p class="whs1">print hypVolume.GetName()</p>\r
640 \r
641 <p class="whs1">print hypVolume.GetId()</p>\r
642 \r
643 <p class="whs1">print hypVolume.GetMaxElementVolume()</p>\r
644 \r
645 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypVolume), \r
646  &quot;MaxElementVolume_500&quot;)</p>\r
647 \r
648 <p class="whs2">&nbsp;</p>\r
649 \r
650 <p class="whs2"># create algorithms</p>\r
651 \r
652 <p class="whs1">print &quot;-------------------------- \r
653  create Algorithms&quot;</p>\r
654 \r
655 <p class="whs1">print &quot;-------------------------- \r
656  Regular_1D&quot;</p>\r
657 \r
658 <p class="whs1">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;, \r
659  &quot;libStdMeshersEngine.so&quot;)</p>\r
660 \r
661 <p class="whs1">smeshgui.SetName(salome.ObjectToID(regular1D), \r
662  &quot;Wire Discretisation&quot;)</p>\r
663 \r
664 <p class="whs1">print &quot;-------------------------- \r
665  MEFISTO_2D&quot;</p>\r
666 \r
667 <p class="whs1">mefisto2D = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, \r
668  &quot;libStdMeshersEngine.so&quot;)</p>\r
669 \r
670 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mefisto2D), \r
671  &quot;MEFISTO_2D&quot;)</p>\r
672 \r
673 <p class="whs2">&nbsp;</p>\r
674 \r
675 <p class="whs2"># initialize a mesh with \r
676  the box</p>\r
677 \r
678 <p class="whs1">mesh = smesh.CreateMesh(box)</p>\r
679 \r
680 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mesh), \r
681  &quot;MeshBox&quot;)</p>\r
682 \r
683 <p class="whs1">&nbsp;</p>\r
684 \r
685 <p class="whs2"># add the hypothesis to \r
686  the box</p>\r
687 \r
688 <p class="whs1">print &quot;-------------------------- \r
689  add hypothesis to the box&quot;</p>\r
690 \r
691 <p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>\r
692 \r
693 <p class="whs1">mesh.AddHypothesis(box,hypArea)</p>\r
694 \r
695 <p class="whs1">mesh.AddHypothesis(box,hypVolume)</p>\r
696 \r
697 <p class="whs1">mesh.AddHypothesis(box,regular1D)</p>\r
698 \r
699 <p class="whs1">mesh.AddHypothesis(box,mefisto2D)</p>\r
700 \r
701 <p class="whs2">&nbsp;</p>\r
702 \r
703 <p class="whs2"># compute the mesh</p>\r
704 \r
705 <p class="whs1">print &quot;-------------------------- \r
706  compute the mesh of the box&quot;</p>\r
707 \r
708 <p class="whs1">ret = smesh.Compute(mesh,box)</p>\r
709 \r
710 <p class="whs1">print ret</p>\r
711 \r
712 <p class="whs1">if ret == 0:</p>\r
713 \r
714 <p class="whs1">&nbsp;&nbsp;&nbsp;&nbsp;print \r
715  &quot;probleme when computing the mesh&quot;</p>\r
716 \r
717 <p class="whs1">salome.sg.updateObjBrowser(1)</p>\r
718 \r
719 <p class="whs1">mesh.ExportMED(&quot;/tmp/meshMED.med&quot;,0)</p>\r
720 \r
721 <p class="whs2">&nbsp;</p>\r
722 \r
723 <p class="whs4">&nbsp;</p>\r
724 \r
725 <script type="text/javascript" language="javascript1.2">\r
726 <!--\r
727 if (window.writeIntopicBar)\r
728         writeIntopicBar(0);\r
729 //-->\r
730 </script>\r
731 </body>\r
732 </html>\r