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

Add spanwise shape variables #75

Merged
merged 16 commits into from
Mar 30, 2021
31 changes: 28 additions & 3 deletions pygeo/DVConstraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def setSurface(self, surf, name='default', addToDVGeo=False, DVGeoName='default'
>>> DVCon.setSurface(surf)

"""
if name in self.surfaces.keys():
raise KeyError('Surface names must be unique. Repeated surface name: ' + str(name))
# if name in self.surfaces.keys():
# raise KeyError('Surface names must be unique. Repeated surface name: ' + str(name))
joanibal marked this conversation as resolved.
Show resolved Hide resolved

self.surfaces[name] = list()
if format == 'point-vector':
Expand All @@ -254,6 +254,7 @@ def setSurface(self, surf, name='default', addToDVGeo=False, DVGeoName='default'
elif isinstance(surf, pyGeo): # Assume it's a pyGeo surface
p0, v1, v2 = self._generateDiscreteSurface(surf)
else:
import ipdb; ipdb.set_trace()
joanibal marked this conversation as resolved.
Show resolved Hide resolved
raise TypeError('surf given is not a supported type [List, plot3D file name, or pyGeo surface]')

p1 = p0 + v1
Expand Down Expand Up @@ -4250,7 +4251,10 @@ def evalFunctions(self, funcs):
cons.extend(self.jac[key].dot(self.DVGeo.DV_listLocal[key].value))
elif key in self.DVGeo.DV_listSectionLocal:
cons.extend(self.jac[key].dot(self.DVGeo.DV_listSectionLocal[key].value))

elif key in self.DVGeo.DV_listSpanwiseLocal:
cons.extend(self.jac[key].dot(self.DVGeo.DV_listSpanwiseLocal[key].value))
else:
raise Error(f"con {self.name} diffined wrt {key}, but {key} not found in DVGeo")
funcs[self.name] = numpy.array(cons).real.astype('d')

def evalFunctionsSens(self, funcsSens):
Expand Down Expand Up @@ -4326,6 +4330,27 @@ def _finalize(self):
self.ncon += len(cons)
ewu63 marked this conversation as resolved.
Show resolved Hide resolved
self.vizConIndices[key] = cons

# Section local shape variables
for key in self.DVGeo.DV_listSpanwiseLocal:
if self.config is None or self.config in self.DVGeo.DV_listSpanwiseLocal[key].config:

# end for (indSet loop)
cons = self.DVGeo.DV_listSpanwiseLocal[key].mapIndexSets(self.indSetA,self.indSetB)
ncon = len(cons)
if ncon > 0:
# Now form the jacobian:
ndv = self.DVGeo.DV_listSpanwiseLocal[key].nVal
jacobian = numpy.zeros((ncon, ndv))
for i in range(ncon):
jacobian[i, cons[i][0]] = self.factorA[i]
jacobian[i, cons[i][1]] = self.factorB[i]
self.jac[key] = jacobian

# Add to the number of constraints and store indices which
# we need for tecplot visualization
self.ncon += len(cons)
self.vizConIndices[key] = cons

# with-respect-to are just the keys of the jacobian
self.wrt = list(self.jac.keys())

Expand Down
Loading