Skip to content

Commit

Permalink
Reduce duplication of species definition in geometries
Browse files Browse the repository at this point in the history
Closes #247

See merge request gysela-developpers/gyselalibxx!518

--------------------------------------------
  • Loading branch information
Emily Bourne committed Jun 17, 2024
1 parent 8825ed4 commit c679ce0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 104 deletions.
4 changes: 2 additions & 2 deletions simulations/geometry5D/testcollisions/testcollisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ int main(int argc, char** argv)
DDomVpar dom_vpar(IdxVpar(0), DVecVpar(grid_vpar.size()));
ddc::init_discrete_space<GridMu>(grid_mu);
DDomMu dom_mu(IdxMu(0), DVecMu(grid_mu.size()));
DVecSp const kinspecies(charges.size());
DDomSp const dom_kinsp(IdxSp(0), kinspecies);
IVectSp const kinspecies(charges.size());
IDomainSp const dom_kinsp(IndexSp(0), kinspecies);

DFieldTor1 field_grid_tor1(dom_tor1);
ddc::parallel_deepcopy(field_grid_tor1, DViewTor1(grid_tor1.data(), dom_tor1));
Expand Down
17 changes: 2 additions & 15 deletions src/geometry5D/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@
*
*/

using Species = IDimSp;
using IdxSp = ddc::DiscreteElement<Species>;
using DVecSp = ddc::DiscreteVector<Species>;
using DDomSp = ddc::DiscreteDomain<Species>;

template <class ElementType>
using FieldSp = ddc::Chunk<ElementType, DDomSp>;
using DFieldSp = FieldSp<double>;

template <class ElementType>
using ViewSp = ddc::ChunkView<ElementType const, DDomSp>;
using DViewSp = ViewSp<double>;

/**
* @brief Define non periodic radial dimension @f$r@f$.
*/
Expand Down Expand Up @@ -129,8 +116,8 @@ using DDomMu = ddc::DiscreteDomain<GridMu>;
using DDomTorCS = ddc::DiscreteDomain<GridTor2, GridTor1>;
using DDomTor3D = ddc::DiscreteDomain<GridTor3, GridTor2, GridTor1>;
using DDomV2D = ddc::DiscreteDomain<GridVpar, GridMu>;
using DDomSpTor3DV2D = ddc::DiscreteDomain<Species, GridTor3, GridTor2, GridTor1, GridVpar, GridMu>;
using DDomSpTorCS = ddc::DiscreteDomain<Species, GridTor2, GridTor1>;
using DDomSpTor3DV2D = ddc::DiscreteDomain<IDimSp, GridTor3, GridTor2, GridTor1, GridVpar, GridMu>;
using DDomSpTorCS = ddc::DiscreteDomain<IDimSp, GridTor2, GridTor1>;

template <class ElementType>
using FieldTor1 = device_t<ddc::Chunk<ElementType, DDomTor1>>;
Expand Down
33 changes: 0 additions & 33 deletions src/geometryRTheta/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,53 +544,40 @@ struct IDimVx : SplineInterpPointsVx::interpolation_mesh_type
{
};



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

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



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

using IVectSp = ddc::DiscreteVector<IDimSp>;
using IVectSpX = ddc::DiscreteVector<IDimSp, IDimX>;
using IVectSpVx = ddc::DiscreteVector<IDimSp, IDimVx>;
using IVectSpXVx = ddc::DiscreteVector<IDimSp, 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 IDomainSp = ddc::DiscreteDomain<IDimSp>;
using IDomainSpX = ddc::DiscreteDomain<IDimSp, IDimX>;
using IDomainSpVx = ddc::DiscreteDomain<IDimSp, IDimVx>;
using IDomainSpXVx = ddc::DiscreteDomain<IDimSp, IDimX, IDimVx>;



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

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

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

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

Expand All @@ -600,27 +587,19 @@ using FieldSpVx = ddc::Chunk<ElementType, IDomainSpVx>;
template <class ElementType>
using FieldSpXVx = ddc::Chunk<ElementType, IDomainSpXVx>;



using DFieldX = FieldX<double>;
using DFieldVx = FieldVx<double>;

using DFieldSp = FieldSp<double>;
using DFieldSpX = FieldSpX<double>;
using DFieldSpVx = FieldSpVx<double>;
using DFieldSpXVx = FieldSpXVx<double>;



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

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

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

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

Expand All @@ -630,27 +609,19 @@ using SpanSpVx = ddc::ChunkSpan<ElementType, IDomainSpVx>;
template <class ElementType>
using SpanSpXVx = ddc::ChunkSpan<ElementType, IDomainSpXVx>;



using DSpanX = SpanX<double>;
using DSpanVx = SpanVx<double>;

using DSpanSp = SpanSp<double>;
using DSpanSpX = SpanSpX<double>;
using DSpanSpVx = SpanSpVx<double>;
using DSpanSpXVx = SpanSpXVx<double>;



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

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

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

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

Expand All @@ -663,12 +634,9 @@ using ViewSpXVx = ddc::ChunkSpan<ElementType const, IDomainSpXVx>;
template <class ElementType>
using BSViewX = ddc::ChunkSpan<ElementType const, BSDomainX>;



using DViewX = ViewX<double>;
using DViewVx = ViewVx<double>;

using DViewSp = ViewSp<double>;
using DViewSpX = ViewSpX<double>;
using DViewSpVx = ViewSpVx<double>;
using DViewSpXVx = ViewSpXVx<double>;
Expand Down Expand Up @@ -968,7 +936,6 @@ template <class ElementType>
using BSViewXY = ddc::ChunkSpan<ElementType const, BSDomainXY>;



using DViewXY = ViewXY<double>;
using DViewVxVy = ViewVxVy<double>;

Expand Down
25 changes: 0 additions & 25 deletions src/geometryXVx/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ struct IDimM : Moments

using IndexM = ddc::DiscreteElement<IDimM>;

using IndexSp = ddc::DiscreteElement<IDimSp>;

using IndexVx = ddc::DiscreteElement<IDimVx>;

using IndexX = ddc::DiscreteElement<IDimX>;
Expand All @@ -204,8 +202,6 @@ using IndexXVx = ddc::DiscreteElement<IDimX, IDimVx>;

using IVectM = ddc::DiscreteVector<IDimM>;

using IVectSp = ddc::DiscreteVector<IDimSp>;

using IVectVx = ddc::DiscreteVector<IDimVx>;

using IVectX = ddc::DiscreteVector<IDimX>;
Expand Down Expand Up @@ -233,14 +229,10 @@ using BSDomainVx = ddc::DiscreteDomain<BSplinesVx>;

using IDomainM = ddc::DiscreteDomain<IDimM>;

using IDomainSp = ddc::DiscreteDomain<IDimSp>;

using IDomainVx = ddc::DiscreteDomain<IDimVx>;

using IDomainX = ddc::DiscreteDomain<IDimX>;



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

using IDomainSpMX = ddc::DiscreteDomain<IDimSp, IDimM, IDimX>;
Expand All @@ -254,10 +246,6 @@ using IDomainSpXVx = ddc::DiscreteDomain<IDimSp, IDimX, IDimVx>;
using IDomainXVx = ddc::DiscreteDomain<IDimX, IDimVx>;



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

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

Expand Down Expand Up @@ -288,8 +276,6 @@ 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>;
Expand All @@ -312,9 +298,6 @@ using DFieldSpXVx = FieldSpXVx<double>;
template <class ElementType>
using BSSpanX = device_t<ddc::ChunkSpan<ElementType, BSDomainX>>;

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

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

Expand All @@ -339,8 +322,6 @@ using DSpan = device_t<ddc::ChunkSpan<double, DomainType>>;

using DBSSpanX = BSSpanX<double>;

using DSpanSp = SpanSp<double>;

using DSpanVx = SpanVx<double>;

using DSpanX = SpanX<double>;
Expand All @@ -354,10 +335,6 @@ using DSpanSpX = SpanSpX<double>;
using DSpanSpXVx = SpanSpXVx<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>>;

Expand Down Expand Up @@ -388,8 +365,6 @@ 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>;
Expand Down
12 changes: 0 additions & 12 deletions src/geometryXYVxVy/geometry/geometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ using BSViewXY = device_t<ddc::ChunkSpan<ElementType const, BSDomainXY>>;
using DBSViewXY = BSViewXY<double>;

// Index
using IndexSp = ddc::DiscreteElement<IDimSp>;
using IndexX = ddc::DiscreteElement<IDimX>;
using IndexY = ddc::DiscreteElement<IDimY>;
using IndexXY = ddc::DiscreteElement<IDimX, IDimY>;
Expand All @@ -267,14 +266,12 @@ using IndexXYVxVy = ddc::DiscreteElement<IDimX, IDimY, IDimVx, IDimVy>;
using IndexSpXYVxVy = ddc::DiscreteElement<IDimSp, IDimX, IDimY, IDimVx, IDimVy>;

// IVect definition
using IVectSp = ddc::DiscreteVector<IDimSp>;
using IVectX = ddc::DiscreteVector<IDimX>;
using IVectY = ddc::DiscreteVector<IDimY>;
using IVectVx = ddc::DiscreteVector<IDimVx>;
using IVectVy = ddc::DiscreteVector<IDimVy>;

// Idomain definition
using IDomainSp = ddc::DiscreteDomain<IDimSp>;
using IDomainX = ddc::DiscreteDomain<IDimX>;
using IDomainY = ddc::DiscreteDomain<IDimY>;
using IDomainXY = ddc::DiscreteDomain<IDimX, IDimY>;
Expand All @@ -285,11 +282,6 @@ using IDomainVxVy = ddc::DiscreteDomain<IDimVx, IDimVy>;
using IDomainSpVxVy = ddc::DiscreteDomain<IDimSp, IDimVx, IDimVy>;
using IDomainSpXYVxVy = ddc::DiscreteDomain<IDimSp, IDimX, IDimY, IDimVx, IDimVy>;

// Field definition
template <class ElementType>
using FieldSp = device_t<ddc::Chunk<ElementType, IDomainSp>>;
using DFieldSp = FieldSp<double>;

template <class ElementType>
using FieldX = device_t<ddc::Chunk<ElementType, IDomainX>>;
using DFieldX = FieldX<double>;
Expand Down Expand Up @@ -358,10 +350,6 @@ using SpanSpXYVxVy = device_t<ddc::ChunkSpan<ElementType, IDomainSpXYVxVy>>;
using DSpanSpXYVxVy = SpanSpXYVxVy<double>;

// View definition
template <class ElementType>
using ViewSp = device_t<ddc::ChunkSpan<ElementType const, IDomainSp>>;
using DViewSp = ViewSp<double>;

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

Expand Down
19 changes: 19 additions & 0 deletions src/speciesinfo/species_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <ddc/ddc.hpp>

#include <ddc_helper.hpp>

/// @brief Species discrete dimension to access constant attributes related to species.
class SpeciesInformation
{
Expand Down Expand Up @@ -161,3 +163,20 @@ KOKKOS_INLINE_FUNCTION double mass(ddc::DiscreteElement<IDimSp> const isp)
{
return ddc::discrete_space<IDimSp>().mass(isp);
}

using IndexSp = ddc::DiscreteElement<IDimSp>;
using IDomainSp = ddc::DiscreteDomain<IDimSp>; // --> Should be DomSp
using IVectSp = ddc::DiscreteVector<IDimSp>; // --> Should be VectSp or VecSp

template <class ElementType>
using FieldSp = ddc::Chunk<ElementType, IDomainSp>;
using DFieldSp = FieldSp<double>;
using IFieldSp = device_t<ddc::Chunk<int, IDomainSp>>;

template <class ElementType>
using ViewSp = ddc::ChunkView<ElementType const, IDomainSp>;
using DViewSp = ViewSp<double>;

template <class ElementType>
using SpanSp = device_t<ddc::ChunkSpan<ElementType, IDomainSp>>;
using DSpanSp = SpanSp<double>;
6 changes: 0 additions & 6 deletions src/speciesinfo/species_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ void init_all_species(
int nb_kinspecies,
int nb_fluidspecies)
{
using IndexSp = ddc::DiscreteElement<IDimSp>;
using IDomainSp = ddc::DiscreteDomain<IDimSp>;
using IVectSp = ddc::DiscreteVector<IDimSp>;
using DFieldSp = device_t<ddc::Chunk<double, IDomainSp>>;
using IFieldSp = device_t<ddc::Chunk<int, IDomainSp>>;

// Define the domain for kinetic species
dom_kinsp = IDomainSp(IndexSp(0), IVectSp(nb_kinspecies));
host_t<IFieldSp> kinetic_charges(dom_kinsp);
Expand Down
11 changes: 0 additions & 11 deletions tests/species_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@

#include <species_info.hpp>

namespace {


using IVectSp = ddc::DiscreteVector<IDimSp>;
using IndexSp = ddc::DiscreteElement<IDimSp>;
using IDomainSp = ddc::DiscreteDomain<IDimSp>;
template <class ElementType>
using FieldSp = ddc::Chunk<ElementType, IDomainSp>;

} // namespace

TEST(SpeciesInfo, Ielec)
{
IVectSp const nb_kinspecies(2);
Expand Down

0 comments on commit c679ce0

Please sign in to comment.