| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// MueLu: A package for multigrid based preconditioning |
| 4 |
// |
| 5 |
// Copyright 2012 NTESS and the MueLu contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef MUELU_VERBOSEOBJECT_HPP |
| 11 |
#define MUELU_VERBOSEOBJECT_HPP |
| 12 |
|
| 13 |
#include "Teuchos_FancyOStream.hpp" // for FancyOStream |
| 14 |
#include "Teuchos_RCPDecl.hpp" // for RCP |
| 15 |
#include "Teuchos_VerboseObject.hpp" |
| 16 |
|
| 17 |
#include "MueLu_VerbosityLevel.hpp" |
| 18 |
|
| 19 |
namespace MueLu { |
| 20 |
|
| 21 |
/*! |
| 22 |
@class VerboseObject class. |
| 23 |
@brief Verbose class for MueLu classes |
| 24 |
|
| 25 |
This class is inspired by BelosOutputManager but: |
| 26 |
- it uses Teuchos stream |
| 27 |
- it allows to print message on proc0 or every processors |
| 28 |
- it is a base class |
| 29 |
|
| 30 |
@todo TODO |
| 31 |
- Right now, you can't change the verbosity level globally. |
| 32 |
We have to take into account Teuchos::EVerbosityLevel from the base class Teuchos::VerboseObject and somehow convert it to a MsgType. |
| 33 |
- Allow users to define the global verbosity level using both MueLu::MsgType and Teuchos::EVerbosityLevel? |
| 34 |
|
| 35 |
@todo TODO |
| 36 |
-# add a function to get the object 'local' verb level (GetVerbLevel does not do this)? |
| 37 |
-# interface without fancyOSstream but std::stream |
| 38 |
-# add 'const' and mutable |
| 39 |
|
| 40 |
@ingroup MueLuBaseClasses |
| 41 |
|
| 42 |
*/ |
| 43 |
class VerboseObject : public Teuchos::VerboseObject<VerboseObject> { |
| 44 |
public: |
| 45 |
//! @name Constructors/Destructors. |
| 46 |
//@{ |
| 47 |
VerboseObject(); |
| 48 |
|
| 49 |
//! Destructor. |
| 50 |
virtual ~VerboseObject(); |
| 51 |
//@} |
| 52 |
|
| 53 |
/*! @brief Get the verbosity level |
| 54 |
|
| 55 |
If a verbosity level has not been specified for this object (using SetVerbLevel), this method returns the default/global verbose level. |
| 56 |
*/ |
| 57 |
VerbLevel GetVerbLevel() const; |
| 58 |
|
| 59 |
//! Set the verbosity level of this object |
| 60 |
void SetVerbLevel(const VerbLevel verbLevel); |
| 61 |
|
| 62 |
//! Get proc rank used for printing. <b>Do not use this information for any other purpose.</b> |
| 63 |
int GetProcRankVerbose() const; |
| 64 |
|
| 65 |
//! Set proc rank used for printing. |
| 66 |
int SetProcRankVerbose(int procRank) const; |
| 67 |
|
| 68 |
/*! @brief Find out whether we need to print out information for a specific message type. |
| 69 |
|
| 70 |
This method is used to determine whether computations are necessary for this message type. |
| 71 |
*/ |
| 72 |
bool IsPrint(MsgType type, int thisProcRankOnly = -1) const; |
| 73 |
|
| 74 |
//! Get an output stream for outputting the input message type. |
| 75 |
Teuchos::FancyOStream& GetOStream(MsgType type, int thisProcRankOnly = 0) const; |
| 76 |
|
| 77 |
Teuchos::FancyOStream& GetBlackHole() const; |
| 78 |
|
| 79 |
static void SetMueLuOStream(const Teuchos::RCP<Teuchos::FancyOStream>& mueluOStream); |
| 80 |
|
| 81 |
static void SetMueLuOFileStream(const std::string& filename); |
| 82 |
|
| 83 |
static Teuchos::RCP<Teuchos::FancyOStream> GetMueLuOStream(); |
| 84 |
|
| 85 |
//! @name Public static member functions |
| 86 |
//@{ |
| 87 |
|
| 88 |
//! Set the default (global) verbosity level. |
| 89 |
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel); |
| 90 |
|
| 91 |
//! Get the default (global) verbosity level. |
| 92 |
static VerbLevel GetDefaultVerbLevel(); |
| 93 |
|
| 94 |
//@} |
| 95 |
|
| 96 |
private: |
| 97 |
//! Verbose level specific to 'this' |
| 98 |
VerbLevel verbLevel_; |
| 99 |
mutable int procRank_; |
| 100 |
int numProcs_; |
| 101 |
|
| 102 |
static Teuchos::RCP<Teuchos::FancyOStream> mueluOutputStream_; |
| 103 |
static Teuchos::RCP<Teuchos::FancyOStream> blackHole_; |
| 104 |
|
| 105 |
//! Global verbose level. This verbose level is used when the verbose level of the object is not specified (verbLevel_ == NotSpecified) |
| 106 |
static VerbLevel globalVerbLevel_; |
| 107 |
}; // class VerboseObject |
| 108 |
|
| 109 |
} // namespace MueLu |
| 110 |
|
| 111 |
#define MUELU_VERBOSECLASS_SHORT |
| 112 |
#endif // MUELU_VERBOSEOBJECT_HPP |