mdolab / pygeo

pyGeo provides geometric design variables and constraints suitable for gradient-based optimization.
https://mdolab-pygeo.readthedocs-hosted.com/en/latest/?badge=latest
Apache License 2.0
122 stars 54 forks source link

Adding DVGeometryMulti to MPhys #230

Closed bernardopacini closed 4 weeks ago

bernardopacini commented 8 months ago

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

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

codecov[bot] commented 8 months ago

Codecov Report

Attention: Patch coverage is 0% with 38 lines in your changes missing coverage. Please review.

Project coverage is 65.35%. Comparing base (3404b51) to head (216832e).

Files Patch % Lines
pygeo/mphys/mphys_dvgeo.py 0.00% 38 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #230 +/- ## ========================================== - Coverage 65.47% 65.35% -0.12% ========================================== Files 47 47 Lines 12265 12286 +21 ========================================== Hits 8030 8030 - Misses 4235 4256 +21 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bernardopacini commented 8 months ago

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 commented 8 months ago

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

bernardopacini commented 8 months ago

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.

bernardopacini commented 6 months ago

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 commented 1 month ago

This is good to go. The issues with derivatives are coming from other code components, not DVGeo, and they are not unique to this PR. We should merge this in so it does not go stale again.

bernardopacini commented 4 weeks ago

Looks good overall. Is there a corresponding addIntersection call? If not, how are you handling it?

Instead of having a pass-through call in MPhys, I just call the DVGeo method directly. For example:

DVGeo = self.geometry.nom_getDVGeo()
self.geometry.nom_addComponent("hub", "FFD/hubFFD.xyz", triMesh="hubTri.cgns")
self.geometry.nom_addComponent("blade", "FFD/bladeFFD.xyz", triMesh="bladeTri.cgns")
DVGeo.addIntersection(
    "hub",
    "blade",
    dStarA=1.0,
    dStarB=0.05,
    featureCurves=featureCurves,
    project=True,
    includeCurves=True,
    curveEpsDict=curveEpsDict,
    anisotropy=[1.0, 1.0, 0.75],
    slidingCurves=slidingCurves,
    trackSurfaces=trackSurfaces,
)

Is this fine with you?

anilyil commented 4 weeks ago

Yeah this is fine I guess. The add intersection call itself does not modify openmdao i/o so thats ok