LCOV - code coverage report
Current view: top level - src/postprocessors - RayleighNumber.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 35 38 92.1 %
Date: 2025-08-14 10:14:56 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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 "RayleighNumber.h"
      11             : 
      12             : registerMooseObject("NavierStokesApp", RayleighNumber);
      13             : 
      14             : InputParameters
      15          76 : RayleighNumber::validParams()
      16             : {
      17          76 :   InputParameters params = GeneralPostprocessor::validParams();
      18             : 
      19          76 :   params.addClassDescription("Postprocessor that computes the Rayleigh number for free flow with "
      20             :                              "natural circulation");
      21             : 
      22             :   // Compute it from a density change
      23         152 :   params.addRequiredParam<PostprocessorName>("rho_ave", "Average density");
      24         152 :   params.addParam<PostprocessorName>("rho_min", "Minimum density");
      25         152 :   params.addParam<PostprocessorName>("rho_max", "Maximum density");
      26             : 
      27             :   // Compute it from a temperature change
      28         152 :   params.addParam<PostprocessorName>("beta",
      29             :                                      "Absolute value of fluid volumetric expansion coefficient");
      30         152 :   params.addParam<PostprocessorName>("T_hot", "Maximum temperature, or hot source temperature");
      31         152 :   params.addParam<PostprocessorName>("T_cold", "Minimum temperature, or cold source temperature");
      32             : 
      33         152 :   params.addRequiredParam<PostprocessorName>("l", "Characteristic distance");
      34         152 :   params.addRequiredParam<PostprocessorName>("mu_ave", "Average value of the dynamic viscosity");
      35         152 :   params.addRequiredParam<PostprocessorName>("k_ave", "Average value of the thermal conductivity");
      36         152 :   params.addRequiredParam<PostprocessorName>("cp_ave",
      37             :                                              "Average value of the specific thermal capacity");
      38         152 :   params.addRequiredParam<Real>("gravity_magnitude",
      39             :                                 "Gravity vector magnitude in the direction of interest");
      40             : 
      41          76 :   return params;
      42           0 : }
      43             : 
      44          38 : RayleighNumber::RayleighNumber(const InputParameters & parameters)
      45             :   : GeneralPostprocessor(parameters),
      46          57 :     _rho_min(isParamValid("rho_min") ? &getPostprocessorValue("rho_min") : nullptr),
      47          95 :     _rho_max(isParamValid("rho_max") ? &getPostprocessorValue("rho_max") : nullptr),
      48          38 :     _rho_ave(getPostprocessorValue("rho_ave")),
      49          95 :     _beta(isParamValid("beta") ? &getPostprocessorValue("beta") : nullptr),
      50          95 :     _T_hot(isParamValid("T_hot") ? &getPostprocessorValue("T_hot") : nullptr),
      51          95 :     _T_cold(isParamValid("T_cold") ? &getPostprocessorValue("T_cold") : nullptr),
      52          38 :     _l(getPostprocessorValue("l")),
      53          38 :     _mu(getPostprocessorValue("mu_ave")),
      54          38 :     _k(getPostprocessorValue("k_ave")),
      55          38 :     _cp(getPostprocessorValue("cp_ave")),
      56         114 :     _gravity(getParam<Real>("gravity_magnitude"))
      57             : {
      58             :   // Check that enough information has been given
      59          38 :   if ((!_rho_ave || !_rho_min || !_rho_max) && (!_rho_ave || !_beta || !_T_hot || !_T_cold))
      60           0 :     mooseError("To compute the density difference for the Rayleigh number, the density "
      61             :                "min/max/average or the expansion coefficient and the temperature min/max "
      62             :                "must be provided.");
      63          38 : }
      64             : 
      65             : Real
      66         282 : RayleighNumber::getValue() const
      67             : {
      68             :   Real drho;
      69         282 :   if (_rho_min)
      70         141 :     drho = *_rho_max - *_rho_min;
      71             :   else
      72         141 :     drho = *_beta * (*_T_hot - *_T_cold) * _rho_ave;
      73             : 
      74         282 :   if (_mu <= 0 || _k <= 0 || _rho_ave <= 0)
      75           0 :     mooseError("Average viscosity, density and thermal conductivity should be strictly positive");
      76             : 
      77         282 :   return drho * std::pow(_l, 3) * _gravity * _cp * _rho_ave / (_mu * _k);
      78             : }

Generated by: LCOV version 1.14