From 84de2acca62fef9b8001fb0f1ff780c861d0685b Mon Sep 17 00:00:00 2001 From: Anil Yildirim Date: Mon, 21 Mar 2022 17:31:51 -0400 Subject: [PATCH] format and lint --- pygeo/mphys/__init__.py | 4 +--- pygeo/mphys/mphys_dvgeo.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pygeo/mphys/__init__.py b/pygeo/mphys/__init__.py index a1c4d723..9cb78094 100644 --- a/pygeo/mphys/__init__.py +++ b/pygeo/mphys/__init__.py @@ -1,5 +1,3 @@ from .mphys_dvgeo import OM_DVGEOCOMP -__all__ = [ - "OM_DVGEOCOMP" -] +__all__ = ["OM_DVGEOCOMP"] diff --git a/pygeo/mphys/mphys_dvgeo.py b/pygeo/mphys/mphys_dvgeo.py index 7cec4b07..dadfad5c 100644 --- a/pygeo/mphys/mphys_dvgeo.py +++ b/pygeo/mphys/mphys_dvgeo.py @@ -3,13 +3,11 @@ try: from pygeo import DVGeometryVSP -except: +except ModuleNotFoundError: # not everyone might have openvsp installed, and thats okay pass from mpi4py import MPI import numpy as np -from openmdao.utils.array_utils import evenly_distrib_idxs -import time # class that actually calls the dvgeometry methods class OM_DVGEOCOMP(om.ExplicitComponent): @@ -41,8 +39,8 @@ def compute(self, inputs, outputs): for var in inputs.keys(): # check that the input name matches the convention for points if var[:2] == "x_": - # trim the _in and add a "0" to signify that these are initial conditions initial - var_out = var[:-3] + '0' + # trim the _in and add a "0" to signify that these are initial conditions initial + var_out = var[:-3] + "0" if var_out not in self.omPtSetList: self.nom_addPointSet(inputs[var], var_out, add_output=False) @@ -156,7 +154,7 @@ def nom_add_LETEConstraint(self, name, volID, faceID): else: self.add_output(name, distributed=True, shape=0) return nCon - + def nom_addLERadiusConstraints(self, name, leList, nSpan, axis, chordDir): self.DVCon.addLERadiusConstraints(leList=leList, nSpan=nSpan, axis=axis, chordDir=chordDir, name=name) comm = self.comm @@ -164,7 +162,7 @@ def nom_addLERadiusConstraints(self, name, leList, nSpan, axis, chordDir): self.add_output(name, distributed=True, val=np.ones(nSpan), shape=nSpan) else: self.add_output(name, distributed=True, shape=0) - + def nom_addCurvatureConstraint1D(self, name, start, end, nPts, axis, **kwargs): self.DVCon.addCurvatureConstraint1D(start=start, end=end, nPts=nPts, axis=axis, name=name, **kwargs) comm = self.comm @@ -172,9 +170,11 @@ def nom_addCurvatureConstraint1D(self, name, start, end, nPts, axis, **kwargs): self.add_output(name, distributed=True, val=1.0) else: self.add_output(name, distributed=True, shape=0) - + def nom_addLinearConstraintsShape(self, name, indSetA, indSetB, factorA, factorB): - self.DVCon.addLinearConstraintsShape(indSetA=indSetA, indSetB=indSetB, factorA=factorA, factorB=factorB, name=name) + self.DVCon.addLinearConstraintsShape( + indSetA=indSetA, indSetB=indSetB, factorA=factorA, factorB=factorB, name=name + ) lSize = len(indSetA) comm = self.comm if comm.rank == 0: @@ -193,7 +193,7 @@ def nom_setConstraintSurface(self, surface): def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode): # only do the computations when we have more than zero entries in d_inputs in the reverse mode ni = len(list(d_inputs.keys())) - + if mode == "rev" and ni > 0: # this flag will be set to True after every compute call.