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