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

Fixed bug for composite DV #129

Merged
merged 6 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pygeo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.10.0"
__version__ = "1.10.1"

from .pyNetwork import pyNetwork
from .pyGeo import pyGeo
Expand Down
16 changes: 13 additions & 3 deletions pygeo/parameterization/DVGeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,6 @@ def addCompositeDV(self, dvName, ptSetName=None, u=None, scale=None):
The scaling applied to this DV, by default None
"""
NDV = self.getNDV()
self.useComposite = True
if self.name is not None:
dvName = f"{self.name}_{dvName}"
if u is not None:
Expand All @@ -1276,7 +1275,13 @@ def addCompositeDV(self, dvName, ptSetName=None, u=None, scale=None):
# normalize the scaling
scale = scale * (NDV / np.sum(scale))

self.DVComposite = geoDVComposite(dvName, NDV, u, scale=scale, s=s)
# map the initial design variable values
# we do this manually instead of calling self.mapVecToComp
# because self.DVComposite.u isn't available yet
values = u.T @ self.convertDictToSensitivity(self.getValues())

self.DVComposite = geoDVComposite(dvName, values, NDV, u, scale=scale, s=s)
self.useComposite = True

def addGeoDVSectionLocal(self, *args, **kwargs):
warnings.warn("addGeoDVSectionLocal will be deprecated, use addLocalSectionDV instead")
Expand Down Expand Up @@ -1461,7 +1466,7 @@ def getValues(self):
"""
Generic routine to return the current set of design
variables. Values are returned in a dictionary format
that would be suitable for a subsequent call to setValues()
that would be suitable for a subsequent call to :func:`setDesignVars`

Returns
-------
Expand Down Expand Up @@ -1495,6 +1500,11 @@ def getValues(self):
if self.useComposite:
dvDict = self.mapXDictToComp(dvDict)

# cast DVs to real if we are in real mode
if not self.complex:
for key, val in dvDict.items():
dvDict[key] = val.real

return dvDict

def extractCoef(self, axisID):
Expand Down
4 changes: 2 additions & 2 deletions pygeo/parameterization/designVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ def mapIndexSets(self, indSetA, indSetB):


class geoDVComposite(object):
def __init__(self, dvName, nVal, u, scale=1.0, s=None):
def __init__(self, dvName, value, nVal, u, scale=1.0, s=None):
"""
Create a set of design variables which are linear combinations of existing design variables.
"""
self.name = dvName
self.nVal = nVal
self.value = np.zeros(self.nVal, "D")
self.value = value
self.lower = None
self.upper = None
self.scale = convertTo1D(scale, self.nVal)
Expand Down