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 "KokkosIntegratedBCValue.h" 13 : 14 : /** 15 : * Implements a Neumann BC where grad(u)=_coupled_var on the boundary. 16 : * Uses the term produced from integrating the diffusion operator by parts. 17 : */ 18 : class KokkosCoupledVarNeumannBC : public Moose::Kokkos::IntegratedBCValue 19 : { 20 : public: 21 : static InputParameters validParams(); 22 : 23 : KokkosCoupledVarNeumannBC(const InputParameters & parameters); 24 : 25 : template <typename Derived> 26 : KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const; 27 : template <typename Derived> 28 : KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int j, 29 : const unsigned int jvar, 30 : const unsigned int qp, 31 : AssemblyDatum & datum) const; 32 : 33 : protected: 34 : /// Variable providing the value of grad(u) on the boundary. 35 : const Moose::Kokkos::VariableValue _coupled_var; 36 : 37 : /// The identifying number of the coupled variable 38 : const unsigned int _coupled_num; 39 : 40 : /// A coefficient that is multiplied with the residual contribution 41 : const Real _coef; 42 : 43 : /// Scale factor 44 : const Moose::Kokkos::VariableValue _scale_factor; 45 : }; 46 : 47 : template <typename Derived> 48 : KOKKOS_FUNCTION Real 49 30312 : KokkosCoupledVarNeumannBC::computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const 50 : { 51 30312 : return -_scale_factor(datum, qp) * _coef * _coupled_var(datum, qp); 52 : } 53 : 54 : template <typename Derived> 55 : KOKKOS_FUNCTION Real 56 40 : KokkosCoupledVarNeumannBC::computeQpOffDiagJacobian(const unsigned int j, 57 : const unsigned int jvar, 58 : const unsigned int qp, 59 : AssemblyDatum & datum) const 60 : { 61 40 : if (jvar == _coupled_num) 62 40 : return -_scale_factor(datum, qp) * _coef * _phi(datum, j, qp); 63 : else 64 0 : return 0; 65 : }