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 "KokkosBoundNodalKernel.h" 13 : 14 : /** 15 : * Class used to enforce a upper bound on a coupled variable 16 : */ 17 : class KokkosUpperBoundNodalKernel final : public KokkosBoundNodalKernel<KokkosUpperBoundNodalKernel> 18 : { 19 : public: 20 : static InputParameters validParams(); 21 : 22 : KokkosUpperBoundNodalKernel(const InputParameters & parameters); 23 : 24 : KOKKOS_FUNCTION Real getResidual(const unsigned int qp, AssemblyDatum & datum) const; 25 : KOKKOS_FUNCTION Real getJacobian(const unsigned int qp, AssemblyDatum & datum) const; 26 : KOKKOS_FUNCTION Real getOffDiagJacobian(const unsigned int jvar, 27 : const unsigned int qp, 28 : AssemblyDatum & datum) const; 29 : 30 : private: 31 : /// The upper bound on the coupled variable 32 : const Real _upper_bound; 33 : }; 34 : 35 : KOKKOS_FUNCTION inline Real 36 57528 : KokkosUpperBoundNodalKernel::getResidual(const unsigned int qp, AssemblyDatum & datum) const 37 : { 38 57528 : return ::Kokkos::min(_u(datum, qp), _upper_bound - _v(datum, qp)); 39 : } 40 : 41 : KOKKOS_FUNCTION inline Real 42 44892 : KokkosUpperBoundNodalKernel::getJacobian(const unsigned int qp, AssemblyDatum & datum) const 43 : { 44 44892 : if (_u(datum, qp) <= _upper_bound - _v(datum, qp)) 45 33495 : return 1; 46 : 47 11397 : return 0; 48 : } 49 : 50 : KOKKOS_FUNCTION inline Real 51 60885 : KokkosUpperBoundNodalKernel::getOffDiagJacobian(const unsigned int jvar, 52 : const unsigned int qp, 53 : AssemblyDatum & datum) const 54 : { 55 60885 : if (jvar == _v_var) 56 44892 : if (_upper_bound - _v(datum, qp) < _u(datum, qp)) 57 11397 : return -1; 58 : 59 49488 : return 0; 60 : }