Skip to content

Commit

Permalink
Reporter system enhancements
Browse files Browse the repository at this point in the history
- Declare Reporter values for PPs and VPPs within the objects themselves
- Add type checking on declare/request for Reporters with the same name
- Add producer/consumer MooseObject ptrs in ReporterState
- Add getter for information about a Reporter (type, producers, consumers,
  context, modes)
- Add more error handling to ReporterData, Reporter, and ReporterInterface

refs idaholab#17512 idaholab#17605
  • Loading branch information
loganharbour authored and somu15 committed May 15, 2021
1 parent b0afd00 commit 57cc599
Show file tree
Hide file tree
Showing 69 changed files with 988 additions and 856 deletions.

This file was deleted.

29 changes: 0 additions & 29 deletions framework/include/actions/SetupPostprocessorDataAction.h

This file was deleted.

7 changes: 6 additions & 1 deletion framework/include/base/MooseObject.h
Expand Up @@ -64,10 +64,15 @@ class MooseObject : public ConsoleStreamInterface, public libMesh::ParallelObjec
/**
* Get the name of the object
* @return The name of the object
* TODO:MooseVariableToMooseObject (see #10601)
*/
virtual const std::string & name() const { return _name; }

/**
* Get the object's combined type and name; useful in error handling.
* @return The type and name of this object in the form '<type()> "<name()>"'.
*/
std::string typeAndName() const;

/**
* Get the parameters of the object
* @return The parameters of the object
Expand Down
2 changes: 0 additions & 2 deletions framework/include/interfaces/PostprocessorInterface.h
Expand Up @@ -113,8 +113,6 @@ class PostprocessorInterface
*/
bool hasPostprocessorByName(const PostprocessorName & name) const;

bool hasEnabledPostprocessorByName(const PostprocessorName & name) const;

/**
* Returns number of Postprocessors coupled under parameter name
* @param param_name The name of the Postprocessor parameter
Expand Down
6 changes: 3 additions & 3 deletions framework/include/postprocessors/Postprocessor.h
Expand Up @@ -28,7 +28,7 @@ class Postprocessor : public OutputInterface
public:
static InputParameters validParams();

Postprocessor(const InputParameters & parameters);
Postprocessor(const MooseObject * moose_object);

/**
* This will get called to actually grab the final value the postprocessor has calculated.
Expand All @@ -38,8 +38,8 @@ class Postprocessor : public OutputInterface
/**
* Returns the name of the Postprocessor.
*/
std::string PPName() { return _pp_name; }
std::string PPName() const { return _pp_name; }

protected:
std::string _pp_name;
const std::string _pp_name;
};
8 changes: 0 additions & 8 deletions framework/include/problems/FEProblemBase.h
Expand Up @@ -899,14 +899,6 @@ class FEProblemBase : public SubProblem, public Restartable
*/
bool hasUserObject(const std::string & name) const;

/**
* Initializes the postprocessor data
*
* This is needed to correctly handle the default values
* @see SetupPostprocessorDataAction, PostprocessorInterface
*/
void initPostprocessorData(const std::string & name);

/**
* Get a read-only reference to the value associated with a Postprocessor that exists.
* @param name The name of the post-processor
Expand Down
22 changes: 17 additions & 5 deletions framework/include/reporters/Reporter.h
Expand Up @@ -47,7 +47,7 @@ class Reporter : public OutputInterface
{
public:
static InputParameters validParams();
Reporter(const InputParameters & parameters);
Reporter(const MooseObject * moose_object);
virtual ~Reporter() = default;
virtual void store(nlohmann::json & json) const;

Expand Down Expand Up @@ -148,6 +148,16 @@ class Reporter : public OutputInterface
T value;
};

/**
* @returns The ReporterValueName associated with the parameter \p param_name.
*
* Performs error checking on if the parameter is valid.
*/
const ReporterValueName & getReporterValueName(const std::string & param_name) const;

/// The MooseObject creating this Reporter
const MooseObject & _reporter_moose_object;

/// Ref. to MooseObject params
const InputParameters & _reporter_params;

Expand Down Expand Up @@ -189,8 +199,7 @@ template <typename T, typename S, typename... Args>
T &
Reporter::declareValue(const std::string & param_name, ReporterMode mode, Args &&... args)
{
const ReporterValueName & value_name = _reporter_params.get<ReporterValueName>(param_name);
return declareValueByName<T, S>(value_name, mode, args...);
return declareValueByName<T, S>(getReporterValueName(param_name), mode, args...);
}

template <typename T, template <typename> class S, typename... Args>
Expand Down Expand Up @@ -222,9 +231,12 @@ Reporter::declareValueByName(const ReporterValueName & value_name,
ReporterMode mode,
Args &&... args)
{
ReporterName state_name(_reporter_name, value_name);
const ReporterName state_name(_reporter_name, value_name);

buildOutputHideVariableList({state_name.getCombinedName()});
return _reporter_data.declareReporterValue<T, S>(state_name, mode, args...);

return _reporter_data.declareReporterValue<T, S>(
state_name, mode, _reporter_moose_object, args...);
}

template <typename T, typename... Args>
Expand Down

0 comments on commit 57cc599

Please sign in to comment.