https://mooseframework.inl.gov
ADNumericalFlux3EqnDGKernel.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 
12 #include "MooseVariable.h"
13 #include "THMIndicesVACE.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", ADNumericalFlux3EqnDGKernel);
16 
19 {
21 
22  params.addClassDescription(
23  "Adds side fluxes for the 1-D, 1-phase, variable-area Euler equations");
24 
25  params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
26  params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
27  params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
28  params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
29  params.addCoupledVar("passives_times_area", "Passive transport solution variables");
30 
31  params.addRequiredParam<UserObjectName>("numerical_flux", "Name of numerical flux user object");
32 
33  return params;
34 }
35 
37  : ADDGKernel(parameters),
38 
39  _A_elem(adCoupledValue("A_linear")),
40  _A_neig(adCoupledNeighborValue("A_linear")),
41  _rhoA1(getADMaterialProperty<Real>("rhoA")),
42  _rhouA1(getADMaterialProperty<Real>("rhouA")),
43  _rhoEA1(getADMaterialProperty<Real>("rhoEA")),
44  _passives_times_area1(getADMaterialProperty<std::vector<Real>>("passives_times_area")),
45  _p1(getADMaterialProperty<Real>("p")),
46  _rhoA2(getNeighborADMaterialProperty<Real>("rhoA")),
47  _rhouA2(getNeighborADMaterialProperty<Real>("rhouA")),
48  _rhoEA2(getNeighborADMaterialProperty<Real>("rhoEA")),
49  _passives_times_area2(getNeighborADMaterialProperty<std::vector<Real>>("passives_times_area")),
50  _p2(getNeighborADMaterialProperty<Real>("p")),
51  _numerical_flux(getUserObject<ADNumericalFlux3EqnBase>("numerical_flux")),
52  _rhoA_var(coupled("rhoA")),
53  _rhouA_var(coupled("rhouA")),
54  _rhoEA_var(coupled("rhoEA")),
55  _n_passives(isParamValid("passives_times_area") ? coupledComponents("passives_times_area") : 0),
56  _jmap(getIndexMapping()),
57  _equation_index(_jmap.at(_var.number()))
58 {
59 }
60 
61 ADReal
63 {
64  // left reconstructed solution
65  std::vector<ADReal> U1(THMVACE1D::N_FLUX_INPUTS + _n_passives, 0.0);
66  U1[THMVACE1D::RHOA] = _rhoA1[_qp];
70  for (const auto i : make_range(_n_passives))
72 
73  // right reconstructed solution
74  std::vector<ADReal> U2(THMVACE1D::N_FLUX_INPUTS + _n_passives, 0.0);
75  U2[THMVACE1D::RHOA] = _rhoA2[_qp];
79  for (const auto i : make_range(_n_passives))
81 
82  const Real nLR_dot_d = _current_side * 2 - 1.0;
83 
84  const std::vector<ADReal> & flux_elem =
85  _numerical_flux.getFlux(_current_side, _current_elem->id(), true, U1, U2, nLR_dot_d);
86  const std::vector<ADReal> & flux_neig =
87  _numerical_flux.getFlux(_current_side, _current_elem->id(), false, U1, U2, nLR_dot_d);
88 
89  ADReal re = 0.0;
90  switch (type)
91  {
92  case Moose::Element:
93  re = flux_elem[_equation_index] * _test[_i][_qp];
94  break;
95  case Moose::Neighbor:
96  re = -flux_neig[_equation_index] * _test_neighbor[_i][_qp];
97  break;
98  }
99  return re;
100 }
101 
102 std::map<unsigned int, unsigned int>
104 {
105  std::map<unsigned int, unsigned int> jmap;
106  jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMVACE1D::MASS));
107  jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMVACE1D::MOMENTUM));
108  jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMVACE1D::ENERGY));
109  for (const auto i : make_range(_n_passives))
110  jmap.insert(std::pair<unsigned int, unsigned int>(coupled("passives_times_area", i),
112 
113  return jmap;
114 }
const ADMaterialProperty< std::vector< Real > > & _passives_times_area2
static InputParameters validParams()
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0) const
std::map< unsigned int, unsigned int > getIndexMapping() const
Creates the mapping of coupled variable index to index in Euler system.
const ADMaterialProperty< Real > & _rhouA1
const ADVariableValue & _A_elem
Area.
const ADMaterialProperty< std::vector< Real > > & _passives_times_area1
const ADNumericalFlux3EqnBase & _numerical_flux
Numerical flux user object.
virtual ADReal computeQpResidual(Moose::DGResidualType type)
static InputParameters validParams()
unsigned int _i
DGResidualType
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.
DualNumber< Real, DNDerivativeType, false > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
ADNumericalFlux3EqnDGKernel(const InputParameters &parameters)
registerMooseObject("ThermalHydraulicsApp", ADNumericalFlux3EqnDGKernel)
unsigned int _qp
const ADMaterialProperty< Real > & _rhouA2
const unsigned int _n_passives
Number of passive transport variables.
const ADMaterialProperty< Real > & _rhoEA2
const VariableTestValue & _test_neighbor
const ADMaterialProperty< Real > & _rhoA1
const std::string & type() const
Base class for computing numerical fluxes for FlowModelSinglePhase.
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.
const unsigned int _equation_index
index within the Euler system of the equation upon which this kernel acts
const ADMaterialProperty< Real > & _rhoEA1
void addCoupledVar(const std::string &name, const std::string &doc_string)
static const unsigned int N_FLUX_OUTPUTS
Number of numerical flux function outputs for 1D.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const ADMaterialProperty< Real > & _rhoA2
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Elem *const & _current_elem
IntRange< T > make_range(T beg, T end)
const unsigned int & _current_side
void addClassDescription(const std::string &doc_string)
const VariableTestValue & _test
Adds side fluxes for the 1-D, 1-phase, variable-area Euler equations.