Line data Source code
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 : 14 : class KokkosCoupledForceNodalKernel : public Moose::Kokkos::NodalKernel 15 : { 16 : public: 17 : static InputParameters validParams(); 18 : 19 : KokkosCoupledForceNodalKernel(const InputParameters & parameters); 20 : 21 : template <typename Derived> 22 : KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const; 23 : template <typename Derived> 24 : KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int jvar, 25 : const unsigned int qp, 26 : AssemblyDatum & datum) const; 27 : 28 : private: 29 : /// The number of the coupled variable 30 : const unsigned int _v_var; 31 : 32 : /// The value of the coupled variable 33 : const Moose::Kokkos::VariableValue _v; 34 : 35 : /// A multiplicative factor for computing the coupled force 36 : const Real _coef; 37 : }; 38 : 39 : template <typename Derived> 40 : KOKKOS_FUNCTION Real 41 117744 : KokkosCoupledForceNodalKernel::computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const 42 : { 43 117744 : return -_coef * _v(datum, qp); 44 : } 45 : 46 : template <typename Derived> 47 : KOKKOS_FUNCTION Real 48 124550 : KokkosCoupledForceNodalKernel::computeQpOffDiagJacobian(const unsigned int jvar, 49 : const unsigned int /* qp */, 50 : AssemblyDatum & /* datum */) const 51 : { 52 124550 : if (jvar == _v_var) 53 91816 : return -_coef; 54 32734 : return 0; 55 : }