How jkkdy/april works
Purpose and Entry Points
APRIL is a header-only C++23 particle-simulation runtime. Applications include the umbrella API, declare a simulation, build it into a specialized system, then run an integrator. Primary public entry point: include/april/april.hpp. Executable usage patterns are shown by examples/galaxy.cpp and examples/sandbox.cpp.
1. Declarative Environment
Environment collects particles, domain extent, typed forces, fields, boundaries, and controllers before execution. Compile-time component packs define possible categories; runtime objects supply parameters. Particle declarations and extensible properties originate in include/april/particle/particle.hpp and include/april/particle/properties.hpp; environment/domain state is in include/april/core/environment.hpp and include/april/core/domain.hpp.
2. Build / Compilation Boundary
build_system(...) is the key materialization boundary: it validates declarations, establishes domain data, maps particle types, builds interaction/boundary tables, initializes storage, and prepares the selected traversal container. This converts descriptive Environment plus Container into executable System, centered in include/april/core/build.hpp, include/april/core/system.hpp, and include/april/core/internal/system_impl.hpp.
3. Particle Storage and Neighbor Traversal
Containers own particle storage and determine both layout and pair traversal. DirectSum provides all-pairs evaluation; LinkedCells provides spatial partitioning for near-neighbor scaling. Layout implementations specialize AoS, SoA, and AoSoA access while exposing common particle views: include/april/containers/container.hpp, include/april/containers/direct_sum.hpp, include/april/containers/linked_cells.hpp. Linked-cell scheduling/configuration is isolated under include/april/containers/linked_cells/lc_scheduling.hpp.
4. Physics Evaluation Pipeline
During force refresh, the system traverses particle pairs through its container, resolves type-selected interactions, adds external fields, and applies domain boundaries/controllers as appropriate. Built-in pair laws are statically composable kernels, e.g. include/april/interactions/force.hpp, include/april/interactions/interaction_table.hpp, and include/april/interactions/lennard_jones.hpp. Fields and boundaries are separate policies in include/april/fields/field.hpp and include/april/boundaries/boundary.hpp.
5. Time Integration and Observation
Integrators own timestep progression and repeatedly invoke system updates; built-ins include Velocity-Verlet and Yoshida fourth-order integration. Controllers modify runtime state such as thermostat behavior, while monitors observe/emits records according to triggers without defining the hot physics path. Relevant boundaries: include/april/integrators/integrator.hpp, include/april/integrators/velocity_verlet.hpp, include/april/controllers/controller.hpp, and include/april/monitors/monitor.hpp.
6. CPU Specialization and Execution
The library uses templates, concepts, CRTP-style interfaces, and static alternatives rather than virtual plugin dispatch. A single user kernel can be specialized for scalar or packed SIMD particle access and for selected layouts. SIMD abstraction supports xsimd or standard SIMD: include/april/simd/packed.hpp, include/april/simd/backend_xsimd.hpp, include/april/simd/backend_std_simd.hpp. Shared-memory execution is selected through policies/executors, with sequential, native-thread, and OpenMP backends under include/april/exec/policy.hpp, include/april/exec/threading/backends/omp_executor.hpp, and include/april/exec/threading/backends/native_spin_executor.hpp.
7. Build and External Dependencies
CMake exposes the header-only library and optional development targets through CMakeLists.txt; examples are separately composed in examples/CMakeLists.txt. The core has no mandatory runtime dependency. Optional CMake-resolved dependencies are xsimd for the default SIMD backend, OpenMP for parallel execution, and GoogleTest for tests. CI builds across platforms in .github/workflows/cmake-multi-platform.yml.
Main entry points: system.hpp System · container.hpp Container abstraction · build.hpp build_system · april.hpp APRIL umbrella API
Components 19
Public API & Models
- Applications · Declare and run simulations.
examples/galaxy.cpp - APRIL umbrella API
include/april/april.hpp - Particle types & properties · Compile-time particle categories and extensible properties.
include/april/particle/particle.hpp - Environment & domain · Collects runtime simulation declarations and extent.
include/april/core/environment.hpp
System Materialization
- build_system · Validates declarations and materializes an executable system.
include/april/core/build.hpp - System · Owns prepared simulation state and force refresh.
include/april/core/system.hpp - System implementation · Initializes storage, tables, domain data, and traversal.
include/april/core/internal/system_impl.hpp
Simulation Runtime
- Container abstraction · Defines particle layout and pair traversal interface.
include/april/containers/container.hpp - DirectSum
include/april/containers/direct_sum.hpp - LinkedCells · Partitions space for near-neighbor traversal.
include/april/containers/linked_cells.hpp - Linked-cell scheduling
include/april/containers/linked_cells/lc_scheduling.hpp - Interaction table & kernels · Resolves type-selected statically composable pair laws.
include/april/interactions/interaction_table.hpp - Fields
include/april/fields/field.hpp - Boundaries
include/april/boundaries/boundary.hpp - Integrators · Repeatedly advance the system and invoke updates.
include/april/integrators/integrator.hpp - Controllers & monitors · Controllers modify state; monitors emit triggered observations.
include/april/controllers/controller.hpp
CPU Execution
- SIMD abstraction · Specializes kernels for scalar or packed particle access.
include/april/simd/packed.hpp - Execution policies · Selects sequential, native-thread, or OpenMP execution.
include/april/exec/policy.hpp
Other components
- CMake build · Exports header-only library and optional development targets.
CMakeLists.txt
Connections 22
- Applications → APRIL umbrella API: includes
- APRIL umbrella API → Particle types & properties: exposes
- APRIL umbrella API → Environment & domain: exposes
- Particle types & properties → Environment & domain: declared in
- Environment & domain → build_system: declarations
- build_system → System implementation: materializes
- System implementation → System: prepares
- build_system → Container abstraction: selects
- Container abstraction → DirectSum: all-pairs variant
- Container abstraction → LinkedCells: spatial variant
- LinkedCells → Linked-cell scheduling: uses
- build_system → Interaction table & kernels: builds tables
- System → Container abstraction: traverses pairs through
- System → Interaction table & kernels: evaluates
- System → Fields: adds
- System → Boundaries: applies
- Integrators → System: advances
- Controllers & monitors → System: modify or observe
- Interaction table & kernels → SIMD abstraction: specialized with
- Container abstraction → SIMD abstraction: provides packed access
- System → Execution policies: executes via
- CMake build → APRIL umbrella API: packages