Ignore:
Timestamp:
Nov 27, 2009, 9:31:34 AM (14 years ago)
Author:
steve
Message:

Committing a version of shallow_water_balanced which passes it unit test
using a version of edge limiting which doesn't limit boundary edges. THis
is useful to allow linear functions to be reconstructed.

Had to play with the transmissive BC and use centroid values which is
set via domain set_centroid_transmissive_bc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water_balanced/swb_domain.py

    r7559 r7573  
    33from anuga.shallow_water.shallow_water_domain import Domain as Sww_domain
    44
     5from swb_boundary_conditions import Transmissive_boundary
    56
    67##############################################################################
     
    1516
    1617    ##
    17     # @brief Instantiate a shallow water domain.
     18    # @brief Instantiate a shallow water balanced domain.
    1819    # @param coordinates
    1920    # @param vertices
     
    4849                 number_of_full_triangles=None):
    4950
     51        conserved_quantities = [ 'stage', 'xmomentum', 'ymomentum']
     52
    5053        evolved_quantities = [ 'stage', 'xmomentum', 'ymomentum', \
    5154                               'height', 'elevation', 'xvelocity', 'yvelocity']
     
    6467                            use_cache = use_cache,
    6568                            verbose = verbose,
     69                            conserved_quantities = conserved_quantities,
    6670                            evolved_quantities = evolved_quantities,
    6771                            other_quantities = other_quantities,
     
    7680        # set some defaults
    7781        #---------------------
    78         self.set_timestepping_method('euler')
    79         self.set_default_order(1)
     82        self.set_timestepping_method(1)
     83        self.set_default_order(2)
    8084        self.set_new_mannings_function(True)
    81         self.set_use_edge_limiter(True)
    82 
    83 
    84 
     85        self.set_centroid_transmissive_bc(True)
     86
     87    ##
     88    # @brief Run integrity checks on shallow water balanced domain.
     89    def check_integrity(self):
     90        Sww_domain.check_integrity(self)
     91
     92        #Check that the evolved quantities are correct (order)
     93        msg = 'First evolved quantity must be "stage"'
     94        assert self.evolved_quantities[0] == 'stage', msg
     95        msg = 'Second evolved quantity must be "xmomentum"'
     96        assert self.evolved_quantities[1] == 'xmomentum', msg
     97        msg = 'Third evolved quantity must be "ymomentum"'
     98        assert self.evolved_quantities[2] == 'ymomentum', msg
     99        msg = 'Fourth evolved quantity must be "height"'
     100        assert self.evolved_quantities[3] == 'height', msg
     101        msg = 'Fifth evolved quantity must be "elevation"'
     102        assert self.evolved_quantities[4] == 'elevation', msg
     103        msg = 'Sixth evolved quantity must be "xvelocity"'
     104        assert self.evolved_quantities[5] == 'xvelocity', msg       
     105        msg = 'Seventh evolved quantity must be "yvelocity"'
     106        assert self.evolved_quantities[6] == 'yvelocity', msg       
     107
     108        msg = 'First other quantity must be "friction"'
     109        assert self.other_quantities[0] == 'friction', msg
     110
     111    ##
     112    # @brief
     113    def compute_fluxes(self):
     114        #Call correct module function (either from this module or C-extension)
     115        compute_fluxes(self)
     116
     117    ##
     118    # @brief
     119    def distribute_to_vertices_and_edges(self):
     120        """Distribution from centroids to edges specific to the SWW eqn.
     121
     122        It will ensure that h (w-z) is always non-negative even in the
     123        presence of steep bed-slopes by taking a weighted average between shallow
     124        and deep cases.
     125
     126        In addition, all conserved quantities get distributed as per either a
     127        constant (order==1) or a piecewise linear function (order==2).
     128       
     129
     130        Precondition:
     131        All conserved quantities defined at centroids and bed elevation defined at
     132        edges.
     133       
     134        Postcondition
     135        Evolved quantities defined at vertices and edges
     136        """
     137
     138
     139        #Shortcuts
     140        Stage  = self.quantities['stage']
     141        Xmom   = self.quantities['xmomentum']
     142        Ymom   = self.quantities['ymomentum']
     143        Elev   = self.quantities['elevation']
     144        Height = self.quantities['height']
     145        Xvel   = self.quantities['xvelocity']
     146        Yvel   = self.quantities['yvelocity']
     147
     148        #Arrays   
     149        w_C   = Stage.centroid_values   
     150        uh_C  = Xmom.centroid_values
     151        vh_C  = Ymom.centroid_values   
     152        z_C   = Elev.centroid_values
     153        h_C   = Height.centroid_values
     154        u_C   = Xvel.centroid_values
     155        v_C   = Yvel.centroid_values
     156
     157        w_C[:] = num.maximum(w_C, z_C)
     158       
     159        h_C[:] = w_C - z_C
     160
     161
     162        assert num.min(h_C) >= 0
     163               
     164        num.putmask(uh_C, h_C < 1.0e-15, 0.0)
     165        num.putmask(vh_C, h_C < 1.0e-15, 0.0)
     166        num.putmask(h_C, h_C < 1.0e-15, 1.0e-15)       
     167       
     168        u_C[:]  = uh_C/h_C
     169        v_C[:]  = vh_C/h_C
     170       
     171        for name in [ 'height', 'xvelocity', 'yvelocity' ]:
     172            Q = self.quantities[name]
     173            if self._order_ == 1:
     174                Q.extrapolate_first_order()
     175            elif self._order_ == 2:
     176                Q.extrapolate_second_order_and_limit_by_edge()
     177            else:
     178                raise 'Unknown order'
     179
     180
     181        w_E     = Stage.edge_values
     182        uh_E    = Xmom.edge_values
     183        vh_E    = Ymom.edge_values     
     184        z_E     = Elev.edge_values     
     185        h_E     = Height.edge_values
     186        u_E     = Xvel.edge_values
     187        v_E     = Yvel.edge_values             
     188
     189
     190        w_E[:]   = z_E + h_E
     191
     192        #num.putmask(u_E, h_temp <= 0.0, 0.0)
     193        #num.putmask(v_E, h_temp <= 0.0, 0.0)
     194        #num.putmask(w_E, h_temp <= 0.0, z_E+h_E)
     195        #num.putmask(h_E, h_E <= 0.0, 0.0)
     196       
     197        uh_E[:] = u_E * h_E
     198        vh_E[:] = v_E * h_E
     199
     200        """
     201        print '=========================================================='
     202        print 'Time ', self.get_time()
     203        print h_E
     204        print uh_E
     205        print vh_E
     206        """
     207       
     208        # Compute vertex values by interpolation
     209        for name in self.evolved_quantities:
     210            Q = self.quantities[name]
     211            Q.interpolate_from_edges_to_vertices()
     212
     213
     214        w_V     = Stage.vertex_values
     215        uh_V    = Xmom.vertex_values
     216        vh_V    = Ymom.vertex_values   
     217        z_V     = Elev.vertex_values   
     218        h_V     = Height.vertex_values
     219        u_V     = Xvel.vertex_values
     220        v_V     = Yvel.vertex_values           
     221
     222
     223        #w_V[:]    = z_V + h_V
     224
     225        #num.putmask(u_V, h_V <= 0.0, 0.0)
     226        #num.putmask(v_V, h_V <= 0.0, 0.0)
     227        #num.putmask(w_V, h_V <= 0.0, z_V)       
     228        #num.putmask(h_V, h_V <= 0.0, 0.0)
     229       
     230        uh_V[:] = u_V * h_V
     231        vh_V[:] = v_V * h_V
     232
     233
     234    ##
     235    # @brief Code to let us use old shallow water domain BCs
    85236    def conserved_values_to_evolved_values(self, q_cons, q_evol):
    86237        """Mapping between conserved quantities and the evolved quantities.
     
    111262        hc = wc - be
    112263
    113         if hc < 0.0:
     264        if hc <= 0.0:
    114265            hc = 0.0
    115266            uc = 0.0
Note: See TracChangeset for help on using the changeset viewer.