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 "CoupledVariableValueMaterial.h" 11 : 12 : #include "metaphysicl/raw_type.h" 13 : 14 : registerMooseObject("ThermalHydraulicsApp", CoupledVariableValueMaterial); 15 : registerMooseObject("ThermalHydraulicsApp", ADCoupledVariableValueMaterial); 16 : 17 : template <bool is_ad> 18 : InputParameters 19 4091 : CoupledVariableValueMaterialTempl<is_ad>::validParams() 20 : { 21 4091 : InputParameters params = Material::validParams(); 22 8182 : params.addRequiredParam<MaterialPropertyName>( 23 : "prop_name", "The name of the material property where we store the variable values."); 24 8182 : params.addRequiredCoupledVar( 25 : "coupled_variable", "The coupled variable that will be stored into the material property"); 26 4091 : params.addClassDescription("Stores values of a variable into material properties"); 27 4091 : return params; 28 0 : } 29 : 30 : template <bool is_ad> 31 3216 : CoupledVariableValueMaterialTempl<is_ad>::CoupledVariableValueMaterialTempl( 32 : const InputParameters & parameters) 33 : : Material(parameters), 34 3216 : _prop_name(getParam<MaterialPropertyName>("prop_name")), 35 3216 : _prop(declareGenericProperty<Real, is_ad>(_prop_name)), 36 3216 : _value((!is_ad) ? coupledValue("coupled_variable") : _zero), 37 6432 : _ad_value((is_ad) ? adCoupledValue("coupled_variable") : _ad_zero) 38 : { 39 3216 : } 40 : 41 : template <bool is_ad> 42 : void 43 2884643 : CoupledVariableValueMaterialTempl<is_ad>::computeQpProperties() 44 : { 45 : if (is_ad) 46 2884643 : _prop[_qp] = MetaPhysicL::raw_value(_ad_value[_qp]); 47 : else 48 0 : _prop[_qp] = _value[_qp]; 49 2884643 : } 50 : 51 : template class CoupledVariableValueMaterialTempl<false>; 52 : template class CoupledVariableValueMaterialTempl<true>;