8#include <ArborX_LinearBVH.hpp>
9#include <Kokkos_Core.hpp>
10#include <Kokkos_Profiling_ScopedRegion.hpp>
18#include "common/transfer.hxx"
20#include "interpolator.hxx"
28template <KokkosViewRank<2> SourceType, KokkosViewRank<1> TargetType,
int_t Dim>
29static inline void FillTarget(
const SourceType &sourceView,
30 TargetType &targetView) {
31 assert(Dim == sourceView.extent_int(1));
32 using ExecSpace =
typename SourceType::execution_space;
33 const int K = sourceView.extent_int(0);
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) {
39 point[axis] = sourceView(k, axis);
41 targetView(k) = point;
59TEMPLATED_CLASSNAME::RbfPumInterpolator(Transfer<ExecSpace, Dim> &rTransfer,
60 int_t nodesPerCluster,
62 fp_t rbfSupportRadius)
63 : mNodesPerCluster(nodesPerCluster), mRelativeOverlap(relativeOverlap),
64 mSupportRadius(rbfSupportRadius) {
65 const std::string _region_name =
"RbfPumInterpolator::RbfPumInterpolator";
66 Kokkos::Profiling::ScopedRegion region(_region_name);
68 const ExecSpace execspace{};
70 this->mSource = rTransfer.sourcePoints;
71 this->mValues = rTransfer.sourceValues;
72 this->mTarget = VectorView<Point>(
73 Kokkos::view_alloc(execspace, Kokkos::WithoutInitializing,
75 rTransfer.targetPoints.extent(0));
76 FillTarget<
decltype(rTransfer.targetPoints),
decltype(this->mTarget), Dim>(
77 rTransfer.targetPoints, this->mTarget);
78 this->out = rTransfer.targetValues;
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{};
90 this->mRbfFunction.SetRadiusInv(
fp_consts::one() / this->mSupportRadius);
91 this->mWeightingFunction.SetRadiusInv(
fp_consts::one() / this->mRadius);
106std::string TEMPLATED_CLASSNAME::GetInterpolatorDetails(
void)
const {
107 std::ostringstream strs;
109 strs <<
"#Source points: " << this->mSource.extent(0) <<
"\n";
110 strs <<
"#Values: " << this->mValues.extent(0) <<
"\n";
111 strs <<
"#Target points: " << this->mTarget.extent(0) <<
"\n";
112 strs <<
"Source bounding box:\n";
113 strs <<
" Lower: " << this->mSourceBvh.bounds().minCorner() <<
"\n";
114 strs <<
" Upper: " << this->mSourceBvh.bounds().maxCorner() <<
"\n";
115 strs <<
"Interpolation params:\n";
116 strs <<
" #Points per cluster: " << this->mNodesPerCluster <<
"\n";
117 strs <<
" Relative overlap: " << this->mRelativeOverlap <<
"\n";
118 strs <<
" RBF Function: " <<
typeid(RbfFunctionBasisType).name() <<
"\n";
119 strs <<
" Execution space: " << ExecSpace{}.name() <<
"\n";
120 strs <<
"Found radius: " << this->mRadius <<
"\n";
121 strs <<
"Number of clusters: " << this->mClusters.extent(0);
A functor which computes a RBF function: WendlandC2 Each RBF function must have a host device method ...
static void FillTarget(const SourceType &sourceView, TargetType &targetView)
KOKKOS_INLINE_FUNCTION consteval fp_t zero(void)
KOKKOS_INLINE_FUNCTION consteval fp_t one(void)
void Interpolate(Transfer< ExecSpace, Dim > &transfer)
Generic C++ interface to PACMAN interpolation methods.