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 "LinearFVMomentumBuoyancy.h" 11 : #include "Assembly.h" 12 : #include "SubProblem.h" 13 : #include "NS.h" 14 : #include "FEProblemBase.h" 15 : 16 : registerMooseObject("NavierStokesApp", LinearFVMomentumBuoyancy); 17 : 18 : InputParameters 19 76 : LinearFVMomentumBuoyancy::validParams() 20 : { 21 76 : InputParameters params = LinearFVElementalKernel::validParams(); 22 76 : params.addClassDescription("Represents the buoyancy term in the Navier Stokes momentum " 23 : "equations, added to the right hand side."); 24 : 25 152 : params.addRequiredParam<RealVectorValue>("gravity", "Gravitational acceleration vector."); 26 76 : params.addRequiredParam<MooseFunctorName>(NS::density, "The value for the density"); 27 152 : params.addRequiredParam<Real>("reference_rho", "The value for the reference density"); 28 152 : MooseEnum momentum_component("x=0 y=1 z=2"); 29 152 : params.addRequiredParam<MooseEnum>( 30 : "momentum_component", 31 : momentum_component, 32 : "The component of the momentum equation that this kernel applies to."); 33 : 34 76 : return params; 35 76 : } 36 : 37 38 : LinearFVMomentumBuoyancy::LinearFVMomentumBuoyancy(const InputParameters & params) 38 : : LinearFVElementalKernel(params), 39 38 : _index(getParam<MooseEnum>("momentum_component")), 40 38 : _rho(getFunctor<Real>(NS::density)), 41 76 : _rho_0(getParam<Real>("reference_rho")), 42 114 : _gravity(getParam<RealVectorValue>("gravity")) 43 : { 44 38 : } 45 : 46 : Real 47 483750 : LinearFVMomentumBuoyancy::computeMatrixContribution() 48 : { 49 483750 : return 0.0; 50 : } 51 : 52 : Real 53 612750 : LinearFVMomentumBuoyancy::computeRightHandSideContribution() 54 : { 55 612750 : const auto elem = makeElemArg(_current_elem_info->elem()); 56 612750 : const auto state = determineState(); 57 612750 : return (_rho(elem, state) - _rho_0) * _gravity(_index) * _current_elem_volume; 58 : }