1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| #include "grid/cartesian1D.h"
#include "conservation.h"
scalar h[];
vector q[];
scalar * scalars = {h};
vector * vectors = {q};
double G = 1.;
void flux (const double * s, double * f, double e[2])
{
double h = s[0], q = s[1], u = q/h;
f[0] = q;
f[1] = q*u + G*h*h/2.;
// min/max eigenvalues
double c = sqrt(G*h);
e[0] = u - c; // min
e[1] = u + c; // max
}
int main()
{
theta = 1.;
origin (-0.5, -0.5);
init_grid (500);
run();
}
event init (i = 0)
{
double a = 200.;
foreach()
h[] = 0.1 + exp(-a*x*x);
}
event logfile (t += 0.1; t <= 0.7) {
foreach()
fprintf (stderr, "%g %g %.6f\n", x, h[], q.x[]);
fprintf (stderr, "\n");
}
|