Skip to content

Commit

Permalink
re-applied commit from Alex
Browse files Browse the repository at this point in the history
  • Loading branch information
ewu63 committed Apr 14, 2021
1 parent ff2f84c commit 4042b13
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions cgnsutilities/cgnsutilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,36 @@ def __init__(self):
self.name = "domain"
self.cellDim = 3

def getCellsNodes(self):
""" Returns the total number of Cells and Nodes in the grid. """
def getTotalCellsNodes(self):
"""
Returns the total number of Cells and Nodes in the grid.
Example
-------
To determine the number of cells/nodes in a grid use:
>>> from cgnsutilities.cgnsutilities import Grid, readGrid
>>> grid = readGrid("gridfilename.cgns")
>>> totalCells, totalNodes = grid.getTotalCellsNodes()
"""
totalCells = 0
totalNodes = 0
for blk in self.blocks:
totalCells += (blk.dims[0] - 1) * (blk.dims[1] - 1) * (blk.dims[2] - 1)
totalNodes += blk.dims[0] * blk.dims[1] * blk.dims[2]

return totalCells, totalNodes


def printInfo(self):
"""Print some information on the mesh to screen. Specifically
information needed by the drag prediction workshop"""
totalCells, totalNodes = self.getCellsNodes()

print("Total Zones:", len(self.blocks))
print("Total Cells:", totalCells)
print("Total Nodes:", totalNodes)
def getWallCellsNodes(self):
"""
Returns the number of Cells and Nodes on wall boundaries
Example
-------
To determine the number of cells/nodes in a grid use:
>>> from cgnsutilities.cgnsutilities import Grid, readGrid
>>> grid = readGrid("gridfilename.cgns")
>>> nWallCells, nWallNodes = grid.getWallCellsNodes()
"""

boundaryNodes = 0
boundaryCells = 0
Expand Down Expand Up @@ -98,6 +109,20 @@ def printInfo(self):
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)
return boundaryCells, boundaryNodes

def printInfo(self):
"""
Prints the number of zones, total number of cells and nodes,
and the number of cells and nodes on wall boundaries.
"""
totalCells, totalNodes = self.getTotalCellsNodes()

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

boundaryCells, boundaryNodes = self.getWallCellsNodes()

print("Wall Boundary Cells:", boundaryCells)
print("Wall Boundary Nodes:", boundaryNodes)
Expand Down

0 comments on commit 4042b13

Please sign in to comment.