2023-02-05 07:34:23 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
|
|
|
* All rights reserved.
|
|
|
|
* Use of this source code is governed by a MIT-style
|
|
|
|
* license that can be found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#include <float.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <mpi.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "parameter.h"
|
|
|
|
#include "progress.h"
|
|
|
|
#include "solver.h"
|
|
|
|
#include "timing.h"
|
|
|
|
#include <mpi.h>
|
|
|
|
|
2023-06-27 16:24:55 +02:00
|
|
|
enum VARIANT { SOR = 1, RB, RBA };
|
|
|
|
|
|
|
|
int main (int argc, char** argv)
|
2023-02-05 07:34:23 +01:00
|
|
|
{
|
|
|
|
int rank;
|
2023-07-14 21:50:38 +02:00
|
|
|
int variant = RB;
|
2023-02-05 07:34:23 +01:00
|
|
|
double S, E;
|
|
|
|
Parameter params;
|
|
|
|
Solver solver;
|
|
|
|
|
|
|
|
MPI_Init(&argc, &argv);
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|
|
|
initParameter(¶ms);
|
|
|
|
|
2023-06-27 16:24:55 +02:00
|
|
|
if (argc < 2) {
|
2023-02-05 07:34:23 +01:00
|
|
|
printf("Usage: %s <configFile>\n", argv[0]);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
readParameter(¶ms, argv[1]);
|
2023-06-27 16:24:55 +02:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
variant = atoi(argv[2]);
|
|
|
|
}
|
2023-02-05 07:34:23 +01:00
|
|
|
if (rank == 0) {
|
|
|
|
printParameter(¶ms);
|
|
|
|
}
|
|
|
|
initSolver(&solver, ¶ms);
|
|
|
|
initProgress(solver.te);
|
|
|
|
|
2023-07-14 21:50:38 +02:00
|
|
|
void (*solver_generic[])(solver) = {solve, solveRB, solveRBA};
|
|
|
|
|
|
|
|
|
2023-02-05 07:34:23 +01:00
|
|
|
double tau = solver.tau;
|
|
|
|
double te = solver.te;
|
|
|
|
double t = 0.0;
|
|
|
|
|
|
|
|
S = getTimeStamp();
|
2023-07-14 21:50:38 +02:00
|
|
|
|
|
|
|
while (t <= te)
|
|
|
|
{
|
2023-06-27 16:24:55 +02:00
|
|
|
if (tau > 0.0) {
|
|
|
|
computeTimestep(&solver);
|
|
|
|
}
|
|
|
|
|
|
|
|
setBoundaryConditions(&solver);
|
|
|
|
setSpecialBoundaryCondition(&solver);
|
|
|
|
computeFG(&solver);
|
|
|
|
computeRHS(&solver);
|
2023-07-14 21:50:38 +02:00
|
|
|
(*solver_generic[variant - 1])(&solver);
|
2023-06-27 16:24:55 +02:00
|
|
|
adaptUV(&solver);
|
|
|
|
t += solver.dt;
|
|
|
|
#ifdef VERBOSE
|
|
|
|
if (rank == 0) {
|
|
|
|
printf("TIME %f , TIMESTEP %f\n", t, solver.dt);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
printProgress(t);
|
|
|
|
#endif
|
2023-07-14 21:50:38 +02:00
|
|
|
}
|
2023-07-05 20:38:50 +02:00
|
|
|
|
2023-06-27 16:24:55 +02:00
|
|
|
|
2023-02-05 07:34:23 +01:00
|
|
|
E = getTimeStamp();
|
|
|
|
stopProgress();
|
|
|
|
if (rank == 0) {
|
|
|
|
printf("Solution took %.2fs\n", E - S);
|
|
|
|
}
|
|
|
|
collectResult(&solver);
|
|
|
|
|
|
|
|
MPI_Finalize();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|