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 "PressureGradient.h" 11 : #include "NS.h" 12 : 13 : registerMooseObject("NavierStokesApp", PressureGradient); 14 : 15 : InputParameters 16 1338 : PressureGradient::validParams() 17 : { 18 1338 : InputParameters params = Kernel::validParams(); 19 1338 : params.addRequiredCoupledVar(NS::pressure, "pressure"); 20 2676 : params.addRequiredParam<unsigned int>("component", "number of component (0 = x, 1 = y, 2 = z)"); 21 1338 : params.addClassDescription( 22 : "Implements the pressure gradient term for one of the Navier Stokes momentum equations."); 23 2676 : params.addParam<bool>( 24 2676 : "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts"); 25 : 26 1338 : return params; 27 0 : } 28 : 29 674 : PressureGradient::PressureGradient(const InputParameters & parameters) 30 : : Kernel(parameters), 31 674 : _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")), 32 1348 : _component(getParam<unsigned int>("component")), 33 674 : _pressure(coupledValue(NS::pressure)), 34 674 : _grad_pressure(coupledGradient(NS::pressure)), 35 674 : _pressure_id(coupled(NS::pressure)), 36 674 : _coord_sys(_assembly.coordSystem()), 37 1348 : _rz_radial_coord(_mesh.getAxisymmetricRadialCoord()) 38 : { 39 674 : } 40 : 41 : Real 42 32991888 : PressureGradient::computeQpResidual() 43 : { 44 32991888 : if (_integrate_p_by_parts) 45 : { 46 17075520 : auto residual = -_pressure[_qp] * _grad_test[_i][_qp](_component); 47 17075520 : if (_coord_sys == Moose::COORD_RZ && (_rz_radial_coord == _component)) 48 8537760 : residual -= _pressure[_qp] / _q_point[_qp](_rz_radial_coord) * _test[_i][_qp]; 49 17075520 : return residual; 50 : } 51 : else 52 15916368 : return _test[_i][_qp] * _grad_pressure[_qp](_component); 53 : } 54 : 55 : Real 56 60427512 : PressureGradient::computeQpJacobian() 57 : { 58 60427512 : return 0.; 59 : } 60 : 61 : Real 62 140352228 : PressureGradient::computeQpOffDiagJacobian(const unsigned int jvar) 63 : { 64 140352228 : if (jvar == _pressure_id) 65 : { 66 44543916 : if (_integrate_p_by_parts) 67 : { 68 4116420 : auto residual = -_phi[_j][_qp] * _grad_test[_i][_qp](_component); 69 4116420 : if (_coord_sys == Moose::COORD_RZ && (_rz_radial_coord == _component)) 70 2058210 : residual -= _phi[_j][_qp] / _q_point[_qp](_rz_radial_coord) * _test[_i][_qp]; 71 4116420 : return residual; 72 : } 73 : else 74 40427496 : return _test[_i][_qp] * _grad_phi[_j][_qp](_component); 75 : } 76 : else 77 : return 0; 78 : }