20template <
class... SpatialIndex>
23template <
class... SpatialIndex>
26template <
class... SpatialIndex>
31template <
class... SpatialIndex>
36template <
class... SpatialIndex>
42struct ElementSpatialDomain;
44template <
class... Tags>
45struct ElementSpatialDomain<ddc::DiscreteElement<Tags...>>
47 using type = ddc::DiscreteDomain<Tags...>;
50template <
class CochainIndex,
class VectorStencil,
class Elem>
51[[nodiscard]] KOKKOS_FUNCTION
auto project_to_scalar_potential_stencil(
52 VectorStencil vector_stencil,
54 ddc::DiscreteElement<CochainIndex> selected_potential_component)
56 using spatial_domain_type =
typename ElementSpatialDomain<Elem>::type;
59 auto projected = sil::exterior::detail::make_stencil<Kokkos::HostSpace, ScalarPotentialIndex>(
60 vector_stencil.non_indices_domain().front());
61 ddc::device_for_each(projected.domain(), [&](
auto projected_elem) {
62 auto const spatial_elem =
63 typename spatial_domain_type::discrete_element_type(projected_elem);
64 projected.mem(projected_elem)
65 = vector_stencil.get(spatial_elem, selected_potential_component);
67 static_cast<void>(elem);
73template <
class... SpatialIndex>
76template <
class... SpatialIndex>
80 using SpatialIndexSeq = ddc::detail::TypeSeq<SpatialIndex...>;
84 PotentialScalarIndex>;
87 template <
class Index>
88 [[nodiscard]] KOKKOS_FUNCTION
static constexpr auto magnetic_induction_component()
91 static_cast<void>(
sizeof(OrthogonalPotentialComponent));
92 if constexpr (std::is_same_v<Index, ddc::type_seq_element_t<0, SpatialIndexSeq>>) {
93 return accessor.template access_element<ddc::type_seq_element_t<1, SpatialIndexSeq>>();
95 return accessor.template access_element<ddc::type_seq_element_t<0, SpatialIndexSeq>>();
100 template <
class Index,
class Elem>
104 std::is_same_v<Index, ddc::type_seq_element_t<0, SpatialIndexSeq>>
105 || std::is_same_v<Index, ddc::type_seq_element_t<1, SpatialIndexSeq>>,
106 "2D magnetic induction component tag must be one of the spatial tags");
107 using spatial_domain_type =
typename detail::ElementSpatialDomain<Elem>::type;
114 value(sil::exterior::detail::IdentityStencilEvaluator {},
118 magnetic_induction_component<Index>());
119 if constexpr (std::is_same_v<Index, ddc::type_seq_element_t<1, SpatialIndexSeq>>) {
125 template <
class TensorType,
class Evaluator,
class ChainType,
class LowerChainType,
class Elem>
127 TensorType magnetic_induction,
130 LowerChainType lower_chain,
139template <
class... SpatialIndex>
140 requires ThreeDimensional<SpatialIndex...>
143 using SpatialIndexSeq = ddc::detail::TypeSeq<SpatialIndex...>;
147 using MagneticInductionIndex
150 template <
class Index>
151 [[nodiscard]] KOKKOS_FUNCTION
static constexpr auto magnetic_induction_component()
154 if constexpr (std::is_same_v<Index, ddc::type_seq_element_t<0, SpatialIndexSeq>>) {
155 return accessor.template access_element<
156 ddc::type_seq_element_t<1, SpatialIndexSeq>,
157 ddc::type_seq_element_t<2, SpatialIndexSeq>>();
158 }
else if constexpr (std::is_same_v<Index, ddc::type_seq_element_t<1, SpatialIndexSeq>>) {
159 return accessor.template access_element<
160 ddc::type_seq_element_t<0, SpatialIndexSeq>,
161 ddc::type_seq_element_t<2, SpatialIndexSeq>>();
163 return accessor.template access_element<
164 ddc::type_seq_element_t<0, SpatialIndexSeq>,
165 ddc::type_seq_element_t<1, SpatialIndexSeq>>();
173 template <
class Index,
class Elem>
174 [[nodiscard]] KOKKOS_FUNCTION
static auto forward_value(Elem elem)
177 std::is_same_v<Index, ddc::type_seq_element_t<0, SpatialIndexSeq>>
178 || std::is_same_v<Index, ddc::type_seq_element_t<1, SpatialIndexSeq>>
179 || std::is_same_v<Index, ddc::type_seq_element_t<2, SpatialIndexSeq>>,
180 "3D magnetic induction component tag must be one of the spatial tags");
181 using spatial_domain_type =
typename detail::ElementSpatialDomain<Elem>::type;
185 auto const output_component = magnetic_induction_component<Index>();
187 value(sil::exterior::detail::IdentityStencilEvaluator {},
192 if constexpr (std::is_same_v<Index, ddc::type_seq_element_t<1, SpatialIndexSeq>>) {
198 template <
class TensorType,
class Evaluator,
class ChainType,
class LowerChainType,
class Elem>
199 KOKKOS_FUNCTION
static void forward(
200 TensorType magnetic_induction,
203 LowerChainType lower_chain,
207 run(magnetic_induction, evaluator, chain, lower_chain, elem);
210 template <
class Index,
class Elem>
211 [[nodiscard]] KOKKOS_FUNCTION
static auto scalar_forward_value(Elem elem)
213 auto stencil = forward_value<Index>(elem);
215 auto projected = detail::project_to_scalar_potential_stencil(
219 .
template access_element<ddc::type_seq_element_t<2, SpatialIndexSeq>>());
220 if constexpr (std::is_same_v<Index, ddc::type_seq_element_t<2, SpatialIndexSeq>>) {