diff --git a/.github/test_real.sh b/.github/test_real.sh index 8224945c..5c36f247 100755 --- a/.github/test_real.sh +++ b/.github/test_real.sh @@ -3,7 +3,7 @@ set -e ./input_files/get-input-files.sh # all tests should pass on private -if [[ $IMAGE == "private" ]] && [[ $OS == "ubuntu" ]]; then +if [[ $OS == "ubuntu" ]]; then EXTRA_FLAGS='--disallow_skipped' fi diff --git a/pygeo/constraints/areaConstraint.py b/pygeo/constraints/areaConstraint.py index 89abf080..0b56131a 100644 --- a/pygeo/constraints/areaConstraint.py +++ b/pygeo/constraints/areaConstraint.py @@ -390,7 +390,7 @@ def evalFunctionsSens(self, funcsSens, config): # for j in range(3): # areas(i) = areas(i) + crosses(i, j)**2 # areas[i] = np.sum(crosses[i, :]**2) - areas = np.sum(crosses ** 2, axis=1) + areas = np.sum(crosses**2, axis=1) for i in range(self.n): # DO i=1,n if areas[i] == 0.0: areasb[i] = 0.0 diff --git a/pygeo/constraints/radiusConstraint.py b/pygeo/constraints/radiusConstraint.py index cb0024ff..3a002581 100644 --- a/pygeo/constraints/radiusConstraint.py +++ b/pygeo/constraints/radiusConstraint.py @@ -91,24 +91,24 @@ def computeCircle(self, coords): # Compute the radius of curvature A = xi1 * (eta2 - eta3) - eta1 * (xi2 - xi3) + xi2 * eta3 - xi3 * eta2 B = ( - (xi1 ** 2 + eta1 ** 2) * (eta3 - eta2) - + (xi2 ** 2 + eta2 ** 2) * (eta1 - eta3) - + (xi3 ** 2 + eta3 ** 2) * (eta2 - eta1) + (xi1**2 + eta1**2) * (eta3 - eta2) + + (xi2**2 + eta2**2) * (eta1 - eta3) + + (xi3**2 + eta3**2) * (eta2 - eta1) ) C = ( - (xi1 ** 2 + eta1 ** 2) * (xi2 - xi3) - + (xi2 ** 2 + eta2 ** 2) * (xi3 - xi1) - + (xi3 ** 2 + eta3 ** 2) * (xi1 - xi2) + (xi1**2 + eta1**2) * (xi2 - xi3) + + (xi2**2 + eta2**2) * (xi3 - xi1) + + (xi3**2 + eta3**2) * (xi1 - xi2) ) D = ( - (xi1 ** 2 + eta1 ** 2) * (xi3 * eta2 - xi2 * eta3) - + (xi2 ** 2 + eta2 ** 2) * (xi1 * eta3 - xi3 * eta1) - + (xi3 ** 2 + eta3 ** 2) * (xi2 * eta1 - xi1 * eta2) + (xi1**2 + eta1**2) * (xi3 * eta2 - xi2 * eta3) + + (xi2**2 + eta2**2) * (xi1 * eta3 - xi3 * eta1) + + (xi3**2 + eta3**2) * (xi2 * eta1 - xi1 * eta2) ) xiC = -B / 2 / A etaC = -C / 2 / A - r = np.sqrt((B ** 2 + C ** 2 - 4 * A * D) / 4 / A ** 2) + r = np.sqrt((B**2 + C**2 - 4 * A * D) / 4 / A**2) # Convert center coordinates back center = origin + nxi * xiC[:, None] + neta * etaC[:, None] diff --git a/pygeo/constraints/thicknessConstraint.py b/pygeo/constraints/thicknessConstraint.py index aca21f64..4f98e8c1 100644 --- a/pygeo/constraints/thicknessConstraint.py +++ b/pygeo/constraints/thicknessConstraint.py @@ -155,8 +155,8 @@ def evalFunctionsSens(self, funcsSens, config): dToCdPt[i, 4 * i, :] = p1b / c / self.ToC0[i] dToCdPt[i, 4 * i + 1, :] = p2b / c / self.ToC0[i] - dToCdPt[i, 4 * i + 2, :] = (-p3b * t / c ** 2) / self.ToC0[i] - dToCdPt[i, 4 * i + 3, :] = (-p4b * t / c ** 2) / self.ToC0[i] + dToCdPt[i, 4 * i + 2, :] = (-p3b * t / c**2) / self.ToC0[i] + dToCdPt[i, 4 * i + 3, :] = (-p4b * t / c**2) / self.ToC0[i] funcsSens[self.name] = self.DVGeo.totalSensitivity(dToCdPt, self.name, config=config) diff --git a/pygeo/geo_utils/rotation.py b/pygeo/geo_utils/rotation.py index 21f3eb3b..9d2fa38f 100644 --- a/pygeo/geo_utils/rotation.py +++ b/pygeo/geo_utils/rotation.py @@ -63,17 +63,17 @@ def rotVbyW(V, W, theta): R = np.zeros((3, 3), dtype) - R[0, 0] = ux ** 2 + (1 - ux ** 2) * c + R[0, 0] = ux**2 + (1 - ux**2) * c R[0, 1] = ux * uy * (1 - c) - uz * s R[0, 2] = ux * uz * (1 - c) + uy * s R[1, 0] = ux * uy * (1 - c) + uz * s - R[1, 1] = uy ** 2 + (1 - uy ** 2) * c + R[1, 1] = uy**2 + (1 - uy**2) * c R[1, 2] = uy * uz * (1 - c) - ux * s R[2, 0] = ux * uz * (1 - c) - uy * s R[2, 1] = uy * uz * (1 - c) + ux * s - R[2, 2] = uz ** 2 + (1 - uz ** 2) * c + R[2, 2] = uz**2 + (1 - uz**2) * c return np.dot(R, V) diff --git a/pygeo/parameterization/DVGeoAxi.py b/pygeo/parameterization/DVGeoAxi.py index 2e176ab9..d4aa39a9 100644 --- a/pygeo/parameterization/DVGeoAxi.py +++ b/pygeo/parameterization/DVGeoAxi.py @@ -56,7 +56,7 @@ def __init__(self, pts, center, collapse_into, isComplex=False, **kwargs): beta = pts[:, self.beta_idx] - center[self.beta_idx] gamma = pts[:, self.gamma_idx] - center[self.gamma_idx] - self.radii = np.sqrt(beta ** 2 + gamma ** 2) + self.radii = np.sqrt(beta**2 + gamma**2) # need to get the real part because arctan2 is not complex save # but its ok, becuase these are constants self.thetas = np.arctan2(gamma.real, beta.real) diff --git a/pygeo/parameterization/DVGeoESP.py b/pygeo/parameterization/DVGeoESP.py index addc1d92..01dbd3a4 100644 --- a/pygeo/parameterization/DVGeoESP.py +++ b/pygeo/parameterization/DVGeoESP.py @@ -7,7 +7,7 @@ import numpy as np from collections import OrderedDict from mpi4py import MPI -from pyOCSM import pyOCSM +from pyOCSM import ocsm from contextlib import contextmanager from baseclasses.utils import Error @@ -147,13 +147,15 @@ def __init__( t1 = time.time() # read the model - self.espModel = pyOCSM.Ocsm(self.espFile) - pyOCSM.SetOutLevel(0) + self.espModel = ocsm.Ocsm(self.espFile) + ocsm.SetOutLevel(0) + # build the baseline model if self.comm.rank == 0: - pyOCSM.SetOutLevel(0) + ocsm.SetOutLevel(0) else: - pyOCSM.SetOutLevel(0) + ocsm.SetOutLevel(0) + self.num_branches_baseline, _, allBodyIndices = self.espModel.Build( 0, 200 ) # pick 200 as arbitrary large number of bodies to allocate @@ -201,24 +203,27 @@ def __init__( pmtrIndex += 1 pmtrType, numRow, numCol, pmtrName = self.espModel.GetPmtr(pmtrIndex) baseValue = np.zeros(numRow * numCol) + for rowIdx in range(numRow): for colIdx in range(numCol): try: baseValue[colIdx + numCol * rowIdx] = self.espModel.GetValu( pmtrIndex, rowIdx + 1, colIdx + 1 )[0] - except pyOCSM.OcsmError as e: + except ocsm.OcsmError as e: if e.value == "ILLEGAL_PTMR_INDEX": # I don't think we should ever make it here if the GetPmtr check is correct raise Error("Column or row index out of range in design parameter " + pmtrName) if pmtrType == ocsmExternal: self.csmDesPmtrs[pmtrName] = ESPParameter(pmtrName, pmtrIndex, numRow, numCol, baseValue) - except pyOCSM.OcsmError as e: + + except ocsm.OcsmError as e: if e.value == "ILLEGAL_PMTR_INDEX": pmtrsleft = False else: raise e + if pmtrIndex == 1: if comm.rank == 0: print("DVGeometryESP Warning: no design parameters defined in the CSM file") @@ -240,7 +245,7 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False, project into the interior of the FFD volume. ptName : str A user supplied name to associate with the set of - coordinates. Thisname will need to be provided when + coordinates. This name will need to be provided when updating the coordinates or when getting the derivatives of the coordinates. distributed : bool @@ -259,8 +264,7 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False, """ # save this name so that we can zero out the jacobians properly - self.points[ptName] = True # ADFlow checks self.points to see - # if something is added or not. + self.points[ptName] = True # ADFlow checks self.points to see if something is added or not points = np.array(points).real.astype("d") # check that duplicated pointsets are actually the same length @@ -471,12 +475,12 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False, # try to match point on edges first with stdout_redirected(self.suppress_stdout): # get the parametric coordinate along the edge - ttemp = self.espModel.GetUV(bodyIndex, pyOCSM.EDGE, edgeIndex, 1, truexyz.tolist()) + ttemp = self.espModel.GetUV(bodyIndex, ocsm.EDGE, edgeIndex, 1, truexyz.tolist()) # get the xyz location of the newly projected point - xyztemp = np.array(self.espModel.GetXYZ(bodyIndex, pyOCSM.EDGE, edgeIndex, 1, ttemp)) + xyztemp = np.array(self.espModel.GetXYZ(bodyIndex, ocsm.EDGE, edgeIndex, 1, ttemp)) dist_temp = np.sum((truexyz - xyztemp) ** 2) ttemp = ttemp[0] - tlimits = self._getUVLimits(bodyIndex, pyOCSM.EDGE, edgeIndex) + tlimits = self._getUVLimits(bodyIndex, ocsm.EDGE, edgeIndex) if not (ttemp < tlimits[0] - rejectuvtol or ttemp > tlimits[1] + rejectuvtol): if dist_temp < dist_best: tlimits_best = tlimits @@ -489,14 +493,14 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False, for faceIndex in range(1, nFaces + 1): with stdout_redirected(self.suppress_stdout): # get the projected points on the ESP surface in UV coordinates - uvtemp = self.espModel.GetUV(bodyIndex, pyOCSM.FACE, faceIndex, 1, truexyz.tolist()) + uvtemp = self.espModel.GetUV(bodyIndex, ocsm.FACE, faceIndex, 1, truexyz.tolist()) # get the XYZ location of the newly projected points - xyztemp = np.array(self.espModel.GetXYZ(bodyIndex, pyOCSM.FACE, faceIndex, 1, uvtemp)) + xyztemp = np.array(self.espModel.GetXYZ(bodyIndex, ocsm.FACE, faceIndex, 1, uvtemp)) dist_temp = np.sum((truexyz - xyztemp) ** 2) # validate u and v utemp = uvtemp[0] vtemp = uvtemp[1] - uvlimits = self._getUVLimits(bodyIndex, pyOCSM.FACE, faceIndex) + uvlimits = self._getUVLimits(bodyIndex, ocsm.FACE, faceIndex) if not ( utemp < uvlimits[0] - rejectuvtol or utemp > uvlimits[1] + rejectuvtol @@ -596,8 +600,7 @@ def addPointSet(self, points, ptName, distributed=True, cache_projections=False, def setDesignVars(self, dvDict, updateJacobian=True): """ - Standard routine for setting design variables from a design - variable dictionary. + Standard routine for setting design variables from a design variable dictionary. Parameters ---------- @@ -1035,7 +1038,7 @@ def _getUVLimits(self, ibody, seltype, iselect): ibody : int Body index seltype : int - pyOCSM.EDGE or pyOCSM.FACE + ocsm.EDGE or ocsm.FACE iselect : int Index of edge or face @@ -1164,18 +1167,18 @@ def _evaluatePoints(self, u, v, t, uvlimits0, tlimits0, bodyID, faceID, edgeID, # get the point from an edge # get upper and lower parametric limits of updated model tlim0 = tlimits0[ptidx] - tlim = self._getUVLimits(bid, pyOCSM.EDGE, eid) + tlim = self._getUVLimits(bid, ocsm.EDGE, eid) trange0 = tlim0[1] - tlim0[0] trange = tlim[1] - tlim[0] tnew = (t[ptidx] - tlim0[0]) * trange / trange0 + tlim[0] - points[ptidx, :] = self.espModel.GetXYZ(bid, pyOCSM.EDGE, eid, 1, [tnew]) + points[ptidx, :] = self.espModel.GetXYZ(bid, ocsm.EDGE, eid, 1, [tnew]) else: # point from a face if fid == -1: raise ValueError("both edge ID and face ID are unset") # get the upper and lower uv limits of the updated model uvlim0 = uvlimits0[ptidx] - uvlim = self._getUVLimits(bid, pyOCSM.FACE, fid) + uvlim = self._getUVLimits(bid, ocsm.FACE, fid) urange0 = uvlim0[1] - uvlim0[0] vrange0 = uvlim0[3] - uvlim0[2] urange = uvlim[1] - uvlim[0] @@ -1183,7 +1186,7 @@ def _evaluatePoints(self, u, v, t, uvlimits0, tlimits0, bodyID, faceID, edgeID, # scale the input uv points according to the original uv limits unew = (u[ptidx] - uvlim0[0]) * urange / urange0 + uvlim[0] vnew = (v[ptidx] - uvlim0[2]) * vrange / vrange0 + uvlim[2] - points[ptidx, :] = self.espModel.GetXYZ(bid, pyOCSM.FACE, fid, 1, [unew, vnew]) + points[ptidx, :] = self.espModel.GetXYZ(bid, ocsm.FACE, fid, 1, [unew, vnew]) points = points * self.espScale return points diff --git a/pygeo/parameterization/DVGeoMulti.py b/pygeo/parameterization/DVGeoMulti.py index 3859fa1e..df4443e5 100644 --- a/pygeo/parameterization/DVGeoMulti.py +++ b/pygeo/parameterization/DVGeoMulti.py @@ -1474,7 +1474,7 @@ def update_d(self, ptSetName, dPt, dSeam): # Do it vectorized rr = pts[j] - self.seam0 LdefoDist = 1.0 / np.sqrt(rr[:, 0] ** 2 + rr[:, 1] ** 2 + rr[:, 2] ** 2 + 1e-16) - LdefoDist3 = LdefoDist ** 3 + LdefoDist3 = LdefoDist**3 Wi = LdefoDist3 den = np.sum(Wi) interp_d = np.zeros(3) @@ -2152,7 +2152,7 @@ def _warpSurfPts(self, pts0, ptsNew, indices, curvePtCoords, delta): # Vectorized point-based warping rr = ptCoords - curvePtCoords LdefoDist = 1.0 / np.sqrt(rr[:, 0] ** 2 + rr[:, 1] ** 2 + rr[:, 2] ** 2 + 1e-16) - LdefoDist3 = LdefoDist ** 3 + LdefoDist3 = LdefoDist**3 Wi = LdefoDist3 den = np.sum(Wi) interp = np.zeros(3) @@ -2185,7 +2185,7 @@ def _warpSurfPts_b(self, dIdPt, pts0, indices, curvePtCoords): # Vectorized point-based warping rr = ptCoords - curvePtCoords LdefoDist = 1.0 / np.sqrt(rr[:, 0] ** 2 + rr[:, 1] ** 2 + rr[:, 2] ** 2 + 1e-16) - LdefoDist3 = LdefoDist ** 3 + LdefoDist3 = LdefoDist**3 Wi = LdefoDist3 den = np.sum(Wi) diff --git a/pygeo/pyBlock.py b/pygeo/pyBlock.py index 459471f0..8c5a4692 100644 --- a/pygeo/pyBlock.py +++ b/pygeo/pyBlock.py @@ -901,7 +901,7 @@ def projectPoints(self, x0, checkErrors, embTol, eps, nIter): if nrm > DMax: DMax = nrm - DRms += nrm ** 2 + DRms += nrm**2 if nrm > embTol: counter += 1 badPts.append([x0[i], D[i]])