Skip to content

Commit

Permalink
Fluid species dimensions implementation
Browse files Browse the repository at this point in the history
This merge request adds the support for describing a fluid species in prevision for the neutral model added in another merge request.

This is done by adding a new dimension:
- the `M`dimension (for Moments): a discrete space for describing the fluid moments of the fluid species. This dimension can be initialized with a varying number of moments that should be taken into account by the underlying physical model (ex. the code can solve only for the density, or for the density and velocity, etc.).

-  A new version of the predictor corrector scheme is added, to solve fluid models for these fluid species on top of the Vlasov-Poisson system.
- A bunch of tests are added.

See merge request gysela-developpers/gyselalibxx!385

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

Co-authored-by: Emily Bourne <[email protected]>
Co-authored-by: yannm <[email protected]>
Co-authored-by: Baptiste LEGOUIX <[email protected]>
  • Loading branch information
3 people committed Apr 9, 2024
1 parent 9194a7b commit 0315225
Show file tree
Hide file tree
Showing 32 changed files with 1,302 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ The `src/` folder contains all the code necessary to build a gyrokinetic semi-La
- [interpolation](./interpolation/README.md) - Code describing interpolation methods.
<!-- - [paraconfpp](./paraconfpp/README.md) - Paraconf utility functions. -->
- [quadrature](./quadrature/README.md) - Code describing different quadrature methods.
<!-- - [speciesinfo](./speciesinfo/README.md) - Code used to describe the different species. -->
- [speciesinfo](./speciesinfo/README.md) - Code used to describe the different species.
- [timestepper](./timestepper/README.md) - Code used to describe time-stepping methods (e.g. Runge-Kutta methods).
- [utils](./utils/README.md) - Code describing utility functions.
2 changes: 2 additions & 0 deletions src/geometryXVx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ cmake_minimum_required(VERSION 3.15)

add_subdirectory(poisson)
add_subdirectory(geometry)
add_subdirectory(geometryMX)
add_subdirectory(time_integration)
add_subdirectory(time_integration_hybrid)
add_subdirectory(rhs)
add_subdirectory(boltzmann)
add_subdirectory(initialization)
Expand Down
2 changes: 2 additions & 0 deletions src/geometryXVx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ The `geometryXVx` folder contains all the code describing methods which are spec

- [boltzmann](./boltzmann/README.md) : Solvers for a Boltzmann equation.
- [geometry](./geometry/README.md) : All the dimension tags used for a simulation in the geometry.
- [geometryMX](./geometryMX/README.md) : Code describing a geometry with a single spatial dimension and a single fluid moment dimension.
- [initialization](./initialization/README.md) : Initialization methods for the distribution function.
- [poisson](./poisson/README.md) : Code describing the polar Poisson solver.
- [rhs](./rhs/README.md) : Code describing the operators on the right hand side of the Boltzmann equation; namely sources, sinks and collisions.
- [time\_integration](./time_integration/README.md) : Time integrators for a Boltzmann-Poisson system of equations.
- [time\_integration\_neutrals](./time_integration_neutrals/README.md) : Time integrators for a Boltzmann-Poisson system of equations, with a fluid neutral species.
- [utils](./utils/README.md) : Miscellaneous utility functions.
1 change: 1 addition & 0 deletions src/geometryXVx/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_include_directories("geometry_${GEOMETRY_VARIANT}"
target_link_libraries("geometry_${GEOMETRY_VARIANT}" INTERFACE
DDC::DDC
gslx::speciesinfo
gslx::moments
gslx::utils
)
add_library("gslx::geometry_${GEOMETRY_VARIANT}" ALIAS "geometry_${GEOMETRY_VARIANT}")
Expand Down
129 changes: 89 additions & 40 deletions src/geometryXVx/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ddc/kernels/splines.hpp>

#include <ddc_helper.hpp>
#include <moments.hpp>
#include <species_info.hpp>

/**
Expand Down Expand Up @@ -47,9 +48,7 @@ struct RDimT
};



using CoordT = ddc::Coordinate<RDimT>;

using CoordX = ddc::Coordinate<RDimX>;

using CoordVx = ddc::Coordinate<RDimVx>;
Expand Down Expand Up @@ -186,74 +185,106 @@ using SplineVxEvaluator_1d = ddc::SplineEvaluator<
// Species dimension
using IDimSp = SpeciesInformation;

using IDimM = Moments;

using IndexX = ddc::DiscreteElement<IDimX>;
using IndexM = ddc::DiscreteElement<IDimM>;

using IndexSp = ddc::DiscreteElement<IDimSp>;

using IndexVx = ddc::DiscreteElement<IDimVx>;

using IndexSp = ddc::DiscreteElement<IDimSp>;
using IndexX = ddc::DiscreteElement<IDimX>;

using IndexSpX = ddc::DiscreteElement<IDimSp, IDimX>;

using IndexXVx = ddc::DiscreteElement<IDimX, IDimVx>;
using IndexSpM = ddc::DiscreteElement<IDimSp, IDimM>;

using IndexSpMX = ddc::DiscreteElement<IDimSp, IDimM, IDimX>;

using IndexSpX = ddc::DiscreteElement<IDimSp, IDimX>;

using IndexSpVx = ddc::DiscreteElement<IDimSp, IDimVx>;

using IndexSpXVx = ddc::DiscreteElement<IDimSp, IDimX, IDimVx>;

using IndexXVx = ddc::DiscreteElement<IDimX, IDimVx>;


using IVectX = ddc::DiscreteVector<IDimX>;

using IVectM = ddc::DiscreteVector<IDimM>;

using IVectSp = ddc::DiscreteVector<IDimSp>;

using IVectVx = ddc::DiscreteVector<IDimVx>;

using IVectXVx = ddc::DiscreteVector<IDimX, IDimVx>;
using IVectX = ddc::DiscreteVector<IDimX>;

using IVectSpXVx = ddc::DiscreteVector<IDimSp, IDimX, IDimVx>;

using IVectSp = ddc::DiscreteVector<IDimSp>;
using IVectSpM = ddc::DiscreteVector<IDimSp, IDimM>;

using IVectSpX = ddc::DiscreteVector<IDimSp, IDimX>;
using IVectSpMX = ddc::DiscreteVector<IDimSp, IDimM, IDimX>;

using IVectSpVx = ddc::DiscreteVector<IDimSp, IDimVx>;

using IVectSpX = ddc::DiscreteVector<IDimSp, IDimX>;

using IVectSpXVx = ddc::DiscreteVector<IDimSp, IDimX, IDimVx>;

using IVectXVx = ddc::DiscreteVector<IDimX, IDimVx>;



using BSDomainX = ddc::DiscreteDomain<BSplinesX>;

using BSDomainVx = ddc::DiscreteDomain<BSplinesVx>;

using IDomainX = ddc::DiscreteDomain<IDimX>;

using IDomainVx = ddc::DiscreteDomain<IDimVx>;

using IDomainXVx = ddc::DiscreteDomain<IDimX, IDimVx>;
using IDomainM = ddc::DiscreteDomain<IDimM>;

using IDomainSp = ddc::DiscreteDomain<IDimSp>;

using IDomainSpX = ddc::DiscreteDomain<IDimSp, IDimX>;
using IDomainVx = ddc::DiscreteDomain<IDimVx>;

using IDomainX = ddc::DiscreteDomain<IDimX>;



using IDomainSpM = ddc::DiscreteDomain<IDimSp, IDimM>;

using IDomainSpMX = ddc::DiscreteDomain<IDimSp, IDimM, IDimX>;

using IDomainSpVx = ddc::DiscreteDomain<IDimSp, IDimVx>;

using IDomainSpX = ddc::DiscreteDomain<IDimSp, IDimX>;

using IDomainSpXVx = ddc::DiscreteDomain<IDimSp, IDimX, IDimVx>;

using IDomainXVx = ddc::DiscreteDomain<IDimX, IDimVx>;



template <class ElementType>
using FieldX = device_t<ddc::Chunk<ElementType, IDomainX>>;
using FieldSp = device_t<ddc::Chunk<ElementType, IDomainSp>>;

template <class ElementType>
using FieldVx = device_t<ddc::Chunk<ElementType, IDomainVx>>;

template <class ElementType>
using FieldSp = device_t<ddc::Chunk<ElementType, IDomainSp>>;
using FieldX = device_t<ddc::Chunk<ElementType, IDomainX>>;


template <class ElementType>
using FieldSpX = device_t<ddc::Chunk<ElementType, IDomainSpX>>;
using FieldSpM = device_t<ddc::Chunk<ElementType, IDomainSpM>>;

template <class ElementType>
using FieldSpMX = device_t<ddc::Chunk<ElementType, IDomainSpMX>>;

template <class ElementType>
using FieldSpVx = device_t<ddc::Chunk<ElementType, IDomainSpVx>>;

template <class ElementType>
using FieldSpX = device_t<ddc::Chunk<ElementType, IDomainSpX>>;

template <class ElementType>
using FieldSpXVx = device_t<ddc::Chunk<ElementType, IDomainSpXVx>>;

Expand All @@ -262,105 +293,123 @@ using FieldSpXVx = device_t<ddc::Chunk<ElementType, IDomainSpXVx>>;
template <class DomainType>
using DField = device_t<ddc::Chunk<double, DomainType>>;

using DFieldSp = FieldSp<double>;

using DFieldVx = FieldVx<double>;

using DFieldX = FieldX<double>;

using DFieldVx = FieldVx<double>;

using DFieldSp = FieldSp<double>;
using DFieldSpM = FieldSpM<double>;

using DFieldSpX = FieldSpX<double>;
using DFieldSpMX = FieldSpMX<double>;

using DFieldSpVx = FieldSpVx<double>;

using DFieldSpX = FieldSpX<double>;

using DFieldSpXVx = FieldSpXVx<double>;


template <class ElementType>
using SpanSp = device_t<ddc::ChunkSpan<ElementType, IDomainSp>>;

template <class ElementType>
using SpanSpX = device_t<ddc::ChunkSpan<ElementType, IDomainSpX>>;
using BSSpanX = device_t<ddc::ChunkSpan<ElementType, BSDomainX>>;

template <class ElementType>
using SpanX = device_t<ddc::ChunkSpan<ElementType, IDomainX>>;
using SpanSp = device_t<ddc::ChunkSpan<ElementType, IDomainSp>>;

template <class ElementType>
using SpanSpX = device_t<ddc::ChunkSpan<ElementType, IDomainSpX>>;
using SpanX = device_t<ddc::ChunkSpan<ElementType, IDomainX>>;

template <class ElementType>
using SpanVx = device_t<ddc::ChunkSpan<ElementType, IDomainVx>>;

template <class ElementType>
using SpanSpXVx = device_t<ddc::ChunkSpan<ElementType, IDomainSpXVx>>;
using SpanSpMX = device_t<ddc::ChunkSpan<ElementType, IDomainSpMX>>;

template <class ElementType>
using SpanSpVx = device_t<ddc::ChunkSpan<ElementType, IDomainSpVx>>;

template <class ElementType>
using BSSpanX = device_t<ddc::ChunkSpan<ElementType, BSDomainX>>;
using SpanSpX = device_t<ddc::ChunkSpan<ElementType, IDomainSpX>>;

template <class ElementType>
using SpanSpXVx = device_t<ddc::ChunkSpan<ElementType, IDomainSpXVx>>;


template <class DomainType>
using DSpan = device_t<ddc::ChunkSpan<double, DomainType>>;

using DBSSpanX = BSSpanX<double>;

using DSpanSp = SpanSp<double>;

using DSpanSpX = SpanSpX<double>;
using DSpanVx = SpanVx<double>;

using DSpanX = SpanX<double>;

using DSpanVx = SpanVx<double>;
using DSpanSpMX = SpanSpMX<double>;

using DSpanSpVx = SpanSpVx<double>;

using DSpanSpX = SpanSpX<double>;

using DSpanSpXVx = SpanSpXVx<double>;

using DSpanSpVx = SpanSpVx<double>;

using DBSSpanX = BSSpanX<double>;

template <class ElementType>
using ViewSp = device_t<ddc::ChunkSpan<ElementType const, IDomainSp>>;

template <class ElementType>
using ViewVx = device_t<ddc::ChunkSpan<ElementType const, IDomainVx>>;

template <class ElementType>
using ViewX = device_t<ddc::ChunkSpan<ElementType const, IDomainX>>;


template <class ElementType>
using ViewVx = device_t<ddc::ChunkSpan<ElementType const, IDomainVx>>;
using BSViewX = device_t<ddc::ChunkSpan<ElementType const, BSDomainX>>;

template <class ElementType>
using ViewSp = device_t<ddc::ChunkSpan<ElementType const, IDomainSp>>;
using ViewSpM = device_t<ddc::ChunkSpan<ElementType const, IDomainSpM>>;

template <class ElementType>
using ViewSpX = device_t<ddc::ChunkSpan<ElementType const, IDomainSpX>>;
using ViewSpMX = device_t<ddc::ChunkSpan<ElementType const, IDomainSpMX>>;

template <class ElementType>
using ViewSpVx = device_t<ddc::ChunkSpan<ElementType const, IDomainSpVx>>;

template <class ElementType>
using ViewSpXVx = device_t<ddc::ChunkSpan<ElementType const, IDomainSpXVx>>;
using ViewSpX = device_t<ddc::ChunkSpan<ElementType const, IDomainSpX>>;

template <class ElementType>
using BSViewX = device_t<ddc::ChunkSpan<ElementType const, BSDomainX>>;
using ViewSpXVx = device_t<ddc::ChunkSpan<ElementType const, IDomainSpXVx>>;



template <class DomainType>
using DView = device_t<ddc::ChunkSpan<double const, DomainType>>;

using DViewSp = ViewSp<double>;

using DViewVx = ViewVx<double>;

using DViewX = ViewX<double>;

using DViewVx = ViewVx<double>;

using DViewSp = ViewSp<double>;
using DBSViewX = BSViewX<double>;

using DViewSpM = ViewSpM<double>;

using DViewSpMX = ViewSpMX<double>;

using DViewSpX = ViewSpX<double>;

using DViewSpVx = ViewSpVx<double>;

using DViewSpXVx = ViewSpXVx<double>;

using DBSViewX = BSViewX<double>;

using RDimFx = ddc::Fourier<RDimX>;
using CoordFx = ddc::Coordinate<RDimFx>;
Expand Down
4 changes: 4 additions & 0 deletions src/geometryXVx/geometryMX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: MIT

add_subdirectory(fluidinitialization)
add_subdirectory(fluidsolver)
6 changes: 6 additions & 0 deletions src/geometryXVx/geometryMX/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Geometry (x)

The `geometryMX` folder contains all the code describing methods which are specific to a geometry with 1 spatial dimension and one dimension describing fluid moments (ex: density, temperature, mean velocity). It is broken up into the following sub-folders:

- [fluidinitialization](./fluidinitialization/README.md) : Initialization methods for fluid species.
- [fluidsolver](./fluidsolver/README.md) : Solver for fluid models.
26 changes: 26 additions & 0 deletions src/geometryXVx/geometryMX/fluidinitialization/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: MIT

foreach(GEOMETRY_VARIANT IN LISTS GEOMETRY_XVx_VARIANTS_LIST)

add_library("fluidinitialization_${GEOMETRY_VARIANT}" STATIC
constantfluidinitialization.cpp
)

target_compile_features("fluidinitialization_${GEOMETRY_VARIANT}"
PUBLIC
cxx_std_17
)

target_include_directories("fluidinitialization_${GEOMETRY_VARIANT}"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
)

target_link_libraries("fluidinitialization_${GEOMETRY_VARIANT}"
PUBLIC
DDC::DDC
gslx::geometry_${GEOMETRY_VARIANT}
)

add_library("gslx::fluidinitialization_${GEOMETRY_VARIANT}" ALIAS "fluidinitialization_${GEOMETRY_VARIANT}")

endforeach()
6 changes: 6 additions & 0 deletions src/geometryXVx/geometryMX/fluidinitialization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Fluid Initialization methods

The fluidinitialization folder contains any methods that define the value of a fluid species at the start of the simulation. The fluid species is described by its fluid moments.

The implemented initialization methods are:
- ConstantFluidInitialization
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT

#include <ddc/ddc.hpp>

#include "constantfluidinitialization.hpp"

ConstantFluidInitialization::ConstantFluidInitialization(host_t<DViewSpM> moments)
: m_moments_alloc(moments.domain())
{
ddc::parallel_deepcopy(m_moments_alloc, moments);
}

DSpanSpMX ConstantFluidInitialization::operator()(DSpanSpMX const fluid_moments) const
{
ddc::ChunkSpan moments(m_moments_alloc.span_view());
ddc::parallel_for_each(
Kokkos::DefaultExecutionSpace(),
fluid_moments.domain(),
KOKKOS_LAMBDA(IndexSpMX const ispmx) {
IndexSpM ispm(ddc::select<IDimSp, IDimM>(ispmx));
fluid_moments(ispmx) = moments(ispm);
});
return fluid_moments;
}
Loading

0 comments on commit 0315225

Please sign in to comment.