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