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
11c14160
Commit
11c14160
authored
9 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Use x_ from the base class
parent
d9b3e85f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/solvers/iterationsteps/cgstep.cc
+3
-3
3 additions, 3 deletions
dune/solvers/iterationsteps/cgstep.cc
dune/solvers/iterationsteps/cgstep.hh
+7
-5
7 additions, 5 deletions
dune/solvers/iterationsteps/cgstep.hh
with
10 additions
and
8 deletions
dune/solvers/iterationsteps/cgstep.cc
+
3
−
3
View file @
11c14160
...
...
@@ -12,7 +12,7 @@ template <class MatrixType, class VectorType>
void
CGStep
<
MatrixType
,
VectorType
>::
preprocess
()
{
// Compute the residual (r starts out as the rhs)
matrix_
->
mmv
(
x_
,
r_
);
matrix_
->
mmv
(
*
x_
,
r_
);
if
(
preconditioner_
)
{
preconditioner_
->
setMatrix
(
*
matrix_
);
...
...
@@ -26,11 +26,11 @@ void CGStep<MatrixType, VectorType>::preprocess()
template
<
class
MatrixType
,
class
VectorType
>
void
CGStep
<
MatrixType
,
VectorType
>::
iterate
()
{
VectorType
q
(
x_
);
VectorType
q
(
*
x_
);
matrix_
->
mv
(
p_
,
q
);
// q_0 = Ap_0
const
double
alpha
=
r_squared_old_
/
(
p_
*
q
);
// alpha_0 = r_0*r_0/p_0*Ap_0
x_
.
axpy
(
alpha
,
p_
);
// x_1 = x_0 + alpha_0 p_0
x_
->
axpy
(
alpha
,
p_
);
// x_1 = x_0 + alpha_0 p_0
r_
.
axpy
(
-
alpha
,
q
);
// r_1 = r_0 - alpha_0 Ap_0
if
(
preconditioner_
)
...
...
This diff is collapsed.
Click to expand it.
dune/solvers/iterationsteps/cgstep.hh
+
7
−
5
View file @
11c14160
...
...
@@ -13,6 +13,8 @@ namespace Dune {
template
<
class
MatrixType
,
class
VectorType
>
class
CGStep
:
public
IterationStep
<
VectorType
>
{
using
Base
=
IterationStep
<
VectorType
>
;
public:
CGStep
()
:
preconditioner_
(
nullptr
)
...
...
@@ -21,7 +23,7 @@ namespace Dune {
CGStep
(
const
MatrixType
&
matrix
,
VectorType
&
x
,
const
VectorType
&
rhs
)
:
p_
(
rhs
.
size
()),
r_
(
rhs
),
x_
(
x
),
matrix_
(
stackobject_to_shared_ptr
(
matrix
)),
:
Base
(
x
),
p_
(
rhs
.
size
()),
r_
(
rhs
),
matrix_
(
stackobject_to_shared_ptr
(
matrix
)),
preconditioner_
(
nullptr
)
{}
...
...
@@ -29,7 +31,7 @@ namespace Dune {
VectorType
&
x
,
const
VectorType
&
rhs
,
Preconditioner
<
MatrixType
,
VectorType
>&
preconditioner
)
:
p_
(
rhs
.
size
()),
r_
(
rhs
),
x_
(
x
),
matrix_
(
matrix
),
:
Base
(
x
),
p_
(
rhs
.
size
()),
r_
(
rhs
),
matrix_
(
matrix
),
preconditioner_
(
&
preconditioner
)
{}
...
...
@@ -37,7 +39,7 @@ namespace Dune {
virtual
void
setProblem
(
const
MatrixType
&
mat
,
VectorType
&
x
,
const
VectorType
&
rhs
)
{
matrix_
=
stackobject_to_shared_ptr
(
mat
);
x_
=
x
;
x_
=
&
x
;
r_
=
rhs
;
}
...
...
@@ -45,12 +47,12 @@ namespace Dune {
void
preprocess
();
void
iterate
();
// Q: do we really want this interface?
VectorType
getSol
()
{
return
x_
;
}
VectorType
getSol
()
{
return
*
x_
;
}
private
:
VectorType
p_
;
// search direction
VectorType
r_
;
// residual
VectorType
&
x_
;
using
Base
::
x_
;
std
::
shared_ptr
<
const
MatrixType
>
matrix_
;
double
r_squared_old_
;
Preconditioner
<
MatrixType
,
VectorType
>*
preconditioner_
;
...
...
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