LCOV - code coverage report
Current view: top level - src/functormaterials - GenericVectorFunctorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 32 37 86.5 %
Date: 2025-07-17 01:28:37 Functions: 13 40 32.5 %
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 "GenericVectorFunctorMaterial.h"
      11             : #include "MathUtils.h"
      12             : 
      13             : registerMooseObject("MooseApp", GenericVectorFunctorMaterial);
      14             : registerMooseObject("MooseApp", ADGenericVectorFunctorMaterial);
      15             : registerMooseObjectRenamed("MooseApp",
      16             :                            GenericConstantVectorFunctorMaterial,
      17             :                            "06/30/2022 24:00",
      18             :                            GenericVectorFunctorMaterial);
      19             : registerMooseObjectRenamed("MooseApp",
      20             :                            ADGenericConstantVectorFunctorMaterial,
      21             :                            "06/30/2022 24:00",
      22             :                            ADGenericVectorFunctorMaterial);
      23             : 
      24             : template <bool is_ad>
      25             : InputParameters
      26       57554 : GenericVectorFunctorMaterialTempl<is_ad>::validParams()
      27             : {
      28       57554 :   InputParameters params = FunctorMaterial::validParams();
      29      115108 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_ALWAYS};
      30       57554 :   params.addClassDescription(
      31             :       "FunctorMaterial object for declaring vector properties that are populated by "
      32             :       "evaluation of functor (constants, functions, variables, matprops) object.");
      33       57554 :   params.addParam<std::vector<std::string>>("prop_names",
      34             :                                             "The names of the properties this material will have");
      35       57554 :   params.addParam<std::vector<MooseFunctorName>>("prop_values",
      36             :                                                  "The corresponding names of the "
      37             :                                                  "functors that are going to provide "
      38             :                                                  "the values for the vector material properties");
      39       57554 :   return params;
      40       57554 : }
      41             : 
      42             : template <bool is_ad>
      43         254 : GenericVectorFunctorMaterialTempl<is_ad>::GenericVectorFunctorMaterialTempl(
      44             :     const InputParameters & parameters)
      45             :   : FunctorMaterial(parameters),
      46         254 :     _prop_names(getParam<std::vector<std::string>>("prop_names")),
      47         508 :     _prop_values(getParam<std::vector<MooseFunctorName>>("prop_values"))
      48             : {
      49         254 :   unsigned int num_names = _prop_names.size();
      50         254 :   unsigned int num_values = _prop_values.size();
      51             : 
      52         254 :   if (num_names * LIBMESH_DIM != num_values)
      53           0 :     mooseError("Number of prop_names times three must match the number of prop_values for a "
      54             :                "GenericVectorFunctorMaterial!");
      55             : 
      56             :   // Check that there is no name conflict, a common mistake with this object
      57         508 :   for (const auto i : make_range(num_names))
      58        1040 :     for (const auto j : make_range(num_values))
      59         786 :       if (_prop_names[i] == _prop_values[j])
      60           4 :         paramError("prop_names",
      61             :                    "prop_names should not be the same as any of the prop_values. They"
      62             :                    " can both be functors, and functors may not have the same name.");
      63             : 
      64         250 :   _num_props = num_names;
      65         250 :   _functors.resize(num_values);
      66             : 
      67        1000 :   for (const auto i : make_range(num_values))
      68         750 :     _functors[i] = &getFunctor<GenericReal<is_ad>>(_prop_values[i]);
      69             : 
      70         250 :   const std::set<ExecFlagType> clearance_schedule(_execute_enum.begin(), _execute_enum.end());
      71         500 :   for (const auto i : make_range(_num_props))
      72             :   {
      73         250 :     addFunctorProperty<GenericRealVectorValue<is_ad>>(
      74             :         _prop_names[i],
      75     2462346 :         [this, i](const auto & r, const auto & t) -> GenericRealVectorValue<is_ad>
      76             :         {
      77      820782 :           return {(*_functors[LIBMESH_DIM * i])(r, t),
      78      820782 :                   (*_functors[LIBMESH_DIM * i + 1])(r, t),
      79      933636 :                   (*_functors[LIBMESH_DIM * i + 2])(r, t)};
      80             :         },
      81             :         clearance_schedule);
      82         250 :     addFunctorProperty<GenericRealVectorValue<is_ad>>(
      83         250 :         MathUtils::timeDerivName(_prop_names[i]),
      84           0 :         [this, i](const auto & r, const auto & t) -> GenericRealVectorValue<is_ad>
      85             :         {
      86           0 :           return {_functors[LIBMESH_DIM * i]->dot(r, t),
      87           0 :                   _functors[LIBMESH_DIM * i + 1]->dot(r, t),
      88           0 :                   _functors[LIBMESH_DIM * i + 2]->dot(r, t)};
      89             :         },
      90             :         clearance_schedule);
      91             :   }
      92         250 : }
      93             : 
      94             : template class GenericVectorFunctorMaterialTempl<false>;
      95             : template class GenericVectorFunctorMaterialTempl<true>;

Generated by: LCOV version 1.14