https://mooseframework.inl.gov
AverageWallTemperature3EqnMaterial.C
Go to the documentation of this file.
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 
11 
13 
16 {
18 
19  params.addClassDescription(
20  "Weighted average wall temperature from multiple sources for 1-phase flow");
21 
22  params.addRequiredCoupledVar("T_wall_sources",
23  "Vector of wall temperatures from individual sources");
24  params.addRequiredParam<std::vector<MaterialPropertyName>>(
25  "Hw_sources", "Vector of wall heat transfer coefficients from individual sources");
26  params.addRequiredCoupledVar("P_hf_sources",
27  "Vector of heated perimeters from individual sources");
28  params.addRequiredCoupledVar("T_fluid", "Fluid temperature");
29  params.addRequiredCoupledVar("P_hf_total", "Total heat flux perimeter from all sources");
30 
31  return params;
32 }
33 
35  const InputParameters & parameters)
36  : Material(parameters),
37  _T_wall(declareProperty<Real>("T_wall")),
38  _n_values(coupledComponents("T_wall_sources")),
39  _T_fluid(coupledValue("T_fluid")),
40  _P_hf_total(coupledValue("P_hf_total"))
41 {
42  // make sure that numbers of values are consistent
43  if (getParam<std::vector<MaterialPropertyName>>("Hw_sources").size() != _n_values)
44  mooseError(name(),
45  ": The number of wall heat transfer coefficient values"
46  " must equal the number of wall temperature values");
47  if (coupledComponents("P_hf_sources") != _n_values)
48  mooseError(name(),
49  ": The number of heated perimeter values"
50  " must equal the number of wall temperature values");
51 
52  // get all of the variable values
53  const std::vector<MaterialPropertyName> & Hw_prop_names =
54  getParam<std::vector<MaterialPropertyName>>("Hw_sources");
55  for (unsigned int i = 0; i < _n_values; i++)
56  {
57  _T_wall_sources.push_back(&coupledValue("T_wall_sources", i));
58  _Hw_sources.push_back(&getMaterialProperty<Real>(Hw_prop_names[i]));
59  _P_hf_sources.push_back(&coupledValue("P_hf_sources", i));
60  }
61 }
62 
63 void
65 {
66  Real denominator = 0;
67  for (unsigned int i = 0; i < _n_values; i++)
68  denominator += (*(_Hw_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
69 
70  if (std::abs(denominator) < 1e-15)
71  {
72  // use alternate definition to avoid division by zero: heated-perimeter-weighted average
73  Real numerator = 0;
74  for (unsigned int i = 0; i < _n_values; i++)
75  numerator += (*(_T_wall_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
76  _T_wall[_qp] = numerator / _P_hf_total[_qp];
77  }
78  else
79  {
80  // use normal definition
81  Real numerator = 0;
82  for (unsigned int i = 0; i < _n_values; i++)
83  numerator += (*(_Hw_sources[i]))[_qp] * ((*(_T_wall_sources[i]))[_qp] - _T_fluid[_qp]) *
84  (*(_P_hf_sources[i]))[_qp];
85  _T_wall[_qp] = _T_fluid[_qp] + numerator / denominator;
86  }
87 }
std::vector< const VariableValue * > _T_wall_sources
Wall temperature values from the individual sources to average.
AverageWallTemperature3EqnMaterial(const InputParameters &parameters)
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
unsigned int _qp
std::vector< const VariableValue * > _P_hf_sources
Heated perimeter values from the individual sources to average.
static InputParameters validParams()
const T & getParam(const std::string &name) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int coupledComponents(const std::string &var_name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MaterialProperty< Real > & _T_wall
Average wall temperature.
const unsigned int _n_values
Number of values to average.
registerMooseObject("ThermalHydraulicsApp", AverageWallTemperature3EqnMaterial)
Weighted average of wall temperature between multiple heat sources to preserve total wall heat...
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
const VariableValue & _T_fluid
Fluid temperature.
std::vector< const MaterialProperty< Real > * > _Hw_sources
Wall heat transfer coefficient values from the individual sources to average.
const VariableValue & _P_hf_total
Total heated perimeter.