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 : using std::atan; 54 : 55 : constexpr Real epsilon = 1e-15; // prevents explosion of sqrt(x) derivative to infinity 56 42000 : const auto fs = 1.0 - _fl(r, t); 57 : mooseAssert(_dendrite_spacing_scaling(r, t) > 0, 58 : "Dendrite spacing scaling should be positive!"); 59 : const auto cs = _c / Utility::pow<2>(_dendrite_spacing_scaling(r, t)); 60 63000 : const auto Fk = 0.5 + atan(_s * (fs - _fs_crit)) / libMesh::pi; 61 42000 : const auto K = 62 21000 : Utility::pow<3>(_fl(r, t)) / ((Utility::pow<2>(fs) + epsilon) * Fk * cs) + epsilon; 63 42000 : return _mu(r, t) / K; 64 : }); 65 : 66 120 : addFunctorProperty<ADReal>( 67 60 : getParam<MooseFunctorName>("Forchheimer_coef_name"), 68 21000 : [this](const auto & r, const auto & t) -> ADReal 69 : { 70 : using std::atan, std::sqrt; 71 : 72 : constexpr Real epsilon = 1e-15; // prevents explosion of sqrt(x) derivative to infinity 73 42000 : const auto fs = 1.0 - _fl(r, t); 74 : mooseAssert(_dendrite_spacing_scaling(r, t) > 0, 75 : "Dendrite spacing scaling should be positive!"); 76 42000 : const auto cs = _c / Utility::pow<2>(_dendrite_spacing_scaling(r, t)); 77 63000 : const auto Fk = 0.5 + atan(_s * (fs - _fs_crit)) / libMesh::pi; 78 0 : const auto K = 79 21000 : Utility::pow<3>(_fl(r, t)) / ((Utility::pow<2>(fs) + epsilon) * Fk * cs) + epsilon; 80 42000 : return _forchheimer_coef * _rho_l(r, t) / sqrt(K); 81 : }); 82 90 : }