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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
| #include "utils.h"
#include "output.h"
#include "check_restriction.h"
#define BGHOSTS 2
int main (int argc, char * argv[])
{
int maxlevel = argc > 1 ? atoi(argv[1]) : 9;
init_grid (16);
origin (-0.1, -0.5, -0.5);
scalar s[];
face vector u[];
reset ({s,u}, undefined);
foreach()
s[] = 1;
foreach_face()
u.x[] = 1;
boundary ({s,u});
scalar * list = {s,u};
timer t = timer_start();
#if 0
refine (level <= maxlevel && sq(x) + sq(y) + sq(z) < sq(0.05));
#else
int refined;
do {
refined = 0;
tree->refined.n = 0;
foreach (serial, nowarning)
if (is_leaf(cell) && level <= maxlevel &&
sq(x) + sq(y) + sq(z) < sq(0.05)) {
refine_cell (point, list, 0, &tree->refined);
refined++;
}
mpi_all_reduce (refined, MPI_INT, MPI_SUM);
if (refined) {
mpi_boundary_refine (list);
mpi_boundary_update_buffers();
grid->tn = 0; // so that tree is not "full"
boundary (list);
foreach()
foreach_neighbor()
assert (s[] == 1);
foreach_face()
assert (u.x[] == 1);
while (balance(0)) {
foreach()
foreach_neighbor()
assert (s[] == 1);
foreach_face()
assert (u.x[] == 1);
}
}
} while (refined);
#endif
long nl = 0;
foreach (serial)
nl++;
long nt = nl;
mpi_all_reduce (nt, MPI_LONG, MPI_SUM);
double elapsed = timer_elapsed(t);
fprintf (stderr, "nl: %ld nt: %ld t: %g s: %g\n", nl, nt, elapsed, nl/elapsed);
foreach()
foreach_neighbor()
assert (s[] == 1);
foreach_face()
for (int i = -2; i <= 2; i++)
assert ((u.x[0,i] == 1));
check_restriction (s);
scalar pid[];
foreach()
pid[] = pid();
output_gfs (file = "out.gfs");
}
|