16#include "metaphysicl/parallel_numberarray.h"
17#include "metaphysicl/parallel_dualnumber.h"
18#include "metaphysicl/parallel_semidynamicsparsenumberarray.h"
19#include "libmesh/parallel_algebra.h"
23const std::vector<std::pair<std::string, unsigned int>>
38 "A_elem",
"Piecewise constant cross-sectional area of connected flow channels");
40 "Piecewise linear cross-sectional area of connected flow channels");
46 "Name of fluid properties user object");
48 params.
addRequiredParam<UserObjectName>(
"numerical_flux",
"Numerical flux user object name");
50 params.
addRequiredParam<std::string>(
"junction_name",
"Name of the junction component");
53 "Computes flux between two subdomains for 1-phase one-to-one junction");
63 _A_linear(adCoupledValue(
"A_linear")),
65 _A_var(getVar(
"A_elem", 0)),
66 _rhoA_var(getVar(
"rhoA", 0)),
67 _rhouA_var(getVar(
"rhouA", 0)),
68 _rhoEA_var(getVar(
"rhoEA", 0)),
74 _junction_name(getParam<
std::string>(
"junction_name")),
76 _dir(getMaterialProperty<RealVectorValue>(
"direction")),
78 _primitive_solutions(_n_connections),
79 _neighbor_primitive_solutions(_n_connections),
81 _fluxes(_n_connections),
82 _dof_indices(_n_connections,
std::vector<dof_id_type>(
THMVACE1D::N_FLUX_OUTPUTS, 0)),
84 _elem_ids(_n_connections),
85 _local_side_ids(_n_connections),
87 _areas_linear(_n_connections),
88 _directions(_n_connections),
89 _positions(_n_connections),
90 _neighbor_positions(_n_connections),
91 _delta_x(_n_connections),
92 _has_neighbor(_n_connections)
127 mooseAssert(dofs.size() == 1,
"There should be only one DoF index.");
141 std::vector<std::vector<GenericReal<true>>> W_neighbor;
142 std::vector<Point> x_neighbor;
144 if (W_neighbor.size() == 1)
170 for (
unsigned int i = 0; i < junction_uo._connection_indices.size(); i++)
215 auto W0_ref = W0_avg;
216 auto W1_ref = W1_avg;
220 std::vector<std::vector<GenericReal<true>>> W_neighbor0;
221 std::vector<Point> x_neighbor0;
228 std::vector<std::vector<GenericReal<true>>> W_neighbor1;
229 std::vector<Point> x_neighbor1;
245 W0[m] = W0_avg[m] + slopes0[m] *
_delta_x[0];
246 W1[m] = W1_avg[m] + slopes1[m] *
_delta_x[1];
250 FlowModel1PhaseUtils::computeConservativeSolutionVector<true>(W0,
_areas_linear[0],
_fp);
252 FlowModel1PhaseUtils::computeConservativeSolutionVector<true>(W1,
_areas_linear[1],
_fp);
262const std::vector<ADReal> &
265 Threads::spin_mutex::scoped_lock lock(
_spin_mutex);
267 return _fluxes[connection_index];
275 return FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U,
_fp);
registerMooseObject("ThermalHydraulicsApp", ADJunctionOneToOne1PhaseUserObject)
DualNumber< Real, DNDerivativeType, true > ADReal
Provides common interfaces for flow junction user objects.
unsigned int getBoundaryIDIndex()
Gets the index of the currently executing boundary within the vector of boundary IDs given to this Si...
static InputParameters validParams()
std::vector< unsigned int > _processor_ids
Owners of each side of the junction.
const unsigned int _n_connections
Number of connected flow channels.
const std::vector< Real > & _normal
Flow channel outward normals or junction inward normals.
Computes flux between two subdomains for 1-phase one-to-one junction.
std::vector< MooseVariable * > _U_vars
Conservative solution variables.
virtual void execute() override
std::vector< unsigned int > _local_side_ids
Local side IDs for each connection.
static const std::vector< std::pair< std::string, unsigned int > > _varname_eq_index_pairs
Pairs of variable names vs. their corresponding equation indices.
const ADVariableValue & _A_linear
Piecewise linear cross-sectional area of connected flow channels.
const MaterialProperty< RealVectorValue > & _dir
Direction material property.
MooseVariable * _rhouA_var
static InputParameters validParams()
virtual void finalize() override
std::vector< std::vector< ADReal > > _primitive_solutions
Primitive solution vectors for each connection.
virtual std::vector< ADReal > computeElementPrimitiveVariables(const Elem *elem) const override
Computes the cell-average primitive variable values for an element.
std::vector< Point > _neighbor_positions
Positions at each connection's neighbor.
std::vector< bool > _has_neighbor
Flags for each connection having a neighbor.
MooseVariable * _rhoEA_var
std::vector< std::vector< dof_id_type > > _dof_indices
Degree of freedom indices; first index is connection, second is equation.
std::vector< ADReal > _areas_linear
Piecewise linear areas at each connection.
ADJunctionOneToOne1PhaseUserObject(const InputParameters ¶ms)
static Threads::spin_mutex _spin_mutex
Thread lock.
const SinglePhaseFluidProperties & _fp
fluid properties user object
std::vector< unsigned int > _elem_ids
Element IDs for each connection.
std::vector< unsigned int > _connection_indices
Connection indices for this thread.
std::vector< Point > _positions
Positions at each connection.
virtual void threadJoin(const UserObject &uo) override
std::vector< Real > _delta_x
Position changes for each connection.
std::vector< std::vector< ADReal > > _neighbor_primitive_solutions
Primitive solution vectors for each connection's neighbor.
std::vector< RealVectorValue > _directions
Directions at each connection.
std::vector< std::vector< ADReal > > _fluxes
Flux vector.
const ADNumericalFlux3EqnBase & _numerical_flux
Numerical flux user object.
const std::vector< ADReal > & getFlux(const unsigned int &connection_index) const override
Gets the flux vector for a connection.
MooseVariable * _rhoA_var
virtual void initialize() override
Base class for computing numerical fluxes for FlowModelSinglePhase.
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
const std::vector< dof_id_type > & dofIndices() const final
virtual const std::vector< ADReal > & getFlux(const unsigned int iside, const dof_id_type ielem, bool res_side_is_left, const std::vector< ADReal > &UL_1d, const std::vector< ADReal > &UR_1d, Real nLR_dot_d) const
Gets the 1D flux vector for an element/side combination.
const unsigned int & _current_side
const MooseArray< Point > & _q_point
const Elem *const & _current_elem
Common class for single phase fluid properties.
Interface class for 1-D slope reconstruction.
virtual void getNeighborPrimitiveVariables(const Elem *elem, std::vector< std::vector< GenericReal< is_ad > > > &W_neighbor, std::vector< Point > &x_neighbor) const
Gets the primitive solution vector and position of neighbor(s)
std::vector< GenericReal< is_ad > > getBoundaryElementSlopes(const std::vector< GenericReal< is_ad > > &W_elem, const Point &x_elem, const RealVectorValue &dir, std::vector< std::vector< GenericReal< is_ad > > > W_neighbor, std::vector< Point > x_neighbor, const std::vector< GenericReal< is_ad > > &W_boundary) const
Gets limited slopes for the primitive variables in the 1-D direction for boundary element.
static InputParameters validParams()
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const Parallel::Communicator & comm() const
static const unsigned int N_PRIM_VARS
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.