1 # Copyright (C) 2014-2022 EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # This is an automation of the cylinder-box object, defined with the coordinates of its center, its radius, and the box's
24 # The pitch ratio is calculated automatically from the minimum of the box dimensions on x and y.
25 # This functions can take a groups input containing the group names of 4 sides in addition to the internal circular boundary
26 # in the following order : [South,North,West,East,Internal].
28 import sys, math, subprocess
29 CWD = subprocess.getoutput('pwd')
33 from MacObject import *
34 import Config, GenFunctions
36 def Cylinder (X0 , Y0 , D , DX , DY , LocalMeshing , **args) :
37 if args.__contains__('DLocal') : DLocal = float(args['DLocal'])
38 else : DLocal = float(min(DX,DY))
40 # K is the pitch ratio
41 K = float(D)/(DLocal-D)
42 print("A local pitch ratio of K =", K ," will be used. ")
43 NumCuts = 2*GenFunctions.QuarCylParam(K)
44 InternalMeshing = int(math.ceil(math.pi*D/(4*NumCuts*LocalMeshing)))
45 if InternalMeshing == 0 : InternalMeshing = 1 # This sets a minimum meshing condition in order to avoid an error. The user is notified of the value considered for the local meshing
46 print("Possible Local meshing is :", math.pi*D/(4*NumCuts*InternalMeshing), "\nThis value is returned by this function for your convenience.\n")
47 if args.__contains__('groups') :
48 GroupNames = args['groups']
49 else : GroupNames = [None, None, None, None, None]
53 GN1 = [None,GroupNames[1],None,GroupNames[3],GroupNames[4]]
54 GN2 = [None,GroupNames[1],GroupNames[2],None,GroupNames[4]]
55 GN3 = [GroupNames[0],None,GroupNames[2],None,GroupNames[4]]
56 GN4 = [GroupNames[0],None,None,GroupNames[3],GroupNames[4]]
58 GN1 = [None,GroupNames[1],None,None,GroupNames[4]]
59 GN2 = [None,GroupNames[1],None,None,GroupNames[4]]
60 GN3 = [GroupNames[0],None,None,None,GroupNames[4]]
61 GN4 = [GroupNames[0],None,None,None,GroupNames[4]]
63 GN5 = [GroupNames[0],GroupNames[1],None,GroupNames[3]]
64 GN6 = [GroupNames[0],GroupNames[1],GroupNames[2],None]
67 GN1 = [None,None,None,GroupNames[3],GroupNames[4]]
68 GN2 = [None,None,GroupNames[2],None,GroupNames[4]]
69 GN3 = [None,None,GroupNames[2],None,GroupNames[4]]
70 GN4 = [None,None,None,GroupNames[3],GroupNames[4]]
71 GN7 = [GroupNames[0],None,GroupNames[2],GroupNames[3]]
72 GN8 = [None,GroupNames[1],GroupNames[2],GroupNames[3]]
74 GN1 = [None,None,None,None,GroupNames[4]]
75 GN2 = [None,None,None,None,GroupNames[4]]
76 GN3 = [None,None,None,None,GroupNames[4]]
77 GN4 = [None,None,None,None,GroupNames[4]]
79 GN5 = [None,None,None,GroupNames[3]]
80 GN6 = [None,None,GroupNames[2],None]
82 GN9 = [GroupNames[0],None,None,GroupNames[3]]
83 GN10 = [GroupNames[0],None,None,None]
84 GN11 = [GroupNames[0],None,GroupNames[2],None]
86 GN12 = [None,GroupNames[1],None,GroupNames[3]]
87 GN13 = [None,GroupNames[1],None,None]
88 GN14 = [None,GroupNames[1],GroupNames[2],None]
92 Obj.append(MacObject('QuartCyl',[(X0+DLocal/4.,Y0+DLocal/4.),(DLocal/2.,DLocal/2.)],[InternalMeshing,'NE',K], groups = GN1))
93 Obj.append(MacObject('QuartCyl',[(X0-DLocal/4.,Y0+DLocal/4.),(DLocal/2.,DLocal/2.)],['auto','NW',K], groups = GN2))
94 Obj.append(MacObject('QuartCyl',[(X0-DLocal/4.,Y0-DLocal/4.),(DLocal/2.,DLocal/2.)],['auto','SW',K], groups = GN3))
95 Obj.append(MacObject('QuartCyl',[(X0+DLocal/4.,Y0-DLocal/4.),(DLocal/2.,DLocal/2.)],['auto','SE',K], groups = GN4))
99 Obj.append(MacObject('CompBoxF',[(X0+DLocal/2.+dX/2.,Y0),(dX,DLocal)],['auto'], groups = GN5))
100 Obj.append(MacObject('CompBoxF',[(X0-DLocal/2.-dX/2.,Y0),(dX,DLocal)],['auto'], groups = GN6))
103 dY = (DY - DLocal)/2.
105 Obj.append(MacObject('CompBoxF',[(X0+DLocal/2.+dX/2.,Y0-DLocal/2.-dY/2.),(dX,dY)],['auto'], groups = GN9))
106 Obj.append(MacObject('CompBoxF',[(X0,Y0-DLocal/2.-dY/2.),(DLocal,dY)],['auto'], groups = GN10))
107 Obj.append(MacObject('CompBoxF',[(X0-DLocal/2.-dX/2.,Y0-DLocal/2.-dY/2.),(dX,dY)],['auto'], groups = GN11))
108 Obj.append(MacObject('CompBoxF',[(X0+DLocal/2.+dX/2.,Y0+DLocal/2.+dY/2.),(dX,dY)],['auto'], groups = GN12))
109 Obj.append(MacObject('CompBoxF',[(X0,Y0+DLocal/2.+dY/2.),(DLocal,dY)],['auto'], groups = GN13))
110 Obj.append(MacObject('CompBoxF',[(X0-DLocal/2.-dX/2.,Y0+DLocal/2.+dY/2.),(dX,dY)],['auto'], groups = GN14))
112 Obj.append(MacObject('CompBoxF',[(X0,Y0-DLocal/2.-dY/2.),(DLocal,dY)],['auto'], groups = GN7))
113 Obj.append(MacObject('CompBoxF',[(X0,Y0+DLocal/2.+dY/2.),(DLocal,dY)],['auto'], groups = GN8))