Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_DOFManager_Functors.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef __Panzer_DOFManager_Functors_hpp__
12 #define __Panzer_DOFManager_Functors_hpp__
13 
14 #include "Kokkos_Core.hpp"
15 #include "Phalanx_KokkosDeviceTypes.hpp"
16 
17 namespace panzer {
18 namespace dof_functors {
19 
21 template <typename ReductionDataType, typename view_t>
22 struct SumRank2 {
23  using policy_t = Kokkos::MDRangePolicy<typename view_t::execution_space, Kokkos::Rank<2>>;
24 
25  const view_t values;
26 
27  void apply(ReductionDataType& sum) const
28  {
29  const auto& values_ref = values;
30 
31  Kokkos::parallel_reduce(
32  policy_t({0, 0}, {values.extent(0), values.extent(1)}),
33  KOKKOS_LAMBDA(const typename policy_t::index_type indexi, const typename policy_t::index_type indexj, ReductionDataType& local_sum)
34  {
35  local_sum += values_ref(indexi, indexj);
36  },
37  Kokkos::Sum<ReductionDataType>(sum)
38  );
39  }
40 };
41 
42 }
43 }
44 
45 #endif
Sums all entries of a Rank 2 Kokkos View.
Kokkos::MDRangePolicy< typename view_t::execution_space, Kokkos::Rank< 2 >> policy_t
void apply(ReductionDataType &sum) const