Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 "MassFluxPenaltyIPHDGAssemblyHelper.h" 11 : 12 : // MOOSE includes 13 : #include "MooseVariableFE.h" 14 : 15 : InputParameters 16 536 : MassFluxPenaltyIPHDGAssemblyHelper::validParams() 17 : { 18 536 : InputParameters params = IPHDGAssemblyHelper::validParams(); 19 1072 : params.addRequiredParam<NonlinearVariableName>("u", "The x-velocity"); 20 1072 : params.addRequiredParam<NonlinearVariableName>("v", "The y-velocity"); 21 1072 : params.addParam<NonlinearVariableName>("w", "The z-velocity"); 22 1072 : params.addRequiredRangeCheckedParam<unsigned short>( 23 : "component", "0<=component<=1", "The velocity component this object is being applied to"); 24 1072 : params.addRequiredParam<Real>("gamma", "The penalty to multiply the jump"); 25 536 : params.addClassDescription("introduces a jump correction on internal faces for grad-div " 26 : "stabilization for discontinuous Galerkin methods."); 27 1072 : params.addRequiredParam<MooseFunctorName>("face_velocity", 28 : "A vector functor representing the face velocity"); 29 536 : return params; 30 0 : } 31 : 32 274 : MassFluxPenaltyIPHDGAssemblyHelper::MassFluxPenaltyIPHDGAssemblyHelper( 33 : const MooseObject * const moose_obj, 34 : MooseVariableDependencyInterface * const mvdi, 35 : const TransientInterface * const ti, 36 : const MooseMesh & mesh, 37 : SystemBase & sys, 38 : const Assembly & assembly, 39 : const THREAD_ID tid, 40 : const std::set<SubdomainID> & block_ids, 41 274 : const std::set<BoundaryID> & boundary_ids) 42 : : IPHDGAssemblyHelper(moose_obj, mvdi, ti, sys, assembly, tid, block_ids, boundary_ids), 43 : ADFunctorInterface(moose_obj), 44 274 : _vel_x_var(sys.getFieldVariable<Real>(tid, moose_obj->getParam<NonlinearVariableName>("u"))), 45 548 : _vel_y_var(sys.getFieldVariable<Real>(tid, moose_obj->getParam<NonlinearVariableName>("v"))), 46 274 : _vel_x(_vel_x_var.adSln()), 47 274 : _vel_y(_vel_y_var.adSln()), 48 274 : _vel_z(moose_obj->isParamValid("w") 49 274 : ? &sys.getFieldVariable<Real>(tid, moose_obj->getParam<NonlinearVariableName>("w")) 50 0 : .adSln() 51 : : nullptr), 52 548 : _comp(moose_obj->getParam<unsigned short>("component")), 53 548 : _gamma(moose_obj->getParam<Real>("gamma")), 54 548 : _face_velocity(getFunctor<ADRealVectorValue>("face_velocity")), 55 274 : _hmax(0) 56 : { 57 274 : if ((mesh.dimension() > 2) && !moose_obj->isParamValid("w")) 58 0 : moose_obj->paramError("w", "For 3D meshes, the z-velocity must be provided"); 59 274 : } 60 : 61 : void 62 1729508 : MassFluxPenaltyIPHDGAssemblyHelper::scalarFace() 63 : { 64 1729508 : _hmax = _ip_current_side_elem->hmax(); 65 : 66 6906392 : for (const auto qp : make_range(_ip_qrule_face->n_points())) 67 : { 68 10353768 : const auto qp_term = computeQpResidualOnSide(qp) * _ip_JxW_face[qp]; 69 36168348 : for (const auto i : index_range(_scalar_re)) 70 61982928 : _scalar_re(i) += qp_term * _scalar_phi_face[i][qp]; 71 : } 72 1729508 : } 73 : 74 : void 75 1673708 : MassFluxPenaltyIPHDGAssemblyHelper::lmFace() 76 : { 77 1673708 : _hmax = _ip_current_side_elem->hmax(); 78 : 79 6694832 : for (const auto qp : make_range(_ip_qrule_face->n_points())) 80 : { 81 10042248 : const auto qp_term = computeQpResidualOnSide(qp) * _ip_JxW_face[qp]; 82 50211240 : for (const auto i : index_range(_lm_re)) 83 90380232 : _lm_re(i) -= qp_term * _lm_phi_face[i][qp]; 84 : } 85 1673708 : } 86 : 87 : ADReal 88 10198008 : MassFluxPenaltyIPHDGAssemblyHelper::computeQpResidualOnSide(const unsigned int qp) 89 : { 90 10198008 : ADRealVectorValue soln_jump(_vel_x[qp], _vel_y[qp], 0); 91 10198008 : if (_vel_z) 92 0 : soln_jump(2) = (*_vel_z)[qp]; 93 10198008 : soln_jump -= _face_velocity( 94 20396016 : Moose::ElemSideQpArg{ 95 10198008 : _ip_current_elem, _ip_current_side, qp, _ip_qrule_face, _ip_q_point_face[qp]}, 96 10198008 : _ti.determineState()); 97 : 98 20396016 : return _gamma / _hmax * soln_jump * _ip_normals[qp] * _ip_normals[qp](_comp); 99 : }