https://mooseframework.inl.gov
KokkosLinearFVElementalKernel.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "KokkosLinearFVKernel.h"
13 #include "KokkosDatum.h"
14 
15 namespace Moose::Kokkos
16 {
17 
22 {
23 public:
25 
28 
29  virtual void computeRightHandSide() override;
30  virtual void computeMatrix() override;
31 
37  template <typename Derived>
38  KOKKOS_FUNCTION void
39  operator()(RightHandSideLoop, const ThreadID tid, const Derived & kernel) const;
40 
46  template <typename Derived>
47  KOKKOS_FUNCTION void operator()(MatrixLoop, const ThreadID tid, const Derived & kernel) const;
48 };
49 
50 template <typename Derived>
51 KOKKOS_FUNCTION void
53  const ThreadID tid,
54  const Derived & kernel) const
55 {
56  const auto elem = kokkosBlockElementID(tid);
58  KOKKOS_ASSERT(_var.components() == 1);
59  const auto & sys = kokkosSystem(_var.sys());
60  kernel.template accumulateTaggedVector<AccumulationMode::NonAtomic>(
61  kernel.template computeRightHandSideContribution<Derived>(datum),
62  sys.getElemLocalDofIndex(elem, 0, _var.var()));
63 }
64 
65 template <typename Derived>
66 KOKKOS_FUNCTION void
67 LinearFVElementalKernel::operator()(MatrixLoop, const ThreadID tid, const Derived & kernel) const
68 {
69  const auto elem = kokkosBlockElementID(tid);
71  KOKKOS_ASSERT(_var.components() == 1);
72  const auto & sys = kokkosSystem(_var.sys());
73  const auto var_num = _var.var();
74  const auto row = sys.getElemLocalDofIndex(elem, 0, var_num);
75  kernel.template accumulateTaggedMatrix<AccumulationMode::NonAtomic>(
76  kernel.template computeMatrixContribution<Derived>(datum),
77  row,
78  sys.getElemGlobalDofIndex(elem, 0, var_num));
79 }
80 
81 } // namespace Moose::Kokkos
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
LinearFVElementalKernel(const InputParameters &parameters)
const unsigned int invalid_uint
static InputParameters validParams()
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Tag dispatch type for the right-hand side computation loop.
KOKKOS_FUNCTION unsigned int components() const
Get the number of components.
MOOSE_KOKKOS_INDEX_TYPE ThreadID
Definition: KokkosThread.h:22
Base class for Kokkos linear finite volume kernels that contribute to the linear system.
KOKKOS_FUNCTION void operator()(RightHandSideLoop, const ThreadID tid, const Derived &kernel) const
Right-hand side dispatch loop body; accumulates the elemental RHS contribution.
KOKKOS_FUNCTION ContiguousElementID kokkosBlockElementID(Moose::Kokkos::ThreadID tid) const
Get the contiguous element ID this Kokkos thread is operating on.
KOKKOS_FUNCTION const Mesh & kokkosMesh() const
Get the const reference of the Kokkos mesh.
Definition: KokkosMesh.h:651
Device-side geometric context for finite volume kernels and boundary conditions.
Definition: KokkosDatum.h:167
virtual void computeMatrix() override
Compute the matrix contributions of this object.
Base class for Kokkos linear finite volume kernels that contribute on elements (volumetric terms) ...
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
virtual void computeRightHandSide() override
Compute the right-hand side contributions of this object.