Merge branch 'main' of git.clustercockpit.org:moebiusband/NuSiF-Solver
This commit is contained in:
commit
cc2aef66b4
90
BasicSolver/3D-mpi-io/src/main.c
Normal file
90
BasicSolver/3D-mpi-io/src/main.c
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "allocate.h"
|
||||
#include "comm.h"
|
||||
#include "parameter.h"
|
||||
#include "progress.h"
|
||||
#include "solver.h"
|
||||
#include "timing.h"
|
||||
#include "vtkWriter.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double timeStart, timeStop;
|
||||
Parameter p;
|
||||
Solver s;
|
||||
|
||||
commInit(&s.comm, argc, argv);
|
||||
initParameter(&p);
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s <configFile>\n", argv[0]);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
readParameter(&p, argv[1]);
|
||||
commPartition(&s.comm, p.kmax, p.jmax, p.imax);
|
||||
if (commIsMaster(&s.comm)) {
|
||||
printParameter(&p);
|
||||
}
|
||||
initSolver(&s, &p);
|
||||
#ifndef VERBOSE
|
||||
initProgress(s.te);
|
||||
#endif
|
||||
|
||||
double tau = s.tau;
|
||||
double te = s.te;
|
||||
double t = 0.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;
|
||||
|
||||
#ifdef VERBOSE
|
||||
if (commIsMaster(&s.comm)) {
|
||||
printf("TIME %f , TIMESTEP %f\n", t, s.dt);
|
||||
}
|
||||
#else
|
||||
printProgress(t);
|
||||
#endif
|
||||
}
|
||||
timeStop = getTimeStamp();
|
||||
#ifndef VERBOSE
|
||||
stopProgress();
|
||||
#endif
|
||||
if (commIsMaster(&s.comm)) {
|
||||
printf("Solution took %.2fs\n", timeStop - timeStart);
|
||||
}
|
||||
|
||||
timeStart = getTimeStamp();
|
||||
VtkOptions opts = { .grid = s.grid, .comm = s.comm };
|
||||
vtkOpen(&opts, s.problem);
|
||||
vtkScalar(&opts, "pressure", s.p);
|
||||
vtkVector(&opts, "velocity", (VtkVector) { s.u, s.v, s.w });
|
||||
vtkClose(&opts);
|
||||
timeStop = getTimeStamp();
|
||||
|
||||
if (commIsMaster(&s.comm)) {
|
||||
printf("Result output took %.2fs\n", timeStop - timeStart);
|
||||
}
|
||||
|
||||
commFinalize(&s.comm);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -15,6 +15,6 @@ endif
|
||||
VERSION = --version
|
||||
CFLAGS = -O3 -xHost -qopt-zmm-usage=high -std=c99 $(OPENMP)
|
||||
LFLAGS = $(OPENMP)
|
||||
DEFINES += -D_GNU_SOURCE
|
||||
DEFINES += -D_GNU_SOURCE# -DDEBUG
|
||||
INCLUDES =
|
||||
LIBS =
|
||||
|
@ -71,6 +71,7 @@ int main(int argc, char** argv)
|
||||
printf("Solution took %.2fs\n", timeStop - timeStart);
|
||||
}
|
||||
|
||||
timeStart = getTimeStamp();
|
||||
#ifdef _VTK_WRITER_MPI
|
||||
VtkOptions opts = { .grid = s.grid, .comm = s.comm };
|
||||
vtkOpen(&opts, s.problem);
|
||||
@ -111,6 +112,12 @@ int main(int argc, char** argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
timeStop = getTimeStamp();
|
||||
|
||||
if (commIsMaster(&s.comm)) {
|
||||
printf("Result output took %.2fs\n", timeStop - timeStart);
|
||||
}
|
||||
|
||||
commFinalize(&s.comm);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -91,8 +91,7 @@ void vtkScalar(VtkOptions* o, char* name, double* s)
|
||||
char header[100];
|
||||
char* cursor = header;
|
||||
|
||||
cursor += sprintf(cursor, "SCALARS %s double 1\n", name);
|
||||
cursor += sprintf(cursor, "LOOKUP_TABLE default\n");
|
||||
cursor += sprintf(cursor, "SCALARS %s double\n", name);
|
||||
|
||||
if (commIsMaster(&o->comm)) {
|
||||
MPI_File_write(o->fh, header, (int)strlen(header), MPI_CHAR, MPI_STATUS_IGNORE);
|
||||
|
@ -111,6 +111,7 @@ int main(int argc, char** argv)
|
||||
#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);
|
||||
@ -126,5 +127,11 @@ int main(int argc, char** argv)
|
||||
vtkScalar(&opts, "pressure", pg);
|
||||
vtkVector(&opts, "velocity", (VtkVector) { ug, vg, wg });
|
||||
vtkClose(&opts);
|
||||
timeStop = getTimeStamp();
|
||||
|
||||
if (commIsMaster(&s.comm)) {
|
||||
printf("Result output took %.2fs\n", timeStop - timeStart);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -69,8 +69,7 @@ void vtkScalar(VtkOptions* o, char* name, double* s)
|
||||
printf("vtkWriter not initialize! Call vtkOpen first!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(o->fh, "SCALARS %s float 1\n", name);
|
||||
fprintf(o->fh, "LOOKUP_TABLE default\n");
|
||||
fprintf(o->fh, "SCALARS %s float\n", name);
|
||||
|
||||
for (int k = 0; k < kmax; k++) {
|
||||
for (int j = 0; j < jmax; j++) {
|
||||
|
Loading…
Reference in New Issue
Block a user