LCOV - code coverage report
Current view: top level - src/auxkernels - FunctorAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 28 30 93.3 %
Date: 2026-05-29 20:35:17 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        9525 : FunctorAux::validParams()
      18             : {
      19        9525 :   InputParameters params = AuxKernel::validParams();
      20       19050 :   params.addClassDescription(
      21             :       "Evaluates a functor (variable, function or functor material property) on the current "
      22             :       "element, quadrature point, or node.");
      23       38100 :   params.addRequiredParam<MooseFunctorName>("functor", "The functor to evaluate");
      24       28575 :   params.addParam<MooseFunctorName>("factor", 1, "A factor to apply on the functor");
      25        9525 :   return params;
      26           0 : }
      27             : 
      28         175 : FunctorAux::FunctorAux(const InputParameters & parameters)
      29             :   : AuxKernel(parameters),
      30         175 :     _functor(getFunctor<Real>("functor")),
      31         350 :     _factor(getFunctor<Real>("factor")),
      32         175 :     _is_standard_fe(dynamic_cast<MooseVariableFE<Real> *>(&_var)),
      33         259 :     _is_standard_fv(dynamic_cast<MooseVariableFV<Real> *>(&_var) ||
      34         259 :                     dynamic_cast<MooseLinearVariableFV<Real> *>(&_var))
      35             : {
      36         175 :   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             : 
      41         350 :   const auto & functor_name = getParam<MooseFunctorName>("functor");
      42             : 
      43             :   // Add user object to dependency
      44         175 :   if (hasUserObjectByName(functor_name))
      45          21 :     getUserObjectBaseByName(functor_name);
      46         175 : }
      47             : 
      48             : Real
      49       97584 : FunctorAux::computeValue()
      50             : {
      51       97584 :   const auto state = determineState();
      52       97584 :   if (isNodal())
      53             :   {
      54         567 :     const Moose::NodeArg node_arg = {_current_node,
      55         567 :                                      &Moose::NodeArg::undefined_subdomain_connection};
      56         567 :     return _factor(node_arg, state) * _functor(node_arg, state);
      57             :   }
      58       97017 :   else if (_is_standard_fe)
      59             :   {
      60       88539 :     const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
      61       88539 :     return _factor(qp_arg, state) * _functor(qp_arg, state);
      62             :   }
      63             :   else
      64             :   {
      65        8478 :     const auto elem_arg = makeElemArg(_current_elem);
      66        8478 :     return _factor(elem_arg, state) * _functor(elem_arg, state);
      67             :   }
      68             : }

Generated by: LCOV version 1.14