https://mooseframework.inl.gov
BoundaryFlux3EqnBC.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 
10 #include "BoundaryFlux3EqnBC.h"
11 #include "MooseVariable.h"
12 #include "THMIndicesVACE.h"
13 
14 registerMooseObject("ThermalHydraulicsApp", BoundaryFlux3EqnBC);
15 
18 {
20 
21  params.addClassDescription(
22  "Boundary conditions for the 1-D, 1-phase, variable-area Euler equations");
23 
24  params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental");
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>("boundary_flux", "Name of boundary flux user object");
31 
32  return params;
33 }
34 
36  : OneDIntegratedBC(parameters),
37 
38  _A_elem(coupledValue("A_elem")),
39  _A_linear(coupledValue("A_linear")),
40 
41  _rhoA(coupledValue("rhoA")),
42  _rhouA(coupledValue("rhouA")),
43  _rhoEA(coupledValue("rhoEA")),
44 
45  _rhoA_var(coupled("rhoA")),
46  _rhouA_var(coupled("rhouA")),
47  _rhoEA_var(coupled("rhoEA")),
48 
49  _jmap(getIndexMapping()),
50  _equation_index(_jmap.at(_var.number())),
51 
52  _flux(getUserObject<BoundaryFluxBase>("boundary_flux"))
53 {
54 }
55 
56 Real
58 {
59  const std::vector<Real> U = {_rhoA[_qp], _rhouA[_qp], _rhoEA[_qp], _A_elem[_qp]};
60  const auto & flux = _flux.getFlux(_current_side, _current_elem->id(), U, _normals[_qp]);
61 
62  // Note that the ratio A_linear / A_elem is necessary because A_elem is passed
63  // to the flux function, but A_linear is to be used on the boundary.
64  return flux[_equation_index] * _A_linear[_qp] / _A_elem[_qp] * _normal * _test[_i][_qp];
65 }
66 
67 Real
69 {
71 }
72 
73 Real
75 {
76  const std::vector<Real> U = {_rhoA[_qp], _rhouA[_qp], _rhoEA[_qp], _A_elem[_qp]};
77  const auto & J = _flux.getJacobian(_current_side, _current_elem->id(), U, {_normal, 0, 0});
78 
79  return J(_equation_index, _jmap.at(jvar)) * _A_linear[_qp] / _A_elem[_qp] * _normal *
80  _phi[_j][_qp] * _test[_i][_qp];
81 }
82 
83 std::map<unsigned int, unsigned int>
85 {
86  std::map<unsigned int, unsigned int> jmap;
87  jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMVACE1D::MASS));
88  jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMVACE1D::MOMENTUM));
89  jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMVACE1D::ENERGY));
90 
91  return jmap;
92 }
const VariableTestValue & _test
virtual const std::vector< Real > & getFlux(unsigned int iside, dof_id_type ielem, const std::vector< Real > &uvec1, const RealVectorValue &dwave) const
Get the boundary flux vector.
Boundary conditions for the 1-D, 1-phase, variable-area Euler equations using a boundary flux user ob...
unsigned int _j
const unsigned int _equation_index
index within the Euler system of the equation upon which this BC acts
const MooseArray< Point > & _normals
const Real _normal
Component of outward normals along 1-D direction.
unsigned int number() const
Base class for integrated boundary conditions for 1D problems in 3D space.
const Elem *const & _current_elem
const std::map< unsigned int, unsigned int > _jmap
map of coupled variable index to equations variable index convention
unsigned int _i
BoundaryFlux3EqnBC(const InputParameters &parameters)
virtual const DenseMatrix< Real > & getJacobian(unsigned int iside, dof_id_type ielem, const std::vector< Real > &uvec1, const RealVectorValue &dwave) const
Get the boundary Jacobian matrix.
virtual Real computeQpJacobian() override
const VariablePhiValue & _phi
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _qp
A base class for computing/caching fluxes at boundaries.
const VariableValue & _A_elem
Cross-sectional area, elemental.
static InputParameters validParams()
const VariableValue & _A_linear
Cross-sectional area, linear.
const unsigned int _rhoA_var
const VariableValue & _rhouA
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
MooseVariable & _var
const unsigned int & _current_side
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const unsigned int _rhoEA_var
const BoundaryFluxBase & _flux
boundary flux user object
virtual Real computeQpResidual() override
void addClassDescription(const std::string &doc_string)
const VariableValue & _rhoA
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const VariableValue & _rhoEA
std::map< unsigned int, unsigned int > getIndexMapping() const
Creates the mapping of coupled variable index to index in Euler system.
const unsigned int _rhouA_var
registerMooseObject("ThermalHydraulicsApp", BoundaryFlux3EqnBC)