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 "KokkosUserObject.h" 13 : #include "KokkosNodalReducer.h" 14 : #include "KokkosMaterialPropertyValue.h" 15 : 16 : #include "CoupleableMooseVariableDependencyIntermediateInterface.h" 17 : #include "TransientInterface.h" 18 : #include "RandomInterface.h" 19 : 20 : namespace Moose::Kokkos 21 : { 22 : 23 : class NodalUserObject : public UserObject, 24 : public NodalReducer, 25 : public ::CoupleableMooseVariableDependencyIntermediateInterface, 26 : public ::TransientInterface, 27 : public ::RandomInterface 28 : { 29 : public: 30 : static InputParameters validParams(); 31 : 32 : NodalUserObject(const InputParameters & parameters); 33 : 34 : /** 35 : * Copy constructor for parallel dispatch 36 : */ 37 : NodalUserObject(const NodalUserObject & object); 38 : 39 : virtual void compute() override; 40 : 41 : /** 42 : * The parallel computation entry function called by Kokkos 43 : */ 44 : template <typename Derived> 45 : KOKKOS_FUNCTION void operator()(DefaultLoop, const ThreadID tid, const Derived & object) const; 46 : 47 : using NodalReducer::operator(); 48 : 49 : protected: 50 15 : virtual ThreadID numUserObjectThreads() const override 51 : { 52 15 : return _bnd ? numKokkosBoundaryNodes() : numKokkosBlockNodes(); 53 : } 54 : }; 55 : 56 : template <typename Derived> 57 : KOKKOS_FUNCTION void 58 96 : NodalUserObject::operator()(DefaultLoop, const ThreadID tid, const Derived & object) const 59 : { 60 96 : auto node = _bnd ? kokkosBoundaryNodeID(tid) : kokkosBlockNodeID(tid); 61 : 62 96 : Datum datum(node, kokkosAssembly(), kokkosSystems()); 63 : 64 96 : object.template execute<Derived>(datum); 65 96 : } 66 : 67 : } // namespace Moose::Kokkos