Ignore:
Timestamp:
Jun 5, 2010, 10:58:55 AM (14 years ago)
Author:
hudson
Message:

Almost all failing tests fixed.

Location:
trunk/anuga_core/source/anuga
Files:
20 edited

Legend:

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

    r7778 r7780  
    1 """ This is the public API to ANUGA. It provides a toolkit of often-used
     1""" ANUGA models the effect of tsunamis and flooding upon a terrain mesh.
     2    In typical usage, a Domain class is created for a particular piece of
     3    terrain. Boundary conditions are specified for the domain, such as inflow
     4    and outflow, and then the simulation is run.
     5
     6    This is the public API to ANUGA. It provides a toolkit of often-used
    27    modules, which can be used directly by including the following line in
    38    the user's code:
    49
    510    import anuga
    6    
    7     It abstracts away the internal heirarchy of the ANUGA system, allowing the
    8     user to concentrate on writing simulations without searching through the
    9     ANUGA source tree for the functions that they need.
     11       
     12    This usage pattern abstracts away the internal heirarchy of the ANUGA
     13    system, allowing the user to concentrate on writing simulations without
     14    searching through the ANUGA source tree for the functions that they need.
    1015   
    1116    Also, it isolates the user from "under-the-hood" refactorings.
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/gauge.py

    r7694 r7780  
    146146    from anuga.utilities.numerical_tools import ensure_numeric, mean, NAN
    147147    import string
    148     from anuga.shallow_water.data_manager import get_all_swwfiles
     148    from anuga.utilities.file_utils import get_all_swwfiles
    149149    from anuga.abstract_2d_finite_volumes.util import file_function   
    150150
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r7737 r7780  
    11"""Class Domain - 2D triangular domains for finite-volume computations of
    22   conservation laws.
     3   
     4   This is the base class for various domain models, such as: the Advection
     5   implementation is a simple algorithm, mainly for testing purposes, and
     6   the standard Shallow Water Wave domain (simply known as Domain) is the
     7   standard for realistic simulation.
    38
    49
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py

    r7778 r7780  
    886886
    887887
    888     def test_that_mesh_methods_exist(self):
    889         """test_that_mesh_methods_exist
    890        
    891         Test that relavent mesh methods are made available in
    892         domain through composition
    893         """
    894         from mesh_factory import rectangular
    895         from shallow_water import Domain
    896 
    897         # Create basic mesh
    898         points, vertices, boundary = rectangular(1, 3)
    899 
    900         # Create shallow water domain
    901         domain = Domain(points, vertices, boundary)                             
    902        
    903        
    904         domain.get_centroid_coordinates()
    905         domain.get_radii()
    906         domain.get_areas()
    907         domain.get_area()
    908         domain.get_vertex_coordinates()
    909         domain.get_triangles()
    910         domain.get_nodes()
    911         domain.get_number_of_nodes()
    912         domain.get_normal(0,0)
    913         domain.get_triangle_containing_point([0.4,0.5])
    914         domain.get_intersecting_segments([[0.0, 0.0], [0.0, 1.0]])
    915         domain.get_disconnected_triangles()
    916         domain.get_boundary_tags()
    917         domain.get_boundary_polygon()
    918         #domain.get_number_of_triangles_per_node()
    919         domain.get_triangles_and_vertices_per_node()
    920         domain.get_interpolation_object()
    921         domain.get_tagged_elements()
    922         domain.get_lone_vertices()
    923         domain.get_unique_vertices()
    924         g = domain.get_georeference()
    925         domain.set_georeference(g)
    926         domain.build_tagged_elements_dictionary()
    927         domain.statistics()
    928         domain.get_extent()
    929 
    930     def NOtest_vertex_within_hole(self):
    931         """ NOTE: This test fails - it is designed to test fitting on
    932             a mesh with a hole, but more info is needed on the specific
    933             problem."""
    934        
    935         # For test_fitting_using_shallow_water_domain example
    936         def linear_function(point):
    937             point = num.array(point)
    938             return point[:,0]+point[:,1]       
    939        
    940         meshname = 'test_mesh.msh'
    941         verbose = False
    942         W = 0
    943         S = 0
    944         E = 10
    945         N = 10
    946 
    947         bounding_polygon = [[W, S], [E, S], [E, N], [W, N]]
    948         hole = [[[.1,.1], [9.9,1.1], [9.9,9.9], [1.1,9.9]]]
    949 
    950         create_mesh_from_regions(bounding_polygon,
    951                                  boundary_tags={'south': [0],
    952                                                 'east': [1],
    953                                                 'north': [2],
    954                                                 'west': [3]},
    955                                  maximum_triangle_area=1,
    956                                  filename=meshname,
    957                                  interior_holes = hole,
    958                                  use_cache=False,
    959                                  verbose=verbose)
    960 
    961         domain = Domain(meshname, use_cache=False, verbose=verbose)
    962         quantity = Quantity(domain)
    963        
    964          # Get (enough) datapoints (relative to georef)
    965         data_points     = [[ 0.66666667, 0.66666667],
    966                            [ 1.33333333, 1.33333333],
    967                            [ 2.66666667, 0.66666667],
    968                            [ 0.66666667, 2.66666667],
    969                            [ 0.0,        1.0],
    970                            [ 0.0,        3.0],
    971                            [ 1.0,        0.0],
    972                            [ 1.0,        1.0],
    973                            [ 1.0,        2.0],
    974                            [ 1.0,        3.0],
    975                            [ 2.0,        1.0],
    976                            [ 3.0,        0.0],
    977                            [ 3.0,        1.0]]
    978 
    979 
    980         attributes = linear_function(data_points)
    981         att = 'spam_and_eggs'
    982 
    983         # Create .txt file
    984         ptsfile = "points.txt"
    985         file = open(ptsfile, "w")
    986         file.write(" x,y," + att + " \n")
    987         for data_point, attribute in map(None, data_points, attributes):
    988             row = (str(data_point[0]) + ',' +
    989                    str(data_point[1]) + ',' +
    990                    str(attribute))
    991             file.write(row + "\n")
    992         file.close()
    993 
    994         # Check that values can be set from file
    995         quantity.set_values(filename=ptsfile, attribute_name=att, alpha=0)
    996         answer = linear_function(quantity.domain.get_vertex_coordinates())
    997 
    998         assert num.allclose(quantity.vertex_values.flat, answer)
    999 
    1000         # Check that values can be set from file using default attribute
    1001         quantity.set_values(filename = ptsfile, alpha = 0)
    1002         assert num.allclose(quantity.vertex_values.flat, answer)       
    1003        
    1004        
    1005 
    1006888#-------------------------------------------------------------
    1007889
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r7484 r7780  
    99from general_mesh import General_mesh
    1010from anuga.coordinate_transforms.geo_reference import Geo_reference
     11from mesh_factory import rectangular
     12from anuga.shallow_water.shallow_water_domain import Domain
    1113
    1214import numpy as num
     
    340342
    341343    def test_areas(self):
    342         from mesh_factory import rectangular
    343         from shallow_water import Domain
    344 
    345344        #Create basic mesh
    346345        points, vertices, boundary = rectangular(1, 3)
     
    354353        get unique_vertex based on triangle lists.
    355354        """
    356         from mesh_factory import rectangular
    357         from shallow_water import Domain
    358355
    359356        #Create basic mesh
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_boundary_conditions.py

    r7737 r7780  
    11#!/usr/bin/env python
     2"""
     3    Generic boundary conditions for a domain.
     4   
     5    A boundary represents the edge of the model, where inflow, outflow, and
     6    reflection can take place.
     7   
     8    The boundaries in this model can be applied universally across all
     9    domain models, without being tied to a particular implementation.
     10"""
    211
    312import unittest
     
    404413
    405414        #Convert ASCII file to NetCDF (Which is what we really like!)
    406         from anuga.shallow_water.file_conversion import timefile2netcdf
     415        from anuga.file_conversion.file_conversion import timefile2netcdf
    407416       
    408417        timefile2netcdf(filename, quantity_names = ['stage', 'xmomentum'])
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_region.py

    r7737 r7780  
    44from math import sqrt
    55
     6from mesh_factory import rectangular
     7from anuga.shallow_water.shallow_water_domain import Domain
    68from generic_domain import Generic_Domain
    79from region import *
     
    4345    def test_region_tags(self):
    4446        """get values based on triangle lists."""
    45 
    46         from mesh_factory import rectangular
    47         from shallow_water import Domain
    4847
    4948        #Create basic mesh
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r7778 r7780  
    1818
    1919from anuga.pmesh.mesh import Mesh
     20import time
     21from mesh_factory import rectangular
     22from anuga.coordinate_transforms.geo_reference import Geo_reference
    2023from anuga.shallow_water.shallow_water_domain import Domain
    21 from generic_boundary_conditions import Transmissive_boundary
     24from generic_boundary_conditions import \
     25                                Transmissive_boundary, Dirichlet_boundary
    2226from anuga.file.sww import SWW_file
    2327from csv import reader,writer
     
    128132        #Create sww file of simple propagation from left to right
    129133        #through rectangular domain
    130         from shallow_water import Domain, Dirichlet_boundary
    131         from mesh_factory import rectangular
    132134
    133135        #Create basic mesh and shallow water domain
     
    333335        NetCDF version (x,y,t dependency)       
    334336        """
    335         import time
    336 
    337         #Create sww file of simple propagation from left to right
    338         #through rectangular domain
    339         from shallow_water import Domain, Dirichlet_boundary
    340         from mesh_factory import rectangular
    341 
    342 
    343         from anuga.coordinate_transforms.geo_reference import Geo_reference
    344337        xllcorner = 2048
    345338        yllcorner = 11000
     
    613606        from anuga.config import time_format
    614607        from mesh_factory import rectangular
    615         from shallow_water import Domain
    616         import anuga.shallow_water.data_manager
     608        from anuga.shallow_water.shallow_water_domain import Domain
    617609
    618610        finaltime = 1200
  • trunk/anuga_core/source/anuga/damage_modelling/test_inundation_damage.py

    r7778 r7780  
    1515from anuga.utilities.numerical_tools import mean
    1616from anuga.file.sww import SWW_file
     17from anuga.shallow_water.shallow_water_domain import Domain
    1718
    1819import numpy as num
  • trunk/anuga_core/source/anuga/file/csv_file.py

    r7778 r7780  
    271271    """
    272272
    273     polygons, values = csv2polygons(file_name,
     273    polygons, values = load_csv_as_polygons(file_name,
    274274                                    value_name='floors',
    275275                                    clipping_polygons=None)   
  • trunk/anuga_core/source/anuga/file/sww.py

    r7776 r7780  
    10391039   
    10401040    from Scientific.IO.NetCDF import NetCDFFile
    1041     from shallow_water import Domain
     1041    from anuga.shallow_water_domain.shallow_water import Domain
    10421042
    10431043    # initialise NaN.
     
    12251225    import types
    12261226    from Scientific.IO.NetCDF import NetCDFFile
    1227     from shallow_water import Domain
    12281227    from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
    12291228
  • trunk/anuga_core/source/anuga/file_conversion/sww2dem.py

    r7778 r7780  
    44
    55# external modules
     6import os
    67import numpy as num
    78
     
    1112from anuga.utilities.system_tools import get_vars_in_expression
    1213import anuga.utilities.log as log
     14from anuga.utilities.file_utils import get_all_swwfiles
    1315
    1416
  • trunk/anuga_core/source/anuga/file_conversion/test_file_conversion.py

    r7776 r7780  
    99from anuga.file.sww import SWW_file
    1010from anuga.file.sww import extent_sww
     11from anuga.file_conversion.urs2nc import lon_lat2grid
    1112from anuga.config import netcdf_float, epsilon, g
    1213from Scientific.IO.NetCDF import NetCDFFile
     
    23462347        return base_name, files
    23472348
     2349
     2350
     2351    def test_lon_lat2grid(self):
     2352        lonlatdep = [
     2353            [ 113.06700134  ,  -26.06669998 ,   1.        ] ,
     2354            [ 113.06700134  ,  -26.33329964 ,   3.        ] ,
     2355            [ 113.19999695  ,  -26.06669998 ,   2.        ] ,
     2356            [ 113.19999695  ,  -26.33329964 ,   4.        ] ]
     2357           
     2358        long, lat, quantity = lon_lat2grid(lonlatdep)
     2359
     2360        for i, result in enumerate(lat):
     2361            assert lonlatdep [i][1] == result
     2362        assert len(lat) == 2
     2363
     2364        for i, result in enumerate(long):
     2365            assert lonlatdep [i*2][0] == result
     2366        assert len(long) == 2
     2367
     2368        for i,q in enumerate(quantity):
     2369            assert q == i+1
     2370           
     2371    def test_lon_lat2grid_bad(self):
     2372        lonlatdep  = [
     2373            [ -26.06669998,  113.06700134,    1.        ],
     2374            [ -26.06669998 , 113.19999695 ,   2.        ],
     2375            [ -26.06669998 , 113.33300018,    3.        ],
     2376            [ -26.06669998 , 113.43299866   , 4.        ],
     2377            [ -26.20000076 , 113.06700134,    5.        ],
     2378            [ -26.20000076 , 113.19999695 ,   6.        ],
     2379            [ -26.20000076 , 113.33300018  ,  7.        ],
     2380            [ -26.20000076 , 113.43299866   , 8.        ],
     2381            [ -26.33329964 , 113.06700134,    9.        ],
     2382            [ -26.33329964 , 113.19999695 ,   10.        ],
     2383            [ -26.33329964 , 113.33300018  ,  11.        ],
     2384            [ -26.33329964 , 113.43299866 ,   12.        ],
     2385            [ -26.43330002 , 113.06700134 ,   13        ],
     2386            [ -26.43330002 , 113.19999695 ,   14.        ],
     2387            [ -26.43330002 , 113.33300018,    15.        ],
     2388            [ -26.43330002 , 113.43299866,    16.        ]]
     2389        try:
     2390            long, lat, quantity = lon_lat2grid(lonlatdep)
     2391        except AssertionError:
     2392            pass
     2393        else:
     2394            msg = 'Should have raised exception'
     2395            raise msg
     2396       
     2397    def test_lon_lat2gridII(self):
     2398        lonlatdep = [
     2399            [ 113.06700134  ,  -26.06669998 ,   1.        ] ,
     2400            [ 113.06700134  ,  -26.33329964 ,   2.        ] ,
     2401            [ 113.19999695  ,  -26.06669998 ,   3.        ] ,
     2402            [ 113.19999695  ,  -26.344329964 ,   4.        ] ]
     2403        try:
     2404            long, lat, quantity = lon_lat2grid(lonlatdep)
     2405        except AssertionError:
     2406            pass
     2407        else:
     2408            msg = 'Should have raised exception'
     2409            raise msg
     2410       
     2411
    23482412#-------------------------------------------------------------
    23492413
  • trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py

    r7778 r7780  
    6060        ######################
    6161        # Boundary conditions
    62         B = Transmissive_boundary(domain)
     62        B = anuga.Transmissive_boundary(domain)
    6363        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
    6464
  • trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r7779 r7780  
    15561556    """
    15571557
    1558     from anuga.shallow_water import Domain
     1558    from anuga.shallow_water.shallow_water_domain import Domain
    15591559    from anuga.geospatial_data.geospatial_data import Geospatial_data
    15601560    from anuga.pmesh.mesh_interface import create_mesh_from_regions
  • trunk/anuga_core/source/anuga/shallow_water/test_data_manager.py

    r7778 r7780  
    2828from anuga.utilities.system_tools import get_pathname_from_package, \
    2929                                            get_revision_number
     30from anuga.utilities.file_utils import get_all_swwfiles
    3031from anuga.utilities.file_utils import del_dir
    3132from anuga.utilities.numerical_tools import ensure_numeric, mean
    3233from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
    3334from anuga.config import netcdf_float, epsilon, g
    34 
     35from anuga.pmesh.mesh_interface import create_mesh_from_regions
     36from anuga.file_conversion.sww2dem import sww2dem_batch
    3537from anuga.file.csv_file import load_csv_as_dict, load_csv_as_array, \
    3638                                load_csv_as_building_polygons, \
    3739                                load_csv_as_polygons
    3840from anuga.file.sts import create_sts_boundary
     41from anuga.file.pts import load_pts_as_polygon
     42from anuga.file.sww import Write_sww
    3943
    4044
     
    803807
    804808        #Export to ascii/prj files
    805         export_grid(self.domain.get_name(),
     809        sww2dem_batch(self.domain.get_name(),
    806810                quantities = 'elevation',
    807811                cellsize = cellsize,
     
    890894        #Export to ascii/prj files
    891895        if True:
    892             export_grid(self.domain.get_name(),
     896            sww2dem_batch(self.domain.get_name(),
    893897                        quantities = ['elevation', 'depth'],
    894898                        cellsize = cellsize,
     
    897901
    898902        else:
    899             export_grid(self.domain.get_name(),
     903            sww2dem_batch(self.domain.get_name(),
    900904                quantities = ['depth'],
    901905                cellsize = cellsize,
     
    10231027        extra_name_out = 'yeah'
    10241028        if True:
    1025             export_grid(self.domain.get_name(),
     1029            sww2dem_batch(self.domain.get_name(),
    10261030                        quantities = ['elevation', 'depth'],
    10271031                        extra_name_out = extra_name_out,
     
    10311035
    10321036        else:
    1033             export_grid(self.domain.get_name(),
     1037            sww2dem_batch(self.domain.get_name(),
    10341038                quantities = ['depth'],
    10351039                cellsize = cellsize,
     
    10381042
    10391043
    1040             export_grid(self.domain.get_name(),
     1044            sww2dem_batch(self.domain.get_name(),
    10411045                quantities = ['elevation'],
    10421046                cellsize = cellsize,
     
    11071111
    11081112        try:
    1109             export_grid('a_small_round-egg',
     1113            sww2dem_batch('a_small_round-egg',
    11101114                        quantities = ['elevation', 'depth'],
    11111115                        cellsize = 99,
     
    11681172        #Export to ascii/prj files
    11691173        extra_name_out = 'yeah'
    1170         export_grid(base_name,
     1174        sww2dem_batch(base_name,
    11711175                    quantities = ['elevation', 'depth'],
    11721176                    extra_name_out = extra_name_out,
     
    14861490        This one uses a sine wave and compares to time boundary
    14871491        """
    1488        
    1489         from anuga.shallow_water.shallow_water_domain import Domain
    1490         from anuga.shallow_water import Reflective_boundary
    1491         from anuga.shallow_water import Dirichlet_boundary
    1492         from anuga.shallow_water import File_boundary
    1493         from anuga.pmesh.mesh_interface import create_mesh_from_regions
    14941492
    14951493        lat_long_points=[[6.01,97.0],[6.02,97.0],[6.05,96.9],[6.0,97.0]]
     
    16831681        """
    16841682       
    1685         from anuga.shallow_water.shallow_water_domain import Domain
    1686         from anuga.shallow_water import Reflective_boundary
    1687         from anuga.shallow_water import Dirichlet_boundary
    1688         from anuga.shallow_water import File_boundary
    1689         from anuga.pmesh.mesh_interface import create_mesh_from_regions
    1690 
    16911683        lat_long_points=[[6.01,97.0],[6.02,97.0],[6.05,96.9],[6.0,97.0]]
    16921684        bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02]]
     
    18301822            raise Exception, 'Should have raised Exception here'
    18311823
    1832     def test_lon_lat2grid(self):
    1833         lonlatdep = [
    1834             [ 113.06700134  ,  -26.06669998 ,   1.        ] ,
    1835             [ 113.06700134  ,  -26.33329964 ,   3.        ] ,
    1836             [ 113.19999695  ,  -26.06669998 ,   2.        ] ,
    1837             [ 113.19999695  ,  -26.33329964 ,   4.        ] ]
    1838            
    1839         long, lat, quantity = lon_lat2grid(lonlatdep)
    1840 
    1841         for i, result in enumerate(lat):
    1842             assert lonlatdep [i][1] == result
    1843         assert len(lat) == 2
    1844 
    1845         for i, result in enumerate(long):
    1846             assert lonlatdep [i*2][0] == result
    1847         assert len(long) == 2
    1848 
    1849         for i,q in enumerate(quantity):
    1850             assert q == i+1
    1851            
    1852     def test_lon_lat2grid_bad(self):
    1853         lonlatdep  = [
    1854             [ -26.06669998,  113.06700134,    1.        ],
    1855             [ -26.06669998 , 113.19999695 ,   2.        ],
    1856             [ -26.06669998 , 113.33300018,    3.        ],
    1857             [ -26.06669998 , 113.43299866   , 4.        ],
    1858             [ -26.20000076 , 113.06700134,    5.        ],
    1859             [ -26.20000076 , 113.19999695 ,   6.        ],
    1860             [ -26.20000076 , 113.33300018  ,  7.        ],
    1861             [ -26.20000076 , 113.43299866   , 8.        ],
    1862             [ -26.33329964 , 113.06700134,    9.        ],
    1863             [ -26.33329964 , 113.19999695 ,   10.        ],
    1864             [ -26.33329964 , 113.33300018  ,  11.        ],
    1865             [ -26.33329964 , 113.43299866 ,   12.        ],
    1866             [ -26.43330002 , 113.06700134 ,   13        ],
    1867             [ -26.43330002 , 113.19999695 ,   14.        ],
    1868             [ -26.43330002 , 113.33300018,    15.        ],
    1869             [ -26.43330002 , 113.43299866,    16.        ]]
    1870         try:
    1871             long, lat, quantity = lon_lat2grid(lonlatdep)
    1872         except AssertionError:
    1873             pass
    1874         else:
    1875             msg = 'Should have raised exception'
    1876             raise msg
    1877        
    1878     def test_lon_lat2gridII(self):
    1879         lonlatdep = [
    1880             [ 113.06700134  ,  -26.06669998 ,   1.        ] ,
    1881             [ 113.06700134  ,  -26.33329964 ,   2.        ] ,
    1882             [ 113.19999695  ,  -26.06669998 ,   3.        ] ,
    1883             [ 113.19999695  ,  -26.344329964 ,   4.        ] ]
    1884         try:
    1885             long, lat, quantity = lon_lat2grid(lonlatdep)
    1886         except AssertionError:
    1887             pass
    1888         else:
    1889             msg = 'Should have raised exception'
    1890             raise msg
    1891        
    18921824    #### END TESTS FOR URS 2 SWW  ###
    18931825
     
    20762008                                           new_origin)),points_utm)
    20772009        os.remove(filename)
    2078        
    2079 
    2080        
    2081     def test_get_all_swwfiles(self):
    2082         try:
    2083             swwfiles = get_all_swwfiles('','test.txt')  #Invalid
    2084         except IOError:
    2085             pass
    2086         else:
    2087             raise 'Should have raised exception'
    2088        
    2089     def test_get_all_swwfiles1(self):
    2090        
    2091         temp_dir = tempfile.mkdtemp('','sww_test')
    2092         filename0 = tempfile.mktemp('.sww','test',temp_dir)
    2093         filename1 = tempfile.mktemp('.sww','test',temp_dir)
    2094         filename2 = tempfile.mktemp('.sww','test',temp_dir)
    2095         filename3 = tempfile.mktemp('.sww','test',temp_dir)
    2096        
    2097         #print'filename', filename0,filename1,filename2,filename3
    2098        
    2099         fid0 = open(filename0, 'w')
    2100         fid1 = open(filename1, 'w')
    2101         fid2 = open(filename2, 'w')
    2102         fid3 = open(filename3, 'w')
    2103 
    2104         fid0.write('hello')
    2105         fid1.write('hello')
    2106         fid2.write('hello')
    2107         fid3.write('hello')
    2108        
    2109         fid0.close()
    2110         fid1.close()
    2111         fid2.close()
    2112         fid3.close()
    2113        
    2114        
    2115         dir, name0 = os.path.split(filename0)
    2116         #print 'dir',dir,name0
    2117        
    2118         iterate=get_all_swwfiles(dir,'test')
    2119        
    2120         del_dir(temp_dir)
    2121 #        removeall(temp_dir)
    2122 
    2123         _, name0 = os.path.split(filename0)
    2124         #print'name0',name0[:-4],iterate[0]   
    2125         _, name1 = os.path.split(filename1)       
    2126         _, name2 = os.path.split(filename2)       
    2127         _, name3 = os.path.split(filename3)       
    2128 
    2129         assert name0[:-4] in iterate
    2130         assert name1[:-4] in iterate
    2131         assert name2[:-4] in iterate
    2132         assert name3[:-4] in iterate
    2133        
    2134         assert len(iterate)==4
    21352010
    21362011 
     
    21472022        G.export_points_file(fileName)
    21482023       
    2149         polygon = points2polygon(fileName)
     2024        polygon = load_pts_as_polygon(fileName)
    21502025       
    21512026        # This test may fail if the order changes
     
    21602035        testfile = os.path.join(path, 'polygon_values_example.csv')               
    21612036
    2162         polygons, values = csv2polygons(testfile,
     2037        polygons, values = load_csv_as_polygons(testfile,
    21632038                                        value_name='floors')
    21642039
     
    22372112        testfile = os.path.join(path, 'polygon_values_example.csv')               
    22382113
    2239         polygons, values = csv2polygons(testfile,
     2114        polygons, values = load_csv_as_polygons(testfile,
    22402115                                        value_name='floors',
    22412116                                        clipping_polygons=None)
     
    23172192        testfile = os.path.join(path, 'polygon_values_example.csv')               
    23182193
    2319         polygons, values = csv2building_polygons(testfile,
     2194        polygons, values = load_csv_as_building_polygons(testfile,
    23202195                                                 floor_height=3)
    23212196
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r7778 r7780  
    15481548        from anuga.abstract_2d_finite_volumes.mesh_factory \
    15491549                import rectangular_cross
    1550         from anuga.shallow_water.shallow_water_domain import Domain
    1551         from anuga.shallow_water import Reflective_boundary
    1552         from anuga.shallow_water import Dirichlet_boundary
    15531550
    15541551        #-----------------------------------------------------------------
     
    60036000        #---------------------------------------------------------------------
    60046001        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    6005         from anuga.shallow_water.shallow_water_domain import Domain
    6006         from anuga.shallow_water import Reflective_boundary
    6007         from anuga.shallow_water import Dirichlet_boundary
    6008         from anuga.shallow_water import Time_boundary
    60096002
    60106003        #---------------------------------------------------------------------
     
    65246517        """
    65256518        from mesh_factory import rectangular
    6526         from shallow_water import Domain
    65276519
    65286520        #Create basic mesh
     
    65406532        """
    65416533        from mesh_factory import rectangular
    6542         from shallow_water import Domain
    65436534
    65446535        #Create basic mesh
     
    65806571        """
    65816572        from mesh_factory import rectangular
    6582         from shallow_water import Domain
    65836573
    65846574        #Create basic mesh
     
    67926782
    67936783
     6784    def test_that_mesh_methods_exist(self):
     6785        """test_that_mesh_methods_exist
     6786       
     6787        Test that relavent mesh methods are made available in
     6788        domain through composition
     6789        """
     6790
     6791        # Create basic mesh
     6792        points, vertices, boundary = rectangular(1, 3)
     6793
     6794        # Create shallow water domain
     6795        domain = Domain(points, vertices, boundary)                             
     6796       
     6797       
     6798        domain.get_centroid_coordinates()
     6799        domain.get_radii()
     6800        domain.get_areas()
     6801        domain.get_area()
     6802        domain.get_vertex_coordinates()
     6803        domain.get_triangles()
     6804        domain.get_nodes()
     6805        domain.get_number_of_nodes()
     6806        domain.get_normal(0,0)
     6807        domain.get_triangle_containing_point([0.4,0.5])
     6808        domain.get_intersecting_segments([[0.0, 0.0], [0.0, 1.0]])
     6809        domain.get_disconnected_triangles()
     6810        domain.get_boundary_tags()
     6811        domain.get_boundary_polygon()
     6812        #domain.get_number_of_triangles_per_node()
     6813        domain.get_triangles_and_vertices_per_node()
     6814        domain.get_interpolation_object()
     6815        domain.get_tagged_elements()
     6816        domain.get_lone_vertices()
     6817        domain.get_unique_vertices()
     6818        g = domain.get_georeference()
     6819        domain.set_georeference(g)
     6820        domain.build_tagged_elements_dictionary()
     6821        domain.statistics()
     6822        domain.get_extent()
     6823
     6824
    67946825
    67956826#################################################################################
  • trunk/anuga_core/source/anuga/shallow_water/test_smf.py

    r7276 r7780  
    22import numpy as num
    33from smf import slide_tsunami, slump_tsunami, Double_gaussian
     4from shallow_water_domain import Domain
    45
    56class Test_smf(unittest.TestCase):
     
    106107                                 verbose = False)
    107108
    108         from anuga.shallow_water import Domain
    109109        domain = Domain('test.msh', use_cache = True, verbose = False)
    110110
  • trunk/anuga_core/source/anuga/shallow_water/test_tsunami_okada.py

    r7276 r7780  
    22import numpy as num
    33from tsunami_okada import earthquake_tsunami,Okada_func
     4from anuga.shallow_water.shallow_water_domain import Domain
    45
    56class Test_eq(unittest.TestCase):
     
    1415        from os import sep, getenv
    1516        import sys
    16         from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    17         from anuga.shallow_water import Domain
     17        from anuga.abstract_2d_finite_volumes.mesh_factory \
     18        import rectangular_cross
     19
    1820        from anuga.abstract_2d_finite_volumes.quantity import Quantity
    1921        from anuga.utilities.system_tools import get_pathname_from_package
     
    150152        from os import sep, getenv
    151153        import sys
    152         from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    153         from anuga.shallow_water import Domain
     154        from anuga.abstract_2d_finite_volumes.mesh_factory \
     155                        import rectangular_cross
    154156        from anuga.abstract_2d_finite_volumes.quantity import Quantity
    155157        from anuga.utilities.system_tools import get_pathname_from_package
  • trunk/anuga_core/source/anuga/utilities/test_file_utils.py

    r7765 r7780  
    44import shutil
    55
    6 from anuga.utilities.file_utils import copy_code_files
     6from anuga.utilities.file_utils import copy_code_files, get_all_swwfiles
     7from anuga.utilities.file_utils import del_dir
    78
    89
     
    5253        # clean up
    5354        shutil.rmtree(work_dir)
    54            
     55       
     56    def test_get_all_swwfiles(self):
     57        try:
     58            swwfiles = get_all_swwfiles('','test.txt')  #Invalid
     59        except IOError:
     60            pass
     61        else:
     62            raise 'Should have raised exception'
     63       
     64    def test_get_all_swwfiles1(self):
     65       
     66        temp_dir = tempfile.mkdtemp('','sww_test')
     67        filename0 = tempfile.mktemp('.sww','test',temp_dir)
     68        filename1 = tempfile.mktemp('.sww','test',temp_dir)
     69        filename2 = tempfile.mktemp('.sww','test',temp_dir)
     70        filename3 = tempfile.mktemp('.sww','test',temp_dir)
     71       
     72        #print'filename', filename0,filename1,filename2,filename3
     73       
     74        fid0 = open(filename0, 'w')
     75        fid1 = open(filename1, 'w')
     76        fid2 = open(filename2, 'w')
     77        fid3 = open(filename3, 'w')
     78
     79        fid0.write('hello')
     80        fid1.write('hello')
     81        fid2.write('hello')
     82        fid3.write('hello')
     83       
     84        fid0.close()
     85        fid1.close()
     86        fid2.close()
     87        fid3.close()
     88       
     89       
     90        dir, name0 = os.path.split(filename0)
     91        #print 'dir',dir,name0
     92       
     93        iterate=get_all_swwfiles(dir,'test')
     94       
     95        del_dir(temp_dir)
     96#        removeall(temp_dir)
     97
     98        _, name0 = os.path.split(filename0)
     99        #print'name0',name0[:-4],iterate[0]   
     100        _, name1 = os.path.split(filename1)       
     101        _, name2 = os.path.split(filename2)       
     102        _, name3 = os.path.split(filename3)       
     103
     104        assert name0[:-4] in iterate
     105        assert name1[:-4] in iterate
     106        assert name2[:-4] in iterate
     107        assert name3[:-4] in iterate
     108       
     109        assert len(iterate)==4           
    55110
    56111#-------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.