Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ jobs:
python3 tests/regression/run_seastack/run_tests.py --all --quiet
--exe build/bin/Release/run_seastack

# Demo cases outside the packaged check, against the reduced references
# under tests/regression/run_seastack/extended.
- name: Run the extended demo cases against their references
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' }}
run: >
python3 tests/regression/run_seastack/run_tests.py --extended --quiet
--exe build/bin/Release/run_seastack

# Wall-clock timings on shared runners are for information only, so this
# step does not fail the job.
- name: Run the benchmarks
Expand Down Expand Up @@ -762,6 +770,14 @@ jobs:
python tests/regression/run_seastack/run_tests.py --all --quiet
--exe build/bin/Release/run_seastack.exe

# Demo cases outside the packaged check, against the reduced references
# under tests/regression/run_seastack/extended.
- name: Run the extended demo cases against their references
if: ${{ !cancelled() && steps.build.conclusion == 'success' && env.FULL_SUITES == 'true' }}
run: >
python tests/regression/run_seastack/run_tests.py --extended --quiet
--exe build/bin/Release/run_seastack.exe

# Wall-clock timings on shared runners are for information only, so this
# step does not fail the job.
- name: Run the benchmarks
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GitHub Actions builds and tests SEA-Stack on Linux, macOS and Windows ([`.github
| Chrono-free | `--no-chrono --external` / `-NoChrono -External` | `chrono-free` label and the downstream-consumer check |
| Chrono | Headless Chrono 10.0.0 built by `scripts/unix/build_chrono.sh` or `scripts/windows/build_chrono.ps1`, with MoorDyn, external modules and demos; no VSG | `unit`, `regression` and `external` labels |

The Chrono job also runs the **full suites** (verification, comparison, long regression, the demo cases through `run_tests.py --all`, and the benchmarks) every night on `dev`, on a manual run of the workflow, and on a pull request that carries the label `full-tests`.
The Chrono job also runs the **full suites** (verification, comparison, long regression, the demo cases through `run_tests.py --all` and `--extended`, and the benchmarks) every night on `dev`, on a manual run of the workflow, and on a pull request that carries the label `full-tests`.

- **Threads:** two tests run at a time, each with `OMP_NUM_THREADS=2`.
- **Skipped tests fail the run.** CTest exits with 0 when a test returns its skip code, for example when a Python package is missing; `scripts/ci/check_ctest_junit.py` reads the JUnit report of each suite and fails unless every test ran and passed. The suite scripts write that report with `--junit FILE` (Unix) or `-Junit FILE` (Windows).
Expand Down
10 changes: 9 additions & 1 deletion tests/regression/run_seastack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ pinned references when the solver or wave settings change).
A case fails when it has no reference under `expected/`, when its reference
lacks one of the case's signals, or when its signal adapter raises an error;
a run is never compared with itself. `--rm3-regular` has no packaged
reference and therefore fails until one is added.
reference; in a source checkout it uses the one under `extended/` (below).

### Extended cases (source checkout only)

`--extended` runs eight further demo cases (5SA spreading and bimodal, Wigley,
trimaran, RM3 regular waves, OSWEC with the built-in power take-off) against
small references kept beside the runner, and `--case <model>/<case>` runs one
of them. They are not part of the release package. See
[extended/README.md](extended/README.md).

## Requirements

Expand Down
Binary file not shown.
Binary file not shown.
73 changes: 73 additions & 0 deletions tests/regression/run_seastack/extended/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Extended demo cases

`run_tests.py --extended` runs demo cases that the packaged check (`--all`)
does not cover and compares their body motions with the references in this
folder. The cases, and the degrees of freedom compared in each, are listed in
`motion_signals.py`:

| Case | What it adds to `--all` |
|------|-------------------------|
| `5sa/spreading`, `5sa/bimodal` | Five hinged bodies with mooring in short-crested and two-peaked seas |
| `wigley/spreading`, `wigley/damping` | A free-floating hull in six degrees of freedom |
| `trimaran/rigid` | Three hulls joined by arms |
| `rm3/regular_waves`, `rm3/regular_waves_cc` | RM3 in regular waves, with the radiation convolution and with constant coefficients |
| `oswec/native_pto` | OSWEC with the built-in power take-off |

These files are in the source tree only. The release package gains no files,
and its `RUN-TESTS` check runs the same cases as before.

## References

A reference is `<model>/<case>/baseline.h5`. It holds the time vector and the
position and orientation of every body of one run, under the same paths as a
results file, and nothing else. Every Nth sample of the run is kept, at about
0.1 s; the root attribute `reference_sample_stride` records N. The values are
the run's own samples in double precision; nothing is interpolated or rounded.
This keeps the eight references to 4.4 MB together; the results files they
come from take about 600 MB.

The comparison takes every Nth sample of the new run, requires each of its
times to equal the reference time, and applies the same limit on the RMS
relative error as `--all`. A translation is compared as displacement from its
first sample, so that the mean position of a body does not enter the error.

The references were written by a build of v1.2.0 on Windows. The other
root attributes give the version, the time step and number of samples of the
run, and the SHA-256 digests of its input files.

## Known platform differences

On macOS (arm64) the two 5SA cases differ from the references by more than
the limit: the surge displacement of the moored bodies by 0.6 % (`spreading`)
and 1 % (`bimodal`) over the 600 s run, and the other motions by up to 8e-4.
Linux and Windows agree with the references to 2e-10, and the six cases
without mooring agree on macOS to 2e-7. The cause is not yet known.

Until it is, `KNOWN_PLATFORM_DIFFERENCES` in `motion_signals.py` lists the two
cases for macOS. There they are still run, their signals and sample times must
match the reference, and each error is printed as `INFO`, but the errors do
not decide the result. The summary line names the cases that were run but not
judged. Remove the entries when the difference is resolved; do not widen the
limit or rewrite the references instead.

## Running

From the repository root, after a build:

```
python tests/regression/run_seastack/run_tests.py --extended --exe build/bin/Release/run_seastack
python tests/regression/run_seastack/run_tests.py --case 5sa/spreading --exe build/bin/Release/run_seastack
```

`--update-baseline` together with `--extended` or `--case` rewrites the
references from the current build. Do this only for an intended change of the
results, and say so in the commit.

## Adding a case

Add the case and its driven degrees of freedom to `CASE_SIGNALS` in
`motion_signals.py`, write its reference with `--case <model>/<case>
--update-baseline`, and check that a second run passes against it. The case
must write one `results.*.h5` under its `outputs/` folder. Leave out degrees
of freedom that stay near zero: they hold rounding noise, and their relative
error means nothing.
78 changes: 78 additions & 0 deletions tests/regression/run_seastack/extended/motion_signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""The extended demo cases of run_tests.py and the body motions compared in each."""
from pathlib import Path

import h5py
import numpy as np

_ALL = ("surge", "sway", "heave", "roll", "pitch", "yaw")

# Case -> body -> degrees of freedom compared. Only motions that the waves
# drive are listed: a degree of freedom that stays near zero (sway, roll and
# yaw in a head sea) holds rounding noise, and its relative error means nothing.
CASE_SIGNALS = {
# Five hinged bodies in short-crested seas, moored: every degree of freedom responds.
"5sa/spreading": {f"body{i}": _ALL for i in range(1, 6)},
"5sa/bimodal": {f"body{i}": _ALL for i in range(1, 6)},
# Single free-floating hull: every degree of freedom responds in both cases.
"wigley/spreading": {"body1": _ALL},
"wigley/damping": {"body1": _ALL},
# Centre hull (body1) and the two floats (body2, body3), which also roll on their arms.
"trimaran/rigid": {"body1": ("surge", "heave", "pitch"), "body2": ("heave", "roll"), "body3": ("heave", "roll")},
# Float (body1) and spar-plate (body2).
"rm3/regular_waves": {"body1": ("surge", "heave", "pitch"), "body2": ("heave",)},
"rm3/regular_waves_cc": {"body1": ("surge", "heave", "pitch"), "body2": ("heave",)},
# Flap (body1) on a fixed base.
"oswec/native_pto": {"body1": ("surge", "pitch")},
}

# Cases whose results on one platform differ from the references by more than
# the limit, for a reason that is known and being followed up. On that platform
# (a value of sys.platform) the case is still run and its errors are printed,
# but they do not decide the result. Remove an entry once the difference is
# resolved; do not widen the limit or rewrite the reference instead.
KNOWN_PLATFORM_DIFFERENCES = {
"darwin": {
"5sa/spreading": "on macOS (arm64) the surge of the moored 5SA differs from Windows and Linux "
"by 0.6 % over the 600 s run; the cases without mooring agree to 2e-7",
"5sa/bimodal": "on macOS (arm64) the surge of the moored 5SA differs from Windows and Linux "
"by 1 % over the 600 s run; the cases without mooring agree to 2e-7",
},
}

# Signal suffix -> (dataset under /results/model/bodies/<body>/, column, label, displacement).
# A translation is compared as displacement from its first sample: the RMS
# relative error divides by the RMS of the reference, and the mean position of
# a body (up to 160 m along the 5SA) would otherwise hide a change in its motion.
DEGREES_OF_FREEDOM = {
"surge": ("position", 0, "Surge displacement (m)", True),
"sway": ("position", 1, "Sway displacement (m)", True),
"heave": ("position", 2, "Heave displacement (m)", True),
"roll": ("orientation_xyz", 0, "Roll (rad)", False),
"pitch": ("orientation_xyz", 1, "Pitch (rad)", False),
"yaw": ("orientation_xyz", 2, "Yaw (rad)", False),
}


def body_motions(h5_path: Path, selection: dict) -> dict:
"""Signals name -> (time, values, label) for `selection`, body -> degrees of freedom.

The signal of body "body2" in "pitch" is named "body2_pitch". A missing
body, dataset or column is an error; no other quantity is substituted.
"""
signals = {}
with h5py.File(h5_path, "r") as f:
time = np.asarray(f["/results/time/time"][:], dtype=float).reshape(-1)
for body, names in selection.items():
for name in names:
dataset, column, label, displacement = DEGREES_OF_FREEDOM[name]
key = f"/results/model/bodies/{body}/{dataset}"
if key not in f:
raise KeyError(f"{key} not found in {h5_path}")
values = np.asarray(f[key][:], dtype=float)
if values.ndim != 2 or values.shape[1] <= column:
raise KeyError(f"{key} has shape {values.shape}; column {column} ({name}) not found")
values = values[:, column]
if displacement:
values = values - values[0]
signals[f"{body}_{name}"] = (time, values, label)
return signals
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading