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