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