Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
getdp
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
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
getdp
getdp
Commits
6362d277
Commit
6362d277
authored
5 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Plain Diff
Merge branch 'fixResiduJacobi' into 'master'
Fix residu jacobi See merge request
!69
parents
1d8d7f9c
bc330a8b
No related branches found
No related tags found
1 merge request
!69
Fix residu jacobi
Pipeline
#4792
passed with warnings
5 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Kernel/Operation_IterativeLinearSolver.cpp
+14
-2
14 additions, 2 deletions
Kernel/Operation_IterativeLinearSolver.cpp
with
14 additions
and
2 deletions
Kernel/Operation_IterativeLinearSolver.cpp
+
14
−
2
View file @
6362d277
...
@@ -917,13 +917,20 @@ static PetscErrorCode PrintVec(Vec b, const char* filename, const char* varname)
...
@@ -917,13 +917,20 @@ static PetscErrorCode PrintVec(Vec b, const char* filename, const char* varname)
static
PetscErrorCode
Jacobi_Solver
(
Mat
A
,
Vec
X
,
Vec
B
,
double
Tol
,
int
MaxIter
)
static
PetscErrorCode
Jacobi_Solver
(
Mat
A
,
Vec
X
,
Vec
B
,
double
Tol
,
int
MaxIter
)
{
{
Vec
X_old
,
W
;
Vec
X_old
,
W
;
double
residu
;
double
residu
,
residuInit
;
_try
(
VecSet
(
X
,
0.
));
_try
(
VecSet
(
X
,
0.
));
_try
(
VecDuplicate
(
X
,
&
X_old
));
_try
(
VecDuplicate
(
X
,
&
X_old
));
_try
(
VecDuplicate
(
X
,
&
W
));
_try
(
VecDuplicate
(
X
,
&
W
));
_try
(
VecCopy
(
X
,
W
));
_try
(
VecCopy
(
X
,
W
));
_try
(
VecNorm
(
B
,
NORM_2
,
&
residuInit
));
Message
::
Info
(
3
,
"Jacobi initial residual %g"
,
residuInit
);
Current
.
Iteration
=
0
;
Current
.
KSPIteration
=
0
;
Current
.
Residual
=
residuInit
;
Current
.
KSPResidual
=
residuInit
;
for
(
int
j
=
1
;
j
<
MaxIter
;
j
++
){
for
(
int
j
=
1
;
j
<
MaxIter
;
j
++
){
_try
(
VecCopy
(
X
,
X_old
));
_try
(
VecCopy
(
X
,
X_old
));
_try
(
MatMultILSMat
(
A
,
X_old
,
X
));
_try
(
MatMultILSMat
(
A
,
X_old
,
X
));
...
@@ -932,7 +939,12 @@ static PetscErrorCode Jacobi_Solver(Mat A, Vec X, Vec B, double Tol, int MaxIter
...
@@ -932,7 +939,12 @@ static PetscErrorCode Jacobi_Solver(Mat A, Vec X, Vec B, double Tol, int MaxIter
_try
(
VecWAXPY
(
W
,
-
1.
,
X_old
,
X
));
//W = X-X_old
_try
(
VecWAXPY
(
W
,
-
1.
,
X_old
,
X
));
//W = X-X_old
_try
(
VecNorm
(
W
,
NORM_2
,
&
residu
));
_try
(
VecNorm
(
W
,
NORM_2
,
&
residu
));
Message
::
Info
(
3
,
"Jacobi iteration %d residual %g"
,
j
,
residu
);
Message
::
Info
(
3
,
"Jacobi iteration %d residual %g"
,
j
,
residu
);
if
(
residu
<
Tol
)
break
;
Current
.
Iteration
=
j
;
Current
.
KSPIteration
=
j
;
Current
.
Residual
=
residu
;
Current
.
KSPResidual
=
residu
;
if
(
residu
/
residuInit
<
Tol
)
break
;
}
}
PetscFunctionReturn
(
0
);
PetscFunctionReturn
(
0
);
}
}
...
...
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