Skip to content

Commit

Permalink
Changed C compiler to icc for Intel config (#63)
Browse files Browse the repository at this point in the history
* updated gitignore

* ran black

* use icc in Intel config

* patch version bump

* rephrased readme
  • Loading branch information
sseraj authored Mar 2, 2023
1 parent a07a21a commit d3f6a4c
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.o
*.so
*.out
doc/_build

# auto generated files
src/libcgns_utils-f2pywrappers2.f90
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
[![Documentation Status](https://readthedocs.com/projects/mdolab-cgnsutilities/badge/?version=latest)](https://mdolab-cgnsutilities.readthedocs-hosted.com/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/mdolab/cgnsutilities/branch/main/graph/badge.svg?token=ZCO3MR2LNL)](https://codecov.io/gh/mdolab/cgnsutilities)

This repository contains a single program called `cgns_utils` that
provides many useful functions for working with cgns grids.
This repository contains many useful functions for working with CGNS grids and a CLI program called `cgns_utils` to call these functions.

## License

Expand Down
2 changes: 1 addition & 1 deletion cgnsutilities/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.7.0"
__version__ = "2.7.1"
2 changes: 0 additions & 2 deletions cgnsutilities/cgns_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ def main():

# Check if the user gave a reference name. Otherwise, use the input name as reference
if args.outFile is None:

# Get the base name
outFile = os.path.splitext(os.path.basename(args.gridFile))[0]

Expand All @@ -1060,7 +1059,6 @@ def main():
pickle.dump(curGrid.convArray, fid)

elif args.outType == "tecplot":

# Create a single 2D array that will contain all data
data = []

Expand Down
35 changes: 1 addition & 34 deletions cgnsutilities/cgnsutilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,10 @@ def printBlockInfo(self):
print("Total Nodes:", allBlocksInfo["totalNodes"])

def addBlock(self, blk):

"""Add a block to the grid"""
self.blocks.append(blk)

def removeBlocks(self, blockIDs):

"""
This function will remove certain blocks from the grid.
The user should ensure that the final mesh is still valid
Expand Down Expand Up @@ -311,7 +309,6 @@ def extractSurface(self, fileName):
f = open(fileName, "w")
f.write("%d\n" % len(patches))
for i in range(len(patches)):

f.write("%d %d 1\n" % (patches[i].shape[0], patches[i].shape[1]))
for i in range(len(patches)):
patches[i][:, :, 0].flatten("F").tofile(f, sep="\n", format="%20.15g")
Expand All @@ -333,7 +330,6 @@ def extractSpecifiedSurface(self, fileName, blkid, imin, imax, jmin, jmax, kmin,
f = open(fileName, "w")
f.write("%d\n" % len(patches))
for i in range(len(patches)):

f.write("%d %d 1\n" % (patches[i].shape[0], patches[i].shape[1]))
for i in range(len(patches)):
patches[i][:, :, 0].flatten("F").tofile(f, sep="\n", format="%20.15g")
Expand Down Expand Up @@ -488,7 +484,6 @@ def writeBCs(self, bcFile):
bcFile = self.name + ".bc"

with open(bcFile, "w") as fid:

for idx_block, block in enumerate(self.blocks):
blockID = idx_block + 1
block.writeBCs(blockID, fid)
Expand Down Expand Up @@ -642,7 +637,6 @@ def double2D(self):
blk.double2D()

def getBoundingBox(self):

# Get the bounds of each grid.
xMin = 1e20 * np.ones(3)
xMax = -1.0 * np.ones(3)
Expand Down Expand Up @@ -826,7 +820,6 @@ def cartesian(self, cartFile, outFile):

# Define tangent bunching law
def tanDist(Sp1, Sp2, N):

"""
This is the tangential spacing developed by Ney Secco.
This bunching law is coarse at the ends and fine at the middle
Expand Down Expand Up @@ -903,7 +896,6 @@ def func(P):
return S

def generateGrid(xmin, xmax, extension1, extension2, nNodes, binVol, weightGR):

"""
Function that optimizes bunching law to match grid resolution
Expand Down Expand Up @@ -1072,7 +1064,6 @@ def func(P):
print("Mesh successfully generated and stored in: " + outFile)

def split(self, extraSplits):

"""Recursively propagate splits due to boundary conditions or
B2B information"""

Expand Down Expand Up @@ -1319,7 +1310,6 @@ def fillOpenBCs(self, bocoType, famName):
blockID = myIDs[i] - 1

if types[i] == 0: # Boco

# Check if face already has a BC
has_bc = False
for boco in self.blocks[blockID].bocos:
Expand Down Expand Up @@ -1426,7 +1416,6 @@ def translate(self, dx, dy, dz):
blk.coords[:, :, :] += [dx, dy, dz]

def rotate(self, vx, vy, vz, theta):

"""
This rotates the grid around an axis that passes through the origin.
vx, vy, vz are the components of the rotation vector
Expand Down Expand Up @@ -1647,7 +1636,6 @@ def coarsen(self):
new_dims = copy.deepcopy(self.dims)
for i in range(3):
if self.dims[i] > 2:

if self.dims[i] % 2 == 0:
print(f"INFO: unevenly coarsing block {self.name} along dimension {i} (size {self.dims[i]}) ")

Expand Down Expand Up @@ -1896,7 +1884,6 @@ def revolve(self, normalDirection, rotationAxis, startAngle, endAngle, nThetas):
for i in range(self.dims[0]):
for j in range(self.dims[1]):
for k in range(nThetas):

tc = self.coords[i, j, 0, :].copy()

angleRad = startAngleRad + angleRadStep * k
Expand Down Expand Up @@ -2193,7 +2180,6 @@ def writeBCs(self, blk_num, file_handle):

data_arr_str = ""
for data_arr in boco.dataSets:

# use the BC dictionary in reverse to find the bc type string
for bctype in BC:
if data_arr.type == BC[bctype]:
Expand Down Expand Up @@ -2267,7 +2253,6 @@ def rebunch(self, spacing, extraCells, nStar):
newNodes = np.zeros((self.dims[0], self.dims[1], self.dims[2], 3))
for i in range(self.dims[0]):
for j in range(self.dims[1]):

xx = self.coords[i, j, :, :]
c = Curve(X=xx, localInterp=True)
# First get the distance off-wall:
Expand Down Expand Up @@ -2318,7 +2303,6 @@ def randomize(self, keepRHS):
# So that filps the order of the axis. We can also perform
# axis swapping.
if np.random.random() > 0.5:

# Swap X and Y axis
newCoords = np.zeros((self.dims[1], self.dims[0], self.dims[2], 3))
for k in range(self.dims[2]):
Expand Down Expand Up @@ -2365,7 +2349,6 @@ def symmZero(self, idir):
self.coords[r[0, 0] - 1 : r[0, 1], r[1, 0] - 1 : r[1, 1], r[2, 0] - 1 : r[2, 1], idir] = 0.0

def symmZeroNoBC(self, idir, tol):

# Find which nodes are closer than the tolerance from the symmetry plane
nodeIDs = np.where(self.coords[:, :, :, idir] < tol)

Expand Down Expand Up @@ -2418,10 +2401,8 @@ def coarsen(self):
"""Coarsen the range of the BC"""

for idim in range(3):

self.ptRange[idim, 0] = int(np.floor((self.ptRange[idim, 0]) / 2)) + 1
if self.ptRange[idim, 1] > 2:

# coarsen the data set if it is an array
if self.dataSets:
for data_set in self.dataSets:
Expand Down Expand Up @@ -2524,11 +2505,9 @@ def __init__(self, connectName, donorName, ptRange, donorRange, transform):
def coarsen(self):
"""Coarsen the range of the B2B along the specified direction"""
for idim in range(3):

donorDir = abs(self.transform[idim]) - 1

for j in range(2):

if self.ptRange[idim, j] > 2:
self.ptRange[idim, j] = (self.ptRange[idim, j] - 1) // 2 + 1

Expand Down Expand Up @@ -2811,6 +2790,7 @@ def simpleCart(xMin, xMax, dh, hExtra, nExtra, sym, mgcycle, outFile):
# # otherwise:
# return 1


# -----------------------------------------------------------------
# These functions perform operations that return new 'Grid' objects
# -----------------------------------------------------------------
Expand Down Expand Up @@ -2848,7 +2828,6 @@ def readGrid(fileName):
if nDataSets != 0:
# Loop over all the datasets for this BC
for iBocoDataSet in range(1, nDataSets + 1):

(
bocoDatasetName,
bocoDataSetType,
Expand Down Expand Up @@ -2886,7 +2865,6 @@ def getBocoDataSetArray(flagDirNeu, iDir):
if nDirichletArrays > 0:
# Loop over Dirichlet data and get the actual data
for iDir in range(1, nDirichletArrays + 1):

# Get the data set
bcDSetArr = getBocoDataSetArray(BCDATATYPE["Dirichlet"], iDir)

Expand All @@ -2899,7 +2877,6 @@ def getBocoDataSetArray(flagDirNeu, iDir):
if nNeumannArrays > 0:
# Loop over Neumann data sets
for iDir in range(1, nNeumannArrays + 1):

# Get the data set
bcDSetArr = getBocoDataSetArray(BCDATATYPE["Neumann"], iDir)

Expand Down Expand Up @@ -3067,7 +3044,6 @@ def mergeGrid(grid):
blocks in the mesh"""

def fullFace(blk, ptRange):

# Face size of the patch:
fSize = abs(ptRange[:, 1] - ptRange[:, 0])

Expand Down Expand Up @@ -3101,7 +3077,6 @@ def faceID(ptRange, blk):
cont = True
iteration = 0
while cont:

# First create a mapping of the blocks from the name to the index
zoneMap = {}

Expand All @@ -3117,7 +3092,6 @@ def faceID(ptRange, blk):

# We haven't used this block yet:
if blockUsed[i] == 0:

# Loop over the B2B of this block:
for b2b in blk.B2Bs:
otherIndex = zoneMap[b2b.donorName]
Expand All @@ -3131,7 +3105,6 @@ def faceID(ptRange, blk):
and blockUsed[otherIndex] == 0
and i != otherIndex
):

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

# Great! These block match. Let's make the new
Expand Down Expand Up @@ -3253,7 +3226,6 @@ def faceID(ptRange, blk):
# block. This is tricky since we need to
# offset and potentially reorient them .
for boco in otherBlk.bocos:

tmp = boco.ptRange.copy()
if face > 0:
# blk then otherBlk. BCs need to be increemented by offset.
Expand Down Expand Up @@ -3331,7 +3303,6 @@ def faceID(ptRange, blk):


def combineGrids(grids, useOldNames=False):

"""Method that takes in a list of grids and returns a new grid object
containing all zones from each grid. The blocks are renamed as
there could (almost most certainly) be conflicts between the zone
Expand All @@ -3346,7 +3317,6 @@ def combineGrids(grids, useOldNames=False):
# as the corresponding keys
gridDict = {}
for grid in grids:

# Create a dictionary of copies so the original grids are not modified
gridDict[grid.name] = copy.deepcopy(grid)

Expand All @@ -3360,7 +3330,6 @@ def combineGrids(grids, useOldNames=False):
# to the newGrid object

for name in nameList:

# Get the grid object corresponding to this name
grid = gridDict[name]

Expand Down Expand Up @@ -3457,7 +3426,6 @@ def explodeByZoneName(grid):

# Loop over all keys and add the grid to the output list
for name in nameList:

# Now rename the blocks, bcs and redo-connectivity, only if we have full mesh
gridDict[name].renameBlocks(useOldNames=True)
gridDict[name].renameBCs()
Expand All @@ -3471,7 +3439,6 @@ def explodeByZoneName(grid):


def write_tecplot_file(filename, title, variable_names, data_points):

"""
Auxiliary function that writes tecplot files
"""
Expand Down
2 changes: 1 addition & 1 deletion config/defaults/config.LINUX_GFORTRAN.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
CGNS_INCLUDE_FLAGS=-I$(CGNS_HOME)/include
CGNS_LINKER_FLAGS=-L$(CGNS_HOME)/lib -lcgns

# Gfortran compiler
# GCC
CC = gcc
CFLAGS = -O2 -fPIC
FC = gfortran
Expand Down
4 changes: 2 additions & 2 deletions config/defaults/config.LINUX_INTEL.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
CGNS_INCLUDE_FLAGS=-I$(CGNS_HOME)/include
CGNS_LINKER_FLAGS=-L$(CGNS_HOME)/lib -lcgns

# Intel Fortran Compiler
CC = gcc
# Intel compilers
CC = icc
CFLAGS = -O2 -fPIC
FC = ifort
FFLAGS = -O2 -r8 -g -fPIC -stand f08
Expand Down
4 changes: 0 additions & 4 deletions tests/test_cgnsutilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def setUp(self):
self.grid = readGrid(os.path.abspath(os.path.join(baseDir, "../examples/block_4x2x3.cgns")))

def test_coarsen(self):

self.grid.coarsen()
for iDim in range(3):
self.assertEqual(2, self.grid.blocks[0].dims[iDim])
Expand Down Expand Up @@ -249,7 +248,6 @@ def setUp(self):
self.grids = [self.grid1, self.grid2]

def test_combineGrids(self, train=False):

combinedNewNames = combineGrids(self.grids)
combinedOldNames = combineGrids(self.grids, useOldNames=True)

Expand Down Expand Up @@ -291,7 +289,6 @@ def test_combineGrids(self, train=False):
)

def test_mirror(self):

# Test mirroring function with useOldNames=True option
newNameList = [
"domain.00001",
Expand Down Expand Up @@ -334,7 +331,6 @@ def test_mirror(self):


class TestExamples(unittest.TestCase):

# Get all example scripts in the example folder and its subfolders
exampleDir = os.path.abspath(os.path.join(baseDir, "../examples"))
examples = []
Expand Down

0 comments on commit d3f6a4c

Please sign in to comment.