https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KokkosIntegratedBCValue.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 "KokkosIntegratedBC.h"
13
14namespace Moose::Kokkos
15{
16
43{
44public:
46
48 static constexpr bool uses_precompute_hooks = true;
49
54
60
69 template <typename Derived>
70 KOKKOS_FUNCTION Real precomputeQpJacobian(const unsigned int /* j */,
71 const unsigned int /* qp */,
72 AssemblyDatum & /* datum */) const
73 {
74 ::Kokkos::abort("Default precomputeQpJacobian() should never be called. Make sure you properly "
75 "redefined this method in your class without typos.");
76
77 return 0;
78 }
89 template <typename Derived>
90 KOKKOS_FUNCTION Real precomputeQpOffDiagJacobian(const unsigned int /* j */,
91 const unsigned int /* jvar */,
92 const unsigned int /* qp */,
93 AssemblyDatum & /* datum */) const
94 {
95 ::Kokkos::abort(
96 "Default precomputeQpOffDiagJacobian() should never be called. Make sure you properly "
97 "redefined this method in your class without typos.");
98
99 return 0;
100 }
102
109 template <typename Derived>
110 static auto defaultJacobian()
111 {
112 return &IntegratedBCValue::precomputeQpJacobian<Derived>;
113 }
114 template <typename Derived>
116 {
117 return &IntegratedBCValue::precomputeQpOffDiagJacobian<Derived>;
118 }
120
126 template <typename Derived>
127 KOKKOS_FUNCTION void computeResidualInternal(const Derived & bc, AssemblyDatum & datum) const;
128 template <typename Derived>
129 KOKKOS_FUNCTION void computeJacobianInternal(const Derived & bc, AssemblyDatum & datum) const;
130 template <typename Derived>
131 KOKKOS_FUNCTION void computeOffDiagJacobianInternal(const Derived & bc,
132 AssemblyDatum & datum) const;
134};
135
136template <typename Derived>
137KOKKOS_FUNCTION void
139{
141 datum,
142 [&](Real * local_re, const unsigned int ib, const unsigned int ie)
143 {
144 for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
145 {
146 Real value = datum.JxW(qp) * bc.template precomputeQpResidual<Derived>(qp, datum);
147
148 for (unsigned int i = ib; i < ie; ++i)
149 local_re[i] += value * _test(datum, i, qp);
150 }
151 });
152}
153
154template <typename Derived>
155KOKKOS_FUNCTION void
157{
159 datum,
160 [&](Real * local_ke, const unsigned int ib, const unsigned int ie, const unsigned int j)
161 {
162 for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
163 {
164 Real value = datum.JxW(qp) * bc.template precomputeQpJacobian<Derived>(j, qp, datum);
165
166 for (unsigned int i = ib; i < ie; ++i)
167 local_ke[i] += value * _test(datum, i, qp);
168 }
169 });
170}
171
172template <typename Derived>
173KOKKOS_FUNCTION void
175{
177 datum,
178 [&](Real * local_ke, const unsigned int ib, const unsigned int ie, const unsigned int j)
179 {
180 for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
181 {
182 Real value = datum.JxW(qp) *
183 bc.template precomputeQpOffDiagJacobian<Derived>(j, datum.jvar(), qp, datum);
184
185 for (unsigned int i = ib; i < ie; ++i)
186 local_ke[i] += value * _test(datum, i, qp);
187 }
188 });
189}
190
191} // 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.
The base class for a user to derive their own Kokkos integrated boundary conditions where the residua...
KOKKOS_FUNCTION void computeOffDiagJacobianInternal(const Derived &bc, AssemblyDatum &datum) const
KOKKOS_FUNCTION void computeResidualInternal(const Derived &bc, AssemblyDatum &datum) const
The parallel computation bodies that hide the base class methods to optimize for factoring out the te...
KOKKOS_FUNCTION Real 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...
IntegratedBCValue(const InputParameters &parameters)
Constructor.
KOKKOS_FUNCTION Real precomputeQpOffDiagJacobian(const unsigned int, const unsigned int, const unsigned int, AssemblyDatum &) const
Compute off-diagonal Jacobian contribution on a quadrature point.
KOKKOS_FUNCTION void computeJacobianInternal(const Derived &bc, AssemblyDatum &datum) const
static InputParameters validParams()
static constexpr bool uses_precompute_hooks
IntegratedBCValue hooks factor out the test function.
static auto defaultJacobian()
Functions used to check if users have overriden the hook methods, whose calculations can be skipped w...
The base class for a user to derive their own Kokkos integrated boundary conditions.
const VariableTestValue _test
Current test function.
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.