Skip to content

Commit 7dc50d4

Browse files
committed
Fix _check_expression_meshes: check parameters, not flux property
The flux property triggers tensor contraction (sympy.tensorcontraction) which fails for scalar diffusion models where the C-tensor shape is incompatible before full solver setup. Check constitutive model parameter expressions instead — these are always safe to inspect. Underworld development team with AI support from Claude Code (https://claude.com/claude-code)
1 parent f8e3bef commit 7dc50d4

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/underworld3/cython/petsc_generic_snes_solvers.pyx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,19 @@ class SolverBaseClass(uw_object):
8282

8383
if hasattr(self, '_constitutive_model') and self._constitutive_model is not None:
8484
cm = self._constitutive_model
85-
if hasattr(cm, 'flux') and cm.flux is not None and hasattr(cm.flux, 'atoms'):
86-
exprs.append(cm.flux)
85+
# Check parameter expressions rather than cm.flux — the flux
86+
# property triggers tensor contraction which can fail for
87+
# some model/solver combinations before setup is complete.
88+
if hasattr(cm, 'Parameters'):
89+
for attr_name in dir(cm.Parameters):
90+
if attr_name.startswith('_'):
91+
continue
92+
try:
93+
val = getattr(cm.Parameters, attr_name)
94+
if hasattr(val, 'atoms'):
95+
exprs.append(val)
96+
except (AttributeError, TypeError):
97+
pass
8798

8899
# Extract all meshes from all expressions
89100
foreign_meshes = set()

0 commit comments

Comments
 (0)