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
c196b700
Commit
c196b700
authored
10 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
Use a shared_ptr to store the matrix internally, instead of a reference
This makes the test compile and pass again.
parent
2202bcd2
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
+3
-3
3 additions, 3 deletions
dune/solvers/iterationsteps/cgstep.hh
with
6 additions
and
6 deletions
dune/solvers/iterationsteps/cgstep.cc
+
3
−
3
View file @
c196b700
...
@@ -9,10 +9,10 @@ template <class MatrixType, class VectorType>
...
@@ -9,10 +9,10 @@ template <class MatrixType, class VectorType>
void
CGStep
<
MatrixType
,
VectorType
>::
preprocess
()
void
CGStep
<
MatrixType
,
VectorType
>::
preprocess
()
{
{
// Compute the residual (r starts out as the rhs)
// Compute the residual (r starts out as the rhs)
matrix_
.
mmv
(
x_
,
r_
);
matrix_
->
mmv
(
x_
,
r_
);
if
(
preconditioner_
)
{
if
(
preconditioner_
)
{
preconditioner_
->
setMatrix
(
matrix_
);
preconditioner_
->
setMatrix
(
*
matrix_
);
preconditioner_
->
apply
(
p_
,
r_
);
preconditioner_
->
apply
(
p_
,
r_
);
}
else
}
else
p_
=
r_
;
p_
=
r_
;
...
@@ -25,7 +25,7 @@ void CGStep<MatrixType, VectorType>::iterate()
...
@@ -25,7 +25,7 @@ void CGStep<MatrixType, VectorType>::iterate()
{
{
VectorType
q
(
x_
);
VectorType
q
(
x_
);
matrix_
.
mv
(
p_
,
q
);
// q_0 = Ap_0
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
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
r_
.
axpy
(
-
alpha
,
q
);
// r_1 = r_0 - alpha_0 Ap_0
...
...
This diff is collapsed.
Click to expand it.
dune/solvers/iterationsteps/cgstep.hh
+
3
−
3
View file @
c196b700
...
@@ -19,7 +19,7 @@ namespace Dune {
...
@@ -19,7 +19,7 @@ namespace Dune {
CGStep
(
const
MatrixType
&
matrix
,
CGStep
(
const
MatrixType
&
matrix
,
VectorType
&
x
,
VectorType
&
x
,
const
VectorType
&
rhs
)
const
VectorType
&
rhs
)
:
p_
(
rhs
.
size
()),
r_
(
rhs
),
x_
(
x
),
matrix_
(
matrix
),
:
p_
(
rhs
.
size
()),
r_
(
rhs
),
x_
(
x
),
matrix_
(
stackobject_to_shared_ptr
(
matrix
)
)
,
preconditioner_
(
nullptr
)
preconditioner_
(
nullptr
)
{}
{}
...
@@ -34,7 +34,7 @@ namespace Dune {
...
@@ -34,7 +34,7 @@ namespace Dune {
//! Set linear operator, solution and right hand side
//! Set linear operator, solution and right hand side
virtual
void
setProblem
(
const
MatrixType
&
mat
,
VectorType
&
x
,
const
VectorType
&
rhs
)
virtual
void
setProblem
(
const
MatrixType
&
mat
,
VectorType
&
x
,
const
VectorType
&
rhs
)
{
{
matrix_
=
mat
;
matrix_
=
stackobject_to_shared_ptr
(
mat
)
;
x_
=
x
;
x_
=
x
;
r_
=
rhs
;
r_
=
rhs
;
}
}
...
@@ -49,7 +49,7 @@ namespace Dune {
...
@@ -49,7 +49,7 @@ namespace Dune {
VectorType
p_
;
// search direction
VectorType
p_
;
// search direction
VectorType
r_
;
// residual
VectorType
r_
;
// residual
VectorType
&
x_
;
VectorType
&
x_
;
const
MatrixType
&
matrix_
;
std
::
shared_ptr
<
const
MatrixType
>
matrix_
;
double
r_squared_old_
;
double
r_squared_old_
;
Preconditioner
<
MatrixType
,
VectorType
>*
preconditioner_
;
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