Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stop using a double as a loop conter
  • Loading branch information
fionn committed Apr 19, 2020
1 parent abd4bd1 commit 2de0e2e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/relax.cpp
Expand Up @@ -15,10 +15,10 @@ double relax(Potential u, int a, int b, int da, int db, double alpha,
else
{
double prev_iteration = INFINITY;
double w = 1, dw = 0.01;

for(double w = 1; w < 2; w += 0.01)
while(w < 2)
{

initialise_boundary(u, a, b, da, db);

int iteration = 0;
Expand All @@ -32,13 +32,15 @@ double relax(Potential u, int a, int b, int da, int db, double alpha,

if(iteration > prev_iteration)
{
std::cout << "ω = " << w - 0.01 << std::endl;
return w - 0.01; // optimal over-relaxation parameter
std::cout << "ω = " << w - dw << std::endl;
return w - dw; // optimal over-relaxation parameter
}
else
prev_iteration = iteration;

std::cout << w << "\t" << iteration << std::endl;

w += dw;
}
}

Expand Down

0 comments on commit 2de0e2e

Please sign in to comment.