https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KokkosUserObject.h
Go to the documentation of this file.
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 "KokkosMesh.h"
13#include "KokkosAssembly.h"
14#include "KokkosFESystem.h"
15#include "KokkosDispatcher.h"
16
17#include "UserObjectBase.h"
18
19namespace Moose::Kokkos
20{
21
23{
24public:
26
27 UserObject(const InputParameters & params);
28
32 UserObject(const UserObject & object);
33
34 // Unused for Kokkos user objects because all subdomains are computed in parallel
35 virtual void subdomainSetup() override final {}
36
37 // Kokkos user objects are never threaded
38 virtual bool needThreadedCopy() const override final { return false; }
39
43 virtual void compute() = 0;
44
49 {
50 };
51
56 template <typename Derived>
57 KOKKOS_FUNCTION void execute(Datum & /* datum */) const
58 {
59 ::Kokkos::abort("Default execute() should never be called. Make sure you properly redefined "
60 "this method in your class without typos.");
61 }
62
67 template <typename Derived>
68 static auto defaultExecute()
69 {
70 return &UserObject::execute<Derived>;
71 }
72
73protected:
77 virtual void computeUserObject();
81 virtual ThreadID numUserObjectThreads() const = 0;
82
86 std::unique_ptr<DispatcherBase> _user_object_dispatcher;
87};
88
89} // namespace Moose::Kokkos
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object.
virtual void compute()=0
Compute this user object.
UserObject(const InputParameters &params)
KOKKOS_FUNCTION void execute(Datum &) const
Default method to prevent compile errors even when this method was not defined in the derived class.
static InputParameters validParams()
UserObject(const UserObject &object)
Copy constructor for parallel dispatch.
static auto defaultExecute()
Function used to check if users have overriden the hook method.
virtual ThreadID numUserObjectThreads() const =0
Get the number of threads.
virtual void subdomainSetup() override final
Gets called when the subdomain changes (i.e.
std::unique_ptr< DispatcherBase > _user_object_dispatcher
Kokkos functor dispatcher.
virtual bool needThreadedCopy() const override final
Whether or not a threaded copy of this object is needed when obtaining it in another object,...
virtual void computeUserObject()
Dispatch parallel operation.
MOOSE_KOKKOS_INDEX_TYPE ThreadID