Dakota  Version 6.21
Explore and Predict with Confidence
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
OutputManager Class Reference

Class to manage redirection of stdout/stderr, keep track of current redir state, and manage rank 0 output. Also manage tabular data output for post-processing with Matlab, Tecplot, etc. and delegate to Graphics for X Windows Graphics. More...

Public Member Functions

 OutputManager ()
 Default constructor (needed for default environment ctors)
 
 OutputManager (const ProgramOptions &prog_opts, int dakota_world_rank=0, bool dakota_mpirun_flag=false)
 Standard constructor, taking user-specified program options and optionally taking the rank of this process in Dakota's MPI_Comm. More...
 
 ~OutputManager ()
 Destructor that closes streams and other outputs.
 
void close_streams ()
 helper to close streams during destructor or abnormal abort
 
Graphicsgraphics ()
 retrieve the graphics handler object
 
void parse (const ProgramOptions &prog_opts, const ProblemDescDB &problem_db)
 Extract environment options from ProblemDescDB and update from late updates to ProgramOptions.
 
void startup_message (const String &start_msg)
 Set the Dakota startup message ("Running on...")
 
void push_output_tag (const String &iterator_tag, const ProgramOptions &prog_opts, bool force_cout_redirect, bool force_rst_redirect)
 Update the tag to use on files and rebind any streams as needed.
 
String build_output_tag () const
 return the full output tag
 
void pop_output_tag ()
 (Potentially) remove an output context and rebind streams More...
 
void output_version (std::ostream &os=Cout) const
 Output the current Dakota version.
 
void output_startup_message (std::ostream &os=Cout) const
 Output the startup header and time.
 
void output_helper (const String &message, std::ostream &os) const
 Output only on Dakota world rank 0 (for version, help, etc.)
 
void append_restart (const ParamResponsePair &prp)
 append a parameter/response set to the restart file
 
void open_tabular_datastream ()
 open the tabular datastream on iterator leaders More...
 
void create_tabular_header (const Variables &vars, const Response &resp)
 output a complete header to the tabular datastream More...
 
void create_tabular_header (const StringArray &iface_ids)
 initiate the header for the tabular datastream with the leading fields
 
void append_tabular_header (const Variables &vars)
 append variables labels to the tabular header
 
void append_tabular_header (const Variables &vars, size_t start_index, size_t num_items)
 append a range of variables labels to the tabular header
 
void append_tabular_header (const StringArray &labels, bool rtn=false)
 append an array of labels to the tabular header
 
void append_tabular_header (const Response &response)
 append response labels to the tabular header
 
void add_tabular_data (const Variables &vars, const String &iface, const Response &response)
 adds data to each window in the 2d graphics and adds a row to the tabular data file for the evaluation variables/response More...
 
void add_tabular_data (const Variables &vars)
 adds data to each window in the 2d graphics and adds a row to the tabular data file for the evaluation variables
 
void add_tabular_data (const Variables &vars, size_t start_index, size_t num_items)
 adds data to each window in the 2d graphics and adds a row to the tabular data file for a portion of the evaluation variables
 
void add_tabular_data (const StringArray &iface_ids)
 adds data to a row of the tabular data file for the interface id
 
void add_tabular_data (const Response &response, bool eol=true)
 adds data to each window in the 2d graphics and adds a row to the tabular data file for the response functions
 
void add_tabular_data (const Response &response, size_t start_index, size_t num_items)
 adds data to each window in the 2d graphics and adds a row to the tabular data file for a portion of the response functions
 
template<class T >
void add_tabular_scalar (T val)
 augments the data set for a row in the tabular data file
 
void add_eol ()
 complete tabular row with EOL
 
void close_tabular_datastream ()
 close tabular datastream
 
void graphics_counter (int cntr)
 set graphicsCntr equal to cntr
 
int graphics_counter () const
 return graphicsCntr
 
void tabular_counter_label (const std::string &label)
 set tabularCntrLabel equal to label
 
void init_results_db ()
 At runtime, initialize the global ResultsManager, tagging filename with MPI worldRank + 1 if needed.
 
void archive_input (const ProgramOptions &prog_opts) const
 Archive the input file to the results database.
 
void check_input_redirs (const ProgramOptions &prog_opts, const std::string &input_file, const std::string &input_string)
 Checked the passed input file or string for output/error_file and redirect accordingly. Command line options take precedence over input file options.
 

Static Public Member Functions

static void check_inputfile_redirs (const std::string &input_string, std::string &output_filename, std::string &error_filename)
 check the specified input file contents for output/error redirection
 
static void check_inputstring_redirs (const std::string &input_string, std::string &output_filename, std::string &error_filename)
 check the specified input string contents for output/error redirection
 
static void check_input_redirs_impl (std::istream &input_stream, std::string &output_filename, std::string &error_filename)
 check the passed input file stream for output/error redirection More...
 

Public Attributes

bool graph2DFlag
 whether user requested 2D graphics plots
 
bool tabularDataFlag
 whether user requested tabular data file
 
bool resultsOutputFlag
 whether user requested results data output
 
String tabularDataFile
 filename for tabulation of graphics data
 
String resultsOutputFile
 filename for results data
 
unsigned short modelEvalsSelection
 Models selected to store their evaluations.
 
unsigned short interfEvalsSelection
 Interfaces selected to store their evaluations.
 

Private Member Functions

void initial_redirects (const ProgramOptions &prog_opts)
 Perform initial output/error redirects from user requests.
 
void read_write_restart (bool restart_requested, bool read_restart_flag, const String &read_restart_filename, size_t stop_restart_eval, const String &write_restart_filename)
 conditionally import evaluations from restart file, then always create or overwrite restart file
 

Private Attributes

int worldRank
 output manager handles rank 0 only output when needed
 
bool mpirunFlag
 some output is only for MPI runs
 
StringArray fileTags
 set of tags for various input/output files (default none)
 
ConsoleRedirector coutRedirector
 set of redirections for Dakota::Cout; stores any tagged filename when there are concurrent Iterators
 
ConsoleRedirector cerrRedirector
 set of redirections for Dakota::Cerr; stores any tagged filename when there are concurrent Iterators and error redirection is requested
 
std::vector< std::shared_ptr< RestartWriter > > restartDestinations
 Stack of active restart destinations; end is the last (active) redirection. All remain open until popped or destroyed.
 
String startupMessage
 message to print at startup when proceeding to instantiate objects
 
Graphics dakotaGraphics
 graphics and tabular data output handler used by meta-iterators, models, and approximations; encapsulated here so destroyed with the OutputManager
 
unsigned short tabularFormat
 tabular format options; see enum
 
int graphicsCntr
 used for x axis values in 2D graphics and for 1st column in tabular data
 
std::ofstream tabularDataFStream
 file stream for tabulation of graphics data within compute_response
 
std::string tabularCntrLabel
 label for counter used in first line comment w/i the tabular data file
 
std::string tabularInterfLabel
 label for interface used in first line comment w/i the tabular data file
 
short outputLevel
 output level (for debugging only; not passed in)
 
unsigned short resultsOutputFormat
 Output results format.
 

Detailed Description

Class to manage redirection of stdout/stderr, keep track of current redir state, and manage rank 0 output. Also manage tabular data output for post-processing with Matlab, Tecplot, etc. and delegate to Graphics for X Windows Graphics.

Constructor & Destructor Documentation

◆ OutputManager()

OutputManager ( const ProgramOptions prog_opts,
int  dakota_world_rank = 0,
bool  dakota_mpirun_flag = false 
)

Standard constructor, taking user-specified program options and optionally taking the rank of this process in Dakota's MPI_Comm.

Only get minimal information off ProgramOptions as may be updated later by broadcast.

References OutputManager::initial_redirects(), OutputManager::mpirunFlag, and Dakota::start_dakota_heartbeat().

Member Function Documentation

◆ pop_output_tag()

void pop_output_tag ( )

◆ open_tabular_datastream()

void open_tabular_datastream ( )

open the tabular datastream on iterator leaders

Opens the tabular data file stream and prints headings, one for each active continuous and discrete variable and one for each response function, using the variable and response function labels. This tabular data is used for post-processing of DAKOTA results in Matlab, Tecplot, etc.

References OutputManager::build_output_tag(), OutputManager::tabularDataFile, and OutputManager::tabularDataFStream.

Referenced by Model::create_tabular_datastream(), and EnsembleSurrModel::create_tabular_datastream().

◆ create_tabular_header()

void create_tabular_header ( const Variables vars,
const Response response 
)

output a complete header to the tabular datastream

Opens the tabular data file stream and prints headings, one for each active continuous and discrete variable and one for each response function, using the variable and response function labels. This tabular data is used for post-processing of DAKOTA results in Matlab, Tecplot, etc.

References OutputManager::tabularCntrLabel, OutputManager::tabularDataFStream, OutputManager::tabularFormat, and OutputManager::tabularInterfLabel.

Referenced by Model::create_tabular_datastream(), and EnsembleSurrModel::create_tabular_datastream().

◆ add_tabular_data()

void add_tabular_data ( const Variables vars,
const String &  iface,
const Response response 
)

adds data to each window in the 2d graphics and adds a row to the tabular data file for the evaluation variables/response

Adds data to each 2d plot and each tabular data column (one for each active variable and for each response function). graphicsCntr is used for the x axis in the graphics and the first column in the tabular data.

References Response::active_set_request_vector(), Graphics::add_datapoint(), OutputManager::dakotaGraphics, OutputManager::graphicsCntr, OutputManager::tabularDataFStream, and OutputManager::tabularFormat.

Referenced by Model::derived_auto_graphics(), and EnsembleSurrModel::derived_auto_graphics().

◆ check_input_redirs_impl()

void check_input_redirs_impl ( std::istream &  input_stream,
std::string &  output_filename,
std::string &  error_filename 
)
static

check the passed input file stream for output/error redirection

This has a stream API to permit multiline matching.

References Dakota::strcontains().

Referenced by OutputManager::check_inputfile_redirs(), and OutputManager::check_inputstring_redirs().


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