Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
agnumpde
dune-solvers
Commits
ba1f9b59
Commit
ba1f9b59
authored
Sep 24, 2014
by
Carsten Gräser
Browse files
Merge master to new_interface branch
Merge branch 'master' into new_interface
parents
b4094424
6087f6d4
Changes
10
Hide whitespace changes
Inline
Side-by-side
TODO
View file @
ba1f9b59
...
...
@@ -65,8 +65,6 @@ and maintain.
## Naming of classes and members
* ignoreNodes_ should be called ignore_/ignoreIndices_/ignoreComponents_
* In some classes the type of the matrix is called 'OperatorType'.
This is old 'dune-fem speak', and should be replaced by 'MatrixType'.
...
...
dune/solvers/common/arithmetic.hh
View file @
ba1f9b59
...
...
@@ -490,12 +490,12 @@ namespace Arithmetic
/** \brief Internal helper class for Matrix operations
*
*/
template
<
class
Operator
Type
,
bool
isMatrix
>
template
<
class
Matrix
Type
,
bool
isMatrix
>
struct
OperatorHelper
{
template
<
class
VectorType
>
static
typename
VectorType
::
field_type
Axy
(
const
Operator
Type
&
A
,
Axy
(
const
Matrix
Type
&
A
,
const
VectorType
&
x
,
const
VectorType
&
y
)
{
...
...
@@ -507,7 +507,7 @@ namespace Arithmetic
template
<
class
VectorType
>
static
typename
VectorType
::
field_type
bmAxy
(
const
Operator
Type
&
A
,
const
VectorType
&
b
,
bmAxy
(
const
Matrix
Type
&
A
,
const
VectorType
&
b
,
const
VectorType
&
x
,
const
VectorType
&
y
)
{
VectorType
tmp
=
b
;
...
...
@@ -569,26 +569,26 @@ namespace Arithmetic
};
//! Compute \f$(Ax,y)\f$
template
<
class
Operator
Type
,
class
VectorType
>
template
<
class
Matrix
Type
,
class
VectorType
>
typename
VectorType
::
field_type
Axy
(
const
Operator
Type
&
A
,
Axy
(
const
Matrix
Type
&
A
,
const
VectorType
&
x
,
const
VectorType
&
y
)
{
return
OperatorHelper
<
Operator
Type
,
MatrixTraits
<
Operator
Type
>::
isMatrix
>::
Axy
(
A
,
x
,
y
);
return
OperatorHelper
<
Matrix
Type
,
MatrixTraits
<
Matrix
Type
>::
isMatrix
>::
Axy
(
A
,
x
,
y
);
}
//! Compute \f$(b-Ax,y)\f$
template
<
class
Operator
Type
,
class
VectorType
>
template
<
class
Matrix
Type
,
class
VectorType
>
typename
VectorType
::
field_type
bmAxy
(
const
Operator
Type
&
A
,
bmAxy
(
const
Matrix
Type
&
A
,
const
VectorType
&
b
,
const
VectorType
&
x
,
const
VectorType
&
y
)
{
return
OperatorHelper
<
Operator
Type
,
MatrixTraits
<
Operator
Type
>::
isMatrix
>::
bmAxy
(
A
,
b
,
x
,
y
);
return
OperatorHelper
<
Matrix
Type
,
MatrixTraits
<
Matrix
Type
>::
isMatrix
>::
bmAxy
(
A
,
b
,
x
,
y
);
}
}
...
...
dune/solvers/iterationsteps/blockgsstep.cc
View file @
ba1f9b59
...
...
@@ -3,21 +3,21 @@
#include
<cassert>
template
<
class
Operator
Type
,
class
DiscFuncType
,
class
BitVectorType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
>
inline
DiscFuncType
BlockGSStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>::
getSol
()
DiscFuncType
BlockGSStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>::
getSol
()
{
return
*
(
this
->
x_
);
}
template
<
class
Operator
Type
,
class
DiscFuncType
,
class
BitVectorType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
>
inline
void
BlockGSStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>::
void
BlockGSStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>::
residual
(
int
index
,
VectorBlock
&
r
)
const
{
const
Operator
Type
&
mat
=
*
this
->
mat_
;
const
Matrix
Type
&
mat
=
*
this
->
mat_
;
typedef
typename
Operator
Type
::
row_type
RowType
;
typedef
typename
Matrix
Type
::
row_type
RowType
;
const
RowType
&
row
=
mat
[
index
];
typedef
typename
RowType
::
ConstIterator
ColumnIterator
;
...
...
@@ -37,11 +37,11 @@ residual(int index, VectorBlock& r) const
}
template
<
class
Operator
Type
,
class
DiscFuncType
,
class
BitVectorType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
>
inline
void
BlockGSStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>::
iterate
()
void
BlockGSStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>::
iterate
()
{
const
Operator
Type
&
mat
=
*
this
->
mat_
;
const
Matrix
Type
&
mat
=
*
this
->
mat_
;
assert
(
this
->
ignoreNodes_
!=
NULL
);
for
(
size_t
i
=
0
;
i
<
this
->
x_
->
size
();
i
++
)
{
...
...
@@ -62,7 +62,7 @@ void BlockGSStep<OperatorType, DiscFuncType, BitVectorType>::iterate()
}
else
{
// Copy the matrix and adjust rhs and matrix so that dofs given in ignoreNodes[i]
// are not touched
typename
Operator
Type
::
block_type
matRes
;
typename
Matrix
Type
::
block_type
matRes
;
for
(
int
j
=
0
;
j
<
BlockSize
;
++
j
)
{
if
((
*
this
->
ignoreNodes_
)[
i
][
j
])
{
r
[
j
]
=
0
;
...
...
dune/solvers/iterationsteps/blockgsstep.hh
View file @
ba1f9b59
...
...
@@ -9,15 +9,15 @@
/** \brief A linear Gauß-Seidel iteration step for convex problems which have a block-structure.
*
* \tparam
Operator
Type The linear operator type
* \tparam
Matrix
Type The linear operator type
* \tparam DiscFuncType The block vector type of the right hand side and the iterates
* \tparam BitVectorType The type of the bit-vector specifying degrees of freedom that shall be ignored.
*
*/
template
<
class
Operator
Type
,
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
=
Dune
::
BitSetVector
<
DiscFuncType
::
block_type
::
dimension
>
>
class
BlockGSStep
:
public
LinearIterationStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>
class
BlockGSStep
:
public
LinearIterationStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>
{
typedef
typename
DiscFuncType
::
block_type
VectorBlock
;
...
...
@@ -30,8 +30,8 @@ template<class OperatorType,
BlockGSStep
()
{}
//! Constructor with a linear problem
BlockGSStep
(
const
Operator
Type
&
mat
,
DiscFuncType
&
x
,
const
DiscFuncType
&
rhs
)
:
LinearIterationStep
<
Operator
Type
,
DiscFuncType
>
(
mat
,
x
,
rhs
)
BlockGSStep
(
const
Matrix
Type
&
mat
,
DiscFuncType
&
x
,
const
DiscFuncType
&
rhs
)
:
LinearIterationStep
<
Matrix
Type
,
DiscFuncType
>
(
mat
,
x
,
rhs
)
{}
//! Perform one iteration
...
...
dune/solvers/iterationsteps/linegsstep.cc
View file @
ba1f9b59
...
...
@@ -3,9 +3,9 @@
#include
<dune/istl/btdmatrix.hh>
#include
<dune/istl/scaledidmatrix.hh>
template
<
class
Operator
Type
,
class
DiscFuncType
,
class
BitVectorType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
>
inline
DiscFuncType
LineGSStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>::
getSol
()
DiscFuncType
LineGSStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>::
getSol
()
{
return
*
(
this
->
x_
);
...
...
@@ -13,13 +13,13 @@ DiscFuncType LineGSStep<OperatorType, DiscFuncType, BitVectorType>::getSol()
}
template
<
class
Operator
Type
,
class
DiscFuncType
,
class
BitVectorType
>
void
LineGSStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>::
iterate
()
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
>
void
LineGSStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>::
iterate
()
{
// input of this method: x^(k) (not the permuted version of x^(k)!)
const
Operator
Type
&
mat
=
*
this
->
mat_
;
const
Matrix
Type
&
mat
=
*
this
->
mat_
;
int
number_of_blocks
=
blockStructure_
.
size
();
...
...
@@ -53,7 +53,7 @@ void LineGSStep<OperatorType, DiscFuncType, BitVectorType >::iterate()
// Copy the linear system for the current line/block into a tridiagonal matrix
// //////////////////////////////////////////////////////////////////////////////////////////////////
Dune
::
BTDMatrix
<
typename
Operator
Type
::
block_type
>
tridiagonalMatrix
(
current_block_size
);
Dune
::
BTDMatrix
<
typename
Matrix
Type
::
block_type
>
tridiagonalMatrix
(
current_block_size
);
for
(
int
j
=
0
;
j
<
current_block_size
;
j
++
)
{
...
...
dune/solvers/iterationsteps/linegsstep.hh
View file @
ba1f9b59
...
...
@@ -7,10 +7,10 @@
#include
<dune/solvers/iterationsteps/blockgsstep.hh>
template
<
class
Operator
Type
,
template
<
class
Matrix
Type
,
class
DiscFuncType
,
class
BitVectorType
=
Dune
::
BitSetVector
<
DiscFuncType
::
block_type
::
dimension
>
>
class
LineGSStep
:
public
BlockGSStep
<
Operator
Type
,
DiscFuncType
,
BitVectorType
>
class
LineGSStep
:
public
BlockGSStep
<
Matrix
Type
,
DiscFuncType
,
BitVectorType
>
{
typedef
typename
DiscFuncType
::
block_type
VectorBlock
;
...
...
@@ -33,8 +33,8 @@ template<class OperatorType,
{}
//! Constructor with a linear problem
LineGSStep
(
const
Operator
Type
&
mat
,
DiscFuncType
&
x
,
DiscFuncType
&
rhs
)
:
BlockGSStep
<
Operator
Type
,
DiscFuncType
>
(
mat
,
x
,
rhs
)
LineGSStep
(
const
Matrix
Type
&
mat
,
DiscFuncType
&
x
,
DiscFuncType
&
rhs
)
:
BlockGSStep
<
Matrix
Type
,
DiscFuncType
>
(
mat
,
x
,
rhs
)
{}
//! Perform one iteration
...
...
dune/solvers/iterationsteps/projectedblockgsstep.cc
View file @
ba1f9b59
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=8 sw=4 sts=4:
template
<
class
Operator
Type
,
class
DiscFuncType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
>
inline
DiscFuncType
ProjectedBlockGSStep
<
Operator
Type
,
DiscFuncType
>::
getSol
()
DiscFuncType
ProjectedBlockGSStep
<
Matrix
Type
,
DiscFuncType
>::
getSol
()
{
return
*
(
this
->
x_
);
}
template
<
class
Operator
Type
,
class
DiscFuncType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
>
inline
void
ProjectedBlockGSStep
<
Operator
Type
,
DiscFuncType
>::
iterate
()
void
ProjectedBlockGSStep
<
Matrix
Type
,
DiscFuncType
>::
iterate
()
{
if
(
hasObstacle_
->
size
()
!=
(
unsigned
int
)
this
->
x_
->
size
())
DUNE_THROW
(
SolverError
,
"Size of hasObstacle ("
<<
hasObstacle_
->
size
()
<<
") doesn't match solution vector ("
<<
this
->
x_
->
size
()
<<
")"
);
const
Operator
Type
&
mat
=
*
this
->
mat_
;
const
Matrix
Type
&
mat
=
*
this
->
mat_
;
for
(
size_t
i
=
0
;
i
<
this
->
x_
->
size
();
i
++
)
{
...
...
dune/solvers/iterationsteps/projectedblockgsstep.hh
View file @
ba1f9b59
...
...
@@ -8,8 +8,8 @@
#include
"blockgsstep.hh"
#include
<dune/solvers/common/boxconstraint.hh>
template
<
class
Operator
Type
,
class
DiscFuncType
>
class
ProjectedBlockGSStep
:
public
BlockGSStep
<
Operator
Type
,
DiscFuncType
>
template
<
class
Matrix
Type
,
class
DiscFuncType
>
class
ProjectedBlockGSStep
:
public
BlockGSStep
<
Matrix
Type
,
DiscFuncType
>
{
typedef
typename
DiscFuncType
::
block_type
VectorBlock
;
...
...
@@ -24,8 +24,8 @@ public:
ProjectedBlockGSStep
()
{}
//! Constructor with a linear problem
ProjectedBlockGSStep
(
const
Operator
Type
&
mat
,
DiscFuncType
&
x
,
const
DiscFuncType
&
rhs
)
:
BlockGSStep
<
Operator
Type
,
DiscFuncType
>
(
mat
,
x
,
rhs
)
ProjectedBlockGSStep
(
const
Matrix
Type
&
mat
,
DiscFuncType
&
x
,
const
DiscFuncType
&
rhs
)
:
BlockGSStep
<
Matrix
Type
,
DiscFuncType
>
(
mat
,
x
,
rhs
)
{}
//! Perform one iteration
...
...
dune/solvers/norms/energynorm.hh
View file @
ba1f9b59
...
...
@@ -25,7 +25,7 @@
*
* \todo Elaborate documentation.
*/
template
<
class
Operator
Type
,
class
V
>
template
<
class
Matrix
Type
,
class
V
>
class
EnergyNorm
:
public
Norm
<
V
>
{
public:
...
...
@@ -36,19 +36,19 @@
EnergyNorm
(
const
double
tol
=
1e-10
)
:
iterationStep_
(
NULL
),
matrix_
(
NULL
),
tol_
(
tol
)
{}
EnergyNorm
(
LinearIterationStep
<
Operator
Type
,
VectorType
>&
it
,
const
double
tol
=
1e-10
)
EnergyNorm
(
LinearIterationStep
<
Matrix
Type
,
VectorType
>&
it
,
const
double
tol
=
1e-10
)
:
iterationStep_
(
&
it
),
matrix_
(
NULL
),
tol_
(
tol
)
{}
EnergyNorm
(
const
Operator
Type
&
matrix
,
const
double
tol
=
1e-10
)
EnergyNorm
(
const
Matrix
Type
&
matrix
,
const
double
tol
=
1e-10
)
:
iterationStep_
(
NULL
),
matrix_
(
&
matrix
),
tol_
(
tol
)
{}
void
setMatrix
(
const
Operator
Type
*
matrix
)
{
void
setMatrix
(
const
Matrix
Type
*
matrix
)
{
matrix_
=
matrix
;
}
void
setIterationStep
(
LinearIterationStep
<
Operator
Type
,
VectorType
>*
iterationStep
)
{
void
setIterationStep
(
LinearIterationStep
<
Matrix
Type
,
VectorType
>*
iterationStep
)
{
iterationStep_
=
iterationStep
;
}
...
...
@@ -74,7 +74,7 @@
if
(
iterationStep_
==
NULL
&&
matrix_
==
NULL
)
DUNE_THROW
(
Dune
::
Exception
,
"You have supplied neither a matrix nor an IterationStep to the EnergyNorm!"
);
const
Operator
Type
&
A
=
(
iterationStep_
)
const
Matrix
Type
&
A
=
(
iterationStep_
)
?
*
(
iterationStep_
->
getMatrix
())
:
*
matrix_
;
...
...
@@ -92,7 +92,7 @@
// \brief Compute the squared norm for a given vector and matrix
DUNE_DEPRECATED
static
field_type
normSquared
(
const
VectorType
&
u
,
const
Operator
Type
&
A
,
const
Matrix
Type
&
A
,
const
double
tol
=
1e-10
)
{
const
field_type
ret
=
Arithmetic
::
Axy
(
A
,
u
,
u
);
...
...
@@ -110,9 +110,9 @@
protected:
LinearIterationStep
<
Operator
Type
,
VectorType
>*
iterationStep_
;
LinearIterationStep
<
Matrix
Type
,
VectorType
>*
iterationStep_
;
const
Operator
Type
*
matrix_
;
const
Matrix
Type
*
matrix_
;
const
double
tol_
;
...
...
dune/solvers/norms/pnorm.hh
View file @
ba1f9b59
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=8 sw=4 sts=4:
#ifndef
_
_PNORM_
_
HH
__
#define
_
_PNORM_
_
HH
__
#ifndef
DUNE_SOLVERS
_PNORM_HH
#define
DUNE_SOLVERS
_PNORM_HH
#include
<cmath>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment