deal.II version 9.7.1
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Textual output
Collaboration diagram for Textual output:

Classes

class  ConvergenceTable
class  LogStream
class  TableHandler
class  Histogram

Functions

 ConditionalOStream (std::ostream &stream, const bool active=true)

Detailed Description

In addition to classes that provide graphical output formats (see the Graphical output topic), deal.II has a number of classes that facilitate textual output in a number of ways. They are collected in this topic. See the documentation of these classes for more details.

Function Documentation

◆ ConditionalOStream()

ConditionalOStream::ConditionalOStream ( std::ostream & stream,
const bool active = true )
explicit

A class that allows printing to an output stream, e.g. std::cout, depending on the ConditionalOStream object being active (default) or not. The condition of this object can be changed by set_condition() and in the constructor. This class is used in the step-17, step-18, step-32, step-33, and step-35 tutorial programs.

This class is mostly useful in parallel computations. Ordinarily, you would use std::cout to print messages like what the program is presently doing, or the number of degrees of freedom in each step. However, in parallel programs, this means that each of the MPI processes write to the screen, which yields many repetitions of the same text. To avoid it, one would have to have a designated process, say the one with MPI process number zero, do the output, and guard each write statement with an if-condition. This becomes cumbersome and clutters up the code. Rather than doing so, the present class can be used: objects of its type act just like a standard output stream, but they only print something based on a condition that can be set to, for example, mpi_process==0, so that only one process has a true condition and in all other processes writes to this object just disappear in nirvana.

The usual usage of this class is as follows:

ConditionalOStream pout(std::cout, this_mpi_process==0);
// all processes print the following information to standard output
std::cout << "Reading parameter file on process "
<< this_mpi_process << std::endl;
// following is printed by process 0 only
pout << "Solving ..." << std::endl;
solve();
pout << "done" << std::endl;
ConditionalOStream(std::ostream &stream, const bool active=true)

Here, Reading parameter file on process xy' is printed by each process separately. In contrast to that, Solving ...' and `done' is printed to standard output only once, namely by process 0.

This class is not derived from ostream. Therefore

system_matrix.print_formatted(pout);

is not possible. Instead use the is_active() function for a work-around:

if (pout.is_active())
system_matrix.print_formatted(cout);

*/ class ConditionalOStream { public: /** Constructor. Set the stream to which we want to write, and the condition based on which writes are actually forwarded. Per default the condition of an object is active.

Definition at line 23 of file conditional_ostream.cc.