Skip to content

Commit

Permalink
Basic conditional ostream class
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Jan 14, 2025
1 parent 62cd026 commit 7dfef89
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions include/core/conditional_ostreams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef CONDITIONAL_OSTREAMS_H_
#define CONDITIONAL_OSTREAMS_H_

#include <deal.II/base/conditional_ostream.h>
#include <deal.II/base/mpi.h>

#include <ostream>

/**
* \brief A class that allows printing to different output streams that are classified
* based on their verbosity. For now, this consists of two stream the release and debug.
* The debug stream provides more information that may be useful when debugging.
*/
class conditionalOStreams
{
public:
/**
* \brief Constructor.
*/
conditionalOStreams();

/**
* \brief Generic parallel output stream. Used for essential information in release and
* debug mode.
*/
static const dealii::ConditionalOStream pout_base;

/**
* \brief Verbose parallel output stream. Used for additional information in debug mode.
*/
static const dealii::ConditionalOStream pout_verbose;
};

// NOLINTBEGIN
const dealii::ConditionalOStream conditionalOStreams::pout_base(
std::cout,
dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0);

const dealii::ConditionalOStream conditionalOStreams::pout_verbose(
std::cout,
#ifndef DEBUG
false &&
#endif
dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0);
// NOLINTEND

#endif

0 comments on commit 7dfef89

Please sign in to comment.