Ignore:
Timestamp:
Aug 23, 2005, 2:56:21 PM (20 years ago)
Author:
ole
Message:

Recovered validation stuff from 18 August + wrapping up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/validation/LWRU2/lwru2.py

    r1736 r1742  
    7777from Numeric import array, zeros, Float, allclose
    7878import filenames
     79from caching import cache
    7980
    80 picklefile = 'domain.pck'
    81 from cPickle import dump, load
     81#Preparing time boundary
     82prepare_timeboundary(filenames.boundary_filename)
    8283
    83 N = 100
    84 
    85 try:
    86     #raise Exception
    87     fid = open(picklefile)
    88     print 'Read pickled domain'
    89     domain = load(fid)
    90 
    91 except:
    92 
    93     #Preparing time boundary
    94     prepare_timeboundary(filenames.boundary_filename)
    95 
    96     #Preparing points
    97     from pyvolution.data_manager import xya2pts
    98     xya2pts(filenames.bathymetry_filename, verbose = True,
    99             z_func = lambda z: -z)
     84#Preparing points
     85from pyvolution.data_manager import xya2pts
     86xya2pts(filenames.bathymetry_filename, verbose = True,
     87        z_func = lambda z: -z)
    10088
    10189
    102     #######################
    103     # Domain
     90#######################
     91# Domain
    10492   
    105     if read_mesh is True:
    106         print 'Creating domain from', filenames.mesh_filename
    107         domain = pmesh_to_domain_instance(filenames.mesh_filename, Domain)   
    108     else:       
    109         print 'Creating regular domain'
    110         points, vertices, boundary = rectangular(N, N/5*3,
    111                                                  len1=5.448, len2=3.402)
    112         domain = Domain(points, vertices, boundary)
     93if read_mesh is True:
     94    print 'Creating domain from', filenames.mesh_filename
     95    domain = pmesh_to_domain_instance(filenames.mesh_filename, Domain)   
     96else:   
     97    print 'Creating regular mesh'
     98    N = 100
     99    points, vertices, boundary = rectangular(N, N/5*3,
     100                                             len1=5.448, len2=3.402)
     101    print 'Creating domain'
     102   
     103    #domain = Domain(points, vertices, boundary)
     104    domain = cache(Domain, (points, vertices, boundary))
    113105
    114106
    115107
    116     print "Number of triangles = ", len(domain)
    117     print 'The extent is ', domain.get_extent()
     108print "Number of triangles = ", len(domain)
     109print 'The extent is ', domain.get_extent()
    118110
    119111
    120     domain.check_integrity()
    121     domain.default_order = 2
     112#domain.check_integrity()
     113domain.default_order = 2
    122114
    123     print "Number of triangles = ", len(domain)
    124     domain.store = True    #Store for visualisation purposes
     115print "Number of triangles = ", len(domain)
     116domain.store = True    #Store for visualisation purposes
    125117
    126     import sys, os
    127     base = os.path.basename(sys.argv[0])
    128     domain.filename, _ = os.path.splitext(base)
     118import sys, os
     119base = os.path.basename(sys.argv[0])
     120domain.filename, _ = os.path.splitext(base)
    129121
    130     #LS code to be included in set_quantity
    131     from pyvolution import util, least_squares
    132     points, attributes = util.read_xya(filenames.bathymetry_filename[:-4] + '.pts')
     122#LS code to be included in set_quantity
     123print 'Reading points'
     124from pyvolution import util, least_squares
     125points, attributes = util.read_xya(filenames.bathymetry_filename[:-4] + '.pts')
     126elevation = attributes['elevation']
    133127
    134     #Fit attributes to mesh
    135     vertex_attributes = least_squares.fit_to_mesh(domain.coordinates,
    136                                                   domain.triangles,
    137                                                   points,
    138                                                   attributes['elevation'],
    139                                                   alpha = 0.0001,
    140                                                   verbose=True)
     128#Fit attributes to mesh
     129#vertex_attributes = least_squares.fit_to_mesh(domain.coordinates,
     130#                                              domain.triangles,
     131#                                              points,
     132#                                              attributes['elevation'],
     133#                                              alpha = 0.0001,
     134#                                              verbose=True)
    141135
    142     print 'Initial values'
    143     domain.set_quantity('elevation', vertex_attributes)
    144     domain.set_quantity('friction', 0.0)
    145     domain.set_quantity('stage', 0.0)
     136#vertex_attributes = cache(least_squares.fit_to_mesh,
     137#                          (domain.coordinates, domain.triangles,
     138#                           points, elevation) ,
     139#                          {'alpha': 0.0001, 'verbose': True})
    146140
     141print 'Initial values'
     142#domain.set_quantity('elevation', vertex_attributes)
     143domain.set_quantity('elevation', points=points, attributes=attributes['elevation'], alpha=0.0001)
     144domain.set_quantity('friction', 0.0)
     145domain.set_quantity('stage', 0.0)
    147146
    148     fid = open('domain.pck', 'w')
    149     dump(domain, fid)
    150     fid.close()
    151147
    152148
     
    166162
    167163#Set boundary conditions
    168 
    169164if read_mesh is True:
    170165    domain.set_boundary({'wave': Bts, 'wall': Br})     
Note: See TracChangeset for help on using the changeset viewer.