Salome HOME
96e2fabfe1912ce45ff7bcdad8640cd474d92771
[modules/smesh.git] / doc / salome / examples / defining_hypotheses_adaptive1d.py
1 import salome, math
2 salome.salome_init()
3 from salome.geom import geomBuilder
4 geompy = geomBuilder.New(salome.myStudy)
5 from salome.smesh import smeshBuilder
6 smesh =  smeshBuilder.New(salome.myStudy)
7
8
9 box   = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
10 tool  = geompy.MakeTranslation( box, 50, 0, 10 )
11 axis  = geompy.MakeVector( geompy.MakeVertex( 100, 0, 100 ),geompy.MakeVertex( 100, 10, 100 ),)
12 tool  = geompy.Rotate( tool, axis, math.pi * 25 / 180. )
13 shape = geompy.MakeCut( box, tool )
14 cyl   = geompy.MakeCylinder( geompy.MakeVertex( -10,5, 95 ), geompy.MakeVectorDXDYDZ(1,0,0), 2, 90)
15 shape = geompy.MakeCut( shape, cyl )
16 tool  = geompy.MakeBoxTwoPnt( geompy.MakeVertex( -10, 2, 15 ), geompy.MakeVertex( 90, 5, 16 ))
17 shape = geompy.MakeCut( shape, tool, theName="shape" )
18
19 # Parameters of Adaptive hypothesis. minSize and maxSize are such that they do not limit
20 # size of segments because size of geometrical features lies within [2.-100.] range, hence
21 # size of segments is defined by deflection parameter and size of geometrical features only.
22 minSize = 0.1
23 maxSize = 200
24 deflection = 0.05
25
26 mesh = smesh.Mesh( shape )
27 mesh.Segment().Adaptive( minSize, maxSize, deflection )
28 mesh.Triangle().MaxElementArea( 300 )
29 mesh.Compute()
30