Skip to content
Snippets Groups Projects
Commit 76f9d1df authored by Elias Pipping's avatar Elias Pipping
Browse files

Only trailing whitespace

and no play makes Jack a dull boy
parent a82dc4ef
Branches
No related tags found
No related merge requests found
...@@ -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_;
......
...@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment