dune-istl
2.3beta2
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
istl
solver.hh
Go to the documentation of this file.
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=4 sw=2 sts=2:
3
4
#ifndef DUNE_ISTL_SOLVER_HH
5
#define DUNE_ISTL_SOLVER_HH
6
7
#include <iomanip>
8
#include <ostream>
9
10
namespace
Dune
11
{
31
struct
InverseOperatorResult
32
{
34
InverseOperatorResult
()
35
{
36
clear
();
37
}
38
40
void
clear
()
41
{
42
iterations
= 0;
43
reduction
= 0;
44
converged
=
false
;
45
conv_rate
= 1;
46
elapsed
= 0;
47
}
48
50
int
iterations
;
51
53
double
reduction
;
54
56
bool
converged
;
57
59
double
conv_rate
;
60
62
double
elapsed
;
63
};
64
65
66
//=====================================================================
78
template
<
class
X,
class
Y>
79
class
InverseOperator
{
80
public
:
82
typedef
X
domain_type
;
83
85
typedef
Y
range_type
;
86
88
typedef
typename
X::field_type
field_type
;
89
99
virtual
void
apply
(X& x, Y& b,
InverseOperatorResult
& res) = 0;
100
111
virtual
void
apply
(X& x, Y& b,
double
reduction,
InverseOperatorResult
& res) = 0;
112
114
virtual
~InverseOperator
() {}
115
116
protected
:
117
// spacing values
118
enum
{
iterationSpacing
= 5 ,
normSpacing
= 16 };
119
121
void
printHeader
(std::ostream& s)
const
122
{
123
s << std::setw(
iterationSpacing
) <<
" Iter"
;
124
s << std::setw(
normSpacing
) <<
"Defect"
;
125
s << std::setw(
normSpacing
) <<
"Rate"
<< std::endl;
126
}
127
129
template
<
class
DataType>
130
void
printOutput
(std::ostream& s,
131
const
double
iter,
132
const
DataType& norm,
133
const
DataType& norm_old)
const
134
{
135
const
DataType rate = norm/norm_old;
136
s << std::setw(
iterationSpacing
) << iter <<
" "
;
137
s << std::setw(
normSpacing
) << norm <<
" "
;
138
s << std::setw(
normSpacing
) << rate << std::endl;
139
}
140
142
template
<
class
DataType>
143
void
printOutput
(std::ostream& s,
144
const
double
iter,
145
const
DataType& norm)
const
146
{
147
s << std::setw(
iterationSpacing
) << iter <<
" "
;
148
s << std::setw(
normSpacing
) << norm << std::endl;
149
}
150
};
151
155
}
156
157
#endif
Generated on Mon Feb 10 2014 21:15:21 for dune-istl by
1.8.1.2