16#ifndef dealii_cuda_hanging_nodes_internal_h
17#define dealii_cuda_hanging_nodes_internal_h
25#include <Kokkos_Macros.hpp>
35 template <
unsigned int size>
37 index2(
unsigned int i,
unsigned int j)
44 template <
unsigned int size>
46 index3(
unsigned int i,
unsigned int j,
unsigned int k)
48 return i + size * j + size * size * k;
53 template <
unsigned int fe_degree,
unsigned int direction>
56 const ::internal::MatrixFreeFunctions::ConstraintKinds
58 const unsigned int x_idx,
59 const unsigned int y_idx)
61 return ((direction == 0) &&
62 (((constraint_mask & ::internal::MatrixFreeFunctions::
63 ConstraintKinds::subcell_y) !=
67 (y_idx == fe_degree))) ||
74 (x_idx == fe_degree)));
77 template <
unsigned int fe_degree,
unsigned int direction>
80 const ::internal::MatrixFreeFunctions::ConstraintKinds
82 const unsigned int x_idx,
83 const unsigned int y_idx,
84 const unsigned int z_idx,
85 const ::internal::MatrixFreeFunctions::ConstraintKinds face1_type,
86 const ::internal::MatrixFreeFunctions::ConstraintKinds face2_type,
87 const ::internal::MatrixFreeFunctions::ConstraintKinds face1,
88 const ::internal::MatrixFreeFunctions::ConstraintKinds face2,
89 const ::internal::MatrixFreeFunctions::ConstraintKinds edge)
91 const unsigned int face1_idx = (direction == 0) ? y_idx :
92 (direction == 1) ? z_idx :
94 const unsigned int face2_idx = (direction == 0) ? z_idx :
95 (direction == 1) ? x_idx :
98 const bool on_face1 = ((constraint_mask & face1_type) !=
99 ::internal::MatrixFreeFunctions::
100 ConstraintKinds::unconstrained) ?
102 (face1_idx == fe_degree);
103 const bool on_face2 = ((constraint_mask & face2_type) !=
104 ::internal::MatrixFreeFunctions::
105 ConstraintKinds::unconstrained) ?
107 (face2_idx == fe_degree);
109 (((constraint_mask & face1) != ::internal::MatrixFreeFunctions::
110 ConstraintKinds::unconstrained) &&
112 (((constraint_mask & face2) != ::internal::MatrixFreeFunctions::
113 ConstraintKinds::unconstrained) &&
115 (((constraint_mask & edge) != ::internal::MatrixFreeFunctions::
116 ConstraintKinds::unconstrained) &&
117 on_face1 && on_face2));
122 template <
unsigned int fe_degree,
123 unsigned int direction,
128 const Kokkos::TeamPolicy<
129 MemorySpace::Default::kokkos_space::execution_space>::member_type
131 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
133 const ::internal::MatrixFreeFunctions::ConstraintKinds
135 Kokkos::View<Number *,
136 MemorySpace::Default::kokkos_space::execution_space::
137 scratch_memory_space,
138 Kokkos::MemoryTraits<Kokkos::Unmanaged>> values)
140 constexpr unsigned int n_q_points_1d = fe_degree + 1;
141 constexpr unsigned int n_q_points =
Utilities::pow(n_q_points_1d, 2);
145 const bool constrained_face =
157 Number tmp[n_q_points];
158 Kokkos::parallel_for(
159 Kokkos::TeamThreadRange(team_member, n_q_points),
160 [&](
const int &q_point) {
161 const unsigned int x_idx = q_point % n_q_points_1d;
162 const unsigned int y_idx = q_point / n_q_points_1d;
164 const auto this_type =
170 const unsigned int interp_idx = (direction == 0) ? x_idx : y_idx;
176 const bool constrained_dof =
177 is_constrained_dof_2d<fe_degree, direction>(constraint_mask,
181 if (constrained_face && constrained_dof)
183 const bool type = (constraint_mask & this_type) !=
184 ::internal::MatrixFreeFunctions::
185 ConstraintKinds::unconstrained;
189 for (
unsigned int i = 0; i <= fe_degree; ++i)
191 const unsigned int real_idx =
192 (direction == 0) ? index2<n_q_points_1d>(i, y_idx) :
193 index2<n_q_points_1d>(x_idx, i);
197 constraint_weights[i * n_q_points_1d + interp_idx] :
198 constraint_weights[interp_idx * n_q_points_1d + i];
199 tmp[q_point] += w * values[real_idx];
204 for (
unsigned int i = 0; i <= fe_degree; ++i)
206 const unsigned int real_idx =
207 (direction == 0) ? index2<n_q_points_1d>(i, y_idx) :
208 index2<n_q_points_1d>(x_idx, i);
212 constraint_weights[(fe_degree - i) * n_q_points_1d +
213 fe_degree - interp_idx] :
214 constraint_weights[(fe_degree - interp_idx) *
217 tmp[q_point] += w * values[real_idx];
225 team_member.team_barrier();
226 Kokkos::parallel_for(Kokkos::TeamThreadRange(team_member, n_q_points),
227 [&](
const int &q_point) {
228 const unsigned int x_idx = q_point % n_q_points_1d;
229 const unsigned int y_idx = q_point / n_q_points_1d;
230 const bool constrained_dof =
231 is_constrained_dof_2d<fe_degree, direction>(
232 constraint_mask, x_idx, y_idx);
233 if (constrained_face && constrained_dof)
234 values[index2<fe_degree + 1>(x_idx, y_idx)] =
238 team_member.team_barrier();
243 template <
unsigned int fe_degree,
244 unsigned int direction,
249 const Kokkos::TeamPolicy<
250 MemorySpace::Default::kokkos_space::execution_space>::member_type
252 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
254 const ::internal::MatrixFreeFunctions::ConstraintKinds
256 Kokkos::View<Number *,
257 MemorySpace::Default::kokkos_space::execution_space::
258 scratch_memory_space,
259 Kokkos::MemoryTraits<Kokkos::Unmanaged>> values)
261 constexpr unsigned int n_q_points_1d = fe_degree + 1;
262 constexpr unsigned int n_q_points =
Utilities::pow(n_q_points_1d, 3);
264 const auto this_type =
270 const auto face1_type =
276 const auto face2_type =
303 const auto constrained_face = constraint_mask & (face1 | face2 | edge);
305 Number tmp[n_q_points];
306 Kokkos::parallel_for(
307 Kokkos::TeamThreadRange(team_member, n_q_points),
308 [&](
const int &q_point) {
309 const unsigned int x_idx = q_point % n_q_points_1d;
310 const unsigned int y_idx = (q_point / n_q_points_1d) % n_q_points_1d;
311 const unsigned int z_idx = q_point / (n_q_points_1d * n_q_points_1d);
313 const unsigned int interp_idx = (direction == 0) ? x_idx :
314 (direction == 1) ? y_idx :
316 const bool constrained_dof =
317 is_constrained_dof_3d<fe_degree, direction>(constraint_mask,
327 if ((constrained_face != ::internal::MatrixFreeFunctions::
328 ConstraintKinds::unconstrained) &&
331 const bool type = (constraint_mask & this_type) !=
332 ::internal::MatrixFreeFunctions::
333 ConstraintKinds::unconstrained;
336 for (
unsigned int i = 0; i <= fe_degree; ++i)
338 const unsigned int real_idx =
340 index3<fe_degree + 1>(i, y_idx, z_idx) :
342 index3<fe_degree + 1>(x_idx, i, z_idx) :
343 index3<fe_degree + 1>(x_idx, y_idx, i);
347 constraint_weights[i * n_q_points_1d + interp_idx] :
348 constraint_weights[interp_idx * n_q_points_1d + i];
349 tmp[q_point] += w * values[real_idx];
354 for (
unsigned int i = 0; i <= fe_degree; ++i)
356 const unsigned int real_idx =
358 index3<n_q_points_1d>(i, y_idx, z_idx) :
360 index3<n_q_points_1d>(x_idx, i, z_idx) :
361 index3<n_q_points_1d>(x_idx, y_idx, i);
365 constraint_weights[(fe_degree - i) * n_q_points_1d +
366 fe_degree - interp_idx] :
367 constraint_weights[(fe_degree - interp_idx) *
370 tmp[q_point] += w * values[real_idx];
378 team_member.team_barrier();
380 Kokkos::parallel_for(
381 Kokkos::TeamThreadRange(team_member, n_q_points),
382 [&](
const int &q_point) {
383 const unsigned int x_idx = q_point % n_q_points_1d;
384 const unsigned int y_idx = (q_point / n_q_points_1d) % n_q_points_1d;
385 const unsigned int z_idx = q_point / (n_q_points_1d * n_q_points_1d);
386 const bool constrained_dof =
387 is_constrained_dof_3d<fe_degree, direction>(constraint_mask,
396 if ((constrained_face != ::internal::MatrixFreeFunctions::
397 ConstraintKinds::unconstrained) &&
399 values[index3<fe_degree + 1>(x_idx, y_idx, z_idx)] = tmp[q_point];
402 team_member.team_barrier();
414 template <
int dim,
int fe_degree,
bool transpose,
typename Number>
417 const Kokkos::TeamPolicy<
418 MemorySpace::Default::kokkos_space::execution_space>::member_type
420 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
422 const ::internal::MatrixFreeFunctions::ConstraintKinds
424 Kokkos::View<Number *,
425 MemorySpace::Default::kokkos_space::execution_space::
426 scratch_memory_space,
427 Kokkos::MemoryTraits<Kokkos::Unmanaged>> values)
431 interpolate_boundary_2d<fe_degree, 0, transpose>(team_member,
436 interpolate_boundary_2d<fe_degree, 1, transpose>(team_member,
444 interpolate_boundary_3d<fe_degree, 0, transpose>(team_member,
449 interpolate_boundary_3d<fe_degree, 1, transpose>(team_member,
454 interpolate_boundary_3d<fe_degree, 2, transpose>(team_member,
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
void interpolate_boundary_3d(const Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type &team_member, Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights, const ::internal::MatrixFreeFunctions::ConstraintKinds constraint_mask, Kokkos::View< Number *, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > values)
unsigned int index3(unsigned int i, unsigned int j, unsigned int k)
void interpolate_boundary_2d(const Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type &team_member, Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights, const ::internal::MatrixFreeFunctions::ConstraintKinds &constraint_mask, Kokkos::View< Number *, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > values)
bool is_constrained_dof_2d(const ::internal::MatrixFreeFunctions::ConstraintKinds &constraint_mask, const unsigned int x_idx, const unsigned int y_idx)
bool is_constrained_dof_3d(const ::internal::MatrixFreeFunctions::ConstraintKinds &constraint_mask, const unsigned int x_idx, const unsigned int y_idx, const unsigned int z_idx, const ::internal::MatrixFreeFunctions::ConstraintKinds face1_type, const ::internal::MatrixFreeFunctions::ConstraintKinds face2_type, const ::internal::MatrixFreeFunctions::ConstraintKinds face1, const ::internal::MatrixFreeFunctions::ConstraintKinds face2, const ::internal::MatrixFreeFunctions::ConstraintKinds edge)
unsigned int index2(unsigned int i, unsigned int j)
void resolve_hanging_nodes(const Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type &team_member, Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights, const ::internal::MatrixFreeFunctions::ConstraintKinds constraint_mask, Kokkos::View< Number *, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > values)
constexpr T pow(const T base, const int iexp)
#define DEAL_II_HOST_DEVICE