www.mooseframework.org
PerfGraphData.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "PerfGraphData.h"
11 #include "SubProblem.h"
12 
13 #include "libmesh/system.h"
14 
16 
17 template <>
20 {
22 
23  MooseEnum data_type("SELF CHILDREN TOTAL SELF_AVG CHILDREN_AVG TOTAL_AVG SELF_PERCENT "
24  "CHILDREN_PERCENT TOTAL_PERCENT CALLS");
25 
26  params.addRequiredParam<std::string>("section_name", "The name of the section to get data for");
27 
29  "data_type", data_type, "The type of data to retrieve for the section_name");
30 
31  params.addClassDescription("Retrieves timing information from the PerfGraph.");
32  return params;
33 }
34 
36  : GeneralPostprocessor(parameters),
37  _data_type(getParam<MooseEnum>("data_type")),
38  _section_name(getParam<std::string>("section_name"))
39 {
40 }
41 
42 Real
44 {
45  switch (_data_type)
46  {
47  case 0:
48  case 1:
49  case 2:
50  case 3:
51  case 4:
52  case 5:
53  case 6:
54  case 7:
55  case 8:
56  return _perf_graph.getTime(static_cast<PerfGraph::TimeType>(_data_type), _section_name);
57  case 9:
59  }
60 
61  mooseError("Unknown selection for data_type!");
62 }
InputParameters validParams< PerfGraphData >()
Definition: PerfGraphData.C:19
unsigned long int getNumCalls(const std::string &section_name)
Get the number of calls for a section.
Definition: PerfGraph.C:71
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
PerfGraph & _perf_graph
The performance graph to add to.
InputParameters validParams< GeneralPostprocessor >()
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: PerfGraphData.C:43
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
const int _data_type
Definition: PerfGraphData.h:37
PerfGraphData(const InputParameters &parameters)
Definition: PerfGraphData.C:35
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...
Real getTime(const TimeType type, const std::string &section_name)
Get a reference to the time for a section.
Definition: PerfGraph.C:87
const std::string & _section_name
Definition: PerfGraphData.h:39
registerMooseObject("MooseApp", PerfGraphData)