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 "LinearFVMomentumBoussinesq.h" 11 : #include "Assembly.h" 12 : #include "SubProblem.h" 13 : #include "NS.h" 14 : #include "FEProblemBase.h" 15 : 16 : registerMooseObject("NavierStokesApp", LinearFVMomentumBoussinesq); 17 : 18 : InputParameters 19 429 : LinearFVMomentumBoussinesq::validParams() 20 : { 21 429 : InputParameters params = LinearFVElementalKernel::validParams(); 22 429 : params.addClassDescription("Represents the Boussinesq term in the Navier Stokes momentum " 23 : "equations, added to the right hand side."); 24 429 : params.addParam<VariableName>(NS::T_fluid, "The fluid temperature variable."); 25 858 : params.addRequiredParam<RealVectorValue>("gravity", "Gravitational acceleration vector."); 26 858 : params.addParam<MooseFunctorName>("alpha_name", 27 : NS::alpha_boussinesq, 28 : "The name of the thermal expansion coefficient" 29 : "this is of the form rho = rho_ref*(1-alpha (T-T_ref))"); 30 858 : params.addRequiredParam<Real>("ref_temperature", "The value for the reference temperature."); 31 429 : params.addRequiredParam<MooseFunctorName>(NS::density, "The value for the density"); 32 858 : MooseEnum momentum_component("x=0 y=1 z=2"); 33 858 : params.addRequiredParam<MooseEnum>( 34 : "momentum_component", 35 : momentum_component, 36 : "The component of the momentum equation that this kernel applies to."); 37 429 : return params; 38 429 : } 39 : 40 224 : LinearFVMomentumBoussinesq::LinearFVMomentumBoussinesq(const InputParameters & params) 41 : : LinearFVElementalKernel(params), 42 224 : _index(getParam<MooseEnum>("momentum_component")), 43 224 : _temperature_var(getTemperatureVariable(NS::T_fluid)), 44 448 : _gravity(getParam<RealVectorValue>("gravity")), 45 448 : _alpha(getFunctor<Real>("alpha_name")), 46 448 : _ref_temperature(getParam<Real>("ref_temperature")), 47 448 : _rho(getFunctor<Real>(NS::density)) 48 : { 49 224 : if (!_rho.isConstant()) 50 0 : paramError(NS::density, "The density in the boussinesq term is not constant!"); 51 224 : } 52 : 53 : const MooseLinearVariableFV<Real> & 54 224 : LinearFVMomentumBoussinesq::getTemperatureVariable(const std::string & vname) 55 : { 56 224 : auto * ptr = dynamic_cast<MooseLinearVariableFV<Real> *>( 57 224 : &_fe_problem.getVariable(_tid, getParam<VariableName>(vname))); 58 : 59 224 : if (!ptr) 60 0 : paramError(NS::T_fluid, 61 : "The fluid temperature variable should be of type MooseLinearVariableFVReal!"); 62 : 63 224 : return *ptr; 64 : } 65 : 66 : Real 67 3934100 : LinearFVMomentumBoussinesq::computeMatrixContribution() 68 : { 69 3934100 : return 0.0; 70 : } 71 : 72 : Real 73 3934100 : LinearFVMomentumBoussinesq::computeRightHandSideContribution() 74 : { 75 3934100 : const auto elem = makeElemArg(_current_elem_info->elem()); 76 3934100 : const auto state = determineState(); 77 3934100 : return -_alpha(elem, state) * _gravity(_index) * _rho(elem, state) * 78 3934100 : (_temperature_var.getElemValue(*_current_elem_info, state) - _ref_temperature) * 79 3934100 : _current_elem_volume; 80 : }