Working basic PT code
This commit is contained in:
@@ -54,14 +54,16 @@ int main(int argc, char** argv)
|
||||
adaptUV(&s);
|
||||
time += s.dt;
|
||||
nt++;
|
||||
|
||||
|
||||
trace(&t, s.u, s.v, time);
|
||||
|
||||
/*
|
||||
#ifdef VERBOSE
|
||||
printf("TIME %f , TIMESTEP %f\n", time, s.dt);
|
||||
#else
|
||||
printProgress(time);
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
timeEnd = getTimeStamp();
|
||||
stopProgress();
|
||||
|
@@ -27,7 +27,7 @@ static void print(Solver* solver, double* grid)
|
||||
for (int j = 0; j < solver->jmax + 2; j++) {
|
||||
printf("%02d: ", j);
|
||||
for (int i = 0; i < solver->imax + 2; i++) {
|
||||
printf("%12.8f ", grid[j * (imax + 2) + i]);
|
||||
printf("%3.2f ", grid[j * (imax + 2) + i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@@ -146,6 +146,9 @@ void solve(Solver* solver)
|
||||
int it = 0;
|
||||
double res = 1.0;
|
||||
|
||||
// printf("\nBefore P : \n");
|
||||
// print(solver, p);
|
||||
|
||||
while ((res >= epssq) && (it < itermax)) {
|
||||
res = 0.0;
|
||||
|
||||
@@ -172,15 +175,27 @@ void solve(Solver* solver)
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
|
||||
/*
|
||||
#ifdef DEBUG
|
||||
printf("%d Residuum: %e\n", it, res);
|
||||
#endif
|
||||
it++;
|
||||
}
|
||||
*/
|
||||
it++;
|
||||
|
||||
|
||||
}
|
||||
// printf("\nAfter P : \n");
|
||||
// print(solver, p);
|
||||
|
||||
/*
|
||||
#ifndef VERBOSE
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
static double maxElement(Solver* solver, double* m)
|
||||
@@ -238,7 +253,7 @@ void setBoundaryConditions(Solver* solver)
|
||||
|
||||
// Left boundary
|
||||
switch (solver->bcLeft) {
|
||||
case NOSLIP:
|
||||
case NOSLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = 0.0;
|
||||
V(0, j) = -V(1, j);
|
||||
@@ -331,6 +346,11 @@ void setBoundaryConditions(Solver* solver)
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
// printf("\nBoundary condition U : \n");
|
||||
// print(solver, u);
|
||||
|
||||
// printf("\nBoundary condition V : \n");
|
||||
// print(solver, v);
|
||||
}
|
||||
|
||||
void setSpecialBoundaryCondition(Solver* solver)
|
||||
@@ -353,6 +373,9 @@ void setSpecialBoundaryCondition(Solver* solver)
|
||||
U(0, j) = y * (ylength - y) * 4.0 / (ylength * ylength);
|
||||
}
|
||||
}
|
||||
|
||||
// printf("\nSpecial Boundary condition U : \n");
|
||||
// print(solver, u);
|
||||
}
|
||||
|
||||
void computeFG(Solver* solver)
|
||||
@@ -426,6 +449,13 @@ void computeFG(Solver* solver)
|
||||
G(i, 0) = V(i, 0);
|
||||
G(i, jmax) = V(i, jmax);
|
||||
}
|
||||
|
||||
// printf("\nComputed F : \n");
|
||||
// print(solver, f);
|
||||
|
||||
// printf("\nComputed G : \n");
|
||||
// print(solver, g);
|
||||
|
||||
}
|
||||
|
||||
void adaptUV(Solver* solver)
|
||||
@@ -446,6 +476,18 @@ void adaptUV(Solver* solver)
|
||||
V(i, j) = G(i, j) - (P(i, j + 1) - P(i, j)) * factorY;
|
||||
}
|
||||
}
|
||||
|
||||
// printf("\nApadted U : \n");
|
||||
// print(solver, u);
|
||||
|
||||
// printf("\nAdapted V : \n");
|
||||
// print(solver, v);
|
||||
|
||||
// char *b;
|
||||
// b='\0';
|
||||
// printf("\nDEBUGGER : ");
|
||||
// scanf("%s", &b);
|
||||
|
||||
}
|
||||
|
||||
void writeResult(Solver* solver)
|
||||
|
Reference in New Issue
Block a user