Belos
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
BelosOutputManager.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Belos: Block Linear Solvers Package
4
//
5
// Copyright 2004-2016 NTESS and the Belos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef BELOS_OUTPUT_MANAGER_HPP
11
#define BELOS_OUTPUT_MANAGER_HPP
12
16
17
#include "
BelosConfigDefs.hpp
"
18
#include "
BelosTypes.hpp
"
19
#include "Teuchos_oblackholestream.hpp"
20
#include "Teuchos_RCP.hpp"
21
22
#ifdef HAVE_MPI
23
#include <mpi.h>
24
#include "
BelosGlobalComm.hpp
"
25
#endif
26
38
39
namespace
Belos
{
40
41
template
<
class
ScalarType>
42
class
OutputManager
{
43
44
public
:
45
47
48
50
OutputManager
(
int
vb =
Belos::Errors
,
const
Teuchos::RCP< std::ostream > &os = Teuchos::rcp(&std::cout,
false
) );
51
53
virtual
~OutputManager
() {};
55
57
58
60
void
setOStream
(
const
Teuchos::RCP<std::ostream> &os ) { myOS_ = os; };
61
63
void
setVerbosity
(
int
vb ) { vb_ = vb; };
64
66
68
69
71
std::ostream&
stream
(
MsgType
type )
72
{
73
if
( (type & vb_) && iPrint_ ) {
74
return
*myOS_;
75
}
76
return
myBHS_;
77
}
78
80
Teuchos::RCP<std::ostream>
getOStream
() {
return
myOS_; };
81
83
85
86
88
91
bool
isVerbosity
(
MsgType
type )
const
{
return
(( type ==
Belos::Errors
) || ( vb_ & type )); };
92
94
96
97
99
void
print
(
MsgType
type,
const
std::string output );
100
102
103
private
:
104
106
107
109
OutputManager
(
const
OutputManager<ScalarType>
& OM );
110
112
OutputManager<ScalarType>
& operator=(
const
OutputManager<ScalarType>
& OM );
113
115
116
int
vb_;
117
Teuchos::RCP<std::ostream> myOS_;
118
Teuchos::oblackholestream myBHS_;
119
bool
iPrint_;
120
};
121
122
template
<
class
ScalarType>
123
OutputManager<ScalarType>::OutputManager
(
int
vb,
const
Teuchos::RCP<std::ostream> &os ) :
124
vb_(vb),
125
myOS_(os)
126
{
127
int
MyPID;
128
#ifdef HAVE_MPI
129
// Initialize MPI
130
int
mpiStarted = 0;
131
MPI_Initialized(&mpiStarted);
132
if
(mpiStarted) MPI_Comm_rank(Belos::get_global_comm(), &MyPID);
133
else
MyPID=0;
134
#else
135
MyPID = 0;
136
#endif
137
iPrint_ = (MyPID == 0);
138
}
139
140
template
<
class
ScalarType>
141
void
OutputManager<ScalarType>::print
(
MsgType
type,
const
std::string output ) {
142
if
( (type & vb_) && iPrint_ ) {
143
*myOS_ << output;
144
}
145
}
146
147
}
// end Belos namespace
148
149
#endif
150
151
// end of file BelosOutputManager.hpp
BelosConfigDefs.hpp
Belos header file which uses auto-configuration information to include necessary C++ headers.
BelosGlobalComm.hpp
BelosTypes.hpp
Collection of types and exceptions used within the Belos solvers.
Belos::OutputManager
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
Definition
BelosOutputManager.hpp:42
Belos::OutputManager::print
void print(MsgType type, const std::string output)
@ name Print methods
Definition
BelosOutputManager.hpp:141
Belos::OutputManager::setVerbosity
void setVerbosity(int vb)
Set the verbosity level for this manager.
Definition
BelosOutputManager.hpp:63
Belos::OutputManager::setOStream
void setOStream(const Teuchos::RCP< std::ostream > &os)
Set the output stream for this manager.
Definition
BelosOutputManager.hpp:60
Belos::OutputManager::getOStream
Teuchos::RCP< std::ostream > getOStream()
Get the output stream for this manager.
Definition
BelosOutputManager.hpp:80
Belos::OutputManager::~OutputManager
virtual ~OutputManager()
Destructor.
Definition
BelosOutputManager.hpp:53
Belos::OutputManager::stream
std::ostream & stream(MsgType type)
Get an output stream for outputting the input message type.
Definition
BelosOutputManager.hpp:71
Belos::OutputManager::OutputManager
OutputManager(int vb=Belos::Errors, const Teuchos::RCP< std::ostream > &os=Teuchos::rcp(&std::cout, false))
Basic constructor.
Definition
BelosOutputManager.hpp:123
Belos::OutputManager::isVerbosity
bool isVerbosity(MsgType type) const
Find out whether we need to print out information for this message type.
Definition
BelosOutputManager.hpp:91
Belos
Definition
Belos_Details_EBelosSolverType.cpp:13
Belos::MsgType
MsgType
Available message types recognized by the linear solvers.
Definition
BelosTypes.hpp:222
Belos::Errors
@ Errors
Definition
BelosTypes.hpp:223
Generated for Belos by
1.17.0