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"><span style="font-family: 'Lucida Console', monospace;">import
105 <p class="whs2">import smesh</p>
107 <p class="whs2"> </p>
109 <p class="whs3"># create a box</p>
111 <p class="whs2">box = geompy.MakeBoxDXDYDZ(10.,
114 <p class="whs2">geompy.addToStudy(box,
117 <p class="whs2"> </p>
119 <p class="whs3"># create a hexahedral
122 <p class="whs2">hexa = smesh.Mesh(box,
123 "Box : hexahedrical mesh")</p>
125 <p class="whs2"> </p>
127 <p class="whs3"># create a Regular 1D
128 algorithm for edges</p>
130 <p class="whs2">algo1D = hexa.Segment()</p>
132 <p class="whs2"> </p>
134 <p class="whs3"># define "Arithmetic1D"
135 hypothesis to cut all edges in several segments with increasing arithmetic
138 <p class="whs2">algo1D.Arithmetic1D(1,
141 <p class="whs2"> </p>
143 <p class="whs3"># create a quadrangle
144 2D algorithm for faces</p>
146 <p class="whs2">hexa.Quadrangle()</p>
148 <p class="whs2"> </p>
150 <p class="whs3"># create a hexahedron
151 3D algorithm for solids</p>
153 <p class="whs2">hexa.Hexahedron()</p>
155 <p class="whs2"> </p>
157 <p class="whs3"># compute the mesh</p>
159 <p class="whs2">hexa.Compute() </p>
161 <p class="whs2"> </p>
163 <h4><a name=bookmark9>Deflection 1D and Number of Segments</a></h4>
165 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">import
168 <p class="whs2">import smesh</p>
170 <p class="whs2"> </p>
172 <p class="whs3"># create a face from
173 arc and straight segment</p>
175 <p class="whs2">px = geompy.MakeVertex(100.,
179 <p class="whs2">py = geompy.MakeVertex(0.
183 <p class="whs2">pz = geompy.MakeVertex(0.
187 <p class="whs2"> </p>
189 <p class="whs2">exy = geompy.MakeEdge(px,
192 <p class="whs2">arc = geompy.MakeArc(py,
195 <p class="whs2"> </p>
197 <p class="whs2">wire = geompy.MakeWire([exy,
200 <p class="whs2"> </p>
202 <p class="whs2">isPlanarFace = 1</p>
204 <p class="whs2">face1 = geompy.MakeFace(wire,
207 <p class="whs2">geompy.addToStudy(face1,"Face1")</p>
209 <p class="whs2"> </p>
211 <p class="whs3"># get edges from the
214 <p class="whs2">e_straight,e_arc =
215 geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])</p>
217 <p class="whs2">geompy.addToStudyInFather(face1,
218 e_arc, "Arc Edge")</p>
220 <p class="whs2"> </p>
222 <p class="whs3"># create hexahedral mesh</p>
224 <p class="whs2">hexa = smesh.Mesh(face1,
225 "Face : triangle mesh")</p>
227 <p class="whs2"> </p>
229 <p class="whs3"># define "NumberOfSegments"
230 hypothesis to cut a straight edge in a fixed number of segments</p>
232 <p class="whs2">algo1D = hexa.Segment()</p>
234 <p class="whs2">algo1D.NumberOfSegments(6)</p>
236 <p class="whs2"> </p>
238 <p class="whs3"># define "MaxElementArea"
241 <p class="whs2">algo2D = hexa.Triangle()</p>
243 <p class="whs2">algo2D.MaxElementArea(70.0)</p>
245 <p class="whs2"> </p>
247 <p class="whs3"># define a local "Deflection1D"
248 hypothesis on the arc</p>
250 <p class="whs2">algo_local = hexa.Segment(e_arc)</p>
252 <p class="whs2">algo_local.Deflection1D(1.0)</p>
254 <p class="whs2"> </p>
256 <p class="whs3"># compute the mesh</p>
258 <p class="whs2">hexa.Compute() </p>
260 <h4><a name=bookmark2>Start and End Length</a></h4>
262 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">from
263 geompy import *</span></p>
265 <p class="whs2">import smesh</p>
267 <p class="whs2"> </p>
269 <p class="whs3"># create a box</p>
271 <p class="whs2">box = MakeBoxDXDYDZ(10.,
274 <p class="whs2">addToStudy(box, "Box")</p>
276 <p class="whs2"> </p>
278 <p class="whs3"># get one edge of the
279 box to put local hypothesis on</p>
281 <p class="whs2">p5 = MakeVertex(5.,
284 <p class="whs2">EdgeX = GetEdgeNearPoint(box,
287 <p class="whs2">addToStudyInFather(box,
288 EdgeX, "Edge [0,0,0 - 10,0,0]")</p>
290 <p class="whs2"> </p>
292 <p class="whs3"># create a hexahedral
295 <p class="whs2">hexa = smesh.Mesh(box,
296 "Box : hexahedrical mesh")</p>
298 <p class="whs2"> </p>
300 <p class="whs3"># set algorithms</p>
302 <p class="whs2">algo1D = hexa.Segment()</p>
304 <p class="whs2">hexa.Quadrangle()</p>
306 <p class="whs2">hexa.Hexahedron()</p>
308 <p class="whs2"> </p>
310 <p class="whs3"># define "NumberOfSegments"
311 hypothesis to cut an edge in a fixed number of segments</p>
313 <p class="whs2">algo1D.NumberOfSegments(4)</p>
315 <p class="whs2"> </p>
317 <p class="whs3"># create a local hypothesis</p>
319 <p class="whs2">algo_local = hexa.Segment(EdgeX)</p>
321 <p class="whs2"> </p>
323 <p class="whs3"># define "StartEndLength"
324 hypothesis to cut an edge in several segments with increasing geometric
327 <p class="whs2">algo_local.StartEndLength(1,
330 <p class="whs2"> </p>
332 <p class="whs3"># define "Propagation"
333 hypothesis that propagates all other hypothesis</p>
335 <p class="whs3"># on all edges on the
336 opposite side in case of quadrangular faces</p>
338 <p class="whs2">algo_local.Propagation()</p>
340 <p class="whs2"> </p>
342 <p class="whs3"># compute the mesh</p>
344 <p class="whs2">hexa.Compute() </p>
346 <h4><a name=bookmark3>Average Length</a></h4>
348 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">from
349 geompy import *</span></p>
351 <p class="whs2">import smesh</p>
353 <p class="whs2"> </p>
355 <p class="whs3"># create a box</p>
357 <p class="whs2">box = MakeBoxDXDYDZ(10.,
360 <p class="whs2">addToStudy(box, "Box")</p>
362 <p class="whs2"> </p>
364 <p class="whs3"># get one edge of the
365 box to put local hypothesis on</p>
367 <p class="whs2">p5 = MakeVertex(5.,
370 <p class="whs2">EdgeX = GetEdgeNearPoint(box,
373 <p class="whs2">addToStudyInFather(box,
374 EdgeX, "Edge [0,0,0 - 10,0,0]")</p>
376 <p class="whs2"> </p>
378 <p class="whs3"># create a hexahedral
381 <p class="whs2">hexa = smesh.Mesh(box,
382 "Box : hexahedrical mesh")</p>
384 <p class="whs2"> </p>
386 <p class="whs3"># set algorithms</p>
388 <p class="whs2">algo1D = hexa.Segment()</p>
390 <p class="whs2">hexa.Quadrangle()</p>
392 <p class="whs2">hexa.Hexahedron()</p>
394 <p class="whs2"> </p>
396 <p class="whs3"># define "NumberOfSegments"
397 hypothesis to cut all edges in a fixed number of segments</p>
399 <p class="whs2">algo1D.NumberOfSegments(4)</p>
401 <p class="whs2"> </p>
403 <p class="whs3"># create a sub-mesh</p>
405 <p class="whs2">algo_local = hexa.Segment(EdgeX)</p>
407 <p class="whs2"> </p>
409 <p class="whs3"># define "LocalLength"
410 hypothesis to cut an edge in several segments with the same length</p>
412 <p class="whs2">algo_local.LocalLength(2.)</p>
414 <p class="whs2"> </p>
416 <p class="whs3"># define "Propagation"
417 hypothesis that propagates all other hypothesis</p>
419 <p class="whs3"># on all edges on the
420 opposite side in case of quadrangular faces</p>
422 <p class="whs2">algo_local.Propagation()</p>
424 <p class="whs2"> </p>
426 <p class="whs3"># compute the mesh</p>
428 <p class="whs2">hexa.Compute() </p>
430 <h3>Defining 2D and 3D hypotheses</h3>
432 <h4><a name=bookmark4>Maximum Element Area</a></h4>
434 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
437 <p class="whs4">import smesh</p>
439 <p class="whs4">import salome </p>
441 <p class="whs4"> </p>
443 <p class="whs5"># create a face</p>
445 <p class="whs4">px =
446 geompy.MakeVertex(100., 0. ,
449 <p class="whs4">py =
450 geompy.MakeVertex(0. ,
453 <p class="whs4">pz =
454 geompy.MakeVertex(0. ,
457 <p class="whs4"> </p>
459 <p class="whs4">vxy = geompy.MakeVector(px,
462 <p class="whs4">arc = geompy.MakeArc(py,
465 <p class="whs4">wire = geompy.MakeWire([vxy,
468 <p class="whs4"> </p>
470 <p class="whs4">isPlanarFace = 1</p>
472 <p class="whs4">face = geompy.MakeFace(wire,
475 <p class="whs4"> </p>
477 <p class="whs5"># add the face in the
480 <p class="whs4">id_face = geompy.addToStudy(face,
481 "Face to be meshed")</p>
483 <p class="whs4"> </p>
485 <p class="whs5"># create a mesh</p>
487 <p class="whs4">tria_mesh = smesh.Mesh(face,
488 "Face : triangulation")</p>
490 <p class="whs4"> </p>
492 <p class="whs5"># define 1D meshing:</p>
494 <p class="whs4">algo = tria_mesh.Segment()</p>
496 <p class="whs4">algo.NumberOfSegments(20)</p>
498 <p class="whs4"> </p>
500 <p class="whs5"># define 2D meshing:</p>
502 <p class="whs5"> </p>
504 <p class="whs5"># assign triangulation
507 <p class="whs4">algo = tria_mesh.Triangle()</p>
509 <p class="whs4"> </p>
511 <p class="whs5"># apply "Max Element
512 Area" hypothesis to each triangle</p>
514 <p class="whs4">algo.MaxElementArea(100)</p>
516 <p class="whs4"> </p>
518 <p class="whs5"># compute the mesh</p>
520 <p class="whs4">tria_mesh.Compute()
523 <p class="whs4"> </p>
525 <h4><a name=bookmark5>Maximum Element Volume</a></h4>
527 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
530 <p class="whs4">import smesh</p>
532 <p class="whs4"> </p>
534 <p class="whs5"># create a cylinder</p>
536 <p class="whs4">cyl = geompy.MakeCylinderRH(30.,
539 <p class="whs4">geompy.addToStudy(cyl,
542 <p class="whs4"> </p>
544 <p class="whs5"># create a mesh on
547 <p class="whs4">tetra = smesh.Mesh(cyl,
548 "Cylinder : tetrahedrical mesh")</p>
550 <p class="whs4"> </p>
552 <p class="whs5"># assign algorithms</p>
554 <p class="whs4">algo1D = tetra.Segment()</p>
556 <p class="whs4">algo2D = tetra.Triangle()</p>
558 <p class="whs4">algo3D = tetra.Tetrahedron(smesh.NETGEN)</p>
560 <p class="whs4"> </p>
562 <p class="whs5"># assign 1D and 2D
565 <p class="whs4">algo1D.NumberOfSegments(7)</p>
567 <p class="whs4">algo2D.MaxElementArea(150.)</p>
569 <p class="whs4"> </p>
571 <p class="whs5"># assign Max Element
572 Volume hypothesis</p>
574 <p class="whs4">algo3D.MaxElementVolume(200.)</p>
576 <p class="whs4"> </p>
578 <p class="whs5"># compute the mesh</p>
580 <p class="whs4">ret = tetra.Compute()</p>
582 <p class="whs4">if ret == 0:</p>
584 <p class="whs4"> print
585 "probleme when computing the mesh"</p>
587 <p class="whs4">else:</p>
589 <p class="whs4"> print
590 "Computation succeded" </p>
592 <h4><a name=bookmark6>Length from Edges</a></h4>
594 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">import
597 <p class="whs2">import smesh</p>
599 <p class="whs2"> </p>
601 <p class="whs3"># create sketchers</p>
603 <p class="whs2">sketcher1 = geompy.MakeSketcher("Sketcher:F
604 0 0:TT 70 0:TT 70 70:TT 0 70:WW")</p>
606 <p class="whs2">sketcher2 = geompy.MakeSketcher("Sketcher:F
607 20 20:TT 50 20:TT 50 50:TT 20 50:WW")</p>
609 <p class="whs2"> </p>
611 <p class="whs3"># create a face from
614 <p class="whs2">isPlanarFace = 1</p>
616 <p class="whs2">face1 = geompy.MakeFaces([sketcher1,
617 sketcher2], isPlanarFace)</p>
619 <p class="whs2">geompy.addToStudy(face1,
620 "Face1")</p>
622 <p class="whs2"> </p>
624 <p class="whs3"># create a mesh</p>
626 <p class="whs2">tria = smesh.Mesh(face1,
627 "Face : triangle 2D mesh")</p>
629 <p class="whs2"> </p>
631 <p class="whs3"># Define 1D meshing</p>
633 <p class="whs2">algo1D = tria.Segment()</p>
635 <p class="whs2">algo1D.NumberOfSegments(2)</p>
637 <p class="whs2"> </p>
639 <p class="whs3"># create and assign the
640 algorithm for 2D meshing with triangles</p>
642 <p class="whs2">algo2D = tria.Triangle()</p>
644 <p class="whs2"> </p>
646 <p class="whs3"># create and assign "LengthFromEdges"
647 hypothesis to build triangles<span style="font-family: 'Times New Roman', serif;">
648 based on the length of the edges taken from the wire</span></p>
650 <p class="whs2">algo2D.LengthFromEdges()</p>
652 <p class="whs2"> </p>
654 <p class="whs3"># compute the mesh</p>
656 <p class="whs2">tria.Compute() </p>
658 <p class="whs2"> </p>
660 <h3>Defining Additional Hypotheses</h3>
662 <h4><a name=bookmark7>Propagation</a></h4>
664 <p class="whs2">from geompy import
667 <p class="whs2">import smesh</p>
669 <p class="whs2"> </p>
671 <p class="whs3"># create a box</p>
673 <p class="whs2">box = MakeBoxDXDYDZ(10.,
676 <p class="whs2">addToStudy(box, "Box")</p>
678 <p class="whs2"> </p>
680 <p class="whs3"># get one edge of the
681 box to put local hypothesis on</p>
683 <p class="whs2">p5 = MakeVertex(5.,
686 <p class="whs2">EdgeX = GetEdgeNearPoint(box,
689 <p class="whs2">addToStudyInFather(box,
690 EdgeX, "Edge [0,0,0 - 10,0,0]")</p>
692 <p class="whs2"> </p>
694 <p class="whs3"># create a hexahedral
697 <p class="whs2">hexa = smesh.Mesh(box,
698 "Box : hexahedrical mesh")</p>
700 <p class="whs2"> </p>
702 <p class="whs3"># set global algorithms
705 <p class="whs2">algo1D = hexa.Segment()</p>
707 <p class="whs2">hexa.Quadrangle()</p>
709 <p class="whs2">hexa.Hexahedron()</p>
711 <p class="whs2">algo1D.NumberOfSegments(4)</p>
713 <p class="whs2"> </p>
715 <p class="whs3"># create a sub-mesh with
716 local 1D hypothesis and propagation</p>
718 <p class="whs2">algo_local = hexa.Segment(EdgeX)</p>
720 <p class="whs2"> </p>
722 <p class="whs3"># define "Arithmetic1D"
723 hypothesis to cut an edge in several segments with increasing length</p>
725 <p class="whs2">algo_local.Arithmetic1D(1,
728 <p class="whs2"> </p>
730 <p class="whs3"># define "Propagation"
731 hypothesis that propagates all other 1D hypotheses</p>
733 <p class="whs3"># from all edges on the
734 opposite side of a face in case of quadrangular faces</p>
736 <p class="whs2">algo_local.Propagation()</p>
738 <p class="whs2"> </p>
740 <p class="whs3"># compute the mesh</p>
742 <p><span style="font-family: 'Lucida Console', monospace;">hexa.Compute()</span>
745 <h3><a name=bookmark8>Defining Meshing Algorithms</a></h3>
747 <p class="whs4">import geompy</p>
749 <p class="whs4">import smesh</p>
751 <p class="whs6"> </p>
753 <p class="whs6"># create a box</p>
755 <p class="whs4">box = geompy.MakeBoxDXDYDZ(10.,
758 <p class="whs4">geompy.addToStudy(box,
761 <p class="whs4"> </p>
763 <p class="whs6"># 1. Create a hexahedral
766 <p class="whs4">hexa = smesh.Mesh(box,
767 "Box : hexahedrical mesh")</p>
769 <p class="whs6"> </p>
771 <p class="whs6"># create a Regular 1D algorithm
774 <p class="whs4">algo1D = hexa.Segment()</p>
776 <p class="whs6"> </p>
778 <p class="whs6"># create a quadrangle 2D
779 algorithm for faces</p>
781 <p class="whs4">algo2D = hexa.Quadrangle()</p>
783 <p class="whs6"> </p>
785 <p class="whs6"># create a hexahedron 3D
786 algorithm for solids</p>
788 <p class="whs4">algo3D = hexa.Hexahedron()</p>
790 <p class="whs6"> </p>
792 <p class="whs6"># define hypotheses</p>
794 <p class="whs4">algo1D.Arithmetic1D(1,
797 <p class="whs6"> </p>
799 <p class="whs6"># compute the mesh</p>
801 <p class="whs4">hexa.Compute()</p>
803 <p class="whs6"> </p>
805 <p class="whs6"># 2. Create a tetrahedral
808 <p class="whs4">tetra = smesh.Mesh(box,
809 "Box : tetrahedrical mesh")</p>
811 <p class="whs6"> </p>
813 <p class="whs6"># create a Regular 1D algorithm
816 <p class="whs4">algo1D = tetra.Segment()</p>
818 <p class="whs6"> </p>
820 <p class="whs6"># create a Mefisto 2D algorithm
823 <p class="whs4">algo2D = tetra.Triangle()</p>
825 <p class="whs6"> </p>
827 <p class="whs6"># create a Netgen 3D algorithm
830 <p class="whs4">algo3D = tetra.Tetrahedron(smesh.NETGEN)</p>
832 <p class="whs6"> </p>
834 <p class="whs6"># define hypotheses</p>
836 <p class="whs4">algo1D.Arithmetic1D(1,
839 <p class="whs4">algo2D.LengthFromEdges()</p>
841 <p class="whs6"> </p>
843 <p class="whs6"># compute the mesh</p>
845 <p class="whs4">tetra.Compute()</p>
847 <p class="whs6"> </p>
849 <p class="whs6"># 3. Create a tetrahedral
850 mesh on the box with NETGEN_2D3D algorithm</p>
852 <p class="whs4">tetraN = smesh.Mesh(box,
853 "Box : tetrahedrical mesh by NETGEN_2D3D")</p>
855 <p class="whs6"> </p>
857 <p class="whs6"># create a Netgen_2D3D
858 algorithm for solids</p>
860 <p class="whs4">algo3D = tetraN.Tetrahedron(smesh.FULL_NETGEN)
863 <p class="whs6"> </p>
865 <p class="whs6"># define hypotheses</p>
867 <p class="whs4">n23_params = algo3D.Parameters()</p>
869 <p class="whs6"> </p>
871 <p class="whs6"># compute the mesh</p>
873 <p class="whs4">tetraN.Compute()
876 <script type="text/javascript" language="javascript1.2">
878 if (window.writeIntopicBar)