Skip to content

Commit 1c84710

Browse files
authored
Merge pull request #66 from underworldcode/fix/sphinx-doc-warnings
Fix all Sphinx doc build warnings
2 parents ac63024 + c585c0a commit 1c84710

File tree

12 files changed

+66
-310
lines changed

12 files changed

+66
-310
lines changed

docs/beginner/parameters.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,35 @@ python script.py -uw_resolution 0.025 -uw_solver superlu_dist
5050
mpirun -np 4 python script.py -uw_resolution 0.01
5151
```
5252

53+
### Why Single-Dash Options?
54+
55+
Underworld uses **PETSc-style** command-line options, not Python's standard `argparse`
56+
conventions. The key differences:
57+
58+
| Convention | Long option | Short option | Word separator |
59+
|------------|-------------|--------------|----------------|
60+
| **PETSc** (Underworld) | `-uw_resolution` || underscore `_` |
61+
| **argparse** (Python) | `--resolution` | `-r` | hyphen `-` |
62+
63+
Underworld inherits PETSc's options database, which uses a **single dash** followed
64+
by a descriptive name with **underscores**. This is by design:
65+
66+
- PETSc solver options (e.g., `-ksp_type gmres`, `-pc_type lu`) use this format
67+
- Underworld user parameters share the same options database
68+
- The `uw_` prefix prevents collisions with PETSc's own options
69+
70+
This means standard Python option parsers (argparse, click) do **not** support this
71+
style of options by default and may require custom handling if you try to parse
72+
`-uw_*` flags yourself. Use `uw.Params` instead — it reads from PETSc's options
73+
database automatically.
74+
75+
```{tip}
76+
If you're writing a wrapper script that also needs argparse-style options,
77+
parse those with argparse first (for example using `parse_known_args`),
78+
then pass only the remaining/unparsed arguments to PETSc via
79+
`petsc4py.init(remaining_argv)` before importing underworld.
80+
```
81+
5382
### Notebook Override
5483

5584
```python

docs/beginner/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Or using the `./uw` wrapper for local parallel runs:
4545
./uw mpirun -np 4 python3 Modelling_Script.py
4646
```
4747

48-
The main difference between notebook development and HPC is interactivity—particularly sending parameters at launch time. We use PETSc's command line parsing so notebooks can ingest runtime parameters when run as scripts.
48+
The main difference between notebook development and HPC is interactivity—particularly sending parameters at launch time. We use PETSc's command line parsing (single-dash options like `-uw_resolution`) so notebooks can ingest runtime parameters when run as scripts. See the [Parameters Guide](parameters.md) for details on the CLI convention.
4949

5050
#### Parallel scaling / performance
5151

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@
188188
'developer/ai-notes/**',
189189
# Skip examples (not needed for main docs)
190190
'examples/**',
191+
# Skip myst_nb execution artifacts (regenerated each build)
192+
'jupyter_execute/**',
191193
]
192194

193195
# =============================================================================

src/underworld3/constitutive_models.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -620,18 +620,6 @@ class ViscousFlowModel(Constitutive_Model):
620620
material_name : str, optional
621621
Name identifier for this material (used in multi-material setups).
622622
623-
Attributes
624-
----------
625-
Parameters : _Parameters
626-
Material parameters container. Set ``Parameters.shear_viscosity_0``
627-
to define the viscosity.
628-
flux : sympy.Matrix
629-
The computed deviatoric stress tensor :math:`\boldsymbol{\tau}`.
630-
C : sympy.Matrix
631-
Mandel form of the constitutive tensor :math:`\eta_{IJ}`.
632-
c : sympy.Array
633-
Rank-4 tensor form :math:`\eta_{ijkl}`.
634-
635623
Examples
636624
--------
637625
>>> import underworld3 as uw
@@ -856,17 +844,6 @@ class ViscoPlasticFlowModel(ViscousFlowModel):
856844
material_name : str, optional
857845
Name identifier for this material.
858846
859-
Attributes
860-
----------
861-
Parameters : _Parameters
862-
Material parameters including:
863-
864-
- ``shear_viscosity_0``: Background viscosity :math:`\eta_0`
865-
- ``yield_stress``: Yield stress :math:`\tau_y`
866-
867-
viscosity : UWexpression
868-
The effective (possibly yielded) viscosity.
869-
870847
Notes
871848
-----
872849
If yield stress is not defined, this model behaves identically to
@@ -1659,18 +1636,6 @@ class DiffusionModel(Constitutive_Model):
16591636
material_name : str, optional
16601637
Name identifier for this material.
16611638
1662-
Attributes
1663-
----------
1664-
Parameters : _Parameters
1665-
Material parameters container. Set ``Parameters.diffusivity``
1666-
to define :math:`\kappa`.
1667-
flux : sympy.Matrix
1668-
The computed diffusive flux vector.
1669-
diffusivity : UWexpression
1670-
Shortcut to ``Parameters.diffusivity``.
1671-
K : UWexpression
1672-
Alias for ``diffusivity``.
1673-
16741639
Examples
16751640
--------
16761641
>>> diffusion = uw.constitutive_models.DiffusionModel(poisson.Unknowns)
@@ -1928,19 +1893,6 @@ class DarcyFlowModel(Constitutive_Model):
19281893
material_name : str, optional
19291894
Name identifier for this material.
19301895
1931-
Attributes
1932-
----------
1933-
Parameters : _Parameters
1934-
Material parameters container:
1935-
1936-
- ``permeability``: Intrinsic permeability :math:`\kappa` [m²]
1937-
- ``s``: Body force vector (e.g., gravity term)
1938-
1939-
flux : sympy.Matrix
1940-
The computed Darcy flux vector.
1941-
permeability : UWexpression
1942-
Shortcut to ``Parameters.permeability``.
1943-
19441896
Examples
19451897
--------
19461898
>>> darcy = uw.constitutive_models.DarcyFlowModel(solver.Unknowns)

src/underworld3/coordinates.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -305,22 +305,6 @@ class CoordinateSystemType(Enum):
305305
system type determines how vector calculus operators (gradient, divergence,
306306
curl) are computed.
307307
308-
Attributes
309-
----------
310-
CARTESIAN : int
311-
Standard Cartesian coordinates (x, y, z).
312-
CYLINDRICAL2D : int
313-
2D cylindrical/polar coordinates (r, theta).
314-
POLAR : int
315-
Alias for CYLINDRICAL2D.
316-
CYLINDRICAL3D : int
317-
3D cylindrical coordinates (r, theta, z).
318-
SPHERICAL : int
319-
Spherical coordinates (r, theta, phi).
320-
GEOGRAPHIC : int
321-
Ellipsoidal geographic coordinates (lon, lat, depth) for
322-
Earth and planetary modeling.
323-
324308
See Also
325309
--------
326310
underworld3.maths.vector_calculus : Operators for each coordinate system.
@@ -500,17 +484,6 @@ class GeographicCoordinateAccessor:
500484
Access via ``mesh.X.geo`` on GEOGRAPHIC meshes. Use ``.view()`` for a
501485
complete summary of available properties and methods.
502486
503-
Attributes
504-
----------
505-
lon : ndarray
506-
Longitude in degrees East (-180 to 180)
507-
lat : ndarray
508-
Geodetic latitude in degrees North (-90 to 90)
509-
depth : ndarray
510-
Depth below ellipsoid surface in km (positive downward)
511-
coords : ndarray
512-
Combined (N, 3) array: [lon, lat, depth]
513-
514487
Examples
515488
--------
516489
>>> geo = mesh.X.geo
@@ -953,19 +926,6 @@ class SphericalCoordinateAccessor:
953926
Access via ``mesh.X.spherical`` on SPHERICAL or CYLINDRICAL2D meshes.
954927
Use ``.view()`` for a complete summary of available properties and methods.
955928
956-
Attributes
957-
----------
958-
r : ndarray
959-
Radial distance from origin
960-
theta : ndarray
961-
Angle in radians:
962-
- 3D: Colatitude (0 at north pole, π at south pole)
963-
- 2D: Polar angle from x-axis (standard θ)
964-
phi : ndarray (3D only)
965-
Longitude/azimuth in radians (-π to π). Not available for 2D meshes.
966-
coords : ndarray
967-
Combined array: [r, θ, φ] for 3D, [r, θ] for 2D
968-
969929
Examples
970930
--------
971931
>>> sph = mesh.X.spherical

src/underworld3/discretisation/discretisation_mesh.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,6 @@ class Mesh(Stateful, uw_object):
176176
verbose : bool, optional
177177
Print mesh construction information.
178178
179-
Attributes
180-
----------
181-
N : sympy.vector.CoordSys3D
182-
SymPy coordinate system for symbolic expressions.
183-
X : UWCoordinate tuple
184-
Coordinate variables (x, y, z) for use in expressions.
185-
dim : int
186-
Spatial dimension of the mesh.
187-
dm : PETSc.DMPlex
188-
Underlying PETSc distributed mesh object.
189-
190179
Examples
191180
--------
192181
Meshes are typically created via the meshing module::

src/underworld3/meshing/faults.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ def __init__(self, name: str, points: np.ndarray = None):
9797
"""Create a fault surface.
9898
9999
Args:
100-
name: Identifier for this fault segment
101-
points: (N, 3) array of 3D points defining the fault surface.
102-
If None, the fault is empty and must be loaded or
103-
have points added later.
100+
name: Identifier for this fault segment.
101+
points: (N, 3) array of 3D points, or None for an empty fault.
104102
"""
105103
self.name = name
106104
self._points = None

src/underworld3/meshing/surfaces.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,7 @@ def discretize(self, offset: float = 0.01, n_segments: int = None) -> None:
890890
891891
Args:
892892
offset: (3D only) Height offset for delaunay_2d (controls curvature tolerance).
893-
n_segments: (2D only) Number of line segments. If None, uses number
894-
of control points minus 1.
893+
n_segments: (2D only) Number of line segments, or None for auto.
895894
896895
Raises:
897896
ImportError: If pyvista not available

src/underworld3/swarm.py

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ class SwarmVariable(DimensionalityMixin, MathematicalMixin, Stateful, uw_object)
112112
Physical units for this variable (e.g., 'kelvin', 'Pa').
113113
Requires reference quantities to be set on the model.
114114
115-
Attributes
116-
----------
117-
data : numpy.ndarray
118-
Direct access to variable values at particle locations.
119-
sym : sympy.Matrix
120-
Symbolic representation for use in expressions.
121-
122115
See Also
123116
--------
124117
MeshVariable : Variable supported by mesh nodes.
@@ -1975,11 +1968,6 @@ class IndexSwarmVariable(SwarmVariable):
19751968
proxy_continuous : bool
19761969
Whether mesh proxy is continuous (default True).
19771970
1978-
Attributes
1979-
----------
1980-
sym : list of sympy.Expr
1981-
Symbolic mask expressions for each material index.
1982-
19831971
Examples
19841972
--------
19851973
>>> material = IndexSwarmVariable("M", swarm, indices=3)
@@ -2375,44 +2363,6 @@ class Swarm(Stateful, uw_object):
23752363
Enable verbose output for debugging and monitoring particle operations.
23762364
Default is False.
23772365
2378-
Attributes
2379-
----------
2380-
mesh : uw.discretisation.Mesh
2381-
Reference to the associated mesh object.
2382-
dim : int
2383-
Spatial dimension of the mesh (2D or 3D).
2384-
cdim : int
2385-
Coordinate dimension of the mesh.
2386-
data : numpy.ndarray
2387-
Direct access to particle coordinate data.
2388-
particle_coordinates : SwarmVariable
2389-
SwarmVariable containing particle coordinate information.
2390-
recycle_rate : int
2391-
Current recycle rate for streak management.
2392-
cycle : int
2393-
Current cycle number for streak particles.
2394-
2395-
Methods
2396-
-------
2397-
populate(fill_param=1)
2398-
Populate the swarm with particles throughout the domain.
2399-
migrate(remove_sent_points=True, delete_lost_points=True, max_its=10)
2400-
Manually migrate particles across MPI processes after coordinate updates.
2401-
add_particles_with_coordinates(coords)
2402-
Add new particles at specified coordinate locations.
2403-
add_particles_with_global_coordinates(coords)
2404-
Add particles using global coordinate system.
2405-
add_variable(name, size, dtype=float)
2406-
Add a new variable to track additional particle properties.
2407-
save(filename, meshUnits=1.0, swarmUnits=1.0, units="dimensionless")
2408-
Save swarm data to file.
2409-
read_timestep(filename, step_name, outputPath="./output/")
2410-
Read swarm data from a specific timestep file.
2411-
advection(V_fn, delta_t, evalf=False, corrector=True, restore_points_func=None)
2412-
Advect particles using a velocity field.
2413-
estimate_dt(V_fn, dt_min=1.0e-15, dt_max=1.0)
2414-
Estimate appropriate timestep for particle advection.
2415-
24162366
Examples
24172367
--------
24182368
Create a basic swarm and populate with particles:
@@ -3360,27 +3310,26 @@ def _force_migration_after_mesh_change(self):
33603310

33613311
@timing.routine_timer_decorator
33623312
def add_particles_with_coordinates(self, coordinatesArray) -> int:
3363-
"""
3364-
Add particles to the swarm using particle coordinates provided
3365-
using a numpy array.
3313+
"""Add particles at given coordinates, keeping only locally-owned points.
33663314
3367-
Note that particles with coordinates NOT local to the current processor will
3368-
be rejected / ignored.
3315+
Each rank filters the input array and adds only the points that fall
3316+
within its local domain partition. Non-local points are silently
3317+
ignored, so it is safe to pass the same global coordinate array to
3318+
every rank — no duplicates will be created.
33693319
3370-
Either include an array with all coordinates to all processors
3371-
or an array with the local coordinates.
3320+
This is the recommended method for user code. For pre-partitioned
3321+
data where each rank already holds only its own points, this method
3322+
also works correctly.
33723323
33733324
Parameters
33743325
----------
33753326
coordinatesArray : numpy.ndarray
3376-
The numpy array containing the coordinate of the new particles. Array is
3377-
expected to take shape n*dim, where n is the number of new particles, and
3378-
dim is the dimensionality of the swarm's supporting mesh.
3327+
Coordinates of new particles, shape ``(n, dim)``.
33793328
33803329
Returns
33813330
--------
3382-
npoints: int
3383-
The number of points added to the local section of the swarm.
3331+
npoints : int
3332+
Number of points actually added on this rank.
33843333
"""
33853334

33863335
if not isinstance(coordinatesArray, np.ndarray):
@@ -3440,23 +3389,33 @@ def add_particles_with_global_coordinates(
34403389
migrate=True,
34413390
delete_lost_points=True,
34423391
) -> int:
3443-
"""
3444-
Add particles to the swarm using particle coordinates provided
3445-
using a numpy array.
3392+
"""Add particles on every rank, then migrate to correct owners.
3393+
3394+
Every rank inserts **all** supplied points into the local swarm, then
3395+
``dm.migrate()`` moves each particle to the rank that owns its
3396+
spatial location. If the same array is passed on every rank, this
3397+
produces one copy of each point in the correct partition — but calling
3398+
it with *different* arrays per rank will accumulate all of them.
34463399
3447-
global coordinates: particles will be appropriately migrated
3400+
This is primarily an internal method used by global-evaluation and
3401+
mesh-transfer utilities. For general use, prefer
3402+
:meth:`add_particles_with_coordinates`, which filters non-local
3403+
points automatically and never creates duplicates.
34483404
34493405
Parameters
34503406
----------
34513407
globalCoordinatesArray : numpy.ndarray
3452-
The numpy array containing the coordinate of the new particles. Array is
3453-
expected to take shape n*dim, where n is the number of new particles, and
3454-
dim is the dimensionality of the swarm's supporting mesh.
3408+
Coordinates of new particles, shape ``(n, dim)``.
3409+
migrate : bool
3410+
Run PETSc swarm migration after insertion (default True).
3411+
delete_lost_points : bool
3412+
Remove particles that fall outside any rank's domain
3413+
during migration (default True).
34553414
34563415
Returns
34573416
--------
3458-
npoints: int
3459-
The number of points added to the local section of the swarm.
3417+
npoints : int
3418+
Number of points added on this rank before migration.
34603419
"""
34613420

34623421
if not isinstance(globalCoordinatesArray, np.ndarray):

0 commit comments

Comments
 (0)