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 "MassFluxPenalty.h" 11 : 12 : // MOOSE includes 13 : #include "MooseVariableFE.h" 14 : 15 : #include "libmesh/utility.h" 16 : 17 : registerMooseObject("NavierStokesApp", MassFluxPenalty); 18 : 19 : InputParameters 20 142 : MassFluxPenalty::validParams() 21 : { 22 142 : InputParameters params = ADDGKernel::validParams(); 23 284 : params.addRequiredCoupledVar("u", "The x-velocity"); 24 284 : params.addRequiredCoupledVar("v", "The y-velocity"); 25 284 : params.addRequiredParam<unsigned short>("component", 26 : "The velocity component this object is being applied to"); 27 284 : params.addParam<Real>("gamma", 1, "The penalty to multiply the jump"); 28 142 : params.addClassDescription( 29 : "introduces a jump correction for grad-div stabilization for discontinuous Galerkin methods"); 30 142 : return params; 31 0 : } 32 : 33 78 : MassFluxPenalty::MassFluxPenalty(const InputParameters & parameters) 34 : : ADDGKernel(parameters), 35 78 : _vel_x(adCoupledValue("u")), 36 78 : _vel_x_neighbor(adCoupledNeighborValue("u")), 37 78 : _vel_y(adCoupledValue("v")), 38 78 : _vel_y_neighbor(adCoupledNeighborValue("v")), 39 156 : _comp(getParam<unsigned short>("component")), 40 156 : _matrix_only(getParam<bool>("matrix_only")), 41 234 : _gamma(getParam<Real>("gamma")) 42 : { 43 78 : if (_mesh.dimension() > 2) 44 0 : mooseError("This class only supports 2D simulations at this time"); 45 78 : } 46 : 47 : void 48 149200 : MassFluxPenalty::computeResidual() 49 : { 50 149200 : if (!_matrix_only) 51 139840 : ADDGKernel::computeResidual(); 52 149200 : } 53 : 54 : ADReal 55 2906400 : MassFluxPenalty::computeQpResidual(Moose::DGResidualType type) 56 : { 57 2906400 : ADReal r = 0.0; 58 : const ADRealVectorValue soln_jump( 59 5812800 : _vel_x[_qp] - _vel_x_neighbor[_qp], _vel_y[_qp] - _vel_y_neighbor[_qp], 0); 60 : 61 2906400 : switch (type) 62 : { 63 1453200 : case Moose::Element: 64 2906400 : r = _gamma * soln_jump * _normals[_qp] * _test[_i][_qp] * _normals[_qp](_comp); 65 1453200 : break; 66 : 67 1453200 : case Moose::Neighbor: 68 2906400 : r = -_gamma * soln_jump * _normals[_qp] * _test_neighbor[_i][_qp] * _normals[_qp](_comp); 69 1453200 : break; 70 : } 71 : 72 2906400 : return r; 73 : }