https://mooseframework.inl.gov
Functions
FlowModel1PhaseUtils Namespace Reference

Functions

template<bool is_ad>
std::vector< GenericReal< is_ad > > computePrimitiveSolutionVector (const std::vector< GenericReal< is_ad >> &U, const SinglePhaseFluidProperties &fp)
 Computes the primitive solution vector from the conservative solution vector. More...
 
template<bool is_ad>
std::vector< GenericReal< is_ad > > computeConservativeSolutionVector (const std::vector< GenericReal< is_ad >> &W, const GenericReal< is_ad > &A, const SinglePhaseFluidProperties &fp)
 Computes the conservative solution vector from the primitive solution vector. More...
 
template<bool is_ad>
std::vector< GenericReal< is_ad > > computeFluxFromPrimitive (const std::vector< GenericReal< is_ad >> &W, const GenericReal< is_ad > &A, const SinglePhaseFluidProperties &fp)
 Computes the numerical flux vector from the primitive solution vector. More...
 
template<bool is_ad>
std::vector< GenericReal< is_ad > > getElementalSolutionVector (const Elem *elem, const std::vector< MooseVariable *> &U_vars, bool is_implicit)
 Gets the elemental conservative solution vector. More...
 

Function Documentation

◆ computeConservativeSolutionVector()

template<bool is_ad>
std::vector<GenericReal<is_ad> > FlowModel1PhaseUtils::computeConservativeSolutionVector ( const std::vector< GenericReal< is_ad >> &  W,
const GenericReal< is_ad > &  A,
const SinglePhaseFluidProperties fp 
)

Computes the conservative solution vector from the primitive solution vector.

Parameters
[in]WPrimitive solution vector
[in]ACross-sectional area
[in]fpFluid properties object

Definition at line 64 of file FlowModel1PhaseUtils.h.

67 {
68  const auto & p = W[THMVACE1D::PRESSURE];
69  const auto & T = W[THMVACE1D::TEMPERATURE];
70  const auto & vel = W[THMVACE1D::VELOCITY];
71  const auto n_passives = W.size() - THMVACE1D::N_PRIM_VARS;
72 
73  const ADReal rho = fp.rho_from_p_T(p, T);
74  const ADReal e = fp.e_from_p_rho(p, rho);
75  const ADReal E = e + 0.5 * vel * vel;
76 
77  std::vector<GenericReal<is_ad>> U(THMVACE1D::N_FLUX_INPUTS + n_passives);
78  U[THMVACE1D::RHOA] = rho * A;
79  U[THMVACE1D::RHOUA] = U[THMVACE1D::RHOA] * vel;
81  U[THMVACE1D::AREA] = A;
82  for (const auto i : make_range(n_passives))
84 
85  return U;
86 }
const double T
DualNumber< Real, DNDerivativeType, false > ADReal
const double rho
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.
static const unsigned int N_PRIM_VARS
const Real p
IntRange< T > make_range(T beg, T end)

◆ computeFluxFromPrimitive()

template<bool is_ad>
std::vector<GenericReal<is_ad> > FlowModel1PhaseUtils::computeFluxFromPrimitive ( const std::vector< GenericReal< is_ad >> &  W,
const GenericReal< is_ad > &  A,
const SinglePhaseFluidProperties fp 
)

Computes the numerical flux vector from the primitive solution vector.

Parameters
[in]WPrimitive solution vector
[in]ACross-sectional area
[in]fpFluid properties object

Definition at line 97 of file FlowModel1PhaseUtils.h.

100 {
101  const auto & p = W[THMVACE1D::PRESSURE];
102  const auto & T = W[THMVACE1D::TEMPERATURE];
103  const auto & vel = W[THMVACE1D::VELOCITY];
104  const auto n_passives = W.size() - THMVACE1D::N_PRIM_VARS;
105 
106  const auto rho = fp.rho_from_p_T(p, T);
107  const auto e = fp.e_from_p_rho(p, rho);
108  const auto E = e + 0.5 * vel * vel;
109 
110  std::vector<ADReal> F(THMVACE1D::N_FLUX_OUTPUTS + n_passives, 0.0);
111  F[THMVACE1D::MASS] = rho * vel * A;
112  F[THMVACE1D::MOMENTUM] = (rho * vel * vel + p) * A;
113  F[THMVACE1D::ENERGY] = vel * (rho * E + p) * A;
114  for (const auto i : make_range(n_passives))
115  F[THMVACE1D::N_FLUX_OUTPUTS + i] = vel * W[THMVACE1D::N_PRIM_VARS + i] * A;
116 
117  return F;
118 }
const double T
static const std::string F
Definition: NS.h:169
const double rho
static const unsigned int N_FLUX_OUTPUTS
Number of numerical flux function outputs for 1D.
static const unsigned int N_PRIM_VARS
const Real p
IntRange< T > make_range(T beg, T end)

◆ computePrimitiveSolutionVector()

template<bool is_ad>
std::vector<GenericReal<is_ad> > FlowModel1PhaseUtils::computePrimitiveSolutionVector ( const std::vector< GenericReal< is_ad >> &  U,
const SinglePhaseFluidProperties fp 
)

Computes the primitive solution vector from the conservative solution vector.

Parameters
[in]UConservative solution vector
[in]fpFluid properties object

Definition at line 29 of file FlowModel1PhaseUtils.h.

31 {
32  const auto & rhoA = U[THMVACE1D::RHOA];
33  const auto & rhouA = U[THMVACE1D::RHOUA];
34  const auto & rhoEA = U[THMVACE1D::RHOEA];
35  const auto & A = U[THMVACE1D::AREA];
36  const auto n_passives = U.size() - THMVACE1D::N_FLUX_INPUTS;
37 
38  const auto rho = rhoA / A;
39  const auto vel = rhouA / rhoA;
40  const auto v = 1.0 / rho;
41  const auto e = rhoEA / rhoA - 0.5 * vel * vel;
42  const auto p = fp.p_from_v_e(v, e);
43  const auto T = fp.T_from_v_e(v, e);
44 
45  std::vector<GenericReal<is_ad>> W(THMVACE1D::N_PRIM_VARS + n_passives);
46  W[THMVACE1D::PRESSURE] = fp.p_from_v_e(v, e);
47  W[THMVACE1D::VELOCITY] = vel;
48  W[THMVACE1D::TEMPERATURE] = fp.T_from_v_e(v, e);
49  for (const auto i : make_range(n_passives))
51 
52  return W;
53 }
const double T
const double v
const double rho
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.
static const unsigned int N_PRIM_VARS
const Real p
IntRange< T > make_range(T beg, T end)

◆ getElementalSolutionVector()

template<bool is_ad>
std::vector<GenericReal<is_ad> > FlowModel1PhaseUtils::getElementalSolutionVector ( const Elem *  elem,
const std::vector< MooseVariable *> &  U_vars,
bool  is_implicit 
)

Gets the elemental conservative solution vector.

Parameters
[in]elemElement
[in]U_varsVector of conservative variable pointers
[in]is_implicitIs implicit?

Definition at line 129 of file FlowModel1PhaseUtils.h.

132 {
133  mooseAssert(elem, "The supplied element is a nullptr.");
134 
135  std::vector<GenericReal<is_ad>> U(U_vars.size(), 0.0);
136 
137  if (is_implicit)
138  {
139  for (const auto i : make_range(U_vars.size()))
140  {
141  mooseAssert(U_vars[i], "The supplied variable is a nullptr.");
142  U[i] = U_vars[i]->getElementalValue(elem);
143 
144  if (i != THMVACE1D::AREA)
145  {
146  std::vector<dof_id_type> dof_indices;
147  U_vars[i]->dofMap().dof_indices(elem, dof_indices, U_vars[i]->number());
148  Moose::derivInsert(U[i].derivatives(), dof_indices[0], 1.0);
149  }
150  }
151  }
152  else
153  {
154  for (const auto i : make_range(U_vars.size()))
155  U[i] = U_vars[i]->getElementalValueOld(elem);
156  }
157 
158  return U;
159 }
IntRange< T > make_range(T beg, T end)
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)