Changeset 3697


Ignore:
Timestamp:
Oct 5, 2006, 12:21:52 PM (18 years ago)
Author:
ole
Message:

Played with limiter example: run_sw_rectangle.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/examples/run_sw_rectangle.py

    r3696 r3697  
    11#!/usr/bin/env python
    2 #########################################################
    3 #
    4 #  Example showing improved wet dry limiting.
    5 #
    6 #
    7 #  Authors: Steve Roberts
    8 # October
    9 #
    10 #
    11 #
    12 #########################################################
     2"""
     3  Example showing improved wet dry limiting.
     4  This script runs the same simulation twice and stores the outputs in
     5  old_limiter.sww and new_limiter.sww respectively.
     6 
     7  Authors: Steve Roberts
     8  October
     9"""
    1310
    14 
     11#-----------------------------------------------------------------
     12# Common structures
     13#-----------------------------------------------------------------
     14import time
    1515from Numeric import array
    1616from anuga.shallow_water import Domain
    17 
    18 
    19 # mesh partition routines
     17from anuga.shallow_water import Reflective_boundary
    2018from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
    21 
    22 
    23 M = 30
    24 points, vertices, boundary = rectangular(M, M, len1 = 1.0, len2 = 1.0)
    25 domain = Domain(points, vertices, boundary)
    26 print 'number of triangles = ', domain.number_of_elements
    27 
    28 
    29 #---------------------------
    30 #Boundaries
    31 #---------------------------
    32 from anuga.shallow_water import Reflective_boundary
    33 
    34 R = Reflective_boundary(domain)
    35 
    36 
    37 domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
    38 domain.check_integrity()
    3919
    4020class Set_Stage:
     
    5333        return self.h0 + self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1))
    5434
     35M = 30
     36points, vertices, boundary = rectangular(M, M, len1 = 1.0, len2 = 1.0)
     37
     38yieldstep = 0.002
     39finaltime = 0.06
     40rect = [0.0, 0.0, 1.0, 1.0]
     41
     42
     43#-----------------------------------------------------------------
     44# Create domain for "old limiter" scenario
     45#-----------------------------------------------------------------
     46domain = Domain(points, vertices, boundary)
     47domain.set_name('old_limiter_second_order')
     48print 'Number of triangles =', len(domain)
     49
     50# Turn on the visualisation
     51try:
     52    domain.initialise_visualiser()
     53except:
     54    pass
     55
     56
     57#-----------------------------------------------------------------
     58# Boundaries and Initial conditions
     59#-----------------------------------------------------------------
     60R = Reflective_boundary(domain)
     61domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
    5562domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
    5663
    57 import time
    58 t0 = time.time()
    59 
    60 
    61 # Turn on the visualisation
    62 
    63 rect = [0.0, 0.0, 1.0, 1.0]
    64 domain.initialise_visualiser()
    65 
    66 yieldstep = 0.002
    67 finaltime = 0.05
    68 
    69 
    70 #===============================================================================
    71 #Old Limiter
    72 #===============================================================================
    73 
     64#-----------------------------------------------------------------
     65# Values for old limiter
     66#-----------------------------------------------------------------
    7467domain.default_order = 2
    7568domain.beta_w      = 0.9
     
    8073domain.beta_vh_dry = 0.9
    8174
    82 #Check that the boundary value gets propagated to all elements
     75#-----------------------------------------------------------------
     76# Evolve
     77#-----------------------------------------------------------------
     78t0 = time.time()
    8379for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    8480    domain.write_time()
    8581
    86 
    8782print 'That took %.2f seconds' %(time.time()-t0)
    8883print 'Note the small timesteps and the irregular flow'
    89 raw_input('press return to continue')
     84#raw_input('press return to continue')
    9085
    91 #===============================================================================
    92 #New Limiter
    93 #===============================================================================
    9486
    95 t0 = time.time()
     87#-----------------------------------------------------------------
     88# Create domain for "new limiter" scenario (2 order)
     89#-----------------------------------------------------------------
     90domain = Domain(points, vertices, boundary)
     91domain.set_name('new_limiter_second_order')
     92print 'Number of triangles =', len(domain)
     93
     94# Turn on the visualisation
     95try:
     96    domain.initialise_visualiser()
     97except:
     98    pass
     99
     100#-----------------------------------------------------------------
     101# Boundaries and Initial conditions
     102#-----------------------------------------------------------------
     103R = Reflective_boundary(domain)
     104domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
    96105domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
    97 domain.set_quantity('xmomentum', 0.0)
    98 domain.set_quantity('ymomentum', 0.0)
    99 domain.time = 0.0
    100 domain.default_order = 2
     106
     107#-----------------------------------------------------------------
     108# Values for new limiter
     109#-----------------------------------------------------------------
     110domain.set_default_order(2)
    101111domain.minimum_allowed_height = 0.001
    102112domain.beta_w      = 1.0
     
    107117domain.beta_vh_dry = 0.2
    108118
    109 #Check that the boundary value gets propagated to all elements
     119#-----------------------------------------------------------------
     120# Evolve
     121#-----------------------------------------------------------------
     122t0 = time.time()
    110123for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    111124    domain.write_time()
    112125
    113 
    114126print 'That took %.2f seconds' %(time.time()-t0)
    115127print 'Note more uniform and large timesteps'
    116 raw_input('press return to continue')
    117 
    118 #===============================================================================
    119 #First Order
    120 #===============================================================================
    121 
    122 t0 = time.time()
    123 domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
    124 domain.set_quantity('xmomentum', 0.0)
    125 domain.set_quantity('ymomentum', 0.0)
    126 domain.time = 0.0
    127 
    128 domain.default_order = 1
     128#raw_input('press return to continue')
    129129
    130130
    131 #Check that the boundary value gets propagated to all elements
     131#-----------------------------------------------------------------
     132# Create domain for "new limiter" scenario (1 order)
     133#-----------------------------------------------------------------
     134domain = Domain(points, vertices, boundary)
     135domain.set_name('new_limiter_first_order')
     136print 'Number of triangles =', len(domain)
     137
     138# Turn on the visualisation
     139try:
     140    domain.initialise_visualiser()
     141except:
     142    pass
     143
     144#-----------------------------------------------------------------
     145# Boundaries and Initial conditions
     146#-----------------------------------------------------------------
     147R = Reflective_boundary(domain)
     148domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
     149domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))
     150
     151#-----------------------------------------------------------------
     152# Values for new limiter first order
     153#-----------------------------------------------------------------
     154domain.set_default_order(1)
     155domain.minimum_allowed_height = 0.001
     156domain.beta_w      = 1.0
     157domain.beta_w_dry  = 0.2
     158domain.beta_uh     = 1.0
     159domain.beta_uh_dry = 0.2
     160domain.beta_vh     = 1.0
     161domain.beta_vh_dry = 0.2
     162
     163#-----------------------------------------------------------------
     164# Evolve
     165#-----------------------------------------------------------------
     166t0 = time.time()
    132167for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    133168    domain.write_time()
    134169
    135 
    136170print 'That took %.2f seconds' %(time.time()-t0)
    137171
     172
Note: See TracChangeset for help on using the changeset viewer.