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 "WCNSFVMomentumFluxBC.h" 11 : #include "INSFVVelocityVariable.h" 12 : #include "NS.h" 13 : 14 : registerMooseObject("NavierStokesApp", WCNSFVMomentumFluxBC); 15 : 16 : InputParameters 17 706 : WCNSFVMomentumFluxBC::validParams() 18 : { 19 706 : InputParameters params = WCNSFVFluxBCBase::validParams(); 20 : 21 706 : params += INSFVMomentumResidualObject::validParams(); 22 706 : params.addClassDescription("Flux boundary conditions for momentum advection."); 23 : 24 706 : return params; 25 0 : } 26 : 27 445 : WCNSFVMomentumFluxBC::WCNSFVMomentumFluxBC(const InputParameters & params) 28 445 : : WCNSFVFluxBCBase(params), INSFVMomentumResidualObject(*this) 29 : { 30 441 : if (!dynamic_cast<INSFVVelocityVariable *>(&_var)) 31 0 : paramError( 32 : "variable", 33 : "The variable argument to WCNSFVMomentumFluxBC must be of type INSFVVelocityVariable"); 34 : 35 : // Need enough information to compute the mass flux 36 441 : if (_mdot_pp && !_area_pp) 37 0 : mooseError("The inlet area should be provided along with the mass flow rate"); 38 441 : if (!_mdot_pp && !_velocity_pp) 39 0 : mooseError("Velocity should be provided if the mass flow rate is not"); 40 441 : } 41 : 42 : ADReal 43 19362 : WCNSFVMomentumFluxBC::computeQpResidual() 44 : { 45 19362 : const auto state = determineState(); 46 : 47 19362 : if (!isInflow()) 48 : { 49 579 : const auto fa = singleSidedFaceArg(); 50 579 : const auto vel_vec = varVelocity(state); 51 1158 : return vel_vec * _normal * _rho(fa, state) * vel_vec(_index); 52 : } 53 : 54 : const Point incoming_vector = 55 18783 : !_direction_specified_by_user ? Point(-_face_info->normal()) : _direction; 56 18783 : ADReal a = 1; 57 18783 : if (_velocity_pp) 58 14462 : a = 1.0 / std::abs(incoming_vector * _normal); 59 18783 : return -_scaling_factor * a * inflowMassFlux(state) * inflowSpeed(state) * 60 18783 : incoming_vector(_index); 61 : }