https://mooseframework.inl.gov
NumericalFlux3EqnDGKernel.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 
11 #include "NumericalFlux3EqnBase.h"
12 #include "MooseVariable.h"
13 #include "THMIndicesVACE.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", NumericalFlux3EqnDGKernel);
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 
30  params.addRequiredParam<UserObjectName>("numerical_flux", "Name of numerical flux user object");
31 
32  return params;
33 }
34 
36  : DGKernel(parameters),
37 
38  _A_elem(coupledValue("A_linear")),
39  _A_neig(coupledNeighborValue("A_linear")),
40  _rhoA1(getMaterialProperty<Real>("rhoA")),
41  _rhouA1(getMaterialProperty<Real>("rhouA")),
42  _rhoEA1(getMaterialProperty<Real>("rhoEA")),
43  _p1(getMaterialProperty<Real>("p")),
44  _rhoA2(getNeighborMaterialProperty<Real>("rhoA")),
45  _rhouA2(getNeighborMaterialProperty<Real>("rhouA")),
46  _rhoEA2(getNeighborMaterialProperty<Real>("rhoEA")),
47  _p2(getNeighborMaterialProperty<Real>("p")),
48  _numerical_flux(getUserObject<NumericalFlux3EqnBase>("numerical_flux")),
49  _rhoA_var(coupled("rhoA")),
50  _rhouA_var(coupled("rhouA")),
51  _rhoEA_var(coupled("rhoEA")),
52  _jmap(getIndexMapping()),
53  _equation_index(_jmap.at(_var.number()))
54 {
55 }
56 
57 Real
59 {
60  // construct the left and right solution vectors from the reconstructed solution
61  std::vector<Real> U1 = {_rhoA1[_qp], _rhouA1[_qp], _rhoEA1[_qp], _A_elem[_qp]};
62  std::vector<Real> U2 = {_rhoA2[_qp], _rhouA2[_qp], _rhoEA2[_qp], _A_neig[_qp]};
63 
64  const Real nLR_dot_d = _current_side * 2 - 1.0;
65 
66  const std::vector<Real> & flux_elem =
67  _numerical_flux.getFlux(_current_side, _current_elem->id(), true, U1, U2, nLR_dot_d);
68  const std::vector<Real> & flux_neig =
69  _numerical_flux.getFlux(_current_side, _current_elem->id(), false, U1, U2, nLR_dot_d);
70 
71  Real re = 0.0;
72  switch (type)
73  {
74  case Moose::Element:
75  re = flux_elem[_equation_index] * _test[_i][_qp];
76  break;
77  case Moose::Neighbor:
78  re = -flux_neig[_equation_index] * _test_neighbor[_i][_qp];
79  break;
80  }
81  return re;
82 }
83 
84 Real
86 {
88 }
89 
90 Real
92 {
93  // construct the left and right solution vectors from the cell-average solution
94  std::vector<Real> U1 = {_rhoA1[_qp], _rhouA1[_qp], _rhoEA1[_qp], _A_elem[_qp]};
95  std::vector<Real> U2 = {_rhoA2[_qp], _rhouA2[_qp], _rhoEA2[_qp], _A_neig[_qp]};
96 
97  // Temporary hack to allow libMesh fix. After the fix, this should be changed to:
98  // const Real nLR_dot_d = _normals[_qp] * _direction[_qp];
99  const Real nLR_dot_d = _current_side * 2 - 1.0;
100 
102  true, true, _current_side, _current_elem->id(), U1, U2, nLR_dot_d);
104  true, false, _current_side, _current_elem->id(), U1, U2, nLR_dot_d);
106  false, true, _current_side, _current_elem->id(), U1, U2, nLR_dot_d);
108  false, false, _current_side, _current_elem->id(), U1, U2, nLR_dot_d);
109 
110  Real re = 0.0;
111  switch (type)
112  {
114  re = dF1_dU1(_equation_index, _jmap.at(jvar)) * _phi[_j][_qp] * _test[_i][_qp];
115  break;
117  re = dF1_dU2(_equation_index, _jmap.at(jvar)) * _phi_neighbor[_j][_qp] * _test[_i][_qp];
118  break;
120  re = -dF2_dU1(_equation_index, _jmap.at(jvar)) * _phi[_j][_qp] * _test_neighbor[_i][_qp];
121  break;
123  re = -dF2_dU2(_equation_index, _jmap.at(jvar)) * _phi_neighbor[_j][_qp] *
125  break;
126  }
127  return re;
128 }
129 
130 std::map<unsigned int, unsigned int>
132 {
133  std::map<unsigned int, unsigned int> jmap;
134  jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMVACE1D::MASS));
135  jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMVACE1D::MOMENTUM));
136  jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMVACE1D::ENERGY));
137 
138  return jmap;
139 }
static InputParameters validParams()
NeighborElement
Adds side fluxes for the 1-D, 1-phase, variable-area Euler equations.
unsigned int number() const
virtual Real computeQpResidual(Moose::DGResidualType type)
const VariablePhiValue & _phi_neighbor
const NumericalFlux3EqnBase & _numerical_flux
Numerical flux user object.
unsigned int _i
DGResidualType
Abstract base class for computing and caching internal or boundary fluxes for RDG for the 3-equation ...
ElementElement
void addRequiredParam(const std::string &name, const std::string &doc_string)
MooseVariable & _var
static InputParameters validParams()
const VariableTestValue & _test_neighbor
unsigned int _qp
const std::map< unsigned int, unsigned int > _jmap
map of coupled variable index to equations variable index convention
unsigned int _j
const MaterialProperty< Real > & _rhouA1
std::map< unsigned int, unsigned int > getIndexMapping() const
Creates the mapping of coupled variable index to index in Euler system.
virtual Real computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar)
ElementNeighbor
const std::string & type() const
const MaterialProperty< Real > & _rhoEA1
const MaterialProperty< Real > & _rhoA2
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
virtual Real computeQpJacobian(Moose::DGJacobianType type)
const VariableTestValue & _test
registerMooseObject("ThermalHydraulicsApp", NumericalFlux3EqnDGKernel)
virtual const std::vector< Real > & getFlux(const unsigned int iside, const dof_id_type ielem, bool res_side_is_left, const std::vector< Real > &UL, const std::vector< Real > &UR, const Real &nLR_dot_d) const
Gets the flux vector for an element/side combination.
DGJacobianType
const MaterialProperty< Real > & _rhouA2
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const DenseMatrix< Real > & getJacobian(bool res_side_is_left, bool jac_side_is_left, const unsigned int iside, const dof_id_type ielem, const std::vector< Real > &UL, const std::vector< Real > &UR, const Real &nLR_dot_d) const
Gets the flux Jacobian matrix for an element/side combination.
const Elem *const & _current_elem
const unsigned int & _current_side
const unsigned int _equation_index
index within the Euler system of the equation upon which this kernel acts
void addClassDescription(const std::string &doc_string)
const VariablePhiValue & _phi
const MaterialProperty< Real > & _rhoEA2
NeighborNeighbor
const VariableValue & _A_elem
Area.
NumericalFlux3EqnDGKernel(const InputParameters &parameters)
const MaterialProperty< Real > & _rhoA1