17 #include "metaphysicl/parallel_numberarray.h" 18 #include "metaphysicl/parallel_dualnumber.h" 19 #include "metaphysicl/parallel_semidynamicsparsenumberarray.h" 20 #include "libmesh/parallel_algebra.h" 40 params.
addRequiredParam<UserObjectName>(
"fp",
"Fluid properties user object name");
45 params.
addParam<
bool>(
"apply_velocity_scaling",
47 "Set to true to apply the scaling to the normal velocity. See " 48 "documentation for more information.");
51 "Computes and caches flux and residual vectors for a 1-phase volume junction");
60 _A(adCoupledValue(
"A")),
61 _rhoA(adCoupledValue(
"rhoA")),
62 _rhouA(adCoupledValue(
"rhouA")),
63 _rhoEA(adCoupledValue(
"rhoEA")),
65 _K(getParam<
Real>(
"K")),
66 _A_ref(getParam<
Real>(
"A_ref")),
68 _apply_velocity_scaling(getParam<bool>(
"apply_velocity_scaling")),
103 const Real nJi_dot_di = -din;
123 const ADReal vJ = 1.0 / rhoJ;
125 const ADReal eJ = rhoEV / rhoV - 0.5 * uvecJ * uvecJ;
126 const ADReal pJ =
_fp.p_from_v_e(vJ, eJ);
132 const ADReal unJ = uvecJ * nJi;
133 const ADReal ut1J = uvecJ * t1;
134 const ADReal ut2J = uvecJ * t2;
138 const ADReal vi = 1.0 / rhoi;
140 const ADReal ci =
_fp.c_from_v_e(vi, ei);
141 const ADReal cJ =
_fp.c_from_v_e(vJ, eJ);
142 const ADReal cmax = std::max(ci, cJ);
144 const ADReal uni_sign = (uni > 0) - (uni < 0);
145 const ADReal factor = 0.5 * (1.0 - uni_sign) * std::min(std::abs(uni - unJ) / cmax, 1.0);
147 const ADReal unJ_mod = uni - factor * (uni - unJ);
149 const ADReal EJ_mod = eJ + 0.5 * uvecJ_mod * uvecJ_mod;
173 if (
c == 0 && std::abs(
_K) > 1e-10)
179 const ADReal p_in =
_fp.p_from_v_e(v_in, e_in);
180 const ADReal s0_in =
_fp.s_from_v_e(v_in, e_in);
181 const ADReal T_in =
_fp.T_from_v_e(v_in, e_in);
182 const ADReal h_in =
_fp.h_from_p_T(p_in, T_in);
183 const ADReal velin2 = vel_in * vel_in;
184 const ADReal h0_in = h_in + 0.5 * velin2;
185 const ADReal p0_in =
_fp.p_from_h_s(h0_in, s0_in);
188 S_loss =
_K * (p0_in - p_in) *
_A[0];
190 S_loss =
_K * (p0_in - p_in) *
_A_ref;
const ADVariableValue & _rhoA
rho*A of the connected flow channels
std::vector< std::vector< ADReal > > _flux
Cached flux vector for each connection.
static InputParameters validParams()
const unsigned int & _current_side
std::vector< ADReal > _cached_junction_var_values
void v_from_rhoA_A(Real rhoA, Real A, Real &v, Real &dv_drhoA)
Computes specific volume and its derivatives from rho*A, and area.
std::vector< std::string > _scalar_variable_names
Vector of coupled variable names for each scalar variable.
static InputParameters validParams()
const SinglePhaseFluidProperties & _fp
Single-phase fluid properties user object.
const Parallel::Communicator & comm() const
virtual void finalize() override
virtual void computeFluxesAndResiduals(const unsigned int &c) override
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
unsigned int _n_scalar_eq
Number of scalar residual components.
const unsigned int _n_connections
Number of connected flow channels.
const std::vector< UserObjectName > & _numerical_flux_names
Names of numerical flux user objects for each connected flow channel.
std::vector< ADReal > _residual
Cached scalar residual vector.
const Real & _volume
Volume of the junction.
std::vector< const ADNumericalFlux3EqnBase * > _numerical_flux_uo
Vector of numerical flux user objects for each connected flow channel.
std::vector< const ADVariableValue * > _junction_var_values
ADVolumeJunction1PhaseUserObject(const InputParameters ¶ms)
std::vector< std::string > _flow_variable_names
Vector of coupled variable names for each flow variable.
const MaterialProperty< RealVectorValue > & _dir
Direction of the element connected to the junction.
static const unsigned int N_EQ
Number of equations for the junction.
const Real & _A_ref
Reference area.
const ADVariableValue & _rhoEA
rho*E*A of the connected flow channels
Common class for single phase fluid properties.
Base class for computing and caching flux and residual vectors for a volume junction.
Computes and caches flux and residual vectors for a 1-phase volume junction.
const Real & _K
Form loss coefficient.
virtual void finalize() override
static const unsigned int N_FLUX_OUTPUTS
Number of numerical flux function outputs for 1D.
void computeOrthogonalDirections(const RealVectorValue &n_unnormalized, RealVectorValue &t1, RealVectorValue &t2)
Computes two unit vectors orthogonal to the given vector.
const ADVariableValue & _A
Cross-sectional area of connected flow channels.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool isInlet(Real vel, Real normal)
Determine if inlet boundary condition should be applied.
const std::vector< Real > & _normal
Flow channel outward normals or junction inward normals.
registerMooseObject("ThermalHydraulicsApp", ADVolumeJunction1PhaseUserObject)
const Elem *const & _current_elem
const bool _apply_velocity_scaling
Apply velocity scaling?
const ADVariableValue & _rhouA
rho*u*A of the connected flow channels
const ADVariableValue & coupledJunctionValue(const std::string &var_name, unsigned int i=0) const
Gets an AD junction variable value.
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 3D.