Belos Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
BelosStatusTestGeneralOutput.hpp
Go to the documentation of this file.
1
//@HEADER
2
// ************************************************************************
3
//
4
// Belos: Block Linear Solvers Package
5
// Copyright 2004 Sandia Corporation
6
//
7
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8
// the U.S. Government retains certain rights in this software.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ************************************************************************
40
//@HEADER
41
//
42
43
#ifndef BELOS_STATUS_TEST_GENERAL_OUTPUT_HPP
44
#define BELOS_STATUS_TEST_GENERAL_OUTPUT_HPP
45
50
51
52
#include "
BelosConfigDefs.hpp
"
53
#include "
BelosTypes.hpp
"
54
#include "
BelosIteration.hpp
"
55
56
#include "
BelosStatusTest.hpp
"
57
#include "
BelosStatusTestOutput.hpp
"
58
#include "
BelosOutputManager.hpp
"
59
60
namespace
Belos
{
61
71
template
<
class
ScalarType,
class
MV,
class
OP>
72
class
StatusTestGeneralOutput
:
public
StatusTestOutput
<ScalarType,MV,OP> {
73
74
public
:
76
77
92
StatusTestGeneralOutput
(
const
Teuchos::RCP<
OutputManager<ScalarType>
> &printer,
93
Teuchos::RCP<
StatusTest<ScalarType,MV,OP>
> test,
94
int
mod = 1,
95
int
printStates =
Passed
)
96
:
printer_
(printer),
97
test_
(test),
98
state_
(
Undefined
),
99
stateTest_
(printStates),
100
modTest_
(mod),
101
numCalls_
(0)
102
{}
103
105
virtual
~StatusTestGeneralOutput
() {};
107
109
110
127
StatusType
checkStatus
(
Iteration<ScalarType,MV,OP>
* solver ) {
128
TEUCHOS_TEST_FOR_EXCEPTION(
test_
== Teuchos::null,
StatusTestError
,
"StatusTestGeneralOutput::checkStatus(): child pointer is null."
);
129
state_
=
test_
->checkStatus(solver);
130
131
if
(
numCalls_
++ %
modTest_
== 0) {
132
if
( (
state_
&
stateTest_
) ==
state_
) {
133
if
(
printer_
->isVerbosity(
StatusTestDetails
) ) {
134
print
(
printer_
->stream(
StatusTestDetails
) );
135
}
136
else
if
(
printer_
->isVerbosity(
Debug
) ) {
137
print
(
printer_
->stream(
Debug
) );
138
}
139
}
140
}
141
142
return
state_
;
143
}
144
146
StatusType
getStatus
()
const
{
147
return
state_
;
148
}
149
150
151
153
154
157
void
setOutputManager
(
const
Teuchos::RCP<
OutputManager<ScalarType>
> &printer) {
printer_
= printer; }
158
161
void
setOutputFrequency
(
int
mod) {
modTest_
= mod; }
162
167
void
setChild
(Teuchos::RCP<
StatusTest<ScalarType,MV,OP>
> test) {
168
test_
= test;
169
state_
=
Undefined
;
170
}
171
173
Teuchos::RCP<StatusTest<ScalarType,MV,OP> >
getChild
()
const
{
174
return
test_
;
175
}
176
179
void
setSolverDesc
(
const
std::string& solverDesc) {
solverDesc_
= solverDesc; }
180
183
void
setPrecondDesc
(
const
std::string& precondDesc) {
precondDesc_
= precondDesc; }
184
186
187
189
190
195
void
reset
() {
196
state_
=
Undefined
;
197
test_
->reset();
198
numCalls_
= 0;
199
}
200
202
void
resetNumCalls
() {
numCalls_
= 0; }
203
205
207
208
210
void
print
(std::ostream& os,
int
indent = 0)
const
{
211
std::string ind(indent,
' '
);
212
os << std::endl << ind <<
"Belos::StatusTestGeneralOutput: "
;
213
switch
(
state_
) {
214
case
Passed
:
215
os <<
"Passed"
<< std::endl;
216
break
;
217
case
Failed
:
218
os <<
"Failed"
<< std::endl;
219
break
;
220
case
Undefined
:
221
os <<
"Undefined"
<< std::endl;
222
break
;
223
}
224
os << ind <<
" (Num calls,Mod test,State test): "
<<
"("
<<
numCalls_
<<
", "
<<
modTest_
<<
","
;
225
if
(
stateTest_
== 0) {
226
os <<
" none)"
<< std::endl;
227
}
228
else
{
229
if
(
stateTest_
&
Passed
) os <<
" Passed"
;
230
if
(
stateTest_
&
Failed
) os <<
" Failed"
;
231
if
(
stateTest_
&
Undefined
) os <<
" Undefined"
;
232
os <<
")"
<< std::endl;
233
}
234
// print child, with extra indention
235
test_
->print(os,indent+3);
236
}
237
239
240
private
:
241
Teuchos::RCP<OutputManager<ScalarType> >
printer_
;
242
Teuchos::RCP<StatusTest<ScalarType,MV,OP> >
test_
;
243
std::string
solverDesc_
;
244
std::string
precondDesc_
;
245
StatusType
state_
;
246
int
stateTest_
;
247
int
modTest_
;
248
int
numCalls_
;
249
};
250
251
}
// end of Belos namespace
252
253
#endif
/* BELOS_STATUS_TEST_OUTPUT_HPP */
BelosConfigDefs.hpp
Belos header file which uses auto-configuration information to include necessary C++ headers.
BelosIteration.hpp
Pure virtual base class which describes the basic interface to the linear solver iteration.
BelosOutputManager.hpp
Class which manages the output and verbosity of the Belos solvers.
BelosStatusTestOutput.hpp
Virtual base class for StatusTest that printing status tests.
BelosStatusTest.hpp
Pure virtual base class for defining the status testing capabilities of Belos.
BelosTypes.hpp
Collection of types and exceptions used within the Belos solvers.
Belos::Iteration
Definition
BelosIteration.hpp:73
Belos::OutputManager
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
Definition
BelosOutputManager.hpp:73
Belos::StatusTestError
Exception thrown to signal error in a status test during Belos::StatusTest::checkStatus().
Definition
BelosStatusTest.hpp:74
Belos::StatusTestGeneralOutput::getStatus
StatusType getStatus() const
Return the result of the most recent checkStatus call, or undefined if it has not been run.
Definition
BelosStatusTestGeneralOutput.hpp:146
Belos::StatusTestGeneralOutput::state_
StatusType state_
Definition
BelosStatusTestGeneralOutput.hpp:245
Belos::StatusTestGeneralOutput::resetNumCalls
void resetNumCalls()
Informs the outputting status test that it should reset the number of calls to zero.
Definition
BelosStatusTestGeneralOutput.hpp:202
Belos::StatusTestGeneralOutput::reset
void reset()
Informs the status test that it should reset its internal configuration to the uninitialized state.
Definition
BelosStatusTestGeneralOutput.hpp:195
Belos::StatusTestGeneralOutput::~StatusTestGeneralOutput
virtual ~StatusTestGeneralOutput()
Destructor.
Definition
BelosStatusTestGeneralOutput.hpp:105
Belos::StatusTestGeneralOutput::printer_
Teuchos::RCP< OutputManager< ScalarType > > printer_
Definition
BelosStatusTestGeneralOutput.hpp:241
Belos::StatusTestGeneralOutput::setOutputManager
void setOutputManager(const Teuchos::RCP< OutputManager< ScalarType > > &printer)
Set the output manager.
Definition
BelosStatusTestGeneralOutput.hpp:157
Belos::StatusTestGeneralOutput::solverDesc_
std::string solverDesc_
Definition
BelosStatusTestGeneralOutput.hpp:243
Belos::StatusTestGeneralOutput::precondDesc_
std::string precondDesc_
Definition
BelosStatusTestGeneralOutput.hpp:244
Belos::StatusTestGeneralOutput::modTest_
int modTest_
Definition
BelosStatusTestGeneralOutput.hpp:247
Belos::StatusTestGeneralOutput::checkStatus
StatusType checkStatus(Iteration< ScalarType, MV, OP > *solver)
Definition
BelosStatusTestGeneralOutput.hpp:127
Belos::StatusTestGeneralOutput::setOutputFrequency
void setOutputFrequency(int mod)
Set how often the child test is printed.
Definition
BelosStatusTestGeneralOutput.hpp:161
Belos::StatusTestGeneralOutput::test_
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test_
Definition
BelosStatusTestGeneralOutput.hpp:242
Belos::StatusTestGeneralOutput::getChild
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > getChild() const
Get child test.
Definition
BelosStatusTestGeneralOutput.hpp:173
Belos::StatusTestGeneralOutput::numCalls_
int numCalls_
Definition
BelosStatusTestGeneralOutput.hpp:248
Belos::StatusTestGeneralOutput::stateTest_
int stateTest_
Definition
BelosStatusTestGeneralOutput.hpp:246
Belos::StatusTestGeneralOutput::setChild
void setChild(Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
Set child test.
Definition
BelosStatusTestGeneralOutput.hpp:167
Belos::StatusTestGeneralOutput::StatusTestGeneralOutput
StatusTestGeneralOutput(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod=1, int printStates=Passed)
Constructor.
Definition
BelosStatusTestGeneralOutput.hpp:92
Belos::StatusTestGeneralOutput::setSolverDesc
void setSolverDesc(const std::string &solverDesc)
Set a short solver description for output clarity.
Definition
BelosStatusTestGeneralOutput.hpp:179
Belos::StatusTestGeneralOutput::print
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Definition
BelosStatusTestGeneralOutput.hpp:210
Belos::StatusTestGeneralOutput::setPrecondDesc
void setPrecondDesc(const std::string &precondDesc)
Set a short preconditioner description for output clarity.
Definition
BelosStatusTestGeneralOutput.hpp:183
Belos::StatusTestOutput::StatusTestOutput
StatusTestOutput()
Default constructor.
Definition
BelosStatusTestOutput.hpp:79
Belos::StatusTest
A pure virtual class for defining the status tests for the Belos iterative solvers.
Definition
BelosStatusTest.hpp:79
Belos
Definition
Belos_Details_EBelosSolverType.cpp:45
Belos::StatusTestDetails
@ StatusTestDetails
Definition
BelosTypes.hpp:261
Belos::Debug
@ Debug
Definition
BelosTypes.hpp:262
Belos::StatusType
StatusType
Whether the StatusTest wants iteration to stop.
Definition
BelosTypes.hpp:189
Belos::Failed
@ Failed
Definition
BelosTypes.hpp:190
Belos::Undefined
@ Undefined
Definition
BelosTypes.hpp:191
Belos::Passed
@ Passed
Definition
BelosTypes.hpp:189
Generated by
1.17.0