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

Make ref axis optional when adding a child FFD #150

Merged
merged 10 commits into from
Aug 19, 2022

Conversation

joanibal
Copy link
Collaborator

@joanibal joanibal commented Aug 2, 2022

Purpose

This PR addresses some challenges @bernardopacini was having when using child FFDs with MPhys.

Expected time until merged

3 days (@bernardopacini is waiting on this)

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

I ran the tandem wing optimization tutorial problem, which has 2 child FFDs. I added a ref axis before adding one the parent and the other after. The results of the optimization are exactly the same.

Checklist

  • I have run flake8 and black to make sure the code adheres to PEP-8 and is consistently formatted
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@joanibal joanibal requested a review from a team as a code owner August 2, 2022 22:40
@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #150 (07a519d) into main (fd60570) will decrease coverage by 10.45%.
The diff coverage is 82.35%.

@@             Coverage Diff             @@
##             main     #150       +/-   ##
===========================================
- Coverage   63.72%   53.27%   -10.46%     
===========================================
  Files          47       47               
  Lines       11676    11689       +13     
===========================================
- Hits         7441     6227     -1214     
- Misses       4235     5462     +1227     
Impacted Files Coverage Δ
pygeo/parameterization/DVGeo.py 64.23% <81.25%> (-0.42%) ⬇️
pygeo/__init__.py 91.30% <100.00%> (+8.69%) ⬆️
pygeo/parameterization/DVGeoMulti.py 0.40% <0.00%> (-89.42%) ⬇️
pygeo/constraints/areaConstraint.py 50.50% <0.00%> (-25.42%) ⬇️
pygeo/constraints/DVCon.py 68.04% <0.00%> (-3.69%) ⬇️
pygeo/pyBlock.py 45.37% <0.00%> (-1.65%) ⬇️
pygeo/topology.py 54.92% <0.00%> (-0.23%) ⬇️
pygeo/parameterization/__init__.py 88.88% <0.00%> (+11.11%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@joanibal joanibal requested a review from bernardopacini August 9, 2022 13:31
Copy link
Contributor

@marcomangano marcomangano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks alright, the current scripts should not even be affected except for the "anticipated" _finalize() call I mention below.
I would still like to have the original developers feedback on this though

@@ -1685,6 +1686,15 @@ def update(self, ptSetName, childDelta=True, config=None):
# We've postponed things as long as we can...do the finalization.
self._finalize()

for iChild in range(len(self.children)):
if len(self.children[iChild].axis) > 0:
self.children[iChild]._finalize()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you mentioned, the _finalize here is needed to get the refAxis.coef (coefficient of refAxis nodes) that are then embedded in the parent control volume below.
I am wondering then:

  1. if it still makes sense to have another child._finalize() here
  2. what caused the mismatch in the previous tests - was it due to the fact that the control points themselves were not embedded or something? I am honestly a bit confused by how pyGeo currently works, maybe there are some other intermediate steps we are missing if the axis is not added rightaway

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The finalize method exists right away if it has already been called. This it is safe to repeatedly call finalize during each call of the update method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't think I know which tests you are referring to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the test failures after the first commit, but the build log is lost now.
Agreed on the multiple finalizing calls.

pygeo/parameterization/DVGeo.py Outdated Show resolved Hide resolved
moved ref axis addition after the FFD coef are set to their original values to ensure ref axis is embedded in the undeformed volume.
@joanibal joanibal requested a review from marcomangano August 18, 2022 14:33
Copy link
Contributor

@marcomangano marcomangano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix, can merge after the code is updated with main and the style errors are fixed

# Make sure coefficients are complex
self._complexifyCoef()

# Set all coef Values back to initial values
if not self.isChild:
self.FFD.coef = self.origFFDCoef.copy()
self._setInitialValues()

for iChild in range(len(self.children)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here, did not realize that the children were trying to initialize themselves again. Out of curiosity, did you have issues because of this or you just re-checked the code?

@ArshSaja
Copy link
Contributor

An optional thought; recently I realized that def nom_addRefAxis(self,comp=None, **kwargs): can be removed from mphys_dvgeo.py since it is easy to call the function from group level which is smth similar to this: self.geo.DVGeo.addRefAxis(name="wing",curve=c1,volumes=[0] )

@bernardopacini
Copy link
Contributor

An optional thought; recently I realized that def nom_addRefAxis(self,comp=None, **kwargs): can be removed from mphys_dvgeo.py since it is easy to call the function from group level which is smth similar to this: self.geo.DVGeo.addRefAxis(name="wing",curve=c1,volumes=[0] )

I agree with this point, though I think we should leave it for a separate PR and discuss it in the MPHYS meeting. Does that seem reasonable? It ultimately still needs the child FFD to be added to the parent to be able to add the axis as you are suggesting, so it would rely on Josh's fix here.

bernardopacini
bernardopacini previously approved these changes Aug 18, 2022
Copy link
Contributor

@bernardopacini bernardopacini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the formatting issues are fixed, looks good to me!

@ArshSaja
Copy link
Contributor

Agree! we can talk about it later.

ArshSaja
ArshSaja previously approved these changes Aug 18, 2022
@ewu63 ewu63 dismissed stale reviews from ArshSaja and bernardopacini via 30fb60b August 18, 2022 23:08
bernardopacini
bernardopacini previously approved these changes Aug 19, 2022
@marcomangano
Copy link
Contributor

@joanibal: @bernardopacini and I just discussed about this PR and figured that this is probably not the best approach to address the MPhys issues. The fix in #144 already makes sense and covers MPhys problems.
The fix in this PR is alright but 1) we are adding a limitation on the number of children levels you can add (not the best practice, but I think now we can have grandchildren, grand-grandchildren and so on) and 2) I feel that instead of adding and additional patch, we should sit down, understand the full workflow, and possibly refactor the FFD initialization and update sequence.

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

@bernardopacini bernardopacini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the added error message, this looks good to me.

@ArshSaja ArshSaja merged commit 8453c44 into mdolab:main Aug 19, 2022
@bernardopacini bernardopacini mentioned this pull request Aug 19, 2022
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants