Implemented Function pointer for SOR, RB and RBA variants
This commit is contained in:
@@ -71,7 +71,7 @@ static void createBulkArrays(Solver* s, double* pg, double* ug, double* vg, doub
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int rank;
|
||||
int variant = SOR;
|
||||
int variant = RB;
|
||||
|
||||
double timeStart, timeStop;
|
||||
Parameter params;
|
||||
@@ -100,53 +100,18 @@ int main(int argc, char** argv)
|
||||
|
||||
timeStart = getTimeStamp();
|
||||
|
||||
switch (variant) {
|
||||
case SOR:
|
||||
printf("Plain SOR\n");
|
||||
while (t <= te) {
|
||||
void (*solver_generic[])(solver) = {solve, solveRB, solveRBA};
|
||||
|
||||
while (t <= te) {
|
||||
if (tau > 0.0) computeTimestep(&s);
|
||||
setBoundaryConditions(&s);
|
||||
setSpecialBoundaryCondition(&s);
|
||||
computeFG(&s);
|
||||
computeRHS(&s);
|
||||
solve(&s);
|
||||
(*solver_generic[variant - 1])(&s);
|
||||
adaptUV(&s);
|
||||
t += s.dt;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RB:
|
||||
printf("Red-black SOR\n");
|
||||
while (t <= te) {
|
||||
if (tau > 0.0) computeTimestep(&s);
|
||||
setBoundaryConditions(&s);
|
||||
setSpecialBoundaryCondition(&s);
|
||||
computeFG(&s);
|
||||
computeRHS(&s);
|
||||
solveRB(&s);
|
||||
adaptUV(&s);
|
||||
t += s.dt;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RBA:
|
||||
printf("Red-black SOR with acceleration\n");
|
||||
while (t <= te) {
|
||||
if (tau > 0.0) computeTimestep(&s);
|
||||
setBoundaryConditions(&s);
|
||||
setSpecialBoundaryCondition(&s);
|
||||
computeFG(&s);
|
||||
computeRHS(&s);
|
||||
solveRBA(&s);
|
||||
adaptUV(&s);
|
||||
t += s.dt;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
if (rank == 0) {
|
||||
printf("TIME %f , TIMESTEP %f\n", t, s.dt);
|
||||
@@ -154,7 +119,7 @@ int main(int argc, char** argv)
|
||||
#else
|
||||
printProgress(t);
|
||||
#endif
|
||||
|
||||
}
|
||||
timeStop = getTimeStamp();
|
||||
#ifndef VERBOSE
|
||||
stopProgress();
|
||||
|
Reference in New Issue
Block a user