sandbox/bugs/singularity_diffusion.c
Dry cells lead to singularities with vertical diffusion
Currently, there are no checks checking if h[]
is
nonzero in the vertical diffusion
module. Hence, dry cells inevitably cause singularities if viscosity
is set to be anything but zero.
#include "grid/multigrid.h"
#include "layered/hydro.h"
If viscous is set to 1, the program crashes with an Arithmetic exception. If viscous is set to 0, the program runs normally.
#define viscous 1
int main(){
= 8;
N = 1;
nl #if viscous
= 1;
nu #else
= 0.0;
nu #endif
periodic(right);
run();
}
We start by initializing a simple grid where the top half of the cells are dry.
event init(i=0){
foreach(){
[] = -1.0;
zbif ( y >= 0.5)
[] = 0.0;
zb(){
foreach_layer[] = -zb[]/nl;
h.x[] = 0.1;
u}
}
// Printing the initial h field values
FILE * fp = fopen("out0.txt", "w");
foreach(){
(){
foreach_layerfprintf(fp, "(x,y) = (%g,%g), h[] = %g\n", x,y,h[]);
}
}
fclose(fp);
}
Output before simulation without viscosity:
And after one timestep
event next_timestep(i=1){
FILE * fp = fopen("out1.txt", "w");
foreach(){
(){
foreach_layerfprintf(fp, "(x,y) = (%g,%g), h[] = %g\n", x,y,h[]);
}
}
fclose(fp);
}
Output before simulation without viscosity: