Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewellis55 committed Feb 24, 2024
1 parent 6b42683 commit 1930c18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openmdao/core/explicitcomponent.py
Expand Up @@ -68,7 +68,7 @@ def _configure(self):
"""
new_jacvec_prod = getattr(self, 'compute_jacvec_product', None)

if self.matrix_free is _UNDEFINED:
if self.matrix_free == _UNDEFINED:
self.matrix_free = overrides_method('compute_jacvec_product', self, ExplicitComponent)

if self.matrix_free:
Expand Down
2 changes: 1 addition & 1 deletion openmdao/core/implicitcomponent.py
Expand Up @@ -76,7 +76,7 @@ def _configure(self):
if self._has_solve_nl is _UNDEFINED:
self._has_solve_nl = overrides_method('solve_nonlinear', self, ImplicitComponent)

if self.matrix_free is _UNDEFINED:
if self.matrix_free == _UNDEFINED:
self.matrix_free = overrides_method('apply_linear', self, ImplicitComponent)

if self.matrix_free:
Expand Down
9 changes: 9 additions & 0 deletions openmdao/solvers/solver.py
Expand Up @@ -217,8 +217,12 @@ def msginfo(self):
str
Info to prepend to messages.
"""
# Default initialization
if self._system is None:
return type(self).__name__
# Following Dead Weakref
elif self._system() is None:
return type(self).__name__
return f"{type(self).__name__} in {self._system().msginfo}"

def _inf_nan_failure(self):
Expand Down Expand Up @@ -307,8 +311,13 @@ def _setup_solvers(self, system, depth):
depth : int
depth of the current system (already incremented).
"""
# Default initialization
if self._system is None:
self._system = weakref.ref(system)
# Following Dead Weakref
elif self._system() is None:
self._system = weakref.ref(system)
# Assignment Mismatch
elif self._system != weakref.ref(system):
raise RuntimeError(f"{type(self).__name__} has already been assigned to "
f"{self._system().msginfo} and cannot also be assigned to "
Expand Down

0 comments on commit 1930c18

Please sign in to comment.