https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ReporterTransferInterface Class Reference

#include <ReporterTransferInterface.h>

Inheritance diagram for ReporterTransferInterface:
[legend]

Public Member Functions

 ReporterTransferInterface (const Transfer *transfer)
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

void addReporterTransferMode (const ReporterName &name, const ReporterMode &mode, FEProblemBase &problem)
 
void transferReporter (const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, unsigned int time_index=0)
 
void transferToVectorReporter (const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, dof_id_type index, unsigned int time_index=0)
 
void transferFromVectorReporter (const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, dof_id_type index, unsigned int time_index=0)
 
void declareClone (const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, const ReporterMode &mode)
 
void declareClone (const ReporterName &rname, FEProblemBase &problem, const std::string &type, const ReporterMode &mode)
 
void declareVectorClone (const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, const ReporterMode &mode)
 
void declareVectorClone (const ReporterName &rname, FEProblemBase &problem, const std::string &type, const ReporterMode &mode)
 
void resizeReporter (const ReporterName &name, FEProblemBase &problem, dof_id_type n)
 
void clearVectorReporter (const ReporterName &name, FEProblemBase &problem)
 
void sumVectorReporter (const ReporterName &name, FEProblemBase &problem)
 
std::vector< ReporterNamegetReporterNamesHelper (std::string prefix, const std::string &obj_name, const std::vector< ReporterName > &rep_names)
 
void checkHasReporterValue (const ReporterName &reporter, const FEProblemBase &problem) const
 Checks if the problem problem has a Reporter value with the name reporter. More...
 

Static Protected Member Functions

static MultiMooseEnum standardTransferTypes ()
 

Private Member Functions

void hideVariableHelper (const ReporterName &reporter, FEProblemBase &problem)
 Helper for hiding the variables in the problem problem if the Reporter with name reporter is associated with a Reporter object (not a PP or VPP) More...
 

Private Attributes

const Transfer_rti_transfer
 The Transfer that this interface is associated with. More...
 

Detailed Description

Definition at line 27 of file ReporterTransferInterface.h.

Constructor & Destructor Documentation

◆ ReporterTransferInterface()

ReporterTransferInterface::ReporterTransferInterface ( const Transfer transfer)

Definition at line 23 of file ReporterTransferInterface.C.

24  : _rti_transfer(*transfer)
25 {
26 }
const Transfer & _rti_transfer
The Transfer that this interface is associated with.

Member Function Documentation

◆ addReporterTransferMode()

void ReporterTransferInterface::addReporterTransferMode ( const ReporterName name,
const ReporterMode mode,
FEProblemBase problem 
)
protected

Definition at line 29 of file ReporterTransferInterface.C.

Referenced by MultiAppCloneReporterTransfer::initialSetup(), MultiAppReporterTransfer::initialSetup(), and MultiAppReporterTransfer::setVectorReporterTransferModes().

32 {
33  checkHasReporterValue(name, problem);
36  .addConsumer(mode, _rti_transfer);
37 }
const ReporterStateBase & getReporterStateBase(const ReporterName &reporter_name) const
The ReporterStateBase associated with the Reporter with name reporter_name.
Definition: ReporterData.C:146
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
void addConsumer(ReporterMode mode, const MooseObject &moose_object)
Add a consumer for this ReporterState.
Definition: ReporterState.C:17
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
const Transfer & _rti_transfer
The Transfer that this interface is associated with.

◆ checkHasReporterValue()

void ReporterTransferInterface::checkHasReporterValue ( const ReporterName reporter,
const FEProblemBase problem 
) const
protected

Checks if the problem problem has a Reporter value with the name reporter.

Definition at line 218 of file ReporterTransferInterface.C.

Referenced by addReporterTransferMode(), clearVectorReporter(), declareClone(), declareVectorClone(), resizeReporter(), sumVectorReporter(), transferFromVectorReporter(), transferReporter(), and transferToVectorReporter().

220 {
221  if (!problem.getReporterData().hasReporterValue(reporter))
222  _rti_transfer.mooseError("Reporter with the name \"",
223  reporter,
224  "\" within app \"",
225  problem.getMooseApp().name(),
226  "\" was not found.");
227 }
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:45
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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
const Transfer & _rti_transfer
The Transfer that this interface is associated with.

◆ clearVectorReporter()

void ReporterTransferInterface::clearVectorReporter ( const ReporterName name,
FEProblemBase problem 
)
protected

Definition at line 190 of file ReporterTransferInterface.C.

Referenced by MultiAppReporterTransfer::executeFromMultiapp().

191 {
192  checkHasReporterValue(name, problem);
194 }
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
virtual void clear()=0
Helper for clearing vector data.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ declareClone() [1/2]

void ReporterTransferInterface::declareClone ( const ReporterName from_reporter,
const ReporterName to_reporter,
const FEProblemBase from_problem,
FEProblemBase to_problem,
const ReporterMode mode 
)
protected

Definition at line 99 of file ReporterTransferInterface.C.

Referenced by MultiAppCloneReporterTransfer::initialSetup().

104 {
105  checkHasReporterValue(from_reporter, from_problem);
106  from_problem.getReporterData()
107  .getReporterContextBase(from_reporter)
108  .declareClone(
109  to_problem.getReporterData(ReporterData::WriteKey()), to_reporter, mode, _rti_transfer);
110 
111  // Hide variables (if requested in parameters) if name is associated with a reporter object
112  hideVariableHelper(to_reporter, to_problem);
113 }
virtual void declareClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const =0
Helper for declaring new reporter values based on this context.
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
void hideVariableHelper(const ReporterName &reporter, FEProblemBase &problem)
Helper for hiding the variables in the problem problem if the Reporter with name reporter is associat...
const Transfer & _rti_transfer
The Transfer that this interface is associated with.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ declareClone() [2/2]

void ReporterTransferInterface::declareClone ( const ReporterName rname,
FEProblemBase problem,
const std::string &  type,
const ReporterMode mode 
)
protected

Definition at line 116 of file ReporterTransferInterface.C.

120 {
122  if (type == "bool")
124  else if (type == "integer")
126  else if (type == "real")
128  else if (type == "string")
130  rname, mode, _rti_transfer);
131  else
132  _rti_transfer.mooseError("Unknown reporter type, ", type, ".");
133 
134  // Hide variables (if requested in parameters) if name is associated with a reporter object
135  hideVariableHelper(rname, problem);
136 }
T & declareReporterValue(const ReporterName &reporter_name, const ReporterMode &mode, const MooseObject &producer, Args &&... args)
Method for returning a writable reference to the current Reporter value.
Definition: ReporterData.h:400
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
void hideVariableHelper(const ReporterName &reporter, FEProblemBase &problem)
Helper for hiding the variables in the problem problem if the Reporter with name reporter is associat...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void ErrorVector unsigned int
const Transfer & _rti_transfer
The Transfer that this interface is associated with.
This is a helper class for managing the storage of declared Reporter object values.
Definition: ReporterData.h:48

◆ declareVectorClone() [1/2]

void ReporterTransferInterface::declareVectorClone ( const ReporterName from_reporter,
const ReporterName to_reporter,
const FEProblemBase from_problem,
FEProblemBase to_problem,
const ReporterMode mode 
)
protected

Definition at line 139 of file ReporterTransferInterface.C.

Referenced by MultiAppCloneReporterTransfer::initialSetup().

144 {
145  checkHasReporterValue(from_reporter, from_problem);
146  from_problem.getReporterData()
147  .getReporterContextBase(from_reporter)
149  to_problem.getReporterData(ReporterData::WriteKey()), to_reporter, mode, _rti_transfer);
150 
151  // Hide variables (if requested in parameters) if name is associated with a reporter object
152  hideVariableHelper(to_reporter, to_problem);
153 }
virtual void declareVectorClone(ReporterData &r_data, const ReporterName &r_name, const ReporterMode &mode, const MooseObject &producer) const =0
Helper for declaring new vector reporter values based on this context.
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
void hideVariableHelper(const ReporterName &reporter, FEProblemBase &problem)
Helper for hiding the variables in the problem problem if the Reporter with name reporter is associat...
const Transfer & _rti_transfer
The Transfer that this interface is associated with.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ declareVectorClone() [2/2]

void ReporterTransferInterface::declareVectorClone ( const ReporterName rname,
FEProblemBase problem,
const std::string &  type,
const ReporterMode mode 
)
protected

Definition at line 156 of file ReporterTransferInterface.C.

160 {
162  if (type == "bool")
163  rdata.declareReporterValue<std::vector<bool>, ReporterVectorContext<bool>>(
164  rname, mode, _rti_transfer);
165  else if (type == "integer")
166  rdata.declareReporterValue<std::vector<int>, ReporterVectorContext<int>>(
167  rname, mode, _rti_transfer);
168  else if (type == "real")
169  rdata.declareReporterValue<std::vector<Real>, ReporterVectorContext<Real>>(
170  rname, mode, _rti_transfer);
171  else if (type == "string")
172  rdata.declareReporterValue<std::vector<std::string>, ReporterVectorContext<std::string>>(
173  rname, mode, _rti_transfer);
174  else
175  _rti_transfer.mooseError("Unknown reporter type, ", type, ".");
176 
177  // Hide variables (if requested in parameters) if name is associated with a reporter object
178  hideVariableHelper(rname, problem);
179 }
T & declareReporterValue(const ReporterName &reporter_name, const ReporterMode &mode, const MooseObject &producer, Args &&... args)
Method for returning a writable reference to the current Reporter value.
Definition: ReporterData.h:400
This context is specific for vector types of reporters, mainly for declaring a vector of the type fro...
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
void hideVariableHelper(const ReporterName &reporter, FEProblemBase &problem)
Helper for hiding the variables in the problem problem if the Reporter with name reporter is associat...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const Transfer & _rti_transfer
The Transfer that this interface is associated with.
This is a helper class for managing the storage of declared Reporter object values.
Definition: ReporterData.h:48

◆ getReporterNamesHelper()

std::vector< ReporterName > ReporterTransferInterface::getReporterNamesHelper ( std::string  prefix,
const std::string &  obj_name,
const std::vector< ReporterName > &  rep_names 
)
protected

Definition at line 204 of file ReporterTransferInterface.C.

207 {
208  if (!prefix.empty())
209  prefix += ":";
210  std::vector<ReporterName> rnames;
211  rnames.reserve(rep_names.size());
212  for (const auto & rn : rep_names)
213  rnames.emplace_back(obj_name, prefix + rn.getObjectName() + ":" + rn.getValueName());
214  return rnames;
215 }

◆ hideVariableHelper()

void ReporterTransferInterface::hideVariableHelper ( const ReporterName reporter,
FEProblemBase problem 
)
private

Helper for hiding the variables in the problem problem if the Reporter with name reporter is associated with a Reporter object (not a PP or VPP)

Definition at line 86 of file ReporterTransferInterface.C.

Referenced by declareClone(), and declareVectorClone().

88 {
89  if (problem.hasUserObject(reporter.getObjectName()))
90  {
91  Reporter * rep =
92  dynamic_cast<Reporter *>(&problem.getUserObject<UserObject>(reporter.getObjectName()));
93  if (rep)
95  }
96 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
bool hasUserObject(const std::string &name) const
Check if there if a user object of given name.
Reporter objects allow for the declaration of arbitrary data types that are aggregate values for a si...
Definition: Reporter.h:47
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
Definition: ReporterName.C:47
void buildOutputHideVariableList(std::set< std::string > variable_names)
Builds hide lists for output objects NOT listed in the &#39;outputs&#39; parameter.
const std::string & getObjectName() const
Return the object name that produces the Reporter value.
Definition: ReporterName.C:35
Base class for user-specific data.
Definition: UserObject.h:40

◆ resizeReporter()

void ReporterTransferInterface::resizeReporter ( const ReporterName name,
FEProblemBase problem,
dof_id_type  n 
)
protected

Definition at line 182 of file ReporterTransferInterface.C.

Referenced by MultiAppReporterTransfer::executeFromMultiapp(), and MultiAppCloneReporterTransfer::initialSetup().

185 {
186  checkHasReporterValue(name, problem);
188 }
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
virtual void resize(dof_id_type local_size)=0
Helper for resizing vector data.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ standardTransferTypes()

static MultiMooseEnum ReporterTransferInterface::standardTransferTypes ( )
inlinestaticprotected

Definition at line 34 of file ReporterTransferInterface.h.

Referenced by MultiAppCloneReporterTransfer::validParams().

35  {
36  return MultiMooseEnum("bool=0 integer=1 real=2 string=3");
37  }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...

◆ sumVectorReporter()

void ReporterTransferInterface::sumVectorReporter ( const ReporterName name,
FEProblemBase problem 
)
protected

Definition at line 197 of file ReporterTransferInterface.C.

Referenced by MultiAppReporterTransfer::executeFromMultiapp().

198 {
199  checkHasReporterValue(name, problem);
201 }
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
virtual void vectorSum()=0
Helper for summing reporter value.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ transferFromVectorReporter()

void ReporterTransferInterface::transferFromVectorReporter ( const ReporterName from_reporter,
const ReporterName to_reporter,
const FEProblemBase from_problem,
FEProblemBase to_problem,
dof_id_type  index,
unsigned int  time_index = 0 
)
protected

Definition at line 70 of file ReporterTransferInterface.C.

Referenced by MultiAppReporterTransfer::executeToMultiapp().

76 {
77  checkHasReporterValue(from_reporter, from_problem);
78  checkHasReporterValue(to_reporter, to_problem);
79  from_problem.getReporterData()
80  .getReporterContextBase(from_reporter)
82  to_problem.getReporterData(ReporterData::WriteKey()), to_reporter, index, time_index);
83 }
virtual void transferFromVector(ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const =0
Helper for enabling generic transfer of a vector Reporter of values to a single value.
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ transferReporter()

void ReporterTransferInterface::transferReporter ( const ReporterName from_reporter,
const ReporterName to_reporter,
const FEProblemBase from_problem,
FEProblemBase to_problem,
unsigned int  time_index = 0 
)
protected

Definition at line 40 of file ReporterTransferInterface.C.

Referenced by MultiAppCloneReporterTransfer::executeFromMultiapp(), MultiAppReporterTransfer::executeFromMultiapp(), and MultiAppReporterTransfer::executeToMultiapp().

45 {
46  checkHasReporterValue(from_reporter, from_problem);
47  checkHasReporterValue(to_reporter, to_problem);
48  from_problem.getReporterData()
49  .getReporterContextBase(from_reporter)
50  .transfer(to_problem.getReporterData(ReporterData::WriteKey()), to_reporter, time_index);
51 }
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
virtual void transfer(ReporterData &r_data, const ReporterName &r_name, unsigned int time_index=0) const =0
Helper for enabling generic transfer of Reporter values.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ transferToVectorReporter()

void ReporterTransferInterface::transferToVectorReporter ( const ReporterName from_reporter,
const ReporterName to_reporter,
const FEProblemBase from_problem,
FEProblemBase to_problem,
dof_id_type  index,
unsigned int  time_index = 0 
)
protected

Definition at line 54 of file ReporterTransferInterface.C.

Referenced by MultiAppCloneReporterTransfer::executeFromMultiapp(), and MultiAppReporterTransfer::executeFromMultiapp().

60 {
61  checkHasReporterValue(from_reporter, from_problem);
62  checkHasReporterValue(to_reporter, to_problem);
63  from_problem.getReporterData()
64  .getReporterContextBase(from_reporter)
66  to_problem.getReporterData(ReporterData::WriteKey()), to_reporter, index, time_index);
67 }
void checkHasReporterValue(const ReporterName &reporter, const FEProblemBase &problem) const
Checks if the problem problem has a Reporter value with the name reporter.
virtual void transferToVector(ReporterData &r_data, const ReporterName &r_name, dof_id_type index, unsigned int time_index=0) const =0
Helper for enabling generic transfer of Reporter values to a vector.
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
Definition: ReporterData.C:130

◆ validParams()

InputParameters ReporterTransferInterface::validParams ( )
static

Definition at line 17 of file ReporterTransferInterface.C.

Referenced by MultiAppCloneReporterTransfer::validParams(), and MultiAppReporterTransfer::validParams().

18 {
20  return params;
21 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()

Member Data Documentation

◆ _rti_transfer

const Transfer& ReporterTransferInterface::_rti_transfer
private

The Transfer that this interface is associated with.

Definition at line 216 of file ReporterTransferInterface.h.

Referenced by addReporterTransferMode(), checkHasReporterValue(), declareClone(), and declareVectorClone().


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