-
Notifications
You must be signed in to change notification settings - Fork 55
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 names to child DVGeos #201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave a quick pass and it looks ok to me, see my comment below. Maybe we should also add a test for activeChildren
?
@@ -752,6 +752,11 @@ def coordXfer(coords, mode="fwd", applyDisplacement=True, **kwargs): | |||
# compNames is only needed for DVGeometryMulti, so remove it if passed | |||
kwargs.pop("compNames", None) | |||
|
|||
# check if we want a custom subset of child DVGeos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an interesting addition, could you please add a short description of the arg and intended functionality in the docstrings for addPointSet
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added docstring
I changed how constraints are added when a childIdx was being provided to use the names. Only relevant example of this that I could find in my computer was in the private tutorial. Created a PR to update it for this change: https://github.com/mdolab/private-MACH-tutorial/pull/96 |
I added tests for the new capability, @marcomangano. @hajdik and @bernardopacini, I modified the MPhys wrapper accordingly. This is backwards breaking for the runscripts, though the fix needed is minimal and the current behavior is much more human readable imo. Please take a look and let me know. This PR is ready for review. |
Codecov Report
@@ Coverage Diff @@
## main #201 +/- ##
==========================================
+ Coverage 65.02% 65.04% +0.01%
==========================================
Files 47 47
Lines 12106 12112 +6
==========================================
+ Hits 7872 7878 +6
Misses 4234 4234
📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here look good to me, just a question regarding compatibility:
- How does this affect other DVGeo variants such as DVGeoMulti or DVGeoAxi? If I am not mistaken, it should be fine because they inherit this base anyways, right?
DVGeoMulti tracks multiple regular DVGeo objects, that can have child DVGeos. DVGeoMulti itself does not have child DVGeos attached, so this will work for that directly. I am not sure about DVGeoAxi. I don't even know if anyone is using it. @hajdik, you mentioned the DVGeo class has a name attribute. Should we change the approach here to rely on that name attribute? |
Yes, there is a |
@hajdik, I made the suggested change on using the name attribute. This PR is ready for another round of review |
dIdPt[5, 1, 2] = 1.0 | ||
dIdx = DVGeo.totalSensitivity(dIdPt, ptName) | ||
|
||
handler.root_add_dict(f"dIdx_{ptName}", dIdx, rtol=1e-10, atol=1e-10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the test is failing here with KeyError: 'child1_span1'
but once that's fixed I'm good with this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -908,17 +941,28 @@ def addGlobalDV(self, dvName, value, func, lower=None, upper=None, scale=1.0, co | |||
Use a string for a single configuration or a list for multiple | |||
configurations. The default value of None implies that the design | |||
variable applies to *ALL* configurations. | |||
prependName : bool | |||
Flag to determine if self.name attribute is prepended to this DV name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add something in the docstring about why this option exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@marcomangano @bernardopacini can one of you take a look at this again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay, this looks good to me! Thanks for the changes.
Purpose
This PR changes how DVGeo class tracks its children. Old implementation just appended the children to a list, which is then indexed in order. The current implementation saves the child DVGeometries in the
self.children
dictionary. The keys of the dictionary are the names of each child DVGeo. This makes the code a lot more readable since each child DVGeo is referenced by its name.The old functionality is maintained, and unless users were accessing the child DVGeometries in a hacky way by indexing the old list, everything should work fine. Some output names might be different, but we can also fix this behavior. The names of the added pointsets will be the same if users don't provide a name for the child DVGeo.
I will apply a similar set of changes to the mphys wrapper once #193 is merged.
Expected time until merged
2 weeks
Type of change
Testing
Checklist
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formattedfprettify
or C/C++ code withclang-format
as applicable