https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Moose::Kokkos::Reporter Class Reference

#include <KokkosReporter.h>

Inheritance diagram for Moose::Kokkos::Reporter:
[legend]

Public Member Functions

 Reporter (const MooseObject *moose_object)
 
 Reporter (const Reporter &object)
 Copy constructor for parallel dispatch.
 
virtual void store (nlohmann::json &json) const
 
virtual bool shouldStore () const
 
virtual void declareLateValues ()
 Method that can be overriden to declare "late" Reporter values.
 
void buildOutputHideVariableList (std::set< std::string > variable_names)
 Builds hide lists for output objects NOT listed in the 'outputs' parameter.
 
const std::set< OutputName > & getOutputs ()
 Get the list of output objects that this class is restricted.
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

template<typename T , typename... Args>
T & declareUnusedValue (Args &&... args)
 Declare a unused value with type T.
 
template<typename T , template< typename > class S = ReporterGeneralContext, typename... Args>
T & declareValue (const std::string &param_name, Args &&... args)
 Method to define a value that the Reporter object is to produced.
 
template<typename T , template< typename > class S = ReporterGeneralContext, typename... Args>
T & declareValue (const std::string &param_name, ReporterMode mode, Args &&... args)
 
template<typename T , typename S , typename... Args>
T & declareValue (const std::string &param_name, Args &&... args)
 
template<typename T , typename S , typename... Args>
T & declareValue (const std::string &param_name, ReporterMode mode, Args &&... args)
 
template<typename T , template< typename > class S = ReporterGeneralContext, typename... Args>
T & declareValueByName (const ReporterValueName &value_name, Args &&... args)
 
template<typename T , template< typename > class S = ReporterGeneralContext, typename... Args>
T & declareValueByName (const ReporterValueName &value_name, ReporterMode mode, Args &&... args)
 
template<typename T , typename S , typename... Args>
T & declareValueByName (const ReporterValueName &value_name, Args &&... args)
 
template<typename T , typename S , typename... Args>
T & declareValueByName (const ReporterValueName &value_name, ReporterMode mode, Args &&... args)
 

Private Member Functions

const ReporterValueName & getReporterValueName (const std::string &param_name) const
 

Private Attributes

const MooseObject_reporter_moose_object
 The MooseObject creating this Reporter.
 
const InputParameters_reporter_params
 Ref. to MooseObject params.
 
const std::string & _reporter_name
 The name of the MooseObject, from "_object_name" param.
 
FEProblemBase_reporter_fe_problem
 Needed for access to FEProblemBase::getReporterData.
 
ReporterData_reporter_data
 Data storage.
 
std::vector< std::unique_ptr< UnusedWrapperBase > > _unused_values
 Storage for unused values declared with declareUnusedValue().
 
MooseApp_oi_moose_app
 Reference the the MooseApp; neede for access to the OutputWarehouse.
 
OutputWarehouse_oi_output_warehouse
 Reference to the OutputWarehouse for populating the Output object hide lists.
 
std::set< OutputName > _oi_outputs
 The set of Output object names listed in the 'outputs' parameter.
 

Detailed Description

Definition at line 17 of file KokkosReporter.h.

Constructor & Destructor Documentation

◆ Reporter() [1/2]

Moose::Kokkos::Reporter::Reporter ( const MooseObject moose_object)

◆ Reporter() [2/2]

Moose::Kokkos::Reporter::Reporter ( const Reporter object)

Copy constructor for parallel dispatch.

Member Function Documentation

◆ buildOutputHideVariableList()

void OutputInterface::buildOutputHideVariableList ( std::set< std::string >  variable_names)
inherited

Builds hide lists for output objects NOT listed in the 'outputs' parameter.

Parameters
variable_namesA set of variables for which the 'outputs' parameter controls

By default this is called by the constructor and passes the block name as the list of variables. This needs to be called explicitly if the build_list flag is set to False in the constructor. The latter cases is needed by the Material object to work correctly with the automatic material output capability.

Definition at line 68 of file OutputInterface.C.

69{
70 // Set of available names
71 const std::set<OutputName> & avail = _oi_output_warehouse.getOutputNames();
72
73 // Check for 'none'; hide variables on all outputs
74 if (_oi_outputs.find("none") != _oi_outputs.end())
75 for (const auto & name : avail)
76 _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
77
78 // Check for empty and 'all' in 'outputs' parameter; do not perform any variable restrictions in
79 // these cases
80 else if (_oi_outputs.empty() || _oi_outputs.find("all") != _oi_outputs.end())
81 return;
82
83 // Limit the variable output to Output objects listed
84 else
85 {
86 // Create a list of outputs where the variable should be hidden
87 std::set<OutputName> hide;
88 std::set_difference(avail.begin(),
89 avail.end(),
90 _oi_outputs.begin(),
91 _oi_outputs.end(),
92 std::inserter(hide, hide.begin()));
93
94 // If 'outputs' is specified add the object name to the list of items to hide
95 for (const auto & name : hide)
96 _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
97 }
98}
OutputWarehouse & _oi_output_warehouse
Reference to the OutputWarehouse for populating the Output object hide lists.
std::set< OutputName > _oi_outputs
The set of Output object names listed in the 'outputs' parameter.
const std::set< OutputName > & getOutputNames()
Get a complete set of all output object names.
std::string name(const ElemQuality q)

Referenced by ReporterTransferInterface::hideVariableHelper(), and OutputInterface::OutputInterface().

◆ declareLateValues()

virtual void Reporter::declareLateValues ( )
inlinevirtualinherited

Method that can be overriden to declare "late" Reporter values.

Values are considered "late" when they need to be declared after all other Reporters have been instantiated. This is called by the "declare_late_reporters" task, which should be called right after the "add_reporters" task.

Reimplemented in AccumulateReporter.

Definition at line 79 of file Reporter.h.

79{}

◆ declareUnusedValue()

template<typename T , typename... Args>
T & Reporter::declareUnusedValue ( Args &&...  args)
protectedinherited

Declare a unused value with type T.

This is useful when you have a reporter that has optional values. In this case, you want to create references to all reporter values. However, because some values are optional, you need something to fill into the reference. This helper will create a unused value. It also allows for the passing of arguments in the case that your value is not trivially default constructable (constructable by default without arguments).

Definition at line 278 of file Reporter.h.

279{
280 _unused_values.emplace_back(std::make_unique<UnusedWrapper<T>>(std::forward(args)...));
281 UnusedWrapper<T> * wrapper = dynamic_cast<UnusedWrapper<T> *>(_unused_values.back().get());
282 return wrapper->value;
283}
std::vector< std::unique_ptr< UnusedWrapperBase > > _unused_values
Storage for unused values declared with declareUnusedValue().
Definition Reporter.h:201

◆ declareValue() [1/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValue ( const std::string &  param_name,
Args &&...  args 
)
protectedinherited

Method to define a value that the Reporter object is to produced.

Template Parameters
TThe C++ type of the value to be produced
S(optional) Context type for performing special operations. For example using the ReporterBroadcastContext will automatically broadcast the produced value from the root processor.
Parameters
nameA unique name for the value to be produced.
mode(optional) The mode that indicates how the value produced is represented in parallel, there is more information about this below
args(optional) Any number of optional arguments passed into the ReporterContext given by the S template parameter. If S = ReporterContext then the first argument can be used as the default value (see ReporterContext.h).

The 'mode' indicates how the value that is produced is represented in parallel. It is the responsibility of the Reporter object to get it to that state. The ReporterContext objects are designed to help with this. The mode can be one of the following:

ReporterMode::ROOT Indicates that the value produced is complete/correct on the
                   root processor for the object.
ReporterMode::REPLICATED Indicates that the value produced is complete/correct on
                         all processors AND that the value is the same on all
                         processors
ReporterMode::DISTRIBUTED Indicates that the value produced is complete/correct on
                          all processors AND that the value is NOT the same on all
                          processors

WARNING! Using the "default value" in ReporterContext: The Reporter system, like the systems before it, allow for objects that consume values to be constructed prior to the produce objects. When a value is requested either by a producer (Reporter) or consumer (ReporterInterface) the data is allocated. As such the assigned default value from the producer should not be relied upon on the consumer side during object construction.

NOTE: The ReporterContext is just a mechanism to allow for handling of values in special ways. In practice it might be better to have specific methods for these special cases. For example, a declareBroadcastValue, etc. Please refer to the ReporterData object for more information on how the data system operates for Reporter values.

Definition at line 206 of file Reporter.h.

207{
208 return declareValue<T, S<T>>(param_name, REPORTER_MODE_UNSET, args...);
209}
const ReporterMode REPORTER_MODE_UNSET

◆ declareValue() [2/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValue ( const std::string &  param_name,
Args &&...  args 
)
protectedinherited

◆ declareValue() [3/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValue ( const std::string &  param_name,
ReporterMode  mode,
Args &&...  args 
)
protectedinherited

Definition at line 213 of file Reporter.h.

214{
215 return declareValue<T, S<T>>(param_name, mode, args...);
216}

◆ declareValue() [4/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValue ( const std::string &  param_name,
ReporterMode  mode,
Args &&...  args 
)
protectedinherited

◆ declareValueByName() [1/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValueByName ( const ReporterValueName &  value_name,
Args &&...  args 
)
protectedinherited

Definition at line 234 of file Reporter.h.

235{
236 return declareValueByName<T, S<T>>(value_name, REPORTER_MODE_UNSET, args...);
237}

◆ declareValueByName() [2/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValueByName ( const ReporterValueName &  value_name,
Args &&...  args 
)
protectedinherited

◆ declareValueByName() [3/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValueByName ( const ReporterValueName &  value_name,
ReporterMode  mode,
Args &&...  args 
)
protectedinherited

Definition at line 241 of file Reporter.h.

244{
245 return declareValueByName<T, S<T>>(value_name, mode, args...);
246}

◆ declareValueByName() [4/4]

template<typename T , typename S , typename... Args>
T & Reporter::declareValueByName ( const ReporterValueName &  value_name,
ReporterMode  mode,
Args &&...  args 
)
protectedinherited

◆ getOutputs()

const std::set< OutputName > & OutputInterface::getOutputs ( )
inherited

Get the list of output objects that this class is restricted.

Returns
A set of OutputNames

Definition at line 101 of file OutputInterface.C.

102{
103 return _oi_outputs;
104}

◆ getReporterValueName()

const ReporterValueName & Reporter::getReporterValueName ( const std::string &  param_name) const
privateinherited
Returns
The ReporterValueName associated with the parameter param_name.

Performs error checking on if the parameter is valid.

Definition at line 61 of file Reporter.C.

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}
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,...
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
const InputParameters & _reporter_params
Ref. to MooseObject params.
Definition Reporter.h:189
const MooseObject & _reporter_moose_object
The MooseObject creating this Reporter.
Definition Reporter.h:186

◆ shouldStore()

virtual bool Reporter::shouldStore ( ) const
inlinevirtualinherited
Returns
Whether or not this Reporter should store its value at this specific time.

Basic Reporters (those that are not GeneralReporters) will store at all times when requested.

Reimplemented in ElementReporter, GeneralReporter, and NodalReporter.

Definition at line 69 of file Reporter.h.

69{ return true; }

◆ store()

void Reporter::store ( nlohmann::json &  json) const
virtualinherited

Definition at line 55 of file Reporter.C.

56{
57 json["type"] = _reporter_moose_object.type();
58}
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93

◆ validParams()

static InputParameters Moose::Kokkos::Reporter::validParams ( )
static

Member Data Documentation

◆ _oi_moose_app

MooseApp& OutputInterface::_oi_moose_app
privateinherited

Reference the the MooseApp; neede for access to the OutputWarehouse.

Definition at line 72 of file OutputInterface.h.

◆ _oi_output_warehouse

OutputWarehouse& OutputInterface::_oi_output_warehouse
privateinherited

Reference to the OutputWarehouse for populating the Output object hide lists.

Definition at line 75 of file OutputInterface.h.

Referenced by OutputInterface::buildOutputHideVariableList().

◆ _oi_outputs

std::set<OutputName> OutputInterface::_oi_outputs
privateinherited

The set of Output object names listed in the 'outputs' parameter.

Definition at line 78 of file OutputInterface.h.

Referenced by OutputInterface::buildOutputHideVariableList(), and OutputInterface::getOutputs().

◆ _reporter_data

ReporterData& Reporter::_reporter_data
privateinherited

Data storage.

Definition at line 198 of file Reporter.h.

◆ _reporter_fe_problem

FEProblemBase& Reporter::_reporter_fe_problem
privateinherited

Needed for access to FEProblemBase::getReporterData.

Definition at line 195 of file Reporter.h.

◆ _reporter_moose_object

const MooseObject& Reporter::_reporter_moose_object
privateinherited

The MooseObject creating this Reporter.

Definition at line 186 of file Reporter.h.

Referenced by Reporter::getReporterValueName(), Reporter::Reporter(), and Reporter::store().

◆ _reporter_name

const std::string& Reporter::_reporter_name
privateinherited

The name of the MooseObject, from "_object_name" param.

Definition at line 192 of file Reporter.h.

◆ _reporter_params

const InputParameters& Reporter::_reporter_params
privateinherited

Ref. to MooseObject params.

Definition at line 189 of file Reporter.h.

Referenced by Reporter::getReporterValueName().

◆ _unused_values

std::vector<std::unique_ptr<UnusedWrapperBase> > Reporter::_unused_values
privateinherited

Storage for unused values declared with declareUnusedValue().

Definition at line 201 of file Reporter.h.

Referenced by Reporter::declareUnusedValue().


The documentation for this class was generated from the following file: