https://mooseframework.inl.gov
ADBoundaryFlux3EqnGhostMassFlowRateTemperature.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 
11 #include "THMIndicesVACE.h"
13 #include "Numerics.h"
14 #include "Function.h"
15 
17 
20 {
22 
23  params.addClassDescription(
24  "Computes a boundary flux from a specified mass flow rate and temperature for the 1-D, "
25  "1-phase, variable-area Euler equations using a ghost cell");
26 
27  params.addRequiredParam<Real>("mass_flow_rate", "Specified mass flow rate");
28  params.addRequiredParam<Real>("T", "Specified temperature");
29  params.addRequiredParam<std::vector<FunctionName>>(
30  "passives", "Specified passive transport functions [amount/m^3]");
31  params.addParam<bool>("reversible", true, "True for reversible, false for pure inlet");
32 
33  params.addRequiredParam<UserObjectName>("fluid_properties",
34  "Name of single-phase fluid properties user object");
35 
36  params.declareControllable("mass_flow_rate T");
37  return params;
38 }
39 
41  const InputParameters & parameters)
42  : ADBoundaryFlux3EqnGhostBase(parameters),
43 
44  _rhouA(getParam<Real>("mass_flow_rate")),
45  _T(getParam<Real>("T")),
46  _reversible(getParam<bool>("reversible")),
47  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
48 {
49  // get specified passive transport functions
50  const auto & passives = getParam<std::vector<FunctionName>>("passives");
51  _n_passives = passives.size();
52  _passives_fn.resize(_n_passives);
53  for (const auto i : make_range(_n_passives))
54  _passives_fn[i] = &getFunctionByName(passives[i]);
55 }
56 
57 std::vector<ADReal>
59  const Point & point) const
60 {
61  const ADReal rhoA = U[THMVACE1D::RHOA];
62  const ADReal rhouA = U[THMVACE1D::RHOUA];
63  const ADReal rhoEA = U[THMVACE1D::RHOEA];
64  const ADReal A = U[THMVACE1D::AREA];
65 
66  std::vector<ADReal> U_ghost(THMVACE1D::N_FLUX_INPUTS + _n_passives);
68  {
69  // Pressure is the only quantity coming from the interior
70  const ADReal rho = rhoA / A;
71  const ADReal vel = rhouA / rhoA;
72  const ADReal E = rhoEA / rhoA;
73  const ADReal e = E - 0.5 * vel * vel;
74  const ADReal p = _fp.p_from_v_e(1.0 / rho, e);
75 
76  const ADReal rho_b = _fp.rho_from_p_T(p, _T);
77  const ADReal vel_b = _rhouA / (rho_b * A);
78  const ADReal e_b = _fp.e_from_p_rho(p, rho_b);
79  const ADReal E_b = e_b + 0.5 * vel_b * vel_b;
80 
81  U_ghost[THMVACE1D::RHOA] = rho_b * A;
82  U_ghost[THMVACE1D::RHOUA] = _rhouA;
83  U_ghost[THMVACE1D::RHOEA] = rho_b * E_b * A;
84  U_ghost[THMVACE1D::AREA] = A;
85  for (const auto i : make_range(_n_passives))
86  U_ghost[THMVACE1D::N_FLUX_INPUTS + i] = _passives_fn[i]->value(_t, point) * A;
87  }
88  else
89  {
90  U_ghost[THMVACE1D::RHOA] = rhoA;
91  U_ghost[THMVACE1D::RHOUA] = _rhouA;
92  U_ghost[THMVACE1D::RHOEA] = rhoEA;
93  U_ghost[THMVACE1D::AREA] = A;
94  for (const auto i : make_range(_n_passives))
96  }
97 
98  return U_ghost;
99 }
static InputParameters validParams()
registerMooseObject("ThermalHydraulicsApp", ADBoundaryFlux3EqnGhostMassFlowRateTemperature)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Computes a boundary flux from a specified mass flow rate and temperature for the 1-D, 1-phase, variable-area Euler equations using a ghost cell.
const SinglePhaseFluidProperties & _fp
Fluid properties object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
const double rho
Computes boundary fluxes for the 1-D, variable-area Euler equations using a numerical flux user objec...
Common class for single phase fluid properties.
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.
unsigned int _n_passives
Number of passive transport variables.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Function & getFunctionByName(const FunctionName &name) const
bool isInlet(Real vel, Real normal)
Determine if inlet boundary condition should be applied.
Definition: Numerics.C:235
const Real p
IntRange< T > make_range(T beg, T end)
virtual std::vector< ADReal > getGhostCellSolution(const std::vector< ADReal > &U, const Point &point) const override
Gets the solution vector in the ghost cell.
void addClassDescription(const std::string &doc_string)
const Real & _normal
Outward normal.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
std::vector< const Function * > _passives_fn
Passive transport functions.