Merge branch 'main' of git.clustercockpit.org:moebiusband/NuSiF-Solver

This commit is contained in:
Jan Eitzinger 2024-01-31 17:50:55 +01:00
commit cc2aef66b4
6 changed files with 110 additions and 8 deletions

View 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;
}

View File

@ -1,11 +1,11 @@
ifeq ($(ENABLE_MPI),true) ifeq ($(ENABLE_MPI),true)
CC = mpiicc CC = mpiicc
DEFINES = -D_MPI DEFINES = -D_MPI
else else
CC = icc CC = icc
endif endif
GCC = gcc GCC = gcc
LINKER = $(CC) LINKER = $(CC)
ifeq ($(ENABLE_OPENMP),true) ifeq ($(ENABLE_OPENMP),true)
@ -15,6 +15,6 @@ endif
VERSION = --version VERSION = --version
CFLAGS = -O3 -xHost -qopt-zmm-usage=high -std=c99 $(OPENMP) CFLAGS = -O3 -xHost -qopt-zmm-usage=high -std=c99 $(OPENMP)
LFLAGS = $(OPENMP) LFLAGS = $(OPENMP)
DEFINES += -D_GNU_SOURCE DEFINES += -D_GNU_SOURCE# -DDEBUG
INCLUDES = INCLUDES =
LIBS = LIBS =

View File

@ -71,6 +71,7 @@ int main(int argc, char** argv)
printf("Solution took %.2fs\n", timeStop - timeStart); printf("Solution took %.2fs\n", timeStop - timeStart);
} }
timeStart = getTimeStamp();
#ifdef _VTK_WRITER_MPI #ifdef _VTK_WRITER_MPI
VtkOptions opts = { .grid = s.grid, .comm = s.comm }; VtkOptions opts = { .grid = s.grid, .comm = s.comm };
vtkOpen(&opts, s.problem); vtkOpen(&opts, s.problem);
@ -111,6 +112,12 @@ int main(int argc, char** argv)
} }
#endif #endif
timeStop = getTimeStamp();
if (commIsMaster(&s.comm)) {
printf("Result output took %.2fs\n", timeStop - timeStart);
}
commFinalize(&s.comm); commFinalize(&s.comm);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -91,8 +91,7 @@ void vtkScalar(VtkOptions* o, char* name, double* s)
char header[100]; char header[100];
char* cursor = header; char* cursor = header;
cursor += sprintf(cursor, "SCALARS %s double 1\n", name); cursor += sprintf(cursor, "SCALARS %s double\n", name);
cursor += sprintf(cursor, "LOOKUP_TABLE default\n");
if (commIsMaster(&o->comm)) { if (commIsMaster(&o->comm)) {
MPI_File_write(o->fh, header, (int)strlen(header), MPI_CHAR, MPI_STATUS_IGNORE); MPI_File_write(o->fh, header, (int)strlen(header), MPI_CHAR, MPI_STATUS_IGNORE);

View File

@ -111,6 +111,7 @@ int main(int argc, char** argv)
#endif #endif
printf("Solution took %.2fs\n", timeStop - timeStart); printf("Solution took %.2fs\n", timeStop - timeStart);
timeStart = getTimeStamp();
double *pg, *ug, *vg, *wg; 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)(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); vtkScalar(&opts, "pressure", pg);
vtkVector(&opts, "velocity", (VtkVector) { ug, vg, wg }); vtkVector(&opts, "velocity", (VtkVector) { ug, vg, wg });
vtkClose(&opts); vtkClose(&opts);
timeStop = getTimeStamp();
if (commIsMaster(&s.comm)) {
printf("Result output took %.2fs\n", timeStop - timeStart);
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -69,8 +69,7 @@ void vtkScalar(VtkOptions* o, char* name, double* s)
printf("vtkWriter not initialize! Call vtkOpen first!\n"); printf("vtkWriter not initialize! Call vtkOpen first!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf(o->fh, "SCALARS %s float 1\n", name); fprintf(o->fh, "SCALARS %s float\n", name);
fprintf(o->fh, "LOOKUP_TABLE default\n");
for (int k = 0; k < kmax; k++) { for (int k = 0; k < kmax; k++) {
for (int j = 0; j < jmax; j++) { for (int j = 0; j < jmax; j++) {