8#define PACMAN_FE_ETI_COMPILATION
12#include <Kokkos_Core.hpp>
13#include <Kokkos_Profiling_ScopedRegion.hpp>
16#include <unordered_map>
19#include "common/transfer.hxx"
28template <
typename ExecSpace, PACMAN::
int_t Dim>
38 PACMAN::Transfer<ExecSpace, Dim> transfer(method);
39 PACMAN::SetupTransferClass(transfer, nSourcePoints, connValSize, connOffSize,
40 nTargetPoints, nComponents, pSourcePoints,
42 pConnVal, pConnOff, pCellTypes, pTargetPoints, fortranIndexing);
45 auto unmanaged_host_ts = Kokkos::View<
47 Kokkos::MemoryTraits<Kokkos::Unmanaged>>(
50 PACMAN::CopyToRowMajorHost(transfer.targetValues, pTargetValues);
51 Kokkos::deep_copy(unmanaged_host_ts, transfer.targetStatus);
54template <PACMAN::
int_t Dim>
65 [&](
auto execSpaceObj) {
66 RunInterpolate<decltype(execSpaceObj), Dim>(
67 method, pSourcePoints, nSourcePoints, pSourceValues, pConnVal,
68 connValSize, pConnOff, connOffSize, pCellTypes, pTargetPoints,
69 nTargetPoints, fortranIndexing, nComponents, pTargetValues,
89 fp_t *targetValues,
int_t *targetStatus,
bool fortranIndexing,
91 const std::string _region_name =
"PACMAN::fe_interpolate";
92 const Kokkos::Profiling::ScopedRegion region(_region_name);
95 if (sourcePoints ==
nullptr && nSourcePoints > 0)
96 throw std::invalid_argument(
"sourcePoints is null but nSourcePoints > 0");
97 if (targetPoints ==
nullptr && nTargetPoints > 0)
98 throw std::invalid_argument(
"targetPoints is null but nTargetPoints > 0");
99 if (sourceValues ==
nullptr && nSourcePoints > 0)
100 throw std::invalid_argument(
"sourceValues is null but nSourcePoints > 0");
101 if (targetValues ==
nullptr && nTargetPoints > 0)
102 throw std::invalid_argument(
"targetValues is null but nTargetPoints > 0");
103 if (targetStatus ==
nullptr && nTargetPoints > 0)
104 throw std::invalid_argument(
"targetStatus is null but nTargetPoints > 0");
106 throw std::invalid_argument(
"nComponents must be greater than zero");
109 switch (spaceDimension) {
111 return Dispatch<1>(execSpace, method, sourcePoints, nSourcePoints,
112 sourceValues, connVal, connValSize, connOff, connOffSize,
113 cellTypes, targetPoints, nTargetPoints, fortranIndexing,
114 nComponents, targetValues, targetStatus);
116 return Dispatch<2>(execSpace, method, sourcePoints, nSourcePoints,
117 sourceValues, connVal, connValSize, connOff, connOffSize,
118 cellTypes, targetPoints, nTargetPoints, fortranIndexing,
119 nComponents, targetValues, targetStatus);
121 return Dispatch<3>(execSpace, method, sourcePoints, nSourcePoints,
122 sourceValues, connVal, connValSize, connOff, connOffSize,
123 cellTypes, targetPoints, nTargetPoints, fortranIndexing,
124 nComponents, targetValues, targetStatus);
127 throw std::runtime_error(
128 "The dimension of the points can only be: 1, 2 or 3.\n");
135 static const std::unordered_map<int_t, CellType> vtk_to_pacman = {
156 for (
int_t i = 0; i < n; ++i) {
157 auto it = vtk_to_pacman.find(vtkTypes[i]);
159 if (it == vtk_to_pacman.end()) {
160 throw std::runtime_error(
"Unsupported VTK cell type: " +
161 std::to_string(vtkTypes[i]));
164 pacmanTypes[i] =
static_cast<cell_t>(it->second);
Generic C++ entry point for PACMAN interpolation methods.
void vtk_to_pacman_cell_type(const int_t *vtkTypes, cell_t *pacmanTypes, int_t n)
Convert an array of VTK cell type IDs to PACMAN CellType enum values.
static AvailableExecSpaces MakeExecSpace(const unsigned char s)
Converts an execution-space selector byte to a variant type.
void Interpolate(Transfer< ExecSpace, Dim > &transfer)
Generic C++ interface to PACMAN interpolation methods.
void fe_interpolate(int_t spaceDimension, unsigned char execSpace, method_t method, coordinates_t *sourcePoints, int_t nSourcePoints, fp_t *sourceValues, int_t *connVal, int_t connValSize, offset_t *connOff, int_t connOffSize, cell_t *cellTypes, coordinates_t *targetPoints, int_t nTargetPoints, fp_t *targetValues, int_t *targetStatus, bool fortranIndexing, int_t nComponents)
C++ interface for finite-elements interpolation.
@ VTK_QUADRATIC_HEXAHEDRON