13 #include "metaphysicl/parallel_numberarray.h" 14 #include "metaphysicl/parallel_dualnumber.h" 15 #include "metaphysicl/parallel_semidynamicsparsenumberarray.h" 16 #include "libmesh/parallel_algebra.h" 24 "use_scalar_variables",
true,
"True if the junction variables are scalar variables");
26 "junction_subdomain_id",
28 "Junction subdomain ID (required if 'use_scalar_variables' is 'false')");
32 "numerical_flux_names",
33 "The names of the user objects that compute the numerical flux at each flow channel.");
34 params.
addClassDescription(
"User object to compute fluxes and residuals for a volume junction");
40 _use_scalar_variables(getParam<bool>(
"use_scalar_variables")),
42 _volume(getParam<
Real>(
"volume")),
43 _numerical_flux_names(getParam<
std::vector<UserObjectName>>(
"numerical_flux_names"))
47 ": The number of supplied numerical flux objects '",
49 "' does not match the number of connections '",
54 mooseError(
"If 'use_scalar_variables' is set to false, 'junction_subdomain_id' is required.");
105 auto && dofs = junction_vars[i]->dofIndices();
106 mooseAssert(dofs.size() == 1,
107 "There should be exactly 1 coupled DoF index for the variable '" +
108 junction_vars[i]->name() +
"'.");
124 auto && dofs = junction_vars[i]->dofIndices();
125 mooseAssert(dofs.size() == 1,
126 "There should be exactly 1 coupled DoF index for the variable '" +
127 junction_vars[i]->name() +
"'.");
147 for (
unsigned int k = 0;
k < dofs.size();
k++)
167 for (
unsigned int i = 0; i < volume_junction_uo._connection_indices.size(); i++)
169 const unsigned int c = volume_junction_uo._connection_indices[i];
171 _flux[
c] = volume_junction_uo._flux[
c];
177 _residual[i] += volume_junction_uo._residual[i];
180 const std::vector<ADReal> &
183 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188 const std::vector<ADReal> &
191 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
194 return _flux[connection_index];
197 std::vector<const MooseVariableBase *>
213 var =
getVar(var_name, i);
219 unsigned int i)
const
std::vector< std::vector< ADReal > > _flux
Cached flux vector for each connection.
std::vector< std::vector< dof_id_type > > _flow_channel_dofs
Degrees of freedom for flow channel variables, for each connection.
libMesh::ConstElemRange * getActiveLocalElementRange()
static InputParameters validParams()
const unsigned int invalid_uint
virtual void computeFluxesAndResiduals(const unsigned int &c)=0
Computes and stores the fluxes, the scalar residuals, and their Jacobians.
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
std::vector< ADReal > _cached_junction_var_values
SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
unsigned int getBoundaryIDIndex()
Gets the index of the currently executing boundary within the vector of boundary IDs given to this Si...
std::vector< std::string > _scalar_variable_names
Vector of coupled variable names for each scalar variable.
const ADVariableValue & adCoupledValue(const std::string &var_name, unsigned int comp=0) const
const Parallel::Communicator & comm() const
unsigned int _n_scalar_eq
Number of scalar residual components.
unsigned int _n_flux_eq
Number of flow channel flux components.
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
virtual void execute() override
const unsigned int _n_connections
Number of connected flow channels.
ADVolumeJunctionBaseUserObject(const InputParameters ¶ms)
Constructor.
virtual void initialize() override
virtual const std::string & name() const
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 subdomain_id_type _junction_subdomain_id
Junction subdomain ID.
virtual std::vector< const MooseVariableBase * > getJunctionVariables() const
Gets the junction variables.
std::vector< const ADVariableValue * > _junction_var_values
std::vector< unsigned int > _connection_indices
Connection indices for this thread.
std::vector< std::string > _flow_variable_names
Vector of coupled variable names for each flow variable.
const std::vector< ADReal > & getResidual() const
Returns the residual vector for the scalar variables.
virtual void threadJoin(const UserObject &uo) override
const std::vector< dof_id_type > & dofIndices() const final
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
const std::vector< ADReal > & getFlux(const unsigned int &connection_index) const override
Gets the flux vector for a connection.
virtual void storeConnectionData()
Stores data (connection index, face shape functions, DoFs associated with flow channel variables) rel...
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
virtual void initialSetup() override
Base class for computing and caching flux and residual vectors for a volume junction.
Provides common interfaces for flow junction user objects.
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
std::vector< dof_id_type > _scalar_dofs
Degrees of freedom for scalar variables.
const bool _use_scalar_variables
True if the junction variables are scalar variables.
bool isParamSetByUser(const std::string &nm) const
const ADVariableValue & adCoupledScalarValue(const std::string &var_name, unsigned int comp=0) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
void mooseError(Args &&... args) const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
void checkValidConnectionIndex(const unsigned int &connection_index) const
Checks that a connection index is valid.
static const std::string k
static InputParameters validParams()
const ADVariableValue & coupledJunctionValue(const std::string &var_name, unsigned int i=0) const
Gets an AD junction variable value.
const MooseVariableBase * getJunctionVar(const std::string &var_name, unsigned int i=0) const
Gets a junction variable.