Skip to content

feat: Add Magnetohydrodynamics (MHD) benchmark suite#9

Merged
amanotk merged 40 commits intodevelopfrom
feature/magnetohydrodynamics
Apr 2, 2026
Merged

feat: Add Magnetohydrodynamics (MHD) benchmark suite#9
amanotk merged 40 commits intodevelopfrom
feature/magnetohydrodynamics

Conversation

@amanotk
Copy link
Copy Markdown
Owner

@amanotk amanotk commented Apr 2, 2026

Summary

Adds a complete Magnetohydrodynamics (MHD) benchmark suite with 4 C++ tasks:

  • cpp-hlld-00: HLLD Riemann solver with detailed guidance
  • cpp-hlld-01: HLLD variant with reduced guidance
  • cpp-full1d-00: Full 1D ideal MHD solver (main+HLLD provided)
  • cpp-full1d-01: Full 1D variant with minimal scaffolding

Changes

  • Shared eval infrastructure (shared/eval/, mhd1d_shared.py)
  • Hidden fixtures for Brio-Wu reference solutions
  • Public tests compare CSV output against golden files
  • Hidden tests use finer grids (nx=200) against hidden references
  • Updated agents_default.toml for opencode config handling
  • VS Code settings for cleaner workspace view
  • Expanded .gitignore for build artifacts

Testing

All tasks include:

  • Public pytest/Catch2 tests (visible to agents)
  • Hidden eval tests (authoritative scoring)
  • Numeric tolerance: 1.0e-12

Related

  • docs/toolchain.md: C++ headers (cxxopts, Catch2) already documented
  • Task specs reference /work/basic_equations.md and /work/hlld.md

amanotk and others added 30 commits March 7, 2026 15:42
Reformatted math equations for better readability.
- Rename ArrayView/XView to ArrayView2D/ArrayView1D, drop ConstArrayView
- Remove all _inplace wrappers and ConstArrayView overloads
- Drop default constructor parameters (domain fixed to [0,1])
- Use constexpr coefficient table for SSP-RK3 substeps
- Extract init_brio_wu_primitive() in main.cpp
- Add cell center view (x) to SolverWorkspace, remove cell_centers()
- Update tests to match new type names and required constructor args
Remove dt and t_final from SolverWorkspace constructor and members.
Pass them directly to evolve_ssp_rk3(workspace, dt, t_final) instead.
Constructor now takes (nx, gamma, bx) only.
…xing

- Simplify initialize() signature: remove discontinuity_x parameter,
  hardcode 0.5 inside; remove unused constants from main.cpp
- Fix cell center initialization to only fill interior cells (Lbx..Ubx)
  instead of all padded cells, matching the physical domain convention
- Rename local dt/t_final to delt/tmax in main()
…0 cells

Update default Nx constant and regenerate golden/reference CSV files.
Improve plot styling with math mode labels and remove subplot titles.
Split the Brio-Wu reference solver and its test fixtures into shared assets,
remove the JSON-based helper path, and make the solver grid size configurable
amanotk and others added 9 commits April 2, 2026 10:18
- cpp-full1d-01 exposes only evolve_ssp_rk3(...) as public solver entrypoint
- HLLD and CLI remain provided, same as cpp-full1d-00
- Public C++ tests adapted to reduced scaffolding
- Fixed hidden eval path in both 00 and 01 to use /eval_shared mount

Co-authored-by: OpenCode Assistant <assistant@opencode.ai>
The eval test was using relative paths based on __file__ position which
breaks when tests run from /eval/tests/. Fixed to use absolute paths:
- WORKSPACE_ROOT = Path("/work/workspace")
- REFERENCE_CSV_PATH uses /eval_shared mount

This affects both cpp-full1d-00 and cpp-full1d-01 variants.
The workdir is mounted at /work, not /work/workspace. The original
workspace subdirectory doesn't exist in the run workdir.
@amanotk
Copy link
Copy Markdown
Owner Author

amanotk commented Apr 2, 2026

Review @codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70f3fa1392

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +152 to +153
for (int ix = lbx - 1; ix <= ubx + 1; ++ix) {
::hlld_flux_from_primitive(&up_l(ix, 0), &up_r(ix + 1, 0), bx, gamma, &flux(ix, 0));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bound HLLD interface loop to allocated stencil

The flux loop iterates through ix <= ubx + 1 while calling up_r(ix + 1, 0), so on the last iteration it reads up_r(ubx + 2, 0) past the allocated Nx + 2*N_margin buffer (N_margin=1). This introduces undefined behavior in the shared reference solver (AddressSanitizer reports a heap-buffer-overflow), which can crash reference generation/tests and make benchmark outputs non-deterministic across builds.

Useful? React with 👍 / 👎.

The flux loop was iterating to ubx + 1 and accessing up_r(ix + 1),
which read past the allocated Nx + 2*N_margin buffer on the last
iteration. Changed loop bound from ubx + 1 to ubx to stay within
allocated memory.
@amanotk amanotk merged commit eb4727f into develop Apr 2, 2026
3 checks passed
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