Changeset 3647


Ignore:
Timestamp:
Sep 21, 2006, 3:20:23 PM (18 years ago)
Author:
ole
Message:

Rearranging okushiri

Location:
anuga_validation/okushiri_2005
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_validation/okushiri_2005/create_okushiri.py

    r3646 r3647  
    66#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    77
     8from Numeric import array, zeros, Float, allclose
     9
    810from anuga.pmesh.mesh import *
    911from anuga.coordinate_transforms.geo_reference import Geo_reference
    1012
     13import project
     14
     15
     16def prepare_timeboundary(filename):
     17    """Converting benchmark 2 time series to NetCDF tms file.
     18    This is a 'throw-away' code taylor made for files like
     19    'Benchmark_2_input.txt' from the LWRU2 benchmark
     20    """
     21
     22    print 'Preparing time boundary from %s' %filename
     23    from Numeric import array
     24
     25    fid = open(filename)
     26
     27    #Skip first line
     28    line = fid.readline()
     29
     30    #Read remaining lines
     31    lines = fid.readlines()
     32    fid.close()
     33
     34
     35    N = len(lines)
     36    T = zeros(N, Float)  #Time
     37    Q = zeros(N, Float)  #Values
     38
     39    for i, line in enumerate(lines):
     40        fields = line.split()
     41
     42        T[i] = float(fields[0])
     43        Q[i] = float(fields[1])
     44
     45
     46    #Create tms file
     47    from Scientific.IO.NetCDF import NetCDFFile
     48
     49    outfile = filename[:-4] + '.tms'
     50    print 'Writing to', outfile
     51    fid = NetCDFFile(outfile, 'w')
     52
     53    fid.institution = 'Geoscience Australia'
     54    fid.description = 'Input wave for Benchmark 2'
     55    fid.starttime = 0.0
     56    fid.createDimension('number_of_timesteps', len(T))
     57    fid.createVariable('time', Float, ('number_of_timesteps',))
     58    fid.variables['time'][:] = T
     59
     60    fid.createVariable('stage', Float, ('number_of_timesteps',))
     61    fid.variables['stage'][:] = Q[:]
     62
     63    fid.createVariable('xmomentum', Float, ('number_of_timesteps',))
     64    fid.variables['xmomentum'][:] = 0.0
     65
     66    fid.createVariable('ymomentum', Float, ('number_of_timesteps',))
     67    fid.variables['ymomentum'][:] = 0.0
     68
     69    fid.close()
     70
     71
    1172#-------------------------------------------------------------
    1273if __name__ == "__main__":
    1374
     75    #Preparing points
     76    #(Only when using original Benchmark_2_Bathymetry.txt file)
     77    #from anuga.abstract_2d_finite_volumes.data_manager import xya2pts
     78    #xya2pts(project.bathymetry_filename, verbose = True,
     79    #        z_func = lambda z: -z)
     80
     81
     82
     83
     84
     85    # Prepare time boundary
     86    prepare_timeboundary(project.boundary_filename)
     87
     88
     89    # Create Mesh
    1490
    1591    #Basic geometry
  • anuga_validation/okushiri_2005/lwru2.py

    r3637 r3647  
    1010"""
    1111
     12# Module imports
     13from Numeric import array, zeros, Float, allclose
     14
     15from anuga.shallow_water import Domain
     16from anuga.shallow_water import Reflective_boundary
     17from anuga.shallow_water import Transmissive_Momentum_Set_Stage_boundary
     18from anuga.abstract_2d_finite_volumes.util import file_function
     19
     20import project
     21
     22
     23#-------------------------
     24# Create Domain
     25#-------------------------
    1226
    1327use_variable_mesh = True #Use large variable mesh generated by create_mesh.py
    1428#use_variable_mesh = False #Use small structured mesh for speed
    1529
    16 
    17 #import sys
    18 #from os import sep
    19 #sys.path.append('..'+sep+'..'+sep) #FIXME: Shouldn't be necessary
    20 
    21 def prepare_timeboundary(filename):
    22     """Converting benchmark 2 time series to NetCDF tms file.
    23     This is a 'throw-away' code taylor made for files like
    24     'Benchmark_2_input.txt' from the LWRU2 benchmark
    25     """
    26 
    27     print 'Preparing time boundary from %s' %filename
    28     from Numeric import array
    29 
    30     fid = open(filename)
    31 
    32     #Skip first line
    33     line = fid.readline()
    34 
    35     #Read remaining lines
    36     lines = fid.readlines()
    37     fid.close()
    38 
    39 
    40     N = len(lines)
    41     T = zeros(N, Float)  #Time
    42     Q = zeros(N, Float)  #Values
    43 
    44     for i, line in enumerate(lines):
    45         fields = line.split()
    46 
    47         T[i] = float(fields[0])
    48         Q[i] = float(fields[1])
    49 
    50 
    51     #Create tms file
    52     from Scientific.IO.NetCDF import NetCDFFile
    53 
    54     outfile = filename[:-4] + '.tms'
    55     print 'Writing to', outfile
    56     fid = NetCDFFile(outfile, 'w')
    57 
    58     fid.institution = 'Geoscience Australia'
    59     fid.description = 'Input wave for Benchmark 2'
    60     fid.starttime = 0.0
    61     fid.createDimension('number_of_timesteps', len(T))
    62     fid.createVariable('time', Float, ('number_of_timesteps',))
    63     fid.variables['time'][:] = T
    64 
    65     fid.createVariable('stage', Float, ('number_of_timesteps',))
    66     fid.variables['stage'][:] = Q[:]
    67 
    68     fid.createVariable('xmomentum', Float, ('number_of_timesteps',))
    69     fid.variables['xmomentum'][:] = 0.0
    70 
    71     fid.createVariable('ymomentum', Float, ('number_of_timesteps',))
    72     fid.variables['ymomentum'][:] = 0.0
    73 
    74     fid.close()
    75 
    76 
    77 # Module imports
    78 from anuga.shallow_water import Domain, Reflective_boundary,\
    79      File_boundary, Transmissive_Momentum_Set_Stage_boundary
    80 
    81 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    82 from anuga.abstract_2d_finite_volumes.pmesh2domain import pmesh_to_domain_instance
    83 from Numeric import array, zeros, Float, allclose
    84 import project
    85 from caching import cache
    86 
    87 #Preparing time boundary
    88 prepare_timeboundary(project.boundary_filename)
    89 
    90 #Preparing points (Only when using original Benchmark_2_Bathymetry.txt file)
    91 #from anuga.abstract_2d_finite_volumes.data_manager import xya2pts
    92 #xya2pts(project.bathymetry_filename, verbose = True,
    93 #        z_func = lambda z: -z)
    94 
    95 
    96 
    97 #######################
    98 # Create Domain
    9930if use_variable_mesh is True:
    10031    print 'Creating domain from', project.mesh_filename
    10132
    10233    domain = Domain(project.mesh_filename, use_cache=True, verbose=True)
    103 
    10434else:
    10535    print 'Creating regular mesh'
     
    11343
    11444
    115 
    116 
    117 import sys, os
    118 base = os.path.basename(sys.argv[0])
    119 domain.filename, _ = os.path.splitext(base)
    120 domain.default_order = 2
    121 domain.store = True    #Store for visualisation purposes
     45domain.set_name('lwru2')
     46domain.set_default_order(2)
    12247
    12348#domain.check_integrity()
     
    12752
    12853
    129 
    130 #######################
     54#-------------------------
    13155# Initial Conditions
    132 print 'Initial values'
    133 
     56#-------------------------
     57domain.set_quantity('friction', 0.0)
     58domain.set_quantity('stage', 0.0)
    13459domain.set_quantity('elevation',
    13560                    filename = project.bathymetry_filename[:-4] + '.pts',
    136                     #alpha = 0.01,
    13761                    alpha = 0.02,                   
    13862                    verbose = True,
    13963                    use_cache = True)
    14064
    141 domain.set_quantity('friction', 0.0)
    142 domain.set_quantity('stage', 0.0)
    143 
    144 
    145 
    146 ######################
     65#-------------------------
    14766# Boundary Conditions
    148 #
    149 print 'Boundaries'
     67#-------------------------
    15068Br = Reflective_boundary(domain)
    15169
    152 from anuga.abstract_2d_finite_volumes.util import file_function
    15370function = file_function(project.boundary_filename[:-4] + '.tms',
    15471                         domain,
    15572                         verbose = True)
     73
    15674Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function)
    15775
     
    16381
    16482
    165 
    166 #######################
    167 # Evolve
     83#-------------------------
     84# Evolve through time
     85#-------------------------
    16886import time
    16987t0 = time.time()
  • anuga_validation/okushiri_2005/okushiri_parallel.py

    r3645 r3647  
    2323
    2424import project
    25 
    26 
    27 
    28 def prepare_timeboundary(filename):
    29     """Converting benchmark 2 time series to NetCDF tms file.
    30     This is a 'throw-away' code taylor made for files like
    31     'Benchmark_2_input.txt' from the LWRU2 benchmark
    32     """
    33 
    34     print 'Preparing time boundary from %s' %filename
    35     fid = open(filename)
    36 
    37     #Skip first line
    38     line = fid.readline()
    39 
    40     #Read remaining lines
    41     lines = fid.readlines()
    42     fid.close()
    43 
    44 
    45     N = len(lines)
    46     T = zeros(N, Float)  #Time
    47     Q = zeros(N, Float)  #Values
    48 
    49     for i, line in enumerate(lines):
    50         fields = line.split()
    51 
    52         T[i] = float(fields[0])
    53         Q[i] = float(fields[1])
    54 
    55 
    56     #Create tms file
    57     from Scientific.IO.NetCDF import NetCDFFile
    58 
    59     outfile = filename[:-4] + '.tms'
    60     print 'Writing to', outfile
    61     fid = NetCDFFile(outfile, 'w')
    62 
    63     fid.institution = 'Geoscience Australia'
    64     fid.description = 'Input wave for Benchmark 2'
    65     fid.starttime = 0.0
    66     fid.createDimension('number_of_timesteps', len(T))
    67     fid.createVariable('time', Float, ('number_of_timesteps',))
    68     fid.variables['time'][:] = T
    69 
    70     fid.createVariable('stage', Float, ('number_of_timesteps',))
    71     fid.variables['stage'][:] = Q[:]
    72 
    73     fid.createVariable('xmomentum', Float, ('number_of_timesteps',))
    74     fid.variables['xmomentum'][:] = 0.0
    75 
    76     fid.createVariable('ymomentum', Float, ('number_of_timesteps',))
    77     fid.variables['ymomentum'][:] = 0.0
    78 
    79     fid.close()
    80 
    81 
    82 
    83 #----------------------
    84 # Preparing time boundary
    85 #-------------------------
    86 if myid == 0:
    87     prepare_timeboundary(project.boundary_filename)
    8825
    8926
Note: See TracChangeset for help on using the changeset viewer.