www.mooseframework.org
NumDOFs.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
19 {
21  MooseEnum system_enum("NL AUX ALL", "ALL");
22  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  params.addClassDescription(
28  "Return the number of Degrees of freedom from either the NL, Aux or both systems.");
29  return params;
30 }
31 
32 NumDOFs::NumDOFs(const InputParameters & parameters)
33  : GeneralPostprocessor(parameters),
34  _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()),
35  _system_pointer(nullptr),
36  _es_pointer(nullptr)
37 {
38  switch (_system_enum)
39  {
40  case NL:
41  mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0");
42  _system_pointer = &_subproblem.es().get_system("nl0");
43  break;
44  case AUX:
45  mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0");
46  _system_pointer = &_subproblem.es().get_system("aux0");
47  break;
48  case ALL:
50  break;
51  default:
52  mooseError("Unhandled enum");
53  }
54 }
55 
56 Real
58 {
59  switch (_system_enum)
60  {
61  case NL:
62  case AUX:
63  return _system_pointer->n_dofs();
64  case ALL:
65  return _es_pointer->n_dofs();
66  default:
67  return 0;
68  }
69 }
registerMooseObject("MooseApp", NumDOFs)
const System * _system_pointer
Definition: NumDOFs.h:42
NumDOFs(const InputParameters &parameters)
Definition: NumDOFs.C:32
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1147
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: NumDOFs.C:57
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
SystemEnum
Definition: NumDOFs.h:33
virtual EquationSystems & es()=0
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:207
const EquationSystems * _es_pointer
Definition: NumDOFs.h:43
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const SystemEnum _system_enum
Definition: NumDOFs.h:40
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
static InputParameters validParams()
Definition: NumDOFs.C:18
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...