www.mooseframework.org
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
OutputWarehouse Class Reference

Class for storing and utilizing output objects. More...

#include <OutputWarehouse.h>

Inheritance diagram for OutputWarehouse:
[legend]

Public Member Functions

 OutputWarehouse (MooseApp &app)
 Class constructor. More...
 
virtual ~OutputWarehouse ()
 
void addOutput (std::shared_ptr< Output > output)
 Adds an existing output object to the warehouse. More...
 
const std::set< OutputName > & getOutputNames ()
 Get a complete set of all output object names. More...
 
bool hasOutput (const std::string &name) const
 Returns true if the output object exists. More...
 
void meshChanged ()
 Calls the meshChanged method for every output object. More...
 
void buildInterfaceHideVariables (const std::string &output_name, std::set< std::string > &hide)
 Return the list of hidden variables for the given output name. More...
 
void setFileNumbers (std::map< std::string, unsigned int > input, unsigned int offset=0)
 Calls the setFileNumber method for every FileOutput output object. More...
 
std::map< std::string, unsigned intgetFileNumbers ()
 Extracts the file numbers from the output objects. More...
 
void setCommonParameters (const InputParameters *params_ptr)
 Stores the common InputParameters object. More...
 
const InputParametersgetCommonParameters () const
 Get a reference to the common output parameters. More...
 
std::set< Real > & getSyncTimes ()
 Return the sync times for all objects. More...
 
void checkOutputs (const std::set< OutputName > &names)
 Test that the output names exist. More...
 
template<typename T >
T * getOutput (const OutputName &name)
 Return an Output object by name. More...
 
template<typename T >
std::vector< T * > getOutputs (const std::vector< OutputName > &names)
 Return a vector of objects by names. More...
 
template<typename T >
std::vector< T * > getOutputs () const
 Return a vector of objects of a given type. More...
 
template<typename T >
std::vector< OutputName > getOutputNames ()
 Return a list of output objects with a given type. More...
 
const std::set< std::string > & getReservedNames () const
 Return a set of reserved output names. More...
 
bool isReservedName (const std::string &name)
 Test if the given name is reserved. More...
 
void mooseConsole ()
 Send current output buffer to Console output objects. More...
 
void mooseConsole (std::ostringstream &buffer)
 Send a buffer to Console output objects. More...
 
std::ostringstream & consoleBuffer ()
 The buffered messages stream for Console objects. More...
 
void bufferConsoleOutputsBeforeConstruction (bool buffer)
 Set if the outputs to Console before its construction are to be buffered or to screen directly. More...
 
void reset ()
 Reset the output system. More...
 
void solveSetup ()
 Calls the timestepSetup function for each of the output objects. More...
 
unsigned long long int numPrinted () const
 The number of times something has been printed. More...
 

Protected Member Functions

PerfGraphperfGraph ()
 Get the PerfGraph. More...
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing. More...
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 Call to register a named section for timing. More...
 
std::string timedSectionName (const std::string &section_name) const
 

Static Protected Member Functions

static InputParameters validParams ()
 

Protected Attributes

MooseApp_pg_moose_app
 The MooseApp that owns the PerfGraph. More...
 
const std::string _prefix
 A prefix to use for all sections. More...
 

Private Member Functions

void outputStep (ExecFlagType type)
 Calls the outputStep method for each output object. More...
 
void forceOutput ()
 Indicates that the next call to outputStep should be forced This is private, users should utilize FEProblemBase::forceOutput() More...
 
void addOutputFilename (const OutputName &obj_name, const OutFileBase &filename)
 Adds the file name to the map of filenames being output with an associated object The main function of this object is to test that the same output file does not already exist in another object to protect against output files overwriting each other. More...
 
void initialSetup ()
 Calls the initialSetup function for each of the output objects. More...
 
void timestepSetup ()
 Calls the timestepSetup function for each of the output objects. More...
 
void customSetup (const ExecFlagType &exec_type)
 Calls the setup function for each of the output objects. More...
 
void jacobianSetup ()
 Calls the jacobianSetup function for each of the output objects. More...
 
void residualSetup ()
 Calls the residualSetup function for each of the output objects. More...
 
void subdomainSetup ()
 Calls the subdomainSetup function for each of the output objects. More...
 
void addInterfaceHideVariables (const std::string &output_name, const std::set< std::string > &variable_names)
 Insert variable names for hiding via the OutoutInterface. More...
 
void setOutputExecutionType (ExecFlagType type)
 Sets the execution flag type. More...
 
void flushConsoleBuffer ()
 If content exists in the buffer, write it. More...
 
void resetFileBase ()
 Resets the file base for all FileOutput objects. More...
 
void allowOutput (bool state)
 Ability to enable/disable output calls This is private, users should utilize FEProblemBase::allowOutput() More...
 
template<typename T >
void allowOutput (bool state)
 

Private Attributes

std::vector< std::shared_ptr< Output > > _all_ptrs
 We are using std::shared_ptr to handle the cleanup of the pointers at the end of execution. More...
 
MooseApp_app
 MooseApp. More...
 
std::vector< Output * > _all_objects
 All instances of objects (raw pointers) More...
 
bool _buffer_action_console_outputs
 True to buffer console outputs in actions. More...
 
std::map< OutputName, Output * > _object_map
 A map of the output pointers. More...
 
std::set< OutputName > _object_names
 A set of output names. More...
 
std::map< OutputName, std::set< OutFileBase > > _file_base_map
 List of object names. More...
 
const InputParameters_common_params_ptr
 Pointer to the common InputParameters (. More...
 
std::set< Real_sync_times
 Sync times for all objects. More...
 
std::string _input_file_name
 Input file name for this output object. More...
 
std::map< OutputName, std::set< AuxVariableName > > _material_output_map
 Map of output name and AuxVariable names to be output (used by auto Material output) More...
 
std::set< AuxVariableName > _all_material_output_variables
 List of all variable created by auto material output. More...
 
std::set< std::string > _reserved
 List of reserved names. More...
 
std::ostringstream _console_buffer
 The stream for holding messages passed to _console prior to Output object construction. More...
 
std::map< std::string, std::set< std::string > > _interface_map
 Storage for variables to hide as prescribed by the object via the OutputInterface. More...
 
ExecFlagType _output_exec_flag
 The current output execution flag. More...
 
bool _force_output
 Flag indicating that next call to outputStep is forced. More...
 
bool _last_message_ended_in_newline
 Whether or not the last thing output by mooseConsole had a newline as the last character. More...
 
const std::ostringstream * _last_buffer
 What the last buffer was that was printed. More...
 
std::atomic< unsigned long long int_num_printed
 Number of times the stream has been printed to. More...
 

Friends

class FEProblemBase
 
class MaterialOutputAction
 
class OutputInterface
 
class PetscOutputInterface
 
class MooseApp
 

Detailed Description

Class for storing and utilizing output objects.

Definition at line 26 of file OutputWarehouse.h.

Constructor & Destructor Documentation

◆ OutputWarehouse()

OutputWarehouse::OutputWarehouse ( MooseApp app)

Class constructor.

Definition at line 25 of file OutputWarehouse.C.

26  : PerfGraphInterface(app, "OutputWarehouse"),
27  _app(app),
29  _common_params_ptr(NULL),
31  _force_output(false),
33  _last_buffer(NULL),
34  _num_printed(0)
35 {
36  // Set the reserved names
37  _reserved.insert("none"); // allows 'none' to be used as a keyword in 'outputs' parameter
38  _reserved.insert("all"); // allows 'all' to be used as a keyword in 'outputs' parameter
39 }
const InputParameters * _common_params_ptr
Pointer to the common InputParameters (.
bool _buffer_action_console_outputs
True to buffer console outputs in actions.
const ExecFlagType EXEC_CUSTOM
Definition: Moose.C:41
std::set< std::string > _reserved
List of reserved names.
const std::ostringstream * _last_buffer
What the last buffer was that was printed.
ExecFlagType _output_exec_flag
The current output execution flag.
MooseApp & _app
MooseApp.
bool _force_output
Flag indicating that next call to outputStep is forced.
std::atomic< unsigned long long int > _num_printed
Number of times the stream has been printed to.
PerfGraphInterface(const MooseObject *moose_object)
For objects that are MooseObjects with a default prefix of type()
bool _last_message_ended_in_newline
Whether or not the last thing output by mooseConsole had a newline as the last character.

◆ ~OutputWarehouse()

OutputWarehouse::~OutputWarehouse ( )
virtual

Definition at line 41 of file OutputWarehouse.C.

42 {
43  // If the output buffer is not empty, it needs to be written
44  if (_console_buffer.str().length())
45  mooseConsole();
46 }
std::ostringstream _console_buffer
The stream for holding messages passed to _console prior to Output object construction.
void mooseConsole()
Send current output buffer to Console output objects.

Member Function Documentation

◆ addInterfaceHideVariables()

void OutputWarehouse::addInterfaceHideVariables ( const std::string &  output_name,
const std::set< std::string > &  variable_names 
)
private

Insert variable names for hiding via the OutoutInterface.

Parameters
output_nameThe name of the output object on which the variable is to be hidden
variable_namesThe names of the variables to be hidden

This is a private method used by the OutputInterface system, it is not intended for any other purpose.

Definition at line 300 of file OutputWarehouse.C.

Referenced by MaterialOutputAction::act(), and OutputInterface::buildOutputHideVariableList().

302 {
303  _interface_map[output_name].insert(variable_names.begin(), variable_names.end());
304 }
std::map< std::string, std::set< std::string > > _interface_map
Storage for variables to hide as prescribed by the object via the OutputInterface.

◆ addOutput()

void OutputWarehouse::addOutput ( std::shared_ptr< Output output)

Adds an existing output object to the warehouse.

Parameters
outputPointer to the output object It is the responsibility of the OutputWarehouse to delete the output objects add using this method

Definition at line 102 of file OutputWarehouse.C.

Referenced by FEProblemBase::addOutput(), and AutomaticMortarGeneration::initOutput().

103 {
104  _all_ptrs.push_back(output);
105 
106  // Add the object to the warehouse storage, Checkpoint placed at end so they are called last
107  Checkpoint * cp = dynamic_cast<Checkpoint *>(output.get());
108  if (cp != NULL)
109  _all_objects.push_back(output.get());
110  else
111  _all_objects.insert(_all_objects.begin(), output.get());
112 
113  // Store the name and pointer
114  _object_map[output->name()] = output.get();
115  _object_names.insert(output->name());
116 
117  // Insert object sync times to the global set
118  const std::set<Real> & sync_times = output->getSyncTimes();
119  _sync_times.insert(sync_times.begin(), sync_times.end());
120 }
std::map< OutputName, Output * > _object_map
A map of the output pointers.
std::set< OutputName > _object_names
A set of output names.
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
Writes out three things:
Definition: Checkpoint.h:58
std::vector< std::shared_ptr< Output > > _all_ptrs
We are using std::shared_ptr to handle the cleanup of the pointers at the end of execution.
std::set< Real > _sync_times
Sync times for all objects.

◆ addOutputFilename()

void OutputWarehouse::addOutputFilename ( const OutputName &  obj_name,
const OutFileBase &  filename 
)
private

Adds the file name to the map of filenames being output with an associated object The main function of this object is to test that the same output file does not already exist in another object to protect against output files overwriting each other.

Parameters
obj_nameName of an FileOutput object
filenameName of an output file (extracted from filename() method of the objects)

Definition at line 141 of file OutputWarehouse.C.

Referenced by resetFileBase().

142 {
143  _file_base_map[obj_name].insert(filename);
144  for (const auto & it : _file_base_map)
145  if (it.first != obj_name && it.second.find(filename) != it.second.end())
146  mooseError("An output file with the name, ", filename, ", already exists.");
147 }
std::map< OutputName, std::set< OutFileBase > > _file_base_map
List of object names.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284

◆ allowOutput() [1/2]

void OutputWarehouse::allowOutput ( bool  state)
private

Ability to enable/disable output calls This is private, users should utilize FEProblemBase::allowOutput()

See also
FEProblemBase::allowOutput()

Definition at line 343 of file OutputWarehouse.C.

Referenced by FEProblemBase::allowOutput().

344 {
345  for (const auto & obj : _all_objects)
346  obj->allowOutput(state);
347 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ allowOutput() [2/2]

template<typename T >
void OutputWarehouse::allowOutput ( bool  state)
private

Definition at line 475 of file OutputWarehouse.h.

476 {
477  std::vector<T *> outputs = getOutputs<T>();
478  for (typename std::vector<T *>::iterator it = outputs.begin(); it != outputs.end(); ++it)
479  (*it)->allowOutput(state);
480 }

◆ bufferConsoleOutputsBeforeConstruction()

void OutputWarehouse::bufferConsoleOutputsBeforeConstruction ( bool  buffer)
inline

Set if the outputs to Console before its construction are to be buffered or to screen directly.

Parameters
bufferTure to buffer

Definition at line 192 of file OutputWarehouse.h.

193  {
195  }
bool _buffer_action_console_outputs
True to buffer console outputs in actions.

◆ buildInterfaceHideVariables()

void OutputWarehouse::buildInterfaceHideVariables ( const std::string &  output_name,
std::set< std::string > &  hide 
)

Return the list of hidden variables for the given output name.

Parameters
output_nameThe name of the output object for which the variables should be returned
hideThe set of variables to hide which is built by this method

Objects inheriting from the OutputInterface have the ability to control the output of variables associated with the objects (i.e., Marker elemental variable). This method returns a list of variables that should be hidden for the supplied object name due to the 'outputs' parameter being set by the object(s).

This method is used by Output::initOutputList to populate the correct hide lists for the output object, it is not intended for general use.

Definition at line 307 of file OutputWarehouse.C.

Referenced by AdvancedOutput::initOutputList().

309 {
310  std::map<std::string, std::set<std::string>>::const_iterator it =
311  _interface_map.find(output_name);
312  if (it != _interface_map.end())
313  hide = it->second;
314 }
std::map< std::string, std::set< std::string > > _interface_map
Storage for variables to hide as prescribed by the object via the OutputInterface.

◆ checkOutputs()

void OutputWarehouse::checkOutputs ( const std::set< OutputName > &  names)

Test that the output names exist.

Parameters
namesA vector of names to check This method will produce an error if any of the supplied names do not exist in the warehouse. Reserved names are not considered.

Definition at line 317 of file OutputWarehouse.C.

Referenced by CheckOutputAction::checkMaterialOutput(), CheckOutputAction::checkVariableOutput(), and AdvancedOutput::initPostprocessorOrVectorPostprocessorLists().

318 {
319  for (const auto & name : names)
320  if (!isReservedName(name) && !hasOutput(name))
321  mooseError("The output object '", name, "' is not a defined output object");
322 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
bool isReservedName(const std::string &name)
Test if the given name is reserved.
bool hasOutput(const std::string &name) const
Returns true if the output object exists.

◆ consoleBuffer()

std::ostringstream& OutputWarehouse::consoleBuffer ( )
inline

The buffered messages stream for Console objects.

Returns
Reference to the stream storing cached messages from calls to _console

Definition at line 186 of file OutputWarehouse.h.

186 { return _console_buffer; }
std::ostringstream _console_buffer
The stream for holding messages passed to _console prior to Output object construction.

◆ customSetup()

void OutputWarehouse::customSetup ( const ExecFlagType exec_type)
private

Calls the setup function for each of the output objects.

See also
FEProblemBase::customSetup(const ExecFlagType & exec_type)

Definition at line 67 of file OutputWarehouse.C.

Referenced by FEProblemBase::customSetup().

68 {
69  for (const auto & obj : _all_objects)
70  obj->customSetup(exec_type);
71 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ flushConsoleBuffer()

void OutputWarehouse::flushConsoleBuffer ( )
private

If content exists in the buffer, write it.

This is used by Console to make sure PETSc related output does not dump before buffered content. It is private because people shouldn't be messing with it.

Definition at line 240 of file OutputWarehouse.C.

Referenced by outputStep().

241 {
242  if (!_console_buffer.str().empty())
243  mooseConsole();
244 }
std::ostringstream _console_buffer
The stream for holding messages passed to _console prior to Output object construction.
void mooseConsole()
Send current output buffer to Console output objects.

◆ forceOutput()

void OutputWarehouse::forceOutput ( )
private

Indicates that the next call to outputStep should be forced This is private, users should utilize FEProblemBase::forceOutput()

See also
FEProblemBase::forceOutput()

Definition at line 350 of file OutputWarehouse.C.

Referenced by FEProblemBase::forceOutput().

351 {
352  _force_output = true;
353 }
bool _force_output
Flag indicating that next call to outputStep is forced.

◆ getCommonParameters()

const InputParameters * OutputWarehouse::getCommonParameters ( ) const

Get a reference to the common output parameters.

Returns
Pointer to the common InputParameters object

Definition at line 288 of file OutputWarehouse.C.

Referenced by FEProblemBase::addOutput().

289 {
290  return _common_params_ptr;
291 }
const InputParameters * _common_params_ptr
Pointer to the common InputParameters (.

◆ getFileNumbers()

std::map< std::string, unsigned int > OutputWarehouse::getFileNumbers ( )

Extracts the file numbers from the output objects.

Returns
Map of file numbers for the output objects

Definition at line 268 of file OutputWarehouse.C.

Referenced by MultiApp::createApp().

269 {
270 
271  std::map<std::string, unsigned int> output;
272  for (const auto & obj : _all_objects)
273  {
274  FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
275  if (ptr != NULL)
276  output[ptr->name()] = ptr->getFileNumber();
277  }
278  return output;
279 }
unsigned int getFileNumber()
Return the current file number for this outputter.
Definition: FileOutput.C:176
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
An outputter with filename support.
Definition: FileOutput.h:20

◆ getOutput()

template<typename T >
T * OutputWarehouse::getOutput ( const OutputName &  name)

Return an Output object by name.

Template Parameters
TThe Out put object type to return
Parameters
nameThe name of the output object
Returns
A pointer to the output object

Definition at line 399 of file OutputWarehouse.h.

400 {
401  // Check that the object exists
402  if (!hasOutput(name))
403  mooseError("An output object with the name '", name, "' does not exist.");
404 
405  // Attempt to cast the object to the correct type
406  T * output = dynamic_cast<T *>(_object_map[name]);
407 
408  // Error if the cast fails
409  if (output == NULL)
410  mooseError("An output object with the name '", name, "' for the specified type does not exist");
411 
412  // Return the object
413  return output;
414 }
std::string name(const ElemQuality q)
std::map< OutputName, Output * > _object_map
A map of the output pointers.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
bool hasOutput(const std::string &name) const
Returns true if the output object exists.

◆ getOutputNames() [1/2]

const std::set< OutputName > & OutputWarehouse::getOutputNames ( )

Get a complete set of all output object names.

Returns
A set of output names for each output object

Note, if this method is called prior to the creation of outputs in AddOutputAction it will create the proxy list of names from the action system. The main use is for the OutputInterface, specifically, when used with Postprocessors in the UserObjects block of the input file. UserObjects are created prior to Outputs objects, but OutputInterface needs the list of output names to operate correctly.

Definition at line 129 of file OutputWarehouse.C.

Referenced by OutputInterface::buildOutputHideVariableList().

130 {
131  if (_object_names.empty() && _app.actionWarehouse().hasActions("add_output"))
132  {
133  const auto & actions = _app.actionWarehouse().getActionListByName("add_output");
134  for (const auto & act : actions)
135  _object_names.insert(act->name());
136  }
137  return _object_names;
138 }
std::set< OutputName > _object_names
A set of output names.
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
MooseApp & _app
MooseApp.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition: MooseApp.h:195
bool hasActions(const std::string &task) const
Check if Actions associated with passed in task exist.

◆ getOutputNames() [2/2]

template<typename T >
std::vector< OutputName > OutputWarehouse::getOutputNames ( )

Return a list of output objects with a given type.

Template Parameters
TThe output object type
Returns
A vector of names

Definition at line 454 of file OutputWarehouse.h.

455 {
456  // The output vector
457  std::vector<OutputName> names;
458 
459  // Loop through the objects and store the name if the type cast succeeds
460  for (std::map<OutputName, Output *>::const_iterator it = _object_map.begin();
461  it != _object_map.end();
462  ++it)
463  {
464  T * output = dynamic_cast<T *>(it->second);
465  if (output != NULL)
466  names.push_back(it->first);
467  }
468 
469  // Return the names
470  return names;
471 }
std::map< OutputName, Output * > _object_map
A map of the output pointers.

◆ getOutputs() [1/2]

template<typename T >
std::vector< T * > OutputWarehouse::getOutputs ( const std::vector< OutputName > &  names)

Return a vector of objects by names.

Template Parameters
TThe Output object type to return
Parameters
namesA vector of names of the output object
Returns
A pointer to the output object

Definition at line 418 of file OutputWarehouse.h.

Referenced by AutoCheckpointAction::act(), CheckOutputAction::checkConsoleOutput(), CheckOutputAction::checkPerfLogOutput(), and ConsoleUtils::outputOutputInformation().

419 {
420  // The vector to output
421  std::vector<T *> outputs;
422 
423  // Populate the vector
424  for (std::vector<OutputName>::const_iterator it = names.begin(); it != names.end(); ++it)
425  outputs.push_back(getOutput<T>(*it));
426 
427  // Return the objects
428  return outputs;
429 }

◆ getOutputs() [2/2]

template<typename T >
std::vector< T * > OutputWarehouse::getOutputs ( ) const

Return a vector of objects of a given type.

Template Parameters
TThe Output object type to return
Returns
A pointer to the output object

Definition at line 433 of file OutputWarehouse.h.

434 {
435  // The vector to output
436  std::vector<T *> outputs;
437 
438  // Populate the vector
439  for (std::map<OutputName, Output *>::const_iterator it = _object_map.begin();
440  it != _object_map.end();
441  ++it)
442  {
443  T * output = dynamic_cast<T *>(it->second);
444  if (output != NULL)
445  outputs.push_back(output);
446  }
447 
448  // Return the objects
449  return outputs;
450 }
std::map< OutputName, Output * > _object_map
A map of the output pointers.

◆ getReservedNames()

const std::set< std::string > & OutputWarehouse::getReservedNames ( ) const

Return a set of reserved output names.

Returns
A std::set of reserved names

Definition at line 325 of file OutputWarehouse.C.

326 {
327  return _reserved;
328 }
std::set< std::string > _reserved
List of reserved names.

◆ getSyncTimes()

std::set< Real > & OutputWarehouse::getSyncTimes ( )

Return the sync times for all objects.

Definition at line 294 of file OutputWarehouse.C.

Referenced by TimePeriod::initialSetup().

295 {
296  return _sync_times;
297 }
std::set< Real > _sync_times
Sync times for all objects.

◆ hasOutput()

bool OutputWarehouse::hasOutput ( const std::string &  name) const

Returns true if the output object exists.

Parameters
nameThe name of the output object for which to test for existence within the warehouse

Definition at line 123 of file OutputWarehouse.C.

Referenced by FEProblemBase::addOutput(), checkOutputs(), and getOutput().

124 {
125  return _object_map.find(name) != _object_map.end();
126 }
std::map< OutputName, Output * > _object_map
A map of the output pointers.

◆ initialSetup()

void OutputWarehouse::initialSetup ( )
private

Calls the initialSetup function for each of the output objects.

See also
FEProblemBase::initialSetup()

Definition at line 49 of file OutputWarehouse.C.

Referenced by FEProblemBase::initialSetup().

50 {
51  TIME_SECTION("initialSetup", 5, "Setting Up Outputs");
52 
53  resetFileBase();
54 
55  for (const auto & obj : _all_objects)
56  obj->initialSetup();
57 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
void resetFileBase()
Resets the file base for all FileOutput objects.

◆ isReservedName()

bool OutputWarehouse::isReservedName ( const std::string &  name)

Test if the given name is reserved.

Parameters
nameThe name to test
Returns
True if the name is reserved

Definition at line 331 of file OutputWarehouse.C.

Referenced by FEProblemBase::addOutput(), and checkOutputs().

332 {
333  return _reserved.find(name) != _reserved.end();
334 }
std::set< std::string > _reserved
List of reserved names.

◆ jacobianSetup()

void OutputWarehouse::jacobianSetup ( )
private

Calls the jacobianSetup function for each of the output objects.

See also
FEProblemBase::computeJacobian

Definition at line 81 of file OutputWarehouse.C.

Referenced by FEProblemBase::computeJacobianTags().

82 {
83  for (const auto & obj : _all_objects)
84  obj->jacobianSetup();
85 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ meshChanged()

void OutputWarehouse::meshChanged ( )

Calls the meshChanged method for every output object.

Definition at line 176 of file OutputWarehouse.C.

Referenced by MooseApp::setOutputPosition().

177 {
178  for (const auto & obj : _all_objects)
179  obj->meshChanged();
180 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ mooseConsole() [1/2]

void OutputWarehouse::mooseConsole ( )

Send current output buffer to Console output objects.

Definition at line 185 of file OutputWarehouse.C.

Referenced by MooseBase::callMooseError(), flushConsoleBuffer(), FEProblemBase::initialSetup(), ConsoleStream::operator<<(), and ~OutputWarehouse().

186 {
188 }
std::ostringstream _console_buffer
The stream for holding messages passed to _console prior to Output object construction.
void mooseConsole()
Send current output buffer to Console output objects.

◆ mooseConsole() [2/2]

void OutputWarehouse::mooseConsole ( std::ostringstream &  buffer)

Send a buffer to Console output objects.

Definition at line 191 of file OutputWarehouse.C.

192 {
193  std::lock_guard<std::mutex> lock(moose_console_mutex);
194 
195  std::string message = buffer.str();
196 
197  // If someone else is writing - then we may need a newline
198  if (&buffer != _last_buffer && !_last_message_ended_in_newline)
199  message = '\n' + message;
200 
201  // Loop through all Console Output objects and pass the current output buffer
202  std::vector<Console *> objects = getOutputs<Console>();
203  if (!objects.empty())
204  {
205  for (const auto & obj : objects)
206  obj->mooseConsole(message);
207 
208  // Reset
209  buffer.clear();
210  buffer.str("");
211  }
212  else if (!_app.actionWarehouse().isTaskComplete("add_output"))
213  {
215  {
216  // this will cause messages to console before its construction immediately flushed and
217  // cleared.
218  bool this_message_ends_in_newline = message.empty() ? true : message.back() == '\n';
219 
220  // If that last message ended in newline then this one may need
221  // to start with indenting
222  // Note that we only indent the first line if the last message ended in new line
223  if (_app.multiAppLevel() > 0)
225 
226  Moose::out << message << std::flush;
227  buffer.clear();
228  buffer.str("");
229 
230  _last_message_ended_in_newline = this_message_ends_in_newline;
231  }
232  }
233 
234  _last_buffer = &buffer;
235 
236  _num_printed++;
237 }
bool _buffer_action_console_outputs
True to buffer console outputs in actions.
bool isTaskComplete(const std::string &task) const
unsigned int multiAppLevel() const
The MultiApp Level.
Definition: MooseApp.h:794
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
const std::ostringstream * _last_buffer
What the last buffer was that was printed.
MooseApp & _app
MooseApp.
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN, bool dont_indent_first_line=true, const std::string &post_prefix=": ")
Indents the supplied message given the prefix and color.
Definition: MooseUtils.C:724
static std::mutex moose_console_mutex
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition: MooseApp.h:195
std::atomic< unsigned long long int > _num_printed
Number of times the stream has been printed to.
bool _last_message_ended_in_newline
Whether or not the last thing output by mooseConsole had a newline as the last character.

◆ numPrinted()

unsigned long long int OutputWarehouse::numPrinted ( ) const
inline

The number of times something has been printed.

Definition at line 212 of file OutputWarehouse.h.

Referenced by ConsoleStream::numPrinted().

212 { return _num_printed; }
std::atomic< unsigned long long int > _num_printed
Number of times the stream has been printed to.

◆ outputStep()

void OutputWarehouse::outputStep ( ExecFlagType  type)
private

Calls the outputStep method for each output object.

Parameters
typeThe type execution flag (see Moose.h)

This is private, users should utilize FEProblemBase::outputStep()

This is one of three locations where we explicitly flush the output buffers during a simulation: PetscOutput::petscNonlinearOutput() PetscOutput::petscLinearOutput() OutputWarehouse::outputStep()

All other Console output should be using newlines to avoid covering buffer errors and to avoid excessive I/O

Definition at line 150 of file OutputWarehouse.C.

Referenced by FEProblemBase::outputStep().

151 {
152  if (_force_output)
153  type = EXEC_FORCED;
154 
155  for (const auto & obj : _all_objects)
156  if (obj->enabled())
157  obj->outputStep(type);
158 
170 
171  // Reset force output flag
172  _force_output = false;
173 }
const ExecFlagType EXEC_FORCED
Definition: Moose.C:39
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
bool _force_output
Flag indicating that next call to outputStep is forced.
void flushConsoleBuffer()
If content exists in the buffer, write it.

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 78 of file PerfGraphInterface.C.

Referenced by CommonOutputAction::act(), PerfGraphData::finalize(), and PerfGraphOutput::output().

79 {
80  return _pg_moose_app.perfGraph();
81 }
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition: MooseApp.h:133

◆ registerTimedSection() [1/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
Returns
The ID of the section - use when starting timing

Definition at line 53 of file PerfGraphInterface.C.

55 {
56  const auto timed_section_name = timedSectionName(section_name);
57  if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
58  return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
59  else
60  return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
61 }
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID The name of the section.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ registerTimedSection() [2/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level,
const std::string &  live_message,
const bool  print_dots = true 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
live_messageThe message to be printed to the screen during execution
print_dotsWhether or not progress dots should be printed for this section
Returns
The ID of the section - use when starting timing

Definition at line 64 of file PerfGraphInterface.C.

68 {
69  const auto timed_section_name = timedSectionName(section_name);
70  if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
72  timedSectionName(section_name), level, live_message, print_dots);
73  else
74  return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
75 }
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID The name of the section.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ reset()

void OutputWarehouse::reset ( )

Reset the output system.

Definition at line 356 of file OutputWarehouse.C.

357 {
358  for (const auto & pair : _object_map)
359  {
360  auto * table = dynamic_cast<TableOutput *>(pair.second);
361  if (table != NULL)
362  table->clear();
363  auto * exodus = dynamic_cast<Exodus *>(pair.second);
364  if (exodus != NULL)
365  exodus->clear();
366  }
367 }
std::map< OutputName, Output * > _object_map
A map of the output pointers.
void clear()
Reset Exodus output.
Definition: Exodus.C:524
Class for output data to the ExodusII format.
Definition: Exodus.h:24
void clear()
Definition: TableOutput.C:247
Base class for scalar variables and postprocessors output objects.
Definition: TableOutput.h:28

◆ resetFileBase()

void OutputWarehouse::resetFileBase ( )
private

Resets the file base for all FileOutput objects.

Definition at line 370 of file OutputWarehouse.C.

Referenced by initialSetup(), and MooseApp::setOutputFileBase().

371 {
372  // Set the file base from the application to FileOutputs and add associated filenames
373  for (const auto & obj : _all_objects)
374  {
375  FileOutput * file_output = dynamic_cast<FileOutput *>(obj);
376  if (file_output)
377  {
378  const std::string file_base = obj->parameters().get<bool>("_built_by_moose")
380  : (_app.getOutputFileBase(true) + "_" + obj->name());
381  file_output->setFileBase(file_base);
382 
383  addOutputFilename(obj->name(), file_output->filename());
384  }
385  }
386 }
virtual std::string filename()
The filename for the output file.
Definition: FileOutput.C:112
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 getOutputFileBase(bool for_non_moose_build_output=false) const
Get the output file base name.
Definition: MooseApp.C:1066
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
MooseApp & _app
MooseApp.
void setFileBase(const std::string &file_base)
Sets the file base string if the &#39;file_base&#39; parameter is not set.
Definition: FileOutput.C:118
void addOutputFilename(const OutputName &obj_name, const OutFileBase &filename)
Adds the file name to the map of filenames being output with an associated object The main function o...
const InputParameters & parameters() const
Get the parameters of the object.
An outputter with filename support.
Definition: FileOutput.h:20

◆ residualSetup()

void OutputWarehouse::residualSetup ( )
private

Calls the residualSetup function for each of the output objects.

See also
FEProblemBase::computeResidualTyp

Definition at line 88 of file OutputWarehouse.C.

Referenced by FEProblemBase::computeResidualAndJacobian(), and FEProblemBase::computeResidualTags().

89 {
90  for (const auto & obj : _all_objects)
91  obj->residualSetup();
92 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ setCommonParameters()

void OutputWarehouse::setCommonParameters ( const InputParameters params_ptr)

Stores the common InputParameters object.

Parameters
params_ptrA pointer to the common parameters object to be stored
See also
CommonOutputAction

Definition at line 282 of file OutputWarehouse.C.

Referenced by CommonOutputAction::act().

283 {
284  _common_params_ptr = params_ptr;
285 }
const InputParameters * _common_params_ptr
Pointer to the common InputParameters (.

◆ setFileNumbers()

void OutputWarehouse::setFileNumbers ( std::map< std::string, unsigned int input,
unsigned int  offset = 0 
)

Calls the setFileNumber method for every FileOutput output object.

Definition at line 247 of file OutputWarehouse.C.

248 {
249  for (const auto & obj : _all_objects)
250  {
251  FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
252  if (ptr != NULL)
253  {
254  std::map<std::string, unsigned int>::const_iterator it = input.find(ptr->name());
255  if (it != input.end())
256  {
257  int value = it->second + offset;
258  if (value < 0)
259  ptr->setFileNumber(0);
260  else
261  ptr->setFileNumber(it->second + offset);
262  }
263  }
264  }
265 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
void setFileNumber(unsigned int num)
Sets the file number manually.
Definition: FileOutput.C:170
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
An outputter with filename support.
Definition: FileOutput.h:20

◆ setOutputExecutionType()

void OutputWarehouse::setOutputExecutionType ( ExecFlagType  type)
private

Sets the execution flag type.

This is a private method used by FEProblemBase, it is not intended for any other purpose

Definition at line 337 of file OutputWarehouse.C.

338 {
339  _output_exec_flag = type;
340 }
ExecFlagType _output_exec_flag
The current output execution flag.

◆ solveSetup()

void OutputWarehouse::solveSetup ( )

Calls the timestepSetup function for each of the output objects.

See also
FEProblemBase::solve() timestepSetup is too early for solver setup where we try to hook up monitor, change prefix, etc. SLEPc solver does not exist yet when we call timestepSetup. Moved this method from the private region to the public region so we can call this function from EigenProblem with no need to make EigenProblem as friend of OutputWarehouse.

Definition at line 74 of file OutputWarehouse.C.

Referenced by EigenProblem::initPetscOutputAndSomeSolverSettings(), and FEProblemBase::initPetscOutputAndSomeSolverSettings().

75 {
76  for (const auto & obj : _all_objects)
77  obj->solveSetup();
78 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ subdomainSetup()

void OutputWarehouse::subdomainSetup ( )
private

Calls the subdomainSetup function for each of the output objects.

See also
FEProblemBase::setupSubdomain

Definition at line 95 of file OutputWarehouse.C.

Referenced by FEProblemBase::subdomainSetup().

96 {
97  for (const auto & obj : _all_objects)
98  obj->subdomainSetup();
99 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ timedSectionName()

std::string PerfGraphInterface::timedSectionName ( const std::string &  section_name) const
protectedinherited
Returns
The name of the timed section with the name section_name.

Optionally adds a prefix if one is defined.

Definition at line 47 of file PerfGraphInterface.C.

Referenced by PerfGraphInterface::registerTimedSection().

48 {
49  return _prefix.empty() ? "" : (_prefix + "::") + section_name;
50 }
const std::string _prefix
A prefix to use for all sections.

◆ timestepSetup()

void OutputWarehouse::timestepSetup ( )
private

Calls the timestepSetup function for each of the output objects.

See also
FEProblemBase::timestepSetup()

Definition at line 60 of file OutputWarehouse.C.

Referenced by FEProblemBase::timestepSetup().

61 {
62  for (const auto & obj : _all_objects)
63  obj->timestepSetup();
64 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

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

Friends And Related Function Documentation

◆ FEProblemBase

friend class FEProblemBase
friend

Definition at line 382 of file OutputWarehouse.h.

◆ MaterialOutputAction

friend class MaterialOutputAction
friend

Definition at line 385 of file OutputWarehouse.h.

◆ MooseApp

friend class MooseApp
friend

Definition at line 394 of file OutputWarehouse.h.

◆ OutputInterface

friend class OutputInterface
friend

Definition at line 388 of file OutputWarehouse.h.

◆ PetscOutputInterface

friend class PetscOutputInterface
friend

Definition at line 391 of file OutputWarehouse.h.

Member Data Documentation

◆ _all_material_output_variables

std::set<AuxVariableName> OutputWarehouse::_all_material_output_variables
private

List of all variable created by auto material output.

Definition at line 354 of file OutputWarehouse.h.

◆ _all_objects

std::vector<Output *> OutputWarehouse::_all_objects
private

◆ _all_ptrs

std::vector<std::shared_ptr<Output> > OutputWarehouse::_all_ptrs
private

We are using std::shared_ptr to handle the cleanup of the pointers at the end of execution.

This is necessary since several warehouses might be sharing a single instance of a MooseObject.

Definition at line 245 of file OutputWarehouse.h.

Referenced by addOutput().

◆ _app

MooseApp& OutputWarehouse::_app
private

MooseApp.

Definition at line 324 of file OutputWarehouse.h.

Referenced by getOutputNames(), mooseConsole(), and resetFileBase().

◆ _buffer_action_console_outputs

bool OutputWarehouse::_buffer_action_console_outputs
private

True to buffer console outputs in actions.

Definition at line 330 of file OutputWarehouse.h.

Referenced by bufferConsoleOutputsBeforeConstruction(), and mooseConsole().

◆ _common_params_ptr

const InputParameters* OutputWarehouse::_common_params_ptr
private

Pointer to the common InputParameters (.

See also
CommonOutputAction)

Definition at line 342 of file OutputWarehouse.h.

Referenced by getCommonParameters(), and setCommonParameters().

◆ _console_buffer

std::ostringstream OutputWarehouse::_console_buffer
private

The stream for holding messages passed to _console prior to Output object construction.

Definition at line 360 of file OutputWarehouse.h.

Referenced by consoleBuffer(), flushConsoleBuffer(), mooseConsole(), and ~OutputWarehouse().

◆ _file_base_map

std::map<OutputName, std::set<OutFileBase> > OutputWarehouse::_file_base_map
private

List of object names.

Definition at line 339 of file OutputWarehouse.h.

Referenced by addOutputFilename().

◆ _force_output

bool OutputWarehouse::_force_output
private

Flag indicating that next call to outputStep is forced.

Definition at line 369 of file OutputWarehouse.h.

Referenced by forceOutput(), and outputStep().

◆ _input_file_name

std::string OutputWarehouse::_input_file_name
private

Input file name for this output object.

Definition at line 348 of file OutputWarehouse.h.

◆ _interface_map

std::map<std::string, std::set<std::string> > OutputWarehouse::_interface_map
private

Storage for variables to hide as prescribed by the object via the OutputInterface.

Definition at line 363 of file OutputWarehouse.h.

Referenced by addInterfaceHideVariables(), and buildInterfaceHideVariables().

◆ _last_buffer

const std::ostringstream* OutputWarehouse::_last_buffer
private

What the last buffer was that was printed.

Definition at line 375 of file OutputWarehouse.h.

Referenced by mooseConsole().

◆ _last_message_ended_in_newline

bool OutputWarehouse::_last_message_ended_in_newline
private

Whether or not the last thing output by mooseConsole had a newline as the last character.

Definition at line 372 of file OutputWarehouse.h.

Referenced by mooseConsole().

◆ _material_output_map

std::map<OutputName, std::set<AuxVariableName> > OutputWarehouse::_material_output_map
private

Map of output name and AuxVariable names to be output (used by auto Material output)

Definition at line 351 of file OutputWarehouse.h.

◆ _num_printed

std::atomic<unsigned long long int> OutputWarehouse::_num_printed
private

Number of times the stream has been printed to.

Definition at line 378 of file OutputWarehouse.h.

Referenced by mooseConsole(), and numPrinted().

◆ _object_map

std::map<OutputName, Output *> OutputWarehouse::_object_map
private

A map of the output pointers.

Definition at line 333 of file OutputWarehouse.h.

Referenced by addOutput(), getOutput(), getOutputNames(), getOutputs(), hasOutput(), and reset().

◆ _object_names

std::set<OutputName> OutputWarehouse::_object_names
private

A set of output names.

Definition at line 336 of file OutputWarehouse.h.

Referenced by addOutput(), and getOutputNames().

◆ _output_exec_flag

ExecFlagType OutputWarehouse::_output_exec_flag
private

The current output execution flag.

Definition at line 366 of file OutputWarehouse.h.

Referenced by setOutputExecutionType().

◆ _pg_moose_app

MooseApp& PerfGraphInterface::_pg_moose_app
protectedinherited

The MooseApp that owns the PerfGraph.

Definition at line 124 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::perfGraph().

◆ _prefix

const std::string PerfGraphInterface::_prefix
protectedinherited

A prefix to use for all sections.

Definition at line 127 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ _reserved

std::set<std::string> OutputWarehouse::_reserved
private

List of reserved names.

Definition at line 357 of file OutputWarehouse.h.

Referenced by getReservedNames(), isReservedName(), and OutputWarehouse().

◆ _sync_times

std::set<Real> OutputWarehouse::_sync_times
private

Sync times for all objects.

Definition at line 345 of file OutputWarehouse.h.

Referenced by addOutput(), and getSyncTimes().


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