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 3310 : LinearFVMomentumPressure::validParams() 20 : { 21 3310 : InputParameters params = LinearFVElementalKernel::validParams(); 22 3310 : params.addClassDescription("Represents the pressure gradient term in the Navier Stokes momentum " 23 : "equations, added to the right hand side."); 24 3310 : params.addParam<VariableName>(NS::pressure, 25 : "The pressure variable whose gradient should be used."); 26 6620 : MooseEnum momentum_component("x=0 y=1 z=2"); 27 6620 : params.addRequiredParam<MooseEnum>( 28 : "momentum_component", 29 : momentum_component, 30 : "The component of the momentum equation that this kernel applies to."); 31 3310 : return params; 32 3310 : } 33 : 34 1745 : LinearFVMomentumPressure::LinearFVMomentumPressure(const InputParameters & params) 35 : : LinearFVElementalKernel(params), 36 1745 : _index(getParam<MooseEnum>("momentum_component")), 37 1745 : _pressure_var(getPressureVariable(NS::pressure)), 38 1745 : _pressure_gradient(_pressure_var.sys().gradientContainer()), 39 1745 : _pressure_var_num(_pressure_var.number()), 40 3490 : _pressure_sys_num(_pressure_var.sys().number()) 41 : { 42 1745 : _pressure_var.computeCellGradients(); 43 1745 : } 44 : 45 : MooseLinearVariableFV<Real> & 46 1745 : LinearFVMomentumPressure::getPressureVariable(const std::string & vname) 47 : { 48 1745 : auto * ptr = dynamic_cast<MooseLinearVariableFV<Real> *>( 49 1745 : &_fe_problem.getVariable(_tid, getParam<VariableName>(vname))); 50 : 51 1745 : if (!ptr) 52 0 : paramError(NS::pressure, "The pressure variable should be of type MooseLinearVariableFVReal!"); 53 : 54 1745 : return *ptr; 55 : } 56 : 57 : Real 58 28833198 : LinearFVMomentumPressure::computeMatrixContribution() 59 : { 60 28833198 : return 0.0; 61 : } 62 : 63 : Real 64 28833198 : LinearFVMomentumPressure::computeRightHandSideContribution() 65 : { 66 28833198 : const auto dof_value = _current_elem_info->dofIndices()[_pressure_sys_num][_pressure_var_num]; 67 28833198 : return -(*_pressure_gradient[_index])(dof_value)*_current_elem_volume; 68 : }