LCOV - code coverage report
Current view: top level - src/fvbcs - WCNSFVMomentumFluxBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 23 27 85.2 %
Date: 2025-08-14 10:14:56 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         602 : WCNSFVMomentumFluxBC::validParams()
      18             : {
      19         602 :   InputParameters params = WCNSFVFluxBCBase::validParams();
      20             : 
      21         602 :   params += INSFVMomentumResidualObject::validParams();
      22         602 :   params.addClassDescription("Flux boundary conditions for momentum advection.");
      23             : 
      24         602 :   return params;
      25           0 : }
      26             : 
      27         379 : WCNSFVMomentumFluxBC::WCNSFVMomentumFluxBC(const InputParameters & params)
      28         379 :   : WCNSFVFluxBCBase(params), INSFVMomentumResidualObject(*this)
      29             : {
      30         375 :   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         375 :   if (_mdot_pp && !_area_pp)
      37           0 :     mooseError("The inlet area should be provided along with the mass flow rate");
      38         375 :   if (!_mdot_pp && !_velocity_pp)
      39           0 :     mooseError("Velocity should be provided if the mass flow rate is not");
      40         375 : }
      41             : 
      42             : ADReal
      43       17391 : WCNSFVMomentumFluxBC::computeQpResidual()
      44             : {
      45       17391 :   const auto state = determineState();
      46             : 
      47       17391 :   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       16812 :       !_direction_specified_by_user ? Point(-_face_info->normal()) : _direction;
      56       16812 :   ADReal a = 1;
      57       16812 :   if (_velocity_pp)
      58       10520 :     a = 1.0 / std::abs(incoming_vector * _normal);
      59       16812 :   return -_scaling_factor * a * inflowMassFlux(state) * inflowSpeed(state) *
      60       16812 :          incoming_vector(_index);
      61             : }

Generated by: LCOV version 1.14