1 | """ |
---|
2 | Template file for implementing a square pipe domain. |
---|
3 | Replace the following placeholders: |
---|
4 | |
---|
5 | <name> |
---|
6 | |
---|
7 | The name of the class. For example, we have: |
---|
8 | |
---|
9 | free_surface_fixed_width_a_d |
---|
10 | |
---|
11 | which implements a free surface flow with a fixed width channel |
---|
12 | and the conserved quantities are a = area, d = discharge. |
---|
13 | |
---|
14 | <conserved> |
---|
15 | |
---|
16 | List of conserved quantities. |
---|
17 | |
---|
18 | <centroids> |
---|
19 | |
---|
20 | Code to clean up centroids. |
---|
21 | |
---|
22 | <extrapolate> |
---|
23 | |
---|
24 | List of quantities to extrapolate from centroids to vertices. |
---|
25 | |
---|
26 | <extrapolated> |
---|
27 | |
---|
28 | Shortcut code for quantities that have been extrapolated. |
---|
29 | |
---|
30 | <update> |
---|
31 | |
---|
32 | Shortcut code for quantities that need to be updated. |
---|
33 | |
---|
34 | <reconstruct> |
---|
35 | |
---|
36 | Code to reconstruct update quantities from extrapolated quantities. |
---|
37 | May need to fix up small heights. |
---|
38 | """ |
---|
39 | |
---|
40 | from anuga_1d.sqpipe.sqpipe_domain import Sqpipe_domain |
---|
41 | from anuga_1d.sqpipe.sqpipe_forcing_terms import * |
---|
42 | from anuga_1d.sqpipe.sqpipe_boundary_conditions import * |
---|
43 | |
---|
44 | |
---|
45 | class Domain(Sqpipe_domain): |
---|
46 | |
---|
47 | def __init__(self, coordinates, boundary = None, tagged_elements = None): |
---|
48 | conserved_quantities = [<conserved>] |
---|
49 | forcing_terms = [gravity] |
---|
50 | Sqpipe_domain.__init__(self, |
---|
51 | coordinates = coordinates, |
---|
52 | conserved_quantities = conserved_quantities, |
---|
53 | forcing_terms = forcing_terms, |
---|
54 | boundary = boundary, |
---|
55 | tagged_elements = tagged_elements) |
---|
56 | |
---|
57 | self.__doc__ = 'sqpipe_<name>_domain' |
---|
58 | |
---|
59 | def compute_fluxes(self): |
---|
60 | #Call correct module function |
---|
61 | #(either from this module or C-extension) |
---|
62 | |
---|
63 | # Set initial timestep to a large value |
---|
64 | import sys |
---|
65 | timestep = float(sys.maxint) |
---|
66 | |
---|
67 | # Import flux method and call it |
---|
68 | from anuga_1d.sqpipe.sqpipe_<name>_comp_flux import compute_fluxes_ext |
---|
69 | self.flux_timestep = compute_fluxes_ext(timestep,self) |
---|
70 | |
---|
71 | def distribute_to_vertices_and_edges(self): |
---|
72 | # Shortcuts |
---|
73 | h0 = self.h0 |
---|
74 | epsilon = self.epsilon |
---|
75 | |
---|
76 | area = self.quantities['area'] |
---|
77 | discharge = self.quantities['discharge'] |
---|
78 | bed = self.quantities['elevation'] |
---|
79 | height = self.quantities['height'] |
---|
80 | velocity = self.quantities['velocity'] |
---|
81 | width = self.quantities['width'] |
---|
82 | top = self.quantities['top'] |
---|
83 | stage = self.quantities['stage'] |
---|
84 | state = self.quantities['state'] |
---|
85 | |
---|
86 | #Arrays |
---|
87 | a_C = area.centroid_values |
---|
88 | d_C = discharge.centroid_values |
---|
89 | z_C = bed.centroid_values |
---|
90 | h_C = height.centroid_values |
---|
91 | u_C = velocity.centroid_values |
---|
92 | b_C = width.centroid_values |
---|
93 | t_C = top.centroid_values |
---|
94 | w_C = stage.centroid_values |
---|
95 | s_C = state.centroid_values |
---|
96 | |
---|
97 | <centroids> |
---|
98 | |
---|
99 | for name in [<extrapolate>]: |
---|
100 | Q = self.quantities[name] |
---|
101 | if self.order == 1: |
---|
102 | Q.extrapolate_first_order() |
---|
103 | elif self.order == 2: |
---|
104 | Q.extrapolate_second_order() |
---|
105 | else: |
---|
106 | raise 'Unknown order' |
---|
107 | |
---|
108 | # These have been extrapolated |
---|
109 | <extrapolated> |
---|
110 | # e.g. |
---|
111 | #w_V = self.quantities['stage'].vertex_values |
---|
112 | #u_V = self.quantities['velocity'].vertex_values |
---|
113 | |
---|
114 | # These are the given geometry and remain fixed |
---|
115 | z_V = bed.vertex_values |
---|
116 | b_V = width.vertex_values |
---|
117 | t_V = top.vertex_values |
---|
118 | |
---|
119 | # These need to be updated |
---|
120 | <update> |
---|
121 | # e.g. |
---|
122 | #a_V = area.vertex_values |
---|
123 | #d_V = discharge.vertex_values |
---|
124 | #h_V = height.vertex_values |
---|
125 | |
---|
126 | <reconstruct> |
---|
127 | |
---|
128 | return |
---|
129 | |
---|
130 | |
---|