LCOV - code coverage report
Current view: top level - src/postprocessors - NumVars.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 28 32 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             : // MOOSE includes
      11             : #include "NumVars.h"
      12             : 
      13             : #include "AuxiliarySystem.h"
      14             : #include "NonlinearSystemBase.h"
      15             : #include "SubProblem.h"
      16             : 
      17             : registerMooseObject("MooseApp", NumVars);
      18             : 
      19             : InputParameters
      20       15349 : NumVars::validParams()
      21             : {
      22       15349 :   InputParameters params = GeneralPostprocessor::validParams();
      23             : 
      24       15349 :   MooseEnum system_enum("NL AUX ALL", "ALL");
      25       15349 :   params.addParam<MooseEnum>("system",
      26             :                              system_enum,
      27             :                              "The system(s) for which you want to retrieve the number of variables "
      28             :                              "(NL, AUX, ALL). Default == ALL");
      29             : 
      30       15349 :   params.addClassDescription(
      31             :       "Return the number of variables from either the NL, Aux, or both systems.");
      32             : 
      33       30698 :   return params;
      34       15349 : }
      35             : 
      36         542 : NumVars::NumVars(const InputParameters & parameters)
      37             :   : GeneralPostprocessor(parameters),
      38         542 :     _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()),
      39         542 :     _system_pointer(nullptr),
      40         542 :     _es_pointer(nullptr)
      41             : {
      42         542 :   switch (_system_enum)
      43             :   {
      44         285 :     case NL:
      45             :       mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0");
      46         285 :       _system_pointer = &_subproblem.es().get_system("nl0");
      47         285 :       break;
      48         245 :     case AUX:
      49             :       mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0");
      50         245 :       _system_pointer = &_subproblem.es().get_system("aux0");
      51         245 :       break;
      52          12 :     case ALL:
      53          12 :       _es_pointer = &_subproblem.es();
      54          12 :       break;
      55           0 :     default:
      56           0 :       mooseError("Unhandled enum");
      57             :   }
      58         542 : }
      59             : 
      60             : Real
      61         557 : NumVars::getValue() const
      62             : {
      63         557 :   switch (_system_enum)
      64             :   {
      65         546 :     case NL:
      66             :     case AUX:
      67         546 :       return _system_pointer->n_vars();
      68          11 :     case ALL:
      69          11 :       return _es_pointer->n_vars();
      70           0 :     default:
      71           0 :       return 0;
      72             :   }
      73             : }

Generated by: LCOV version 1.14