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

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

#include <OutputWarehouse.h>

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 int > getFileNumbers ()
 Extracts the file numbers from the output objects. More...
 
void setCommonParameters (InputParameters *params_ptr)
 Stores the common InputParameters object. More...
 
InputParametersgetCommonParameters ()
 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...
 
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 setLoggingRequested ()
 Sets a Boolean indicating that at least one object is requesting performance logging in this application. More...
 
bool getLoggingRequested () const
 Returns a Boolean indicating whether performance logging is requested in this application. More...
 
void reset ()
 Reset the output system. 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 OutFileBase &filename)
 Adds the file name to the list of filenames being output The main function of this object is to test that the same output file does not already exist 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 solveSetup ()
 Calls the timestepSetup 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 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::set< OutFileBase > _file_base_set
 List of object names. More...
 
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 _logging_requested
 Indicates that performance logging has been requested by the console or some object (PerformanceData) More...
 

Friends

class FEProblemBase
 
class MaterialOutputAction
 
class OutputInterface
 
class PetscOutput
 

Detailed Description

Class for storing and utilizing output objects.

Definition at line 23 of file OutputWarehouse.h.

Constructor & Destructor Documentation

◆ OutputWarehouse()

OutputWarehouse::OutputWarehouse ( MooseApp app)

Class constructor.

Definition at line 25 of file OutputWarehouse.C.

26  : _app(app),
29  _force_output(false),
30  _logging_requested(false)
31 {
32  // Set the reserved names
33  _reserved.insert("none"); // allows 'none' to be used as a keyword in 'outputs' parameter
34  _reserved.insert("all"); // allows 'all' to be used as a keyword in 'outputs' parameter
35 }
bool _buffer_action_console_outputs
True to buffer console outputs in actions.
const ExecFlagType EXEC_CUSTOM
std::set< std::string > _reserved
List of reserved names.
ExecFlagType _output_exec_flag
The current output execution flag.
MooseApp & _app
MooseApp.
bool _force_output
Flag indicating that next call to outputStep is forced.
bool _logging_requested
Indicates that performance logging has been requested by the console or some object (PerformanceData)...

◆ ~OutputWarehouse()

OutputWarehouse::~OutputWarehouse ( )
virtual

Definition at line 37 of file OutputWarehouse.C.

38 {
39  // If the output buffer is not empty, it needs to be written
40  if (_console_buffer.str().length())
41  mooseConsole();
42 }
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 265 of file OutputWarehouse.C.

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

267 {
268  _interface_map[output_name].insert(variable_names.begin(), variable_names.end());
269 }
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 87 of file OutputWarehouse.C.

Referenced by FEProblemBase::addOutput().

88 {
89  _all_ptrs.push_back(output);
90 
91  // Add the object to the warehouse storage, Checkpoint placed at end so they are called last
92  Checkpoint * cp = dynamic_cast<Checkpoint *>(output.get());
93  if (cp != NULL)
94  _all_objects.push_back(output.get());
95  else
96  _all_objects.insert(_all_objects.begin(), output.get());
97 
98  // Store the name and pointer
99  _object_map[output->name()] = output.get();
100  _object_names.insert(output->name());
101 
102  // If the output object is a FileOutput then store the output filename
103  FileOutput * ptr = dynamic_cast<FileOutput *>(output.get());
104  if (ptr != NULL)
105  addOutputFilename(ptr->filename());
106 
107  // Insert object sync times to the global set
108  if (output->parameters().isParamValid("sync_times"))
109  {
110  std::vector<Real> sync_times = output->parameters().get<std::vector<Real>>("sync_times");
111  _sync_times.insert(sync_times.begin(), sync_times.end());
112  }
113 }
virtual std::string filename()
The filename for the output file.
Definition: FileOutput.C:172
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)
void addOutputFilename(const OutFileBase &filename)
Adds the file name to the list of filenames being output The main function of this object is to test ...
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.
An outputter with filename support.
Definition: FileOutput.h:27
std::set< Real > _sync_times
Sync times for all objects.

◆ addOutputFilename()

void OutputWarehouse::addOutputFilename ( const OutFileBase &  filename)
private

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

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

Definition at line 134 of file OutputWarehouse.C.

Referenced by addOutput().

135 {
136  if (_file_base_set.find(filename) != _file_base_set.end())
137  mooseError("An output file with the name, ", filename, ", already exists.");
138  _file_base_set.insert(filename);
139 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::set< OutFileBase > _file_base_set
List of object names.

◆ 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 308 of file OutputWarehouse.C.

Referenced by FEProblemBase::allowOutput().

309 {
310  for (const auto & obj : _all_objects)
311  obj->allowOutput(state);
312 }
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 443 of file OutputWarehouse.h.

444 {
445  std::vector<T *> outputs = getOutputs<T>();
446  for (typename std::vector<T *>::iterator it = outputs.begin(); it != outputs.end(); ++it)
447  (*it)->allowOutput(state);
448 }

◆ 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 184 of file OutputWarehouse.h.

185  {
187  }
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 272 of file OutputWarehouse.C.

Referenced by AdvancedOutput::initOutputList().

274 {
275  std::map<std::string, std::set<std::string>>::const_iterator it =
276  _interface_map.find(output_name);
277  if (it != _interface_map.end())
278  hide = it->second;
279 }
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 282 of file OutputWarehouse.C.

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

283 {
284  for (const auto & name : names)
285  if (!isReservedName(name) && !hasOutput(name))
286  mooseError("The output object '", name, "' is not a defined output object");
287 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
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 178 of file OutputWarehouse.h.

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

◆ 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 205 of file OutputWarehouse.C.

Referenced by outputStep(), PetscOutput::petscLinearOutput(), and PetscOutput::petscNonlinearOutput().

206 {
207  if (!_console_buffer.str().empty())
208  mooseConsole();
209 }
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 315 of file OutputWarehouse.C.

Referenced by FEProblemBase::forceOutput().

316 {
317  _force_output = true;
318 }
bool _force_output
Flag indicating that next call to outputStep is forced.

◆ getCommonParameters()

InputParameters * OutputWarehouse::getCommonParameters ( )

Get a reference to the common output parameters.

Returns
Pointer to the common InputParameters object

Definition at line 253 of file OutputWarehouse.C.

Referenced by FEProblemBase::addOutput().

254 {
255  return _common_params_ptr;
256 }
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 233 of file OutputWarehouse.C.

Referenced by MultiApp::createApp().

234 {
235 
236  std::map<std::string, unsigned int> output;
237  for (const auto & obj : _all_objects)
238  {
239  FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
240  if (ptr != NULL)
241  output[ptr->name()] = ptr->getFileNumber();
242  }
243  return output;
244 }
unsigned int getFileNumber()
Return the current file number for this outputter.
Definition: FileOutput.C:184
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:56
An outputter with filename support.
Definition: FileOutput.h:27

◆ getLoggingRequested()

bool OutputWarehouse::getLoggingRequested ( ) const
inline

Returns a Boolean indicating whether performance logging is requested in this application.

Definition at line 193 of file OutputWarehouse.h.

193 { return _logging_requested; }
bool _logging_requested
Indicates that performance logging has been requested by the console or some object (PerformanceData)...

◆ 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 367 of file OutputWarehouse.h.

368 {
369  // Check that the object exists
370  if (!hasOutput(name))
371  mooseError("An output object with the name '", name, "' does not exist.");
372 
373  // Attempt to cast the object to the correct type
374  T * output = dynamic_cast<T *>(_object_map[name]);
375 
376  // Error if the cast fails
377  if (output == NULL)
378  mooseError("An output object with the name '", name, "' for the specified type does not exist");
379 
380  // Return the object
381  return output;
382 }
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:208
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 122 of file OutputWarehouse.C.

Referenced by OutputInterface::buildOutputHideVariableList().

123 {
124  if (_object_names.empty() && _app.actionWarehouse().hasActions("add_output"))
125  {
126  const auto & actions = _app.actionWarehouse().getActionListByName("add_output");
127  for (const auto & act : actions)
128  _object_names.insert(act->name());
129  }
130  return _object_names;
131 }
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()
Definition: MooseApp.h:140
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 422 of file OutputWarehouse.h.

423 {
424  // The output vector
425  std::vector<OutputName> names;
426 
427  // Loop through the objects and store the name if the type cast succeeds
428  for (std::map<OutputName, Output *>::const_iterator it = _object_map.begin();
429  it != _object_map.end();
430  ++it)
431  {
432  T * output = dynamic_cast<T *>(it->second);
433  if (output != NULL)
434  names.push_back(it->first);
435  }
436 
437  // Return the names
438  return names;
439 }
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 386 of file OutputWarehouse.h.

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

387 {
388  // The vector to output
389  std::vector<T *> outputs;
390 
391  // Populate the vector
392  for (std::vector<OutputName>::const_iterator it = names.begin(); it != names.end(); ++it)
393  outputs.push_back(getOutput<T>(*it));
394 
395  // Return the objects
396  return outputs;
397 }

◆ 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 401 of file OutputWarehouse.h.

402 {
403  // The vector to output
404  std::vector<T *> outputs;
405 
406  // Populate the vector
407  for (std::map<OutputName, Output *>::const_iterator it = _object_map.begin();
408  it != _object_map.end();
409  ++it)
410  {
411  T * output = dynamic_cast<T *>(it->second);
412  if (output != NULL)
413  outputs.push_back(output);
414  }
415 
416  // Return the objects
417  return outputs;
418 }
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 290 of file OutputWarehouse.C.

291 {
292  return _reserved;
293 }
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 259 of file OutputWarehouse.C.

Referenced by TimePeriod::initialSetup().

260 {
261  return _sync_times;
262 }
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 116 of file OutputWarehouse.C.

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

117 {
118  return _object_map.find(name) != _object_map.end();
119 }
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 45 of file OutputWarehouse.C.

Referenced by FEProblemBase::initialSetup().

46 {
47  for (const auto & obj : _all_objects)
48  obj->initialSetup();
49 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ 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 296 of file OutputWarehouse.C.

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

297 {
298  return _reserved.find(name) != _reserved.end();
299 }
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 66 of file OutputWarehouse.C.

Referenced by FEProblemBase::computeJacobianTags().

67 {
68  for (const auto & obj : _all_objects)
69  obj->jacobianSetup();
70 }
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 168 of file OutputWarehouse.C.

Referenced by MooseApp::setOutputPosition().

169 {
170  for (const auto & obj : _all_objects)
171  obj->meshChanged();
172 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

◆ mooseConsole()

void OutputWarehouse::mooseConsole ( )

Send current output buffer to Console output objects.

Definition at line 175 of file OutputWarehouse.C.

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

176 {
177  // Loop through all Console Output objects and pass the current output buffer
178  std::vector<Console *> objects = getOutputs<Console>();
179  if (!objects.empty())
180  {
181  for (const auto & obj : objects)
182  obj->mooseConsole(_console_buffer.str());
183 
184  // Reset
185  _console_buffer.clear();
186  _console_buffer.str("");
187  }
188  else
189  {
191  {
192  // this will cause messages to console before its construction immediately flushed and
193  // cleared.
194  std::string message = _console_buffer.str();
195  if (_app.multiAppLevel() > 0)
196  MooseUtils::indentMessage(_app.name(), message);
197  Moose::out << message << std::flush;
198  _console_buffer.clear();
199  _console_buffer.str("");
200  }
201  }
202 }
const std::string & name() const
Get the name of the object.
Definition: MooseApp.h:73
bool _buffer_action_console_outputs
True to buffer console outputs in actions.
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN)
Indents the supplied message given the prefix and color.
Definition: MooseUtils.C:479
unsigned int multiAppLevel() const
The MultiApp Level.
Definition: MooseApp.h:511
MooseApp & _app
MooseApp.
std::ostringstream _console_buffer
The stream for holding messages passed to _console prior to Output object construction.

◆ 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 142 of file OutputWarehouse.C.

Referenced by FEProblemBase::outputStep().

143 {
144  if (_force_output)
145  type = EXEC_FORCED;
146 
147  for (const auto & obj : _all_objects)
148  if (obj->enabled())
149  obj->outputStep(type);
150 
162 
163  // Reset force output flag
164  _force_output = false;
165 }
const ExecFlagType EXEC_FORCED
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
bool _force_output
Flag indicating that next call to outputStep is forced.
MatType type
void flushConsoleBuffer()
If content exists in the buffer, write it.

◆ reset()

void OutputWarehouse::reset ( )

Reset the output system.

Definition at line 321 of file OutputWarehouse.C.

322 {
323  for (const auto & pair : _object_map)
324  {
325  auto * table = dynamic_cast<TableOutput *>(pair.second);
326  if (table != NULL)
327  table->clear();
328  auto * exodus = dynamic_cast<Exodus *>(pair.second);
329  if (exodus != NULL)
330  exodus->clear();
331  }
332 }
std::map< OutputName, Output * > _object_map
A map of the output pointers.
void clear()
Reset Exodus output.
Definition: Exodus.h:104
Class for output data to the ExodusII format.
Definition: Exodus.h:31
void clear()
Definition: TableOutput.C:221
Base class for scalar variables and postprocessors output objects.
Definition: TableOutput.h:34

◆ residualSetup()

void OutputWarehouse::residualSetup ( )
private

Calls the residualSetup function for each of the output objects.

See also
FEProblemBase::computeResidualTyp

Definition at line 73 of file OutputWarehouse.C.

Referenced by FEProblemBase::computeResidualTags().

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

◆ setCommonParameters()

void OutputWarehouse::setCommonParameters ( 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 247 of file OutputWarehouse.C.

Referenced by CommonOutputAction::act().

248 {
249  _common_params_ptr = params_ptr;
250 }
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 212 of file OutputWarehouse.C.

213 {
214  for (const auto & obj : _all_objects)
215  {
216  FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
217  if (ptr != NULL)
218  {
219  std::map<std::string, unsigned int>::const_iterator it = input.find(ptr->name());
220  if (it != input.end())
221  {
222  int value = it->second + offset;
223  if (value < 0)
224  ptr->setFileNumber(0);
225  else
226  ptr->setFileNumber(it->second + offset);
227  }
228  }
229  }
230 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
void setFileNumber(unsigned int num)
Sets the file number manually.
Definition: FileOutput.C:178
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:56
An outputter with filename support.
Definition: FileOutput.h:27

◆ setLoggingRequested()

void OutputWarehouse::setLoggingRequested ( )
inline

Sets a Boolean indicating that at least one object is requesting performance logging in this application.

Definition at line 190 of file OutputWarehouse.h.

Referenced by PerformanceData::PerformanceData().

190 { _logging_requested = true; }
bool _logging_requested
Indicates that performance logging has been requested by the console or some object (PerformanceData)...

◆ 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 302 of file OutputWarehouse.C.

303 {
305 }
ExecFlagType _output_exec_flag
The current output execution flag.
MatType type

◆ solveSetup()

void OutputWarehouse::solveSetup ( )
private

Calls the timestepSetup function for each of the output objects.

See also
FEProblemBase::solve()

Definition at line 59 of file OutputWarehouse.C.

Referenced by FEProblemBase::initPetscOutput().

60 {
61  for (const auto & obj : _all_objects)
62  obj->solveSetup();
63 }
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 80 of file OutputWarehouse.C.

Referenced by FEProblemBase::subdomainSetup().

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

◆ timestepSetup()

void OutputWarehouse::timestepSetup ( )
private

Calls the timestepSetup function for each of the output objects.

See also
FEProblemBase::timestepSetup()

Definition at line 52 of file OutputWarehouse.C.

Referenced by FEProblemBase::timestepSetup().

53 {
54  for (const auto & obj : _all_objects)
55  obj->timestepSetup();
56 }
std::vector< Output * > _all_objects
All instances of objects (raw pointers)

Friends And Related Function Documentation

◆ FEProblemBase

friend class FEProblemBase
friend

Definition at line 353 of file OutputWarehouse.h.

◆ MaterialOutputAction

friend class MaterialOutputAction
friend

Definition at line 356 of file OutputWarehouse.h.

◆ OutputInterface

friend class OutputInterface
friend

Definition at line 359 of file OutputWarehouse.h.

◆ PetscOutput

friend class PetscOutput
friend

Definition at line 362 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 331 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 229 of file OutputWarehouse.h.

Referenced by addOutput().

◆ _app

MooseApp& OutputWarehouse::_app
private

MooseApp.

Definition at line 301 of file OutputWarehouse.h.

Referenced by getOutputNames(), and mooseConsole().

◆ _buffer_action_console_outputs

bool OutputWarehouse::_buffer_action_console_outputs
private

True to buffer console outputs in actions.

Definition at line 307 of file OutputWarehouse.h.

Referenced by bufferConsoleOutputsBeforeConstruction(), and mooseConsole().

◆ _common_params_ptr

InputParameters* OutputWarehouse::_common_params_ptr
private

Pointer to the common InputParameters (.

See also
CommonOutputAction)

Definition at line 319 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 337 of file OutputWarehouse.h.

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

◆ _file_base_set

std::set<OutFileBase> OutputWarehouse::_file_base_set
private

List of object names.

Definition at line 316 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 346 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 325 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 340 of file OutputWarehouse.h.

Referenced by addInterfaceHideVariables(), and buildInterfaceHideVariables().

◆ _logging_requested

bool OutputWarehouse::_logging_requested
private

Indicates that performance logging has been requested by the console or some object (PerformanceData)

Definition at line 349 of file OutputWarehouse.h.

Referenced by getLoggingRequested(), and setLoggingRequested().

◆ _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 328 of file OutputWarehouse.h.

◆ _object_map

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

A map of the output pointers.

Definition at line 310 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 313 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 343 of file OutputWarehouse.h.

Referenced by setOutputExecutionType().

◆ _reserved

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

List of reserved names.

Definition at line 334 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 322 of file OutputWarehouse.h.

Referenced by addOutput(), and getSyncTimes().


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