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
76f9d1df
Commit
76f9d1df
authored
9 years ago
by
Elias Pipping
Browse files
Options
Downloads
Patches
Plain Diff
Only trailing whitespace
and no play makes Jack a dull boy
parent
a82dc4ef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/solvers/solvers/cgsolver.cc
+10
-10
10 additions, 10 deletions
dune/solvers/solvers/cgsolver.cc
dune/solvers/solvers/cgsolver.hh
+8
-8
8 additions, 8 deletions
dune/solvers/solvers/cgsolver.hh
with
18 additions
and
18 deletions
dune/solvers/solvers/cgsolver.cc
+
10
−
10
View file @
76f9d1df
...
@@ -65,13 +65,13 @@ void CGSolver<MatrixType, VectorType>::solve()
...
@@ -65,13 +65,13 @@ void CGSolver<MatrixType, VectorType>::solve()
VectorType
p
(
*
x_
);
// the search direction
VectorType
p
(
*
x_
);
// the search direction
VectorType
q
(
*
x_
);
// a temporary vector
VectorType
q
(
*
x_
);
// a temporary vector
// some local variables
// some local variables
double
rho
,
rholast
,
lambda
,
alpha
,
beta
;
double
rho
,
rholast
,
lambda
,
alpha
,
beta
;
// determine initial search direction
// determine initial search direction
p
=
0
;
// clear correction
p
=
0
;
// clear correction
if
(
preconditioner_
)
{
if
(
preconditioner_
)
{
preconditioner_
->
setProblem
(
*
matrix_
,
p
,
b
);
preconditioner_
->
setProblem
(
*
matrix_
,
p
,
b
);
preconditioner_
->
iterate
();
preconditioner_
->
iterate
();
...
@@ -80,13 +80,13 @@ void CGSolver<MatrixType, VectorType>::solve()
...
@@ -80,13 +80,13 @@ void CGSolver<MatrixType, VectorType>::solve()
p
=
b
;
p
=
b
;
rholast
=
p
*
b
;
// orthogonalization
rholast
=
p
*
b
;
// orthogonalization
// Loop until desired tolerance or maximum number of iterations is reached
// Loop until desired tolerance or maximum number of iterations is reached
for
(
i
=
0
;
i
<
this
->
maxIterations_
&&
(
error
>
this
->
tolerance_
||
std
::
isnan
(
error
));
i
++
)
{
for
(
i
=
0
;
i
<
this
->
maxIterations_
&&
(
error
>
this
->
tolerance_
||
std
::
isnan
(
error
));
i
++
)
{
// Backup of the current solution for the error computation later on
// Backup of the current solution for the error computation later on
VectorType
oldSolution
=
*
x_
;
VectorType
oldSolution
=
*
x_
;
// Perform one iteration step
// Perform one iteration step
// minimize in given search direction p
// minimize in given search direction p
matrix_
->
mv
(
p
,
q
);
// q=Ap
matrix_
->
mv
(
p
,
q
);
// q=Ap
...
@@ -97,7 +97,7 @@ void CGSolver<MatrixType, VectorType>::solve()
...
@@ -97,7 +97,7 @@ void CGSolver<MatrixType, VectorType>::solve()
// determine new search direction
// determine new search direction
q
=
0
;
// clear correction
q
=
0
;
// clear correction
// apply preconditioner
// apply preconditioner
if
(
preconditioner_
)
{
if
(
preconditioner_
)
{
preconditioner_
->
setProblem
(
*
matrix_
,
q
,
b
);
preconditioner_
->
setProblem
(
*
matrix_
,
q
,
b
);
...
@@ -105,7 +105,7 @@ void CGSolver<MatrixType, VectorType>::solve()
...
@@ -105,7 +105,7 @@ void CGSolver<MatrixType, VectorType>::solve()
q
=
preconditioner_
->
getSol
();
q
=
preconditioner_
->
getSol
();
}
else
}
else
q
=
b
;
q
=
b
;
rho
=
q
*
b
;
// orthogonalization
rho
=
q
*
b
;
// orthogonalization
beta
=
rho
/
rholast
;
// scaling factor
beta
=
rho
/
rholast
;
// scaling factor
p
*=
beta
;
// scale old search direction
p
*=
beta
;
// scale old search direction
...
@@ -113,10 +113,10 @@ void CGSolver<MatrixType, VectorType>::solve()
...
@@ -113,10 +113,10 @@ void CGSolver<MatrixType, VectorType>::solve()
rholast
=
rho
;
// remember rho for recurrence
rholast
=
rho
;
// remember rho for recurrence
// write iteration to file, if requested
// write iteration to file, if requested
if
(
this
->
historyBuffer_
!=
""
)
if
(
this
->
historyBuffer_
!=
""
)
this
->
writeIterate
(
*
x_
,
i
);
this
->
writeIterate
(
*
x_
,
i
);
// Compute error
// Compute error
double
oldNorm
=
errorNorm_
->
operator
()(
oldSolution
);
double
oldNorm
=
errorNorm_
->
operator
()(
oldSolution
);
oldSolution
-=
*
x_
;
oldSolution
-=
*
x_
;
...
...
This diff is collapsed.
Click to expand it.
dune/solvers/solvers/cgsolver.hh
+
8
−
8
View file @
76f9d1df
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include
<dune/solvers/iterationsteps/lineariterationstep.hh>
#include
<dune/solvers/iterationsteps/lineariterationstep.hh>
#include
<dune/solvers/norms/norm.hh>
#include
<dune/solvers/norms/norm.hh>
/** \brief A conjugate gradient solver
/** \brief A conjugate gradient solver
*
*
*/
*/
template
<
class
MatrixType
,
class
VectorType
>
template
<
class
MatrixType
,
class
VectorType
>
...
@@ -15,10 +15,10 @@ class CGSolver : public IterativeSolver<VectorType>
...
@@ -15,10 +15,10 @@ class CGSolver : public IterativeSolver<VectorType>
{
{
static
const
int
blocksize
=
VectorType
::
block_type
::
dimension
;
static
const
int
blocksize
=
VectorType
::
block_type
::
dimension
;
public:
public:
/** \brief Constructor taking all relevant data */
/** \brief Constructor taking all relevant data */
CGSolver
(
const
MatrixType
*
matrix
,
CGSolver
(
const
MatrixType
*
matrix
,
VectorType
*
x
,
VectorType
*
x
,
VectorType
*
rhs
,
VectorType
*
rhs
,
...
@@ -32,11 +32,11 @@ public:
...
@@ -32,11 +32,11 @@ public:
matrix_
(
matrix
),
x_
(
x
),
rhs_
(
rhs
),
matrix_
(
matrix
),
x_
(
x
),
rhs_
(
rhs
),
preconditioner_
(
preconditioner
),
errorNorm_
(
errorNorm
)
preconditioner_
(
preconditioner
),
errorNorm_
(
errorNorm
)
{}
{}
/** \brief Loop, call the iteration procedure
/** \brief Loop, call the iteration procedure
* and monitor convergence */
* and monitor convergence */
virtual
void
solve
();
virtual
void
solve
();
/** \brief Checks whether all relevant member variables are set
/** \brief Checks whether all relevant member variables are set
* \exception SolverError if the iteration step is not set up properly
* \exception SolverError if the iteration step is not set up properly
*/
*/
...
@@ -47,13 +47,13 @@ public:
...
@@ -47,13 +47,13 @@ public:
VectorType
*
x_
;
VectorType
*
x_
;
VectorType
*
rhs_
;
VectorType
*
rhs_
;
//! The iteration step used by the algorithm
//! The iteration step used by the algorithm
LinearIterationStep
<
MatrixType
,
VectorType
>*
preconditioner_
;
LinearIterationStep
<
MatrixType
,
VectorType
>*
preconditioner_
;
//! The norm used to measure convergence
//! The norm used to measure convergence
Norm
<
VectorType
>*
errorNorm_
;
Norm
<
VectorType
>*
errorNorm_
;
};
};
#include
"cgsolver.cc"
#include
"cgsolver.cc"
...
...
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