Skip to content

Commit

Permalink
Minor syntax changes (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewu63 authored Apr 19, 2020
1 parent 4304ee1 commit f95b3ec
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 35 deletions.
5 changes: 2 additions & 3 deletions bin/cgns_utils
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ read cngs file -> Do some operations on it -> | .or.
Developed by Dr. Gaetan K. W. Kenway
"""
from __future__ import print_function, division
import sys
import os
import copy
Expand Down Expand Up @@ -797,7 +796,7 @@ elif args.mode == 'cartesian':
if found_overset:
curGrid.cartesian(args.cartFile,args.outFile)
else:
print ('The CGNS file has no overset boundary conditions')
print('The CGNS file has no overset boundary conditions')
sys.exit(0)

elif args.mode == 'simpleCart':
Expand Down Expand Up @@ -848,7 +847,7 @@ elif args.mode == 'include':

elif args.mode == 'section':
if len(curGrid.blocks) != 1:
print ('section command works only on grids with 1 block')
print('section command works only on grids with 1 block')
sys.exit(0)
curGrid.blocks[0].section(args.iStart, args.iEnd, args.jStart, args.jEnd,
args.kStart, args.kEnd)
Expand Down
54 changes: 27 additions & 27 deletions bin/cgns_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def printInfo(self):
totalCells += (blk.dims[0]-1)*(blk.dims[1]-1)*(blk.dims[2]-1)
totalNodes += blk.dims[0]*blk.dims[1]*blk.dims[2]

print ('Total Zones:', len(self.blocks))
print ('Total Cells:', totalCells)
print ('Total Nodes:', totalNodes)
print('Total Zones:', len(self.blocks))
print('Total Cells:', totalCells)
print('Total Nodes:', totalNodes)

boundaryNodes = 0
boundaryCells = 0
Expand Down Expand Up @@ -100,8 +100,8 @@ def printInfo(self):
(ptRange[1, 1] - ptRange[1, 0] +1)


print ('Wall Boundary Cells:', boundaryCells)
print ('Wall Boundary Nodes:', boundaryNodes)
print('Wall Boundary Cells:', boundaryCells)
print('Wall Boundary Nodes:', boundaryNodes)


def printBlockInfo(self):
Expand All @@ -114,16 +114,16 @@ def printBlockInfo(self):
for blk in self.blocks:
nCells = (blk.dims[0]-1)*(blk.dims[1]-1)*(blk.dims[2]-1)
nNodes = blk.dims[0]*blk.dims[1]*blk.dims[2]
print ('Block Number:', counter)
print ('Number of Cells:', nCells)
print ('Number of Nodes:', nNodes)
print('Block dimensions:', blk.dims)
print('Block Number:', counter)
print('Number of Cells:', nCells)
print('Number of Nodes:', nNodes)
print('Block dimensions:', list(blk.dims))
totalCells += nCells
totalNodes += nNodes
counter +=1
print ('Total Zones:', len(self.blocks))
print ('Total Cells:', totalCells)
print ('Total Nodes:', totalNodes)
print('Total Zones:', len(self.blocks))
print('Total Cells:', totalCells)
print('Total Nodes:', totalNodes)

def addBlock(self, blk):

Expand Down Expand Up @@ -235,7 +235,7 @@ def extractSurface(self, fileName):
f.write('\n')
f.close()
else:
print ('Warning: No wall surfaces found!')
print('Warning: No wall surfaces found!')

def extractSpecifiedSurface(self, fileName,blkid,imin,imax,jmin,jmax,kmin,kmax):
""" Extract Specified surfaces and write to plot3d file"""
Expand All @@ -258,7 +258,7 @@ def extractSpecifiedSurface(self, fileName,blkid,imin,imax,jmin,jmax,kmin,kmax):
f.write('\n')
f.close()
else:
print ('Warning: No surfaces found!')
print('Warning: No surfaces found!')

def overwriteFamilies(self, familyFile):
"""Overwrite families of BC with information given in the
Expand Down Expand Up @@ -621,7 +621,7 @@ def cartesian(self, cartFile, outFile):
inLayer = 2 # How many layers of the overset interpolation
# faces will be used for volume computation

print ('Running cartesian grid generator')
print('Running cartesian grid generator')

# Preallocate arrays
extensions = numpy.zeros((2,3),order='F')
Expand Down Expand Up @@ -951,14 +951,14 @@ def func(P):
gz = None

# Print growth ratios
print ('')
print ('Maximum growth ratios along each direction:')
print ('X: ',gx)
print ('Y: ',gy)
print ('Z: ',gz)
print('')
print('Maximum growth ratios along each direction:')
print('X: ',gx)
print('Y: ',gy)
print('Z: ',gz)
if max(gx,gy,gz) > 1.2:
print ("You may bring weightGR closer to 1 to decrease ratios")
print ('')
print("You may bring weightGR closer to 1 to decrease ratios")
print('')

# Allocate coordinates block
X = numpy.zeros((nNodes[0],nNodes[1],nNodes[2],3))
Expand All @@ -982,7 +982,7 @@ def func(P):
libcgns_utils.utils.closefile(cg)

# Print
print ('Mesh successfully generated and stored in: '+outFile)
print('Mesh successfully generated and stored in: '+outFile)

def split(self, extraSplits):

Expand Down Expand Up @@ -2561,8 +2561,8 @@ def simpleCart(xMin, xMax, dh, hExtra, nExtra, sym, mgcycle, outFile):
shp = [Xcart[0].shape[0], Xcart[1].shape[0], Xcart[2].shape[0]]
X = numpy.zeros((shp[0], shp[1], shp[2], 3))

print ('Grid Dimensions:', shp)
print ('Grid Ratios:', r)
print('Grid Dimensions:', shp)
print('Grid Ratios:', r)
# Write grid coordinates
Xx, Xy, Xz = numpy.meshgrid(Xcart[0], Xcart[1], Xcart[2], indexing='ij')
X[:,:,:,0] = Xx
Expand Down Expand Up @@ -2858,7 +2858,7 @@ def faceID(ptRange, blk):
blockUsed[otherIndex] == 0 and
i != otherIndex):

print ('Merging:', i+1, otherIndex+1)
print('Merging:', i+1, otherIndex+1)

# Great! These block match. Let's make the new
# block
Expand Down Expand Up @@ -3040,7 +3040,7 @@ def faceID(ptRange, blk):

# Set the new blocks
grid.blocks = newBlocks
print ("New number of blocks:", len(grid.blocks))
print("New number of blocks:", len(grid.blocks))

# Rename the blocks and remove any B2B info since it will all
# be recomputed:
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default:
@echo "#------------------------------------------------------#"

# Generate Numpy include directory
$(eval NUMPY_INCLUDES = $(shell $(PYTHON) -c 'from __future__ import print_function; import numpy; print(numpy.get_include())'))
$(eval NUMPY_INCLUDES = $(shell $(PYTHON) -c 'import numpy; print(numpy.get_include())'))
@echo "#------------------------------------------------------#"
@echo Numpy Include Directory: $(NUMPY_INCLUDES)
@echo "#------------------------------------------------------#"
Expand Down
3 changes: 1 addition & 2 deletions src/get_f2py.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
#------------- VERY IMPORTANT ------------

# This script is necessary since f2py INSISTS on priting crap out when
Expand All @@ -12,4 +11,4 @@
sys.stdout = sys.stderr
import numpy.f2py
sys.stdout = tmp
print (os.path.dirname(os.path.abspath(numpy.f2py.__file__)))
print(os.path.dirname(os.path.abspath(numpy.f2py.__file__)))
4 changes: 2 additions & 2 deletions src/importTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import sys

name = 'libcgns_utils'
print ("Testing if module %s can be imported..." % name)
print("Testing if module %s can be imported..." % name)
import_cmd = "import %s" % name
try:
exec(import_cmd)
except:
print ("Error: libcgns_utils was not imported correctly")
print("Error: libcgns_utils was not imported correctly")
sys.exit(1)
# end try

Expand Down

0 comments on commit f95b3ec

Please sign in to comment.