LCOV - code coverage report
Current view: top level - src/fvbcs - WCNSFVMomentumFluxBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #31653 (2d163b) with base 0cc44f Lines: 23 27 85.2 %
Date: 2025-11-04 20:40:30 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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             :   using std::abs;
      46             : 
      47       19362 :   const auto state = determineState();
      48             : 
      49       19362 :   if (!isInflow())
      50             :   {
      51         579 :     const auto fa = singleSidedFaceArg();
      52         579 :     const auto vel_vec = varVelocity(state);
      53        1158 :     return vel_vec * _normal * _rho(fa, state) * vel_vec(_index);
      54             :   }
      55             : 
      56             :   const Point incoming_vector =
      57       18783 :       !_direction_specified_by_user ? Point(-_face_info->normal()) : _direction;
      58       18783 :   ADReal a = 1;
      59       18783 :   if (_velocity_pp)
      60       14462 :     a = 1.0 / abs(incoming_vector * _normal);
      61       37563 :   return -_scaling_factor * a * inflowMassFlux(state) * inflowSpeed(state) *
      62       18783 :          incoming_vector(_index);
      63             : }

Generated by: LCOV version 1.14