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("Introduces a jump correction on internal faces for grad-div " 29 : "stabilization for discontinuous Galerkin methods. Because this is " 30 : "derived from DGKernel this class executes once per face."); 31 142 : return params; 32 0 : } 33 : 34 78 : MassFluxPenalty::MassFluxPenalty(const InputParameters & parameters) 35 : : ADDGKernel(parameters), 36 78 : _vel_x(adCoupledValue("u")), 37 78 : _vel_x_neighbor(adCoupledNeighborValue("u")), 38 78 : _vel_y(adCoupledValue("v")), 39 78 : _vel_y_neighbor(adCoupledNeighborValue("v")), 40 156 : _comp(getParam<unsigned short>("component")), 41 156 : _matrix_only(getParam<bool>("matrix_only")), 42 234 : _gamma(getParam<Real>("gamma")) 43 : { 44 78 : if (_mesh.dimension() > 2) 45 0 : mooseError("This class only supports 2D simulations at this time"); 46 78 : } 47 : 48 : void 49 149200 : MassFluxPenalty::computeResidual() 50 : { 51 149200 : if (!_matrix_only) 52 139840 : ADDGKernel::computeResidual(); 53 149200 : } 54 : 55 : ADReal 56 2906400 : MassFluxPenalty::computeQpResidual(Moose::DGResidualType type) 57 : { 58 2906400 : ADReal r = 0.0; 59 : const ADRealVectorValue soln_jump( 60 5812800 : _vel_x[_qp] - _vel_x_neighbor[_qp], _vel_y[_qp] - _vel_y_neighbor[_qp], 0); 61 : 62 2906400 : switch (type) 63 : { 64 1453200 : case Moose::Element: 65 2906400 : r = _gamma * soln_jump * _normals[_qp] * _test[_i][_qp] * _normals[_qp](_comp); 66 1453200 : break; 67 : 68 1453200 : case Moose::Neighbor: 69 2906400 : r = -_gamma * soln_jump * _normals[_qp] * _test_neighbor[_i][_qp] * _normals[_qp](_comp); 70 1453200 : break; 71 : } 72 : 73 2906400 : return r; 74 : }