smesh/doc/salome/gui/SMESH/defining_hypotheses_tui.htm

1475 lines
34 KiB
HTML
Raw Normal View History

2005-11-28 14:57:47 +05:00
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
<title>Defining hypotheses TUI</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style>
<!--
P { margin-top:0pt; margin-bottom:0pt; }
LI.kadov-P { }
-->
</style><style type="text/css">
<!--
p.whs1 { font-weight:bold; }
p.whs2 { font-family:'Lucida Console' , monospace; }
p.whs3 { font-family:'Times New Roman' , serif; }
p.whs4 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
p.whs5 { margin-top:0pt; margin-bottom:0pt; }
p.whs6 { margin-top:0pt; margin-bottom:0pt; font-family:Tahoma, sans-serif; }
p.whs7 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
-->
</style><script type="text/javascript" language="JavaScript">
<!--
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
{
var strNSS = "<style type='text/css'>";
strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs6 {margin-top:1pt;margin-bottom:1pt; }";
strNSS += "p.whs7 {margin-top:1pt;margin-bottom:1pt; }";
strNSS +="</style>";
document.write(strNSS);
}
//-->
</script>
<script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
<!--
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();
}
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
origWidth = innerWidth;
origHeight = innerHeight;
onresize = reDo;
}
onerror = null;
//-->
</script>
<style type="text/css">
<!--
div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
-->
</style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
<script type="text/javascript" language="javascript" src="whver.js"></script>
<script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
<script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
<script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
</head>
<body><script type="text/javascript" language="javascript1.2">
<!--
if (window.gbWhTopic)
{
if (window.addTocInfo)
{
addTocInfo("MESH module\nTUI Scripts\nDefining Hypotheses");
addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");
}
if (window.writeBtnStyle)
writeBtnStyle();
if (window.writeIntopicBar)
writeIntopicBar(1);
if (window.setRelStartPage)
{
setRelStartPage("smesh.htm");
autoSync(1);
sendSyncInfo();
sendAveInfoOut();
}
}
else
if (window.gbIE4)
document.location.reload();
//-->
</script>
<h1>Defining Hypotheses and Algorithms</h1>
<h3>Defining 1D Hypotheses</h3>
<p class="whs1"><a name=bookmark>1D Arithmetic</a></p>
<p>&nbsp;</p>
<p class="whs2">from geompy import
*</p>
<p class="whs2">import smesh</p>
<p>&nbsp;</p>
<p># create vertices</p>
<p class="whs2">Point111 = MakeVertex(
0, &nbsp;0, &nbsp;0)</p>
<p class="whs2">Point211 = MakeVertex(10,
&nbsp;0, &nbsp;0)</p>
<p class="whs2">Point121 = MakeVertex(
0, 10, &nbsp;0)</p>
<p class="whs2">Point221 = MakeVertex(10,
10, &nbsp;0)</p>
<p class="whs2">Point112 = MakeVertex(
0, &nbsp;0, 10)</p>
<p class="whs2">Point212 = MakeVertex(10,
&nbsp;0, 10)</p>
<p class="whs2">Point122 = MakeVertex(
0, 10, 10)</p>
<p class="whs2">Point222 = MakeVertex(10,
10, 10)</p>
<p>&nbsp;</p>
<p># create edges</p>
<p class="whs2">EdgeX111 = MakeEdge(Point111,
Point211)</p>
<p class="whs2">EdgeX121 = MakeEdge(Point121,
Point221)</p>
<p class="whs2">EdgeX112 = MakeEdge(Point112,
Point212)</p>
<p class="whs2">EdgeX122 = MakeEdge(Point122,
Point222)</p>
<p class="whs2">EdgeY11 = MakeEdge(Point111,
Point121)</p>
<p class="whs2">EdgeY21 = MakeEdge(Point211,
Point221)</p>
<p class="whs2">EdgeY12 = MakeEdge(Point112,
Point122)</p>
<p class="whs2">EdgeY22 = MakeEdge(Point212,
Point222)</p>
<p class="whs2">EdgeZ111 = MakeEdge(Point111,
Point112)</p>
<p class="whs2">EdgeZ211 = MakeEdge(Point211,
Point212)</p>
<p class="whs2">EdgeZ121 = MakeEdge(Point121,
Point122)</p>
<p class="whs2">EdgeZ221 = MakeEdge(Point221,
Point222)</p>
<p>&nbsp;</p>
<p># create faces</p>
<p class="whs2">FaceX11 = MakeQuad(EdgeY11,
EdgeZ111, EdgeY12, EdgeZ121)</p>
<p class="whs2">FaceX21 = MakeQuad(EdgeY21,
EdgeZ211, EdgeY22, EdgeZ221)</p>
<p class="whs2">FaceY111 = MakeQuad(EdgeX111,
EdgeZ111, EdgeX112, EdgeZ211)</p>
<p class="whs2">FaceY121 = MakeQuad(EdgeX121,
EdgeZ121, EdgeX122, EdgeZ221)</p>
<p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
EdgeY11, EdgeX121, EdgeY21)</p>
<p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
EdgeY12, EdgeX122, EdgeY22)</p>
<p>&nbsp;</p>
<p># create a solid</p>
<p class="whs2">Block = MakeHexa(FaceX11,
FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
<p>&nbsp;</p>
<p># create a compound</p>
<p class="whs2">box = MakeCompound([Block])</p>
<p>&nbsp;</p>
<p># add in the study</p>
<p class="whs2">box_id = addToStudy(box,
&quot;Box compound&quot;)</p>
<p>&nbsp;</p>
<p># create a hexahedral mesh on the box</p>
<p class="whs2">hexa = smesh.Mesh(box,
&quot;Box compound : hexahedrical mesh&quot;)</p>
<p class="whs2">algo = hexa.Segment()</p>
<p>&nbsp;</p>
<p># define &quot;NumberOfSegments&quot; hypothesis to cut an edge in a
fixed number of segments</p>
<p class="whs2">algo.NumberOfSegments(4)</p>
<p>&nbsp;</p>
<p># create a quadrangle 2D algorithm for faces</p>
<p class="whs2">hexa.Quadrangle()</p>
<p>&nbsp;</p>
<p># create a hexahedron 3D algorithm for solids</p>
<p class="whs2">hexa.Hexahedron()</p>
<p>&nbsp;</p>
<p># create a local hypothesis</p>
<p class="whs2">algo = hexa.Segment(EdgeX111)</p>
<p>&nbsp;</p>
<p># define &quot;Arithmetic1D&quot; hypothesis to cut an edge in several
segments with arithmetic length increasing</p>
<p class="whs2">algo.Arithmetic1D(1,
4)</p>
<p>&nbsp;</p>
<p># define &quot;Propagation&quot; hypothesis that propagates all other
hypothesis on all edges on the opposite side in case of quadrangular faces</p>
<p class="whs2">algo.Propagation()</p>
<p>&nbsp;</p>
<p># compute the mesh</p>
<p class="whs2">hexa.Compute() </p>
<p class="whs2">&nbsp;</p>
<h4><a name=bookmark9>Deflection 1D and Number of Segments</a></h4>
<p class="whs2">&nbsp;</p>
<p class="whs2">import smesh</p>
<p class="whs2">import geompy</p>
<p class="whs2">import salome</p>
<p class="whs2">gg = salome.ImportComponentGUI(&quot;GEOM&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create vertices</p>
<p class="whs2">px &nbsp;&nbsp;=geompy.MakeVertex(100., 0. &nbsp;,0. &nbsp;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">py &nbsp;&nbsp;=geompy.MakeVertex(0. &nbsp;,100., 0. &nbsp;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">pz &nbsp;&nbsp;=geompy.MakeVertex(0. &nbsp;,0. &nbsp;, 100.)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a vector from
two points</p>
<p class="whs2">vxy = geompy.MakeVector(px,py)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs3"># create an arc from
three points</p>
<p class="whs2">arc = geompy.MakeArc(py, pz, px)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a wire</p>
<p class="whs2">wire = geompy.MakeWire([vxy,arc])</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">isPlanarFace = 1</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a face from the wire</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">face1 = geompy.MakeFace(wire,isPlanarFace)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs3"># get edges from the face</p>
<p class="whs2">vxy, arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># add objects in the study</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">id_face1 = geompy.addToStudy(face1,&quot;Face1&quot;)</p>
<p class="whs2">id_arc = geompy.addToStudyInFather(face1,arc,&quot;Arc Edge&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">&nbsp;</p>
<p class="whs3"># display faces</p>
<p class="whs2">gg.createAndDisplayGO(id_face1)</p>
<p class="whs2">gg.setDisplayMode(id_face1,1)</p>
<p class="whs2">gg.setTransparency(id_face1,0.2)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create hexahedral mesh</p>
<p class="whs2">hexa = smesh.Mesh(face1,&quot;Face compound : hexahedrical mesh&quot;)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">algo = hexa.Triangle()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;MaxElementArea&quot;hypothesis</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">algo.MaxElementArea(30)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a local hypothesis on the wire</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">algo = hexa.Segment(wire)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;NumberOfSegments&quot;hypothesis to cut
a straight edge in a fixed number of segments</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">algo.NumberOfSegments(6)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define a local &quot;Deflection1D&quot;hypothesis on the arc</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">algo = hexa.Segment(arc)</p>
2005-11-28 14:57:47 +05:00
<p class="whs2">algo.Deflection1D(1)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># compute the mesh</p>
<p class="whs2">hexa.Compute() </p>
<p>&nbsp;</p>
<h4><a name=bookmark2>Start and End Length</a></h4>
<p class="whs2">from geompy import
*</p>
<p class="whs2">import smesh</p>
<p>&nbsp;</p>
<p># create vertices</p>
<p class="whs2">Point111 = MakeVertex(
0, &nbsp;0, &nbsp;0)</p>
<p class="whs2">Point211 = MakeVertex(10,
&nbsp;0, &nbsp;0)</p>
<p class="whs2">Point121 = MakeVertex(
0, 10, &nbsp;0)</p>
<p class="whs2">Point221 = MakeVertex(10,
10, &nbsp;0)</p>
<p class="whs2">Point112 = MakeVertex(
0, &nbsp;0, 10)</p>
<p class="whs2">Point212 = MakeVertex(10,
&nbsp;0, 10)</p>
<p class="whs2">Point122 = MakeVertex(
0, 10, 10)</p>
<p class="whs2">Point222 = MakeVertex(10,
10, 10)</p>
<p>&nbsp;</p>
<p># create edges</p>
<p class="whs2">EdgeX111 = MakeEdge(Point111,
Point211)</p>
<p class="whs2">EdgeX121 = MakeEdge(Point121,
Point221)</p>
<p class="whs2">EdgeX112 = MakeEdge(Point112,
Point212)</p>
<p class="whs2">EdgeX122 = MakeEdge(Point122,
Point222)</p>
<p class="whs2">EdgeY11 = MakeEdge(Point111,
Point121)</p>
<p class="whs2">EdgeY21 = MakeEdge(Point211,
Point221)</p>
<p class="whs2">EdgeY12 = MakeEdge(Point112,
Point122)</p>
<p class="whs2">EdgeY22 = MakeEdge(Point212,
Point222)</p>
<p class="whs2">EdgeZ111 = MakeEdge(Point111,
Point112)</p>
<p class="whs2">EdgeZ211 = MakeEdge(Point211,
Point212)</p>
<p class="whs2">EdgeZ121 = MakeEdge(Point121,
Point122)</p>
<p class="whs2">EdgeZ221 = MakeEdge(Point221,
Point222)</p>
<p>&nbsp;</p>
<p># create faces</p>
<p class="whs2">FaceX11 = MakeQuad(EdgeY11,
EdgeZ111, EdgeY12, EdgeZ121)</p>
<p class="whs2">FaceX21 = MakeQuad(EdgeY21,
EdgeZ211, EdgeY22, EdgeZ221)</p>
<p class="whs2">FaceY111 = MakeQuad(EdgeX111,
EdgeZ111, EdgeX112, EdgeZ211)</p>
<p class="whs2">FaceY121 = MakeQuad(EdgeX121,
EdgeZ121, EdgeX122, EdgeZ221)</p>
<p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
EdgeY11, EdgeX121, EdgeY21)</p>
<p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
EdgeY12, EdgeX122, EdgeY22)</p>
<p>&nbsp;</p>
<p># create a solid</p>
<p class="whs2">Block = MakeHexa(FaceX11,
FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
<p>&nbsp;</p>
<p># create a compound</p>
<p class="whs2">box = MakeCompound([Block])</p>
<p>&nbsp;</p>
<p># add in the study</p>
<p class="whs2">box_id = addToStudy(box,
&quot;Box compound&quot;)</p>
<p>&nbsp;</p>
<p># create a hexahedral mesh on the box</p>
<p class="whs2">hexa = smesh.Mesh(box,
&quot;Box compound : hexahedrical mesh&quot;)</p>
<p class="whs2">algo = hexa.Segment()</p>
<p>&nbsp;</p>
<p># define &quot;NumberOfSegments&quot; hypothesis to cut an edge in a
fixed number of segments</p>
<p class="whs2">algo.NumberOfSegments(4)</p>
<p>&nbsp;</p>
<p># create a quadrangle 2D algorithm for faces</p>
<p class="whs2">hexa.Quadrangle()</p>
<p>&nbsp;</p>
<p># create a hexahedron 3D algorithm for solids</p>
<p class="whs2">hexa.Hexahedron()</p>
<p>&nbsp;</p>
<p># create a local hypothesis</p>
<p class="whs2">algo = hexa.Segment(EdgeX111)</p>
<p>&nbsp;</p>
<p># define &quot;StartEndLength&quot; hypothesis to cut an edge in several
segments with increasing geometric length </p>
<p class="whs2">algo.StartEndLength(1,
6)</p>
<p>&nbsp;</p>
<p># define &quot;Propagation&quot; hypothesis that propagates all other
hypothesis on all edges on the opposite side in case of quadrangular faces</p>
<p class="whs2">algo.Propagation()</p>
<p>&nbsp;</p>
<p># compute the mesh</p>
<p class="whs2">hexa.Compute() </p>
<p class="whs2">&nbsp;</p>
<h4><a name=bookmark3>Average Length</a></h4>
<p class="whs2">from geompy import
*</p>
<p class="whs2">import smesh</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create vertices</p>
<p class="whs2">Point111 = MakeVertex(
0, &nbsp;0, &nbsp;0)</p>
<p class="whs2">Point211 = MakeVertex(10,
&nbsp;0, &nbsp;0)</p>
<p class="whs2">Point121 = MakeVertex(
0, 10, &nbsp;0)</p>
<p class="whs2">Point221 = MakeVertex(10,
10, &nbsp;0)</p>
<p class="whs2">Point112 = MakeVertex(
0, &nbsp;0, 10)</p>
<p class="whs2">Point212 = MakeVertex(10,
&nbsp;0, 10)</p>
<p class="whs2">Point122 = MakeVertex(
0, 10, 10)</p>
<p class="whs2">Point222 = MakeVertex(10,
10, 10)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create edges</p>
<p class="whs2">EdgeX111 = MakeEdge(Point111,
Point211)</p>
<p class="whs2">EdgeX121 = MakeEdge(Point121,
Point221)</p>
<p class="whs2">EdgeX112 = MakeEdge(Point112,
Point212)</p>
<p class="whs2">EdgeX122 = MakeEdge(Point122,
Point222)</p>
<p class="whs2">EdgeY11 = MakeEdge(Point111,
Point121)</p>
<p class="whs2">EdgeY21 = MakeEdge(Point211,
Point221)</p>
<p class="whs2">EdgeY12 = MakeEdge(Point112,
Point122)</p>
<p class="whs2">EdgeY22 = MakeEdge(Point212,
Point222)</p>
<p class="whs2">EdgeZ111 = MakeEdge(Point111,
Point112)</p>
<p class="whs2">EdgeZ211 = MakeEdge(Point211,
Point212)</p>
<p class="whs2">EdgeZ121 = MakeEdge(Point121,
Point122)</p>
<p class="whs2">EdgeZ221 = MakeEdge(Point221,
Point222)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create faces</p>
<p class="whs2">FaceX11 = MakeQuad(EdgeY11,
EdgeZ111, EdgeY12, EdgeZ121)</p>
<p class="whs2">FaceX21 = MakeQuad(EdgeY21,
EdgeZ211, EdgeY22, EdgeZ221)</p>
<p class="whs2">FaceY111 = MakeQuad(EdgeX111,
EdgeZ111, EdgeX112, EdgeZ211)</p>
<p class="whs2">FaceY121 = MakeQuad(EdgeX121,
EdgeZ121, EdgeX122, EdgeZ221)</p>
<p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
EdgeY11, EdgeX121, EdgeY21)</p>
<p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
EdgeY12, EdgeX122, EdgeY22)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a solid</p>
<p class="whs2">Block = MakeHexa(FaceX11,
FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a compound</p>
<p class="whs2">box = MakeCompound([Block])</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># add in the study</p>
<p class="whs2">box_id = addToStudy(box,
&quot;Box compound&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a hexahedral
mesh on the box</p>
<p class="whs2">hexa = smesh.Mesh(box,
&quot;Box compound : hexahedrical mesh&quot;)</p>
<p class="whs2">algo = hexa.Segment()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;NumberOfSegments&quot;
hypothesis to cut an edge in a fixed number of segments</p>
<p class="whs2">algo.NumberOfSegments(4)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a quadrangle
2D algorithm for faces</p>
<p class="whs2">hexa.Quadrangle()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a hexahedron
3D algorithm for solids</p>
<p class="whs2">hexa.Hexahedron()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a local hypothesis</p>
<p class="whs2">algo = hexa.Segment(EdgeX111)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;LocalLength&quot;
hypothesis to cut an edge in several segments with the same length</p>
<p class="whs2">algo.LocalLength(2)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;Propagation&quot;
hypothesis that propagates all other hypothesis on all edges on<span style="font-family: 'Times New Roman', serif;">
the opposite side in case of quadrangular faces</span></p>
<p class="whs2">algo.Propagation()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># compute the mesh</p>
<p class="whs2">hexa.Compute() </p>
<p class="whs2">&nbsp;</p>
<p class="whs2">&nbsp;</p>
<h3>Defining 2D and 3D hypotheses</h3>
<h4><a name=bookmark4>Maximum Element Area</a></h4>
<p class="whs4">import smesh</p>
<p class="whs4">import geompy</p>
<p class="whs4">import salome</p>
<p class="whs4">gg = salome.ImportComponentGUI(&quot;GEOM&quot;)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create vertices</p>
<p class="whs4">px &nbsp;&nbsp;=
geompy.MakeVertex(100., 0. &nbsp;,
0. &nbsp;)</p>
<p class="whs4">py &nbsp;&nbsp;=
geompy.MakeVertex(0. &nbsp;,
100., 0. &nbsp;)</p>
<p class="whs4">pz &nbsp;&nbsp;=
geompy.MakeVertex(0. &nbsp;,
0. &nbsp;, 100.)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create a vector from
two points</p>
<p class="whs4">vxy = geompy.MakeVector(px,
py)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create an arc from three
points</p>
<p class="whs4">arc = geompy.MakeArc(py,
pz, px)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create a wire</p>
<p class="whs4">wire = geompy.MakeWire([vxy,
arc])</p>
<p class="whs4">isPlanarFace = 1</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create a face from the
wire</p>
<p class="whs4">face1 = geompy.MakeFace(wire,
isPlanarFace)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># add objects in the study</p>
<p class="whs4">id_face1 = geompy.addToStudy(face1,&quot;Face1&quot;)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># display faces</p>
<p class="whs4">gg.createAndDisplayGO(id_face1)</p>
<p class="whs4">gg.setDisplayMode(id_face1,1)</p>
<p class="whs4">gg.setTransparency(id_face1,0.2)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create a hexahedral mesh</p>
<p class="whs4">hexa = smesh.Mesh(face1,
&quot;Face compound : hexahedrical mesh&quot;)</p>
<p class="whs4">algo = hexa.Triangle()</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># define &quot;MaxElementArea&quot;
hypothesis to be applied to each triangle</p>
<p class="whs4">algo.MaxElementArea(7)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create a quadrangle 2D
algorithm for faces</p>
<p class="whs4">hexa.Quadrangle()</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create a local hypothesis</p>
<p class="whs6">algo = hexa.Segment(wire)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># define &quot;NumberOfSegments&quot;
hypothesis to cut an edge in a fixed number of segments</p>
<p class="whs4">algo.NumberOfSegments(10)</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># compute the mesh</p>
<p class="whs4">hexa.Compute() </p>
<p class="whs4">&nbsp;</p>
<h4><a name=bookmark5>Maximum Element Volume</a></h4>
<p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
salome</span></p>
<p class="whs4">import geompy</p>
<p class="whs4">import StdMeshers</p>
<p class="whs4">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;,
&quot;SMESH&quot;)</p>
<p class="whs4">smeshgui = salome.ImportComponentGUI(&quot;SMESH&quot;)</p>
<p class="whs4">smeshgui.Init(salome.myStudyId);</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create a box</p>
<p class="whs4">box = geompy.MakeCylinderRH(30,
50) #MakeBox(0., 0., 0., 100., 200., 300.)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># add the box to the
study</p>
<p class="whs4">idbox = geompy.addToStudy(box,
&quot;box&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create vertices</p>
<p class="whs4">px &nbsp;&nbsp;=
geompy.MakeVertex(100., 0. &nbsp;,
0. &nbsp;)</p>
<p class="whs4">py &nbsp;&nbsp;=
geompy.MakeVertex(0. &nbsp;,
100., 0. &nbsp;)</p>
<p class="whs4">pz &nbsp;&nbsp;=
geompy.MakeVertex(0. &nbsp;,
0. &nbsp;, 100.)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create a vector from
two points</p>
<p class="whs4">vxy = geompy.MakeVector(px,
py)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create an arc from
three points</p>
<p class="whs4">arc = geompy.MakeArc(py,
pz, px)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create a wire</p>
<p class="whs4">wire = geompy.MakeWire([vxy,
arc])</p>
<p class="whs4">isPlanarFace = 1</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create a face from
the wire</p>
<p class="whs4">#face1</p>
<p class="whs4">box = geompy.MakeFace(wire,
isPlanarFace)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># add objects in the
study</p>
<p class="whs4">id_face1 = geompy.addToStudy(box,&quot;Face1&quot;)</p>
<p class="whs4">#geompy.addToStudy(face1,&quot;Face1&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># display faces</p>
<p class="whs4">gg.createAndDisplayGO(id_face1)</p>
<p class="whs4">gg.setDisplayMode(id_face1,1)</p>
<p class="whs4">gg.setTransparency(id_face1,0.2)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create a hypothesis</p>
<p class="whs4">print &quot;--------------------------
create Hypothesis&quot;</p>
<p class="whs4">print &quot;--------------------------
NumberOfSegments&quot;</p>
<p class="whs4">numberOfSegments
= 7</p>
<p class="whs4">hypNbSeg = smesh.CreateHypothesis(&quot;NumberOfSegments&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">hypNbSeg.SetNumberOfSegments(numberOfSegments)</p>
<p class="whs4">print hypNbSeg.GetName()</p>
<p class="whs4">print hypNbSeg.GetId()</p>
<p class="whs4">print hypNbSeg.GetNumberOfSegments()</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(hypNbSeg),
&quot;NumberOfSegments_10&quot;)</p>
<p class="whs4">print &quot;--------------------------
MaxElementArea&quot;</p>
<p class="whs4">maxElementArea =
800</p>
<p class="whs4">hypArea = smesh.CreateHypothesis(&quot;MaxElementArea&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">hypArea.SetMaxElementArea(maxElementArea)</p>
<p class="whs4">print hypArea.GetName()</p>
<p class="whs4">print hypArea.GetId()</p>
<p class="whs4">print hypArea.GetMaxElementArea()</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(hypArea),
&quot;MaxElementArea_800&quot;)</p>
<p class="whs4">print &quot;--------------------------
MaxElementVolume&quot;</p>
<p class="whs4">maxElementVolume
= 900</p>
<p class="whs4">hypVolume = smesh.CreateHypothesis(&quot;MaxElementVolume&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">hypVolume.SetMaxElementVolume(maxElementVolume)</p>
<p class="whs4">print hypVolume.GetName()</p>
<p class="whs4">print hypVolume.GetId()</p>
<p class="whs4">print hypVolume.GetMaxElementVolume()</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(hypVolume),
&quot;MaxElementVolume_900&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># create algorithms</p>
<p class="whs4">print &quot;--------------------------
create Algorithms&quot;</p>
<p class="whs4">print &quot;--------------------------
Regular_1D&quot;</p>
<p class="whs4">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(regular1D),
&quot;Wire Discretisation&quot;)</p>
<p class="whs4">print &quot;--------------------------
MEFISTO_2D&quot;</p>
<p class="whs4">mefisto2D = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(mefisto2D),
&quot;MEFISTO_2D&quot;)</p>
<p class="whs4">#print &quot;--------------------------
Hexa_3D (Hexahedron meshing algorithm)&quot;</p>
<p class="whs4">hexa3D = smesh.CreateHypothesis(&quot;Hexa_3D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(hexa3D),
&quot;HEXA_3D&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># initialize a mesh
with the box</p>
<p class="whs4">mesh = smesh.CreateMesh(box)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(mesh),
&quot;MeshBox&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># add a hypothesis
to the box</p>
<p class="whs4">print &quot;--------------------------
add hypothesis to the box&quot;</p>
<p class="whs4">mesh.AddHypothesis(box,hypNbSeg)</p>
<p class="whs4">mesh.AddHypothesis(box,hypArea)</p>
<p class="whs4">mesh.AddHypothesis(box,hypVolume)</p>
<p class="whs4">mesh.AddHypothesis(box,regular1D)</p>
<p class="whs4">mesh.AddHypothesis(box,mefisto2D)</p>
<p class="whs4">mesh.AddHypothesis(box,hexa3D)</p>
<p class="whs4">&nbsp;</p>
<p class="whs7"># compute the mesh</p>
<p class="whs4">print &quot;--------------------------
compute the mesh of the box&quot;</p>
<p class="whs4">ret = smesh.Compute(mesh,box)</p>
<p class="whs4">print ret</p>
<p class="whs4">if ret == 0:</p>
<p class="whs4">&nbsp;&nbsp;&nbsp;&nbsp;print
&quot;probleme when computing the mesh&quot;</p>
<p class="whs4">salome.sg.updateObjBrowser(1)</p>
<p class="whs4">&nbsp;</p>
<h3>Defining Additional Hypotheses</h3>
<h4><a name=bookmark6>Length from Edges</a></h4>
<p class="whs2">import smesh</p>
<p class="whs2">import geompy</p>
<p class="whs2">import salome</p>
<p class="whs2">gg = salome.ImportComponentGUI(&quot;GEOM&quot;)</p>
<p>&nbsp;</p>
<p># create sketchers</p>
<p class="whs2">sketcher1 = geompy.MakeSketcher(&quot;Sketcher:F
0 0:TT 70 0:TT 70 70:TT 0 70:WW&quot;)</p>
<p class="whs2">sketcher2 = geompy.MakeSketcher(&quot;Sketcher:F
20 20:TT 50 20:TT 50 50:TT 20 50:WW&quot;)</p>
<p class="whs2">isPlanarFace = 1</p>
<p>&nbsp;</p>
<p># create faces from two wires</p>
<p class="whs2">face1 = geompy.MakeFaces([sketcher1,
sketcher2],isPlanarFace)</p>
<p>&nbsp;</p>
<p># add objects in the study</p>
<p class="whs2">id_face1 = geompy.addToStudy(face1,&quot;Face1&quot;)</p>
<p>&nbsp;</p>
<p># display faces</p>
<p class="whs2">gg.createAndDisplayGO(id_face1)</p>
<p class="whs2">gg.setDisplayMode(id_face1,1)</p>
<p class="whs2">gg.setTransparency(id_face1,0.2)</p>
<p>&nbsp;</p>
<p># create a mesh</p>
<p class="whs2">hexa = smesh.Mesh(face1,
&quot;Face : triangle 2D mesh&quot;)</p>
<p class="whs2">algo = hexa.Triangle()</p>
<p>&nbsp;</p>
<p># define &quot;MaxElementArea&quot; hypothesis to be applied to each
triangle</p>
<p class="whs2">algo.MaxElementArea(30)</p>
<p>&nbsp;</p>
<p># define &quot;LengthFromEdges&quot; hypothesis to build triangles based
on the length of the edges taken from the wire</p>
<p class="whs2">algo.LengthFromEdges()</p>
<p>&nbsp;</p>
<p># create local hypothesis</p>
<p class="whs2">algo = hexa.Segment()</p>
<p>&nbsp;</p>
<p># define &quot;NumberOfSegments&quot; hypothesis to cut an edge in a
fixed number of segments</p>
<p class="whs2">algo.NumberOfSegments(2)</p>
<p>&nbsp;</p>
<p># compute the mesh</p>
<p class="whs2">hexa.Compute() </p>
<p class="whs2">&nbsp;</p>
<h4><a name=bookmark7>Propagation</a></h4>
<p class="whs2">from geompy import
*</p>
<p class="whs2">import smesh</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create vertices</p>
<p class="whs2">Point111 = MakeVertex(
0, &nbsp;0, &nbsp;0)</p>
<p class="whs2">Point211 = MakeVertex(10,
&nbsp;0, &nbsp;0)</p>
<p class="whs2">Point121 = MakeVertex(
0, 10, &nbsp;0)</p>
<p class="whs2">Point221 = MakeVertex(10,
10, &nbsp;0)</p>
<p class="whs2">Point112 = MakeVertex(
0, &nbsp;0, 10)</p>
<p class="whs2">Point212 = MakeVertex(10,
&nbsp;0, 10)</p>
<p class="whs2">Point122 = MakeVertex(
0, 10, 10)</p>
<p class="whs2">Point222 = MakeVertex(10,
10, 10)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create edges</p>
<p class="whs2">EdgeX111 = MakeEdge(Point111,
Point211)</p>
<p class="whs2">EdgeX121 = MakeEdge(Point121,
Point221)</p>
<p class="whs2">EdgeX112 = MakeEdge(Point112,
Point212)</p>
<p class="whs2">EdgeX122 = MakeEdge(Point122,
Point222)</p>
<p class="whs2">EdgeY11 = MakeEdge(Point111,
Point121)</p>
<p class="whs2">EdgeY21 = MakeEdge(Point211,
Point221)</p>
<p class="whs2">EdgeY12 = MakeEdge(Point112,
Point122)</p>
<p class="whs2">EdgeY22 = MakeEdge(Point212,
Point222)</p>
<p class="whs2">EdgeZ111 = MakeEdge(Point111,
Point112)</p>
<p class="whs2">EdgeZ211 = MakeEdge(Point211,
Point212)</p>
<p class="whs2">EdgeZ121 = MakeEdge(Point121,
Point122)</p>
<p class="whs2">EdgeZ221 = MakeEdge(Point221,
Point222)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create faces</p>
<p class="whs2">FaceX11 = MakeQuad(EdgeY11,
EdgeZ111, EdgeY12, EdgeZ121)</p>
<p class="whs2">FaceX21 = MakeQuad(EdgeY21,
EdgeZ211, EdgeY22, EdgeZ221)</p>
<p class="whs2">FaceY111 = MakeQuad(EdgeX111,
EdgeZ111, EdgeX112, EdgeZ211)</p>
<p class="whs2">FaceY121 = MakeQuad(EdgeX121,
EdgeZ121, EdgeX122, EdgeZ221)</p>
<p class="whs2">FaceZ11 = MakeQuad(EdgeX111,
EdgeY11, EdgeX121, EdgeY21)</p>
<p class="whs2">FaceZ12 = MakeQuad(EdgeX112,
EdgeY12, EdgeX122, EdgeY22)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a solid</p>
<p class="whs2">Block = MakeHexa(FaceX11,
FaceX21, FaceY111, FaceY121, FaceZ11, FaceZ12)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a compound</p>
<p class="whs2">box = MakeCompound([Block])</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># add in the study</p>
<p class="whs2">box_id = addToStudy(box,
&quot;Box compound&quot;)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a hexahedral
mesh on the box</p>
<p class="whs2">hexa = smesh.Mesh(box,
&quot;Box compound : hexahedrical mesh&quot;)</p>
<p class="whs2">algo = hexa.Segment()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;NumberOfSegments&quot;
hypothesis to cut an edge in a fixed number of segments</p>
<p class="whs2">algo.NumberOfSegments(4)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a quadrangle
2D algorithm for faces</p>
<p class="whs2">hexa.Quadrangle()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a hexahedron
3D algorithm for solids</p>
<p class="whs2">hexa.Hexahedron()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a local hypothesis</p>
<p class="whs2">algo = hexa.Segment(EdgeX111)</p>
<p class="whs2">&nbsp;</p>
<p class="whs2"><span style="font-family: 'Times New Roman', serif;">#
define &quot;Arithmetic1D&quot; hypothesis to cut an edge in several segments
with arithmetic length</span> </p>
<p class="whs2">increasing</p>
<p class="whs2">algo.Arithmetic1D(1,
4)</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;Propagation&quot;
hypothesis that propagatea all other hypothesis on all edges on the opposite
side in case of quadrangular faces</p>
<p class="whs2">algo.Propagation()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># compute the mesh</p>
<p class="whs2">hexa.Compute() </p>
<p class="whs2">&nbsp;</p>
<h3><a name=bookmark8>Defining Meshing Algorithms</a></h3>
<p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
salome</span></p>
<p class="whs4">import StdMeshers</p>
<p class="whs4">import NETGENPlugin</p>
<p class="whs4">&nbsp;</p>
<p class="whs4">smesh = salome.lcc.FindOrLoadComponent(&quot;FactoryServer&quot;,
&quot;SMESH&quot;)</p>
<p class="whs4">smeshgui = salome.ImportComponentGUI(&quot;SMESH&quot;)</p>
<p class="whs4">smeshgui.Init(salome.myStudyId);</p>
<p class="whs5">&nbsp;</p>
<p class="whs5"># create algorithms</p>
<p class="whs4">print &quot;--------------------------
create Algorithms&quot;</p>
<p class="whs4">print &quot;--------------------------
Regular_1D (Wire discretisation)&quot;</p>
<p class="whs4">regular1D = smesh.CreateHypothesis(&quot;Regular_1D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(regular1D),
&quot;Wire Discretisation&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs4">print &quot;--------------------------
MEFISTO_2D (Triangle meshing algorithm)&quot;</p>
<p class="whs4">mefisto2D = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(mefisto2D),
&quot;MEFISTO_2D&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs4">print &quot;--------------------------
Quadrangle_2D (Quadrangle meshing algorithm)&quot;</p>
<p class="whs4">quad2D = smesh.CreateHypothesis(
&quot;Quadrangle_2D&quot;, &quot;libStdMeshersEngine.so&quot; )</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(quad2D),
&quot;Quadrangle_2D&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs4">print &quot;--------------------------
Hexa_3D (Hexahedron meshing algorithm)&quot;</p>
<p class="whs4">hexa3D = smesh.CreateHypothesis(&quot;Hexa_3D&quot;,
&quot;libStdMeshersEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(hexa3D),
&quot;HEXA_3D&quot;)</p>
<p class="whs4">&nbsp;</p>
<p class="whs4">print &quot;--------------------------
NETGEN_3D (Tetrahedron meshing algorithm)&quot;</p>
<p class="whs4">netgen3D = smesh.CreateHypothesis(&quot;NETGEN_3D&quot;,
&quot;libNETGENEngine.so&quot;)</p>
<p class="whs4">smeshgui.SetName(salome.ObjectToID(netgen3D),
&quot;NETGEN_3D&quot;)</p>
<p class="whs4">salome.sg.updateObjBrowser(1)</p>
<p class="whs5">&nbsp;</p>
<script type="text/javascript" language="javascript1.2">
<!--
if (window.writeIntopicBar)
writeIntopicBar(0);
//-->
</script>
</body>
</html>