Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Core Modules
dune-istl
Commits
1098cc77
Commit
1098cc77
authored
19 years ago
by
Peter Bastian
Browse files
Options
Downloads
Patches
Plain Diff
restructured CG
[[Imported from SVN: r412]]
parent
e69aaca6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
istl/solvers.hh
+27
-11
27 additions, 11 deletions
istl/solvers.hh
with
27 additions
and
11 deletions
istl/solvers.hh
+
27
−
11
View file @
1098cc77
...
...
@@ -458,8 +458,8 @@ namespace Dune {
_prec
.
pre
(
x
,
b
);
// prepare preconditioner
_op
.
applyscaleadd
(
-
1
,
x
,
b
);
// overwrite b with defect
X
p
(
x
);
//
create local vectors
X
q
(
b
);
X
p
(
x
.
size
());
//
the search direction
X
q
(
x
.
size
());
// a temporary vector
double
def0
=
_sp
.
norm
(
b
);
// compute norm
if
(
def0
<
1E-30
)
// convergence check
...
...
@@ -481,20 +481,27 @@ namespace Dune {
if
(
_verbose
>
1
)
printf
(
"%5d %12.4E
\n
"
,
0
,
def0
);
}
int
i
=
1
;
double
def
=
def0
;
// loop variables
field_type
rho
,
rholast
,
lambda
;
// some local variables
double
def
=
def0
;
// loop variables
field_type
rho
,
rholast
,
lambda
,
alpha
,
beta
;
// determine initial search direction
p
=
0
;
// clear correction
_prec
.
apply
(
p
,
b
);
// apply preconditioner
rholast
=
_sp
.
dot
(
p
,
b
);
// orthogonalization
// the loop
int
i
=
1
;
for
(
;
i
<=
_maxit
;
i
++
)
{
p
=
0
;
// clear correction
_prec
.
apply
(
p
,
b
);
// apply preconditioner
rho
=
_sp
.
dot
(
p
,
b
);
// orthogonalization
if
(
i
>
1
)
p
.
axpy
(
rho
/
rholast
,
q
);
rholast
=
rho
;
// remember rho for recurrence
// minimize in given search direction p
_op
.
apply
(
p
,
q
);
// q=Ap
lambda
=
rho
/
_sp
.
dot
(
q
,
p
);
// minimization
alpha
=
_sp
.
dot
(
q
,
p
);
// scalar product
lambda
=
rholast
/
alpha
;
// minimization
x
.
axpy
(
lambda
,
p
);
// update solution
b
.
axpy
(
-
lambda
,
q
);
// update defect
q
=
p
;
// remember search direction
// convergence test
double
defnew
=
_sp
.
norm
(
b
);
// comp defect norm
if
(
_verbose
>
1
)
// print
printf
(
"%5d %12.4E %12.4g
\n
"
,
i
,
defnew
,
defnew
/
def
);
...
...
@@ -504,6 +511,15 @@ namespace Dune {
r
.
converged
=
true
;
break
;
}
// determine new search direction
q
=
0
;
// clear correction
_prec
.
apply
(
q
,
b
);
// apply preconditioner
rho
=
_sp
.
dot
(
q
,
b
);
// orthogonalization
beta
=
rho
/
rholast
;
// scaling factor
p
*=
beta
;
// scale old search direction
p
+=
q
;
// orthogonalization with correction
rholast
=
rho
;
// remember rho for recurrence
}
if
(
_verbose
==
1
)
// printing for non verbose
...
...
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