Changeset 7780
- Timestamp:
- Jun 5, 2010, 10:58:55 AM (15 years ago)
- 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 2 7 modules, which can be used directly by including the following line in 3 8 the user's code: 4 9 5 10 import anuga 6 7 It abstracts away the internal heirarchy of the ANUGA system, allowing the8 user to concentrate on writing simulations without searching through the9 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. 10 15 11 16 Also, it isolates the user from "under-the-hood" refactorings. -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/gauge.py
r7694 r7780 146 146 from anuga.utilities.numerical_tools import ensure_numeric, mean, NAN 147 147 import string 148 from anuga. shallow_water.data_managerimport get_all_swwfiles148 from anuga.utilities.file_utils import get_all_swwfiles 149 149 from anuga.abstract_2d_finite_volumes.util import file_function 150 150 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r7737 r7780 1 1 """Class Domain - 2D triangular domains for finite-volume computations of 2 2 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. 3 8 4 9 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py
r7778 r7780 886 886 887 887 888 def test_that_mesh_methods_exist(self):889 """test_that_mesh_methods_exist890 891 Test that relavent mesh methods are made available in892 domain through composition893 """894 from mesh_factory import rectangular895 from shallow_water import Domain896 897 # Create basic mesh898 points, vertices, boundary = rectangular(1, 3)899 900 # Create shallow water domain901 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 on932 a mesh with a hole, but more info is needed on the specific933 problem."""934 935 # For test_fitting_using_shallow_water_domain example936 def linear_function(point):937 point = num.array(point)938 return point[:,0]+point[:,1]939 940 meshname = 'test_mesh.msh'941 verbose = False942 W = 0943 S = 0944 E = 10945 N = 10946 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 file984 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 file995 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 attribute1001 quantity.set_values(filename = ptsfile, alpha = 0)1002 assert num.allclose(quantity.vertex_values.flat, answer)1003 1004 1005 1006 888 #------------------------------------------------------------- 1007 889 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py
r7484 r7780 9 9 from general_mesh import General_mesh 10 10 from anuga.coordinate_transforms.geo_reference import Geo_reference 11 from mesh_factory import rectangular 12 from anuga.shallow_water.shallow_water_domain import Domain 11 13 12 14 import numpy as num … … 340 342 341 343 def test_areas(self): 342 from mesh_factory import rectangular343 from shallow_water import Domain344 345 344 #Create basic mesh 346 345 points, vertices, boundary = rectangular(1, 3) … … 354 353 get unique_vertex based on triangle lists. 355 354 """ 356 from mesh_factory import rectangular357 from shallow_water import Domain358 355 359 356 #Create basic mesh -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_boundary_conditions.py
r7737 r7780 1 1 #!/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 """ 2 11 3 12 import unittest … … 404 413 405 414 #Convert ASCII file to NetCDF (Which is what we really like!) 406 from anuga. shallow_water.file_conversion import timefile2netcdf415 from anuga.file_conversion.file_conversion import timefile2netcdf 407 416 408 417 timefile2netcdf(filename, quantity_names = ['stage', 'xmomentum']) -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_region.py
r7737 r7780 4 4 from math import sqrt 5 5 6 from mesh_factory import rectangular 7 from anuga.shallow_water.shallow_water_domain import Domain 6 8 from generic_domain import Generic_Domain 7 9 from region import * … … 43 45 def test_region_tags(self): 44 46 """get values based on triangle lists.""" 45 46 from mesh_factory import rectangular47 from shallow_water import Domain48 47 49 48 #Create basic mesh -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py
r7778 r7780 18 18 19 19 from anuga.pmesh.mesh import Mesh 20 import time 21 from mesh_factory import rectangular 22 from anuga.coordinate_transforms.geo_reference import Geo_reference 20 23 from anuga.shallow_water.shallow_water_domain import Domain 21 from generic_boundary_conditions import Transmissive_boundary 24 from generic_boundary_conditions import \ 25 Transmissive_boundary, Dirichlet_boundary 22 26 from anuga.file.sww import SWW_file 23 27 from csv import reader,writer … … 128 132 #Create sww file of simple propagation from left to right 129 133 #through rectangular domain 130 from shallow_water import Domain, Dirichlet_boundary131 from mesh_factory import rectangular132 134 133 135 #Create basic mesh and shallow water domain … … 333 335 NetCDF version (x,y,t dependency) 334 336 """ 335 import time336 337 #Create sww file of simple propagation from left to right338 #through rectangular domain339 from shallow_water import Domain, Dirichlet_boundary340 from mesh_factory import rectangular341 342 343 from anuga.coordinate_transforms.geo_reference import Geo_reference344 337 xllcorner = 2048 345 338 yllcorner = 11000 … … 613 606 from anuga.config import time_format 614 607 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 617 609 618 610 finaltime = 1200 -
trunk/anuga_core/source/anuga/damage_modelling/test_inundation_damage.py
r7778 r7780 15 15 from anuga.utilities.numerical_tools import mean 16 16 from anuga.file.sww import SWW_file 17 from anuga.shallow_water.shallow_water_domain import Domain 17 18 18 19 import numpy as num -
trunk/anuga_core/source/anuga/file/csv_file.py
r7778 r7780 271 271 """ 272 272 273 polygons, values = csv2polygons(file_name,273 polygons, values = load_csv_as_polygons(file_name, 274 274 value_name='floors', 275 275 clipping_polygons=None) -
trunk/anuga_core/source/anuga/file/sww.py
r7776 r7780 1039 1039 1040 1040 from Scientific.IO.NetCDF import NetCDFFile 1041 from shallow_water import Domain1041 from anuga.shallow_water_domain.shallow_water import Domain 1042 1042 1043 1043 # initialise NaN. … … 1225 1225 import types 1226 1226 from Scientific.IO.NetCDF import NetCDFFile 1227 from shallow_water import Domain1228 1227 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 1229 1228 -
trunk/anuga_core/source/anuga/file_conversion/sww2dem.py
r7778 r7780 4 4 5 5 # external modules 6 import os 6 7 import numpy as num 7 8 … … 11 12 from anuga.utilities.system_tools import get_vars_in_expression 12 13 import anuga.utilities.log as log 14 from anuga.utilities.file_utils import get_all_swwfiles 13 15 14 16 -
trunk/anuga_core/source/anuga/file_conversion/test_file_conversion.py
r7776 r7780 9 9 from anuga.file.sww import SWW_file 10 10 from anuga.file.sww import extent_sww 11 from anuga.file_conversion.urs2nc import lon_lat2grid 11 12 from anuga.config import netcdf_float, epsilon, g 12 13 from Scientific.IO.NetCDF import NetCDFFile … … 2346 2347 return base_name, files 2347 2348 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 2348 2412 #------------------------------------------------------------- 2349 2413 -
trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r7778 r7780 60 60 ###################### 61 61 # Boundary conditions 62 B = Transmissive_boundary(domain)62 B = anuga.Transmissive_boundary(domain) 63 63 domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B}) 64 64 -
trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py
r7779 r7780 1556 1556 """ 1557 1557 1558 from anuga.shallow_water import Domain1558 from anuga.shallow_water.shallow_water_domain import Domain 1559 1559 from anuga.geospatial_data.geospatial_data import Geospatial_data 1560 1560 from anuga.pmesh.mesh_interface import create_mesh_from_regions -
trunk/anuga_core/source/anuga/shallow_water/test_data_manager.py
r7778 r7780 28 28 from anuga.utilities.system_tools import get_pathname_from_package, \ 29 29 get_revision_number 30 from anuga.utilities.file_utils import get_all_swwfiles 30 31 from anuga.utilities.file_utils import del_dir 31 32 from anuga.utilities.numerical_tools import ensure_numeric, mean 32 33 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 33 34 from anuga.config import netcdf_float, epsilon, g 34 35 from anuga.pmesh.mesh_interface import create_mesh_from_regions 36 from anuga.file_conversion.sww2dem import sww2dem_batch 35 37 from anuga.file.csv_file import load_csv_as_dict, load_csv_as_array, \ 36 38 load_csv_as_building_polygons, \ 37 39 load_csv_as_polygons 38 40 from anuga.file.sts import create_sts_boundary 41 from anuga.file.pts import load_pts_as_polygon 42 from anuga.file.sww import Write_sww 39 43 40 44 … … 803 807 804 808 #Export to ascii/prj files 805 export_grid(self.domain.get_name(),809 sww2dem_batch(self.domain.get_name(), 806 810 quantities = 'elevation', 807 811 cellsize = cellsize, … … 890 894 #Export to ascii/prj files 891 895 if True: 892 export_grid(self.domain.get_name(),896 sww2dem_batch(self.domain.get_name(), 893 897 quantities = ['elevation', 'depth'], 894 898 cellsize = cellsize, … … 897 901 898 902 else: 899 export_grid(self.domain.get_name(),903 sww2dem_batch(self.domain.get_name(), 900 904 quantities = ['depth'], 901 905 cellsize = cellsize, … … 1023 1027 extra_name_out = 'yeah' 1024 1028 if True: 1025 export_grid(self.domain.get_name(),1029 sww2dem_batch(self.domain.get_name(), 1026 1030 quantities = ['elevation', 'depth'], 1027 1031 extra_name_out = extra_name_out, … … 1031 1035 1032 1036 else: 1033 export_grid(self.domain.get_name(),1037 sww2dem_batch(self.domain.get_name(), 1034 1038 quantities = ['depth'], 1035 1039 cellsize = cellsize, … … 1038 1042 1039 1043 1040 export_grid(self.domain.get_name(),1044 sww2dem_batch(self.domain.get_name(), 1041 1045 quantities = ['elevation'], 1042 1046 cellsize = cellsize, … … 1107 1111 1108 1112 try: 1109 export_grid('a_small_round-egg',1113 sww2dem_batch('a_small_round-egg', 1110 1114 quantities = ['elevation', 'depth'], 1111 1115 cellsize = 99, … … 1168 1172 #Export to ascii/prj files 1169 1173 extra_name_out = 'yeah' 1170 export_grid(base_name,1174 sww2dem_batch(base_name, 1171 1175 quantities = ['elevation', 'depth'], 1172 1176 extra_name_out = extra_name_out, … … 1486 1490 This one uses a sine wave and compares to time boundary 1487 1491 """ 1488 1489 from anuga.shallow_water.shallow_water_domain import Domain1490 from anuga.shallow_water import Reflective_boundary1491 from anuga.shallow_water import Dirichlet_boundary1492 from anuga.shallow_water import File_boundary1493 from anuga.pmesh.mesh_interface import create_mesh_from_regions1494 1492 1495 1493 lat_long_points=[[6.01,97.0],[6.02,97.0],[6.05,96.9],[6.0,97.0]] … … 1683 1681 """ 1684 1682 1685 from anuga.shallow_water.shallow_water_domain import Domain1686 from anuga.shallow_water import Reflective_boundary1687 from anuga.shallow_water import Dirichlet_boundary1688 from anuga.shallow_water import File_boundary1689 from anuga.pmesh.mesh_interface import create_mesh_from_regions1690 1691 1683 lat_long_points=[[6.01,97.0],[6.02,97.0],[6.05,96.9],[6.0,97.0]] 1692 1684 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02]] … … 1830 1822 raise Exception, 'Should have raised Exception here' 1831 1823 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] == result1843 assert len(lat) == 21844 1845 for i, result in enumerate(long):1846 assert lonlatdep [i*2][0] == result1847 assert len(long) == 21848 1849 for i,q in enumerate(quantity):1850 assert q == i+11851 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 pass1874 else:1875 msg = 'Should have raised exception'1876 raise msg1877 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 pass1888 else:1889 msg = 'Should have raised exception'1890 raise msg1891 1892 1824 #### END TESTS FOR URS 2 SWW ### 1893 1825 … … 2076 2008 new_origin)),points_utm) 2077 2009 os.remove(filename) 2078 2079 2080 2081 def test_get_all_swwfiles(self):2082 try:2083 swwfiles = get_all_swwfiles('','test.txt') #Invalid2084 except IOError:2085 pass2086 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,filename32098 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,name02117 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 iterate2130 assert name1[:-4] in iterate2131 assert name2[:-4] in iterate2132 assert name3[:-4] in iterate2133 2134 assert len(iterate)==42135 2010 2136 2011 … … 2147 2022 G.export_points_file(fileName) 2148 2023 2149 polygon = points2polygon(fileName)2024 polygon = load_pts_as_polygon(fileName) 2150 2025 2151 2026 # This test may fail if the order changes … … 2160 2035 testfile = os.path.join(path, 'polygon_values_example.csv') 2161 2036 2162 polygons, values = csv2polygons(testfile,2037 polygons, values = load_csv_as_polygons(testfile, 2163 2038 value_name='floors') 2164 2039 … … 2237 2112 testfile = os.path.join(path, 'polygon_values_example.csv') 2238 2113 2239 polygons, values = csv2polygons(testfile,2114 polygons, values = load_csv_as_polygons(testfile, 2240 2115 value_name='floors', 2241 2116 clipping_polygons=None) … … 2317 2192 testfile = os.path.join(path, 'polygon_values_example.csv') 2318 2193 2319 polygons, values = csv2building_polygons(testfile,2194 polygons, values = load_csv_as_building_polygons(testfile, 2320 2195 floor_height=3) 2321 2196 -
trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r7778 r7780 1548 1548 from anuga.abstract_2d_finite_volumes.mesh_factory \ 1549 1549 import rectangular_cross 1550 from anuga.shallow_water.shallow_water_domain import Domain1551 from anuga.shallow_water import Reflective_boundary1552 from anuga.shallow_water import Dirichlet_boundary1553 1550 1554 1551 #----------------------------------------------------------------- … … 6003 6000 #--------------------------------------------------------------------- 6004 6001 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 6005 from anuga.shallow_water.shallow_water_domain import Domain6006 from anuga.shallow_water import Reflective_boundary6007 from anuga.shallow_water import Dirichlet_boundary6008 from anuga.shallow_water import Time_boundary6009 6002 6010 6003 #--------------------------------------------------------------------- … … 6524 6517 """ 6525 6518 from mesh_factory import rectangular 6526 from shallow_water import Domain6527 6519 6528 6520 #Create basic mesh … … 6540 6532 """ 6541 6533 from mesh_factory import rectangular 6542 from shallow_water import Domain6543 6534 6544 6535 #Create basic mesh … … 6580 6571 """ 6581 6572 from mesh_factory import rectangular 6582 from shallow_water import Domain6583 6573 6584 6574 #Create basic mesh … … 6792 6782 6793 6783 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 6794 6825 6795 6826 ################################################################################# -
trunk/anuga_core/source/anuga/shallow_water/test_smf.py
r7276 r7780 2 2 import numpy as num 3 3 from smf import slide_tsunami, slump_tsunami, Double_gaussian 4 from shallow_water_domain import Domain 4 5 5 6 class Test_smf(unittest.TestCase): … … 106 107 verbose = False) 107 108 108 from anuga.shallow_water import Domain109 109 domain = Domain('test.msh', use_cache = True, verbose = False) 110 110 -
trunk/anuga_core/source/anuga/shallow_water/test_tsunami_okada.py
r7276 r7780 2 2 import numpy as num 3 3 from tsunami_okada import earthquake_tsunami,Okada_func 4 from anuga.shallow_water.shallow_water_domain import Domain 4 5 5 6 class Test_eq(unittest.TestCase): … … 14 15 from os import sep, getenv 15 16 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 18 20 from anuga.abstract_2d_finite_volumes.quantity import Quantity 19 21 from anuga.utilities.system_tools import get_pathname_from_package … … 150 152 from os import sep, getenv 151 153 import sys 152 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross153 from anuga.shallow_water import Domain154 from anuga.abstract_2d_finite_volumes.mesh_factory \ 155 import rectangular_cross 154 156 from anuga.abstract_2d_finite_volumes.quantity import Quantity 155 157 from anuga.utilities.system_tools import get_pathname_from_package -
trunk/anuga_core/source/anuga/utilities/test_file_utils.py
r7765 r7780 4 4 import shutil 5 5 6 from anuga.utilities.file_utils import copy_code_files 6 from anuga.utilities.file_utils import copy_code_files, get_all_swwfiles 7 from anuga.utilities.file_utils import del_dir 7 8 8 9 … … 52 53 # clean up 53 54 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 55 110 56 111 #-------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.