Salome HOME
2a9d61b70654e6ab6bf2d25fa431bb4c8dd35a04
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / disque_perce.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2014-2020  EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import sys
22 import salome
23
24 salome.salome_init()
25
26 import salome_notebook
27 notebook = salome_notebook.notebook
28
29 import os
30 from blocFissure import gmu
31
32
33 ###
34 ### GEOM component
35 ###
36
37 import GEOM
38 from salome.geom import geomBuilder
39 import math
40 import SALOMEDS
41
42
43 geompy = geomBuilder.New()
44
45 O = geompy.MakeVertex(0, 0, 0)
46 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
47 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
48 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
49 Cylinder_1 = geompy.MakeCylinderRH(100, 300)
50 Cylinder_2 = geompy.MakeCylinderRH(600, 200)
51 Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1)
52 Face_1 = geompy.MakeFaceHW(500, 1500, 3)
53 Disque = geompy.MakePartition([Cut_1], [Face_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
54 [Compound_1, Compound_2, Compound_3, Compound_4] = geompy.Propagate(Disque)
55 geompy.addToStudy( O, 'O' )
56 geompy.addToStudy( OX, 'OX' )
57 geompy.addToStudy( OY, 'OY' )
58 geompy.addToStudy( OZ, 'OZ' )
59 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
60 geompy.addToStudy( Cylinder_2, 'Cylinder_2' )
61 geompy.addToStudy( Cut_1, 'Cut_1' )
62 geompy.addToStudy( Face_1, 'Face_1' )
63 geompy.addToStudy( Disque, 'Disque' )
64 geompy.addToStudyInFather( Disque, Compound_1, 'Compound_1' )
65 geompy.addToStudyInFather( Disque, Compound_2, 'Compound_2' )
66 geompy.addToStudyInFather( Disque, Compound_3, 'Compound_3' )
67 geompy.addToStudyInFather( Disque, Compound_4, 'Compound_4' )
68
69 ###
70 ### SMESH component
71 ###
72
73 import  SMESH, SALOMEDS
74 from salome.smesh import smeshBuilder
75
76 smesh = smeshBuilder.New()
77 from salome.StdMeshers import StdMeshersBuilder
78 Disque_1 = smesh.Mesh(Disque)
79 smesh.SetName(Disque_1, 'Disque')
80 Regular_1D = Disque_1.Segment()
81 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
82 Nb_Segments_1.SetDistrType( 0 )
83 Hexa_3D = Disque_1.Hexahedron(algo=smeshBuilder.Hexa)
84 Regular_1D_1 = Disque_1.Segment(geom=Compound_3)
85 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20)
86 Nb_Segments_2.SetDistrType( 0 )
87 Regular_1D_2 = Disque_1.Segment(geom=Compound_4)
88 status = Disque_1.AddHypothesis(Nb_Segments_2,Compound_4)
89 Quadrangle_2D = Disque_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
90 is_done = Disque_1.Compute()
91 text = "Disque_1.Compute"
92 if is_done:
93   logging.info(text+" OK")
94 else:
95   text = "Erreur au calcul du maillage.\n" + text
96   logging.info(text)
97   raise Exception(text)
98 Disque_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "disque.med"))
99 SubMesh_1 = Regular_1D_1.GetSubMesh()
100 SubMesh_2 = Regular_1D_2.GetSubMesh()
101
102 ## set object names
103 smesh.SetName(Disque_1.GetMesh(), 'Disque')
104 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
105 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
106 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
107 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
108 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
109 smesh.SetName(SubMesh_1, 'SubMesh_1')
110 smesh.SetName(SubMesh_2, 'SubMesh_2')
111
112 if salome.sg.hasDesktop():
113   salome.sg.updateObjBrowser()