https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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#ifdef MOOSE_KOKKOS_ENABLED
31 : _ri_params(object._ri_params),
32 _ri_fe_problem_base(object._ri_fe_problem_base),
33 _ri_reporter_data(object._ri_reporter_data),
34 _ri_moose_object(object._ri_moose_object)
35{
36}
37#endif
38
39bool
40ReporterInterface::hasReporterValue(const std::string & param_name) const
41{
42 if (!reportersAdded())
44 "Cannot call hasReporterValue() until all Reporters have been constructed.");
45
46 return hasReporterValueByName(getReporterName(param_name));
47}
48
49bool
51{
52 if (!reportersAdded())
54 "Cannot call hasReporterValueByName() until all Reporters have been constructed.");
55
56 return _ri_reporter_data.hasReporterValue(reporter_name);
57}
58
61{
62 if (!reportersAdded())
64 "Cannot call getReporterContextBaseByName() until all Reporters have been constructed.");
65
66 return _ri_reporter_data.getReporterContextBase(reporter_name);
67}
68
69const ReporterName &
70ReporterInterface::getReporterName(const std::string & param_name) const
71{
72 if (!_ri_params.isParamValid(param_name))
74 "When getting a Reporter, failed to get a parameter with the name \"",
75 param_name,
76 "\".",
77 "\n\nKnown parameters:\n",
79
80 if (_ri_params.isType<ReporterName>(param_name))
81 return _ri_params.get<ReporterName>(param_name);
82
83 _ri_moose_object.mooseError("Supplied parameter with name \"",
84 param_name,
85 "\" of type \"",
86 _ri_params.type(param_name),
87 "\" is not an expected type for getting a Reporter.\n\n",
88 "The expected type is \"ReporterName\".");
89}
90
91bool
InputParameters emptyInputParameters()
bool isTaskComplete(const std::string &task) const
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
bool isType(const std::string &name) const
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition MooseApp.h:217
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition MooseBase.h:87
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
This is a helper class to aid with parallel communication of compute Reporter values as well as provi...
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
Interface to allow object to consume Reporter values.
const ReporterName & getReporterName(const std::string &param_name) const
bool reportersAdded() const
const InputParameters & _ri_params
Parameters for the MooseObject inherting from this interface.
const MooseObject & _ri_moose_object
The MooseObject needing this interface.
static InputParameters validParams()
const ReporterData & _ri_reporter_data
The ReporterData.
bool hasReporterValueByName(const ReporterName &reporter_name) const
bool hasReporterValue(const std::string &param_name) const
Return True if the Reporter value exists.
FEProblemBase & _ri_fe_problem_base
Provides access to FEProblemBase::getReporterData.
ReporterInterface(const MooseObject *moose_object)
const ReporterContextBase & getReporterContextBaseByName(const ReporterName &reporter_name) const
Get the reporter context to allow non-typed operations with the data.
The Reporter system is comprised of objects that can contain any number of data values.