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 "MaterialPropertyValue.h" 11 : 12 : registerMooseObject("MooseApp", MaterialPropertyValue); 13 : registerMooseObject("MooseApp", ADMaterialPropertyValue); 14 : 15 : template <bool is_ad> 16 : InputParameters 17 28555 : MaterialPropertyValueTempl<is_ad>::validParams() 18 : { 19 28555 : InputParameters params = KernelValueParent<is_ad>::validParams(); 20 28555 : params.addClassDescription( 21 : "Residual term (u - prop) to set variable u equal to a given material property prop"); 22 28555 : params.addRequiredParam<MaterialPropertyName>( 23 : "prop_name", "Name of material property to be used in the kernel"); 24 85665 : params.addParam<bool>( 25 57110 : "positive", true, "If the kernel is positive, this is true, if negative, it is false"); 26 28555 : return params; 27 0 : } 28 : 29 : template <bool is_ad> 30 13 : MaterialPropertyValueTempl<is_ad>::MaterialPropertyValueTempl(const InputParameters & parameters) 31 : : KernelValueParent<is_ad>(parameters), 32 13 : _kernel_sign(this->template getParam<bool>("positive") ? 1.0 : -1.0), 33 26 : _prop(this->template getGenericMaterialProperty<Real, is_ad>("prop_name")) 34 : { 35 13 : } 36 : 37 : template <> 38 : Real 39 102600 : MaterialPropertyValueTempl<false>::precomputeQpResidual() 40 : { 41 102600 : return _kernel_sign * (_prop[_qp] - _u[_qp]); 42 : } 43 : 44 : template <> 45 : ADReal 46 0 : MaterialPropertyValueTempl<true>::precomputeQpResidual() 47 : { 48 0 : return _kernel_sign * (_prop[_qp] - _u[_qp]); 49 : } 50 : 51 : template <> 52 : Real 53 57600 : MaterialPropertyValueTempl<false>::precomputeQpJacobian() 54 : { 55 57600 : return -_kernel_sign * _phi[_j][_qp]; 56 : } 57 : 58 : template <> 59 : Real 60 0 : MaterialPropertyValueTempl<true>::precomputeQpJacobian() 61 : { 62 0 : mooseError("This should never get called"); 63 : } 64 : 65 : template class MaterialPropertyValueTempl<false>; 66 : template class MaterialPropertyValueTempl<true>;