LCOV - code coverage report
Current view: top level - src/functormaterials - NSFVMixtureFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 33 36 91.7 %
Date: 2025-08-13 06:50:25 Functions: 8 16 50.0 %
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 "NSFVMixtureFunctorMaterialTempl.h"
      11             : #include "NS.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", WCNSLinearFVMixtureFunctorMaterial);
      14             : registerMooseObject("NavierStokesApp", NSFVMixtureFunctorMaterial);
      15             : registerMooseObjectRenamed("NavierStokesApp",
      16             :                            NSFVMixtureMaterial,
      17             :                            "08/01/2024 00:00",
      18             :                            NSFVMixtureFunctorMaterial);
      19             : 
      20             : template <bool is_ad>
      21             : InputParameters
      22         548 : NSFVMixtureFunctorMaterialTempl<is_ad>::validParams()
      23             : {
      24         548 :   InputParameters params = FunctorMaterial::validParams();
      25         548 :   params.addClassDescription(
      26             :       "Compute the arithmetic mean of material properties using a phase fraction.");
      27        1096 :   params.addRequiredParam<std::vector<MooseFunctorName>>(
      28             :       "phase_1_names", "The names of the properties for phase 1.");
      29        1096 :   params.addRequiredParam<std::vector<MooseFunctorName>>(
      30             :       "phase_2_names", "The names of the properties for phase 2.");
      31        1096 :   params.addRequiredParam<std::vector<MooseFunctorName>>(
      32             :       "prop_names", "The name of the mixture properties output from the material.");
      33        1096 :   params.addRequiredParam<MooseFunctorName>("phase_1_fraction", "Phase 1 fraction.");
      34        1096 :   params.addParam<bool>(
      35        1096 :       "limit_phase_fraction", false, "Whether to bound the phase fraction between 0 and 1");
      36         548 :   return params;
      37           0 : }
      38             : 
      39             : template <bool is_ad>
      40         291 : NSFVMixtureFunctorMaterialTempl<is_ad>::NSFVMixtureFunctorMaterialTempl(
      41             :     const InputParameters & parameters)
      42             :   : FunctorMaterial(parameters),
      43         582 :     _phase_1_names(getParam<std::vector<MooseFunctorName>>("phase_1_names")),
      44         582 :     _phase_2_names(getParam<std::vector<MooseFunctorName>>("phase_2_names")),
      45         582 :     _mixture_names(getParam<std::vector<MooseFunctorName>>("prop_names")),
      46         582 :     _phase_1_fraction(getFunctor<GenericReal<is_ad>>("phase_1_fraction")),
      47         873 :     _limit_pf(getParam<bool>("limit_phase_fraction"))
      48             : {
      49             : 
      50         291 :   if (_phase_1_names.size() != _phase_2_names.size())
      51           0 :     paramError("phase_2_names", "Phase 1 and Phase 2 names do not have the same length.");
      52             : 
      53         291 :   if (_phase_1_names.size() != _mixture_names.size())
      54           0 :     paramError("prop_names", "Phase 1 and mixture property names do not have the same length.");
      55             : 
      56        1101 :   for (const auto prop_index : index_range(_phase_1_names))
      57             :   {
      58         810 :     _phase_1_properties.push_back(&getFunctor<GenericReal<is_ad>>(_phase_1_names[prop_index]));
      59         810 :     _phase_2_properties.push_back(&getFunctor<GenericReal<is_ad>>(_phase_2_names[prop_index]));
      60             : 
      61        2430 :     addFunctorProperty<GenericReal<is_ad>>(
      62             :         _mixture_names[prop_index],
      63    94059323 :         [this, prop_index](const auto & r, const auto & t) -> GenericReal<is_ad>
      64             :         {
      65             :           // Avoid messing up the fluid properties, but keep the same dependencies
      66             :           // AD-version needs to preserve sparsity pattern
      67    46448923 :           const auto phase_1_fraction =
      68             :               _limit_pf
      69   188118646 :                   ? (is_ad ? std::max(std::min(_phase_1_fraction(r, t), (GenericReal<is_ad>)1),
      70    46448923 :                                       (GenericReal<is_ad>)0) +
      71    46448923 :                                  0 * _phase_1_fraction(r, t)
      72    47610400 :                            : std::max(std::min(_phase_1_fraction(r, t), (GenericReal<is_ad>)1),
      73    47610400 :                                       (GenericReal<is_ad>)0))
      74    46448923 :                   : _phase_1_fraction(r, t);
      75    94059323 :           return phase_1_fraction * (*_phase_1_properties[prop_index])(r, t) +
      76   186957169 :                  (1.0 - phase_1_fraction) * (*_phase_2_properties[prop_index])(r, t);
      77             :         });
      78             :   }
      79        1101 : }
      80             : 
      81             : template class NSFVMixtureFunctorMaterialTempl<false>;
      82             : template class NSFVMixtureFunctorMaterialTempl<true>;

Generated by: LCOV version 1.14