Gyselalib++
 
Loading...
Searching...
No Matches
multipatch_math_tools.hpp
1// SPDX-License-Identifier: MIT
2#pragma once
3#include "l_norm_tools.hpp"
4#include "multipatch_field.hpp"
5
12template <class ExecSpace, template <typename P> typename T, class... Patches>
13double norm_inf(ExecSpace exec_space, MultipatchField<T, Patches...> multipatch_function)
14{
15 using FuncType = MultipatchField<T, Patches...>;
16 static_assert(
17 Kokkos::SpaceAccessibility<ExecSpace, typename FuncType::memory_space>::accessible);
18 using IdxRangeFunc = typename FuncType::discrete_domain_type;
19 constexpr std::size_t NPatches = multipatch_function.size();
20 IdxRangeFunc idx_range = get_idx_range(multipatch_function);
21 std::array<double, NPatches> norm_inf_on_patch(
22 {(norm_inf(exec_space, multipatch_function.template get<Patches>()))...});
23 double result(0.0);
24 for (std::size_t i(0); i < NPatches; ++i) {
25 result = std::max(result, norm_inf_on_patch[i]);
26 }
27 return result;
28}
29
37template <class ExecSpace, template <typename P> typename T, class... Patches>
38double error_norm_inf(
39 ExecSpace exec_space,
40 MultipatchField<T, Patches...> multipatch_function,
41 MultipatchField<T, Patches...> multipatch_exact_function)
42{
43 using FuncType = MultipatchField<T, Patches...>;
44 static_assert(
45 Kokkos::SpaceAccessibility<ExecSpace, typename FuncType::memory_space>::accessible);
46 using IdxRangeFunc = typename FuncType::discrete_domain_type;
47 constexpr std::size_t NPatches = multipatch_function.size();
48 IdxRangeFunc idx_range = get_idx_range(multipatch_function);
49 std::array<double, NPatches> norm_inf_on_patch({(error_norm_inf(
50 exec_space,
51 multipatch_function.template get<Patches>(),
52 multipatch_exact_function.template get<Patches>()))...});
53 double result(0.0);
54 for (std::size_t i(0); i < NPatches; ++i) {
55 result = std::max(result, norm_inf_on_patch[i]);
56 }
57 return result;
58}
A class to store field objects on patches.
Definition multipatch_field.hpp:30
static constexpr std::size_t size()
Get the number of objects stored inside the class.
Definition multipatch_type.hpp:131
File Describing useful mathematical functions to compute Lnorms.
KOKKOS_FUNCTION double norm_inf(ddc::Coordinate< Tags... > coord)
Compute the infinity norm.
Definition l_norm_tools.hpp:25
A class which describes the real space in the temporal direction.
Definition geometry.hpp:44