dolfin/log

Documentation for C++ code found in dolfin/log/*.h

Enumerations

LogLevel

C++ documentation for LogLevel from dolfin/log/LogLevel.h:

enum dolfin::LogLevel

These log levels match the levels in the Python ‘logging’ module (and adds trace/progress).

enumerator dolfin::LogLevel::CRITICAL = 50
enumerator dolfin::LogLevel::ERROR = 40
enumerator dolfin::LogLevel::WARNING = 30
enumerator dolfin::LogLevel::INFO = 20
enumerator dolfin::LogLevel::PROGRESS = 16
enumerator dolfin::LogLevel::TRACE = 13
enumerator dolfin::LogLevel::DBG = 10

Functions

begin

C++ documentation for begin from dolfin/log/log.h:

void dolfin::begin(int debug_level, std::string msg, ...)

Begin task (increase indentation level)

Parameters:
  • debug_level
  • msg

C++ documentation for begin from dolfin/log/log.h:

void dolfin::begin(std::string msg, ...)

Begin task (increase indentation level)

Parameters:msg

deprecation

C++ documentation for deprecation from dolfin/log/log.h:

void dolfin::deprecation(std::string feature, std::string version_deprecated, std::string message, ...)

Issue deprecation warning for removed feature Arguments feature (std::string) Name of the feature that has been removed. version_deprecated (std::string) Version number of the release in which the feature is deprecated. message (std::string) A format string explaining the deprecation.

Parameters:
  • feature
  • version_deprecated
  • message

dolfin_error

C++ documentation for dolfin_error from dolfin/log/log.h:

void dolfin::dolfin_error(std::string location, std::string task, std::string reason, ...)

Print error message. Prefer this to the above generic error message. Arguments location (std::string) Name of the file from which the error message was generated. task (std::string) Name of the task that failed. Note that this string should begin with lowercase. Note that this string should not be punctuated. reason (std::string) A format string explaining the reason for the failure. Note that this string should begin with uppercase. Note that this string should not be punctuated. Note that this string may contain printf style formatting. ... (primitive types like int, std::size_t, double, bool) Optional arguments for the format string. Developers should read the file dolfin/log/README in the DOLFIN source tree for further notes about the use of this function.

Parameters:
  • location
  • task
  • reason

end

C++ documentation for end from dolfin/log/log.h:

void dolfin::end()

End task (decrease indentation level)

error

C++ documentation for error from dolfin/log/log.h:

void dolfin::error(std::string msg, ...)

Print error message and throw an exception. Note to developers: this function should not be used internally in DOLFIN. Use the more informative dolfin_error instead.

Parameters:msg

get_log_level

C++ documentation for get_log_level from dolfin/log/log.h:

int dolfin::get_log_level()

Get log level.

info

C++ documentation for info from dolfin/log/log.h:

void dolfin::info(const Parameters &parameters, bool verbose = false)

Print parameter (using output of str() method)

Parameters:
  • parameters
  • verbose

C++ documentation for info from dolfin/log/log.h:

void dolfin::info(const Variable &variable, bool verbose = false)

Print variable (using output of str() method)

Parameters:
  • variable
  • verbose

C++ documentation for info from dolfin/log/log.h:

void dolfin::info(std::string msg, ...)

Print message. The DOLFIN log system provides the following set of functions for uniform handling of log messages, warnings and errors. In addition, macros are provided for debug messages and dolfin_assertions. Only messages with a debug level higher than or equal to the current log level are printed (the default being zero). Logging may also be turned off by calling set_log_active(false).

Parameters:msg

info_stream

C++ documentation for info_stream from dolfin/log/log.h:

void dolfin::info_stream(std::ostream &out, std::string msg)

Print message to stream.

Parameters:
  • out
  • msg

info_underline

C++ documentation for info_underline from dolfin/log/log.h:

void dolfin::info_underline(std::string msg, ...)

Print underlined message.

Parameters:msg

log

C++ documentation for log from dolfin/log/log.h:

void dolfin::log(int debug_level, std::string msg, ...)

Print message at given debug level.

Parameters:
  • debug_level
  • msg

monitor_memory_usage

C++ documentation for monitor_memory_usage from dolfin/log/log.h:

void dolfin::monitor_memory_usage()

Monitor memory usage. Call this function at the start of a program to continuously monitor the memory usage of the process.

not_working_in_parallel

C++ documentation for not_working_in_parallel from dolfin/log/log.h:

void dolfin::not_working_in_parallel(std::string what)

Report that functionality has not (yet) been implemented to work in parallel

Parameters:what

set_indentation_level

C++ documentation for set_indentation_level from dolfin/log/log.h:

void dolfin::set_indentation_level(std::size_t indentation_level)

Set indentation level.

Parameters:indentation_level

set_log_active

C++ documentation for set_log_active from dolfin/log/log.h:

void dolfin::set_log_active(bool active = true)

Turn logging on or off.

Parameters:active

set_log_level

C++ documentation for set_log_level from dolfin/log/log.h:

void dolfin::set_log_level(int level)

Set log level.

Parameters:level

set_output_stream

C++ documentation for set_output_stream from dolfin/log/log.h:

void dolfin::set_output_stream(std::ostream &out)

Set output stream.

Parameters:out

warning

C++ documentation for warning from dolfin/log/log.h:

void dolfin::warning(std::string msg, ...)

Print warning.

Parameters:msg

Variables

cout

C++ documentation for cout from dolfin/log/LogStream.h:

LogStream dolfin::cout

dolfin::cout

endl

C++ documentation for endl from dolfin/log/LogStream.h:

LogStream dolfin::endl

dolfin::endl ;

Classes

Event

C++ documentation for Event from dolfin/log/Event.h:

class dolfin::Event

A event is a string message which is displayed only a limited number of times.

Event event("System is stiff, damping is needed.");
while ()
{
...
if ( ... )
{
event();
...
}
}
dolfin::Event::Event(const std::string msg, unsigned int maxcount = 1)

Constructor.

Parameters:
  • msg
  • maxcount
unsigned int dolfin::Event::count() const

Display count.

unsigned int dolfin::Event::maxcount() const

Maximum display count.

void dolfin::Event::operator()()

Display message.

dolfin::Event::~Event()

Destructor.

LogManager

C++ documentation for LogManager from dolfin/log/LogManager.h:

class dolfin::LogManager

Logger initialisation.

Logger &dolfin::LogManager::logger()

Singleton instance of logger.

LogStream

C++ documentation for LogStream from dolfin/log/LogStream.h:

class dolfin::LogStream

This class provides functionality similar to standard C++ streams (std::cout, std::endl) for output but working through the DOLFIN log system.

dolfin::LogStream::LogStream(Type type)

Create log stream of given type.

Parameters:type
enum dolfin::LogStream::Type

Stream types.

enumerator dolfin::LogStream::Type::COUT
enumerator dolfin::LogStream::Type::ENDL
std::stringstream dolfin::LogStream::buffer
LogStream &dolfin::LogStream::operator<<(const LogStream &stream)

Output for log stream.

Parameters:stream
LogStream &dolfin::LogStream::operator<<(const MeshEntity &entity)

Output for mesh entity (not subclass of Variable for efficiency)

Parameters:entity
LogStream &dolfin::LogStream::operator<<(const Point &point)

Output for point (not subclass of Variable for efficiency)

Parameters:point
LogStream &dolfin::LogStream::operator<<(const Variable &variable)

Output for variable (calling str() method)

Parameters:variable
LogStream &dolfin::LogStream::operator<<(const std::string &s)

Output for string.

Parameters:s
LogStream &dolfin::LogStream::operator<<(double a)

Output for double.

Parameters:a
LogStream &dolfin::LogStream::operator<<(int a)

Output for int.

Parameters:a
LogStream &dolfin::LogStream::operator<<(long int a)

Output for long int.

Parameters:a
LogStream & dolfin::LogStream::operator<<(long unsigned int a)

Output for long int.

Parameters:a
LogStream &dolfin::LogStream::operator<<(std::complex<double> z)

Output for std::complex<double>

Parameters:z
LogStream &dolfin::LogStream::operator<<(unsigned int a)

Output for unsigned int.

Parameters:a
void dolfin::LogStream::setprecision(std::streamsize n)

Set precision.

Parameters:n
dolfin::LogStream::~LogStream()

Destructor.

Logger

C++ documentation for Logger from dolfin/log/Logger.h:

class dolfin::Logger

Handling of error messages, logging and informational display.

dolfin::Logger::Logger()

Constructor.

void dolfin::Logger::begin(std::string msg, int log_level = INFO)

Begin task (increase indentation level)

Parameters:
  • msg
  • log_level
void dolfin::Logger::deprecation(std::string feature, std::string version_deprecated, std::string message) const

Issue deprecation warning for removed feature.

Parameters:
  • feature
  • version_deprecated
  • message
void dolfin::Logger::dolfin_error(std::string location, std::string task, std::string reason, int mpi_rank = -1) const

Print error message, prefer this to the above generic error message

Parameters:
  • location
  • task
  • reason
  • mpi_rank
void dolfin::Logger::dump_timings_to_xml(std::string filename, TimingClear clear)

Dump a summary of timings and tasks to XML file, optionally clearing stored timings. MPI_MAX , MPI_MIN and MPI_AVG reductions are stored. Collective on ``Logger::mpi_comm() `` .

Parameters:
  • filename
  • clear
void dolfin::Logger::end()

End task (decrease indentation level)

void dolfin::Logger::error(std::string msg) const

Print error message and throw exception.

Parameters:msg
int dolfin::Logger::get_log_level() const

Get log level.

std::ostream &dolfin::Logger::get_output_stream()

Get output stream.

bool dolfin::Logger::is_active()

Return true iff logging is active.

void dolfin::Logger::list_timings(TimingClear clear, std::set<TimingType> type)

List a summary of timings and tasks, optionally clearing stored timings. MPI_AVG reduction is printed. Collective on ``Logger::mpi_comm() `` .

Parameters:
  • clear
  • type
void dolfin::Logger::log(std::string msg, int log_level = INFO) const

Print message.

Parameters:
  • msg
  • log_level
void dolfin::Logger::log_underline(std::string msg, int log_level = INFO) const

Print underlined message.

Parameters:
  • msg
  • log_level
std::ostream *dolfin::Logger::logstream
void dolfin::Logger::monitor_memory_usage()

Monitor memory usage. Call this function at the start of a program to continuously monitor the memory usage of the process.

MPI_Comm dolfin::Logger::mpi_comm()

Return MPI Communicator of Logger .

void dolfin::Logger::progress(std::string title, double p) const

Draw progress bar.

Parameters:
  • title
  • p
void dolfin::Logger::register_timing(std::string task, std::tuple<double, double, double> elapsed)

Register timing (for later summary)

Parameters:
  • task
  • elapsed
void dolfin::Logger::set_indentation_level(std::size_t indentation_level)

Set indentation level.

Parameters:indentation_level
void dolfin::Logger::set_log_active(bool active)

Turn logging on or off.

Parameters:active
void dolfin::Logger::set_log_level(int log_level)

Set log level.

Parameters:log_level
void dolfin::Logger::set_output_stream(std::ostream &stream)

Set output stream.

Parameters:stream
std::tuple<std::size_t, double, double, double> dolfin::Logger::timing(std::string task, TimingClear clear)

Return timing (count, total wall time, total user time, total system time) for given task, optionally clearing all timings for the task

Parameters:
  • task
  • clear
Table dolfin::Logger::timings(TimingClear clear, std::set<TimingType> type)

Return a summary of timings and tasks in a Table , optionally clearing stored timings

Parameters:
  • clear
  • type
void dolfin::Logger::warning(std::string msg) const

Print warning.

Parameters:msg
void dolfin::Logger::write(int log_level, std::string msg) const
Parameters:
  • log_level
  • msg
dolfin::Logger::~Logger()

Destructor.

Progress

C++ documentation for Progress from dolfin/log/Progress.h:

class dolfin::Progress

This class provides a simple way to create and update progress bars during a computation.

A progress bar may be used either in an iteration with a known number
of steps:
Progress p("Iterating...", n);
for (int i = 0; i < n; i++)
{
...
p++;
}
or in an iteration with an unknown number of steps:
Progress p("Iterating...");
while (t < T)
{
...
p = t / T;
}
dolfin::Progress::Progress(std::string title)

Create progress bar with an unknown number of steps

Parameters:title – (std::string) The title.
dolfin::Progress::Progress(std::string title, unsigned int n)

Create progress bar with a known number of steps

Parameters:
  • title – (std::string) The title.
  • n – (unsigned int) Number of steps.
bool dolfin::Progress::always
std::size_t dolfin::Progress::c_step
std::size_t dolfin::Progress::counter
bool dolfin::Progress::displayed
bool dolfin::Progress::finished
std::size_t dolfin::Progress::i
void dolfin::Progress::operator++(int)

Increment progress.

void dolfin::Progress::operator=(double p)

Set current position

Parameters:p – (double) The position.
double dolfin::Progress::t_step
double dolfin::Progress::tc
void dolfin::Progress::update(double p)
Parameters:p
dolfin::Progress::~Progress()

Destructor.

Table

C++ documentation for Table from dolfin/log/Table.h:

class dolfin::Table

This class provides storage and pretty-printing for tables. Example usage: Table table(“Timings”); table(“Eigen”, “Assemble”) = 0.010; table(“Eigen”, “Solve”) = 0.020; table(“PETSc”, “Assemble”) = 0.011; table(“PETSc”, “Solve”) = 0.019; table(“Tpetra”, “Assemble”) = 0.012; table(“Tpetra”, “Solve”) = 0.018; info(table);

Friends: MPI, XMLTable.

dolfin::Table::Table(std::string title = "", bool right_justify = true)

Create empty table.

Parameters:
  • title
  • right_justify
std::set<std::string> dolfin::Table::col_set
std::vector<std::string> dolfin::Table::cols
std::map<std::pair<std::string, std::string>, double> dolfin::Table::dvalues
std::string dolfin::Table::get(std::string row, std::string col) const

Get value of table entry.

Parameters:
  • row
  • col
double dolfin::Table::get_value(std::string row, std::string col) const

Get value of table entry.

Parameters:
  • row
  • col
TableEntry dolfin::Table::operator()(std::string row, std::string col)

Return table entry.

Parameters:
  • row
  • col
const Table &dolfin::Table::operator=(const Table &table)

Assignment operator.

Parameters:table
std::set<std::string> dolfin::Table::row_set
std::vector<std::string> dolfin::Table::rows
void dolfin::Table::set(std::string row, std::string col, double value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
void dolfin::Table::set(std::string row, std::string col, int value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
void dolfin::Table::set(std::string row, std::string col, std::size_t value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
void dolfin::Table::set(std::string row, std::string col, std::string value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
std::string dolfin::Table::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
std::string dolfin::Table::str_latex() const

Return informal string representation for LaTeX.

std::map<std::pair<std::string, std::string>, std::string> dolfin::Table::values
dolfin::Table::~Table()

Destructor.

TableEntry

C++ documentation for TableEntry from dolfin/log/Table.h:

class dolfin::TableEntry

This class represents an entry in a Table .

dolfin::TableEntry::TableEntry(std::string row, std::string col, Table &table)

Create table entry.

Parameters:
  • row
  • col
  • table
dolfin::TableEntry::operator std::string() const

Cast to entry value.

const TableEntry &dolfin::TableEntry::operator=(double value)

Assign value to table entry.

Parameters:value
const TableEntry &dolfin::TableEntry::operator=(int value)

Assign value to table entry.

Parameters:value
const TableEntry &dolfin::TableEntry::operator=(std::size_t value)

Assign value to table entry.

Parameters:value
const TableEntry &dolfin::TableEntry::operator=(std::string value)

Assign value to table entry.

Parameters:value
dolfin::TableEntry::~TableEntry()

Destructor.