1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
6 <title>Defining hypotheses TUI</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>
10 P { margin-top:0pt; margin-bottom:0pt; }
13 </style><style type="text/css">
15 p.whs1 { font-weight:bold; }
16 p.whs2 { font-family:'Lucida Console' , monospace; }
17 p.whs3 { font-family:'Times New Roman' , serif; }
18 p.whs4 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
19 p.whs5 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
20 p.whs6 { margin-top:0pt; margin-bottom:0pt; }
22 </style><script type="text/javascript" language="JavaScript">
24 if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
26 var strNSS = "<style type='text/css'>";
27 strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";
28 strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";
29 strNSS += "p.whs6 {margin-top:1pt;margin-bottom:1pt; }";
31 document.write(strNSS);
35 <script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
38 if (innerWidth != origWidth || innerHeight != origHeight)
41 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
42 origWidth = innerWidth;
43 origHeight = innerHeight;
49 <style type="text/css">
51 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
52 p.WebHelpNavBar { text-align:right; }
54 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
55 <script type="text/javascript" language="javascript" src="whver.js"></script>
56 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
57 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
58 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
59 <script type="text/javascript" language="javascript1.2">
63 if (window.setRelStartPage)
65 addTocInfo("MESH module\nTUI Scripts\nDefining Hypotheses");
66 addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");
67 addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");
72 if (window.setRelStartPage)
74 setRelStartPage("index.htm");
84 document.location.reload();
88 <body><script type="text/javascript" language="javascript1.2">
90 if (window.writeIntopicBar)
94 <h1>Defining Hypotheses and Algorithms</h1>
96 <h3>Defining 1D Hypotheses</h3>
98 <p class="whs1"><a name=bookmark>1D Arithmetic</a></p>
102 <p class="whs2">from geompy import
105 <p class="whs2">import smesh</p>
109 <p># create vertices</p>
111 <p class="whs2">Point111 = MakeVertex(
112 0, 0, 0)</p>
114 <p class="whs2">Point211 = MakeVertex(10,
115 0, 0)</p>
117 <p class="whs2">Point121 = MakeVertex(
120 <p class="whs2">Point221 = MakeVertex(10,
123 <p class="whs2">Point112 = MakeVertex(
126 <p class="whs2">Point212 = MakeVertex(10,
129 <p class="whs2">Point122 = MakeVertex(
132 <p class="whs2">Point222 = MakeVertex(10,
137 <p># create edges</p>
139 <p class="whs2">EdgeX111 = MakeEdge(Point111,
142 <p class="whs2">EdgeX121 = MakeEdge(Point121,
145 <p class="whs2">EdgeX112 = MakeEdge(Point112,
148 <p class="whs2">EdgeX122 = MakeEdge(Point122,
151 <p class="whs2">EdgeY11 = MakeEdge(Point111,
154 <p class="whs2">EdgeY21 = MakeEdge(Point211,
157 <p class="whs2">EdgeY12 = MakeEdge(Point112,
160 <p class="whs2">EdgeY22 = MakeEdge(Point212,
163 <p class="whs2">EdgeZ111 = MakeEdge(Point111,
166 <p class="whs2">EdgeZ211 = MakeEdge(Point211,
169 <p class="whs2">EdgeZ121 = MakeEdge(Point121,
172 <p class="whs2">EdgeZ221 = MakeEdge(Point221,
177 <p># create faces</p>
179 <p class="whs2">FaceX11 = MakeQuad(EdgeY11,
180 EdgeZ111, EdgeY12, EdgeZ121)</p>
182 <p class="whs2">FaceX21 = MakeQuad(EdgeY21,
183 EdgeZ211, EdgeY22, EdgeZ221)</p>
185 <p class="whs2">FaceY111 = MakeQuad(EdgeX111,
186 EdgeZ111, EdgeX112, EdgeZ211)</p>
188 <p class="whs2">FaceY121 = MakeQuad(EdgeX121,
189 EdgeZ121, EdgeX122, EdgeZ221)</p>
191 <p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
192 EdgeY11, EdgeX121, EdgeY21)</p>
194 <p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
195 EdgeY12, EdgeX122, EdgeY22)</p>
199 <p># create a solid</p>
201 <p class="whs2">Block = MakeHexa(FaceX11,
202 FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
206 <p># create a compound</p>
208 <p class="whs2">box = MakeCompound([Block])</p>
212 <p># add in the study</p>
214 <p class="whs2">box_id = addToStudy(box,
215 "Box compound")</p>
219 <p># create a hexahedral mesh on the box</p>
221 <p class="whs2">hexa = smesh.Mesh(box,
222 "Box compound : hexahedrical mesh")</p>
224 <p class="whs2">algo = hexa.Segment()</p>
228 <p># define "NumberOfSegments" hypothesis to cut an edge in a
229 fixed number of segments</p>
231 <p class="whs2">algo.NumberOfSegments(4)</p>
235 <p># create a quadrangle 2D algorithm for faces</p>
237 <p class="whs2">hexa.Quadrangle()</p>
241 <p># create a hexahedron 3D algorithm for solids</p>
243 <p class="whs2">hexa.Hexahedron()</p>
247 <p># create a local hypothesis</p>
249 <p class="whs2">algo = hexa.Segment(EdgeX111)</p>
253 <p># define "Arithmetic1D" hypothesis to cut an edge in several
254 segments with arithmetic length increasing</p>
256 <p class="whs2">algo.Arithmetic1D(1,
261 <p># define "Propagation" hypothesis that propagates all other
262 hypothesis on all edges on the opposite side in case of quadrangular faces</p>
264 <p class="whs2">algo.Propagation()</p>
268 <p># compute the mesh</p>
270 <p class="whs2">hexa.Compute() </p>
272 <p class="whs2"> </p>
274 <h4><a name=bookmark9>Deflection 1D and Number of Segments</a></h4>
276 <p class="whs2"> </p>
278 <p class="whs2">import smesh</p>
280 <p class="whs2">import geompy</p>
282 <p class="whs2">import salome</p>
284 <p class="whs2">gg = salome.ImportComponentGUI("GEOM")</p>
286 <p class="whs2"> </p>
288 <p class="whs3"># create vertices</p>
290 <p class="whs2">px =
291 geompy.MakeVertex(100., 0. ,
294 <p class="whs2">py =
295 geompy.MakeVertex(0. ,
298 <p class="whs2">pz =
299 geompy.MakeVertex(0. ,
302 <p class="whs2"> </p>
304 <p class="whs3"># create a vector from
307 <p class="whs2">vxy = geompy.MakeVector(px,
310 <p class="whs2"> </p>
312 <p class="whs3"># create an arc from
315 <p class="whs2">arc = geompy.MakeArc(py,
318 <p class="whs2"> </p>
320 <p class="whs3"># create a wire</p>
322 <p class="whs2">wire = geompy.MakeWire([vxy,
325 <p class="whs2">isPlanarFace = 1</p>
327 <p class="whs2"> </p>
329 <p class="whs3"># create a face from
332 <p class="whs2">face1 = geompy.MakeFace(wire,
335 <p class="whs2"> </p>
337 <p class="whs3"><span style="font-family: 'Times New Roman', serif;">#
338 get edges from the face</span></p>
340 <p class="whs2">vxy,arc = geompy.SubShapeAll(face1,geompy.ShapeType["EDGE"])</p>
342 <p class="whs3"> </p>
344 <p class="whs3"># add objects in the
347 <p class="whs2">id_face1 = geompy.addToStudy(face1,"Face1")</p>
349 <p class="whs2">id_arc = geompy.addToStudyInFather(face1,arc,"Arc
352 <p class="whs2"> </p>
354 <p class="whs3"># display faces</p>
356 <p class="whs2">gg.createAndDisplayGO(id_face1)</p>
358 <p class="whs2">gg.setDisplayMode(id_face1,1)</p>
360 <p class="whs2">gg.setTransparency(id_face1,0.2)</p>
362 <p class="whs2"> </p>
364 <p class="whs3"># create hexahedral mesh</p>
366 <p class="whs2">hexa = smesh.Mesh(face1,
367 "Face compound : hexahedrical mesh")</p>
369 <p class="whs2">algo = hexa.Triangle()</p>
371 <p class="whs2"> </p>
373 <p class="whs3"># define "MaxElementArea"
376 <p class="whs2">algo.MaxElementArea(30)</p>
378 <p class="whs2"> </p>
380 <p class="whs3"># create a local hypothesis
383 <p class="whs2">algo = hexa.Segment(wire)</p>
385 <p class="whs2"> </p>
387 <p class="whs3"># define "NumberOfSegments"
388 hypothesis to cut a straight edge in a fixed number of segments</p>
390 <p class="whs2">algo.NumberOfSegments(6)</p>
392 <p class="whs2"> </p>
394 <p class="whs3"># define a local "Deflection1D"
395 hypothesis on the arc</p>
397 <p class="whs2">algo = hexa.Segment(arc)</p>
399 <p class="whs2">algo.Deflection1D(1)</p>
401 <p class="whs2"> </p>
403 <p class="whs2"> </p>
405 <p class="whs3"># compute the mesh</p>
407 <p class="whs2">hexa.Compute() </p>
411 <h4><a name=bookmark2>Start and End Length</a></h4>
413 <p class="whs2">from geompy import
416 <p class="whs2">import smesh</p>
420 <p># create vertices</p>
422 <p class="whs2">Point111 = MakeVertex(
423 0, 0, 0)</p>
425 <p class="whs2">Point211 = MakeVertex(10,
426 0, 0)</p>
428 <p class="whs2">Point121 = MakeVertex(
431 <p class="whs2">Point221 = MakeVertex(10,
434 <p class="whs2">Point112 = MakeVertex(
437 <p class="whs2">Point212 = MakeVertex(10,
440 <p class="whs2">Point122 = MakeVertex(
443 <p class="whs2">Point222 = MakeVertex(10,
448 <p># create edges</p>
450 <p class="whs2">EdgeX111 = MakeEdge(Point111,
453 <p class="whs2">EdgeX121 = MakeEdge(Point121,
456 <p class="whs2">EdgeX112 = MakeEdge(Point112,
459 <p class="whs2">EdgeX122 = MakeEdge(Point122,
462 <p class="whs2">EdgeY11 = MakeEdge(Point111,
465 <p class="whs2">EdgeY21 = MakeEdge(Point211,
468 <p class="whs2">EdgeY12 = MakeEdge(Point112,
471 <p class="whs2">EdgeY22 = MakeEdge(Point212,
474 <p class="whs2">EdgeZ111 = MakeEdge(Point111,
477 <p class="whs2">EdgeZ211 = MakeEdge(Point211,
480 <p class="whs2">EdgeZ121 = MakeEdge(Point121,
483 <p class="whs2">EdgeZ221 = MakeEdge(Point221,
488 <p># create faces</p>
490 <p class="whs2">FaceX11 = MakeQuad(EdgeY11,
491 EdgeZ111, EdgeY12, EdgeZ121)</p>
493 <p class="whs2">FaceX21 = MakeQuad(EdgeY21,
494 EdgeZ211, EdgeY22, EdgeZ221)</p>
496 <p class="whs2">FaceY111 = MakeQuad(EdgeX111,
497 EdgeZ111, EdgeX112, EdgeZ211)</p>
499 <p class="whs2">FaceY121 = MakeQuad(EdgeX121,
500 EdgeZ121, EdgeX122, EdgeZ221)</p>
502 <p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
503 EdgeY11, EdgeX121, EdgeY21)</p>
505 <p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
506 EdgeY12, EdgeX122, EdgeY22)</p>
510 <p># create a solid</p>
512 <p class="whs2">Block = MakeHexa(FaceX11,
513 FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
517 <p># create a compound</p>
519 <p class="whs2">box = MakeCompound([Block])</p>
523 <p># add in the study</p>
525 <p class="whs2">box_id = addToStudy(box,
526 "Box compound")</p>
530 <p># create a hexahedral mesh on the box</p>
532 <p class="whs2">hexa = smesh.Mesh(box,
533 "Box compound : hexahedrical mesh")</p>
535 <p class="whs2">algo = hexa.Segment()</p>
539 <p># define "NumberOfSegments" hypothesis to cut an edge in a
540 fixed number of segments</p>
542 <p class="whs2">algo.NumberOfSegments(4)</p>
546 <p># create a quadrangle 2D algorithm for faces</p>
548 <p class="whs2">hexa.Quadrangle()</p>
552 <p># create a hexahedron 3D algorithm for solids</p>
554 <p class="whs2">hexa.Hexahedron()</p>
558 <p># create a local hypothesis</p>
560 <p class="whs2">algo = hexa.Segment(EdgeX111)</p>
564 <p># define "StartEndLength" hypothesis to cut an edge in several
565 segments with increasing geometric length </p>
567 <p class="whs2">algo.StartEndLength(1,
572 <p># define "Propagation" hypothesis that propagates all other
573 hypothesis on all edges on the opposite side in case of quadrangular faces</p>
575 <p class="whs2">algo.Propagation()</p>
579 <p># compute the mesh</p>
581 <p class="whs2">hexa.Compute() </p>
583 <p class="whs2"> </p>
585 <h4><a name=bookmark3>Average Length</a></h4>
587 <p class="whs2">from geompy import
590 <p class="whs2">import smesh</p>
592 <p class="whs2"> </p>
594 <p class="whs3"># create vertices</p>
596 <p class="whs2">Point111 = MakeVertex(
597 0, 0, 0)</p>
599 <p class="whs2">Point211 = MakeVertex(10,
600 0, 0)</p>
602 <p class="whs2">Point121 = MakeVertex(
605 <p class="whs2">Point221 = MakeVertex(10,
608 <p class="whs2">Point112 = MakeVertex(
611 <p class="whs2">Point212 = MakeVertex(10,
614 <p class="whs2">Point122 = MakeVertex(
617 <p class="whs2">Point222 = MakeVertex(10,
620 <p class="whs2"> </p>
622 <p class="whs3"># create edges</p>
624 <p class="whs2">EdgeX111 = MakeEdge(Point111,
627 <p class="whs2">EdgeX121 = MakeEdge(Point121,
630 <p class="whs2">EdgeX112 = MakeEdge(Point112,
633 <p class="whs2">EdgeX122 = MakeEdge(Point122,
636 <p class="whs2">EdgeY11 = MakeEdge(Point111,
639 <p class="whs2">EdgeY21 = MakeEdge(Point211,
642 <p class="whs2">EdgeY12 = MakeEdge(Point112,
645 <p class="whs2">EdgeY22 = MakeEdge(Point212,
648 <p class="whs2">EdgeZ111 = MakeEdge(Point111,
651 <p class="whs2">EdgeZ211 = MakeEdge(Point211,
654 <p class="whs2">EdgeZ121 = MakeEdge(Point121,
657 <p class="whs2">EdgeZ221 = MakeEdge(Point221,
660 <p class="whs2"> </p>
662 <p class="whs3"># create faces</p>
664 <p class="whs2">FaceX11 = MakeQuad(EdgeY11,
665 EdgeZ111, EdgeY12, EdgeZ121)</p>
667 <p class="whs2">FaceX21 = MakeQuad(EdgeY21,
668 EdgeZ211, EdgeY22, EdgeZ221)</p>
670 <p class="whs2">FaceY111 = MakeQuad(EdgeX111,
671 EdgeZ111, EdgeX112, EdgeZ211)</p>
673 <p class="whs2">FaceY121 = MakeQuad(EdgeX121,
674 EdgeZ121, EdgeX122, EdgeZ221)</p>
676 <p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
677 EdgeY11, EdgeX121, EdgeY21)</p>
679 <p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
680 EdgeY12, EdgeX122, EdgeY22)</p>
682 <p class="whs2"> </p>
684 <p class="whs3"># create a solid</p>
686 <p class="whs2">Block = MakeHexa(FaceX11,
687 FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
689 <p class="whs2"> </p>
691 <p class="whs3"># create a compound</p>
693 <p class="whs2">box = MakeCompound([Block])</p>
695 <p class="whs2"> </p>
697 <p class="whs3"># add in the study</p>
699 <p class="whs2">box_id = addToStudy(box,
700 "Box compound")</p>
702 <p class="whs2"> </p>
704 <p class="whs3"># create a hexahedral
707 <p class="whs2">hexa = smesh.Mesh(box,
708 "Box compound : hexahedrical mesh")</p>
710 <p class="whs2">algo = hexa.Segment()</p>
712 <p class="whs2"> </p>
714 <p class="whs3"># define "NumberOfSegments"
715 hypothesis to cut an edge in a fixed number of segments</p>
717 <p class="whs2">algo.NumberOfSegments(4)</p>
719 <p class="whs2"> </p>
721 <p class="whs3"># create a quadrangle
722 2D algorithm for faces</p>
724 <p class="whs2">hexa.Quadrangle()</p>
726 <p class="whs2"> </p>
728 <p class="whs3"># create a hexahedron
729 3D algorithm for solids</p>
731 <p class="whs2">hexa.Hexahedron()</p>
733 <p class="whs2"> </p>
735 <p class="whs3"># create a local hypothesis</p>
737 <p class="whs2">algo = hexa.Segment(EdgeX111)</p>
739 <p class="whs2"> </p>
741 <p class="whs3"># define "LocalLength"
742 hypothesis to cut an edge in several segments with the same length</p>
744 <p class="whs2">algo.LocalLength(2)</p>
746 <p class="whs2"> </p>
748 <p class="whs3"># define "Propagation"
749 hypothesis that propagates all other hypothesis on all edges on<span style="font-family: 'Times New Roman', serif;">
750 the opposite side in case of quadrangular faces</span></p>
752 <p class="whs2">algo.Propagation()</p>
754 <p class="whs2"> </p>
756 <p class="whs3"># compute the mesh</p>
758 <p class="whs2">hexa.Compute() </p>
760 <p class="whs2"> </p>
762 <p class="whs2"> </p>
764 <h3>Defining 2D and 3D hypotheses</h3>
766 <h4><a name=bookmark4>Maximum Element Area</a></h4>
768 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
771 <p class="whs4">import geompy</p>
773 <p class="whs4">import salome</p>
775 <p class="whs4"> </p>
777 <p class="whs5"># create a face</p>
779 <p class="whs4">px =
780 geompy.MakeVertex(100., 0. ,
783 <p class="whs4">py =
784 geompy.MakeVertex(0. ,
787 <p class="whs4">pz =
788 geompy.MakeVertex(0. ,
791 <p class="whs4"> </p>
793 <p class="whs4">vxy = geompy.MakeVector(px,
796 <p class="whs4">arc = geompy.MakeArc(py,
799 <p class="whs4">wire = geompy.MakeWire([vxy,
802 <p class="whs4"> </p>
804 <p class="whs4">isPlanarFace = 1</p>
806 <p class="whs4">face = geompy.MakeFace(wire,
809 <p class="whs4"> </p>
811 <p class="whs5"># add the face in the
814 <p class="whs4">id_face = geompy.addToStudy(face,
815 "Face to be meshed")</p>
817 <p class="whs4"> </p>
819 <p class="whs5"># create a mesh</p>
821 <p class="whs4">tria_mesh = smesh.Mesh(face,
822 "Face : triangulation")</p>
824 <p class="whs4"> </p>
826 <p class="whs5"># define 1D meshing:</p>
828 <p class="whs4">algo = tria_mesh.Segment()</p>
830 <p class="whs4">algo.NumberOfSegments(20)</p>
832 <p class="whs4"> </p>
834 <p class="whs5"># define 2D meshing:</p>
836 <p class="whs5"> </p>
838 <p class="whs5"># assign triangulation
841 <p class="whs4">algo = tria_mesh.Triangle()</p>
843 <p class="whs4"> </p>
845 <p class="whs5"># apply "Max Element
846 Area" hypothesis to each triangle</p>
848 <p class="whs4">algo.MaxElementArea(100)</p>
850 <p class="whs4"> </p>
852 <p class="whs5"># compute the mesh</p>
854 <p class="whs4">tria_mesh.Compute()
857 <p class="whs4"> </p>
859 <h4><a name=bookmark5>Maximum Element Volume</a></h4>
861 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
864 <p class="whs4">import geompy</p>
866 <p class="whs4">import StdMeshers</p>
868 <p class="whs4">import NETGENPlugin</p>
870 <p class="whs4"> </p>
872 <p class="whs4">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
873 "SMESH")</p>
875 <p class="whs4">smeshgui = salome.ImportComponentGUI("SMESH")</p>
877 <p class="whs4">smeshgui.Init(salome.myStudyId);</p>
879 <p class="whs4"> </p>
881 <p class="whs5"># create a box</p>
883 <p class="whs4">box = geompy.MakeCylinderRH(30,
884 50) #MakeBox(0., 0., 0., </p>
886 <p class="whs4">100., 200., 300.)</p>
888 <p class="whs4"> </p>
890 <p class="whs5"># add the box in the
893 <p class="whs4">idbox = geompy.addToStudy(box,
896 <p class="whs4"> </p>
898 <p class="whs5"># create a set of hypotheses</p>
900 <p class="whs5"> </p>
902 <p class="whs5"># Number of Segments</p>
904 <p class="whs4">numberOfSegments
907 <p class="whs4">hypNbSeg = smesh.CreateHypothesis("NumberOfSegments",
908 "libStdMeshersEngine.so")</p>
910 <p class="whs4">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>
912 <p class="whs4">print hypNbSeg.GetName()</p>
914 <p class="whs4">print hypNbSeg.GetNumberOfSegments()</p>
916 <p class="whs4">smeshgui.SetName(salome.ObjectToID(hypNbSeg),
917 "NumberOfSegments_7")</p>
919 <p class="whs4"> </p>
921 <p class="whs5"># Max Element Area</p>
923 <p class="whs4">maxElementArea =
926 <p class="whs4">hypArea = smesh.CreateHypothesis("MaxElementArea",
927 "libStdMeshersEngine.so")</p>
929 <p class="whs4">hypArea.SetMaxElementArea(maxElementArea)</p>
931 <p class="whs4">print hypArea.GetName()</p>
933 <p class="whs4">print hypArea.GetMaxElementArea()</p>
935 <p class="whs4">smeshgui.SetName(salome.ObjectToID(hypArea),
936 "MaxElementArea_800")</p>
938 <p class="whs4"> </p>
940 <p class="whs5"># Max Element Volume</p>
942 <p class="whs4">maxElementVolume
945 <p class="whs4">hypVolume = smesh.CreateHypothesis("MaxElementVolume",
946 "libStdMeshersEngine.so")</p>
948 <p class="whs4">hypVolume.SetMaxElementVolume(maxElementVolume)</p>
950 <p class="whs4">print hypVolume.GetName()</p>
952 <p class="whs4">print hypVolume.GetMaxElementVolume()</p>
954 <p class="whs4">smeshgui.SetName(salome.ObjectToID(hypVolume),
955 "MaxElementVolume_900")</p>
957 <p class="whs4"> </p>
959 <p class="whs5"># create a set of algorithms</p>
961 <p class="whs5"> </p>
963 <p class="whs5"># Regular_1D</p>
965 <p class="whs4">regular1D = smesh.CreateHypothesis("Regular_1D",
966 "libStdMeshersEngine.so")</p>
968 <p class="whs4">smeshgui.SetName(salome.ObjectToID(regular1D),
969 "Wire Discretisation")</p>
971 <p class="whs4"> </p>
973 <p class="whs5"># MEFISTO_2D</p>
975 <p class="whs4">mefisto2D = smesh.CreateHypothesis("MEFISTO_2D",
976 "libStdMeshersEngine.so")</p>
978 <p class="whs4">smeshgui.SetName(salome.ObjectToID(mefisto2D),
979 "MEFISTO_2D")</p>
981 <p class="whs4"> </p>
983 <p class="whs5"># NETGEN_3D (Tetrahedron
984 meshing algorithm)</p>
986 <p class="whs4">tetra3D = smesh.CreateHypothesis("NETGEN_3D",
987 "libNETGENEngine.so")</p>
989 <p class="whs4">smeshgui.SetName(salome.ObjectToID(tetra3D),
990 "NETGEN_3D")</p>
992 <p class="whs4"> </p>
994 <p class="whs5"># initialize a mesh
997 <p class="whs4">mesh = smesh.CreateMesh(box)</p>
999 <p class="whs4">smeshgui.SetName(salome.ObjectToID(mesh),
1000 "MeshBox")</p>
1002 <p class="whs4"> </p>
1004 <p class="whs5"># add hypotheses and
1005 algorithms to the box</p>
1007 <p class="whs4">mesh.AddHypothesis(box,hypNbSeg)</p>
1009 <p class="whs4">mesh.AddHypothesis(box,hypArea)</p>
1011 <p class="whs4">mesh.AddHypothesis(box,hypVolume)</p>
1013 <p class="whs4">mesh.AddHypothesis(box,regular1D)</p>
1015 <p class="whs4">mesh.AddHypothesis(box,mefisto2D)</p>
1017 <p class="whs4">mesh.AddHypothesis(box,tetra3D)</p>
1019 <p class="whs4"> </p>
1021 <p class="whs5"># compute the mesh</p>
1023 <p class="whs4">ret = smesh.Compute(mesh,box)</p>
1025 <p class="whs4">if ret == 0:</p>
1027 <p class="whs4"> print
1028 "probleme when computing the mesh"</p>
1030 <p class="whs4">else:</p>
1032 <p class="whs4"> print
1033 "Computation succeded"</p>
1035 <p class="whs4">salome.sg.updateObjBrowser(1)
1038 <p class="whs4"> </p>
1040 <h4><a name=bookmark6>Length from Edges</a></h4>
1042 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">import
1045 <p class="whs2">import geompy</p>
1047 <p class="whs2">import smesh</p>
1049 <p class="whs2"> </p>
1051 <p class="whs3"># create sketchers</p>
1053 <p class="whs2">sketcher1 = geompy.MakeSketcher("Sketcher:F
1054 0 0:TT 70 0:TT 70 70:TT 0 70:WW")</p>
1056 <p class="whs2">sketcher2 = geompy.MakeSketcher("Sketcher:F
1057 20 20:TT 50 20:TT 50 50:TT 20 50:WW")</p>
1059 <p class="whs2">isPlanarFace = 1</p>
1061 <p class="whs2"> </p>
1063 <p class="whs3"># create a face from
1066 <p class="whs2">face1 = geompy.MakeFaces([sketcher1,
1067 sketcher2],isPlanarFace)</p>
1069 <p class="whs2"> </p>
1071 <p class="whs3"># add object in the study</p>
1073 <p class="whs2">id_face1 = geompy.addToStudy(face1,"Face1")</p>
1075 <p class="whs2"> </p>
1077 <p class="whs3"># create a mesh</p>
1079 <p class="whs2">tria = smesh.Mesh(face1,
1080 "Face : triangle 2D mesh")</p>
1082 <p class="whs2"> </p>
1084 <p class="whs3"># Define 1D meshing</p>
1086 <p class="whs2">algo = tria.Segment()</p>
1088 <p class="whs2">algo.NumberOfSegments(2)</p>
1090 <p class="whs2"> </p>
1092 <p class="whs3"># create and assign the
1093 algorithm for 2D meshing with triangles</p>
1095 <p class="whs2">algo = tria.Triangle()</p>
1097 <p class="whs2"> </p>
1099 <p class="whs3"># create and assign "LengthFromEdges"
1100 hypothesis to build triangles </p>
1102 <p class="whs3"># based on the length
1103 of the edges taken from the wire</p>
1105 <p class="whs2">algo.LengthFromEdges()</p>
1107 <p class="whs2"> </p>
1109 <p class="whs3"># compute the mesh</p>
1111 <p class="whs2">tria.Compute() </p>
1113 <p class="whs2"> </p>
1115 <h3>Defining Additional Hypotheses</h3>
1117 <h4><a name=bookmark7>Propagation</a></h4>
1119 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">from
1120 geompy import *</span></p>
1122 <p class="whs2">import smesh</p>
1124 <p class="whs2"> </p>
1126 <p class="whs3"># create vertices</p>
1128 <p class="whs2">Point111 = MakeVertex(
1129 0, 0, 0)</p>
1131 <p class="whs2">Point211 = MakeVertex(10,
1132 0, 0)</p>
1134 <p class="whs2">Point121 = MakeVertex(
1137 <p class="whs2">Point221 = MakeVertex(10,
1140 <p class="whs2">Point112 = MakeVertex(
1143 <p class="whs2">Point212 = MakeVertex(10,
1146 <p class="whs2">Point122 = MakeVertex(
1149 <p class="whs2">Point222 = MakeVertex(10,
1152 <p class="whs2"> </p>
1154 <p class="whs3"># create edges</p>
1156 <p class="whs2">EdgeX111 = MakeEdge(Point111,
1159 <p class="whs2">EdgeX121 = MakeEdge(Point121,
1162 <p class="whs2">EdgeX112 = MakeEdge(Point112,
1165 <p class="whs2">EdgeX122 = MakeEdge(Point122,
1168 <p class="whs2">EdgeY11 = MakeEdge(Point111,
1171 <p class="whs2">EdgeY21 = MakeEdge(Point211,
1174 <p class="whs2">EdgeY12 = MakeEdge(Point112,
1177 <p class="whs2">EdgeY22 = MakeEdge(Point212,
1180 <p class="whs2">EdgeZ111 = MakeEdge(Point111,
1183 <p class="whs2">EdgeZ211 = MakeEdge(Point211,
1186 <p class="whs2">EdgeZ121 = MakeEdge(Point121,
1189 <p class="whs2">EdgeZ221 = MakeEdge(Point221,
1192 <p class="whs2"> </p>
1194 <p class="whs3"># create faces</p>
1196 <p class="whs2">FaceX11 = MakeQuad(EdgeY11,
1197 EdgeZ111, EdgeY12, EdgeZ121)</p>
1199 <p class="whs2">FaceX21 = MakeQuad(EdgeY21,
1200 EdgeZ211, EdgeY22, EdgeZ221)</p>
1202 <p class="whs2">FaceY111 = MakeQuad(EdgeX111,
1203 EdgeZ111, EdgeX112, EdgeZ211)</p>
1205 <p class="whs2">FaceY121 = MakeQuad(EdgeX121,
1206 EdgeZ121, EdgeX122, EdgeZ221)</p>
1208 <p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
1209 EdgeY11, EdgeX121, EdgeY21)</p>
1211 <p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
1212 EdgeY12, EdgeX122, EdgeY22)</p>
1214 <p class="whs2"> </p>
1216 <p class="whs3"># create a solid</p>
1218 <p class="whs2">box = MakeHexa(FaceX11,
1219 FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
1221 <p class="whs2"> </p>
1223 <p class="whs3"># add in the study</p>
1225 <p class="whs2">box_id = addToStudy(box,
1226 "Box")</p>
1228 <p class="whs2"> </p>
1230 <p class="whs3"># create a hexahedral
1233 <p class="whs2">hexa = smesh.Mesh(box,
1234 "Box : hexahedrical mesh")</p>
1236 <p class="whs2"> </p>
1238 <p class="whs3"># create an 1D algorithm
1241 <p class="whs2">algo = hexa.Segment()</p>
1243 <p class="whs2"> </p>
1245 <p class="whs3"># define "NumberOfSegments"
1246 hypothesis to cut an edge in a fixed number of segments</p>
1248 <p class="whs2">algo.NumberOfSegments(4)</p>
1250 <p class="whs2"> </p>
1252 <p class="whs3"># create a quadrangle
1253 2D algorithm for faces</p>
1255 <p class="whs2">hexa.Quadrangle()</p>
1257 <p class="whs2"> </p>
1259 <p class="whs3"># create a hexahedron
1260 3D algorithm for solids</p>
1262 <p class="whs2">hexa.Hexahedron()</p>
1264 <p class="whs2"> </p>
1266 <p class="whs3"># create a local hypothesis</p>
1268 <p class="whs2">algo = hexa.Segment(EdgeX111)</p>
1270 <p class="whs2"> </p>
1272 <p class="whs3"># define "Arithmetic1D"
1273 hypothesis to cut an edge<span style="font-family: 'Times New Roman', serif;">
1274 in several segments with increasing length</span></p>
1276 <p class="whs2">algo.Arithmetic1D(1,
1279 <p class="whs2"> </p>
1281 <p class="whs3"># define "Propagation"
1282 hypothesis that propagates all other 1D hypotheses</p>
1284 <p class="whs3"># from all edges on the
1285 opposite side of a face in case of quadrangular faces</p>
1287 <p class="whs2">algo.Propagation()</p>
1289 <p class="whs2"> </p>
1291 <p class="whs3"># compute the mesh</p>
1293 <p class="whs2">hexa.Compute() </p>
1295 <h3><a name=bookmark8>Defining Meshing Algorithms</a></h3>
1297 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
1300 <p class="whs4">import StdMeshers</p>
1302 <p class="whs4">import NETGENPlugin</p>
1304 <p class="whs4"> </p>
1306 <p class="whs4">smesh = salome.lcc.FindOrLoadComponent("FactoryServer",
1307 "SMESH")</p>
1309 <p class="whs4">smeshgui = salome.ImportComponentGUI("SMESH")</p>
1311 <p class="whs4">smeshgui.Init(salome.myStudyId);</p>
1313 <p class="whs6"> </p>
1315 <p class="whs6"># create algorithms</p>
1317 <p class="whs4">print "--------------------------
1318 create Algorithms"</p>
1320 <p class="whs4">print "--------------------------
1321 Regular_1D (Wire discretisation)"</p>
1323 <p class="whs4">regular1D = smesh.CreateHypothesis("Regular_1D",
1324 "libStdMeshersEngine.so")</p>
1326 <p class="whs4">smeshgui.SetName(salome.ObjectToID(regular1D),
1327 "Wire Discretisation")</p>
1329 <p class="whs4"> </p>
1331 <p class="whs4">print "--------------------------
1332 MEFISTO_2D (Triangle meshing algorithm)"</p>
1334 <p class="whs4">mefisto2D = smesh.CreateHypothesis("MEFISTO_2D",
1335 "libStdMeshersEngine.so")</p>
1337 <p class="whs4">smeshgui.SetName(salome.ObjectToID(mefisto2D),
1338 "MEFISTO_2D")</p>
1340 <p class="whs4"> </p>
1342 <p class="whs4">print "--------------------------
1343 Quadrangle_2D (Quadrangle meshing algorithm)"</p>
1345 <p class="whs4">quad2D = smesh.CreateHypothesis(
1346 "Quadrangle_2D", "libStdMeshersEngine.so" )</p>
1348 <p class="whs4">smeshgui.SetName(salome.ObjectToID(quad2D),
1349 "Quadrangle_2D")</p>
1351 <p class="whs4"> </p>
1353 <p class="whs4">print "--------------------------
1354 Hexa_3D (Hexahedron meshing algorithm)"</p>
1356 <p class="whs4">hexa3D = smesh.CreateHypothesis("Hexa_3D",
1357 "libStdMeshersEngine.so")</p>
1359 <p class="whs4">smeshgui.SetName(salome.ObjectToID(hexa3D),
1360 "HEXA_3D")</p>
1362 <p class="whs4"> </p>
1364 <p class="whs4">print "--------------------------
1365 NETGEN_3D (Tetrahedron meshing algorithm)"</p>
1367 <p class="whs4">netgen3D = smesh.CreateHypothesis("NETGEN_3D",
1368 "libNETGENEngine.so")</p>
1370 <p class="whs4">smeshgui.SetName(salome.ObjectToID(netgen3D),
1371 "NETGEN_3D")</p>
1373 <p class="whs4">salome.sg.updateObjBrowser(1)</p>
1375 <p class="whs6"> </p>
1377 <script type="text/javascript" language="javascript1.2">
1379 if (window.writeIntopicBar)