File size: 7,281 Bytes
73e6b79
 
 
 
 
 
 
 
 
 
 
 
 
30884fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
license: cc-by-4.0
pretty_name: solve-anywhere linear-system sequences
size_categories:
- 10K<n<100K
tags:
- sparse-matrices
- linear-systems
- linear-solvers
- finite-element-method
- scientific-computing
---

# solve-anywhere linear-system sequences

Sparse linear systems `A x = b` captured from FEM simulations (MFEM and FEniCSx/DOLFINx).
Each problem is run across a refinement ladder (~1k up to 5-10M DoFs), several
polynomial orders, and a sweep of physical parameters. Every run keeps the *sequence*
of systems it solved (time steps, Newton iterations, load steps, frequencies), with
metadata, so selection and online learning can be studied on realistic sequences.

## Quick start

```python
import sys; sys.path.insert(0, "data/sequences")
from load import runs, systems, load, meta

for run in runs(problem="ex16p", max_n=1e6):     # filter the catalog
    m = meta(run)                                 # mesh, order, parameters, ...
    for rec in systems(run, "heat"):              # per-system metadata
        A, b, x = load(run, "heat", rec["sys"])   # scipy CSR, numpy arrays
```

`python load.py` prints a summary of the catalog; `python load.py --mtx <run> <stream> <i> <prefix>`
writes one system as Matrix Market files.

## Layout

```
catalog.jsonl                   one line per run (if a run was redone, the last line counts)
<source>/<problem>/<run>/       one simulation: fixed mesh + parameters
  meta.json                     run metadata
  log.txt                       the program's output
  <stream>/index.jsonl          one line per saved system, in order
  <stream>/A_0000.npz           matrix, CSR (scipy.sparse.load_npz); written only when it changes,
                                so consecutive systems may share one file (index field "A")
  <stream>/sys_00000.npz        b, x (the program's own solution), and extra vectors if any
```

A *stream* is one kind of system within a run (e.g. `jacobian`, or `pressure` and `velocity`
for Navier-Stokes).

## Metadata

**Run (`meta.json`)**: `description`; `mesh_file`, `dim`, `mesh_elements`, `mesh_element_types`,
`mesh_h_min`/`mesh_h_max`; per stream `space_<stream>`, `order_<stream>`, `vdim_<stream>`,
`ordering_<stream>`, `true_dofs_<stream>`, and `stream_<stream>` (what the matrix is);
physical parameters; `params` (the sweep values); `command`/`argv`; `nranks`; `sampling`
and `thinning` (see below); `wall_s`, `peak_rss_total_bytes` (all processes), `exit`.

**System (`index.jsonl`)**:

| field | meaning |
|---|---|
| `sys`, `A` | system number; matrix file id |
| `n`, `nnz` | size |
| `b_norm` | ‖b‖₂. For Newton streams b is the nonlinear residual, so this is the current Newton residual (FEniCSx also writes `newton_residual`, `newton_residual_rel`) |
| `context.step`, `context.t`, `context.dt` | time / load / frequency step |
| `context.solve_in_step` | solve index within the step, i.e. the Newton iteration for Newton problems |
| `context.ip_iter`, `mu` | contact: interior-point iteration and barrier parameter |
| `context.k` | Helmholtz wavenumber |
| `iters`, `converged`, `final_norm`, `solve_s`, `rel_tol`, `ksp`, `pc` | the program's own linear solve |
| `vectors` | arrays stored in `sys_*.npz`: `b`, `x`, optionally `x0` (initial guess), `contact_dofs`, `block_id` |
| `rank_row_starts` | first row of each MPI rank's block (MFEM orders vector DoFs byNODES *within* each rank) |
| `pure_neumann` | Navier pressure: singular system (constant null space) |

## Problems

| source / problem | systems | sweep | largest |
|---|---|---|---|
| mfem/ex10p — nonlinear elasticity (Neo-Hookean beam, backward Euler + Newton) | Jacobians, ~7/step | 3 materials (default; nearly incompressible; stiff), order 1-3, 2D/3D | 9.9M (2D, order 3) |
| mfem/ex16p — nonlinear heat conduction | 1 matrix per step, 3 stages | conductivity nonlinearity α ∈ {0.01, 1, 100} | 5.3M |
| mfem/ex23 — wave equation | 1 matrix, 1 RHS per step | wave speed c ∈ {1, 10, 100} | 5.4M |
| mfem/ex31p — anisotropic definite Maxwell (Nédélec) | 1 per run | mass scale σ ∈ {1, 1e-2, 1e-4} | 9.0M |
| mfem/ex40p — Eikonal (proximal Galerkin, RT×L2 saddle point) | Newton systems; `block_id` vector | step size α ∈ {1, 10} | 8.9M |
| mfem/contact — frictionless contact (Tribol mortar, interior point) | reduced IP-Newton systems; `contact_dofs` vector | two-block, ironing, beam-sphere (linear / nonlinear) | ~3.8M (3D only) |
| mfem/navier_shear — 2D periodic shear layer | pressure (singular) + velocity per step | viscosity | 7.4M |
| mfem/navier_3dfoc — 3D flow past a cylinder | pressure (singular) + velocity per step | order | ~1.4M (3D) |
| fenicsx/poisson | 1 per run | coefficient: uniform, checkerboard contrast 1e3 / 1e6 | 5.9M |
| fenicsx/nonlinear_poisson — q(u) = 1 + βu² | Newton Jacobians (nonsymmetric) | β ∈ {1, 10, 100} | 5.9M |
| fenicsx/hyperelasticity — Neo-Hookean beam, 9 load steps | Newton Jacobians | Poisson ratio ν ∈ {0.3, 0.45, 0.49}; P1 tets and the tutorial's P2 hexes | 6.3M |
| fenicsx/ns_cylinder — DFG 2D-3, IPCS | 3 per step: tentative velocity (new each step), pressure, velocity correction | viscosity (Re 50/100/200) | 5.0M |
| fenicsx/helmholtz — real indefinite −Δu − k²u = f | 1 per wavenumber | wavenumber sweep (20 values, 8 on the largest meshes) | 5.9M |

Parameter sweeps cover runs below 500k DoFs; larger runs use the default parameters.
3D variants stop at 1-4M DoFs where the next refinement (8x) no longer fits in memory.

## Sampling

Small and medium runs keep every system. When a run would exceed its size budget
(500 MB, or enough for at least 5 matrices on the largest meshes), systems are thinned
uniformly over the whole run: every k-th step is kept (with all of its Newton
iterations) when that still leaves at least 4 steps; otherwise every k-th system,
which spreads the samples evenly over all steps. `meta.json` records the
thinning factor (`thinning.k`, plus `sampling.step_stride` applied while running);
`index.jsonl` keeps each system's original position (`seen`, `context`).

## Caveats

- `x` is the program's own solution, not an exact reference: inexact Newton steps (ex10p,
  Eisenstat-Walker tolerances) leave relative residuals up to ~0.2; most other streams are
  solved to 1e-6-1e-12 (see `validation.jsonl`). 3D Helmholtz on the largest meshes stores no x.
- Changes to the programs' own solvers (systems are unaffected): ex10p uses GMRES + BoomerAMG
  (instead of MINRES + Jacobi), Eisenstat-Walker tolerance capped at 0.1, up to 50 Newton
  iterations, dt = 1 for the stiff/incompressible materials; Navier uses assembled matrices
  (not partial assembly); contact uses AMGF with SuperLU_DIST; FEniCSx problems use
  AMG-preconditioned Krylov solvers (MUMPS for small hyperelasticity runs and Helmholtz).
- Dirichlet conditions: rows/columns eliminated with a unit diagonal (both libraries).
- Runs that failed (e.g. Newton divergence) keep what they saved and have `exit != 0`.

## Regenerating

Code is in `generators/`: `run_all.py` (all runs; `--list` shows the plan), `mfem/` (patched
MFEM examples and `sa_dump.hpp`), `fenicsx/` (DOLFINx scripts and `sa_fenicsx.py`),
`sa_store.py` (format, packing), `validate.py`. Libraries are built in `external/`.