├── .clang-format ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── problems-at-compile--runtime.md └── workflows │ └── actions.yml ├── .gitignore ├── .gitmodules ├── .vscode ├── .taplo.toml ├── extensions.json └── suppress_warnings.h ├── CMakeLists.txt ├── LICENSE ├── README.md ├── TASKLIST.md ├── cmake ├── MPIConfig.cmake ├── adios2Config.cmake ├── config.cmake ├── defaults.cmake ├── dependencies.cmake ├── kokkosConfig.cmake ├── report.cmake ├── styling.cmake └── tests.cmake ├── conda-entity-nompi.sh ├── dev ├── Dockerfile.common ├── Dockerfile.cuda ├── Dockerfile.rocm ├── runners │ ├── Dockerfile.runner.cuda │ ├── Dockerfile.runner.rocm │ ├── README.md │ └── start.sh ├── welcome.cuda └── welcome.rocm ├── docker-compose.yml ├── input.example.toml ├── legacy ├── Makefile.in ├── Nttiny.mk ├── Tests.mk ├── benchmarks │ ├── CMakeLists.txt │ ├── gr.cpp │ ├── sr-mink.cpp │ └── sr-sph.cpp ├── cmake │ └── config.cmake ├── configure.py ├── deploy │ ├── aux │ │ ├── argparse.sh │ │ ├── aux.sh │ │ ├── config.sh │ │ ├── default.sh │ │ ├── globals.sh │ │ └── run.sh │ ├── compile_adios2.sh │ ├── compile_hdf5.sh │ ├── compile_kokkos.sh │ ├── compile_ompi.sh │ ├── compile_ucx.sh │ ├── deploy.py │ ├── personal.toml │ ├── stellar.toml │ └── zaratan.toml ├── src │ ├── framework │ │ ├── digital_filters.hpp │ │ ├── io │ │ │ ├── output_csv.cpp │ │ │ └── output_csv.h │ │ ├── ks_phys_units.h │ │ ├── metrics │ │ │ └── kerr_schild_nomass.h │ │ ├── utils │ │ │ ├── current_filter.cpp │ │ │ ├── current_filter.hpp │ │ │ ├── particle_injectors.hpp │ │ │ ├── timer.cpp │ │ │ └── timer.h │ │ └── writer.cpp │ ├── grpic │ │ └── boundaries │ │ │ └── fields_bc.cpp │ ├── nttiny.cpp │ ├── particle_pusher_sr.hpp │ └── pic │ │ ├── boundaries │ │ ├── currents_bc.cpp │ │ └── currents_bc.hpp │ │ ├── fields │ │ ├── ampere_curv.hpp │ │ ├── ampere_mink.hpp │ │ ├── faraday_curv.hpp │ │ └── faraday_mink.hpp │ │ ├── particles │ │ └── particle_pusher.hpp │ │ └── pgen │ │ └── old │ │ ├── debug.cpp │ │ ├── debug.hpp │ │ ├── deposit.cpp │ │ ├── deposit.hpp │ │ ├── em.cpp │ │ ├── em.hpp │ │ ├── magnetosphere.hpp │ │ ├── oneprtl.cpp │ │ ├── oneprtl.hpp │ │ ├── oneprtl_sph.cpp │ │ └── oneprtl_sph.hpp └── tests │ ├── TODO_CMakeLists.txt │ ├── deposit.cpp │ ├── kernels-gr.cpp │ ├── kernels-sr.cpp │ ├── pusher-sr-mink.cpp │ ├── utils-comm.cpp │ ├── utils-metadomain.cpp │ └── utils-writer.cpp ├── setups ├── CMakeLists.txt ├── grpic │ └── pgen_grpic_example.hpp ├── pgen.hpp ├── srpic │ ├── em_vacuum │ │ ├── em_vacuum.py │ │ ├── em_vacuum.toml │ │ └── pgen.hpp │ ├── example │ │ └── pgen.hpp │ ├── langmuir │ │ ├── langmuir.py │ │ ├── langmuir.toml │ │ └── pgen.hpp │ ├── magnetar │ │ ├── magnetar.py │ │ ├── magnetar.toml │ │ └── pgen.hpp │ ├── magnetosphere │ │ ├── magnetosphere.py │ │ ├── magnetosphere.toml │ │ └── pgen.hpp │ ├── monopole │ │ ├── monopole.toml │ │ └── pgen.hpp │ ├── pgen_srpic_example.hpp │ ├── shock │ │ ├── pgen.hpp │ │ ├── shock.py │ │ └── shock.toml │ ├── turbulence │ │ ├── pgen.hpp │ │ └── turbulence.toml │ └── weibel │ │ ├── pgen.hpp │ │ └── weibel.toml ├── tests │ ├── blob │ │ ├── blob.toml │ │ └── pgen.hpp │ ├── customout │ │ ├── customout.toml │ │ └── pgen.hpp │ ├── deposit │ │ ├── deposit.toml │ │ └── pgen.hpp │ └── injector │ │ ├── injector.toml │ │ └── pgen.hpp └── wip │ ├── rec-gravity │ ├── pgen.hpp │ └── rec-gravity.toml │ ├── reconnection │ ├── pgen.hpp │ └── reconnection.toml │ └── spider │ └── pgen.hpp └── src ├── CMakeLists.txt ├── archetypes ├── CMakeLists.txt ├── energy_dist.h ├── field_setter.h ├── particle_injector.h ├── problem_generator.h ├── spatial_dist.h └── tests │ ├── CMakeLists.txt │ ├── energy_dist.cpp │ ├── field_setter.cpp │ └── spatial_dist.cpp ├── engines ├── CMakeLists.txt ├── engine.hpp ├── engine_init.cpp ├── engine_printer.cpp ├── engine_run.cpp ├── engine_step_report.cpp ├── grpic.hpp └── srpic.hpp ├── entity.cpp ├── framework ├── CMakeLists.txt ├── containers │ ├── fields.cpp │ ├── fields.h │ ├── particles.cpp │ ├── particles.h │ └── species.h ├── domain │ ├── comm_mpi.hpp │ ├── comm_nompi.hpp │ ├── communications.cpp │ ├── domain.h │ ├── grid.cpp │ ├── grid.h │ ├── mesh.h │ ├── metadomain.cpp │ ├── metadomain.h │ └── output.cpp ├── parameters.cpp ├── parameters.h ├── simulation.cpp ├── simulation.h └── tests │ ├── CMakeLists.txt │ ├── comm_mpi.cpp │ ├── comm_nompi.cpp │ ├── fields.cpp │ ├── grid_mesh.cpp │ ├── metadomain.cpp │ ├── parameters.cpp │ ├── particles.cpp │ └── simulation.cpp ├── global ├── CMakeLists.txt ├── arch │ ├── directions.h │ ├── kokkos_aliases.cpp │ ├── kokkos_aliases.h │ ├── mpi_aliases.h │ ├── mpi_tags.h │ └── traits.h ├── defaults.h ├── enums.h ├── global.cpp ├── global.h ├── tests │ ├── CMakeLists.txt │ ├── comparators.cpp │ ├── directions.cpp │ ├── enums.cpp │ ├── global.cpp │ ├── kokkos_aliases.cpp │ ├── numeric.cpp │ ├── param_container.cpp │ └── sorting.cpp └── utils │ ├── cargs.cpp │ ├── cargs.h │ ├── colors.h │ ├── comparators.h │ ├── error.h │ ├── formatting.h │ ├── log.h │ ├── numeric.h │ ├── param_container.h │ ├── plog.h │ ├── progressbar.h │ ├── sorting.h │ ├── timer.h │ └── tools.h ├── kernels ├── CMakeLists.txt ├── ampere_gr.hpp ├── ampere_mink.hpp ├── ampere_sr.hpp ├── aux_fields_gr.hpp ├── currents_deposit.hpp ├── digital_filter.hpp ├── faraday_gr.hpp ├── faraday_mink.hpp ├── faraday_sr.hpp ├── fields_bcs.hpp ├── fields_to_phys.hpp ├── injectors.hpp ├── particle_moments.hpp ├── particle_pusher_gr.hpp ├── particle_pusher_sr.hpp ├── prtls_to_phys.hpp └── tests │ ├── CMakeLists.txt │ ├── ampere_mink.cpp │ ├── deposit.cpp │ ├── digital_filter.cpp │ ├── faraday_mink.cpp │ ├── fields_to_phys.cpp │ ├── gca_pusher.cpp │ ├── particle_moments.cpp │ ├── prtl_bc.cpp │ └── prtls_to_phys.cpp ├── metrics ├── CMakeLists.txt ├── kerr_schild.h ├── kerr_schild_0.h ├── metric_base.h ├── minkowski.h ├── qkerr_schild.h ├── qspherical.h ├── spherical.h └── tests │ ├── CMakeLists.txt │ ├── coord_trans.cpp │ ├── ks-qks.cpp │ ├── minkowski.cpp │ ├── sph-qsph.cpp │ ├── sr-cart-sph.cpp │ └── vec_trans.cpp └── output ├── CMakeLists.txt ├── fields.cpp ├── fields.h ├── particles.h ├── spectra.h ├── tests ├── CMakeLists.txt ├── fields.cpp ├── writer-mpi.cpp └── writer-nompi.cpp ├── utils ├── attr_writer.h ├── interpret_prompt.cpp └── interpret_prompt.h ├── write_attrs.cpp ├── writer.cpp └── writer.h /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: template for reporting an unexpected behavior or bugs 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **describe the bug** 11 | a clear and concise description of what the bug is 12 | 13 | **code version** 14 | ideally, the git hash which is shown both at compile time and printed during runtime to the `.info` file 15 | 16 | **compiler/library versions** 17 | versions of both host (gcc/clang) and gpu (cuda/rocm) compilers, version of hdf5/mpi (if applicable) and adios2/kokkos 18 | 19 | **cmake configuration command** 20 | which flags are being used by cmake to configure/compile the code? 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/problems-at-compile--runtime.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Problems at compile-/runtime 3 | about: report any issues or errors thrown when compiling/running the code 4 | title: "[ERROR | QUESTION]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **describe the issue** 11 | ideally, what are the steps to reproduce the error. at which stage does it occur (compilation, running, first timestep, etc.)? 12 | 13 | **code version** 14 | ideally, the git hash which is shown both at compile time and printed during runtime to the `.info` file 15 | 16 | **compiler/library versions** 17 | versions of both host (gcc/clang) and gpu (cuda/rocm) compilers, version of hdf5/mpi (if applicable) and adios2/kokkos 18 | 19 | **cmake configuration command** 20 | which flags are being used by cmake to configure/compile the code? 21 | 22 | **applicable files** 23 | if the issue occurs at runtime, attach the `.toml` input file, as well as `.diag` and `.info` files written during runtime. 24 | -------------------------------------------------------------------------------- /.github/workflows/actions.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**rc' 7 | - 'master' 8 | 9 | jobs: 10 | tests: 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | device: [amd-gpu, nvidia-gpu] 15 | precision: [double, single] 16 | exclude: 17 | - device: amd-gpu 18 | precision: double 19 | # my AMD GPUs doesn't support fp64 atomics : ( 20 | runs-on: [self-hosted, "${{ matrix.device }}"] 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v3.3.0 24 | - name: Configure 25 | run: | 26 | if [ "${{ matrix.device }}" = "nvidia-gpu" ]; then 27 | FLAGS="-D Kokkos_ENABLE_CUDA=ON" 28 | if [[ ! -z $(nvidia-smi | grep "V100") ]]; then 29 | FLAGS+=" -D Kokkos_ARCH_VOLTA70=ON" 30 | elif [[ ! -z $(nvidia-smi | grep "A100") ]]; then 31 | FLAGS+=" -D Kokkos_ARCH_AMPERE80=ON" 32 | else 33 | FLAGS+=" -D Kokkos_ARCH_AMPERE86=ON" 34 | fi 35 | elif [ "${{ matrix.device }}" = "amd-gpu" ]; then 36 | FLAGS="-D Kokkos_ENABLE_HIP=ON -D Kokkos_ARCH_AMD_GFX1100=ON" 37 | fi 38 | cmake -B build -D TESTS=ON -D output=ON -D precision=${{ matrix.precision }} $FLAGS 39 | - name: Compile 40 | run: | 41 | cmake --build build -j $(nproc) 42 | - name: Run tests 43 | run: | 44 | ctest --test-dir build --output-on-failure --verbose 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Filesystem specific 2 | .DS_Store 3 | 4 | # Compilation junk 5 | *.o 6 | build*/ 7 | bin/ 8 | compile_commands.json 9 | .cache/ 10 | 11 | # Python files 12 | *.ipynb 13 | __pycache__ 14 | *ipynb_checkpoints 15 | 16 | # Notation files 17 | *.cson 18 | 19 | # Temporary files 20 | *.swp 21 | *.ini 22 | *.tmp 23 | temp*/ 24 | logs/ 25 | *.log 26 | *.bak 27 | 28 | # Trash files 29 | .trash/ 30 | *~ 31 | 32 | .vscode/*.log 33 | 34 | .venv/ 35 | venv/ 36 | 37 | # Temporary media files 38 | *.jpg 39 | *.png 40 | *.mov 41 | *.mp4 42 | 43 | # Accidental files 44 | *.xc 45 | *.h5 46 | 47 | # VSCode files 48 | .vscode/c_cpp_properties.json 49 | .vscode/settings.json 50 | 51 | # CMake testing files 52 | Testing/ 53 | 54 | .schema.json 55 | *_old/ 56 | action-token 57 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "extern/toml11"] 2 | path = extern/toml11 3 | url = https://github.com/ToruNiina/toml11.git 4 | [submodule "extern/plog"] 5 | path = extern/plog 6 | url = https://github.com/SergiusTheBest/plog.git 7 | [submodule "extern/adios2"] 8 | path = extern/adios2 9 | url = https://github.com/ornladios/ADIOS2.git 10 | branch = master 11 | [submodule "extern/Kokkos"] 12 | path = extern/Kokkos 13 | url = https://github.com/kokkos/kokkos.git 14 | -------------------------------------------------------------------------------- /.vscode/.taplo.toml: -------------------------------------------------------------------------------- 1 | include = ["input.example.toml", "setups/**/*.toml"] 2 | exclude = [".taplo.toml"] 3 | 4 | [formatting] 5 | align_entries = true 6 | align_comments = true 7 | array_trailing_comma = true 8 | array_auto_expand = true 9 | array_auto_collapse = true 10 | compact_arrays = true 11 | compact_inline_tables = false 12 | inline_table_expand = true 13 | compact_entries = false 14 | column_width = 80 15 | indent_tables = true 16 | indent_entries = true 17 | indent_string = " " 18 | trailing_newline = true 19 | reorder_keys = false 20 | reorder_arrays = false 21 | allowed_blank_lines = 2 22 | crlf = false 23 | 24 | [schema] 25 | path = "./.schema.json" 26 | enabled = false 27 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.cpptools", 4 | "ms-python.python", 5 | "xaver.clang-format", 6 | "ms-vscode.cmake-tools", 7 | "tamasfe.even-better-toml", 8 | ] 9 | } -------------------------------------------------------------------------------- /.vscode/suppress_warnings.h: -------------------------------------------------------------------------------- 1 | #ifdef __INTELLISENSE__ 2 | # pragma diag_suppress 1758 3 | # pragma diag_suppress 1670 4 | # pragma diag_suppress 864 5 | # pragma diag_suppress 258 6 | # pragma diag_suppress 77 7 | # pragma diag_suppress 65 8 | # pragma diag_suppress 20 9 | # pragma diag_suppress 18 10 | #endif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2024, Princeton University (PU), and 4 | Princeton Plasma Physics Lab (PPPL). 5 | All rights reserved. 6 | 7 | Core developers (alphabetical order): 8 | * Alexander Chernoglazov 9 | * Benjamin Crinquand 10 | * Alisa Galishnikova 11 | * Hayk Hakobyan 12 | * Jens Mahlmann 13 | * Sasha Philippov 14 | * Arno Vanthieghem 15 | * Muni Zhou 16 | 17 | Redistribution and use in source and binary forms, with or without 18 | modification, are permitted provided that the following conditions are met: 19 | 20 | 1. Redistributions of source code must retain the above copyright notice, this 21 | list of conditions and the following disclaimer. 22 | 23 | 2. Redistributions in binary form must reproduce the above copyright notice, 24 | this list of conditions and the following disclaimer in the documentation 25 | and/or other materials provided with the distribution. 26 | 27 | 3. Neither the name of the copyright holder nor the names of its 28 | contributors may be used to endorse or promote products derived from 29 | this software without specific prior written permission. 30 | 31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 32 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 34 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 35 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 37 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 38 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 39 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `Entity` 2 | 3 | tl;dr: One particle-in-cell code to rule them all. 4 | 5 | `Entity` is an open-source coordinate-agnostic particle-in-cell (PIC) code written in C++17 specifically targeted to study plasma physics in relativistic astrophysical systems. The main algorithms of the code are written in covariant form, allowing to easily implement arbitrary grid geometries. The code is highly modular, and is written in the architecture-agnostic way using the [`Kokkos`](https://kokkos.org/kokkos-core-wiki/) performance portability library, allowing the code to efficiently use device parallelization on CPU and GPU architectures of different types. The multi-node parallelization is implemented using the `MPI` library, and the data output is done via the [`ADIOS2`](https://github.com/ornladios/ADIOS2) library which supports multiple output formats, including `HDF5` and `BP5`. 6 | 7 | `Entity` is part of the `Entity toolkit` framework, which also includes a Python library for fast and efficient data analysis and visualization of the simulation data: [`nt2py`](https://pypi.org/project/nt2py/). 8 | 9 | Our [detailed documentation](https://entity-toolkit.github.io/) includes everything you need to know to get started with using and/or contributing to the `Entity toolkit`. If you find bugs or issues, please feel free to add a GitHub issue or submit a pull request. Users with significant contributions to the code will be added to the list of developers, and assigned an emoji of their choice (important). 10 | 11 | [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) 12 | 13 | ## Core developers (alphabetical) 14 | 15 | 👀 __Yangyang Cai__ {[@StaticObserver](https://github.com/StaticObserver): GRPIC} 16 | 17 | 💁‍♂️ __Alexander Chernoglazov__ {[@SChernoglazov](https://github.com/SChernoglazov): PIC} 18 | 19 | 🍵 __Benjamin Crinquand__ {[@bcrinquand](https://github.com/bcrinquand): GRPIC, cubed-sphere} 20 | 21 | 🧋 __Alisa Galishnikova__ {[@alisagk](https://github.com/alisagk): GRPIC} 22 | 23 | ☕ __Hayk Hakobyan__ {[@haykh](https://github.com/haykh): framework, PIC, GRPIC, cubed-sphere} 24 | 25 | 🥔 __Jens Mahlmann__ {[@jmahlmann](https://github.com/jmahlmann): framework, MPI, cubed-sphere} 26 | 27 | 🐬 __Sasha Philippov__ {[@sashaph](https://github.com/sashaph): all-around} 28 | 29 | 🤷 __Arno Vanthieghem__ {[@vanthieg](https://github.com/vanthieg): framework, PIC} 30 | 31 | 😺 __Muni Zhou__ {[@munizhou](https://github.com/munizhou): PIC} 32 | 33 | ## Branch policy 34 | 35 | Master branch contains the latest stable version of the code which has already been released. Development on the core is done on branches starting with `dev/`, while fixing bugs is done in branches that start with `bug/`. User-specific modifications (i.e., new problem generators plus perhaps minor corrections in the core) are done on branches starting with `pgen/`. Before merging to the master branch, all the branches must first be merged to the latest release-candidate branch, which ends with `rc`, via a pull request. After which, when all the release goals are met, the `rc` branch is merged to the master and released as a new stable version. Stale branches will be archived with a tag starting with `archive/` (can still be accessed via the "Tags" tab) and removed. 36 | -------------------------------------------------------------------------------- /TASKLIST.md: -------------------------------------------------------------------------------- 1 | # v0.8 2 | 3 | - [x] thick layer boundary for the monopole 4 | - [x] test with filters 5 | - [x] add diagnostics for nans in fields and particles 6 | - [x] add gravitationally bound atmosphere 7 | - [x] rewrite UniformInjector with global random pool 8 | - [x] add particle deletion routine 9 | - [x] make more user-friendly and understandable boundary conditions 10 | - [x] refine output 11 | - [x] add different moments (momX, momY, momZ, meanGamma) 12 | - [x] add charge 13 | - [x] add per species densities 14 | 15 | # v0.9 16 | 17 | - [x] add current deposit/filtering for GR 18 | - [x] add moments for GR 19 | - [x] add Maxwellian for GR 20 | 21 | # v1.0.0 22 | 23 | - [x] particle output 24 | - [x] BUG in MPI particles/currents 25 | 26 | # v1.1.0 27 | 28 | - [ ] custom boundary conditions for particles and fields 29 | - [ ] transfer GR from v0.9 30 | 31 | ### Performance improvements to try 32 | 33 | - [ ] removing temporary variables in interpolation 34 | - [ ] passing by value vs const ref in metric 35 | - [ ] return physical coords one-by-one instead of by passing full vector 36 | -------------------------------------------------------------------------------- /cmake/MPIConfig.cmake: -------------------------------------------------------------------------------- 1 | find_package(MPI REQUIRED) 2 | include_directories(${MPI_CXX_INCLUDE_PATH}) 3 | add_compile_options("-D MPI_ENABLED") -------------------------------------------------------------------------------- /cmake/adios2Config.cmake: -------------------------------------------------------------------------------- 1 | # ----------------------------- Adios2 settings ---------------------------- # 2 | set(ADIOS2_BUILD_EXAMPLES OFF CACHE BOOL "Build ADIOS2 examples") 3 | 4 | # Language support 5 | set(ADIOS2_USE_Python OFF CACHE BOOL "Use Python for ADIOS2") 6 | set(ADIOS2_USE_Fortran OFF CACHE BOOL "Use Fortran for ADIOS2") 7 | 8 | # Format/compression support 9 | set(ADIOS2_USE_ZeroMQ OFF CACHE BOOL "Use ZeroMQ for ADIOS2") 10 | 11 | set(ADIOS2_USE_MPI ${mpi} CACHE BOOL "Use MPI for ADIOS2") 12 | 13 | set(ADIOS2_USE_CUDA OFF CACHE BOOL "Use CUDA for ADIOS2") 14 | 15 | add_compile_options("-D OUTPUT_ENABLED") 16 | -------------------------------------------------------------------------------- /cmake/config.cmake: -------------------------------------------------------------------------------- 1 | # -------------------------------- Precision ------------------------------- # 2 | function(set_precision precision_name) 3 | list(FIND precisions ${precision_name} PRECISION_FOUND) 4 | 5 | if(${PRECISION_FOUND} EQUAL -1) 6 | message(FATAL_ERROR "Invalid precision: ${precision_name}\nValid options are: ${precisions}") 7 | endif() 8 | 9 | if(${precision_name} STREQUAL "single") 10 | add_compile_options("-DSINGLE_PRECISION") 11 | endif() 12 | endfunction() 13 | 14 | # ---------------------------- Problem generator --------------------------- # 15 | function(set_problem_generator pgen_name) 16 | file(GLOB_RECURSE PGENS "${CMAKE_CURRENT_SOURCE_DIR}/setups/**/pgen.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/setups/pgen.hpp") 17 | foreach(PGEN ${PGENS}) 18 | get_filename_component(PGEN_NAME ${PGEN} DIRECTORY) 19 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/setups/" "" PGEN_NAME ${PGEN_NAME}) 20 | string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/setups" "" PGEN_NAME ${PGEN_NAME}) 21 | list(APPEND PGEN_NAMES ${PGEN_NAME}) 22 | endforeach() 23 | list(FIND PGEN_NAMES ${pgen_name} PGEN_FOUND) 24 | if(NOT ${pgen_name} STREQUAL "." AND ${PGEN_FOUND} EQUAL -1) 25 | message(FATAL_ERROR "Invalid problem generator: ${pgen_name}\nValid options are: ${PGEN_NAMES}") 26 | endif() 27 | set(PGEN ${pgen_name} PARENT_SCOPE) 28 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/setups/${pgen_name}) 29 | set(PGEN_FOUND TRUE PARENT_SCOPE) 30 | set(problem_generators ${PGEN_NAMES} PARENT_SCOPE) 31 | endfunction() 32 | -------------------------------------------------------------------------------- /cmake/defaults.cmake: -------------------------------------------------------------------------------- 1 | # ----------------------------- Defaults ---------------------------------- # 2 | if(DEFINED ENV{Entity_ENABLE_DEBUG}) 3 | set(default_debug $ENV{Entity_ENABLE_DEBUG} CACHE INTERNAL "Default flag for debug mode") 4 | else() 5 | set(default_debug OFF CACHE INTERNAL "Default flag for debug mode") 6 | endif() 7 | 8 | set_property(CACHE default_debug PROPERTY TYPE BOOL) 9 | 10 | set(default_engine "pic" CACHE INTERNAL "Default engine") 11 | set(default_precision "single" CACHE INTERNAL "Default precision") 12 | set(default_pgen "." CACHE INTERNAL "Default problem generator") 13 | set(default_sr_metric "minkowski" CACHE INTERNAL "Default SR metric") 14 | set(default_gr_metric "kerr_schild" CACHE INTERNAL "Default GR metric") 15 | 16 | if(DEFINED ENV{Entity_ENABLE_OUTPUT}) 17 | set(default_output $ENV{Entity_ENABLE_OUTPUT} CACHE INTERNAL "Default flag for output") 18 | else() 19 | set(default_output OFF CACHE INTERNAL "Default flag for output") 20 | endif() 21 | 22 | set_property(CACHE default_output PROPERTY TYPE BOOL) 23 | 24 | if(DEFINED ENV{Entity_ENABLE_GUI}) 25 | set(default_gui $ENV{Entity_ENABLE_GUI} CACHE INTERNAL "Default flag for GUI") 26 | else() 27 | set(default_gui OFF CACHE INTERNAL "Default flag for GUI") 28 | endif() 29 | 30 | set_property(CACHE default_gui PROPERTY TYPE BOOL) 31 | 32 | if(DEFINED ENV{Kokkos_ENABLE_CUDA}) 33 | set(default_KOKKOS_ENABLE_CUDA $ENV{Kokkos_ENABLE_CUDA} CACHE INTERNAL "Default flag for CUDA") 34 | else() 35 | set(default_KOKKOS_ENABLE_CUDA OFF CACHE INTERNAL "Default flag for CUDA") 36 | endif() 37 | 38 | set_property(CACHE default_KOKKOS_ENABLE_CUDA PROPERTY TYPE BOOL) 39 | 40 | if(DEFINED ENV{Kokkos_ENABLE_HIP}) 41 | set(default_KOKKOS_ENABLE_HIP $ENV{Kokkos_ENABLE_HIP} CACHE INTERNAL "Default flag for HIP") 42 | else() 43 | set(default_KOKKOS_ENABLE_HIP OFF CACHE INTERNAL "Default flag for HIP") 44 | endif() 45 | 46 | set_property(CACHE default_KOKKOS_ENABLE_HIP PROPERTY TYPE BOOL) 47 | 48 | if(DEFINED ENV{Kokkos_ENABLE_OPENMP}) 49 | set(default_KOKKOS_ENABLE_OPENMP $ENV{Kokkos_ENABLE_OPENMP} CACHE INTERNAL "Default flag for OpenMP") 50 | else() 51 | set(default_KOKKOS_ENABLE_OPENMP OFF CACHE INTERNAL "Default flag for OpenMP") 52 | endif() 53 | 54 | set_property(CACHE default_KOKKOS_ENABLE_OPENMP PROPERTY TYPE BOOL) 55 | 56 | if(DEFINED ENV{Entity_ENABLE_MPI}) 57 | set(default_mpi $ENV{Entity_ENABLE_MPI} CACHE INTERNAL "Default flag for MPI") 58 | else() 59 | set(default_mpi OFF CACHE INTERNAL "Default flag for MPI") 60 | endif() 61 | 62 | set_property(CACHE default_mpi PROPERTY TYPE BOOL) 63 | -------------------------------------------------------------------------------- /cmake/kokkosConfig.cmake: -------------------------------------------------------------------------------- 1 | # ----------------------------- Kokkos settings ---------------------------- # 2 | if(${DEBUG} STREQUAL "OFF") 3 | set(Kokkos_ENABLE_AGGRESSIVE_VECTORIZATION ON CACHE BOOL "Kokkos aggressive vectorization") 4 | set(Kokkos_ENABLE_COMPILER_WARNINGS OFF CACHE BOOL "Kokkos compiler warnings") 5 | set(Kokkos_ENABLE_DEBUG OFF CACHE BOOL "Kokkos debug") 6 | set(Kokkos_ENABLE_DEBUG_BOUNDS_CHECK OFF CACHE BOOL "Kokkos debug bounds check") 7 | else() 8 | set(Kokkos_ENABLE_AGGRESSIVE_VECTORIZATION OFF CACHE BOOL "Kokkos aggressive vectorization") 9 | set(Kokkos_ENABLE_COMPILER_WARNINGS ON CACHE BOOL "Kokkos compiler warnings") 10 | set(Kokkos_ENABLE_DEBUG ON CACHE BOOL "Kokkos debug") 11 | set(Kokkos_ENABLE_DEBUG_BOUNDS_CHECK ON CACHE BOOL "Kokkos debug bounds check") 12 | endif() 13 | 14 | set(Kokkos_ENABLE_HIP ${default_KOKKOS_ENABLE_HIP} CACHE BOOL "Enable HIP") 15 | set(Kokkos_ENABLE_CUDA ${default_KOKKOS_ENABLE_CUDA} CACHE BOOL "Enable CUDA") 16 | set(Kokkos_ENABLE_OPENMP ${default_KOKKOS_ENABLE_OPENMP} CACHE BOOL "Enable OpenMP") 17 | 18 | # set memory space 19 | if(${Kokkos_ENABLE_CUDA}) 20 | add_compile_definitions(CUDA_ENABLED) 21 | set(ACC_MEM_SPACE Kokkos::CudaSpace) 22 | elseif(${Kokkos_ENABLE_HIP}) 23 | add_compile_definitions(HIP_ENABLED) 24 | set(ACC_MEM_SPACE Kokkos::HIPSpace) 25 | else() 26 | set(ACC_MEM_SPACE Kokkos::HostSpace) 27 | endif() 28 | 29 | set(HOST_MEM_SPACE Kokkos::HostSpace) 30 | 31 | # set execution space 32 | if(${Kokkos_ENABLE_CUDA}) 33 | set(ACC_EXE_SPACE Kokkos::Cuda) 34 | elseif(${Kokkos_ENABLE_HIP}) 35 | set(ACC_EXE_SPACE Kokkos::HIP) 36 | elseif(${Kokkos_ENABLE_OPENMP}) 37 | set(ACC_EXE_SPACE Kokkos::OpenMP) 38 | else() 39 | set(ACC_EXE_SPACE Kokkos::Serial) 40 | endif() 41 | 42 | if(${Kokkos_ENABLE_OPENMP}) 43 | set(HOST_EXE_SPACE Kokkos::OpenMP) 44 | else() 45 | set(HOST_EXE_SPACE Kokkos::Serial) 46 | endif() 47 | 48 | add_compile_options("-D AccelExeSpace=${ACC_EXE_SPACE}") 49 | add_compile_options("-D AccelMemSpace=${ACC_MEM_SPACE}") 50 | add_compile_options("-D HostExeSpace=${HOST_EXE_SPACE}") 51 | add_compile_options("-D HostMemSpace=${HOST_MEM_SPACE}") 52 | 53 | if(${BUILD_TESTING} STREQUAL "OFF") 54 | set(Kokkos_ENABLE_TESTS OFF CACHE BOOL "Kokkos tests") 55 | else() 56 | set(Kokkos_ENABLE_TESTS ON CACHE BOOL "Kokkos tests") 57 | endif() 58 | -------------------------------------------------------------------------------- /cmake/styling.cmake: -------------------------------------------------------------------------------- 1 | if(NOT WIN32) 2 | string(ASCII 27 Esc) 3 | set(ColorReset "${Esc}[m") 4 | set(ColourBold "${Esc}[1m") 5 | set(Underline "${Esc}[4m") 6 | set(Red "${Esc}[31m") 7 | set(Green "${Esc}[32m") 8 | set(Yellow "${Esc}[33m") 9 | set(Blue "${Esc}[34m") 10 | set(Magenta "${Esc}[35m") 11 | set(Cyan "${Esc}[36m") 12 | set(White "${Esc}[37m") 13 | set(BoldRed "${Esc}[1;31m") 14 | set(BoldGreen "${Esc}[1;32m") 15 | set(BoldYellow "${Esc}[1;33m") 16 | set(BoldBlue "${Esc}[1;34m") 17 | set(BoldMagenta "${Esc}[1;35m") 18 | set(BoldCyan "${Esc}[1;36m") 19 | set(BoldWhite "${Esc}[1;37m") 20 | set(DarkGray "${Esc}[1;90m") 21 | set(Dim "${Esc}[2m") 22 | set(StrikeBegin "${Esc}[9m") 23 | set(StrikeEnd "${Esc}[0m") 24 | endif() 25 | 26 | # message("This is normal") 27 | # message("${Red}This is Red${ColorReset}") 28 | # message("${Green}This is Green${ColorReset}") 29 | # message("${Yellow}This is Yellow${ColorReset}") 30 | # message("${Blue}This is Blue${ColorReset}") 31 | # message("${Magenta}This is Magenta${ColorReset}") 32 | # message("${Cyan}This is Cyan${ColorReset}") 33 | # message("${White}This is White${ColorReset}") 34 | # message("${BoldRed}This is BoldRed${ColorReset}") 35 | # message("${BoldGreen}This is BoldGreen${ColorReset}") 36 | # message("${BoldYellow}This is BoldYellow${ColorReset}") 37 | # message("${BoldBlue}This is BoldBlue${ColorReset}") 38 | # message("${BoldMagenta}This is BoldMagenta${ColorReset}") 39 | # message("${BoldCyan}This is BoldCyan${ColorReset}") 40 | # message("${BoldWhite}This is BoldWhite\n\n${ColorReset}") 41 | 42 | # message() -------------------------------------------------------------------------------- /cmake/tests.cmake: -------------------------------------------------------------------------------- 1 | include(CTest) 2 | enable_testing() 3 | 4 | set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) 5 | 6 | add_subdirectory(${SRC_DIR}/global ${CMAKE_CURRENT_BINARY_DIR}/global) 7 | add_subdirectory(${SRC_DIR}/metrics ${CMAKE_CURRENT_BINARY_DIR}/metrics) 8 | add_subdirectory(${SRC_DIR}/kernels ${CMAKE_CURRENT_BINARY_DIR}/kernels) 9 | add_subdirectory(${SRC_DIR}/archetypes ${CMAKE_CURRENT_BINARY_DIR}/archetypes) 10 | add_subdirectory(${SRC_DIR}/framework ${CMAKE_CURRENT_BINARY_DIR}/framework) 11 | if (${output}) 12 | add_subdirectory(${SRC_DIR}/output ${CMAKE_CURRENT_BINARY_DIR}/output) 13 | endif() 14 | 15 | if (${mpi}) 16 | # tests with mpi 17 | if (${output}) 18 | add_subdirectory(${SRC_DIR}/output/tests ${CMAKE_CURRENT_BINARY_DIR}/output/tests) 19 | add_subdirectory(${SRC_DIR}/framework/tests ${CMAKE_CURRENT_BINARY_DIR}/framework/tests) 20 | endif() 21 | else() 22 | # tests without mpi 23 | add_subdirectory(${SRC_DIR}/global/tests ${CMAKE_CURRENT_BINARY_DIR}/global/tests) 24 | add_subdirectory(${SRC_DIR}/metrics/tests ${CMAKE_CURRENT_BINARY_DIR}/metrics/tests) 25 | add_subdirectory(${SRC_DIR}/kernels/tests ${CMAKE_CURRENT_BINARY_DIR}/kernels/tests) 26 | add_subdirectory(${SRC_DIR}/archetypes/tests ${CMAKE_CURRENT_BINARY_DIR}/archetypes/tests) 27 | add_subdirectory(${SRC_DIR}/framework/tests ${CMAKE_CURRENT_BINARY_DIR}/framework/tests) 28 | if (${output}) 29 | add_subdirectory(${SRC_DIR}/output/tests ${CMAKE_CURRENT_BINARY_DIR}/output/tests) 30 | endif() 31 | endif() 32 | -------------------------------------------------------------------------------- /conda-entity-nompi.sh: -------------------------------------------------------------------------------- 1 | conda create -n entity-nompi &&\ 2 | conda activate entity-nompi &&\ 3 | conda install "conda-forge::gxx[version='>=9,<10']" &&\ 4 | conda install conda-forge::hdf5 &&\ 5 | conda install conda-forge::adios2 &&\ 6 | conda install pip &&\ 7 | pip install nt2py 8 | 9 | -------------------------------------------------------------------------------- /dev/Dockerfile.common: -------------------------------------------------------------------------------- 1 | ARG DEBIAN_FRONTEND=noninteractive 2 | ENV DISPLAY=host.docker.internal:0.0 3 | 4 | # upgrade 5 | RUN apt-get update && apt-get upgrade -y 6 | 7 | # cmake & build tools 8 | RUN apt-get remove -y --purge cmake && \ 9 | apt-get install -y wget build-essential && \ 10 | wget "https://github.com/Kitware/CMake/releases/download/v3.29.6/cmake-3.29.6-linux-x86_64.tar.gz" -P /opt && \ 11 | tar xvf /opt/cmake-3.29.6-linux-x86_64.tar.gz -C /opt && \ 12 | rm /opt/cmake-3.29.6-linux-x86_64.tar.gz 13 | ENV PATH=/opt/cmake-3.29.6-linux-x86_64/bin:$PATH 14 | 15 | # adios2 16 | RUN apt-get update && apt-get install -y git libhdf5-dev && \ 17 | git clone https://github.com/ornladios/ADIOS2.git /opt/adios2-src && \ 18 | cd /opt/adios2-src && \ 19 | cmake -B build \ 20 | -D CMAKE_CXX_STANDARD=17 \ 21 | -D CMAKE_CXX_EXTENSIONS=OFF \ 22 | -D CMAKE_POSITION_INDEPENDENT_CODE=TRUE \ 23 | -D BUILD_SHARED_LIBS=ON \ 24 | -D ADIOS2_USE_HDF5=ON \ 25 | -D ADIOS2_USE_Python=OFF \ 26 | -D ADIOS2_USE_Fortran=OFF \ 27 | -D ADIOS2_USE_ZeroMQ=OFF \ 28 | -D BUILD_TESTING=OFF \ 29 | -D ADIOS2_BUILD_EXAMPLES=OFF \ 30 | -D ADIOS2_USE_MPI=OFF \ 31 | -D ADIOS2_HAVE_HDF5_VOL=OFF \ 32 | -D CMAKE_INSTALL_PREFIX=/opt/adios2 && \ 33 | cmake --build build -j && \ 34 | cmake --install build && \ 35 | rm -rf /opt/adios2-src 36 | ENV ADIOS2_DIR=/opt/adios2 37 | ENV HDF5_ROOT=/usr 38 | 39 | # other packages + python 40 | RUN apt-get update && \ 41 | apt-get install -y bc gpg curl ssh vim emacs bat fzf ffmpeg hdf5-tools software-properties-common && \ 42 | add-apt-repository ppa:deadsnakes/ppa && \ 43 | apt-get update && apt-get install -y python3.12-dev python3.12-venv 44 | 45 | # eza 46 | RUN mkdir -p /etc/apt/keyrings && \ 47 | wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | gpg --dearmor -o /etc/apt/keyrings/gierens.gpg && \ 48 | echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | tee /etc/apt/sources.list.d/gierens.list && \ 49 | chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list && \ 50 | apt-get update && apt-get install -y eza 51 | 52 | # cleanup 53 | RUN apt-get clean && \ 54 | apt-get autoclean && \ 55 | apt-get autoremove -y && \ 56 | rm -rf /var/lib/cache/* && \ 57 | rm -rf /var/lib/log/* && \ 58 | rm -rf /var/lib/apt/lists/* 59 | 60 | # python 61 | RUN ln -s $(which python3.12) /bin/python && \ 62 | python -m venv /opt/venv && \ 63 | /opt/venv/bin/pip install --upgrade pip && \ 64 | /opt/venv/bin/pip install black numpy myplotlib nt2py jupyterlab ipykernel 65 | ENV VIRTUAL_ENV=/opt/venv 66 | 67 | # user environment 68 | ARG HOME=/root 69 | WORKDIR $HOME 70 | RUN echo "alias ls='eza -a --sort=type'" >> $HOME/.bashrc && \ 71 | echo "alias ll='eza -a --long --header --sort=type --time-style=long-iso'" >> $HOME/.bashrc && \ 72 | echo "alias cat='batcat -pp'" >> $HOME/.bashrc 73 | 74 | RUN curl -sS https://starship.rs/install.sh | sh -s -- --yes && \ 75 | echo eval "\$(starship init bash)" >> $HOME/.bashrc && \ 76 | mkdir -p $HOME/.config && \ 77 | starship preset pure-preset -o $HOME/.config/starship.toml && \ 78 | sed -i 's/$python\\//g' $HOME/.config/starship.toml 79 | ENV STARSHIP_CONFIG=$HOME/.config/starship.toml 80 | 81 | ENV PATH=/opt/adios2/bin:/opt/venv/bin:$PATH 82 | -------------------------------------------------------------------------------- /dev/Dockerfile.cuda: -------------------------------------------------------------------------------- 1 | # syntax = devthefuture/dockerfile-x 2 | 3 | FROM nvidia/cuda:12.2.2-devel-ubuntu22.04 4 | 5 | ENV CUDA_HOME=/usr/local/cuda 6 | ENV PATH=/usr/local/cuda/bin:$PATH 7 | 8 | INCLUDE Dockerfile.common 9 | 10 | # welcome message 11 | COPY welcome.cuda /root/.welcome.cuda 12 | RUN echo '/usr/bin/bash /root/.welcome.cuda' | tee -a /etc/profile.d/welcome.sh 13 | 14 | ENTRYPOINT ["/usr/bin/bash", "-l"] 15 | -------------------------------------------------------------------------------- /dev/Dockerfile.rocm: -------------------------------------------------------------------------------- 1 | # syntax = devthefuture/dockerfile-x 2 | 3 | FROM rocm/rocm-terminal:latest 4 | 5 | USER root 6 | ENV PATH=/opt/rocm/bin:$PATH 7 | 8 | INCLUDE Dockerfile.common 9 | 10 | # additional ROCm packages 11 | RUN git clone -b release/rocm-rel-6.1.1.1 https://github.com/ROCm/rocThrust.git /opt/rocthrust-src && \ 12 | git clone -b release/rocm-rel-6.1.00.36 https://github.com/ROCm/rocPRIM.git /opt/rocprim-src && \ 13 | cd /opt/rocthrust-src && ./install --install && \ 14 | cd /opt/rocprim-src && ./install --install && \ 15 | rm -rf /opt/rocthrust-src /opt/rocprim-src 16 | 17 | ENV CMAKE_PREFIX_PATH=/opt/rocm 18 | ENV CC=hipcc 19 | ENV CXX=hipcc 20 | 21 | # welcome message 22 | COPY welcome.rocm /root/.welcome.rocm 23 | RUN echo '/usr/bin/bash /root/.welcome.rocm' | tee -a /etc/profile.d/welcome.sh 24 | 25 | ENTRYPOINT ["/usr/bin/bash", "-l"] 26 | -------------------------------------------------------------------------------- /dev/runners/Dockerfile.runner.cuda: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:12.5.0-devel-ubuntu22.04 2 | 3 | ARG DEBIAN_FRONTEND=noninteractive 4 | ENV DISPLAY=host.docker.internal:0.0 5 | 6 | # upgrade 7 | RUN apt-get update && apt-get upgrade -y 8 | 9 | # cmake & build tools 10 | RUN apt-get remove -y --purge cmake && \ 11 | apt-get install -y sudo wget curl build-essential && \ 12 | wget "https://github.com/Kitware/CMake/releases/download/v3.29.6/cmake-3.29.6-linux-x86_64.tar.gz" -P /opt && \ 13 | tar xvf /opt/cmake-3.29.6-linux-x86_64.tar.gz -C /opt && \ 14 | rm /opt/cmake-3.29.6-linux-x86_64.tar.gz 15 | ENV PATH=/opt/cmake-3.29.6-linux-x86_64/bin:$PATH 16 | 17 | # adios2 18 | RUN apt-get update && apt-get install -y git libhdf5-dev && \ 19 | git clone https://github.com/ornladios/ADIOS2.git /opt/adios2-src && \ 20 | cd /opt/adios2-src && \ 21 | cmake -B build \ 22 | -D CMAKE_CXX_STANDARD=17 \ 23 | -D CMAKE_CXX_EXTENSIONS=OFF \ 24 | -D CMAKE_POSITION_INDEPENDENT_CODE=TRUE \ 25 | -D BUILD_SHARED_LIBS=ON \ 26 | -D ADIOS2_USE_HDF5=ON \ 27 | -D ADIOS2_USE_Python=OFF \ 28 | -D ADIOS2_USE_Fortran=OFF \ 29 | -D ADIOS2_USE_ZeroMQ=OFF \ 30 | -D BUILD_TESTING=OFF \ 31 | -D ADIOS2_BUILD_EXAMPLES=OFF \ 32 | -D ADIOS2_USE_MPI=OFF \ 33 | -D ADIOS2_HAVE_HDF5_VOL=OFF \ 34 | -D CMAKE_INSTALL_PREFIX=/opt/adios2 && \ 35 | cmake --build build -j && \ 36 | cmake --install build && \ 37 | rm -rf /opt/adios2-src 38 | 39 | ENV CUDA_HOME=/usr/local/cuda 40 | ENV HDF5_ROOT=/usr 41 | ENV ADIOS2_DIR=/opt/adios2 42 | ENV PATH=/opt/adios2/bin:/usr/local/cuda/bin:$PATH 43 | 44 | # cleanup 45 | RUN apt-get clean && \ 46 | apt-get autoclean && \ 47 | apt-get autoremove -y && \ 48 | rm -rf /var/lib/cache/* && \ 49 | rm -rf /var/lib/log/* && \ 50 | rm -rf /var/lib/apt/lists/* 51 | 52 | ARG USER=runner 53 | RUN useradd -ms /usr/bin/zsh $USER && \ 54 | usermod -aG sudo $USER && \ 55 | echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers 56 | 57 | USER $USER 58 | ARG HOME=/home/$USER 59 | WORKDIR $HOME 60 | 61 | # gh runner 62 | RUN mkdir actions-runner 63 | WORKDIR $HOME/actions-runner 64 | 65 | RUN --mount=type=secret,id=ghtoken \ 66 | curl -o actions-runner-linux-x64-2.317.0.tar.gz \ 67 | -L https://github.com/actions/runner/releases/download/v2.317.0/actions-runner-linux-x64-2.317.0.tar.gz && \ 68 | tar xzf ./actions-runner-linux-x64-2.317.0.tar.gz && \ 69 | sudo ./bin/installdependencies.sh && \ 70 | ./config.sh --url https://github.com/entity-toolkit/entity --token "$(sudo cat /run/secrets/ghtoken)" --labels nvidia-gpu 71 | 72 | ENTRYPOINT ["./run.sh"] 73 | -------------------------------------------------------------------------------- /dev/runners/Dockerfile.runner.rocm: -------------------------------------------------------------------------------- 1 | FROM rocm/rocm-terminal:latest 2 | 3 | USER root 4 | ENV PATH=/opt/rocm/bin:$PATH 5 | 6 | ARG DEBIAN_FRONTEND=noninteractive 7 | ENV DISPLAY=host.docker.internal:0.0 8 | 9 | # upgrade 10 | RUN apt-get update && apt-get upgrade -y 11 | 12 | # cmake & build tools 13 | RUN apt-get remove -y --purge cmake && \ 14 | apt-get install -y sudo wget curl build-essential && \ 15 | wget "https://github.com/Kitware/CMake/releases/download/v3.29.6/cmake-3.29.6-linux-x86_64.tar.gz" -P /opt && \ 16 | tar xvf /opt/cmake-3.29.6-linux-x86_64.tar.gz -C /opt && \ 17 | rm /opt/cmake-3.29.6-linux-x86_64.tar.gz 18 | ENV PATH=/opt/cmake-3.29.6-linux-x86_64/bin:$PATH 19 | 20 | # adios2 21 | RUN apt-get update && apt-get install -y git libhdf5-dev && \ 22 | git clone https://github.com/ornladios/ADIOS2.git /opt/adios2-src && \ 23 | cd /opt/adios2-src && \ 24 | cmake -B build \ 25 | -D CMAKE_CXX_STANDARD=17 \ 26 | -D CMAKE_CXX_EXTENSIONS=OFF \ 27 | -D CMAKE_POSITION_INDEPENDENT_CODE=TRUE \ 28 | -D BUILD_SHARED_LIBS=ON \ 29 | -D ADIOS2_USE_HDF5=ON \ 30 | -D ADIOS2_USE_Python=OFF \ 31 | -D ADIOS2_USE_Fortran=OFF \ 32 | -D ADIOS2_USE_ZeroMQ=OFF \ 33 | -D BUILD_TESTING=OFF \ 34 | -D ADIOS2_BUILD_EXAMPLES=OFF \ 35 | -D ADIOS2_USE_MPI=OFF \ 36 | -D ADIOS2_HAVE_HDF5_VOL=OFF \ 37 | -D CMAKE_INSTALL_PREFIX=/opt/adios2 && \ 38 | cmake --build build -j && \ 39 | cmake --install build && \ 40 | rm -rf /opt/adios2-src 41 | 42 | ENV HDF5_ROOT=/usr 43 | ENV ADIOS2_DIR=/opt/adios2 44 | ENV PATH=/opt/adios2/bin:$PATH 45 | 46 | # additional ROCm packages 47 | RUN git clone -b release/rocm-rel-6.1.1.1 https://github.com/ROCm/rocThrust.git /opt/rocthrust-src && \ 48 | git clone -b release/rocm-rel-6.1.00.36 https://github.com/ROCm/rocPRIM.git /opt/rocprim-src && \ 49 | cd /opt/rocthrust-src && ./install --install && \ 50 | cd /opt/rocprim-src && ./install --install && \ 51 | rm -rf /opt/rocthrust-src /opt/rocprim-src 52 | 53 | ENV CMAKE_PREFIX_PATH=/opt/rocm 54 | ENV CC=hipcc 55 | ENV CXX=hipcc 56 | 57 | # cleanup 58 | RUN apt-get clean && \ 59 | apt-get autoclean && \ 60 | apt-get autoremove -y && \ 61 | rm -rf /var/lib/cache/* && \ 62 | rm -rf /var/lib/log/* && \ 63 | rm -rf /var/lib/apt/lists/* 64 | 65 | ARG USER=runner 66 | RUN useradd -ms /usr/bin/zsh $USER && \ 67 | usermod -aG sudo $USER && \ 68 | echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers 69 | 70 | USER $USER 71 | ARG HOME=/home/$USER 72 | WORKDIR $HOME 73 | 74 | # gh runner 75 | ARG RUNNER_VERSION=2.317.0 76 | RUN mkdir actions-runner 77 | WORKDIR $HOME/actions-runner 78 | 79 | RUN curl -o actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \ 80 | -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz && \ 81 | tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz && \ 82 | sudo ./bin/installdependencies.sh 83 | 84 | ADD start.sh start.sh 85 | RUN sudo chown $USER:$USER start.sh && \ 86 | sudo chmod +x start.sh 87 | 88 | ENTRYPOINT ["./start.sh"] 89 | -------------------------------------------------------------------------------- /dev/runners/README.md: -------------------------------------------------------------------------------- 1 | ## Self-hosted runners 2 | 3 | GitHub allows to listen to repository changes and run the so-called "actions" (e.g., tests) if a particular event has been triggered (e.g., a pull request has been created). To test Entity on GPUs, we provide Docker runner images, with all the proper compilers already preinstalled, which can fetch the actions directly from GitHub and run them within the container environment. 4 | 5 | To do that, one needs to create an image with the corresponding `Dockerfile`, and then launch a Docker container which will run in the background, listening to commands and running any actions forwarded from the GitHub. 6 | 7 | First, you will need to obtain a runner token from the Entity GitHub repo, by going to Settings -> Actions -> Runners -> New self-hosted runner. Copy the token to use it later. The images differ slightly from the type of runner. 8 | 9 | ### NVIDIA GPUs 10 | 11 | ```sh 12 | docker build -t ghrunner:nvidia -f Dockerfile.runner.cuda . 13 | docker run -e TOKEN= -e LABEL=nvidia-gpu --runtime=nvidia --gpus=all -dt ghrunner:nvidia 14 | ``` 15 | 16 | ### AMD GPUs 17 | 18 | ```sh 19 | docker build -t ghrunner:amd -f Dockerfile.runner.rocm . 20 | docker run -e TOKEN= -e LABEL=amd-gpu --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video -dt ghrunner:amd 21 | ``` 22 | -------------------------------------------------------------------------------- /dev/runners/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./config.sh --unattended --url https://github.com/entity-toolkit/entity --token ${TOKEN} --labels ${LABEL} 4 | 5 | if [[ ${LABEL} == "amd-gpu" ]]; then 6 | echo "AMD GPU runner detected" 7 | export HSA_OVERRIDE_GFX_VERSION=11.0.0 HIP_VISIBLE_DEVICES=0 ROCR_VISIBLE_DEVICES=0 8 | else 9 | echo "Non-AMD runner" 10 | fi 11 | 12 | cleanup() { 13 | echo "Removing runner..." 14 | ./config.sh remove --unattended --token ${TOKEN} 15 | } 16 | 17 | trap 'cleanup; exit 130' INT 18 | trap 'cleanup; exit 143' TERM 19 | 20 | ./run.sh & 21 | wait $! 22 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | x-common-config: &common-config 2 | stdin_open: true 3 | tty: true 4 | ports: 5 | - "8080:8080" 6 | volumes: 7 | - type: bind 8 | source: . 9 | target: /root/entity/ 10 | 11 | x-cuda-base: &cuda-base 12 | image: morninbru/entity:cuda 13 | 14 | x-rocm-base: &rocm-base 15 | image: morninbru/entity:rocm 16 | 17 | services: 18 | entity-cuda-compilers: 19 | container_name: entity_cuda_compilers 20 | <<: [*cuda-base, *common-config] 21 | entity-cuda: 22 | container_name: entity_cuda 23 | runtime: nvidia 24 | environment: 25 | - NVIDIA_VISIBLE_DEVICES=all 26 | <<: [*cuda-base, *common-config] 27 | entity-rocm-compilers: 28 | container_name: entity_rocm_compilers 29 | <<: [*common-config, *rocm-base] 30 | entity-rocm: 31 | container_name: entity_rocm 32 | devices: 33 | - "/dev/kfd" 34 | - "/dev/dri" 35 | security_opt: 36 | - seccomp:unconfined 37 | <<: [*common-config, *rocm-base] 38 | -------------------------------------------------------------------------------- /legacy/Nttiny.mk: -------------------------------------------------------------------------------- 1 | # to compile visualization app 2 | # 3 | COMPILER := ${HOST_CXX} 4 | VIS_TARGET := ${BIN_DIR}/vis.exec 5 | BUILD_VIS_DIR := $(subst ${ROOT_DIR}/,,${VIS_DIR}) 6 | 7 | VIS_SRC := ${VIS_DIR}/nttiny.cpp 8 | VIS_OBJ := $(subst ${VIS_DIR},${BUILD_VIS_DIR},$(VIS_SRC:%=%.o)) 9 | 10 | ENV_VAR_FILES := ${BUILD_DIR}/lib/NTTINY_INC_DIRS ${BUILD_DIR}/lib/NTTINY_LIB_DIRS ${BUILD_DIR}/lib/NTTINY_LIBS 11 | 12 | nttiny : ${BUILD_DIR}/lib/libnttiny.a $(ENV_VAR_FILES) 13 | 14 | vis : pgenCopy nttiny ${VIS_TARGET} 15 | 16 | ${BUILD_DIR}/lib/libnttiny.a $(ENV_VAR_FILES) : ${NTTINY_DIR} 17 | @echo ${BUILD_DIR} 18 | $(HIDE)cd ${NTTINY_DIR} && cmake -B build -D CMAKE_CXX_COMPILER=${HOST_CXX} -D CMAKE_LD_FLAGS="" -D CMAKE_INSTALL_PREFIX=${BUILD_DIR}/lib && cd build && make nttiny -j && make install 19 | 20 | nttiny_clean : 21 | $(HIDE)rm -rf ${BUILD_DIR}/lib/*nttiny* $(ENV_VAR_FILES) 22 | $(HIDE)cd ${NTTINY_DIR}/build && make clean 23 | 24 | ${VIS_TARGET} : ${BUILD_DIR}/lib/libnttiny.a $(OBJS) $(VIS_OBJ) 25 | $(eval NTTINY_LIB_DIRS := $(subst ",,$(subst ;, ,"$(shell cat ${BUILD_DIR}/lib/NTTINY_LIB_DIRS)")) ${BUILD_DIR}/lib) 26 | $(eval NTTINY_LIBS := $(subst ",,$(subst ;, ,"$(shell cat ${BUILD_DIR}/lib/NTTINY_LIBS)")) nttiny) 27 | $(eval NTTINY_LIB_FLAGS := $(addprefix -l, $(NTTINY_LIBS))) 28 | $(eval NTTINY_LD_FLAGS := $(addprefix -L, $(NTTINY_LIB_DIRS)) $(LIBS)) 29 | @echo [L]inking $@ from $^ 30 | $(HIDE)mkdir -p ${BIN_DIR} 31 | $(HIDE)${link_command} $^ $(NTTINY_LIB_FLAGS) -o $@ $(NTTINY_LD_FLAGS) 32 | 33 | ${BUILD_VIS_DIR}/%.o : ${VIS_DIR}/% 34 | $(eval NTTINY_INC_DIRS := $(subst ",,$(subst ;, ,"$(shell cat ${BUILD_DIR}/lib/NTTINY_INC_DIRS)"))) 35 | $(eval NTTINY_INC_FLAGS := $(addprefix -I, $(NTTINY_INC_DIRS) ${NTTINY_DIR}/src ${NTTINY_DIR}/extern $(dir $(wildcard ${NTTINY_DIR}/src/**/)))) 36 | @echo [C]ompiling \`vis\`: $(subst ${ROOT_DIR}/,,$<) 37 | $(HIDE)mkdir -p $(dir $@) 38 | $(HIDE)${compile_command} $(NTTINY_INC_FLAGS) -c $^ -o $@ 39 | -------------------------------------------------------------------------------- /legacy/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src) 2 | 3 | # include main source directory for all targets 4 | include_directories(${SOURCE_DIR}) 5 | 6 | # --------------------------------- Wrapper -------------------------------- # 7 | set(WRAPPER ${PROJECT_NAME}-wrapper) 8 | add_library(${WRAPPER} STATIC ${SOURCE_DIR}/wrapper/kokkos.cpp) 9 | 10 | # link wrapper with all targets 11 | link_libraries(${WRAPPER}) 12 | 13 | # include wrapper header for all targets 14 | include_directories(${SOURCE_DIR}/wrapper) 15 | 16 | # -------------------------------- Framework ------------------------------- # 17 | file(GLOB_RECURSE FRAMEWORK_FILES ${SOURCE_DIR}/framework/*.cpp) 18 | file(GLOB_RECURSE PIC_FILES ${SOURCE_DIR}/pic/*.cpp) 19 | file(GLOB_RECURSE GRPIC_FILES ${SOURCE_DIR}/grpic/*.cpp) 20 | 21 | # include framework headers for all targets 22 | include_directories(${SOURCE_DIR}/framework) 23 | 24 | set(all_metrics ${sr_metrics} ${gr_metrics}) 25 | 26 | # Libraries for all metrics and engines 27 | # compile framework for all metrics and engines + all engines with corresponding metrics 28 | foreach(metric ${all_metrics}) 29 | list(FIND sr_metrics ${metric} sr_metric_index) 30 | 31 | if(NOT ${sr_metric_index} EQUAL -1) 32 | set(engine pic) 33 | else() 34 | set(engine grpic) 35 | endif() 36 | 37 | string(TOUPPER ${metric} metric_upper) 38 | string(TOUPPER ${engine} engine_upper) 39 | 40 | add_library(framework-${metric} STATIC ${FRAMEWORK_FILES}) 41 | target_compile_options(framework-${metric} PUBLIC -D${metric_upper}_METRIC -D${engine_upper}_ENGINE -DSIMULATION_METRIC=\"${metric}\" -DMETRIC_HEADER=\"metrics/${metric}.h\") 42 | 43 | add_library(engine-${engine}-${metric} STATIC ${${engine_upper}_FILES}) 44 | 45 | target_compile_options(engine-${engine}-${metric} PUBLIC -D${metric_upper}_METRIC -D${engine_upper}_ENGINE -DSIMULATION_METRIC=\"${metric}\" -DMETRIC_HEADER=\"metrics/${metric}.h\") 46 | target_compile_options(engine-${engine}-${metric} PUBLIC "-DPGEN_HEADER=\"pgen/dummy.hpp\"") 47 | target_include_directories(engine-${engine}-${metric} PRIVATE ${SOURCE_DIR}/${engine}) 48 | endforeach() 49 | 50 | # ----------------------------------- Benchmarks ----------------------------------- # 51 | function(define_benchmark metric engine title file) 52 | add_executable(bmark-${title}.xc ${file}) 53 | target_link_libraries(bmark-${title}.xc PUBLIC framework-${metric} engine-${engine}-${metric}) 54 | target_include_directories(bmark-${title}.xc PRIVATE ${SOURCE_DIR}/${engine}) 55 | endfunction() 56 | 57 | define_benchmark("minkowski" "pic" "sr-mink" "sr-mink.cpp") 58 | define_benchmark("spherical" "pic" "sr-sph" "sr-sph.cpp") 59 | define_benchmark("qspherical" "pic" "sr-qsph" "sr-sph.cpp") 60 | define_benchmark("kerr_schild" "grpic" "gr-ks" "gr.cpp") 61 | define_benchmark("qkerr_schild" "grpic" "gr-qks" "gr.cpp") -------------------------------------------------------------------------------- /legacy/deploy/aux/argparse.sh: -------------------------------------------------------------------------------- 1 | while [ $# -gt 0 ]; do 2 | if [[ $1 == "--help" ]] || [[ $1 == "-h" ]]; then 3 | usage 4 | exit 0 5 | elif [[ $1 == "--"* ]]; then 6 | v="${1/--/}" 7 | v=$(echo $v | sed 's/-/_/g') 8 | if [[ -z "$2" ]] || [[ "$2" == --* ]] || [[ "$2" == -* ]]; then 9 | if [[ "$1" != "--deploy" ]] && [[ "$1" != "--verbose" ]]; then 10 | printf "\n${RED}Invalid option: $1${NC}\n" 11 | exit 1 12 | fi 13 | declare "$v"="ON" 14 | else 15 | declare "$v"="$2" 16 | shift 17 | fi 18 | elif [[ $1 == "-"* ]]; then 19 | if [[ -z "$2" ]] || [[ "$2" == --* ]] || [[ "$2" == -* ]]; then 20 | if [[ $1 == "-v" ]]; then 21 | verbose="ON" 22 | elif [[ $1 == "-d" ]]; then 23 | deploy="ON" 24 | else 25 | printf "\n${RED}Invalid option: $1${NC}\n" 26 | exit 1 27 | fi 28 | else 29 | printf "\n${RED}Invalid option: $1${NC}\n" 30 | exit 1 31 | fi 32 | fi 33 | shift 34 | done 35 | 36 | # manage invalid options 37 | if [ $with_cuda = "ON" ]; then 38 | printf "\n${RED}Please specify CUDA path or modulename${NC}\n" 39 | exit 1 40 | fi 41 | 42 | if [ $with_mpi = "ON" ]; then 43 | printf "\n${RED}Please specify MPI path or modulename${NC}\n" 44 | exit 1 45 | fi -------------------------------------------------------------------------------- /legacy/deploy/aux/aux.sh: -------------------------------------------------------------------------------- 1 | rtouch() { 2 | mkdir -p $(sed 's/\(.*\)\/.*/\1/' <<<$1) && touch $1 3 | } 4 | 5 | function runcommand { 6 | if [ $deploy = "OFF" ]; then 7 | echo ": $1" 8 | else 9 | if [ $verbose = "ON" ]; then 10 | eval "$1" 11 | else 12 | eval "$1" >>${logfile} 2>>${logfile} 13 | fi 14 | fi 15 | } 16 | 17 | declare -x FRAME 18 | declare -x FRAME_INTERVAL 19 | 20 | set_spinner() { 21 | case $1 in 22 | spinner1) 23 | FRAME=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 24 | FRAME_INTERVAL=0.1 25 | ;; 26 | spinner2) 27 | FRAME=("-" "\\" "|" "/") 28 | FRAME_INTERVAL=0.25 29 | ;; 30 | spinner3) 31 | FRAME=("◐" "◓" "◑" "◒") 32 | FRAME_INTERVAL=0.5 33 | ;; 34 | spinner4) 35 | FRAME=(":(" ":|" ":)" ":D") 36 | FRAME_INTERVAL=0.5 37 | ;; 38 | spinner5) 39 | FRAME=("◇" "◈" "◆") 40 | FRAME_INTERVAL=0.5 41 | ;; 42 | spinner6) 43 | FRAME=("⚬" "⚭" "⚮" "⚯") 44 | FRAME_INTERVAL=0.25 45 | ;; 46 | spinner7) 47 | FRAME=("░" "▒" "▓" "█" "▓" "▒") 48 | FRAME_INTERVAL=0.25 49 | ;; 50 | spinner8) 51 | FRAME=("☉" "◎" "◉" "●" "◉") 52 | FRAME_INTERVAL=0.1 53 | ;; 54 | spinner9) 55 | FRAME=("❤" "♥" "♡") 56 | FRAME_INTERVAL=0.15 57 | ;; 58 | spinner10) 59 | FRAME=("✧" "☆" "★" "✪" "◌" "✲") 60 | FRAME_INTERVAL=0.1 61 | ;; 62 | spinner11) 63 | FRAME=("●" "◕" "☯" "◔" "◕") 64 | FRAME_INTERVAL=0.25 65 | ;; 66 | *) 67 | echo "No spinner is defined for $1" 68 | exit 1 69 | ;; 70 | esac 71 | } 72 | 73 | function is_gpu_arch { 74 | local ar=$1 75 | if [[ $ar == "VOLTA"* ]] || [[ $ar == "TURING"* ]] || [[ $ar == "AMPERE"* ]] || [[ $ar == "MAXWELL"* ]] || [[ $ar == "PASCAL"* ]] || [[ $ar == "KEPLER"* ]] || [[ $ar == "INTEL"* ]] || [[ $ar == "VEGA"* ]] || [[ $ar == "NAVI"* ]]; then 76 | echo "TRUE" 77 | else 78 | echo "FALSE" 79 | fi 80 | } 81 | 82 | GRAY='\033[0;30m' 83 | GREEN='\033[0;32m' 84 | RED='\033[0;31m' 85 | BLUE='\033[0;34m' 86 | NC='\033[0m' 87 | -------------------------------------------------------------------------------- /legacy/deploy/aux/config.sh: -------------------------------------------------------------------------------- 1 | declare -x writing_modulefile="ON" 2 | declare -x use_modules="OFF" 3 | declare -x enable_cuda="OFF" 4 | declare -x install_path=${install_prefix}/${modulename_lower} 5 | 6 | if [ -z $has_modulefile ]; then 7 | writing_modulefile="OFF" 8 | else 9 | modnm=$(eval echo "\${${modulename_lower}_module}") 10 | if [[ $has_modulefile = "OFF" || $modnm = "OFF" ]]; then 11 | writing_modulefile="OFF" 12 | fi 13 | fi 14 | 15 | if [ ! $with_cuda = "OFF" ]; then 16 | enable_cuda="ON" 17 | if [[ $with_cuda == module:* ]]; then 18 | cuda_module=$(echo $with_cuda | cut -d':' -f2) 19 | use_modules="ON" 20 | else 21 | cuda_path=$with_cuda 22 | fi 23 | fi 24 | 25 | if [[ $with_cc == module:* ]]; then 26 | cc_module=$(echo $with_cc | cut -d':' -f2) 27 | use_modules="ON" 28 | fi 29 | 30 | if [ ! $with_mpi = "OFF" ]; then 31 | if [[ $with_mpi == module:* ]]; then 32 | mpi_module=$(echo $with_mpi | cut -d':' -f2) 33 | use_modules="ON" 34 | if [ ! $with_cuda = "OFF" ]; then 35 | mpi_module=$mpi_module/cuda 36 | else 37 | mpi_module=$mpi_module/cpu 38 | fi 39 | else 40 | mpi_path=$with_mpi 41 | fi 42 | fi 43 | 44 | function define_kokkos_suffix { 45 | local arch_raw=$1 46 | local suffix="" 47 | declare -xa archs 48 | IFS=',' read -ra archs <<<"$arch_raw" 49 | 50 | for ar in "${archs[@]}"; do 51 | if [ $ar = "AUTO" ]; then 52 | break 53 | fi 54 | is_gpu=$(is_gpu_arch $ar) 55 | if [ $is_gpu = "TRUE" ]; then 56 | if [ $enable_cuda != "ON" ]; then 57 | printf "\n${RED}GPU architecture $ar is specified but CUDA is not enabled${NC}\n" 58 | exit 1 59 | fi 60 | suffix+="/${ar,,}" 61 | fi 62 | done 63 | for ar in "${archs[@]}"; do 64 | if [ $ar = "AUTO" ]; then 65 | break 66 | fi 67 | is_gpu=$(is_gpu_arch $ar) 68 | if [ $is_gpu != "TRUE" ]; then 69 | suffix+="/${ar,,}" 70 | fi 71 | done 72 | echo $suffix 73 | } 74 | -------------------------------------------------------------------------------- /legacy/deploy/aux/default.sh: -------------------------------------------------------------------------------- 1 | default_with_cuda="module:cudatoolkit/12.0" 2 | declare with_cuda="${default_with_cuda}" 3 | 4 | default_with_cc="module:gcc-toolset/10" 5 | declare with_cc="${default_with_cc}" 6 | 7 | default_install_prefix="${HOME}/opt" 8 | declare install_prefix="${default_install_prefix}" 9 | 10 | default_module_path="${HOME}/opt/.modules" 11 | default_src_path="${HOME}/opt/src" 12 | 13 | declare -r modulename_lower=${modulename,,} 14 | 15 | declare ${modulename_lower}_module="${default_module_path}/${modulename_lower}" 16 | declare ${modulename_lower}_src_path="${default_src_path}/${modulename_lower}" 17 | 18 | declare deploy="OFF" 19 | declare verbose="OFF" 20 | 21 | declare -r programname=$0 -------------------------------------------------------------------------------- /legacy/deploy/aux/globals.sh: -------------------------------------------------------------------------------- 1 | declare -r logfile="$(pwd)/${modulename_lower}.log" 2 | 3 | function common_help { 4 | echo "" 5 | echo "Build and install $modulename" 6 | echo "" 7 | echo "usage: bash $programname --deploy -v --install_prefix ... [options]" 8 | echo "" 9 | echo " -h, --help print this help message" 10 | echo "" 11 | echo " -d, --deploy execute the script" 12 | echo " -d OFF shows the command to be executed" 13 | echo " (default: $deploy)" 14 | echo "" 15 | echo " -v, --verbose whether to print the compilation progress or not" 16 | echo " (default: $verbose)" 17 | echo "" 18 | echo " --install_prefix path to $modulename installation directory" 19 | echo " (default: $default_install_prefix)" 20 | echo "" 21 | printf "%-33s%s" " --${modulename_lower}_src_path " "path to ${modulename} source directory" 22 | echo "" 23 | echo " (default: $default_src_path/${modulename_lower})" 24 | if [ ! -z $has_modulefile ]; then 25 | echo "" 26 | printf "%-33s%s" " --${modulename_lower}_module " "path to ${modulename} module" 27 | echo "" 28 | echo " set to OFF to disable modulefile installation" 29 | echo " (default: $default_module_path/${modulename_lower})" 30 | fi 31 | echo "" 32 | echo " --with-cc C compiler path or modulename (\`module:\`)" 33 | echo " (default: $default_with_cc)" 34 | echo "" 35 | echo " --with-cuda CUDA path or modulename via (\`module:\`)" 36 | echo " set to OFF to disable CUDA support" 37 | echo " (default: $default_with_cuda)" 38 | echo "" 39 | } 40 | -------------------------------------------------------------------------------- /legacy/deploy/compile_ucx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) 4 | 5 | source ${SCRIPT_DIR}/aux/aux.sh 6 | 7 | declare -r modulename="UCX" 8 | source ${SCRIPT_DIR}/aux/default.sh 9 | source ${SCRIPT_DIR}/aux/globals.sh 10 | 11 | function usage { 12 | common_help 13 | } 14 | 15 | source ${SCRIPT_DIR}/aux/argparse.sh 16 | source ${SCRIPT_DIR}/aux/config.sh 17 | 18 | if [ $enable_cuda = "ON" ]; then 19 | install_path="${install_path}/cuda" 20 | else 21 | install_path="${install_path}/cpu" 22 | fi 23 | 24 | compile_args=( 25 | --prefix=$install_path 26 | ) 27 | 28 | if [ $use_modules = "ON" ]; then 29 | if [ $enable_cuda = "ON" ]; then 30 | compile_args+=( 31 | --with-cuda=\$CUDA_HOME 32 | ) 33 | fi 34 | else 35 | if [ $enable_cuda = "ON" ]; then 36 | compile_args+=( 37 | --with-cuda=$cuda_path 38 | ) 39 | fi 40 | fi 41 | 42 | source ${SCRIPT_DIR}/aux/run.sh 43 | 44 | function prebuild { 45 | if [ $use_modules = "ON" ]; then 46 | runcommand "module purge" 47 | runcommand "module load $cc_module" 48 | runcommand "export CC=\$(which gcc) CXX=\$(which g++)" 49 | if [ $enable_cuda = "ON" ]; then 50 | runcommand "module load $cuda_module" 51 | fi 52 | fi 53 | } 54 | 55 | function configure { 56 | prebuild 57 | runcommand "cd $ucx_src_path" 58 | runcommand "rm -rf build" 59 | runcommand "./autogen.sh" 60 | runcommand "mkdir build" 61 | runcommand "cd build" 62 | local args=$(printf " %s" "${compile_args[@]}") 63 | runcommand "../configure$args" 64 | } 65 | 66 | function compile { 67 | prebuild 68 | runcommand "cd $ucx_src_path/build" 69 | runcommand "make -j" 70 | } 71 | 72 | function install { 73 | runcommand "cd $ucx_src_path/build" 74 | runcommand "make install" 75 | } 76 | 77 | function cleanup { 78 | runcommand "cd $ucx_src_path" 79 | runcommand "rm -rf build" 80 | } 81 | 82 | run configure compile install cleanup 83 | -------------------------------------------------------------------------------- /legacy/deploy/personal.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | cuda = "module:cuda/12.0" 3 | cc = "module:gcc/11.4" 4 | mpi = "module:$HOME/opt/.modules/ompi" 5 | hdf5 = "module:$HOME/opt/.modules/hdf5" 6 | kokkos = "module:$HOME/opt/.modules/kokkos" 7 | adios2 = "module:$HOME/opt/.modules/adios2" 8 | 9 | [entity] 10 | modulepath = "$HOME/.modules/entity" 11 | 12 | [entity.instances] 13 | debug = [true, false] 14 | with_cuda = [true, false] 15 | with_mpi = [true, false] 16 | archs = ["ZEN2,AMPERE86", "ZEN2"] 17 | -------------------------------------------------------------------------------- /legacy/deploy/stellar.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | cuda = "module:cudatoolkit/12.0" 3 | cc = "module:gcc-toolset/10" 4 | mpi = "module:$HOME/opt/.modules/ompi" 5 | hdf5 = "module:$HOME/opt/.modules/hdf5" 6 | kokkos = "module:$HOME/opt/.modules/kokkos" 7 | adios2 = "module:$HOME/opt/.modules/adios2" 8 | 9 | [entity] 10 | modulepath = "$HOME/.modules/entity" 11 | 12 | [entity.instances] 13 | debug = [true, false] 14 | with_cuda = [true, false] 15 | with_mpi = [true, false] 16 | archs = ["ZEN2,AMPERE80", "VOLTA70,SKX", "SKX"] 17 | -------------------------------------------------------------------------------- /legacy/deploy/zaratan.toml: -------------------------------------------------------------------------------- 1 | [dependencies] 2 | cuda = "module:cuda/11.8.0/gcc/11.3.0/zen2" 3 | cc = "module:gcc/11.3.0" 4 | mpi = "" 5 | hdf5 = "module:hdf5" 6 | kokkos = "module:$HOME/opt/.modules/kokkos" 7 | adios2 = "module:$HOME/opt/.modules/adios2" 8 | 9 | [entity] 10 | modulepath = "$HOME/opt/.modules/entity" 11 | 12 | [entity.instances] 13 | debug = [false] 14 | with_cuda = [true] 15 | with_mpi = [false] 16 | archs = ["ZEN2,AMPERE80"] 17 | -------------------------------------------------------------------------------- /legacy/src/framework/io/output_csv.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_OUTPUT_CSV_H 2 | #define IO_OUTPUT_CSV_H 3 | 4 | #include "wrapper.h" 5 | #include "io/output.h" 6 | #include "meshblock/meshblock.h" 7 | 8 | namespace ntt { 9 | // enum class OutputMode { UNDEFINED, WRITE, APPEND }; 10 | 11 | namespace csv { 12 | // /** 13 | // * @brief Write a field component to a csv file. 14 | // * @param[in] fname Filename to write to. 15 | // * @param[in] mblock Meshblock. 16 | // * @param[in] em Field component to output. 17 | // */ 18 | // template 19 | // void writeField(const std::string&, const Meshblock&, const em&); 20 | 21 | // /** 22 | // * @brief Write a current component to a csv file. 23 | // * @overload 24 | // * @param[in] fname Filename to write to. 25 | // * @param[in] mblock Meshblock. 26 | // * @param[in] cur Current component to output. 27 | // */ 28 | // template 29 | // void writeField(const std::string&, const Meshblock&, const cur&); 30 | 31 | // /** 32 | // * @brief Write a particle data to a csv file. 33 | // * @param[in] fname Filename to write to. 34 | // * @param[in] mblock Meshblock. 35 | // * @param[in] spec_id Species id. 36 | // * @param[in] prtl_id Particle id. 37 | // * @param[in] mode Write mode {WRITE, APPEND}. 38 | // */ 39 | // template 40 | // void writeParticle(std::string, 41 | // const Meshblock&, 42 | // const std::size_t&, 43 | // const std::size_t&, 44 | // const OutputMode& mode = OutputMode::WRITE); 45 | 46 | // /** 47 | // * @brief Ensure the file exists (raises an error if not). 48 | // */ 49 | // void ensureFileExists(const std::string&); 50 | } // namespace csv 51 | } // namespace ntt 52 | 53 | #endif -------------------------------------------------------------------------------- /legacy/src/framework/utils/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_TIMER_H 2 | #define UTILS_TIMER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace ntt { 10 | // Type to be used for s/ms/us/ms 11 | class TimeUnit { 12 | private: 13 | double multiplier; 14 | std::string unitname; 15 | 16 | public: 17 | TimeUnit() = default; 18 | TimeUnit(const double& mult, const std::string& unit) 19 | : multiplier {mult}, unitname {unit} {} 20 | ~TimeUnit() = default; 21 | [[nodiscard]] auto getMultiplier() const -> double; 22 | friend auto operator<<(std::ostream& os, TimeUnit const& v) -> std::ostream&; 23 | }; 24 | 25 | // declaration of s/ms/us/ms 26 | inline const TimeUnit second(1, "s"); 27 | inline const TimeUnit millisecond(1e-3, "ms"); 28 | inline const TimeUnit microsecond(1e-6, "us"); 29 | inline const TimeUnit nanosecond(1e-9, "ns"); 30 | 31 | // Type to keep track of timestamp 32 | class Time { 33 | private: 34 | long double value {0.0}; 35 | const TimeUnit* unit; 36 | 37 | public: 38 | Time() = default; 39 | Time(const long double& v, const TimeUnit& u = second); 40 | ~Time() = default; 41 | // void convert(const TimeUnit& to); 42 | // [[nodiscard]] auto getValue() const -> long double; 43 | [[nodiscard]] auto represent(const TimeUnit& to) const -> Time; 44 | // Time operator=(const Time & rhs); 45 | auto operator-() const -> Time; 46 | 47 | // friend auto operator+(Time const&, Time const&) -> Time; 48 | // friend auto operator-(Time const&, Time const&) -> Time; 49 | // friend auto operator*(double x, Time const& t) -> Time; 50 | // friend auto operator*(Time const&, double x) -> Time; 51 | friend auto operator<<(std::ostream& os, Time const& t) -> std::ostream&; 52 | friend class Timer; 53 | }; 54 | 55 | using TimeContainer = std::chrono::time_point; 56 | 57 | class Timer { 58 | private: 59 | std::string name; 60 | bool init {false}; 61 | bool on {false}; 62 | TimeContainer t_start; 63 | Time t_elapsed; 64 | 65 | public: 66 | Timer() : name("NULL"), t_elapsed {0.0} {} 67 | Timer(const std::string& name) : name(std::move(name)), t_elapsed {0.0} {} 68 | ~Timer() = default; 69 | void start(); 70 | void check(); 71 | void stop(); 72 | [[nodiscard]] auto getElapsedIn(const TimeUnit& u) const -> long double; 73 | [[nodiscard]] auto getName() const -> std::string; 74 | void printElapsed(const TimeUnit& u = second) const; 75 | void printElapsed(std::ostream& os = std::cout, const TimeUnit& u = second) const; 76 | }; 77 | 78 | class TimerCollection { 79 | private: 80 | // TODO: maybe map? 81 | std::vector m_timers; 82 | 83 | public: 84 | // TimerCollection(const std::vector& timers); 85 | TimerCollection(const std::vector& timers) : m_timers(timers) {} 86 | ~TimerCollection() = default; 87 | void start(const int& i); 88 | void stop(const int& i); 89 | void printAll(std::ostream& os = std::cout, const TimeUnit& u = second) const; 90 | void printAll(const TimeUnit& u = second) const; 91 | }; 92 | 93 | } // namespace ntt 94 | 95 | #endif // TIMER_H 96 | -------------------------------------------------------------------------------- /legacy/src/framework/writer.cpp: -------------------------------------------------------------------------------- 1 | 2 | if constexpr (D == Dim1) { 3 | extent = fmt::format("{} {} 0 0 0 0", params.extent()[0], params.extent()[1]); 4 | } else if constexpr (D == Dim2) { 5 | extent = fmt::format("{} {} {} {} 0 0", 6 | params.extent()[0], 7 | params.extent()[1], 8 | params.extent()[2], 9 | params.extent()[3]); 10 | } else if constexpr (D == Dim3) { 11 | extent = fmt::format("{} {} {} {} {} {}", 12 | params.extent()[0], 13 | params.extent()[1], 14 | params.extent()[2], 15 | params.extent()[3], 16 | params.extent()[4], 17 | params.extent()[5]); 18 | } 19 | 20 | const std::string vtk_xml = R"( 21 | 22 | 23 | " 25 | 27 | 28 | 29 | 30 | step 31 | 32 | 33 | 34 | 35 | )"; 36 | 37 | if constexpr (D == Dim1) { 38 | extent = fmt::format("0 {} 0 0 0 0", params.resolution()[0] + 1); 39 | } else if constexpr (D == Dim2) { 40 | extent 41 | = fmt::format("0 {} 0 {} 0 0", params.resolution()[0] + 1, params.resolution()[1] + 42 | 1); 43 | } else if constexpr (D == Dim3) { 44 | extent = fmt::format("0 {} 0 {} 0 {}", 45 | params.resolution()[0] + 1, 46 | params.resolution()[1] + 1, 47 | params.resolution()[2] + 1); 48 | } 49 | const std::string vtk_xml = R"( 50 | 51 | 52 | 54 | 56 | 57 | 58 | 59 | time 60 | 61 | 62 | 63 | 64 | )"; 65 | 66 | std::cout << vtk_xml << std::endl; 67 | 68 | m_io.DefineAttribute("vtk.xml", vtk_xml); 69 | -------------------------------------------------------------------------------- /legacy/src/pic/boundaries/currents_bc.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fields_bc.cpp 3 | * @brief Absorbing boundary conditions for the currents at rmax (for 2D axisymmetric). 4 | * @implements: `CurrentsBoundaryConditions` method of the `PIC` class 5 | * @includes: `currents_bc.hpp 6 | * @depends: `pic.h` 7 | * 8 | * @notes: - Periodic boundary conditions are implemented in `currents_exch.cpp` 9 | * 10 | */ 11 | 12 | #include "wrapper.h" 13 | 14 | #include "pic.h" 15 | 16 | #include "meshblock/meshblock.h" 17 | 18 | #ifndef MINKOWSKI_METRIC 19 | #include "currents_bc.hpp" 20 | #endif 21 | 22 | namespace ntt { 23 | /** 24 | * @brief Special boundary conditions on currents 25 | */ 26 | #ifdef MINKOWSKI_METRIC 27 | template 28 | void PIC::CurrentsBoundaryConditions() {} 29 | 30 | #else 31 | 32 | template <> 33 | void PIC::CurrentsBoundaryConditions() { 34 | // auto& mblock = this->meshblock; 35 | // if (mblock.boundaries[0][1] == BoundaryCondition::ABSORB) { 36 | // auto& pgen = this->problem_generator; 37 | // auto params = *(this->params()); 38 | // auto r_absorb = params.metricParameters()[2]; 39 | // auto r_max = mblock.metric.x1_max; 40 | // const auto i1_absorb = (std::size_t)(mblock.metric.x1_Sph2Code(r_absorb)); 41 | // NTTHostErrorIf(i1_absorb >= mblock.i1_max(), 42 | // "Absorbing layer is too small, consider " 43 | // "increasing r_absorb"); 44 | // /** 45 | // * . . . . . . . . . . . . . 46 | // * . . 47 | // * . . 48 | // * . ^= = = = = = = =^ . 49 | // * . |* * * * * * * *\ . 50 | // * . |* * * * * * * *\ . 51 | // * . | \ . 52 | // * . | \ . 53 | // * . ^- - - - - - - -^ . 54 | // * . . 55 | // * . . 56 | // * . . . . . . . . . . . . . 57 | // * 58 | // */ 59 | // Kokkos::parallel_for( 60 | // "CurrentsBoundaryConditions", 61 | // CreateRangePolicy({ i1_absorb, 0 }, 62 | // { mblock.i1_max(), mblock.i2_max() }), 63 | // AbsorbCurrents_kernel(mblock, pgen, r_absorb, r_max)); 64 | // } 65 | } 66 | 67 | template <> 68 | void PIC::CurrentsBoundaryConditions() { 69 | NTTHostError("not applicable"); 70 | } 71 | 72 | template <> 73 | void PIC::CurrentsBoundaryConditions() { 74 | NTTHostError("not implemented"); 75 | } 76 | #endif 77 | 78 | } // namespace ntt 79 | 80 | #ifdef MINKOWSKI_METRIC 81 | template void ntt::PIC::CurrentsBoundaryConditions(); 82 | template void ntt::PIC::CurrentsBoundaryConditions(); 83 | template void ntt::PIC::CurrentsBoundaryConditions(); 84 | #endif -------------------------------------------------------------------------------- /legacy/src/pic/boundaries/currents_bc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PIC_CURRENTS_BC_H 2 | #define PIC_CURRENTS_BC_H 3 | 4 | #include "wrapper.h" 5 | 6 | #include "field_macros.h" 7 | #include "pic.h" 8 | 9 | #include PGEN_HEADER 10 | 11 | namespace ntt { 12 | // /** 13 | // * @brief Algorithms for PIC current boundary conditions. 14 | // * @tparam D Dimension. 15 | // */ 16 | // template 17 | // class AbsorbCurrents_kernel { 18 | // Meshblock m_mblock; 19 | // ProblemGenerator m_pgen; 20 | // real_t m_rabsorb; 21 | // real_t m_rmax; 22 | 23 | // public: 24 | // /** 25 | // * @brief Constructor. 26 | // * @param mblock Meshblock. 27 | // * @param pgen Problem generator. 28 | // * @param rabsorb Absorbing radius. 29 | // * @param rmax Maximum radius. 30 | // */ 31 | // AbsorbCurrents_kernel(const Meshblock& mblock, 32 | // const ProblemGenerator& pgen, 33 | // real_t r_absorb, 34 | // real_t r_max) : 35 | // m_mblock { mblock }, 36 | // m_pgen { pgen }, 37 | // m_rabsorb { r_absorb }, 38 | // m_rmax { r_max } {} 39 | 40 | // /** 41 | // * @brief 2D implementation of the algorithm. 42 | // * @param i1 index. 43 | // * @param i2 index. 44 | // */ 45 | // Inline void operator()(index_t, index_t) const; 46 | // }; 47 | 48 | // template <> 49 | // Inline void AbsorbCurrents_kernel::operator()(index_t i, index_t j) const { 50 | // const real_t i_ { static_cast(static_cast(i) - N_GHOSTS) }; 51 | // const real_t j_ { static_cast(static_cast(j) - N_GHOSTS) }; 52 | 53 | // const real_t i1 54 | // // vec_t rth_; 55 | // // m_mblock.metric.x_Code2Sph({ i_, j_, ZERO }, rth_); 56 | // real_t delta_r1 { (rth_[0] - m_rabsorb) / (m_rmax - m_rabsorb) }; 57 | // real_t sigma_r1 { HEAVISIDE(delta_r1) * delta_r1 * delta_r1 * delta_r1 }; 58 | 59 | // JX1(i, j) = (ONE - sigma_r1) * JX1(i, j); 60 | // JX2(i, j) = (ONE - sigma_r1) * JX2(i, j); 61 | // JX3(i, j) = (ONE - sigma_r1) * JX3(i, j); 62 | // } 63 | } // namespace ntt 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /legacy/src/pic/fields/ampere_mink.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PIC_AMPERE_MINKOWSKI_H 2 | #define PIC_AMPERE_MINKOWSKI_H 3 | 4 | #include "wrapper.h" 5 | 6 | #include "field_macros.h" 7 | #include "pic.h" 8 | 9 | #include "io/output.h" 10 | #include "meshblock/meshblock.h" 11 | 12 | namespace ntt { 13 | /** 14 | * @brief Algorithm for the Ampere's law: `dE/dt = curl B` in Minkowski space. 15 | * @tparam D Dimension. 16 | */ 17 | template 18 | class Ampere_kernel { 19 | Meshblock m_mblock; 20 | real_t m_coeff; 21 | 22 | public: 23 | /** 24 | * @brief Constructor. 25 | * @param mblock Meshblock. 26 | * @param coeff Coefficient to be multiplied by dE/dt = coeff * curl B. 27 | */ 28 | Ampere_kernel(const Meshblock& mblock, const real_t& coeff) : 29 | m_mblock(mblock), 30 | m_coeff(coeff) {} 31 | 32 | /** 33 | * @brief 1D implementation of the algorithm. 34 | * @param i1 index. 35 | */ 36 | Inline void operator()(index_t) const; 37 | 38 | /** 39 | * @brief 2D implementation of the algorithm. 40 | * @param i1 index. 41 | * @param i2 index. 42 | */ 43 | Inline void operator()(index_t, index_t) const; 44 | 45 | /** 46 | * @brief 3D implementation of the algorithm. 47 | * @param i1 index. 48 | * @param i2 index. 49 | * @param i3 index. 50 | */ 51 | Inline void operator()(index_t, index_t, index_t) const; 52 | }; 53 | 54 | template <> 55 | Inline void Ampere_kernel::operator()(index_t i) const { 56 | EX2(i) += m_coeff * (BX3(i - 1) - BX3(i)); 57 | EX3(i) += m_coeff * (BX2(i) - BX2(i - 1)); 58 | } 59 | 60 | template <> 61 | Inline void Ampere_kernel::operator()(index_t i, index_t j) const { 62 | EX1(i, j) += m_coeff * (BX3(i, j) - BX3(i, j - 1)); 63 | EX2(i, j) += m_coeff * (BX3(i - 1, j) - BX3(i, j)); 64 | EX3(i, j) += m_coeff * (BX1(i, j - 1) - BX1(i, j) + BX2(i, j) - BX2(i - 1, j)); 65 | } 66 | 67 | template <> 68 | Inline void Ampere_kernel::operator()(index_t i, index_t j, index_t k) const { 69 | EX1(i, j, k) += m_coeff * (BX2(i, j, k - 1) - BX2(i, j, k) + BX3(i, j, k) - 70 | BX3(i, j - 1, k)); 71 | EX2(i, j, k) += m_coeff * (BX3(i - 1, j, k) - BX3(i, j, k) + BX1(i, j, k) - 72 | BX1(i, j, k - 1)); 73 | EX3(i, j, k) += m_coeff * (BX1(i, j - 1, k) - BX1(i, j, k) + BX2(i, j, k) - 74 | BX2(i - 1, j, k)); 75 | } 76 | } // namespace ntt 77 | #endif // PIC_AMPERE_MINKOWSKI_H -------------------------------------------------------------------------------- /legacy/src/pic/fields/faraday_curv.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PIC_FARADAY_CURVILINEAR_H 2 | #define PIC_FARADAY_CURVILINEAR_H 3 | 4 | #include "wrapper.h" 5 | 6 | #include "field_macros.h" 7 | #include "pic.h" 8 | 9 | #include "io/output.h" 10 | #include "meshblock/meshblock.h" 11 | 12 | #include 13 | 14 | namespace ntt { 15 | 16 | /** 17 | * @brief Algorithm for the Faraday's law: `dB/dt = -curl E` in Curvilinear 18 | * space (diagonal metric). 19 | * @tparam D Dimension. 20 | */ 21 | template 22 | class Faraday_kernel { 23 | Meshblock m_mblock; 24 | real_t m_coeff; 25 | 26 | public: 27 | /** 28 | * @brief Constructor. 29 | * @param mblock Meshblock. 30 | * @param coeff Coefficient to be multiplied by dB/dt = coeff * -curl E. 31 | */ 32 | Faraday_kernel(const Meshblock& mblock, const real_t& coeff) : 33 | m_mblock(mblock), 34 | m_coeff(coeff) {} 35 | 36 | /** 37 | * @brief 2D implementation of the algorithm. 38 | * @param i1 index. 39 | * @param i2 index. 40 | */ 41 | Inline void operator()(index_t, index_t) const; 42 | /** 43 | * @brief 3D implementation of the algorithm. 44 | * @param i1 index. 45 | * @param i2 index. 46 | * @param i3 index. 47 | */ 48 | Inline void operator()(index_t, index_t, index_t) const; 49 | }; 50 | 51 | template <> 52 | Inline void Faraday_kernel::operator()(index_t i, index_t j) const { 53 | real_t i_ { static_cast(static_cast(i) - N_GHOSTS) }; 54 | real_t j_ { static_cast(static_cast(j) - N_GHOSTS) }; 55 | 56 | real_t inv_sqrt_detH_iPj { ONE / m_mblock.metric.sqrt_det_h({ i_ + HALF, j_ }) }; 57 | real_t inv_sqrt_detH_ijP { ONE / m_mblock.metric.sqrt_det_h({ i_, j_ + HALF }) }; 58 | real_t inv_sqrt_detH_iPjP { ONE / m_mblock.metric.sqrt_det_h( 59 | { i_ + HALF, j_ + HALF }) }; 60 | real_t h1_iPjP1 { m_mblock.metric.h_11({ i_ + HALF, j_ + ONE }) }; 61 | real_t h1_iPj { m_mblock.metric.h_11({ i_ + HALF, j_ }) }; 62 | real_t h2_iP1jP { m_mblock.metric.h_22({ i_ + ONE, j_ + HALF }) }; 63 | real_t h2_ijP { m_mblock.metric.h_22({ i_, j_ + HALF }) }; 64 | real_t h3_ij { m_mblock.metric.h_33({ i_, j_ }) }; 65 | real_t h3_iP1j { m_mblock.metric.h_33({ i_ + ONE, j_ }) }; 66 | real_t h3_ijP1 { m_mblock.metric.h_33({ i_, j_ + ONE }) }; 67 | 68 | BX1(i, j) += m_coeff * inv_sqrt_detH_ijP * 69 | (h3_ij * EX3(i, j) - h3_ijP1 * EX3(i, j + 1)); 70 | if (j == N_GHOSTS) { 71 | BX2(i, j) =m_coeff * (EX3(i + 1, j) - EX3(i, j)); 72 | } else { 73 | BX2(i, j) += m_coeff * inv_sqrt_detH_iPj * 74 | (h3_iP1j * EX3(i + 1, j) - h3_ij * EX3(i, j)); 75 | } 76 | BX3(i, j) += m_coeff * inv_sqrt_detH_iPjP * 77 | (h1_iPjP1 * EX1(i, j + 1) - h1_iPj * EX1(i, j) + 78 | h2_ijP * EX2(i, j) - h2_iP1jP * EX2(i + 1, j)); 79 | } 80 | 81 | template <> 82 | Inline void Faraday_kernel::operator()(index_t, index_t, index_t) const { 83 | // 3d curvilinear faraday not implemented 84 | } 85 | } // namespace ntt 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /legacy/src/pic/fields/faraday_mink.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PIC_FARADAY_MINKOWSKI_H 2 | #define PIC_FARADAY_MINKOWSKI_H 3 | 4 | #include "wrapper.h" 5 | 6 | #include "field_macros.h" 7 | #include "pic.h" 8 | 9 | #include "io/output.h" 10 | #include "meshblock/meshblock.h" 11 | 12 | namespace ntt { 13 | 14 | /** 15 | * @brief Algorithm for the Faraday's law: `dB/dt = -curl E` in Minkowski space. 16 | * @tparam D Dimension. 17 | */ 18 | template 19 | class Faraday_kernel { 20 | Meshblock m_mblock; 21 | real_t m_coeff; 22 | 23 | public: 24 | /** 25 | * @brief Constructor. 26 | * @param mblock Meshblock. 27 | * @param coeff Coefficient to be multiplied by dB/dt = coeff * -curl E. 28 | */ 29 | Faraday_kernel(const Meshblock& mblock, const real_t& coeff) : 30 | m_mblock(mblock), 31 | m_coeff(coeff) {} 32 | 33 | /** 34 | * @brief 1D implementation of the algorithm. 35 | * @param i1 index. 36 | */ 37 | Inline void operator()(index_t) const; 38 | /** 39 | * @brief 2D implementation of the algorithm. 40 | * @param i1 index. 41 | * @param i2 index. 42 | */ 43 | Inline void operator()(index_t, index_t) const; 44 | /** 45 | * @brief 3D implementation of the algorithm. 46 | * @param i1 index. 47 | * @param i2 index. 48 | * @param i3 index. 49 | */ 50 | Inline void operator()(index_t, index_t, index_t) const; 51 | }; 52 | 53 | template <> 54 | Inline void Faraday_kernel::operator()(index_t i) const { 55 | BX2(i) += m_coeff * (EX3(i + 1) - EX3(i)); 56 | BX3(i) += m_coeff * (EX2(i) - EX2(i + 1)); 57 | } 58 | 59 | template <> 60 | Inline void Faraday_kernel::operator()(index_t i, index_t j) const { 61 | BX1(i, j) += m_coeff * (EX3(i, j) - EX3(i, j + 1)); 62 | BX2(i, j) += m_coeff * (EX3(i + 1, j) - EX3(i, j)); 63 | BX3(i, j) += m_coeff * (EX1(i, j + 1) - EX1(i, j) + EX2(i, j) - EX2(i + 1, j)); 64 | } 65 | 66 | template <> 67 | Inline void Faraday_kernel::operator()(index_t i, index_t j, index_t k) const { 68 | BX1(i, j, k) += m_coeff * (EX2(i, j, k + 1) - EX2(i, j, k) + EX3(i, j, k) - 69 | EX3(i, j + 1, k)); 70 | BX2(i, j, k) += m_coeff * (EX3(i + 1, j, k) - EX3(i, j, k) + EX1(i, j, k) - 71 | EX1(i, j, k + 1)); 72 | BX3(i, j, k) += m_coeff * (EX1(i, j + 1, k) - EX1(i, j, k) + EX2(i, j, k) - 73 | EX2(i + 1, j, k)); 74 | } 75 | } // namespace ntt 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/debug.cpp: -------------------------------------------------------------------------------- 1 | #include "wrapper.h" 2 | #include "io/input.h" 3 | #include "sim_params.h" 4 | #include "meshblock/meshblock.h" 5 | #include "particle_macros.h" 6 | 7 | #include "problem_generator.hpp" 8 | 9 | #include 10 | 11 | namespace ntt { 12 | 13 | template <> 14 | void ProblemGenerator::UserInitFields(const SimulationParams&, 15 | Meshblock& mblock) { 16 | 17 | Kokkos::parallel_for( 18 | "UserInitFlds", mblock.rangeActiveCells(), Lambda(index_t i, index_t j) { 19 | real_t i_ {(real_t)(static_cast(i) - N_GHOSTS)}, 20 | j_ {(real_t)(static_cast(j) - N_GHOSTS)}; 21 | real_t ex2_hat {0.1}, bx3_hat {1.0}; 22 | vec_t e_cntrv, b_cntrv; 23 | mblock.metric.v_Hat2Cntrv({i_ + HALF, j_}, {ZERO, ex2_hat, ZERO}, e_cntrv); 24 | mblock.metric.v_Hat2Cntrv({i_ + HALF, j_ + HALF}, {ZERO, ZERO, bx3_hat}, b_cntrv); 25 | mblock.em(i, j, em::ex1) = ZERO; 26 | mblock.em(i, j, em::ex2) = ZERO; 27 | mblock.em(i, j, em::ex3) = ZERO; 28 | mblock.em(i, j, em::bx1) = ZERO; 29 | mblock.em(i, j, em::bx2) = ZERO; 30 | mblock.em(i, j, em::bx3) = ZERO; 31 | }); 32 | } 33 | 34 | template <> 35 | void ProblemGenerator::UserInitParticles(const SimulationParams&, 36 | Meshblock& mblock) { 37 | auto& electrons = mblock.particles[0]; 38 | auto& positrons = mblock.particles[1]; 39 | auto random_pool = *(mblock.random_pool_ptr); 40 | Kokkos::parallel_for( 41 | "UserInitPrtls", CreateRangePolicy({0}, {1}), Lambda(index_t p) { 42 | typename RandomNumberPool_t::generator_type rand_gen = random_pool.get_state(); 43 | real_t rx = rand_gen.frand((real_t)(-2.0), (real_t)(2.0)); 44 | real_t ry = rand_gen.frand((real_t)(-2.0), (real_t)(2.0)); 45 | init_prtl_2d_XYZ(mblock, electrons, p, rx, ry, 1.0, 0.0, 0.0); 46 | init_prtl_2d_XYZ(mblock, positrons, p, rx, ry, 1.0, 0.0, 0.0); 47 | // init_prtl_2d_XYZ(&mblock, 2, p, 0.1, 0.12, 1.0, 0.0, 0.0); 48 | // init_prtl_2d_XYZ(&mblock, 3, p, 0.1, 0.12, 1.0, 0.0, 0.0); 49 | }); 50 | electrons.setNpart(1); 51 | positrons.setNpart(1); 52 | // mblock.particles[2].setNpart(1); 53 | // mblock.particles[3].setNpart(1); 54 | } 55 | // 1D 56 | template <> 57 | void ProblemGenerator::UserInitFields(const SimulationParams&, 58 | Meshblock&) {} 59 | template <> 60 | void ProblemGenerator::UserInitParticles(const SimulationParams&, 61 | Meshblock&) {} 62 | 63 | // 3D 64 | template <> 65 | void ProblemGenerator::UserInitFields(const SimulationParams&, 66 | Meshblock&) {} 67 | template <> 68 | void ProblemGenerator::UserInitParticles(const SimulationParams&, 69 | Meshblock&) {} 70 | 71 | } // namespace ntt 72 | 73 | template struct ntt::ProblemGenerator; 74 | template struct ntt::ProblemGenerator; 75 | template struct ntt::ProblemGenerator; 76 | -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/debug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "wrapper.h" 5 | #include "sim_params.h" 6 | #include "meshblock/meshblock.h" 7 | 8 | namespace ntt { 9 | 10 | template 11 | struct ProblemGenerator { 12 | ProblemGenerator(const SimulationParams&) {} 13 | 14 | void UserInitFields(const SimulationParams&, Meshblock&); 15 | void UserInitParticles(const SimulationParams&, Meshblock&); 16 | void UserBCFields(const real_t&, const SimulationParams&, Meshblock&); 17 | Inline auto UserTargetField_br_hat(const Meshblock&, const coord_t&) const 18 | -> real_t { 19 | return ZERO; 20 | } 21 | void UserDriveParticles(const real_t&, const SimulationParams&, Meshblock&) {} 22 | }; 23 | 24 | } // namespace ntt 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/deposit.cpp: -------------------------------------------------------------------------------- 1 | #include "wrapper.h" 2 | #include "io/input.h" 3 | #include "sim_params.h" 4 | #include "meshblock/meshblock.h" 5 | 6 | #include "problem_generator.hpp" 7 | 8 | #include 9 | 10 | namespace ntt { 11 | 12 | template <> 13 | void ProblemGenerator::userInitFields( 14 | const SimulationParams&, Meshblock& mblock) { 15 | 16 | Kokkos::parallel_for( 17 | "userInitFlds", mblock.rangeActiveCells(), Lambda(index_t i, index_t j) { 18 | real_t i_ {(real_t)(static_cast(i) - N_GHOSTS)}, 19 | j_ {(real_t)(static_cast(j) - N_GHOSTS)}; 20 | // real_t ex2_hat {0.1}, bx3_hat {1.0}; 21 | // vec_t e_cntrv, b_cntrv; 22 | // mblock.metric.v_Hat2Cntrv({i_ + HALF, j_}, {ZERO, ex2_hat, ZERO}, e_cntrv); 23 | // mblock.metric.v_Hat2Cntrv({i_ + HALF, j_ + HALF}, {ZERO, ZERO, bx3_hat}, b_cntrv); 24 | mblock.em(i, j, em::ex1) = ZERO; 25 | mblock.em(i, j, em::ex2) = ZERO; // e_cntrv[1]; 26 | mblock.em(i, j, em::ex3) = ZERO; 27 | mblock.em(i, j, em::bx1) = ZERO; 28 | mblock.em(i, j, em::bx2) = ZERO; 29 | mblock.em(i, j, em::bx3) = ZERO; // b_cntrv[2]; 30 | }); 31 | } 32 | 33 | template <> 34 | void ProblemGenerator::userInitParticles( 35 | const SimulationParams&, Meshblock& mblock) { 36 | 37 | Kokkos::parallel_for( 38 | "userInitPrtls", CreateRangePolicy({0}, {1}), Lambda(index_t p) { 39 | coord_t x {0.0, 0.0}, x_CU; 40 | mblock.metric.x_Cart2Code(x, x_CU); 41 | auto [i1, dx1] = mblock.metric.CU_to_Idi(x_CU[0]); 42 | auto [i2, dx2] = mblock.metric.CU_to_Idi(x_CU[1]); 43 | // electron 44 | mblock.particles[0].i1(p) = i1; 45 | mblock.particles[0].i2(p) = i2; 46 | mblock.particles[0].dx1(p) = dx1; 47 | mblock.particles[0].dx2(p) = dx2; 48 | // mblock.particles[0].ux1(p) = -2.0; 49 | // mblock.particles[0].ux2(p) = -5.0; 50 | mblock.particles[0].ux1(p) = 12.0; 51 | // positron 52 | mblock.particles[1].i1(p) = i1; 53 | mblock.particles[1].i2(p) = i2; 54 | mblock.particles[1].dx1(p) = dx1; 55 | mblock.particles[1].dx2(p) = dx2; 56 | // mblock.particles[0].ux1(p) = -2.0; 57 | // mblock.particles[0].ux2(p) = 6.0; 58 | // mblock.particles[1].ux3(p) = 0.0; 59 | }); 60 | mblock.particles[0].setNpart(1); 61 | mblock.particles[1].setNpart(1); 62 | } 63 | // 1D 64 | template <> 65 | void ProblemGenerator::userInitFields( 66 | const SimulationParams&, Meshblock&) {} 67 | template <> 68 | void ProblemGenerator::userInitParticles( 69 | const SimulationParams&, Meshblock&) {} 70 | 71 | // 3D 72 | template <> 73 | void ProblemGenerator::userInitFields( 74 | const SimulationParams&, Meshblock&) {} 75 | template <> 76 | void ProblemGenerator::userInitParticles( 77 | const SimulationParams&, Meshblock&) {} 78 | 79 | } // namespace ntt 80 | 81 | template struct ntt::ProblemGenerator; 82 | template struct ntt::ProblemGenerator; 83 | template struct ntt::ProblemGenerator; -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/deposit.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "wrapper.h" 5 | #include "sim_params.h" 6 | #include "meshblock/meshblock.h" 7 | 8 | namespace ntt { 9 | 10 | template 11 | struct ProblemGenerator { 12 | ProblemGenerator(const SimulationParams&) {} 13 | 14 | void userInitFields(const SimulationParams&, Meshblock&); 15 | void userInitParticles(const SimulationParams&, Meshblock&); 16 | void userBCFields(const real_t&, const SimulationParams&, Meshblock&); 17 | Inline auto userTargetField_br_hat(const Meshblock&, const coord_t&) const 18 | -> real_t { 19 | return ZERO; 20 | } 21 | }; 22 | } // namespace ntt 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/em.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "wrapper.h" 5 | #include "sim_params.h" 6 | #include "meshblock/meshblock.h" 7 | 8 | namespace ntt { 9 | 10 | template 11 | struct ProblemGenerator { 12 | ProblemGenerator(const SimulationParams&); 13 | 14 | void UserInitFields(const SimulationParams&, Meshblock&); 15 | void UserInitParticles(const SimulationParams&, Meshblock&); 16 | void UserBCFields(const real_t&, const SimulationParams&, Meshblock&); 17 | Inline auto UserTargetField_br_hat(const Meshblock&, const coord_t&) const 18 | -> real_t; 19 | void UserDriveParticles(const real_t&, const SimulationParams&, Meshblock&); 20 | 21 | private: 22 | int m_nx1, m_nx2; 23 | real_t m_amplitude; 24 | }; 25 | 26 | } // namespace ntt 27 | 28 | #endif -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/oneprtl.cpp: -------------------------------------------------------------------------------- 1 | #include "wrapper.h" 2 | #include "io/input.h" 3 | #include "sim_params.h" 4 | #include "meshblock/meshblock.h" 5 | #include "particle_macros.h" 6 | 7 | #include "problem_generator.hpp" 8 | 9 | #include 10 | 11 | namespace ntt { 12 | 13 | template <> 14 | ProblemGenerator::ProblemGenerator(const SimulationParams&) {} 15 | 16 | template <> 17 | void ProblemGenerator::UserInitFields(const SimulationParams&, 18 | Meshblock& mblock) { 19 | Kokkos::parallel_for( 20 | "UserInitFlds", mblock.rangeActiveCells(), Lambda(index_t i, index_t j) { 21 | real_t i_ {(real_t)(static_cast(i) - N_GHOSTS)}, 22 | j_ {(real_t)(static_cast(j) - N_GHOSTS)}; 23 | // real_t ex2_hat {0.1}, bx3_hat {1.0}; 24 | vec_t e_cntrv; 25 | mblock.metric.v_Hat2Cntrv({i_, j_}, {1e-4, ZERO, ZERO}, e_cntrv); 26 | mblock.em(i, j, em::ex1) = e_cntrv[0]; 27 | // mblock.em(i, j, em::ex2) = e_cntrv[1]; 28 | // mblock.em(i, j, em::ex3) = ZERO; 29 | // mblock.em(i, j, em::bx1) = ZERO; 30 | // mblock.em(i, j, em::bx2) = ZERO; 31 | // mblock.em(i, j, em::bx3) = b_cntrv[2]; 32 | }); 33 | } 34 | 35 | template <> 36 | void ProblemGenerator::UserInitParticles(const SimulationParams&, 37 | Meshblock& mblock) { 38 | auto& electrons = mblock.particles[0]; 39 | // auto& positrons = mblock.particles[1]; 40 | electrons.setNpart(1); 41 | // positrons.setNpart(1); 42 | Kokkos::parallel_for( 43 | "UserInitPrtls", CreateRangePolicy({0}, {1}), Lambda(index_t p) { 44 | real_t rx = 0.0, ry = 0.0; 45 | init_prtl_2d_XYZ(mblock, electrons, p, rx, ry, 0.0, 0.0, 0.0); 46 | // init_prtl_2d_XYZ(mblock, positrons, p, rx, ry, 1.0, 0.0, 0.0); 47 | }); 48 | } 49 | 50 | template <> 51 | void ProblemGenerator::UserDriveParticles(const real_t&, 52 | const SimulationParams&, 53 | Meshblock&) {} 54 | 55 | template <> 56 | void ProblemGenerator::UserBCFields(const real_t&, 57 | const SimulationParams&, 58 | Meshblock&) {} 59 | template <> 60 | Inline auto ProblemGenerator::UserTargetField_br_hat( 61 | const Meshblock&, const coord_t&) const -> real_t { 62 | return ZERO; 63 | } 64 | 65 | // clang-format off 66 | @PgenPlaceholder1D@ 67 | @PgenPlaceholder3D@ 68 | // clang-format on 69 | 70 | } // namespace ntt 71 | 72 | template struct ntt::ProblemGenerator; 73 | template struct ntt::ProblemGenerator; 74 | template struct ntt::ProblemGenerator; 75 | -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/oneprtl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "wrapper.h" 5 | #include "sim_params.h" 6 | #include "meshblock/meshblock.h" 7 | 8 | namespace ntt { 9 | 10 | template 11 | struct ProblemGenerator { 12 | ProblemGenerator(const SimulationParams&); 13 | 14 | void UserInitFields(const SimulationParams&, Meshblock&); 15 | void UserInitParticles(const SimulationParams&, Meshblock&); 16 | void UserBCFields(const real_t&, const SimulationParams&, Meshblock&); 17 | Inline auto UserTargetField_br_hat(const Meshblock&, const coord_t&) const 18 | -> real_t; 19 | void UserDriveParticles(const real_t&, const SimulationParams&, Meshblock&); 20 | }; 21 | 22 | } // namespace ntt 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /legacy/src/pic/pgen/old/oneprtl_sph.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "wrapper.h" 5 | #include "sim_params.h" 6 | #include "meshblock/meshblock.h" 7 | 8 | namespace ntt { 9 | 10 | template 11 | struct ProblemGenerator { 12 | ProblemGenerator(const SimulationParams&) {} 13 | 14 | void UserInitFields(const SimulationParams&, Meshblock&); 15 | void UserInitParticles(const SimulationParams&, Meshblock&); 16 | void UserBCFields(const real_t&, const SimulationParams&, Meshblock&); 17 | Inline auto UserTargetField_br_hat(const Meshblock&, const coord_t&) const 18 | -> real_t { 19 | return ZERO; 20 | } 21 | void UserDriveParticles(const real_t&, const SimulationParams&, Meshblock&); 22 | }; 23 | 24 | } // namespace ntt 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /setups/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # @defines: ntt_pgen [INTERFACE] 3 | # @includes: 4 | # - ../ 5 | # @depends: 6 | # - ntt_pgen [required] 7 | # @uses: 8 | # - kokkos [required] 9 | # - plog [required] 10 | # - mpi [optional] 11 | # ------------------------------ 12 | 13 | add_library(ntt_pgen INTERFACE) 14 | target_link_libraries(ntt_pgen INTERFACE 15 | ntt_global 16 | ntt_framework 17 | ntt_archetypes 18 | ntt_kernels 19 | ) 20 | 21 | target_include_directories(ntt_pgen 22 | INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${PGEN} 23 | ) -------------------------------------------------------------------------------- /setups/grpic/pgen_grpic_example.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/traits.h" 8 | 9 | #include "archetypes/problem_generator.h" 10 | 11 | namespace user { 12 | using namespace ntt; 13 | 14 | template 15 | struct PGen : public ProblemGenerator { 16 | // compatibility traits for the problem generator 17 | static constexpr auto engines { traits::compatible_with::value }; 18 | static constexpr auto metrics { 19 | traits::compatible_with::value 20 | }; 21 | static constexpr auto dimensions { traits::compatible_with::value }; 22 | 23 | // for easy access to variables in the child class 24 | using ProblemGenerator::D; 25 | using ProblemGenerator::C; 26 | using ProblemGenerator::params; 27 | using ProblemGenerator::domain; 28 | 29 | inline PGen(SimulationParams& p, const Metadomain&) : 30 | ProblemGenerator(p) {} 31 | 32 | inline PGen() {} 33 | }; 34 | 35 | } // namespace user 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /setups/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/traits.h" 8 | #include "utils/formatting.h" 9 | 10 | #include "archetypes/problem_generator.h" 11 | #include "framework/domain/metadomain.h" 12 | 13 | #include 14 | 15 | namespace user { 16 | using namespace ntt; 17 | 18 | template 19 | struct PGen : public arch::ProblemGenerator { 20 | // compatibility traits for the problem generator 21 | static constexpr auto engines { 22 | traits::compatible_with::value 23 | }; 24 | static constexpr auto metrics { 25 | traits::compatible_with::value 31 | }; 32 | static constexpr auto dimensions { 33 | traits::compatible_with::value 34 | }; 35 | 36 | // for easy access to variables in the child class 37 | using arch::ProblemGenerator::D; 38 | using arch::ProblemGenerator::C; 39 | using arch::ProblemGenerator::params; 40 | 41 | inline PGen(const SimulationParams& p, const Metadomain&) 42 | : arch::ProblemGenerator { p } { 43 | const auto message = fmt::format( 44 | "Problem generator initialized with `%s` engine and `%dD %s` metric", 45 | SimEngine(S).to_string(), 46 | D, 47 | Metric(M::MetricType).to_string()); 48 | PLOGI << message; 49 | } 50 | }; 51 | 52 | } // namespace user 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /setups/srpic/em_vacuum/em_vacuum.py: -------------------------------------------------------------------------------- 1 | import nt2.read as nt2r 2 | import matplotlib.pyplot as plt 3 | 4 | data = nt2r.Data("em_vacuum.h5") 5 | 6 | 7 | def plot(ti): 8 | fig = plt.figure(figsize=(10, 5), dpi=150) 9 | ax = fig.add_subplot(121) 10 | data.Bz.isel(t=ti).plot(ax=ax, cmap="BrBG") 11 | ax = fig.add_subplot(122) 12 | data.Ey.isel(t=ti).plot(ax=ax, cmap="RdBu_r") 13 | for ax in fig.axes[::2]: 14 | ax.set_aspect("equal") 15 | -------------------------------------------------------------------------------- /setups/srpic/em_vacuum/em_vacuum.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "em_vacuum" 3 | engine = "srpic" 4 | runtime = 2.0 5 | 6 | [grid] 7 | resolution = [256, 512] 8 | extent = [[-1.0, 1.0], [-2.0, 2.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 0.1 19 | skindepth0 = 0.01 20 | 21 | [algorithms] 22 | 23 | [algorithms.timestep] 24 | CFL = 0.5 25 | 26 | [particles] 27 | ppc0 = 1.0 28 | 29 | [setup] 30 | amplitude = 1.0 31 | kx1 = 1 32 | kx2 = 1 33 | kx3 = 0 34 | 35 | [output] 36 | format = "hdf5" 37 | interval_time = 0.1 38 | 39 | [output.fields] 40 | quantities = ["E", "B"] 41 | 42 | [diagnostics] 43 | colored_stdout = true 44 | -------------------------------------------------------------------------------- /setups/srpic/langmuir/langmuir.py: -------------------------------------------------------------------------------- 1 | import nt2.read as nt2r 2 | import matplotlib.pyplot as plt 3 | 4 | data = nt2r.Data("langmuir.h5") 5 | 6 | 7 | def plot(ti, d): 8 | # for 2D 9 | fig = plt.figure(figsize=(10, 5), dpi=150) 10 | ax = fig.add_subplot(211) 11 | d.Rho.isel(t=ti).plot(ax=ax, cmap="inferno", vmin=0, vmax=4) 12 | ax = fig.add_subplot(212) 13 | d.Ex.isel(t=ti).plot(ax=ax, cmap="RdBu_r", vmin=-1, vmax=1) 14 | for ax in fig.get_axes()[::2]: 15 | ax.set_aspect("equal") 16 | fig.get_axes()[0].set(xlabel="", xticks=[]) 17 | fig.get_axes()[2].set(title=None) 18 | -------------------------------------------------------------------------------- /setups/srpic/langmuir/langmuir.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "langmuir" 3 | engine = "srpic" 4 | runtime = 1.0 5 | 6 | [grid] 7 | resolution = [2048, 512] 8 | extent = [[0.0, 1.0], [0.0, 0.25]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 0.1 19 | skindepth0 = 0.01 20 | 21 | [algorithms] 22 | current_filters = 4 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 14.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e7 35 | 36 | [[particles.species]] 37 | label = "e+" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e7 41 | 42 | [setup] 43 | vmax = 0.1 44 | nx1 = 4 45 | nx2 = 2 46 | 47 | [output] 48 | format = "hdf5" 49 | interval_time = 0.0025 50 | 51 | [output.fields] 52 | quantities = ["Rho", "E"] 53 | 54 | [diagnostics] 55 | colored_stdout = true 56 | -------------------------------------------------------------------------------- /setups/srpic/magnetar/magnetar.py: -------------------------------------------------------------------------------- 1 | import nt2.read as nt2r 2 | import matplotlib as mpl 3 | 4 | data = nt2r.Data("magnetar.h5") 5 | 6 | def plot (ti, data): 7 | (data.Bph*(data.r*np.sin(data.th))).isel(t=ti).polar.pcolor( 8 | norm=mpl.colors.Normalize(vmin=-0.075, vmax=0.075), 9 | cmap="PuOr") -------------------------------------------------------------------------------- /setups/srpic/magnetar/magnetar.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "magnetar" 3 | engine = "srpic" 4 | runtime = 50.0 5 | 6 | [grid] 7 | resolution = [2048,1024] 8 | extent = [[1.0, 400.0]] 9 | 10 | [grid.metric] 11 | metric = "qspherical" 12 | 13 | [grid.boundaries] 14 | fields = [["ATMOSPHERE", "ABSORB"]] 15 | particles = [["ATMOSPHERE", "ABSORB"]] 16 | 17 | [grid.boundaries.absorb] 18 | ds = 1.0 19 | 20 | [grid.boundaries.atmosphere] 21 | temperature = 0.1 22 | density = 40.0 23 | height = 0.02 24 | species = [1, 2] 25 | ds = 0.5 26 | 27 | [scales] 28 | larmor0 = 1e-5 29 | skindepth0 = 0.01 30 | 31 | [algorithms] 32 | current_filters = 4 33 | 34 | [algorithms.timestep] 35 | CFL = 0.5 36 | 37 | [algorithms.gca] 38 | e_ovr_b_max = 0.9 39 | larmor_max = 100.0 40 | 41 | [particles] 42 | ppc0 = 4.0 43 | use_weights = true 44 | sort_interval = 100 45 | 46 | [[particles.species]] 47 | label = "e-" 48 | mass = 1.0 49 | charge = -1.0 50 | maxnpart = 5e7 51 | pusher = "Boris,GCA" 52 | 53 | [[particles.species]] 54 | label = "e+" 55 | mass = 1.0 56 | charge = 1.0 57 | maxnpart = 5e7 58 | pusher = "Boris,GCA" 59 | 60 | [[particles.species]] 61 | label = "e-" 62 | mass = 1.0 63 | charge = -1.0 64 | maxnpart = 5e7 65 | pusher = "Boris,GCA" 66 | 67 | [[particles.species]] 68 | label = "e+" 69 | mass = 1.0 70 | charge = 1.0 71 | maxnpart = 5e7 72 | pusher = "Boris,GCA" 73 | 74 | [[particles.species]] 75 | label = "e-" 76 | mass = 1.0 77 | charge = -1.0 78 | maxnpart = 5e7 79 | pusher = "Boris,GCA" 80 | 81 | [[particles.species]] 82 | label = "e+" 83 | mass = 1.0 84 | charge = 1.0 85 | maxnpart = 5e7 86 | pusher = "Boris,GCA" 87 | 88 | [setup] 89 | Bsurf = 1.0 90 | omega = 0.0125 91 | pp_thres = 10.0 92 | gamma_pairs = 1.75 93 | 94 | [output] 95 | format = "hdf5" 96 | 97 | [output.fields] 98 | interval_time = 0.5 99 | quantities = ["N_1", "N_2", "N_3", "N_4", "N_5", "N_6", "B", "E", "J"] 100 | 101 | [output.particles] 102 | enable = false 103 | 104 | [output.spectra] 105 | enable = false 106 | 107 | [diagnostics] 108 | interval = 1 109 | -------------------------------------------------------------------------------- /setups/srpic/magnetosphere/magnetosphere.py: -------------------------------------------------------------------------------- 1 | import nt2.read as nt2r 2 | import matplotlib as mpl 3 | 4 | data = nt2r.Data("magnetosphere.h5") 5 | 6 | def plot (ti, data): 7 | (data.N_2 - data.N_1).isel(t=ti).polar.pcolor( 8 | norm=mpl.colors.SymLogNorm(vmin=-5, vmax=5, linthresh=1e-2, linscale=1), 9 | cmap="RdBu_r") -------------------------------------------------------------------------------- /setups/srpic/magnetosphere/magnetosphere.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "magnetosphere" 3 | engine = "srpic" 4 | runtime = 60.0 5 | 6 | [grid] 7 | resolution = [2048, 1024] 8 | extent = [[1.0, 50.0]] 9 | 10 | [grid.metric] 11 | metric = "qspherical" 12 | 13 | [grid.boundaries] 14 | fields = [["ATMOSPHERE", "ABSORB"]] 15 | particles = [["ATMOSPHERE", "ABSORB"]] 16 | 17 | [grid.boundaries.absorb] 18 | ds = 1.0 19 | 20 | [grid.boundaries.atmosphere] 21 | temperature = 0.1 22 | density = 10.0 23 | height = 0.02 24 | species = [1, 2] 25 | ds = 2.0 26 | 27 | [scales] 28 | larmor0 = 2e-5 29 | skindepth0 = 0.01 30 | 31 | [algorithms] 32 | current_filters = 4 33 | 34 | [algorithms.timestep] 35 | CFL = 0.5 36 | 37 | [algorithms.gca] 38 | e_ovr_b_max = 0.9 39 | larmor_max = 1.0 40 | 41 | [particles] 42 | ppc0 = 5.0 43 | use_weights = true 44 | sort_interval = 100 45 | 46 | [[particles.species]] 47 | label = "e-" 48 | mass = 1.0 49 | charge = -1.0 50 | maxnpart = 1e8 51 | pusher = "Boris,GCA" 52 | 53 | [[particles.species]] 54 | label = "e+" 55 | mass = 1.0 56 | charge = 1.0 57 | maxnpart = 1e8 58 | pusher = "Boris,GCA" 59 | 60 | [setup] 61 | Bsurf = 1.0 62 | period = 60.0 63 | 64 | [output] 65 | format = "hdf5" 66 | 67 | [output.fields] 68 | interval_time = 0.1 69 | quantities = ["N_1", "N_2", "E", "B", "T00"] 70 | 71 | [output.particles] 72 | enable = false 73 | 74 | [output.spectra] 75 | enable = false 76 | 77 | [diagnostics] 78 | interval = 50 79 | colored_stdout = true 80 | -------------------------------------------------------------------------------- /setups/srpic/magnetosphere/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/kokkos_aliases.h" 8 | #include "arch/traits.h" 9 | 10 | #include "archetypes/problem_generator.h" 11 | #include "framework/domain/metadomain.h" 12 | 13 | namespace user { 14 | using namespace ntt; 15 | 16 | template 17 | struct InitFields { 18 | InitFields(real_t bsurf, real_t rstar) : Bsurf { bsurf }, Rstar { rstar } {} 19 | 20 | Inline auto bx1(const coord_t& x_Ph) const -> real_t { 21 | return Bsurf * math::cos(x_Ph[1]) / CUBE(x_Ph[0] / Rstar); 22 | } 23 | 24 | Inline auto bx2(const coord_t& x_Ph) const -> real_t { 25 | return Bsurf * HALF * math::sin(x_Ph[1]) / CUBE(x_Ph[0] / Rstar); 26 | } 27 | 28 | private: 29 | const real_t Bsurf, Rstar; 30 | }; 31 | 32 | template 33 | struct DriveFields : public InitFields { 34 | DriveFields(real_t time, real_t bsurf, real_t rstar, real_t omega) 35 | : InitFields { bsurf, rstar } 36 | , time { time } 37 | , Omega { omega } {} 38 | 39 | using InitFields::bx1; 40 | using InitFields::bx2; 41 | 42 | Inline auto bx3(const coord_t&) const -> real_t { 43 | return ZERO; 44 | } 45 | 46 | Inline auto ex1(const coord_t& x_Ph) const -> real_t { 47 | return Omega * bx2(x_Ph) * x_Ph[0] * math::sin(x_Ph[1]); 48 | } 49 | 50 | Inline auto ex2(const coord_t& x_Ph) const -> real_t { 51 | return -Omega * bx1(x_Ph) * x_Ph[0] * math::sin(x_Ph[1]); 52 | } 53 | 54 | Inline auto ex3(const coord_t&) const -> real_t { 55 | return ZERO; 56 | } 57 | 58 | private: 59 | const real_t time, Omega; 60 | }; 61 | 62 | template 63 | struct PGen : public arch::ProblemGenerator { 64 | // compatibility traits for the problem generator 65 | static constexpr auto engines { traits::compatible_with::value }; 66 | static constexpr auto metrics { 67 | traits::compatible_with::value 68 | }; 69 | static constexpr auto dimensions { traits::compatible_with::value }; 70 | 71 | // for easy access to variables in the child class 72 | using arch::ProblemGenerator::D; 73 | using arch::ProblemGenerator::C; 74 | using arch::ProblemGenerator::params; 75 | 76 | const real_t Bsurf, Rstar, Omega; 77 | InitFields init_flds; 78 | 79 | inline PGen(const SimulationParams& p, const Metadomain& m) 80 | : arch::ProblemGenerator(p) 81 | , Bsurf { p.template get("setup.Bsurf", ONE) } 82 | , Rstar { m.mesh().extent(in::x1).first } 83 | , Omega { static_cast(constant::TWO_PI) / 84 | p.template get("setup.period", ONE) } 85 | , init_flds { Bsurf, Rstar } {} 86 | 87 | inline PGen() {} 88 | 89 | auto FieldDriver(real_t time) const -> DriveFields { 90 | return DriveFields { time, Bsurf, Rstar, Omega }; 91 | } 92 | }; 93 | 94 | } // namespace user 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /setups/srpic/monopole/monopole.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "monopole" 3 | engine = "srpic" 4 | runtime = 60.0 5 | 6 | [grid] 7 | resolution = [2048, 1024] 8 | extent = [[1.0, 50.0]] 9 | 10 | [grid.metric] 11 | metric = "qspherical" 12 | 13 | [grid.boundaries] 14 | fields = [["ATMOSPHERE", "ABSORB"]] 15 | particles = [["ATMOSPHERE", "ABSORB"]] 16 | 17 | [grid.boundaries.absorb] 18 | ds = 1.0 19 | 20 | [grid.boundaries.atmosphere] 21 | temperature = 0.1 22 | density = 10.0 23 | height = 0.02 24 | species = [1, 2] 25 | ds = 2.0 26 | 27 | [scales] 28 | larmor0 = 2e-5 29 | skindepth0 = 0.01 30 | 31 | [algorithms] 32 | current_filters = 4 33 | 34 | [algorithms.timestep] 35 | CFL = 0.5 36 | 37 | [algorithms.gca] 38 | e_ovr_b_max = 0.9 39 | larmor_max = 1.0 40 | 41 | [particles] 42 | ppc0 = 5.0 43 | use_weights = true 44 | sort_interval = 100 45 | 46 | [[particles.species]] 47 | label = "e-" 48 | mass = 1.0 49 | charge = -1.0 50 | maxnpart = 1e8 51 | pusher = "Boris,GCA" 52 | 53 | [[particles.species]] 54 | label = "e+" 55 | mass = 1.0 56 | charge = 1.0 57 | maxnpart = 1e8 58 | pusher = "Boris,GCA" 59 | 60 | [setup] 61 | Bsurf = 1.0 62 | period = 60.0 63 | 64 | [output] 65 | format = "hdf5" 66 | 67 | [output.fields] 68 | interval_time = 0.1 69 | quantities = ["N_1", "N_2", "E", "B", "T00"] 70 | mom_smooth = 2 71 | 72 | [output.particles] 73 | enable = false 74 | 75 | [output.spectra] 76 | enable = false 77 | 78 | [diagnostics] 79 | interval = 50 80 | colored_stdout = true 81 | -------------------------------------------------------------------------------- /setups/srpic/monopole/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/kokkos_aliases.h" 8 | #include "arch/traits.h" 9 | #include "utils/numeric.h" 10 | 11 | #include "archetypes/problem_generator.h" 12 | #include "framework/domain/metadomain.h" 13 | 14 | namespace user { 15 | using namespace ntt; 16 | 17 | template 18 | struct InitFields { 19 | InitFields(real_t bsurf, real_t rstar) : Bsurf { bsurf }, Rstar { rstar } {} 20 | 21 | Inline auto bx1(const coord_t& x_Ph) const -> real_t { 22 | return Bsurf * SQR(Rstar / x_Ph[0]); 23 | } 24 | 25 | private: 26 | const real_t Bsurf, Rstar; 27 | }; 28 | 29 | template 30 | struct DriveFields : public InitFields { 31 | DriveFields(real_t time, real_t bsurf, real_t rstar, real_t omega) 32 | : InitFields { bsurf, rstar } 33 | , time { time } 34 | , Omega { omega } {} 35 | 36 | using InitFields::bx1; 37 | 38 | Inline auto bx2(const coord_t&) const -> real_t { 39 | return ZERO; 40 | } 41 | 42 | Inline auto bx3(const coord_t&) const -> real_t { 43 | return ZERO; 44 | } 45 | 46 | Inline auto ex1(const coord_t& x_Ph) const -> real_t { 47 | return ZERO; 48 | } 49 | 50 | Inline auto ex2(const coord_t& x_Ph) const -> real_t { 51 | return -Omega * bx1(x_Ph) * x_Ph[0] * math::sin(x_Ph[1]); 52 | } 53 | 54 | Inline auto ex3(const coord_t&) const -> real_t { 55 | return ZERO; 56 | } 57 | 58 | private: 59 | const real_t time, Omega; 60 | }; 61 | 62 | template 63 | struct PGen : public arch::ProblemGenerator { 64 | // compatibility traits for the problem generator 65 | static constexpr auto engines { traits::compatible_with::value }; 66 | static constexpr auto metrics { 67 | traits::compatible_with::value 68 | }; 69 | static constexpr auto dimensions { traits::compatible_with::value }; 70 | 71 | // for easy access to variables in the child class 72 | using arch::ProblemGenerator::D; 73 | using arch::ProblemGenerator::C; 74 | using arch::ProblemGenerator::params; 75 | 76 | const real_t Bsurf, Rstar, Omega; 77 | InitFields init_flds; 78 | 79 | inline PGen(const SimulationParams& p, const Metadomain& m) 80 | : arch::ProblemGenerator(p) 81 | , Bsurf { p.template get("setup.Bsurf", ONE) } 82 | , Rstar { m.mesh().extent(in::x1).first } 83 | , Omega { static_cast(constant::TWO_PI) / 84 | p.template get("setup.period", ONE) } 85 | , init_flds { Bsurf, Rstar } {} 86 | 87 | inline PGen() {} 88 | 89 | auto FieldDriver(real_t time) const -> DriveFields { 90 | return DriveFields { time, Bsurf, Rstar, Omega }; 91 | } 92 | }; 93 | 94 | } // namespace user 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /setups/srpic/pgen_srpic_example.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/traits.h" 8 | 9 | #include "archetypes/problem_generator.h" 10 | #include "framework/domain/metadomain.h" 11 | 12 | namespace user { 13 | using namespace ntt; 14 | 15 | template 16 | struct PGen : public arch::ProblemGenerator { 17 | // compatibility traits for the problem generator 18 | static constexpr auto engines { traits::compatible_with::value }; 19 | static constexpr auto metrics { 20 | traits::compatible_with::value 21 | }; 22 | static constexpr auto dimensions { 23 | traits::compatible_with::value 24 | }; 25 | 26 | // for easy access to variables in the child class 27 | using arch::ProblemGenerator::D; 28 | using arch::ProblemGenerator::C; 29 | using arch::ProblemGenerator::params; 30 | 31 | inline PGen(const SimulationParams& p, const Metadomain&) 32 | : arch::ProblemGenerator(p) {} 33 | 34 | inline PGen() {} 35 | }; 36 | 37 | } // namespace user 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /setups/srpic/shock/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/traits.h" 8 | 9 | #include "archetypes/energy_dist.h" 10 | #include "archetypes/particle_injector.h" 11 | #include "archetypes/problem_generator.h" 12 | #include "framework/domain/metadomain.h" 13 | 14 | namespace user { 15 | using namespace ntt; 16 | 17 | template 18 | struct PGen : public arch::ProblemGenerator { 19 | // compatibility traits for the problem generator 20 | static constexpr auto engines { traits::compatible_with::value }; 21 | static constexpr auto metrics { traits::compatible_with::value }; 22 | static constexpr auto dimensions { 23 | traits::compatible_with::value 24 | }; 25 | 26 | // for easy access to variables in the child class 27 | using arch::ProblemGenerator::D; 28 | using arch::ProblemGenerator::C; 29 | using arch::ProblemGenerator::params; 30 | 31 | const real_t drift_ux, temperature; 32 | 33 | inline PGen(const SimulationParams& p, const Metadomain& m) 34 | : arch::ProblemGenerator(p) 35 | , drift_ux { p.template get("setup.drift_ux") } 36 | , temperature { p.template get("setup.temperature") } {} 37 | 38 | inline PGen() {} 39 | 40 | inline void InitPrtls(Domain& local_domain) { 41 | const auto energy_dist = arch::Maxwellian(local_domain.mesh.metric, 42 | local_domain.random_pool, 43 | temperature, 44 | -drift_ux, 45 | in::x1); 46 | const auto injector = arch::UniformInjector( 47 | energy_dist, 48 | { 1, 2 }); 49 | arch::InjectUniform>( 50 | params, 51 | local_domain, 52 | injector, 53 | 1.0); 54 | } 55 | }; 56 | 57 | } // namespace user 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /setups/srpic/shock/shock.py: -------------------------------------------------------------------------------- 1 | import nt2.read as nt2r 2 | import matplotlib.pyplot as plt 3 | import matplotlib as mpl 4 | 5 | data = nt2r.Data("shock-03.h5") 6 | 7 | 8 | def frame(ti, f): 9 | quantities = [ 10 | { 11 | "name": "density", 12 | "compute": lambda f: f.N_2 + f.N_1, 13 | "cmap": "inferno", 14 | "norm": mpl.colors.Normalize(0, 5), 15 | }, 16 | { 17 | "name": r"$E_x$", 18 | "compute": lambda f: f.Ex, 19 | "cmap": "RdBu_r", 20 | "norm": mpl.colors.Normalize(-0.05, 0.05), 21 | }, 22 | { 23 | "name": r"$E_y$", 24 | "compute": lambda f: f.Ey, 25 | "cmap": "RdBu_r", 26 | "norm": mpl.colors.Normalize(-0.05, 0.05), 27 | }, 28 | { 29 | "name": r"$E_z$", 30 | "compute": lambda f: f.Ez, 31 | "cmap": "RdBu_r", 32 | "norm": mpl.colors.Normalize(-0.05, 0.05), 33 | }, 34 | { 35 | "name": r"$B_x$", 36 | "compute": lambda f: f.Bx, 37 | "cmap": "BrBG", 38 | "norm": mpl.colors.Normalize(-0.05, 0.05), 39 | }, 40 | { 41 | "name": r"$B_y$", 42 | "compute": lambda f: f.By, 43 | "cmap": "BrBG", 44 | "norm": mpl.colors.Normalize(-0.05, 0.05), 45 | }, 46 | { 47 | "name": r"$B_z$", 48 | "compute": lambda f: f.Bz, 49 | "cmap": "BrBG", 50 | "norm": mpl.colors.Normalize(-0.05, 0.05), 51 | }, 52 | ] 53 | fig = plt.figure(figsize=(12, 5.5), dpi=300) 54 | gs = fig.add_gridspec(len(quantities), 1, hspace=0.02) 55 | axs = [fig.add_subplot(gs[i]) for i in range(len(quantities))] 56 | 57 | for ax, q in zip(axs, quantities): 58 | q["compute"](f).coarsen(x=2, y=2).mean().plot( 59 | ax=ax, 60 | cmap=q["cmap"], 61 | norm=q["norm"], 62 | cbar_kwargs={"label": q["name"], "shrink": 0.8, "aspect": 10, "pad": 0.005}, 63 | ) 64 | for i, ax in enumerate(axs): 65 | ax.set(aspect=1) 66 | if i != 0: 67 | ax.set(title=None) 68 | if i != len(axs) - 1: 69 | ax.set( 70 | xticks=[], 71 | xticklabels=[], 72 | xlabel=None, 73 | title=ax.get_title().split(",")[0], 74 | ) 75 | return fig 76 | -------------------------------------------------------------------------------- /setups/srpic/shock/shock.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "shock" 3 | engine = "srpic" 4 | runtime = 50.0 5 | 6 | [grid] 7 | resolution = [2048, 128] 8 | extent = [[0.0, 10.0], [-0.3125, 0.3125]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["CONDUCTOR", "ABSORB"], ["PERIODIC"]] 15 | particles = [["REFLECT", "ABSORB"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 1e-2 19 | skindepth0 = 1e-2 20 | 21 | [algorithms] 22 | current_filters = 8 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 16.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e8 35 | 36 | [[particles.species]] 37 | label = "e+" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e8 41 | 42 | [setup] 43 | drift_ux = 0.1 44 | temperature = 1e-3 45 | 46 | [output] 47 | interval_time = 0.1 48 | format = "hdf5" 49 | 50 | [output.fields] 51 | quantities = ["N_1", "N_2", "E", "B", "T0i_1", "T0i_2", "J"] 52 | -------------------------------------------------------------------------------- /setups/srpic/turbulence/turbulence.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "turbulence" 3 | engine = "srpic" 4 | runtime = 20.0 5 | 6 | [grid] 7 | resolution = [184, 184, 184] 8 | extent = [[-1.0, 1.0], [-1.0, 1.0], [-1.0, 1.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 0.02 19 | skindepth0 = 0.02 20 | 21 | [algorithms] 22 | current_filters = 4 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 32.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e8 35 | 36 | [[particles.species]] 37 | label = "e+" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e8 41 | 42 | [setup] 43 | 44 | [output] 45 | format = "hdf5" 46 | interval_time = 0.1 47 | 48 | [output.fields] 49 | quantities = ["N_1", "N_2", "E", "B", "J", "T00_1", "T00_2"] 50 | -------------------------------------------------------------------------------- /setups/srpic/weibel/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/kokkos_aliases.h" 8 | #include "arch/traits.h" 9 | 10 | #include "archetypes/energy_dist.h" 11 | #include "archetypes/particle_injector.h" 12 | #include "archetypes/problem_generator.h" 13 | #include "framework/domain/domain.h" 14 | #include "framework/domain/metadomain.h" 15 | 16 | namespace user { 17 | using namespace ntt; 18 | 19 | template 20 | struct PGen : public arch::ProblemGenerator { 21 | 22 | // compatibility traits for the problem generator 23 | static constexpr auto engines = traits::compatible_with::value; 24 | static constexpr auto metrics = traits::compatible_with::value; 25 | static constexpr auto dimensions = 26 | traits::compatible_with::value; 27 | 28 | // for easy access to variables in the child class 29 | using arch::ProblemGenerator::D; 30 | using arch::ProblemGenerator::C; 31 | using arch::ProblemGenerator::params; 32 | 33 | const real_t temp_1, temp_2; 34 | const real_t drift_u_1, drift_u_2; 35 | 36 | inline PGen(const SimulationParams& p, const Metadomain& global_domain) 37 | : arch::ProblemGenerator { p } 38 | , temp_1 { p.template get("setup.temp_1") } 39 | , temp_2 { p.template get("setup.temp_2") } 40 | , drift_u_1 { p.template get("setup.drift_u_1") } 41 | , drift_u_2 { p.template get("setup.drift_u_2") } {} 42 | 43 | inline void InitPrtls(Domain& local_domain) { 44 | const auto energy_dist_1 = arch::Maxwellian(local_domain.mesh.metric, 45 | local_domain.random_pool, 46 | temp_1, 47 | -drift_u_1, 48 | in::x3); 49 | const auto energy_dist_2 = arch::Maxwellian(local_domain.mesh.metric, 50 | local_domain.random_pool, 51 | temp_2, 52 | drift_u_2, 53 | in::x3); 54 | const auto injector_1 = arch::UniformInjector( 55 | energy_dist_1, 56 | { 1, 2 }); 57 | const auto injector_2 = arch::UniformInjector( 58 | energy_dist_2, 59 | { 3, 4 }); 60 | arch::InjectUniform>( 61 | params, 62 | local_domain, 63 | injector_1, 64 | HALF); 65 | arch::InjectUniform>( 66 | params, 67 | local_domain, 68 | injector_2, 69 | HALF); 70 | } 71 | }; 72 | 73 | } // namespace user 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /setups/srpic/weibel/weibel.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "weibel" 3 | engine = "srpic" 4 | runtime = 100.0 5 | 6 | [grid] 7 | resolution = [512, 512] 8 | extent = [[-10.0, 10.0], [-10.0, 10.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 1.0 19 | skindepth0 = 1.0 20 | 21 | [algorithms] 22 | current_filters = 4 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 16.0 29 | 30 | [[particles.species]] 31 | label = "e-_p" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e7 35 | 36 | [[particles.species]] 37 | label = "e+_p" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e7 41 | 42 | [[particles.species]] 43 | label = "e-_b" 44 | mass = 1.0 45 | charge = -1.0 46 | maxnpart = 1e7 47 | 48 | [[particles.species]] 49 | label = "e+_b" 50 | mass = 1.0 51 | charge = 1.0 52 | maxnpart = 1e7 53 | 54 | [setup] 55 | drift_u_1 = 0.2 56 | drift_u_2 = 0.2 57 | temp_1 = 1e-4 58 | temp_2 = 1e-4 59 | 60 | [output] 61 | format = "hdf5" 62 | interval_time = 0.25 63 | 64 | [output.fields] 65 | quantities = ["N_1_2", "N_3_4", "B", "E", "T0i_1", "T0i_3"] 66 | 67 | [output.particles] 68 | enable = false 69 | 70 | [output.spectra] 71 | enable = false 72 | 73 | [diagnostics] 74 | colored_stdout = true 75 | -------------------------------------------------------------------------------- /setups/tests/blob/blob.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "blob-1x1x2" 3 | engine = "srpic" 4 | runtime = 5.0 5 | 6 | [simulation.domain] 7 | decomposition = [1, 1, 2] 8 | 9 | [grid] 10 | resolution = [128, 192, 64] 11 | # extent = [[1.0, 10.0]] 12 | extent = [[-2.0, 2.0], [-3.0, 3.0], [-1.0, 1.0]] 13 | 14 | [grid.metric] 15 | # metric = "qspherical" 16 | metric = "minkowski" 17 | 18 | [grid.boundaries] 19 | # fields = [["ATMOSPHERE", "ABSORB"]] 20 | # particles = [["ATMOSPHERE", "ABSORB"]] 21 | fields = [["PERIODIC"], ["PERIODIC"], ["PERIODIC"]] 22 | particles = [["PERIODIC"], ["PERIODIC"], ["PERIODIC"]] 23 | 24 | # [grid.boundaries.absorb] 25 | # ds = 1.0 26 | 27 | [scales] 28 | larmor0 = 2e-5 29 | skindepth0 = 0.01 30 | 31 | [algorithms] 32 | current_filters = 4 33 | 34 | [algorithms.timestep] 35 | CFL = 0.5 36 | 37 | [particles] 38 | ppc0 = 20.0 39 | # use_weights = true 40 | 41 | [[particles.species]] 42 | label = "e-" 43 | mass = 1.0 44 | charge = -1.0 45 | maxnpart = 1e7 46 | pusher = "Boris" 47 | 48 | [[particles.species]] 49 | label = "e+" 50 | mass = 1.0 51 | charge = 1.0 52 | maxnpart = 1e7 53 | pusher = "Boris" 54 | 55 | [setup] 56 | xi_min = [0.55, 1.85, -0.25] 57 | xi_max = [0.65, 2.3, -0.1] 58 | v1 = [0.25, -0.55, 0.0] 59 | v2 = [-0.75, -0.15, 0.0] 60 | 61 | [output] 62 | format = "hdf5" 63 | interval_time = 0.02 64 | 65 | [output.fields] 66 | quantities = ["Nppc_1", "Nppc_2", "E", "B", "J"] 67 | -------------------------------------------------------------------------------- /setups/tests/customout/customout.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "customout" 3 | engine = "srpic" 4 | runtime = 10.0 5 | 6 | [grid] 7 | resolution = [256, 256] 8 | extent = [[-1.0, 1.0], [-1.0, 1.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 0.01 19 | skindepth0 = 0.01 20 | 21 | [algorithms] 22 | current_filters = 4 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 20.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e7 35 | pusher = "Boris" 36 | 37 | [[particles.species]] 38 | label = "e+" 39 | mass = 1.0 40 | charge = 1.0 41 | maxnpart = 1e7 42 | pusher = "Boris" 43 | 44 | [output] 45 | format = "hdf5" 46 | interval_time = 0.02 47 | 48 | [output.fields] 49 | quantities = ["E", "B", "J"] 50 | custom = ["mybuff", "EdotB+1"] 51 | -------------------------------------------------------------------------------- /setups/tests/customout/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/kokkos_aliases.h" 8 | #include "arch/traits.h" 9 | 10 | #include "archetypes/problem_generator.h" 11 | #include "framework/domain/metadomain.h" 12 | 13 | namespace user { 14 | using namespace ntt; 15 | 16 | template 17 | struct PGen : public arch::ProblemGenerator { 18 | // compatibility traits for the problem generator 19 | static constexpr auto engines { traits::compatible_with::value }; 20 | static constexpr auto metrics { traits::compatible_with::value }; 21 | static constexpr auto dimensions { traits::compatible_with::value }; 22 | 23 | // for easy access to variables in the child class 24 | using arch::ProblemGenerator::D; 25 | using arch::ProblemGenerator::C; 26 | using arch::ProblemGenerator::params; 27 | 28 | array_t cbuff; 29 | 30 | inline PGen(const SimulationParams& p, const Metadomain&) 31 | : arch::ProblemGenerator(p) {} 32 | 33 | inline PGen() {} 34 | 35 | void CustomPostStep(std::size_t step, long double, Domain& domain) { 36 | if (step == 0) { 37 | // allocate the array at time = 0 38 | cbuff = array_t("cbuff", 39 | domain.mesh.n_all(in::x1), 40 | domain.mesh.n_all(in::x2)); 41 | } 42 | // fill with zeros 43 | Kokkos::deep_copy(cbuff, ZERO); 44 | // populate the array atomically (here it's not strictly necessary) 45 | auto cbuff_sc = Kokkos::Experimental::create_scatter_view(cbuff); 46 | Kokkos::parallel_for( 47 | "FillCbuff", 48 | domain.mesh.rangeActiveCells(), 49 | Lambda(index_t i1, index_t i2) { 50 | auto cbuff_acc = cbuff_sc.access(); 51 | cbuff_acc(i1, i2) += static_cast(i1 + i2); 52 | }); 53 | Kokkos::Experimental::contribute(cbuff, cbuff_sc); 54 | } 55 | 56 | void CustomFieldOutput(const std::string& name, 57 | ndfield_t buffer, 58 | std::size_t index, 59 | const Domain& domain) { 60 | printf("CustomFieldOutput: %s\n", name.c_str()); 61 | // examples for 2D 62 | if (name == "mybuff") { 63 | // copy the custom buffer to the buffer output 64 | Kokkos::deep_copy(Kokkos::subview(buffer, Kokkos::ALL, Kokkos::ALL, index), 65 | cbuff); 66 | } else if (name == "EdotB+1") { 67 | // calculate the custom buffer from EM fields 68 | const auto& EM = domain.fields.em; 69 | Kokkos::parallel_for( 70 | "EdotB+1", 71 | domain.mesh.rangeActiveCells(), 72 | Lambda(index_t i1, index_t i2) { 73 | buffer(i1, i2, index) = EM(i1, i2, em::ex1) * EM(i1, i2, em::bx1) + 74 | EM(i1, i2, em::ex2) * EM(i1, i2, em::bx2) + 75 | EM(i1, i2, em::ex3) * EM(i1, i2, em::bx3) + 76 | ONE; 77 | }); 78 | } else { 79 | raise::Error("Custom output not provided", HERE); 80 | } 81 | } 82 | }; 83 | 84 | } // namespace user 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /setups/tests/deposit/deposit.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "deposit-test" 3 | engine = "srpic" 4 | runtime = 1.0 5 | 6 | [grid] 7 | resolution = [256, 256] 8 | extent = [[0.0, 1.0], [0.0, 1.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 0.1 19 | skindepth0 = 0.1 20 | 21 | [algorithms] 22 | current_filters = 4 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 10.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e2 35 | 36 | [[particles.species]] 37 | label = "e+" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e2 41 | 42 | [setup] 43 | 44 | [output] 45 | format = "hdf5" 46 | interval_time = 0.01 47 | 48 | [output.quantities] 49 | quantities = ["N_1", "N_2", "E", "B", "J"] 50 | 51 | [diagnostics] 52 | colored_stdout = true 53 | blocking_timers = true 54 | -------------------------------------------------------------------------------- /setups/tests/injector/injector.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "injector-test" 3 | engine = "srpic" 4 | runtime = 2.0 5 | 6 | [grid] 7 | resolution = [512, 512] 8 | extent = [[-1.0, 1.0], [-1.0, 1.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["ABSORB", "ABSORB"], ["ABSORB", "ABSORB"]] 15 | particles = [["ABSORB", "ABSORB"], ["ABSORB", "ABSORB"]] 16 | 17 | [grid.boundaries.absorb] 18 | ds = 0.15 19 | 20 | [scales] 21 | larmor0 = 0.1 22 | skindepth0 = 0.1 23 | 24 | [algorithms] 25 | current_filters = 4 26 | 27 | [algorithms.timestep] 28 | CFL = 0.5 29 | 30 | [particles] 31 | ppc0 = 1.0 32 | 33 | [[particles.species]] 34 | label = "e-" 35 | mass = 1.0 36 | charge = -1.0 37 | maxnpart = 1e6 38 | 39 | [[particles.species]] 40 | label = "e+" 41 | mass = 1.0 42 | charge = 1.0 43 | maxnpart = 1e6 44 | 45 | [setup] 46 | period = 0.1 47 | vmax = 1.0 48 | x1c = 0.25 49 | x2c = -0.32 50 | dr = 1e-2 51 | rate = 0.1 52 | 53 | [output] 54 | format = "hdf5" 55 | interval_time = 0.01 56 | 57 | [output.fields] 58 | quantities = ["N_1", "N_2", "E"] 59 | 60 | [diagnostics] 61 | interval = 10 62 | colored_stdout = true 63 | -------------------------------------------------------------------------------- /setups/wip/rec-gravity/rec-gravity.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "rec-gravity" 3 | engine = "srpic" 4 | runtime = 20.0 5 | 6 | [grid] 7 | resolution = [2000, 4000] 8 | extent = [[-0.5, 0.5], [-1.0, 1.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 3.1e-4 19 | skindepth0 = 1e-3 20 | 21 | [algorithms] 22 | current_filters = 8 23 | 24 | [algorithms.timestep] 25 | CFL = 0.45 26 | 27 | [particles] 28 | ppc0 = 8.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e8 35 | 36 | [[particles.species]] 37 | label = "e+" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e8 41 | 42 | [setup] 43 | Bmag = 1.0 44 | width = 0.04 45 | bg_temp = 1e-4 46 | overdensity = 3.0 47 | angle = 0.0 48 | 49 | [output] 50 | format = "hdf5" 51 | interval_time = 0.36 52 | 53 | [output.fields] 54 | quantities = ["N_1", "N_2", "E", "B", "J", "T00_1", "T00_2"] 55 | -------------------------------------------------------------------------------- /setups/wip/reconnection/reconnection.toml: -------------------------------------------------------------------------------- 1 | [simulation] 2 | name = "reconnection" 3 | engine = "srpic" 4 | runtime = 10.0 5 | 6 | [grid] 7 | resolution = [1024, 2048] 8 | extent = [[-1.0, 1.0], [-2.0, 2.0]] 9 | 10 | [grid.metric] 11 | metric = "minkowski" 12 | 13 | [grid.boundaries] 14 | fields = [["PERIODIC"], ["PERIODIC"]] 15 | particles = [["PERIODIC"], ["PERIODIC"]] 16 | 17 | [scales] 18 | larmor0 = 2e-4 19 | skindepth0 = 2e-3 20 | 21 | [algorithms] 22 | current_filters = 4 23 | 24 | [algorithms.timestep] 25 | CFL = 0.5 26 | 27 | [particles] 28 | ppc0 = 8.0 29 | 30 | [[particles.species]] 31 | label = "e-" 32 | mass = 1.0 33 | charge = -1.0 34 | maxnpart = 1e7 35 | 36 | [[particles.species]] 37 | label = "e+" 38 | mass = 1.0 39 | charge = 1.0 40 | maxnpart = 1e7 41 | 42 | [setup] 43 | Bmag = 1.0 44 | width = 0.01 45 | bg_temp = 1e-4 46 | overdensity = 3.0 47 | 48 | [output] 49 | format = "hdf5" 50 | interval_time = 0.1 51 | 52 | [output.fields] 53 | quantities = ["N_1", "N_2", "E", "B", "J"] 54 | -------------------------------------------------------------------------------- /setups/wip/spider/pgen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PROBLEM_GENERATOR_H 2 | #define PROBLEM_GENERATOR_H 3 | 4 | #include "enums.h" 5 | #include "global.h" 6 | 7 | #include "arch/kokkos_aliases.h" 8 | #include "arch/traits.h" 9 | 10 | #include "archetypes/problem_generator.h" 11 | #include "framework/domain/metadomain.h" 12 | 13 | namespace user { 14 | using namespace ntt; 15 | 16 | template 17 | struct PGen : public arch::ProblemGenerator { 18 | // compatibility traits for the problem generator 19 | static constexpr auto engines { traits::compatible_with::value }; 20 | static constexpr auto metrics { traits::compatible_with::value }; 21 | static constexpr auto dimensions { 22 | traits::compatible_with::value 23 | }; 24 | 25 | // for easy access to variables in the child class 26 | using arch::ProblemGenerator::D; 27 | using arch::ProblemGenerator::C; 28 | using arch::ProblemGenerator::params; 29 | 30 | inline PGen(const SimulationParams& p, const Metadomain& m) 31 | : arch::ProblemGenerator(p) {} 32 | 33 | inline PGen() {} 34 | }; 35 | 36 | } // namespace user 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # @defines: entity [STATIC/SHARED] 3 | # @sources: 4 | # - entity.cpp 5 | # @depends: 6 | # - ntt_global [required] 7 | # - ntt_framework [required] 8 | # - ntt_metrics [required] 9 | # - ntt_engine [required] 10 | # @uses: 11 | # - kokkos [required] 12 | # - plog [required] 13 | # - toml11 [required] 14 | # - ADIOS2 [optional] 15 | # - mpi [optional] 16 | # ------------------------------ 17 | 18 | 19 | set(ENTITY ${PROJECT_NAME}.xc) 20 | set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 21 | set(SOURCES 22 | ${SRC_DIR}/entity.cpp 23 | ) 24 | add_executable(${ENTITY} entity.cpp) 25 | 26 | # dependencies 27 | add_subdirectory(${SRC_DIR}/global ${CMAKE_CURRENT_BINARY_DIR}/global) 28 | add_subdirectory(${SRC_DIR}/metrics ${CMAKE_CURRENT_BINARY_DIR}/metrics) 29 | add_subdirectory(${SRC_DIR}/kernels ${CMAKE_CURRENT_BINARY_DIR}/kernels) 30 | add_subdirectory(${SRC_DIR}/archetypes ${CMAKE_CURRENT_BINARY_DIR}/archetypes) 31 | add_subdirectory(${SRC_DIR}/framework ${CMAKE_CURRENT_BINARY_DIR}/framework) 32 | add_subdirectory(${SRC_DIR}/engines ${CMAKE_CURRENT_BINARY_DIR}/engines) 33 | if (${output} STREQUAL "ON") 34 | add_subdirectory(${SRC_DIR}/output ${CMAKE_CURRENT_BINARY_DIR}/output) 35 | endif() 36 | add_subdirectory(${SRC_DIR}/../setups ${CMAKE_CURRENT_BINARY_DIR}/setups) 37 | 38 | set(libs ntt_global ntt_framework ntt_metrics ntt_engines ntt_pgen) 39 | add_dependencies(${ENTITY} ${libs}) 40 | target_link_libraries(${ENTITY} PUBLIC ${libs}) 41 | -------------------------------------------------------------------------------- /src/archetypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # @defines: ntt_archetypes [INTERFACE] 3 | # @includes: 4 | # - ../ 5 | # @depends: 6 | # - ntt_global [required] 7 | # - ntt_kernels [required] 8 | # @uses: 9 | # - kokkos [required] 10 | # - mpi [optional] 11 | # ------------------------------ 12 | 13 | add_library(ntt_archetypes INTERFACE) 14 | 15 | set(libs ntt_global ntt_kernels) 16 | add_dependencies(ntt_archetypes ${libs}) 17 | target_link_libraries(ntt_archetypes INTERFACE ${libs}) 18 | 19 | target_include_directories(ntt_archetypes 20 | INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../ 21 | ) -------------------------------------------------------------------------------- /src/archetypes/problem_generator.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file archetypes/problem_generator.hpp 3 | * @brief Base class for all problem generators 4 | * @implements 5 | * - arch::ProblemGenerator<> 6 | * @namespace 7 | * - arch:: 8 | * @note 9 | * To have easier access to variables inside ProblemGenerator in children 10 | * classes, one should simply add: 11 | * ```c++ 12 | * using ProblemGenerator::D; 13 | * using ProblemGenerator::C; 14 | * using ProblemGenerator::params; 15 | * ``` 16 | * in the child class. This will allow to access these variables without 17 | * the need to use `this->` or `ProblemGenerator::` prefix. 18 | */ 19 | 20 | #ifndef ARCHETYPES_PROBLEM_GENERATOR_HPP 21 | #define ARCHETYPES_PROBLEM_GENERATOR_HPP 22 | 23 | #include "enums.h" 24 | #include "global.h" 25 | 26 | #include "framework/parameters.h" 27 | 28 | namespace arch { 29 | using namespace ntt; 30 | 31 | template 32 | struct ProblemGenerator { 33 | static_assert(M::is_metric, "M must be a metric class"); 34 | static constexpr bool is_pgen { true }; 35 | static constexpr Dimension D { M::Dim }; 36 | static constexpr Coord C { M::CoordType }; 37 | 38 | const SimulationParams& params; 39 | 40 | ProblemGenerator(const SimulationParams& p) : params { p } {} 41 | 42 | ~ProblemGenerator() = default; 43 | }; 44 | 45 | } // namespace arch 46 | 47 | #endif // ARCHETYPES_PROBLEM_GENERATOR_HPP 48 | -------------------------------------------------------------------------------- /src/archetypes/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # @brief: Generates tests for the `ntt_archetypes` module 3 | # @uses: 4 | # - kokkos [required] 5 | # - plog [required] 6 | # - mpi [optional] 7 | # ------------------------------ 8 | 9 | set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../) 10 | 11 | function(gen_test title) 12 | set(exec test-archetypes-${title}.xc) 13 | set(src ${title}.cpp) 14 | add_executable(${exec} ${src}) 15 | 16 | set(libs ntt_archetypes ntt_global ntt_metrics) 17 | add_dependencies(${exec} ${libs}) 18 | target_link_libraries(${exec} PRIVATE ${libs}) 19 | 20 | add_test(NAME "ARCHETYPES::${title}" COMMAND "${exec}") 21 | endfunction() 22 | 23 | gen_test(energy_dist) 24 | gen_test(spatial_dist) 25 | gen_test(field_setter) -------------------------------------------------------------------------------- /src/archetypes/tests/field_setter.cpp: -------------------------------------------------------------------------------- 1 | #include "archetypes/field_setter.h" 2 | 3 | #include "enums.h" 4 | #include "global.h" 5 | 6 | #include "metrics/minkowski.h" 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | using namespace ntt; 14 | using namespace metric; 15 | using namespace arch; 16 | 17 | template 18 | struct ConstantFiller { 19 | 20 | ConstantFiller(real_t value) : value { value } {} 21 | 22 | Inline auto ex1(const coord_t&) const -> real_t { 23 | return value; 24 | } 25 | 26 | Inline auto bx3(const coord_t&) const -> real_t { 27 | return -value; 28 | } 29 | 30 | private: 31 | real_t value; 32 | }; 33 | 34 | auto main(int argc, char* argv[]) -> int { 35 | Kokkos::initialize(argc, argv); 36 | try { 37 | constexpr std::size_t nx1 = 20; 38 | ndfield_t EM { "EM", nx1 + 2 * N_GHOSTS }; 39 | Minkowski metric { { nx1 }, { { -2.0, 2.0 } } }; 40 | ConstantFiller finit { 123.0 }; 41 | SetEMFields_kernel, SimEngine::SRPIC, Minkowski> 42 | finitializer { EM, finit, metric }; 43 | Kokkos::parallel_for( 44 | "InitFields", 45 | CreateRangePolicy({ N_GHOSTS }, { nx1 + N_GHOSTS }), 46 | finitializer); 47 | auto EM_h = Kokkos::create_mirror_view(EM); 48 | Kokkos::deep_copy(EM_h, EM); 49 | for (std::size_t i1 = 0; i1 < nx1 + 2 * N_GHOSTS; ++i1) { 50 | if ((i1 < N_GHOSTS) || (i1 >= nx1 + N_GHOSTS)) { 51 | for (const auto& comp : 52 | { em::ex1, em::ex2, em::ex3, em::bx1, em::bx2, em::bx3 }) { 53 | raise::ErrorIf(EM_h(i1, comp) != 0.0, "Invalid value", HERE); 54 | } 55 | } 56 | if ((i1 >= N_GHOSTS) && (i1 < nx1 + N_GHOSTS)) { 57 | raise::ErrorIf(EM_h(i1, em::ex1) != 615.0, "Invalid value", HERE); 58 | raise::ErrorIf(EM_h(i1, em::bx3) != -123.0, "Invalid value", HERE); 59 | for (const auto& comp : { em::ex2, em::ex3, em::bx1, em::bx2 }) { 60 | raise::ErrorIf(EM_h(i1, comp) != 0.0, "Invalid value", HERE); 61 | } 62 | } 63 | } 64 | } catch (std::exception& e) { 65 | std::cerr << e.what() << std::endl; 66 | Kokkos::finalize(); 67 | return 1; 68 | } 69 | Kokkos::finalize(); 70 | return 0; 71 | } -------------------------------------------------------------------------------- /src/engines/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # @defines: ntt_engines [STATIC/SHARED] 3 | # @sources: 4 | # - engine_printer.cpp 5 | # - engine_init.cpp 6 | # - engine_run.cpp 7 | # - engine_step_report.cpp 8 | # @includes: 9 | # - ../ 10 | # @depends: 11 | # - ntt_global [required] 12 | # - ntt_framework [required] 13 | # - ntt_metrics [required] 14 | # - ntt_kernels [required] 15 | # - ntt_archetypes [required] 16 | # - ntt_pgen [required] 17 | # - ntt_output [optional] 18 | # @uses: 19 | # - kokkos [required] 20 | # - plog [required] 21 | # - adios2 [optional] 22 | # - hdf5 [optional] 23 | # - mpi [optional] 24 | # ------------------------------ 25 | 26 | set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 27 | set(SOURCES 28 | ${SRC_DIR}/engine_printer.cpp 29 | ${SRC_DIR}/engine_init.cpp 30 | ${SRC_DIR}/engine_run.cpp 31 | ${SRC_DIR}/engine_step_report.cpp 32 | ) 33 | add_library(ntt_engines ${SOURCES}) 34 | 35 | set(libs ntt_global ntt_framework ntt_metrics ntt_archetypes ntt_kernels ntt_pgen) 36 | if(${output}) 37 | list(APPEND libs ntt_output hdf5::hdf5) 38 | endif() 39 | add_dependencies(ntt_engines ${libs}) 40 | target_link_libraries(ntt_engines PUBLIC ${libs}) 41 | target_compile_definitions(ntt_engines PRIVATE PGEN=\"${PGEN}\") 42 | 43 | target_include_directories(ntt_engines 44 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ 45 | INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../ 46 | ) 47 | -------------------------------------------------------------------------------- /src/engines/engine_init.cpp: -------------------------------------------------------------------------------- 1 | #include "enums.h" 2 | #include "global.h" 3 | 4 | #include "arch/traits.h" 5 | 6 | #include "metrics/kerr_schild.h" 7 | #include "metrics/kerr_schild_0.h" 8 | #include "metrics/minkowski.h" 9 | #include "metrics/qkerr_schild.h" 10 | #include "metrics/qspherical.h" 11 | #include "metrics/spherical.h" 12 | 13 | #include "archetypes/field_setter.h" 14 | #include "engines/engine.hpp" 15 | 16 | #include 17 | 18 | namespace ntt { 19 | 20 | template 21 | void Engine::init() { 22 | if constexpr (pgen_is_ok) { 23 | #if defined(OUTPUT_ENABLED) 24 | m_metadomain.InitWriter(m_params); 25 | #endif 26 | logger::Checkpoint("Initializing Engine", HERE); 27 | if constexpr ( 28 | traits::has_member>::value) { 29 | logger::Checkpoint("Initializing fields from problem generator", HERE); 30 | m_metadomain.runOnLocalDomains([&](auto& loc_dom) { 31 | Kokkos::parallel_for( 32 | "InitFields", 33 | loc_dom.mesh.rangeActiveCells(), 34 | arch::SetEMFields_kernel { 35 | loc_dom.fields.em, 36 | m_pgen.init_flds, 37 | loc_dom.mesh.metric }); 38 | }); 39 | } 40 | if constexpr ( 41 | traits::has_member>::value) { 42 | logger::Checkpoint("Initializing particles from problem generator", HERE); 43 | m_metadomain.runOnLocalDomains([&](auto& loc_dom) { 44 | m_pgen.InitPrtls(loc_dom); 45 | }); 46 | } 47 | } 48 | } 49 | 50 | template class Engine>; 51 | template class Engine>; 52 | template class Engine>; 53 | template class Engine>; 54 | template class Engine>; 55 | template class Engine>; 56 | template class Engine>; 57 | template class Engine>; 58 | } // namespace ntt -------------------------------------------------------------------------------- /src/engines/grpic.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file engines/grpic.hpp 3 | * @brief Simulation engien class which specialized on GRPIC 4 | * @implements 5 | * - ntt::GRPICEngine<> : ntt::Engine<> 6 | * @cpp: 7 | * - srpic.cpp 8 | * @namespaces: 9 | * - ntt:: 10 | */ 11 | 12 | #ifndef ENGINES_GRPIC_GRPIC_H 13 | #define ENGINES_GRPIC_GRPIC_H 14 | 15 | #include "enums.h" 16 | 17 | #include "utils/timer.h" 18 | 19 | #include "framework/domain/domain.h" 20 | 21 | #include "engines/engine.hpp" 22 | 23 | namespace ntt { 24 | 25 | template 26 | class GRPICEngine : public Engine { 27 | using Engine::m_params; 28 | using Engine::m_metadomain; 29 | 30 | public: 31 | static constexpr auto S { SimEngine::SRPIC }; 32 | 33 | GRPICEngine(SimulationParams& params) 34 | : Engine { params } {} 35 | 36 | ~GRPICEngine() = default; 37 | 38 | void step_forward(timer::Timers&, Domain&) override {} 39 | }; 40 | 41 | } // namespace ntt 42 | 43 | #endif // ENGINES_GRPIC_GRPIC_H 44 | -------------------------------------------------------------------------------- /src/framework/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------ 2 | # @defines: ntt_framework [STATIC/SHARED] 3 | # @sources: 4 | # - parameters.cpp 5 | # - simulation.cpp 6 | # - domain/grid.cpp 7 | # - domain/metadomain.cpp 8 | # - domain/communications.cpp 9 | # - containers/particles.cpp 10 | # - containers/fields.cpp 11 | # - domain/output.cpp 12 | # @includes: 13 | # - ../ 14 | # @depends: 15 | # - ntt_global [required] 16 | # - ntt_metrics [required] 17 | # - ntt_kernels [required] 18 | # - ntt_output [optional] 19 | # @uses: 20 | # - kokkos [required] 21 | # - plog [required] 22 | # - toml11 [required] 23 | # - ADIOS2 [optional] 24 | # - mpi [optional] 25 | # ------------------------------ 26 | 27 | set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 28 | set(SOURCES 29 | ${SRC_DIR}/parameters.cpp 30 | ${SRC_DIR}/simulation.cpp 31 | ${SRC_DIR}/domain/grid.cpp 32 | ${SRC_DIR}/domain/metadomain.cpp 33 | ${SRC_DIR}/domain/communications.cpp 34 | ${SRC_DIR}/containers/particles.cpp 35 | ${SRC_DIR}/containers/fields.cpp 36 | ) 37 | if (${output}) 38 | list(APPEND SOURCES ${SRC_DIR}/domain/output.cpp) 39 | endif() 40 | add_library(ntt_framework ${SOURCES}) 41 | 42 | set(libs ntt_global ntt_metrics ntt_kernels) 43 | if(${output}) 44 | list(APPEND libs ntt_output) 45 | endif() 46 | add_dependencies(ntt_framework ${libs}) 47 | target_link_libraries(ntt_framework PUBLIC ${libs}) 48 | 49 | target_include_directories(ntt_framework 50 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ 51 | INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../ 52 | ) -------------------------------------------------------------------------------- /src/framework/containers/fields.cpp: -------------------------------------------------------------------------------- 1 | #include "framework/containers/fields.h" 2 | 3 | #include "enums.h" 4 | #include "global.h" 5 | 6 | #include 7 | 8 | namespace ntt { 9 | 10 | template 11 | Fields::Fields(const std::vector& res) { 12 | std::size_t nx1, nx2, nx3; 13 | nx1 = res[0] + 2 * N_GHOSTS; 14 | if constexpr ((D == Dim::_3D) || (D == Dim::_2D)) { 15 | nx2 = res[1] + 2 * N_GHOSTS; 16 | } 17 | if constexpr (D == Dim::_3D) { 18 | nx3 = res[2] + 2 * N_GHOSTS; 19 | } 20 | 21 | if constexpr (D == Dim::_1D) { 22 | em = ndfield_t { "EM", nx1 }; 23 | bckp = ndfield_t { "BCKP", nx1 }; 24 | cur = ndfield_t { "J", nx1 }; 25 | buff = ndfield_t { "BUFF", nx1 }; 26 | } else if constexpr (D == Dim::_2D) { 27 | em = ndfield_t { "EM", nx1, nx2 }; 28 | bckp = ndfield_t { "BCKP", nx1, nx2 }; 29 | cur = ndfield_t { "J", nx1, nx2 }; 30 | buff = ndfield_t { "BUFF", nx1, nx2 }; 31 | if constexpr (S == SimEngine::GRPIC) { 32 | aux = ndfield_t { "AUX", nx1, nx2 }; 33 | em0 = ndfield_t { "EM0", nx1, nx2 }; 34 | cur0 = ndfield_t { "CUR0", nx1, nx2 }; 35 | } 36 | } else if constexpr (D == Dim::_3D) { 37 | em = ndfield_t { "EM", nx1, nx2, nx3 }; 38 | bckp = ndfield_t { "BCKP", nx1, nx2, nx3 }; 39 | cur = ndfield_t { "J", nx1, nx2, nx3 }; 40 | buff = ndfield_t { "BUFF", nx1, nx2, nx3 }; 41 | if constexpr (S == SimEngine::GRPIC) { 42 | aux = ndfield_t { "AUX", nx1, nx2, nx3 }; 43 | em0 = ndfield_t { "EM0", nx1, nx2, nx3 }; 44 | cur0 = ndfield_t { "CUR0", nx1, nx2, nx3 }; 45 | } 46 | } 47 | } 48 | 49 | template struct Fields; 50 | template struct Fields; 51 | template struct Fields; 52 | template struct Fields; 53 | template struct Fields; 54 | 55 | } // namespace ntt -------------------------------------------------------------------------------- /src/framework/parameters.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file framework/parameters.h 3 | * @brief Structure for defining and holding initial simulation parameters 4 | * @implements 5 | * - ntt::SimulationParams : ntt::Parameters 6 | * @cpp: 7 | * - parameters.cpp 8 | * @namespaces: 9 | * - ntt:: 10 | * @macros: 11 | * - MPI_ENABLED 12 | * @note The parameters are read from the toml file and stored in a container 13 | * @note Some of the parameters are inferred from the context (see input.example.toml) 14 | * @note A proper metric is used to infer the minimum cell size/volume etc. 15 | */ 16 | 17 | #ifndef FRAMEWORK_PARAMETERS_H 18 | #define FRAMEWORK_PARAMETERS_H 19 | 20 | #include "utils/param_container.h" 21 | 22 | #include 23 | 24 | namespace ntt { 25 | 26 | struct SimulationParams : public prm::Parameters { 27 | SimulationParams() = default; 28 | SimulationParams(const toml::value&); 29 | 30 | SimulationParams& operator=(const SimulationParams& other) { 31 | vars = std::move(other.vars); 32 | promises = std::move(other.promises); 33 | return *this; 34 | } 35 | 36 | ~SimulationParams() = default; 37 | }; 38 | 39 | } // namespace ntt 40 | 41 | #endif // FRAMEWORK_PARAMETERS_H 42 | -------------------------------------------------------------------------------- /src/framework/simulation.cpp: -------------------------------------------------------------------------------- 1 | #include "framework/simulation.h" 2 | 3 | #include "defaults.h" 4 | #include "global.h" 5 | 6 | #include "utils/cargs.h" 7 | #include "utils/error.h" 8 | #include "utils/formatting.h" 9 | #include "utils/plog.h" 10 | 11 | #include "framework/parameters.h" 12 | 13 | #include 14 | 15 | #include 16 | 17 | namespace ntt { 18 | 19 | Simulation::Simulation(int argc, char* argv[]) { 20 | GlobalInitialize(argc, argv); 21 | 22 | cargs::CommandLineArguments cl_args; 23 | cl_args.readCommandLineArguments(argc, argv); 24 | const auto inputfname = static_cast( 25 | cl_args.getArgument("-input", defaults::input_filename)); 26 | const auto outputdir = static_cast( 27 | cl_args.getArgument("-output", defaults::output_path)); 28 | 29 | const auto inputdata = toml::parse(inputfname); 30 | const auto sim_name = toml::find(inputdata, "simulation", "name"); 31 | logger::initPlog(sim_name); 32 | 33 | params = SimulationParams(inputdata); 34 | } 35 | 36 | Simulation::~Simulation() { 37 | GlobalFinalize(); 38 | } 39 | 40 | } // namespace ntt -------------------------------------------------------------------------------- /src/framework/simulation.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file framework/simulation.h 3 | * @brief Simulation class which creates and calles the engines 4 | * @implements 5 | * - ntt::Simulation 6 | * @cpp: 7 | * - simulation.cpp 8 | * @namespaces: 9 | * - ntt:: 10 | * @macros: 11 | * - DEBUG 12 | */ 13 | 14 | #ifndef FRAMEWORK_SIMULATION_H 15 | #define FRAMEWORK_SIMULATION_H 16 | 17 | #include "enums.h" 18 | 19 | #include "arch/traits.h" 20 | #include "utils/error.h" 21 | 22 | #include "framework/parameters.h" 23 | 24 | #include 25 | #include 26 | 27 | namespace ntt { 28 | 29 | class Simulation { 30 | SimulationParams params; 31 | 32 | public: 33 | Simulation(int argc, char* argv[]); 34 | ~Simulation(); 35 | 36 | template