1 | # -*- coding: utf-8 -*- |
---|
2 | """Class Parallel_shallow_water_domain - |
---|
3 | 2D triangular domains for finite-volume computations of |
---|
4 | the shallow water equation, with extra structures to allow |
---|
5 | communication between other Parallel_domains and itself |
---|
6 | |
---|
7 | This module contains a specialisation of class Domain |
---|
8 | from module shallow_water.py |
---|
9 | |
---|
10 | Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou |
---|
11 | Geoscience Australia, 2004-2005 |
---|
12 | |
---|
13 | """ |
---|
14 | |
---|
15 | from anuga import Domain |
---|
16 | |
---|
17 | import numpy as num |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | class GPU_domain(Domain): |
---|
22 | |
---|
23 | def __init__(self, coordinates, vertices, |
---|
24 | boundary=None, |
---|
25 | full_send_dict=None, |
---|
26 | ghost_recv_dict=None, |
---|
27 | number_of_full_nodes=None, |
---|
28 | number_of_full_triangles=None, |
---|
29 | geo_reference=None): #jj added this |
---|
30 | |
---|
31 | Domain.__init__(self, |
---|
32 | coordinates, |
---|
33 | vertices, |
---|
34 | boundary, |
---|
35 | full_send_dict=full_send_dict, |
---|
36 | ghost_recv_dict=ghost_recv_dict, |
---|
37 | number_of_full_nodes=number_of_full_nodes, |
---|
38 | number_of_full_triangles=number_of_full_triangles, |
---|
39 | geo_reference=geo_reference) #jj added this |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | def compute_fluxes(self): |
---|
46 | """Compute fluxes and timestep suitable for all volumes in domain. |
---|
47 | |
---|
48 | Compute total flux for each conserved quantity using "flux_function" |
---|
49 | |
---|
50 | Fluxes across each edge are scaled by edgelengths and summed up |
---|
51 | Resulting flux is then scaled by area and stored in |
---|
52 | explicit_update for each of the three conserved quantities |
---|
53 | stage, xmomentum and ymomentum |
---|
54 | |
---|
55 | The maximal allowable speed computed by the flux_function for each volume |
---|
56 | is converted to a timestep that must not be exceeded. The minimum of |
---|
57 | those is computed as the next overall timestep. |
---|
58 | |
---|
59 | Post conditions: |
---|
60 | domain.explicit_update is reset to computed flux values |
---|
61 | domain.timestep is set to the largest step satisfying all volumes. |
---|
62 | |
---|
63 | This wrapper calls the underlying C version of compute fluxes |
---|
64 | """ |
---|
65 | |
---|
66 | import sys |
---|
67 | from gpu_python_glue import compute_fluxes_ext_central_new_gpu as compute_fluxes_ext |
---|
68 | |
---|
69 | # Shortcuts |
---|
70 | Stage = self.quantities['stage'] |
---|
71 | Xmom = self.quantities['xmomentum'] |
---|
72 | Ymom = self.quantities['ymomentum'] |
---|
73 | Bed = self.quantities['elevation'] |
---|
74 | |
---|
75 | timestep = float(sys.maxint) |
---|
76 | print timestep, self, Stage, Xmom, Ymom, Bed |
---|
77 | print self.tri_full_flag |
---|
78 | print "areas: ", self.areas |
---|
79 | |
---|
80 | flux_timestep = compute_fluxes_ext(timestep, self, Stage, Xmom, Ymom, Bed) |
---|
81 | self.flux_timestep = flux_timestep |
---|
82 | print "Updates: " |
---|
83 | print "stage ", Stage.explicit_update |
---|
84 | print "xmom ", Xmom.explicit_update |
---|
85 | print "ymom ", Ymom.explicit_update |
---|
86 | |
---|