Separate discretization and solver. Port Multigrid solver.
This commit is contained in:
@@ -4,12 +4,11 @@
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "discretization.h"
|
||||
#include "parameter.h"
|
||||
#include "progress.h"
|
||||
#include "solver.h"
|
||||
@@ -17,39 +16,41 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double S, E;
|
||||
Parameter params;
|
||||
Solver solver;
|
||||
initParameter(¶ms);
|
||||
double timeStart, timeStop;
|
||||
Parameter p;
|
||||
Discretization d;
|
||||
Solver s;
|
||||
initParameter(&p);
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s <configFile>\n", argv[0]);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
readParameter(¶ms, argv[1]);
|
||||
printParameter(¶ms);
|
||||
initSolver(&solver, ¶ms);
|
||||
readParameter(&p, argv[1]);
|
||||
printParameter(&p);
|
||||
initDiscretization(&d, &p);
|
||||
initSolver(&s, &d, &p);
|
||||
#ifndef VERBOSE
|
||||
initProgress(solver.te);
|
||||
initProgress(d.te);
|
||||
#endif
|
||||
|
||||
double tau = solver.tau;
|
||||
double te = solver.te;
|
||||
double tau = d.tau;
|
||||
double te = d.te;
|
||||
double t = 0.0;
|
||||
int nt = 0;
|
||||
|
||||
S = getTimeStamp();
|
||||
timeStart = getTimeStamp();
|
||||
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;
|
||||
if (tau > 0.0) computeTimestep(&d);
|
||||
setBoundaryConditions(&d);
|
||||
setSpecialBoundaryCondition(&d);
|
||||
computeFG(&d);
|
||||
computeRHS(&d);
|
||||
if (nt % 100 == 0) normalizePressure(&d);
|
||||
solve(&s, d.p, d.rhs);
|
||||
adaptUV(&d);
|
||||
t += d.dt;
|
||||
nt++;
|
||||
|
||||
#ifdef VERBOSE
|
||||
@@ -58,9 +59,9 @@ int main(int argc, char** argv)
|
||||
printProgress(t);
|
||||
#endif
|
||||
}
|
||||
E = getTimeStamp();
|
||||
timeStop = getTimeStamp();
|
||||
stopProgress();
|
||||
printf("Solution took %.2fs\n", E - S);
|
||||
writeResult(&solver);
|
||||
printf("Solution took %.2fs\n", timeStop - timeStart);
|
||||
writeResult(&d);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user