diff --git a/cgnsutilities/cgnsutilities.py b/cgnsutilities/cgnsutilities.py index 85c1b8f..d6c79d6 100755 --- a/cgnsutilities/cgnsutilities.py +++ b/cgnsutilities/cgnsutilities.py @@ -101,31 +101,19 @@ def getWallCellsNodes(self): if boco.type in wallBCs: ptRange = boco.ptRange if ptRange[0, 0] == ptRange[0, 1]: - boundaryCells += (ptRange[1, 1] - ptRange[1, 0]) * ( - ptRange[2, 1] - ptRange[2, 0] - ) + boundaryCells += (ptRange[1, 1] - ptRange[1, 0]) * (ptRange[2, 1] - ptRange[2, 0]) - boundaryNodes += (ptRange[1, 1] - ptRange[1, 0] + 1) * ( - ptRange[2, 1] - ptRange[2, 0] + 1 - ) + boundaryNodes += (ptRange[1, 1] - ptRange[1, 0] + 1) * (ptRange[2, 1] - ptRange[2, 0] + 1) elif ptRange[1, 0] == ptRange[1, 1]: - boundaryCells += (ptRange[0, 1] - ptRange[0, 0]) * ( - ptRange[2, 1] - ptRange[2, 0] - ) + boundaryCells += (ptRange[0, 1] - ptRange[0, 0]) * (ptRange[2, 1] - ptRange[2, 0]) - boundaryNodes += (ptRange[0, 1] - ptRange[0, 0] + 1) * ( - ptRange[2, 1] - ptRange[2, 0] + 1 - ) + boundaryNodes += (ptRange[0, 1] - ptRange[0, 0] + 1) * (ptRange[2, 1] - ptRange[2, 0] + 1) elif ptRange[2, 0] == ptRange[2, 1]: - boundaryCells += (ptRange[0, 1] - ptRange[0, 0]) * ( - ptRange[1, 1] - ptRange[1, 0] - ) + boundaryCells += (ptRange[0, 1] - ptRange[0, 0]) * (ptRange[1, 1] - ptRange[1, 0]) - boundaryNodes += (ptRange[0, 1] - ptRange[0, 0] + 1) * ( - ptRange[1, 1] - ptRange[1, 0] + 1 - ) + boundaryNodes += (ptRange[0, 1] - ptRange[0, 0] + 1) * (ptRange[1, 1] - ptRange[1, 0] + 1) return boundaryCells, boundaryNodes @@ -277,17 +265,11 @@ def extractSurface(self, fileName): else: print("Warning: No wall surfaces found!") - def extractSpecifiedSurface( - self, fileName, blkid, imin, imax, jmin, jmax, kmin, kmax - ): + def extractSpecifiedSurface(self, fileName, blkid, imin, imax, jmin, jmax, kmin, kmax): """ Extract Specified surfaces and write to plot3d file""" patches = [] blk = self.blocks[int(blkid)] - patches.extend( - blk.extractSpecifiedSurfaces( - int(imin), int(imax), int(jmin), int(jmax), int(kmin), int(kmax) - ) - ) + patches.extend(blk.extractSpecifiedSurfaces(int(imin), int(imax), int(jmin), int(jmax), int(kmin), int(kmax))) if len(patches) > 0: f = open(fileName, "w") f.write("%d\n" % len(patches)) @@ -331,25 +313,14 @@ def writeSubfaceFamily(self, familyFile): # Locate the Boco we're replacing boco = None for i in range(len(self.blocks[blockID].bocos)): - r = ( - self.blocks[blockID].bocos[i].ptRange - ) # get the point range for existing boco + r = self.blocks[blockID].bocos[i].ptRange # get the point range for existing boco if ( (r[0][0] == r[0][1] == 1 and face == "ilow") - or ( - r[0][0] == r[0][1] == self.blocks[blockID].dims[0] - and face == "ihigh" - ) + or (r[0][0] == r[0][1] == self.blocks[blockID].dims[0] and face == "ihigh") or (r[1][0] == r[1][1] == 1 and face == "jlow") - or ( - r[1][0] == r[1][1] == self.blocks[blockID].dims[1] - and face == "jhigh" - ) + or (r[1][0] == r[1][1] == self.blocks[blockID].dims[1] and face == "jhigh") or (r[2][0] == r[2][1] == 1 and face == "klow") - or ( - r[2][0] == r[2][1] == self.blocks[blockID].dims[2] - and face == "khigh" - ) + or (r[2][0] == r[2][1] == self.blocks[blockID].dims[2] and face == "khigh") ): boco = i break @@ -420,9 +391,7 @@ def overwriteBCs(self, bcFile): dataArr = numpy.zeros(1, dtype=numpy.float64, order="F") dataArr[0] = float(aux[i + 1]) - bcDataArr = BocoDataSetArray( - arrayName, dType, nDims, dataDims, dataArr - ) + bcDataArr = BocoDataSetArray(arrayName, dType, nDims, dataDims, dataArr) if DirNeu == "Dirichlet": bcDSet.addDirichletDataSet(bcDataArr) elif DirNeu == "Neumann": @@ -486,9 +455,7 @@ def autoOversetBC(self, sym, connectSelf, tol): famName = "overset" # Now simply add the boco - self.blocks[blockID].addBoco( - Boco("dummy", bocoType, pointRanges[:, :, i], famName) - ) + self.blocks[blockID].addBoco(Boco("dummy", bocoType, pointRanges[:, :, i], famName)) # Lastly rename the BCs to be consistent self.renameBCs() @@ -531,9 +498,7 @@ def autoNearfieldBC(self, sym): famName = "overset" # Now simply add the boco - self.blocks[blockID].addBoco( - Boco("dummy", bocoType, pointRanges[:, :, i], famName) - ) + self.blocks[blockID].addBoco(Boco("dummy", bocoType, pointRanges[:, :, i], famName)) # Lastly rename the BCs to be consistent self.renameBCs() @@ -576,9 +541,7 @@ def autoFarfieldBC(self, sym): famName = "far" # Now simply add the boco - self.blocks[blockID].addBoco( - Boco("dummy", bocoType, pointRanges[:, :, i], famName) - ) + self.blocks[blockID].addBoco(Boco("dummy", bocoType, pointRanges[:, :, i], famName)) # Lastly rename the BCs to be consistent self.renameBCs() @@ -711,9 +674,7 @@ def cartesian(self, cartFile, outFile): # Initialize bounding box coordinates using the first point of the first zone xBounds = numpy.zeros((2, 3), order="F") - xBounds[0, 0] = self.blocks[0].coords[ - 0, 0, 0, 0 - ] # Using the first point for initialization + xBounds[0, 0] = self.blocks[0].coords[0, 0, 0, 0] # Using the first point for initialization xBounds[1, 0] = self.blocks[0].coords[0, 0, 0, 0] # because I can't use 0 xBounds[0, 1] = self.blocks[0].coords[0, 0, 0, 1] xBounds[1, 1] = self.blocks[0].coords[0, 0, 0, 1] @@ -722,9 +683,7 @@ def cartesian(self, cartFile, outFile): binVolX = numpy.zeros(numBins[0], order="F") # Assign zeroes to all bins binVolY = numpy.zeros(numBins[1], order="F") binVolZ = numpy.zeros(numBins[2], order="F") - binCellsX = numpy.zeros( - numBins[0], order="F", dtype=int - ) # Initialize cells counter for each bin + binCellsX = numpy.zeros(numBins[0], order="F", dtype=int) # Initialize cells counter for each bin binCellsY = numpy.zeros(numBins[1], order="F", dtype=int) binCellsZ = numpy.zeros(numBins[2], order="F", dtype=int) @@ -743,9 +702,7 @@ def cartesian(self, cartFile, outFile): jmax = r[1][1] kmin = r[2][0] - 1 kmax = r[2][1] - elif ( - r[0][0] == r[0][1] == self.blocks[index].dims[0] - ): # ihigh detected + elif r[0][0] == r[0][1] == self.blocks[index].dims[0]: # ihigh detected imin = max(self.blocks[index].dims[0] - inLayer, 0) imax = self.blocks[index].dims[0] jmin = r[1][0] - 1 @@ -759,9 +716,7 @@ def cartesian(self, cartFile, outFile): jmax = min(0 + inLayer, self.blocks[index].dims[1]) kmin = r[2][0] - 1 kmax = r[2][1] - elif ( - r[1][0] == r[1][1] == self.blocks[index].dims[1] - ): # jhigh detected + elif r[1][0] == r[1][1] == self.blocks[index].dims[1]: # jhigh detected imin = r[0][0] - 1 imax = r[0][1] jmin = max(self.blocks[index].dims[1] - inLayer, 0) @@ -775,9 +730,7 @@ def cartesian(self, cartFile, outFile): jmax = r[1][1] kmin = 0 kmax = min(0 + inLayer, self.blocks[index].dims[2]) - elif ( - r[2][0] == r[2][1] == self.blocks[index].dims[2] - ): # khigh detected + elif r[2][0] == r[2][1] == self.blocks[index].dims[2]: # khigh detected imin = r[0][0] - 1 imax = r[0][1] jmin = r[1][0] - 1 @@ -805,9 +758,7 @@ def cartesian(self, cartFile, outFile): jmax = r[1][1] kmin = r[2][0] - 1 kmax = r[2][1] - elif ( - r[0][0] == r[0][1] == self.blocks[index].dims[0] - ): # ihigh detected + elif r[0][0] == r[0][1] == self.blocks[index].dims[0]: # ihigh detected imin = max(self.blocks[index].dims[0] - inLayer, 0) imax = self.blocks[index].dims[0] jmin = r[1][0] - 1 @@ -821,9 +772,7 @@ def cartesian(self, cartFile, outFile): jmax = min(0 + inLayer, self.blocks[index].dims[1]) kmin = r[2][0] - 1 kmax = r[2][1] - elif ( - r[1][0] == r[1][1] == self.blocks[index].dims[1] - ): # jhigh detected + elif r[1][0] == r[1][1] == self.blocks[index].dims[1]: # jhigh detected imin = r[0][0] - 1 imax = r[0][1] jmin = max(self.blocks[index].dims[1] - inLayer, 0) @@ -837,9 +786,7 @@ def cartesian(self, cartFile, outFile): jmax = r[1][1] kmin = 0 kmax = min(0 + inLayer, self.blocks[index].dims[2]) - elif ( - r[2][0] == r[2][1] == self.blocks[index].dims[2] - ): # khigh detected + elif r[2][0] == r[2][1] == self.blocks[index].dims[2]: # khigh detected imin = r[0][0] - 1 imax = r[0][1] jmin = r[1][0] - 1 @@ -996,16 +943,11 @@ def func(P): x0bin = xmin + dxBin * binIndex xfbin = xmin + dxBin * (binIndex + 1) # Find cells that touch this interval and get their edges - bol = -( - ((S[:-1] < x0bin) * (S[1:] < x0bin)) - + ((S[:-1] > xfbin) * (S[1:] > xfbin)) - ) + bol = -(((S[:-1] < x0bin) * (S[1:] < x0bin)) + ((S[:-1] > xfbin) * (S[1:] > xfbin))) bolEdges = E[bol] # print bol # Compute edge mismatch and increment variable - edgeError = ( - edgeError + mean((bolEdges - binEdge[binIndex]) ** 2) / 2 - ) + edgeError = edgeError + mean((bolEdges - binEdge[binIndex]) ** 2) / 2 # Compute term regarding growing ratios at the ends if nNodes > 3: @@ -1016,9 +958,7 @@ def func(P): growthRatio = 0 # Return objective function - return (1 - weightGR) * edgeError / mean( - binEdge - ) + weightGR * growthRatio + return (1 - weightGR) * edgeError / mean(binEdge) + weightGR * growthRatio # Note that the edgeError is normalized so that the weighed average makes sense # Define initial guess based on uniform spacing @@ -1076,21 +1016,15 @@ def func(P): # Compute growth ratios if nNodes[0] > 3: - gx = max( - (Sx[1] - Sx[0]) / (Sx[2] - Sx[1]), (Sx[-1] - Sx[-2]) / (Sx[-2] - Sx[-3]) - ) + gx = max((Sx[1] - Sx[0]) / (Sx[2] - Sx[1]), (Sx[-1] - Sx[-2]) / (Sx[-2] - Sx[-3])) else: gx = None if nNodes[1] > 3: - gy = max( - (Sy[1] - Sy[0]) / (Sy[2] - Sy[1]), (Sy[-1] - Sy[-2]) / (Sy[-2] - Sy[-3]) - ) + gy = max((Sy[1] - Sy[0]) / (Sy[2] - Sy[1]), (Sy[-1] - Sy[-2]) / (Sy[-2] - Sy[-3])) else: gy = None if nNodes[2] > 3: - gz = max( - (Sz[1] - Sz[0]) / (Sz[2] - Sz[1]), (Sz[-1] - Sz[-2]) / (Sz[-2] - Sz[-3]) - ) + gz = max((Sz[1] - Sz[0]) / (Sz[2] - Sz[1]), (Sz[-1] - Sz[-2]) / (Sz[-2] - Sz[-3])) else: gz = None @@ -1372,9 +1306,7 @@ def autoBC(self, radius, sym, offset): famName = "far" # Now simply add the boco - self.blocks[blockID].addBoco( - Boco("dummy", bocoType, pointRanges[:, :, i], famName) - ) + self.blocks[blockID].addBoco(Boco("dummy", bocoType, pointRanges[:, :, i], famName)) # Lastly rename the BCs to be consistent self.renameBCs() @@ -1408,9 +1340,7 @@ def fillOpenBCs(self, bocoType, famName): # Add new BC if necessary if not has_bc: - self.blocks[blockID].addBoco( - Boco("dummy", bocoType, pointRanges[:, :, i], famName) - ) + self.blocks[blockID].addBoco(Boco("dummy", bocoType, pointRanges[:, :, i], famName)) # Lastly rename the BCs to be consistent self.renameBCs() @@ -1631,14 +1561,10 @@ def writeToCGNS(self, cg): zoneID = libcgns_utils.utils.writezone(cg, self.name, self.dims) libcgns_utils.utils.writecoordinates(cg, zoneID, self.coords) for boco in self.bocos: - iBC = libcgns_utils.utils.writebc( - cg, zoneID, boco.name, boco.family, boco.ptRange, boco.type - ) + iBC = libcgns_utils.utils.writebc(cg, zoneID, boco.name, boco.family, boco.ptRange, boco.type) for dataSet in boco.dataSets: # Write the header for the BCDataSet - iDataSet = libcgns_utils.utils.writebcdataheader( - cg, zoneID, dataSet.type, iBC, dataSet.name - ) + iDataSet = libcgns_utils.utils.writebcdataheader(cg, zoneID, dataSet.type, iBC, dataSet.name) # Loop over all Dirichlet and Neumann sets writeBCDataHeader = True @@ -1695,9 +1621,7 @@ def writeDimsPlot3d(self, f): def writeCoordsPlot3d(self, f): """Write coordinates to plot3d file""" for iDim in range(3): - self.coords[:, :, :, iDim].flatten("F").tofile( - f, sep="\n", format="%20.15g" - ) + self.coords[:, :, :, iDim].flatten("F").tofile(f, sep="\n", format="%20.15g") f.write("\n") def scale(self, scaleFact): @@ -1727,10 +1651,7 @@ def flip(self, axis): if boco.ptRange[0, 0] == boco.ptRange[0, 1] and boco.ptRange[0, 0] == 1: boco.ptRange[0, 0] = self.dims[0] boco.ptRange[0, 1] = self.dims[0] - elif ( - boco.ptRange[0, 0] == boco.ptRange[0, 1] - and boco.ptRange[0, 0] == self.dims[0] - ): + elif boco.ptRange[0, 0] == boco.ptRange[0, 1] and boco.ptRange[0, 0] == self.dims[0]: boco.ptRange[0, 0] = 1 boco.ptRange[0, 1] = 1 @@ -1772,9 +1693,7 @@ def refine(self, axes): """Refine the block uniformly. We will also update the boundary conditions and B2Bs if necessary""" axes = "".join(axes) - self.coords = libcgns_utils.utils.refine( - self.coords, "i" in axes, "j" in axes, "k" in axes - ) + self.coords = libcgns_utils.utils.refine(self.coords, "i" in axes, "j" in axes, "k" in axes) self.dims[0] = self.coords.shape[0] self.dims[1] = self.coords.shape[1] self.dims[2] = self.coords.shape[2] @@ -1787,9 +1706,7 @@ def refine(self, axes): def section(self, iStart, iEnd, jStart, jEnd, kStart, kEnd): self.bocos = [] self.B2Bs = [] - self.coords = self.coords[ - iStart - 1 : iEnd, jStart - 1 : jEnd, kStart - 1 : kEnd, : - ] + self.coords = self.coords[iStart - 1 : iEnd, jStart - 1 : jEnd, kStart - 1 : kEnd, :] self.dims[0] = self.coords.shape[0] self.dims[1] = self.coords.shape[1] self.dims[2] = self.coords.shape[2] @@ -1802,34 +1719,26 @@ def double2D(self): # Increase the size of the 2D dimension new_dimensions = self.dims[:] new_dimensions[dim_index] = new_dimensions[dim_index] + 1 - newCoords = numpy.zeros( - (new_dimensions[0], new_dimensions[1], new_dimensions[2], 3) - ) + newCoords = numpy.zeros((new_dimensions[0], new_dimensions[1], new_dimensions[2], 3)) if dim_index == 0: for i in range(self.dims[1]): for j in range(self.dims[2]): newCoords[0, i, j, :] = self.coords[0, i, j, :] newCoords[2, i, j, :] = self.coords[1, i, j, :] - newCoords[1, i, j, :] = 0.5 * ( - newCoords[0, i, j, :] + newCoords[2, i, j, :] - ) + newCoords[1, i, j, :] = 0.5 * (newCoords[0, i, j, :] + newCoords[2, i, j, :]) elif dim_index == 1: for i in range(self.dims[0]): for j in range(self.dims[2]): newCoords[i, 0, j, :] = self.coords[i, 0, j, :] newCoords[i, 2, j, :] = self.coords[i, 1, j, :] - newCoords[i, 1, j, :] = 0.5 * ( - newCoords[i, 0, j, :] + newCoords[i, 2, j, :] - ) + newCoords[i, 1, j, :] = 0.5 * (newCoords[i, 0, j, :] + newCoords[i, 2, j, :]) elif dim_index == 2: for i in range(self.dims[0]): for j in range(self.dims[1]): newCoords[i, j, 0, :] = self.coords[i, j, 0, :] newCoords[i, j, 2, :] = self.coords[i, j, 1, :] - newCoords[i, j, 1, :] = 0.5 * ( - newCoords[i, j, 0, :] + newCoords[i, j, 2, :] - ) + newCoords[i, j, 1, :] = 0.5 * (newCoords[i, j, 0, :] + newCoords[i, j, 2, :]) for boco in self.bocos: for j in range(2): @@ -1866,11 +1775,7 @@ def _extrudeGetDataOrderAndDIms(self, directionNormal, nSteps): order = [0, 1, 2] newDims = [self.dims[0], self.dims[1], nSteps, 3] else: - print( - "ERROR direction normal <{0}> not supported...exit".format( - directionNormal - ) - ) + print("ERROR direction normal <{0}> not supported...exit".format(directionNormal)) exit() return order, numpy.array(newDims) @@ -2188,9 +2093,7 @@ def divide(self): def removeSymBCs(self): """Remove any sym BC's there may be""" - self.bocos = [ - boco for boco in self.bocos if not boco.type == BC["bcsymmetryplane"] - ] + self.bocos = [boco for boco in self.bocos if not boco.type == BC["bcsymmetryplane"]] def extractWallSurfaces(self): """Return patches for any surfaces that have BCViscous on them""" @@ -2211,15 +2114,9 @@ def extractWallSurfaces(self): # flip an index on any "high" boundary condition: if ( - ( - ptRange[0, 0] == ptRange[0, 1] - and ptRange[0, 0] + 1 == self.dims[0] - ) + (ptRange[0, 0] == ptRange[0, 1] and ptRange[0, 0] + 1 == self.dims[0]) or (ptRange[1, 0] == ptRange[1, 1] and ptRange[1, 0] + 1 == 1) - or ( - ptRange[2, 0] == ptRange[2, 1] - and ptRange[2, 0] + 1 == self.dims[2] - ) + or (ptRange[2, 0] == ptRange[2, 1] and ptRange[2, 0] + 1 == self.dims[2]) ): patches[-1] = patches[-1][::-1, :, :] @@ -2339,16 +2236,11 @@ def overwriteBCs(self, faceStr, bcType, family, dataSet): elif faceStr == "khigh": ptRange = [[1, 1, d[2]], [d[0], d[1], d[2]]] else: - print( - "ERROR: faceStr must be one of iLow, iHigh, jLow, jHigh, kLow or kHigh. Got %s" - % faceStr - ) + print("ERROR: faceStr must be one of iLow, iHigh, jLow, jHigh, kLow or kHigh. Got %s" % faceStr) exit() ptRange = numpy.array(ptRange).T - newBoco = Boco( - "boco_%d" % self.bocoCounter, BC[bcType.lower()], ptRange, family, dataSet - ) + newBoco = Boco("boco_%d" % self.bocoCounter, BC[bcType.lower()], ptRange, family, dataSet) self.bocoCounter += 1 self.bocos.append(newBoco) @@ -2420,9 +2312,7 @@ def randomize(self, keepRHS): newCoords = numpy.zeros((self.dims[1], self.dims[0], self.dims[2], 3)) for k in range(self.dims[2]): for idim in range(3): - newCoords[:, :, k, idim] = numpy.rot90( - self.coords[:, :, k, idim].copy() - ) + newCoords[:, :, k, idim] = numpy.rot90(self.coords[:, :, k, idim].copy()) self.dims = list(newCoords.shape[0:3]) self.coords = newCoords.copy() @@ -2543,13 +2433,9 @@ class BocoDataSetArray(object): def __init__(self, arrayName, dType, nDims, dataDims, dataArr): self.name = arrayName.strip() - self.dataType = ( - dType # This is the CGNS datatype that was read from the CGNS file. - ) + self.dataType = dType # This is the CGNS datatype that was read from the CGNS file. self.nDimensions = nDims # Number of dimensions that the data has - self.dataDimensions = ( - dataDims # Number of data points of every dimensions. Array of ints - ) + self.dataDimensions = dataDims # Number of data points of every dimensions. Array of ints self.dataArr = dataArr # Note that this is a flat 1D numpy array and is float64 @@ -2603,9 +2489,7 @@ def refine(self, axes): for i, axis in enumerate(["i", "j", "k"]): for j in range(2): self.ptRange[i, j] = (self.ptRange[i, j] - 1) * 2 ** (axis in axes) + 1 - self.donorRange[i, j] = (self.donorRange[i, j] - 1) * 2 ** ( - axis in axes - ) + 1 + self.donorRange[i, j] = (self.donorRange[i, j] - 1) * 2 ** (axis in axes) + 1 # ---------------------------------------- @@ -2731,10 +2615,7 @@ def inRange(ptRange, chkRange): """Determine if 'chkRange' fully overlaps with 'ptRange'""" val = True for iDim in range(3): - if not ( - chkRange[iDim][0] >= ptRange[iDim][0] - and chkRange[iDim][1] <= ptRange[iDim][1] - ): + if not (chkRange[iDim][0] >= ptRange[iDim][0] and chkRange[iDim][1] <= ptRange[iDim][1]): val = False return val @@ -2844,15 +2725,11 @@ def simpleCart(xMin, xMax, dh, hExtra, nExtra, sym, mgcycle, outFile): # Add neg part if necessary: if neg: for i in range(nExtra): - x[iStart - 1 - i] = x[iStart - i] - r[iDim] * ( - x[iStart - i + 1] - x[iStart - i] - ) + x[iStart - 1 - i] = x[iStart - i] - r[iDim] * (x[iStart - i + 1] - x[iStart - i]) if pos: iStart = iStart + N[iDim] for i in range(nExtra): - x[iStart + i + 1] = x[iStart + i] + r[iDim] * ( - x[iStart + i] - x[iStart + i - 1] - ) + x[iStart + i + 1] = x[iStart + i] + r[iDim] * (x[iStart + i] - x[iStart + i - 1]) Xcart.append(x) @@ -2921,9 +2798,7 @@ def readGrid(fileName): if cellDim == 2: dims[2] = 1 - coords = libcgns_utils.utils.getcoordinates( - inFile, iBlock, dims[0], dims[1], dims[2] - ) + coords = libcgns_utils.utils.getcoordinates(inFile, iBlock, dims[0], dims[1], dims[2]) blk = Block(zoneName, dims, coords) for iBoco in range(1, nBoco + 1): @@ -2947,9 +2822,7 @@ def readGrid(fileName): bocoDataSetType, nDirichletArrays, nNeumannArrays, - ) = libcgns_utils.utils.getbcdatasetinfo( - inFile, iBlock, iBoco, iBocoDataSet - ) + ) = libcgns_utils.utils.getbcdatasetinfo(inFile, iBlock, iBoco, iBocoDataSet) bcDSet = BocoDataSet(bocoDatasetName, bocoType) def getBocoDataSetArray(flagDirNeu): @@ -3033,9 +2906,7 @@ def getBocoDataSetArray(flagDirNeu): if nIterations > 0: for arrayID in range(nArrays): # Read array - arrayName, arrayData = libcgns_utils.utils.getconvarray( - inFile, nIterations, arrayID + 1 - ) + arrayName, arrayData = libcgns_utils.utils.getconvarray(inFile, nIterations, arrayID + 1) # Remove blank spaces arrayName = arrayName.strip() @@ -3218,9 +3089,7 @@ def faceID(ptRange, blk): face = faceID(b2b.ptRange, blk) dims = blk.dims.copy() - dims[abs(face) - 1] += ( - otherBlk.dims[abs(transform[abs(face) - 1]) - 1] - 1 - ) + dims[abs(face) - 1] += otherBlk.dims[abs(transform[abs(face) - 1]) - 1] - 1 newCoords = numpy.zeros((dims[0], dims[1], dims[2], 3)) # Now transform the other coordinates to make @@ -3279,21 +3148,15 @@ def faceID(ptRange, blk): else: # otherBlk then blk if face == -1: - newCoords[ - 0 : dims[0] - blk.dims[0] + 1, :, :, : - ] = otherCoords + newCoords[0 : dims[0] - blk.dims[0] + 1, :, :, :] = otherCoords newCoords[dims[0] - blk.dims[0] :, :, :] = blk.coords elif face == -2: - newCoords[ - :, 0 : dims[1] - blk.dims[1] + 1, :, : - ] = otherCoords + newCoords[:, 0 : dims[1] - blk.dims[1] + 1, :, :] = otherCoords newCoords[:, dims[1] - blk.dims[1] :, :, :] = blk.coords elif face == -3: - newCoords[ - :, :, 0 : dims[2] - blk.dims[2] + 1, : - ] = otherCoords + newCoords[:, :, 0 : dims[2] - blk.dims[2] + 1, :] = otherCoords newCoords[:, :, dims[2] - blk.dims[2] :, :] = blk.coords # Create the new block @@ -3341,26 +3204,16 @@ def faceID(ptRange, blk): if jdim > 0: # Other block dim +ve, (ie in the same direction) - boco.ptRange[idim, 0] = ( - offset[idim] + tmp[jdim - 1, 0] - ) - boco.ptRange[idim, 1] = ( - offset[idim] + tmp[jdim - 1, 1] - ) + boco.ptRange[idim, 0] = offset[idim] + tmp[jdim - 1, 0] + boco.ptRange[idim, 1] = offset[idim] + tmp[jdim - 1, 1] else: # Other block dim -ve, (ie in the opposite direction) jdim = -jdim boco.ptRange[idim, 0] = ( - offset[idim] - + otherBlk.dims[jdim - 1] - - tmp[jdim - 1, 1] - + 1 + offset[idim] + otherBlk.dims[jdim - 1] - tmp[jdim - 1, 1] + 1 ) boco.ptRange[idim, 1] = ( - offset[idim] - + otherBlk.dims[jdim - 1] - - tmp[jdim - 1, 0] - + 1 + offset[idim] + otherBlk.dims[jdim - 1] - tmp[jdim - 1, 0] + 1 ) else: @@ -3375,16 +3228,8 @@ def faceID(ptRange, blk): else: # Other block dim -ve, (ie in the opposite direction) jdim = -jdim - boco.ptRange[idim, 0] = ( - otherBlk.dims[jdim - 1] - - tmp[jdim - 1, 1] - + 1 - ) - boco.ptRange[idim, 1] = ( - otherBlk.dims[jdim - 1] - - tmp[jdim - 1, 0] - + 1 - ) + boco.ptRange[idim, 0] = otherBlk.dims[jdim - 1] - tmp[jdim - 1, 1] + 1 + boco.ptRange[idim, 1] = otherBlk.dims[jdim - 1] - tmp[jdim - 1, 0] + 1 newBlk.addBoco(boco) @@ -3579,25 +3424,19 @@ def write_tecplot_file(filename, title, variable_names, data_points): fid.write("title = " + title + "\n") # Write tha variable names - varnames_commas = ",".join( - variable_names - ) # Merge names in a single string separated by commas + varnames_commas = ",".join(variable_names) # Merge names in a single string separated by commas fid.write("variables = " + varnames_commas + ",\n") # Write to the file # Write data points if type(data_points) is list: # Check if user provided a list for point in data_points: str_points = [str(x) for x in point] # Covert each entry to string - str_points = " ".join( - str_points - ) # Merge all entries in a single string separated by whitespace + str_points = " ".join(str_points) # Merge all entries in a single string separated by whitespace fid.write(str_points + "\n") # Write to file else: # The user probably provided a numpy array for index in range(data_points.shape[0]): str_points = [str(x) for x in data_points[index, :]] - str_points = " ".join( - str_points - ) # Merge all entries in a single string separated by whitespace + str_points = " ".join(str_points) # Merge all entries in a single string separated by whitespace fid.write(str_points + "\n") # Write to file # Close file