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 "ADGateValve1PhaseBC.h" 11 : #include "ADGateValve1PhaseUserObject.h" 12 : #include "THMIndicesVACE.h" 13 : #include "Assembly.h" 14 : 15 : registerMooseObject("ThermalHydraulicsApp", ADGateValve1PhaseBC); 16 : 17 : InputParameters 18 996 : ADGateValve1PhaseBC::validParams() 19 : { 20 996 : InputParameters params = ADOneDIntegratedBC::validParams(); 21 : 22 1992 : params.addRequiredParam<unsigned int>("connection_index", "Index of the connected flow channel"); 23 1992 : params.addRequiredParam<UserObjectName>("gate_valve_uo", "1-phase gate valve user object"); 24 : 25 1992 : params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental"); 26 1992 : params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear"); 27 : 28 1992 : params.addRequiredCoupledVar("rhoA", "Flow channel variable: rho*A"); 29 1992 : params.addRequiredCoupledVar("rhouA", "Flow channel variable: rho*u*A"); 30 1992 : params.addRequiredCoupledVar("rhoEA", "Flow channel variable: rho*E*A"); 31 : 32 996 : params.addClassDescription( 33 : "Adds boundary fluxes for flow channels connected to a 1-phase gate valve"); 34 : 35 996 : return params; 36 0 : } 37 : 38 540 : ADGateValve1PhaseBC::ADGateValve1PhaseBC(const InputParameters & params) 39 : : ADOneDIntegratedBC(params), 40 : 41 540 : _connection_index(getParam<unsigned int>("connection_index")), 42 540 : _gate_valve_uo(getUserObject<ADGateValve1PhaseUserObject>("gate_valve_uo")), 43 : 44 540 : _A_elem(adCoupledValue("A_elem")), 45 540 : _A_linear(adCoupledValue("A_linear")), 46 : 47 540 : _rhoA_jvar(coupled("rhoA")), 48 540 : _rhouA_jvar(coupled("rhouA")), 49 540 : _rhoEA_jvar(coupled("rhoEA")), 50 : 51 540 : _jvar_map(getIndexMapping()), 52 1620 : _equation_index(_jvar_map.at(_var.number())) 53 : { 54 540 : } 55 : 56 : ADReal 57 29460 : ADGateValve1PhaseBC::computeQpResidual() 58 : { 59 29460 : const auto & flux = _gate_valve_uo.getFlux(_connection_index); 60 : 61 : // Note that the ratio A_linear / A_elem is necessary because A_elem is passed 62 : // to the flux function, but A_linear is to be used on the boundary. 63 29460 : return flux[_equation_index] * _A_linear[_qp] / _A_elem[_qp] * _normal * _test[_i][_qp]; 64 : } 65 : 66 : std::map<unsigned int, unsigned int> 67 540 : ADGateValve1PhaseBC::getIndexMapping() const 68 : { 69 : std::map<unsigned int, unsigned int> jvar_map; 70 540 : jvar_map.insert(std::pair<unsigned int, unsigned int>(_rhoA_jvar, THMVACE1D::MASS)); 71 540 : jvar_map.insert(std::pair<unsigned int, unsigned int>(_rhouA_jvar, THMVACE1D::MOMENTUM)); 72 540 : jvar_map.insert(std::pair<unsigned int, unsigned int>(_rhoEA_jvar, THMVACE1D::ENERGY)); 73 : 74 540 : return jvar_map; 75 : }