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 "INSFVMomentumBoussinesq.h" 11 : #include "NS.h" 12 : 13 : registerMooseObject("NavierStokesApp", INSFVMomentumBoussinesq); 14 : 15 : InputParameters 16 824 : INSFVMomentumBoussinesq::validParams() 17 : { 18 824 : InputParameters params = FVElementalKernel::validParams(); 19 824 : params += INSFVMomentumResidualObject::validParams(); 20 824 : params.addClassDescription("Computes a body force for natural convection buoyancy."); 21 824 : params.addRequiredParam<MooseFunctorName>(NS::T_fluid, "the fluid temperature"); 22 1648 : params.addRequiredParam<RealVectorValue>("gravity", "Direction of the gravity vector"); 23 1648 : params.addParam<MooseFunctorName>("alpha_name", 24 : NS::alpha_boussinesq, 25 : "The name of the thermal expansion coefficient" 26 : "this is of the form rho = rho*(1-alpha (T-T_ref))"); 27 1648 : params.addRequiredParam<Real>("ref_temperature", "The value for the reference temperature."); 28 824 : params.addRequiredParam<MooseFunctorName>(NS::density, "The value for the density"); 29 824 : params.addPrivateParam("_override_constant_check", false); 30 824 : return params; 31 0 : } 32 : 33 480 : INSFVMomentumBoussinesq::INSFVMomentumBoussinesq(const InputParameters & params) 34 : : FVElementalKernel(params), 35 : INSFVMomentumResidualObject(*this), 36 960 : _temperature(getFunctor<ADReal>(NS::T_fluid)), 37 960 : _gravity(getParam<RealVectorValue>("gravity")), 38 960 : _alpha(getFunctor<ADReal>("alpha_name")), 39 960 : _ref_temperature(getParam<Real>("ref_temperature")), 40 960 : _rho(getFunctor<ADReal>(NS::density)) 41 : { 42 480 : if (!_rho.isConstant() && !getParam<bool>("_override_constant_check")) 43 0 : paramError(NS::density, "The density in the boussinesq term is not constant!"); 44 480 : } 45 : 46 : ADReal 47 4657914 : INSFVMomentumBoussinesq::computeQpResidual() 48 : { 49 4657914 : const auto elem = makeElemArg(_current_elem); 50 4657914 : const auto state = determineState(); 51 4657914 : return _alpha(elem, state) * _gravity(_index) * _rho(elem, state) * 52 9315828 : (_temperature(elem, state) - _ref_temperature); 53 : }