Salome HOME
Merge branch V7_3_1_BR
[modules/smesh.git] / src / Tools / MacMesh / Example / PressureValve.py.in
1 # Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 ##################################################################
23 # Header for salome initialization ###############################
24
25 import sys, salome, math, os
26 sys.path.append( os.path.join( os.getenv('SMESH_ROOT_DIR'), '@MACMESH_INSTALL_PY@'))
27
28 import Config, GenFunctions
29
30 Config.theStudy = salome.myStudy; 
31
32 from MacObject import *
33 from SharpAngle import *
34 from CentralUnrefine import *
35 from PublishGroups import *
36 from CompositeBox import *
37 from CompositeBoxF import *
38
39
40
41 ##################################################################
42 # Mesh name ######################################################
43
44 Config.StudyName = "SRV_X."
45
46 ##################################################################
47 # Definition of geometrical parameters ###########################
48
49 X = 1.0         # Valve initial opening
50
51 Config.StudyName += str(X)+"mm"
52
53 R = 7.5         # Upstream pipe radius
54 T = 5.0         # Upstream pipe thickness
55 H = 20.0        # Upstream pipe height
56 J = 6.0         # Jet distance
57 E = 60.0        # Exit extent
58
59 ##################################################################
60 # Definition of meshing parameters ###############################
61
62 d = 0.1         # Meshing element size at the inner corner
63 Nl = 1          # Number of levels in the local refinement
64 ##################################################################
65 Bloc = []
66
67 # Object No. 1 #
68 Bloc.append( SharpAngleOut(0.,0.,X,1.5*X,X,d,'NE',Nl,
69               groups=['PH','PV_IN','VH',None,None,None])  )
70
71 # Object No. 2 #
72 Bloc.append( CompositeBox(X/2.+0.5*(R-X/2.),0.5*(X+X/2.)-X/2.,R-X/2.,X+X/2.,
73               groups=[None,'VH',None,'AXIS']           )  )
74
75 # Object No. 3 #
76 Bloc.append( CompositeBoxF((0.,-X/2.),(R,-X/2.),(R,-H),(0.,-H),
77               groups=['IN',None,'PV_IN','AXIS']           )  )
78
79 # Object No. 4 #
80 Bloc.append( SharpAngleOut(-T,0.,X,X,X,d,'NW',Nl,
81               groups=['PH','PV_OUT',None,None,None,None])  )
82               
83 # Object No. 5 #
84 Bloc.append( SharpAngleOut(-T,X,X,X,X,d,'SW',Nl,
85               groups=['VH','VV',None,None,None,None])  )
86               
87 if X < T :
88         gap = T-X
89         Bloc.append( MacObject('CompBoxF',[(-X/2.-gap/2.,X/2.),(gap,X)],
90               ['auto'],groups=['PH','VH',None,None]    )  )
91               
92 # Object No. 6 #
93 Bloc.append( MacObject('CompBoxF',[(-T-X/2.-(J-X/2.)/2.,X/2.),(J-X/2.,2.*X)],
94               ['auto'],groups=[None,None,None,None]    )  )    
95
96 # Object No. 7 #
97 Bloc.append( CentralUnrefine(-T-J,X/2.,2.*E-J,E,'EW',
98               groups=[None,None,None,'OUT_V','OUT_H_HI','OUT_H_LO'])) 
99
100 # Object No. 8 #
101 Bloc.append( CompositeBox(-T-J/2.,-X/2.-0.5*((E-X)/2.-X/2.),J,(E-X)/2.-X/2.,
102               groups=['OUT_H_LO',None,None,'PV_OUT']   )  )
103                
104 # Object No. 9 #
105 Bloc.append( CompositeBox(-T-J/2.,X+X/2.+0.5*((E-X)/2.-X/2.),J,(E-X)/2.-X/2.,
106               groups=[None,'OUT_H_HI',None,'VV'] )  )
107                                                                                   
108 SRVMesh = PublishGroups()
109
110 RealLocalMeshing = Bloc[0][0].GeoPar[1][0]/Bloc[0][0].DirectionalMeshParams[0]
111 ExtrusionAngle = 2. * math.asin(RealLocalMeshing/(2*R))*180./math.pi
112 print "\nThe mesh will be revolved with an angle of :",ExtrusionAngle
113
114 RevolveMesh(SRVMesh, Center=[R+0.01,0,0], Direction=[0,1,0], AngleDeg=ExtrusionAngle, Scale=0.001)
115