Gyselalib++
 
Loading...
Searching...
No Matches
constant_extrapolation_rules_onion.hpp
1// SPDX-License-Identifier: MIT
2
3#pragma once
4#include <ddc/ddc.hpp>
5#include <ddc/kernels/splines.hpp>
6
7#include "ddc_aliases.hpp"
8#include "multipatch_field.hpp"
9#include "multipatch_type.hpp"
10#include "onion_patch_locator.hpp"
11#include "utils_patch_locators.hpp"
12
13
19template <class PatchLocator>
21{
22private:
23 static_assert(
24 is_onion_patch_locator_v<PatchLocator>,
25 "Extrapolation rule only defined for OnionPatchLocator.");
26
27 using PatchOrdering = typename PatchLocator::PatchOrdering;
28
29 static constexpr std::size_t n_patches = ddc::type_seq_size_v<PatchOrdering>;
30
31 using MinRadiusPatch = ddc::type_seq_element_t<0, PatchOrdering>;
32 using MaxRadiusPatch = ddc::type_seq_element_t<n_patches - 1, PatchOrdering>;
33
34 using R_min = typename MinRadiusPatch::Dim1;
35 using Theta_min = typename MinRadiusPatch::Dim2;
36
37 using R_max = typename MaxRadiusPatch::Dim1;
38 using Theta_max = typename MaxRadiusPatch::Dim2;
39
40 ddc::ConstantExtrapolationRule<R_min, Theta_min> const bc_r_min;
41 ddc::ConstantExtrapolationRule<R_max, Theta_max> const bc_r_max;
42
43public:
52 explicit ConstantExtrapolationRuleOnion(Coord<R_min> const& r_min, Coord<R_max> const& r_max)
53 : bc_r_min(r_min)
54 , bc_r_max(r_max)
55 {
56 }
57
69 template <class... Dim, template <typename P> typename SplinesOnPatch, class... Patches>
70 KOKKOS_FUNCTION double operator()(
71 Coord<Dim...> const& coord_extrap,
73 int const out_of_bounds_idx) const
74 {
75 assert((out_of_bounds_idx == PatchLocator::outside_rmin_domain)
76 || (out_of_bounds_idx == PatchLocator::outside_rmax_domain));
77
78 if (out_of_bounds_idx == PatchLocator::outside_rmin_domain) {
79 SplinesOnPatch<MinRadiusPatch> const min_spline
80 = patches_splines.template get<MinRadiusPatch>();
81 return bc_r_min(coord_extrap, min_spline);
82 } else {
83 SplinesOnPatch<MaxRadiusPatch> const max_spline
84 = patches_splines.template get<MaxRadiusPatch>();
85 return bc_r_max(coord_extrap, max_spline);
86 }
87 }
88};
A class to store field objects on patches.
Definition multipatch_field.hpp:30
Define constant extrapolation rule for onion shape geometries.
Definition constant_extrapolation_rules_onion.hpp:21
KOKKOS_FUNCTION double operator()(Coord< Dim... > const &coord_extrap, MultipatchField< SplinesOnPatch, Patches... > const &patches_splines, int const out_of_bounds_idx) const
Evaluate at a given outside coordinate.
Definition constant_extrapolation_rules_onion.hpp:70
ConstantExtrapolationRuleOnion(Coord< R_min > const &r_min, Coord< R_max > const &r_max)
Instantiate a ConstantExtrapolationRuleOnion.
Definition constant_extrapolation_rules_onion.hpp:52