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 "GradDiv.h" 11 : 12 : registerMooseObject("NavierStokesApp", GradDiv); 13 : 14 : InputParameters 15 142 : GradDiv::validParams() 16 : { 17 142 : InputParameters params = ADKernel::validParams(); 18 284 : params.addRequiredCoupledVar("u", "The x-velocity"); 19 284 : params.addRequiredCoupledVar("v", "The y-velocity"); 20 284 : params.addRequiredParam<unsigned short>("component", 21 : "The velocity component this object is being applied to"); 22 284 : params.addParam<Real>("gamma", 1, "The penalty parameter"); 23 142 : params.addClassDescription("Adds grad-div stabilization for scalar field velocity component " 24 : "Navier-Stokes implementations."); 25 142 : return params; 26 0 : } 27 : 28 78 : GradDiv::GradDiv(const InputParameters & parameters) 29 : : ADKernel(parameters), 30 78 : _grad_vel_x(adCoupledGradient("u")), 31 78 : _grad_vel_y(adCoupledGradient("v")), 32 156 : _comp(getParam<unsigned short>("component")), 33 156 : _matrix_only(getParam<bool>("matrix_only")), 34 234 : _gamma(getParam<Real>("gamma")) 35 : { 36 78 : } 37 : 38 : void 39 104480 : GradDiv::computeResidual() 40 : { 41 104480 : if (!_matrix_only) 42 97280 : ADKernel::computeResidual(); 43 104480 : } 44 : 45 : ADReal 46 2050440 : GradDiv::computeQpResidual() 47 : { 48 4100880 : return _gamma * (_grad_vel_x[_qp](0) + _grad_vel_y[_qp](1)) * _grad_test[_i][_qp](_comp); 49 : }