Skip to content

Commit

Permalink
Redesign n4::run_manager interface
Browse files Browse the repository at this point in the history
Closes 122
  • Loading branch information
gonzaponte committed Sep 6, 2023
2 parents 0bcde11 + a8d875d commit 96ac1ea
Show file tree
Hide file tree
Showing 26 changed files with 368 additions and 504 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,5 @@ jobs:
- name: Run compile-time tests
run: nix develop .#${{ matrix.devshell }} -c just test-compile-time

- name: Run nain4 examples
run: nix develop .#${{ matrix.devshell }} -c just test-examples

- name: Run G4 examples
run: nix develop .#${{ matrix.devshell }} -c just g4-examples/run-examples-that-work
16 changes: 12 additions & 4 deletions compile-time-tests/generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
( "no member named 'initialize'"
, """
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.initialize();
""")
,
Expand All @@ -20,6 +21,7 @@
("no member named 'geometry'"
,"""
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.geometry (dummy_geometry)
.actions (dummy_actions)
.initialize();
Expand All @@ -31,9 +33,10 @@
( "no member named 'actions'"
, """
n4::run_manager::create()
.actions (dummy_actions)
.geometry (dummy_geometry)
.initialize();
.ui("program-name", argc, argv, false)
.actions (dummy_actions)
.geometry (dummy_geometry)
.initialize();
""")
,

Expand All @@ -42,6 +45,7 @@
( "no member named 'initialize'"
, """
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.physics(dummy_physics_list)
.initialize();
""")
Expand All @@ -52,6 +56,7 @@
( "no member named 'actions'"
, """
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.physics(dummy_physics_list)
.actions(dummy_actions)
.initialize();
Expand All @@ -63,6 +68,7 @@
( "no member named 'geometry'"
, """
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.geometry (dummy_geometry)
.physics (dummy_physics_list)
.actions (dummy_actions)
Expand All @@ -76,6 +82,7 @@
( "no member named 'actions'"
, """
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.actions (dummy_actions)
.physics (dummy_physics_list)
.geometry (dummy_geometry)
Expand All @@ -89,6 +96,7 @@
( "no member named 'actions'"
, """
n4::run_manager::create()
.ui("program-name", argc, argv, false)
.physics (dummy_physics_list)
.actions (dummy_actions)
.geometry (dummy_geometry)
Expand All @@ -103,7 +111,7 @@
#include "nain4.hh"
#include "compile_time_common.hh"
int main() {{
int main(int argc, char** argv) {{
{snippet}
Expand Down
27 changes: 17 additions & 10 deletions doc/src/how-to/build-a-minimal-nain4-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

## Building the app

The most basic example of a nain4 app can be found in [examples/00-basic/n4app.cc](../../../examples/00-basic/n4app.cc). Here is the full file:
One of the most basic examples of a nain4 app can be found in [templates/basic/src/n4app.cc](../../../templates/basic/src/n4app.cc). Here is the full file:

```c++
{{#include ../../../examples/00-basic/n4app.cc:full_file}}
{{#include ../../../templates/basic/src/n4app.cc:full_file}}
```
Now, let's split it into bite-sized portions. First we create a simple program that reads the number of events from CLI:
```c++
{{#include ../../../examples/00-basic/n4app.cc:pick_cli_arguments}}
{{#include ../../../examples/00-basic/n4app.cc:closing_bracket}}
{{#include ../../../templates/basic/src/n4app.cc:pick_cli_arguments}}
{{#include ../../../templates/basic/src/n4app.cc:closing_bracket}}
```

In order to run a simulation we need to create a run manager:
```c++
{{#include ../../../examples/00-basic/n4app.cc:create_run_manager}}
{{#include ../../../templates/basic/src/n4app.cc:create_run_manager}}
```
The run manager needs to be initialized with 3 attributes:
Expand All @@ -28,25 +28,32 @@ To build the action set we need to provide a primary generator action. Other act
Note that the physics list must be instantiated and given to the run manager before the primary generator is instantiated. We provide the run manager with these attributes:
```c++
{{#include ../../../examples/00-basic/n4app.cc:build_minimal_framework}}
{{#include ../../../templates/basic/src/n4app.cc:build_minimal_framework}}
```

here, `my_geometry`, and `my_generator` are the two functions we need to provide to run our simulation:

```c++
{{#include ../../../examples/00-basic/n4app.cc:my_geometry}}
{{#include ../../../templates/basic/src/n4app.cc:my_geometry}}

{{#include ../../../examples/00-basic/n4app.cc:my_generator}}
{{#include ../../../templates/basic/src/n4app.cc:my_generator}}
```
and `create_actions` is defined as:
```c++
{{#include ../../../templates/basic/src/n4app.cc:create_actions}}
```


With this, our setup is ready, and we can start the simulation with
```c++
{{#include ../../../examples/00-basic/n4app.cc:run}}
{{#include ../../../templates/basic/src/n4app.cc:run}}
```
Don't forget to add the relevant includes
```c++
{{#include ../../../examples/00-basic/n4app.cc:includes}}
{{#include ../../../templates/basic/src/n4app.cc:includes}}
```

## Compiling the app
Expand Down
57 changes: 0 additions & 57 deletions examples/00-basic/CMakeLists.txt

This file was deleted.

15 changes: 0 additions & 15 deletions examples/00-basic/justfile

This file was deleted.

30 changes: 0 additions & 30 deletions examples/00-basic/macs/run.mac

This file was deleted.

84 changes: 0 additions & 84 deletions examples/00-basic/macs/vis.mac

This file was deleted.

Loading

0 comments on commit 96ac1ea

Please sign in to comment.