Gyselalib++
 
Loading...
Searching...
No Matches
connectivity.hpp
1// SPDX-License-Identifier: MIT
2#pragma once
3
4#include "ddc/ddc.hpp"
5
6#include "connectivity_details.hpp"
7#include "ddc_aliases.hpp"
8#include "multipatch_type.hpp"
9
16template <class... Interfaces>
18{
19public:
21 using interface_collection = ddc::detail::TypeSeq<Interfaces...>;
22
25 = strip_outside_edges_t<typename Interfaces::Edge1..., typename Interfaces::Edge2...>;
26
28 using all_patches = extract_patches_t<inner_edges>;
29
30 static_assert(
31 ddc::type_seq_size_v<inner_edges> == 4 * ddc::type_seq_size_v<all_patches>,
32 "Missing edges. There should be 4 edges for each patch.");
33
39 template <class QueryPatch>
40 using get_type_seq_connections_t = interfaces_of_patch_t<QueryPatch, interface_collection>;
41
47 template <class QueryPatch>
48 using get_connections_t = to_tuple_t<get_type_seq_connections_t<QueryPatch>>;
49
56 template <class QueryPatch1, class QueryPatch2>
57 using find_connections_t = ddcHelper::type_seq_intersection_t<
60
66 template <class Grid1D>
67 using get_all_interfaces_along_direction_t = collect_interfaces_on_dim_t<
68 find_patch_t<Grid1D, all_patches>,
69 Grid1D,
71
81 template <class Grid1D, class... IdxRanges>
82 static auto get_all_idx_ranges_along_direction(std::tuple<IdxRanges...> all_idx_ranges)
83 {
84 using StartPatch = find_patch_t<Grid1D, all_patches>;
85 using RelevantGrids = collect_grids_on_dim_t<StartPatch, Grid1D, interface_collection>;
86 static_assert(ddc::type_seq_size_v<RelevantGrids> > 0);
87 return get_idx_range<RelevantGrids>(
88 all_idx_ranges,
89 std::make_index_sequence<ddc::type_seq_size_v<RelevantGrids>> {});
90 }
91
101 template <class Grid1D, template <typename P> typename T, class... Patches>
103 {
104 static_assert(ddc::type_seq_same_v<all_patches, ddc::detail::TypeSeq<Patches...>>);
105 return get_all_idx_ranges_along_direction<Grid1D>(all_idx_ranges.get_tuple());
106 }
107
108private:
110 template <class RelevantGrids, class IdxRangeTuple, std::size_t... PatchIndex>
111 static auto get_idx_range(IdxRangeTuple all_idx_ranges, std::index_sequence<PatchIndex...>)
112 {
113 return std::make_tuple(
114 get_idx_range<PatchIndex, RelevantGrids, IdxRangeTuple>(all_idx_ranges)...);
115 }
116
118 template <std::size_t PatchIndex, class RelevantGrids, class IdxRangeTuple>
119 static auto get_idx_range(IdxRangeTuple all_idx_ranges)
120 {
121 using GridToLocate = ddc::type_seq_element_t<PatchIndex, RelevantGrids>;
122 using GridLocation = find_relevant_idx_range_t<GridToLocate, IdxRangeTuple>;
123 return ddc::select<GridToLocate>(std::get<GridLocation>(all_idx_ranges));
124 }
125};
A helper class which provides functionalities to recognise how different patches are connected.
Definition connectivity.hpp:18
to_tuple_t< get_type_seq_connections_t< QueryPatch > > get_connections_t
A tool to find a tuple of all interfaces of a patch.
Definition connectivity.hpp:48
extract_patches_t< inner_edges > all_patches
A type sequence of all the patches handled by this class.
Definition connectivity.hpp:28
ddcHelper::type_seq_intersection_t< get_type_seq_connections_t< QueryPatch1 >, get_type_seq_connections_t< QueryPatch2 > > find_connections_t
A tool to find all interfaces linking 2 patches.
Definition connectivity.hpp:59
interfaces_of_patch_t< QueryPatch, interface_collection > get_type_seq_connections_t
A tool to find a type sequence of all interfaces of a patch.
Definition connectivity.hpp:40
strip_outside_edges_t< typename Interfaces::Edge1..., typename Interfaces::Edge2... > inner_edges
A type sequence of all the edges handled by this class except the OuterEdge types.
Definition connectivity.hpp:25
collect_interfaces_on_dim_t< find_patch_t< Grid1D, all_patches >, Grid1D, interface_collection > get_all_interfaces_along_direction_t
A tool to find all interfaces along a line which passes through the requested grid.
Definition connectivity.hpp:70
static auto get_all_idx_ranges_along_direction(MultipatchType< T, Patches... > all_idx_ranges)
A function to return all index ranges which can be used to obtain coordinates along a line which pass...
Definition connectivity.hpp:102
ddc::detail::TypeSeq< Interfaces... > interface_collection
A type sequence of all the interfaces handled by this class.
Definition connectivity.hpp:21
static auto get_all_idx_ranges_along_direction(std::tuple< IdxRanges... > all_idx_ranges)
A function to return all index ranges which can be used to obtain coordinates along a line which pass...
Definition connectivity.hpp:82
A class to store several objects that are of a type which is templated by the patch.
Definition multipatch_type.hpp:32
KOKKOS_FUNCTION std::tuple< T< Patches >... > const & get_tuple() const
Get a constant reference to the tuple of objects stored inside this MultipatchType.
Definition multipatch_type.hpp:141
A class which describes the real space in the temporal direction.
Definition geometry.hpp:44