Salome HOME
Add “Grading” parameter to Adaptive 1D hypothesis
[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 # grading is defined how much size of adjacent elements can differ.
23 minSize = 0.1
24 maxSize = 200
25 deflection = 0.05
26 grading = 0.7
27
28 mesh = smesh.Mesh( shape )
29 mesh.Segment().Adaptive( minSize, maxSize, deflection, grading )
30 mesh.Triangle().MaxElementArea( 300 )
31 mesh.Compute()
32