https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Reporter.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 "Reporter.h"
11#include "InputParameters.h"
12#include "FEProblemBase.h"
13#include "MooseApp.h"
14
17{
20
21 params.registerBase("Reporter");
22 return params;
23}
24
25// The OutputInterface automatic creation of the "variable" build list is disabled because the
26// output names for the reporters are more than just the block name. The list is updated manually
27// when each value is declared.
28
29Reporter::Reporter(const MooseObject * moose_object)
30 : OutputInterface(moose_object->parameters(), /*build_list=*/false),
31 _reporter_moose_object(*moose_object),
32 _reporter_params(_reporter_moose_object.parameters()),
33 _reporter_name(_reporter_moose_object.name()),
34 _reporter_fe_problem(
35 *_reporter_params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
36 _reporter_data(_reporter_fe_problem.getReporterData(ReporterData::WriteKey()))
37{
38 // For the callback to declareLateValues()
40}
41
42#ifdef MOOSE_KOKKOS_ENABLED
44 : OutputInterface(object, key),
45 _reporter_moose_object(object._reporter_moose_object),
46 _reporter_params(object._reporter_params),
47 _reporter_name(object._reporter_name),
48 _reporter_fe_problem(object._reporter_fe_problem),
49 _reporter_data(object._reporter_data)
50{
51}
52#endif
53
54void
55Reporter::store(nlohmann::json & json) const
56{
57 json["type"] = _reporter_moose_object.type();
58}
59
60const ReporterValueName &
61Reporter::getReporterValueName(const std::string & param_name) const
62{
63 if (!_reporter_params.isParamValid(param_name))
65 "When getting a ReporterValueName, failed to get a parameter with the name \"",
66 param_name,
67 "\".",
68 "\n\nKnown parameters:\n",
70
71 if (_reporter_params.isType<ReporterValueName>(param_name))
72 return _reporter_params.get<ReporterValueName>(param_name);
73
74 _reporter_moose_object.mooseError("Supplied parameter with name \"",
75 param_name,
76 "\" of type \"",
77 _reporter_params.type(param_name),
78 "\" is not an expected type for getting a Reporter value.\n\n",
79 "The expected type is \"ReporterValueName\".");
80}
InputParameters emptyInputParameters()
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.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action 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,...
void registerInterfaceObject(T &interface)
Registers an interface object for accessing with getInterfaceObjects.
Definition MooseApp.h:1779
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
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
A class to provide an common interface to objects requiring "outputs" option.
static InputParameters validParams()
This is a helper class for managing the storage of declared Reporter object values.
Reporter objects allow for the declaration of arbitrary data types that are aggregate values for a si...
Definition Reporter.h:48
const InputParameters & _reporter_params
Ref. to MooseObject params.
Definition Reporter.h:189
virtual void store(nlohmann::json &json) const
Definition Reporter.C:55
Reporter(const MooseObject *moose_object)
Definition Reporter.C:29
const ReporterValueName & getReporterValueName(const std::string &param_name) const
Definition Reporter.C:61
static InputParameters validParams()
Definition Reporter.C:16
const MooseObject & _reporter_moose_object
The MooseObject creating this Reporter.
Definition Reporter.h:186