Multilayer and MPI - gathering data from each core

42 views
Skip to first unread message

Cyril Gadal

unread,
Jun 18, 2024, 7:41:56 AMJun 18
to basilisk-fr
Dear all,
I am just getting started with basilisk, and interested in running simulations with the non-hydrostatic multilayer. I started with the example lock.c that I have modified little by little.

Now, I am at the point where I want to increase the grid, and as such run it on multiple cores: CC='mpicc -D_MPI=4' make lock_exchange_base.tst

I have trouble adapting my plot and dump functions, that for now return only 1/4 of the data:

event output (t += step2)
event output1 (t += step1; t <= tmax) {
char s[120];
sprintf (s, "profiles/profiles-%.5f.txt", t);
FILE * f = fopen (s, "w");
foreach(serial)
foreach_layer() {
z += h[]/2.;
fprintf (f, "%g %g %g %g %g %g %g\n", x, eta[], zb[], u.x[], z, h[], T[]);
z += h[]/2.;}
fclose(f);
}

// DUMP snapshots of density field

void plot_density (FILE * fp)
{
fprintf (fp,
"set cbrange [-0.0:0.05]\n" // Density
"set title 't = %.2f'\n"
"sp '-' u 1:2:4\n",t);
foreach (serial) {
double z = zb[];
fprintf (fp, "%g %g %g %g\n", x, z, u.x[], T[]);
foreach_layer() {
z += h[];
fprintf (fp, "%g %g %g %g\n", x, z, u.x[], T[]);
}
fprintf (fp, "\n");
}
fprintf (fp, "e\n\n");
fflush (fp);
}

void setup (FILE * fp)
{
fprintf (fp,
#if ISOPYCNAL
"set pm3d map corners2color c2\n"
#else
"set pm3d map\n"
#endif
"# jet colormap\n"
"set palette defined ( 0 0 0 0.5647, 0.125 0 0.05882 1, 0.25"
" 0 0.5647 1, 0.375 0.05882 1 0.9333, 0.5 0.5647 1 0.4392, 0.625"
" 1 0.9333 0, 0.75 1 0.4392 0, 0.875 0.9333 0 0, 1 0.498 0 0 )\n"
"unset key\n"
"set xlabel 'x'\n"
"set ylabel 'depth'\n"
);
}


event gnuplot (t += step1)
{
static FILE * fp = popen ("gnuplot 2> /dev/null", "w");
if (i == 0)
setup (fp);

fprintf (fp,
"set term pngcairo font \",10\" size 1600,266\n"
"set xrange [0:4]\n"
"set yrange [-0.5:0.5]\n"
"set size ratio -1\n"
"unset ytics\n"
"set output 'gnuplot/plot-%0.2f.png'\n", t);
plot_density (fp);
}

How should I gather all the data from all cores before calling these functions?

lock_exchange_base.c

Cyril Gadal

unread,
Jun 18, 2024, 8:16:08 AMJun 18
to basilisk-fr

Apologies, I linked the wrong input file. Here is the correct one.
lock_exchange_base.c
Reply all
Reply to author
Forward
0 new messages