-
Notifications
You must be signed in to change notification settings - Fork 52
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
Embedding tolerance update #116
Conversation
Codecov Report
@@ Coverage Diff @@
## master #116 +/- ##
==========================================
- Coverage 63.86% 63.86% -0.01%
==========================================
Files 41 41
Lines 10932 10931 -1
==========================================
- Hits 6982 6981 -1
Misses 3950 3950
Continue to review full report at Codecov.
|
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 fine to me, but I'll leave the approvals to others because I was involved in making the changes
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.
Minor comments, let me know if this is unclear.
pygeo/pyBlock.py
Outdated
nIter = kwargs.get("nIter", 100) | ||
eps = kwargs.get("eps", 1e-12) |
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.
Dont see the need to expand these here, as they are not used/needed in this function (see the comment below).
Also, this is creating "artificial" defaults for the following function, instead of using the func default.
pygeo/pyBlock.py
Outdated
volID, u, v, w, D = self.projectPoints( | ||
coordinates, eps=eps, checkErrors=True, nIter=nIter, embTol=embTol | ||
) | ||
self.embeddedVolumes[ptSetName] = EmbeddedVolume(volID, u, v, w) | ||
else: | ||
volID, u, v, w, D = self.projectPoints(coordinates, checkErrors=False, eps=eps, nIter=nIter) | ||
volID, u, v, w, D = self.projectPoints( | ||
coordinates, eps=eps, checkErrors=False, nIter=nIter, embTol=embTol | ||
) |
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.
Since this function already takes in **kwargs
(and keywords are not changed and passed to next func) why not just pass it on as **kwargs
here instead of expanding and passing explicitly nIter
and eps
?
pygeo/parameterization/DVGeo.py
Outdated
@@ -600,6 +613,8 @@ def addPointSet(self, points, ptName, origConfig=True, **kwargs): | |||
|
|||
""" | |||
|
|||
embTol = kwargs.get("embTol", 1e-10) # see pyBlock.attachPoints() documentation |
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.
Dont think this is needed here as its not used (see comment below for pyBlock on kwargs
)
pygeo/parameterization/DVGeo.py
Outdated
self.FFD.attachPoints(self.points[ptName], ptName, interiorOnly=True, embTol=embTol, **kwargs) | ||
else: | ||
self.FFD.attachPoints(self.points[ptName], ptName, interiorOnly=False) | ||
self.FFD.attachPoints(self.points[ptName], ptName, interiorOnly=False, embTol=embTol, **kwargs) |
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.
Same here. See other comments on kwargs
@eirikurj : We were waiting for a feedback on that! @sseraj and I spent some time discussing about it, and the final criteria we picked was to have the docstring for the argument (which then must be passed explicitly into the function) where the argument is actually used. As Hope this is clear, if you still prefer to move all the expansions down to one level we can do it. |
@marcomangano I agree that the appropriate docstrings should be where the function parameters are defined/given, and thats all fine. |
@marcomangano I pushed what we discussed offline, here are the two branches that have the changes/suggestions that we talked about. Would be good to have some discussion.
|
Thanks for putting this together!!! From my point of view option 1 is better - and we can add a warning/check on |
* Properly passing kwargs * More fixes * Remove removed variable in tests Co-authored-by: Eirikur Jonsson <eirikurj@umich.edu>
@eirikurj check the second-to-last commit, if we remove |
@marcomangano I dont think you can remove the |
@eirikurj After some discussion, we decided to go for an approach closer to your Suggestion 2. Following a suggestion from @nwu63, I removed all keyword arguments from @marcomangano This should also catch unused kwargs. Popping |
@@ -600,6 +613,9 @@ def addPointSet(self, points, ptName, origConfig=True, **kwargs): | |||
|
|||
""" | |||
|
|||
# compNames is only needed for DVGeometryMulti, so remove it if passed | |||
kwargs.pop("compNames", None) |
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.
Just a minor concern. DVGeoMulti has more arguments than just compNames
, like applyIC
and comm
. While no constraints that are calling addPointSet
are including these parameters at the moment, they may. Should we pop them here? If not, the following call to attachPoints
will fail. To avoid that, you are basically back to my Suggestion 2. Not sure if this is a concern. @sseraj you may have more insights into if that is possibly needed for the constraints when using DVGeoMulti.
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 am fine with popping all the unnecessary kwargs
here
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 don't anticipate adding the other kwargs like comm
and applyIC
to the constraints. If we do end up adding them in the future, we can also pop them. I would like to keep this list to a minimum though just so we catch any potential errors.
@joanibal could you take a look at this? |
Sure, sorry I didn't know who was responsible for this review |
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.
One small request
pygeo/pyBlock.py
Outdated
|
||
# Project Points, if some were actually passed in: | ||
if coordinates is not None: | ||
if not interiorOnly: | ||
volID, u, v, w, D = self.projectPoints(coordinates, checkErrors=True, eps=eps, nIter=nIter) | ||
volID, u, v, w, D = self.projectPoints(coordinates, True, embTol, eps, nIter) |
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 we get the CheckErrors=True back the in the function call, otherwise one has to look at projectPoints
to see what the True
is doing.
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.
We had quite a long discussion about removing kwargs there, I would rather add a local var checkErrors : bool
in this function and pass that instead of the bare True
of False
- would it work?
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 like the idea of adding a checkErrors
local variable. My proposal would be to do checkErrors = not interiorOnly
and move the projectPoints
calls outside the if not interiorOnly
block.
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.
on it
self.embeddedVolumes[ptSetName] = EmbeddedVolume(volID, u, v, w) | ||
else: | ||
volID, u, v, w, D = self.projectPoints(coordinates, checkErrors=False, eps=eps, nIter=nIter) |
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.
same as above
@@ -823,7 +818,7 @@ def attachPoints(self, coordinates, ptSetName, interiorOnly=False, faceFreeze=No | |||
# Geometric Functions | |||
# ---------------------------------------------------------------------- | |||
|
|||
def projectPoints(self, x0, eps=1e-12, checkErrors=True, nIter=100): | |||
def projectPoints(self, x0, checkErrors, embTol, eps, nIter): |
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.
See earlier comments about keeping checkErrors a key word arg
@eirikurj @sseraj @joanibal check out the updated function and let me know if this is clearer and cleaner. I now just wonder... should we add some kind of message at least, if we call |
There are some scenarios where we have empty point sets (like in parallel when some procs have points and others don't). I think this is fine as is because |
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.
@marcomangano I think you can merge this. The last change was fairly minor.
Purpose
The arbitrary tolerance currently set to determine if a point is embedded when interiorOnly is True (children FFDs most commonly use this option) was creating issues in some of my cases, leaving some points stationary as the rest of the mesh/geometry object is deformed:
This PR addressed this issue doing two things:
embTol
to1e-10
instead ofeps * 50
(witheps
being the tolerance for the Newton search in the projection subroutine in pySpline) and decouples it fromeps
;embTol
as an argument for easier tuning of the mesh deformation properties.Note that, as
attachPoints
is called from addPointSet, which is in turn usually called from other solvers methods (see how it's done in ADflow), other sibling PRs should be opened to propagate the new option to the user level.Co-authored with @sseraj
Type of change
Testing
Checklist
flake8
andblack
to make sure the code adheres to PEP-8 and is consistently formatted