Ignore:
Timestamp:
Mar 11, 2008, 4:21:13 AM (17 years ago)
Author:
ole
Message:

Updated the old netherlands example in preparation for Steve's new deep-water limiter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/demos/netherlands.py

    r4713 r5153  
    66"""
    77
    8 ######################
    9 # Module imports
    10 #
     8#------------------------------------------------------------------------------
     9# Import necessary modules
     10#------------------------------------------------------------------------------
     11
     12from anuga.shallow_water import Domain
     13from anuga.shallow_water import Reflective_boundary, Dirichlet_boundary
     14from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
     15import os
     16
     17#from anuga.visualiser import RealtimeVisualiser
    1118#import rpdb
    1219#rpdb.set_active()
    1320
    14 from anuga.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
    15      Transmissive_boundary, Constant_height, Constant_stage
    1621
    17 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    18 from Numeric import array
    19 from anuga.visualiser import RealtimeVisualiser
     22#------------------------------------------------------------------------------
     23# Setup computational domain
     24#------------------------------------------------------------------------------
     25
     26N = 150 # size = 45000
     27N = 130 # size = 33800
     28N = 600 # Size = 720000
     29N = 100
     30
     31points, elements, boundary = rectangular_cross(N, N)
     32domain = Domain(points, elements, boundary, use_inscribed_circle=True)
     33
     34domain.check_integrity()
     35
     36domain.set_name(os.path.splitext(__file__)[0])
     37domain.set_timestepping_method('rk3')
     38domain.set_default_order(2)
     39domain.set_store_vertices_uniquely(True) # Store as internally represented
     40domain.tight_slope_limiters = True
     41print domain.statistics()
     42
     43
     44# Setup order and all the beta's for the limiters (these should become defaults
     45
     46#domain.beta_w      = 1.0
     47#domain.beta_w_dry  = 0.2
     48#domain.beta_uh     = 1.0
     49#domain.beta_uh_dry = 0.2
     50#domain.beta_vh     = 1.0
     51#domain.beta_vh_dry = 0.2
     52
     53#domain.alpha_balance = 100.0
     54
     55
     56
     57#------------------------------------------------------------------------------
     58# Setup initial conditions
     59#------------------------------------------------------------------------------
    2060
    2161class Weir:
     
    3575        z = zeros(N, Float)
    3676        for i in range(N):
    37             z[i] = -x[i]/20  #General slope
     77            z[i] = -x[i]/20  # General slope
    3878
    39             #Flattish bit to the left
     79            # Flattish bit to the left
    4080            if x[i] <= 0.3:
    4181                #z[i] = -x[i]/5
     
    4383
    4484
    45             #Weir
     85            # Weir
    4686            if x[i] > 0.3 and x[i] < 0.4:
    4787                z[i] = -x[i]/20+1.2
    4888
    49             #Dip
     89            # Dip
    5090            #if x[i] > 0.6 and x[i] < 0.9:
    5191            #    z[i] = -x[i]/20-0.5  #-y[i]/5
    5292
    53             #Hole in weir
     93            # Hole in weir
    5494            #if x[i] > 0.3 and x[i] < 0.4 and y[i] > 0.2 and y[i] < 0.4:
    5595            if x[i] > 0.3 and x[i] < 0.4 and y[i] > 0.4 and y[i] < 0.6:
     
    5797                z[i] = -x[i]/20
    5898
    59             #Poles
     99            # Poles
    60100            #if x[i] > 0.65 and x[i] < 0.8 and y[i] > 0.55 and y[i] < 0.65 or\
    61101            #       x[i] > 0.75 and x[i] < 0.9 and y[i] > 0.35 and y[i] < 0.45:
     
    67107
    68108
    69             #Wall
     109            # Wall
    70110            if x[i] > 0.995:
    71111                z[i] = -x[i]/20+0.3
     
    74114
    75115
     116inflow_stage = 0.5
     117manning = 0.0
    76118
    77 ######################
    78 # Domain
    79 #
     119domain.set_quantity('elevation', Weir(inflow_stage))
     120domain.set_quantity('friction', manning)
     121domain.set_quantity('stage', expression='elevation + 0.0')
    80122
    81123
    82 N = 150 #size = 45000
    83 N = 130 #size = 33800
    84 N = 600 #Size = 720000
    85 N = 100
     124#------------------------------------------------------------------------------
     125# Setup boundary conditions
     126#------------------------------------------------------------------------------
     127
     128Br = Reflective_boundary(domain)
     129Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0]) # Constant inflow
     130domain.set_boundary({'left': Bd, 'right': Br, 'bottom': Br, 'top': Br})
    86131
    87132
    88 #N = 15
     133#------------------------------------------------------------------------------
     134# Evolve system through time
     135#------------------------------------------------------------------------------
    89136
    90 print 'Creating domain'
    91 #Create basic mesh
    92 points, elements, boundary = rectangular_cross(N, N)
    93137
    94 #Create shallow water domain
    95 domain = Domain(points, elements, boundary, use_inscribed_circle=True)
     138if N <= 150:
     139    # Initialise real-time visualiser
    96140
    97 domain.check_integrity()
    98 
    99 domain.set_timestepping_method('rk3')
    100 domain.set_default_order(2)
    101 
    102 #Setup order and all the beta's for the limiters (these should become defaults
    103 
    104 ## domain.beta_w      = 1.0
    105 ## domain.beta_w_dry  = 0.2
    106 ## domain.beta_uh     = 1.0
    107 ## domain.beta_uh_dry = 0.2
    108 ## domain.beta_vh     = 1.0
    109 ## domain.beta_vh_dry = 0.2
    110 
    111 ## domain.alpha_balance = 100.0
    112 
    113 #Output params
    114 domain.smooth = False
    115 domain.reduction = min  #Looks a lot better on top of steep slopes
    116 
    117 print "Number of triangles = ", len(domain)
    118 print "Extent = ", domain.get_extent()
    119 
    120 #Set bed-slope and friction
    121 inflow_stage = 0.5
    122 manning = 0.0
    123 Z = Weir(inflow_stage)
    124 
    125 if N > 150:
    126     domain.checkpoint = False
    127     domain.store = True    #Store for visualisation purposes
    128     domain.format = 'sww'   #Native netcdf visualisation format
    129     import sys, os
    130     #FIXME: This was os.path.splitext but caused weird filenames based on root
    131     base = os.path.basename(sys.argv[0])
    132     basename, _ = os.path.splitext(base)
    133     domain.set_name(basename)
    134 else:
    135     domain.checkpoint = False
    136     domain.store = False
    137     vis = RealtimeVisualiser(domain)
    138     vis.render_quantity_height("elevation", dynamic=False)
    139     vis.render_quantity_height("stage", dynamic=True)
    140     vis.colour_height_quantity('stage', (0.0, 0.0, 0.8))
    141     vis.start()
     141    pass
     142    #vis = RealtimeVisualiser(domain)
     143    #vis.render_quantity_height("elevation", dynamic=False)
     144    #vis.render_quantity_height("stage", dynamic=True)
     145    #vis.colour_height_quantity('stage', (0.0, 0.0, 0.8))
     146    #vis.start()
    142147
    143148
    144149
    145 print 'Field values'
    146 domain.set_quantity('elevation', Z)
    147 domain.set_quantity('friction', manning)
    148 
    149 
    150 ######################
    151 # Boundary conditions
    152 #
    153 print 'Boundaries'
    154 Br = Reflective_boundary(domain)
    155 Bt = Transmissive_boundary(domain)
    156 
    157 #Constant inflow
    158 Bd = Dirichlet_boundary([inflow_stage, 0.0, 0.0])
    159 
    160 
    161 #Set boundary conditions
    162 domain.set_boundary({'left': Bd, 'right': Br, 'bottom': Br, 'top': Br})
    163 
    164 
    165 ######################
    166 #Initial condition
    167 #
    168 print 'Initial condition'
    169 domain.set_quantity('stage', expression='elevation + 0.0')
    170 
    171 #Evolve
    172150import time
    173151t0 = time.time()
    174152
    175153for t in domain.evolve(yieldstep = 0.005, finaltime = None):
    176     domain.write_time()
    177     #domain.write_boundary()
    178     vis.update()
     154    print domain.timestepping_statistics()
    179155    print domain.quantities['stage'].get_values(location='centroids',
    180156                                                indices=[0])
     157                                               
     158    #vis.update()                                               
    181159    #time.sleep(0.1)
    182160    #raw_input('pause>')
     
    184162    #rpdb.set_active()
    185163    #integral_label.text='Integral=%10.5e'%domain.quantities['stage'].get_integral()
    186 vis.evolveFinished()
     164#vis.evolveFinished()
    187165
    188166print 'That took %.2f seconds' %(time.time()-t0)
    189167
    190 
    191 vis.join()
     168#vis.join()
Note: See TracChangeset for help on using the changeset viewer.