sandbox/WMW/duffy_underwater_eruption.c
Buoyant plume
plot 'WG4_minlevel1_maxlevel9_error03_0_0' u 1:2 w l ''
#include "saint-venant.h"
double default_sea_level=0.;
#include "cgd_read2D.h"
#include "input.h"
We then define a few useful macros and constants.
#define MAXLEVEL 9
#define MINLEVEL 1
#define ETAE 1e-3 // error on free surface elevation
int main()
{
#if QUADTREE
// 32^2 grid points to start with
= 1 << MINLEVEL;
N #else // Cartesian
// 1024^2 grid points
= 1 << MAXLEVEL;
N #endif
(16.);
size (-8.,-8.);
origin = 1 << MAXLEVEL;
N run();
}
int adapt() {
#if QUADTREE
scalar eta[];
foreach()
[] = h[] > dry ? h[] + zb[] : 0;
etaboundary ({eta});
astats s = adapt_wavelet ({eta}, (double[]){ETAE},
, MINLEVEL);
MAXLEVELfprintf (stderr, "# refined %d cells, coarsened %d cells\n", s.nf, s.nc);
return s.nf;
#else // Cartesian
return 0;
#endif
}
event init (i = 0)
{
foreach(){
[]=-1.;
zb[] = max(0., - zb[]);}
hboundary ({h,zb});
/* Open the file. */
char *fname = "output0.cgd";
FILE *fidin=fopen(fname,"r");
(x=0., y=0., fid = fidin, iterate = adapt );
deformation_cgd_read fprintf(stderr,"deformation\n");
fclose ( fidin );
}
Gauge gauges[] = {
{"WG4_minlevel1_maxlevel9_error03_0_0", 0, 0},
{NULL}
};
event output (t += 0.1; t <= 21)
output_gauges (gauges, {eta});
Adaptivity
And finally we apply our adapt() function at every timestep.