LCOV - code coverage report
Current view: top level - src/auxkernels - ElementUOAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 21 24 87.5 %
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 "ElementUOAux.h"
      11             : #include "ElementUOProvider.h"
      12             : 
      13             : registerMooseObject("MooseApp", ElementUOAux);
      14             : 
      15             : InputParameters
      16       16015 : ElementUOAux::validParams()
      17             : {
      18       16015 :   InputParameters params = AuxKernel::validParams();
      19       16015 :   params.addRequiredParam<UserObjectName>("element_user_object",
      20             :                                           "The ElementUOProvider where this Aux pulls values from");
      21             : 
      22       16015 :   params.addParam<std::string>("field_name",
      23             :                                "The field name to retrieve from the ElementUOProvider");
      24             : 
      25       16015 :   MooseEnum field_type("long Real", "long");
      26       16015 :   params.addParam<MooseEnum>("field_type", field_type, "The type of field to retrieve");
      27             : 
      28       16015 :   params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_BEGIN;
      29       16015 :   params.addClassDescription("Aux Kernel to display generic spatial (elemental) information from a "
      30             :                              "UserObject that satisfies the underlying ElementUOProvider "
      31             :                              "interface.");
      32       32030 :   return params;
      33       16015 : }
      34             : 
      35         916 : ElementUOAux::ElementUOAux(const InputParameters & params)
      36             :   : AuxKernel(params),
      37             :     // doco-get-user-object-begin
      38         916 :     _elem_uo(getUserObject<ElementUOProvider>("element_user_object")),
      39             :     // doco-get-user-object-end
      40         916 :     _field_name(isParamValid("field_name") ? getParam<std::string>("field_name") : "default"),
      41        1832 :     _field_type(getParam<MooseEnum>("field_type"))
      42             : {
      43         916 :   if (isNodal())
      44           0 :     mooseError("This AuxKernel only supports Elemental fields");
      45         916 : }
      46             : 
      47             : Real
      48     6358720 : ElementUOAux::computeValue()
      49             : {
      50     6358720 :   if (_field_type == "long")
      51             :   {
      52     6358720 :     auto value = _elem_uo.getElementalValueLong(_current_elem->id(), _field_name);
      53     6358720 :     if (value == std::numeric_limits<unsigned long>::max())
      54           0 :       return -1.0;
      55             :     else
      56     6358720 :       return value;
      57             :   }
      58             :   else
      59           0 :     return _elem_uo.getElementalValueReal(_current_elem->id(), _field_name);
      60             : }

Generated by: LCOV version 1.14