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 "KokkosNodalBC.h" 13 : 14 : /** 15 : * Implements a simple coupled boundary condition where u=v on the boundary. 16 : */ 17 : class KokkosMatchedValueBC final : public Moose::Kokkos::NodalBC<KokkosMatchedValueBC> 18 : { 19 : public: 20 : static InputParameters validParams(); 21 : 22 : KokkosMatchedValueBC(const InputParameters & parameters); 23 : 24 : KOKKOS_FUNCTION Real computeQpResidual(const ContiguousNodeID node) const; 25 : KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int jvar, 26 : const ContiguousNodeID node) const; 27 : 28 : protected: 29 : const Moose::Kokkos::VariableNodalValue _v; 30 : 31 : /// The id of the coupled variable 32 : const unsigned int _v_num; 33 : /// Coefficient for primary variable 34 : const Real _u_coeff; 35 : /// Coefficient for coupled variable 36 : const Real _v_coeff; 37 : }; 38 : 39 : KOKKOS_FUNCTION inline Real 40 36 : KokkosMatchedValueBC::computeQpResidual(const ContiguousNodeID node) const 41 : { 42 36 : return _u_coeff * _u(node) - _v_coeff * _v(node); 43 : } 44 : 45 : KOKKOS_FUNCTION inline Real 46 18 : KokkosMatchedValueBC::computeQpOffDiagJacobian(const unsigned int jvar, 47 : const ContiguousNodeID /* node */) const 48 : { 49 18 : if (jvar == _v_num) 50 18 : return -_v_coeff; 51 : else 52 0 : return 0; 53 : }