Skip to content

make simulator an interface - no binary target#969

Merged
PhilipDeegan merged 2 commits intoPHAREHUB:masterfrom
PhilipDeegan:libsimulator
Mar 10, 2025
Merged

make simulator an interface - no binary target#969
PhilipDeegan merged 2 commits intoPHAREHUB:masterfrom
PhilipDeegan:libsimulator

Conversation

@PhilipDeegan
Copy link
Member

@PhilipDeegan PhilipDeegan commented Mar 6, 2025

It's not necessary for the simulator component to be a library

All the binary was used for is the "makeAtRuntime" stuff which is only used for phare-exe

so I moved it there, which is a compiled binary already

another potential solution for #958 - (appears it is)

coderabbitai[bot]

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as off-topic.

@PHAREHUB PHAREHUB deleted a comment from coderabbitai bot Mar 6, 2025
@PHAREHUB PHAREHUB deleted a comment from coderabbitai bot Mar 6, 2025
phare_diagnostic
)

set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " ${PHARE_LINK_FLAGS}")
Copy link
Member

Choose a reason for hiding this comment

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

TORM

@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2025

📝 Walkthrough

Walkthrough

The changes introduce a new function getSimulator in the PHARE namespace within src/phare/phare.cpp that creates and returns a unique pointer to PHARE::ISimulator by retrieving simulation parameters and using a runtime factory. The fromCommandLine function has been moved outside the PHARE namespace. Additionally, the simulator source and header files have been updated: the implementation and declaration of getSimulator have been removed from their previous locations. The simulator project build configuration has been modified to define an interface library rather than compiling source files.

Changes

Files Change Summary
src/phare/phare.cpp - Added new function getSimulator returning a unique pointer to PHARE::ISimulator using runtime parameters.
- Moved fromCommandLine outside the PHARE namespace.
- Reorganized header inclusions and improved error handling.
src/simulator/CMakeLists.txt - Changed library definition to an INTERFACE library by removing source file inclusion (simulator.cpp).
- Updated target linking and removed compile options related to the built library.
src/simulator/simulator.cpp
src/simulator/simulator.hpp
- Removed implementation and declaration of getSimulator.
- Updated the catch block syntax in the header file for exception handling.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant PHARE.getSimulator
    participant ParamDict
    participant SimulatorMaker

    Caller->>PHARE.getSimulator: Call getSimulator(hierarchy)
    PHARE.getSimulator->>ParamDict: Retrieve simulation parameters (dimension, interpolation order, refined particles)
    PHARE.getSimulator->>SimulatorMaker: Create simulator with parameters
    SimulatorMaker-->>PHARE.getSimulator: Return unique_ptr to ISimulator
    PHARE.getSimulator-->>Caller: Return unique_ptr to ISimulator
Loading

Suggested reviewers

  • nicolasaunai

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 254aeb4 and 7550761.

📒 Files selected for processing (4)
  • src/phare/phare.cpp (3 hunks)
  • src/simulator/CMakeLists.txt (1 hunks)
  • src/simulator/simulator.cpp (0 hunks)
  • src/simulator/simulator.hpp (1 hunks)
💤 Files with no reviewable changes (1)
  • src/simulator/simulator.cpp
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.hpp`: Review the C++ code, point out issues relative t...

**/*.hpp: Review the C++ code, point out issues relative to principles of clean code, expressiveness, and performance.

  • src/simulator/simulator.hpp
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest, clang)
  • GitHub Check: Analyze (cpp)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-latest, gcc)
  • GitHub Check: Analyze (python)
  • GitHub Check: build (macos-13)
🔇 Additional comments (6)
src/simulator/simulator.hpp (1)

382-382: Consistent use of east-const style.

The change from catch (const std::runtime_error& e) to catch (std::runtime_error const& e) maintains consistent use of the "east-const" style, where const appears after the type it modifies. This style is often preferred for its readability, especially with complex types.

src/phare/phare.cpp (4)

9-10: Header organization looks good.

The reordering of headers maintains good organization by grouping standard library headers together.


25-35: Implementation of getSimulator moved appropriately.

The implementation of the getSimulator function has been moved from the simulator module to the PHARE namespace, which aligns with the PR objective to eliminate the simulator component as a library. The function properly retrieves simulation parameters and creates a simulator instance.


40-58: Function moved outside namespace as intended.

Moving fromCommandLine outside the PHARE namespace is consistent with the restructuring. This change maintains the function's original functionality while adapting to the new architectural design.


62-69: Improved error handling with braces.

Adding braces to the conditional statements is a good practice that improves code readability and reduces the potential for bugs in future modifications.

src/simulator/CMakeLists.txt (1)

9-11: Appropriate conversion to interface library.

Converting from a standard library to an INTERFACE library properly reflects the architectural change where the simulator is now just an interface without compiled source files. This aligns perfectly with the PR objective to "eliminate the necessity for the simulator component to function as a library."

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@PhilipDeegan PhilipDeegan merged commit a9ae15d into PHAREHUB:master Mar 10, 2025
13 checks passed
@PhilipDeegan PhilipDeegan deleted the libsimulator branch March 10, 2025 19:19
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Apr 23, 2025
* make simulator an interface - no binary target

* torm
PhilipDeegan added a commit to PhilipDeegan/PHARE that referenced this pull request Oct 8, 2025
* make simulator an interface - no binary target

* torm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants