LCOV - code coverage report
Current view: top level - src/auxkernels - FunctorAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 26 28 92.9 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.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 "FunctorAux.h"
      11             : 
      12             : registerMooseObject("MooseApp", FunctorAux);
      13             : registerMooseObjectRenamed("MooseApp", FunctorElementalAux, "10/14/2024 00:00", FunctorAux);
      14             : registerMooseObjectRenamed("MooseApp", ADFunctorElementalAux, "10/14/2024 00:00", FunctorAux);
      15             : 
      16             : InputParameters
      17       43142 : FunctorAux::validParams()
      18             : {
      19       43142 :   InputParameters params = AuxKernel::validParams();
      20       43142 :   params.addClassDescription(
      21             :       "Evaluates a functor (variable, function or functor material property) on the current "
      22             :       "element, quadrature point, or node.");
      23       43142 :   params.addRequiredParam<MooseFunctorName>("functor", "The functor to evaluate");
      24       43142 :   params.addParam<MooseFunctorName>("factor", 1, "A factor to apply on the functor");
      25       43142 :   return params;
      26           0 : }
      27             : 
      28         176 : FunctorAux::FunctorAux(const InputParameters & parameters)
      29             :   : AuxKernel(parameters),
      30         176 :     _functor(getFunctor<Real>("functor")),
      31         176 :     _factor(getFunctor<Real>("factor")),
      32         176 :     _is_standard_fe(dynamic_cast<MooseVariableFE<Real> *>(&_var)),
      33         261 :     _is_standard_fv(dynamic_cast<MooseVariableFV<Real> *>(&_var) ||
      34         261 :                     dynamic_cast<MooseLinearVariableFV<Real> *>(&_var))
      35             : {
      36         176 :   if (!_is_standard_fe && !_is_standard_fv)
      37           0 :     paramError(
      38             :         "variable",
      39             :         "The variable must be a non-vector, non-array finite-volume/finite-element variable.");
      40         176 : }
      41             : 
      42             : Real
      43       97291 : FunctorAux::computeValue()
      44             : {
      45       97291 :   mooseDoOnce( // PPs: need to execute before this auxkernel
      46             :       const auto & functor_name = getParam<MooseFunctorName>("functor");
      47             :       if (_c_fe_problem.hasPostprocessorValueByName(functor_name)) {
      48             :         if (!(_c_fe_problem.getUserObjectBase(functor_name).isParamValid("force_preaux") &&
      49             :               _c_fe_problem.getUserObjectBase(functor_name).getParam<bool>("force_preaux")))
      50             :           paramError(
      51             :               "functor",
      52             :               "Functor is a postprocessor and does not have 'force_preaux' set to true. The value "
      53             :               "of the postprocessor would be lagged in the functor evaluation. 'force_preaux' will "
      54             :               "ensure the value is updated before the auxiliary variables computation.");
      55             :       } else if (_c_fe_problem.hasUserObject(functor_name)) {
      56             :         const auto & uo = _c_fe_problem.getUserObjectBase(functor_name);
      57             :         if (!(uo.isParamValid("force_preaux") && uo.getParam<bool>("force_preaux")))
      58             :           paramError(
      59             :               "functor",
      60             :               "Functor is a user object and does not have 'force_preaux' set to true. The value "
      61             :               "of the user object would be lagged in the functor evaluation. 'force_preaux' will "
      62             :               "ensure the value is updated before the auxiliary variables computation.");
      63             :       });
      64             : 
      65       97291 :   const auto state = determineState();
      66       97291 :   if (isNodal())
      67             :   {
      68         504 :     const Moose::NodeArg node_arg = {_current_node,
      69         504 :                                      &Moose::NodeArg::undefined_subdomain_connection};
      70         504 :     return _factor(node_arg, state) * _functor(node_arg, state);
      71             :   }
      72       96787 :   else if (_is_standard_fe)
      73             :   {
      74       88539 :     const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
      75       88539 :     return _factor(qp_arg, state) * _functor(qp_arg, state);
      76             :   }
      77             :   else
      78             :   {
      79        8248 :     const auto elem_arg = makeElemArg(_current_elem);
      80        8248 :     return _factor(elem_arg, state) * _functor(elem_arg, state);
      81             :   }
      82             : }

Generated by: LCOV version 1.14