LCOV - code coverage report
Current view: top level - src/kernels - INSADSmagorinskyEddyViscosity.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 20 21 95.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 "INSADSmagorinskyEddyViscosity.h"
      11             : 
      12             : registerMooseObject("NavierStokesApp", INSADSmagorinskyEddyViscosity);
      13             : 
      14             : InputParameters
      15          41 : INSADSmagorinskyEddyViscosity::validParams()
      16             : {
      17          41 :   InputParameters params = ADVectorKernelGrad::validParams();
      18          41 :   params.addClassDescription("Computes eddy viscosity term using Smagorinky's LES model");
      19          82 :   params.addParam<Real>("smagorinsky_constant", 0.18, "Value of Smagorinsky's constant to use");
      20          82 :   params.addParam<MaterialPropertyName>(
      21             :       "rho_name", "rho", "The name of the density material property");
      22          41 :   return params;
      23           0 : }
      24             : 
      25          22 : INSADSmagorinskyEddyViscosity::INSADSmagorinskyEddyViscosity(const InputParameters & parameters)
      26             :   : ADVectorKernelGrad(parameters),
      27          22 :     _rho(getADMaterialProperty<Real>("rho_name")),
      28          66 :     _smagorinsky_constant(getParam<Real>("smagorinsky_constant"))
      29             : {
      30          22 : }
      31             : 
      32             : ADRealTensorValue
      33      479232 : INSADSmagorinskyEddyViscosity::precomputeQpResidual()
      34             : {
      35             :   constexpr Real offset = 1e-15; // prevents explosion of sqrt(x) derivative to infinity
      36             :   const ADReal strain_rate_tensor_mag = std::sqrt(
      37      958464 :       2.0 * Utility::pow<2>(_grad_u[_qp](0, 0)) + 2.0 * Utility::pow<2>(_grad_u[_qp](1, 1)) +
      38      479232 :       2.0 * Utility::pow<2>(_grad_u[_qp](2, 2)) +
      39      479232 :       Utility::pow<2>(_grad_u[_qp](0, 2) + _grad_u[_qp](2, 0)) +
      40      479232 :       Utility::pow<2>(_grad_u[_qp](0, 1) + _grad_u[_qp](1, 0)) +
      41      958464 :       Utility::pow<2>(_grad_u[_qp](1, 2) + _grad_u[_qp](2, 1)) + offset);
      42             :   constexpr Real one_third = 1.0 / 3.0;
      43      479232 :   return strain_rate_tensor_mag *
      44      479232 :          Utility::pow<2>(_smagorinsky_constant * std::pow(_current_elem_volume, one_third) /
      45      479232 :                          _current_elem->default_order()) *
      46      958464 :          _rho[_qp] * _grad_u[_qp];
      47             : }

Generated by: LCOV version 1.14