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

Codecov and flake8 fix #99

Merged
merged 12 commits into from
Aug 27, 2021
2 changes: 1 addition & 1 deletion .github/build_real.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
set -e
pip install -e .[testing]
pip install .[testing]
1 change: 1 addition & 0 deletions .github/test_real.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ if [[ $IMAGE == "private" ]] && [[ $OS == "ubuntu" ]]; then
EXTRA_FLAGS='--disallow_skipped'
fi

cd tests
testflo -v -n 1 --coverage --coverpkg pygeo $EXTRA_FLAGS
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Please cite pyGeo in any publication for which you find it useful.
For more background, theory, and figures, see the [this paper](http://umich.edu/~mdolaboratory/pdf/Kenway2010b.pdf).

G. K. W. Kenway, Kennedy, G. J., and Martins, J. R. R. A., “A CAD-Free Approach to High-Fidelity Aerostructural Optimization”, in Proceedings of the 13th AIAA/ISSMO Multidisciplinary Analysis Optimization Conference, Fort Worth, TX, 2010.

```
@conference {Kenway:2010:C,
title = {A {CAD}-Free Approach to High-Fidelity Aerostructural Optimization},
Expand Down
4 changes: 2 additions & 2 deletions examples/deform_geometry/ffd/simple_ffd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
f = open(filename, "w")
f.write("\t\t1\n")
f.write("\t\t%d\t\t%d\t\t%d\n" % (nX, nY, nZ))
for set in [X, Y, Z]:
for row in set:
for i in [X, Y, Z]:
for row in i:
vals = tuple(row)
f.write("\t%3.8f\t%3.8f\t%3.8f\t%3.8f\t%3.8f\t%3.8f\n" % vals)
f.close()
12 changes: 4 additions & 8 deletions pygeo/constraints/DVCon.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,28 @@ def __init__(self, name="DVCon1"):
self.surfaces = {}
self.DVGeometries = {}

def setSurface(self, surf, name="default", addToDVGeo=False, DVGeoName="default", format="point-vector"):
def setSurface(self, surf, name="default", addToDVGeo=False, DVGeoName="default", surfFormat="point-vector"):
"""
Set the surface DVConstraints will use to perform projections.

Parameters
----------
surf : pyGeo object or list

This is the surface representation to use for
projections. If available, a pyGeo surface object can be
used OR a triagnulaed surface in the form [p0, v1, v2] can
be used. This triangulated surface form can be supplied
form pyADflow or from pyTrian.

addToDVGeo : bool or str

To embed the surface pointset in a DVGeo object,
give the DVGeo name as a string. Otherwise, leave False

name : str

Name associated with the surface. Must be unique. For backward compatibility,
the name is 'default' by default

DVGeoName : str

Name of the DVGeo object to set the surface to. You only
need to set this if you're using multiple DVGeo objects
for a problem. For backward compatibility, the name is 'default' by default
Expand All @@ -123,7 +119,7 @@ def setSurface(self, surf, name="default", addToDVGeo=False, DVGeoName="default"
raise KeyError("Surface names must be unique. Repeated surface name: " + str(name))

self.surfaces[name] = list()
if format == "point-vector":
if surfFormat == "point-vector":
if type(surf) == list:
# Data from ADflow
p0 = np.array(surf[0])
Expand All @@ -140,7 +136,7 @@ def setSurface(self, surf, name="default", addToDVGeo=False, DVGeoName="default"

p1 = p0 + v1
p2 = p0 + v2
elif format == "point-point":
elif surfFormat == "point-point":
if type(surf) == str:
# load from file
raise NotImplementedError
Expand Down Expand Up @@ -2797,7 +2793,7 @@ def addMonotonicConstraints(self, key, slope=1.0, name=None, start=0, stop=-1, c
self.linearCon[conName] = GlobalLinearConstraint(
conName,
key,
type="monotonic",
conType="monotonic",
options=options,
lower=0,
upper=None,
Expand Down
4 changes: 2 additions & 2 deletions pygeo/constraints/baseConstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ class GlobalLinearConstraint(object):
constriants coupling global design variables together.
"""

def __init__(self, name, key, type, options, lower, upper, DVGeo, config):
def __init__(self, name, key, conType, options, lower, upper, DVGeo, config):
# No error checking here since the calling routine should have
# already done it.
self.name = name
self.key = key
self.type = type
self.type = conType
self.lower = lower
self.upper = upper
self.DVGeo = DVGeo
Expand Down
12 changes: 4 additions & 8 deletions pygeo/geo_utils/bilinear_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
def getBiLinearMap(edge0, edge1, edge2, edge3):
"""Get the UV coordinates on a square defined from spacing on the edges"""

assert len(edge0) == len(
edge1
), "Error, getBiLinearMap:\
The len of edge0 and edge1 are not the same"
assert len(edge2) == len(
edge3
), "Error, getBiLinearMap:\
The len of edge2 and edge3 are no the same"
if len(edge0) != len(edge1):
raise ValueError("getBiLinearMap: The len of edge0 and edge1 are not the same")
if len(edge2) != len(edge3):
raise ValueError("getBiLinearMap: The len of edge2 and edge3 are no the same")

N = len(edge0)
M = len(edge2)
Expand Down
6 changes: 3 additions & 3 deletions pygeo/geo_utils/dcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,17 +452,17 @@ def loadDCEL(self, fileName):
self.vl = []
self.el = []
self.faceInfo = []
for i in range(nvertices):
for _i in range(nvertices):
a = f.readline().split()
self.vl.append(DCELVertex([float(a[0]), float(a[1])], np.array([float(a[2]), float(a[3]), float(a[4])])))

for i in range(nedges):
for _i in range(nedges):
a = f.readline().split()
self.el.append(DCELEdge(int(a[0]), int(a[1]), None, None, None, a[8]))
self.el[-1].x1 = np.array([float(a[2]), float(a[3]), float(a[4])])
self.el[-1].x2 = np.array([float(a[5]), float(a[6]), float(a[7])])

for i in range(nfaces):
for _i in range(nfaces):
a = f.readline().split()
self.faceInfo.append(a[0])

Expand Down
4 changes: 2 additions & 2 deletions pygeo/geo_utils/node_edge_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def setNodeValue(arr, value, nodeIndex):
return arr


def setEdgeValue(arr, values, dir, edgeIndex):
def setEdgeValue(arr, values, edgeDir, edgeIndex):

if dir == -1: # Reverse values
if edgeDir == -1: # Reverse values
values = values[::-1]

if edgeIndex == 0:
Expand Down
29 changes: 14 additions & 15 deletions pygeo/geo_utils/pointselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,23 @@ def __init__(self, psType, *args, **kwargs):
"""

if psType == "x" or psType == "y" or psType == "z":
assert (
"pt1" in kwargs and "pt2" in kwargs
), "Error:, two points \
must be specified with initialization type x,y, or z. Points are specified \
with kwargs pt1=[x1,y1,z1],pt2=[x2,y2,z2]"

if not ("pt1" in kwargs and "pt2" in kwargs):
raise ValueError(
"Two points must be specified with initialization type x, y, or z. "
+ "Points are specified with kwargs pt1=[x1,y1,z1], pt2=[x2,y2,z2]"
)
elif psType == "quad":
assert (
"pt1" in kwargs and "pt2" in kwargs and "pt3" in kwargs and "pt4" in kwargs
), "Error:, four points \
must be specified with initialization type quad. Points are specified \
with kwargs pt1=[x1,y1,z1],pt2=[x2,y2,z2],pt3=[x3,y3,z3],pt4=[x4,y4,z4]"
if not ("pt1" in kwargs and "pt2" in kwargs and "pt3" in kwargs and "pt4" in kwargs):
raise ValueError(
"Four points must be specified with initialization type quad. "
+ "Points are specified with kwargs pt1=[x1,y1,z1], pt2=[x2,y2,z2], pt3=[x3,y3,z3], pt4=[x4,y4,z4]"
)

elif psType == "ijkBounds":
assert (
"ijkBounds" in kwargs
), "Error:, ijkBounds selection method requires a dictonary with \
the specific ijkBounds for each volume."
if not ("ijkBounds" in kwargs):
raise ValueError(
"ijkBounds selection method requires a dictonary with the specific ijkBounds for each volume."
)

corners = np.zeros([4, 3])
if psType in ["x", "y", "z", "corners"]:
Expand Down
14 changes: 4 additions & 10 deletions pygeo/geo_utils/split_quad.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,10 @@ def tfi_2d(e0, e1, e2, e3):

Nu = len(e0)
Nv = len(e2)
assert Nu == len(e1), (
"Number of nodes on edge0 and edge1\
are not the same, %d %d"
% (len(e0), len(e1))
)
assert Nv == len(e3), (
"Number of nodes on edge2 and edge3\
are not the same, %d %d"
% (len(e2), len(e3))
)
if Nu != len(e1):
raise ValueError(f"Number of nodes on edge0 and edge1 are not the same: {len(e0)} {len(e1)}")
if Nv != len(e3):
raise ValueError(f"Number of nodes on edge2 and edge3 are not the same: {len(e2)} {len(e3)}")

U = np.linspace(0, 1, Nu)
V = np.linspace(0, 1, Nv)
Expand Down
18 changes: 12 additions & 6 deletions pygeo/parameterization/DVGeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ class DVGeometry(object):
>>>
"""

def __init__(self, fileName, complex=False, child=False, faceFreeze=None, name=None, *args, **kwargs):
def __init__(self, fileName, isComplex=False, child=False, faceFreeze=None, name=None, *args, **kwargs):

self.DV_listGlobal = OrderedDict() # Global Design Variable List
self.DV_listLocal = OrderedDict() # Local Design Variable List
self.DV_listSectionLocal = OrderedDict() # Local Normal Design Variable List
self.DV_listSpanwiseLocal = OrderedDict() # Local Normal Design Variable List

# FIXME: for backwards compatibility we still allow the argument complex=True/False
# which we now check in kwargs and overwrite
if "complex" in kwargs:
isComplex = kwargs.pop("complex")
warnings.warn("The keyword argument 'complex' is deprecated, use 'isComplex' instead.")

# Coefficient rotation matrix dict for Section Local variables
self.coefRotM = {}

Expand All @@ -97,7 +103,7 @@ def __init__(self, fileName, complex=False, child=False, faceFreeze=None, name=N
self.updated = {}
self.masks = None
self.finalized = False
self.complex = complex
self.complex = isComplex
if self.complex:
self.dtype = "D"
else:
Expand Down Expand Up @@ -362,7 +368,7 @@ def addRefAxis(

curveSymm = copy.deepcopy(curve)
curveSymm.reverse()
for coef in curveSymm.coef:
for _coef in curveSymm.coef:
curveSymm.coef[:, index] = -curveSymm.coef[:, index]
self.axis[name] = {
"curve": curve,
Expand Down Expand Up @@ -417,7 +423,7 @@ def addRefAxis(
nVol = len(v)
volOrd = [v.pop(0)]
faceLink = self.FFD.topo.faceLink
for iter in range(nVol):
for _iter in range(nVol):
for vInd, i in enumerate(v):
for pInd, j in enumerate(volOrd):
if faceLink[i, faceCol] == faceLink[j, faceCol + 1]:
Expand Down Expand Up @@ -4220,8 +4226,8 @@ def sectionFrame(self, sectionIndex, sectionTransform, sectionLink, ivol=0, orie

# Need to initialize coefRotM to identity matrix for case with no
# global design variables
for slice in rolledlIndex[i, :, :]:
for coef in slice:
for j in rolledlIndex[i, :, :]:
for coef in j:
self.coefRotM[coef] = np.eye(3)

return nSections
21 changes: 17 additions & 4 deletions pygeo/parameterization/DVGeoAxi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
import numpy as np
from scipy import sparse
from collections import OrderedDict
Expand Down Expand Up @@ -29,8 +30,14 @@ class _AxiTransform(object):
into the x,z plane and use z as the rotational axis
"""

def __init__(self, pts, center, collapse_into, complex=False):
self.complex = complex
def __init__(self, pts, center, collapse_into, isComplex=False, **kwargs):
# FIXME: for backwards compatibility we still allow the argument complex=True/False
# which we now check in kwargs and overwrite
if "complex" in kwargs:
isComplex = kwargs.pop("complex")
warnings.warn("The keyword argument 'complex' is deprecated, use 'isComplex' instead.")

self.complex = isComplex

self.c_plane = collapse_into
self.n_points = pts.shape[0]
Expand Down Expand Up @@ -193,11 +200,17 @@ class DVGeometryAxi(DVGeometry):
>>>
"""

def __init__(self, fileName, center, collapse_into, complex=False, child=False, *args, **kwargs):
def __init__(self, fileName, center, collapse_into, isComplex=False, child=False, *args, **kwargs):

self.axiTransforms = OrderedDict() # TODO: Why is this ordered?

super(DVGeometryAxi, self).__init__(fileName, complex, child, *args, **kwargs)
# FIXME: for backwards compatibility we still allow the argument complex=True/False
# which we now check in kwargs and overwrite
if "complex" in kwargs:
isComplex = kwargs.pop("complex")
warnings.warn("The keyword argument 'complex' is deprecated, use 'isComplex' instead.")

super().__init__(fileName, isComplex=isComplex, child=child, *args, **kwargs)

self.center = center
self.collapse_into = collapse_into
Expand Down
Loading