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 9352 : VolumeJunction1PhaseIC::validParams() 18 : { 19 9352 : InputParameters params = InitialCondition::validParams(); 20 18704 : MooseEnum quantity("rhoV rhouV rhovV rhowV rhoEV p T vel"); 21 18704 : params.addRequiredParam<MooseEnum>("quantity", quantity, "Which quantity to compute"); 22 18704 : params.addRequiredParam<FunctionName>("initial_p", "Initial pressure [Pa]"); 23 18704 : params.addRequiredParam<FunctionName>("initial_T", "Initial temperature [K]"); 24 18704 : params.addRequiredParam<FunctionName>("initial_vel_x", "Initial velocity in x-direction [m/s]"); 25 18704 : params.addRequiredParam<FunctionName>("initial_vel_y", "Initial velocity in y-direction [m/s]"); 26 18704 : params.addRequiredParam<FunctionName>("initial_vel_z", "Initial velocity in z-direction [m/s]"); 27 18704 : params.addRequiredParam<Real>("volume", "Volume of the junction [m^3]"); 28 18704 : params.addRequiredParam<Point>("position", "Spatial position of the center of the junction [m]"); 29 18704 : params.addRequiredParam<UserObjectName>("fluid_properties", "SinglePhaseFluidProperties object"); 30 9352 : params.addClassDescription("IC for junction variables in VolumeJunction1Phase."); 31 9352 : return params; 32 9352 : } 33 : 34 4976 : VolumeJunction1PhaseIC::VolumeJunction1PhaseIC(const InputParameters & parameters) 35 : : InitialCondition(parameters), 36 4976 : _quantity(getParam<MooseEnum>("quantity").getEnum<Quantity>()), 37 4976 : _p_fn(getFunction("initial_p")), 38 4976 : _T_fn(getFunction("initial_T")), 39 4976 : _vel_x_fn(getFunction("initial_vel_x")), 40 4976 : _vel_y_fn(getFunction("initial_vel_y")), 41 4976 : _vel_z_fn(getFunction("initial_vel_z")), 42 9952 : _volume(getParam<Real>("volume")), 43 9952 : _position(getParam<Point>("position")), 44 9952 : _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")) 45 : { 46 4976 : } 47 : 48 : Real 49 2712 : VolumeJunction1PhaseIC::value(const Point & /*p*/) 50 : { 51 2712 : const Real p = _p_fn.value(_t, _position); 52 2712 : const Real T = _T_fn.value(_t, _position); 53 2712 : const Real vel_x = _vel_x_fn.value(_t, _position); 54 2712 : const Real vel_y = _vel_y_fn.value(_t, _position); 55 2712 : const Real vel_z = _vel_z_fn.value(_t, _position); 56 : 57 2712 : const Real rho = _fp.rho_from_p_T(p, T); 58 : const RealVectorValue vel(vel_x, vel_y, vel_z); 59 2712 : const Real E = _fp.e_from_p_rho(p, rho) + 0.5 * vel * vel; 60 : 61 2712 : switch (_quantity) 62 : { 63 339 : case Quantity::RHOV: 64 339 : return rho * _volume; 65 : break; 66 339 : case Quantity::RHOUV: 67 339 : return rho * vel_x * _volume; 68 : break; 69 339 : case Quantity::RHOVV: 70 339 : return rho * vel_y * _volume; 71 : break; 72 339 : case Quantity::RHOWV: 73 339 : return rho * vel_z * _volume; 74 : break; 75 339 : case Quantity::RHOEV: 76 339 : return rho * E * _volume; 77 : break; 78 : case Quantity::P: 79 : return p; 80 : break; 81 339 : case Quantity::T: 82 339 : return T; 83 : break; 84 339 : case Quantity::VEL: 85 339 : return vel.norm(); 86 : break; 87 0 : default: 88 0 : mooseError("Invalid 'quantity' parameter."); 89 : } 90 : }