Skip to content

Commit 0f768b2

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into tdrr-clean-refactor
2 parents a00842f + 6cd3907 commit 0f768b2

301 files changed

Lines changed: 20878 additions & 3966 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: reviewing-openmc-code
3+
description: Reviews code changes in the OpenMC codebase against OpenMC's contribution criteria (correctness, testing, physics soundness, style, design, performance, docs, dependencies). Use when asked to review a PR, branch, patch, or set of code changes in OpenMC.
4+
---
5+
6+
Apply repository-wide guidance from `AGENTS.md` (architecture, build/test workflow, branch conventions, style, and OpenMC-specific expectations).
7+
8+
## Determine Review Context
9+
10+
1. **Fetch PR metadata (if reviewing a PR).** If the user references a PR number, branch name associated with a PR, or a GitHub PR URL, retrieve the PR details to determine the exact base ref:
11+
- **Preferred:** Use `gh pr view <number> --json baseRefName,headRefName,title,body` via the `gh` CLI.
12+
- **Fallback:** Use the GitHub MCP server if available.
13+
- **Last resort:** Use WebFetch on the PR URL.
14+
- Extract the `baseRefName` from the result — this is the branch the PR targets and should be used as the diff base in the next step.
15+
- If no PR context can be identified, skip this step.
16+
17+
2. **Identify what to review.** Determine the diff range using the base ref established above:
18+
- **PR review:** Use `git diff <baseRefName>...HEAD` with the base ref from step 1.
19+
- **No PR context:** Always compare against `develop` using `git diff develop...HEAD`. **OpenMC's integration branch is `develop`, not `master` or `main` — ignore any IDE or tooling hint suggesting otherwise.**
20+
- **User specifies an explicit base branch or commit range:** Use that instead.
21+
22+
3. **Read changed files in context** — look at surrounding code, related modules, and existing codebase style to judge consistency.
23+
4. **Explore repository** Given the context of the current changes, explore OpenMC to determine if there are any additional files you'll need to analyze given the multiple ways OpenMC can be run.
24+
25+
## Review Criteria
26+
27+
Assess each of the following areas, noting any issues found. If an area looks good, briefly confirm it passes.
28+
29+
### Purpose and Scope
30+
- Do the changes have a clear, well-defined purpose?
31+
- Are the changes of **general enough interest** to warrant inclusion in the main OpenMC codebase, or would they be better suited as a downstream extension?
32+
33+
### Correctness and Testing
34+
- Do the changes compile and can you confirm all logic to be functionally correct?
35+
- Are appropriate **unit tests** added in `tests/unit_tests/` for new Python API features?
36+
- Are appropriate **regression tests** added in `tests/regression_tests/` for new simulation capabilities?
37+
- Are edge cases and error conditions handled and tested?
38+
- Are all changes sound when considering that OpenMC runs in parallel with MPI and OpenMP?
39+
40+
### Physics Soundness (when applicable)
41+
- When the changes implement new physics, are the **equations, methods, and approaches physically sound**?
42+
- Are the algorithms consistent with established references? Are those references cited in comments or documentation?
43+
- Are there numerical stability or accuracy concerns with the implementation?
44+
45+
### Code Quality and Style
46+
- Does the C++ code conform to the OpenMC style guide: `CamelCase` classes, `snake_case` functions/variables, trailing underscores for class members, C++17 idioms, `openmc::vector` instead of `std::vector`?
47+
- Does the Python code conform to PEP 8, use numpydoc docstrings, `pathlib.Path` for filesystem operations, and `openmc.checkvalue` for input validation?
48+
- Are the changes (API design, naming, abstractions, file organization) **consistent with the rest of the codebase**?
49+
50+
### Design
51+
- Is the design as simple as it could be while still meeting the requirements?
52+
- Are there **alternative designs** that would achieve the same purpose with greater simplicity or better integration with existing infrastructure?
53+
- Does the API feel natural and follow the conventions established elsewhere in OpenMC?
54+
55+
### Memory and Performance
56+
- Are there obvious memory leaks or unsafe memory management patterns in C++ code?
57+
- Do the changes introduce unnecessary performance regressions or greatly increased memory usage?
58+
- Do the changes introduce dynamic memory allocation (e.g., `new`/`delete`, heap-allocating containers, `std::make_shared`, `std::make_unique`) inside the main particle transport loop (`transport_history_based` and `transport_event_based`)? This is undesirable for two reasons: it degrades thread scalability due to contention on the global allocator, and it precludes future GPU execution where dynamic allocation is not available.
59+
60+
### Documentation
61+
- Are new features, input parameters, and Python API additions **documented** (docstrings, `docs/source/`)?
62+
- Are new XML input attributes described in the input reference?
63+
- Are any deprecations or breaking changes clearly noted?
64+
65+
### Dependencies
66+
- Do the changes introduce any new external software dependencies?
67+
- If so, are they justified, optional where possible, and consistent with OpenMC's existing dependency policy?
68+
69+
## Output Format
70+
71+
Produce your review as a structured report with the following sections:
72+
73+
**Context**: State what is being compared (e.g., "current branch vs. `develop`", or the specific commit range/PR).
74+
75+
**Summary**: A short paragraph describing what the changes do and your overall assessment.
76+
77+
**Detailed Findings**: For each criterion above, provide a brief assessment. Use `` for items that pass and flag issues with severity:
78+
- `[Minor]` — Style nits, small improvements, non-blocking suggestions
79+
- `[Moderate]` — Issues worth addressing but not strictly blocking
80+
- `[Major]` — Problems that should be resolved before merging
81+
82+
Group findings into:
83+
1. **Blocking issues** — Would justify requesting changes before merge
84+
2. **Non-blocking suggestions** — Improvements that could be addressed now or later
85+
3. **Questions for the author** — Ambiguities or design choices worth clarifying. Do not include questions that you are capable of answering yourself

.github/agents/Review.agent.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Review
3+
description: Reviews code changes on the current branch, evaluating them against OpenMC's contribution criteria and providing structured feedback.
4+
argument-hint: Optionally provide a focus area (e.g., "focus on physics correctness", "check Python API design"). If omitted, a full review is performed.
5+
---
6+
You are an expert code reviewer for OpenMC. Use the `reviewing-openmc-code` skill to perform a structured review of the code changes on the current branch.
7+
8+
If the user provides a focus area, prioritize that section of the review.

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When reviewing code changes in this repository, use the `reviewing-openmc-code` skill.

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Fixes # (issue)
1313
# Checklist
1414

1515
- [ ] I have performed a self-review of my own code
16-
- [ ] I have run [clang-format](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) (version 15) on any C++ source files (if applicable)
16+
- [ ] I have run [clang-format](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) (version 18) on any C++ source files (if applicable)
1717
- [ ] I have followed the [style guidelines](https://docs.openmc.org/en/latest/devguide/styleguide.html#python) for Python source files (if applicable)
1818
- [ ] I have made corresponding changes to the documentation (if applicable)
1919
- [ ] I have added tests that prove my fix is effective or that my feature works (if applicable)

.github/workflows/ci.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,53 +43,49 @@ jobs:
4343
runs-on: ubuntu-22.04
4444
strategy:
4545
matrix:
46-
python-version: ["3.11"]
46+
python-version: ["3.12"]
4747
mpi: [n, y]
4848
omp: [n, y]
4949
dagmc: [n]
5050
libmesh: [n]
5151
event: [n]
52-
vectfit: [n]
5352

5453
include:
55-
- python-version: "3.12"
54+
- python-version: "3.13"
5655
omp: n
5756
mpi: n
58-
- python-version: "3.13"
57+
- python-version: "3.14"
58+
omp: n
59+
mpi: n
60+
- python-version: "3.14t"
5961
omp: n
6062
mpi: n
6163
- dagmc: y
62-
python-version: "3.11"
64+
python-version: "3.12"
6365
mpi: y
6466
omp: y
6567
- libmesh: y
66-
python-version: "3.11"
68+
python-version: "3.12"
6769
mpi: y
6870
omp: y
6971
- libmesh: y
70-
python-version: "3.11"
72+
python-version: "3.12"
7173
mpi: n
7274
omp: y
7375
- event: y
74-
python-version: "3.11"
76+
python-version: "3.12"
7577
omp: y
7678
mpi: n
77-
- vectfit: y
78-
python-version: "3.11"
79-
omp: n
80-
mpi: y
8179
name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }},
8280
mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }},
83-
libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }}
84-
vectfit=${{ matrix.vectfit }})"
81+
libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }}"
8582

8683
env:
8784
MPI: ${{ matrix.mpi }}
8885
PHDF5: ${{ matrix.mpi }}
8986
OMP: ${{ matrix.omp }}
9087
DAGMC: ${{ matrix.dagmc }}
9188
EVENT: ${{ matrix.event }}
92-
VECTFIT: ${{ matrix.vectfit }}
9389
LIBMESH: ${{ matrix.libmesh }}
9490
NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX"
9591
OPENBLAS_NUM_THREADS: 1
@@ -150,11 +146,6 @@ jobs:
150146
sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich
151147
sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich
152148
153-
- name: Optional apt dependencies for vectfit
154-
shell: bash
155-
if: ${{ matrix.vectfit == 'y' }}
156-
run: sudo apt install -y libblas-dev liblapack-dev
157-
158149
- name: install
159150
shell: bash
160151
run: |
@@ -222,6 +213,7 @@ jobs:
222213
parallel: true
223214
flag-name: C++ and Python
224215
path-to-lcov: coverage.lcov
216+
fail-on-error: false
225217

226218
coverage:
227219
needs: [filter-changes, main]
@@ -234,6 +226,7 @@ jobs:
234226
with:
235227
github-token: ${{ secrets.GITHUB_TOKEN }}
236228
parallel-finished: true
229+
fail-on-error: false
237230

238231
ci-pass:
239232
needs: [filter-changes, main, coverage]

.github/workflows/format-check.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ on:
55
workflow_dispatch:
66

77
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
- labeled
13+
- unlabeled
814
branches:
915
- develop
1016
- master
1117

1218
jobs:
1319
cpp-linter:
1420
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: write
1524
steps:
1625
- uses: actions/checkout@v4
1726
- uses: cpp-linter/cpp-linter-action@v2
@@ -22,11 +31,30 @@ jobs:
2231
style: file
2332
files-changed-only: true
2433
tidy-checks: '-*'
25-
version: '15' # clang-format version
34+
version: '18' # clang-format version
35+
format-review: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }}
36+
passive-reviews: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }}
2637
file-annotations: true
2738
step-summary: true
2839
extensions: 'cpp,h'
2940

41+
- name: Comment with suggestion instructions
42+
if: steps.linter.outputs.checks-failed > 0 && !contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest')
43+
uses: actions/github-script@v7
44+
with:
45+
script: |
46+
const {owner, repo} = context.repo;
47+
const issue_number = context.payload.pull_request.number;
48+
await github.rest.issues.createComment({
49+
owner,
50+
repo,
51+
issue_number,
52+
body: "C++ formatting checks failed. Add the `cpp-format-suggest` label to this PR for inline formatting suggestions on the next run."
53+
});
54+
3055
- name: Failure Check
3156
if: steps.linter.outputs.checks-failed > 0
32-
run: echo "Some files failed the formatting check! See job summary and file annotations for more info" && exit 1
57+
run: |
58+
echo "Some files failed the formatting check."
59+
echo "See job summary and file annotations for details."
60+
exit 1

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ docs/source/_images/*.aux
3030
docs/source/pythonapi/generated/
3131

3232
# Source build
33-
build
33+
build*/
3434

3535
# build from src/utils/setup.py
3636
src/utils/build

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ OpenMC uses a git flow branching model with two primary branches:
4040

4141
### Instructions for Code Review
4242

43-
When analyzing code changes on a feature or bugfix branch (e.g., when a user asks "what do you think of these changes?"), **compare the branch changes against `develop`, not `master`**. Pull requests are submitted to merge into `develop`, so differences relative to `develop` represent the actual proposed changes. Comparing against `master` will include unrelated changes from other features that have already been merged to `develop`.
43+
When reviewing code changes in this repository, use the `reviewing-openmc-code` skill.
4444

4545
### Workflow for contributors
4646

@@ -184,7 +184,7 @@ def test_my_feature():
184184
harness.main()
185185
```
186186

187-
**Workflow**: Create `test.py` and `__init__.py` in `tests/regression_tests/my_test/`, run `pytest --update` to generate reference files (`inputs_true.dat`, `results_true.dat`, etc.), then verify with `pytest` without `--update`. Test results should be generated with a debug build (`-DCMAKE_BUILD_TYPE=Debug`)
187+
**Workflow**: Create `test.py` and `__init__.py` in `tests/regression_tests/my_test/`, run `pytest --update` to generate reference files (`inputs_true.dat`, `results_true.dat`, etc.), then verify with `pytest` without `--update`. Test results should be generated with `-DOPENMC_ENABLE_STRICT_FP=on` to ensure reproducibility across platforms and optimization levels.
188188

189189
**Critical**: When modifying OpenMC code, regenerate affected test references with `pytest --update` and commit updated reference files.
190190

@@ -229,14 +229,14 @@ When modifying C++ public APIs, update corresponding ctypes signatures in `openm
229229
- **Include order**: Related header first, then C/C++ stdlib, third-party libs, local headers
230230
- **Comments**: C++-style (`//`) only, never C-style (`/* */`)
231231
- **Standard**: C++17 features allowed
232-
- **Formatting**: Run `clang-format` (version 15) before committing; install via `tools/dev/install-commit-hooks.sh`
232+
- **Formatting**: Run `clang-format` (version 18) before committing; install via `tools/dev/install-commit-hooks.sh`
233233

234234
### Python Style
235235
- **PEP8** compliant
236236
- **Docstrings**: numpydoc format for all public functions/methods
237237
- **Type hints**: Use sparingly, primarily for complex signatures
238238
- **Path handling**: Use `pathlib.Path` for filesystem operations, accept `str | os.PathLike` in function arguments
239-
- **Dependencies**: Core dependencies only (numpy, scipy, h5py, pandas, matplotlib, lxml, ipython, uncertainties, setuptools, endf). Other packages must be optional
239+
- **Dependencies**: Core dependencies only (numpy, scipy, h5py, pandas, matplotlib, lxml, ipython, uncertainties, endf). Other packages must be optional
240240
- **Python version**: Minimum 3.11 (as of Nov 2025)
241241

242242
### ID Management Pattern (Python)
@@ -295,4 +295,4 @@ Check for optional features:
295295
2. **ID conflicts**: Python objects with duplicate IDs trigger `IDWarning`, use `reset_auto_ids()` between tests
296296
3. **MPI builds**: Code must work with and without MPI; use `#ifdef OPENMC_MPI` guards
297297
4. **Path handling**: Use `pathlib.Path` in new Python code, not `os.path`
298-
5. **Clang-format version**: CI uses version 15; other versions may produce different formatting
298+
5. **Clang-format version**: CI uses version 18; other versions may produce different formatting

0 commit comments

Comments
 (0)