https://mooseframework.inl.gov
LinearFVEnergyAdvection.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 "MooseLinearVariableFV.h"
12 #include "NSFVUtils.h"
13 #include "NS.h"
14 
16 
19 {
21  params.addClassDescription("Represents the matrix and right hand side contributions of an "
22  "advection term for the energy e.g. h=int(cp dT). A user may still "
23  "override what quantity is advected, but the default is temperature.");
24  MooseEnum advected_quantity("enthalpy temperature", "enthalpy");
25  params.addParam<MooseEnum>("advected_quantity", advected_quantity, "The advected quantity");
26  params.addParam<Real>("cp", "Constant specific heat value");
27  params.addRequiredParam<UserObjectName>(
28  "rhie_chow_user_object",
29  "The rhie-chow user-object which is used to determine the face velocity.");
31  return params;
32 }
33 
35  : LinearFVFluxKernel(params),
36  _advected_quantity(getParam<MooseEnum>("advected_quantity").getEnum<AdvectedQuantityEnum>()),
37  _cp(isParamValid("cp") ? getParam<Real>("cp") : 1.0),
38  _mass_flux_provider(getUserObject<RhieChowMassFlux>("rhie_chow_user_object")),
39  _advected_interp_coeffs(std::make_pair<Real, Real>(0, 0)),
40  _face_mass_flux(0.0)
41 {
42  Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
43 
45  paramError("cp", "cp should not be specified for enthalpy advection");
46 
48  paramError("cp", "cp should be specified for temperature advection");
49 }
50 
51 Real
53 {
55 }
56 
57 Real
59 {
61 }
62 
63 Real
65 {
66  return 0.0;
67 }
68 
69 Real
71 {
72  return 0.0;
73 }
74 
75 Real
77 {
78  const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
79  mooseAssert(adv_bc, "This should be a valid BC!");
80 
81  const auto boundary_value_matrix_contrib = adv_bc->computeBoundaryValueMatrixContribution();
82 
83  // We support internal boundaries too so we have to make sure the normal points always outward
84  const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0;
85 
86  return _cp * boundary_value_matrix_contrib * factor * _face_mass_flux * _current_face_area;
87 }
88 
89 Real
91 {
92  const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
93  mooseAssert(adv_bc, "This should be a valid BC!");
94 
95  // We support internal boundaries too so we have to make sure the normal points always outward
96  const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0);
97 
98  const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution();
99  return -_cp * boundary_value_rhs_contrib * factor * _face_mass_flux * _current_face_area;
100 }
101 
102 void
104 {
106 
107  // Caching the mass flux on the face which will be reused in the advection term's matrix and right
108  // hand side contributions
110 
111  // Caching the interpolation coefficients so they will be reused for the matrix and right hand
112  // side terms
115 }
virtual Real computeElemMatrixContribution() override
static InputParameters validParams()
virtual Real computeNeighborRightHandSideContribution() override
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
void paramError(const std::string &param, Args... args) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
AdvectedQuantityEnum _advected_quantity
The advected quantity.
An advection kernel that implements the advection term for the enthalpy in the energy equation...
std::pair< Real, Real > interpCoeffs(const InterpMethod m, const FaceInfo &fi, const bool one_is_elem, const T &face_flux=0.0)
Real getMassFlux(const FaceInfo &fi) const
Get the face velocity times density (used in advection terms)
virtual Real computeBoundaryMatrixContribution(const LinearFVBoundaryCondition &bc) override
virtual void setupFaceData(const FaceInfo *face_info)
virtual void setupFaceData(const FaceInfo *face_info) override
const RhieChowMassFlux & _mass_flux_provider
The Rhie-Chow user object that provides us with the face velocity.
FaceInfo::VarFaceNeighbors _current_face_type
void addRequiredParam(const std::string &name, const std::string &doc_string)
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
Real _face_mass_flux
Container for the mass flux on the face which will be reused in the advection term&#39;s matrix and right...
std::pair< Real, Real > _advected_interp_coeffs
Container for the current advected interpolation coefficients on the face to make sure we don&#39;t compu...
AdvectedQuantityEnum
The advected quantity options.
static InputParameters validParams()
const FaceInfo * _current_face_info
InputParameters advectedInterpolationParameter()
const Real _cp
The constant specific heat value.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
LinearFVEnergyAdvection(const InputParameters &params)
void addClassDescription(const std::string &doc_string)
virtual Real computeNeighborMatrixContribution() override
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
bool isParamValid(const std::string &name) const
registerMooseObject("NavierStokesApp", LinearFVEnergyAdvection)
virtual Real computeElemRightHandSideContribution() override
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)