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

Adding DVGeometryMulti to MPhys #230

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

bernardopacini
Copy link
Contributor

@bernardopacini bernardopacini commented Dec 2, 2023

Purpose

Adding DVGeometryMulti to MPhys. I added pass-through functions and modified the compute and compute_jacvec_product calls as needed.

Expected time until merged

1 week.

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 tried this on my optimization and it appears to work (local analysis and derivatives on HPC). I would appreciate others verifying this on their cases.

Checklist

  • I have run flake8 and black to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • 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

@bernardopacini bernardopacini added the enhancement New feature or request label Dec 2, 2023
@bernardopacini bernardopacini self-assigned this Dec 2, 2023
@bernardopacini bernardopacini requested a review from a team as a code owner December 2, 2023 19:30
Copy link

codecov bot commented Dec 2, 2023

Codecov Report

Attention: 72 lines in your changes are missing coverage. Please review.

Comparison is base (e47a454) 65.04% compared to head (a383525) 64.83%.

Files Patch % Lines
pygeo/mphys/mphys_dvgeo.py 0.00% 72 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #230      +/-   ##
==========================================
- Coverage   65.04%   64.83%   -0.21%     
==========================================
  Files          47       47              
  Lines       12112    12150      +38     
==========================================
  Hits         7878     7878              
- Misses       4234     4272      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bernardopacini
Copy link
Contributor Author

I didn't add the addIntersection() method to the MPhys wrapper. Let me know if you think it should be here or if it should be left as a direct reference to the underlying class.

@bernardopacini bernardopacini removed the request for review from marcomangano December 2, 2023 21:51
@bernardopacini
Copy link
Contributor Author

Additional note: when adding a global DV the input was being added twice to OpenMDAO. This bug is fixed here too.

@bernardopacini
Copy link
Contributor Author

It turns out PR #201 broke the naming convention for child FFDs by prepending the child name by default. This meant that MPhys would not connect the OM variable to the DVGeo variable because the names would not match. I fixed that in this PR by setting prependName=False for all FFD-based design variables.

Copy link
Contributor

@sseraj sseraj left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I just have a few minor comments

pygeo/mphys/mphys_dvgeo.py Show resolved Hide resolved
pygeo/mphys/mphys_dvgeo.py Outdated Show resolved Hide resolved
pygeo/mphys/mphys_dvgeo.py Show resolved Hide resolved
Copy link
Contributor

@anilyil anilyil left a comment

Choose a reason for hiding this comment

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

Most of this look good, but one big picture comment: it looks like the logical check to find the correct dvgeo is repeated in several places. Instead, I think you can reduce duplication by using "nom_getDVGeo" before each DV addition. That way you wont need to duplicate the code that finds the right DVGeo. Is this correct? If you also think this makes sense, I say go for it. If not, I am fine with merging as is.

Copy link
Contributor

@hajdik hajdik left a comment

Choose a reason for hiding this comment

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

LGTM, just a few comments

@@ -125,7 +128,21 @@ def compute(self, inputs, outputs):
# next time the jacvec product routine is called
self.update_jac = True

def nom_addChild(self, ffd_file, DVGeoName=None, childName=None):
def nom_addComponent(self, comp, ffd_file, triMesh, DVGeoName=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a docstring for this function since you added it??

return DVGeo.children[childName]

# return the top level DVGeo
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Anil on using this to cover finding the right DVGeo even with the child/component logic instead of repeating the same checks. I think I just didn't realize it could eliminate the checks for child that I put in when I redid the DV adding functions.

@bernardopacini
Copy link
Contributor Author

There is some weird behavior in the derivatives: the first check totals is fine, but a second check totals after a design perturbation makes the second function derivative wrong. This only happens when there is an intersection. I can't exclude this being an issue with DAFoam (or even IDwarp), but I do not have the bandwidth to look more into this now. Converting to a draft.

@bernardopacini bernardopacini marked this pull request as draft February 19, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants