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
26 changes: 25 additions & 1 deletion pygeo/DVConstraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4250,7 +4250,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 +4329,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