Loading [MathJax]/extensions/tex2jax.js
www.mooseframework.org
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 
18 
21 {
23  MooseEnum system_enum("NL AUX ALL", "ALL");
24  params.addParam<MooseEnum>("system",
25  system_enum,
26  "The system(s) for which you want to retrieve the number of DOFs (NL, "
27  "AUX, ALL). Default == ALL");
28 
29  params.addClassDescription(
30  "Return the number of Degrees of freedom from either the NL, Aux or both systems.");
31  return params;
32 }
33 
34 NumDOFs::NumDOFs(const InputParameters & parameters)
35  : GeneralPostprocessor(parameters),
36  _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()),
37  _system_pointer(nullptr),
38  _es_pointer(nullptr)
39 {
40  switch (_system_enum)
41  {
42  case NL:
43  mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0");
44  _system_pointer = &_subproblem.es().get_system("nl0");
45  break;
46  case AUX:
47  mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0");
48  _system_pointer = &_subproblem.es().get_system("aux0");
49  break;
50  case ALL:
52  break;
53  default:
54  mooseError("Unhandled enum");
55  }
56 }
57 
58 Real
60 {
61  switch (_system_enum)
62  {
63  case NL:
64  case AUX:
65  return _system_pointer->n_dofs();
66  case ALL:
67  return _es_pointer->n_dofs();
68  default:
69  return 0;
70  }
71 }
NumDOFs::NL
Definition: NumDOFs.h:41
registerMooseObject
registerMooseObject("MooseApp", NumDOFs)
NumDOFs::NumDOFs
NumDOFs(const InputParameters &parameters)
Definition: NumDOFs.C:34
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition: MooseObject.h:141
GeneralPostprocessor::validParams
static InputParameters validParams()
Definition: GeneralPostprocessor.C:15
MooseEnum
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
InputParameters::addParam
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.
Definition: InputParameters.h:1198
NumDOFs::AUX
Definition: NumDOFs.h:42
NumDOFs::validParams
static InputParameters validParams()
Definition: NumDOFs.C:20
SubProblem::es
virtual EquationSystems & es()=0
defineLegacyParams
defineLegacyParams(NumDOFs)
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
GeneralPostprocessor
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
Definition: GeneralPostprocessor.h:27
InputParameters::addClassDescription
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.
Definition: InputParameters.C:70
NumDOFs::_system_enum
const SystemEnum _system_enum
Definition: NumDOFs.h:46
SubProblem.h
NumDOFs::_system_pointer
const System * _system_pointer
Definition: NumDOFs.h:48
NumDOFs::_es_pointer
const EquationSystems * _es_pointer
Definition: NumDOFs.h:49
NumDOFs::SystemEnum
SystemEnum
Definition: NumDOFs.h:39
NumDOFs::ALL
Definition: NumDOFs.h:43
UserObject::_subproblem
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:142
NumDOFs::getValue
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: NumDOFs.C:59
NumDOFs
Definition: NumDOFs.h:27
NumDOFs.h