LCOV - code coverage report
Current view: top level - src/auxkernels - ElementAdaptivityLevelAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: a4781e Lines: 14 18 77.8 %
Date: 2025-09-23 09:14:59 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 "ElementAdaptivityLevelAux.h"
      11             : 
      12             : registerMooseObject("MooseApp", ElementAdaptivityLevelAux);
      13             : 
      14             : InputParameters
      15       14772 : ElementAdaptivityLevelAux::validParams()
      16             : {
      17       14772 :   InputParameters params = AuxKernel::validParams();
      18       29544 :   params.addClassDescription("stores the element hierarchy in a aux variable");
      19       29544 :   params.addRequiredParam<MooseEnum>(
      20       73860 :       "level", MooseEnum("h p"), "The type of adaptivity level to compute.");
      21             : 
      22       14772 :   return params;
      23           0 : }
      24             : 
      25          14 : ElementAdaptivityLevelAux::ElementAdaptivityLevelAux(const InputParameters & parameters)
      26          28 :   : AuxKernel(parameters), _level_type(getParam<MooseEnum>("level").getEnum<LevelType>())
      27             : {
      28          14 :   if (mooseVariableBase()->feType() != libMesh::FEType(CONSTANT, MONOMIAL))
      29           0 :     paramError("variable", "Must be of type CONSTANT MONOMIAL");
      30          14 : }
      31             : 
      32             : Real
      33         225 : ElementAdaptivityLevelAux::computeValue()
      34             : {
      35             :   // Only check if the user asked to compute p level
      36             :   // if it's not p level then presume that h adaptivity level was asked
      37         225 :   switch (_level_type)
      38             :   {
      39           0 :     case LevelType::P:
      40           0 :       return static_cast<Real>(_current_elem->p_level());
      41         225 :     default:
      42         225 :       return static_cast<Real>(_current_elem->level());
      43             :   }
      44             : }

Generated by: LCOV version 1.14