Skip to content

Fix runtime errors in intermediate utility examples - #1171

Open
ss2098 wants to merge 1 commit into
underworldcode:developmentfrom
ss2098:fix/intermediate-utility-examples
Open

ss2098 wants to merge 1 commit into
underworldcode:developmentfrom
ss2098:fix/intermediate-utility-examples

Conversation

@ss2098

@ss2098 ss2098 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix runtime failures in three intermediate Underworld3 utility examples.

These failures were reproduced using the existing Pixi environment with Python 3.12 and PETSc 3.25.3. The corrections preserve the intended demonstrations without modifying the Underworld3 numerical implementation.

Changes

Ex_Projection_Function_Eval.py

Correct the assignment of evaluated scalar and vector fields.

The function evaluator returns arrays with singleton dimensions, whereas individual swarm-variable components expect one-dimensional arrays.

Flatten the evaluated results before assignment.

Ex_Gradient_Methods_Comparison.py

Remove explicit MPI finalization.

Calling MPI.Finalize() manually caused an MPI operation after finalization during interpreter shutdown, terminating the process with a nonzero exit status.

The example completed successfully when MPI finalization was left to mpi4py.

Ex_BCs_from_meshVariables.py

Repair the annular Poisson demonstration.

The original code generated annular geometry but constructed a solid disk for the UW3 solver. It also used outdated boundary-condition arguments and incompatible array shapes.

The corrected example:

  • Uses an annulus with inner radius 0.1 and outer radius 1.0.
  • Applies boundary conditions to Upper and Lower.
  • Uses quadrature degree 6 with a degree-3 solution field.
  • Updates the diffusion coefficient through the constitutive model.
  • Corrects boundary-value array shapes.
  • Uses supported vector-form boundary conditions.
  • Corrects a mesh-variable name in the visualization section.
  • Adds a finite, nonconstant solution check.

A standalone annular Poisson test previously completed successfully with 4,239 solution degrees of freedom and a finite solution ranging from -1 to approximately 1.

Validation

The complete corrected examples were executed separately using the existing Pixi Python installation.

The PR creation command requires all three examples to complete successfully before committing and opening this PR.

Python syntax validation and Git whitespace checks were also performed.

Scope and limitations

Only three verified intermediate example corrections are included.

Other intermediate scripts were also audited. Several visualization examples depend on simulation checkpoints stored outside the repository. Other examples involve older swarm, checkpoint, or internal solver APIs that require separate validation.

These unrelated issues are deliberately excluded rather than changing their scientific behavior or substituting artificial checkpoint data.

No PETSc, MPI, solver-core, or packaging implementation is changed.

@ss2098
ss2098 requested a review from lmoresi as a code owner November 13, 2026 23:10

This branch has not been deployed

No deployments
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.

1 participant