Implemented Function pointer for SOR, RB and RBA variants

This commit is contained in:
2023-07-14 21:50:38 +02:00
parent 9f55413efb
commit b50dbe7d4b
30 changed files with 61658 additions and 61142 deletions

View File

@@ -24,7 +24,7 @@ enum VARIANT { SOR = 1, RB, RBA };
int main(int argc, char** argv)
{
int rank;
int variant = SOR;
int variant = RB;
double timeStart, timeStop;
Parameter params;
@@ -57,60 +57,22 @@ int main(int argc, char** argv)
double t = 0.0;
int nt = 0;
void (*solver_generic[])(solver) = {solve, solveRB, solveRBA};
timeStart = getTimeStamp();
switch (variant) {
case SOR:
printf("Plain SOR\n");
while (t <= te) {
while (t <= te) {
if (tau > 0.0) computeTimestep(&solver);
setBoundaryConditions(&solver);
setSpecialBoundaryCondition(&solver);
computeFG(&solver);
computeRHS(&solver);
// if (nt % 100 == 0) normalizePressure(&solver);
solve(&solver);
(*solver_generic[variant - 1])(&solver);
adaptUV(&solver);
t += solver.dt;
nt++;
}
break;
case RB:
printf("Red-black SOR\n");
while (t <= te) {
if (tau > 0.0) computeTimestep(&solver);
setBoundaryConditions(&solver);
setSpecialBoundaryCondition(&solver);
computeFG(&solver);
computeRHS(&solver);
// if (nt % 100 == 0) normalizePressure(&solver);
solveRB(&solver);
adaptUV(&solver);
t += solver.dt;
nt++;
}
break;
case RBA:
printf("Red-black SOR with acceleration\n");
while (t <= te) {
if (tau > 0.0) computeTimestep(&solver);
setBoundaryConditions(&solver);
setSpecialBoundaryCondition(&solver);
computeFG(&solver);
computeRHS(&solver);
// if (nt % 100 == 0) normalizePressure(&solver);
solveRBA(&solver);
adaptUV(&solver);
t += solver.dt;
nt++;
}
break;
}
#ifdef VERBOSE
if (rank == 0) {
@@ -119,6 +81,9 @@ int main(int argc, char** argv)
#else
printProgress(t);
#endif
}
timeStop = getTimeStamp();
stopProgress();

View File

@@ -449,7 +449,6 @@ void solveRBA(Solver* s)
int it = 0;
double res = 1.0;
int pass, ksw, jsw, isw;
commExchange(&s->comm, p);
while ((res >= epssq) && (it < itermax)) {
res = 0.0;