Skip to content

Commit

Permalink
Update DDC
Browse files Browse the repository at this point in the history
See merge request gysela-developpers/gyselalibxx!421

--------------------------------------------
  • Loading branch information
EmilyBourne committed Mar 26, 2024
1 parent cd0ae13 commit 3a413f8
Show file tree
Hide file tree
Showing 11 changed files with 517 additions and 143 deletions.
15 changes: 0 additions & 15 deletions vendor/ddc/.github/workflows/reuse.yml

This file was deleted.

7 changes: 3 additions & 4 deletions vendor/ddc/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
exclude: ''
extensions: 'hpp,cpp'
clangFormatVersion: 12
- name: REUSE Compliance Check
if: always()
uses: fsfe/reuse-action@v3

id_repo:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -133,12 +136,10 @@ jobs:
export CC=hipcc
export CXX=hipcc
EXTRA_CMAKE_FLAGS="-DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON -DCMAKE_PREFIX_PATH=/opt/rocm"
CMAKE_CXX_FLAGS="-Wno-gnu-zero-variadic-macro-arguments"
;;
'cpu-clang')
export CC=clang
export CXX=clang++
CMAKE_CXX_FLAGS="-Wno-gnu-zero-variadic-macro-arguments"
;;
'cpu-gcc')
export CC=gcc
Expand All @@ -154,7 +155,6 @@ jobs:
-DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
-DMDSPAN_CXX_STANDARD=${{matrix.cxx_version}} \
-DKokkos_ENABLE_DEPRECATED_CODE_3=OFF \
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-DCMAKE_CXX_FLAGS="\
Expand Down Expand Up @@ -218,7 +218,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DMDSPAN_CXX_STANDARD=17 \
-DKokkos_ENABLE_DEPRECATED_CODE_3=OFF \
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-S /src \
Expand Down
121 changes: 0 additions & 121 deletions vendor/ddc/LICENSES/CC0-1.0.txt

This file was deleted.

8 changes: 8 additions & 0 deletions vendor/ddc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ All these abstractions are handled at compilation using C++ template meta-progra
If you like the project, please leave us a github star.

If you want to know more, join un on [Slack](https://join.slack.com/t/ddc-lib/shared_invite/zt-14b6rjcrn-AwSfM6_arEamAKk_VgQPhg)

## Getting the code and basic configuration

```bash
git clone --recurse-submodules -j8 https://github.com/CExA-project/ddc.git
cd ddc
cmake -B build -D DDC_BUILD_KERNELS_FFT=OFF -D DDC_BUILD_KERNELS_SPLINES=OFF -D DDC_BUILD_PDI_WRAPPER=OFF
```
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,39 @@ struct ConstantExtrapolationRule
{
};

/**
* @brief A functor for describing a spline boundary value by a constant extrapolation for 1D evaluator.
*
* To define the value of a function on B-splines out of the domain, we here use a constant
* extrapolation on the edge.
*/
template <class DimI>
struct ConstantExtrapolationRule<DimI>
{
private:
ddc::Coordinate<DimI> m_eval_pos;

public:
/**
* @brief Instantiate a ConstantExtrapolationRule.
*
* The boundary value will be the same as at the coordinate eval_pos given.
*
* @param[in] eval_pos
* Coordinate inside the domain where we will evaluate each points outside the domain.
*/
explicit ConstantExtrapolationRule(ddc::Coordinate<DimI> eval_pos) : m_eval_pos(eval_pos) {}

/**
* @brief Get the value of the function on B-splines at a coordinate outside the domain.
*
* @param[in] pos
* The coordinate where we want to evaluate the function on B-splines.
* @param[in] spline_coef
* The coefficients of the function on B-splines.
*
* @return A double with the value of the function on B-splines evaluated at the coordinate.
*/
template <class CoordType, class BSplines, class Layout, class MemorySpace>
KOKKOS_FUNCTION double operator()(
CoordType,
Expand All @@ -43,6 +67,12 @@ struct ConstantExtrapolationRule<DimI>
}
};

/**
* @brief A functor for describing a spline boundary value by a constant extrapolation for 2D evaluator.
*
* To define the value of a function on B-splines out of the domain, we here use a constant
* extrapolation on the edge.
*/
template <class DimI, class DimNI>
struct ConstantExtrapolationRule<DimI, DimNI>
{
Expand All @@ -52,6 +82,23 @@ struct ConstantExtrapolationRule<DimI, DimNI>
ddc::Coordinate<DimNI> m_eval_pos_not_interest_max;

public:
/**
* @brief Instantiate a ConstantExtrapolationRule.
*
* The boundary value will be the same as at the coordinate given in a dimension given.
* The dimension of the input defines the dimension of the boundary condition.
* The second and the third parameters are needed in case of non-periodic splines on the
* dimension off-interest (the complementary dimension of the boundary condition),
* because the evaluator can receive coordinates outside the domain in both dimension.
*
* @param[in] eval_pos_bc
* Coordinate in the dimension given inside the domain where we will evaluate
* each points outside the domain.
* @param[in] eval_pos_not_interest_min
* The minimum coordinate inside the domain on the complementary dimension of the boundary condition.
* @param[in] eval_pos_not_interest_max
* The maximum coordinate inside the domain on the complementary dimension of the boundary condition.
*/
explicit ConstantExtrapolationRule(
ddc::Coordinate<DimI> eval_pos,
ddc::Coordinate<DimNI> eval_pos_not_interest_min,
Expand All @@ -62,6 +109,18 @@ struct ConstantExtrapolationRule<DimI, DimNI>
{
}

/**
* @brief Instantiate a ConstantExtrapolationRule.
*
* The boundary value will be the same as at the coordinate given in a dimension given.
* The dimension of the input defines the dimension of the boundary condition.
* No second and third parameters are needed in case of periodic splines on the
* dimension off-interest (the complementary dimension of the boundary condition).
*
* @param[in] eval_pos_bc
* Coordinate in the dimension given inside the domain where we will evaluate
* each points outside the domain.
*/
template <class DimNI_sfinae = DimNI, std::enable_if_t<DimNI_sfinae::PERIODIC, int> = 0>
explicit ConstantExtrapolationRule(ddc::Coordinate<DimI> eval_pos)
: m_eval_pos(eval_pos)
Expand All @@ -70,6 +129,23 @@ struct ConstantExtrapolationRule<DimI, DimNI>
{
}

/**
* @brief Get the value of the function on B-splines at a coordinate outside the domain.
*
* In the dimension defined in the constructor Dim1 (or Dim2), it sets the coordinate pos_1 (or pos_2)
* given at the m_eval_pos coordinate if it is outside the domain.
* If the coordinate on the complementary dimension of the boundary condition dimension ddc::select<DimNI>(coord_extrap) is
* outside the domain, then it also sets the coordinate at eval_pos_not_interest_min
* (if ddc::select<DimNI>(coord_extrap) @f$ < @f$ eval_pos_not_interest_min) or
* at eval_pos_not_interest_max (if ddc::select<DimNI>(coord_extrap) @f$ > @f$ eval_pos_not_interest_max).
*
* @param[in] coord_extrap
* The coordinates where we want to evaluate the function on B-splines
* @param[in] spline_coef
* The coefficients of the function on B-splines.
*
*@return A double with the value of the function on B-splines evaluated at the coordinate.
*/
template <class CoordType, class BSplines1, class BSplines2, class Layout, class MemorySpace>
KOKKOS_FUNCTION double operator()(
CoordType coord_extrap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
#include "spline_boundary_conditions.hpp"

namespace ddc {
/**
* A class which provides helper functions to initialise the Greville points from a B-Spline definition.
*
* @tparam BSplines The bspline class relative to which the Greville points will be calculated.
* @tparam BcXmin The (left) boundary condition that will be used to build the splines.
* @tparam BcXmax The (right) boundary condition that will be used to build the splines.
*/
template <class BSplines, ddc::BoundCond BcXmin, ddc::BoundCond BcXmax>
class GrevilleInterpolationPoints
{
Expand All @@ -39,7 +46,12 @@ class GrevilleInterpolationPoints
using Sampling = ddc::NonUniformPointSampling<tag_type>;
using SamplingImpl = typename Sampling::template Impl<Kokkos::HostSpace>;

std::vector<double> greville_points(ddc::discrete_space<BSplines>().nbasis());
int n_greville_points = ddc::discrete_space<BSplines>().nbasis();
if constexpr (U::is_periodic()) {
n_greville_points += 1;
}

std::vector<double> greville_points(n_greville_points);
ddc::DiscreteDomain<BSplines> bspline_domain
= ddc::discrete_space<BSplines>().full_domain().take_first(
ddc::DiscreteVector<BSplines>(ddc::discrete_space<BSplines>().nbasis()));
Expand Down Expand Up @@ -72,6 +84,10 @@ class GrevilleInterpolationPoints
greville_points[ddc::discrete_space<BSplines>().nbasis() - npoints + i]
= temp_knots[i];
}

// Save a periodic point to initialise the domain size
greville_points[n_greville_points - 1]
= greville_points[0] + ddc::discrete_space<BSplines>().length();
}

return SamplingImpl(greville_points);
Expand All @@ -84,6 +100,15 @@ class GrevilleInterpolationPoints
= U::is_uniform() && ((N_BE_MIN != 0 && N_BE_MAX != 0) || U::is_periodic());

public:
/**
* Get the UniformPointSampling defining the Greville points.
*
* This function is called when the result is a UniformPointSampling. This is the case
* when uniform splines are used with an odd degree and with boundary conditions which
* do not introduce additional interpolation points.
*
* @returns The mesh of uniform Greville points.
*/
template <
typename U = BSplines,
std::enable_if_t<
Expand All @@ -94,6 +119,11 @@ class GrevilleInterpolationPoints
return uniform_greville_points();
}

/**
* Get the NonUniformPointSampling defining the Greville points.
*
* @returns The mesh of non-uniform Greville points.
*/
template <
typename U = BSplines,
std::enable_if_t<
Expand Down Expand Up @@ -187,8 +217,18 @@ class GrevilleInterpolationPoints
}
}

/**
* The type of the mesh.
*
* This is either NonUniformPointSampling or UniformPointSampling.
*/
using interpolation_mesh_type = typename decltype(get_sampling())::discrete_dimension_type;

/**
* Get the domain which gives us access to all of the Greville points.
*
* @returns The domain of the Greville points.
*/
static ddc::DiscreteDomain<interpolation_mesh_type> get_domain()
{
int const npoints = ddc::discrete_space<BSplines>().nbasis() - N_BE_MIN - N_BE_MAX;
Expand Down
Loading

0 comments on commit 3a413f8

Please sign in to comment.