https://mooseframework.inl.gov
NumElements.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 "NumElements.h"
12 #include "SubProblem.h"
13 #include "MooseMesh.h"
14 
15 registerMooseObject("MooseApp", NumElements);
16 registerMooseObjectRenamed("MooseApp", NumElems, "04/01/2025 00:00", NumElements);
17 
20 {
22  MooseEnum filt("active total", "active");
23  params.addParam<MooseEnum>(
24  "elem_filter",
25  filt,
26  "The type of elements to include in the count (active, total). Default == active");
27 
28  params.addClassDescription("Return the number of active or total elements in the simulation.");
29  return params;
30 }
31 
33  : GeneralPostprocessor(parameters),
34  _filt(parameters.get<MooseEnum>("elem_filter").getEnum<ElemFilter>()),
35  _mesh(_subproblem.mesh().getMesh())
36 {
37 }
38 
39 Real
41 {
43  return _mesh.n_active_elem();
44  return _mesh.n_elem();
45 }
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
NumElements(const InputParameters &parameters)
Definition: NumElements.C:32
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MeshBase & _mesh
Mesh to act on.
Definition: NumElements.h:40
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
registerMooseObjectRenamed("MooseApp", NumElems, "04/01/2025 00:00", NumElements)
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
registerMooseObject("MooseApp", NumElements)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Counts the number of elements in the entire mesh.
Definition: NumElements.h:17
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: NumElements.C:40
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...
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...
const ElemFilter _filt
Whether to count all elements or only the active ones.
Definition: NumElements.h:37
static InputParameters validParams()
Definition: NumElements.C:19