7#include <similie/exterior/continuous_hodge_star/continuous_hodge_star.hpp>
8#include <similie/exterior/operator_representation.hpp>
12template <
class Operator,
class Exec,
class Metric,
class Position>
13Operator make_composed_operator(Exec
const& exec, Metric
const& metric, Position
const& position)
15 if constexpr (std::is_constructible_v<Operator, Exec const&, Metric, Position>)
16 return Operator(exec, metric, position);
17 else if constexpr (std::is_constructible_v<Operator, Exec const&, Metric>)
18 return Operator(exec, metric);
19 else if constexpr (std::is_constructible_v<
23 typename Metric::non_indices_domain_t>)
24 return Operator(exec, position, metric.non_indices_domain());
43 template <
class,
class,
class, CellComplex>
class ReconstructionPolicy,
44 template <
class,
class,
class, CellComplex>
class ReductionPolicy,
45 template <
class,
class,
class,
class>
class HodgePolicy>
51 using ReconstructionOperator = ReconstructionPolicy<
56 using ReductionOperator = ReductionPolicy<Indices2, PositionType, BatchElem, Complex>;
57 using HodgeOperator = HodgePolicy<Indices1, Indices2, MetricType, BatchElem>;
58 ReconstructionOperator m_reconstruction;
59 ReductionOperator m_reduction;
67 typename MetricType::non_indices_domain_t,
68 typename MetricType::memory_space,
69 typename MetricType::memory_space::execution_space,
80 detail::make_composed_operator<ReconstructionOperator>(exec, metric, position))
81 , m_reduction(detail::make_composed_operator<ReductionOperator>(exec, metric, position))
82 , m_hodge(detail::make_composed_operator<HodgeOperator>(exec, metric, position))
86 template <CochainType Output, CochainType Input>
90 MetricType
const& metric,
91 PositionType
const& position,
92 BatchElem element)
const
94 auto reconstructed = detail::make_stencil<typename MetricType::memory_space, Source>(
95 ddc::DiscreteElement<>());
96 auto transformed = detail::make_stencil<typename MetricType::memory_space, Target>(
97 ddc::DiscreteElement<>());
103 [&](
auto const& form,
auto const& cochain) {
104 m_reconstruction(form, cochain, position, element);
106 [&](
auto const& cochain,
auto const& form) {
107 m_reduction(cochain, form, metric, position, element);
113 KOKKOS_FUNCTION detail::LocalOperatorStencil<Source, Target>
value(
114 MetricType
const& metric,
115 PositionType
const& position,
116 BatchElem element)
const
118 detail::LocalOperatorStencil<Source, Target> result;
119 auto unit = detail::make_stencil<typename MetricType::memory_space, Source>(
120 ddc::DiscreteElement<>());
121 auto output = detail::make_stencil<typename MetricType::memory_space, Target>(
122 ddc::DiscreteElement<>());
123 for (std::size_t source = 0; source < Source::mem_size(); ++source) {
124 unit.mem(ddc::DiscreteElement<Source>(source)) = 1.0;
131 for (std::size_t target = 0; target < Target::mem_size(); ++target)
132 result.weights[target * Source::mem_size() + source]
133 = output.mem(ddc::DiscreteElement<Target>(target));
134 unit.mem(ddc::DiscreteElement<Source>(source)) = 0.0;
139 template <
class NaturalElement>
141 MetricType
const& metric,
142 PositionType
const& position,
144 NaturalElement natural)
const
148 return detail::local_stencil_coefficient<Source, Target>(
149 value(metric, position, element),
150 ddc::detail::array(SourceElement(natural)),
151 ddc::detail::array(TargetElement(natural)));
155static_assert(DiscreteHodgeStarConcept<
158 ddc::TypeSeq<detail::DirectionConcept>,
160 detail::FieldConcept<detail::MetricIndexConcept>,
161 detail::FieldConcept<detail::PositionIndexConcept>,
162 ddc::DiscreteElement<detail::GridConcept>>,
163 detail::CochainFieldConcept<detail::ScalarConcept>,
164 detail::CochainFieldConcept<detail::DirectionConcept>,
165 detail::FieldConcept<detail::MetricIndexConcept>,
166 detail::FieldConcept<detail::PositionIndexConcept>,
167 ddc::DiscreteElement<detail::GridConcept>,
168 ddc::DiscreteElement<detail::DirectionConcept>>);
179struct FillDiscreteHodgeStarMem
181 HodgeStarType m_hodge_star;
183 PositionType m_position;
186 template <
class MemElem>
187 KOKKOS_FUNCTION
void operator()(MemElem mem_elem)
const
189 m_hodge_star.mem(
typename HodgeStarType::discrete_element_type(m_elem, mem_elem))
200 m_hodge_star.accessor().canonical_natural_element(mem_elem));
Cochain(Tensor const &) -> Cochain< Tensor >
typename detail::ReductionTargetIndex< Indices >::type reduction_index_t
Form(Coefficients const &) -> Form< Coefficients >
typename detail::ConvertTypeSeqTo< T, Seq >::type convert_type_seq_to_t
detail::Lower< T >::type lower_t
Compose reconstruction, continuous Hodge star and reduction policies.
KOKKOS_FUNCTION void operator()(Output const &output, Input const &input, MetricType const &metric, PositionType const &position, BatchElem element) const
DiscreteHodgeStar()=default
KOKKOS_FUNCTION detail::LocalOperatorStencil< Source, Target > value(MetricType const &metric, PositionType const &position, BatchElem element) const
KOKKOS_FUNCTION double value(MetricType const &metric, PositionType const &position, BatchElem element, NaturalElement natural) const
detail::LinearLocalOperatorStorage< DiscreteHodgeStar, tensor::lower_t< reduction_index_t< Indices1 > >, reduction_index_t< Indices2 >, typename MetricType::non_indices_domain_t, typename MetricType::memory_space, typename MetricType::memory_space::execution_space, tensor::TensorFullIndex, misc::convert_type_seq_to_t< ddc::DiscreteElement, Indices1 >, misc::convert_type_seq_to_t< ddc::DiscreteElement, Indices2 > > staged_storage_type
DiscreteHodgeStar(Exec const &exec, MetricType const &metric, PositionType const &position)