Salome HOME
Merge branch 'master' into gni/evolution
[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 logging
22
23 import sys
24 import salome
25
26 salome.salome_init()
27
28 import salome_notebook
29 notebook = salome_notebook.notebook
30
31 import os
32 from blocFissure import gmu
33
34
35 ###
36 ### GEOM component
37 ###
38
39 import GEOM
40 from salome.geom import geomBuilder
41 import math
42 import SALOMEDS
43
44
45 geompy = geomBuilder.New()
46
47 O = geompy.MakeVertex(0, 0, 0)
48 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
49 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
50 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
51 Cylinder_1 = geompy.MakeCylinderRH(100, 300)
52 Cylinder_2 = geompy.MakeCylinderRH(600, 200)
53 Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1)
54 Face_1 = geompy.MakeFaceHW(500, 1500, 3)
55 Disque = geompy.MakePartition([Cut_1], [Face_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
56 [Compound_1, Compound_2, Compound_3, Compound_4] = geompy.Propagate(Disque)
57 geompy.addToStudy( O, 'O' )
58 geompy.addToStudy( OX, 'OX' )
59 geompy.addToStudy( OY, 'OY' )
60 geompy.addToStudy( OZ, 'OZ' )
61 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
62 geompy.addToStudy( Cylinder_2, 'Cylinder_2' )
63 geompy.addToStudy( Cut_1, 'Cut_1' )
64 geompy.addToStudy( Face_1, 'Face_1' )
65 geompy.addToStudy( Disque, 'Disque' )
66 geompy.addToStudyInFather( Disque, Compound_1, 'Compound_1' )
67 geompy.addToStudyInFather( Disque, Compound_2, 'Compound_2' )
68 geompy.addToStudyInFather( Disque, Compound_3, 'Compound_3' )
69 geompy.addToStudyInFather( Disque, Compound_4, 'Compound_4' )
70
71 ###
72 ### SMESH component
73 ###
74
75 import  SMESH, SALOMEDS
76 from salome.smesh import smeshBuilder
77
78 smesh = smeshBuilder.New()
79 from salome.StdMeshers import StdMeshersBuilder
80 Disque_1 = smesh.Mesh(Disque)
81 smesh.SetName(Disque_1, 'Disque')
82 Regular_1D = Disque_1.Segment()
83 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
84 Nb_Segments_1.SetDistrType( 0 )
85 Hexa_3D = Disque_1.Hexahedron(algo=smeshBuilder.Hexa)
86 Regular_1D_1 = Disque_1.Segment(geom=Compound_3)
87 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20)
88 Nb_Segments_2.SetDistrType( 0 )
89 Regular_1D_2 = Disque_1.Segment(geom=Compound_4)
90 status = Disque_1.AddHypothesis(Nb_Segments_2,Compound_4)
91 Quadrangle_2D = Disque_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
92
93 is_done = Disque_1.Compute()
94 text = "Disque_1.Compute"
95 if is_done:
96   logging.info(text+" OK")
97 else:
98   text = "Erreur au calcul du maillage.\n" + text
99   logging.info(text)
100   raise Exception(text)
101
102 Disque_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "disque.med"))
103 SubMesh_1 = Regular_1D_1.GetSubMesh()
104 SubMesh_2 = Regular_1D_2.GetSubMesh()
105
106 ## set object names
107 smesh.SetName(Disque_1.GetMesh(), 'Disque')
108 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
109 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
110 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
111 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
112 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
113 smesh.SetName(SubMesh_1, 'SubMesh_1')
114 smesh.SetName(SubMesh_2, 'SubMesh_2')
115
116 if salome.sg.hasDesktop():
117   salome.sg.updateObjBrowser()