https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KokkosVectorIntegratedBCValue.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
14namespace Moose::Kokkos
15{
16
22{
23public:
25
27 static constexpr bool use_precompute_hooks = true;
28
33
39 template <typename Derived>
40 KOKKOS_FUNCTION Real3 precomputeQpJacobian(const unsigned int /* j */,
41 const unsigned int /* qp */,
42 AssemblyDatum & /* datum */) const
43 {
44 ::Kokkos::abort("Default precomputeQpJacobian() should never be called. Make sure you properly "
45 "redefined this method in your class without typos.");
46
47 return Real3(0);
48 }
49 template <typename Derived>
50 KOKKOS_FUNCTION Real3 precomputeQpOffDiagJacobian(const unsigned int /* j */,
51 const unsigned int /* jvar */,
52 const unsigned int /* qp */,
53 AssemblyDatum & /* datum */) const
54 {
55 ::Kokkos::abort(
56 "Default precomputeQpOffDiagJacobian() should never be called. Make sure you properly "
57 "redefined this method in your class without typos.");
58
59 return Real3(0);
60 }
62
68 template <typename Derived>
69 static auto defaultJacobian()
70 {
71 return &VectorIntegratedBCValue::precomputeQpJacobian<Derived>;
72 }
73 template <typename Derived>
75 {
76 return &VectorIntegratedBCValue::precomputeQpOffDiagJacobian<Derived>;
77 }
79
84 template <typename Derived>
85 KOKKOS_FUNCTION void computeResidualInternal(const Derived & bc, AssemblyDatum & datum) const;
86 template <typename Derived>
87 KOKKOS_FUNCTION void computeJacobianInternal(const Derived & bc, AssemblyDatum & datum) const;
88 template <typename Derived>
89 KOKKOS_FUNCTION void computeOffDiagJacobianInternal(const Derived & bc,
90 AssemblyDatum & datum) const;
92};
93
94template <typename Derived>
95KOKKOS_FUNCTION void
97{
99 datum,
100 [&](Real * local_re, const unsigned int ib, const unsigned int ie)
101 {
102 for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
103 {
104 Real3 value = datum.JxW(qp) * bc.template precomputeQpResidual<Derived>(qp, datum);
105
106 for (unsigned int i = ib; i < ie; ++i)
107 local_re[i] += value * _test(datum, i, qp);
108 }
109 });
110}
111
112template <typename Derived>
113KOKKOS_FUNCTION void
115{
117 datum,
118 [&](Real * local_ke, const unsigned int ib, const unsigned int ie, const unsigned int j)
119 {
120 for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
121 {
122 Real3 value = datum.JxW(qp) * bc.template precomputeQpJacobian<Derived>(j, qp, datum);
123
124 for (unsigned int i = ib; i < ie; ++i)
125 local_ke[i] += value * _test(datum, i, qp);
126 }
127 });
128}
129
130template <typename Derived>
131KOKKOS_FUNCTION void
133 AssemblyDatum & datum) const
134{
136 datum,
137 [&](Real * local_ke, const unsigned int ib, const unsigned int ie, const unsigned int j)
138 {
139 for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
140 {
141 Real3 value = datum.JxW(qp) * bc.template precomputeQpOffDiagJacobian<Derived>(
142 j, datum.jvar(), qp, datum);
143
144 for (unsigned int i = ib; i < ie; ++i)
145 local_ke[i] += value * _test(datum, i, qp);
146 }
147 });
148}
149
150} // namespace Moose::Kokkos
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
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels.
KOKKOS_FUNCTION unsigned int jvar() const
Get the coupled variable number.
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.
KOKKOS_FUNCTION void computeJacobianInternal(AssemblyDatum &datum, function body) const
The common loop structure template for computing elemental Jacobian.
KOKKOS_FUNCTION void computeResidualInternal(AssemblyDatum &datum, function body) const
The common loop structure template for computing elemental residual.
The base class for Kokkos integrated boundary conditions on vector variables where the residual is of...
static auto defaultJacobian()
Functions used to check if users have overriden the hook methods, whose calculations can be skipped w...
static constexpr bool use_precompute_hooks
VectorIntegratedBCValue hooks factor out the test function.
KOKKOS_FUNCTION void computeJacobianInternal(const Derived &bc, AssemblyDatum &datum) const
VectorIntegratedBCValue(const InputParameters &parameters)
Constructor.
KOKKOS_FUNCTION Real3 precomputeQpOffDiagJacobian(const unsigned int, const unsigned int, const unsigned int, AssemblyDatum &) const
static InputParameters validParams()
KOKKOS_FUNCTION Real3 precomputeQpJacobian(const unsigned int, const unsigned int, AssemblyDatum &) const
Default methods to prevent compile errors even when these methods were not defined in the derived cla...
KOKKOS_FUNCTION void computeResidualInternal(const Derived &bc, AssemblyDatum &datum) const
Optimized computation bodies that factor out the vector test function.
KOKKOS_FUNCTION void computeOffDiagJacobianInternal(const Derived &bc, AssemblyDatum &datum) const
The base class for a user to derive their own Kokkos integrated boundary conditions on vector variabl...
const VectorVariableTestValue _test
Current vector test function.
Vector3< Real > Real3
Definition KokkosTypes.h:32