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 "LinearFVMomentumPressure.h" 11 : #include "Assembly.h" 12 : #include "SubProblem.h" 13 : #include "NS.h" 14 : #include "FEProblemBase.h" 15 : 16 : registerMooseObject("NavierStokesApp", LinearFVMomentumPressure); 17 : 18 : InputParameters 19 2471 : LinearFVMomentumPressure::validParams() 20 : { 21 2471 : InputParameters params = LinearFVElementalKernel::validParams(); 22 2471 : params.addClassDescription("Represents the pressure gradient term in the Navier Stokes momentum " 23 : "equations, added to the right hand side."); 24 2471 : params.addParam<VariableName>(NS::pressure, 25 : "The pressure variable whose gradient should be used."); 26 4942 : MooseEnum momentum_component("x=0 y=1 z=2"); 27 4942 : params.addRequiredParam<MooseEnum>( 28 : "momentum_component", 29 : momentum_component, 30 : "The component of the momentum equation that this kernel applies to."); 31 2471 : return params; 32 2471 : } 33 : 34 1298 : LinearFVMomentumPressure::LinearFVMomentumPressure(const InputParameters & params) 35 : : LinearFVElementalKernel(params), 36 1298 : _index(getParam<MooseEnum>("momentum_component")), 37 2596 : _pressure_var(getPressureVariable(NS::pressure)) 38 : { 39 : _pressure_var.computeCellGradients(); 40 1298 : } 41 : 42 : MooseLinearVariableFV<Real> & 43 1298 : LinearFVMomentumPressure::getPressureVariable(const std::string & vname) 44 : { 45 1298 : auto * ptr = dynamic_cast<MooseLinearVariableFV<Real> *>( 46 1298 : &_fe_problem.getVariable(_tid, getParam<VariableName>(vname))); 47 : 48 1298 : if (!ptr) 49 0 : paramError(NS::pressure, "The pressure variable should be of type MooseLinearVariableFVReal!"); 50 : 51 1298 : return *ptr; 52 : } 53 : 54 : Real 55 20382532 : LinearFVMomentumPressure::computeMatrixContribution() 56 : { 57 20382532 : return 0.0; 58 : } 59 : 60 : Real 61 20382532 : LinearFVMomentumPressure::computeRightHandSideContribution() 62 : { 63 20382532 : return -_pressure_var.gradSlnComponent(*_current_elem_info, _index) * _current_elem_volume; 64 : }