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 : #include "NumDOFs.h" 11 : #include "SubProblem.h" 12 : 13 : #include "libmesh/system.h" 14 : 15 : registerMooseObject("MooseApp", NumDOFs); 16 : 17 : InputParameters 18 15717 : NumDOFs::validParams() 19 : { 20 15717 : InputParameters params = GeneralPostprocessor::validParams(); 21 15717 : MooseEnum system_enum("NL AUX ALL", "ALL"); 22 15717 : 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 15717 : params.addClassDescription( 28 : "Return the number of Degrees of freedom from either the NL, Aux or both systems."); 29 31434 : return params; 30 15717 : } 31 : 32 722 : NumDOFs::NumDOFs(const InputParameters & parameters) 33 : : GeneralPostprocessor(parameters), 34 722 : _system_enum(parameters.get<MooseEnum>("system").getEnum<SystemEnum>()), 35 722 : _system_pointer(nullptr), 36 722 : _es_pointer(nullptr) 37 : { 38 722 : switch (_system_enum) 39 : { 40 36 : case NL: 41 : mooseAssert(_subproblem.es().has_system("nl0"), "No Nonlinear System found with name nl0"); 42 36 : _system_pointer = &_subproblem.es().get_system("nl0"); 43 36 : break; 44 12 : case AUX: 45 : mooseAssert(_subproblem.es().has_system("aux0"), "No Auxilary System found with name aux0"); 46 12 : _system_pointer = &_subproblem.es().get_system("aux0"); 47 12 : break; 48 674 : case ALL: 49 674 : _es_pointer = &_subproblem.es(); 50 674 : break; 51 0 : default: 52 0 : mooseError("Unhandled enum"); 53 : } 54 722 : } 55 : 56 : Real 57 1815 : NumDOFs::getValue() const 58 : { 59 1815 : switch (_system_enum) 60 : { 61 330 : case NL: 62 : case AUX: 63 330 : return _system_pointer->n_dofs(); 64 1485 : case ALL: 65 1485 : return _es_pointer->n_dofs(); 66 0 : default: 67 0 : return 0; 68 : } 69 : }