https://mooseframework.inl.gov
Normalized1PhaseResidualNorm.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 
12 #include "Function.h"
13 
14 registerMooseObject("ThermalHydraulicsApp", Normalized1PhaseResidualNorm);
15 
18 {
20 
21  params.addClassDescription(
22  "Computes a normalized residual norm for the single-phase flow model.");
23 
24  params.addRequiredParam<Real>("p_ref", "Reference pressure [Pa]");
25  params.addRequiredParam<Real>("T_ref", "Reference temperature [K]");
26  params.addRequiredParam<Real>("vel_ref", "Reference velocity [m/s]");
27  params.addRequiredParam<FunctionName>("A", "Cross-sectional area function [m^2]");
28  params.addRequiredParam<Point>("point",
29  "Point at which to evaluate cross-sectional area function [m]");
30  params.addRequiredParam<UserObjectName>("fluid_properties",
31  "Single-phase fluid properties object");
32  params.addRequiredParam<Real>("min_elem_size", "Minimum element size on block [m]");
33 
34  return params;
35 }
36 
38  : DiscreteVariableResidualNorm(parameters), _initialized(false)
39 {
40 }
41 
42 void
44 {
46 
47  // This cannot be done in constructor or initialSetup() due to some fluid
48  // properties not being initialized yet.
49  if (!_initialized)
50  {
52  _initialized = true;
53  }
54 }
55 
56 Real
58 {
59  const auto h_min = getParam<Real>("min_elem_size");
60 
61  const auto & A_fn = getFunction("A");
62  const auto & point = getParam<Point>("point");
63  const auto A_ref = A_fn.value(0.0, point);
64 
65  const auto p_ref = getParam<Real>("p_ref");
66  const auto T_ref = getParam<Real>("T_ref");
67  const auto vel_ref = getParam<Real>("vel_ref");
68 
69  const auto & fp = getUserObject<SinglePhaseFluidProperties>("fluid_properties");
70  const auto rho_ref = fp.rho_from_p_T(p_ref, T_ref);
71 
72  const auto variable = getParam<VariableName>("variable");
73  if (variable == "rhoA")
74  return rho_ref * A_ref * h_min;
75  else if (variable == "rhouA")
76  return rho_ref * vel_ref * A_ref * h_min;
77  else if (variable == "rhoEA")
78  {
79  const auto e_ref = fp.e_from_p_T(p_ref, T_ref);
80  const auto E_ref = e_ref + 0.5 * vel_ref * vel_ref;
81  return rho_ref * E_ref * A_ref * h_min;
82  }
83  else
84  mooseError("The 'variable' parameter must be one of the following: {rhoA, rhouA, rhoEA}.");
85 }
86 
87 Real
89 {
91 }
virtual PostprocessorValue getValue() const override
Computes a normalized residual norm for the mass, momentum, or energy equation for a flow channel...
const Function & getFunction(const std::string &name) const
Real computeNormalization() const
Computes (but does not update) the normalization constant.
registerMooseObject("ThermalHydraulicsApp", Normalized1PhaseResidualNorm)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
Normalized1PhaseResidualNorm(const InputParameters &parameters)
virtual Real getValue() const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real _normalization
Normalization constant.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
virtual void initialize() override