source: anuga_core/source/anuga/shallow_water_balanced/swb_domain.py @ 7559

Last change on this file since 7559 was 7559, checked in by steve, 14 years ago

Broke up test_swb_domain so that we can concentrate on new functionality

File size: 4.1 KB
Line 
1
2from anuga.shallow_water.shallow_water_domain import *
3from anuga.shallow_water.shallow_water_domain import Domain as Sww_domain
4
5
6##############################################################################
7# Shallow Water Balanced Domain
8#
9# Uses extra evolved quantities height, elevation, xvelocity, yvelocity
10##############################################################################
11
12##
13# @brief Class for a shallow water balanced domain.
14class Domain(Sww_domain):
15
16    ##
17    # @brief Instantiate a shallow water domain.
18    # @param coordinates
19    # @param vertices
20    # @param boundary
21    # @param tagged_elements
22    # @param geo_reference
23    # @param use_inscribed_circle
24    # @param mesh_filename
25    # @param use_cache
26    # @param verbose
27    # @param full_send_dict
28    # @param ghost_recv_dict
29    # @param processor
30    # @param numproc
31    # @param number_of_full_nodes
32    # @param number_of_full_triangles
33    def __init__(self,
34                 coordinates=None,
35                 vertices=None,
36                 boundary=None,
37                 tagged_elements=None,
38                 geo_reference=None,
39                 use_inscribed_circle=False,
40                 mesh_filename=None,
41                 use_cache=False,
42                 verbose=False,
43                 full_send_dict=None,
44                 ghost_recv_dict=None,
45                 processor=0,
46                 numproc=1,
47                 number_of_full_nodes=None,
48                 number_of_full_triangles=None):
49
50        evolved_quantities = [ 'stage', 'xmomentum', 'ymomentum', \
51                               'height', 'elevation', 'xvelocity', 'yvelocity']
52       
53        other_quantities = [ 'friction' ]
54
55
56        Sww_domain.__init__(self,
57                            coordinates = coordinates,
58                            vertices = vertices,
59                            boundary = boundary,
60                            tagged_elements = tagged_elements,
61                            geo_reference = geo_reference,
62                            use_inscribed_circle = use_inscribed_circle,
63                            mesh_filename = mesh_filename,
64                            use_cache = use_cache,
65                            verbose = verbose,
66                            evolved_quantities = evolved_quantities,
67                            other_quantities = other_quantities,
68                            full_send_dict = full_send_dict,
69                            ghost_recv_dict = ghost_recv_dict,
70                            processor = processor,
71                            numproc = numproc,
72                            number_of_full_nodes = number_of_full_nodes,
73                            number_of_full_triangles = number_of_full_triangles)
74       
75        #---------------------
76        # set some defaults
77        #---------------------
78        self.set_timestepping_method('euler')
79        self.set_default_order(1)
80        self.set_new_mannings_function(True)
81        self.set_use_edge_limiter(True)
82
83
84
85    def conserved_values_to_evolved_values(self, q_cons, q_evol):
86        """Mapping between conserved quantities and the evolved quantities.
87        Used where we have a boundary condition which works with conserved
88        quantities and we now want to use them for the new well balanced
89        code using the evolved quantities
90
91        Typically the old boundary condition will set the values in q_cons,
92
93        q_evol on input will have the values of the evolved quantities at the
94        edge point (useful as it provides values for evlevation).
95        """
96
97        wc  = q_cons[0]
98        uhc = q_cons[1]
99        vhc = q_cons[2]
100
101        we  = q_evol[0]
102        uhe = q_evol[1]
103        vhe = q_evol[2]
104
105        he  = q_evol[3]
106        be  = q_evol[4]
107        ue  = q_evol[5]
108        ve  = q_evol[6]
109
110
111        hc = wc - be
112
113        if hc < 0.0:
114            hc = 0.0
115            uc = 0.0
116            vc = 0.0
117        else:
118            uc = uhc/hc
119            vc = vhc/hc
120
121        q_evol[0]  = wc
122        q_evol[1]  = uhc
123        q_evol[2]  = vhc
124
125        q_evol[3]  = hc
126        q_evol[4]  = be
127        q_evol[5]  = uc
128        q_evol[6]  = vc
129
130
131        return q_evol
132
133 
Note: See TracBrowser for help on using the repository browser.