1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
6 <title>Constructing Meshes</title>
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style type="text/css">
10 p.whs1 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
11 p.whs2 { margin-top:0pt; margin-bottom:0pt; }
12 p.whs3 { font-family:'Lucida Console' , monospace; margin-top:0px; margin-bottom:0px; }
13 p.whs4 { margin-top:0px; margin-bottom:0px; }
14 p.whs5 { margin-top:0px; margin-bottom:0px; font-family:'Times New Roman' , serif; }
16 </style><script type="text/javascript" language="JavaScript">
18 if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
20 var strNSS = "<style type='text/css'>";
21 strNSS += "p.whs1 {margin-top:1pt;margin-bottom:1pt; }";
22 strNSS += "p.whs2 {margin-top:1pt;margin-bottom:1pt; }";
23 strNSS += "p.whs3 {margin-top:1pt;margin-bottom:1pt; }";
24 strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";
25 strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";
27 document.write(strNSS);
31 <script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
34 if (innerWidth != origWidth || innerHeight != origHeight)
37 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
38 origWidth = innerWidth;
39 origHeight = innerHeight;
45 <style type="text/css">
47 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
48 p.WebHelpNavBar { text-align:right; }
50 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
51 <script type="text/javascript" language="javascript" src="whver.js"></script>
52 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
53 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
54 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
55 <script type="text/javascript" language="javascript1.2">
59 if (window.setRelStartPage)
61 addTocInfo("MESH module\nTUI Scripts\nCreating Meshes");
62 addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");
63 addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");
68 if (window.setRelStartPage)
70 setRelStartPage("index.htm");
80 document.location.reload();
84 <body><script type="text/javascript" language="javascript1.2">
86 if (window.writeIntopicBar)
90 <h1>Creating Meshes</h1>
92 <h3><a name=bookmark>Construction of a Mesh</a></h3>
94 <p class="whs1">import salome</p>
96 <p class="whs1">import geompy</p>
98 <p class="whs1">import StdMeshers</p>
100 <p class="whs1">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
101 "SMESH")</p>
103 <p class="whs1">smeshgui = salome.ImportComponentGUI("SMESH")</p>
105 <p class="whs1">smeshgui.Init(salome.myStudyId);</p>
107 <p class="whs2"> </p>
109 <p class="whs2"># create a box</p>
111 <p class="whs1">box = geompy.MakeBox(0.,
112 0., 0., 100., 200., 300.)</p>
114 <p class="whs2"> </p>
116 <p class="whs2"># add box to the study</p>
118 <p class="whs1">idbox = geompy.addToStudy(box,
121 <p class="whs2"> </p>
123 <p class="whs2"># create a hypothesis</p>
125 <p class="whs1">print "--------------------------
126 create Hypothesis"</p>
128 <p class="whs1">print "--------------------------
129 NumberOfSegments"</p>
131 <p class="whs1">numberOfSegments
134 <p class="whs1">hypNbSeg = smesh.CreateHypothesis("NumberOfSegments",
135 "libStdMeshersEngine.so")</p>
137 <p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>
139 <p class="whs1">print hypNbSeg.GetName()</p>
141 <p class="whs1">print hypNbSeg.GetId()</p>
143 <p class="whs1">print hypNbSeg.GetNumberOfSegments()</p>
145 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypNbSeg),
146 "NumberOfSegments_10")</p>
148 <p class="whs1">print "--------------------------
149 MaxElementArea"</p>
151 <p class="whs1">maxElementArea =
154 <p class="whs1">hypArea = smesh.CreateHypothesis("MaxElementArea",
155 "libStdMeshersEngine.so")</p>
157 <p class="whs1">hypArea.SetMaxElementArea(maxElementArea)</p>
159 <p class="whs1">print hypArea.GetName()</p>
161 <p class="whs1">print hypArea.GetId()</p>
163 <p class="whs1">print hypArea.GetMaxElementArea()</p>
165 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypArea),
166 "MaxElementArea_500")</p>
168 <p class="whs1">print "--------------------------
169 MaxElementVolume"</p>
171 <p class="whs1">maxElementVolume
174 <p class="whs1">hypVolume = smesh.CreateHypothesis("MaxElementVolume",
175 "libStdMeshersEngine.so")</p>
177 <p class="whs1">hypVolume.SetMaxElementVolume(maxElementVolume)</p>
179 <p class="whs1">print hypVolume.GetName()</p>
181 <p class="whs1">print hypVolume.GetId()</p>
183 <p class="whs1">print hypVolume.GetMaxElementVolume()</p>
185 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypVolume),
186 "MaxElementVolume_500")</p>
188 <p class="whs2"> </p>
190 <p class="whs2"># create algorithms</p>
192 <p class="whs1">print "--------------------------
193 create Algorithms"</p>
195 <p class="whs1">print "--------------------------
198 <p class="whs1">regular1D = smesh.CreateHypothesis("Regular_1D",
199 "libStdMeshersEngine.so")</p>
201 <p class="whs1">smeshgui.SetName(salome.ObjectToID(regular1D),
202 "Wire Discretisation")</p>
204 <p class="whs1">print "--------------------------
207 <p class="whs1">mefisto2D = smesh.CreateHypothesis("MEFISTO_2D",
208 "libStdMeshersEngine.so")</p>
210 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mefisto2D),
211 "MEFISTO_2D")</p>
213 <p class="whs2"> </p>
215 <p class="whs2"># initialize a mesh with
218 <p class="whs1">mesh = smesh.CreateMesh(box)</p>
220 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mesh),
221 "MeshBox")</p>
223 <p class="whs2"> </p>
225 <p class="whs2"># add the hypothesis to
228 <p class="whs1">print "--------------------------
229 add hypothesis to the box"</p>
231 <p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>
233 <p class="whs1">mesh.AddHypothesis(box,hypArea)</p>
235 <p class="whs1">mesh.AddHypothesis(box,hypVolume)</p>
237 <p class="whs1">mesh.AddHypothesis(box,regular1D)</p>
239 <p class="whs1">mesh.AddHypothesis(box,mefisto2D)</p>
241 <p class="whs2"> </p>
243 <p class="whs2"># compute the mesh</p>
245 <p class="whs1">print "--------------------------
246 compute the mesh of the box"</p>
248 <p class="whs1">ret = smesh.Compute(mesh,box)</p>
250 <p class="whs1">print ret</p>
252 <p class="whs1">if ret == 0:</p>
254 <p class="whs1"> print
255 "probleme when computing the mesh"</p>
257 <p class="whs1">salome.sg.updateObjBrowser(1)</p>
259 <p class="whs1"> </p>
261 <h3><a name=bookmark1>Construction of a Submesh</a></h3>
263 <p class="whs3"> </p>
265 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">from
266 geompy import *</span></p>
268 <p class="whs3">import smesh</p>
270 <p class="whs4"> </p>
272 <p class="whs4"># create vertices</p>
274 <p class="whs3">Point111 = MakeVertex( 0, 0,
277 <p class="whs3">Point211 = MakeVertex(10, 0,
280 <p class="whs3">Point121 = MakeVertex( 0, 10, 0)</p>
282 <p class="whs3">Point221 = MakeVertex(10, 10, 0)</p>
284 <p class="whs3">Point112 = MakeVertex( 0, 0,
287 <p class="whs3">Point212 = MakeVertex(10, 0,
290 <p class="whs3">Point122 = MakeVertex( 0, 10, 10)</p>
292 <p class="whs3">Point222 = MakeVertex(10, 10, 10)</p>
294 <p class="whs4"> </p>
296 <p class="whs4"># create edges</p>
298 <p class="whs3">EdgeX111 = MakeEdge(Point111, Point211)</p>
300 <p class="whs3">EdgeX121 = MakeEdge(Point121, Point221)</p>
302 <p class="whs3">EdgeX112 = MakeEdge(Point112, Point212)</p>
304 <p class="whs3">EdgeX122 = MakeEdge(Point122, Point222)</p>
306 <p class="whs3">EdgeY11 = MakeEdge(Point111, Point121)</p>
308 <p class="whs3">EdgeY21 = MakeEdge(Point211, Point221)</p>
310 <p class="whs3">EdgeY12 = MakeEdge(Point112, Point122)</p>
312 <p class="whs3">EdgeY22 = MakeEdge(Point212, Point222)</p>
314 <p class="whs3">EdgeZ111 = MakeEdge(Point111, Point112)</p>
316 <p class="whs3">EdgeZ211 = MakeEdge(Point211, Point212)</p>
318 <p class="whs3">EdgeZ121 = MakeEdge(Point121, Point122)</p>
320 <p class="whs3">EdgeZ221 = MakeEdge(Point221, Point222)</p>
322 <p class="whs4"> </p>
324 <p class="whs4"># create faces</p>
326 <p class="whs3">FaceX11 = MakeQuad(EdgeY11, EdgeZ111,
327 EdgeY12, EdgeZ121)</p>
329 <p class="whs3">FaceX21 = MakeQuad(EdgeY21, EdgeZ211,
330 EdgeY22, EdgeZ221)</p>
332 <p class="whs3">FaceY111 = MakeQuad(EdgeX111, EdgeZ111,
333 EdgeX112, EdgeZ211)</p>
335 <p class="whs3">FaceY121 = MakeQuad(EdgeX121, EdgeZ121,
336 EdgeX122, EdgeZ221)</p>
338 <p class="whs3">FaceZ11 = MakeQuad(EdgeX111, EdgeY11,
339 EdgeX121, EdgeY21)</p>
341 <p class="whs3">FaceZ12 = MakeQuad(EdgeX112, EdgeY12,
342 EdgeX122, EdgeY22)</p>
344 <p class="whs4"> </p>
346 <p class="whs4"># create a solid</p>
348 <p class="whs3">Block = MakeHexa(FaceX11, FaceX21, FaceY111,
349 FaceY121, FaceZ11, FaceZ12)</p>
351 <p class="whs4"> </p>
353 <p class="whs4"># create a compound</p>
355 <p class="whs3">box = MakeCompound([Block])</p>
357 <p class="whs4"> </p>
359 <p class="whs4"># add in the study</p>
361 <p class="whs3">box_id = addToStudy(box, "Box compound")</p>
363 <p class="whs4"> </p>
365 <p class="whs4"># create hexahedral mesh
368 <p class="whs3">hexa = smesh.Mesh(box, "Box compound
369 : hexahedrical mesh")</p>
371 <p class="whs3">algo = hexa.Segment()</p>
373 <p class="whs4"> </p>
375 <p class="whs4"># define "NumberOfSegments"
376 hypothesis to cut the edge in a fixed number of segments</p>
378 <p class="whs3">algo.NumberOfSegments(4)</p>
380 <p class="whs4"> </p>
382 <p class="whs4"># creates a quadrangle
383 2D algorithm for the faces</p>
385 <p class="whs3">hexa.Quadrangle()</p>
387 <p class="whs4"> </p>
389 <p class="whs4"># construct a submesh with
390 a local hypothesis</p>
392 <p class="whs3">algo = hexa.Segment(EdgeX111)</p>
394 <p class="whs4"> </p>
396 <p class="whs4"># define "Arithmetic1D"
397 hypothesis to cut an edge in several segments with increasing arithmetic
400 <p class="whs3">algo.Arithmetic1D(1, 4)</p>
402 <p class="whs4"> </p>
404 <p class="whs4"># define "Propagation"
405 hypothesis that propagates all other hypothesis on all edges on the opposite
406 side in case of quadrangular faces</p>
408 <p class="whs3">algo.Propagation()</p>
410 <p class="whs4"> </p>
412 <p class="whs4"># compute the mesh</p>
414 <p class="whs3">hexa.Compute() </p>
416 <p class="whs3"> </p>
418 <h3><a name=bookmark2>Editing of a mesh</a></h3>
420 <p class="whs3"> </p>
422 <p class="whs3"><span style="font-family: 'Lucida Console', monospace;">import
425 <p class="whs3">import geompy</p>
427 <p class="whs3">import SMESH</p>
429 <p class="whs3">import StdMeshers</p>
431 <p class="whs3"> </p>
433 <p class="whs3">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
434 "SMESH")</p>
436 <p class="whs3">smesh.SetCurrentStudy(salome.myStudy)</p>
438 <p class="whs3"> </p>
440 <p class="whs3">box =
441 geompy.MakeBox(0., 0., 0., 20., 20., 20.)</p>
443 <p class="whs3">idbox = geompy.addToStudy(box, "box")</p>
445 <p class="whs3"> </p>
447 <p class="whs3">subShapeList = geompy.SubShapeAll(box,
448 geompy.ShapeType["EDGE"])</p>
450 <p class="whs3">edge =
453 <p class="whs3">name =
454 geompy.SubShapeName(edge, box)</p>
456 <p class="whs3">idedge = geompy.addToStudyInFather(box,
459 <p class="whs3"> </p>
461 <p class="whs3">box =
462 salome.IDToObject(idbox)</p>
464 <p class="whs3">edge = salome.IDToObject(idedge)</p>
466 <p class="whs3"> </p>
468 <p class="whs3">hyp1 = smesh.CreateHypothesis("NumberOfSegments",
469 "libStdMeshersEngine.so")</p>
471 <p class="whs3">hyp1.SetNumberOfSegments(3)</p>
473 <p class="whs3">hyp2 = smesh.CreateHypothesis("MaxElementArea",
474 "libStdMeshersEngine.so")</p>
476 <p class="whs3">hyp2.SetMaxElementArea(10)</p>
478 <p class="whs3">hyp3 = smesh.CreateHypothesis("Arithmetic1D",
479 "libStdMeshersEngine.so")</p>
481 <p class="whs3">hyp3.SetLength(1,1)</p>
483 <p class="whs3">hyp3.SetLength(6,0)</p>
485 <p class="whs3">hyp4 = smesh.CreateHypothesis("Propagation",
486 "libStdMeshersEngine.so")</p>
488 <p class="whs3"> </p>
490 <p class="whs3">algo1 = smesh.CreateHypothesis("Regular_1D",
491 "libStdMeshersEngine.so")</p>
493 <p class="whs3">algo2 = smesh.CreateHypothesis("MEFISTO_2D",
494 "libStdMeshersEngine.so")</p>
496 <p class="whs3"> </p>
498 <p class="whs3">mesh = smesh.CreateMesh(box)</p>
500 <p class="whs3">mesh.AddHypothesis(box,hyp1)</p>
502 <p class="whs3">mesh.AddHypothesis(box,hyp2)</p>
504 <p class="whs3">mesh.AddHypothesis(box,algo1)</p>
506 <p class="whs3">mesh.AddHypothesis(box,algo2)</p>
508 <p class="whs3">mesh.AddHypothesis(edge,hyp3)</p>
510 <p class="whs3">mesh.AddHypothesis(edge,hyp4)</p>
512 <p class="whs3">mesh.AddHypothesis(edge,algo1)</p>
514 <p class="whs3"> </p>
516 <p class="whs3">smesh.Compute(mesh,box)</p>
518 <p class="whs3">salome.sg.updateObjBrowser(1)</p>
520 <p class="whs3"> </p>
522 <p class="whs5"># remove a hypothesis</p>
524 <p class="whs3">mesh.RemoveHypothesis(edge,hyp4)</p>
526 <p class="whs3"> </p>
528 <p class="whs3">smesh.Compute(mesh,box)</p>
530 <p class="whs3">salome.sg.updateObjBrowser(1)</p>
532 <p class="whs3"> </p>
534 <p class="whs5"># change the value
535 of the hypothesis</p>
537 <p class="whs3">hyp2.SetMaxElementArea(2)</p>
539 <p class="whs3">mesh.AddHypothesis(box,hyp2)</p>
541 <p class="whs3"> </p>
543 <p class="whs3">smesh.Compute(mesh,box)</p>
545 <p class="whs3">salome.sg.updateObjBrowser(1) </p>
547 <p class="whs4"> </p>
549 <h3><a name=bookmark3>Export of a Mesh</a></h3>
551 <p class="whs4"> </p>
553 <p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
556 <p class="whs1">import geompy</p>
558 <p class="whs1">import StdMeshers</p>
560 <p class="whs1">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
561 "SMESH")</p>
563 <p class="whs1">smeshgui = salome.ImportComponentGUI("SMESH")</p>
565 <p class="whs1">smeshgui.Init(salome.myStudyId);</p>
567 <p class="whs2"> </p>
569 <p class="whs2"># create a box</p>
571 <p class="whs1">box = geompy.MakeBox(0.,
572 0., 0., 100., 200., 300.)</p>
574 <p class="whs2"> </p>
576 <p class="whs2"># add the box to the study</p>
578 <p class="whs1">idbox = geompy.addToStudy(box,
581 <p class="whs2"> </p>
583 <p class="whs2"># create a hypothesis</p>
585 <p class="whs1">print "--------------------------
586 create Hypothesis"</p>
588 <p class="whs1">print "--------------------------
589 NumberOfSegments"</p>
591 <p class="whs1">numberOfSegments
594 <p class="whs1">hypNbSeg = smesh.CreateHypothesis("NumberOfSegments",
595 "libStdMeshersEngine.so")</p>
597 <p class="whs1">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>
599 <p class="whs1">print hypNbSeg.GetName()</p>
601 <p class="whs1">print hypNbSeg.GetId()</p>
603 <p class="whs1">print hypNbSeg.GetNumberOfSegments()</p>
605 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypNbSeg),
606 "NumberOfSegments_10")</p>
608 <p class="whs1">print "--------------------------
609 MaxElementArea"</p>
611 <p class="whs1">maxElementArea =
614 <p class="whs1">hypArea = smesh.CreateHypothesis("MaxElementArea",
615 "libStdMeshersEngine.so")</p>
617 <p class="whs1">hypArea.SetMaxElementArea(maxElementArea)</p>
619 <p class="whs1">print hypArea.GetName()</p>
621 <p class="whs1">print hypArea.GetId()</p>
623 <p class="whs1">print hypArea.GetMaxElementArea()</p>
625 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypArea),
626 "MaxElementArea_500")</p>
628 <p class="whs1">print "--------------------------
629 MaxElementVolume"</p>
631 <p class="whs1">maxElementVolume
634 <p class="whs1">hypVolume = smesh.CreateHypothesis("MaxElementVolume",
635 "libStdMeshersEngine.so")</p>
637 <p class="whs1">hypVolume.SetMaxElementVolume(maxElementVolume)</p>
639 <p class="whs1">print hypVolume.GetName()</p>
641 <p class="whs1">print hypVolume.GetId()</p>
643 <p class="whs1">print hypVolume.GetMaxElementVolume()</p>
645 <p class="whs1">smeshgui.SetName(salome.ObjectToID(hypVolume),
646 "MaxElementVolume_500")</p>
648 <p class="whs2"> </p>
650 <p class="whs2"># create algorithms</p>
652 <p class="whs1">print "--------------------------
653 create Algorithms"</p>
655 <p class="whs1">print "--------------------------
658 <p class="whs1">regular1D = smesh.CreateHypothesis("Regular_1D",
659 "libStdMeshersEngine.so")</p>
661 <p class="whs1">smeshgui.SetName(salome.ObjectToID(regular1D),
662 "Wire Discretisation")</p>
664 <p class="whs1">print "--------------------------
667 <p class="whs1">mefisto2D = smesh.CreateHypothesis("MEFISTO_2D",
668 "libStdMeshersEngine.so")</p>
670 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mefisto2D),
671 "MEFISTO_2D")</p>
673 <p class="whs2"> </p>
675 <p class="whs2"># initialize a mesh with
678 <p class="whs1">mesh = smesh.CreateMesh(box)</p>
680 <p class="whs1">smeshgui.SetName(salome.ObjectToID(mesh),
681 "MeshBox")</p>
683 <p class="whs1"> </p>
685 <p class="whs2"># add the hypothesis to
688 <p class="whs1">print "--------------------------
689 add hypothesis to the box"</p>
691 <p class="whs1">mesh.AddHypothesis(box,hypNbSeg)</p>
693 <p class="whs1">mesh.AddHypothesis(box,hypArea)</p>
695 <p class="whs1">mesh.AddHypothesis(box,hypVolume)</p>
697 <p class="whs1">mesh.AddHypothesis(box,regular1D)</p>
699 <p class="whs1">mesh.AddHypothesis(box,mefisto2D)</p>
701 <p class="whs2"> </p>
703 <p class="whs2"># compute the mesh</p>
705 <p class="whs1">print "--------------------------
706 compute the mesh of the box"</p>
708 <p class="whs1">ret = smesh.Compute(mesh,box)</p>
710 <p class="whs1">print ret</p>
712 <p class="whs1">if ret == 0:</p>
714 <p class="whs1"> print
715 "probleme when computing the mesh"</p>
717 <p class="whs1">salome.sg.updateObjBrowser(1)</p>
719 <p class="whs1">mesh.ExportMED("/tmp/meshMED.med",0)</p>
721 <p class="whs2"> </p>
723 <p class="whs4"> </p>
725 <script type="text/javascript" language="javascript1.2">
727 if (window.writeIntopicBar)