LCOV - code coverage report
Current view: top level - src/ics - VolumeJunction1PhaseIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 49 51 96.1 %
Date: 2025-07-30 13:02:48 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 "VolumeJunction1PhaseIC.h"
      11             : #include "Function.h"
      12             : #include "SinglePhaseFluidProperties.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", VolumeJunction1PhaseIC);
      15             : 
      16             : InputParameters
      17       18544 : VolumeJunction1PhaseIC::validParams()
      18             : {
      19       18544 :   InputParameters params = InitialCondition::validParams();
      20       37088 :   MooseEnum quantity("rhoV rhouV rhovV rhowV rhoEV p T vel");
      21       37088 :   params.addRequiredParam<MooseEnum>("quantity", quantity, "Which quantity to compute");
      22       37088 :   params.addRequiredParam<FunctionName>("initial_p", "Initial pressure [Pa]");
      23       37088 :   params.addRequiredParam<FunctionName>("initial_T", "Initial temperature [K]");
      24       37088 :   params.addRequiredParam<FunctionName>("initial_vel_x", "Initial velocity in x-direction [m/s]");
      25       37088 :   params.addRequiredParam<FunctionName>("initial_vel_y", "Initial velocity in y-direction [m/s]");
      26       37088 :   params.addRequiredParam<FunctionName>("initial_vel_z", "Initial velocity in z-direction [m/s]");
      27       37088 :   params.addRequiredParam<Real>("volume", "Volume of the junction [m^3]");
      28       37088 :   params.addRequiredParam<Point>("position", "Spatial position of the center of the junction [m]");
      29       37088 :   params.addRequiredParam<UserObjectName>("fluid_properties", "SinglePhaseFluidProperties object");
      30       18544 :   params.addClassDescription("IC for junction variables in VolumeJunction1Phase.");
      31       18544 :   return params;
      32       18544 : }
      33             : 
      34       10144 : VolumeJunction1PhaseIC::VolumeJunction1PhaseIC(const InputParameters & parameters)
      35             :   : InitialCondition(parameters),
      36       10144 :     _quantity(getParam<MooseEnum>("quantity").getEnum<Quantity>()),
      37       10144 :     _p_fn(getFunction("initial_p")),
      38       10144 :     _T_fn(getFunction("initial_T")),
      39       10144 :     _vel_x_fn(getFunction("initial_vel_x")),
      40       10144 :     _vel_y_fn(getFunction("initial_vel_y")),
      41       10144 :     _vel_z_fn(getFunction("initial_vel_z")),
      42       20288 :     _volume(getParam<Real>("volume")),
      43       20288 :     _position(getParam<Point>("position")),
      44       20288 :     _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
      45             : {
      46       10144 : }
      47             : 
      48             : Real
      49        4280 : VolumeJunction1PhaseIC::value(const Point & /*p*/)
      50             : {
      51        4280 :   const Real p = _p_fn.value(_t, _position);
      52        4280 :   const Real T = _T_fn.value(_t, _position);
      53        4280 :   const Real vel_x = _vel_x_fn.value(_t, _position);
      54        4280 :   const Real vel_y = _vel_y_fn.value(_t, _position);
      55        4280 :   const Real vel_z = _vel_z_fn.value(_t, _position);
      56             : 
      57        4280 :   const Real rho = _fp.rho_from_p_T(p, T);
      58             :   const RealVectorValue vel(vel_x, vel_y, vel_z);
      59        4280 :   const Real E = _fp.e_from_p_rho(p, rho) + 0.5 * vel * vel;
      60             : 
      61        4280 :   switch (_quantity)
      62             :   {
      63         535 :     case Quantity::RHOV:
      64         535 :       return rho * _volume;
      65             :       break;
      66         535 :     case Quantity::RHOUV:
      67         535 :       return rho * vel_x * _volume;
      68             :       break;
      69         535 :     case Quantity::RHOVV:
      70         535 :       return rho * vel_y * _volume;
      71             :       break;
      72         535 :     case Quantity::RHOWV:
      73         535 :       return rho * vel_z * _volume;
      74             :       break;
      75         535 :     case Quantity::RHOEV:
      76         535 :       return rho * E * _volume;
      77             :       break;
      78             :     case Quantity::P:
      79             :       return p;
      80             :       break;
      81         535 :     case Quantity::T:
      82         535 :       return T;
      83             :       break;
      84         535 :     case Quantity::VEL:
      85         535 :       return vel.norm();
      86             :       break;
      87           0 :     default:
      88           0 :       mooseError("Invalid 'quantity' parameter.");
      89             :   }
      90             : }

Generated by: LCOV version 1.14