-def CompositeBoxF (Pt1 , Pt2 , Pt3 , Pt4 , **args ) :
- [Pt1 , Pt2 , Pt3 , Pt4] = GenFunctions.SortPoints([Pt1 , Pt2 , Pt3 , Pt4])
- if args.__contains__('groups') :
- GroupNames = args['groups']
- else : GroupNames = [None, None, None, None]
- # Create a full NonOrtho box just to inherit, globally, the mesh parameters of bounding objects
- dummy = MacObject('NonOrtho',[Pt1,Pt2,Pt3,Pt4],['auto'],publish=0)
- # Save the existing number of segments on each direction
- ExistingSeg0 = Config.ListObj[-1].DirectionalMeshParams
- Convention = [2,3,0,1]
- ExistingSegments = [ExistingSeg0[Convention[i]] for i in range(4)]
- # Save Boundary lengths on each direction
- BoundaryLengths = [IntLen(dummy.DirBoundaries(i)) for i in range(4) ]
- # Calculate global mesh element size on each direction
- GlobalDelta = [1.*BoundaryLengths[i]/ExistingSegments[i] for i in range(4) ]
- print "GlobalDelta :",GlobalDelta
- # Sort the connection list for the full Box
- [(X0,Y0),(DX,DY)] = dummy.GeoPar
- ObjIDLists = SortObjLists(Config.Connections[-1],X0 , Y0 , DX , DY )
- [Xmin,Xmax,Ymin,Ymax] = dummy.Boundaries() # Used for groups determination
- RemoveLastObj()
-
- RealSegments = []
- Direction = []
- flag = 0
- if not(args.__contains__('recursive')) :
- Config.Count = 0
-
- Config.Criterion = GetCriterion(ObjIDLists)
- for index, ObjList in enumerate(ObjIDLists) :
- if not (ObjList[0] == -1 or Config.Count >= Config.Criterion):
- if not(args.__contains__('recursive')) :
- Config.DirIndex = index
- if index > 1 : Config.RefPts = [Pt2, Pt3]
- elif index == 0 : Config.RefPts = [Pt1, Pt2]
- else : Config.RefPts = [Pt4, Pt3]
-
- if len(ObjList)>1 : flag = 1
- else : flag = 0
- for ObjID in ObjList:
- ToLook0 = [2,3,0,1][index]
- ToLook1 = [3,2,1,0][index]
- CommonSide = FindCommonSide(Config.ListObj[ObjID].DirBoundaries(ToLook1),dummy.DirBoundaries(ToLook0))
- ToLook2 = [1,0,3,2][index]
- RealSegments = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]*IntLen(CommonSide)/IntLen(Config.ListObj[ObjID].DirBoundaries(ToLook1))
- LocalDelta = 1.*IntLen(CommonSide)/RealSegments
- print "Direction:", ["West","East","South","North"][ToLook2]
- print "IntLen(CommonSide):",IntLen(CommonSide)
- print "RealSegments:",RealSegments
- print "LocalDelta:",LocalDelta
- if flag and Config.Count < Config.Criterion:
- if index ==0 :
- if abs(CommonSide[0] - Ymin)<1e-7 : SouthGR = GroupNames[0]
- else : SouthGR = None
- if abs(CommonSide[1] - Ymax)<1e-7 : NorthGR = GroupNames[1]
- else : NorthGR = None
-
- NDelta = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]* (LocalDelta-GlobalDelta[Convention[index]])
- [Pt1,Pt2] = Config.RefPts
- Coef = [1.,-1.][index]
- Vref1 = [Coef*(Pt2[0]-Pt1[0]),Coef*(Pt2[1]-Pt1[1])]
- Vref2 = NormalizeVector([Pt2[0]-Pt3[0],Pt2[1]-Pt3[1]])
- Ptref = Config.ListObj[ObjID].PtCoor[[2,3][index]]
- NewPt = ExtrapPoint (Ptref,Vref1,Vref2,NDelta)
- CompositeBoxF (Pt1, Pt2, NewPt, Ptref, recursive=1, groups = [SouthGR,NorthGR]+GroupNames[2:4])
- elif index == 1:
- if abs(CommonSide[0] - Ymin)<1e-7 : SouthGR = GroupNames[0]
- else : SouthGR = None
- if abs(CommonSide[1] - Ymax)<1e-7 : NorthGR = GroupNames[1]
- else : NorthGR = None
-
- NDelta = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]* (LocalDelta-GlobalDelta[Convention[index]])
- [Pt4,Pt3] = Config.RefPts
- Coef = 1.
- Vref1 = [Coef*(Pt4[0]-Pt3[0]),Coef*(Pt4[1]-Pt3[1])]
- Vref2 = NormalizeVector([Pt1[0]-Pt4[0],Pt1[1]-Pt4[1]])
- Ptref = Config.ListObj[ObjID].PtCoor[0]
- NewPt = ExtrapPoint (Ptref,Vref1,Vref2,NDelta)
- CompositeBoxF (NewPt, Ptref, Pt3, Pt4, recursive=1, groups = [SouthGR,NorthGR]+GroupNames[2:4])
- else :
- if abs(CommonSide[0] - Xmin)<1e-7 : WestGR = GroupNames[2]
- else : WestGR = None
- if abs(CommonSide[1] - Xmax)<1e-7 : EastGR = GroupNames[3]
- else : EastGR = None
-
- NDelta = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]* (LocalDelta-GlobalDelta[Convention[index]])
- [Pt2,Pt3] = Config.RefPts
- Coef = [1.,-1.][index-2]
- Vref1 = [Coef*(Pt3[0]-Pt2[0]),Coef*(Pt3[1]-Pt2[1])]
- Vref2 = NormalizeVector([Pt3[0]-Pt4[0],Pt3[1]-Pt4[1]])
- Ptref = Config.ListObj[ObjID].PtCoor[[3,0][index-2]]
- NewPt = ExtrapPoint (Ptref,Vref1,Vref2,NDelta)
- CompositeBoxF (Ptref, Pt2, Pt3, NewPt, recursive=1, groups = GroupNames[0:2] + [WestGR,EastGR])
-
- if Config.Count >= Config.Criterion :
- break
- if flag == 0 and Config.Count < Config.Criterion:
- print "Creating NonOrtho object with the points:", Pt1,Pt2,Pt3,Pt4
- MacObject('NonOrtho',[Pt1,Pt2,Pt3,Pt4] ,['auto'], groups = GroupNames)
-
- Config.Count += 1
- if Config.DirIndex > 1 : Config.RefPts = [Pt1, Pt4]
- elif Config.DirIndex==0 : Config.RefPts = [Pt4, Pt3]
- else : Config.RefPts = [Pt1, Pt2]
-
+def CompositeBoxF (Pt1 , Pt2 , Pt3 , Pt4 , **args ) :
+ [Pt1 , Pt2 , Pt3 , Pt4] = GenFunctions.SortPoints([Pt1 , Pt2 , Pt3 , Pt4])
+ if args.__contains__('groups') :
+ GroupNames = args['groups']
+ else : GroupNames = [None, None, None, None]
+ # Create a full NonOrtho box just to inherit, globally, the mesh parameters of bounding objects
+ dummy = MacObject('NonOrtho',[Pt1,Pt2,Pt3,Pt4],['auto'],publish=0)
+ # Save the existing number of segments on each direction
+ ExistingSeg0 = Config.ListObj[-1].DirectionalMeshParams
+ Convention = [2,3,0,1]
+ ExistingSegments = [ExistingSeg0[Convention[i]] for i in range(4)]
+ # Save Boundary lengths on each direction
+ BoundaryLengths = [IntLen(dummy.DirBoundaries(i)) for i in range(4) ]
+ # Calculate global mesh element size on each direction
+ GlobalDelta = [1.*BoundaryLengths[i]/ExistingSegments[i] for i in range(4) ]
+ print("GlobalDelta :",GlobalDelta)
+ # Sort the connection list for the full Box
+ [(X0,Y0),(DX,DY)] = dummy.GeoPar
+ ObjIDLists = SortObjLists(Config.Connections[-1],X0 , Y0 , DX , DY )
+ [Xmin,Xmax,Ymin,Ymax] = dummy.Boundaries() # Used for groups determination
+ RemoveLastObj()
+
+ RealSegments = []
+ Direction = []
+ flag = 0
+ if not(args.__contains__('recursive')) :
+ Config.Count = 0
+
+ Config.Criterion = GetCriterion(ObjIDLists)
+ for index, ObjList in enumerate(ObjIDLists) :
+ if not (ObjList[0] == -1 or Config.Count >= Config.Criterion):
+ if not(args.__contains__('recursive')) :
+ Config.DirIndex = index
+ if index > 1 : Config.RefPts = [Pt2, Pt3]
+ elif index == 0 : Config.RefPts = [Pt1, Pt2]
+ else : Config.RefPts = [Pt4, Pt3]
+
+ if len(ObjList)>1 : flag = 1
+ else : flag = 0
+ for ObjID in ObjList:
+ ToLook0 = [2,3,0,1][index]
+ ToLook1 = [3,2,1,0][index]
+ CommonSide = FindCommonSide(Config.ListObj[ObjID].DirBoundaries(ToLook1),dummy.DirBoundaries(ToLook0))
+ ToLook2 = [1,0,3,2][index]
+ RealSegments = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]*IntLen(CommonSide)/IntLen(Config.ListObj[ObjID].DirBoundaries(ToLook1))
+ LocalDelta = 1.*IntLen(CommonSide)/RealSegments
+ print("Direction:", ["West","East","South","North"][ToLook2])
+ print("IntLen(CommonSide):",IntLen(CommonSide))
+ print("RealSegments:",RealSegments)
+ print("LocalDelta:",LocalDelta)
+ if flag and Config.Count < Config.Criterion:
+ if index ==0 :
+ if abs(CommonSide[0] - Ymin)<1e-7 : SouthGR = GroupNames[0]
+ else : SouthGR = None
+ if abs(CommonSide[1] - Ymax)<1e-7 : NorthGR = GroupNames[1]
+ else : NorthGR = None
+
+ NDelta = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]* (LocalDelta-GlobalDelta[Convention[index]])
+ [Pt1,Pt2] = Config.RefPts
+ Coef = [1.,-1.][index]
+ Vref1 = [Coef*(Pt2[0]-Pt1[0]),Coef*(Pt2[1]-Pt1[1])]
+ Vref2 = NormalizeVector([Pt2[0]-Pt3[0],Pt2[1]-Pt3[1]])
+ Ptref = Config.ListObj[ObjID].PtCoor[[2,3][index]]
+ NewPt = ExtrapPoint (Ptref,Vref1,Vref2,NDelta)
+ CompositeBoxF (Pt1, Pt2, NewPt, Ptref, recursive=1, groups = [SouthGR,NorthGR]+GroupNames[2:4])
+ elif index == 1:
+ if abs(CommonSide[0] - Ymin)<1e-7 : SouthGR = GroupNames[0]
+ else : SouthGR = None
+ if abs(CommonSide[1] - Ymax)<1e-7 : NorthGR = GroupNames[1]
+ else : NorthGR = None
+
+ NDelta = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]* (LocalDelta-GlobalDelta[Convention[index]])
+ [Pt4,Pt3] = Config.RefPts
+ Coef = 1.
+ Vref1 = [Coef*(Pt4[0]-Pt3[0]),Coef*(Pt4[1]-Pt3[1])]
+ Vref2 = NormalizeVector([Pt1[0]-Pt4[0],Pt1[1]-Pt4[1]])
+ Ptref = Config.ListObj[ObjID].PtCoor[0]
+ NewPt = ExtrapPoint (Ptref,Vref1,Vref2,NDelta)
+ CompositeBoxF (NewPt, Ptref, Pt3, Pt4, recursive=1, groups = [SouthGR,NorthGR]+GroupNames[2:4])
+ else :
+ if abs(CommonSide[0] - Xmin)<1e-7 : WestGR = GroupNames[2]
+ else : WestGR = None
+ if abs(CommonSide[1] - Xmax)<1e-7 : EastGR = GroupNames[3]
+ else : EastGR = None
+
+ NDelta = Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]* (LocalDelta-GlobalDelta[Convention[index]])
+ [Pt2,Pt3] = Config.RefPts
+ Coef = [1.,-1.][index-2]
+ Vref1 = [Coef*(Pt3[0]-Pt2[0]),Coef*(Pt3[1]-Pt2[1])]
+ Vref2 = NormalizeVector([Pt3[0]-Pt4[0],Pt3[1]-Pt4[1]])
+ Ptref = Config.ListObj[ObjID].PtCoor[[3,0][index-2]]
+ NewPt = ExtrapPoint (Ptref,Vref1,Vref2,NDelta)
+ CompositeBoxF (Ptref, Pt2, Pt3, NewPt, recursive=1, groups = GroupNames[0:2] + [WestGR,EastGR])
+
+ if Config.Count >= Config.Criterion :
+ break
+ if flag == 0 and Config.Count < Config.Criterion:
+ print("Creating NonOrtho object with the points:", Pt1,Pt2,Pt3,Pt4)
+ MacObject('NonOrtho',[Pt1,Pt2,Pt3,Pt4] ,['auto'], groups = GroupNames)
+
+ Config.Count += 1
+ if Config.DirIndex > 1 : Config.RefPts = [Pt1, Pt4]
+ elif Config.DirIndex==0 : Config.RefPts = [Pt4, Pt3]
+ else : Config.RefPts = [Pt1, Pt2]
+