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 : using std::sqrt, std::pow; 36 : 37 : constexpr Real offset = 1e-15; // prevents explosion of sqrt(x) derivative to infinity 38 : const ADReal strain_rate_tensor_mag = 39 958464 : sqrt(2.0 * Utility::pow<2>(_grad_u[_qp](0, 0)) + 2.0 * Utility::pow<2>(_grad_u[_qp](1, 1)) + 40 479232 : 2.0 * Utility::pow<2>(_grad_u[_qp](2, 2)) + 41 479232 : Utility::pow<2>(_grad_u[_qp](0, 2) + _grad_u[_qp](2, 0)) + 42 479232 : Utility::pow<2>(_grad_u[_qp](0, 1) + _grad_u[_qp](1, 0)) + 43 958464 : Utility::pow<2>(_grad_u[_qp](1, 2) + _grad_u[_qp](2, 1)) + offset); 44 : constexpr Real one_third = 1.0 / 3.0; 45 479232 : return strain_rate_tensor_mag * 46 479232 : Utility::pow<2>(_smagorinsky_constant * pow(_current_elem_volume, one_third) / 47 479232 : _current_elem->default_order()) * 48 958464 : _rho[_qp] * _grad_u[_qp]; 49 : }