LCOV - code coverage report
Current view: top level - src/auxkernels - NSMachAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 33 34 97.1 %
Date: 2026-05-29 20:37:52 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             : // Navier-Stokes includes
      11             : #include "NSMachAux.h"
      12             : #include "NS.h"
      13             : 
      14             : // FluidProperties includes
      15             : #include "SinglePhaseFluidProperties.h"
      16             : 
      17             : // MOOSE includes
      18             : #include "MooseMesh.h"
      19             : 
      20             : #include "metaphysicl/raw_type.h"
      21             : 
      22             : registerMooseObject("NavierStokesApp", NSMachAux);
      23             : 
      24             : InputParameters
      25          87 : NSMachAux::validParams()
      26             : {
      27          87 :   InputParameters params = AuxKernel::validParams();
      28             : 
      29          87 :   params.addClassDescription(
      30             :       "Auxiliary kernel for computing the Mach number assuming an ideal gas.");
      31         174 :   params.addParam<bool>("use_material_properties",
      32         174 :                         false,
      33             :                         "Whether to use material properties to compute the Mach number");
      34          87 :   params.addCoupledVar(NS::velocity_x, "x-velocity");
      35          87 :   params.addCoupledVar(NS::velocity_y, "y-velocity"); // Only required in >= 2D
      36          87 :   params.addCoupledVar(NS::velocity_z, "z-velocity"); // Only required in 3D...
      37          87 :   params.addCoupledVar(NS::specific_volume, "specific volume");
      38          87 :   params.addCoupledVar(NS::specific_internal_energy, "internal energy");
      39         174 :   params.addRequiredParam<UserObjectName>("fluid_properties",
      40             :                                           "The name of the user object for fluid properties");
      41             : 
      42          87 :   return params;
      43           0 : }
      44             : 
      45          46 : NSMachAux::NSMachAux(const InputParameters & parameters)
      46             :   : AuxKernel(parameters),
      47          46 :     _use_mat_props(getParam<bool>("use_material_properties")),
      48          46 :     _u_vel(_use_mat_props ? nullptr : &coupledValue(NS::velocity_x)),
      49          46 :     _v_vel(_use_mat_props ? nullptr
      50          10 :                           : (_mesh.dimension() >= 2 ? &coupledValue(NS::velocity_y) : &_zero)),
      51          46 :     _w_vel(_use_mat_props ? nullptr
      52          10 :                           : (_mesh.dimension() == 3 ? &coupledValue(NS::velocity_z) : &_zero)),
      53          46 :     _specific_volume(_use_mat_props ? nullptr : &coupledValue(NS::specific_volume)),
      54          46 :     _specific_internal_energy(_use_mat_props ? nullptr
      55          10 :                                              : &coupledValue(NS::specific_internal_energy)),
      56          46 :     _mat_speed(_use_mat_props ? &getADMaterialProperty<Real>(NS::speed) : nullptr),
      57          46 :     _mat_pressure(_use_mat_props ? &getADMaterialProperty<Real>(NS::pressure) : nullptr),
      58          46 :     _mat_T_fluid(_use_mat_props ? &getADMaterialProperty<Real>(NS::T_fluid) : nullptr),
      59          92 :     _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
      60             : {
      61          46 : }
      62             : 
      63             : Real
      64      436455 : NSMachAux::computeValue()
      65             : {
      66      436455 :   if (_use_mat_props)
      67      151830 :     return MetaPhysicL::raw_value((*_mat_speed)[_qp] /
      68      303660 :                                   _fp.c_from_p_T((*_mat_pressure)[_qp], (*_mat_T_fluid)[_qp]));
      69             :   else
      70      284625 :     return RealVectorValue((*_u_vel)[_qp], (*_v_vel)[_qp], (*_w_vel)[_qp]).norm() /
      71      284625 :            _fp.c_from_v_e((*_specific_volume)[_qp], (*_specific_internal_energy)[_qp]);
      72             : }

Generated by: LCOV version 1.14