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 "INSFEFluidMassBC.h" 11 : 12 : registerMooseObject("NavierStokesApp", INSFEFluidMassBC); 13 : registerMooseObjectRenamed("NavierStokesApp", MDFluidMassBC, "02/01/2024 00:00", INSFEFluidMassBC); 14 : 15 : InputParameters 16 287 : INSFEFluidMassBC::validParams() 17 : { 18 287 : InputParameters params = INSFEFluidIntegratedBCBase::validParams(); 19 287 : params.addClassDescription( 20 : "Specifies flow of mass through a boundary given a velocity function or postprocessor"); 21 574 : params.addParam<FunctionName>("v_fn", "Velocity function with time at the boundary"); 22 574 : params.addParam<std::string>("v_pps", 23 : "The Postprocessor name to setup the velocity boundary value."); 24 : 25 287 : return params; 26 0 : } 27 : 28 154 : INSFEFluidMassBC::INSFEFluidMassBC(const InputParameters & parameters) 29 : : INSFEFluidIntegratedBCBase(parameters), 30 154 : _has_vfn(parameters.isParamValid("v_fn")), 31 154 : _has_vpps(parameters.isParamValid("v_pps")), 32 154 : _velocity_fn(_has_vfn ? &getFunction("v_fn") : NULL), 33 308 : _v_pps_name(_has_vpps ? getParam<std::string>("v_pps") : "") 34 : { 35 154 : if (_has_vfn && _has_vpps) 36 0 : mooseError("'v_fn' and 'v_pps' cannot be BOTH specified in INSFEFluidMassBC."); 37 154 : } 38 : 39 : Real 40 1037184 : INSFEFluidMassBC::computeQpResidual() 41 : { 42 1037184 : RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]); 43 : 44 : Real v_bc = 0; 45 1037184 : if (_has_vfn) 46 356768 : v_bc = -_velocity_fn->value(_t, _q_point[_qp]); // normals[i] at inlet is negative. 47 680416 : else if (_has_vpps) 48 0 : v_bc = -getPostprocessorValueByName(_v_pps_name); 49 : else 50 680416 : v_bc = vec_vel * _normals[_qp]; 51 : 52 1037184 : return _rho[_qp] * v_bc * _test[_i][_qp]; 53 : } 54 : 55 : Real 56 145280 : INSFEFluidMassBC::computeQpJacobian() 57 : { 58 145280 : return 0; 59 : } 60 : 61 : Real 62 404096 : INSFEFluidMassBC::computeQpOffDiagJacobian(unsigned int jvar) 63 : { 64 404096 : unsigned m = this->mapVarNumber(jvar); 65 : 66 404096 : switch (m) 67 : { 68 290560 : case 1: 69 : case 2: 70 : case 3: 71 : { 72 290560 : if (_has_vfn || _has_vpps) 73 : return 0.; 74 : else 75 76032 : return _rho[_qp] * _phi[_j][_qp] * _normals[_qp](m - 1) * _test[_i][_qp]; 76 : } 77 : 78 113536 : case 4: 79 : { 80 113536 : RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]); 81 : Real rho, drho_dp, drho_dT; 82 113536 : _eos.rho_from_p_T(_u[_qp], _temperature[_qp], rho, drho_dp, drho_dT); 83 113536 : return drho_dT * _phi[_j][_qp] * vec_vel * _normals[_qp] * _test[_i][_qp]; 84 : } 85 : 86 : default: 87 : return 0; 88 : } 89 : }