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 "INSFVMushyPorousFrictionFunctorMaterial.h" 11 : #include "MooseMesh.h" 12 : #include "NS.h" 13 : 14 : registerMooseObject("NavierStokesApp", INSFVMushyPorousFrictionFunctorMaterial); 15 : registerMooseObjectRenamed("NavierStokesApp", 16 : INSFVMushyPorousFrictionMaterial, 17 : "08/01/2024 00:00", 18 : INSFVMushyPorousFrictionFunctorMaterial); 19 : 20 : InputParameters 21 57 : INSFVMushyPorousFrictionFunctorMaterial::validParams() 22 : { 23 57 : InputParameters params = FunctorMaterial::validParams(); 24 57 : params.addClassDescription( 25 : "Computes the mushy zone porous resistance for solidification/melting problems."); 26 114 : params.addRequiredParam<MooseFunctorName>("liquid_fraction", "Liquid Fraction Functor."); 27 57 : params.addRequiredParam<MooseFunctorName>(NS::mu, "The liquid dynamic viscosity."); 28 114 : params.addRequiredParam<MooseFunctorName>("rho_l", "The liquid density (not the mixture one)."); 29 114 : params.addParam<MooseFunctorName>( 30 : "dendrite_spacing_scaling", "1e-4", "The dendrite spacing scaling."); 31 114 : params.addParam<MooseFunctorName>( 32 : "Darcy_coef_name", "Darcy_coefficient", "Name of the Darcy friction coefficient"); 33 114 : params.addParam<MooseFunctorName>("Forchheimer_coef_name", 34 : "Forchheimer_coefficient", 35 : "Name of the Forchheimer friction coefficient"); 36 : 37 57 : return params; 38 0 : } 39 : 40 30 : INSFVMushyPorousFrictionFunctorMaterial::INSFVMushyPorousFrictionFunctorMaterial( 41 30 : const InputParameters & parameters) 42 : : FunctorMaterial(parameters), 43 30 : _fl(getFunctor<ADReal>("liquid_fraction")), 44 30 : _mu(getFunctor<ADReal>(NS::mu)), 45 60 : _rho_l(getFunctor<ADReal>("rho_l")), 46 90 : _dendrite_spacing_scaling(getFunctor<ADReal>("dendrite_spacing_scaling")) 47 : { 48 : 49 120 : addFunctorProperty<ADReal>( 50 60 : getParam<MooseFunctorName>("Darcy_coef_name"), 51 21000 : [this](const auto & r, const auto & t) -> ADReal 52 : { 53 : constexpr Real epsilon = 1e-15; // prevents explosion of sqrt(x) derivative to infinity 54 42000 : const auto fs = 1.0 - _fl(r, t); 55 : mooseAssert(_dendrite_spacing_scaling(r, t) > 0, 56 : "Dendrite spacing scaling should be positive!"); 57 42000 : const auto cs = _c / Utility::pow<2>(_dendrite_spacing_scaling(r, t)); 58 63000 : const auto Fk = 0.5 + std::atan(_s * (fs - _fs_crit)) / libMesh::pi; 59 21000 : const auto K = 60 21000 : Utility::pow<3>(_fl(r, t)) / ((Utility::pow<2>(fs) + epsilon) * Fk * cs) + epsilon; 61 42000 : return _mu(r, t) / K; 62 : }); 63 : 64 120 : addFunctorProperty<ADReal>( 65 60 : getParam<MooseFunctorName>("Forchheimer_coef_name"), 66 21000 : [this](const auto & r, const auto & t) -> ADReal 67 : { 68 : constexpr Real epsilon = 1e-15; // prevents explosion of sqrt(x) derivative to infinity 69 42000 : const auto fs = 1.0 - _fl(r, t); 70 : mooseAssert(_dendrite_spacing_scaling(r, t) > 0, 71 : "Dendrite spacing scaling should be positive!"); 72 42000 : const auto cs = _c / Utility::pow<2>(_dendrite_spacing_scaling(r, t)); 73 63000 : const auto Fk = 0.5 + std::atan(_s * (fs - _fs_crit)) / libMesh::pi; 74 0 : const auto K = 75 21000 : Utility::pow<3>(_fl(r, t)) / ((Utility::pow<2>(fs) + epsilon) * Fk * cs) + epsilon; 76 42000 : return _forchheimer_coef * _rho_l(r, t) / std::sqrt(K); 77 : }); 78 90 : }