LCOV - code coverage report
Current view: top level - src/functormaterials - INSFVMushyPorousFrictionFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 34 36 94.4 %
Date: 2026-05-29 20:37:52 Functions: 4 14 28.6 %
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 "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          41 : INSFVMushyPorousFrictionFunctorMaterial::validParams()
      22             : {
      23          41 :   InputParameters params = FunctorMaterial::validParams();
      24          41 :   params.addClassDescription(
      25             :       "Computes the mushy zone porous resistance for solidification/melting problems.");
      26          82 :   params.addRequiredParam<MooseFunctorName>("liquid_fraction", "Liquid Fraction Functor.");
      27          41 :   params.addRequiredParam<MooseFunctorName>(NS::mu, "The liquid dynamic viscosity.");
      28          82 :   params.addRequiredParam<MooseFunctorName>("rho_l", "The liquid density (not the mixture one).");
      29          82 :   params.addParam<MooseFunctorName>(
      30             :       "dendrite_spacing_scaling", "1e-4", "The dendrite spacing scaling.");
      31          82 :   params.addParam<MooseFunctorName>(
      32             :       "Darcy_coef_name", "Darcy_coefficient", "Name of the Darcy friction coefficient");
      33          82 :   params.addParam<MooseFunctorName>("Forchheimer_coef_name",
      34             :                                     "Forchheimer_coefficient",
      35             :                                     "Name of the Forchheimer friction coefficient");
      36             : 
      37          41 :   return params;
      38           0 : }
      39             : 
      40          22 : INSFVMushyPorousFrictionFunctorMaterial::INSFVMushyPorousFrictionFunctorMaterial(
      41          22 :     const InputParameters & parameters)
      42             :   : FunctorMaterial(parameters),
      43          22 :     _fl(getFunctor<ADReal>("liquid_fraction")),
      44          22 :     _mu(getFunctor<ADReal>(NS::mu)),
      45          44 :     _rho_l(getFunctor<ADReal>("rho_l")),
      46          66 :     _dendrite_spacing_scaling(getFunctor<ADReal>("dendrite_spacing_scaling"))
      47             : {
      48             : 
      49          88 :   addFunctorProperty<ADReal>(
      50          44 :       getParam<MooseFunctorName>("Darcy_coef_name"),
      51       18600 :       [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       37200 :         const auto fs = 1.0 - _fl(r, t);
      57             :         mooseAssert(_dendrite_spacing_scaling(r, t) > 0,
      58             :                     "Dendrite spacing scaling should be positive!");
      59       37200 :         const auto cs = _c / Utility::pow<2>(_dendrite_spacing_scaling(r, t));
      60       55800 :         const auto Fk = 0.5 + atan(_s * (fs - _fs_crit)) / libMesh::pi;
      61       37200 :         const auto K =
      62       18600 :             Utility::pow<3>(_fl(r, t)) / ((Utility::pow<2>(fs) + epsilon) * Fk * cs) + epsilon;
      63       37200 :         return _mu(r, t) / K;
      64             :       });
      65             : 
      66          88 :   addFunctorProperty<ADReal>(
      67          44 :       getParam<MooseFunctorName>("Forchheimer_coef_name"),
      68       18600 :       [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       37200 :         const auto fs = 1.0 - _fl(r, t);
      74             :         mooseAssert(_dendrite_spacing_scaling(r, t) > 0,
      75             :                     "Dendrite spacing scaling should be positive!");
      76       37200 :         const auto cs = _c / Utility::pow<2>(_dendrite_spacing_scaling(r, t));
      77       55800 :         const auto Fk = 0.5 + atan(_s * (fs - _fs_crit)) / libMesh::pi;
      78           0 :         const auto K =
      79       18600 :             Utility::pow<3>(_fl(r, t)) / ((Utility::pow<2>(fs) + epsilon) * Fk * cs) + epsilon;
      80       37200 :         return _forchheimer_coef * _rho_l(r, t) / sqrt(K);
      81             :       });
      82          66 : }

Generated by: LCOV version 1.14