252 MemorySpace::Default::kokkos_space::execution_space>::member_type
254 const Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
259#if KOKKOS_VERSION >= 40000
260 if constexpr (dim == 1)
261 apply_1d<n_q_points_1d, Number, direction, dof_to_quad, add, in_place>(
262 team_member, shape_data, in, out);
263 if constexpr (dim == 2)
264 apply_2d<n_q_points_1d, Number, direction, dof_to_quad, add, in_place>(
265 team_member, shape_data, in, out);
266 if constexpr (dim == 3)
267 apply_3d<n_q_points_1d, Number, direction, dof_to_quad, add, in_place>(
268 team_member, shape_data, in, out);
270 constexpr unsigned int n_q_points =
Utilities::pow(n_q_points_1d, dim);
272 Number t[n_q_points];
273 Kokkos::parallel_for(
274 Kokkos::TeamThreadRange(team_member, n_q_points),
275 [&](
const int &q_point) {
276 const unsigned int i = (dim == 1) ? 0 : q_point % n_q_points_1d;
277 const unsigned int j =
278 (dim == 3) ? (q_point / n_q_points_1d) % n_q_points_1d : 0;
279 const unsigned int q =
280 (dim == 1) ? q_point :
281 (dim == 2) ? (q_point / n_q_points_1d) % n_q_points_1d :
282 q_point / (n_q_points_1d * n_q_points_1d);
286 const int stride_shape = dof_to_quad ? n_q_points_1d : 1;
288 const int base_shape = dof_to_quad ? q : (q * n_q_points_1d);
290 (direction == 0) ? (n_q_points_1d * (i + n_q_points_1d * j)) :
291 (direction == 1) ? (i + n_q_points_1d * (n_q_points_1d * j)) :
292 (i + n_q_points_1d * j);
294 shape_data[base_shape] * (in_place ? out(base) : in(base));
295 for (
int k = 1; k < n_q_points_1d; ++k)
298 shape_data[base_shape + k * stride_shape] *
299 (in_place ? out(base + k * stride) : in(base + k * stride));
305 team_member.team_barrier();
307 Kokkos::parallel_for(
308 Kokkos::TeamThreadRange(team_member, n_q_points),
309 [&](
const int &q_point) {
310 const unsigned int i = (dim == 1) ? 0 : q_point % n_q_points_1d;
311 const unsigned int j =
312 (dim == 3) ? (q_point / n_q_points_1d) % n_q_points_1d : 0;
313 const unsigned int q =
314 (dim == 1) ? q_point :
315 (dim == 2) ? (q_point / n_q_points_1d) % n_q_points_1d :
316 q_point / (n_q_points_1d * n_q_points_1d);
318 const unsigned int destination_idx =
319 (direction == 0) ? (q + n_q_points_1d * (i + n_q_points_1d * j)) :
320 (direction == 1) ? (i + n_q_points_1d * (q + n_q_points_1d * j)) :
321 (i + n_q_points_1d * (j + n_q_points_1d * q));
324 Kokkos::atomic_add(&out(destination_idx), t[q_point]);
326 out(destination_idx) = t[q_point];
358 MemorySpace::Default::kokkos_space::execution_space>::member_type;
363 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> shape_values,
364 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
366 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
372 template <
typename ViewType>
374 evaluate_values(ViewType u);
380 template <
typename ViewTypeIn,
typename ViewTypeOut>
382 evaluate_gradients(
const ViewTypeIn u, ViewTypeOut grad_u);
388 template <
typename ViewType1,
typename ViewType2>
390 evaluate_values_and_gradients(ViewType1 u, ViewType2 grad_u);
395 template <
typename ViewType>
397 integrate_values(ViewType u);
403 template <
bool add,
typename ViewType1,
typename ViewType2>
405 integrate_gradients(ViewType1 u, ViewType2 grad_u);
411 template <
typename ViewType1,
typename ViewType2>
413 integrate_values_and_gradients(ViewType1 u, ViewType2 grad_u);
419 template <
int direction,
424 typename ViewTypeOut>
426 values(
const ViewTypeIn in, ViewTypeOut out)
const;
432 template <
int direction,
437 typename ViewTypeOut>
439 gradients(
const ViewTypeIn in, ViewTypeOut out)
const;
446 template <
int direction,
451 typename ViewTypeOut>
453 co_gradients(
const ViewTypeIn in, ViewTypeOut out)
const;
463 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
468 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
474 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
572 Number>::evaluate_values(ViewType u)
574 if constexpr (dim == 1)
575 values<0, true, false, true>(u, u);
576 else if constexpr (dim == 2)
578 values<0, true, false, true>(u, u);
579 team_member.team_barrier();
580 values<1, true, false, true>(u, u);
582 else if constexpr (dim == 3)
584 values<0, true, false, true>(u, u);
585 team_member.team_barrier();
586 values<1, true, false, true>(u, u);
587 team_member.team_barrier();
588 values<2, true, false, true>(u, u);
591 Kokkos::abort(
"dim must not exceed 3!");
603 Number>::integrate_values(ViewType u)
605 if constexpr (dim == 1)
606 values<0, false, false, true>(u, u);
607 else if constexpr (dim == 2)
609 values<0, false, false, true>(u, u);
610 team_member.team_barrier();
611 values<1, false, false, true>(u, u);
613 else if constexpr (dim == 3)
615 values<0, false, false, true>(u, u);
616 team_member.team_barrier();
617 values<1, false, false, true>(u, u);
618 team_member.team_barrier();
619 values<2, false, false, true>(u, u);
622 Kokkos::abort(
"dim must not exceed 3!");
634 Number>::evaluate_gradients(
const ViewTypeIn u,
637 if constexpr (dim == 1)
639 gradients<0, true, false, false>(
640 u, Kokkos::subview(grad_u, Kokkos::ALL, 0));
642 else if constexpr (dim == 2)
644 gradients<0, true, false, false>(
645 u, Kokkos::subview(grad_u, Kokkos::ALL, 0));
646 values<0, true, false, false>(
647 u, Kokkos::subview(grad_u, Kokkos::ALL, 1));
649 team_member.team_barrier();
651 values<1, true, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 0),
652 Kokkos::subview(grad_u, Kokkos::ALL, 0));
653 gradients<1, true, false, true>(
654 Kokkos::subview(grad_u, Kokkos::ALL, 1),
655 Kokkos::subview(grad_u, Kokkos::ALL, 1));
657 else if constexpr (dim == 3)
659 gradients<0, true, false, false>(
660 u, Kokkos::subview(grad_u, Kokkos::ALL, 0));
661 values<0, true, false, false>(
662 u, Kokkos::subview(grad_u, Kokkos::ALL, 1));
663 values<0, true, false, false>(
664 u, Kokkos::subview(grad_u, Kokkos::ALL, 2));
666 team_member.team_barrier();
668 values<1, true, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 0),
669 Kokkos::subview(grad_u, Kokkos::ALL, 0));
670 gradients<1, true, false, true>(
671 Kokkos::subview(grad_u, Kokkos::ALL, 1),
672 Kokkos::subview(grad_u, Kokkos::ALL, 1));
673 values<1, true, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 2),
674 Kokkos::subview(grad_u, Kokkos::ALL, 2));
676 team_member.team_barrier();
678 values<2, true, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 0),
679 Kokkos::subview(grad_u, Kokkos::ALL, 0));
680 values<2, true, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 1),
681 Kokkos::subview(grad_u, Kokkos::ALL, 1));
682 gradients<2, true, false, true>(
683 Kokkos::subview(grad_u, Kokkos::ALL, 2),
684 Kokkos::subview(grad_u, Kokkos::ALL, 2));
687 Kokkos::abort(
"dim must not exceed 3!");
699 Number>::evaluate_values_and_gradients(ViewType1 u,
703 if constexpr (dim == 1)
705 values<0, true, false, true>(u, u);
706 team_member.team_barrier();
708 co_gradients<0, true, false, false>(
709 u, Kokkos::subview(grad_u, Kokkos::ALL, 0));
711 else if constexpr (dim == 2)
713 values<0, true, false, true>(u, u);
714 team_member.team_barrier();
715 values<1, true, false, true>(u, u);
716 team_member.team_barrier();
718 co_gradients<0, true, false, false>(
719 u, Kokkos::subview(grad_u, Kokkos::ALL, 0));
720 co_gradients<1, true, false, false>(
721 u, Kokkos::subview(grad_u, Kokkos::ALL, 1));
723 else if constexpr (dim == 3)
725 values<0, true, false, true>(u, u);
726 team_member.team_barrier();
727 values<1, true, false, true>(u, u);
728 team_member.team_barrier();
729 values<2, true, false, true>(u, u);
730 team_member.team_barrier();
732 co_gradients<0, true, false, false>(
733 u, Kokkos::subview(grad_u, Kokkos::ALL, 0));
734 co_gradients<1, true, false, false>(
735 u, Kokkos::subview(grad_u, Kokkos::ALL, 1));
736 co_gradients<2, true, false, false>(
737 u, Kokkos::subview(grad_u, Kokkos::ALL, 2));
740 Kokkos::abort(
"dim must not exceed 3!");
752 Number>::integrate_gradients(ViewType1 u,
755 if constexpr (dim == 1)
757 gradients<0, false, add, false>(
758 Kokkos::subview(grad_u, Kokkos::ALL, dim), u);
760 else if constexpr (dim == 2)
762 gradients<0, false, false, true>(
763 Kokkos::subview(grad_u, Kokkos::ALL, 0),
764 Kokkos::subview(grad_u, Kokkos::ALL, 0));
765 values<0, false, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 1),
766 Kokkos::subview(grad_u,
770 team_member.team_barrier();
772 values<1, false, add, false>(Kokkos::subview(grad_u, Kokkos::ALL, 0),
774 team_member.team_barrier();
775 gradients<1, false, true, false>(
776 Kokkos::subview(grad_u, Kokkos::ALL, 1), u);
778 else if constexpr (dim == 3)
780 gradients<0, false, false, true>(
781 Kokkos::subview(grad_u, Kokkos::ALL, 0),
782 Kokkos::subview(grad_u, Kokkos::ALL, 0));
783 values<0, false, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 1),
784 Kokkos::subview(grad_u,
787 values<0, false, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 2),
788 Kokkos::subview(grad_u,
792 team_member.team_barrier();
794 values<1, false, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 0),
795 Kokkos::subview(grad_u,
798 gradients<1, false, false, true>(
799 Kokkos::subview(grad_u, Kokkos::ALL, 1),
800 Kokkos::subview(grad_u, Kokkos::ALL, 1));
801 values<1, false, false, true>(Kokkos::subview(grad_u, Kokkos::ALL, 2),
802 Kokkos::subview(grad_u,
806 team_member.team_barrier();
808 values<2, false, add, false>(Kokkos::subview(grad_u, Kokkos::ALL, 0),
810 team_member.team_barrier();
811 values<2, false, true, false>(Kokkos::subview(grad_u, Kokkos::ALL, 1),
813 team_member.team_barrier();
814 gradients<2, false, true, false>(
815 Kokkos::subview(grad_u, Kokkos::ALL, 2), u);
818 Kokkos::abort(
"dim must not exceed 3!");
830 Number>::integrate_values_and_gradients(ViewType1 u,
834 if constexpr (dim == 1)
836 co_gradients<0, false, true, false>(
837 Kokkos::subview(grad_u, Kokkos::ALL, 0), u);
838 team_member.team_barrier();
840 values<0, false, false, true>(u, u);
842 else if constexpr (dim == 2)
844 co_gradients<1, false, true, false>(
845 Kokkos::subview(grad_u, Kokkos::ALL, 1), u);
846 team_member.team_barrier();
847 co_gradients<0, false, true, false>(
848 Kokkos::subview(grad_u, Kokkos::ALL, 0), u);
849 team_member.team_barrier();
851 values<1, false, false, true>(u, u);
852 team_member.team_barrier();
853 values<0, false, false, true>(u, u);
854 team_member.team_barrier();
856 else if constexpr (dim == 3)
858 co_gradients<2, false, true, false>(
859 Kokkos::subview(grad_u, Kokkos::ALL, 2), u);
860 team_member.team_barrier();
861 co_gradients<1, false, true, false>(
862 Kokkos::subview(grad_u, Kokkos::ALL, 1), u);
863 team_member.team_barrier();
864 co_gradients<0, false, true, false>(
865 Kokkos::subview(grad_u, Kokkos::ALL, 0), u);
866 team_member.team_barrier();
868 values<2, false, false, true>(u, u);
869 team_member.team_barrier();
870 values<1, false, false, true>(u, u);
871 team_member.team_barrier();
872 values<0, false, false, true>(u, u);
873 team_member.team_barrier();
876 Kokkos::abort(
"dim must not exceed 3!");