Skip to content

Commit

Permalink
Make ref axis optional when adding a child FFD (#150)
Browse files Browse the repository at this point in the history
* added ref axis checks

* fixed refinalizing of child ref axis

* Update DVGeo.py

moved ref axis addition after the FFD coef are set to their original values to ensure ref axis is embedded in the undeformed volume.

* black format

* version bump

* added error message

added error message for adding ref axis to grand children after the child is added to the parent

* Fixing formatting

Co-authored-by: Neil Wu <[email protected]>
Co-authored-by: Bernardo Pacini <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2022
1 parent fd60570 commit 8453c44
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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.12.0"
__version__ = "1.12.1"

from .pyNetwork import pyNetwork
from .pyGeo import pyGeo
Expand Down
23 changes: 20 additions & 3 deletions pygeo/parameterization/DVGeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,10 @@ def addChild(self, childDVGeo):

# We must finalize the Child here since we need the ref axis
# coefficients
childDVGeo._finalizeAxis()
self.FFD.attachPoints(childDVGeo.refAxis.coef, "child%d_axis" % (iChild))
self.FFD.calcdPtdCoef("child%d_axis" % (iChild))
if len(childDVGeo.axis) > 0:
childDVGeo._finalizeAxis()
self.FFD.attachPoints(childDVGeo.refAxis.coef, "child%d_axis" % (iChild))
self.FFD.calcdPtdCoef("child%d_axis" % (iChild))

# Add the child to the parent and return
self.children.append(childDVGeo)
Expand Down Expand Up @@ -1692,7 +1693,23 @@ def update(self, ptSetName, childDelta=True, config=None):
if not self.isChild:
self.FFD.coef = self.origFFDCoef.copy()
self._setInitialValues()

for iChild in range(len(self.children)):
if len(self.children[iChild].axis) > 0:
self.children[iChild]._finalize()
refaxis_ptSetName = "child%d_axis" % (iChild)
if refaxis_ptSetName not in self.FFD.embeddedVolumes:
self.FFD.attachPoints(self.children[iChild].refAxis.coef, refaxis_ptSetName)
self.FFD.calcdPtdCoef("child%d_axis" % (iChild))
else:
for iChild in range(len(self.children)):
if len(self.children[iChild].axis) > 0:
refaxis_ptSetName = "child%d_axis" % (iChild)
if refaxis_ptSetName not in self.FFD.embeddedVolumes:
raise Error(
f"refaxis {refaxis_ptSetName} cannot be added to child FFD after child is appended to parent"
)

# Update all coef
self.FFD._updateVolumeCoef()

Expand Down

0 comments on commit 8453c44

Please sign in to comment.