1 | """Class Parallel_shallow_water_domain - |
---|
2 | 2D triangular domains for finite-volume computations of |
---|
3 | the shallow water equation, with extra structures to allow |
---|
4 | communication between other Parallel_domains and itself |
---|
5 | |
---|
6 | This module contains a specialisation of class Domain |
---|
7 | from module shallow_water.py |
---|
8 | |
---|
9 | Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou |
---|
10 | Geoscience Australia, 2004-2005 |
---|
11 | |
---|
12 | """ |
---|
13 | |
---|
14 | from anuga import Domain |
---|
15 | |
---|
16 | from anuga_parallel.parallel_generic_communications import * |
---|
17 | |
---|
18 | import numpy as num |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | class Parallel_domain(Domain): |
---|
23 | |
---|
24 | def __init__(self, coordinates, vertices, |
---|
25 | boundary=None, |
---|
26 | full_send_dict=None, |
---|
27 | ghost_recv_dict=None, |
---|
28 | number_of_full_nodes=None, |
---|
29 | number_of_full_triangles=None, |
---|
30 | geo_reference=None): #jj added this |
---|
31 | |
---|
32 | Domain.__init__(self, |
---|
33 | coordinates, |
---|
34 | vertices, |
---|
35 | boundary, |
---|
36 | full_send_dict=full_send_dict, |
---|
37 | ghost_recv_dict=ghost_recv_dict, |
---|
38 | processor=pypar.rank(), |
---|
39 | numproc=pypar.size(), |
---|
40 | number_of_full_nodes=number_of_full_nodes, |
---|
41 | number_of_full_triangles=number_of_full_triangles, |
---|
42 | geo_reference=geo_reference) #jj added this |
---|
43 | |
---|
44 | |
---|
45 | setup_buffers(self) |
---|
46 | |
---|
47 | |
---|
48 | def set_name(self, name): |
---|
49 | """Assign name based on processor number |
---|
50 | """ |
---|
51 | |
---|
52 | if name.endswith('.sww'): |
---|
53 | name = name[:-4] |
---|
54 | |
---|
55 | # Call parents method with processor number attached. |
---|
56 | Domain.set_name(self, name + '_P%d_%d' %(self.processor, self.numproc)) |
---|
57 | |
---|
58 | |
---|
59 | def update_timestep(self, yieldstep, finaltime): |
---|
60 | """Calculate local timestep |
---|
61 | """ |
---|
62 | |
---|
63 | communicate_flux_timestep(self, yieldstep, finaltime) |
---|
64 | |
---|
65 | Domain.update_timestep(self, yieldstep, finaltime) |
---|
66 | |
---|
67 | |
---|
68 | def update_ghosts(self): |
---|
69 | |
---|
70 | # We must send the information from the full cells and |
---|
71 | # receive the information for the ghost cells |
---|
72 | |
---|
73 | |
---|
74 | communicate_ghosts(self) |
---|