https://mooseframework.inl.gov
LinearFVMomentumBoussinesq.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 "Assembly.h"
12 #include "SubProblem.h"
13 #include "NS.h"
14 #include "FEProblemBase.h"
15 
17 
20 {
22  params.addClassDescription("Represents the Boussinesq term in the Navier Stokes momentum "
23  "equations, added to the right hand side.");
24  params.addParam<VariableName>(NS::T_fluid, "The fluid temperature variable.");
25  params.addRequiredParam<RealVectorValue>("gravity", "Gravitational acceleration vector.");
26  params.addParam<MooseFunctorName>("alpha_name",
28  "The name of the thermal expansion coefficient"
29  "this is of the form rho = rho_ref*(1-alpha (T-T_ref))");
30  params.addRequiredParam<Real>("ref_temperature", "The value for the reference temperature.");
31  params.addRequiredParam<MooseFunctorName>(NS::density, "The value for the density");
32  MooseEnum momentum_component("x=0 y=1 z=2");
34  "momentum_component",
35  momentum_component,
36  "The component of the momentum equation that this kernel applies to.");
37  return params;
38 }
39 
41  : LinearFVElementalKernel(params),
42  _index(getParam<MooseEnum>("momentum_component")),
43  _temperature_var(getTemperatureVariable(NS::T_fluid)),
44  _gravity(getParam<RealVectorValue>("gravity")),
45  _alpha(getFunctor<Real>("alpha_name")),
46  _ref_temperature(getParam<Real>("ref_temperature")),
47  _rho(getFunctor<Real>(NS::density))
48 {
49  if (!_rho.isConstant())
50  paramError(NS::density, "The density in the boussinesq term is not constant!");
51 }
52 
55 {
56  auto * ptr = dynamic_cast<MooseLinearVariableFV<Real> *>(
57  &_fe_problem.getVariable(_tid, getParam<VariableName>(vname)));
58 
59  if (!ptr)
61  "The fluid temperature variable should be of type MooseLinearVariableFVReal!");
62 
63  return *ptr;
64 }
65 
66 Real
68 {
69  return 0.0;
70 }
71 
72 Real
74 {
75  const auto elem = makeElemArg(_current_elem_info->elem());
76  const auto state = determineState();
77  return -_alpha(elem, state) * _gravity(_index) * _rho(elem, state) *
80 }
const ElemInfo * _current_elem_info
LinearFVMomentumBoussinesq(const InputParameters &params)
Class constructor.
const unsigned int _index
Index x|y|z of the momentum equation component.
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)
registerMooseObject("NavierStokesApp", LinearFVMomentumBoussinesq)
Moose::StateArg determineState() const
const Elem * elem() const
static const std::string alpha_boussinesq
Definition: NS.h:113
static InputParameters validParams()
static const std::string density
Definition: NS.h:33
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
const THREAD_ID _tid
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
static const std::string T_fluid
Definition: NS.h:106
Kernel that adds the component of the Boussinesq term in the momentum equations to the right hand sid...
const MooseLinearVariableFV< Real > & getTemperatureVariable(const std::string &vname)
Fluid Temperature.
const Moose::Functor< Real > & _rho
the density
const MooseLinearVariableFV< Real > & _temperature_var
Pointer to the linear finite volume temperature variable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeRightHandSideContribution() override
virtual Real computeMatrixContribution() override
const Moose::Functor< Real > & _alpha
The thermal expansion coefficient.
Real getElemValue(const ElemInfo &elem_info, const StateArg &state) const
void addClassDescription(const std::string &doc_string)
const RealVectorValue _gravity
The gravity vector.
FEProblemBase & _fe_problem
const Real _ref_temperature
Reference temperature at which the reference value of the density (_rho) was measured.