Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
ee1b52d3
There was an error fetching the commit references. Please try again later.
Commit
ee1b52d3
authored
9 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Fixing the TFQMR solver.
parent
8b0a59cb
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
src/solvers/linear/krylov/tnlTFQMRSolver.h
+1
-1
1 addition, 1 deletion
src/solvers/linear/krylov/tnlTFQMRSolver.h
src/solvers/linear/krylov/tnlTFQMRSolver_impl.h
+16
-26
16 additions, 26 deletions
src/solvers/linear/krylov/tnlTFQMRSolver_impl.h
with
17 additions
and
27 deletions
src/solvers/linear/krylov/tnlTFQMRSolver.h
+
1
−
1
View file @
ee1b52d3
...
...
@@ -75,7 +75,7 @@ class tnlTFQMRSolver : public tnlObject,
bool
setSize
(
IndexType
size
);
tnlVector
<
RealType
,
Device
,
IndexType
>
d
,
r
,
w
,
u
,
v
,
r_ast
,
u
_new
,
Au
,
Au_new
;
tnlVector
<
RealType
,
Device
,
IndexType
>
d
,
r
,
w
,
u
,
v
,
r_ast
,
A
u
;
const
MatrixType
*
matrix
;
const
PreconditionerType
*
preconditioner
;
...
...
This diff is collapsed.
Click to expand it.
src/solvers/linear/krylov/tnlTFQMRSolver_impl.h
+
16
−
26
View file @
ee1b52d3
...
...
@@ -36,10 +36,9 @@ template< typename Matrix,
typename
Preconditioner
>
tnlString
tnlTFQMRSolver
<
Matrix
,
Preconditioner
>
::
getType
()
const
{
/*return tnlString( "tnlTFQMRSolver< " ) +
tnlString( getType< RealType >() + ", " +
Device :: getDeviceType() + ", " +
tnlString( getType< RealType >() + " >";*/
return
tnlString
(
"tnlTFQMRSolver< "
)
+
this
->
matrix
->
getType
()
+
", "
+
this
->
preconditioner
->
getType
()
+
" >"
;
}
template
<
typename
Matrix
,
...
...
@@ -84,9 +83,6 @@ bool tnlTFQMRSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector&
dbgFunctionName
(
"tnlTFQMRSolver"
,
"Solve"
);
if
(
!
this
->
setSize
(
matrix
->
getRows
()
)
)
return
false
;
this
->
resetIterations
();
this
->
setResidue
(
this
->
getConvergenceResidue
()
+
1.0
);
RealType
tau
,
theta
,
eta
,
rho
,
alpha
,
w_norm
;
RealType
b_norm
=
b
.
lpNorm
(
2.0
);
if
(
b_norm
==
0.0
)
...
...
@@ -102,38 +98,31 @@ bool tnlTFQMRSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector&
theta
=
eta
=
0.0
;
r_ast
=
r
;
rho
=
r_ast
.
scalarProduct
(
r
);
alpha
=
0.0
;
// TODO
// only to avoid compiler warning; alpha is initialized inside the loop
alpha
=
0.0
;
this
->
resetIterations
();
this
->
setResidue
(
tau
/
b_norm
);
this
->
setResidue
(
tau
/
b_norm
);
while
(
this
->
nextIteration
()
)
{
// start counting from 0
const
IndexType
iter
=
this
->
getIterations
()
-
1
;
// cerr << "Starting TFQMR iteration " << iter << endl;
const
IndexType
iter
=
this
->
getIterations
();
if
(
iter
%
2
==
0
)
{
if
(
iter
%
2
==
1
)
{
alpha
=
rho
/
v
.
scalarProduct
(
this
->
r_ast
);
}
else
{
// not necessary in
even
iter
ation
since the previous
odd
iteration
// not necessary in
odd
iter since the previous iteration
// already computed v_{m+1} = A*u_{m+1}
matrix
->
vectorProduct
(
u
,
Au
);
}
w
.
addVector
(
Au
,
-
alpha
);
// cerr << "alpha = " << alpha << endl;
//cerr << "theta * theta / alpha * eta = " << theta * theta / alpha * eta << endl;
d
.
addVector
(
u
,
1.0
,
theta
*
theta
*
eta
/
alpha
);
d
.
addVector
(
u
,
1.0
,
theta
*
theta
*
eta
/
alpha
);
w_norm
=
w
.
lpNorm
(
2.0
);
// cerr << "w_norm / b_norm = residue = " << w_norm / b_norm << endl;
theta
=
w_norm
/
tau
;
const
RealType
c
=
1.0
/
sqrt
(
1.0
+
theta
*
theta
);
tau
=
tau
*
theta
*
c
;
// cerr << "tau * sqrt(m+1) = " << tau * sqrt(iter+1) << endl;
eta
=
c
*
c
*
alpha
;
//cerr << "eta = " << eta << endl;
x
.
addVector
(
d
,
eta
);
this
->
setResidue
(
tau
*
sqrt
(
iter
+
1
)
/
b_norm
);
...
...
@@ -141,8 +130,7 @@ bool tnlTFQMRSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector&
break
;
}
if
(
iter
%
2
==
1
)
{
if
(
iter
%
2
==
0
)
{
const
RealType
rho_new
=
w
.
scalarProduct
(
this
->
r_ast
);
const
RealType
beta
=
rho_new
/
rho
;
rho
=
rho_new
;
...
...
@@ -159,6 +147,10 @@ bool tnlTFQMRSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector&
this
->
refreshSolverMonitor
();
}
// this->matrix->vectorProduct( x, r );
// r.addVector( b, 1.0, -1.0 );
// this->setResidue( r.lpNorm( 2.0 ) / b_norm );
this
->
refreshSolverMonitor
(
true
);
return
this
->
checkConvergence
();
};
...
...
@@ -179,9 +171,7 @@ bool tnlTFQMRSolver< Matrix, Preconditioner > :: setSize( IndexType size )
!
u
.
setSize
(
size
)
||
!
v
.
setSize
(
size
)
||
!
r_ast
.
setSize
(
size
)
||
!
u_new
.
setSize
(
size
)
||
!
Au
.
setSize
(
size
)
||
!
Au_new
.
setSize
(
size
)
)
!
Au
.
setSize
(
size
)
)
{
cerr
<<
"I am not able to allocate all supporting vectors for the TFQMR solver."
<<
endl
;
return
false
;
...
...
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