Skip to content

Commit

Permalink
Add a first version of the 5D geometry in (tor1,tor2,tor3,vpar,mu)
Browse files Browse the repository at this point in the history
This version is a temporary step that will quickly be moved to a 4D geometry (tor1,tor2,vpar,mu) because we realized the strategy to create directly a 5D geometry with only one point in tor3 direction is not a good idea.
The interest of merging this temporary branch is due to the fact that it contains,
- a first example of HDF5 file reading (initialized from external python scripts developed in [gysela_io project](https://gitlab.maisondelasimulation.fr/gysela-developpers/gysela_io)
- a first coupling with collision operator developed within [koliop library](https://gitlab.com/cines/code.gysela/libkoliop)
- Adastra configuration

See merge request gysela-developpers/gyselalibxx!405

--------------------------------------------

Co-authored-by: Etienne Malaboeuf <[email protected]>
  • Loading branch information
EmilyBourne and etiennemlb committed Mar 28, 2024
1 parent 7c5e4de commit 33b4111
Show file tree
Hide file tree
Showing 55 changed files with 2,083 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build*/
*.pyc
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
[submodule "vendor/eigen"]
path = vendor/eigen
url = https://gitlab.com/libeigen/eigen.git
[submodule "vendor/koliop"]
path = vendor/koliop
url = https://gitlab.com/cines/code.gysela/koliop.git
[submodule "vendor/kokkos-tools"]
path = vendor/kokkos-tools
url = https://github.com/kokkos/kokkos-tools.git
25 changes: 15 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ if("${BUILD_TESTING}")
if("${GYSELALIBXX_GTest_DEPENDENCY_POLICY}" STREQUAL "AUTO")
find_package(GTest "1.12" QUIET)
if(NOT "${GTest_FOUND}")
add_subdirectory("vendor/googletest/" "googletest")
add_subdirectory("vendor/googletest/" "googletest") # SYSTEM)
endif()
elseif("${GYSELALIBXX_GTest_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
add_subdirectory("vendor/googletest/" "googletest")
add_subdirectory("vendor/googletest/" "googletest") # SYSTEM)
elseif("${GYSELALIBXX_GTest_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(GTest "1.12" REQUIRED)
endif()
Expand All @@ -94,12 +94,12 @@ if("${BUILD_BENCHMARKS}")
if(NOT "${benchmark_FOUND}")
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" OFF)
add_subdirectory("vendor/benchmark/" "benchmark")
add_subdirectory("vendor/benchmark/" "benchmark") # SYSTEM)
endif()
elseif("${GYSELALIBXX_benchmark_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" OFF)
add_subdirectory("vendor/benchmark/" "benchmark")
add_subdirectory("vendor/benchmark/" "benchmark") # SYSTEM)
elseif("${GYSELALIBXX_benchmark_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(benchmark "1.6" REQUIRED)
endif()
Expand All @@ -113,11 +113,11 @@ if("${GYSELALIBXX_mdspan_DEPENDENCY_POLICY}" STREQUAL "AUTO")
find_package(mdspan "0.3" QUIET)
if(NOT "${mdspan_FOUND}")
set(MDSPAN_CXX_STANDARD "${CMAKE_CXX_STANDARD}" CACHE STRING "Override the default CXX_STANDARD to compile with" FORCE)
add_subdirectory("vendor/mdspan/" "mdspan")
add_subdirectory("vendor/mdspan/" "mdspan") # SYSTEM)
endif()
elseif("${GYSELALIBXX_mdspan_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
set(MDSPAN_CXX_STANDARD "${CMAKE_CXX_STANDARD}" CACHE STRING "Override the default CXX_STANDARD to compile with" FORCE)
add_subdirectory("vendor/mdspan/" "mdspan")
add_subdirectory("vendor/mdspan/" "mdspan") # SYSTEM)
elseif("${GYSELALIBXX_mdspan_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(mdspan "0.3" REQUIRED)
endif()
Expand All @@ -127,21 +127,26 @@ if("${Kokkos_ENABLE_CUDA}")
option(Kokkos_ENABLE_CUDA_CONSTEXPR "Whether to activate experimental relaxed constexpr functions" ON)
option(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE "Whether to enable relocatable device code (RDC) for CUDA" ON)
endif()
add_subdirectory("vendor/kokkos/" "kokkos")
add_subdirectory("vendor/kokkos/" "kokkos") # SYSTEM)

find_package (Eigen3 3.3 NO_MODULE)

if (NOT EIGEN3_FOUND)
## Use Eigen from `vendor/`
set(EIGEN_BUILD_DOC OFF CACHE BOOL "Don't build eigen docs")
add_subdirectory("vendor/eigen/" "eigen")
add_subdirectory("vendor/eigen/" "eigen") # SYSTEM)
endif (NOT EIGEN3_FOUND)

## Use the discrete domain computation library (ddc) from `vendor/`
add_subdirectory("vendor/ddc/" "ddc")
add_subdirectory("vendor/ddc/" "ddc") # SYSTEM)

## Use selalib's splines from `vendor/`
add_subdirectory("vendor/sll/" "sll")
add_subdirectory("vendor/sll/" "sll") # SYSTEM)

# TODO(Etienne M): We may have to handle kokkos kernel in the same way.
set(koliop_ENABLE_Kokkos "SUBDIRECTORY" CACHE STRING "")
set(koliop_BUILD_TESTING OFF CACHE BOOL "")
add_subdirectory("vendor/koliop/" "koliop") # SYSTEM)

## Use the kokkos-tools for profiling purpose from `vendor/`
include(vendor/kokkos-tools/cmake/utils.cmake)
Expand Down
73 changes: 73 additions & 0 deletions prepare.gyselalibxx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

[[ -z ${1+x} ]] && echo -e "Gyselalibxx preparation shortcut script:\n ./prepare.gyselalibxx.sh <toolchain/machine [mi250.cce.adastra.spack|...]> <do prepare [default: TRUE|FALSE]> <force a fresh build [default: TRUE|FALSE]> <extra CMake flags>" && exit 1

PREPARE_ROOT_DIRECTORY="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)"

set -eu

PREPARE_TOOLCHAIN_NAME="${1}"

if [[ ! -z ${2+x} ]]; then
PREPARE_DONT_SKIP="${2}"
else
PREPARE_DONT_SKIP="TRUE"
fi

if [[ ! -z ${3+x} ]]; then
PREPARE_FORCE_FRESH_BUILD="${3}"
else
PREPARE_FORCE_FRESH_BUILD="TRUE"
fi

# A toolchain script should NOT expect we source/execute them from the toolchain
# directory.
PREPARE_TOOLCHAIN_PATH="${PREPARE_ROOT_DIRECTORY}/toolchains/${PREPARE_TOOLCHAIN_NAME}"

if [[ "${PREPARE_DONT_SKIP}" != "TRUE" ]]; then
echo "[PREPARE] Skipping the environment preparation (presumably already prepared)."
else
# Anything that does not match "TRUE" disable the feature.
echo "[PREPARE] Preparing the environment. Preparation log in 'log.prepare.${PREPARE_TOOLCHAIN_NAME}'."
# Maybe a noop.
"${PREPARE_TOOLCHAIN_PATH}/prepare.sh" >"log.prepare.${PREPARE_TOOLCHAIN_NAME}" 2>&1 || (echo "The environment preparation failed! Check the log." && exit 1)
fi

PREPARE_BUILD_NAME="build.${PREPARE_TOOLCHAIN_NAME}"
PREPARE_BUILD_DIRECTORY="${PREPARE_ROOT_DIRECTORY}/${PREPARE_BUILD_NAME}"
PREPARE_TOOLCHAIN_FILE="${PREPARE_TOOLCHAIN_PATH}/toolchain.cmake"

if [[ "${PREPARE_FORCE_FRESH_BUILD}" != "TRUE" ]]; then
echo "[PREPARE] Keeping the old build directory."
else
# Anything that does not machine "TRUE" disable the feature.
echo "[PREPARE] Removing old build directory..."
rm -rf -- "${PREPARE_BUILD_DIRECTORY}"
fi

PREPARE_BUILD_GENERATOR="Unix Makefiles"

if which ninja >/dev/null 2>&1; then
PREPARE_BUILD_GENERATOR="Ninja"
fi

echo "[PREPARE] Using build system: '${PREPARE_BUILD_GENERATOR}'."

source -- "${PREPARE_TOOLCHAIN_PATH}/environment.sh"

PREPARE_BUILD_CMAKE_FLAG="${@:4}"

cmake \
-B "${PREPARE_BUILD_DIRECTORY}" \
-S . \
-G "${PREPARE_BUILD_GENERATOR}" \
-DCMAKE_TOOLCHAIN_FILE="${PREPARE_TOOLCHAIN_FILE}" \
"${PREPARE_BUILD_CMAKE_FLAG}"

echo "Building in '${PREPARE_BUILD_NAME}'. Build log in 'log.build.${PREPARE_TOOLCHAIN_NAME}'."
cmake --build "${PREPARE_BUILD_DIRECTORY}" >"log.build.${PREPARE_TOOLCHAIN_NAME}" 2>&1 || (echo "The build failed! Check the log." && exit 1)

echo "The build completed. You can use the binaries in the following directory:"
echo " \"${PREPARE_BUILD_DIRECTORY}\""
echo "Do not forget to source the environment file like so:"
echo " $ source -- \"${PREPARE_TOOLCHAIN_PATH}/environment.sh\""
1 change: 1 addition & 0 deletions simulations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
add_subdirectory(geometryXVx)
add_subdirectory(geometryRTheta)
add_subdirectory(geometryXYVxVy)
add_subdirectory(geometry5D)
add_subdirectory(utilities)
3 changes: 3 additions & 0 deletions simulations/geometry5D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: MIT

add_subdirectory(testcollisions)
20 changes: 20 additions & 0 deletions simulations/geometry5D/testcollisions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-License-Identifier: MIT


add_executable(testcollisions testcollisions.cpp)
target_compile_features(testcollisions PUBLIC cxx_std_17)
target_link_libraries(testcollisions
PUBLIC
DDC::DDC
DDC::PDI_Wrapper
gslx::speciesinfo
gslx::geometry5D
gslx::paraconfpp
gslx::quadrature
gslx::collisions_rhs_5D
PDI::pdi
paraconf::paraconf
)

install(TARGETS testcollisions)

124 changes: 124 additions & 0 deletions simulations/geometry5D/testcollisions/pdi_out.yml.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// SPDX-License-Identifier: MIT

constexpr char const* const PDI_CFG = R"PDI_CFG(
metadata:
read_restart_filename_size: size_t
read_restart_filename: {type: array, subtype: char, size: "$read_restart_filename_size"}
write_restart_filename_size: size_t
write_restart_filename: {type: array, subtype: char, size: "$write_restart_filename_size"}
iter_start : int
iter_saved : int
time_saved : double
grid_tor1_extents: { type: array, subtype: size_t, size: 1 }
grid_tor2_extents: { type: array, subtype: size_t, size: 1 }
grid_tor3_extents: { type: array, subtype: size_t, size: 1 }
grid_vpar_extents: { type: array, subtype: size_t, size: 1 }
grid_mu_extents: { type: array, subtype: size_t, size: 1 }
species_extents: { type: array, subtype: size_t, size: 1 }
masses_extents: { type: array, subtype: size_t, size: 1 }
charges_extents: { type: array, subtype: size_t, size: 1 }
data:
grid_tor1:
type: array
subtype: double
size: [ '$grid_tor1_extents[0]' ]
grid_tor2:
type: array
subtype: double
size: [ '$grid_tor2_extents[0]' ]
grid_tor3:
type: array
subtype: double
size: [ '$grid_tor3_extents[0]' ]
grid_vpar:
type: array
subtype: double
size: [ '$grid_vpar_extents[0]' ]
grid_mu:
type: array
subtype: double
size: [ '$grid_mu_extents[0]' ]
species:
type: array
subtype: int
size: [ '$species_extents[0]' ]
masses:
type: array
subtype: double
size: [ '$masses_extents[0]' ]
charges:
type: array
subtype: double
size: [ '$charges_extents[0]' ]
densityTorCS:
type: array
subtype: double
size: [ '$species_extents[0]', '$grid_tor2_extents[0]', '$grid_tor1_extents[0]' ]
temperatureTorCS:
type: array
subtype: double
size: [ '$species_extents[0]', '$grid_tor2_extents[0]', '$grid_tor1_extents[0]' ]
UparTorCS:
type: array
subtype: double
size: [ '$species_extents[0]', '$grid_tor2_extents[0]', '$grid_tor1_extents[0]' ]
fdistribu:
type: array
subtype: double
size: [ '$species_extents[0]', '$grid_tor3_extents[0]', '$grid_tor2_extents[0]', '$grid_tor1_extents[0]', '$grid_vpar_extents[0]', '$grid_mu_extents[0]' ]
plugins:
decl_hdf5:
- file: '${read_restart_filename}'
on_event: [read_grid_extents]
read:
grid_tor1_extents: {size_of: grid_tor1}
grid_tor2_extents: {size_of: grid_tor2}
grid_tor3_extents: {size_of: grid_tor3}
grid_vpar_extents: {size_of: grid_vpar}
grid_mu_extents: {size_of: grid_mu}
species_extents: {size_of: species}
masses_extents: {size_of: masses}
charges_extents: {size_of: charges}
- file: '${read_restart_filename}'
on_event: [read_grid]
read:
grid_tor1: ~
grid_tor2: ~
grid_tor3: ~
grid_vpar: ~
grid_mu: ~
species: ~
masses: ~
charges: ~
- file: '${read_restart_filename}'
on_event: [read_profiles]
read:
- densityTorCS
- temperatureTorCS
- UparTorCS
- file: '${read_restart_filename}'
on_event: [read_fdistribu]
read:
- time_saved
- fdistribu
- file: '${write_restart_filename}'
on_event: [write_restart]
collision_policy: skip_and_warn
write:
- iter_saved
- time_saved
- grid_tor1
- grid_tor2
- grid_tor3
- grid_vpar
- grid_mu
- species
- masses
- charges
- densityTorCS
- temperatureTorCS
- UparTorCS
- fdistribu
trace: ~
)PDI_CFG";
Loading

0 comments on commit 33b4111

Please sign in to comment.