Line data Source code
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 "NumericalFluxGasMixDGKernel.h" 11 : #include "NumericalFluxGasMixBase.h" 12 : #include "MooseVariable.h" 13 : #include "THMIndicesGasMix.h" 14 : #include "THMNames.h" 15 : 16 : registerMooseObject("ThermalHydraulicsApp", NumericalFluxGasMixDGKernel); 17 : 18 : InputParameters 19 164 : NumericalFluxGasMixDGKernel::validParams() 20 : { 21 164 : InputParameters params = ADDGKernel::validParams(); 22 : 23 164 : params.addClassDescription("Adds side fluxes from NumericalFluxGasMixBase objects."); 24 : 25 328 : params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear"); 26 328 : params.addRequiredCoupledVar("xirhoA", "Conserved variable xi*rho*A"); 27 328 : params.addRequiredCoupledVar("rhoA", "Conserved variable rho*A"); 28 328 : params.addRequiredCoupledVar("rhouA", "Conserved variable rho*u*A"); 29 328 : params.addRequiredCoupledVar("rhoEA", "Conserved variable rho*E*A"); 30 : 31 328 : params.addRequiredParam<UserObjectName>("numerical_flux", 32 : "Name of NumericalFluxGasMixBase object"); 33 : 34 164 : return params; 35 0 : } 36 : 37 88 : NumericalFluxGasMixDGKernel::NumericalFluxGasMixDGKernel(const InputParameters & parameters) 38 : : ADDGKernel(parameters), 39 : 40 88 : _A_elem(adCoupledValue("A_linear")), 41 88 : _A_neig(adCoupledNeighborValue("A_linear")), 42 88 : _xirhoA1(getADMaterialProperty<Real>(THM::XIRHOA)), 43 88 : _rhoA1(getADMaterialProperty<Real>(THM::RHOA)), 44 88 : _rhouA1(getADMaterialProperty<Real>(THM::RHOUA)), 45 88 : _rhoEA1(getADMaterialProperty<Real>(THM::RHOEA)), 46 88 : _xirhoA2(getNeighborADMaterialProperty<Real>(THM::XIRHOA)), 47 88 : _rhoA2(getNeighborADMaterialProperty<Real>(THM::RHOA)), 48 88 : _rhouA2(getNeighborADMaterialProperty<Real>(THM::RHOUA)), 49 88 : _rhoEA2(getNeighborADMaterialProperty<Real>(THM::RHOEA)), 50 88 : _numerical_flux(getUserObject<NumericalFluxGasMixBase>("numerical_flux")), 51 88 : _xirhoA_var(coupled("xirhoA")), 52 88 : _rhoA_var(coupled("rhoA")), 53 88 : _rhouA_var(coupled("rhouA")), 54 88 : _rhoEA_var(coupled("rhoEA")), 55 88 : _jmap(getIndexMapping()), 56 176 : _equation_index(_jmap.at(_var.number())) 57 : { 58 88 : } 59 : 60 : ADReal 61 90160 : NumericalFluxGasMixDGKernel::computeQpResidual(Moose::DGResidualType type) 62 : { 63 : // construct the left and right solution vectors from the reconstructed solution 64 90160 : std::vector<ADReal> U1(THMGasMix1D::N_FLUX_INPUTS, 0.0); 65 90160 : U1[THMGasMix1D::XIRHOA] = _xirhoA1[_qp]; 66 90160 : U1[THMGasMix1D::RHOA] = _rhoA1[_qp]; 67 90160 : U1[THMGasMix1D::RHOUA] = _rhouA1[_qp]; 68 90160 : U1[THMGasMix1D::RHOEA] = _rhoEA1[_qp]; 69 90160 : U1[THMGasMix1D::AREA] = _A_elem[_qp]; 70 : 71 90160 : std::vector<ADReal> U2(THMGasMix1D::N_FLUX_INPUTS, 0.0); 72 90160 : U2[THMGasMix1D::XIRHOA] = _xirhoA2[_qp]; 73 90160 : U2[THMGasMix1D::RHOA] = _rhoA2[_qp]; 74 90160 : U2[THMGasMix1D::RHOUA] = _rhouA2[_qp]; 75 90160 : U2[THMGasMix1D::RHOEA] = _rhoEA2[_qp]; 76 90160 : U2[THMGasMix1D::AREA] = _A_neig[_qp]; 77 : 78 90160 : const Real nLR_dot_d = _current_side * 2 - 1.0; 79 : 80 : const std::vector<ADReal> & flux_elem = 81 90160 : _numerical_flux.getFlux(_current_side, _current_elem->id(), true, U1, U2, nLR_dot_d); 82 : const std::vector<ADReal> & flux_neig = 83 90160 : _numerical_flux.getFlux(_current_side, _current_elem->id(), false, U1, U2, nLR_dot_d); 84 : 85 90160 : ADReal re = 0.0; 86 90160 : switch (type) 87 : { 88 45080 : case Moose::Element: 89 90160 : re = flux_elem[_equation_index] * _test[_i][_qp]; 90 45080 : break; 91 45080 : case Moose::Neighbor: 92 90160 : re = -flux_neig[_equation_index] * _test_neighbor[_i][_qp]; 93 45080 : break; 94 : } 95 90160 : return re; 96 : } 97 : 98 : std::map<unsigned int, unsigned int> 99 88 : NumericalFluxGasMixDGKernel::getIndexMapping() const 100 : { 101 : std::map<unsigned int, unsigned int> jmap; 102 88 : jmap.insert(std::pair<unsigned int, unsigned int>(_xirhoA_var, THMGasMix1D::SPECIES)); 103 88 : jmap.insert(std::pair<unsigned int, unsigned int>(_rhoA_var, THMGasMix1D::MASS)); 104 88 : jmap.insert(std::pair<unsigned int, unsigned int>(_rhouA_var, THMGasMix1D::MOMENTUM)); 105 88 : jmap.insert(std::pair<unsigned int, unsigned int>(_rhoEA_var, THMGasMix1D::ENERGY)); 106 : 107 88 : return jmap; 108 : }