PACMAN 0.1.0
Portable Algorithms for Coupling, Mapping, and Adaptive iNterpolation
Loading...
Searching...
No Matches
rbf_pum/interpolator.hpp
Go to the documentation of this file.
1//
2// This file is subject to the terms and conditions defined in
3// file 'LICENSE', which is part of this source code package.
4//
5
6#pragma once
7
8#include <ArborX_LinearBVH.hpp>
9#include <Kokkos_Core.hpp>
10#include <Kokkos_Profiling_ScopedRegion.hpp>
11#include <iomanip>
12#include <iostream>
13#include <sstream>
14
15#include "callbacks.hpp"
18#include "common/transfer.hxx"
19#include "common/types.hpp"
20#include "interpolator.hxx"
22#include "solver/solver.hpp"
23#include "utils/operators.hpp"
24#include "utils/utils.hpp"
25
26namespace PACMAN {
27namespace RbfPum {
28template <KokkosViewRank<2> SourceType, KokkosViewRank<1> TargetType, int_t Dim>
29static inline void FillTarget(const SourceType &sourceView,
31 assert(Dim == sourceView.extent_int(1));
32 using ExecSpace = typename SourceType::execution_space;
33 const int K = sourceView.extent_int(0);
34 Kokkos::parallel_for(
35 "FillTarget", Kokkos::RangePolicy(ExecSpace{}, 0, K),
36 KOKKOS_LAMBDA(const int &k) {
37 ::ArborX::Point<Dim, coordinates_t> point{};
38 for (int_t axis = 0; axis < Dim; ++axis) {
40 }
41 targetView(k) = point;
42 });
43}
44
59TEMPLATED_CLASSNAME::RbfPumInterpolator(Transfer<ExecSpace, Dim> &rTransfer,
65 const std::string _region_name = "RbfPumInterpolator::RbfPumInterpolator";
66 Kokkos::Profiling::ScopedRegion region(_region_name);
67
68 const ExecSpace execspace{};
69
70 this->mSource = rTransfer.sourcePoints;
71 this->mValues = rTransfer.sourceValues;
72 this->mTarget = VectorView<Point>(
73 Kokkos::view_alloc(execspace, Kokkos::WithoutInitializing,
74 "this->mTarget"),
75 rTransfer.targetPoints.extent(0));
76 FillTarget<decltype(rTransfer.targetPoints), decltype(this->mTarget), Dim>(
77 rTransfer.targetPoints, this->mTarget);
78 this->out = rTransfer.targetValues;
79
80 this->mRadius = fp_consts::zero();
81 this->mSourceBvh = ::ArborX::BoundingVolumeHierarchy{
82 execspace, ::ArborX::Experimental::attach_indices(this->mSource)};
83 this->mTargetBvh = ::ArborX::BoundingVolumeHierarchy{
84 execspace, ::ArborX::Experimental::attach_indices(this->mTarget)};
85 this->mRbfFunction = RbfFunctionBasisType{};
86 this->mWeightingFunction = WendlandC2{};
87 Kokkos::fence();
88
89 FindRadius();
90 this->mRbfFunction.SetRadiusInv(fp_consts::one() / this->mSupportRadius);
91 this->mWeightingFunction.SetRadiusInv(fp_consts::one() / this->mRadius);
92 CreateClusters();
94}
95
104FULL_TEMPLATE
105std::string TEMPLATED_CLASSNAME::GetInterpolatorDetails(void) const {
106 std::ostringstream strs;
107 strs << fp_consts::set_precision();
108 strs << "#Source points: " << this->mSource.extent(0) << "\n";
109 strs << "#Values: " << this->mValues.extent(0) << "\n";
110 strs << "#Target points: " << this->mTarget.extent(0) << "\n";
111 strs << "Source bounding box:\n";
112 strs << " Lower: " << this->mSourceBvh.bounds().minCorner() << "\n";
113 strs << " Upper: " << this->mSourceBvh.bounds().maxCorner() << "\n";
114 strs << "Interpolation params:\n";
115 strs << " #Points per cluster: " << this->mNodesPerCluster << "\n";
116 strs << " Relative overlap: " << this->mRelativeOverlap << "\n";
117 strs << " RBF Function: " << typeid(RbfFunctionBasisType).name() << "\n";
118 strs << " Execution space: " << ExecSpace{}.name() << "\n";
119 strs << "Found radius: " << this->mRadius << "\n";
120 strs << "Number of clusters: " << this->mClusters.extent(0);
121
122 return strs.str();
123}
124
125} // namespace RbfPum
126} // namespace PACMAN
static void FillTarget(const SourceType &sourceView, TargetType &targetView)
KOKKOS_INLINE_FUNCTION consteval fp_t zero(void)
Definition types.hpp:92
auto set_precision(void)
Definition types.hpp:101
KOKKOS_INLINE_FUNCTION consteval fp_t one(void)
Definition types.hpp:95
double fp_t
Definition types.hpp:15
void Interpolate(Transfer< ExecSpace, Dim > &transfer)
Generic C++ interface to PACMAN interpolation methods.
int32_t int_t
Definition types.hpp:18