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 "ExponentialFrictionFunctorMaterial.h" 11 : #include "MooseMesh.h" 12 : #include "NS.h" 13 : 14 : registerMooseObjectRenamed("NavierStokesApp", 15 : ExponentialFrictionMaterial, 16 : "02/01/2025 00:00", 17 : ExponentialFrictionFunctorMaterial); 18 : registerMooseObject("NavierStokesApp", ExponentialFrictionFunctorMaterial); 19 : 20 : InputParameters 21 265 : ExponentialFrictionFunctorMaterial::validParams() 22 : { 23 265 : InputParameters params = FunctorMaterial::validParams(); 24 265 : params.addClassDescription("Computes a Reynolds number-exponential friction factor."); 25 265 : params.addRequiredParam<MooseFunctorName>(NS::Reynolds, "The Reynolds number."); 26 265 : params.addParam<MooseFunctorName>(NS::speed, "The velocity magnitude of the fluid."); 27 530 : params.addRequiredParam<Real>("c1", "c2 in c1/Re^(c2) expression."); 28 530 : params.addRequiredParam<Real>("c2", "c2 in c1/Re^(c2) expression."); 29 530 : params.addRequiredParam<std::string>("friction_factor_name", 30 : "The name of the output friction factor."); 31 530 : params.addParam<bool>( 32 : "include_velocity_factor", 33 530 : false, 34 : "If a factor of velocity magnitude should be included in the friction factor. This is " 35 : "typically the case for prorous medium Forcheimer friction therms."); 36 265 : return params; 37 0 : } 38 : 39 143 : ExponentialFrictionFunctorMaterial::ExponentialFrictionFunctorMaterial( 40 143 : const InputParameters & parameters) 41 : : FunctorMaterial(parameters), 42 143 : _Re(getFunctor<ADReal>(NS::Reynolds)), 43 143 : _speed(isParamValid(NS::speed) ? &getFunctor<ADReal>(NS::speed) : nullptr), 44 286 : _c1(getParam<Real>("c1")), 45 286 : _c2(getParam<Real>("c2")), 46 286 : _friction_factor_name(getParam<std::string>("friction_factor_name")), 47 429 : _include_velocity_factor(getParam<bool>("include_velocity_factor")) 48 : { 49 143 : if (_include_velocity_factor && !_speed) 50 0 : paramError(NS::speed, 51 : "To be able to include an additional multiplier in the friction factor, please " 52 : "provide the speed of the fluid."); 53 429 : addFunctorProperty<ADReal>(_friction_factor_name, 54 511440 : [this](const auto & r, const auto & t) -> ADReal 55 : { 56 511440 : return _c1 * std::pow(_Re(r, t), _c2) * 57 511440 : (_include_velocity_factor ? (*_speed)(r, t) : ADReal(1.0)); 58 : }); 59 286 : }