Compare commits
No commits in common. "develop" and "v0.12.2" have entirely different histories.
|
|
@ -84,7 +84,6 @@ PenaltyBreakTemplateDeclaration: 10
|
||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 1000000
|
||||||
PenaltyReturnTypeOnItsOwnLine: 200
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
QualifierAlignment: Left
|
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
SortIncludes: true
|
SortIncludes: true
|
||||||
SortUsingDeclarations: true
|
SortUsingDeclarations: true
|
||||||
|
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
---
|
|
||||||
name: reviewing-openmc-code
|
|
||||||
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.
|
|
||||||
---
|
|
||||||
|
|
||||||
Apply repository-wide guidance from `AGENTS.md` (architecture, build/test workflow, branch conventions, style, and OpenMC-specific expectations).
|
|
||||||
|
|
||||||
## Determine Review Context
|
|
||||||
|
|
||||||
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:
|
|
||||||
- **Preferred:** Use `gh pr view <number> --json baseRefName,headRefName,title,body` via the `gh` CLI.
|
|
||||||
- **Fallback:** Use the GitHub MCP server if available.
|
|
||||||
- **Last resort:** Use WebFetch on the PR URL.
|
|
||||||
- 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.
|
|
||||||
- If no PR context can be identified, skip this step.
|
|
||||||
|
|
||||||
2. **Identify what to review.** Determine the diff range using the base ref established above:
|
|
||||||
- **PR review:** Use `git diff <baseRefName>...HEAD` with the base ref from step 1.
|
|
||||||
- **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.**
|
|
||||||
- **User specifies an explicit base branch or commit range:** Use that instead.
|
|
||||||
|
|
||||||
3. **Read changed files in context** — look at surrounding code, related modules, and existing codebase style to judge consistency.
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Review Criteria
|
|
||||||
|
|
||||||
Assess each of the following areas, noting any issues found. If an area looks good, briefly confirm it passes.
|
|
||||||
|
|
||||||
### Purpose and Scope
|
|
||||||
- Do the changes have a clear, well-defined purpose?
|
|
||||||
- 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?
|
|
||||||
|
|
||||||
### Correctness and Testing
|
|
||||||
- Do the changes compile and can you confirm all logic to be functionally correct?
|
|
||||||
- Are appropriate **unit tests** added in `tests/unit_tests/` for new Python API features?
|
|
||||||
- Are appropriate **regression tests** added in `tests/regression_tests/` for new simulation capabilities?
|
|
||||||
- Are edge cases and error conditions handled and tested?
|
|
||||||
- Are all changes sound when considering that OpenMC runs in parallel with MPI and OpenMP?
|
|
||||||
|
|
||||||
### Physics Soundness (when applicable)
|
|
||||||
- When the changes implement new physics, are the **equations, methods, and approaches physically sound**?
|
|
||||||
- Are the algorithms consistent with established references? Are those references cited in comments or documentation?
|
|
||||||
- Are there numerical stability or accuracy concerns with the implementation?
|
|
||||||
|
|
||||||
### Code Quality and Style
|
|
||||||
- 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`?
|
|
||||||
- Does the Python code conform to PEP 8, use numpydoc docstrings, `pathlib.Path` for filesystem operations, and `openmc.checkvalue` for input validation?
|
|
||||||
- Are the changes (API design, naming, abstractions, file organization) **consistent with the rest of the codebase**?
|
|
||||||
|
|
||||||
### Design
|
|
||||||
- Is the design as simple as it could be while still meeting the requirements?
|
|
||||||
- Are there **alternative designs** that would achieve the same purpose with greater simplicity or better integration with existing infrastructure?
|
|
||||||
- Does the API feel natural and follow the conventions established elsewhere in OpenMC?
|
|
||||||
|
|
||||||
### Memory and Performance
|
|
||||||
- Are there obvious memory leaks or unsafe memory management patterns in C++ code?
|
|
||||||
- Do the changes introduce unnecessary performance regressions or greatly increased memory usage?
|
|
||||||
- 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.
|
|
||||||
|
|
||||||
### Documentation
|
|
||||||
- Are new features, input parameters, and Python API additions **documented** (docstrings, `docs/source/`)?
|
|
||||||
- Are new XML input attributes described in the input reference?
|
|
||||||
- Are any deprecations or breaking changes clearly noted?
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Do the changes introduce any new external software dependencies?
|
|
||||||
- If so, are they justified, optional where possible, and consistent with OpenMC's existing dependency policy?
|
|
||||||
|
|
||||||
## Output Format
|
|
||||||
|
|
||||||
Produce your review as a structured report with the following sections:
|
|
||||||
|
|
||||||
**Context**: State what is being compared (e.g., "current branch vs. `develop`", or the specific commit range/PR).
|
|
||||||
|
|
||||||
**Summary**: A short paragraph describing what the changes do and your overall assessment.
|
|
||||||
|
|
||||||
**Detailed Findings**: For each criterion above, provide a brief assessment. Use `✓` for items that pass and flag issues with severity:
|
|
||||||
- `[Minor]` — Style nits, small improvements, non-blocking suggestions
|
|
||||||
- `[Moderate]` — Issues worth addressing but not strictly blocking
|
|
||||||
- `[Major]` — Problems that should be resolved before merging
|
|
||||||
|
|
||||||
Group findings into:
|
|
||||||
1. **Blocking issues** — Would justify requesting changes before merge
|
|
||||||
2. **Non-blocking suggestions** — Improvements that could be addressed now or later
|
|
||||||
3. **Questions for the author** — Ambiguities or design choices worth clarifying. Do not include questions that you are capable of answering yourself
|
|
||||||
|
|
@ -1,250 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""MCP server that exposes OpenMC's RAG semantic search to AI coding agents.
|
|
||||||
|
|
||||||
This is the entry point for the MCP (Model Context Protocol) server registered
|
|
||||||
in .mcp.json at the repo root. When an MCP-capable agent (e.g. Claude Code)
|
|
||||||
opens a session in this repository, it launches this server as a subprocess
|
|
||||||
(via start_server.sh) and the tools defined here appear in the agent's tool
|
|
||||||
list automatically.
|
|
||||||
|
|
||||||
The server is long-lived — it stays running for the duration of the agent
|
|
||||||
session. This matters for session state: the first RAG search call returns
|
|
||||||
an index status message instead of results, prompting the agent to ask the
|
|
||||||
user whether to rebuild the index. That first-call flag resets each session.
|
|
||||||
|
|
||||||
Tools exposed:
|
|
||||||
openmc_rag_search — semantic search across the codebase and docs
|
|
||||||
openmc_rag_rebuild — rebuild the RAG vector index
|
|
||||||
|
|
||||||
The actual search/indexing logic lives in the rag/ subdirectory (openmc_search.py,
|
|
||||||
indexer.py, chunker.py, embeddings.py). This file is just the MCP interface
|
|
||||||
layer and session state management.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from mcp.server.fastmcp import FastMCP
|
|
||||||
import json
|
|
||||||
import logging
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
from datetime import datetime
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# MCP communicates over stdin/stdout with JSON-RPC framing. Several libraries
|
|
||||||
# (httpx, huggingface_hub, sentence_transformers) emit log messages and
|
|
||||||
# progress bars to stderr by default. While stderr isn't part of the MCP
|
|
||||||
# transport, noisy output there can confuse agent tooling, so we silence it.
|
|
||||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
||||||
logging.getLogger("huggingface_hub").setLevel(logging.ERROR)
|
|
||||||
logging.getLogger("sentence_transformers").setLevel(logging.WARNING)
|
|
||||||
|
|
||||||
# Path constants. This file lives at .claude/tools/openmc_mcp_server.py,
|
|
||||||
# so parents[2] is the OpenMC repo root.
|
|
||||||
OPENMC_ROOT = Path(__file__).resolve().parents[2]
|
|
||||||
CACHE_DIR = OPENMC_ROOT / ".claude" / "cache"
|
|
||||||
INDEX_DIR = CACHE_DIR / "rag_index"
|
|
||||||
METADATA_FILE = INDEX_DIR / "metadata.json"
|
|
||||||
|
|
||||||
# The RAG modules (openmc_search, indexer, etc.) live in .claude/tools/rag/.
|
|
||||||
# We add that directory to sys.path so we can import them directly.
|
|
||||||
TOOLS_DIR = Path(__file__).resolve().parent
|
|
||||||
sys.path.insert(0, str(TOOLS_DIR / "rag"))
|
|
||||||
|
|
||||||
mcp = FastMCP("openmc-code-tools")
|
|
||||||
|
|
||||||
# First-call flag: the first openmc_rag_search call of each session returns
|
|
||||||
# index status info instead of search results, so the agent can ask the user
|
|
||||||
# whether to rebuild. This resets when the server process restarts (i.e. each
|
|
||||||
# new agent session).
|
|
||||||
_rag_first_call = True
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Helpers
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def _get_current_branch():
|
|
||||||
"""Get the current git branch name."""
|
|
||||||
try:
|
|
||||||
result = subprocess.run(
|
|
||||||
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
|
||||||
capture_output=True, text=True, cwd=str(OPENMC_ROOT),
|
|
||||||
)
|
|
||||||
if result.returncode != 0 or not result.stdout.strip():
|
|
||||||
return "unknown"
|
|
||||||
return result.stdout.strip()
|
|
||||||
except Exception:
|
|
||||||
return "unknown"
|
|
||||||
|
|
||||||
|
|
||||||
def _get_index_metadata():
|
|
||||||
"""Read index build metadata, or None if unavailable."""
|
|
||||||
if not METADATA_FILE.exists():
|
|
||||||
return None
|
|
||||||
try:
|
|
||||||
return json.loads(METADATA_FILE.read_text())
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _save_index_metadata():
|
|
||||||
"""Save index build metadata alongside the index."""
|
|
||||||
metadata = {
|
|
||||||
"built_at": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
|
||||||
"branch": _get_current_branch(),
|
|
||||||
}
|
|
||||||
METADATA_FILE.write_text(json.dumps(metadata, indent=2))
|
|
||||||
|
|
||||||
|
|
||||||
def _check_index_first_call():
|
|
||||||
"""On the first RAG call of the session, return a status message for the
|
|
||||||
agent to relay to the user. Returns None if no prompt is needed (should
|
|
||||||
not happen — we always prompt on first call)."""
|
|
||||||
current_branch = _get_current_branch()
|
|
||||||
|
|
||||||
if not INDEX_DIR.exists():
|
|
||||||
return (
|
|
||||||
"No RAG index found. Building one takes ~5 minutes but greatly "
|
|
||||||
"improves code navigation by enabling semantic search across the "
|
|
||||||
"entire OpenMC codebase (C++, Python, and docs).\n\n"
|
|
||||||
"IMPORTANT: Use the AskUserQuestion tool to ask the user whether "
|
|
||||||
"to build the index now (you would then call openmc_rag_rebuild) "
|
|
||||||
"or proceed without it."
|
|
||||||
)
|
|
||||||
|
|
||||||
meta = _get_index_metadata()
|
|
||||||
if meta:
|
|
||||||
built_at = meta.get("built_at", "unknown time")
|
|
||||||
built_branch = meta.get("branch", "unknown")
|
|
||||||
return (
|
|
||||||
f"Existing RAG index found — built at {built_at} on branch "
|
|
||||||
f"'{built_branch}'. Current branch is '{current_branch}'.\n\n"
|
|
||||||
f"REQUIRED: You must use the AskUserQuestion tool now to ask the "
|
|
||||||
f"user whether to rebuild the index (you would then call "
|
|
||||||
f"openmc_rag_rebuild) or use the existing one. Do not skip this "
|
|
||||||
f"step — the user may have uncommitted changes. Do not decide "
|
|
||||||
f"on their behalf."
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
f"RAG index found but has no build metadata. "
|
|
||||||
f"Current branch is '{current_branch}'.\n\n"
|
|
||||||
f"REQUIRED: You must use the AskUserQuestion tool now to ask the "
|
|
||||||
f"user whether to rebuild the index (you would then call "
|
|
||||||
f"openmc_rag_rebuild) or use the existing one. Do not skip this "
|
|
||||||
f"step. Do not decide on their behalf."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Tools
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@mcp.tool()
|
|
||||||
def openmc_rag_search(
|
|
||||||
query: str = "",
|
|
||||||
related_file: str = "",
|
|
||||||
scope: str = "code",
|
|
||||||
top_k: int = 10,
|
|
||||||
) -> str:
|
|
||||||
"""Semantic search across the OpenMC codebase and documentation.
|
|
||||||
|
|
||||||
Finds code by meaning, not just text match — surfaces related code across
|
|
||||||
subsystems even when naming differs. Use for discovery and exploration
|
|
||||||
before reaching for grep. Covers C++, Python, and RST docs.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
query: Search query (e.g. "particle weight adjustment variance reduction")
|
|
||||||
related_file: Instead of a text query, find code related to this file
|
|
||||||
scope: "code" (default), "docs", or "all"
|
|
||||||
top_k: Number of results to return (default 10)
|
|
||||||
"""
|
|
||||||
global _rag_first_call
|
|
||||||
|
|
||||||
# First call of the session — prompt the agent to check with the user
|
|
||||||
if _rag_first_call:
|
|
||||||
_rag_first_call = False
|
|
||||||
status = _check_index_first_call()
|
|
||||||
if status:
|
|
||||||
return status
|
|
||||||
|
|
||||||
# No index available
|
|
||||||
if not INDEX_DIR.exists():
|
|
||||||
return (
|
|
||||||
"No RAG index available. Call openmc_rag_rebuild() to build one "
|
|
||||||
"(takes ~5 minutes)."
|
|
||||||
)
|
|
||||||
|
|
||||||
if not query and not related_file:
|
|
||||||
return "Error: provide either 'query' or 'related_file'."
|
|
||||||
|
|
||||||
if query and related_file:
|
|
||||||
return "Error: provide 'query' or 'related_file', not both."
|
|
||||||
|
|
||||||
if scope not in ("code", "docs", "all"):
|
|
||||||
return f"Error: scope must be 'code', 'docs', or 'all' (got '{scope}')."
|
|
||||||
|
|
||||||
if top_k < 1:
|
|
||||||
return f"Error: top_k must be at least 1 (got {top_k})."
|
|
||||||
|
|
||||||
try:
|
|
||||||
from openmc_search import (
|
|
||||||
get_db_and_embedder, search_table, format_results, search_related,
|
|
||||||
)
|
|
||||||
|
|
||||||
db, embedder = get_db_and_embedder()
|
|
||||||
|
|
||||||
if related_file:
|
|
||||||
results = search_related(db, embedder, related_file, top_k)
|
|
||||||
return format_results(results, f"Code related to {related_file}")
|
|
||||||
elif scope == "all":
|
|
||||||
code_results = search_table(db, embedder, "code", query, top_k)
|
|
||||||
doc_results = search_table(db, embedder, "docs", query, top_k)
|
|
||||||
return (format_results(code_results, "Code") + "\n"
|
|
||||||
+ format_results(doc_results, "Documentation"))
|
|
||||||
elif scope == "docs":
|
|
||||||
results = search_table(db, embedder, "docs", query, top_k)
|
|
||||||
return format_results(results, "Documentation")
|
|
||||||
else:
|
|
||||||
results = search_table(db, embedder, "code", query, top_k)
|
|
||||||
return format_results(results, "Code")
|
|
||||||
except Exception as e:
|
|
||||||
return f"Error during search: {e}"
|
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
|
||||||
def openmc_rag_rebuild() -> str:
|
|
||||||
"""Rebuild the RAG semantic search index from the current codebase.
|
|
||||||
|
|
||||||
Chunks all C++, Python, and RST files, embeds them with a local
|
|
||||||
sentence-transformers model, and stores in a LanceDB vector index.
|
|
||||||
Takes ~5 minutes on 10 CPU cores. Call this after pulling new code
|
|
||||||
or switching branches.
|
|
||||||
"""
|
|
||||||
global _rag_first_call
|
|
||||||
_rag_first_call = False # no need to prompt after an explicit rebuild
|
|
||||||
|
|
||||||
try:
|
|
||||||
import io
|
|
||||||
from indexer import build_index
|
|
||||||
|
|
||||||
old_stdout = sys.stdout
|
|
||||||
sys.stdout = captured = io.StringIO()
|
|
||||||
try:
|
|
||||||
build_index()
|
|
||||||
finally:
|
|
||||||
sys.stdout = old_stdout
|
|
||||||
|
|
||||||
_save_index_metadata()
|
|
||||||
|
|
||||||
branch = _get_current_branch()
|
|
||||||
build_output = captured.getvalue()
|
|
||||||
return (
|
|
||||||
f"Index rebuilt successfully on branch '{branch}'.\n\n"
|
|
||||||
f"{build_output}"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
return f"Error rebuilding index: {e}"
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
mcp.run()
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
"""Split source files into overlapping text chunks for vector embedding.
|
|
||||||
|
|
||||||
The indexer (indexer.py) calls chunk_file() on every C++, Python, and RST file
|
|
||||||
in the repo. Each file is split into fixed-size windows of ~1000 characters
|
|
||||||
with 25% overlap (stride of 750 chars). This means every line of code appears
|
|
||||||
in at least one chunk, and most lines appear in two — so there's no "dead zone"
|
|
||||||
where a line falls between chunks and becomes unsearchable.
|
|
||||||
|
|
||||||
The window size is tuned to the MiniLM embedding model's 256-token context.
|
|
||||||
Code averages ~4 characters per token, so 1000 chars ≈ 250 tokens — just
|
|
||||||
under the model's limit. Chunks are snapped to line boundaries to avoid
|
|
||||||
splitting mid-line.
|
|
||||||
|
|
||||||
Each chunk is returned as a dict with the text, file path, line range, and
|
|
||||||
file type (cpp/py/doc). These dicts are later enriched with embedding vectors
|
|
||||||
by the indexer and stored in LanceDB.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# ~256 tokens for MiniLM. 1 token ≈ 4 chars for code.
|
|
||||||
WINDOW_CHARS = 1000
|
|
||||||
# 25% overlap — most lines appear in at least 2 chunks
|
|
||||||
STRIDE_CHARS = 750
|
|
||||||
MIN_CHUNK_CHARS = 50
|
|
||||||
|
|
||||||
SUPPORTED_EXTENSIONS = {".cpp", ".h", ".py", ".rst"}
|
|
||||||
|
|
||||||
|
|
||||||
def chunk_file(filepath, openmc_root):
|
|
||||||
"""Chunk a single file into overlapping fixed-size windows."""
|
|
||||||
filepath = Path(filepath)
|
|
||||||
if filepath.suffix not in SUPPORTED_EXTENSIONS:
|
|
||||||
return []
|
|
||||||
|
|
||||||
rel = str(filepath.relative_to(openmc_root))
|
|
||||||
try:
|
|
||||||
content = filepath.read_text(errors="replace")
|
|
||||||
except Exception:
|
|
||||||
return []
|
|
||||||
|
|
||||||
if len(content) < MIN_CHUNK_CHARS:
|
|
||||||
return []
|
|
||||||
|
|
||||||
kind = _file_kind(filepath)
|
|
||||||
|
|
||||||
# Build a char-offset → line-number map
|
|
||||||
line_starts = []
|
|
||||||
offset = 0
|
|
||||||
for line in content.split("\n"):
|
|
||||||
line_starts.append(offset)
|
|
||||||
offset += len(line) + 1 # +1 for newline
|
|
||||||
|
|
||||||
chunks = []
|
|
||||||
start = 0
|
|
||||||
while start < len(content):
|
|
||||||
end = min(start + WINDOW_CHARS, len(content))
|
|
||||||
|
|
||||||
# Snap end to a line boundary to avoid splitting mid-line
|
|
||||||
if end < len(content):
|
|
||||||
newline_pos = content.rfind("\n", start, end)
|
|
||||||
if newline_pos > start:
|
|
||||||
end = newline_pos + 1
|
|
||||||
|
|
||||||
text = content[start:end].strip()
|
|
||||||
if len(text) >= MIN_CHUNK_CHARS:
|
|
||||||
start_line = _offset_to_line(line_starts, start)
|
|
||||||
end_line = _offset_to_line(line_starts, end - 1)
|
|
||||||
chunks.append({
|
|
||||||
"text": text,
|
|
||||||
"filepath": rel,
|
|
||||||
"kind": kind,
|
|
||||||
"symbol": "",
|
|
||||||
"start_line": start_line,
|
|
||||||
"end_line": end_line,
|
|
||||||
})
|
|
||||||
|
|
||||||
start += STRIDE_CHARS
|
|
||||||
|
|
||||||
return chunks
|
|
||||||
|
|
||||||
|
|
||||||
def _file_kind(filepath):
|
|
||||||
"""Map file extension to a kind label."""
|
|
||||||
ext = filepath.suffix
|
|
||||||
if ext in (".cpp", ".h"):
|
|
||||||
return "cpp"
|
|
||||||
elif ext == ".py":
|
|
||||||
return "py"
|
|
||||||
elif ext == ".rst":
|
|
||||||
return "doc"
|
|
||||||
return "other"
|
|
||||||
|
|
||||||
|
|
||||||
def _offset_to_line(line_starts, offset):
|
|
||||||
"""Convert a character offset to a 1-based line number."""
|
|
||||||
# Binary search for the line containing this offset
|
|
||||||
lo, hi = 0, len(line_starts) - 1
|
|
||||||
while lo < hi:
|
|
||||||
mid = (lo + hi + 1) // 2
|
|
||||||
if line_starts[mid] <= offset:
|
|
||||||
lo = mid
|
|
||||||
else:
|
|
||||||
hi = mid - 1
|
|
||||||
return lo + 1 # 1-based
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
"""Thin wrapper around sentence-transformers for embedding text into vectors.
|
|
||||||
|
|
||||||
Uses the all-MiniLM-L6-v2 model — a small (22M param, 384-dim) model that
|
|
||||||
runs on CPU with no GPU or API key required.
|
|
||||||
|
|
||||||
Network behavior and privacy
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
No user code, queries, or file contents are EVER sent to HuggingFace or any
|
|
||||||
external service. All embedding computation happens locally. The only network
|
|
||||||
activity is the one-time model download on first use:
|
|
||||||
|
|
||||||
First run (model not yet cached, ~80MB download):
|
|
||||||
- Downloads model weight files from huggingface.co. This is a standard
|
|
||||||
HTTP file download, similar to pip installing a package.
|
|
||||||
- The only metadata sent in these requests is an HTTP user-agent header
|
|
||||||
containing library version numbers (e.g. "hf_hub/1.6.0;
|
|
||||||
python/3.12.3; torch/2.10.0"). No filenames, file contents, queries,
|
|
||||||
or any user-identifiable information is sent.
|
|
||||||
- The huggingface_hub library has an optional feature where it can report
|
|
||||||
anonymous library usage statistics (just version numbers, not user
|
|
||||||
data) back to HuggingFace. We disable this by setting
|
|
||||||
HF_HUB_DISABLE_TELEMETRY=1.
|
|
||||||
|
|
||||||
Subsequent runs (model already cached):
|
|
||||||
- We set HF_HUB_OFFLINE=1 automatically (see _set_offline_if_cached()
|
|
||||||
below), which prevents ALL network calls. The model loads entirely
|
|
||||||
from the local cache at ~/.cache/huggingface/hub/. Zero bytes leave
|
|
||||||
the machine.
|
|
||||||
|
|
||||||
How the model is downloaded
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
The SentenceTransformer() constructor (called in __init__ below) handles
|
|
||||||
the download automatically on first use. It calls into the huggingface_hub
|
|
||||||
library, which downloads the model files from:
|
|
||||||
|
|
||||||
https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
|
|
||||||
|
|
||||||
The files are saved to ~/.cache/huggingface/hub/ and reused on subsequent
|
|
||||||
runs. We pass token=False to ensure no authentication token is sent.
|
|
||||||
|
|
||||||
This module is imported by both the MCP server (for search queries) and the
|
|
||||||
indexer (for bulk embedding of code chunks). The bulk embed() call shows a
|
|
||||||
progress bar; the single-query embed_query() does not.
|
|
||||||
|
|
||||||
The env vars below must be set before importing transformers or
|
|
||||||
sentence_transformers. They suppress warnings and progress bars that these
|
|
||||||
libraries emit by default. Stray stderr output would interfere with the MCP
|
|
||||||
server's JSON-RPC transport.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
MODEL_NAME = "all-MiniLM-L6-v2"
|
|
||||||
|
|
||||||
# These env vars control logging behavior in the HuggingFace libraries.
|
|
||||||
# They must be set before the libraries are imported.
|
|
||||||
os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error") # suppress warnings
|
|
||||||
os.environ.setdefault("HF_HUB_VERBOSITY", "error") # suppress warnings
|
|
||||||
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
|
|
||||||
os.environ.setdefault("TOKENIZERS_PARALLELISM", "false") # suppress threading warning
|
|
||||||
# Disable anonymous library usage statistics (version numbers only, not user
|
|
||||||
# data — but we disable it anyway as a matter of policy).
|
|
||||||
os.environ.setdefault("HF_HUB_DISABLE_TELEMETRY", "1")
|
|
||||||
|
|
||||||
|
|
||||||
def _set_offline_if_cached():
|
|
||||||
"""If the model has already been downloaded, tell huggingface_hub to
|
|
||||||
skip all network calls by setting HF_HUB_OFFLINE=1.
|
|
||||||
|
|
||||||
Without this, huggingface_hub makes an HTTP request to huggingface.co
|
|
||||||
on every load to check if the cached model is still up to date — even
|
|
||||||
though the model never changes. Setting HF_HUB_OFFLINE=1 prevents this.
|
|
||||||
|
|
||||||
This must run before sentence_transformers is imported, because the
|
|
||||||
library reads the env var at import time.
|
|
||||||
"""
|
|
||||||
# HuggingFace caches downloaded models under ~/.cache/huggingface/hub/
|
|
||||||
# in directories named like "models--sentence-transformers--all-MiniLM-L6-v2".
|
|
||||||
# The HF_HOME env var can override the base cache location.
|
|
||||||
hf_home = os.environ.get("HF_HOME")
|
|
||||||
if hf_home:
|
|
||||||
cache_dir = Path(hf_home) / "hub"
|
|
||||||
else:
|
|
||||||
cache_dir = Path.home() / ".cache" / "huggingface" / "hub"
|
|
||||||
|
|
||||||
model_dir = cache_dir / f"models--sentence-transformers--{MODEL_NAME}"
|
|
||||||
if model_dir.exists():
|
|
||||||
os.environ.setdefault("HF_HUB_OFFLINE", "1")
|
|
||||||
|
|
||||||
|
|
||||||
_set_offline_if_cached()
|
|
||||||
|
|
||||||
# This import must come after the env vars above are set, because the
|
|
||||||
# transformers library reads them at import time.
|
|
||||||
import transformers
|
|
||||||
transformers.logging.disable_progress_bar()
|
|
||||||
|
|
||||||
|
|
||||||
class EmbeddingProvider:
|
|
||||||
"""Sentence-transformers embedder using all-MiniLM-L6-v2."""
|
|
||||||
|
|
||||||
def __init__(self, model_name: str = MODEL_NAME):
|
|
||||||
from sentence_transformers import SentenceTransformer
|
|
||||||
|
|
||||||
# This constructor loads the model from the local cache. If the model
|
|
||||||
# has not been downloaded yet, it downloads it from huggingface.co
|
|
||||||
# (~80MB, one-time). token=False ensures no auth token is sent.
|
|
||||||
self.model = SentenceTransformer(model_name, token=False)
|
|
||||||
self.dim = self.model.get_sentence_embedding_dimension()
|
|
||||||
|
|
||||||
def embed(self, texts: list[str]) -> list[list[float]]:
|
|
||||||
"""Embed a list of texts into vectors."""
|
|
||||||
embeddings = self.model.encode(texts, show_progress_bar=True,
|
|
||||||
batch_size=64)
|
|
||||||
return embeddings.tolist()
|
|
||||||
|
|
||||||
def embed_query(self, text: str) -> list[float]:
|
|
||||||
"""Embed a single query text."""
|
|
||||||
return self.model.encode([text])[0].tolist()
|
|
||||||
|
|
@ -1,136 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""Build the RAG vector index for the OpenMC codebase.
|
|
||||||
|
|
||||||
This is the index-building half of the RAG pipeline. All operations are local
|
|
||||||
once the embedding model has been downloaded and cached (see embeddings.py for
|
|
||||||
details on model download, caching, and network behavior). It walks the repo,
|
|
||||||
chunks every
|
|
||||||
C++/Python/RST file (via chunker.py), embeds all chunks into 384-dim vectors
|
|
||||||
(via embeddings.py), and stores them in a local LanceDB database on disk. The
|
|
||||||
result is a .claude/cache/rag_index/ directory containing two tables — "code"
|
|
||||||
and "docs" — that openmc_search.py queries at search time.
|
|
||||||
|
|
||||||
Building the full index takes ~5 minutes on a 10-core machine. The bottleneck
|
|
||||||
is the embedding step (running all chunks through the MiniLM model on CPU).
|
|
||||||
|
|
||||||
Can be run standalone: python indexer.py
|
|
||||||
Or called programmatically: from indexer import build_index; build_index()
|
|
||||||
The MCP server (openmc_mcp_server.py) uses the latter when the agent calls
|
|
||||||
openmc_rag_rebuild.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import lancedb
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# This file lives at .claude/tools/rag/indexer.py. The sys.path insert lets
|
|
||||||
# us import sibling modules (embeddings, chunker) when run as a standalone
|
|
||||||
# script. When imported from the MCP server, the server has already done this.
|
|
||||||
TOOLS_DIR = Path(__file__).resolve().parent.parent
|
|
||||||
sys.path.insert(0, str(TOOLS_DIR / "rag"))
|
|
||||||
|
|
||||||
from embeddings import EmbeddingProvider
|
|
||||||
from chunker import chunk_file
|
|
||||||
|
|
||||||
|
|
||||||
OPENMC_ROOT = Path(__file__).resolve().parents[3]
|
|
||||||
CACHE_DIR = OPENMC_ROOT / ".claude" / "cache"
|
|
||||||
INDEX_DIR = CACHE_DIR / "rag_index"
|
|
||||||
|
|
||||||
CODE_PATTERNS = [
|
|
||||||
"src/**/*.cpp",
|
|
||||||
"include/openmc/**/*.h",
|
|
||||||
"openmc/**/*.py",
|
|
||||||
"tests/**/*.py",
|
|
||||||
"examples/**/*.py",
|
|
||||||
]
|
|
||||||
|
|
||||||
DOC_PATTERNS = [
|
|
||||||
"docs/**/*.rst",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def collect_chunks(patterns, openmc_root):
|
|
||||||
"""Collect all chunks from files matching the given patterns."""
|
|
||||||
chunks = []
|
|
||||||
for pattern in patterns:
|
|
||||||
for filepath in sorted(openmc_root.glob(pattern)):
|
|
||||||
if "__pycache__" in str(filepath):
|
|
||||||
continue
|
|
||||||
file_chunks = chunk_file(filepath, openmc_root)
|
|
||||||
chunks.extend(file_chunks)
|
|
||||||
return chunks
|
|
||||||
|
|
||||||
|
|
||||||
def build_index():
|
|
||||||
"""Build or rebuild the complete vector index."""
|
|
||||||
start = time.time()
|
|
||||||
|
|
||||||
# Collect all chunks
|
|
||||||
print("Collecting code chunks...")
|
|
||||||
code_chunks = collect_chunks(CODE_PATTERNS, OPENMC_ROOT)
|
|
||||||
print(f" {len(code_chunks)} code chunks")
|
|
||||||
|
|
||||||
print("Collecting doc chunks...")
|
|
||||||
doc_chunks = collect_chunks(DOC_PATTERNS, OPENMC_ROOT)
|
|
||||||
print(f" {len(doc_chunks)} doc chunks")
|
|
||||||
|
|
||||||
all_chunks = code_chunks + doc_chunks
|
|
||||||
if not all_chunks:
|
|
||||||
print("ERROR: No chunks collected!", file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Create embeddings
|
|
||||||
all_texts = [c["text"] for c in all_chunks]
|
|
||||||
print("Creating embedding provider...")
|
|
||||||
embedder = EmbeddingProvider()
|
|
||||||
print(f" dim={embedder.dim}")
|
|
||||||
|
|
||||||
print("Embedding chunks...")
|
|
||||||
all_embeddings = embedder.embed(all_texts)
|
|
||||||
|
|
||||||
# Build LanceDB tables
|
|
||||||
INDEX_DIR.mkdir(parents=True, exist_ok=True)
|
|
||||||
db = lancedb.connect(str(INDEX_DIR))
|
|
||||||
|
|
||||||
# Separate code vs doc records by index (code_chunks come first in all_chunks)
|
|
||||||
n_code = len(code_chunks)
|
|
||||||
code_records = []
|
|
||||||
doc_records = []
|
|
||||||
for i, (chunk, emb) in enumerate(zip(all_chunks, all_embeddings)):
|
|
||||||
record = {
|
|
||||||
"text": chunk["text"],
|
|
||||||
"filepath": chunk["filepath"],
|
|
||||||
"kind": chunk["kind"],
|
|
||||||
"symbol": chunk.get("symbol", ""),
|
|
||||||
"start_line": chunk.get("start_line", 0),
|
|
||||||
"end_line": chunk.get("end_line", 0),
|
|
||||||
"vector": emb,
|
|
||||||
}
|
|
||||||
if i < n_code:
|
|
||||||
code_records.append(record)
|
|
||||||
else:
|
|
||||||
doc_records.append(record)
|
|
||||||
|
|
||||||
# Create tables (drop existing)
|
|
||||||
result = db.table_names() if hasattr(db, "table_names") else db.list_tables()
|
|
||||||
existing = result.tables if hasattr(result, "tables") else list(result)
|
|
||||||
for table_name in ("code", "docs"):
|
|
||||||
if table_name in existing:
|
|
||||||
db.drop_table(table_name)
|
|
||||||
|
|
||||||
if code_records:
|
|
||||||
db.create_table("code", code_records)
|
|
||||||
print(f" Created 'code' table: {len(code_records)} rows")
|
|
||||||
|
|
||||||
if doc_records:
|
|
||||||
db.create_table("docs", doc_records)
|
|
||||||
print(f" Created 'docs' table: {len(doc_records)} rows")
|
|
||||||
|
|
||||||
elapsed = time.time() - start
|
|
||||||
print(f"Done in {elapsed:.1f}s")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
build_index()
|
|
||||||
|
|
@ -1,202 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""Query the RAG vector index to find semantically related code and docs.
|
|
||||||
|
|
||||||
This is the query-time half of the RAG pipeline (the counterpart to indexer.py,
|
|
||||||
which builds the index). All operations are local — no network calls are made
|
|
||||||
once the embedding model has been downloaded (see embeddings.py for details on
|
|
||||||
model download and caching). Given a natural-language query, it embeds the query
|
|
||||||
with the same MiniLM model
|
|
||||||
used at index time, then finds the closest chunks in the local LanceDB vector
|
|
||||||
database by cosine similarity.
|
|
||||||
|
|
||||||
The core functions (get_db_and_embedder, search_table, format_results,
|
|
||||||
search_related) are imported by the MCP server for tool calls. The script
|
|
||||||
can also be run standalone from the command line.
|
|
||||||
|
|
||||||
The "related file" mode works differently from a text query: it reads the
|
|
||||||
target file's chunks from the index, combines them into a synthetic query
|
|
||||||
vector, and searches for the nearest chunks from *other* files. This surfaces
|
|
||||||
files that are semantically similar to the target file.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
openmc_search.py "query" # Search code (default)
|
|
||||||
openmc_search.py "query" --docs # Search documentation
|
|
||||||
openmc_search.py "query" --all # Search both code and docs
|
|
||||||
openmc_search.py --related src/particle.cpp # Find related code
|
|
||||||
openmc_search.py "query" --top-k 20 # Return more results
|
|
||||||
"""
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# Same sys.path setup as indexer.py — needed for standalone CLI use.
|
|
||||||
TOOLS_DIR = Path(__file__).resolve().parent.parent
|
|
||||||
sys.path.insert(0, str(TOOLS_DIR / "rag"))
|
|
||||||
|
|
||||||
OPENMC_ROOT = Path(__file__).resolve().parents[3]
|
|
||||||
CACHE_DIR = OPENMC_ROOT / ".claude" / "cache"
|
|
||||||
INDEX_DIR = CACHE_DIR / "rag_index"
|
|
||||||
|
|
||||||
|
|
||||||
def get_db_and_embedder():
|
|
||||||
"""Load the LanceDB database and embedding provider."""
|
|
||||||
import lancedb
|
|
||||||
from embeddings import EmbeddingProvider
|
|
||||||
|
|
||||||
if not INDEX_DIR.exists():
|
|
||||||
raise FileNotFoundError(
|
|
||||||
"No RAG index found. Call openmc_rag_rebuild() to build one."
|
|
||||||
)
|
|
||||||
|
|
||||||
db = lancedb.connect(str(INDEX_DIR))
|
|
||||||
|
|
||||||
embedder = EmbeddingProvider()
|
|
||||||
return db, embedder
|
|
||||||
|
|
||||||
|
|
||||||
def _table_names(db):
|
|
||||||
"""Return table names as a list, compatible with multiple LanceDB versions."""
|
|
||||||
result = db.table_names() if hasattr(db, "table_names") else db.list_tables()
|
|
||||||
return result.tables if hasattr(result, "tables") else list(result)
|
|
||||||
|
|
||||||
|
|
||||||
def search_table(db, embedder, table_name, query, top_k):
|
|
||||||
"""Search a LanceDB table with a text query."""
|
|
||||||
if table_name not in _table_names(db):
|
|
||||||
print(f"Table '{table_name}' not found in index.", file=sys.stderr)
|
|
||||||
return []
|
|
||||||
|
|
||||||
table = db.open_table(table_name)
|
|
||||||
query_vec = embedder.embed_query(query)
|
|
||||||
results = table.search(query_vec).limit(top_k).to_list()
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
def format_results(results, label=""):
|
|
||||||
"""Format search results for display."""
|
|
||||||
if not results:
|
|
||||||
return "No results found.\n"
|
|
||||||
|
|
||||||
output = []
|
|
||||||
if label:
|
|
||||||
output.append(f"=== {label} ===\n")
|
|
||||||
|
|
||||||
for i, r in enumerate(results, 1):
|
|
||||||
filepath = r["filepath"]
|
|
||||||
start = r["start_line"]
|
|
||||||
end = r["end_line"]
|
|
||||||
kind = r["kind"]
|
|
||||||
dist = r.get("_distance", 0)
|
|
||||||
|
|
||||||
header = f"[{i}] {filepath}:{start}-{end} ({kind}, dist={dist:.3f})"
|
|
||||||
output.append(header)
|
|
||||||
|
|
||||||
# Show text preview (first 500 chars)
|
|
||||||
text = r["text"][:500]
|
|
||||||
if len(r["text"]) > 500:
|
|
||||||
text += "\n ..."
|
|
||||||
# Indent the text
|
|
||||||
for line in text.split("\n"):
|
|
||||||
output.append(f" {line}")
|
|
||||||
output.append("")
|
|
||||||
|
|
||||||
return "\n".join(output)
|
|
||||||
|
|
||||||
|
|
||||||
def search_related(db, embedder, filepath, top_k):
|
|
||||||
"""Find code related to a given file."""
|
|
||||||
if "code" not in _table_names(db):
|
|
||||||
print("No 'code' table in index.", file=sys.stderr)
|
|
||||||
return []
|
|
||||||
|
|
||||||
table = db.open_table("code")
|
|
||||||
|
|
||||||
# Normalize filepath
|
|
||||||
fp = filepath
|
|
||||||
if Path(filepath).is_absolute():
|
|
||||||
try:
|
|
||||||
fp = str(Path(filepath).relative_to(OPENMC_ROOT))
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Get chunks from target file
|
|
||||||
try:
|
|
||||||
safe_fp = fp.replace("'", "''")
|
|
||||||
target_chunks = table.search().where(
|
|
||||||
f"filepath = '{safe_fp}'"
|
|
||||||
).limit(50).to_list()
|
|
||||||
except Exception:
|
|
||||||
# LanceDB where clause might not work in all versions
|
|
||||||
# Fall back to fetching all and filtering
|
|
||||||
all_data = table.to_pandas()
|
|
||||||
target_rows = all_data[all_data["filepath"] == fp]
|
|
||||||
if target_rows.empty:
|
|
||||||
print(f"No chunks found for '{fp}'", file=sys.stderr)
|
|
||||||
return []
|
|
||||||
target_chunks = target_rows.head(50).to_dict("records")
|
|
||||||
|
|
||||||
if not target_chunks:
|
|
||||||
print(f"No chunks found for '{fp}'", file=sys.stderr)
|
|
||||||
return []
|
|
||||||
|
|
||||||
# Combine top chunks as the query
|
|
||||||
combined_text = " ".join(c["text"][:200] for c in target_chunks[:5])
|
|
||||||
query_vec = embedder.embed_query(combined_text)
|
|
||||||
|
|
||||||
# Search excluding the source file
|
|
||||||
results = table.search(query_vec).limit(top_k + 10).to_list()
|
|
||||||
# Filter out same file
|
|
||||||
results = [r for r in results if r["filepath"] != fp][:top_k]
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description="Semantic search across OpenMC codebase and docs",
|
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
||||||
epilog="""examples:
|
|
||||||
%(prog)s "particle random number seed initialization"
|
|
||||||
%(prog)s "how to define tallies" --docs
|
|
||||||
%(prog)s "weight window variance reduction" --all
|
|
||||||
%(prog)s "where is cross section data loaded" --top-k 15
|
|
||||||
%(prog)s --related src/simulation.cpp
|
|
||||||
%(prog)s --related src/particle_restart.cpp --top-k 5""",
|
|
||||||
)
|
|
||||||
parser.add_argument("query", nargs="?", help="Search query")
|
|
||||||
parser.add_argument("--docs", action="store_true",
|
|
||||||
help="Search documentation instead of code")
|
|
||||||
parser.add_argument("--all", action="store_true",
|
|
||||||
help="Search both code and documentation")
|
|
||||||
parser.add_argument("--related", metavar="FILE",
|
|
||||||
help="Find code related to a given file")
|
|
||||||
parser.add_argument("--top-k", type=int, default=10,
|
|
||||||
help="Number of results (default: 10)")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if not args.query and not args.related:
|
|
||||||
parser.print_help()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
db, embedder = get_db_and_embedder()
|
|
||||||
|
|
||||||
if args.related:
|
|
||||||
results = search_related(db, embedder, args.related, args.top_k)
|
|
||||||
print(format_results(results, f"Code related to {args.related}"))
|
|
||||||
elif args.all:
|
|
||||||
code_results = search_table(
|
|
||||||
db, embedder, "code", args.query, args.top_k)
|
|
||||||
doc_results = search_table(
|
|
||||||
db, embedder, "docs", args.query, args.top_k)
|
|
||||||
print(format_results(code_results, "Code"))
|
|
||||||
print(format_results(doc_results, "Documentation"))
|
|
||||||
elif args.docs:
|
|
||||||
results = search_table(db, embedder, "docs", args.query, args.top_k)
|
|
||||||
print(format_results(results, "Documentation"))
|
|
||||||
else:
|
|
||||||
results = search_table(db, embedder, "code", args.query, args.top_k)
|
|
||||||
print(format_results(results, "Code"))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
# MCP server
|
|
||||||
mcp>=1.0.0
|
|
||||||
|
|
||||||
# Vector database
|
|
||||||
lancedb>=0.15.0
|
|
||||||
|
|
||||||
# Embeddings (local, no API key)
|
|
||||||
sentence-transformers>=2.7.0
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Bootstrap the Python venv (if needed) and start the OpenMC MCP server.
|
|
||||||
set -e
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
||||||
CACHE_DIR="$(dirname "$SCRIPT_DIR")/cache"
|
|
||||||
VENV_DIR="$CACHE_DIR/.venv"
|
|
||||||
SENTINEL="$VENV_DIR/.installed"
|
|
||||||
|
|
||||||
if ! command -v python3 >/dev/null 2>&1; then
|
|
||||||
echo "Error: python3 not found on PATH." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! python3 -c 'import sys; assert sys.version_info >= (3,12)' 2>/dev/null; then
|
|
||||||
echo "Error: Python 3.12+ is required." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "$SENTINEL" ]; then
|
|
||||||
rm -rf "$VENV_DIR"
|
|
||||||
mkdir -p "$CACHE_DIR"
|
|
||||||
python3 -m venv "$VENV_DIR"
|
|
||||||
|
|
||||||
if ! "$VENV_DIR/bin/pip" install -q -r "$SCRIPT_DIR/requirements.txt"; then
|
|
||||||
echo "Error: pip install failed. Remove $VENV_DIR and retry." >&2
|
|
||||||
rm -rf "$VENV_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
touch "$SENTINEL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$VENV_DIR/bin/python" "$SCRIPT_DIR/openmc_mcp_server.py"
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
# Applied clang-format to all source files
|
|
||||||
1bc2bd84600c8d2ca9253339c167401127f6a9f3
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
commit: $Format:%H$
|
|
||||||
commit-date: $Format:%cI$
|
|
||||||
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
|
|
||||||
1
.gitattributes
vendored
|
|
@ -1 +0,0 @@
|
||||||
.git_archival.txt export-subst
|
|
||||||
29
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
|
@ -1,29 +0,0 @@
|
||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Report a bug that is preventing proper operation
|
|
||||||
title: ''
|
|
||||||
labels: Bugs
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--
|
|
||||||
If you are a user of OpenMC and are running into trouble with the code or are
|
|
||||||
seeking general user support, we highly recommend posting on the OpenMC
|
|
||||||
discourse forum first. GitHub issues should be used specifically for bug reports
|
|
||||||
and feature requests.
|
|
||||||
|
|
||||||
https://openmc.discourse.group/
|
|
||||||
|
|
||||||
-->
|
|
||||||
|
|
||||||
## Bug Description
|
|
||||||
<!--A clear and concise description of the problem (Note: A missing feature is not a bug).-->
|
|
||||||
|
|
||||||
|
|
||||||
## Steps to Reproduce
|
|
||||||
<!--Steps to reproduce the behavior (input file, or modifications to an existing input file, etc.)-->
|
|
||||||
|
|
||||||
|
|
||||||
## Environment
|
|
||||||
<!--Operating system, OpenMC version, how OpenMC was installed, nuclear data being used, etc.-->
|
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1,5 +0,0 @@
|
||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Troubleshooting and User Support
|
|
||||||
url: https://openmc.discourse.group/
|
|
||||||
about: For user support and troubleshooting, please use our Discourse forum
|
|
||||||
10
.github/ISSUE_TEMPLATE/documentation.md
vendored
|
|
@ -1,10 +0,0 @@
|
||||||
---
|
|
||||||
name: Documentation improvement
|
|
||||||
about: Found something incomplete or incorrect in our documentation?
|
|
||||||
title: ''
|
|
||||||
labels: Documentation
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--Describe the issue with the documentation and include a URL to the corresponding page-->
|
|
||||||
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
|
@ -1,19 +0,0 @@
|
||||||
---
|
|
||||||
name: Feature or enhancement request
|
|
||||||
about: Suggest a new feature or enhancement to existing capabilities
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Description
|
|
||||||
<!--What is the feature or enhancement?-->
|
|
||||||
|
|
||||||
|
|
||||||
## Alternatives
|
|
||||||
<!--If alternative solutions have been considered, describe them here and the reasoning for the chosen solution --->
|
|
||||||
|
|
||||||
|
|
||||||
## Compatibility
|
|
||||||
<!--Will the enhancement change existing APIs or add something new?-->
|
|
||||||
8
.github/agents/Review.agent.md
vendored
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
name: Review
|
|
||||||
description: Reviews code changes on the current branch, evaluating them against OpenMC's contribution criteria and providing structured feedback.
|
|
||||||
argument-hint: Optionally provide a focus area (e.g., "focus on physics correctness", "check Python API design"). If omitted, a full review is performed.
|
|
||||||
---
|
|
||||||
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.
|
|
||||||
|
|
||||||
If the user provides a focus area, prioritize that section of the review.
|
|
||||||
1
.github/copilot-instructions.md
vendored
|
|
@ -1 +0,0 @@
|
||||||
When reviewing code changes in this repository, use the `reviewing-openmc-code` skill.
|
|
||||||
24
.github/pull_request_template.md
vendored
|
|
@ -1,24 +0,0 @@
|
||||||
<!--
|
|
||||||
If you are a first-time contributor to OpenMC, please have a look at our
|
|
||||||
contributing guidelines:
|
|
||||||
https://github.com/openmc-dev/openmc/blob/develop/CONTRIBUTING.md
|
|
||||||
-->
|
|
||||||
|
|
||||||
# Description
|
|
||||||
|
|
||||||
Please include a summary of the change and which issue is fixed if applicable. Please also include relevant motivation and context.
|
|
||||||
|
|
||||||
Fixes # (issue)
|
|
||||||
|
|
||||||
# Checklist
|
|
||||||
|
|
||||||
- [ ] I have performed a self-review of my own code
|
|
||||||
- [ ] 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)
|
|
||||||
- [ ] I have followed the [style guidelines](https://docs.openmc.org/en/latest/devguide/styleguide.html#python) for Python source files (if applicable)
|
|
||||||
- [ ] I have made corresponding changes to the documentation (if applicable)
|
|
||||||
- [ ] I have added tests that prove my fix is effective or that my feature works (if applicable)
|
|
||||||
<!--
|
|
||||||
While tests will automatically be checked by CI, it is good practice to
|
|
||||||
ensure that they pass locally first. See instructions here:
|
|
||||||
https://docs.openmc.org/en/latest/devguide/tests.html
|
|
||||||
-->
|
|
||||||
208
.github/workflows/ci.yml
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
name: Tests and Coverage
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# allows us to run workflows manually
|
# allows us to run workflows manually
|
||||||
|
|
@ -20,65 +20,51 @@ env:
|
||||||
COVERALLS_PARALLEL: true
|
COVERALLS_PARALLEL: true
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
filter-changes:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
source_changed: ${{ steps.filter.outputs.source_changed }}
|
|
||||||
steps:
|
|
||||||
- name: Check out the repository
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
- name: Examine changed files
|
|
||||||
id: filter
|
|
||||||
uses: dorny/paths-filter@v4
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
source_changed:
|
|
||||||
- '!docs/**'
|
|
||||||
- '!**/*.md'
|
|
||||||
predicate-quantifier: 'every'
|
|
||||||
main:
|
main:
|
||||||
needs: filter-changes
|
runs-on: ubuntu-20.04
|
||||||
if: ${{ needs.filter-changes.outputs.source_changed == 'true' }}
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.12"]
|
python-version: [3.8]
|
||||||
mpi: [n, y]
|
mpi: [n, y]
|
||||||
omp: [n, y]
|
omp: [n, y]
|
||||||
dagmc: [n]
|
dagmc: [n]
|
||||||
libmesh: [n]
|
libmesh: [n]
|
||||||
event: [n]
|
event: [n]
|
||||||
|
vectfit: [n]
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- python-version: "3.13"
|
- python-version: 3.6
|
||||||
omp: n
|
omp: n
|
||||||
mpi: n
|
mpi: n
|
||||||
- python-version: "3.14"
|
- python-version: 3.7
|
||||||
omp: n
|
|
||||||
mpi: n
|
|
||||||
- python-version: "3.14t"
|
|
||||||
omp: n
|
omp: n
|
||||||
mpi: n
|
mpi: n
|
||||||
- dagmc: y
|
- dagmc: y
|
||||||
python-version: "3.12"
|
python-version: 3.8
|
||||||
mpi: y
|
mpi: y
|
||||||
omp: y
|
omp: y
|
||||||
- libmesh: y
|
- libmesh: y
|
||||||
python-version: "3.12"
|
python-version: 3.8
|
||||||
mpi: y
|
mpi: y
|
||||||
omp: y
|
omp: y
|
||||||
- libmesh: y
|
- libmesh: y
|
||||||
python-version: "3.12"
|
python-version: 3.8
|
||||||
mpi: n
|
mpi: n
|
||||||
omp: y
|
omp: y
|
||||||
- event: y
|
- event: y
|
||||||
python-version: "3.12"
|
python-version: 3.8
|
||||||
omp: y
|
omp: y
|
||||||
mpi: n
|
mpi: n
|
||||||
name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }},
|
- vectfit: y
|
||||||
|
python-version: 3.8
|
||||||
|
omp: n
|
||||||
|
mpi: y
|
||||||
|
name: 'Python ${{ matrix.python-version }} (omp=${{ matrix.omp }},
|
||||||
mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }},
|
mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }},
|
||||||
libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }}"
|
libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }}
|
||||||
|
vectfit=${{ matrix.vectfit }})'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MPI: ${{ matrix.mpi }}
|
MPI: ${{ matrix.mpi }}
|
||||||
|
|
@ -86,163 +72,67 @@ jobs:
|
||||||
OMP: ${{ matrix.omp }}
|
OMP: ${{ matrix.omp }}
|
||||||
DAGMC: ${{ matrix.dagmc }}
|
DAGMC: ${{ matrix.dagmc }}
|
||||||
EVENT: ${{ matrix.event }}
|
EVENT: ${{ matrix.event }}
|
||||||
|
VECTFIT: ${{ matrix.vectfit }}
|
||||||
LIBMESH: ${{ matrix.libmesh }}
|
LIBMESH: ${{ matrix.libmesh }}
|
||||||
NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX"
|
|
||||||
OPENBLAS_NUM_THREADS: 1
|
|
||||||
PYTEST_ADDOPTS: --cov=openmc --cov-report=lcov:coverage-python.lcov
|
|
||||||
# libfabric complains about fork() as a result of using Python multiprocessing.
|
|
||||||
# We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with
|
|
||||||
# FI_EFA_FORK_SAFE=1 in more recent versions.
|
|
||||||
RDMAV_FORK_SAFE: 1
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup cmake
|
- uses: actions/checkout@v2
|
||||||
uses: jwlawson/actions-setup-cmake@v2
|
|
||||||
with:
|
|
||||||
cmake-version: '3.31'
|
|
||||||
|
|
||||||
- name: Checkout repository
|
-
|
||||||
uses: actions/checkout@v6
|
name: Set up Python ${{ matrix.python-version }}
|
||||||
with:
|
uses: actions/setup-python@v2
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v6
|
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
-
|
||||||
- name: Environment Variables
|
name: Environment Variables
|
||||||
run: |
|
run: |
|
||||||
|
echo "DAGMC_ROOT=$HOME/DAGMC"
|
||||||
echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV
|
echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV
|
||||||
echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV
|
echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV
|
||||||
# get the sha of the last branch commit
|
|
||||||
# for push and workflow_dispatch events, use the current reference head
|
|
||||||
BRANCH_SHA=HEAD
|
|
||||||
# for a pull_request event, use the last reference of the parents of the merge commit
|
|
||||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
|
||||||
BRANCH_SHA=$(git rev-list --parents -n 1 HEAD | rev | cut -d" " -f 1 | rev)
|
|
||||||
fi
|
|
||||||
COMMIT_MESSAGE=$(git log $BRANCH_SHA -1 --pretty=%B | tr '\n' ' ')
|
|
||||||
echo ${COMMIT_MESSAGE}
|
|
||||||
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Apt dependencies
|
-
|
||||||
|
name: Apt dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt -y update
|
sudo apt -y update
|
||||||
sudo apt install -y libpng-dev \
|
sudo apt install -y libmpich-dev \
|
||||||
libnetcdf-dev \
|
libnetcdf-dev \
|
||||||
libpnetcdf-dev \
|
libpnetcdf-dev \
|
||||||
libhdf5-serial-dev \
|
libhdf5-serial-dev \
|
||||||
|
libhdf5-mpich-dev \
|
||||||
libeigen3-dev
|
libeigen3-dev
|
||||||
|
|
||||||
- name: Optional apt dependencies for MPI
|
|
||||||
shell: bash
|
|
||||||
if: ${{ matrix.mpi == 'y' }}
|
|
||||||
run: |
|
|
||||||
sudo apt install -y libhdf5-mpich-dev \
|
|
||||||
libmpich-dev
|
|
||||||
sudo update-alternatives --set mpi /usr/bin/mpicc.mpich
|
sudo update-alternatives --set mpi /usr/bin/mpicc.mpich
|
||||||
sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich
|
sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich
|
||||||
sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich
|
sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich
|
||||||
|
|
||||||
- name: install
|
-
|
||||||
|
name: install
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "$HOME/NJOY2016/build" >> $GITHUB_PATH
|
echo "$HOME/NJOY2016/build" >> $GITHUB_PATH
|
||||||
$GITHUB_WORKSPACE/tools/ci/gha-install.sh
|
$GITHUB_WORKSPACE/tools/ci/gha-install.sh
|
||||||
|
-
|
||||||
- name: display-config
|
name: before
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
openmc -v
|
|
||||||
|
|
||||||
- name: cache-xs
|
|
||||||
uses: actions/cache@v5
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/nndc_hdf5
|
|
||||||
~/endf-b-vii.1
|
|
||||||
key: ${{ runner.os }}-build-xs-cache-${{ hashFiles(format('{0}/tools/ci/download-xs.sh', github.workspace)) }}
|
|
||||||
|
|
||||||
- name: before
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh
|
run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh
|
||||||
|
-
|
||||||
|
name: test
|
||||||
|
shell: bash
|
||||||
|
run: $GITHUB_WORKSPACE/tools/ci/gha-script.sh
|
||||||
|
|
||||||
- name: test
|
-
|
||||||
|
name: after_success
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
CTEST_OUTPUT_ON_FAILURE=1 make test -C $GITHUB_WORKSPACE/build/
|
cpp-coveralls -i src -i include --exclude-pattern "/usr/*" --dump cpp_cov.json
|
||||||
$GITHUB_WORKSPACE/tools/ci/gha-script.sh
|
coveralls --merge=cpp_cov.json --service=github
|
||||||
|
|
||||||
- name: Setup tmate debug session
|
finish:
|
||||||
continue-on-error: true
|
needs: main
|
||||||
if: ${{ failure() && contains(env.COMMIT_MESSAGE, '[gha-debug]') }}
|
|
||||||
uses: mxschmitt/action-tmate@v3
|
|
||||||
timeout-minutes: 10
|
|
||||||
|
|
||||||
- name: Generate C++ coverage (gcovr)
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# Produce LCOV directly from gcov data in the build tree
|
|
||||||
gcovr \
|
|
||||||
--root "$GITHUB_WORKSPACE" \
|
|
||||||
--object-directory "$GITHUB_WORKSPACE/build" \
|
|
||||||
--filter "$GITHUB_WORKSPACE/src" \
|
|
||||||
--filter "$GITHUB_WORKSPACE/include" \
|
|
||||||
--exclude "$GITHUB_WORKSPACE/src/external/.*" \
|
|
||||||
--exclude "$GITHUB_WORKSPACE/src/include/openmc/external/.*" \
|
|
||||||
--gcov-ignore-errors source_not_found \
|
|
||||||
--gcov-ignore-errors output_error \
|
|
||||||
--gcov-ignore-parse-errors suspicious_hits.warn \
|
|
||||||
--merge-mode-functions=separate \
|
|
||||||
--print-summary \
|
|
||||||
--lcov -o coverage-cpp.lcov || true
|
|
||||||
|
|
||||||
- name: Merge C++ and Python coverage
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# Merge C++ and Python LCOV into a single file for upload
|
|
||||||
cat coverage-cpp.lcov coverage-python.lcov > coverage.lcov
|
|
||||||
|
|
||||||
- name: Upload coverage to Coveralls
|
|
||||||
if: ${{ hashFiles('coverage.lcov') != '' }}
|
|
||||||
uses: coverallsapp/github-action@v2
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
parallel: true
|
|
||||||
flag-name: C++ and Python
|
|
||||||
path-to-lcov: coverage.lcov
|
|
||||||
fail-on-error: false
|
|
||||||
|
|
||||||
coverage:
|
|
||||||
needs: [filter-changes, main]
|
|
||||||
if: ${{ always() }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Coveralls Finished
|
- name: Coveralls Finished
|
||||||
if: ${{ needs.filter-changes.outputs.source_changed == 'true' }}
|
uses: coverallsapp/github-action@master
|
||||||
uses: coverallsapp/github-action@v2
|
with:
|
||||||
with:
|
github-token: ${{ secrets.github_token }}
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
parallel-finished: true
|
||||||
parallel-finished: true
|
|
||||||
fail-on-error: false
|
|
||||||
|
|
||||||
ci-pass:
|
|
||||||
needs: [filter-changes, main, coverage]
|
|
||||||
name: Check CI status
|
|
||||||
if: ${{ always() }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check CI status
|
|
||||||
run: |
|
|
||||||
if [[ "${{ needs.filter-changes.outputs.source_changed }}" == "false" ]]; then
|
|
||||||
echo "Documentation-only change - CI skipped successfully"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if [[ "${{ needs.main.result }}" == "success" && "${{ needs.coverage.result }}" == "success" ]]; then
|
|
||||||
echo "CI passed"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "CI failed"
|
|
||||||
exit 1
|
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
name: dockerhub-publish-latest-dagmc-libmesh
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: openmc/openmc:latest-dagmc-libmesh
|
|
||||||
build-args: |
|
|
||||||
build_dagmc=on
|
|
||||||
build_libmesh=on
|
|
||||||
compile_cores=2
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
13
.github/workflows/dockerhub-publish-dagmc.yml
vendored
|
|
@ -2,8 +2,7 @@ name: dockerhub-publish-latest-dagmc
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: master
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
|
|
@ -11,25 +10,25 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: openmc/openmc:latest-dagmc
|
tags: openmc/openmc:latest-dagmc
|
||||||
build-args: |
|
build-args: |
|
||||||
build_dagmc=on
|
include_dagmc=true
|
||||||
compile_cores=2
|
compile_cores=2
|
||||||
-
|
-
|
||||||
name: Image digest
|
name: Image digest
|
||||||
|
|
|
||||||
12
.github/workflows/dockerhub-publish-dev.yml
vendored
|
|
@ -2,8 +2,7 @@ name: dockerhub-publish-develop
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: develop
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
|
|
@ -11,26 +10,25 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: openmc/openmc:develop
|
tags: openmc/openmc:develop
|
||||||
build-args: |
|
build-args: |
|
||||||
compile_cores=2
|
compile_cores=2
|
||||||
openmc_branch=develop
|
|
||||||
-
|
-
|
||||||
name: Image digest
|
name: Image digest
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
name: dockerhub-publish-develop-dagmc-libmesh
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: openmc/openmc:develop-dagmc-libmesh
|
|
||||||
build-args: |
|
|
||||||
build_dagmc=on
|
|
||||||
build_libmesh=on
|
|
||||||
compile_cores=2
|
|
||||||
openmc_branch=develop
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
|
|
@ -2,8 +2,7 @@ name: dockerhub-publish-develop-dagmc
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: develop
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
|
|
@ -11,27 +10,26 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: openmc/openmc:develop-dagmc
|
tags: openmc/openmc:develop-dagmc
|
||||||
build-args: |
|
build-args: |
|
||||||
build_dagmc=on
|
include_dagmc=true
|
||||||
compile_cores=2
|
compile_cores=2
|
||||||
openmc_branch=develop
|
|
||||||
-
|
-
|
||||||
name: Image digest
|
name: Image digest
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
name: dockerhub-publish-develop-libmesh
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: openmc/openmc:develop-libmesh
|
|
||||||
build-args: |
|
|
||||||
build_libmesh=on
|
|
||||||
compile_cores=2
|
|
||||||
openmc_branch=develop
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
36
.github/workflows/dockerhub-publish-libmesh.yml
vendored
|
|
@ -1,36 +0,0 @@
|
||||||
name: dockerhub-publish-latest-libmesh
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: openmc/openmc:latest-libmesh
|
|
||||||
build-args: |
|
|
||||||
build_libmesh=on
|
|
||||||
compile_cores=2
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
name: dockerhub-publish-release-dagmc-libmesh
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*.*.*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Set env
|
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-dagmc-libmesh
|
|
||||||
build-args: |
|
|
||||||
build_dagmc=on
|
|
||||||
build_libmesh=on
|
|
||||||
compile_cores=2
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
|
|
@ -2,37 +2,36 @@ name: dockerhub-publish-release-dagmc
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags: 'v*.*.*'
|
||||||
- 'v*.*.*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v2
|
||||||
- name: Set env
|
- name: Set env
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-dagmc
|
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-dagmc
|
||||||
build-args: |
|
build-args: |
|
||||||
build_dagmc=on
|
include_dagmc=true
|
||||||
compile_cores=2
|
compile_cores=2
|
||||||
-
|
-
|
||||||
name: Image digest
|
name: Image digest
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
name: dockerhub-publish-release-libmesh
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*.*.*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Set env
|
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}-libmesh
|
|
||||||
build-args: |
|
|
||||||
build_libmesh=on
|
|
||||||
compile_cores=2
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
13
.github/workflows/dockerhub-publish-release.yml
vendored
|
|
@ -2,32 +2,31 @@ name: dockerhub-publish-release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags: 'v*.*.*'
|
||||||
- 'v*.*.*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v2
|
||||||
- name: Set env
|
- name: Set env
|
||||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: openmc/openmc:${{ env.RELEASE_VERSION }}
|
tags: openmc/openmc:${{ env.RELEASE_VERSION }}
|
||||||
|
|
|
||||||
11
.github/workflows/dockerhub-publish.yml
vendored
|
|
@ -2,8 +2,7 @@ name: dockerhub-publish-latest
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: master
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
main:
|
||||||
|
|
@ -11,20 +10,20 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: openmc/openmc:latest
|
tags: openmc/openmc:latest
|
||||||
|
|
|
||||||
60
.github/workflows/format-check.yml
vendored
|
|
@ -1,60 +0,0 @@
|
||||||
name: C++ Format Check
|
|
||||||
|
|
||||||
on:
|
|
||||||
# allow workflow to be run manually
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
- labeled
|
|
||||||
- unlabeled
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
cpp-linter:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: cpp-linter/cpp-linter-action@v2
|
|
||||||
id: linter
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
style: file
|
|
||||||
files-changed-only: true
|
|
||||||
tidy-checks: '-*'
|
|
||||||
version: '18' # clang-format version
|
|
||||||
format-review: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }}
|
|
||||||
passive-reviews: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest') }}
|
|
||||||
file-annotations: true
|
|
||||||
step-summary: true
|
|
||||||
extensions: 'cpp,h'
|
|
||||||
|
|
||||||
- name: Comment with suggestion instructions
|
|
||||||
if: steps.linter.outputs.checks-failed > 0 && !contains(github.event.pull_request.labels.*.name, 'cpp-format-suggest')
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const {owner, repo} = context.repo;
|
|
||||||
const issue_number = context.payload.pull_request.number;
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number,
|
|
||||||
body: "C++ formatting checks failed. Add the `cpp-format-suggest` label to this PR for inline formatting suggestions on the next run."
|
|
||||||
});
|
|
||||||
|
|
||||||
- name: Failure Check
|
|
||||||
if: steps.linter.outputs.checks-failed > 0
|
|
||||||
run: |
|
|
||||||
echo "Some files failed the formatting check."
|
|
||||||
echo "See job summary and file annotations for details."
|
|
||||||
exit 1
|
|
||||||
26
.gitignore
vendored
|
|
@ -1,9 +1,9 @@
|
||||||
# Compiled objects and modules
|
# Compiled objects and modules
|
||||||
*.a
|
*.a
|
||||||
*.o
|
*.o
|
||||||
|
*.mod
|
||||||
*.log
|
*.log
|
||||||
*.out
|
*.out
|
||||||
*.pkl
|
|
||||||
|
|
||||||
# Compiler python objects
|
# Compiler python objects
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
@ -25,17 +25,19 @@ examples/**/*.xml
|
||||||
|
|
||||||
# Documentation builds
|
# Documentation builds
|
||||||
docs/build
|
docs/build
|
||||||
docs/doxygen/xml
|
|
||||||
docs/source/_images/*.pdf
|
docs/source/_images/*.pdf
|
||||||
docs/source/_images/*.aux
|
docs/source/_images/*.aux
|
||||||
docs/source/pythonapi/generated/
|
docs/source/pythonapi/generated/
|
||||||
|
|
||||||
# Source build
|
# Source build
|
||||||
build*/
|
build
|
||||||
|
|
||||||
# build from src/utils/setup.py
|
# build from src/utils/setup.py
|
||||||
src/utils/build
|
src/utils/build
|
||||||
|
|
||||||
|
# xml-fortran reader
|
||||||
|
src/xml-fortran/xmlreader
|
||||||
|
|
||||||
# Test results error file
|
# Test results error file
|
||||||
results_error.dat
|
results_error.dat
|
||||||
inputs_error.dat
|
inputs_error.dat
|
||||||
|
|
@ -66,7 +68,6 @@ scripts/*.tar.*
|
||||||
scripts/G4EMLOW*/
|
scripts/G4EMLOW*/
|
||||||
|
|
||||||
# Images
|
# Images
|
||||||
*.png
|
|
||||||
*.ppm
|
*.ppm
|
||||||
*.voxel
|
*.voxel
|
||||||
*.vti
|
*.vti
|
||||||
|
|
@ -78,6 +79,17 @@ scripts/G4EMLOW*/
|
||||||
# IPython notebook checkpoints
|
# IPython notebook checkpoints
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# Jupyter notebooks
|
||||||
|
examples/jupyter/*.xml
|
||||||
|
examples/jupyter/*.png
|
||||||
|
examples/jupyter/*.xls
|
||||||
|
examples/jupyter/*.ace
|
||||||
|
examples/jupyter/*.endf
|
||||||
|
examples/jupyter/mgxs
|
||||||
|
examples/jupyter/tracks
|
||||||
|
examples/jupyter/fission-rates
|
||||||
|
examples/jupyter/plots
|
||||||
|
|
||||||
# Cython files
|
# Cython files
|
||||||
*.c
|
*.c
|
||||||
*.html
|
*.html
|
||||||
|
|
@ -104,9 +116,3 @@ CMakeSettings.json
|
||||||
|
|
||||||
# Visual Studio Code configuration files
|
# Visual Studio Code configuration files
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
# Claude Code agent tools (cached/generated artifacts)
|
|
||||||
.claude/cache/
|
|
||||||
|
|
||||||
# Python pickle files
|
|
||||||
*.pkl
|
|
||||||
|
|
|
||||||
12
.gitmodules
vendored
|
|
@ -1,9 +1,15 @@
|
||||||
[submodule "vendor/pugixml"]
|
[submodule "vendor/pugixml"]
|
||||||
path = vendor/pugixml
|
path = vendor/pugixml
|
||||||
url = https://github.com/zeux/pugixml.git
|
url = https://github.com/zeux/pugixml.git
|
||||||
|
[submodule "vendor/gsl-lite"]
|
||||||
|
path = vendor/gsl-lite
|
||||||
|
url = https://github.com/martinmoene/gsl-lite.git
|
||||||
|
[submodule "vendor/xtensor"]
|
||||||
|
path = vendor/xtensor
|
||||||
|
url = https://github.com/xtensor-stack/xtensor.git
|
||||||
|
[submodule "vendor/xtl"]
|
||||||
|
path = vendor/xtl
|
||||||
|
url = https://github.com/xtensor-stack/xtl.git
|
||||||
[submodule "vendor/fmt"]
|
[submodule "vendor/fmt"]
|
||||||
path = vendor/fmt
|
path = vendor/fmt
|
||||||
url = https://github.com/fmtlib/fmt.git
|
url = https://github.com/fmtlib/fmt.git
|
||||||
[submodule "vendor/Catch2"]
|
|
||||||
path = vendor/Catch2
|
|
||||||
url = https://github.com/catchorg/Catch2.git
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"openmc-code-tools": {
|
|
||||||
"type": "stdio",
|
|
||||||
"command": "bash",
|
|
||||||
"args": [".claude/tools/start_server.sh"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
version: 2
|
|
||||||
|
|
||||||
build:
|
|
||||||
os: "ubuntu-24.04"
|
|
||||||
tools:
|
|
||||||
python: "3.12"
|
|
||||||
jobs:
|
|
||||||
post_checkout:
|
|
||||||
- git fetch --unshallow || true
|
|
||||||
- cd docs/doxygen && doxygen && cd -
|
|
||||||
|
|
||||||
sphinx:
|
|
||||||
configuration: docs/source/conf.py
|
|
||||||
|
|
||||||
formats:
|
|
||||||
- pdf
|
|
||||||
|
|
||||||
python:
|
|
||||||
install:
|
|
||||||
- method: pip
|
|
||||||
path: .
|
|
||||||
extra_requirements:
|
|
||||||
- docs
|
|
||||||
348
AGENTS.md
|
|
@ -1,348 +0,0 @@
|
||||||
# OpenMC AI Coding Agent Instructions
|
|
||||||
|
|
||||||
## Project Overview
|
|
||||||
|
|
||||||
OpenMC is a Monte Carlo particle transport code for simulating nuclear reactors,
|
|
||||||
fusion devices, or other systems with neutron/photon radiation. It's a hybrid
|
|
||||||
C++17/Python codebase where:
|
|
||||||
- **C++ core** (`src/`, `include/openmc/`) handles the computationally intensive transport simulation
|
|
||||||
- **Python API** (`openmc/`) provides user-facing model building, post-processing, and depletion capabilities
|
|
||||||
- **C API bindings** (`openmc/lib/`) wrap the C++ library via ctypes for runtime control
|
|
||||||
|
|
||||||
## Architecture & Key Components
|
|
||||||
|
|
||||||
### C++ Component Structure
|
|
||||||
- **Global vectors of unique_ptrs**: Core objects like `model::cells`, `model::universes`, `nuclides` are stored as `vector<unique_ptr<T>>` in nested namespaces (`openmc::model`, `openmc::simulation`, `openmc::settings`, `openmc::data`)
|
|
||||||
- **Custom container types**: OpenMC provides its own `vector`, `array`, `unique_ptr`, and `make_unique` in the `openmc::` namespace (defined in `vector.h`, `array.h`, `memory.h`). These are currently typedefs to `std::` equivalents but may become custom implementations for accelerator support. Always use `openmc::vector`, not `std::vector`.
|
|
||||||
- **Geometry systems**:
|
|
||||||
- **CSG (default)**: Arbitrarily complex Constructive Solid Geometry using `Surface`, `Region`, `Cell`, `Universe`, `Lattice`
|
|
||||||
- **DAGMC**: CAD-based geometry via Direct Accelerated Geometry Monte Carlo (optional, requires `OPENMC_USE_DAGMC`)
|
|
||||||
- **Unstructured mesh**: libMesh-based geometry (optional, requires `OPENMC_USE_LIBMESH`)
|
|
||||||
- **Particle tracking**: `Particle` class with `GeometryState` manages particle transport through geometry
|
|
||||||
- **Tallies**: Score quantities during simulation via `Filter` and `Tally` objects
|
|
||||||
- **Random ray solver**: Alternative deterministic method in `src/random_ray/`
|
|
||||||
- **Optional features**: DAGMC (CAD geometry), libMesh (unstructured mesh), MPI, all controlled by `#ifdef OPENMC_MPI`, etc.
|
|
||||||
|
|
||||||
### Python Component Structure
|
|
||||||
- **ID management**: All geometry objects (Cell, Surface, Material, etc.) inherit from `IDManagerMixin` which auto-assigns unique integer IDs and tracks them via class-level `used_ids` and `next_id`
|
|
||||||
- **Input validation**: Extensive use of `openmc.checkvalue` module functions (`check_type`, `check_value`, `check_length`) for all setters
|
|
||||||
- **XML I/O**: Most classes implement `to_xml_element()` and `from_xml_element()` for serialization to OpenMC's XML input format
|
|
||||||
- **HDF5 output**: Post-simulation data in statepoint files read via `openmc.StatePoint`
|
|
||||||
- **Depletion**: `openmc.deplete` implements burnup via operator-splitting with various integrators (Predictor, CECM, etc.)
|
|
||||||
- **Nuclear Data**: `openmc.data` provides programmatic access to nuclear data files (ENDF, ACE, HDF5)
|
|
||||||
|
|
||||||
## Git Branching Workflow
|
|
||||||
|
|
||||||
OpenMC uses a git flow branching model with two primary branches:
|
|
||||||
|
|
||||||
- **`develop` branch**: The main development branch where all ongoing development takes place. This is the **primary branch against which pull requests are submitted and merged**. This branch is not guaranteed to be stable and may contain work-in-progress features.
|
|
||||||
- **`master` branch**: The stable release branch containing the latest stable release of OpenMC. This branch only receives merges from `develop` when the development team decides a release should occur.
|
|
||||||
|
|
||||||
### Instructions for Code Review
|
|
||||||
|
|
||||||
When reviewing code changes in this repository, use the `reviewing-openmc-code` skill.
|
|
||||||
|
|
||||||
## Codebase Navigation Tools
|
|
||||||
|
|
||||||
Two MCP tools are registered in `.mcp.json` at the repo root and appear
|
|
||||||
automatically in any MCP-capable agent session.
|
|
||||||
|
|
||||||
**`openmc_rag_search`** — Semantic search across the codebase (C++, Python, RST
|
|
||||||
docs). Finds code by meaning, not just text match. Surfaces related code across
|
|
||||||
subsystems even when naming differs (e.g., "particle RNG seeding" finds code
|
|
||||||
across transport, restart, and random ray modes — files you would never find
|
|
||||||
with `grep "particle seed"`). The index uses a small 22M-param embedding model
|
|
||||||
(384-dim). Phrase-level natural-language queries work much better than single
|
|
||||||
keywords or symbol names.
|
|
||||||
|
|
||||||
**`openmc_rag_rebuild`** — Rebuild the RAG vector index. Call after pulling new
|
|
||||||
code or switching branches. The first RAG search of each session will report
|
|
||||||
the index status and ask whether to rebuild — you can also call this explicitly.
|
|
||||||
|
|
||||||
### Why RAG matters
|
|
||||||
|
|
||||||
OpenMC is large enough that changes in one subsystem can silently break
|
|
||||||
invariants that distant subsystems depend on — and those distant files often
|
|
||||||
use different naming, so grep won't find them. The RAG search finds code by
|
|
||||||
meaning, surfacing files you wouldn't have thought to open.
|
|
||||||
|
|
||||||
An agent reviewed a large OpenMC PR without RAG. It found 1 of 11 serious
|
|
||||||
bugs. Its post-mortem:
|
|
||||||
|
|
||||||
> **I treated the diff as a closed system.** I verified internal consistency of
|
|
||||||
> the changed code obsessively, but never built a global understanding of how
|
|
||||||
> the changed code fits into the wider codebase. The diff altered assumptions
|
|
||||||
> that code elsewhere silently relied on — but I couldn't see that because I
|
|
||||||
> never looked beyond the diff. I couldn't see the forest for the trees.
|
|
||||||
>
|
|
||||||
> **Why I resisted RAG:** Overconfidence. My internal model was "I can see the
|
|
||||||
> diff, I understand the data structures, I can trace the logic." The diff felt
|
|
||||||
> self-contained. RAG felt like it would return noisy results about tangentially
|
|
||||||
> related code. But in a codebase this large, changes in one subsystem can
|
|
||||||
> quietly break invariants that distant subsystems depend on — and you need
|
|
||||||
> global awareness to foresee that.
|
|
||||||
>
|
|
||||||
> **In the post-mortem**, I re-ran the RAG queries I should have run during the
|
|
||||||
> review. They directly surfaced the files containing the bugs I missed — files
|
|
||||||
> I never thought to open because they weren't in the diff.
|
|
||||||
|
|
||||||
The takeaway: when reviewing or modifying code, ask yourself "what else in this
|
|
||||||
codebase might depend on the behavior I'm changing?" If you aren't sure, that's
|
|
||||||
a good time for a RAG query. It won't replace the grep-based investigation you
|
|
||||||
should already be doing — but it can surface files you wouldn't have thought to
|
|
||||||
open.
|
|
||||||
|
|
||||||
### Workflow for contributors
|
|
||||||
|
|
||||||
1. Create a feature/bugfix branch off `develop`
|
|
||||||
2. Make changes and commit to the feature branch
|
|
||||||
3. Open a pull request to merge the feature branch into `develop`
|
|
||||||
4. A committer reviews and merges the PR into `develop`
|
|
||||||
|
|
||||||
## Critical Build & Test Workflows
|
|
||||||
|
|
||||||
### Build Dependencies
|
|
||||||
- **C++17 compiler**: GCC, Clang, or Intel
|
|
||||||
- **CMake** (3.16+): Required for configuring and building the C++ library
|
|
||||||
- **HDF5**: Required for cross section data and output file formats
|
|
||||||
- **libpng**: Used for generating visualization when OpenMC is run in plotting mode
|
|
||||||
|
|
||||||
Without CMake and HDF5, OpenMC cannot be compiled.
|
|
||||||
|
|
||||||
### Building the C++ Library
|
|
||||||
```bash
|
|
||||||
# Configure with CMake (from build/ directory)
|
|
||||||
cmake .. -DOPENMC_USE_MPI=ON -DOPENMC_USE_OPENMP=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
|
|
||||||
# Available CMake options (all default OFF except OPENMC_USE_OPENMP and OPENMC_BUILD_TESTS):
|
|
||||||
# -DOPENMC_USE_OPENMP=ON/OFF # OpenMP parallelism
|
|
||||||
# -DOPENMC_USE_MPI=ON/OFF # MPI support
|
|
||||||
# -DOPENMC_USE_DAGMC=ON/OFF # CAD geometry support
|
|
||||||
# -DOPENMC_USE_LIBMESH=ON/OFF # Unstructured mesh
|
|
||||||
# -DOPENMC_ENABLE_PROFILE=ON/OFF # Profiling flags
|
|
||||||
# -DOPENMC_ENABLE_COVERAGE=ON/OFF # Coverage analysis
|
|
||||||
|
|
||||||
# Build
|
|
||||||
make -j
|
|
||||||
|
|
||||||
# C++ unit tests (uses Catch2)
|
|
||||||
ctest
|
|
||||||
```
|
|
||||||
|
|
||||||
### Python Development
|
|
||||||
```bash
|
|
||||||
# Install in development mode (requires building C++ library first)
|
|
||||||
pip install -e .
|
|
||||||
|
|
||||||
# Python tests (uses pytest)
|
|
||||||
pytest tests/unit_tests/ # Fast unit tests
|
|
||||||
pytest tests/regression_tests/ # Full regression suite (requires nuclear data)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Nuclear Data Setup (CRITICAL for Running OpenMC)
|
|
||||||
Most tests require the NNDC HDF5 nuclear cross-section library.
|
|
||||||
|
|
||||||
**Important**: Check if `OPENMC_CROSS_SECTIONS` is already set in the user's
|
|
||||||
environment before downloading, as many users already have nuclear data
|
|
||||||
installed. Though do note that if this variable is present that it may point to
|
|
||||||
different cross section data and that the NNDC data is required for tests to
|
|
||||||
pass.
|
|
||||||
|
|
||||||
**If not already configured, download and setup:**
|
|
||||||
```bash
|
|
||||||
# Download NNDC HDF5 cross section library (~800 MB compressed)
|
|
||||||
wget -q -O - https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz | tar -C $HOME -xJ
|
|
||||||
|
|
||||||
# Set environment variable (add to ~/.bashrc or ~/.zshrc for persistence)
|
|
||||||
export OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml
|
|
||||||
```
|
|
||||||
|
|
||||||
**Alternative**: Use the provided download script (checks if data exists before downloading):
|
|
||||||
```bash
|
|
||||||
bash tools/ci/download-xs.sh # Downloads both NNDC HDF5 and ENDF/B-VII.1 data
|
|
||||||
```
|
|
||||||
|
|
||||||
Without this data, regression tests will fail with "No cross_sections.xml file
|
|
||||||
found" errors, or, in the case that alternative cross section data is configured
|
|
||||||
the tests will execute but will not pass. The `cross_sections.xml` file is an
|
|
||||||
index listing paths to individual HDF5 nuclear data files for each nuclide.
|
|
||||||
|
|
||||||
## Testing Expectations
|
|
||||||
|
|
||||||
### Environment Requirements
|
|
||||||
|
|
||||||
- **Data**: As described above, OpenMC's test suite requires OpenMC to be configured with NNDC data.
|
|
||||||
- **OpenMP Settings**: OpenMC's tests may fail is more than two OpenMP threads are used. The environment variable `OMP_NUM_THREADS=2` should be set to avoid sporadic test failures.
|
|
||||||
- **Executable configuration**: The OpenMC executable should compiled with debug symbols enabled.
|
|
||||||
|
|
||||||
### C++ Tests
|
|
||||||
Located in `tests/cpp_unit_tests/`, use Catch2 framework. Run via `ctest` after building with `-DOPENMC_BUILD_TESTS=ON`.
|
|
||||||
|
|
||||||
### Python Unit Tests
|
|
||||||
Located in `tests/unit_tests/`, these are fast, standalone tests that verify Python API functionality without running full simulations. Use standard pytest patterns:
|
|
||||||
|
|
||||||
**Categories**:
|
|
||||||
- **API validation**: Test object creation, property setters/getters, XML serialization (e.g., `test_material.py`, `test_cell.py`, `test_source.py`)
|
|
||||||
- **Data processing**: Test nuclear data handling, cross sections, depletion chains (e.g., `test_data_neutron.py`, `test_deplete_chain.py`)
|
|
||||||
- **Library bindings**: Test `openmc.lib` ctypes interface with `model.init_lib()`/`model.finalize_lib()` (e.g., `test_lib.py`)
|
|
||||||
- **Geometry operations**: Test bounding boxes, containment, lattice generation (e.g., `test_bounding_box.py`, `test_lattice.py`)
|
|
||||||
|
|
||||||
**Common patterns**:
|
|
||||||
- Use fixtures from `tests/unit_tests/conftest.py` (e.g., `uo2`, `water`, `sphere_model`)
|
|
||||||
- Test invalid inputs with `pytest.raises(ValueError)` or `pytest.raises(TypeError)`
|
|
||||||
- Use `run_in_tmpdir` fixture for tests that create files
|
|
||||||
- Tests with `openmc.lib` require calling `model.init_lib()` in try/finally with `model.finalize_lib()`
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
```python
|
|
||||||
def test_material_properties():
|
|
||||||
m = openmc.Material()
|
|
||||||
m.add_nuclide('U235', 1.0)
|
|
||||||
assert 'U235' in m.nuclides
|
|
||||||
|
|
||||||
with pytest.raises(TypeError):
|
|
||||||
m.add_nuclide('H1', '1.0') # Invalid type
|
|
||||||
```
|
|
||||||
|
|
||||||
Unit tests should be fast. For tests requiring simulation output, use regression tests instead.
|
|
||||||
|
|
||||||
### Python Regression Tests
|
|
||||||
Regression tests compare OpenMC output against reference data. **Prefer using existing models from `openmc.examples` or those found in tests/unit_tests/conftest.py** (like `pwr_pin_cell()`, `pwr_assembly()`, `slab_mg()`) rather than building from scratch.
|
|
||||||
|
|
||||||
**Test Harness Types** (in `tests/testing_harness.py`):
|
|
||||||
- **PyAPITestHarness**: Standard harness for Python API tests. Compares `inputs_true.dat` (XML hash) and `results_true.dat` (statepoint k-eff and tally values). Requires `model.xml` generation.
|
|
||||||
- **HashedPyAPITestHarness**: Like PyAPITestHarness but hashes the results for compact comparison
|
|
||||||
- **TolerantPyAPITestHarness**: For tests with floating-point non-associativity (e.g., random ray solver with single precision). Uses relative tolerance comparisons.
|
|
||||||
- **WeightWindowPyAPITestHarness**: Compares weight window bounds from `weight_windows.h5`
|
|
||||||
- **CollisionTrackTestHarness**: Compares collision track data from `collision_track.h5` against `collision_track_true.h5`
|
|
||||||
- **TestHarness**: Base harness for XML-based tests (no Python model building)
|
|
||||||
- **PlotTestHarness**: Compares plot output files (PNG or voxel HDF5)
|
|
||||||
- **CMFDTestHarness**: Specialized for CMFD acceleration tests
|
|
||||||
- **ParticleRestartTestHarness**: Tests particle restart functionality
|
|
||||||
|
|
||||||
Almost all cases use either `PyAPITestHarness` or `HashedPyAPITestHarness`
|
|
||||||
|
|
||||||
**Example Test**:
|
|
||||||
```python
|
|
||||||
from openmc.examples import pwr_pin_cell
|
|
||||||
from tests.testing_harness import PyAPITestHarness
|
|
||||||
|
|
||||||
def test_my_feature():
|
|
||||||
model = pwr_pin_cell()
|
|
||||||
model.settings.particles = 1000 # Modify to exercise feature
|
|
||||||
harness = PyAPITestHarness('statepoint.10.h5', model)
|
|
||||||
harness.main()
|
|
||||||
```
|
|
||||||
|
|
||||||
**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.
|
|
||||||
|
|
||||||
**Critical**: When modifying OpenMC code, regenerate affected test references with `pytest --update` and commit updated reference files.
|
|
||||||
|
|
||||||
### Test Configuration
|
|
||||||
|
|
||||||
`pytest.ini` sets: `python_files = test*.py`, `python_classes = NoThanks` (disables class-based test collection).
|
|
||||||
|
|
||||||
### Testing Options
|
|
||||||
|
|
||||||
For builds of OpenMC with MPI enabled, the `--mpi` flag should be passed to the test suite to ensure that appropriate tests are executed using two MPI processes.
|
|
||||||
|
|
||||||
The entire test suite can be executed with OpenMC running in event-based mode (instead of the default history-based mode) by providing the `--event` flag to the `pytest` command.
|
|
||||||
|
|
||||||
## Cross-Language Boundaries
|
|
||||||
|
|
||||||
The C API (defined in `include/openmc/capi.h`) exposes C++ functionality to Python via ctypes bindings in `openmc/lib/`. Example:
|
|
||||||
```cpp
|
|
||||||
// C++ API in capi.h
|
|
||||||
extern "C" int openmc_run();
|
|
||||||
|
|
||||||
// Python binding in openmc/lib/core.py
|
|
||||||
_dll.openmc_run.restype = c_int
|
|
||||||
def run():
|
|
||||||
_dll.openmc_run()
|
|
||||||
```
|
|
||||||
|
|
||||||
When modifying C++ public APIs, update corresponding ctypes signatures in `openmc/lib/*.py`.
|
|
||||||
|
|
||||||
## Code Style & Conventions
|
|
||||||
|
|
||||||
### C++ Style (enforced by .clang-format)
|
|
||||||
OpenMC generally tries to follow C++ core guidelines where possible
|
|
||||||
(https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) and follow
|
|
||||||
modern C++ practices (e.g. RAII) whenever possible.
|
|
||||||
|
|
||||||
- **Naming**:
|
|
||||||
- Classes: `CamelCase` (e.g., `HexLattice`)
|
|
||||||
- Functions/methods: `snake_case` (e.g., `get_indices`)
|
|
||||||
- Variables: `snake_case` with trailing underscore for class members (e.g., `n_particles_`, `energy_`)
|
|
||||||
- Constants: `UPPER_SNAKE_CASE` (e.g., `SQRT_PI`)
|
|
||||||
- **Namespaces**: All code in `openmc::` namespace, global state in sub-namespaces
|
|
||||||
- **Include order**: Related header first, then C/C++ stdlib, third-party libs, local headers
|
|
||||||
- **Comments**: C++-style (`//`) only, never C-style (`/* */`)
|
|
||||||
- **Standard**: C++17 features allowed
|
|
||||||
- **Formatting**: Run `clang-format` (version 18) before committing; install via `tools/dev/install-commit-hooks.sh`
|
|
||||||
|
|
||||||
### Python Style
|
|
||||||
- **PEP8** compliant
|
|
||||||
- **Docstrings**: numpydoc format for all public functions/methods
|
|
||||||
- **Type hints**: Use sparingly, primarily for complex signatures
|
|
||||||
- **Path handling**: Use `pathlib.Path` for filesystem operations, accept `str | os.PathLike` in function arguments
|
|
||||||
- **Dependencies**: Core dependencies only (numpy, scipy, h5py, pandas, matplotlib, lxml, ipython, uncertainties, endf). Other packages must be optional
|
|
||||||
- **Python version**: Minimum 3.11 (as of Nov 2025)
|
|
||||||
|
|
||||||
### ID Management Pattern (Python)
|
|
||||||
When creating geometry objects, IDs can be auto-assigned or explicit:
|
|
||||||
```python
|
|
||||||
# Auto-assigned ID
|
|
||||||
cell = openmc.Cell() # Gets next available ID
|
|
||||||
|
|
||||||
# Explicit ID
|
|
||||||
cell = openmc.Cell(id=10) # Warning if ID already used
|
|
||||||
|
|
||||||
# Reset all IDs (useful in test fixtures)
|
|
||||||
openmc.reset_auto_ids()
|
|
||||||
```
|
|
||||||
|
|
||||||
### Input Validation Pattern (Python)
|
|
||||||
All setters use checkvalue functions:
|
|
||||||
```python
|
|
||||||
import openmc.checkvalue as cv
|
|
||||||
|
|
||||||
@property
|
|
||||||
def temperature(self):
|
|
||||||
return self._temperature
|
|
||||||
|
|
||||||
@temperature.setter
|
|
||||||
def temperature(self, temp):
|
|
||||||
cv.check_type('temperature', temp, Real)
|
|
||||||
cv.check_greater_than('temperature', temp, 0.0)
|
|
||||||
self._temperature = temp
|
|
||||||
```
|
|
||||||
|
|
||||||
### Working with HDF5 Files
|
|
||||||
C++ uses custom HDF5 wrappers in `src/hdf5_interface.cpp`. Python uses h5py directly. Statepoint format version is `VERSION_STATEPOINT` in `include/openmc/constants.h`.
|
|
||||||
|
|
||||||
### Conditional Compilation
|
|
||||||
Check for optional features:
|
|
||||||
```cpp
|
|
||||||
#ifdef OPENMC_MPI
|
|
||||||
// MPI-specific code
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OPENMC_DAGMC
|
|
||||||
// DAGMC-specific code
|
|
||||||
#endif
|
|
||||||
```
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
- **User docs**: Sphinx documentation in `docs/source/` hosted at https://docs.openmc.org
|
|
||||||
- **C++ docs**: Doxygen-style comments with `\brief`, `\param` tags
|
|
||||||
- **Python docs**: numpydoc format docstrings
|
|
||||||
|
|
||||||
## Common Pitfalls
|
|
||||||
|
|
||||||
1. **Forgetting nuclear data**: Tests fail without `OPENMC_CROSS_SECTIONS` environment variable
|
|
||||||
2. **ID conflicts**: Python objects with duplicate IDs trigger `IDWarning`, use `reset_auto_ids()` between tests
|
|
||||||
3. **MPI builds**: Code must work with and without MPI; use `#ifdef OPENMC_MPI` guards
|
|
||||||
4. **Path handling**: Use `pathlib.Path` in new Python code, not `os.path`
|
|
||||||
5. **Clang-format version**: CI uses version 18; other versions may produce different formatting
|
|
||||||
68
CITATION.cff
|
|
@ -1,68 +0,0 @@
|
||||||
cff-version: 1.2.0
|
|
||||||
message: "If you use this software, please cite it as below."
|
|
||||||
title: OpenMC
|
|
||||||
authors:
|
|
||||||
- family-names: Romano
|
|
||||||
given-names: Paul K.
|
|
||||||
orcid: "https://orcid.org/0000-0002-1147-045X"
|
|
||||||
- family-names: Shriwise
|
|
||||||
given-names: Patrick C.
|
|
||||||
orcid: "https://orcid.org/0000-0002-3979-7665"
|
|
||||||
- family-names: Shimwell
|
|
||||||
given-names: Jonathan
|
|
||||||
orcid: "https://orcid.org/0000-0001-6909-0946"
|
|
||||||
- family-names: Harper
|
|
||||||
given-names: Sterling
|
|
||||||
- family-names: Boyd
|
|
||||||
given-names: Will
|
|
||||||
- family-names: Nelson
|
|
||||||
given-names: Adam G.
|
|
||||||
orcid: "https://orcid.org/0000-0002-3614-0676"
|
|
||||||
- family-names: Tramm
|
|
||||||
given-names: John R.
|
|
||||||
orcid: "https://orcid.org/0000-0002-5397-4402"
|
|
||||||
- family-names: Ridley
|
|
||||||
given-names: Gavin
|
|
||||||
orcid: "https://orcid.org/0000-0003-1635-8042"
|
|
||||||
- family-names: Johnson
|
|
||||||
given-names: Andrew
|
|
||||||
orcid: "https://orcid.org/0000-0003-2125-8775"
|
|
||||||
- family-names: Peterson
|
|
||||||
given-names: Ethan E.
|
|
||||||
orcid: "https://orcid.org/0000-0002-5694-7194"
|
|
||||||
- family-names: Herman
|
|
||||||
given-names: Bryan R.
|
|
||||||
preferred-citation:
|
|
||||||
authors:
|
|
||||||
- family-names: Romano
|
|
||||||
given-names: Paul K.
|
|
||||||
orcid: "https://orcid.org/0000-0002-1147-045X"
|
|
||||||
- family-names: Horelik
|
|
||||||
given-names: Nicholas E.
|
|
||||||
- family-names: Herman
|
|
||||||
given-names: Bryan R.
|
|
||||||
- family-names: Nelson
|
|
||||||
given-names: Adam G.
|
|
||||||
orcid: "https://orcid.org/0000-0002-3614-0676"
|
|
||||||
- family-names: Forget
|
|
||||||
given-names: Benoit
|
|
||||||
orcid: "https://orcid.org/0000-0003-1459-7672"
|
|
||||||
- family-names: Smith
|
|
||||||
given-names: Kord
|
|
||||||
contact:
|
|
||||||
- family-names: Romano
|
|
||||||
given-names: Paul K.
|
|
||||||
orcid: "https://orcid.org/0000-0002-1147-045X"
|
|
||||||
doi: 10.1016/j.anucene.2014.07.048
|
|
||||||
issn: 0306-4549
|
|
||||||
volume: 82
|
|
||||||
journal: Annals of Nuclear Energy
|
|
||||||
publisher:
|
|
||||||
name: Elsevier
|
|
||||||
start: 90
|
|
||||||
end: 97
|
|
||||||
year: 2015
|
|
||||||
month: 8
|
|
||||||
title: "OpenMC: A state-of-the-art Monte Carlo code for research and development"
|
|
||||||
type: article
|
|
||||||
url: "https://doi.org/10.1016/j.anucene.2014.07.048"
|
|
||||||
14
CLAUDE.md
|
|
@ -1,14 +0,0 @@
|
||||||
## OpenMC Codebase Tools
|
|
||||||
|
|
||||||
Read the FULL `AGENTS.md` in this directory before starting work. It contains
|
|
||||||
project context, coding conventions, and documentation of the RAG search tools
|
|
||||||
registered in `.mcp.json`.
|
|
||||||
|
|
||||||
### Claude Code-specific: first-call behavior
|
|
||||||
|
|
||||||
The first `openmc_rag_search` call of each session returns an index status
|
|
||||||
message instead of search results. When this happens, you MUST use the
|
|
||||||
`AskUserQuestion` tool to present the rebuild/use-existing choice to the user.
|
|
||||||
Do not ask conversationally — always use the widget. Do not skip this step even
|
|
||||||
if the index looks current — the user may have uncommitted changes that warrant
|
|
||||||
a rebuild.
|
|
||||||
470
CMakeLists.txt
|
|
@ -1,18 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||||
project(openmc C CXX)
|
project(openmc C CXX)
|
||||||
|
|
||||||
# Set module path
|
# Set version numbers
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
set(OPENMC_VERSION_MAJOR 0)
|
||||||
|
set(OPENMC_VERSION_MINOR 12)
|
||||||
include(GetVersionFromGit)
|
set(OPENMC_VERSION_RELEASE 2)
|
||||||
|
set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE})
|
||||||
# Output version information
|
|
||||||
message(STATUS "OpenMC version: ${OPENMC_VERSION}")
|
|
||||||
message(STATUS "OpenMC dev state: ${OPENMC_DEV_STATE}")
|
|
||||||
message(STATUS "OpenMC commit hash: ${OPENMC_COMMIT_HASH}")
|
|
||||||
message(STATUS "OpenMC commit count: ${OPENMC_COMMIT_COUNT}")
|
|
||||||
|
|
||||||
# Generate version.h
|
|
||||||
configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY)
|
configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY)
|
||||||
|
|
||||||
# Setup output directories
|
# Setup output directories
|
||||||
|
|
@ -20,156 +13,72 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
# Generate compile_commands.json for clangd and other tools
|
# Set module path
|
||||||
if("${CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "")
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Enable correct usage of CXX_EXTENSIONS
|
# Allow user to specify <project>_ROOT variables
|
||||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
|
if (NOT (CMAKE_VERSION VERSION_LESS 3.12))
|
||||||
cmake_policy(SET CMP0128 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Command line options
|
# Command line options
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
option(OPENMC_USE_OPENMP "Enable shared-memory parallelism with OpenMP" ON)
|
option(openmp "Enable shared-memory parallelism with OpenMP" ON)
|
||||||
option(OPENMC_BUILD_TESTS "Build tests" ON)
|
option(profile "Compile with profiling flags" OFF)
|
||||||
option(OPENMC_ENABLE_PROFILE "Compile with profiling flags" OFF)
|
option(debug "Compile with debug flags" OFF)
|
||||||
option(OPENMC_ENABLE_COVERAGE "Compile with coverage analysis flags" OFF)
|
option(optimize "Turn on all compiler optimization flags" OFF)
|
||||||
option(OPENMC_USE_DAGMC "Enable support for DAGMC (CAD) geometry" OFF)
|
option(coverage "Compile with coverage analysis flags" OFF)
|
||||||
option(OPENMC_USE_LIBMESH "Enable support for libMesh unstructured mesh tallies" OFF)
|
option(dagmc "Enable support for DAGMC (CAD) geometry" OFF)
|
||||||
option(OPENMC_USE_MPI "Enable MPI" OFF)
|
option(libmesh "Enable support for libMesh unstructured mesh tallies" OFF)
|
||||||
option(OPENMC_USE_UWUW "Enable UWUW" OFF)
|
|
||||||
option(OPENMC_FORCE_VENDORED_LIBS "Explicitly use submodules defined in 'vendor'" OFF)
|
|
||||||
option(OPENMC_ENABLE_STRICT_FP "Enable strict FP flags to improve test portability" OFF)
|
|
||||||
|
|
||||||
message(STATUS "OPENMC_USE_OPENMP ${OPENMC_USE_OPENMP}")
|
|
||||||
message(STATUS "OPENMC_BUILD_TESTS ${OPENMC_BUILD_TESTS}")
|
|
||||||
message(STATUS "OPENMC_ENABLE_PROFILE ${OPENMC_ENABLE_PROFILE}")
|
|
||||||
message(STATUS "OPENMC_ENABLE_COVERAGE ${OPENMC_ENABLE_COVERAGE}")
|
|
||||||
message(STATUS "OPENMC_USE_DAGMC ${OPENMC_USE_DAGMC}")
|
|
||||||
message(STATUS "OPENMC_USE_LIBMESH ${OPENMC_USE_LIBMESH}")
|
|
||||||
message(STATUS "OPENMC_USE_MPI ${OPENMC_USE_MPI}")
|
|
||||||
message(STATUS "OPENMC_USE_UWUW ${OPENMC_USE_UWUW}")
|
|
||||||
message(STATUS "OPENMC_FORCE_VENDORED_LIBS ${OPENMC_FORCE_VENDORED_LIBS}")
|
|
||||||
message(STATUS "OPENMC_ENABLE_STRICT_FP ${OPENMC_ENABLE_STRICT_FP}")
|
|
||||||
|
|
||||||
# Warnings for deprecated options
|
|
||||||
foreach(OLD_OPT IN ITEMS "openmp" "profile" "coverage" "dagmc" "libmesh")
|
|
||||||
if(DEFINED ${OLD_OPT})
|
|
||||||
string(TOUPPER ${OLD_OPT} OPT_UPPER)
|
|
||||||
if ("${OLD_OPT}" STREQUAL "profile" OR "${OLD_OPT}" STREQUAL "coverage")
|
|
||||||
set(NEW_OPT_PREFIX "OPENMC_ENABLE")
|
|
||||||
else()
|
|
||||||
set(NEW_OPT_PREFIX "OPENMC_USE")
|
|
||||||
endif()
|
|
||||||
message(WARNING "The OpenMC CMake option '${OLD_OPT}' has been deprecated. "
|
|
||||||
"Its value will be ignored. "
|
|
||||||
"Please use '-D${NEW_OPT_PREFIX}_${OPT_UPPER}=${${OLD_OPT}}' instead.")
|
|
||||||
unset(${OLD_OPT} CACHE)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(OLD_BLD in ITEMS "debug" "optimize")
|
|
||||||
if(DEFINED ${OLD_BLD})
|
|
||||||
if("${OLD_BLD}" STREQUAL "debug")
|
|
||||||
set(BLD_VAR "Debug")
|
|
||||||
else()
|
|
||||||
set(BLD_VAR "Release")
|
|
||||||
endif()
|
|
||||||
message(WARNING "The OpenMC CMake option '${OLD_BLD}' has been deprecated. "
|
|
||||||
"Its value will be ignored. "
|
|
||||||
"OpenMC now uses the CMAKE_BUILD_TYPE variable to set the build mode. "
|
|
||||||
"Please use '-DCMAKE_BUILD_TYPE=${BLD_VAR}' instead.")
|
|
||||||
unset(${OLD_BLD} CACHE)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Set a default build configuration if not explicitly specified
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
message(STATUS "No build type selected, defaulting to RelWithDebInfo")
|
|
||||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# When STRICT_FP is enabled, remove NDEBUG from RelWithDebInfo flags so that
|
|
||||||
# assert() remains active. CMake normally adds -DNDEBUG for both Release and
|
|
||||||
# RelWithDebInfo, which disables C/C++ assert() statements.
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
if(OPENMC_ENABLE_STRICT_FP)
|
|
||||||
foreach(FLAG_VAR CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELWITHDEBINFO)
|
|
||||||
string(REPLACE "-DNDEBUG" "" ${FLAG_VAR} "${${FLAG_VAR}}")
|
|
||||||
string(REPLACE "/DNDEBUG" "" ${FLAG_VAR} "${${FLAG_VAR}}")
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# OpenMP for shared-memory parallelism (and GPU support some day!)
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
if(OPENMC_USE_OPENMP)
|
|
||||||
find_package(OpenMP REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# MPI for distributed-memory parallelism
|
# MPI for distributed-memory parallelism
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
if(OPENMC_USE_MPI)
|
set(MPI_ENABLED FALSE)
|
||||||
find_package(MPI REQUIRED)
|
if(${CMAKE_CXX_COMPILER} MATCHES "(mpi[^/]*|CC)$")
|
||||||
|
message(STATUS "Detected MPI wrapper: ${CMAKE_CXX_COMPILER}")
|
||||||
|
set(MPI_ENABLED TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Helper macro for finding a dependency
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
macro(find_package_write_status pkg)
|
|
||||||
find_package(${pkg} QUIET NO_SYSTEM_ENVIRONMENT_PATH)
|
|
||||||
if(${pkg}_FOUND)
|
|
||||||
message(STATUS "Found ${pkg}: ${${pkg}_DIR} (version ${${pkg}_VERSION})")
|
|
||||||
else()
|
|
||||||
message(STATUS "Did not find ${pkg}, will use submodule instead")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# DAGMC Geometry Support - need DAGMC/MOAB
|
# DAGMC Geometry Support - need DAGMC/MOAB
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
if(dagmc)
|
||||||
if(OPENMC_USE_DAGMC)
|
|
||||||
find_package(DAGMC REQUIRED PATH_SUFFIXES lib/cmake)
|
find_package(DAGMC REQUIRED PATH_SUFFIXES lib/cmake)
|
||||||
if (${DAGMC_VERSION} VERSION_LESS 3.2.0)
|
if (${DAGMC_VERSION} VERSION_LESS 3.2.0)
|
||||||
message(FATAL_ERROR "Discovered DAGMC Version: ${DAGMC_VERSION}."
|
message(FATAL_ERROR "Discovered DAGMC Version: ${DAGMC_VERSION}. \
|
||||||
"Please update DAGMC to version 3.2.0 or greater.")
|
Please update DAGMC to version 3.2.0 or greater.")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "Found DAGMC: ${DAGMC_DIR} (version ${DAGMC_VERSION})")
|
endif()
|
||||||
|
|
||||||
# Check if UWUW is needed and available
|
#===============================================================================
|
||||||
if(OPENMC_USE_UWUW AND NOT DAGMC_BUILD_UWUW)
|
# Check for submodules perhaps already on system
|
||||||
message(FATAL_ERROR "UWUW is enabled but DAGMC was not configured with UWUW.")
|
#===============================================================================
|
||||||
endif()
|
|
||||||
|
# If not found, we just pull appropriate versions from github and build them.
|
||||||
|
find_package(fmt QUIET NO_SYSTEM_ENVIRONMENT_PATH)
|
||||||
|
if(fmt_FOUND)
|
||||||
|
message(STATUS "Found fmt: ${fmt_DIR} (version ${fmt_VERSION})")
|
||||||
|
else()
|
||||||
|
message(STATUS "Did not find fmt, will use submodule instead")
|
||||||
|
endif()
|
||||||
|
find_package(pugixml QUIET NO_SYSTEM_ENVIRONMENT_PATH)
|
||||||
|
if(pugixml_FOUND)
|
||||||
|
message(STATUS "Found pugixml: ${pugixml_DIR}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Did not find pugixml, will use submodule instead")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# libMesh Unstructured Mesh Support
|
# libMesh Unstructured Mesh Support
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
if(libmesh)
|
||||||
if(OPENMC_USE_LIBMESH)
|
|
||||||
find_package(LIBMESH REQUIRED)
|
find_package(LIBMESH REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# libpng
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
find_package(PNG)
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# HDF5 for binary output
|
# HDF5 for binary output
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
@ -188,16 +97,11 @@ if(NOT DEFINED HDF5_PREFER_PARALLEL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(HDF5 REQUIRED COMPONENTS C HL)
|
find_package(HDF5 REQUIRED COMPONENTS C HL)
|
||||||
|
|
||||||
# Remove HDF5 transitive dependencies that are system libraries
|
|
||||||
list(FILTER HDF5_LIBRARIES EXCLUDE REGEX ".*lib(pthread|dl|m).*")
|
|
||||||
message(STATUS "HDF5 Libraries: ${HDF5_LIBRARIES}")
|
|
||||||
|
|
||||||
if(HDF5_IS_PARALLEL)
|
if(HDF5_IS_PARALLEL)
|
||||||
if(NOT OPENMC_USE_MPI)
|
if(NOT MPI_ENABLED)
|
||||||
message(FATAL_ERROR "Parallel HDF5 was detected, but MPI was not enabled.\
|
message(FATAL_ERROR "Parallel HDF5 was detected, but the detected compiler,\
|
||||||
To use parallel HDF5, OpenMC needs to be built with MPI support by passing\
|
${CMAKE_CXX_COMPILER}, does not support MPI. An MPI-capable compiler must \
|
||||||
-DOPENMC_USE_MPI=ON when calling cmake.")
|
be used with parallel HDF5.")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "Using parallel HDF5")
|
message(STATUS "Using parallel HDF5")
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -205,7 +109,7 @@ endif()
|
||||||
# Version 1.12 of HDF5 deprecates the H5Oget_info_by_idx() interface.
|
# Version 1.12 of HDF5 deprecates the H5Oget_info_by_idx() interface.
|
||||||
# Thus, we give these flags to allow usage of the old interface in newer
|
# Thus, we give these flags to allow usage of the old interface in newer
|
||||||
# versions of HDF5.
|
# versions of HDF5.
|
||||||
if(${HDF5_VERSION} VERSION_GREATER_EQUAL 1.12.0)
|
if(NOT (${HDF5_VERSION} VERSION_LESS 1.12.0))
|
||||||
list(APPEND cxxflags -DH5Oget_info_by_idx_vers=1 -DH5O_info_t_vers=1)
|
list(APPEND cxxflags -DH5Oget_info_by_idx_vers=1 -DH5O_info_t_vers=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -213,36 +117,33 @@ endif()
|
||||||
# Set compile/link flags based on which compiler is being used
|
# Set compile/link flags based on which compiler is being used
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
# When OPENMC_ENABLE_STRICT_FP is enabled, disable compiler optimizations that change
|
|
||||||
# floating-point results relative to -O0, improving cross-platform and
|
|
||||||
# cross-optimization-level reproducibility for regression testing:
|
|
||||||
# -ffp-contract=off Prevents FMA contraction (fused multiply-add changes rounding)
|
|
||||||
# -fno-builtin Prevents replacing math function calls (pow, exp, log, etc.)
|
|
||||||
# with builtin versions that may differ from libm
|
|
||||||
# By default (OFF), the compiler is free to use all optimizations for best
|
|
||||||
# performance.
|
|
||||||
if(OPENMC_ENABLE_STRICT_FP)
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
check_cxx_compiler_flag(-ffp-contract=off SUPPORTS_FP_CONTRACT_OFF)
|
|
||||||
if(SUPPORTS_FP_CONTRACT_OFF)
|
|
||||||
list(APPEND cxxflags -ffp-contract=off)
|
|
||||||
endif()
|
|
||||||
check_cxx_compiler_flag(-fno-builtin SUPPORTS_NO_BUILTIN)
|
|
||||||
if(SUPPORTS_NO_BUILTIN)
|
|
||||||
list(APPEND cxxflags -fno-builtin)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Skip for Visual Studio which has its own configurations through GUI
|
# Skip for Visual Studio which has its own configurations through GUI
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
if(openmp)
|
||||||
|
# Requires CMake 3.1+
|
||||||
if(OPENMC_ENABLE_PROFILE)
|
find_package(OpenMP)
|
||||||
list(APPEND cxxflags -g -fno-omit-frame-pointer)
|
if(OPENMP_FOUND)
|
||||||
|
list(APPEND cxxflags ${OpenMP_CXX_FLAGS})
|
||||||
|
list(APPEND ldflags ${OpenMP_CXX_FLAGS})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OPENMC_ENABLE_COVERAGE)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
list(APPEND cxxflags -O2)
|
||||||
|
if(debug)
|
||||||
|
list(REMOVE_ITEM cxxflags -O2)
|
||||||
|
list(APPEND cxxflags -g -O0)
|
||||||
|
endif()
|
||||||
|
if(profile)
|
||||||
|
list(APPEND cxxflags -g -fno-omit-frame-pointer)
|
||||||
|
endif()
|
||||||
|
if(optimize)
|
||||||
|
list(REMOVE_ITEM cxxflags -O2)
|
||||||
|
list(APPEND cxxflags -O3)
|
||||||
|
endif()
|
||||||
|
if(coverage)
|
||||||
list(APPEND cxxflags --coverage)
|
list(APPEND cxxflags --coverage)
|
||||||
list(APPEND ldflags --coverage)
|
list(APPEND ldflags --coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -256,6 +157,8 @@ endif()
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Update git submodules as needed
|
# Update git submodules as needed
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
|
find_package(Git)
|
||||||
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
option(GIT_SUBMODULE "Check submodules during build" ON)
|
option(GIT_SUBMODULE "Check submodules during build" ON)
|
||||||
if(GIT_SUBMODULE)
|
if(GIT_SUBMODULE)
|
||||||
|
|
@ -280,47 +183,45 @@ endif()
|
||||||
# pugixml library
|
# pugixml library
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
if(OPENMC_FORCE_VENDORED_LIBS)
|
if (NOT pugixml_FOUND)
|
||||||
add_subdirectory(vendor/pugixml)
|
add_subdirectory(vendor/pugixml)
|
||||||
set_target_properties(pugixml PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF)
|
set_target_properties(pugixml PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF)
|
||||||
else()
|
|
||||||
find_package_write_status(pugixml)
|
|
||||||
if (NOT pugixml_FOUND)
|
|
||||||
add_subdirectory(vendor/pugixml)
|
|
||||||
set_target_properties(pugixml PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# {fmt} library
|
# {fmt} library
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
if(OPENMC_FORCE_VENDORED_LIBS)
|
if (NOT fmt_FOUND)
|
||||||
set(FMT_INSTALL ON CACHE BOOL "Generate the install target.")
|
set(FMT_INSTALL ON CACHE BOOL "Generate the install target.")
|
||||||
add_subdirectory(vendor/fmt)
|
add_subdirectory(vendor/fmt)
|
||||||
else()
|
|
||||||
find_package_write_status(fmt)
|
|
||||||
if (NOT fmt_FOUND)
|
|
||||||
set(FMT_INSTALL ON CACHE BOOL "Generate the install target.")
|
|
||||||
add_subdirectory(vendor/fmt)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Catch2 library
|
# xtensor header-only library
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
if(OPENMC_BUILD_TESTS)
|
# CMake 3.13+ will complain about policy CMP0079 unless it is set explicitly
|
||||||
if (OPENMC_FORCE_VENDORED_LIBS)
|
if (NOT (CMAKE_VERSION VERSION_LESS 3.13))
|
||||||
add_subdirectory(vendor/Catch2)
|
cmake_policy(SET CMP0079 NEW)
|
||||||
else()
|
|
||||||
find_package_write_status(Catch2)
|
|
||||||
if (NOT Catch2_FOUND)
|
|
||||||
add_subdirectory(vendor/Catch2)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(vendor/xtl)
|
||||||
|
set(xtl_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/xtl)
|
||||||
|
add_subdirectory(vendor/xtensor)
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# GSL header-only library
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
set(GSL_LITE_OPT_INSTALL_COMPAT_HEADER ON CACHE BOOL
|
||||||
|
"Install MS-GSL compatibility header <gsl/gsl>")
|
||||||
|
add_subdirectory(vendor/gsl-lite)
|
||||||
|
|
||||||
|
# Make sure contract violations throw exceptions
|
||||||
|
target_compile_definitions(gsl-lite-v1 INTERFACE GSL_THROW_ON_CONTRACT_VIOLATION)
|
||||||
|
target_compile_definitions(gsl-lite-v1 INTERFACE gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON=1)
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# RPATH information
|
# RPATH information
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
@ -350,21 +251,30 @@ if("${isSystemDir}" STREQUAL "-1")
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# faddeeva library
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
add_library(faddeeva STATIC vendor/faddeeva/Faddeeva.cc)
|
||||||
|
target_include_directories(faddeeva
|
||||||
|
PUBLIC
|
||||||
|
$<INSTALL_INTERFACE:include/faddeeva>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vendor/faddeeva>
|
||||||
|
)
|
||||||
|
target_compile_options(faddeeva PRIVATE ${cxxflags})
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# libopenmc
|
# libopenmc
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|
||||||
list(APPEND libopenmc_SOURCES
|
list(APPEND libopenmc_SOURCES
|
||||||
src/atomic_mass.cpp
|
|
||||||
src/bank.cpp
|
src/bank.cpp
|
||||||
src/boundary_condition.cpp
|
src/boundary_condition.cpp
|
||||||
src/bremsstrahlung.cpp
|
src/bremsstrahlung.cpp
|
||||||
src/cell.cpp
|
|
||||||
src/chain.cpp
|
|
||||||
src/cmfd_solver.cpp
|
|
||||||
src/collision_track.cpp
|
|
||||||
src/cross_sections.cpp
|
|
||||||
src/dagmc.cpp
|
src/dagmc.cpp
|
||||||
|
src/cell.cpp
|
||||||
|
src/cmfd_solver.cpp
|
||||||
|
src/cross_sections.cpp
|
||||||
src/distribution.cpp
|
src/distribution.cpp
|
||||||
src/distribution_angle.cpp
|
src/distribution_angle.cpp
|
||||||
src/distribution_energy.cpp
|
src/distribution_energy.cpp
|
||||||
|
|
@ -374,29 +284,23 @@ list(APPEND libopenmc_SOURCES
|
||||||
src/endf.cpp
|
src/endf.cpp
|
||||||
src/error.cpp
|
src/error.cpp
|
||||||
src/event.cpp
|
src/event.cpp
|
||||||
src/file_utils.cpp
|
src/initialize.cpp
|
||||||
src/finalize.cpp
|
src/finalize.cpp
|
||||||
src/geometry.cpp
|
src/geometry.cpp
|
||||||
src/geometry_aux.cpp
|
src/geometry_aux.cpp
|
||||||
src/hdf5_interface.cpp
|
src/hdf5_interface.cpp
|
||||||
src/ifp.cpp
|
|
||||||
src/initialize.cpp
|
|
||||||
src/lattice.cpp
|
src/lattice.cpp
|
||||||
src/material.cpp
|
src/material.cpp
|
||||||
src/math_functions.cpp
|
src/math_functions.cpp
|
||||||
src/mcpl_interface.cpp
|
|
||||||
src/mesh.cpp
|
src/mesh.cpp
|
||||||
src/message_passing.cpp
|
src/message_passing.cpp
|
||||||
src/mgxs.cpp
|
src/mgxs.cpp
|
||||||
src/mgxs_interface.cpp
|
src/mgxs_interface.cpp
|
||||||
src/ncrystal_interface.cpp
|
|
||||||
src/ncrystal_load.cpp
|
|
||||||
src/nuclide.cpp
|
src/nuclide.cpp
|
||||||
src/output.cpp
|
src/output.cpp
|
||||||
src/particle.cpp
|
src/particle.cpp
|
||||||
src/particle_data.cpp
|
src/particle_data.cpp
|
||||||
src/particle_restart.cpp
|
src/particle_restart.cpp
|
||||||
src/particle_type.cpp
|
|
||||||
src/photon.cpp
|
src/photon.cpp
|
||||||
src/physics.cpp
|
src/physics.cpp
|
||||||
src/physics_common.cpp
|
src/physics_common.cpp
|
||||||
|
|
@ -406,13 +310,6 @@ list(APPEND libopenmc_SOURCES
|
||||||
src/progress_bar.cpp
|
src/progress_bar.cpp
|
||||||
src/random_dist.cpp
|
src/random_dist.cpp
|
||||||
src/random_lcg.cpp
|
src/random_lcg.cpp
|
||||||
src/random_ray/random_ray_simulation.cpp
|
|
||||||
src/random_ray/random_ray.cpp
|
|
||||||
src/random_ray/flat_source_domain.cpp
|
|
||||||
src/random_ray/linear_source_domain.cpp
|
|
||||||
src/random_ray/moment_matrix.cpp
|
|
||||||
src/random_ray/source_region.cpp
|
|
||||||
src/ray.cpp
|
|
||||||
src/reaction.cpp
|
src/reaction.cpp
|
||||||
src/reaction_product.cpp
|
src/reaction_product.cpp
|
||||||
src/scattdata.cpp
|
src/scattdata.cpp
|
||||||
|
|
@ -431,55 +328,39 @@ list(APPEND libopenmc_SOURCES
|
||||||
src/tallies/derivative.cpp
|
src/tallies/derivative.cpp
|
||||||
src/tallies/filter.cpp
|
src/tallies/filter.cpp
|
||||||
src/tallies/filter_azimuthal.cpp
|
src/tallies/filter_azimuthal.cpp
|
||||||
src/tallies/filter_cell.cpp
|
|
||||||
src/tallies/filter_cell_instance.cpp
|
|
||||||
src/tallies/filter_cellborn.cpp
|
src/tallies/filter_cellborn.cpp
|
||||||
src/tallies/filter_cellfrom.cpp
|
src/tallies/filter_cellfrom.cpp
|
||||||
src/tallies/filter_collision.cpp
|
src/tallies/filter_cell.cpp
|
||||||
|
src/tallies/filter_cell_instance.cpp
|
||||||
src/tallies/filter_delayedgroup.cpp
|
src/tallies/filter_delayedgroup.cpp
|
||||||
src/tallies/filter_distribcell.cpp
|
src/tallies/filter_distribcell.cpp
|
||||||
src/tallies/filter_energy.cpp
|
|
||||||
src/tallies/filter_energyfunc.cpp
|
src/tallies/filter_energyfunc.cpp
|
||||||
|
src/tallies/filter_energy.cpp
|
||||||
|
src/tallies/filter_collision.cpp
|
||||||
src/tallies/filter_legendre.cpp
|
src/tallies/filter_legendre.cpp
|
||||||
src/tallies/filter_material.cpp
|
src/tallies/filter_material.cpp
|
||||||
src/tallies/filter_materialfrom.cpp
|
|
||||||
src/tallies/filter_mesh.cpp
|
src/tallies/filter_mesh.cpp
|
||||||
src/tallies/filter_meshborn.cpp
|
|
||||||
src/tallies/filter_meshmaterial.cpp
|
|
||||||
src/tallies/filter_meshsurface.cpp
|
src/tallies/filter_meshsurface.cpp
|
||||||
src/tallies/filter_mu.cpp
|
src/tallies/filter_mu.cpp
|
||||||
src/tallies/filter_musurface.cpp
|
|
||||||
src/tallies/filter_parent_nuclide.cpp
|
|
||||||
src/tallies/filter_particle.cpp
|
src/tallies/filter_particle.cpp
|
||||||
src/tallies/filter_particle_production.cpp
|
|
||||||
src/tallies/filter_polar.cpp
|
src/tallies/filter_polar.cpp
|
||||||
src/tallies/filter_reaction.cpp
|
|
||||||
src/tallies/filter_sph_harm.cpp
|
src/tallies/filter_sph_harm.cpp
|
||||||
src/tallies/filter_sptl_legendre.cpp
|
src/tallies/filter_sptl_legendre.cpp
|
||||||
src/tallies/filter_surface.cpp
|
src/tallies/filter_surface.cpp
|
||||||
src/tallies/filter_time.cpp
|
|
||||||
src/tallies/filter_universe.cpp
|
src/tallies/filter_universe.cpp
|
||||||
src/tallies/filter_weight.cpp
|
|
||||||
src/tallies/filter_zernike.cpp
|
src/tallies/filter_zernike.cpp
|
||||||
src/tallies/tally.cpp
|
src/tallies/tally.cpp
|
||||||
src/tallies/tally_scoring.cpp
|
src/tallies/tally_scoring.cpp
|
||||||
src/tallies/trigger.cpp
|
src/tallies/trigger.cpp
|
||||||
src/thermal.cpp
|
|
||||||
src/timer.cpp
|
src/timer.cpp
|
||||||
|
src/thermal.cpp
|
||||||
src/track_output.cpp
|
src/track_output.cpp
|
||||||
src/universe.cpp
|
|
||||||
src/urr.cpp
|
src/urr.cpp
|
||||||
src/volume_calc.cpp
|
src/volume_calc.cpp
|
||||||
src/weight_windows.cpp
|
|
||||||
src/wmp.cpp
|
src/wmp.cpp
|
||||||
src/xml_interface.cpp
|
src/xml_interface.cpp
|
||||||
src/xsdata.cpp)
|
src/xsdata.cpp)
|
||||||
|
|
||||||
# Add bundled external dependencies
|
|
||||||
list(APPEND libopenmc_SOURCES
|
|
||||||
src/external/quartic_solver.cpp
|
|
||||||
src/external/Faddeeva.cc)
|
|
||||||
|
|
||||||
# For Visual Studio compilers
|
# For Visual Studio compilers
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Use static library (otherwise explicit symbol portings are needed)
|
# Use static library (otherwise explicit symbol portings are needed)
|
||||||
|
|
@ -492,8 +373,6 @@ else()
|
||||||
add_library(libopenmc SHARED ${libopenmc_SOURCES})
|
add_library(libopenmc SHARED ${libopenmc_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(OpenMC::libopenmc ALIAS libopenmc)
|
|
||||||
|
|
||||||
# Avoid vs error lnk1149 :output filename matches input filename
|
# Avoid vs error lnk1149 :output filename matches input filename
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set_target_properties(libopenmc PROPERTIES OUTPUT_NAME openmc)
|
set_target_properties(libopenmc PROPERTIES OUTPUT_NAME openmc)
|
||||||
|
|
@ -510,93 +389,55 @@ target_include_directories(libopenmc
|
||||||
target_compile_options(libopenmc PRIVATE ${cxxflags})
|
target_compile_options(libopenmc PRIVATE ${cxxflags})
|
||||||
|
|
||||||
# Add include directory for configured version file
|
# Add include directory for configured version file
|
||||||
target_include_directories(libopenmc
|
target_include_directories(libopenmc PRIVATE ${CMAKE_BINARY_DIR}/include)
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
|
||||||
|
|
||||||
if (HDF5_IS_PARALLEL)
|
if (HDF5_IS_PARALLEL)
|
||||||
target_compile_definitions(libopenmc PRIVATE -DPHDF5)
|
target_compile_definitions(libopenmc PRIVATE -DPHDF5)
|
||||||
endif()
|
endif()
|
||||||
if (OPENMC_USE_MPI)
|
if (MPI_ENABLED)
|
||||||
target_compile_definitions(libopenmc PUBLIC -DOPENMC_MPI)
|
target_compile_definitions(libopenmc PUBLIC -DOPENMC_MPI)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Set git SHA1 hash as a compile definition
|
||||||
|
if(GIT_FOUND)
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE GIT_SHA1_SUCCESS
|
||||||
|
OUTPUT_VARIABLE GIT_SHA1
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(GIT_SHA1_SUCCESS EQUAL 0)
|
||||||
|
target_compile_definitions(libopenmc PRIVATE -DGIT_SHA1="${GIT_SHA1}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# target_link_libraries treats any arguments starting with - but not -l as
|
# target_link_libraries treats any arguments starting with - but not -l as
|
||||||
# linker flags. Thus, we can pass both linker flags and libraries together.
|
# linker flags. Thus, we can pass both linker flags and libraries together.
|
||||||
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
|
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
|
||||||
fmt::fmt ${CMAKE_DL_LIBS})
|
pugixml faddeeva xtensor gsl-lite-v1 fmt::fmt)
|
||||||
|
|
||||||
if(TARGET pugixml::pugixml)
|
if(dagmc)
|
||||||
target_link_libraries(libopenmc pugixml::pugixml)
|
target_compile_definitions(libopenmc PRIVATE DAGMC)
|
||||||
else()
|
target_link_libraries(libopenmc dagmc-shared uwuw-shared)
|
||||||
target_link_libraries(libopenmc pugixml)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OPENMC_USE_DAGMC)
|
if(libmesh)
|
||||||
target_compile_definitions(libopenmc PUBLIC OPENMC_DAGMC_ENABLED)
|
target_compile_definitions(libopenmc PRIVATE LIBMESH)
|
||||||
target_link_libraries(libopenmc dagmc-shared)
|
|
||||||
|
|
||||||
if(OPENMC_USE_UWUW)
|
|
||||||
target_compile_definitions(libopenmc PRIVATE OPENMC_UWUW_ENABLED)
|
|
||||||
target_link_libraries(libopenmc uwuw-shared)
|
|
||||||
endif()
|
|
||||||
elseif(OPENMC_USE_UWUW)
|
|
||||||
set(OPENMC_USE_UWUW OFF)
|
|
||||||
message(FATAL_ERROR "DAGMC must be enabled when UWUW is enabled.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(OPENMC_USE_LIBMESH)
|
|
||||||
target_compile_definitions(libopenmc PRIVATE OPENMC_LIBMESH_ENABLED)
|
|
||||||
target_link_libraries(libopenmc PkgConfig::LIBMESH)
|
target_link_libraries(libopenmc PkgConfig::LIBMESH)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PNG_FOUND)
|
|
||||||
target_compile_definitions(libopenmc PRIVATE USE_LIBPNG)
|
|
||||||
target_link_libraries(libopenmc PNG::PNG)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (OPENMC_USE_OPENMP)
|
|
||||||
target_link_libraries(libopenmc OpenMP::OpenMP_CXX)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (OPENMC_USE_MPI)
|
|
||||||
target_link_libraries(libopenmc MPI::MPI_CXX)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (OPENMC_BUILD_TESTS)
|
|
||||||
# Add cpp tests directory
|
|
||||||
include(CTest)
|
|
||||||
add_subdirectory(tests/cpp_unit_tests)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Log build info that this executable can report later
|
|
||||||
#===============================================================================
|
|
||||||
target_compile_definitions(libopenmc PRIVATE BUILD_TYPE=${CMAKE_BUILD_TYPE})
|
|
||||||
target_compile_definitions(libopenmc PRIVATE COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
|
|
||||||
target_compile_definitions(libopenmc PRIVATE COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION})
|
|
||||||
if (OPENMC_ENABLE_PROFILE)
|
|
||||||
target_compile_definitions(libopenmc PRIVATE PROFILINGBUILD)
|
|
||||||
endif()
|
|
||||||
if (OPENMC_ENABLE_COVERAGE)
|
|
||||||
target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD)
|
|
||||||
endif()
|
|
||||||
if (OPENMC_ENABLE_STRICT_FP)
|
|
||||||
target_compile_definitions(libopenmc PRIVATE OPENMC_ENABLE_STRICT_FP)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# openmc executable
|
# openmc executable
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
add_executable(openmc src/main.cpp)
|
add_executable(openmc src/main.cpp)
|
||||||
add_executable(OpenMC::openmc ALIAS openmc)
|
|
||||||
target_compile_options(openmc PRIVATE ${cxxflags})
|
target_compile_options(openmc PRIVATE ${cxxflags})
|
||||||
target_include_directories(openmc PRIVATE ${CMAKE_BINARY_DIR}/include)
|
target_include_directories(openmc PRIVATE ${CMAKE_BINARY_DIR}/include)
|
||||||
target_link_libraries(openmc libopenmc)
|
target_link_libraries(openmc libopenmc)
|
||||||
|
|
||||||
# Ensure C++17 standard is used and turn off GNU extensions
|
# Ensure C++14 standard is used. Starting with CMake 3.8, another way this could
|
||||||
target_compile_features(openmc PUBLIC cxx_std_17)
|
# be done is using the cxx_std_14 compiler feature.
|
||||||
target_compile_features(libopenmc PUBLIC cxx_std_17)
|
set_target_properties(
|
||||||
set_target_properties(openmc libopenmc PROPERTIES CXX_EXTENSIONS OFF)
|
openmc libopenmc faddeeva
|
||||||
|
PROPERTIES CXX_STANDARD 14 CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Python package
|
# Python package
|
||||||
|
|
@ -611,10 +452,12 @@ add_custom_command(TARGET libopenmc POST_BUILD
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Install executable, scripts, manpage, license
|
# Install executable, scripts, manpage, license
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
|
configure_file(cmake/OpenMCConfig.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" @ONLY)
|
||||||
|
configure_file(cmake/OpenMCConfigVersion.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" @ONLY)
|
||||||
|
|
||||||
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
|
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
|
||||||
install(TARGETS openmc libopenmc
|
install(TARGETS openmc libopenmc faddeeva
|
||||||
EXPORT openmc-targets
|
EXPORT openmc-targets
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
|
@ -625,25 +468,16 @@ install(EXPORT openmc-targets
|
||||||
NAMESPACE OpenMC::
|
NAMESPACE OpenMC::
|
||||||
DESTINATION ${INSTALL_CONFIGDIR})
|
DESTINATION ${INSTALL_CONFIGDIR})
|
||||||
|
|
||||||
configure_package_config_file(
|
install(DIRECTORY src/relaxng DESTINATION ${CMAKE_INSTALL_DATADIR}/openmc)
|
||||||
"cmake/OpenMCConfig.cmake.in"
|
|
||||||
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
|
|
||||||
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
write_basic_package_version_file(
|
|
||||||
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake"
|
|
||||||
VERSION ${OPENMC_VERSION}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
|
||||||
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake"
|
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake"
|
||||||
DESTINATION "${INSTALL_CONFIGDIR}"
|
DESTINATION ${INSTALL_CONFIGDIR})
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||||
install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright)
|
install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright)
|
||||||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
install(FILES "${CMAKE_BINARY_DIR}/include/openmc/version.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openmc)
|
install(FILES "${CMAKE_BINARY_DIR}/include/openmc/version.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openmc)
|
||||||
|
|
||||||
|
# Copy headers for vendored dependencies (note that all except faddeeva are handled
|
||||||
|
# separately since they are managed by CMake)
|
||||||
|
install(DIRECTORY vendor/faddeeva DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
|
|
||||||
25
CODEOWNERS
|
|
@ -5,9 +5,9 @@ openmc/data/ @paulromano
|
||||||
openmc/lib/ @paulromano
|
openmc/lib/ @paulromano
|
||||||
|
|
||||||
# Depletion
|
# Depletion
|
||||||
openmc/deplete/ @paulromano
|
openmc/deplete/ @drewejohnson
|
||||||
tests/regression_tests/deplete/ @paulromano
|
tests/regression_tests/deplete/ @drewejohnson
|
||||||
tests/unit_tests/test_deplete_*.py @paulromano
|
tests/unit_tests/test_deplete_*.py @drewejohnson
|
||||||
|
|
||||||
# MG-related functionality
|
# MG-related functionality
|
||||||
openmc/mgxs_library.py @nelsonag
|
openmc/mgxs_library.py @nelsonag
|
||||||
|
|
@ -26,12 +26,6 @@ src/dagmc.cpp @pshriwise
|
||||||
tests/regression_tests/dagmc/ @pshriwise
|
tests/regression_tests/dagmc/ @pshriwise
|
||||||
tests/unit_tests/dagmc/ @pshriwise
|
tests/unit_tests/dagmc/ @pshriwise
|
||||||
|
|
||||||
# Weight windows
|
|
||||||
openmc/weight_windows.py @pshriwise
|
|
||||||
openmc/lib/weight_windows.py @pshriwise
|
|
||||||
src/weight_windows.py @pshriwise
|
|
||||||
tests/unit_tests/weightwindows/ @pshriwise
|
|
||||||
|
|
||||||
# Photon transport
|
# Photon transport
|
||||||
openmc/data/BREMX.DAT @amandalund
|
openmc/data/BREMX.DAT @amandalund
|
||||||
openmc/data/compton_profiles.h5 @amandalund
|
openmc/data/compton_profiles.h5 @amandalund
|
||||||
|
|
@ -52,16 +46,3 @@ openmc/lib/plot.py @pshriwise
|
||||||
|
|
||||||
# Resonance covariance
|
# Resonance covariance
|
||||||
openmc/data/resonance_covariance.py @icmeyer
|
openmc/data/resonance_covariance.py @icmeyer
|
||||||
|
|
||||||
# Docker
|
|
||||||
Dockerfile @shimwell
|
|
||||||
|
|
||||||
# Random ray
|
|
||||||
src/random_ray/ @jtramm
|
|
||||||
|
|
||||||
# NCrystal interface
|
|
||||||
src/ncrystal_interface.cpp @marquezj @tkittel
|
|
||||||
src/ncrystal_load.cpp @marquezj @tkittel
|
|
||||||
|
|
||||||
# MCPL interface
|
|
||||||
src/mcpl_interface.cpp @ebknudsen
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,9 @@ openmc@anl.gov.
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
- [GitHub Repository](https://github.com/openmc-dev/openmc)
|
- [GitHub Repository](https://github.com/openmc-dev/openmc)
|
||||||
- [Documentation](https://docs.openmc.org/en/latest)
|
- [Documentation](http://openmc.readthedocs.io/en/latest)
|
||||||
- [Discussion Forum](https://openmc.discourse.group)
|
- [User's Mailing List](openmc-users@googlegroups.com)
|
||||||
|
- [Developer's Mailing List](openmc-dev@googlegroups.com)
|
||||||
- [Slack Community](https://openmc.slack.com/signup) (If you don't see your
|
- [Slack Community](https://openmc.slack.com/signup) (If you don't see your
|
||||||
domain listed, contact openmc@anl.gov)
|
domain listed, contact openmc@anl.gov)
|
||||||
|
|
||||||
|
|
@ -36,10 +37,10 @@ development team will be happy to discuss it.
|
||||||
|
|
||||||
All changes to OpenMC happen through pull requests. For a full overview of the
|
All changes to OpenMC happen through pull requests. For a full overview of the
|
||||||
process, see the developer's guide section on [Contributing to
|
process, see the developer's guide section on [Contributing to
|
||||||
OpenMC](https://docs.openmc.org/en/latest/devguide/contributing.html).
|
OpenMC](http://openmc.readthedocs.io/en/latest/devguide/contributing.html).
|
||||||
|
|
||||||
## Code Style
|
## Code Style
|
||||||
|
|
||||||
Before you run off to make changes to the code, please have a look at our [style
|
Before you run off to make changes to the code, please have a look at our [style
|
||||||
guide](https://docs.openmc.org/en/latest/devguide/styleguide.html), which
|
guide](http://openmc.readthedocs.io/en/latest/devguide/styleguide.html), which
|
||||||
is used when reviewing new contributions.
|
is used when reviewing new contributions.
|
||||||
|
|
|
||||||
310
Dockerfile
|
|
@ -1,229 +1,149 @@
|
||||||
# To build with OpenMC and by default this Dockerfile builds the master branch of OpenMC.
|
# To build with OpenMC
|
||||||
# docker build -t openmc .
|
# docker build -t openmc .
|
||||||
|
|
||||||
# To build with OpenMC develop branch
|
|
||||||
# docker build -t openmc_develop --build-arg openmc_branch=develop .
|
|
||||||
|
|
||||||
# To build with OpenMC and DAGMC enabled
|
# To build with OpenMC and DAGMC enabled
|
||||||
# docker build -t openmc_dagmc --build-arg build_dagmc=on --build-arg compile_cores=4 .
|
# docker build -t openmc_dagmc --build-arg include_dagmc=true .
|
||||||
|
|
||||||
# To build with OpenMC and Libmesh enabled
|
# To make use of multiple cores during the compile stages of the docker build
|
||||||
# docker build -t openmc_libmesh --build-arg build_libmesh=on --build-arg compile_cores=4 .
|
# docker build -t openmc_dagmc --build-arg compile_cores=8 .
|
||||||
|
|
||||||
# To build with both DAGMC and Libmesh enabled
|
FROM ubuntu:latest
|
||||||
# docker build -t openmc_dagmc_libmesh --build-arg build_dagmc=on --build-arg build_libmesh=on --build-arg compile_cores=4 .
|
|
||||||
|
|
||||||
# sudo docker run image_name:tag_name or ID with no tag sudo docker run ID number
|
# By default this Dockerfile builds OpenMC without dagmc
|
||||||
|
ARG include_dagmc=false
|
||||||
|
|
||||||
|
|
||||||
# global ARG as these ARGS are used in multiple stages
|
|
||||||
# By default one core is used to compile
|
# By default one core is used to compile
|
||||||
ARG compile_cores=1
|
ARG compile_cores=1
|
||||||
|
|
||||||
# By default this Dockerfile builds OpenMC without DAGMC and LIBMESH support
|
|
||||||
ARG build_dagmc=off
|
|
||||||
ARG build_libmesh=off
|
|
||||||
|
|
||||||
FROM ubuntu:24.04 AS dependencies
|
|
||||||
|
|
||||||
ARG compile_cores
|
|
||||||
ARG build_dagmc
|
|
||||||
ARG build_libmesh
|
|
||||||
|
|
||||||
# Set default value of HOME to /root
|
|
||||||
ENV HOME=/root
|
|
||||||
|
|
||||||
# MOAB variables
|
|
||||||
ENV MOAB_TAG='5.5.1'
|
|
||||||
ENV MOAB_REPO='https://bitbucket.org/fathomteam/moab/'
|
|
||||||
|
|
||||||
# Double-Down variables
|
|
||||||
ENV DD_TAG='v1.1.0'
|
|
||||||
ENV DD_REPO='https://github.com/pshriwise/double-down'
|
|
||||||
ENV DD_INSTALL_DIR=$HOME/Double_down
|
|
||||||
|
|
||||||
# DAGMC variables
|
|
||||||
ENV DAGMC_BRANCH='v3.2.4'
|
|
||||||
ENV DAGMC_REPO='https://github.com/svalinn/DAGMC'
|
|
||||||
ENV DAGMC_INSTALL_DIR=$HOME/DAGMC/
|
|
||||||
|
|
||||||
# LIBMESH variables
|
|
||||||
ENV LIBMESH_TAG='v1.7.1'
|
|
||||||
ENV LIBMESH_REPO='https://github.com/libMesh/libmesh'
|
|
||||||
ENV LIBMESH_INSTALL_DIR=$HOME/LIBMESH
|
|
||||||
|
|
||||||
# NJOY variables
|
|
||||||
ENV NJOY_TAG='2016.78'
|
|
||||||
ENV NJOY_REPO='https://github.com/njoy/NJOY2016'
|
|
||||||
|
|
||||||
# Setup environment variables for Docker image
|
# Setup environment variables for Docker image
|
||||||
ENV LD_LIBRARY_PATH=${DAGMC_INSTALL_DIR}/lib:${LD_LIBRARY_PATH:-} \
|
ENV CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx \
|
||||||
|
PATH=/opt/openmc/bin:/opt/NJOY2016/build:$PATH \
|
||||||
|
LD_LIBRARY_PATH=/opt/openmc/lib:$LD_LIBRARY_PATH \
|
||||||
|
OPENMC_CROSS_SECTIONS=/root/nndc_hdf5/cross_sections.xml \
|
||||||
OPENMC_ENDF_DATA=/root/endf-b-vii.1 \
|
OPENMC_ENDF_DATA=/root/endf-b-vii.1 \
|
||||||
DEBIAN_FRONTEND=noninteractive
|
DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# Install and update dependencies from Debian package manager
|
# Install dependencies from Debian package manager
|
||||||
RUN apt-get update -y && \
|
RUN apt-get update -y && \
|
||||||
apt-get upgrade -y && \
|
apt-get upgrade -y && \
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
python3-pip python-is-python3 wget git build-essential cmake \
|
python3-pip python-is-python3 wget git gfortran g++ cmake \
|
||||||
mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev \
|
mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev \
|
||||||
libpng-dev libpugixml-dev libfmt-dev catch2 python3-venv && \
|
imagemagick && \
|
||||||
apt-get autoremove
|
apt-get autoremove
|
||||||
|
|
||||||
# create virtual enviroment to avoid externally managed environment error
|
|
||||||
RUN python3 -m venv openmc_venv
|
|
||||||
ENV PATH=/openmc_venv/bin:$PATH
|
|
||||||
|
|
||||||
# Update system-provided pip
|
# Update system-provided pip
|
||||||
RUN pip install --upgrade pip
|
RUN pip3 install --upgrade pip
|
||||||
|
|
||||||
# Clone and install NJOY2016
|
# Clone and install NJOY2016
|
||||||
RUN cd $HOME \
|
RUN git clone https://github.com/njoy/NJOY2016.git /opt/NJOY2016 && \
|
||||||
&& git clone --single-branch -b ${NJOY_TAG} --depth 1 ${NJOY_REPO} \
|
cd /opt/NJOY2016 && \
|
||||||
&& cd NJOY2016 \
|
mkdir build && cd build && \
|
||||||
&& mkdir build \
|
cmake -Dstatic=on .. && make 2>/dev/null && make install
|
||||||
&& cd build \
|
|
||||||
&& cmake -Dstatic=on .. \
|
|
||||||
&& make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& rm -rf $HOME/NJOY2016
|
|
||||||
|
|
||||||
|
# Clone and install OpenMC without DAGMC
|
||||||
RUN if [ "$build_dagmc" = "on" ]; then \
|
RUN if [ "$include_dagmc" = "false" ] ; \
|
||||||
# Install addition packages required for DAGMC
|
then git clone --recurse-submodules https://github.com/openmc-dev/openmc.git /opt/openmc ; \
|
||||||
apt-get -y install \
|
cd /opt/openmc ; \
|
||||||
libeigen3-dev libnetcdf-dev libtbb-dev libglfw3-dev libembree-dev \
|
mkdir -p build ; \
|
||||||
&& pip install --upgrade numpy \
|
cd build ; \
|
||||||
&& pip install --no-cache-dir setuptools cython \
|
cmake -Doptimize=on \
|
||||||
# Clone and install MOAB
|
-DHDF5_PREFER_PARALLEL=on .. ; \
|
||||||
&& mkdir -p $HOME/MOAB && cd $HOME/MOAB \
|
make -j"$compile_cores" ; \
|
||||||
&& git clone --single-branch -b ${MOAB_TAG} --depth 1 ${MOAB_REPO} \
|
make -j"$compile_cores" install ; \
|
||||||
&& mkdir build && cd build \
|
cd .. ; \
|
||||||
&& cmake ../moab -DCMAKE_BUILD_TYPE=Release \
|
pip install -e .[test] ; \
|
||||||
-DENABLE_HDF5=ON \
|
|
||||||
-DENABLE_NETCDF=ON \
|
|
||||||
-DBUILD_SHARED_LIBS=OFF \
|
|
||||||
-DENABLE_FORTRAN=OFF \
|
|
||||||
-DENABLE_BLASLAPACK=OFF \
|
|
||||||
-DENABLE_TESTING=OFF \
|
|
||||||
&& make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& cmake ../moab \
|
|
||||||
-DENABLE_PYMOAB=ON \
|
|
||||||
-DBUILD_SHARED_LIBS=ON \
|
|
||||||
&& make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& cd pymoab && bash install.sh \
|
|
||||||
&& python setup.py install \
|
|
||||||
&& python -c "import pymoab" \
|
|
||||||
&& rm -rf $HOME/MOAB ; \
|
|
||||||
# Clone and install Double-Down
|
|
||||||
mkdir -p $HOME/Double_down && cd $HOME/Double_down \
|
|
||||||
&& git clone --single-branch -b ${DD_TAG} --depth 1 ${DD_REPO} \
|
|
||||||
&& mkdir build && cd build \
|
|
||||||
&& cmake ../double-down -DCMAKE_INSTALL_PREFIX=${DD_INSTALL_DIR} \
|
|
||||||
-DMOAB_DIR=/usr/local \
|
|
||||||
-DEMBREE_DIR=/usr \
|
|
||||||
&& make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& rm -rf ${DD_INSTALL_DIR}/build ${DD_INSTALL_DIR}/double-down ; \
|
|
||||||
# Clone and install DAGMC
|
|
||||||
mkdir -p $HOME/DAGMC && cd $HOME/DAGMC \
|
|
||||||
&& git clone --single-branch -b ${DAGMC_BRANCH} --depth 1 ${DAGMC_REPO} \
|
|
||||||
&& mkdir build && cd build \
|
|
||||||
&& cmake ../DAGMC -DBUILD_TALLY=ON \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=${DAGMC_INSTALL_DIR} \
|
|
||||||
-DMOAB_DIR=/usr/local \
|
|
||||||
-DDOUBLE_DOWN=ON \
|
|
||||||
-DDOUBLE_DOWN_DIR=${DD_INSTALL_DIR} \
|
|
||||||
-DCMAKE_PREFIX_PATH=${DD_INSTALL_DIR}/lib \
|
|
||||||
-DBUILD_STATIC_LIBS=OFF \
|
|
||||||
-DBUILD_TESTS=OFF \
|
|
||||||
&& make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& rm -rf ${DAGMC_INSTALL_DIR}/DAGMC ${DAGMC_INSTALL_DIR}/build ; \
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# install addition packages required for DAGMC
|
||||||
RUN if [ "$build_libmesh" = "on" ]; then \
|
RUN if [ "$include_dagmc" = "true" ] ; \
|
||||||
# Install addition packages required for LIBMESH
|
then apt-get --yes install libeigen3-dev ; \
|
||||||
apt-get -y install m4 libnetcdf-dev libpnetcdf-dev \
|
apt-get --yes install libnetcdf-dev ; \
|
||||||
# Install LIBMESH
|
apt-get --yes install libtbb-dev ; \
|
||||||
&& mkdir -p $HOME/LIBMESH && cd $HOME/LIBMESH \
|
apt-get --yes install libglfw3-dev ; \
|
||||||
&& git clone --shallow-submodules --recurse-submodules --single-branch -b ${LIBMESH_TAG} --depth 1 ${LIBMESH_REPO} \
|
|
||||||
&& mkdir build && cd build \
|
|
||||||
&& ../libmesh/configure \
|
|
||||||
--prefix=${LIBMESH_INSTALL_DIR} CXX=mpicxx CC=mpicc FC=mpifort F77=mpif77 \
|
|
||||||
--enable-exodus \
|
|
||||||
--enable-mpi \
|
|
||||||
--enable-silent-rules \
|
|
||||||
--enable-unique-id \
|
|
||||||
--disable-eigen \
|
|
||||||
--disable-fortran \
|
|
||||||
--disable-lapack \
|
|
||||||
--disable-examples \
|
|
||||||
--disable-warnings \
|
|
||||||
--disable-maintainer-mode \
|
|
||||||
--disable-metaphysicl \
|
|
||||||
--with-methods="opt" \
|
|
||||||
--without-gdb-command \
|
|
||||||
--with-cxx-std-min=2014 \
|
|
||||||
&& make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& rm -rf ${LIBMESH_INSTALL_DIR}/build ${LIBMESH_INSTALL_DIR}/libmesh ; \
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FROM dependencies AS build
|
# Clone and install Embree
|
||||||
|
RUN if [ "$include_dagmc" = "true" ] ; \
|
||||||
|
then git clone --single-branch --branch v3.12.2 https://github.com/embree/embree.git ; \
|
||||||
|
cd embree ; \
|
||||||
|
mkdir build ; \
|
||||||
|
cd build ; \
|
||||||
|
cmake .. -DCMAKE_INSTALL_PREFIX=.. \
|
||||||
|
-DEMBREE_ISPC_SUPPORT=OFF ; \
|
||||||
|
make -j"$compile_cores" ; \
|
||||||
|
make -j"$compile_cores" install ; \
|
||||||
|
fi
|
||||||
|
|
||||||
ENV HOME=/root
|
# Clone and install MOAB
|
||||||
|
RUN if [ "$include_dagmc" = "true" ] ; \
|
||||||
|
then pip install --upgrade numpy cython ; \
|
||||||
|
mkdir MOAB ; \
|
||||||
|
cd MOAB ; \
|
||||||
|
mkdir build ; \
|
||||||
|
git clone --single-branch --branch 5.2.1 https://bitbucket.org/fathomteam/moab.git ; \
|
||||||
|
cd build ; \
|
||||||
|
cmake ../moab -DENABLE_HDF5=ON \
|
||||||
|
-DENABLE_NETCDF=ON \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DENABLE_FORTRAN=OFF \
|
||||||
|
-DENABLE_BLASLAPACK=OFF ; \
|
||||||
|
make -j"$compile_cores" ; \
|
||||||
|
make -j"$compile_cores" install ; \
|
||||||
|
rm -rf * ; \
|
||||||
|
cmake ../moab -DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DENABLE_HDF5=ON \
|
||||||
|
-DENABLE_PYMOAB=ON \
|
||||||
|
-DENABLE_FORTRAN=OFF \
|
||||||
|
-DENABLE_BLASLAPACK=OFF ; \
|
||||||
|
make -j"$compile_cores" ; \
|
||||||
|
make -j"$compile_cores" install ; \
|
||||||
|
fi
|
||||||
|
|
||||||
ARG openmc_branch=master
|
# Clone and install Double-Down
|
||||||
ENV OPENMC_REPO='https://github.com/openmc-dev/openmc'
|
RUN if [ "$include_dagmc" = "true" ] ; \
|
||||||
|
then git clone --single-branch --branch main https://github.com/pshriwise/double-down.git ; \
|
||||||
|
cd double-down ; \
|
||||||
|
mkdir build ; \
|
||||||
|
cd build ; \
|
||||||
|
cmake .. -DCMAKE_INSTALL_PREFIX=.. \
|
||||||
|
-DMOAB_DIR=/usr/local \
|
||||||
|
-DEMBREE_DIR=/embree ; \
|
||||||
|
make -j"$compile_cores" ; \
|
||||||
|
make -j"$compile_cores" install ; \
|
||||||
|
fi
|
||||||
|
|
||||||
ARG compile_cores
|
# Clone and install DAGMC
|
||||||
ARG build_dagmc
|
RUN if [ "$include_dagmc" = "true" ] ; \
|
||||||
ARG build_libmesh
|
then mkdir DAGMC ; \
|
||||||
|
cd DAGMC ; \
|
||||||
|
git clone --single-branch --branch 3.2.0 https://github.com/svalinn/DAGMC.git ; \
|
||||||
|
mkdir build ; \
|
||||||
|
cd build ; \
|
||||||
|
cmake ../DAGMC -DBUILD_TALLY=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=/DAGMC/ \
|
||||||
|
-DMOAB_DIR=/usr/local \
|
||||||
|
-DBUILD_STATIC_LIBS=OFF \
|
||||||
|
-DBUILD_STATIC_EXE=OFF ; \
|
||||||
|
make -j"$compile_cores" install ; \
|
||||||
|
rm -rf /DAGMC/DAGMC /DAGMC/build ; \
|
||||||
|
fi
|
||||||
|
|
||||||
ENV DAGMC_INSTALL_DIR=$HOME/DAGMC/
|
# Clone and install OpenMC with DAGMC
|
||||||
ENV LIBMESH_INSTALL_DIR=$HOME/LIBMESH
|
RUN if [ "$include_dagmc" = "true" ] ; \
|
||||||
|
then git clone --recurse-submodules https://github.com/openmc-dev/openmc.git /opt/openmc ; \
|
||||||
# clone and install openmc
|
cd /opt/openmc ; \
|
||||||
RUN mkdir -p ${HOME}/OpenMC && cd ${HOME}/OpenMC \
|
mkdir build ; \
|
||||||
&& git clone --shallow-submodules --recurse-submodules --single-branch -b ${openmc_branch} ${OPENMC_REPO} \
|
cd build ; \
|
||||||
&& mkdir build && cd build ; \
|
cmake -Doptimize=on \
|
||||||
if [ ${build_dagmc} = "on" ] && [ ${build_libmesh} = "on" ]; then \
|
-Ddagmc=ON \
|
||||||
cmake ../openmc \
|
-DDAGMC_DIR=/DAGMC/ \
|
||||||
-DCMAKE_CXX_COMPILER=mpicxx \
|
-DHDF5_PREFER_PARALLEL=on .. ; \
|
||||||
-DOPENMC_USE_MPI=on \
|
make -j"$compile_cores" ; \
|
||||||
-DHDF5_PREFER_PARALLEL=on \
|
make -j"$compile_cores" install ; \
|
||||||
-DOPENMC_USE_DAGMC=on \
|
cd .. ; \
|
||||||
-DOPENMC_USE_LIBMESH=on \
|
pip install -e .[test] ; \
|
||||||
-DCMAKE_PREFIX_PATH="${DAGMC_INSTALL_DIR};${LIBMESH_INSTALL_DIR}" ; \
|
fi
|
||||||
fi ; \
|
|
||||||
if [ ${build_dagmc} = "on" ] && [ ${build_libmesh} = "off" ]; then \
|
|
||||||
cmake ../openmc \
|
|
||||||
-DCMAKE_CXX_COMPILER=mpicxx \
|
|
||||||
-DOPENMC_USE_MPI=on \
|
|
||||||
-DHDF5_PREFER_PARALLEL=on \
|
|
||||||
-DOPENMC_USE_DAGMC=ON \
|
|
||||||
-DCMAKE_PREFIX_PATH=${DAGMC_INSTALL_DIR} ; \
|
|
||||||
fi ; \
|
|
||||||
if [ ${build_dagmc} = "off" ] && [ ${build_libmesh} = "on" ]; then \
|
|
||||||
cmake ../openmc \
|
|
||||||
-DCMAKE_CXX_COMPILER=mpicxx \
|
|
||||||
-DOPENMC_USE_MPI=on \
|
|
||||||
-DHDF5_PREFER_PARALLEL=on \
|
|
||||||
-DOPENMC_USE_LIBMESH=on \
|
|
||||||
-DCMAKE_PREFIX_PATH=${LIBMESH_INSTALL_DIR} ; \
|
|
||||||
fi ; \
|
|
||||||
if [ ${build_dagmc} = "off" ] && [ ${build_libmesh} = "off" ]; then \
|
|
||||||
cmake ../openmc \
|
|
||||||
-DCMAKE_CXX_COMPILER=mpicxx \
|
|
||||||
-DOPENMC_USE_MPI=on \
|
|
||||||
-DHDF5_PREFER_PARALLEL=on ; \
|
|
||||||
fi ; \
|
|
||||||
make 2>/dev/null -j${compile_cores} install \
|
|
||||||
&& cd ../openmc && pip install .[test,depletion-mpi] \
|
|
||||||
&& python -c "import openmc"
|
|
||||||
|
|
||||||
FROM build AS release
|
|
||||||
|
|
||||||
ENV HOME=/root
|
|
||||||
ENV OPENMC_CROSS_SECTIONS=/root/nndc_hdf5/cross_sections.xml
|
|
||||||
|
|
||||||
# Download cross sections (NNDC and WMP) and ENDF data needed by test suite
|
# Download cross sections (NNDC and WMP) and ENDF data needed by test suite
|
||||||
RUN ${HOME}/OpenMC/openmc/tools/ci/download-xs.sh
|
RUN /opt/openmc/tools/ci/download-xs.sh
|
||||||
|
|
|
||||||
3
LICENSE
|
|
@ -1,5 +1,4 @@
|
||||||
Copyright (c) 2011-2026 Massachusetts Institute of Technology, UChicago Argonne
|
Copyright (c) 2011-2021 Massachusetts Institute of Technology and OpenMC contributors
|
||||||
LLC, and OpenMC contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
||||||
15
MANIFEST.in
|
|
@ -8,6 +8,7 @@ include schemas.xml
|
||||||
include pyproject.toml
|
include pyproject.toml
|
||||||
include pytest.ini
|
include pytest.ini
|
||||||
include docs/source/_templates/layout.html
|
include docs/source/_templates/layout.html
|
||||||
|
include docs/sphinxext/LICENSE
|
||||||
global-include *.cmake
|
global-include *.cmake
|
||||||
global-include *.cmake.in
|
global-include *.cmake.in
|
||||||
global-include *.rst
|
global-include *.rst
|
||||||
|
|
@ -19,20 +20,25 @@ recursive-include docs *.svg
|
||||||
recursive-include docs *.tex
|
recursive-include docs *.tex
|
||||||
recursive-include docs *.txt
|
recursive-include docs *.txt
|
||||||
recursive-include docs Makefile
|
recursive-include docs Makefile
|
||||||
recursive-include examples *.cpp
|
recursive-include examples *.h5
|
||||||
|
recursive-include examples *.ipynb
|
||||||
|
recursive-include examples *.png
|
||||||
recursive-include examples *.py
|
recursive-include examples *.py
|
||||||
recursive-include examples *.xml
|
recursive-include examples *.xml
|
||||||
recursive-include include *.h
|
recursive-include include *.h
|
||||||
recursive-include include *.h.in
|
|
||||||
recursive-include include *.hh
|
|
||||||
recursive-include man *.1
|
recursive-include man *.1
|
||||||
|
recursive-inlcude openmc *.pyx
|
||||||
|
recursive-include openmc *.c
|
||||||
|
recursive-include src *.c
|
||||||
recursive-include src *.cc
|
recursive-include src *.cc
|
||||||
recursive-include src *.cpp
|
recursive-include src *.cpp
|
||||||
|
recursive-include src *.h
|
||||||
|
recursive-include src *.hpp
|
||||||
recursive-include src *.rnc
|
recursive-include src *.rnc
|
||||||
recursive-include src *.rng
|
recursive-include src *.rng
|
||||||
recursive-include tests *.dat
|
recursive-include tests *.dat
|
||||||
recursive-include tests *.h5
|
recursive-include tests *.h5
|
||||||
recursive-include tests *.h5m
|
recursive-inlcude tests *.h5m
|
||||||
recursive-include tests *.py
|
recursive-include tests *.py
|
||||||
recursive-include tests *.xml
|
recursive-include tests *.xml
|
||||||
recursive-include vendor CMakeLists.txt
|
recursive-include vendor CMakeLists.txt
|
||||||
|
|
@ -43,5 +49,6 @@ recursive-include vendor *.hh
|
||||||
recursive-include vendor *.hpp
|
recursive-include vendor *.hpp
|
||||||
recursive-include vendor *.pc.in
|
recursive-include vendor *.pc.in
|
||||||
recursive-include vendor *.natvis
|
recursive-include vendor *.natvis
|
||||||
|
include vendor/gsl-lite/include/gsl/gsl
|
||||||
prune docs/build
|
prune docs/build
|
||||||
prune docs/source/pythonapi/generated/
|
prune docs/source/pythonapi/generated/
|
||||||
|
|
|
||||||
35
README.md
|
|
@ -1,11 +1,10 @@
|
||||||
# OpenMC Monte Carlo Particle Transport Code
|
# OpenMC Monte Carlo Particle Transport Code
|
||||||
|
|
||||||
[](https://docs.openmc.org/en/latest/license.html)
|
[](http://openmc.readthedocs.io/en/latest/license.html)
|
||||||
[](https://github.com/openmc-dev/openmc/actions/workflows/ci.yml)
|
[](https://github.com/openmc-dev/openmc/actions?query=workflow%3ACI)
|
||||||
[](https://coveralls.io/github/openmc-dev/openmc?branch=develop)
|
[](https://coveralls.io/github/openmc-dev/openmc?branch=develop)
|
||||||
[](https://github.com/openmc-dev/openmc/actions?query=workflow%3Adockerhub-publish-develop-dagmc)
|
[](https://github.com/openmc-dev/openmc/actions?query=workflow%3Adockerhub-publish-develop-dagmc)
|
||||||
[](https://github.com/openmc-dev/openmc/actions?query=workflow%3Adockerhub-publish-develop)
|
[](https://github.com/openmc-dev/openmc/actions?query=workflow%3Adockerhub-publish-develop)
|
||||||
[](https://anaconda.org/conda-forge/openmc)
|
|
||||||
|
|
||||||
The OpenMC project aims to provide a fully-featured Monte Carlo particle
|
The OpenMC project aims to provide a fully-featured Monte Carlo particle
|
||||||
transport code based on modern methods. It is a constructive solid geometry,
|
transport code based on modern methods. It is a constructive solid geometry,
|
||||||
|
|
@ -13,15 +12,14 @@ continuous-energy transport code that uses HDF5 format cross sections. The
|
||||||
project started under the Computational Reactor Physics Group at MIT.
|
project started under the Computational Reactor Physics Group at MIT.
|
||||||
|
|
||||||
Complete documentation on the usage of OpenMC is hosted on Read the Docs (both
|
Complete documentation on the usage of OpenMC is hosted on Read the Docs (both
|
||||||
for the [latest release](https://docs.openmc.org/en/stable/) and
|
for the [latest release](http://openmc.readthedocs.io/en/stable/) and
|
||||||
[developmental](https://docs.openmc.org/en/latest/) version). If you are
|
[developmental](http://openmc.readthedocs.io/en/latest/) version). If you are
|
||||||
interested in the project, or would like to help and contribute, please get in
|
interested in the project, or would like to help and contribute, please get in touch on the OpenMC [discussion forum](https://openmc.discourse.group/).
|
||||||
touch on the OpenMC [discussion forum](https://openmc.discourse.group/).
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Detailed [installation
|
Detailed [installation
|
||||||
instructions](https://docs.openmc.org/en/stable/usersguide/install.html)
|
instructions](http://openmc.readthedocs.io/en/stable/usersguide/install.html)
|
||||||
can be found in the User's Guide.
|
can be found in the User's Guide.
|
||||||
|
|
||||||
## Citing
|
## Citing
|
||||||
|
|
@ -37,23 +35,22 @@ citing the following publication:
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If you run into problems compiling, installing, or running OpenMC, first check
|
If you run into problems compiling, installing, or running OpenMC, first check
|
||||||
the [Troubleshooting
|
the [Troubleshooting section](http://openmc.readthedocs.io/en/stable/usersguide/troubleshoot.html) in
|
||||||
section](https://docs.openmc.org/en/stable/usersguide/troubleshoot.html) in the
|
the User's Guide. If you are not able to find a solution to your problem there,
|
||||||
User's Guide. If you are not able to find a solution to your problem there,
|
|
||||||
please post to the [discussion forum](https://openmc.discourse.group/).
|
please post to the [discussion forum](https://openmc.discourse.group/).
|
||||||
|
|
||||||
## Reporting Bugs
|
## Reporting Bugs
|
||||||
|
|
||||||
OpenMC is hosted on GitHub and all bugs are reported and tracked through the
|
OpenMC is hosted on GitHub and all bugs are reported and tracked through the
|
||||||
[Issues](https://github.com/openmc-dev/openmc/issues) feature on GitHub.
|
[Issues](https://github.com/openmc-dev/openmc/issues) feature on GitHub. However,
|
||||||
However, GitHub Issues should not be used for common troubleshooting purposes.
|
GitHub Issues should not be used for common troubleshooting purposes. If you are
|
||||||
If you are having trouble installing the code or getting your model to run
|
having trouble installing the code or getting your model to run properly, you
|
||||||
properly, you should first send a message to the [discussion
|
should first send a message to the User's Group mailing list. If it turns out
|
||||||
forum](https://openmc.discourse.group/). If it turns out your issue really is a
|
your issue really is a bug in the code, an issue will then be created on
|
||||||
bug in the code, an issue will then be created on GitHub. If you want to request
|
GitHub. If you want to request that a feature be added to the code, you may
|
||||||
that a feature be added to the code, you may create an Issue on github.
|
create an Issue on github.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
OpenMC is distributed under the MIT/X
|
OpenMC is distributed under the MIT/X
|
||||||
[license](https://docs.openmc.org/en/stable/license.html).
|
[license](http://openmc.readthedocs.io/en/stable/license.html).
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ if(DEFINED ENV{METHOD})
|
||||||
message(STATUS "Using environment variable METHOD to determine libMesh build: ${LIBMESH_PC_FILE}")
|
message(STATUS "Using environment variable METHOD to determine libMesh build: ${LIBMESH_PC_FILE}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
include(FindPkgConfig)
|
||||||
|
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${LIBMESH_PC}")
|
||||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
|
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
|
||||||
pkg_check_modules(LIBMESH REQUIRED ${LIBMESH_PC_FILE}>=1.7.0 IMPORTED_TARGET)
|
pkg_check_modules(LIBMESH REQUIRED ${LIBMESH_PC_FILE}>=1.6.0 IMPORTED_TARGET)
|
||||||
pkg_get_variable(LIBMESH_PREFIX ${LIBMESH_PC_FILE} prefix)
|
pkg_get_variable(LIBMESH_PREFIX ${LIBMESH_PC_FILE} prefix)
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
# GetVersionFromGit.cmake
|
|
||||||
# Standalone script to retrieve versioning information from Git or .git_archival.txt.
|
|
||||||
# Customizable for any project by setting variables before including this file.
|
|
||||||
|
|
||||||
# Configurable variables:
|
|
||||||
# - VERSION_PREFIX: Prefix for version tags (default: "v").
|
|
||||||
# - VERSION_SUFFIX: Suffix for version tags (default: "[~+-]([a-zA-Z0-9]+)").
|
|
||||||
# - VERSION_REGEX: Regex to extract version (default: "(?[0-9]+\\.[0-9]+\\.[0-9]+)").
|
|
||||||
# - ARCHIVAL_FILE: Path to .git_archival.txt (default: "${CMAKE_SOURCE_DIR}/.git_archival.txt").
|
|
||||||
# - DESCRIBE_NAME_KEY: Key for describe name in .git_archival.txt (default: "describe-name: ").
|
|
||||||
# - COMMIT_HASH_KEY: Key for commit hash in .git_archival.txt (default: "commit: ").
|
|
||||||
|
|
||||||
# Default Format Example:
|
|
||||||
# 1.2.3 v1.2.3 v1.2.3-rc1
|
|
||||||
|
|
||||||
set(VERSION_PREFIX "v" CACHE STRING "Prefix used in version tags")
|
|
||||||
set(VERSION_SUFFIX "[~+-]([a-zA-Z0-9]+)" CACHE STRING "Suffix used in version tags")
|
|
||||||
set(VERSION_REGEX "?([0-9]+\\.[0-9]+\\.[0-9]+)" CACHE STRING "Regex for extracting version")
|
|
||||||
set(ARCHIVAL_FILE "${CMAKE_SOURCE_DIR}/.git_archival.txt" CACHE STRING "Path to .git_archival.txt")
|
|
||||||
set(DESCRIBE_NAME_KEY "describe-name: " CACHE STRING "Key for describe name in .git_archival.txt")
|
|
||||||
set(COMMIT_HASH_KEY "commit: " CACHE STRING "Key for commit hash in .git_archival.txt")
|
|
||||||
|
|
||||||
|
|
||||||
# Combine prefix and regex
|
|
||||||
set(VERSION_REGEX_WITH_PREFIX "^${VERSION_PREFIX}${VERSION_REGEX}")
|
|
||||||
|
|
||||||
# Find Git
|
|
||||||
find_package(Git)
|
|
||||||
|
|
||||||
# Attempt to retrieve version from Git
|
|
||||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND GIT_FOUND)
|
|
||||||
message(STATUS "Using git describe for versioning")
|
|
||||||
|
|
||||||
# Extract the version string
|
|
||||||
execute_process(
|
|
||||||
COMMAND git describe --tags --dirty
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE VERSION_STRING
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
ERROR_QUIET
|
|
||||||
)
|
|
||||||
|
|
||||||
# If no tags are found, set version to 0 and show a warning
|
|
||||||
if(VERSION_STRING STREQUAL "")
|
|
||||||
set(VERSION_STRING "0.0.0")
|
|
||||||
message(WARNING
|
|
||||||
"No git tags found. Version set to 0.0.0.\n"
|
|
||||||
"Run 'git fetch --tags' to ensure proper versioning.\n"
|
|
||||||
"For more information, see OpenMC developer documentation."
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Extract the commit hash
|
|
||||||
execute_process(
|
|
||||||
COMMAND git rev-parse HEAD
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
OUTPUT_VARIABLE COMMIT_HASH
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
message(STATUS "Using archival file for versioning: ${ARCHIVAL_FILE}")
|
|
||||||
if(EXISTS "${ARCHIVAL_FILE}")
|
|
||||||
file(READ "${ARCHIVAL_FILE}" ARCHIVAL_CONTENT)
|
|
||||||
|
|
||||||
# Extract the describe-name line
|
|
||||||
string(REGEX MATCH "${DESCRIBE_NAME_KEY}([^\\n]+)" VERSION_STRING "${ARCHIVAL_CONTENT}")
|
|
||||||
if(VERSION_STRING MATCHES "${DESCRIBE_NAME_KEY}(.*)")
|
|
||||||
set(VERSION_STRING "${CMAKE_MATCH_1}")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Could not extract version from ${ARCHIVAL_FILE}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Extract the commit hash
|
|
||||||
string(REGEX MATCH "${COMMIT_HASH_KEY}([a-f0-9]+)" COMMIT_HASH "${ARCHIVAL_CONTENT}")
|
|
||||||
if(COMMIT_HASH MATCHES "${COMMIT_HASH_KEY}([a-f0-9]+)")
|
|
||||||
set(COMMIT_HASH "${CMAKE_MATCH_1}")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Could not extract commit hash from ${ARCHIVAL_FILE}")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Neither git describe nor ${ARCHIVAL_FILE} is available for versioning.")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Ensure version string format
|
|
||||||
if(VERSION_STRING MATCHES "${VERSION_REGEX_WITH_PREFIX}")
|
|
||||||
set(VERSION_NO_SUFFIX "${CMAKE_MATCH_1}")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Invalid version format: Missing base version in ${VERSION_STRING}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check for development state
|
|
||||||
if(VERSION_STRING MATCHES "-([0-9]+)-g([0-9a-f]+)")
|
|
||||||
set(DEV_STATE "true")
|
|
||||||
set(COMMIT_COUNT "${CMAKE_MATCH_1}")
|
|
||||||
string(REGEX REPLACE "-([0-9]+)-g([0-9a-f]+)" "" VERSION_WITHOUT_META "${VERSION_STRING}")
|
|
||||||
else()
|
|
||||||
set(DEV_STATE "false")
|
|
||||||
set(VERSION_WITHOUT_META "${VERSION_STRING}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Split and set version components
|
|
||||||
string(REPLACE "." ";" VERSION_LIST "${VERSION_NO_SUFFIX}")
|
|
||||||
list(GET VERSION_LIST 0 VERSION_MAJOR)
|
|
||||||
list(GET VERSION_LIST 1 VERSION_MINOR)
|
|
||||||
list(GET VERSION_LIST 2 VERSION_PATCH)
|
|
||||||
|
|
||||||
# Increment patch number for dev versions
|
|
||||||
if(DEV_STATE)
|
|
||||||
math(EXPR VERSION_PATCH "${VERSION_PATCH} + 1")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Export variables
|
|
||||||
set(OPENMC_VERSION_MAJOR "${VERSION_MAJOR}")
|
|
||||||
set(OPENMC_VERSION_MINOR "${VERSION_MINOR}")
|
|
||||||
set(OPENMC_VERSION_PATCH "${VERSION_PATCH}")
|
|
||||||
set(OPENMC_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
|
||||||
set(OPENMC_COMMIT_HASH "${COMMIT_HASH}")
|
|
||||||
set(OPENMC_DEV_STATE "${DEV_STATE}")
|
|
||||||
set(OPENMC_COMMIT_COUNT "${COMMIT_COUNT}")
|
|
||||||
|
|
@ -1,45 +1,21 @@
|
||||||
@PACKAGE_INIT@
|
get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/OpenMCConfigVersion.cmake")
|
find_package(fmt REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../fmt)
|
||||||
include(CMakeFindDependencyMacro)
|
find_package(gsl-lite REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../gsl-lite)
|
||||||
|
find_package(pugixml REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../pugixml)
|
||||||
# Explicitly calculate prefix if it was not generated above
|
find_package(xtl REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtl)
|
||||||
if(NOT DEFINED PACKAGE_PREFIX_DIR)
|
find_package(xtensor REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtensor)
|
||||||
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
|
if(@DAGMC_FOUND@)
|
||||||
|
find_package(DAGMC REQUIRED HINTS @DAGMC_DIR@)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_dependency(fmt CONFIG REQUIRED HINTS ${PACKAGE_PREFIX_DIR})
|
if(@LIBMESH_FOUND@)
|
||||||
find_dependency(pugixml CONFIG REQUIRED HINTS ${PACKAGE_PREFIX_DIR})
|
|
||||||
|
|
||||||
if(@OPENMC_USE_DAGMC@)
|
|
||||||
find_dependency(DAGMC REQUIRED HINTS @DAGMC_DIR@)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(@OPENMC_USE_LIBMESH@)
|
|
||||||
include(FindPkgConfig)
|
include(FindPkgConfig)
|
||||||
list(APPEND CMAKE_PREFIX_PATH @LIBMESH_PREFIX@)
|
list(APPEND CMAKE_PREFIX_PATH @LIBMESH_PREFIX@)
|
||||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
|
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH True)
|
||||||
pkg_check_modules(LIBMESH REQUIRED @LIBMESH_PC_FILE@>=1.7.0 IMPORTED_TARGET)
|
pkg_check_modules(LIBMESH REQUIRED @LIBMESH_PC_FILE@>=1.6.0 IMPORTED_TARGET)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("@PNG_FOUND@")
|
if(NOT TARGET OpenMC::libopenmc)
|
||||||
find_dependency(PNG)
|
include("${OpenMC_CMAKE_DIR}/OpenMCTargets.cmake")
|
||||||
endif()
|
|
||||||
|
|
||||||
if(@OPENMC_USE_MPI@)
|
|
||||||
find_dependency(MPI REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(@OPENMC_USE_OPENMP@)
|
|
||||||
find_dependency(OpenMP REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(@OPENMC_USE_UWUW@ AND NOT ${DAGMC_BUILD_UWUW})
|
|
||||||
message(FATAL_ERROR "UWUW is enabled in OpenMC but the DAGMC installation discovered was not configured with UWUW.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/OpenMCTargets.cmake")
|
|
||||||
|
|
||||||
if(NOT OpenMC_FIND_QUIETLY)
|
|
||||||
message(STATUS "Found OpenMC: ${PACKAGE_VERSION} (found in ${PACKAGE_PREFIX_DIR})")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
11
cmake/OpenMCConfigVersion.cmake.in
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
set(PACKAGE_VERSION "@OPENMC_VERSION@")
|
||||||
|
|
||||||
|
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||||
|
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
else()
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||||
|
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||||
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
@ -45,7 +45,6 @@ help:
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(BUILDDIR)/*
|
-rm -rf $(BUILDDIR)/*
|
||||||
-rm -rf source/pythonapi/generated/
|
-rm -rf source/pythonapi/generated/
|
||||||
-rm -rf doxygen/xml
|
|
||||||
|
|
||||||
html:
|
html:
|
||||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
# Doxyfile 1.9.1
|
|
||||||
|
|
||||||
# This file describes the settings to be used by the documentation system
|
|
||||||
# doxygen (www.doxygen.org) for a project.
|
|
||||||
|
|
||||||
# Difference with default Doxyfile 1.9.1
|
|
||||||
PROJECT_NAME = OpenMC
|
|
||||||
QUIET = YES
|
|
||||||
WARN_IF_UNDOCUMENTED = NO
|
|
||||||
INPUT = ../../include/openmc/capi.h
|
|
||||||
GENERATE_HTML = NO
|
|
||||||
GENERATE_LATEX = NO
|
|
||||||
GENERATE_XML = YES
|
|
||||||
11
docs/requirements-rtd.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
sphinx-numfig
|
||||||
|
jupyter
|
||||||
|
sphinxcontrib-katex
|
||||||
|
sphinxcontrib-svg2pdfconverter
|
||||||
|
nbsphinx
|
||||||
|
numpy
|
||||||
|
scipy
|
||||||
|
h5py
|
||||||
|
pandas
|
||||||
|
uncertainties
|
||||||
|
matplotlib
|
||||||
|
Before Width: | Height: | Size: 265 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 167 KiB |
BIN
docs/source/_images/plotmeshtally.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 72 KiB |
|
|
@ -46,29 +46,41 @@ Type Definitions
|
||||||
Functions
|
Functions
|
||||||
---------
|
---------
|
||||||
|
|
||||||
..
|
.. c:function:: int openmc_calculate_volumes()
|
||||||
Once documentation is complete in capi.h, use:
|
|
||||||
.. doxygenfile:: capi.h
|
|
||||||
to populate this documentation without using
|
|
||||||
.. doxygenfunction::
|
|
||||||
for every function.
|
|
||||||
|
|
||||||
.. doxygenfunction:: openmc_calculate_volumes
|
Run a stochastic volume calculation
|
||||||
|
|
||||||
.. doxygenfunction:: openmc_cell_get_fill
|
:return: Return status (negative if an error occurred)
|
||||||
|
:rtype: int
|
||||||
|
|
||||||
.. doxygenfunction:: openmc_cell_get_id
|
.. c:function:: int openmc_cell_get_fill(int32_t index, int* type, int32_t** indices, int32_t* n)
|
||||||
|
|
||||||
.. doxygenfunction:: openmc_cell_get_temperature
|
Get the fill for a cell
|
||||||
|
|
||||||
.. c:function:: int openmc_cell_get_density(int32_t index, const int32_t* instance, double* density)
|
|
||||||
|
|
||||||
Get the density of a cell
|
|
||||||
|
|
||||||
:param int32_t index: Index in the cells array
|
:param int32_t index: Index in the cells array
|
||||||
:param int32_t* instance: Which instance of the cell. If a null pointer is passed, the density
|
:param int* type: Type of the fill
|
||||||
multiplier of the first instance is returned.
|
:param int32_t** indices: Array of material indices for cell
|
||||||
:param double* density: Density of the cell in [g/cm3]
|
:param int32_t* n: Length of indices array
|
||||||
|
:return: Return status (negative if an error occurred)
|
||||||
|
:rtype: int
|
||||||
|
|
||||||
|
.. c:function:: int openmc_cell_get_id(int32_t index, int32_t* id)
|
||||||
|
|
||||||
|
Get the ID of a cell
|
||||||
|
|
||||||
|
:param int32_t index: Index in the cells array
|
||||||
|
:param int32_t* id: ID of the cell
|
||||||
|
:return: Return status (negative if an error occurred)
|
||||||
|
:rtype: int
|
||||||
|
|
||||||
|
.. c:function:: int openmc_cell_get_temperature(int32_t index, const int32_t* instance, double* T)
|
||||||
|
|
||||||
|
Get the temperature of a cell
|
||||||
|
|
||||||
|
:param int32_t index: Index in the cells array
|
||||||
|
:param int32_t* instance: Which instance of the cell. If a null pointer is passed, the temperature
|
||||||
|
of the first instance is returned.
|
||||||
|
:param double* T: temperature of the cell
|
||||||
:return: Return status (negative if an error occurred)
|
:return: Return status (negative if an error occurred)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
|
|
@ -101,22 +113,8 @@ Functions
|
||||||
:param double T: Temperature in Kelvin
|
:param double T: Temperature in Kelvin
|
||||||
:param instance: Which instance of the cell. To set the temperature for all
|
:param instance: Which instance of the cell. To set the temperature for all
|
||||||
instances, pass a null pointer.
|
instances, pass a null pointer.
|
||||||
:param bool set_contained: If the cell is not filled by a material, whether
|
:param set_contained: If the cell is not filled by a material, whether to set the temperatures
|
||||||
to set the temperatures of all filled cells
|
of all filled cells
|
||||||
:type instance: const int32_t*
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_cell_set_density(index index, double density, const int32_t* instance, bool set_contained)
|
|
||||||
|
|
||||||
Set the density of a cell.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the cells array
|
|
||||||
:param double density: Density of the cell in [g/cm3]
|
|
||||||
:param instance: Which instance of the cell. To set the density multiplier for all
|
|
||||||
instances, pass a null pointer.
|
|
||||||
:param bool set_contained: If the cell is not filled by a material, whether
|
|
||||||
to set the density multiplier of all filled cells
|
|
||||||
:type instance: const int32_t*
|
:type instance: const int32_t*
|
||||||
:return: Return status (negative if an error occurred)
|
:return: Return status (negative if an error occurred)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
@ -357,7 +355,7 @@ Functions
|
||||||
Get density of a material.
|
Get density of a material.
|
||||||
|
|
||||||
:param int32_t index: Index in the materials array
|
:param int32_t index: Index in the materials array
|
||||||
:param double* density: Pointer to a density
|
:param double* denity: Pointer to a density
|
||||||
:return: Return status (negative if an error occurs)
|
:return: Return status (negative if an error occurs)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
|
|
@ -422,16 +420,6 @@ Functions
|
||||||
:return: Return status (negative if an error occurred)
|
:return: Return status (negative if an error occurred)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
.. c:function:: int openmc_mesh_filter_get_mesh(int32_t index, int32_t* index_mesh)
|
|
||||||
|
|
||||||
Get the mesh for a mesh filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param index_mesh: Index in the meshes array
|
|
||||||
:type index_mesh: int32_t*
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_mesh_filter_set_mesh(int32_t index, int32_t index_mesh)
|
.. c:function:: int openmc_mesh_filter_set_mesh(int32_t index, int32_t index_mesh)
|
||||||
|
|
||||||
Set the mesh for a mesh filter
|
Set the mesh for a mesh filter
|
||||||
|
|
@ -441,98 +429,6 @@ Functions
|
||||||
:return: Return status (negative if an error occurred)
|
:return: Return status (negative if an error occurred)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
.. c:function:: int openmc_mesh_filter_get_translation(int32_t index, double translation[3])
|
|
||||||
|
|
||||||
Get the 3-D translation coordinates for a mesh filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param double[3] translation: 3-D translation coordinates
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_mesh_filter_set_translation(int32_t index, double translation[3])
|
|
||||||
|
|
||||||
Set the 3-D translation coordinates for a mesh filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param double[3] translation: 3-D translation coordinates
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshborn_filter_get_mesh(int32_t index, int32_t* index_mesh)
|
|
||||||
|
|
||||||
Get the mesh for a meshborn filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param index_mesh: Index in the meshes array
|
|
||||||
:type index_mesh: int32_t*
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshborn_filter_set_mesh(int32_t index, int32_t index_mesh)
|
|
||||||
|
|
||||||
Set the mesh for a meshborn filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param int32_t index_mesh: Index in the meshes array
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshborn_filter_get_translation(int32_t index, double translation[3])
|
|
||||||
|
|
||||||
Get the 3-D translation coordinates for a meshborn filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param double[3] translation: 3-D translation coordinates
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshborn_filter_set_translation(int32_t index, double translation[3])
|
|
||||||
|
|
||||||
Set the 3-D translation coordinates for a meshborn filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param double[3] translation: 3-D translation coordinates
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshsurface_filter_get_mesh(int32_t index, int32_t* index_mesh)
|
|
||||||
|
|
||||||
Get the mesh for a mesh surface filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param index_mesh: Index in the meshes array
|
|
||||||
:type index_mesh: int32_t*
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshsurface_filter_set_mesh(int32_t index, int32_t index_mesh)
|
|
||||||
|
|
||||||
Set the mesh for a mesh surface filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param int32_t index_mesh: Index in the meshes array
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshsurface_filter_get_translation(int32_t index, double translation[3])
|
|
||||||
|
|
||||||
Get the 3-D translation coordinates for a mesh surface filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param double[3] translation: 3-D translation coordinates
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_meshsurface_filter_set_translation(int32_t index, double translation[3])
|
|
||||||
|
|
||||||
Set the 3-D translation coordinates for a mesh surface filter
|
|
||||||
|
|
||||||
:param int32_t index: Index in the filters array
|
|
||||||
:param double[3] translation: 3-D translation coordinates
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_next_batch()
|
.. c:function:: int openmc_next_batch()
|
||||||
|
|
||||||
Simulate next batch of particles. Must be called after openmc_simulation_init().
|
Simulate next batch of particles. Must be called after openmc_simulation_init().
|
||||||
|
|
@ -557,279 +453,6 @@ Functions
|
||||||
:return: Return status (negative if an error occurs)
|
:return: Return status (negative if an error occurs)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
.. c:function:: int openmc_get_plot_index(int32_t id, int32_t* index)
|
|
||||||
|
|
||||||
Get the index in the plots array for a plot with a given ID.
|
|
||||||
|
|
||||||
:param int32_t id: Plot ID
|
|
||||||
:param int32_t* index: Index in the plots array
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_plot_get_id(int32_t index, int32_t* id)
|
|
||||||
|
|
||||||
Get the ID of a plot.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t* id: Plot ID
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_plot_set_id(int32_t index, int32_t id)
|
|
||||||
|
|
||||||
Set the ID of a plot.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t id: Plot ID
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: size_t openmc_plots_size()
|
|
||||||
|
|
||||||
Number of plots currently allocated.
|
|
||||||
|
|
||||||
:return: Number of plots in the plots array
|
|
||||||
:rtype: size_t
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_create(int32_t* index)
|
|
||||||
|
|
||||||
Create a new solid raytrace plot.
|
|
||||||
|
|
||||||
:param int32_t* index: Index of the newly created plot
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_pixels(int32_t index, int32_t* width, int32_t* height)
|
|
||||||
|
|
||||||
Get output pixel dimensions for a solid raytrace plot.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t* width: Image width in pixels
|
|
||||||
:param int32_t* height: Image height in pixels
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_pixels(int32_t index, int32_t width, int32_t height)
|
|
||||||
|
|
||||||
Set output pixel dimensions for a solid raytrace plot.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t width: Image width in pixels
|
|
||||||
:param int32_t height: Image height in pixels
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_color_by(int32_t index, int32_t* color_by)
|
|
||||||
|
|
||||||
Get the domain type used for coloring (0=materials, 1=cells).
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t* color_by: Coloring mode
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_color_by(int32_t index, int32_t color_by)
|
|
||||||
|
|
||||||
Set the domain type used for coloring (0=materials, 1=cells).
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t color_by: Coloring mode
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_default_colors(int32_t index)
|
|
||||||
|
|
||||||
Set default random colors for the current ``color_by`` mode.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_all_opaque(int32_t index)
|
|
||||||
|
|
||||||
Mark all domains in the current ``color_by`` mode as opaque.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_opaque(int32_t index, int32_t id, bool visible)
|
|
||||||
|
|
||||||
Set whether a specific domain ID is opaque (visible) in the rendered image.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t id: Cell/material ID (based on ``color_by``)
|
|
||||||
:param bool visible: Whether the domain is opaque
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_color(int32_t index, int32_t id, uint8_t r, uint8_t g, uint8_t b)
|
|
||||||
|
|
||||||
Set RGB color for a specific domain ID.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t id: Cell/material ID (based on ``color_by``)
|
|
||||||
:param uint8_t r: Red channel
|
|
||||||
:param uint8_t g: Green channel
|
|
||||||
:param uint8_t b: Blue channel
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_color(int32_t index, int32_t id, uint8_t* r, uint8_t* g, uint8_t* b)
|
|
||||||
|
|
||||||
Get RGB color for a specific domain ID.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param int32_t id: Cell/material ID (based on ``color_by``)
|
|
||||||
:param uint8_t* r: Red channel
|
|
||||||
:param uint8_t* g: Green channel
|
|
||||||
:param uint8_t* b: Blue channel
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_camera_position(int32_t index, double* x, double* y, double* z)
|
|
||||||
|
|
||||||
Get camera position.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double* x: X coordinate
|
|
||||||
:param double* y: Y coordinate
|
|
||||||
:param double* z: Z coordinate
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_camera_position(int32_t index, double x, double y, double z)
|
|
||||||
|
|
||||||
Set camera position.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double x: X coordinate
|
|
||||||
:param double y: Y coordinate
|
|
||||||
:param double z: Z coordinate
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_look_at(int32_t index, double* x, double* y, double* z)
|
|
||||||
|
|
||||||
Get camera target point.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double* x: X coordinate
|
|
||||||
:param double* y: Y coordinate
|
|
||||||
:param double* z: Z coordinate
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_look_at(int32_t index, double x, double y, double z)
|
|
||||||
|
|
||||||
Set camera target point.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double x: X coordinate
|
|
||||||
:param double y: Y coordinate
|
|
||||||
:param double z: Z coordinate
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_up(int32_t index, double* x, double* y, double* z)
|
|
||||||
|
|
||||||
Get the camera up vector.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double* x: X component
|
|
||||||
:param double* y: Y component
|
|
||||||
:param double* z: Z component
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_up(int32_t index, double x, double y, double z)
|
|
||||||
|
|
||||||
Set the camera up vector.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double x: X component
|
|
||||||
:param double y: Y component
|
|
||||||
:param double z: Z component
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_light_position(int32_t index, double* x, double* y, double* z)
|
|
||||||
|
|
||||||
Get light source position.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double* x: X coordinate
|
|
||||||
:param double* y: Y coordinate
|
|
||||||
:param double* z: Z coordinate
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_light_position(int32_t index, double x, double y, double z)
|
|
||||||
|
|
||||||
Set light source position.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double x: X coordinate
|
|
||||||
:param double y: Y coordinate
|
|
||||||
:param double z: Z coordinate
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_fov(int32_t index, double* fov)
|
|
||||||
|
|
||||||
Get horizontal field of view in degrees.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double* fov: Field of view in degrees
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_fov(int32_t index, double fov)
|
|
||||||
|
|
||||||
Set horizontal field of view in degrees.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double fov: Field of view in degrees
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_get_diffuse_fraction(int32_t index, double* diffuse_fraction)
|
|
||||||
|
|
||||||
Get diffuse-light fraction.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double* diffuse_fraction: Diffuse fraction in [0, 1]
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_set_diffuse_fraction(int32_t index, double diffuse_fraction)
|
|
||||||
|
|
||||||
Set diffuse-light fraction.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param double diffuse_fraction: Diffuse fraction in [0, 1]
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_update_view(int32_t index)
|
|
||||||
|
|
||||||
Recompute internal camera/view transforms after camera changes.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_solidraytrace_plot_create_image(int32_t index, uint8_t* data_out, int32_t width, int32_t height)
|
|
||||||
|
|
||||||
Render the plot to an RGB image buffer.
|
|
||||||
|
|
||||||
:param int32_t index: Index in the plots array
|
|
||||||
:param uint8_t* data_out: Output buffer of shape ``height*width*3``
|
|
||||||
:param int32_t width: Image width in pixels
|
|
||||||
:param int32_t height: Image height in pixels
|
|
||||||
:return: Return status (negative if an error occurred)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_reset()
|
.. c:function:: int openmc_reset()
|
||||||
|
|
||||||
Resets all tally scores
|
Resets all tally scores
|
||||||
|
|
@ -837,13 +460,6 @@ Functions
|
||||||
:return: Return status (negative if an error occurs)
|
:return: Return status (negative if an error occurs)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
.. c:function:: int openmc_remove_tally(int32_t index);
|
|
||||||
|
|
||||||
Given an index of a tally, remove it from the tallies array
|
|
||||||
:param int index: Index in tallies array
|
|
||||||
:return: Return status (negative if an error occurs)
|
|
||||||
:rtype: int
|
|
||||||
|
|
||||||
.. c:function:: int openmc_run()
|
.. c:function:: int openmc_run()
|
||||||
|
|
||||||
Run a simulation
|
Run a simulation
|
||||||
|
|
@ -851,10 +467,6 @@ Functions
|
||||||
:return: Return status (negative if an error occurs)
|
:return: Return status (negative if an error occurs)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
.. c:function:: void openmc_run_random_ray()
|
|
||||||
|
|
||||||
Run a random ray simulation
|
|
||||||
|
|
||||||
.. c:function:: int openmc_set_n_batches(int32_t n_batches, bool set_max_batches, bool add_statepoint_batch)
|
.. c:function:: int openmc_set_n_batches(int32_t n_batches, bool set_max_batches, bool add_statepoint_batch)
|
||||||
|
|
||||||
Set number of batches and number of max batches
|
Set number of batches and number of max batches
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,7 @@
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import os
|
import sys, os
|
||||||
from pathlib import Path
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# Determine if we're on Read the Docs server
|
# Determine if we're on Read the Docs server
|
||||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||||
|
|
@ -40,7 +37,6 @@ sys.path.insert(0, os.path.abspath('../..'))
|
||||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
'breathe',
|
|
||||||
'sphinx.ext.autodoc',
|
'sphinx.ext.autodoc',
|
||||||
'sphinx.ext.napoleon',
|
'sphinx.ext.napoleon',
|
||||||
'sphinx.ext.autosummary',
|
'sphinx.ext.autosummary',
|
||||||
|
|
@ -48,17 +44,16 @@ extensions = [
|
||||||
'sphinx.ext.viewcode',
|
'sphinx.ext.viewcode',
|
||||||
'sphinxcontrib.katex',
|
'sphinxcontrib.katex',
|
||||||
'sphinx_numfig',
|
'sphinx_numfig',
|
||||||
|
'nbsphinx'
|
||||||
]
|
]
|
||||||
if not on_rtd:
|
if not on_rtd:
|
||||||
extensions.append('sphinxcontrib.rsvgconverter')
|
extensions.append('sphinxcontrib.rsvgconverter')
|
||||||
doxygen_dir = Path(__file__).parents[1] / 'doxygen'
|
|
||||||
subprocess.run(['doxygen'], cwd=doxygen_dir, check=True)
|
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
|
||||||
# The suffix of source filenames.
|
# The suffix of source filenames.
|
||||||
source_suffix = {'.rst': 'restructuredtext'}
|
source_suffix = '.rst'
|
||||||
|
|
||||||
# The encoding of source files.
|
# The encoding of source files.
|
||||||
#source_encoding = 'utf-8'
|
#source_encoding = 'utf-8'
|
||||||
|
|
@ -68,17 +63,16 @@ master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = 'OpenMC'
|
project = 'OpenMC'
|
||||||
copyright = '2011-2026, Massachusetts Institute of Technology, UChicago Argonne LLC, and OpenMC contributors'
|
copyright = '2011-2021, Massachusetts Institute of Technology and OpenMC contributors'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
|
# The short X.Y version.
|
||||||
import openmc
|
version = "0.12"
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
version = release = openmc.__version__
|
release = "0.12.2"
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
@ -123,17 +117,14 @@ pygments_style = 'tango'
|
||||||
# A list of ignored prefixes for module index sorting.
|
# A list of ignored prefixes for module index sorting.
|
||||||
#modindex_common_prefix = []
|
#modindex_common_prefix = []
|
||||||
|
|
||||||
# -- Options breathe + doxygen -------------------------------------------------
|
|
||||||
|
|
||||||
breathe_projects = {"OpenMC": "../doxygen/xml"}
|
|
||||||
breathe_default_project = "OpenMC"
|
|
||||||
breathe_domain_by_file_pattern = {"*capi.h": "c"}
|
|
||||||
|
|
||||||
# -- Options for HTML output ---------------------------------------------------
|
# -- Options for HTML output ---------------------------------------------------
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages
|
# The theme to use for HTML and HTML Help pages
|
||||||
html_theme = 'sphinx_rtd_theme'
|
if not on_rtd:
|
||||||
html_baseurl = "https://docs.openmc.org/en/stable/"
|
import sphinx_rtd_theme
|
||||||
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||||
|
|
||||||
html_logo = '_images/openmc_logo.png'
|
html_logo = '_images/openmc_logo.png'
|
||||||
|
|
||||||
|
|
@ -147,7 +138,7 @@ html_title = "OpenMC Documentation"
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
html_favicon = 'favicon.ico'
|
#html_favicon = None
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
|
@ -225,7 +216,6 @@ latex_elements = {
|
||||||
\setcounter{tocdepth}{2}
|
\setcounter{tocdepth}{2}
|
||||||
\numberwithin{equation}{section}
|
\numberwithin{equation}{section}
|
||||||
\DeclareUnicodeCharacter{03B1}{$\alpha$}
|
\DeclareUnicodeCharacter{03B1}{$\alpha$}
|
||||||
\DeclareUnicodeCharacter{03C0}{$\pi$}
|
|
||||||
""",
|
""",
|
||||||
'printindex': r""
|
'printindex': r""
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +247,7 @@ napoleon_use_ivar = True
|
||||||
intersphinx_mapping = {
|
intersphinx_mapping = {
|
||||||
'python': ('https://docs.python.org/3', None),
|
'python': ('https://docs.python.org/3', None),
|
||||||
'numpy': ('https://numpy.org/doc/stable/', None),
|
'numpy': ('https://numpy.org/doc/stable/', None),
|
||||||
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
|
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
|
||||||
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
|
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
|
||||||
'matplotlib': ('https://matplotlib.org/stable/', None)
|
'matplotlib': ('https://matplotlib.org/', None)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
.. _devguide_agentic_tools:
|
|
||||||
|
|
||||||
===========================
|
|
||||||
Agentic Development Tools
|
|
||||||
===========================
|
|
||||||
|
|
||||||
OpenMC ships a set of tools designed for AI coding agents (such as
|
|
||||||
`Claude Code`_) that agents can use to navigate and understand the codebase.
|
|
||||||
|
|
||||||
.. _Claude Code: https://claude.ai/code
|
|
||||||
|
|
||||||
Motivation
|
|
||||||
----------
|
|
||||||
|
|
||||||
Agentic tools like Claude Code are skilled at using grep to navigate and
|
|
||||||
understand large code bases. However, grep can only find exact text matches —
|
|
||||||
it cannot discover code that is *conceptually* related but uses different
|
|
||||||
naming. Without a "global view" of the codebase that a human developer will
|
|
||||||
build up over time, the agent is generally blind to any file it hasn't
|
|
||||||
tokenized fully. While it can grep to see who else calls a function, it
|
|
||||||
remains blind if other areas might be related but not share identical naming
|
|
||||||
conventions.
|
|
||||||
|
|
||||||
This problem is mitigated somewhat by using a model with a longer context
|
|
||||||
window. OpenMC has somewhere around ~1 million tokens of C++ and ~1 million
|
|
||||||
tokens of python. While Claude Code in early 2026 only has a context window
|
|
||||||
of 200k tokens, beta versions have extended context windows of 1M tokens,
|
|
||||||
and it's not unreasonable to assume that models may be available in the near
|
|
||||||
future that greatly exceed these limits.
|
|
||||||
|
|
||||||
However, even assuming the entire repository can be fit within a context
|
|
||||||
window, there are several downsides to doing this.
|
|
||||||
`Model performance degrades significantly as context size increases`_.
|
|
||||||
Benchmark results are
|
|
||||||
greatly improved if the model has less garbage to pick through. Additionally, API usage
|
|
||||||
is typically billed as tokens in/out per turn. As the context file
|
|
||||||
grows these costs become much larger. As such, there is still significant
|
|
||||||
motivation to solving the above problem, so as to ensure only relevant
|
|
||||||
information is drawn into context so as to maximize model performance and
|
|
||||||
minimize costs.
|
|
||||||
|
|
||||||
Setup
|
|
||||||
-----
|
|
||||||
|
|
||||||
The tools are registered as an `MCP (Model Context Protocol)`_ server in
|
|
||||||
``.mcp.json`` at the repository root. AI agents that support MCP (such as
|
|
||||||
Claude Code) discover them automatically on session start. The underlying
|
|
||||||
Python scripts can also be run directly from the command line.
|
|
||||||
|
|
||||||
All tools run entirely locally — no API keys or external service accounts are
|
|
||||||
required. Python dependencies are installed automatically into an isolated
|
|
||||||
virtual environment at ``.claude/cache/.venv/`` on first use.
|
|
||||||
|
|
||||||
.. _Model performance degrades significantly as context size increases: https://www.anthropic.com/news/claude-opus-4-6
|
|
||||||
.. _MCP (Model Context Protocol): https://modelcontextprotocol.io
|
|
||||||
|
|
||||||
RAG Semantic Search
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
The RAG (Retrieval-Augmented Generation) semantic search addresses this
|
|
||||||
problem — it finds code by meaning, not just text match, surfacing related code
|
|
||||||
across subsystems that ``grep`` would miss entirely. Two MCP tools are provided:
|
|
||||||
|
|
||||||
- **openmc_rag_search** — Given a natural-language query, returns the most
|
|
||||||
relevant code chunks with file paths, line numbers, and a preview. Can search
|
|
||||||
code, documentation, or both. Can also find code related to a given file.
|
|
||||||
- **openmc_rag_rebuild** — Rebuilds the search index. Should be called after
|
|
||||||
pulling new code or switching branches.
|
|
||||||
|
|
||||||
How it works
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
The search pipeline runs entirely on your local CPU:
|
|
||||||
|
|
||||||
1. **Chunking.** All C++, Python, and RST files are split into overlapping
|
|
||||||
fixed-size windows (~1000 characters, 25% overlap). This ensures every line
|
|
||||||
of code appears in at least one chunk and most lines appear in two.
|
|
||||||
|
|
||||||
2. **Embedding.** Each chunk is embedded into a 384-dimensional vector using
|
|
||||||
the `all-MiniLM-L6-v2`_ sentence-transformer model (22 million parameters).
|
|
||||||
This model runs on CPU with no GPU required. No API key is needed — the
|
|
||||||
model weights are downloaded once from Hugging Face and cached locally.
|
|
||||||
|
|
||||||
3. **Indexing.** The vectors are stored in a local LanceDB_ database on disk.
|
|
||||||
Building the full index takes approximately 5 minutes on a machine with
|
|
||||||
10 CPU cores. The index is stored in ``.claude/cache/rag_index/`` and
|
|
||||||
persists across sessions.
|
|
||||||
|
|
||||||
4. **Searching.** Your query is embedded using the same model, and the closest
|
|
||||||
chunks are retrieved by vector similarity. Results include the file path,
|
|
||||||
line range, file type, similarity distance, and a text preview.
|
|
||||||
|
|
||||||
.. _all-MiniLM-L6-v2: https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
|
|
||||||
.. _LanceDB: https://lancedb.com
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
No system dependencies beyond **Python 3.12+** with ``pip``. An internet
|
|
||||||
connection is required on first use to download the Python packages and
|
|
||||||
embedding model weights; subsequent runs are fully offline. The Python packages
|
|
||||||
(``sentence-transformers``, ``lancedb``) and their dependencies (including
|
|
||||||
PyTorch, ~2GB) are installed automatically into an isolated virtual environment
|
|
||||||
on first use.
|
|
||||||
|
|
@ -109,10 +109,9 @@ Leadership Team
|
||||||
The TC consists of the following individuals:
|
The TC consists of the following individuals:
|
||||||
|
|
||||||
- `Paul Romano <https://github.com/paulromano>`_
|
- `Paul Romano <https://github.com/paulromano>`_
|
||||||
- `Patrick Shriwise <https://github.com/pshriwise>`_
|
- `Sterling Harper <https://github.com/smharper>`_
|
||||||
- `Adam Nelson <https://github.com/nelsonag>`_
|
- `Adam Nelson <https://github.com/nelsonag>`_
|
||||||
- `Jonathan Shimwell <https://github.com/shimwell>`_
|
- `Benoit Forget <https://github.com/bforget>`_
|
||||||
- `John Tramm <https://github.com/jtramm>`_
|
|
||||||
|
|
||||||
The Project Lead is Paul Romano.
|
The Project Lead is Paul Romano.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,21 @@ Building Sphinx Documentation
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
In order to build the documentation in the ``docs`` directory, you will need to
|
In order to build the documentation in the ``docs`` directory, you will need to
|
||||||
have the several third-party Python packages installed, including `Sphinx
|
have the `Sphinx <https://www.sphinx-doc.org/en/master/>`_ third-party Python
|
||||||
<https://www.sphinx-doc.org/en/master/>`_. To install the necessary
|
package. The easiest way to install Sphinx is via pip:
|
||||||
prerequisites, provide the optional "docs" dependencies when installing OpenMC's
|
|
||||||
Python API. That is, from the root directory of the OpenMC repository:
|
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
python -m pip install ".[docs]"
|
pip install sphinx
|
||||||
|
|
||||||
The OpenMC documentation also uses Doxygen to automatically generate its
|
Additionally, you will need several Sphinx extensions that can be installed
|
||||||
C/C++ API documentation directly from the docstrings available in the source
|
directly with pip:
|
||||||
code. You will need to have a working installation of Doxygen to generate the
|
|
||||||
documentation locally.
|
.. code-block:: sh
|
||||||
|
|
||||||
|
pip install sphinx-numfig
|
||||||
|
pip install sphinxcontrib-katex
|
||||||
|
pip install sphinxcontrib-svg2pdfconverter
|
||||||
|
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
Building Documentation as a Webpage
|
Building Documentation as a Webpage
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,12 @@ Now you can run the following to create a `Docker container`_ called
|
||||||
This command will open an interactive shell running from within the
|
This command will open an interactive shell running from within the
|
||||||
Docker container where you have access to use OpenMC.
|
Docker container where you have access to use OpenMC.
|
||||||
|
|
||||||
.. note:: The ``docker run`` command supports many options_
|
.. note:: The ``docker run`` command supports many
|
||||||
|
`options <https://docs.docker.com/engine/reference/commandline/run/>`_
|
||||||
for spawning containers -- including `mounting volumes`_ from the
|
for spawning containers -- including `mounting volumes`_ from the
|
||||||
host filesystem -- which many users will find useful.
|
host filesystem -- which many users will find useful.
|
||||||
|
|
||||||
.. _Docker image: https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-an-image/
|
.. _Docker image: https://docs.docker.com/engine/reference/commandline/images/
|
||||||
.. _Docker container: https://www.docker.com/resources/what-container
|
.. _Docker container: https://www.docker.com/resources/what-container
|
||||||
.. _options: https://docs.docker.com/reference/cli/docker/container/run/
|
.. _options: https://docs.docker.com/engine/reference/commandline/run/
|
||||||
.. _mounting volumes: https://docs.docker.com/engine/storage/volumes/
|
.. _mounting volumes: https://docs.docker.com/storage/volumes/
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@ other related topics.
|
||||||
|
|
||||||
contributing
|
contributing
|
||||||
workflow
|
workflow
|
||||||
agentic-tools
|
|
||||||
styleguide
|
styleguide
|
||||||
policies
|
|
||||||
tests
|
tests
|
||||||
user-input
|
user-input
|
||||||
docbuild
|
docbuild
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
.. _devguide_policies:
|
|
||||||
|
|
||||||
========
|
|
||||||
Policies
|
|
||||||
========
|
|
||||||
|
|
||||||
---------------------
|
|
||||||
Python Version Policy
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
OpenMC follows the Scientific Python Ecosystem Coordination guidelines `SPEC 0
|
|
||||||
<https://scientific-python.org/specs/spec-0000/>`_ on minimum supported
|
|
||||||
versions, which recommends that support for Python versions be dropped 3 years
|
|
||||||
after their initial release.
|
|
||||||
|
|
||||||
-------------------
|
|
||||||
C++ Standard Policy
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
C++ code in OpenMC must conform to the most recent C++ standard that is fully
|
|
||||||
supported in the `version of the gcc compiler
|
|
||||||
<https://gcc.gnu.org/projects/cxx-status.html>`_ that is distributed with the
|
|
||||||
oldest version of Ubuntu that is still within its `standard support period
|
|
||||||
<https://ubuntu.com/about/release-cycle>`_. Ubuntu 22.04 LTS will be supported
|
|
||||||
through April 2027 and is distributed with gcc 11.4.0, which fully supports the
|
|
||||||
C++17 standard.
|
|
||||||
|
|
||||||
--------------------
|
|
||||||
CMake Version Policy
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Similar to the C++ standard policy, the minimum supported version of CMake
|
|
||||||
corresponds to whatever version is distributed with the oldest version of Ubuntu
|
|
||||||
still within its standard support period. Ubuntu 22.04 LTS is distributed with
|
|
||||||
CMake 3.22.
|
|
||||||
|
|
@ -12,26 +12,18 @@ adding new code in OpenMC.
|
||||||
C++
|
C++
|
||||||
---
|
---
|
||||||
|
|
||||||
.. _styleguide_formatting:
|
.. important:: To ensure consistent styling with little effort, this project
|
||||||
|
uses `clang-format <https://clang.llvm.org/docs/ClangFormat.html>`_. The
|
||||||
|
repository contains a ``.clang-format`` file that can be used to
|
||||||
|
automatically apply the style rules that are described below. The easiest
|
||||||
|
way to use clang-format is through a plugin/extension for your editor/IDE
|
||||||
|
that automatically runs clang-format using the ``.clang-format`` file
|
||||||
|
whenever a file is saved.
|
||||||
|
|
||||||
Automatic Formatting
|
Indentation
|
||||||
--------------------
|
-----------
|
||||||
|
|
||||||
To ensure consistent styling with little effort, this project uses `clang-format
|
Use two spaces per indentation level.
|
||||||
<https://clang.llvm.org/docs/ClangFormat.html>`_. The repository contains a
|
|
||||||
``.clang-format`` file that can be used to automatically apply a consistent
|
|
||||||
format. The easiest way to use clang-format is to run
|
|
||||||
``tools/dev/install-commit-hooks.sh`` to install a post-commit hook that gets
|
|
||||||
executed each time a commit is made. Note that this script requires that you
|
|
||||||
already have clang-format installed. In addition, you may want to configure your
|
|
||||||
editor/IDE to automatically runs clang-format using the ``.clang-format`` file
|
|
||||||
whenever a file is saved. For example, `Visual Studio Code
|
|
||||||
<https://code.visualstudio.com/docs/cpp/cpp-ide#_code-formatting>`_ includes
|
|
||||||
support for running clang-format.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
OpenMC's CI uses `clang-format` version 18. A different version of `clang-format`
|
|
||||||
may produce different line changes and as a result fail the CI test.
|
|
||||||
|
|
||||||
Miscellaneous
|
Miscellaneous
|
||||||
-------------
|
-------------
|
||||||
|
|
@ -40,15 +32,14 @@ Follow the `C++ Core Guidelines`_ except when they conflict with another
|
||||||
guideline listed here. For convenience, many important guidelines from that
|
guideline listed here. For convenience, many important guidelines from that
|
||||||
list are repeated here.
|
list are repeated here.
|
||||||
|
|
||||||
Conform to the C++17 standard.
|
Conform to the C++14 standard.
|
||||||
|
|
||||||
Always use C++-style comments (``//``) as opposed to C-style (``/**/``). (It
|
Always use C++-style comments (``//``) as opposed to C-style (``/**/``). (It
|
||||||
is more difficult to comment out a large section of code that uses C-style
|
is more difficult to comment out a large section of code that uses C-style
|
||||||
comments.)
|
comments.)
|
||||||
|
|
||||||
Do not use C-style casting. Always use the C++-style casts ``static_cast``,
|
Do not use C-style casting. Always use the C++-style casts ``static_cast``,
|
||||||
``const_cast``, or ``reinterpret_cast``. (See `ES.49
|
``const_cast``, or ``reinterpret_cast``. (See `ES.49 <http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast>`_)
|
||||||
<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast>`_)
|
|
||||||
|
|
||||||
Source Files
|
Source Files
|
||||||
------------
|
------------
|
||||||
|
|
@ -56,7 +47,7 @@ Source Files
|
||||||
Use a ``.cpp`` suffix for code files and ``.h`` for header files.
|
Use a ``.cpp`` suffix for code files and ``.h`` for header files.
|
||||||
|
|
||||||
Header files should always use include guards with the following style (See
|
Header files should always use include guards with the following style (See
|
||||||
`SF.8 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-guards>`_):
|
`SF.8 <http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf8-use-include-guards-for-all-h-files>`_):
|
||||||
|
|
||||||
.. code-block:: C++
|
.. code-block:: C++
|
||||||
|
|
||||||
|
|
@ -132,6 +123,94 @@ Variables declared constexpr or const that have static storage duration (exist
|
||||||
for the duration of the program) should be upper-case with underscores,
|
for the duration of the program) should be upper-case with underscores,
|
||||||
e.g., ``SQRT_PI``.
|
e.g., ``SQRT_PI``.
|
||||||
|
|
||||||
|
Use C++-style declarator layout (see `NL.18
|
||||||
|
<http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl18-use-c-style-declarator-layout>`_):
|
||||||
|
pointer and reference operators in declarations should be placed adject to the
|
||||||
|
base type rather than the variable name. Avoid declaring multiple names in a
|
||||||
|
single declaration to avoid confusion:
|
||||||
|
|
||||||
|
.. code-block:: C++
|
||||||
|
|
||||||
|
T* p; // good
|
||||||
|
T& p; // good
|
||||||
|
T *p; // bad
|
||||||
|
T* p, q; // misleading
|
||||||
|
|
||||||
|
Curly braces
|
||||||
|
------------
|
||||||
|
|
||||||
|
For a class declaration, the opening brace should be on the same line that
|
||||||
|
lists the name of the class.
|
||||||
|
|
||||||
|
.. code-block:: C++
|
||||||
|
|
||||||
|
class Matrix {
|
||||||
|
...
|
||||||
|
};
|
||||||
|
|
||||||
|
For a function definition, the opening and closing braces should each be on
|
||||||
|
their own lines. This helps distinguish function code from the argument list.
|
||||||
|
If the entire function fits on one or two lines, then the braces can be on the
|
||||||
|
same line. e.g.:
|
||||||
|
|
||||||
|
.. code-block:: C++
|
||||||
|
|
||||||
|
return_type function(type1 arg1, type2 arg2)
|
||||||
|
{
|
||||||
|
content();
|
||||||
|
}
|
||||||
|
|
||||||
|
return_type
|
||||||
|
function_with_many_args(type1 arg1, type2 arg2, type3 arg3,
|
||||||
|
type4 arg4)
|
||||||
|
{
|
||||||
|
content();
|
||||||
|
}
|
||||||
|
|
||||||
|
int return_one() {return 1;}
|
||||||
|
|
||||||
|
int return_one()
|
||||||
|
{return 1;}
|
||||||
|
|
||||||
|
For a conditional, the opening brace should be on the same line as the end of
|
||||||
|
the conditional statement. If there is a following ``else if`` or ``else``
|
||||||
|
statement, the closing brace should be on the same line as that following
|
||||||
|
statement. Otherwise, the closing brace should be on its own line. A one-line
|
||||||
|
conditional can have the closing brace on the same line or it can omit the
|
||||||
|
braces entirely e.g.:
|
||||||
|
|
||||||
|
.. code-block:: C++
|
||||||
|
|
||||||
|
if (condition) {
|
||||||
|
content();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition1) {
|
||||||
|
content();
|
||||||
|
} else if (condition 2) {
|
||||||
|
more_content();
|
||||||
|
} else {
|
||||||
|
further_content();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (condition) {content()};
|
||||||
|
|
||||||
|
if (condition) content();
|
||||||
|
|
||||||
|
For loops similarly have an opening brace on the same line as the statement and
|
||||||
|
a closing brace on its own line. One-line loops may have the closing brace on
|
||||||
|
the same line or omit the braces entirely.
|
||||||
|
|
||||||
|
.. code-block:: C++
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
content();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++) {content();}
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++) content();
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
@ -147,7 +226,7 @@ Style for Python code should follow PEP8_.
|
||||||
|
|
||||||
Docstrings for functions and methods should follow numpydoc_ style.
|
Docstrings for functions and methods should follow numpydoc_ style.
|
||||||
|
|
||||||
Python code should work with Python 3.8+.
|
Python code should work with Python 3.4+.
|
||||||
|
|
||||||
Use of third-party Python packages should be limited to numpy_, scipy_,
|
Use of third-party Python packages should be limited to numpy_, scipy_,
|
||||||
matplotlib_, pandas_, and h5py_. Use of other third-party packages must be
|
matplotlib_, pandas_, and h5py_. Use of other third-party packages must be
|
||||||
|
|
@ -157,11 +236,11 @@ Prefer pathlib_ when working with filesystem paths over functions in the os_
|
||||||
module or other standard-library modules. Functions that accept arguments that
|
module or other standard-library modules. Functions that accept arguments that
|
||||||
represent a filesystem path should work with both strings and Path_ objects.
|
represent a filesystem path should work with both strings and Path_ objects.
|
||||||
|
|
||||||
.. _C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
|
.. _C++ Core Guidelines: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
|
||||||
.. _PEP8: https://peps.python.org/pep-0008/
|
.. _PEP8: https://www.python.org/dev/peps/pep-0008/
|
||||||
.. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html
|
.. _numpydoc: https://numpydoc.readthedocs.io/en/latest/format.html
|
||||||
.. _numpy: https://numpy.org/
|
.. _numpy: https://numpy.org/
|
||||||
.. _scipy: https://scipy.org/
|
.. _scipy: https://www.scipy.org/
|
||||||
.. _matplotlib: https://matplotlib.org/
|
.. _matplotlib: https://matplotlib.org/
|
||||||
.. _pandas: https://pandas.pydata.org/
|
.. _pandas: https://pandas.pydata.org/
|
||||||
.. _h5py: https://www.h5py.org/
|
.. _h5py: https://www.h5py.org/
|
||||||
|
|
|
||||||
|
|
@ -23,28 +23,25 @@ Prerequisites
|
||||||
OpenMC in development/editable mode. With setuptools, this is accomplished by
|
OpenMC in development/editable mode. With setuptools, this is accomplished by
|
||||||
running::
|
running::
|
||||||
|
|
||||||
python -m pip install -e .[test]
|
python setup.py develop
|
||||||
|
|
||||||
|
or using pip (recommended)::
|
||||||
|
|
||||||
|
pip install -e .[test]
|
||||||
|
|
||||||
- The test suite requires a specific set of cross section data in order for
|
- The test suite requires a specific set of cross section data in order for
|
||||||
tests to pass. A download URL for the data that OpenMC expects can be found
|
tests to pass. A download URL for the data that OpenMC expects can be found
|
||||||
within ``tools/ci/download-xs.sh``. Once the tarball is downloaded and
|
within ``tools/ci/download-xs.sh``.
|
||||||
unpacked, set the :envvar:`OPENMC_CROSS_SECTIONS` environment variable to the
|
|
||||||
path of the ``cross_sections.xml`` file within the unpacked data.
|
|
||||||
- In addition to the HDF5 data, some tests rely on ENDF files. A download URL
|
- In addition to the HDF5 data, some tests rely on ENDF files. A download URL
|
||||||
for those can also be found in ``tools/ci/download-xs.sh``. Once the tarball
|
for those can also be found in ``tools/ci/download-xs.sh``.
|
||||||
is downloaded and unpacked, set the :envvar:`OPENMC_ENDF_DATA` environment
|
|
||||||
variable to the top-level directory of the unpacked tarball.
|
|
||||||
- Some tests require `NJOY <https://www.njoy21.io/NJOY2016>`_ to preprocess
|
- Some tests require `NJOY <https://www.njoy21.io/NJOY2016>`_ to preprocess
|
||||||
cross section data. The test suite assumes that you have an ``njoy``
|
cross section data. The test suite assumes that you have an ``njoy``
|
||||||
executable available on your :envvar:`PATH`.
|
executable available on your :envvar:`PATH`.
|
||||||
- OpenMC should be compiled with ``-DOPENMC_ENABLE_STRICT_FP=on`` to ensure
|
|
||||||
reproducible floating-point results across platforms and optimization levels.
|
|
||||||
Without this flag, regression tests may not match reference values.
|
|
||||||
|
|
||||||
Running Tests
|
Running Tests
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
To execute the Python test suite, go to the ``tests/`` directory and run::
|
To execute the test suite, go to the ``tests/`` directory and run::
|
||||||
|
|
||||||
pytest
|
pytest
|
||||||
|
|
||||||
|
|
@ -54,65 +51,6 @@ installed and run::
|
||||||
|
|
||||||
pytest --cov=../openmc --cov-report=html
|
pytest --cov=../openmc --cov-report=html
|
||||||
|
|
||||||
To execute the C++ test suite, go to your build directory and run::
|
|
||||||
|
|
||||||
ctest
|
|
||||||
|
|
||||||
If you want to view testing output on failure run::
|
|
||||||
|
|
||||||
ctest --output-on-failure
|
|
||||||
|
|
||||||
Possible Reasons for Test Failures
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
You may find that when you run the test suite, not everything passes. First,
|
|
||||||
make sure you have satisfied all the prerequisites above. After you have done
|
|
||||||
that, consider the following:
|
|
||||||
|
|
||||||
- When building OpenMC, make sure you run CMake with
|
|
||||||
``-DOPENMC_ENABLE_STRICT_FP=on``. This prevents the compiler from applying
|
|
||||||
floating-point optimizations (such as replacing math library calls with
|
|
||||||
builtins or contracting multiply-add into FMA instructions) that can produce
|
|
||||||
bit-level differences across platforms and optimization levels. Any
|
|
||||||
``CMAKE_BUILD_TYPE`` can be used.
|
|
||||||
- Because tallies involve the sum of many floating point numbers, the
|
|
||||||
non-associativity of floating point numbers can result in different answers
|
|
||||||
especially when the number of threads is high (different order of operations).
|
|
||||||
Thus, if you are running on a CPU with many cores, you may need to limit the
|
|
||||||
number of OpenMP threads used. It is recommended to set the
|
|
||||||
:envvar:`OMP_NUM_THREADS` environment variable to 2.
|
|
||||||
- Recent versions of NumPy use instruction dispatch that may generate different
|
|
||||||
results depending the particular ISA that you are running on. To avoid issues,
|
|
||||||
you may need to disable AVX512 instructions. This can be done by setting the
|
|
||||||
:envvar:`NPY_DISABLE_CPU_FEATURES` environment variable to "AVX512F
|
|
||||||
AVX512_SKX". When NumPy/SciPy are built against OpenBLAS, you may also need to
|
|
||||||
limit the number of threads that OpenBLAS uses internally; this can be done by
|
|
||||||
setting the :envvar:`OPENBLAS_NUM_THREADS` environment variable to 1.
|
|
||||||
|
|
||||||
Debugging Tests in CI
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
Tests can be debugged in CI using a feature called
|
|
||||||
`tmate <https://github.com/mxschmitt/action-tmate?tab=readme-ov-file#debug-your-github-actions-by-using-tmate>`_.
|
|
||||||
CI debugging can be
|
|
||||||
enabled by including "[gha-debug]" in the commit message. When the test fails, a
|
|
||||||
link similar to the one shown below will be provided in the GitHub Actions
|
|
||||||
output after failure occurs. Logging into the provided link will allow you to
|
|
||||||
debug the test in the CI environment. The following is an example of the output
|
|
||||||
shown in the CI log that provides the link to the tmate session:
|
|
||||||
|
|
||||||
.. code-block:: text
|
|
||||||
:linenos:
|
|
||||||
|
|
||||||
Created new session successfully
|
|
||||||
ssh 2VcykjU7vNdvAzEjQcc839GM2@nyc1.tmate.io
|
|
||||||
https://tmate.io/t/2VcykjU7vNdvAzEjQcc839GM2
|
|
||||||
Entering main loop
|
|
||||||
Web shell: https://tmate.io/t/2VcykjU7vNdvAzEjQcc839GM2
|
|
||||||
SSH: ssh 2VcykjU7vNdvAzEjQcc839GM2@nyc1.tmate.io
|
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
Generating XML Inputs
|
Generating XML Inputs
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
@ -124,23 +62,6 @@ run::
|
||||||
|
|
||||||
pytest --build-inputs <name-of-test>
|
pytest --build-inputs <name-of-test>
|
||||||
|
|
||||||
Adding C++ Unit Tests
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
The C++ test suite uses Catch2 integrated with CTest. Each header file should
|
|
||||||
have a corresponding test file in ``tests/cpp_unit_tests/``. If the test file
|
|
||||||
does not exist run::
|
|
||||||
|
|
||||||
touch test_<name-of-header-file>.cpp
|
|
||||||
|
|
||||||
The file must be added to the CMake build system in
|
|
||||||
``tests/cpp_unit_tests/CMakeLists.txt``. ``test_<name-of-header-file>`` should
|
|
||||||
be added to ``TEST_NAMES``.
|
|
||||||
|
|
||||||
To add a test case to ``test_<name-of-header-file>.cpp`` ensure
|
|
||||||
``catch2/catch_test_macros.hpp`` is included. A unit test can then be added
|
|
||||||
using the ``TEST_CASE`` macro and the ``REQUIRE`` assertion from Catch2.
|
|
||||||
|
|
||||||
Adding Tests to the Regression Suite
|
Adding Tests to the Regression Suite
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
|
|
@ -163,12 +84,6 @@ following files to your new test directory:
|
||||||
compiler options during openmc configuration and build (e.g., no MPI, no
|
compiler options during openmc configuration and build (e.g., no MPI, no
|
||||||
debug/optimization).
|
debug/optimization).
|
||||||
|
|
||||||
For tests using the Python API, both the **inputs_true.dat** and
|
|
||||||
**results_true.dat** files can be generated automatically in the correct format
|
|
||||||
via::
|
|
||||||
|
|
||||||
pytest --update <name-of-test>
|
|
||||||
|
|
||||||
In addition to this description, please see the various types of tests that are
|
In addition to this description, please see the various types of tests that are
|
||||||
already included in the test suite to see how to create them. If all is
|
already included in the test suite to see how to create them. If all is
|
||||||
implemented correctly, the new test will automatically be discovered by pytest.
|
implemented correctly, the new test will automatically be discovered by pytest.
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,23 @@ following steps should be followed to make changes to user input:
|
||||||
written out to the statepoint or summary files and that the
|
written out to the statepoint or summary files and that the
|
||||||
:class:`openmc.StatePoint` and :class:`openmc.Summary` classes read them in.
|
:class:`openmc.StatePoint` and :class:`openmc.Summary` classes read them in.
|
||||||
|
|
||||||
|
7. Finally, a set of `RELAX NG`_ schemas exists that enables validation of input
|
||||||
|
files. You should modify the RELAX NG schema for the file you changed. The
|
||||||
|
easiest way to do this is to change the `compact syntax`_ file
|
||||||
|
(e.g. ``src/relaxng/geometry.rnc``) and then convert it to regular XML syntax
|
||||||
|
using trang_::
|
||||||
|
|
||||||
|
trang geometry.rnc geometry.rng
|
||||||
|
|
||||||
For most user input additions and changes, it is simple enough to follow a
|
For most user input additions and changes, it is simple enough to follow a
|
||||||
"monkey see, monkey do" approach. When in doubt, contact your nearest OpenMC
|
"monkey see, monkey do" approach. When in doubt, contact your nearest OpenMC
|
||||||
developer or send a message to the `developers mailing list`_.
|
developer or send a message to the `developers mailing list`_.
|
||||||
|
|
||||||
|
|
||||||
.. _property attribute: https://docs.python.org/3.6/library/functions.html#property
|
.. _property attribute: https://docs.python.org/3.6/library/functions.html#property
|
||||||
.. _XML Schema Part 2: https://www.w3.org/TR/xmlschema-2/
|
.. _XML Schema Part 2: http://www.w3.org/TR/xmlschema-2/
|
||||||
.. _boolean: https://www.w3.org/TR/xmlschema-2/#boolean
|
.. _boolean: http://www.w3.org/TR/xmlschema-2/#boolean
|
||||||
|
.. _RELAX NG: https://relaxng.org/
|
||||||
|
.. _compact syntax: https://relaxng.org/compact-tutorial-20030326.html
|
||||||
|
.. _trang: https://relaxng.org/jclark/trang.html
|
||||||
.. _developers mailing list: https://groups.google.com/forum/?fromgroups=#!forum/openmc-dev
|
.. _developers mailing list: https://groups.google.com/forum/?fromgroups=#!forum/openmc-dev
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
Development Workflow
|
Development Workflow
|
||||||
====================
|
====================
|
||||||
|
|
||||||
Anyone wishing to make contributions to OpenMC should be fully acquainted and
|
Anyone wishing to make contributions to OpenMC should be fully acquianted and
|
||||||
comfortable working with git_ and GitHub_. We assume here that you have git
|
comfortable working with git_ and GitHub_. We assume here that you have git
|
||||||
installed on your system, have a GitHub account, and have setup SSH keys to be
|
installed on your system, have a GitHub account, and have setup SSH keys to be
|
||||||
able to create/push to repositories on GitHub.
|
able to create/push to repositories on GitHub.
|
||||||
|
|
@ -67,12 +67,6 @@ features and bug fixes. The general steps for contributing are as follows:
|
||||||
cd openmc
|
cd openmc
|
||||||
git checkout -b newbranch develop
|
git checkout -b newbranch develop
|
||||||
|
|
||||||
3. Run ``tools/dev/install-commit-hooks.sh`` to install a post-commit hook that
|
|
||||||
runs clang-format on C++ files to apply :ref:`automatic code formatting
|
|
||||||
<styleguide_formatting>` (requires that clang-format already be installed).
|
|
||||||
In addition, you may want to configure your text editor to automatically run
|
|
||||||
clang-format when saving C++ files.
|
|
||||||
|
|
||||||
3. Make your changes on the new branch that you intend to have included in
|
3. Make your changes on the new branch that you intend to have included in
|
||||||
*develop*. If you have made other changes that should not be merged back,
|
*develop*. If you have made other changes that should not be merged back,
|
||||||
ensure that those changes are made on a different branch.
|
ensure that those changes are made on a different branch.
|
||||||
|
|
@ -81,7 +75,7 @@ features and bug fixes. The general steps for contributing are as follows:
|
||||||
openmc-dev/openmc as the target.
|
openmc-dev/openmc as the target.
|
||||||
|
|
||||||
At a minimum, you should describe what the changes you've made are and why
|
At a minimum, you should describe what the changes you've made are and why
|
||||||
you are making them. If the changes are related to an outstanding issue, make
|
you are making them. If the changes are related to an oustanding issue, make
|
||||||
sure it is cross-referenced.
|
sure it is cross-referenced.
|
||||||
|
|
||||||
5. A committer will review your pull request based on the criteria
|
5. A committer will review your pull request based on the criteria
|
||||||
|
|
@ -91,30 +85,6 @@ features and bug fixes. The general steps for contributing are as follows:
|
||||||
6. After the pull request has been thoroughly vetted, it is merged back into the
|
6. After the pull request has been thoroughly vetted, it is merged back into the
|
||||||
*develop* branch of openmc-dev/openmc.
|
*develop* branch of openmc-dev/openmc.
|
||||||
|
|
||||||
Setting Up Upstream Tracking (Required for Versioning)
|
|
||||||
------------------------------------------------------
|
|
||||||
|
|
||||||
By default, your fork **does not** include tags from the upstream OpenMC repository.
|
|
||||||
OpenMC relies on `git describe --tags` for versioning in source builds, and missing tags can lead
|
|
||||||
to incorrect version detection (i.e., ``0.0.0``). To ensure proper versioning, follow these steps:
|
|
||||||
|
|
||||||
1. **Add the Upstream Repository**
|
|
||||||
This allows you to fetch updates from the main OpenMC repository.
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
git remote add upstream https://github.com/openmc-dev/openmc.git
|
|
||||||
|
|
||||||
2. **Fetch and Push Tags**
|
|
||||||
Retrieve tags from the upstream repository and update your fork:
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
git fetch --tags upstream
|
|
||||||
git push --tags origin
|
|
||||||
|
|
||||||
This ensures that both your **local** and **remote** fork have the correct versioning information.
|
|
||||||
|
|
||||||
Private Development
|
Private Development
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
@ -140,20 +110,20 @@ pip_. From the root directory of the OpenMC repository, run:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
python -m pip install -e .[test]
|
pip install -e .[test]
|
||||||
|
|
||||||
This installs the OpenMC Python package in `"editable" mode
|
This installs the OpenMC Python package in `"editable" mode
|
||||||
<https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs>`_ so that 1)
|
<https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_ so
|
||||||
it can be imported from a Python interpreter and 2) any changes made are
|
that 1) it can be imported from a Python interpreter and 2) any changes made are
|
||||||
immediately reflected in the installed version (that is, you don't need to keep
|
immediately reflected in the installed version (that is, you don't need to keep
|
||||||
reinstalling it). While the same effect can be achieved using the
|
reinstalling it). While the same effect can be achieved using the
|
||||||
:envvar:`PYTHONPATH` environment variable, this is generally discouraged as it
|
:envvar:`PYTHONPATH` environment variable, this is generally discouraged as it
|
||||||
can interfere with virtual environments.
|
can interfere with virtual environments.
|
||||||
|
|
||||||
.. _git: https://git-scm.com/
|
.. _git: http://git-scm.com/
|
||||||
.. _GitHub: https://github.com/
|
.. _GitHub: https://github.com/
|
||||||
.. _git flow: https://nvie.com/git-model
|
.. _git flow: https://nvie.com/git-model
|
||||||
.. _valgrind: https://valgrind.org/
|
.. _valgrind: https://www.valgrind.org/
|
||||||
.. _style guide: https://docs.openmc.org/en/latest/devguide/styleguide.html
|
.. _style guide: https://docs.openmc.org/en/latest/devguide/styleguide.html
|
||||||
.. _pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
|
.. _pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
|
||||||
.. _openmc-dev/openmc: https://github.com/openmc-dev/openmc
|
.. _openmc-dev/openmc: https://github.com/openmc-dev/openmc
|
||||||
|
|
|
||||||
1
docs/source/examples/cad-based-geometry.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/cad-based-geometry.ipynb
|
||||||
1
docs/source/examples/candu.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/candu.ipynb
|
||||||
1
docs/source/examples/capi.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/capi.ipynb
|
||||||
1
docs/source/examples/expansion-filters.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/expansion-filters.ipynb
|
||||||
1
docs/source/examples/hexagonal-lattice.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/hexagonal-lattice.ipynb
|
||||||
73
docs/source/examples/index.rst
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
.. _examples:
|
||||||
|
|
||||||
|
========
|
||||||
|
Examples
|
||||||
|
========
|
||||||
|
|
||||||
|
The following series of `Jupyter <https://jupyter.org/>`_ Notebooks provide
|
||||||
|
examples for how to use various features of OpenMC by leveraging the
|
||||||
|
:ref:`pythonapi`.
|
||||||
|
|
||||||
|
-------------
|
||||||
|
General Usage
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
pincell
|
||||||
|
post-processing
|
||||||
|
pandas-dataframes
|
||||||
|
tally-arithmetic
|
||||||
|
capi
|
||||||
|
expansion-filters
|
||||||
|
search
|
||||||
|
nuclear-data
|
||||||
|
nuclear-data-resonance-covariance
|
||||||
|
pincell_depletion
|
||||||
|
|
||||||
|
--------
|
||||||
|
Geometry
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
hexagonal-lattice
|
||||||
|
triso
|
||||||
|
candu
|
||||||
|
cad-based-geometry
|
||||||
|
|
||||||
|
-----------------------------------
|
||||||
|
Multigroup Cross Section Generation
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
mgxs-part-i
|
||||||
|
mgxs-part-ii
|
||||||
|
mgxs-part-iii
|
||||||
|
mdgxs-part-i
|
||||||
|
mdgxs-part-ii
|
||||||
|
|
||||||
|
---------------
|
||||||
|
Multigroup Mode
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
mg-mode-part-i
|
||||||
|
mg-mode-part-ii
|
||||||
|
mg-mode-part-iii
|
||||||
|
|
||||||
|
-----------------
|
||||||
|
Unstructured Mesh
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
unstructured-mesh-part-i
|
||||||
|
unstructured-mesh-part-ii
|
||||||
1
docs/source/examples/mdgxs-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mdgxs-part-i.ipynb
|
||||||
1
docs/source/examples/mdgxs-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mdgxs-part-ii.ipynb
|
||||||
1
docs/source/examples/mg-mode-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mg-mode-part-i.ipynb
|
||||||
1
docs/source/examples/mg-mode-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mg-mode-part-ii.ipynb
|
||||||
1
docs/source/examples/mg-mode-part-iii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mg-mode-part-iii.ipynb
|
||||||
1
docs/source/examples/mgxs-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mgxs-part-i.ipynb
|
||||||
1
docs/source/examples/mgxs-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mgxs-part-ii.ipynb
|
||||||
1
docs/source/examples/mgxs-part-iii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/mgxs-part-iii.ipynb
|
||||||
1
docs/source/examples/nuclear-data-resonance-covariance.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/nuclear-data-resonance-covariance.ipynb
|
||||||
1
docs/source/examples/nuclear-data.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/nuclear-data.ipynb
|
||||||
1
docs/source/examples/pandas-dataframes.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/pandas-dataframes.ipynb
|
||||||
1
docs/source/examples/pincell.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/pincell.ipynb
|
||||||
1
docs/source/examples/pincell_depletion.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/pincell_depletion.ipynb
|
||||||
1
docs/source/examples/post-processing.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/post-processing.ipynb
|
||||||
1
docs/source/examples/search.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/search.ipynb
|
||||||
1
docs/source/examples/tally-arithmetic.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/tally-arithmetic.ipynb
|
||||||
1
docs/source/examples/triso.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/triso.ipynb
|
||||||
1
docs/source/examples/unstructured-mesh-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/unstructured-mesh-part-i.ipynb
|
||||||
1
docs/source/examples/unstructured-mesh-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../examples/jupyter/unstructured-mesh-part-ii.ipynb
|
||||||
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -12,7 +12,7 @@ files produced by NJOY. Parallelism is enabled via a hybrid MPI and OpenMP
|
||||||
programming model.
|
programming model.
|
||||||
|
|
||||||
OpenMC was originally developed by members of the `Computational Reactor Physics
|
OpenMC was originally developed by members of the `Computational Reactor Physics
|
||||||
Group <https://crpg.mit.edu>`_ at the `Massachusetts Institute of Technology
|
Group <http://crpg.mit.edu>`_ at the `Massachusetts Institute of Technology
|
||||||
<https://web.mit.edu>`_ starting in 2011. Various universities, laboratories,
|
<https://web.mit.edu>`_ starting in 2011. Various universities, laboratories,
|
||||||
and other organizations now contribute to the development of OpenMC. For more
|
and other organizations now contribute to the development of OpenMC. For more
|
||||||
information on OpenMC, feel free to post a message on the `OpenMC Discourse
|
information on OpenMC, feel free to post a message on the `OpenMC Discourse
|
||||||
|
|
@ -36,7 +36,7 @@ Forum <https://openmc.discourse.group/>`_.
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
quickinstall
|
quickinstall
|
||||||
Examples <https://github.com/openmc-dev/openmc/wiki/Example-Jupyter-Notebooks>
|
examples/index
|
||||||
releasenotes/index
|
releasenotes/index
|
||||||
methods/index
|
methods/index
|
||||||
usersguide/index
|
usersguide/index
|
||||||
|
|
|
||||||