LCOV - code coverage report
Current view: top level - src/postprocessors - NumDOFs.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33187 (5aa0b2) with base d7c4bd Lines: 27 29 93.1 %
Date: 2026-06-30 12:18:20 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 "NumDOFs.h"
      11             : #include "SubProblem.h"
      12             : #include "MooseStringUtils.h"
      13             : 
      14             : #include "libmesh/equation_systems.h"
      15             : #include "libmesh/system.h"
      16             : 
      17             : registerMooseObject("MooseApp", NumDOFs);
      18             : 
      19             : InputParameters
      20        4705 : NumDOFs::validParams()
      21             : {
      22        4705 :   InputParameters params = GeneralPostprocessor::validParams();
      23       18820 :   params.addParam<std::string>(
      24             :       "system",
      25             :       "ALL",
      26             :       "The system for which you want to retrieve the number of DOFs. Use ALL for all systems, "
      27             :       "NL as an alias for nl0, AUX as an alias for aux0, or the name of a specific system.");
      28             : 
      29        4705 :   params.addClassDescription(
      30             :       "Return the number of Degrees of freedom from one or more equation systems.");
      31        4705 :   return params;
      32           0 : }
      33             : 
      34         819 : NumDOFs::NumDOFs(const InputParameters & parameters)
      35             :   : GeneralPostprocessor(parameters),
      36         819 :     _all_systems(false),
      37         819 :     _system_pointer(nullptr),
      38         819 :     _es_pointer(nullptr)
      39             : {
      40        1638 :   const auto system_param = getParam<std::string>("system");
      41         819 :   const auto system_upper = MooseUtils::toUpper(system_param);
      42             : 
      43         819 :   if (system_upper == "ALL")
      44             :   {
      45         677 :     _all_systems = true;
      46         677 :     _es_pointer = &_subproblem.es();
      47         677 :     return;
      48             :   }
      49             : 
      50         142 :   std::string system_name = system_param;
      51         142 :   if (system_upper == "NL")
      52          82 :     system_name = "nl0";
      53          60 :   else if (system_upper == "AUX")
      54          36 :     system_name = "aux0";
      55             : 
      56         142 :   if (!_subproblem.es().has_system(system_name))
      57           0 :     paramError("system", "No system found with name '", system_name, "'.");
      58             : 
      59         142 :   _system_pointer = &_subproblem.es().get_system(system_name);
      60        1496 : }
      61             : 
      62             : Real
      63        2065 : NumDOFs::getValue() const
      64             : {
      65        2065 :   if (_all_systems)
      66        1513 :     return _es_pointer->n_dofs();
      67             : 
      68         552 :   return _system_pointer->n_dofs();
      69             : }

Generated by: LCOV version 1.14