https://mooseframework.inl.gov
KokkosNodalReducer.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 "KokkosReducerBase.h"
13 
14 #include "BlockRestrictable.h"
15 #include "BoundaryRestrictable.h"
16 
17 namespace Moose::Kokkos
18 {
19 
21 {
22 public:
24 
25  NodalReducer(const MooseObject * object);
26 
30  NodalReducer(const NodalReducer & object);
31 
32  virtual ThreadID numReducerThreads() const override
33  {
35  }
36 
40  template <typename Derived>
41  KOKKOS_FUNCTION void
42  operator()(ReducerLoop, const ThreadID tid, const Derived & reducer, Real * result) const;
43 
44 protected:
48  const bool _bnd;
53 };
54 
55 template <typename Derived>
56 KOKKOS_FUNCTION void
58  const ThreadID tid,
59  const Derived & reducer,
60  Real * result) const
61 {
62  auto node = _bnd ? kokkosBoundaryNodeID(tid) : kokkosBlockNodeID(tid);
63 
64  Datum datum(node, kokkosAssembly(), kokkosSystems());
65 
66  reducer.template reduce<Derived>(datum, result);
67 }
68 
69 } // namespace Moose::Kokkos
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
Definition: KokkosDatum.h:23
KOKKOS_FUNCTION const Assembly & kokkosAssembly() const
Get the const reference of the Kokkos assembly.
KOKKOS_FUNCTION ContiguousNodeID kokkosBoundaryNodeID(Moose::Kokkos::ThreadID tid) const
Get the contiguous node ID this Kokkos thread is operating on.
const bool _unique_node_execute
Flag for enable/disabling multiple execute calls on nodes that share block ids.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
KOKKOS_FUNCTION dof_id_type numKokkosBoundaryNodes() const
Get the number of nodes this Kokkos object is operating on.
virtual ThreadID numReducerThreads() const override
Get the number of threads.
const bool _bnd
Flag whether this object is boundary-restricted.
MOOSE_KOKKOS_INDEX_TYPE ThreadID
Definition: KokkosThread.h:22
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
static InputParameters validParams()
NodalReducer(const MooseObject *object)
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
KOKKOS_FUNCTION void operator()(ReducerLoop, const ThreadID tid, const Derived &reducer, Real *result) const
The parallel computation entry function called by Kokkos.
KOKKOS_FUNCTION ContiguousElementID kokkosBlockNodeID(Moose::Kokkos::ThreadID tid) const
Get the contiguous node index this Kokkos thread is operating on.
KOKKOS_FUNCTION const Array< System > & kokkosSystems() const
Get the const reference of the Kokkos systems.
Definition: KokkosSystem.h:775
KOKKOS_FUNCTION dof_id_type numKokkosBlockNodes() const
Get the number of nodes this Kokkos object is operating on.