From 7dfef8905d99e8066c28e510807ca62e8c13dc84 Mon Sep 17 00:00:00 2001 From: landinjm Date: Tue, 14 Jan 2025 16:02:19 -0500 Subject: [PATCH] Basic conditional ostream class --- include/core/conditional_ostreams.h | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/core/conditional_ostreams.h diff --git a/include/core/conditional_ostreams.h b/include/core/conditional_ostreams.h new file mode 100644 index 00000000..ed27efbc --- /dev/null +++ b/include/core/conditional_ostreams.h @@ -0,0 +1,47 @@ +#ifndef CONDITIONAL_OSTREAMS_H_ +#define CONDITIONAL_OSTREAMS_H_ + +#include +#include + +#include + +/** + * \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 \ No newline at end of file