LCOV - code coverage report
Current view: top level - src/auxkernels - NSMachAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 33 34 97.1 %
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             : // 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         165 : NSMachAux::validParams()
      26             : {
      27         165 :   InputParameters params = AuxKernel::validParams();
      28             : 
      29         165 :   params.addClassDescription(
      30             :       "Auxiliary kernel for computing the Mach number assuming an ideal gas.");
      31         330 :   params.addParam<bool>("use_material_properties",
      32         330 :                         false,
      33             :                         "Whether to use material properties to compute the Mach number");
      34         165 :   params.addCoupledVar(NS::velocity_x, "x-velocity");
      35         165 :   params.addCoupledVar(NS::velocity_y, "y-velocity"); // Only required in >= 2D
      36         165 :   params.addCoupledVar(NS::velocity_z, "z-velocity"); // Only required in 3D...
      37         165 :   params.addCoupledVar(NS::specific_volume, "specific volume");
      38         165 :   params.addCoupledVar(NS::specific_internal_energy, "internal energy");
      39         330 :   params.addRequiredParam<UserObjectName>("fluid_properties",
      40             :                                           "The name of the user object for fluid properties");
      41             : 
      42         165 :   return params;
      43           0 : }
      44             : 
      45          90 : NSMachAux::NSMachAux(const InputParameters & parameters)
      46             :   : AuxKernel(parameters),
      47          90 :     _use_mat_props(getParam<bool>("use_material_properties")),
      48          90 :     _u_vel(_use_mat_props ? nullptr : &coupledValue(NS::velocity_x)),
      49          90 :     _v_vel(_use_mat_props ? nullptr
      50          22 :                           : (_mesh.dimension() >= 2 ? &coupledValue(NS::velocity_y) : &_zero)),
      51          90 :     _w_vel(_use_mat_props ? nullptr
      52          22 :                           : (_mesh.dimension() == 3 ? &coupledValue(NS::velocity_z) : &_zero)),
      53          90 :     _specific_volume(_use_mat_props ? nullptr : &coupledValue(NS::specific_volume)),
      54          90 :     _specific_internal_energy(_use_mat_props ? nullptr
      55          22 :                                              : &coupledValue(NS::specific_internal_energy)),
      56          90 :     _mat_speed(_use_mat_props ? &getADMaterialProperty<Real>(NS::speed) : nullptr),
      57          90 :     _mat_pressure(_use_mat_props ? &getADMaterialProperty<Real>(NS::pressure) : nullptr),
      58          90 :     _mat_T_fluid(_use_mat_props ? &getADMaterialProperty<Real>(NS::T_fluid) : nullptr),
      59         180 :     _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
      60             : {
      61          90 : }
      62             : 
      63             : Real
      64      608340 : NSMachAux::computeValue()
      65             : {
      66      608340 :   if (_use_mat_props)
      67      186240 :     return MetaPhysicL::raw_value((*_mat_speed)[_qp] /
      68      372480 :                                   _fp.c_from_p_T((*_mat_pressure)[_qp], (*_mat_T_fluid)[_qp]));
      69             :   else
      70      422100 :     return RealVectorValue((*_u_vel)[_qp], (*_v_vel)[_qp], (*_w_vel)[_qp]).norm() /
      71      422100 :            _fp.c_from_v_e((*_specific_volume)[_qp], (*_specific_internal_energy)[_qp]);
      72             : }

Generated by: LCOV version 1.14