1 <!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
\r
6 <title>Constructing Meshes</title>
\r
7 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
\r
8 <meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com"><style type="text/css">
\r
10 p.whs1 { margin-top:0pt; margin-bottom:0pt; }
\r
11 p.whs2 { margin-top:0pt; margin-bottom:0pt; font-family:'Lucida Console' , monospace; }
\r
12 p.whs3 { margin-top:0pt; margin-bottom:0pt; font-family:'Times New Roman' , serif; }
\r
13 p.whs4 { font-family:'Lucida Console' , monospace; margin-top:0px; margin-bottom:0px; }
\r
14 p.whs5 { margin-top:0px; margin-bottom:0px; font-family:'Times New Roman' , serif; }
\r
15 p.whs6 { margin-top:0px; margin-bottom:0px; }
\r
16 p.whs7 { margin-top:0px; margin-bottom:0px; font-family:'Lucida Console' , monospace; }
\r
18 </style><script type="text/javascript" language="JavaScript">
\r
20 if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
\r
22 var strNSS = "<style type='text/css'>";
\r
23 strNSS += "p.whs1 {margin-top:1pt;margin-bottom:1pt; }";
\r
24 strNSS += "p.whs2 {margin-top:1pt;margin-bottom:1pt; }";
\r
25 strNSS += "p.whs3 {margin-top:1pt;margin-bottom:1pt; }";
\r
26 strNSS += "p.whs4 {margin-top:1pt;margin-bottom:1pt; }";
\r
27 strNSS += "p.whs5 {margin-top:1pt;margin-bottom:1pt; }";
\r
28 strNSS += "p.whs6 {margin-top:1pt;margin-bottom:1pt; }";
\r
29 strNSS += "p.whs7 {margin-top:1pt;margin-bottom:1pt; }";
\r
30 strNSS +="</style>";
\r
31 document.write(strNSS);
\r
35 <script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
\r
38 if (innerWidth != origWidth || innerHeight != origHeight)
\r
41 if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
\r
42 origWidth = innerWidth;
\r
43 origHeight = innerHeight;
\r
49 <style type="text/css">
\r
51 div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
\r
52 p.WebHelpNavBar { text-align:right; }
\r
54 </style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
\r
55 <script type="text/javascript" language="javascript" src="whver.js"></script>
\r
56 <script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
\r
57 <script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
\r
58 <script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
\r
59 <script type="text/javascript" language="javascript1.2">
\r
61 if (window.gbWhTopic)
\r
63 if (window.setRelStartPage)
\r
65 addTocInfo("MESH module\nTUI Scripts\nCreating Meshes");
\r
66 addButton("show",BTN_IMG,"Show","","","","",0,0,"whd_show0.gif","whd_show2.gif","whd_show1.gif");
\r
67 addButton("hide",BTN_IMG,"Hide","","","","",0,0,"whd_hide0.gif","whd_hide2.gif","whd_hide1.gif");
\r
72 if (window.setRelStartPage)
\r
74 setRelStartPage("index.htm");
\r
84 document.location.reload();
\r
88 <body><script type="text/javascript" language="javascript1.2">
\r
90 if (window.writeIntopicBar)
\r
94 <h1>Creating Meshes</h1>
\r
96 <p class="whs1">First of all see <a href="smesh_py_introduction.htm">Example
\r
97 of 3d mesh generation</a>, which is an example of good python script style
\r
98 for Mesh module. </p>
\r
100 <p class="whs1">Other examples of python
\r
101 scripts will be also updated soon to use smesh package instead of direct
\r
102 usage of idl interface. </p>
\r
104 <h3><a name=bookmark>Construction of a Mesh</a></h3>
\r
106 <p class="whs2"><span style="font-family: 'Lucida Console', monospace;">import
\r
109 <p class="whs2">import smesh</p>
\r
111 <p class="whs2"> </p>
\r
113 <p class="whs3"># create a box</p>
\r
115 <p class="whs2">box = geompy.MakeBox(0.,
\r
116 0., 0., 100., 200., 300.)</p>
\r
118 <p class="whs2">idbox = geompy.addToStudy(box,
\r
119 "box")</p>
\r
121 <p class="whs2"> </p>
\r
123 <p class="whs3"># create a mesh</p>
\r
125 <p class="whs2">tetra = smesh.Mesh(box,
\r
126 "MeshBox")</p>
\r
128 <p class="whs2"> </p>
\r
130 <p class="whs2">algo1D = tetra.Segment()</p>
\r
132 <p class="whs2">algo1D.NumberOfSegments(7)</p>
\r
134 <p class="whs2"> </p>
\r
136 <p class="whs2">algo2D = tetra.Triangle()</p>
\r
138 <p class="whs2">algo2D.MaxElementArea(800.)</p>
\r
140 <p class="whs2"> </p>
\r
142 <p class="whs2">algo3D = tetra.Tetrahedron(smesh.NETGEN)</p>
\r
144 <p class="whs2">algo3D.MaxElementVolume(900.)</p>
\r
146 <p class="whs2"> </p>
\r
148 <p class="whs3"># compute the mesh</p>
\r
150 <p class="whs2">ret = tetra.Compute()</p>
\r
152 <p class="whs2">if ret == 0:</p>
\r
154 <p class="whs2"> print
\r
155 "problem when computing the mesh"</p>
\r
157 <p class="whs2">else:</p>
\r
159 <p class="whs2"> print
\r
160 "mesh computed"</p>
\r
162 <p class="whs2"> pass
\r
165 <p class="whs2"> </p>
\r
167 <p class="whs2"> </p>
\r
169 <h3><a name=bookmark1>Construction of a Submesh</a></h3>
\r
171 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">from
\r
172 geompy import *</span></p>
\r
174 <p class="whs4">import smesh</p>
\r
176 <p class="whs4"> </p>
\r
178 <p class="whs5"># create a box</p>
\r
180 <p class="whs4">box = MakeBoxDXDYDZ(10., 10., 10.)</p>
\r
182 <p class="whs4">addToStudy(box, "Box")</p>
\r
184 <p class="whs4"> </p>
\r
186 <p class="whs5"># select one edge of
\r
187 the box for definition of a local hypothesis</p>
\r
189 <p class="whs4">p5 = MakeVertex(5., 0., 0.)</p>
\r
191 <p class="whs4">EdgeX = GetEdgeNearPoint(box, p5)</p>
\r
193 <p class="whs4">addToStudyInFather(box, EdgeX, "Edge
\r
194 [0,0,0 - 10,0,0]")</p>
\r
196 <p class="whs4"> </p>
\r
198 <p class="whs5"># create a hexahedral
\r
199 mesh on the box</p>
\r
201 <p class="whs4">quadra = smesh.Mesh(box, "Box : quadrangle
\r
204 <p class="whs4"> </p>
\r
206 <p class="whs5"># create a regular
\r
207 1D algorithm for the faces</p>
\r
209 <p class="whs4">algo1D = quadra.Segment()</p>
\r
211 <p class="whs4"> </p>
\r
213 <p class="whs5"># define "NumberOfSegments"
\r
214 hypothesis to cut</p>
\r
216 <p class="whs5"># all the edges in
\r
217 a fixed number of segments</p>
\r
219 <p class="whs4">algo1D.NumberOfSegments(4)</p>
\r
221 <p class="whs4"> </p>
\r
223 <p class="whs5"># create a quadrangle
\r
224 2D algorithm for the faces</p>
\r
226 <p class="whs4">quadra.Quadrangle()</p>
\r
228 <p class="whs4"> </p>
\r
230 <p class="whs5"># construct a submesh
\r
231 on the edge with a local hypothesis</p>
\r
233 <p class="whs4">algo_local = quadra.Segment(EdgeX)</p>
\r
235 <p class="whs4"> </p>
\r
237 <p class="whs5"># define "Arithmetic1D"
\r
238 hypothesis to cut the edge<span style="margin-top: 0px;
\r
239 margin-bottom: 0px;
\r
240 font-family: 'Times New Roman', serif;">
\r
241 in several segments with increasing arithmetic length</span></p>
\r
243 <p class="whs4">algo_local.Arithmetic1D(1, 4)</p>
\r
245 <p class="whs4"> </p>
\r
247 <p class="whs5"># define "Propagation"
\r
248 hypothesis that propagates all other hypotheses</p>
\r
250 <p class="whs5"># on all edges of the
\r
251 opposite side in case of quadrangular faces</p>
\r
253 <p class="whs4">algo_local.Propagation()</p>
\r
255 <p class="whs4"> </p>
\r
257 <p class="whs5"># compute the mesh</p>
\r
259 <p class="whs4">quadra.Compute() </p>
\r
261 <p class="whs4"> </p>
\r
263 <h3><a name=bookmark2>Editing of a mesh</a></h3>
\r
265 <p class="whs4"><span style="font-family: 'Lucida Console', monospace;">import
\r
268 <p class="whs4">import smesh</p>
\r
270 <p class="whs4"> </p>
\r
272 <p class="whs4">def PrintMeshInfo(theMesh):</p>
\r
274 <p class="whs4"> aMesh
\r
275 = theMesh.GetMesh()</p>
\r
277 <p class="whs4"> print
\r
278 "Information about mesh:"</p>
\r
280 <p class="whs4"> print
\r
281 "Number of nodes :
\r
282 ", aMesh.NbNodes()</p>
\r
284 <p class="whs4"> print
\r
285 "Number of edges :
\r
286 ", aMesh.NbEdges()</p>
\r
288 <p class="whs4"> print
\r
289 "Number of faces :
\r
290 ", aMesh.NbFaces()</p>
\r
292 <p class="whs4"> print
\r
293 "Number of volumes :
\r
294 ", aMesh.NbVolumes()</p>
\r
296 <p class="whs4"> pass</p>
\r
298 <p class="whs4"> </p>
\r
300 <p class="whs5"># create a box</p>
\r
302 <p class="whs4">box = geompy.MakeBox(0., 0., 0., 20.,
\r
305 <p class="whs4">geompy.addToStudy(box, "box")</p>
\r
307 <p class="whs4"> </p>
\r
309 <p class="whs5"># select one edge of
\r
310 the box for definition of a local hypothesis</p>
\r
312 <p class="whs4">subShapeList = geompy.SubShapeAll(box,
\r
313 geompy.ShapeType["EDGE"])</p>
\r
315 <p class="whs4">edge = subShapeList[0]</p>
\r
317 <p class="whs4">name = geompy.SubShapeName(edge, box)</p>
\r
319 <p class="whs4">geompy.addToStudyInFather(box, edge, name)</p>
\r
321 <p class="whs4"> </p>
\r
323 <p class="whs5"># create a mesh</p>
\r
325 <p class="whs4">tria = smesh.Mesh(box, "Mesh 2D")</p>
\r
327 <p class="whs4">algo1D = tria.Segment()</p>
\r
329 <p class="whs4">hyp1 = algo1D.NumberOfSegments(3)</p>
\r
331 <p class="whs4">algo2D = tria.Triangle()</p>
\r
333 <p class="whs4">hyp2 = algo2D.MaxElementArea(10.)</p>
\r
335 <p class="whs4"> </p>
\r
337 <p class="whs5"># create a sub-mesh</p>
\r
339 <p class="whs4">algo_local = tria.Segment(edge)</p>
\r
341 <p class="whs4">hyp3 = algo_local.Arithmetic1D(1, 6)</p>
\r
343 <p class="whs4">hyp4 = algo_local.Propagation()</p>
\r
345 <p class="whs4"> </p>
\r
347 <p class="whs5"># compute the mesh</p>
\r
349 <p class="whs4">tria.Compute()</p>
\r
351 <p class="whs4">PrintMeshInfo(tria)</p>
\r
353 <p class="whs4"> </p>
\r
355 <p class="whs5"># remove a local hypothesis</p>
\r
357 <p class="whs4">mesh = tria.GetMesh()</p>
\r
359 <p class="whs4">mesh.RemoveHypothesis(edge, hyp4)</p>
\r
361 <p class="whs4"> </p>
\r
363 <p class="whs5"># compute the mesh</p>
\r
365 <p class="whs4">tria.Compute()</p>
\r
367 <p class="whs4">PrintMeshInfo(tria)</p>
\r
369 <p class="whs4"> </p>
\r
371 <p class="whs5"># change the value
\r
372 of the 2D hypothesis</p>
\r
374 <p class="whs4">hyp2.SetMaxElementArea(2.)</p>
\r
376 <p class="whs4"> </p>
\r
378 <p class="whs5"># compute the mesh</p>
\r
380 <p class="whs4">tria.Compute()</p>
\r
382 <p class="whs4">PrintMeshInfo(tria) </p>
\r
384 <p class="whs6"> </p>
\r
386 <h3><a name=bookmark3>Export of a Mesh</a></h3>
\r
388 <p class="whs7">import geompy</p>
\r
390 <p class="whs7">import smesh</p>
\r
392 <p class="whs6"> </p>
\r
394 <p class="whs6"># create a box</p>
\r
396 <p class="whs7">box = geompy.MakeBox(0.,
\r
397 0., 0., 100., 200., 300.)</p>
\r
399 <p class="whs7">idbox = geompy.addToStudy(box,
\r
400 "box")</p>
\r
402 <p class="whs6"> </p>
\r
404 <p class="whs6"># create a mesh</p>
\r
406 <p class="whs7">tetra = smesh.Mesh(box,
\r
407 "MeshBox")</p>
\r
409 <p class="whs6"> </p>
\r
411 <p class="whs7">algo1D = tetra.Segment()</p>
\r
413 <p class="whs7">algo1D.NumberOfSegments(7)</p>
\r
415 <p class="whs7"> </p>
\r
417 <p class="whs7">algo2D = tetra.Triangle()</p>
\r
419 <p class="whs7">algo2D.MaxElementArea(800.)</p>
\r
421 <p class="whs7"> </p>
\r
423 <p class="whs7">algo3D = tetra.Tetrahedron(smesh.NETGEN)</p>
\r
425 <p class="whs7">algo3D.MaxElementVolume(900.)</p>
\r
427 <p class="whs6"> </p>
\r
429 <p class="whs6"># compute the mesh</p>
\r
431 <p class="whs7">tetra.Compute()</p>
\r
433 <p class="whs6"> </p>
\r
435 <p class="whs6"># export the mesh in a
\r
438 <p class="whs7">tetra.ExportMED("/tmp/meshMED.med",
\r
441 <script type="text/javascript" language="javascript1.2">
\r
443 if (window.writeIntopicBar)
\r
444 writeIntopicBar(0);
\r