Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : #include "KokkosReducerBase.h" 13 : 14 : #include "BlockRestrictable.h" 15 : #include "BoundaryRestrictable.h" 16 : 17 : namespace Moose::Kokkos 18 : { 19 : 20 : class NodalReducer : public ReducerBase, public ::BlockRestrictable, public ::BoundaryRestrictable 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : 25 : NodalReducer(const MooseObject * object); 26 : 27 : /** 28 : * Copy constructor for parallel dispatch 29 : */ 30 : NodalReducer(const NodalReducer & object); 31 : 32 784 : virtual ThreadID numReducerThreads() const override 33 : { 34 784 : return _bnd ? numKokkosBoundaryNodes() : numKokkosBlockNodes(); 35 : } 36 : 37 : /** 38 : * The parallel computation entry function called by Kokkos 39 : */ 40 : template <typename Derived> 41 : KOKKOS_FUNCTION void 42 : operator()(ReducerLoop, const ThreadID tid, const Derived & reducer, Real * result) const; 43 : 44 : protected: 45 : /** 46 : * Flag whether this object is boundary-restricted 47 : */ 48 : const bool _bnd; 49 : /** 50 : * Flag for enable/disabling multiple execute calls on nodes that share block ids 51 : */ 52 : const bool _unique_node_execute; 53 : }; 54 : 55 : template <typename Derived> 56 : KOKKOS_FUNCTION void 57 153672 : NodalReducer::operator()(ReducerLoop, 58 : const ThreadID tid, 59 : const Derived & reducer, 60 : Real * result) const 61 : { 62 153672 : auto node = _bnd ? kokkosBoundaryNodeID(tid) : kokkosBlockNodeID(tid); 63 : 64 153672 : Datum datum(node, kokkosAssembly(), kokkosSystems()); 65 : 66 153672 : reducer.template reduce<Derived>(datum, result); 67 153672 : } 68 : 69 : } // namespace Moose::Kokkos