Skip to content

Conversation

A-CGray
Copy link
Member

@A-CGray A-CGray commented Oct 6, 2025

Purpose

1: Addresses #273

2: Improvements to nom_addPointSet

  1. Add argument allowing users to control whether output points are distributed
  2. Remove unnecessary if statement
  3. Change call to reshape so that it works whether supplied points are flattened or (N,3) array

3: Add helpful error message if nom_getDVGeo is called before setup

The DVGeo instances associated with an instance of OM_DVGEOCOMP are only created when setup is called. Because OpenMDAO calls setup starting from top level groups and works down, calling nom_getDVGeo (or another method that calls it such as nom_addPointSet) in the setup method of an OpenMDAO group that contains an OM_DVGEOCOMP will cause an error. However, the error message that currently gets raised when you do this doesn't make this obvious:

Traceback (most recent call last):
  File "/home/ali/repos/AerostructuralOptBenchmark/runscripts/aeroStructRun-MultipointParallel.py", line 855, in <module>
    flightPointProb.setup(force_alloc_complex=isComplex, mode="rev")
  File "/home/ali/.pyenv/versions/MACH312/lib/python3.12/site-packages/openmdao/core/problem.py", line 1164, in setup
    model._setup(model_comm, self._metadata)
  File "/home/ali/.pyenv/versions/MACH312/lib/python3.12/site-packages/openmdao/core/group.py", line 830, in _setup
    self._setup_procs(self.pathname, comm, prob_meta)
  File "/home/ali/.pyenv/versions/MACH312/lib/python3.12/site-packages/openmdao/core/group.py", line 645, in _setup_procs
    self.setup()
  File "/home/ali/repos/AerostructuralOptBenchmark/runscripts/aeroStructRun-MultipointParallel.py", line 566, in setup
    geometryComp.nom_addPointSet(wimpressCalc.getCoords(packed=True), ptName=wimpressCoordName)
  File "/home/ali/repos/pygeo/pygeo/mphys/mphys_dvgeo.py", line 230, in nom_addPointSet
    DVGeo = self.nom_getDVGeo(DVGeoName=DVGeoName)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ali/repos/pygeo/pygeo/mphys/mphys_dvgeo.py", line 273, in nom_getDVGeo
    if self.multDVGeo:
       ^^^^^^^^^^^^^^
AttributeError: 'OM_DVGEOCOMP' object has no attribute 'multDVGeo'

This PR adds a helpful error that is raised in these cases that recommends users move their function call to the configure method, where nom_getDVGeo will work:

Traceback (most recent call last):
  File "/home/ali/repos/AerostructuralOptBenchmark/runscripts/aeroStructRun-MultipointParallel.py", line 856, in <module>
    flightPointProb.setup(force_alloc_complex=isComplex, mode="rev")
  File "/home/ali/.pyenv/versions/MACH312/lib/python3.12/site-packages/openmdao/core/problem.py", line 1164, in setup
    model._setup(model_comm, self._metadata)
  File "/home/ali/.pyenv/versions/MACH312/lib/python3.12/site-packages/openmdao/core/group.py", line 830, in _setup
    self._setup_procs(self.pathname, comm, prob_meta)
  File "/home/ali/.pyenv/versions/MACH312/lib/python3.12/site-packages/openmdao/core/group.py", line 645, in _setup_procs
    self.setup()
  File "/home/ali/repos/AerostructuralOptBenchmark/runscripts/aeroStructRun-MultipointParallel.py", line 568, in setup
    geometryComp.nom_addPointSet(wimpressCalc.getCoords(packed=True), ptName=wimpressCoordName)
  File "/home/ali/repos/pygeo/pygeo/mphys/mphys_dvgeo.py", line 230, in nom_addPointSet
    DVGeo = self.nom_getDVGeo(DVGeoName=DVGeoName)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ali/repos/pygeo/pygeo/mphys/mphys_dvgeo.py", line 274, in nom_getDVGeo
    raise RuntimeError(
RuntimeError: Cannot call `nom_getDVGeo` before OM_DVGEOCOMP's `setup` method has been called. If you are calling this function in the `setup` method of a group containing an OM_DVGEOCOMP, move the call to `configure` instead.

Expected time until merged

Soon

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

Checklist

  • I have run ruff check and ruff format 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

@A-CGray A-CGray requested a review from a team as a code owner October 6, 2025 22:16
@A-CGray A-CGray requested review from hajdik and sabakhshi October 6, 2025 22:16
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.10%. Comparing base (ee331a6) to head (01cfee5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #279   +/-   ##
=======================================
  Coverage   67.10%   67.10%           
=======================================
  Files          48       48           
  Lines       12378    12378           
=======================================
  Hits         8306     8306           
  Misses       4072     4072           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@A-CGray A-CGray changed the title Add helpful error message if nom_getDVGeo is called before setup MPhys wrapper improvements Oct 6, 2025
A-CGray added a commit that referenced this pull request Oct 10, 2025
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.

OM_DVGEOCOMP's update_jac may not be defined on hot start

1 participant