https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.
 
virtual ~OutputWarehouse ()
 
void addOutput (std::shared_ptr< Output > output)
 Adds an existing output object to the warehouse.
 
const std::set< OutputName > & getOutputNames ()
 Get a complete set of all output object names.
 
bool hasOutput (const std::string &name) const
 Returns true if the output object exists.
 
bool hasMaterialPropertyOutput (const std::string &name) const
 Returns true if the output object exists, and it supports material property output.
 
void meshChanged ()
 Calls the meshChanged method for every output object.
 
void buildInterfaceHideVariables (const std::string &output_name, std::set< std::string > &hide)
 Return the list of hidden variables for the given output name.
 
void setFileNumbers (std::map< std::string, unsigned int > input, unsigned int offset=0)
 Calls the setFileNumber method for every FileOutput output object.
 
std::map< std::string, unsigned intgetFileNumbers ()
 Extracts the file numbers from the output objects.
 
void setCommonParameters (const InputParameters *params_ptr)
 Stores the common InputParameters object.
 
const InputParametersgetCommonParameters () const
 Get a reference to the common output parameters.
 
bool commonFileBaseSet () const
 Whether the common [Outputs] block set file_base from input parsing.
 
std::set< Real > & getSyncTimes ()
 Return the sync times for all objects.
 
void checkOutputs (const std::set< OutputName > &names, const bool supports_material_output=false)
 Test that the output names exist.
 
std::set< OutputName > getAllMaterialPropertyOutputNames () const
 Returns all output names that support material output.
 
template<typename T >
T * getOutput (const OutputName &name)
 Return an Output object by name.
 
template<typename T >
std::vector< T * > getOutputs (const std::vector< OutputName > &names)
 Return a vector of objects by names.
 
template<typename T >
std::vector< T * > getOutputs () const
 Return a vector of objects of a given type.
 
template<typename T >
std::vector< OutputName > getOutputNames ()
 Return a list of output objects with a given type.
 
const std::set< std::string > & getReservedNames () const
 Return a set of reserved output names.
 
bool isReservedName (const std::string &name)
 Test if the given name is reserved.
 
void mooseConsole ()
 Send current output buffer to Console output objects.
 
void mooseConsole (std::ostringstream &buffer)
 Send a buffer to Console output objects.
 
std::ostringstream & consoleBuffer ()
 The buffered messages stream for Console objects.
 
void bufferConsoleOutputsBeforeConstruction (bool buffer)
 Set if the outputs to Console before its construction are to be buffered or to screen directly.
 
void reset ()
 Reset the output system.
 
void solveSetup ()
 Calls the timestepSetup function for each of the output objects.
 
unsigned long long int numPrinted () const
 The number of times something has been printed.
 

Protected Member Functions

PerfGraphperfGraph ()
 Get the PerfGraph.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing.
 
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.
 
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.
 
const std::string _prefix
 A prefix to use for all sections.
 

Private Member Functions

void outputStep (ExecFlagType type)
 Calls the outputStep method for each output object.
 
void forceOutput ()
 Indicates that the next call to outputStep should be forced This is private, users should utilize FEProblemBase::forceOutput()
 
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.
 
void initialSetup ()
 Calls the initialSetup function for each of the output objects.
 
void timestepSetup ()
 Calls the timestepSetup function for each of the output objects.
 
void customSetup (const ExecFlagType &exec_type)
 Calls the setup function for each of the output objects.
 
void jacobianSetup ()
 Calls the jacobianSetup function for each of the output objects.
 
void residualSetup ()
 Calls the residualSetup function for each of the output objects.
 
void subdomainSetup ()
 Calls the subdomainSetup function for each of the output objects.
 
void addInterfaceHideVariables (const std::string &output_name, const std::set< std::string > &variable_names)
 Insert variable names for hiding via the OutoutInterface.
 
void setOutputExecutionType (ExecFlagType type)
 Sets the execution flag type.
 
void flushConsoleBuffer ()
 If content exists in the buffer, write it.
 
void resetFileBase ()
 Resets the file base for all FileOutput objects.
 
void allowOutput (bool state)
 Ability to enable/disable output calls This is private, users should utilize FEProblemBase::allowOutput()
 
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.
 
MooseApp_app
 MooseApp.
 
std::vector< Output * > _all_objects
 All instances of objects (raw pointers)
 
bool _buffer_action_console_outputs
 True to buffer console outputs in actions.
 
std::map< OutputName, Output * > _object_map
 A map of the output pointers.
 
std::set< OutputName > _object_names
 A set of output names.
 
std::map< OutputName, std::set< OutFileBase > > _file_base_map
 List of object names.
 
const InputParameters_common_params_ptr
 Pointer to the common InputParameters (.
 
std::set< Real > _sync_times
 Sync times for all objects.
 
std::string _input_file_name
 Input file name for this output object.
 
std::map< OutputName, std::set< AuxVariableName > > _material_output_map
 Map of output name and AuxVariable names to be output (used by auto Material output)
 
std::set< AuxVariableName > _all_material_output_variables
 List of all variable created by auto material output.
 
std::set< std::string > _reserved
 List of reserved names.
 
std::ostringstream _console_buffer
 The stream for holding messages passed to _console prior to Output object construction.
 
std::map< std::string, std::set< std::string > > _interface_map
 Storage for variables to hide as prescribed by the object via the OutputInterface.
 
ExecFlagType _output_exec_flag
 The current output execution flag.
 
bool _force_output
 Flag indicating that next call to outputStep is forced.
 
bool _last_message_ended_in_newline
 Whether or not the last thing output by mooseConsole had a newline as the last character.
 
const std::ostringstream * _last_buffer
 What the last buffer was that was printed.
 
std::atomic< unsigned long long int_num_printed
 Number of times the stream has been printed to.
 

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),
31 _force_output(false),
33 _last_buffer(NULL),
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 ExecFlagType EXEC_CUSTOM
Definition Moose.C:52
std::atomic< unsigned long long int > _num_printed
Number of times the stream has been printed to.
const InputParameters * _common_params_ptr
Pointer to the common InputParameters (.
const std::ostringstream * _last_buffer
What the last buffer was that was printed.
MooseApp & _app
MooseApp.
bool _last_message_ended_in_newline
Whether or not the last thing output by mooseConsole had a newline as the last character.
ExecFlagType _output_exec_flag
The current output execution flag.
bool _buffer_action_console_outputs
True to buffer console outputs in actions.
bool _force_output
Flag indicating that next call to outputStep is forced.
std::set< std::string > _reserved
List of reserved names.
Interface for objects interacting with the PerfGraph.

◆ ~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())
46}
void mooseConsole()
Send current output buffer to Console output objects.
std::ostringstream _console_buffer
The stream for holding messages passed to _console prior to Output object construction.

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

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

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

◆ 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.

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}
Writes out three things:
Definition Checkpoint.h:49
std::vector< Output * > _all_objects
All instances of objects (raw pointers)
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.
std::set< OutputName > _object_names
A set of output names.
std::map< OutputName, Output * > _object_map
A map of the output pointers.
const std::set< Real > & getSyncTimes()
Definition Output.h:144

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

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

156{
157 _file_base_map[obj_name].insert(filename);
158 for (const auto & it : _file_base_map)
159 if (it.first != obj_name && it.second.find(filename) != it.second.end())
160 mooseError("An output file with the name, ",
161 filename,
162 ", already exists. If both outputs fall back to a common 'file_base' set in the "
163 "[Outputs] block, give one of them its own distinct 'file_base' or set "
164 "'append_object_name = true' on it to avoid this collision.");
165}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::map< OutputName, std::set< OutFileBase > > _file_base_map
List of object names.
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition KokkosUtils.h:40

Referenced by resetFileBase().

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

394{
395 for (const auto & obj : _all_objects)
396 obj->allowOutput(state);
397}
void allowOutput(bool state)
Ability to enable/disable output calls This is private, users should utilize FEProblemBase::allowOutp...

Referenced by FEProblemBase::allowOutput().

◆ allowOutput() [2/2]

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

Definition at line 496 of file OutputWarehouse.h.

497{
498 std::vector<T *> outputs = getOutputs<T>();
499 for (typename std::vector<T *>::iterator it = outputs.begin(); it != outputs.end(); ++it)
500 (*it)->allowOutput(state);
501}

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

214 {
216 }

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

331{
332 std::map<std::string, std::set<std::string>>::const_iterator it =
333 _interface_map.find(output_name);
334 if (it != _interface_map.end())
335 hide = it->second;
336}

Referenced by AdvancedOutput::initOutputList().

◆ checkOutputs()

void OutputWarehouse::checkOutputs ( const std::set< OutputName > &  names,
const bool  supports_material_output = false 
)

Test that the output names exist.

Parameters
namesA vector of names to check
supports_material_outputOptional parameter to check if all output objects associated with 'names' must support material property output

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

341{
342 std::string reserved_name = "";
343 for (const auto & name : names)
344 {
345 const bool is_reserved_name = isReservedName(name);
346 if (is_reserved_name)
347 reserved_name = name;
348 if (!is_reserved_name)
349 {
350 if (!hasOutput(name))
351 mooseError("The output object '", name, "' is not a defined output object.");
352 if (supports_material_output && !hasMaterialPropertyOutput(name))
353 mooseError("The output object '", name, "' does not support material output.");
354 }
355 }
356 if (!reserved_name.empty() && names.size() > 1)
357 mooseError("When setting output name to reserved name '" + reserved_name +
358 "', only one entry is allowed in outputs parameter.");
359}
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.
bool hasMaterialPropertyOutput(const std::string &name) const
Returns true if the output object exists, and it supports material property output.
std::string name(const ElemQuality q)

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

◆ commonFileBaseSet()

bool OutputWarehouse::commonFileBaseSet ( ) const

Whether the common [Outputs] block set file_base from input parsing.

Definition at line 310 of file OutputWarehouse.C.

311{
312 return _common_params_ptr && _common_params_ptr->isParamValid("file_base");
313}
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...

Referenced by resetFileBase().

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

207{ return _console_buffer; }

◆ 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.

68{
69 for (const auto & obj : _all_objects)
70 obj->customSetup(exec_type);
71}
void customSetup(const ExecFlagType &exec_type)
Calls the setup function for each of the output objects.

Referenced by FEProblemBase::customSetup().

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

257{
258 if (!_console_buffer.str().empty())
259 mooseConsole();
260}

Referenced by outputStep().

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

401{
402 _force_output = true;
403}

Referenced by FEProblemBase::forceOutput().

◆ getAllMaterialPropertyOutputNames()

std::set< OutputName > OutputWarehouse::getAllMaterialPropertyOutputNames ( ) const

Returns all output names that support material output.

Returns
A set of all output names that support material output

Definition at line 362 of file OutputWarehouse.C.

363{
364 std::set<OutputName> output_names;
365 for (const auto & pair : _object_map)
366 {
367 const auto * output = cast_ptr<const Output *>(pair.second);
368 if (output->supportsMaterialPropertyOutput())
369 output_names.insert(pair.first);
370 }
371 return output_names;
372}

Referenced by MaterialOutputAction::act().

◆ getCommonParameters()

const InputParameters * OutputWarehouse::getCommonParameters ( ) const

Get a reference to the common output parameters.

Returns
Pointer to the common InputParameters object

Definition at line 304 of file OutputWarehouse.C.

305{
306 return _common_params_ptr;
307}

Referenced by FEProblemBase::addOutput().

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

285{
286
287 std::map<std::string, unsigned int> output;
288 for (const auto & obj : _all_objects)
289 {
290 FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
291 if (ptr != NULL)
292 output[ptr->name()] = ptr->getFileNumber();
293 }
294 return output;
295}
An outputter with filename support.
Definition FileOutput.h:21
unsigned int getFileNumber()
Return the current file number for this outputter.
Definition FileOutput.C:191
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103

Referenced by MultiApp::createApp().

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

421{
422 // Check that the object exists
423 if (!hasOutput(name))
424 mooseError("An output object with the name '", name, "' does not exist.");
425
426 // Attempt to cast the object to the correct type
427 T * output = dynamic_cast<T *>(_object_map[name]);
428
429 // Error if the cast fails
430 if (output == NULL)
431 mooseError("An output object with the name '", name, "' for the specified type does not exist");
432
433 // Return the object
434 return output;
435}

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

144{
145 if (_object_names.empty() && _app.actionWarehouse().hasActions("add_output"))
146 {
147 const auto & actions = _app.actionWarehouse().getActionListByName("add_output");
148 for (const auto & act : actions)
149 _object_names.insert(act->name());
150 }
151 return _object_names;
152}
bool hasActions(const std::string &task) const
Check if Actions associated with passed in task exist.
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition MooseApp.h:217

Referenced by OutputInterface::buildOutputHideVariableList().

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

476{
477 // The output vector
478 std::vector<OutputName> names;
479
480 // Loop through the objects and store the name if the type cast succeeds
481 for (std::map<OutputName, Output *>::const_iterator it = _object_map.begin();
482 it != _object_map.end();
483 ++it)
484 {
485 T * output = dynamic_cast<T *>(it->second);
486 if (output != NULL)
487 names.push_back(it->first);
488 }
489
490 // Return the names
491 return names;
492}

◆ getOutputs() [1/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 454 of file OutputWarehouse.h.

455{
456 // The vector to output
457 std::vector<T *> outputs;
458
459 // Populate the vector
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 outputs.push_back(output);
467 }
468
469 // Return the objects
470 return outputs;
471}

◆ getOutputs() [2/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 439 of file OutputWarehouse.h.

440{
441 // The vector to output
442 std::vector<T *> outputs;
443
444 // Populate the vector
445 for (std::vector<OutputName>::const_iterator it = names.begin(); it != names.end(); ++it)
446 outputs.push_back(getOutput<T>(*it));
447
448 // Return the objects
449 return outputs;
450}

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

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

376{
377 return _reserved;
378}

◆ getSyncTimes()

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

Return the sync times for all objects.

Definition at line 316 of file OutputWarehouse.C.

317{
318 return _sync_times;
319}

Referenced by TimePeriod::initialSetup().

◆ hasMaterialPropertyOutput()

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

Returns true if the output object exists, and it supports material property output.

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

Definition at line 129 of file OutputWarehouse.C.

130{
131 const auto found_object = hasOutput(name);
132 if (!found_object)
133 return false;
134 else
135 {
136 // Check if output object supports material property output
137 const auto * output_object = cast_ptr<const Output *>(_object_map.at(name));
138 return output_object->supportsMaterialPropertyOutput();
139 }
140}

Referenced by checkOutputs().

◆ 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.

124{
125 return _object_map.find(name) != _object_map.end();
126}

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

◆ 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.

50{
51 TIME_SECTION("initialSetup", 5, "Setting Up Outputs");
52
54
55 for (const auto & obj : _all_objects)
56 obj->initialSetup();
57}
void initialSetup()
Calls the initialSetup function for each of the output objects.
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 381 of file OutputWarehouse.C.

382{
383 return _reserved.find(name) != _reserved.end();
384}

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

◆ 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.

82{
83 for (const auto & obj : _all_objects)
84 obj->jacobianSetup();
85}
void jacobianSetup()
Calls the jacobianSetup function for each of the output objects.

Referenced by FEProblemBase::computeJacobianTags(), and FEProblemBase::computeLinearSystemTags().

◆ meshChanged()

void OutputWarehouse::meshChanged ( )

Calls the meshChanged method for every output object.

Definition at line 194 of file OutputWarehouse.C.

195{
196 for (const auto & obj : _all_objects)
197 obj->meshChanged();
198}
void meshChanged()
Calls the meshChanged method for every output object.

Referenced by MooseApp::setOutputPosition().

◆ mooseConsole() [1/2]

void OutputWarehouse::mooseConsole ( )

Send current output buffer to Console output objects.

Definition at line 203 of file OutputWarehouse.C.

204{
206}

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

◆ mooseConsole() [2/2]

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

Send a buffer to Console output objects.

Definition at line 209 of file OutputWarehouse.C.

210{
211 std::lock_guard<std::mutex> lock(moose_console_mutex);
212
213 std::string message = buffer.str();
214
215 // If someone else is writing - then we may need a newline
217 message = '\n' + message;
218
219 // Loop through all Console Output objects and pass the current output buffer
220 std::vector<Console *> objects = getOutputs<Console>();
221 if (!objects.empty())
222 {
223 for (const auto & obj : objects)
224 obj->mooseConsole(message);
225
226 // Reset
227 buffer.clear();
228 buffer.str("");
229 }
230 else if (_app.actionWarehouse().hasTask("add_output") &&
232 {
233 // this will cause messages to console before its construction immediately flushed and
234 // cleared.
235 bool this_message_ends_in_newline = message.empty() ? true : message.back() == '\n';
236
237 // If that last message ended in newline then this one may need
238 // to start with indenting
239 // Note that we only indent the first line if the last message ended in new line
240 if (_app.multiAppLevel() > 0)
242
243 Moose::out << message << std::flush;
244 buffer.clear();
245 buffer.str("");
246
247 _last_message_ended_in_newline = this_message_ends_in_newline;
248 }
249
250 _last_buffer = &buffer;
251
252 _num_printed++;
253}
static std::mutex moose_console_mutex
bool isTaskComplete(const std::string &task) const
bool hasTask(const std::string &task) const
unsigned int multiAppLevel() const
The MultiApp Level.
Definition MooseApp.h:855
void indentMessage(const std::string &prefix, std::string &message, const char *color, bool indent_first_line, const std::string &post_prefix)
Definition MooseUtils.C:749

◆ numPrinted()

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

The number of times something has been printed.

Definition at line 233 of file OutputWarehouse.h.

233{ return _num_printed; }

Referenced by ConsoleStream::numPrinted().

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

169{
170 if (_force_output)
171 type = EXEC_FORCED;
172
173 for (const auto & obj : _all_objects)
174 if (obj->enabled())
175 obj->outputStep(type);
176
188
189 // Reset force output flag
190 _force_output = false;
191}
const ExecFlagType EXEC_FORCED
Definition Moose.C:50
void flushConsoleBuffer()
If content exists in the buffer, write it.
void outputStep(ExecFlagType type)
Calls the outputStep method for each output object.

Referenced by FEProblemBase::outputStep().

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 86 of file PerfGraphInterface.C.

87{
88 return _pg_moose_app.perfGraph();
89}
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition MooseApp.h:179
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.

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

◆ 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 61 of file PerfGraphInterface.C.

63{
64 const auto timed_section_name = timedSectionName(section_name);
65 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
66 return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
67 else
68 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
69}
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID @section_name The name of the section.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
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 72 of file PerfGraphInterface.C.

76{
77 const auto timed_section_name = timedSectionName(section_name);
78 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
80 timedSectionName(section_name), level, live_message, print_dots);
81 else
82 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
83}

◆ reset()

void OutputWarehouse::reset ( )

Reset the output system.

Definition at line 406 of file OutputWarehouse.C.

407{
408 for (const auto & pair : _object_map)
409 {
410 auto * table = dynamic_cast<TableOutput *>(pair.second);
411 if (table != NULL)
412 table->clear();
413 auto * exodus = dynamic_cast<Exodus *>(pair.second);
414 if (exodus != NULL)
415 exodus->clear();
416 }
417}
Class for output data to the ExodusII format.
Definition Exodus.h:25
void clear()
Reset Exodus output.
Definition Exodus.C:554
Base class for scalar variables and postprocessors output objects.
Definition TableOutput.h:29

◆ resetFileBase()

void OutputWarehouse::resetFileBase ( )
private

Resets the file base for all FileOutput objects.

Definition at line 420 of file OutputWarehouse.C.

421{
422 // Tentatively resolve every FileOutput that will fall back to the app's
423 // file_base -- shortcut-syntax outputs built by CommonOutputAction and
424 // sub-block outputs alike, as long as neither sets its own 'file_base' --
425 // and tally the results by the resulting (extension-inclusive) filename.
426 // Two fallback outputs whose tentative filenames match this way would
427 // otherwise collide (see #4215); shortcut outputs are included here so a
428 // sub-block output colliding with a shortcut output is detected too, even
429 // though only sub-block outputs act on the collision below (shortcut
430 // outputs always keep the common file_base verbatim).
431 std::map<std::string, unsigned int> fallback_filename_counts;
432 for (const auto & obj : _all_objects)
433 if (FileOutput * file_output = dynamic_cast<FileOutput *>(obj))
434 if (!obj->getParam<bool>("_file_base_set_by_own_block"))
435 {
436 file_output->setFileBase(_app.getOutputFileBase());
437 fallback_filename_counts[file_output->filename()]++;
438 }
439
440 // Set the file base from the application to FileOutputs and add associated filenames
441 for (const auto & obj : _all_objects)
442 if (FileOutput * file_output = dynamic_cast<FileOutput *>(obj))
443 {
444 std::string file_base;
445 if (obj->parameters().get<bool>("_built_by_moose"))
446 {
447 // Shortcut-syntax outputs always keep the common/default file_base
448 // verbatim; the object name is never appended to them.
449 if (obj->isParamValid("file_base"))
450 file_base = obj->getParam<std::string>("file_base");
451 else
452 file_base = _app.getOutputFileBase();
453 }
454 else
455 {
456 // A sub-block output that doesn't set its own 'file_base' and whose
457 // tentatively-resolved filename collides with another output's --
458 // another sub-block, or a shortcut-syntax output -- must be
459 // disambiguated. MOOSE will not silently choose a name for the user
460 // in that case: require the user to explicitly opt in to appending
461 // the object name (or to explicitly opt out and accept the
462 // collision) rather than doing it for them. With no common
463 // 'file_base' set at all, the object name is always appended,
464 // matching the ordinary default naming scheme -- there is no
465 // collision to speak of in that case.
466 const bool collides = commonFileBaseSet() &&
467 !obj->getParam<bool>("_file_base_set_by_own_block") &&
468 fallback_filename_counts[file_output->filename()] > 1;
469
470 if (collides && !obj->parameters().isParamSetByUser("append_object_name"))
472 "The output object '",
473 obj->name(),
474 "' would write to the file '",
475 file_output->filename(),
476 "', which is also used by another output object, because both fall back to the "
477 "common 'file_base' set in the [Outputs] block. MOOSE will not silently rename an "
478 "output to resolve this collision. Set 'append_object_name = true' on '",
479 obj->name(),
480 "' (or on the other colliding output(s)) to have the object name appended and "
481 "disambiguate the filenames, or give '",
482 obj->name(),
483 "' its own distinct 'file_base'.");
484
485 const bool append_by_default = !commonFileBaseSet();
486 const bool append = obj->parameters().isParamSetByUser("append_object_name")
487 ? obj->getParam<bool>("append_object_name")
488 : append_by_default;
489
490 if (append)
491 file_base = _app.getOutputFileBase(true) + "_" + obj->name();
492 else
493 file_base = _app.getOutputFileBase();
494 }
495
496 file_output->setFileBase(file_base);
497 addOutputFilename(obj->name(), file_output->filename());
498 }
499}
std::string getOutputFileBase(bool for_non_moose_build_output=false) const
Get the output file base name.
Definition MooseApp.C:1538
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...
bool commonFileBaseSet() const
Whether the common [Outputs] block set file_base from input parsing.

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

◆ 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.

89{
90 for (const auto & obj : _all_objects)
91 obj->residualSetup();
92}
void residualSetup()
Calls the residualSetup function for each of the output objects.

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

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

299{
300 _common_params_ptr = params_ptr;
301}

Referenced by CommonOutputAction::act().

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

264{
265 for (const auto & obj : _all_objects)
266 {
267 FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
268 if (ptr != NULL)
269 {
270 std::map<std::string, unsigned int>::const_iterator it = input.find(ptr->name());
271 if (it != input.end())
272 {
273 int value = it->second + offset;
274 if (value < 0)
275 ptr->setFileNumber(0);
276 else
277 ptr->setFileNumber(it->second + offset);
278 }
279 }
280 }
281}
void setFileNumber(unsigned int num)
Sets the file number manually.
Definition FileOutput.C:185
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

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

388{
389 _output_exec_flag = type;
390}

◆ 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.

75{
76 for (const auto & obj : _all_objects)
77 obj->solveSetup();
78}
void solveSetup()
Calls the timestepSetup function for each of the output objects.

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

◆ 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.

96{
97 for (const auto & obj : _all_objects)
98 obj->subdomainSetup();
99}
void subdomainSetup()
Calls the subdomainSetup function for each of the output objects.

Referenced by FEProblemBase::subdomainSetup().

◆ 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 55 of file PerfGraphInterface.C.

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

Referenced by PerfGraphInterface::registerTimedSection(), and PerfGraphInterface::registerTimedSection().

◆ 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.

61{
62 for (const auto & obj : _all_objects)
63 obj->timestepSetup();
64}
void timestepSetup()
Calls the timestepSetup function for each of the output objects.

Referenced by FEProblemBase::timestepSetup().

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

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

Referenced by Convergence::validParams().

Friends And Related Symbol Documentation

◆ FEProblemBase

friend class FEProblemBase
friend

Definition at line 403 of file OutputWarehouse.h.

◆ MaterialOutputAction

friend class MaterialOutputAction
friend

Definition at line 406 of file OutputWarehouse.h.

◆ MooseApp

friend class MooseApp
friend

Definition at line 415 of file OutputWarehouse.h.

◆ OutputInterface

friend class OutputInterface
friend

Definition at line 409 of file OutputWarehouse.h.

◆ PetscOutputInterface

friend class PetscOutputInterface
friend

Definition at line 412 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 375 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 266 of file OutputWarehouse.h.

Referenced by addOutput().

◆ _app

MooseApp& OutputWarehouse::_app
private

MooseApp.

Definition at line 345 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 351 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 363 of file OutputWarehouse.h.

Referenced by commonFileBaseSet(), 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 381 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 360 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 390 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 369 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 384 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 396 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 393 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 372 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 399 of file OutputWarehouse.h.

Referenced by mooseConsole(), and numPrinted().

◆ _object_map

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

◆ _object_names

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

A set of output names.

Definition at line 357 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 387 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 135 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 138 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ _reserved

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

List of reserved names.

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

Referenced by addOutput(), and getSyncTimes().


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