https://mooseframework.inl.gov
KokkosBoundNodalKernel.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 "KokkosNodalKernel.h"
13 
15 {
16 public:
18 
20 
21  virtual void initialSetup() override;
22 
23  template <typename Derived>
24  KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const;
25  template <typename Derived>
26  KOKKOS_FUNCTION Real computeQpJacobian(const unsigned int qp, AssemblyDatum & datum) const;
27  template <typename Derived>
28  KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int jvar,
29  const unsigned int qp,
30  AssemblyDatum & datum) const;
31 
32 protected:
34  const unsigned int _v_var;
35 
38 
39 private:
40  KOKKOS_FUNCTION bool skipOnBoundary(const ContiguousNodeID node) const;
41 
44 };
45 
46 KOKKOS_FUNCTION inline bool
48 {
49  for (dof_id_type b = 0; b < _bnd_ids.size(); ++b)
50  if (kokkosMesh().isBoundaryNode(node, _bnd_ids[b]))
51  return true;
52 
53  return false;
54 }
55 
56 template <typename Derived>
57 KOKKOS_FUNCTION Real
58 KokkosBoundNodalKernel::computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const
59 {
60  if (skipOnBoundary(datum.node()))
61  return _u(datum, qp);
62 
63  return static_cast<const Derived *>(this)->getResidual(qp, datum);
64 }
65 
66 template <typename Derived>
67 KOKKOS_FUNCTION Real
68 KokkosBoundNodalKernel::computeQpJacobian(const unsigned int qp, AssemblyDatum & datum) const
69 {
70  if (skipOnBoundary(datum.node()))
71  return 1;
72 
73  return static_cast<const Derived *>(this)->getJacobian(qp, datum);
74 }
75 
76 template <typename Derived>
77 KOKKOS_FUNCTION Real
79  const unsigned int qp,
80  AssemblyDatum & datum) const
81 {
82  if (skipOnBoundary(datum.node()))
83  return 0;
84 
85  return static_cast<const Derived *>(this)->getOffDiagJacobian(jvar, qp, datum);
86 }
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...
The base class for a user to derive their own Kokkos nodal kernels.
Moose::Kokkos::Array< ContiguousBoundaryID > _bnd_ids
Boundaries on which we should not execute this object.
KOKKOS_FUNCTION bool skipOnBoundary(const ContiguousNodeID node) const
KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum &datum) const
KOKKOS_FUNCTION bool isBoundaryNode(ContiguousNodeID node, ContiguousBoundaryID boundary) const
Get whether a node is on a boundary.
Definition: KokkosMesh.h:411
dof_id_type ContiguousNodeID
Definition: KokkosMesh.h:21
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
The Kokkos wrapper classes for MOOSE-like variable value access.
KOKKOS_FUNCTION index_type size() const
Get the total array size.
Definition: KokkosArray.h:205
KOKKOS_FUNCTION const Mesh & kokkosMesh() const
Get the const reference of the Kokkos mesh.
Definition: KokkosMesh.h:452
KOKKOS_FUNCTION ContiguousNodeID node() const
Get the contiguous node ID.
Definition: KokkosDatum.h:113
const unsigned int _v_var
The number of the coupled variable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Moose::Kokkos::VariableValue _v
The value of the coupled variable.
const VariableValue _u
Current solution at nodes.
KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int jvar, const unsigned int qp, AssemblyDatum &datum) const
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels...
Definition: KokkosDatum.h:364
KOKKOS_FUNCTION Real computeQpJacobian(const unsigned int qp, AssemblyDatum &datum) const
KokkosBoundNodalKernel(const InputParameters &parameters)
uint8_t dof_id_type