76 const ::internal::MatrixFreeFunctions::ConstraintKinds
78 const unsigned int x_idx,
79 const unsigned int y_idx,
80 const unsigned int z_idx,
81 const ::internal::MatrixFreeFunctions::ConstraintKinds face1_type,
82 const ::internal::MatrixFreeFunctions::ConstraintKinds face2_type,
83 const ::internal::MatrixFreeFunctions::ConstraintKinds face1,
84 const ::internal::MatrixFreeFunctions::ConstraintKinds face2,
85 const ::internal::MatrixFreeFunctions::ConstraintKinds edge)
87 const unsigned int face1_idx = (direction == 0) ? y_idx :
88 (direction == 1) ? z_idx :
90 const unsigned int face2_idx = (direction == 0) ? z_idx :
91 (direction == 1) ? x_idx :
94 const bool on_face1 = ((constraint_mask & face1_type) !=
95 ::internal::MatrixFreeFunctions::
96 ConstraintKinds::unconstrained) ?
98 (face1_idx == fe_degree);
99 const bool on_face2 = ((constraint_mask & face2_type) !=
100 ::internal::MatrixFreeFunctions::
101 ConstraintKinds::unconstrained) ?
103 (face2_idx == fe_degree);
105 (((constraint_mask & face1) != ::internal::MatrixFreeFunctions::
106 ConstraintKinds::unconstrained) &&
108 (((constraint_mask & face2) != ::internal::MatrixFreeFunctions::
109 ConstraintKinds::unconstrained) &&
111 (((constraint_mask & edge) != ::internal::MatrixFreeFunctions::
112 ConstraintKinds::unconstrained) &&
113 on_face1 && on_face2));
141 const Kokkos::TeamPolicy<
142 MemorySpace::Default::kokkos_space::execution_space>::member_type
144 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
146 const ::internal::MatrixFreeFunctions::ConstraintKinds
150 static_assert(dim == 2 || dim == 3,
"Only implemented for 2d and 3d");
151 static_assert(direction >= 0 && direction < dim,
152 "direction must be in [0, dim)");
154 using ConstraintKinds =
157 constexpr unsigned int n_dofs_1d = fe_degree + 1;
160 constexpr unsigned int n_lines =
Utilities::pow(n_dofs_1d, dim - 1);
161 constexpr unsigned int stride =
Utilities::pow(n_dofs_1d, direction);
167 const auto this_type = (direction == 0) ? ConstraintKinds::subcell_x :
168 (direction == 1) ? ConstraintKinds::subcell_y :
169 ConstraintKinds::subcell_z;
170 [[maybe_unused]]
const auto face1_type =
171 (direction == 0) ? ConstraintKinds::subcell_y :
172 (direction == 1) ? ConstraintKinds::subcell_z :
173 ConstraintKinds::subcell_x;
174 [[maybe_unused]]
const auto face2_type =
175 (direction == 0) ? ConstraintKinds::subcell_z :
176 (direction == 1) ? ConstraintKinds::subcell_x :
177 ConstraintKinds::subcell_y;
179 const auto face1 = (direction == 0) ? ConstraintKinds::face_y :
180 (direction == 1) ? ConstraintKinds::face_z :
181 ConstraintKinds::face_x;
182 const auto face2 = (direction == 0) ? ConstraintKinds::face_z :
183 (direction == 1) ? ConstraintKinds::face_x :
184 ConstraintKinds::face_y;
185 const auto edge = (direction == 0) ? ConstraintKinds::edge_x :
186 (direction == 1) ? ConstraintKinds::edge_y :
187 ConstraintKinds::edge_z;
189 const auto constrained_faces =
190 (dim == 2) ? ((direction == 0) ? ConstraintKinds::face_y :
191 ConstraintKinds::face_x) :
192 (face1 | face2 | edge);
195 if ((constraint_mask & constrained_faces) ==
196 ConstraintKinds::unconstrained)
199 Kokkos::parallel_for(
200 Kokkos::TeamThreadRange(team_member, n_lines),
201 [&](
const unsigned int line) {
204 unsigned int x_idx = 0, y_idx = 0, z_idx = 0;
205 if constexpr (dim == 2)
214 const unsigned int i1 = line % n_dofs_1d;
215 const unsigned int i2 = line / n_dofs_1d;
221 else if (direction == 1)
233 bool constrained_line;
234 if constexpr (dim == 2)
236 is_constrained_dof_2d<fe_degree, direction>(constraint_mask,
241 is_constrained_dof_3d<fe_degree, direction>(constraint_mask,
250 if (!constrained_line)
253 const unsigned int offset = (dim == 2) ?
254 index2<n_dofs_1d>(x_idx, y_idx) :
255 index3<n_dofs_1d>(x_idx, y_idx, z_idx);
258 Number line_values[n_dofs_1d];
259 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
260 line_values[i] = values(offset + i * stride);
263 (constraint_mask & this_type) != ConstraintKinds::unconstrained;
265 for (
unsigned int j = 0; j < n_dofs_1d; ++j)
269 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
272 constraint_weights[i * n_dofs_1d + j] :
273 constraint_weights[j * n_dofs_1d + i];
274 sum += w * line_values[i];
277 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
281 constraint_weights[(fe_degree - i) * n_dofs_1d +
283 constraint_weights[(fe_degree - j) * n_dofs_1d +
285 sum += w * line_values[i];
287 values(offset + j * stride) = sum;
291 team_member.team_barrier();
312 const Kokkos::TeamPolicy<
313 MemorySpace::Default::kokkos_space::execution_space>::member_type
315 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
317 const ::internal::MatrixFreeFunctions::ConstraintKinds
321 if constexpr (dim == 2)
323 interpolate_boundary<2, fe_degree, 0, transpose>(team_member,
327 interpolate_boundary<2, fe_degree, 1, transpose>(team_member,
332 else if constexpr (dim == 3)
335 interpolate_boundary<3, fe_degree, 0, transpose>(team_member,
340 interpolate_boundary<3, fe_degree, 1, transpose>(team_member,
345 interpolate_boundary<3, fe_degree, 2, transpose>(team_member,
399 const Kokkos::TeamPolicy<
400 MemorySpace::Default::kokkos_space::execution_space>::member_type
405 const int batch_size = 1)
407 static_assert(dim == 2 || dim == 3,
"Only implemented for 2d and 3d");
408 static_assert(direction >= 0 && direction < dim,
409 "direction must be in [0, dim)");
411 using ConstraintKinds =
414 constexpr unsigned int n_dofs_1d = fe_degree + 1;
418 constexpr unsigned int n_lines =
Utilities::pow(n_dofs_1d, dim - 1);
419 constexpr unsigned int stride =
Utilities::pow(n_dofs_1d, direction);
422 Assert(constraint_masks.extent(0) >=
423 static_cast<std::size_t
>(batch_size),
425 Assert(values.size() >=
static_cast<std::size_t
>(batch_size) * n_dofs,
429 const auto this_type = (direction == 0) ? ConstraintKinds::subcell_x :
430 (direction == 1) ? ConstraintKinds::subcell_y :
431 ConstraintKinds::subcell_z;
432 [[maybe_unused]]
const auto face1_type =
433 (direction == 0) ? ConstraintKinds::subcell_y :
434 (direction == 1) ? ConstraintKinds::subcell_z :
435 ConstraintKinds::subcell_x;
436 [[maybe_unused]]
const auto face2_type =
437 (direction == 0) ? ConstraintKinds::subcell_z :
438 (direction == 1) ? ConstraintKinds::subcell_x :
439 ConstraintKinds::subcell_y;
441 const auto face1 = (direction == 0) ? ConstraintKinds::face_y :
442 (direction == 1) ? ConstraintKinds::face_z :
443 ConstraintKinds::face_x;
444 const auto face2 = (direction == 0) ? ConstraintKinds::face_z :
445 (direction == 1) ? ConstraintKinds::face_x :
446 ConstraintKinds::face_y;
447 const auto edge = (direction == 0) ? ConstraintKinds::edge_x :
448 (direction == 1) ? ConstraintKinds::edge_y :
449 ConstraintKinds::edge_z;
451 const auto constrained_faces =
452 (dim == 2) ? ((direction == 0) ? ConstraintKinds::face_y :
453 ConstraintKinds::face_x) :
454 (face1 | face2 | edge);
457 ConstraintKinds batch_mask = ConstraintKinds::unconstrained;
458 for (
int cell = 0; cell < batch_size; ++cell)
459 batch_mask |= constraint_masks(cell);
460 if ((batch_mask & constrained_faces) == ConstraintKinds::unconstrained)
463 Assert(constraint_weights.size() >= n_dofs_1d * n_dofs_1d,
466 Kokkos::parallel_for(
467 Kokkos::TeamVectorRange(team_member, batch_size * n_lines),
469 const int cell = tid / n_lines;
470 const unsigned int line = tid % n_lines;
472 const ConstraintKinds constraint_mask = constraint_masks(cell);
473 if ((constraint_mask & constrained_faces) ==
474 ConstraintKinds::unconstrained)
479 unsigned int x_idx = 0, y_idx = 0, z_idx = 0;
480 if constexpr (dim == 2)
489 const unsigned int i1 = line % n_dofs_1d;
490 const unsigned int i2 = line / n_dofs_1d;
496 else if (direction == 1)
508 bool constrained_line;
509 if constexpr (dim == 2)
511 is_constrained_dof_2d<fe_degree, direction>(constraint_mask,
516 is_constrained_dof_3d<fe_degree, direction>(constraint_mask,
525 if (!constrained_line)
528 const unsigned int offset =
529 cell * n_dofs + ((dim == 2) ?
530 index2<n_dofs_1d>(x_idx, y_idx) :
531 index3<n_dofs_1d>(x_idx, y_idx, z_idx));
534 Number line_values[n_dofs_1d];
535 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
536 line_values[i] = values(offset + i * stride);
539 (constraint_mask & this_type) != ConstraintKinds::unconstrained;
541 for (
unsigned int j = 0; j < n_dofs_1d; ++j)
545 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
548 constraint_weights[i * n_dofs_1d + j] :
549 constraint_weights[j * n_dofs_1d + i];
550 sum += w * line_values[i];
553 for (
unsigned int i = 0; i < n_dofs_1d; ++i)
557 constraint_weights[(fe_degree - i) * n_dofs_1d +
559 constraint_weights[(fe_degree - j) * n_dofs_1d +
561 sum += w * line_values[i];
563 values(offset + j * stride) = sum;
567 team_member.team_barrier();
590 const Kokkos::TeamPolicy<
591 MemorySpace::Default::kokkos_space::execution_space>::member_type
596 const int batch_size = 1)
598 if constexpr (dim == 2)
600 interpolate_boundary<2, fe_degree, 0, transpose>(team_member,
605 interpolate_boundary<2, fe_degree, 1, transpose>(team_member,
611 else if constexpr (dim == 3)
614 interpolate_boundary<3, fe_degree, 0, transpose>(team_member,
620 interpolate_boundary<3, fe_degree, 1, transpose>(team_member,
626 interpolate_boundary<3, fe_degree, 2, transpose>(team_member,
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)