9#include <algorithms/ArborX_ClosestPoint.hpp>
12#include "common/transfer.hxx"
31template <
typename ExecSpace,
int_t Dim>
39 template <
typename Predicate,
typename Value>
40 KOKKOS_FUNCTION
auto operator()(
const Predicate &predicate,
41 const Value &value)
const {
43 const int predicate_index = ArborX::getData(predicate);
45 const auto cellType =
transfer.cellTypes(curElem);
47 Kokkos::Array<fp_t, MaxNodesPerElt> warr;
48 Kokkos::Array<coordinates_t, MaxNodesPerElt * Dim> Xarr;
49 Kokkos::Array<coordinates_t, Dim> tpa;
50 Kokkos::View<coordinates_t *, ExecSpace> tp(tpa.data(), Dim);
52 for (
int_t j = 0; j < Dim; j++) {
53 tp(j) =
transfer.targetPoints(predicate_index, j);
55 const auto localConn =
57 Kokkos::make_pair(
transfer.connOffsets(curElem),
61 Kokkos::View<fp_t *, ExecSpace> weights(warr.data(), nbConnNodes);
62 Kokkos::View<coordinates_t **, ExecSpace> Xcoor(Xarr.data(), nbConnNodes,
64 for (
int_t j = 0; j < nbConnNodes; ++j) {
65 const auto nodeId = localConn(j);
66 for (
int_t k = 0; k < Dim; ++k) {
67 Xcoor(j, k) =
transfer.sourcePoints(nodeId)[k];
72 for (
int_t j = 0; j < nbConnNodes; ++j) {
73 const auto nodeId = localConn(j);
75 component <
transfer.sourceValues.extent(1); ++component) {
76 transfer.targetValues(predicate_index, component) +=
77 weights[j] *
transfer.sourceValues(nodeId, component);
81 return ArborX::CallbackTreeTraversalControl::early_exit;
83 return ArborX::CallbackTreeTraversalControl::normal_continuation;
96 Kokkos::View<TransferStatus *, MemorySpace>
status;
100 template <
typename Predicate,
typename Value,
typename OutputFunctor>
103 const OutputFunctor &out)
const {
104 const int predicate_index = ArborX::getData(predicate);
107 ArborX::Point<Dim, coordinates_t> targetPoint;
108 for (
int_t k = 0; k < Dim; k++) {
112 auto triangle = value.value;
114 using PointTag = ArborX::GeometryTraits::PointTag;
115 using TriangleTag = ArborX::GeometryTraits::TriangleTag;
116 using Point =
decltype(targetPoint);
117 using Triangle =
decltype(triangle);
119 ArborX::Details::Dispatch::distance<PointTag, TriangleTag, Point,
122 targetPoint = ArborX::Experimental::closestPoint(targetPoint, triangle);
123 for (
int_t k = 0; k < Dim; k++) {
127 out(predicate_index);
140 Kokkos::View<TransferStatus *, MemorySpace>
status;
144 template <
typename Predicate,
typename Value,
typename OutputFunctor>
147 const OutputFunctor &out)
const {
148 const int predicate_index = ArborX::getData(predicate);
152 out(predicate_index);
159 template <
typename Predicate,
typename Value,
typename OutputFunctor>
160 KOKKOS_FUNCTION
void operator()(Predicate,
const Value &value,
161 const OutputFunctor &out)
const {
170 Kokkos::View<coordinates_t **, MemorySpace>
points;
180 template <
typename Predicate,
typename Value>
182 const Value &value)
const {
183 const int predicate_index = ArborX::getData(predicate);
197 Kokkos::View<coordinates_t **, MemorySpace>
points;
206template <PACMAN::KokkosViewRank<1> ViewType>
207struct AccessTraits<
PACMAN::FiniteElements::PointNearest<ViewType>> {
214 return attach(nearest(self.
points(i), 1), (
int)i);
219template <
typename MemorySpace,
int Dim>
221 PACMAN::FiniteElements::PointCloudNearest<MemorySpace, Dim>> {
229 Point<Dim, PACMAN::coordinates_t> point;
230 for (
int k = 0; k < Dim; k++) {
231 point[k] = self.
points(i, k);
233 return attach(nearest(point, 1), (
int)i);
238template <
typename MemorySpace,
int Dim>
239struct AccessTraits<
PACMAN::FiniteElements::PointIntersect<MemorySpace, Dim>> {
247 Point<Dim, PACMAN::coordinates_t> point;
248 for (
int k = 0; k < Dim; k++) {
249 point[k] = self.
points(i, k);
251 return attach(intersects(point), (
int)i);
KOKKOS_FUNCTION bool ApplyNewtonOnElement(const cell_t type, const Kokkos::View< coordinates_t **, ExecSpace > Xcoor, const Kokkos::View< coordinates_t[Dim], ExecSpace > targetPoint, Kokkos::View< fp_t *, ExecSpace > weights, const bool forceEvaluation=false)
Dispatch Newton-based FE inversion to the correct element type.
static KOKKOS_FUNCTION size_t size(const Self &self)
PACMAN::FiniteElements::PointCloudNearest< MemorySpace, Dim > Self
static KOKKOS_FUNCTION auto get(const Self &self, size_t i)
static KOKKOS_FUNCTION auto get(const Self &self, size_t i)
PACMAN::FiniteElements::PointIntersect< MemorySpace, Dim > Self
static KOKKOS_FUNCTION size_t size(const Self &self)
static KOKKOS_FUNCTION auto get(const Self &self, size_t i)
typename ViewType::memory_space memory_space
static KOKKOS_FUNCTION size_t size(const Self &self)
PACMAN::FiniteElements::PointNearest< ViewType > Self
Callback assigning source value at nearest-neighbor index.
Kokkos::View< fp_t **, MemorySpace > sourceValues
Kokkos::View< fp_t **, MemorySpace > targetValues
Kokkos::View< TransferStatus *, MemorySpace > targetStatus
KOKKOS_FUNCTION void operator()(const Predicate &predicate, const Value &value) const
Predicate wrapper for nearest-neighbor queries over point clouds.
Kokkos::View< coordinates_t **, MemorySpace > points
Point-finite element intersection and interplolation callback.
Kokkos::View< int *, MemorySpace > parents
typename ExecSpace::memory_space MemorySpace
Transfer< ExecSpace, Dim > transfer
KOKKOS_FUNCTION auto operator()(const Predicate &predicate, const Value &value) const
ArborX callback: project one outside target point and emit output.
Predicate wrapper for point/box intersection queries.
Kokkos::View< coordinates_t **, MemorySpace > points
Wrapper for nearest-neighbor predicates built from 1D point views.
Project outside target points onto nearest 3D skin triangle.
Kokkos::View< int_t *, MemorySpace > skinParents
KOKKOS_FUNCTION void operator()(const Predicate &predicate, const Value &value, const OutputFunctor &out) const
ArborX callback: project one outside target point and emit output.
Kokkos::View< coordinates_t **, MemorySpace > targetPointsPtr
typename ExecSpace::memory_space MemorySpace
Kokkos::View< int_t *, MemorySpace > parentElt
Kokkos::View< TransferStatus *, MemorySpace > status