https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NumVars.C
Go to the documentation of this file.
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// MOOSE includes
11#include "NumVars.h"
12
13#include "AuxiliarySystem.h"
14#include "NonlinearSystemBase.h"
15#include "SubProblem.h"
16
18
21{
23
24 MooseEnum system_enum("NL AUX ALL", "ALL");
25 params.addParam<MooseEnum>("system",
26 system_enum,
27 "The system(s) for which you want to retrieve the number of variables "
28 "(NL, AUX, ALL). Default == ALL");
29
31 "Return the number of variables from either the NL, Aux, or both systems.");
32
33 return params;
34}
35
37 : GeneralPostprocessor(parameters),
38 _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()),
39 _system_pointer(nullptr),
40 _es_pointer(nullptr)
41{
42 switch (_system_enum)
43 {
44 case NL:
45 mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0");
47 break;
48 case AUX:
49 mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0");
51 break;
52 case ALL:
54 break;
55 default:
56 mooseError("Unhandled enum");
57 }
58}
59
60Real
62{
63 switch (_system_enum)
64 {
65 case NL:
66 case AUX:
67 return _system_pointer->n_vars();
68 case ALL:
69 return _es_pointer->n_vars();
70 default:
71 return 0;
72 }
73}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", NumVars)
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
const libMesh::System * _system_pointer
Definition NumVars.h:37
SystemEnum
Definition NumVars.h:29
@ ALL
Definition NumVars.h:32
@ AUX
Definition NumVars.h:31
const EquationSystems * _es_pointer
Definition NumVars.h:38
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition NumVars.C:61
const SystemEnum _system_enum
Definition NumVars.h:35
static InputParameters validParams()
Definition NumVars.C:20
NumVars(const InputParameters &parameters)
Definition NumVars.C:36
virtual libMesh::EquationSystems & es()=0
SubProblem & _subproblem
Reference to the Subproblem for this user object.
bool has_system(std::string_view name) const
const T_sys & get_system(std::string_view name) const
unsigned int n_vars() const