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 "MassFluxPenaltyBC.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("NavierStokesApp", MassFluxPenaltyBC); 14 : 15 : InputParameters 16 444 : MassFluxPenaltyBC::validParams() 17 : { 18 444 : InputParameters params = ADIntegratedBC::validParams(); 19 888 : params.addRequiredCoupledVar("u", "The x-velocity"); 20 888 : params.addRequiredCoupledVar("v", "The y-velocity"); 21 888 : params.addRequiredParam<unsigned short>("component", 22 : "The velocity component this object is being applied to"); 23 888 : params.addParam<Real>("gamma", 1, "The penalty to multiply the jump with"); 24 444 : params.addClassDescription("Adds the exterior boundary contribution of penalized jumps in the " 25 : "velocity variable in one component of the momentum equations."); 26 888 : params.addRequiredParam<FunctionName>("dirichlet_value", 27 : "The velocity Dirichlet value on the boundary"); 28 444 : return params; 29 0 : } 30 : 31 236 : MassFluxPenaltyBC::MassFluxPenaltyBC(const InputParameters & parameters) 32 : : ADIntegratedBC(parameters), 33 236 : _vel_x(adCoupledValue("u")), 34 236 : _vel_y(adCoupledValue("v")), 35 472 : _comp(getParam<unsigned short>("component")), 36 472 : _matrix_only(getParam<bool>("matrix_only")), 37 472 : _gamma(getParam<Real>("gamma")), 38 944 : _dirichlet_func(isParamValid("dirichlet_value") ? &getFunction("dirichlet_value") : nullptr) 39 : { 40 236 : if (_mesh.dimension() > 2) 41 0 : mooseError("This class only supports 2D simulations at this time"); 42 236 : } 43 : 44 : void 45 33344 : MassFluxPenaltyBC::computeResidual() 46 : { 47 33344 : if (!_matrix_only) 48 30464 : ADIntegratedBC::computeResidual(); 49 33344 : } 50 : 51 : ADReal 52 624192 : MassFluxPenaltyBC::computeQpResidual() 53 : { 54 624192 : ADRealVectorValue soln_jump(_vel_x[_qp], _vel_y[_qp], 0); 55 624192 : if (_dirichlet_func) 56 1248384 : soln_jump -= _dirichlet_func->vectorValue(_t, _q_point[_qp]); 57 : 58 1248384 : return _gamma * soln_jump * _normals[_qp] * _test[_i][_qp] * _normals[_qp](_comp); 59 : }