Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-solvers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
agnumpde
dune-solvers
Commits
6bc19aaf
Commit
6bc19aaf
authored
12 years ago
by
Uli Sack
Committed by
usack
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
* added some docu
* made the local solver exchangeable [[Imported from SVN: r7058]]
parent
84d8dd28
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/solvers/iterationsteps/truncatedblockgsstep.hh
+84
-8
84 additions, 8 deletions
dune/solvers/iterationsteps/truncatedblockgsstep.hh
with
84 additions
and
8 deletions
dune/solvers/iterationsteps/truncatedblockgsstep.hh
+
84
−
8
View file @
6bc19aaf
...
...
@@ -117,6 +117,14 @@ struct RecursiveGSStep<1>
}
// end namespace TruncatedBlockGSStepNS
/** \brief nonrecursive specialization of the TruncatedBlockGSStep
*
* \tparam SparseMatrixType the type of the sparse matrix in the SumOperator
* \tparam LowRankMatrixType the type of the lowrank matrix in the SumOperator
* \tparam VectorType the type of the solution vector
* \tparam BitVectorType the type of the truncation field
* \tparam localSolver static switch for local solver, see specializations of method localSolve
*/
template
<
class
SparseMatrixType
,
class
LowRankMatrixType
,
class
VectorType
,
class
BitVectorType
>
class
TruncatedBlockGSStep
<
SumOperator
<
SparseMatrixType
,
LowRankMatrixType
>
,
VectorType
,
BitVectorType
>
:
public
LinearIterationStep
<
SumOperator
<
SparseMatrixType
,
LowRankMatrixType
>
,
VectorType
,
BitVectorType
>
...
...
@@ -125,14 +133,22 @@ class TruncatedBlockGSStep<SumOperator<SparseMatrixType, LowRankMatrixType>, Vec
typedef
typename
VectorType
::
block_type
VectorBlock
;
typedef
typename
VectorType
::
field_type
field_type
;
typedef
typename
SparseMatrixType
::
block_type
SpBlock
;
typedef
typename
LowRankMatrixType
::
block_type
LRBlock
;
typedef
typename
StaticMatrix
::
Promote
<
SpBlock
,
LRBlock
>::
Type
MBlock
;
typedef
typename
VectorType
::
block_type
VBlock
;
public:
//! Default constructor. Doesn't init anything
TruncatedBlockGSStep
()
{}
TruncatedBlockGSStep
(
int
localSolver
=
0
)
:
localSolver
(
localSolver
)
{}
//! Constructor with a linear problem
TruncatedBlockGSStep
(
MatrixType
&
mat
,
VectorType
&
x
,
VectorType
&
rhs
)
:
LinearIterationStep
<
MatrixType
,
VectorType
>
(
mat
,
x
,
rhs
)
TruncatedBlockGSStep
(
MatrixType
&
mat
,
VectorType
&
x
,
VectorType
&
rhs
,
int
localSolver
=
0
)
:
LinearIterationStep
<
MatrixType
,
VectorType
>
(
mat
,
x
,
rhs
),
localSolver
(
localSolver
)
{}
virtual
VectorType
getSol
()
...
...
@@ -145,10 +161,6 @@ public:
{
typedef
typename
SparseMatrixType
::
row_type
::
ConstIterator
SparseMatrixColumnIterator
;
typedef
typename
LowRankMatrixType
::
LowRankFactorType
::
row_type
::
ConstIterator
LowRankFactorColumnIterator
;
typedef
typename
SparseMatrixType
::
block_type
SpBlock
;
typedef
typename
LowRankMatrixType
::
block_type
LRBlock
;
typedef
typename
StaticMatrix
::
Promote
<
SpBlock
,
LRBlock
>::
Type
MBlock
;
typedef
typename
VectorType
::
block_type
VBlock
;
const
MatrixType
&
mat
=
*
this
->
mat_
;
const
SparseMatrixType
&
sparse_mat
=
mat
.
sparseMatrix
();
...
...
@@ -200,11 +212,12 @@ public:
// "solve" Local system by one GS step
// if (Aii!=0)
#if 0
{
for(typename MBlock::size_type i=0; i<Aii.N(); ++i)
{
const typename MBlock::field_type& aii = Aii[i][i];
if
(
aii
>
0
)
if (
fabs(aii)>1e-13
)
{
if (not(ignore[row][i]))
{
...
...
@@ -219,6 +232,12 @@ public:
}
}
}
#endif
if
(
localSolver
==
1
)
localExactSolve
(
Aii
,
r
,
x
[
row
],
ignore
[
row
]);
else
localGSSolve
(
Aii
,
r
,
x
[
row
],
ignore
[
row
]);
// update the mx
for
(
typename
LowRankMatrixType
::
size_type
k
=
0
;
k
<
lowrank_mat
.
lowRankFactor
().
N
();
++
k
)
...
...
@@ -228,6 +247,63 @@ public:
}
}
}
private
:
int
localSolver
;
/** \brief solve method for local problems
*
* This version "solves" by one GS step.
* This is the "default" behaviour
*/
void
localGSSolve
(
MBlock
&
A
,
VBlock
&
b
,
VBlock
&
x
,
typename
BitVectorType
::
const_reference
ignore
)
{
for
(
typename
MBlock
::
size_type
i
=
0
;
i
<
A
.
N
();
++
i
)
{
const
typename
MBlock
::
field_type
&
aii
=
A
[
i
][
i
];
if
(
fabs
(
aii
)
>
1e-13
)
{
if
(
not
(
ignore
[
i
]))
{
x
[
i
]
=
b
[
i
];
typename
MBlock
::
row_type
::
Iterator
inner_it
=
A
[
i
].
begin
();
typename
MBlock
::
row_type
::
Iterator
inner_end
=
A
[
i
].
end
();
for
(;
inner_it
!=
inner_end
;
++
inner_it
)
if
(
inner_it
.
index
()
!=
i
)
x
[
i
]
-=
(
*
inner_it
)
*
x
[
inner_it
.
index
()];
x
[
i
]
/=
aii
;
}
}
}
}
/** \brief solve method for local problems
*
* uses the solve method of FieldMatrix
*/
void
localExactSolve
(
MBlock
&
A
,
VBlock
&
b
,
VBlock
&
x
,
typename
BitVectorType
::
const_reference
ignore
)
{
for
(
typename
MBlock
::
size_type
i
=
0
;
i
<
A
.
N
();
++
i
)
{
if
(
ignore
[
i
])
{
A
[
i
]
=
0.0
;
}
typename
MBlock
::
row_type
::
Iterator
inner_it
=
A
[
i
].
begin
();
typename
MBlock
::
row_type
::
Iterator
inner_end
=
A
[
i
].
end
();
for
(;
inner_it
!=
inner_end
;
++
inner_it
)
if
(
inner_it
.
index
()
==
i
and
*
inner_it
==
0.0
)
{
*
inner_it
=
1.0
;
b
[
i
]
=
x
[
i
];
}
}
A
.
solve
(
x
,
b
);
}
};
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment