LCOV - code coverage report
Current view: top level - src/postprocessors - NumDOFs.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 1f9d31 Lines: 28 32 87.5 %
Date: 2025-09-02 20:01: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             : 
      13             : #include "libmesh/system.h"
      14             : 
      15             : registerMooseObject("MooseApp", NumDOFs);
      16             : 
      17             : InputParameters
      18       15873 : NumDOFs::validParams()
      19             : {
      20       15873 :   InputParameters params = GeneralPostprocessor::validParams();
      21       63492 :   MooseEnum system_enum("NL AUX ALL", "ALL");
      22       63492 :   params.addParam<MooseEnum>("system",
      23             :                              system_enum,
      24             :                              "The system(s) for which you want to retrieve the number of DOFs (NL, "
      25             :                              "AUX, ALL). Default == ALL");
      26             : 
      27       15873 :   params.addClassDescription(
      28             :       "Return the number of Degrees of freedom from either the NL, Aux or both systems.");
      29       31746 :   return params;
      30       15873 : }
      31             : 
      32         800 : NumDOFs::NumDOFs(const InputParameters & parameters)
      33             :   : GeneralPostprocessor(parameters),
      34         800 :     _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()),
      35         800 :     _system_pointer(nullptr),
      36         800 :     _es_pointer(nullptr)
      37             : {
      38         800 :   switch (_system_enum)
      39             :   {
      40          65 :     case NL:
      41             :       mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0");
      42          65 :       _system_pointer = &_subproblem.es().get_system("nl0");
      43          65 :       break;
      44          13 :     case AUX:
      45             :       mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0");
      46          13 :       _system_pointer = &_subproblem.es().get_system("aux0");
      47          13 :       break;
      48         722 :     case ALL:
      49         722 :       _es_pointer = &_subproblem.es();
      50         722 :       break;
      51           0 :     default:
      52           0 :       mooseError("Unhandled enum");
      53             :   }
      54         800 : }
      55             : 
      56             : Real
      57        2005 : NumDOFs::getValue() const
      58             : {
      59        2005 :   switch (_system_enum)
      60             :   {
      61         388 :     case NL:
      62             :     case AUX:
      63         388 :       return _system_pointer->n_dofs();
      64        1617 :     case ALL:
      65        1617 :       return _es_pointer->n_dofs();
      66           0 :     default:
      67           0 :       return 0;
      68             :   }
      69             : }

Generated by: LCOV version 1.14