Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and linting fixes #77

Merged
merged 19 commits into from
Apr 2, 2021
Merged
6 changes: 2 additions & 4 deletions pygeo/DVConstraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,6 @@ def _readPlot3DSurfFile(self, fileName):
an unstructured mesh format"""

pts = None
conn = None

f = open(fileName, "r")
nSurf = numpy.fromfile(f, "int", count=1, sep=" ")[0]
Expand Down Expand Up @@ -4058,7 +4057,6 @@ def evalFunctionsSens(self, funcsSens, config):

# assume evalFunctions was called just prior and grad was stashed on rank=0
grad_vol = self.compute_volume_sens(self.surf_p0, self.surf_p1, self.surf_p2)
nDV = self.DVGeo.getNDV()
if self.scaled:
tmp_p0 = self.DVGeo.totalSensitivity(grad_vol[0] / self.vol_0, self.surface_name + "_p0", config=config)
tmp_p1 = self.DVGeo.totalSensitivity(grad_vol[1] / self.vol_0, self.surface_name + "_p1", config=config)
Expand Down Expand Up @@ -5964,12 +5962,12 @@ def evalCurvAreaSens(self, iSurf):

if self.curvatureType == "Gaussian":
# Now compute integral (K**2) over S, equivelent to sum(K**2*dS)
kS = numpy.dot(one, K * K * dS)
# kS = numpy.dot(one, K * K * dS)
ewu63 marked this conversation as resolved.
Show resolved Hide resolved
DkSDX = (self.diags(2 * K * dS).dot(DKDX) + self.diags(K * K).dot(DdSDX)).T.dot(one)
return DkSDX
elif self.curvatureType == "mean":
# Now compute integral (H**2) over S, equivelent to sum(H**2*dS)
hS = numpy.dot(one, H * H * dS)
# hS = numpy.dot(one, H * H * dS)
DhSDX = (self.diags(2 * H * dS).dot(DHDX) + self.diags(H * H).dot(DdSDX)).T.dot(one)
return DhSDX
elif self.curvatureType == "combined":
Expand Down
8 changes: 4 additions & 4 deletions pygeo/DVGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,8 @@ def addGeoDVSpanwiseLocal(
volList = numpy.arange(self.FFD.nVol)
ind = numpy.arange(len(self.FFD.coef))

secLink = numpy.zeros(self.FFD.coef.shape[0], dtype=int)
secTransform = [numpy.eye(3)]
# secLink = numpy.zeros(self.FFD.coef.shape[0], dtype=int)
# secTransform = [numpy.eye(3)]

if type(spanIndex) is str:
spanIndex = [spanIndex] * len(volList)
Expand Down Expand Up @@ -2723,7 +2723,7 @@ def demoDesignVars(self, directory, includeLocal=True, includeGlobal=True, point
x[j] = val
dvDict.update({key: x})
self.setDesignVars(dvDict)
X = self.update(pointSet)
self.update(pointSet)
anilyil marked this conversation as resolved.
Show resolved Hide resolved

# Write FFD
self.writeTecplot("{}/ffd/iter_{:03d}.dat".format(directory, count))
Expand Down Expand Up @@ -4134,7 +4134,7 @@ def sectionFrame(self, sectionIndex, sectionTransform, sectionLink, ivol=0, orie
List of transformation matrices for the sections of a given volume.
Transformations are set up from local section frame to global frame.
"""
xyz_2_idx = {"x": 0, "y": 1, "z": 2}
# xyz_2_idx = {"x": 0, "y": 1, "z": 2}
anilyil marked this conversation as resolved.
Show resolved Hide resolved
ijk_2_idx = {"i": 0, "j": 1, "k": 2}
lIndex = self.FFD.topo.lIndex[ivol]

Expand Down
12 changes: 5 additions & 7 deletions pygeo/DVGeometryESP.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def __init__(
pmtrIndex = 0
pmtrsleft = True
ocsmExternal = 500
ocsmIllegalPmtrIndex = -262
# ocsmIllegalPmtrIndex = -262
while pmtrsleft:
try:
pmtrIndex += 1
Expand Down Expand Up @@ -375,7 +375,7 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False,
if distributed:
# displacements for scatter
disp = numpy.array([numpy.sum(sizes[:i]) for i in range(self.comm.size)], dtype="intc")
nptsg = numpy.sum(sizes)
# nptsg = numpy.sum(sizes)
if self.comm.rank == 0:
sendbuf1 = [bodyIDg, sizes, disp, MPI.INT]
sendbuf2 = [faceIDg, sizes, disp, MPI.INT]
Expand All @@ -401,7 +401,7 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False,
# nondistributed pointset
# read on proc 0 and bcast to all
# then check that the points are correct
nptsg = points.shape[0]
# nptsg = points.shape[0]
if self.comm.rank == 0:
faceIDl[:] = faceIDg[:]
bodyIDl[:] = bodyIDg[:]
Expand Down Expand Up @@ -654,7 +654,6 @@ def setDesignVars(self, dvDict, updateJacobian=True):

def writeCADFile(self, filename):
valid_filetypes = ["brep", "bstl", "egads", "egg", "iges", "igs", "sens", "step", "stl", "stp", "tess", "grid"]
splitfile = filename.split(".")
file_extension = filename.split(".")[-1]
if file_extension.lower() not in valid_filetypes:
raise IOError(
Expand Down Expand Up @@ -803,8 +802,7 @@ def totalSensitivity(self, dIdpt, ptSetName, comm=None, config=None):
if len(dIdpt.shape) == 2:
dIdpt = numpy.array([dIdpt])
N = dIdpt.shape[0]

nDV = self.getNDV()
nPt = dIdpt.shape[1]
ewu63 marked this conversation as resolved.
Show resolved Hide resolved

# The following code computes the final sensitivity product:
#
Expand All @@ -820,7 +818,7 @@ def totalSensitivity(self, dIdpt, ptSetName, comm=None, config=None):
# a copy because we may need to modify it.

# reshape the dIdpt array from [N] * [nPt] * [3] to [N] * [nPt*3]
dIdpt = dIdpt.reshape((dIdpt.shape[0], dIdpt.shape[1] * 3))
dIdpt = dIdpt.reshape((N, nPt * 3))

# # transpose dIdpt and vstack;
# # Now vstack the result with seamBar as that is far as the
Expand Down
5 changes: 1 addition & 4 deletions pygeo/geo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ def calculateAverageNormal(p0, v1, v2):
take in a triangulated surface and calculate the centroid
"""
p0 = np.array(p0)
p1 = np.array(v1) + p0
p2 = np.array(v2) + p0

# compute the normal of each triangle
normal = np.cross(v1, v2)
Expand Down Expand Up @@ -270,7 +268,6 @@ def readAirfoilFile(fileName, bluntTe=False, bluntTaperRange=0.1, bluntThickness
npt = len(x)

xMin = min(x)
xMax = max(x)

# There are 4 possibilites we have to deal with:
# a. Given a sharp TE -- User wants a sharp TE
Expand Down Expand Up @@ -2181,7 +2178,7 @@ def calcGlobalNumberingDummy(self, sizes, surfaceList=None):
lIndex = []
# Now actually fill everything up
for ii in range(len(surfaceList)):
isurf = surfaceList[ii]
iSurf = surfaceList[ii]
ewu63 marked this conversation as resolved.
Show resolved Hide resolved
N = sizes[iSurf][0]
M = sizes[iSurf][1]
lIndex.append(-1 * np.ones((N, M), "intc"))
Expand Down
2 changes: 0 additions & 2 deletions pygeo/pyBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,6 @@ def getAttachedPoints(self, ptSetName):
only the points corresponding to the indices in mask will be
non-zero in the array.
"""

volID = self.embededVolumes[ptSetName].volID
u = self.embededVolumes[ptSetName].u
v = self.embededVolumes[ptSetName].v
w = self.embededVolumes[ptSetName].w
Expand Down
2 changes: 1 addition & 1 deletion pygeo/pyGeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _readIges(self, fileName):
start_lines = int((Ifile[-1][1:8]))
general_lines = int((Ifile[-1][9:16]))
directory_lines = int((Ifile[-1][17:24]))
parameter_lines = int((Ifile[-1][25:32]))
# parameter_lines = int((Ifile[-1][25:32]))

# Now we know how many lines we have to deal with
dir_offset = start_lines + general_lines
Expand Down
7 changes: 2 additions & 5 deletions tests/reg_tests/test_DVGeometryESP.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def setup_cubemodel_analytic_jac(self):
def test_load_a_model(self):
# load the box model and build the box model
csmFile = os.path.join(self.input_path, "inputFiles/esp/box.csm")
DVGeo = DVGeometryESP(csmFile)
DVGeometryESP(csmFile)

def test_save_cadfile(self):
write_fullpath = os.path.join(self.input_path, "reg_tests/fullpath_" + str(self.N_PROCS) + ".step")
Expand Down Expand Up @@ -193,7 +193,6 @@ def test_finite_precision(self):

DVGeo.addVariable("cubey0")
DVGeo.setDesignVars({"cubey0": np.array([4.2 + 1e-12])}, updateJacobian=False)
npts = initpts.shape[0]
self.assertAlmostEqual(DVGeo.pointSets["mypts"].proj_pts[0, 1] - 4.2, 1e-12, 15)
DVGeo.addVariable("cubedz")
DVGeo.setDesignVars({"cubedz": np.array([9.5 - 1e-12])}, updateJacobian=False)
Expand Down Expand Up @@ -362,7 +361,7 @@ def setup_cubemodel_analytic_jac(self):
def test_load_a_model(self):
# load the box model and build the box model
csmFile = os.path.join(self.input_path, "inputFiles/esp/box.csm")
DVGeo = DVGeometryESP(csmFile)
DVGeometryESP(csmFile)

def test_add_desvars(self):
# load the box model and build the box model
Expand Down Expand Up @@ -692,8 +691,6 @@ def test_point_mismatch(self):
# dim 1 is each vertex of the triangle
# dim 2 is x, y, z dimension
p0 = testobj.vectors[:, 0, :]
p1 = testobj.vectors[:, 1, :]
p2 = testobj.vectors[:, 2, :]
with self.assertRaises(ValueError):
distglobal1 = DVGeo.addPointSet(p0, "airfoil_p0")
self.assertGreater(distglobal1, 0.01)
Expand Down
4 changes: 0 additions & 4 deletions tests/reg_tests/test_DVGeometryVSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def sample_uv(nu, nv):

# convert the ptvec into list of coordinates
points = []
radError = 1e-20
radii = []
for pt in ptvec:
# print (pt)
Expand Down Expand Up @@ -177,8 +176,6 @@ def sample_uv(nu, nv):
openvsp.ReadVSPFile(vspFile)
geoms = openvsp.FindGeoms()

comps = []

DVGeo = DVGeometryVSP(vspFile)
comp = "WingGeom"
# loop over sections
Expand Down Expand Up @@ -232,7 +229,6 @@ def sample_uv(nu, nv):

# get the coordinates
nNodes = len(uv[0, :])
ptVecA = openvsp.CompVecPnt01(geoms[0], 0, uv[0, :], uv[1, :])
anilyil marked this conversation as resolved.
Show resolved Hide resolved

# extract node coordinates and save them in a numpy array
coor = numpy.zeros((nNodes, 3))
Expand Down