www.mooseframework.org
NumDOFs.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "NumDOFs.h"
16 #include "SubProblem.h"
17 
18 #include "libmesh/system.h"
19 
20 template <>
23 {
25  MooseEnum system_enum("NL AUX ALL", "ALL");
26  params.addParam<MooseEnum>(
27  "system",
28  system_enum,
29  "The system(s) to retrieve the number of DOFs from (NL, AUX, ALL). Default == ALL");
30  return params;
31 }
32 
33 NumDOFs::NumDOFs(const InputParameters & parameters)
34  : GeneralPostprocessor(parameters),
35  _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()),
36  _system_pointer(NULL),
37  _es_pointer(NULL)
38 {
39  switch (_system_enum)
40  {
41  case NL:
42  mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0");
43  _system_pointer = &_subproblem.es().get_system("nl0");
44  break;
45  case AUX:
46  mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0");
47  _system_pointer = &_subproblem.es().get_system("aux0");
48  break;
49  case ALL:
51  break;
52  default:
53  mooseError("Unhandled enum");
54  }
55 }
56 
57 Real
59 {
60  switch (_system_enum)
61  {
62  case NL:
63  case AUX:
64  return _system_pointer->n_dofs();
65  case ALL:
66  return _es_pointer->n_dofs();
67  default:
68  return 0;
69  }
70 }
const System * _system_pointer
Definition: NumDOFs.h:52
NumDOFs(const InputParameters &parameters)
Definition: NumDOFs.C:33
InputParameters validParams< NumDOFs >()
Definition: NumDOFs.C:22
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
SystemEnum
Definition: NumDOFs.h:43
virtual EquationSystems & es()=0
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:146
const EquationSystems * _es_pointer
Definition: NumDOFs.h:53
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: NumDOFs.C:58
const SystemEnum _system_enum
Definition: NumDOFs.h:50
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80