https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
16public:
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
32protected:
34 const unsigned int _v_var;
35
38
39private:
40 KOKKOS_FUNCTION bool skipOnBoundary(const ContiguousNodeID node) const;
41
44};
45
46KOKKOS_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
56template <typename Derived>
57KOKKOS_FUNCTION Real
58KokkosBoundNodalKernel::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
66template <typename Derived>
67KOKKOS_FUNCTION Real
68KokkosBoundNodalKernel::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
76template <typename Derived>
77KOKKOS_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}
dof_id_type ContiguousNodeID
Definition KokkosMesh.h:21
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Moose::Kokkos::Array< ContiguousBoundaryID > _bnd_ids
Boundaries on which we should not execute this object.
KokkosBoundNodalKernel(const InputParameters &parameters)
KOKKOS_FUNCTION Real computeQpJacobian(const unsigned int qp, AssemblyDatum &datum) const
KOKKOS_FUNCTION bool skipOnBoundary(const ContiguousNodeID node) const
KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum &datum) const
KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int jvar, const unsigned int qp, AssemblyDatum &datum) const
static InputParameters validParams()
const unsigned int _v_var
The number of the coupled variable.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
const Moose::Kokkos::VariableValue _v
The value of the coupled variable.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
KOKKOS_FUNCTION index_type size() const
Get the total array size.
The Kokkos array class.
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels.
KOKKOS_FUNCTION ContiguousNodeID node() const
Get the contiguous node ID.
KOKKOS_FUNCTION const Mesh & kokkosMesh() const
Get the const reference of the Kokkos mesh.
Definition KokkosMesh.h:651
The base class for a user to derive their own Kokkos nodal kernels.
const VariableValue _u
Current solution at nodes.
The Kokkos wrapper classes for MOOSE-like variable value access.