https://mooseframework.inl.gov
ReporterInterface.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 #include "ReporterInterface.h"
11 
12 #include "FEProblemBase.h"
13 
16 {
17  return emptyInputParameters();
18 }
19 
21  : _ri_params(moose_object->parameters()),
22  _ri_fe_problem_base(*_ri_params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
23  _ri_reporter_data(_ri_fe_problem_base.getReporterData()),
24  _ri_moose_object(*moose_object)
25 {
26 }
27 
28 bool
29 ReporterInterface::hasReporterValue(const std::string & param_name) const
30 {
31  if (!reportersAdded())
33  "Cannot call hasReporterValue() until all Reporters have been constructed.");
34 
35  return hasReporterValueByName(getReporterName(param_name));
36 }
37 
38 bool
40 {
41  if (!reportersAdded())
43  "Cannot call hasReporterValueByName() until all Reporters have been constructed.");
44 
45  return _ri_reporter_data.hasReporterValue(reporter_name);
46 }
47 
48 const ReporterName &
49 ReporterInterface::getReporterName(const std::string & param_name) const
50 {
51  if (!_ri_params.isParamValid(param_name))
53  "When getting a Reporter, failed to get a parameter with the name \"",
54  param_name,
55  "\".",
56  "\n\nKnown parameters:\n",
58 
59  if (_ri_params.isType<ReporterName>(param_name))
60  return _ri_params.get<ReporterName>(param_name);
61 
62  _ri_moose_object.mooseError("Supplied parameter with name \"",
63  param_name,
64  "\" of type \"",
65  _ri_params.type(param_name),
66  "\" is not an expected type for getting a Reporter.\n\n",
67  "The expected type is \"ReporterName\".");
68 }
69 
70 bool
72 {
74 }
static InputParameters validParams()
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
bool isTaskComplete(const std::string &task) const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const ReporterName & getReporterName(const std::string &param_name) const
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:45
InputParameters emptyInputParameters()
bool reportersAdded() const
bool hasReporterValue(const std::string &param_name) const
Return True if the Reporter value exists.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition: MooseApp.h:237
ReporterInterface(const MooseObject *moose_object)
bool isType(const std::string &name) const
const MooseObject & _ri_moose_object
The MooseObject needing this interface.
const InputParameters & _ri_params
Parameters for the MooseObject inherting from this interface.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const ReporterData & _ri_reporter_data
The ReporterData.
const InputParameters & parameters() const
Get the parameters of the object.
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
Definition: ReporterData.h:445
bool hasReporterValueByName(const ReporterName &reporter_name) const
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30
FEProblemBase & _ri_fe_problem_base
Provides access to FEProblemBase::getReporterData.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.