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 78 : MassFluxPenalty::validParams() 21 : { 22 78 : InputParameters params = ADDGKernel::validParams(); 23 156 : params.addRequiredCoupledVar("u", "The x-velocity"); 24 156 : params.addRequiredCoupledVar("v", "The y-velocity"); 25 156 : params.addRequiredParam<unsigned short>("component", 26 : "The velocity component this object is being applied to"); 27 156 : params.addParam<Real>("gamma", 1, "The penalty to multiply the jump"); 28 78 : 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 78 : return params; 32 0 : } 33 : 34 42 : MassFluxPenalty::MassFluxPenalty(const InputParameters & parameters) 35 : : ADDGKernel(parameters), 36 42 : _vel_x(adCoupledValue("u")), 37 42 : _vel_x_neighbor(adCoupledNeighborValue("u")), 38 42 : _vel_y(adCoupledValue("v")), 39 42 : _vel_y_neighbor(adCoupledNeighborValue("v")), 40 84 : _comp(getParam<unsigned short>("component")), 41 84 : _matrix_only(getParam<bool>("matrix_only")), 42 84 : _gamma(getParam<Real>("gamma")), 43 42 : _hmax(0) 44 : { 45 42 : if (_mesh.dimension() > 2) 46 0 : mooseError("This class only supports 2D simulations at this time"); 47 42 : } 48 : 49 : void 50 313976 : MassFluxPenalty::precalculateResidual() 51 : { 52 313976 : _hmax = _current_side_elem->hmax(); 53 313976 : } 54 : 55 : void 56 75856 : MassFluxPenalty::computeResidual() 57 : { 58 75856 : if (!_matrix_only) 59 70656 : ADDGKernel::computeResidual(); 60 75856 : } 61 : 62 : ADReal 63 1506720 : MassFluxPenalty::computeQpResidual(Moose::DGResidualType type) 64 : { 65 1506720 : ADReal r = 0.0; 66 : const ADRealVectorValue soln_jump( 67 3013440 : _vel_x[_qp] - _vel_x_neighbor[_qp], _vel_y[_qp] - _vel_y_neighbor[_qp], 0); 68 : 69 1506720 : switch (type) 70 : { 71 753360 : case Moose::Element: 72 1506720 : r = _gamma / _hmax * soln_jump * _normals[_qp] * _test[_i][_qp] * _normals[_qp](_comp); 73 753360 : break; 74 : 75 753360 : case Moose::Neighbor: 76 753360 : r = -_gamma / _hmax * soln_jump * _normals[_qp] * _test_neighbor[_i][_qp] * 77 1506720 : _normals[_qp](_comp); 78 753360 : break; 79 : } 80 : 81 1506720 : return r; 82 : }