forked from moebiusband/NuSiF-Solver
Cleanup. Port MultiGrid to 3D-seq
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "allocate.h"
|
||||
#include "discretization.h"
|
||||
#include "parameter.h"
|
||||
#include "progress.h"
|
||||
#include "solver.h"
|
||||
@@ -17,7 +18,8 @@
|
||||
|
||||
#define G(v, i, j, k) v[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
|
||||
|
||||
static void createBulkArrays(Solver* s, double* pg, double* ug, double* vg, double* wg)
|
||||
static void createBulkArrays(
|
||||
Discretization* s, double* pg, double* ug, double* vg, double* wg)
|
||||
{
|
||||
int imax = s->grid.imax;
|
||||
int jmax = s->grid.jmax;
|
||||
@@ -67,6 +69,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
double timeStart, timeStop;
|
||||
Parameter p;
|
||||
Discretization d;
|
||||
Solver s;
|
||||
initParameter(&p);
|
||||
|
||||
@@ -77,51 +80,53 @@ int main(int argc, char** argv)
|
||||
|
||||
readParameter(&p, argv[1]);
|
||||
printParameter(&p);
|
||||
initSolver(&s, &p);
|
||||
initDiscretization(&d, &p);
|
||||
initSolver(&s, &d, &p);
|
||||
#ifndef VERBOSE
|
||||
initProgress(s.te);
|
||||
initProgress(d.te);
|
||||
#endif
|
||||
|
||||
double tau = s.tau;
|
||||
double te = s.te;
|
||||
double tau = d.tau;
|
||||
double te = d.te;
|
||||
double t = 0.0;
|
||||
int nt = 0;
|
||||
|
||||
timeStart = getTimeStamp();
|
||||
while (t <= te) {
|
||||
if (tau > 0.0) computeTimestep(&s);
|
||||
setBoundaryConditions(&s);
|
||||
setSpecialBoundaryCondition(&s);
|
||||
computeFG(&s);
|
||||
computeRHS(&s);
|
||||
solve(&s);
|
||||
adaptUV(&s);
|
||||
t += s.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
|
||||
printf("TIME %f , TIMESTEP %f\n", t, s.dt);
|
||||
printf("TIME %f , TIMESTEP %f\n", t, solver.dt);
|
||||
#else
|
||||
printProgress(t);
|
||||
#endif
|
||||
}
|
||||
timeStop = getTimeStamp();
|
||||
#ifndef VERBOSE
|
||||
stopProgress();
|
||||
#endif
|
||||
printf("Solution took %.2fs\n", timeStop - timeStart);
|
||||
|
||||
timeStart = getTimeStamp();
|
||||
double *pg, *ug, *vg, *wg;
|
||||
|
||||
size_t bytesize = (size_t)(s.grid.imax * s.grid.jmax * s.grid.kmax) * sizeof(double);
|
||||
size_t bytesize = (size_t)(d.grid.imax * d.grid.jmax * d.grid.kmax) * sizeof(double);
|
||||
|
||||
pg = allocate(64, bytesize);
|
||||
ug = allocate(64, bytesize);
|
||||
vg = allocate(64, bytesize);
|
||||
wg = allocate(64, bytesize);
|
||||
|
||||
createBulkArrays(&s, pg, ug, vg, wg);
|
||||
VtkOptions opts = { .grid = s.grid };
|
||||
vtkOpen(&opts, s.problem);
|
||||
createBulkArrays(&d, pg, ug, vg, wg);
|
||||
VtkOptions opts = { .grid = d.grid };
|
||||
vtkOpen(&opts, d.problem);
|
||||
vtkScalar(&opts, "pressure", pg);
|
||||
vtkVector(&opts, "velocity", (VtkVector) { ug, vg, wg });
|
||||
vtkClose(&opts);
|
||||
|
Reference in New Issue
Block a user