https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
13#include "KokkosDatum.h"
14
15namespace Moose::Kokkos
16{
17
22{
23public:
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
50template <typename Derived>
51KOKKOS_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
65template <typename Derived>
66KOKKOS_FUNCTION void
67LinearFVElementalKernel::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 ContiguousElementID kokkosBlockElementID(Moose::Kokkos::ThreadID tid) const
Get the contiguous element ID this Kokkos thread is operating on.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Device-side geometric context for finite volume kernels and boundary conditions.
Base class for Kokkos linear finite volume kernels that contribute on elements (volumetric terms)
virtual void computeMatrix() override
Compute the matrix contributions of this object.
LinearFVElementalKernel(const InputParameters &parameters)
LinearFVElementalKernel(const LinearFVElementalKernel &object)
static InputParameters validParams()
virtual void computeRightHandSide() override
Compute the right-hand side contributions of this object.
KOKKOS_FUNCTION void operator()(RightHandSideLoop, const ThreadID tid, const Derived &kernel) const
Right-hand side dispatch loop body; accumulates the elemental RHS contribution.
Base class for Kokkos linear finite volume kernels that contribute to the linear system.
KOKKOS_FUNCTION const Mesh & kokkosMesh() const
Get the const reference of the Kokkos mesh.
Definition KokkosMesh.h:651
KOKKOS_FUNCTION unsigned int components() const
Get the number of components.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
MOOSE_KOKKOS_INDEX_TYPE ThreadID
const unsigned int invalid_uint
Tag dispatch type for the right-hand side computation loop.