9#include <initializer_list>
12#include <similie/tensor/owning_tensor.hpp>
18struct FormArrayStorage : std::false_type
21template <
class T, std::
size_t N>
22struct FormArrayStorage<std::array<T, N>> : std::true_type
30template <
class Coefficients>
31class Form :
public Coefficients
36 || detail::FormArrayStorage<Coefficients>::value);
41 KOKKOS_DEFAULTED_FUNCTION
constexpr Form() =
default;
42 KOKKOS_DEFAULTED_FUNCTION
constexpr Form(
Form const&) =
default;
43 KOKKOS_DEFAULTED_FUNCTION
constexpr Form(
Form&&) =
default;
52 KOKKOS_FUNCTION
constexpr Form(std::initializer_list<typename Coefficients::value_type> values)
53 requires(detail::FormArrayStorage<Coefficients>::value)
56 if (values.size() > this->size())
57 Kokkos::abort(
"Too many differential-form coefficients");
59 for (
typename Coefficients::value_type
const& value : values)
60 Coefficients::operator[](i++) = value;
66 return static_cast<typename Coefficients::tensor_type const&
>(*
this);
68 return static_cast<Coefficients const&
>(*this);
73 return static_cast<typename Coefficients::tensor_type&
>(*
this);
75 return static_cast<Coefficients&
>(*this);
79 requires requires(Coefficients& left, Coefficients
const& right) { left += right; }
85 template <
class Scalar>
93 template <
class Element>
94 KOKKOS_FUNCTION
constexpr decltype(
auto)
operator[](Element element)
const
96 if constexpr (!detail::FormArrayStorage<Coefficients>::value)
97 return ::sil::exterior::Form(Coefficients::operator[](element));
99 return Coefficients::operator[](element);
102 template <
class Element>
103 KOKKOS_FUNCTION
constexpr decltype(
auto)
operator[](Element element)
105 if constexpr (!detail::FormArrayStorage<Coefficients>::value)
106 return ::sil::exterior::Form(Coefficients::operator[](element));
108 return Coefficients::operator[](element);
117 double m_value = 0.0;
121 KOKKOS_DEFAULTED_FUNCTION
constexpr Form() =
default;
122 KOKKOS_FUNCTION
constexpr explicit Form(
double value) : m_value(value) {}
123 KOKKOS_FUNCTION
constexpr operator double()
const
127 KOKKOS_FUNCTION
constexpr double value()
const
166template <
class Coefficients>
176template <
class Domain>
178template <
class... Index>
179struct FormDegree<
ddc::DiscreteDomain<Index...>>
180 : std::integral_constant<std::size_t, (Index::rank() + ... + 0)>
185template <TensorFormType T>
187 = detail::FormDegree<typename T::indices_domain_t>::value;
Form(Coefficients const &) -> Form< Coefficients >
constexpr std::size_t form_degree_v