https://mooseframework.inl.gov
ADGateValve1PhaseBC.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 
10 #include "ADGateValve1PhaseBC.h"
12 #include "THMIndicesVACE.h"
13 #include "Assembly.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", ADGateValve1PhaseBC);
16 
19 {
21 
22  params.addRequiredParam<unsigned int>("connection_index", "Index of the connected flow channel");
23  params.addRequiredParam<UserObjectName>("gate_valve_uo", "1-phase gate valve user object");
24 
25  params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental");
26  params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
27 
28  params.addRequiredCoupledVar("rhoA", "Flow channel variable: rho*A");
29  params.addRequiredCoupledVar("rhouA", "Flow channel variable: rho*u*A");
30  params.addRequiredCoupledVar("rhoEA", "Flow channel variable: rho*E*A");
31 
32  params.addClassDescription(
33  "Adds boundary fluxes for flow channels connected to a 1-phase gate valve");
34 
35  return params;
36 }
37 
39  : ADOneDIntegratedBC(params),
40 
41  _connection_index(getParam<unsigned int>("connection_index")),
42  _gate_valve_uo(getUserObject<ADGateValve1PhaseUserObject>("gate_valve_uo")),
43 
44  _A_elem(adCoupledValue("A_elem")),
45  _A_linear(adCoupledValue("A_linear")),
46 
47  _rhoA_jvar(coupled("rhoA")),
48  _rhouA_jvar(coupled("rhouA")),
49  _rhoEA_jvar(coupled("rhoEA")),
50 
51  _jvar_map(getIndexMapping()),
52  _equation_index(_jvar_map.at(_var.number()))
53 {
54 }
55 
56 ADReal
58 {
59  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  return flux[_equation_index] * _A_linear[_qp] / _A_elem[_qp] * _normal * _test[_i][_qp];
64 }
65 
66 std::map<unsigned int, unsigned int>
68 {
69  std::map<unsigned int, unsigned int> jvar_map;
70  jvar_map.insert(std::pair<unsigned int, unsigned int>(_rhoA_jvar, THMVACE1D::MASS));
71  jvar_map.insert(std::pair<unsigned int, unsigned int>(_rhouA_jvar, THMVACE1D::MOMENTUM));
72  jvar_map.insert(std::pair<unsigned int, unsigned int>(_rhoEA_jvar, THMVACE1D::ENERGY));
73 
74  return jvar_map;
75 }
const ADVariableValue & _A_elem
Cross-sectional area, elemental.
Gate valve user object for 1-phase flow.
std::map< unsigned int, unsigned int > getIndexMapping() const
Creates mapping of coupled variable index to local equation system index.
ADGateValve1PhaseBC(const InputParameters &params)
const unsigned int _rhouA_jvar
rho*u*A coupled variable index
registerMooseObject("ThermalHydraulicsApp", ADGateValve1PhaseBC)
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _qp
const unsigned int _rhoA_jvar
rho*A coupled variable index
const unsigned int _equation_index
Index within local system of the equation upon which this object acts.
const ADGateValve1PhaseUserObject & _gate_valve_uo
1-phase gate valve user object
const unsigned int _rhoEA_jvar
rho*E*A coupled variable index
static InputParameters validParams()
const std::vector< ADReal > & getFlux(const unsigned int &connection_index) const override
Gets the flux vector for a connection.
const unsigned int _connection_index
Index of connected flow channel.
static InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const ADTemplateVariableTestValue< T > & _test
Adds boundary fluxes for flow channels connected to a 1-phase gate valve.
virtual ADReal computeQpResidual() override
void addClassDescription(const std::string &doc_string)
const Real _normal
Component of outward normals along 1-D direction.
Base class for integrated boundary conditions for 1D problems in 3D space.
void ErrorVector unsigned int
const ADVariableValue & _A_linear
Cross-sectional area, linear.