Working 2D MPI v3 PT with VTK

This commit is contained in:
Aditya Ujeniya 2023-08-26 12:03:16 +02:00
parent 920dd887ea
commit b696d4860e
4 changed files with 19547 additions and 19501 deletions

View File

@ -32,7 +32,7 @@ jmax 50 # number of interior cells in y-direction
# Time Data: # Time Data:
# --------- # ---------
te 100.0 # final time te 60.0 # final time
dt 0.02 # time stepsize dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt) tau 0.5 # safety factor for time stepsize control (<0 constant delt)

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,18 @@ static int ts = 0;
#define XOFFSETEND 2 #define XOFFSETEND 2
#define YOFFSETEND 3 #define YOFFSETEND 3
static double sum(int* sizes, int size)
{
double sum = 0;
for (int i = 0; i < size; ++i)
{
sum += sizes[i];
}
return sum;
}
static double sumX(double* sizes, int size, int offset, int coord, int init) static double sumX(double* sizes, int size, int offset, int coord, int init)
{ {
double sum = 0; double sum = 0;
@ -283,13 +295,30 @@ void writeParticles(ParticleTracer* particletracer)
char filename[50]; char filename[50];
FILE* fp; FILE* fp;
snprintf(filename, 50, "vis_files/particles_%d.dat", ts); snprintf(filename, 50, "vtk_files/particles_%d.vtk", ts);
fp = fopen(filename, "w"); fp = fopen(filename, "w");
if (fp == NULL) { if (fp == NULL) {
printf("Error!\n"); printf("Error!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf(fp, "# vtk DataFile Version 3.0\n");
fprintf(fp, "PAMPI cfd solver particle tracing file\n");
fprintf(fp, "ASCII\n");
fprintf(fp, "DATASET UNSTRUCTURED_GRID\n");
fprintf(fp, "FIELD FieldData 2\n");
fprintf(fp, "TIME 1 1 double\n");
fprintf(fp, "%d\n", ts);
fprintf(fp, "CYCLE 1 1 int\n");
fprintf(fp, "1\n");
int overallTotalParticles = sum(collectedBuffIndex, particletracer->size);
fprintf(fp, "POINTS %d float\n", overallTotalParticles);
printf("Total particles : %d\n", overallTotalParticles);
for (int i = 1; i < particletracer->size; ++i) for (int i = 1; i < particletracer->size; ++i)
{ {
@ -300,7 +329,7 @@ void writeParticles(ParticleTracer* particletracer)
{ {
double x = recvBuff[j].x; double x = recvBuff[j].x;
double y = recvBuff[j].y; double y = recvBuff[j].y;
fprintf(fp, "%f %f\n", x, y); fprintf(fp, "%f %f 0\n", x, y);
//printf("Rank : 0 receiving from rank %d X : %.2f, Y : %.2f with totalpt : %d\n", i, x, y, particletracer->totalParticles); //printf("Rank : 0 receiving from rank %d X : %.2f, Y : %.2f with totalpt : %d\n", i, x, y, particletracer->totalParticles);
} }
@ -310,8 +339,25 @@ void writeParticles(ParticleTracer* particletracer)
{ {
double x = particletracer->particlePool[i].x; double x = particletracer->particlePool[i].x;
double y = particletracer->particlePool[i].y; double y = particletracer->particlePool[i].y;
fprintf(fp, "%f %f\n", x, y); fprintf(fp, "%f %f 0\n", x, y);
} }
fprintf(fp, "CELLS %d %d\n", overallTotalParticles, 2 * overallTotalParticles);
for (int i = 0; i < overallTotalParticles; ++i)
{
fprintf(fp, "1 %d\n", i);
}
fprintf(fp, "CELL_TYPES %d\n", overallTotalParticles);
for (int i = 0; i < overallTotalParticles; ++i)
{
fprintf(fp, "1\n");
}
fclose(fp); fclose(fp);
} }

File diff suppressed because it is too large Load Diff