diff --git a/BasicSolver/3D-mpi-io/src/main.c b/BasicSolver/3D-mpi-io/src/main.c new file mode 100644 index 0000000..97739ac --- /dev/null +++ b/BasicSolver/3D-mpi-io/src/main.c @@ -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 +#include +#include +#include +#include + +#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 \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; +} diff --git a/BasicSolver/3D-mpi/include_ICC.mk b/BasicSolver/3D-mpi/include_ICC.mk index 02d7076..0575de6 100644 --- a/BasicSolver/3D-mpi/include_ICC.mk +++ b/BasicSolver/3D-mpi/include_ICC.mk @@ -1,11 +1,11 @@ ifeq ($(ENABLE_MPI),true) -CC = mpiicc +CC = mpiicc DEFINES = -D_MPI else -CC = icc +CC = icc endif -GCC = gcc +GCC = gcc LINKER = $(CC) ifeq ($(ENABLE_OPENMP),true) @@ -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 = diff --git a/BasicSolver/3D-mpi/src/main.c b/BasicSolver/3D-mpi/src/main.c index 9562307..153abbf 100644 --- a/BasicSolver/3D-mpi/src/main.c +++ b/BasicSolver/3D-mpi/src/main.c @@ -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; } diff --git a/BasicSolver/3D-mpi/src/vtkWriter-mpi.c b/BasicSolver/3D-mpi/src/vtkWriter-mpi.c index 7ff124d..8b29c56 100644 --- a/BasicSolver/3D-mpi/src/vtkWriter-mpi.c +++ b/BasicSolver/3D-mpi/src/vtkWriter-mpi.c @@ -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); diff --git a/BasicSolver/3D-seq/src/main.c b/BasicSolver/3D-seq/src/main.c index 54cc9c9..83035dd 100644 --- a/BasicSolver/3D-seq/src/main.c +++ b/BasicSolver/3D-seq/src/main.c @@ -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; } diff --git a/BasicSolver/3D-seq/src/vtkWriter.c b/BasicSolver/3D-seq/src/vtkWriter.c index 2f7e8c5..0565c0c 100644 --- a/BasicSolver/3D-seq/src/vtkWriter.c +++ b/BasicSolver/3D-seq/src/vtkWriter.c @@ -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++) {