Changeset 4360 for anuga_core


Ignore:
Timestamp:
Apr 4, 2007, 12:48:14 PM (18 years ago)
Author:
nick
Message:

Mux to sww tests almost finished
added field_boundary to _init_

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/__init__.py

    r3678 r4360  
    1212    Transmissive_Momentum_Set_Stage_boundary,\
    1313    Dirichlet_Discharge_boundary,\
    14     Constant_stage, Constant_height
     14    Constant_stage, Constant_height,\
     15    Field_boundary
    1516
    1617
  • anuga_core/source/anuga/shallow_water/xtest_Bf.py

    r4317 r4360  
    2222
    2323# Related major packages
    24 from anuga.shallow_water import Domain,Dirichlet_boundary,File_boundary,Transmissive_boundary
    25 #from anuga.shallow_water import Reflective_boundary
     24from anuga.shallow_water import Domain,Dirichlet_boundary,File_boundary,Transmissive_boundary, Field_boundary
     25#from anuga.shallow_water.shallow_water_domain import Field_boundary
    2626from Numeric import allclose, array
    2727from anuga.pmesh.mesh_interface import create_mesh_from_regions
     
    4343tide = 2.4
    4444
     45
     46#EVOLVED MODEL
     47
    4548#--------------------------------------------------------------------------
    4649# Create the triangular mesh based on overall clipping polygon with a
     
    5255#all = [[469000,7760000],[470000,7758000],[468000,7758000]]
    5356#all = [[470000,7760000],[469000,7758000],[468000,7760000]]
    54 all_large = [[474000,7764000],[474000,7756000],[466000,7756000],[466000,7764000]]
    55 all = [[470000,7764000],[470000,7756000],[466000,7756000],[466000,7764000]]
     57
     58#all_large = [[474000,7764000],[474000,7756000],[466000,7756000],[466000,7764000]]
     59#all = [[470000,7764000],[470000,7756000],[466000,7756000],[466000,7764000]]
     60all = [[465184,7764500],[470397,7764510],[470407,7758988],[465195,7758979]]
     61# N, W, S, E
     62
    5663create_mesh_from_regions(all,
    5764#                             boundary_tags={'ocean': [0,1,2]},
    5865#                             boundary_tags={'ocean': [ 2],'side': [0, 1]},
    59                              boundary_tags={'ocean': [ 2],'side': [1, 3], 'back': [0]},
     66                             boundary_tags={'ocean': [ 0],'side': [1, 3], 'back': [2]},
    6067                             maximum_triangle_area=50000,
    6168                             filename=meshes_dir_name,
    6269                             use_cache=False,
    63                              #verbose=True
     70#                             verbose=True
    6471                             )
    6572
     
    6774# Setup computational domain
    6875#-------------------------------------------------------------------------
    69 print 'Setup computational domain'
     76#print 'Setup computational domain'
    7077domain = Domain( meshes_dir_name, verbose=True)
     78
     79from anuga.shallow_water.data_manager import urs2sww
     80boundaries_dir_name = 'o_test'
     81
     82# convert MUX urs files to an SWW file output
     83#print 'boundary file is: ',boundaries_dir_name
     84from caching import cache
     85cache(urs2sww,
     86          (boundaries_dir_name,
     87           boundaries_dir_name),
     88          {'verbose': False,
     89           'mint': 9200, 'maxt': 11200,
     90#           'origin': domain.geo_reference.get_origin(),
     91           'fail_on_NaN': False},
     92           verbose = False,
     93           )
    7194   
    7295#-------------------------------------------------------------------------
     
    7497#-------------------------------------------------------------------------
    7598
    76 print 'Start Set quantity'
     99#print 'Start Set quantity'
    77100
    78101domain.set_quantity('elevation', -42.3)
    79102
    80 print 'Finished Set quantity'
     103#print 'Finished Set quantity'
    81104
    82105#------------------------------------------------------
     
    84107#------------------------------------------------------
    85108
    86 domain.set_quantity('stage', 2.4)
     109domain.set_quantity('stage', tide)
    87110domain.set_quantity('friction', 0.01)
    88111domain.set_name(fileName)
     
    92115# Setup boundary conditions
    93116#-------------------------------------------------------------------------
    94 Bf = File_boundary(out_dir + 'o_test_8500_12000.sww',
    95                   domain, time_thinning=24, use_cache=True, verbose=True)
    96 
    97 print 'finished reading boundary file'
     117#Bf = File_boundary(out_dir + 'o_test_8500_12000.sww',
     118#                  domain, time_thinning=24, use_cache=True, verbose=True)
     119Bf = Field_boundary(out_dir + 'o_test.sww',
     120                  domain, mean_stage=tide, use_cache=True, verbose=False)
     121
     122#print 'finished reading boundary file'
    98123
    99124#Br = Reflective_boundary(domain)
     
    101126Bd = Dirichlet_boundary([tide,0,0])
    102127
    103 print'set_boundary'
     128#print'set_boundary'
    104129
    105130domain.set_boundary({'back': Bt,
     
    107132                    'ocean': Bf
    108133                    })
    109 print'finish set boundary'
     134#print'finish set boundary'
    110135
    111136#----------------------------------------------------------------------------
     
    113138#----------------------------------------------------------------------------
    114139
     140#remove mesh file!!! and o_test.sww
    115141t0 = time.time()
    116142
    117 for t in domain.evolve(yieldstep = 60, finaltime = 3400):
     143for t in domain.evolve(yieldstep = 60, finaltime = 1920):
    118144    domain.write_time()
    119     domain.write_boundary_statistics(tags = 'ocean')
    120 
    121 
    122 
    123 
     145#    domain.write_boundary_statistics()
     146
     147
     148
     149#Gets timeseries from boundary sww and evolved sww
    124150home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
    125151#user = get_user_name()
     
    145171
    146172
    147 gauge_boundary_filename = 'boundary_gauge_near_top.csv'
     173#gauge_boundary_filename = 'boundary_gauge_near_top.csv'
     174gauge_boundary_filename = 'gauges_time_series_b_near_top.csv'
    148175gauge_evolved_filename = 'gauges_time_series_near_top.csv'
    149176
    150177boundary_dir_filename = os.path.join(out_dir,gauge_boundary_filename)
    151 print'boundary_dir_filename',boundary_dir_filename
     178#print'boundary_dir_filename',boundary_dir_filename
    152179
    153180evolved_dir_filename= os.path.join(out_dir,gauge_evolved_filename)
    154181
    155 print'boundary_dir_filename',boundary_dir_filename
    156 print'evolved_dir_filename',evolved_dir_filename
     182#print'boundary_dir_filename',boundary_dir_filename
     183#print'evolved_dir_filename',evolved_dir_filename
    157184                                     
    158185swwfiles = {}
    159186swwfile = out_dir + fileName + '.sww'
    160187swwfiles[swwfile] = run_time
    161 print"swwfiles",swwfiles,"shallow_water"
     188#print"swwfiles",swwfiles,"shallow_water"
    162189       
    163190texname, elev_output = sww2timeseries(swwfiles,
     
    171198                                      title_on = False,
    172199                                      use_cache = True,
    173                                       verbose = True)
     200                                      verbose = False)
     201                                     
     202swwfiles = {}
     203swwfile = out_dir + boundaries_dir_name + '.sww'
     204swwfiles[swwfile] = run_time
     205#print"swwfiles",swwfiles,"shallow_water"
     206       
     207texname, elev_output = sww2timeseries(swwfiles,
     208                                      out_dir+sep+"boundary_gauges.csv",
     209                                      production_dirs,
     210                                      report = False,
     211                                      plot_quantity = ['stage', 'xmomentum', 'ymomentum'],
     212                                      surface = False,
     213                                      time_min = None,
     214                                      time_max = None,
     215                                      title_on = False,
     216                                      use_cache = True,
     217                                      verbose = False)
    174218
    175219#makes the csv files from the evolved model
     
    182226e_elevation = e_data[:,4]
    183227
    184 print'boundary_dir_filename',boundary_dir_filename
     228#print'boundary_dir_filename',boundary_dir_filename
    185229b_header, b_data = get_data_from_file(boundary_dir_filename)
    186230
     
    194238# compares the 2 models
    195239j=0
    196 k=1
     240k=0
    197241b_sample = []
    198242e_sample = []
     
    200244#    if j<(len(e_time)) and b_time[i] == e_time[j]:
    201245    if j<(len(e_time)) and k<(len(e_time)) and b_time[i] == e_time[j]:
    202         b_sample.append(float(b_stage[i]))
     246        b_sample.append(float(tide+b_stage[i]))
    203247        e_sample.append(float(e_stage[k]))
    204 #        print 'out:', b_time[i], b_stage[i],i, j, b_sample[j],e_stage[j]
    205 #        if k <len(e_time): print 'time e equal b:', b_time[i], b_stage[i],i, j, b_sample[j],e_stage[j], e_stage[k],(len(e_time)-1)
    206         if k <len(e_time): print 'time e equal b:', b_time[i],i, j, b_stage[i], e_stage[k],(len(e_time)-1)
     248#        if k <len(e_time): print 'time e equal b:', b_time[i],i, j, b_stage[i], b_sample[i], e_stage[k],(len(e_time)-1)
    207249        j = j +1
    208250        k = k +1
    209251
    210252
    211 print len(b_sample), len(e_stage),e_stage,type(e_stage)
     253#print len(b_sample), len(e_stage),e_stage,type(e_stage)
    212254e_stage = e_stage.tolist()
    213255e_stage.pop()
    214256#e_stage.pop()
    215257 
    216 print len(b_sample), len(e_stage),e_stage
     258#print len(b_sample), len(e_stage),e_stage
    217259
    218260
     
    220262print "test successful"
    221263os.remove(fileName+'.sww')
    222 print 'evolved_dir_filename',evolved_dir_filename
     264#print 'evolved_dir_filename',evolved_dir_filename
    223265os.remove('gauges_time_series_near_top.csv')
     266os.remove('gauges_time_series_b_near_top.csv')
     267os.remove('gauges_t0.csv')
    224268os.remove('gauges_maxmins.csv')
     269os.remove(meshes_dir_name)
     270
    225271
    226272assert allclose (b_sample, e_sample, 0.5, 0.5)
Note: See TracChangeset for help on using the changeset viewer.