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 "ThermalConductivity.h" 11 : 12 : registerMooseObject("HeatTransferApp", ThermalConductivity); 13 : 14 : InputParameters 15 0 : ThermalConductivity::validParams() 16 : { 17 0 : InputParameters params = SideAverageValue::validParams(); 18 0 : params.addRequiredParam<Real>("dx", "Length between sides of sample in length_scale"); 19 0 : params.addRequiredParam<PostprocessorName>( 20 : "flux", "Heat flux out of 'cold' boundary in solution units, should always be positive"); 21 0 : params.addRequiredParam<PostprocessorName>("T_hot", "Temperature on 'hot' boundary in K"); 22 0 : params.addParam<Real>("length_scale", 1e-8, "Length scale of the solution, default is 1e-8"); 23 0 : params.addParam<Real>("k0", 0.0, "Initial value of the thermal conductivity"); 24 0 : params.addClassDescription("Computes the effective thermal conductivity averaged on a boundary."); 25 0 : return params; 26 0 : } 27 : 28 0 : ThermalConductivity::ThermalConductivity(const InputParameters & parameters) 29 : : SideAverageValue(parameters), 30 0 : _dx(getParam<Real>("dx")), 31 0 : _flux(getPostprocessorValue("flux")), 32 0 : _T_hot(getPostprocessorValue("T_hot")), 33 0 : _length_scale(getParam<Real>("length_scale")), 34 0 : _k0(getParam<Real>("k0")), 35 0 : _step_zero(declareRestartableData<bool>("step_zero", true)), 36 0 : _value(0.0) 37 : { 38 0 : } 39 : 40 : void 41 0 : ThermalConductivity::finalize() 42 : { 43 0 : SideAverageValue::finalize(); 44 : 45 0 : const Real T_cold = _integral_value / _volume; 46 : Real Th_cond = 0.0; 47 0 : if (_t_step >= 1) 48 0 : _step_zero = false; 49 : 50 : // Calculate effective thermal conductivity in W/(length_scale-K) 51 0 : if (std::abs(_T_hot - T_cold) > 1.0e-20) 52 0 : Th_cond = std::abs(_flux) * _dx / std::abs(_T_hot - T_cold); 53 : 54 0 : if (_step_zero) 55 0 : _value = _k0; 56 : else 57 0 : _value = Th_cond / _length_scale; // In W/(m-K) 58 0 : } 59 : 60 : Real 61 0 : ThermalConductivity::getValue() const 62 : { 63 0 : return _value; 64 : }