Skip to content

Conversation

@lmoresi
Copy link
Member

@lmoresi lmoresi commented Nov 18, 2025

The full release of UW3 should be at 3.0 ... when we do this, I would like to introduce some new coding patterns that are more conducive to the having and AI-bot (AI-Bat ?) give advice.

So that means there is a lot to review in here.

lmoresi and others added 30 commits August 8, 2025 20:45
Wrapper function for the access manager to improve usability
Minor deetails.
Attempting to fix up the evaluation to be internally consistent, adding the wrappers for the access manager (and calling it `array` for now).

Fix up tests to account for changes to evaluation array sizes on return (mostly squeezes)

Fix a couple of other evaluation bugs (like the need to add a zero vector to some nearly-constant matrices).

Repairing the quickstart guide here and there.
Fix for the first comment by @jcgraciosa.

Also needed to update the JIT code to understand the MATRIX variable type and removing the other types that are (currently) not used. These cause compilation errors if they are lit up by mistake (even if that variable is not in any expression).

Solvers: Navier Stokes / Advection-Diffusion - fix the projection terms and how they pack up their data.
Adding global evaluation routines to compute values anywhere in the distributed domain (also with extrapolation using rbf)
Fixing broken test (array shape)
Not setting initial rank - this has problems when the particle is located on the correct rank because it automatically, always gets migrated to rank 0 and we start hunting for it again (but always in the wrong place).
Missed one !
Nodal Point Swarm also had the issue of uninitialised rank. This causes particles on rank > 1 to be migrated to rank 0 on the first call to migrate. They then get lost ...

Potential fix @jcgraciosa but maybe not the only issue here.
Fixing lack of rank initialisation in swarm.populate.

Also: some changes to the derivative expressions code:
  - .where relevant sym returns the inner expression derived by the diff_variable inner expression in symbolic form (which is closer to the intent of .sym) and does not return the evaluated form.
  - .doit function returns the evaluated form (so this is like the sympy deferred derivative).
This code is *probably* no longer needed
And leaving NodalPointPICSwarm alone
Shortening some monster-sized files.
Imports etc should not change
…t in a more user friendly form attached to the swarm
lmoresi and others added 30 commits January 10, 2026 18:06
- Full docstrings for cylindrical coordinate methods (divergence, gradient, curl, strain_tensor)
- Full docstrings for spherical coordinate methods
- Full docstrings for 2D spherical surface methods
- Enhanced class docstrings with Parameters and Notes sections
- Fixed incorrect deprecation message in swarm.data (was incorrectly referencing swarm variable data)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- UWDerivativeExpression: Parameters, Examples, Returns
- simplify_units: Parameters, Returns
- is_constant_expr: Parameters, Returns
- extract_expressions: Parameters, Returns
- extract_expressions_and_functions: Parameters, Returns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- divergence, gradient, curl, jacobian: Vector calculus methods
- clone: Create copy with new name/symbol
- rbf_interpolate: RBF interpolation to new coordinates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Properties: mesh, data, particle_coordinates, particle_cellid, vars
- Methods: read_timestep, add_variable, advection (both classes)
- All include Parameters and Returns sections

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Module docstring added
- initialise: PyVista initialization
- mesh_to_pv_mesh: Mesh conversion
- coords_to_pv_coords, swarm_to_pv_cloud: Coordinate conversions
- meshVariable_to_pv_cloud/mesh_object: Variable visualization
- scalar_fn_to_pv_points, vector_fn_to_pv_points: Function evaluation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds brief docstrings to setter methods across solver classes:
- SNES_Projection: smoothing, uw_weighting_function
- SNES_Vector_Projection: smoothing, penalty, uw_weighting_function
- SNES_Tensor_Projection: uw_scalar_function
- SNES_AdvectionDiffusion: f, delta_t
- SNES_Diffusion: f, delta_t (with property docstrings)
- SNES_NavierStokes: delta_t, rho, f, DuDt, DFDt, constraints,
  bodyforce, saddle_preconditioner, penalty

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds brief docstrings to:
- problem_description methods (poisson, darcy, stokes, projection,
  advection-diffusion, navier_stokes)
- F0/F1/PF0 template properties for FEM assembly
- Getter properties (smoothing, penalty, uw_weighting_function,
  delta_t, div_u, strainrate, uw_scalar_function)
- SNES_Tensor_Projection.solve method

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documents that the symmetric strain rate tensor includes the 1/2 factor:
ε_ij = (1/2)(∂u_i/∂x_j + ∂u_j/∂x_i)

This clarifies the convention used, which is important since some codes
omit the 1/2 factor.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 1 of the docstring audit covering:

constitutive_models.py:
- DarcyFlowModel: s property getter/setter, K property
- TransverseIsotropicFlowModel: grad_u property with math formula
- GenericFluxModel: flux property getter/setter
- AnisotropicDiffusionModel: diffusivity getter/setter
- Various validate_parameters and setter methods

systems/ddt.py:
- Symbolic class: psi_fn getter/setter, update methods, adams_moulton_flux
- Eulerian class: all public methods with consistent docstrings
- SemiLagrangian class: update methods, bdf, adams_moulton_flux
- Lagrangian and Lagrangian_Swarm: update methods and flux approximations

swarm.py:
- SwarmVariable.rbf_interpolate method with full parameter documentation

All docstrings follow NumPy format with RST math notation where
appropriate, documenting mathematical formulas for strain rate
tensors, BDF schemes, and Adams-Moulton flux approximations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 2 docstring additions for coordinates module:

CoordinateSystem class:
- X, x, N, R, r, xR coordinate properties with brief descriptions
- rRotN, xRotN rotation matrix properties with math notation
- unit_e_0/1/2 natural basis vectors with math notation
- unit_i/j/k Cartesian basis vectors
- unit_ijk method

All properties now have one-liner docstrings clarifying their purpose
and relationship to the coordinate system geometry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…solvers)

- _function.pyx: UnderworldAppliedFunction, UnderworldAppliedFunctionDeriv,
  dm_swarm_get/set_migrate_type, fdiff methods (as SymPy protocol methods)
- ckdtree.pyx: n, ndim properties, rbf_interpolator_local method
- petsc_maths.pyx: Fixed CellWiseIntegral docstring, added evaluate docstring
- petsc_generic_snes_solvers.pyx: _Unknowns class and properties (u, DuDt,
  DFDt, E, L, W, Einv2), solver properties (u, DuDt, DFDt, constitutive_model),
  improved BC method docstrings (add_dirichlet_bc, add_natural_bc, add_essential_bc)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
IndexSwarmVariable:
- sym_1d: One-dimensional symbolic mask array property
- createMask: Create material-weighted symbolic expressions (improved)
- viewMask: Decompose masked expressions (noted as not implemented)
- visMask: Create visualization mask showing material indices

Swarm:
- clip_to_mesh: Property for particle clipping control

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
MeshVariable (discretisation_mesh_variables.py):
- .sym: Symbolic representation for equations with examples
- .array: Primary data interface with shape/unit documentation
- .data: Canonical storage explaining when to use vs .array
- .coords: DOF coordinates with unit handling explanation

SwarmVariable (swarm.py):
- .data: Canonical storage with variable transfer guidance
- .array: Primary particle data interface with examples

CoordinateSystem (coordinates.py):
- mesh.X: Comprehensive symbolic/numerical access documentation
- mesh.X.coords: Mesh vertex coordinates with examples
- mesh.X.units: Physical coordinate units

These docstrings clarify the three-domain access pattern:
- Symbolic (.sym) for equations
- Numerical (.array/.data) for data manipulation
- Coordinate (.coords) for spatial positions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- SNES_Scalar.solve(): Parameters, examples, collective operation note
- SNES_Vector.solve(): Parameters, return docs, see-also references
- SNES_Stokes_SaddlePt.solve(): Picard iteration docs, nonlinear usage examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- SNES_Scalar.tolerance: Explains auto-config of snes_rtol, ksp_rtol, ksp_atol
- SNES_Vector.tolerance: Same documentation pattern
- SNES_Stokes_SaddlePt.tolerance: Documents fieldsplit tolerances and EW adaptive
- SNES_Stokes_SaddlePt.strategy: Documents preconditioner strategy options
- SNES_Stokes_SaddlePt.PF0: Pressure constraint term (incompressibility)
- SNES_Stokes_SaddlePt.p: Pressure solution variable
- SNES_Stokes_SaddlePt.saddle_preconditioner: Custom Schur complement preconditioner

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- add_essential_bc: Scalar/vector/symbolic examples, See Also references
- add_natural_bc: Flux and traction examples, mathematical notes
- add_dirichlet_bc: Common patterns (no-slip, free-slip, lid-driven cavity)
- All methods: Case-sensitive boundary name warnings, Raises section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documents the common pattern for free-slip boundary conditions on
curved surfaces (spherical models) using penalty method with mesh.Gamma
surface normal vector.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- SNES_Scalar: Parameters, Attributes, Examples, See Also sections
- SNES_Vector: Parameters, Attributes, Examples, See Also sections
- SNES_Stokes_SaddlePt: Parameters, Attributes, Examples, See Also sections

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Enhanced docstrings for all five time history manager classes:
- Symbolic: Purely symbolic history manager for understanding BDF/AM formulas
- Eulerian: Mesh-based history for fixed-grid time-stepping
- SemiLagrangian: Nodal-swarm approach for advection-dominated problems
- Lagrangian: Full material tracking with internal swarm management
- Lagrangian_Swarm: User-provided swarm variant with step averaging

Each docstring now includes Parameters, Attributes, Notes, and See Also
sections following NumPy docstring conventions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add self.__doc__ = description to ExpressionDescriptor for Sphinx autodoc
- Add physics-aware docstrings to F0, F1, PF0 Templates in all solvers
- Fix penalty docstring: Augmented Lagrangian uses O(1) penalties, not 1e6*eta
- Add Glowinski & Le Tallec (1989) reference for Augmented Lagrangian method
- Document Sphinx + MyST + ReadTheDocs decision with sphinx-math-dollar config
- Use $...$ math syntax in docstrings (requires sphinx-math-dollar extension)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create docs/api/ with Sphinx + MyST + Furo configuration
- Add API doc pages: solvers, meshing, discretisation, coordinates, etc.
- Configure sphinx-math-dollar for $...$ math in docstrings
- Add .readthedocs.yaml for ReadTheDocs deployment
- Add pixi tasks: api-docs-build, api-docs-clean
- Add Sphinx dependencies (sphinx, furo, myst-nb) to dev environment

Build with: pixi run -e dev api-docs-build

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- .binder/Dockerfile: Uses ghcr.io/underworldcode/uw3-base:2025.01
- .binder/start: Pulls latest code and rebuilds on launch
- container/Dockerfile.base: Recipe for building the base image

The binder setup uses a pre-built pixi-based container that:
1. Contains full pixi environment with underworld3 built
2. On launch, pulls latest code from uw3-release-candidate
3. Rebuilds underworld3 (~30s) to ensure latest changes
4. Starts JupyterLab with tutorials copied to workspace

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replaced by pixi-based approach:
- container/Dockerfile.base for building base image
- .binder/Dockerfile for mybinder.org launches

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Build context is repo root, not .binder/ directory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Mock petsc4py, mpi4py, gmsh, h5py, pyvista, and Cython-compiled
underworld3 modules so ReadTheDocs can build API documentation
without requiring a full PETSc/MPI environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Base image now includes start script and ENTRYPOINT
- .binder/Dockerfile is now just a single FROM line
- No additional Docker build/push needed by mybinder.org
- Start script: pulls latest code, rebuilds, launches jupyter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add quarto intermediate files pattern to docs/.gitignore
- Update Stokes tutorial with explicit penalty variable definition
- Update docstring inventory.json with latest coverage data
- Update review_queue.md with current docstring status

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Explains the pre-built image strategy, file locations,
maintenance procedures, and troubleshooting.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. Notebook kernels: Normalize all tutorials to use 'python3' kernel
   instead of 'pixi-kernel-python3' which doesn't exist on binder

2. Visualization: Add OSMesa libraries and PYVISTA_OFF_SCREEN env var
   for headless software rendering in containers

3. DMInterpolationEvaluate_UW: Add petsc_tools.c to _dminterp_wrapper
   extension sources - fixes undefined symbol error

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove pip install of underworld3 package - we use autodoc mocking
so only Sphinx dependencies are needed, not the full package.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants