Salome HOME
Create LICENSE
[plugins/hexoticplugin.git] / doc / salome / examples / hexoticsubdom1.py
1 import salome
2 salome.salome_init()
3
4 from salome.geom import geomBuilder
5 geompy = geomBuilder.New()
6
7 import SMESH, SALOMEDS
8 from salome.smesh import smeshBuilder
9 smesh =  smeshBuilder.New()
10
11
12 # Create geometry: a box cut by a holed sphere
13 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
14 Sphere_1 = geompy.MakeSphereR(75)
15 Sphere_2 = geompy.MakeSphereR(25)
16 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
17 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
18 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
19 geompy.addToStudy( Box_1, 'Box_1' )
20 geompy.addToStudy( Sphere_1, 'Sphere_1' )
21 geompy.addToStudy( Sphere_2, 'Sphere_2' )
22 geompy.addToStudy( Cut_1, 'Cut_1' )
23 geompy.addToStudy( Cut_2, 'Cut_2' )
24
25 # Create filters
26 # aFilter1: elements inside small sphere
27 aFilter1 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2)
28 # aFilter2: elements inside big sphere and not inside small sphere
29 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalAND),
30                                         smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2, SMESH.FT_LogicalNOT)])
31 # aFilter3: elements not inside big sphere
32 aFilter3 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalNOT)
33
34 # Create mesh of Cut_2 with sd mode 1
35 print("Create mesh of Cut_2 with sd mode 1")
36 Mesh_mghexa_sd1 = smesh.Mesh(Cut_2, "Mesh_mghexa_sd1")
37
38 # Create the 2D algo: MG-CADSurf with geometrical mesh
39 Mesh_mghexa_sd1.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
40
41 # Create the 3D algo: MG-Hexa with:
42 # - minl = 4
43 # - maxl = 8
44 # - sd = 1
45 Mesh_mghexa_sd1.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 1 )
46
47 # Create the groups on filters
48 g1 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'small sphere', aFilter1 )
49 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
50 g2 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'big sphere - small sphere', aFilter2 )
51 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
52 g3 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'box - big sphere', aFilter3 )
53 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
54
55 # Compute
56 assert Mesh_mghexa_sd1.Compute(), "Meshing fails"
57
58 # End of script