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 : // MOOSE includes 11 : #include "NumVars.h" 12 : 13 : #include "AuxiliarySystem.h" 14 : #include "NonlinearSystemBase.h" 15 : #include "SubProblem.h" 16 : 17 : registerMooseObject("MooseApp", NumVars); 18 : 19 : InputParameters 20 4083 : NumVars::validParams() 21 : { 22 4083 : InputParameters params = GeneralPostprocessor::validParams(); 23 : 24 16332 : MooseEnum system_enum("NL AUX ALL", "ALL"); 25 16332 : 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 : 30 4083 : params.addClassDescription( 31 : "Return the number of variables from either the NL, Aux, or both systems."); 32 : 33 8166 : return params; 34 4083 : } 35 : 36 511 : NumVars::NumVars(const InputParameters & parameters) 37 : : GeneralPostprocessor(parameters), 38 511 : _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()), 39 511 : _system_pointer(nullptr), 40 511 : _es_pointer(nullptr) 41 : { 42 511 : switch (_system_enum) 43 : { 44 269 : case NL: 45 : mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0"); 46 269 : _system_pointer = &_subproblem.es().get_system("nl0"); 47 269 : break; 48 230 : case AUX: 49 : mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0"); 50 230 : _system_pointer = &_subproblem.es().get_system("aux0"); 51 230 : break; 52 12 : case ALL: 53 12 : _es_pointer = &_subproblem.es(); 54 12 : break; 55 0 : default: 56 0 : mooseError("Unhandled enum"); 57 : } 58 511 : } 59 : 60 : Real 61 545 : NumVars::getValue() const 62 : { 63 545 : switch (_system_enum) 64 : { 65 534 : case NL: 66 : case AUX: 67 534 : return _system_pointer->n_vars(); 68 11 : case ALL: 69 11 : return _es_pointer->n_vars(); 70 0 : default: 71 0 : return 0; 72 : } 73 : }