11#include "quadrature.hpp"
24template <
class... Tags>
25KOKKOS_FUNCTION
double norm_inf(ddc::Coordinate<Tags...> coord)
28 ((result = Kokkos::max(result, Kokkos::fabs(coord.template get<Tags>()))), ...);
44KOKKOS_INLINE_FUNCTION
double norm_inf(
double const coord)
53template <
class ExecSpace,
class FuncType>
54double norm_inf(ExecSpace exec_space, FuncType function)
57 Kokkos::SpaceAccessibility<ExecSpace, typename FuncType::memory_space>::accessible);
58 using IdxRangeFunc =
typename FuncType::discrete_domain_type;
59 using IdxFunc =
typename IdxRangeFunc::discrete_element_type;
60 IdxRangeFunc idx_range = get_idx_range(function);
61 return ddc::parallel_transform_reduce(
65 ddc::reducer::max<double>(),
66 KOKKOS_LAMBDA(IdxFunc
const idx) { return ::norm_inf(function(idx)); });
71template <
class ExecSpace,
class FuncType>
72double error_norm_inf(ExecSpace exec_space, FuncType function, FuncType exact_function)
75 Kokkos::SpaceAccessibility<ExecSpace, typename FuncType::memory_space>::accessible);
76 using IdxRangeFunc =
typename FuncType::discrete_domain_type;
77 using IdxFunc =
typename IdxRangeFunc::discrete_element_type;
78 IdxRangeFunc idx_range = get_idx_range(function);
79 return ddc::parallel_transform_reduce(
83 ddc::reducer::max<double>(),
84 KOKKOS_LAMBDA(IdxFunc
const idx) {
85 return ::norm_inf(function(idx) - exact_function(idx));
97template <
class ExecSpace,
class ElementType,
class IdxRange>
100 ConstField<ElementType, IdxRange, typename ExecSpace::memory_space> function)
102 return detail::norm_inf(exec_space, function);
111template <
class ExecSpace,
class ElementType,
class IdxRange,
class NDTag>
113 ExecSpace exec_space,
116 return detail::norm_inf(exec_space, function);
126template <
class ExecSpace,
class ElementType,
class IdxRange>
128 ExecSpace exec_space,
129 ConstField<ElementType, IdxRange, typename ExecSpace::memory_space> function,
130 ConstField<ElementType, IdxRange, typename ExecSpace::memory_space> exact_function)
132 return detail::error_norm_inf(exec_space, function, exact_function);
142template <
class ExecSpace,
class ElementType,
class IdxRange,
class NDTag>
144 ExecSpace exec_space,
149 return detail::error_norm_inf(exec_space, function, exact_function);
166template <
class IdxRangeQuad,
class ExecSpace>
168 ExecSpace exec_space,
170 DField<IdxRangeQuad, typename ExecSpace::memory_space> function)
172 using IdxQuad =
typename IdxRangeQuad::discrete_element_type;
175 KOKKOS_LAMBDA(IdxQuad
const idx) {
return Kokkos::fabs(function(idx)); });
186template <
class IdxRangeQuad,
class ExecSpace>
188 ExecSpace exec_space,
190 DField<IdxRangeQuad, typename ExecSpace::memory_space> function,
191 DField<IdxRangeQuad, typename ExecSpace::memory_space> exact_function)
193 using IdxQuad =
typename IdxRangeQuad::discrete_element_type;
196 KOKKOS_LAMBDA(IdxQuad
const idx) {
197 return Kokkos::fabs(function(idx) - exact_function(idx));
216template <
class IdxRangeQuad,
class ExecSpace>
218 ExecSpace exec_space,
220 DField<IdxRangeQuad, typename ExecSpace::memory_space> function)
222 using IdxQuad =
typename IdxRangeQuad::discrete_element_type;
223 return std::sqrt(quadrature(
225 KOKKOS_LAMBDA(IdxQuad
const idx) {
return function(idx) * function(idx); }));
236template <
class IdxRangeQuad,
class ExecSpace>
238 ExecSpace exec_space,
240 DField<IdxRangeQuad, typename ExecSpace::memory_space> function,
241 DField<IdxRangeQuad, typename ExecSpace::memory_space> exact_function)
243 using IdxQuad =
typename IdxRangeQuad::discrete_element_type;
244 return std::sqrt(quadrature(
246 KOKKOS_LAMBDA(IdxQuad
const idx) {
247 double err = function(idx) - exact_function(idx);
A class providing an operator for integrating functions defined on a discrete index range.
Definition quadrature.hpp:29
A class which holds multiple (scalar) fields in order to represent a vector field.
Definition vector_field.hpp:64