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 : #include "PorousFlowExponentialDecay.h" 11 : 12 : #include "MooseVariable.h" 13 : 14 : registerMooseObject("PorousFlowApp", PorousFlowExponentialDecay); 15 : registerMooseObject("PorousFlowApp", ADPorousFlowExponentialDecay); 16 : 17 : template <bool is_ad> 18 : InputParameters 19 77 : PorousFlowExponentialDecayTempl<is_ad>::validParams() 20 : { 21 : InputParameters params = GenericKernel<is_ad>::validParams(); 22 90 : params.addCoupledVar("rate", 1.0, "Rate of exponential decay"); 23 90 : params.addCoupledVar("reference", 0.0, "Reference value of the variable"); 24 45 : params.addClassDescription("Residual = rate * (variable - reference). Useful for modelling " 25 : "exponential decay of a variable"); 26 45 : return params; 27 0 : } 28 : 29 : template <bool is_ad> 30 24 : PorousFlowExponentialDecayTempl<is_ad>::PorousFlowExponentialDecayTempl( 31 : const InputParameters & parameters) 32 : : GenericKernel<is_ad>(parameters), 33 24 : _rate(this->template coupledGenericValue<is_ad>("rate")), 34 48 : _reference(this->template coupledGenericValue<is_ad>("reference")) 35 : { 36 24 : } 37 : 38 : template <bool is_ad> 39 : GenericReal<is_ad> 40 2080 : PorousFlowExponentialDecayTempl<is_ad>::computeQpResidual() 41 : { 42 2656 : return _test[_i][_qp] * _rate[_qp] * (_u[_qp] - _reference[_qp]); 43 : } 44 : 45 : template <bool is_ad> 46 : Real 47 2240 : PorousFlowExponentialDecayTempl<is_ad>::computeQpJacobian() 48 : { 49 : if constexpr (!is_ad) 50 2240 : return _test[_i][_qp] * _rate[_qp] * _phi[_j][_qp]; 51 0 : return 0.0; 52 : } 53 : 54 : template class PorousFlowExponentialDecayTempl<false>; 55 : template class PorousFlowExponentialDecayTempl<true>;