1 | import numpy as num |
---|
2 | from gpu_domain import GPU_domain |
---|
3 | |
---|
4 | """test flux calculation (actual C implementation) |
---|
5 | |
---|
6 | This one tests the constant case where only the pressure term |
---|
7 | contributes to each edge and cancels out once the total flux has |
---|
8 | been summed up. |
---|
9 | """ |
---|
10 | |
---|
11 | a = [0.0, 0.0] |
---|
12 | b = [0.0, 2.0] |
---|
13 | c = [2.0, 0.0] |
---|
14 | d = [0.0, 4.0] |
---|
15 | e = [2.0, 2.0] |
---|
16 | f = [4.0, 0.0] |
---|
17 | |
---|
18 | points = [a, b, c, d, e, f] |
---|
19 | # bac, bce, ecf, dbe |
---|
20 | vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]] |
---|
21 | |
---|
22 | domain = GPU_domain(points, vertices) |
---|
23 | domain.check_integrity() |
---|
24 | |
---|
25 | # The constant case |
---|
26 | domain.set_quantity('elevation', -1) |
---|
27 | domain.set_quantity('stage', 1) |
---|
28 | |
---|
29 | domain.compute_fluxes() |
---|
30 | print "+++ fluxes: done +++" |
---|
31 | domain.compute_fluxes() |
---|
32 | print "+++ fluxes: done +++" |
---|
33 | # Central triangle |
---|
34 | #assert num.allclose(domain.get_quantity('stage').explicit_update[1], 0) |
---|
35 | |
---|
36 | # The more general case |
---|
37 | #def surface(x, y): |
---|
38 | # return -x/2 |
---|
39 | |
---|
40 | #domain.set_quantity('elevation', -10) |
---|
41 | #domain.set_quantity('stage', surface) |
---|
42 | #domain.set_quantity('xmomentum', 1) |
---|
43 | |
---|
44 | #domain.compute_fluxes() |
---|
45 | |
---|
46 | #print domain.get_quantity('stage').explicit_update |
---|
47 | # FIXME (Ole): TODO the general case |
---|
48 | #assert allclose(domain.get_quantity('stage').explicit_update[1], ...??) |
---|