Changeset 7778
- Timestamp:
- Jun 4, 2010, 10:03:48 PM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 1 added
- 30 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r7776 r7778 22 22 #----------------------------------------------------- 23 23 24 from anuga.shallow_water import Domain24 from anuga.shallow_water.shallow_water_domain import Domain 25 25 26 26 from anuga.abstract_2d_finite_volumes.util import file_function … … 28 28 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 29 29 30 from anuga.file.csv_file import csv2building_polygons 30 from anuga.file.csv_file import load_csv_as_building_polygons, \ 31 load_csv_as_polygons 31 32 32 33 from anuga.file.sts import create_sts_boundary … … 35 36 from anuga.geometry.polygon import Polygon_function 36 37 37 from anuga.abstract_2d_finite_volumes.pmesh2domain import pmesh_to_domain_instance 38 from anuga.abstract_2d_finite_volumes.pmesh2domain import \ 39 pmesh_to_domain_instance 38 40 39 41 … … 219 221 """ 220 222 221 from anuga.shallow_water import Domain223 from anuga.shallow_water.shallow_water_domain import Domain 222 224 from anuga.pmesh.mesh_interface import create_mesh_from_regions 223 225 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py
r7737 r7778 3 3 import unittest 4 4 from math import sqrt 5 6 import anuga 5 7 6 8 from anuga.abstract_2d_finite_volumes.generic_domain import * 7 9 from anuga.pmesh.mesh_interface import create_mesh_from_regions 8 10 from anuga.config import epsilon 9 from anuga.shallow_water import Reflective_boundary10 from anuga.shallow_water import Dirichlet_boundary11 11 import numpy as num 12 12 from anuga.pmesh.mesh import Segment, Vertex, Mesh … … 484 484 domain = Generic_Domain(points, vertices) 485 485 486 domain.set_boundary( {default_boundary_tag: Dirichlet_boundary([5,2,1])} ) 486 domain.set_boundary( \ 487 {default_boundary_tag: anuga.Dirichlet_boundary([5,2,1])} ) 487 488 488 489 … … 524 525 525 526 526 domain.set_boundary( {'First': Dirichlet_boundary([5,2,1]),527 'Second': Transmissive_boundary(domain)} )527 domain.set_boundary( {'First': anuga.Dirichlet_boundary([5,2,1]), 528 'Second': anuga.Transmissive_boundary(domain)} ) 528 529 529 530 domain.update_boundary() … … 590 591 591 592 592 domain.set_boundary( {'First': Dirichlet_boundary([5,2,1,4,6]),593 'Second': Transmissive_boundary(domain)} )593 domain.set_boundary( {'First': anuga.Dirichlet_boundary([5,2,1,4,6]), 594 'Second': anuga.Transmissive_boundary(domain)} ) 594 595 595 596 try: -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_gauge.py
r7776 r7778 7 7 from os import access, F_OK,sep, removedirs,remove,mkdir,getcwd 8 8 9 import anuga 9 10 #from anuga.abstract_2d_finite_volumes.util import * 10 11 from anuga.abstract_2d_finite_volumes.gauge import * … … 16 17 17 18 from anuga.pmesh.mesh import Mesh 18 from anuga.shallow_water import Domain, Transmissive_boundary 19 19 20 from anuga.file.sww import SWW_file 20 21 from anuga.file_conversion.file_conversion import timefile2netcdf 21 22 from anuga.utilities.file_utils import del_dir 22 from csv import reader, writer23 from csv import reader, writer 23 24 import time 24 25 import string … … 47 48 48 49 # Create shallow water domain 49 domain = Domain(mesh_file)50 domain = anuga.Domain(mesh_file) 50 51 os.remove(mesh_file) 51 52 … … 64 65 ###################### 65 66 # Boundary conditions 66 B = Transmissive_boundary(domain)67 B = anuga.Transmissive_boundary(domain) 67 68 domain.set_boundary( {'exterior': B}) 68 69 … … 161 162 def test_sww2csv_gauges1(self): 162 163 from anuga.pmesh.mesh import Mesh 163 from anuga.shallow_water import Domain, Transmissive_boundary164 164 from csv import reader,writer 165 165 import time … … 304 304 def test_sww2csv_gauge_point_off_mesh(self): 305 305 from anuga.pmesh.mesh import Mesh 306 from anuga.shallow_water import Domain, Transmissive_boundary307 306 from csv import reader,writer 308 307 import time -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py
r7776 r7778 18 18 19 19 from anuga.pmesh.mesh import Mesh 20 from anuga.shallow_water import Domain, Transmissive_boundary 20 from anuga.shallow_water.shallow_water_domain import Domain 21 from generic_boundary_conditions import Transmissive_boundary 21 22 from anuga.file.sww import SWW_file 22 23 from csv import reader,writer -
trunk/anuga_core/source/anuga/culvert_flows/test_culvert_class.py
r7711 r7778 12 12 from anuga.abstract_2d_finite_volumes.quantity import Quantity 13 13 14 from anuga.shallow_water import Domain, Reflective_boundary,\ 15 Dirichlet_boundary,\ 16 Transmissive_boundary, Time_boundary 17 18 from anuga.culvert_flows.culvert_class import Culvert_flow, Culvert_flow_rating, Culvert_flow_energy 14 import anuga 15 16 from anuga.culvert_flows.culvert_class import Culvert_flow, \ 17 Culvert_flow_rating, Culvert_flow_energy 19 18 from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model 20 19 21 from math import pi, pow,sqrt20 from math import pi, pow, sqrt 22 21 23 22 import numpy as num … … 38 37 len1=length, 39 38 len2=width) 40 domain = Domain(points, vertices, boundary)39 domain = anuga.Domain(points, vertices, boundary) 41 40 domain.set_name('Test_culvert_shallow') # Output name 42 41 domain.set_default_order(2) … … 105 104 # Inflow based on Flow Depth and Approaching Momentum 106 105 107 Br = Reflective_boundary(domain) # Solid reflective wall106 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 108 107 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 109 108 … … 152 151 len1=length, 153 152 len2=width) 154 domain = Domain(points, vertices, boundary)153 domain = anuga.Domain(points, vertices, boundary) 155 154 domain.set_name('Test_culvert') # Output name 156 155 domain.set_default_order(2) … … 214 213 215 214 # Inflow based on Flow Depth and Approaching Momentum 216 Bi = Dirichlet_boundary([0.0, 0.0, 0.0])217 Br = Reflective_boundary(domain) # Solid reflective wall218 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow215 Bi = anuga.Dirichlet_boundary([0.0, 0.0, 0.0]) 216 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 217 Bo = anuga.Dirichlet_boundary([-5, 0, 0]) # Outflow 219 218 220 219 # Upstream and downstream conditions that will exceed the rating curve 221 220 # I.e produce delta_h outside the range [0, 10] specified in the the 222 221 # file example_rating_curve.csv 223 Btus = Time_boundary(domain, lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0]) 224 Btds = Time_boundary(domain, lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0]) 222 Btus = anuga.Time_boundary(domain, \ 223 lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0]) 224 Btds = anuga.Time_boundary(domain, \ 225 lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0]) 225 226 domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br}) 226 227 … … 268 269 len1=length, 269 270 len2=width) 270 domain = Domain(points, vertices, boundary)271 domain = anuga.Domain(points, vertices, boundary) 271 272 domain.set_name('Test_culvert_dry') # Output name 272 273 domain.set_default_order(2) … … 331 332 # Inflow based on Flow Depth and Approaching Momentum 332 333 333 Br = Reflective_boundary(domain) # Solid reflective wall334 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 334 335 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 335 336 … … 388 389 len1=length, 389 390 len2=width) 390 domain = Domain(points, vertices, boundary)391 domain = anuga.Domain(points, vertices, boundary) 391 392 domain.set_name('Test_culvert_shallow') # Output name 392 393 domain.set_default_order(2) … … 463 464 # Inflow based on Flow Depth and Approaching Momentum 464 465 465 Br = Reflective_boundary(domain) # Solid reflective wall466 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 466 467 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 467 468 … … 525 526 len1=length, 526 527 len2=width) 527 domain = Domain(points, vertices, boundary)528 domain = anuga.Domain(points, vertices, boundary) 528 529 domain.set_name('Test_culvert_dry') # Output name 529 530 domain.set_default_order(2) … … 594 595 # Inflow based on Flow Depth and Approaching Momentum 595 596 596 Br = Reflective_boundary(domain) # Solid reflective wall597 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 597 598 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 598 599 … … 635 636 len1=length, 636 637 len2=width) 637 domain = Domain(points, vertices, boundary)638 domain = anuga.Domain(points, vertices, boundary) 638 639 639 640 domain.set_name('test_culvert') # Output name … … 711 712 len1=length, 712 713 len2=width) 713 domain = Domain(points, vertices, boundary)714 domain = anuga.Domain(points, vertices, boundary) 714 715 domain.set_name('Test_culvert_shallow') # Output name 715 716 domain.set_default_order(2) … … 782 783 783 784 784 Br = Reflective_boundary(domain) # Solid reflective wall785 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 785 786 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 786 787 -
trunk/anuga_core/source/anuga/culvert_flows/test_new_culvert_class.py
r7727 r7778 6 6 import sys 7 7 8 import anuga 9 8 10 from anuga.utilities.system_tools import get_pathname_from_package 9 11 from anuga.geometry.polygon import Polygon_function … … 11 13 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 12 14 from anuga.abstract_2d_finite_volumes.quantity import Quantity 13 14 from anuga.shallow_water import Domain, Reflective_boundary,\15 Dirichlet_boundary,\16 Transmissive_boundary, Time_boundary17 15 18 16 from anuga.culvert_flows.new_culvert_class import Culvert_flow … … 38 36 len1=length, 39 37 len2=width) 40 domain = Domain(points, vertices, boundary)38 domain = anuga.Domain(points, vertices, boundary) 41 39 domain.set_name('Test_culvert_shallow') # Output name 42 40 domain.set_default_order(2) … … 105 103 # Inflow based on Flow Depth and Approaching Momentum 106 104 107 Br = Reflective_boundary(domain) # Solid reflective wall105 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 108 106 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 109 107 … … 152 150 len1=length, 153 151 len2=width) 154 domain = Domain(points, vertices, boundary)152 domain = anuga.Domain(points, vertices, boundary) 155 153 domain.set_name('Test_culvert') # Output name 156 154 domain.set_default_order(2) … … 214 212 215 213 # Inflow based on Flow Depth and Approaching Momentum 216 Bi = Dirichlet_boundary([0.0, 0.0, 0.0])217 Br = Reflective_boundary(domain) # Solid reflective wall218 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow214 Bi = anuga.Dirichlet_boundary([0.0, 0.0, 0.0]) 215 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 216 Bo = anuga.Dirichlet_boundary([-5, 0, 0]) # Outflow 219 217 220 218 # Upstream and downstream conditions that will exceed the rating curve 221 219 # I.e produce delta_h outside the range [0, 10] specified in the the 222 220 # file example_rating_curve.csv 223 Btus = Time_boundary(domain, lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0])224 Btds = Time_boundary(domain, lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0])221 Btus = anuga.Time_boundary(domain, lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0]) 222 Btds = anuga.Time_boundary(domain, lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0]) 225 223 domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br}) 226 224 … … 268 266 len1=length, 269 267 len2=width) 270 domain = Domain(points, vertices, boundary)268 domain = anuga.Domain(points, vertices, boundary) 271 269 domain.set_name('Test_culvert_dry') # Output name 272 270 domain.set_default_order(2) … … 331 329 # Inflow based on Flow Depth and Approaching Momentum 332 330 333 Br = Reflective_boundary(domain) # Solid reflective wall331 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 334 332 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 335 333 … … 388 386 len1=length, 389 387 len2=width) 390 domain = Domain(points, vertices, boundary)388 domain = anuga.Domain(points, vertices, boundary) 391 389 domain.set_name('Test_culvert_shallow') # Output name 392 390 domain.set_default_order(2) … … 463 461 # Inflow based on Flow Depth and Approaching Momentum 464 462 465 Br = Reflective_boundary(domain) # Solid reflective wall463 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 466 464 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 467 465 … … 525 523 len1=length, 526 524 len2=width) 527 domain = Domain(points, vertices, boundary)525 domain = anuga.Domain(points, vertices, boundary) 528 526 domain.set_name('Test_culvert_dry') # Output name 529 527 domain.set_default_order(2) … … 594 592 # Inflow based on Flow Depth and Approaching Momentum 595 593 596 Br = Reflective_boundary(domain) # Solid reflective wall594 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 597 595 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 598 596 … … 635 633 len1=length, 636 634 len2=width) 637 domain = Domain(points, vertices, boundary)635 domain = anuga.Domain(points, vertices, boundary) 638 636 639 637 domain.set_name('test_culvert') # Output name … … 711 709 len1=length, 712 710 len2=width) 713 domain = Domain(points, vertices, boundary)711 domain = anuga.Domain(points, vertices, boundary) 714 712 domain.set_name('Test_culvert_shallow') # Output name 715 713 domain.set_default_order(2) … … 782 780 783 781 784 Br = Reflective_boundary(domain) # Solid reflective wall782 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 785 783 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 786 784 -
trunk/anuga_core/source/anuga/damage_modelling/test_inundation_damage.py
r7776 r7778 13 13 from anuga.pmesh.mesh import Mesh 14 14 from anuga.coordinate_transforms.geo_reference import Geo_reference 15 from anuga.shallow_water import Domain, Transmissive_boundary16 15 from anuga.utilities.numerical_tools import mean 17 16 from anuga.file.sww import SWW_file -
trunk/anuga_core/source/anuga/file/csv_file.py
r7776 r7778 242 242 243 243 244 def csv2building_polygons(file_name,244 def load_csv_as_building_polygons(file_name, 245 245 floor_height=3, 246 246 clipping_polygons=None): … … 287 287 # @brief Convert CSV file into a dictionary of polygons and associated values. 288 288 # @param filename The path to the file to read, value_name name for the 4th column 289 def csv2polygons(file_name,289 def load_csv_as_polygons(file_name, 290 290 value_name='value', 291 291 clipping_polygons=None): -
trunk/anuga_core/source/anuga/file/pts.py
r7776 r7778 16 16 17 17 from anuga.pmesh.mesh import Mesh, importMeshFromFile 18 from anuga.shallow_water import Domain18 from anuga.shallow_water.shallow_water_domain import Domain 19 19 from anuga.pmesh.mesh_interface import create_mesh_from_regions 20 20 -
trunk/anuga_core/source/anuga/file/sts.py
r7766 r7778 1 1 import numpy as num 2 import log 3 from Scientific.IO.NetCDF import NetCDFFile 4 2 5 from anuga.config import max_float 3 6 from anuga.config import netcdf_float, netcdf_float32, netcdf_int … … 5 8 from anuga.coordinate_transforms.geo_reference import Geo_reference, \ 6 9 ensure_geo_reference 7 10 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 8 11 9 12 class Write_sts: … … 268 271 # @param stsname Stem of path to the STS file to read. 269 272 # @return A list of boundary points. 270 def create_sts_boundary(sts name):273 def create_sts_boundary(sts_filename): 271 274 """Create a list of points defining a boundary from an STS file. 272 275 … … 280 283 """ 281 284 285 if sts_filename.endswith('.sts'): 286 stsname_postfixed = sts_filename 287 else: 288 stsname_postfixed = sts_filename + '.sts' 289 282 290 try: 283 fid = NetCDFFile(stsname + '.sts', netcdf_mode_r)284 except :285 msg = 'Cannot open %s' % stsname + '.sts'291 fid = NetCDFFile(stsname_postfixed, netcdf_mode_r) 292 except IOError: 293 msg = 'Cannot open %s' % stsname_postfixed 286 294 raise IOError(msg) 287 295 -
trunk/anuga_core/source/anuga/file_conversion/__init__.py
r7776 r7778 1 1 """ Modules for performing conversions between file types, or for 2 resampling a given file. 2 resampling a given file. 3 4 In general, the naming convention follows this rule: 5 <file_ext_in>2<file_ext_out>('filename_in', 'filename_out') 6 7 for example: 8 sww2dem('northbeach.sww', 'outfile.dem') 3 9 """ 4 10 -
trunk/anuga_core/source/anuga/file_conversion/dem2dem.py
r7776 r7778 2 2 """ 3 3 4 import numpy as num 5 6 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_float 4 7 5 8 def dem2dem(basename_in, stencil, cellsize_new, basename_out=None, -
trunk/anuga_core/source/anuga/file_conversion/sww2dem.py
r7776 r7778 1 """ 2 Module to convert SWW to DEM files. 3 """ 4 1 5 # external modules 2 6 import numpy as num … … 417 421 418 422 419 420 ##421 # @brief422 # @param basename_in423 # @param extra_name_out424 # @param quantities425 # @param timestep426 # @param reduction427 # @param cellsize428 # @param number_of_decimal_places429 # @param NODATA_value430 # @param easting_min431 # @param easting_max432 # @param northing_min433 # @param northing_max434 # @param verbose435 # @param origin436 # @param datum437 # @param format438 # @return439 423 def sww2dem_batch(basename_in, extra_name_out=None, 440 424 quantities=None, # defaults to elevation -
trunk/anuga_core/source/anuga/file_conversion/test_urs2sts.py
r7770 r7778 13 13 from anuga.file.csv_file import load_csv_as_dict, load_csv_as_array 14 14 15 from anuga.shallow_water.shallow_water_domain import Domain 16 15 17 # boundary functions 16 18 from anuga.shallow_water.boundaries import Reflective_boundary, \ … … 20 22 import Transmissive_boundary, Dirichlet_boundary, \ 21 23 Time_boundary, File_boundary, AWI_boundary 24 25 from anuga.pmesh.mesh_interface import create_mesh_from_regions 22 26 23 27 from urs2sts import urs2sts … … 1316 1320 """ 1317 1321 1318 # FIXME (Ole): These tests should really move to1319 # test_generic_boundaries.py1320 1321 from anuga.shallow_water import Domain1322 from anuga.shallow_water import Reflective_boundary1323 from anuga.shallow_water import Dirichlet_boundary1324 from anuga.shallow_water import File_boundary1325 from anuga.pmesh.mesh_interface import create_mesh_from_regions1326 1327 1322 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02]] 1328 1323 tide = 0.37 … … 1458 1453 import warnings 1459 1454 warnings.simplefilter('ignore') 1460 1461 from anuga.shallow_water import Domain1462 from anuga.shallow_water import Reflective_boundary1463 from anuga.shallow_water import Dirichlet_boundary1464 from anuga.shallow_water import File_boundary1465 from anuga.pmesh.mesh_interface import create_mesh_from_regions1466 1455 1467 1456 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0], … … 1605 1594 import warnings 1606 1595 warnings.simplefilter('ignore') 1607 1608 from anuga.shallow_water import Domain1609 from anuga.shallow_water import Reflective_boundary1610 from anuga.shallow_water import Dirichlet_boundary1611 from anuga.shallow_water import File_boundary1612 from anuga.pmesh.mesh_interface import create_mesh_from_regions1613 1596 1614 1597 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0], … … 1723 1706 the correct order). 1724 1707 """ 1725 1726 from anuga.shallow_water import Domain1727 from anuga.shallow_water import Reflective_boundary1728 from anuga.shallow_water import Dirichlet_boundary1729 from anuga.shallow_water import File_boundary1730 from anuga.pmesh.mesh_interface import create_mesh_from_regions1731 1708 1732 1709 bounding_polygon=[[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02],[6.0,97.0]] … … 1831 1808 Read correct points from ordering file and apply sts to boundary 1832 1809 """ 1833 from anuga.shallow_water import Domain1834 from anuga.shallow_water import Reflective_boundary1835 from anuga.shallow_water import Dirichlet_boundary1836 from anuga.shallow_water import File_boundary1837 from anuga.pmesh.mesh_interface import create_mesh_from_regions1838 1810 1839 1811 lat_long_points=[[6.01,97.0],[6.02,97.0],[6.05,96.9],[6.0,97.0]] … … 1859 1831 ua=ua, 1860 1832 va=va) 1833 # base name will not exist, but 3 other files are created 1861 1834 1862 1835 # Write order file … … 1886 1859 self.delete_mux(files) 1887 1860 1888 assert(os.access( base_name, os.R_OK))1861 assert(os.access(sts_file+'.sts', os.F_OK)) 1889 1862 1890 1863 boundary_polygon = create_sts_boundary(base_name) … … 1979 1952 #assert allclose(domain_drchlt.quantities['stage'].vertex_values[6], 2) 1980 1953 #assert allclose(domain_fbound.quantities['stage'].vertex_values[6], 2) 1981 1982 1983 1954 1984 1955 try: 1985 1956 os.remove(sts_file+'.sts') 1986 except :1957 except IOError: 1987 1958 # Windoze can't remove this file for some reason 1988 1959 pass -
trunk/anuga_core/source/anuga/file_conversion/urs2sts.py
r7765 r7778 1 1 import numpy as num 2 import log 2 3 3 4 # ANUGA modules … … 315 316 316 317 outfile.close() 317 318 319 if verbose: 320 log.critical('Wrote sts file ' + stsname) 321 322 -
trunk/anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
r7751 r7778 28 28 from anuga.pmesh.mesh import Mesh 29 29 from anuga.geospatial_data.geospatial_data import Geospatial_data 30 from anuga.shallow_water import Domain30 from anuga.shallow_water.shallow_water_domain import Domain 31 31 from anuga.fit_interpolate.fit import Fit, fit_to_mesh 32 32 from anuga.fit_interpolate.interpolate import benchmark_interpolate -
trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py
r7717 r7778 33 33 from anuga.geospatial_data.geospatial_data import Geospatial_data 34 34 from anuga.geospatial_data.geospatial_data import ensure_absolute 35 from anuga. geometry.mesh_quadtree import MeshQuadtree35 from anuga.pmesh.mesh_quadtree import MeshQuadtree 36 36 from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate 37 37 from anuga.abstract_2d_finite_volumes.file_function import file_function -
trunk/anuga_core/source/anuga/fit_interpolate/test_fit.py
r7276 r7778 19 19 from anuga.utilities.numerical_tools import ensure_numeric 20 20 from anuga.geospatial_data.geospatial_data import Geospatial_data 21 from anuga.shallow_water import Domain21 from anuga.shallow_water.shallow_water_domain import Domain 22 22 23 23 import numpy as num -
trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r7776 r7778 18 18 19 19 20 21 20 # ANUGA code imports 21 import anuga 22 22 from interpolate import * 23 23 from anuga.coordinate_transforms.geo_reference import Geo_reference 24 from anuga.shallow_water import Domain, Transmissive_boundary25 24 from anuga.utilities.numerical_tools import mean, NAN 26 25 from anuga.file.sww import SWW_file -
trunk/anuga_core/source/anuga/geometry/polygon.py
r7711 r7778 7 7 from math import sqrt 8 8 from anuga.utilities.numerical_tools import ensure_numeric 9 from anuga.geospatial_data.geospatial_data import ensure_absolute, Geospatial_data 9 from anuga.geospatial_data.geospatial_data import ensure_absolute, \ 10 Geospatial_data 10 11 from anuga.config import netcdf_float 11 12 import anuga.utilities.log as log … … 69 70 % (str(p1), str(p2), str(p3), str(p4))) 70 71 71 # 0s1 0e1 1s0 1e0 # line 0 starts on 1, 0 ends 1, 1 starts 0, 1 ends 0 72 collinear_result = { (False, False, False, False): lines_dont_coincide, 73 (False, False, False, True ): lines_error, 74 (False, False, True, False): lines_error, 75 (False, False, True, True ): lines_1_fully_included_in_0, 76 (False, True, False, False): lines_error, 77 (False, True, False, True ): lines_overlap_opposite_direction2, 78 (False, True, True, False): lines_overlap_same_direction2, 79 (False, True, True, True ): lines_1_fully_included_in_0, 80 (True, False, False, False): lines_error, 81 (True, False, False, True ): lines_overlap_same_direction, 82 (True, False, True, False): lines_overlap_opposite_direction, 83 (True, False, True, True ): lines_1_fully_included_in_0, 84 (True, True, False, False): lines_0_fully_included_in_1, 85 (True, True, False, True ): lines_0_fully_included_in_1, 86 (True, True, True, False): lines_0_fully_included_in_1, 87 (True, True, True, True ): lines_0_fully_included_in_1 88 } 72 collinear_result = { 73 # line 0 starts on 1, 0 ends 1, 1 starts 0, 1 ends 0 74 # 0s1 0e1 1s0 1e0 75 (False, False, False, False): lines_dont_coincide, 76 (False, False, False, True ): lines_error, 77 (False, False, True, False): lines_error, 78 (False, False, True, True ): lines_1_fully_included_in_0, 79 (False, True, False, False): lines_error, 80 (False, True, False, True ): lines_overlap_opposite_direction2, 81 (False, True, True, False): lines_overlap_same_direction2, 82 (False, True, True, True ): lines_1_fully_included_in_0, 83 (True, False, False, False): lines_error, 84 (True, False, False, True ): lines_overlap_same_direction, 85 (True, False, True, False): lines_overlap_opposite_direction, 86 (True, False, True, True ): lines_1_fully_included_in_0, 87 (True, True, False, False): lines_0_fully_included_in_1, 88 (True, True, False, True ): lines_0_fully_included_in_1, 89 (True, True, True, False): lines_0_fully_included_in_1, 90 (True, True, True, True ): lines_0_fully_included_in_1 91 } 89 92 90 93 ## … … 275 278 276 279 # Quickly reject points that are clearly outside 277 if point[0] < min(triangle[:, 0]): return False278 if point[0] > max(triangle[:, 0]): return False279 if point[1] < min(triangle[:, 1]): return False280 if point[1] > max(triangle[:, 1]): return False280 if point[0] < min(triangle[:, 0]): return False 281 if point[0] > max(triangle[:, 0]): return False 282 if point[1] < min(triangle[:, 1]): return False 283 if point[1] > max(triangle[:, 1]): return False 281 284 282 285 … … 367 370 (type, point) = intersection(leftmost, l_x[cmp]) 368 371 comparisons += 1 369 if type != 0 and type != 4 or (type == 2 and list(point[0]) != list(point[1])): 372 if type != 0 and type != 4 or (type == 2 and list(point[0]) !=\ 373 list(point[1])): 370 374 if verbose: 371 print 'Self-intersecting polygon found, type ', type, ' point', point, 375 print 'Self-intersecting polygon found, type ', type 376 print 'point', point, 372 377 print 'vertices: ', leftmost, ' - ', l_x[cmp] 373 378 return True … … 586 591 if count == len(indices): 587 592 # No points are outside 588 return indices[:count], []593 return indices[:count], [] 589 594 else: 590 595 return indices[:count], indices[count:][::-1] #return reversed 591 596 592 ## 593 # @brief Sort a list of points into contiguous points inside+outside a polygon. 594 # @param points A set of points (tuple, list or array). 595 # @param polygon A set of points defining a polygon (tuple, list or array). 596 # @param closed True if points on boundary are considered 'inside' polygon. 597 # @param verbose True if this function is to be verbose. 598 # @return (indices, count) where indices are point indices and count is the 599 # delimiter index between point inside (on left) and others. 597 598 600 599 def separate_points_by_polygon(points, polygon, 601 600 closed=True, … … 644 643 if check_input: 645 644 #Input checks 646 assert isinstance(closed, bool), 'Keyword argument "closed" must be boolean' 647 assert isinstance(verbose, bool), 'Keyword argument "verbose" must be boolean' 645 assert isinstance(closed, bool), \ 646 'Keyword argument "closed" must be boolean' 647 assert isinstance(verbose, bool), \ 648 'Keyword argument "verbose" must be boolean' 648 649 649 650 try: … … 737 738 return abs(poly_area/2) 738 739 739 ## 740 # @brief Plot a set of polygons. 741 # @param polygons_points List of polygons to plot. 742 # @param style List of styles for each polygon. 743 # @param figname Name to save figure to. 744 # @param label Title for the plot. 745 # @param verbose True if this function is to be verbose. 746 # @return A list of min/max x and y values [minx, maxx, miny, maxy]. 747 # @note A style value is 'line' for polygons, 'outside' for points outside. 740 748 741 def plot_polygons(polygons_points, 749 742 style=None, … … 818 811 if s == 'outside': colour.append('r.') 819 812 if s == 'point': colour.append('g.') 820 if s <>'line':821 if s <>'outside':822 if s <>'point':813 if s != 'line': 814 if s != 'outside': 815 if s != 'point': 823 816 colour.append(s) 824 817 … … 836 829 title(label) 837 830 838 #raw_input('wait 1')839 #FIXME(Ole): This makes for some strange scalings sometimes.840 #if minx <> 0:841 # axis([minx*0.9,maxx*1.1,miny*0.9,maxy*1.1])842 #else:843 # if miny == 0:844 # axis([-maxx*.01,maxx*1.1,-maxy*0.01,maxy*1.1])845 # else:846 # axis([-maxx*.01,maxx*1.1,miny*0.9,maxy*1.1])847 848 831 if figname is not None: 849 832 savefig(figname) … … 856 839 return vec 857 840 858 ## 859 # @brief 860 # @param polygon A set of points defining a polygon. 861 # @param verbose True if this function is to be verbose. 862 # @return A tuple (x, y) of X and Y coordinates of the polygon. 863 # @note We duplicate the first point so can have closed polygon in plot. 841 864 842 def poly_xy(polygon, verbose=False): 865 843 """ this is used within plot_polygons so need to duplicate 866 844 the first point so can have closed polygon in plot 845 # @param polygon A set of points defining a polygon. 846 # @param verbose True if this function is to be verbose. 847 # @return A tuple (x, y) of X and Y coordinates of the polygon. 848 # @note We duplicate the first point so can have closed polygon in plot. 867 849 """ 868 850 … … 884 866 885 867 886 ##887 # @brief Define a class that defines a callable object for a polygon.888 # @note Object created is function: f: x,y -> z889 # where x, y and z are vectors and z depends on whether x,y belongs890 # to specified polygons.891 868 class Polygon_function: 892 869 """Create callable object f: x,y -> z, where a,y,z are vectors and … … 923 900 """ 924 901 925 ##926 # @brief Create instance of a polygon function.927 # @param regions A list of (x,y) tuples defining a polygon.928 # @param default Value or function returning value for points outside poly.929 # @param geo_reference ??930 902 def __init__(self, regions, default=0.0, geo_reference=None): 903 """ 904 # @brief Create instance of a polygon function. 905 # @param regions A list of (x,y) tuples defining a polygon. 906 # @param default Value or function returning value for points outside poly. 907 # @param geo_reference ?? 908 """ 909 931 910 try: 932 911 len(regions) … … 967 946 self.regions.append((P, value)) 968 947 969 ##970 # @brief Implement the 'callable' property of Polygon_function.971 # @param x List of x coordinates of points ot interest.972 # @param y List of y coordinates of points ot interest.973 948 def __call__(self, x, y): 949 """ 950 # @brief Implement the 'callable' property of Polygon_function. 951 # @param x List of x coordinates of points ot interest. 952 # @param y List of y coordinates of points ot interest. 953 """ 974 954 x = num.array(x, num.float) 975 955 y = num.array(y, num.float) … … 1014 994 ################################################################################ 1015 995 1016 ## 1017 # @brief Read polygon data from a file. 996 def read_polygon(filename, delimiter=','): 997 """Read points assumed to form a polygon. 998 1018 999 # @param filename Path to file containing polygon data. 1019 1000 # @param delimiter Delimiter to split polygon data with. 1020 1001 # @return A list of point data from the polygon file. 1021 def read_polygon(filename, delimiter=','): 1022 """Read points assumed to form a polygon. 1002 1023 1003 1024 1004 There must be exactly two numbers in each line separated by the delimiter. … … 1036 1016 # check this is a valid polygon. 1037 1017 if is_complex(polygon, verbose=True): 1038 msg = 'ERROR: Self-intersecting polygon detected in file ' + filename +'. ' 1039 msg += 'A complex polygon will not necessarily break the algorithms within ANUGA, ' 1040 msg += 'but it usually signifies pathological data. Please fix this file.' 1018 msg = 'ERROR: Self-intersecting polygon detected in file ' 1019 msg += filename +'. A complex polygon will not ' 1020 msg += 'necessarily break the algorithms within ANUGA, but it' 1021 msg += 'usually signifies pathological data. Please fix this file.' 1041 1022 raise Exception, msg 1042 1023 … … 1069 1050 pass 1070 1051 1071 ## 1072 # @brief Populate given polygon with uniformly distributed points. 1073 # @param polygon Polygon to uniformly fill. 1074 # @param number_of_points Number of points required in polygon. 1075 # @param seed Seed for random number generator. 1076 # @param exclude List of polygons inside main where points should be excluded. 1077 # @return List of random points inside input polygon. 1078 # @note Delimiter is assumed to be a comma. 1052 1079 1053 def populate_polygon(polygon, number_of_points, seed=None, exclude=None): 1080 1054 """Populate given polygon with uniformly distributed points. … … 1131 1105 return points 1132 1106 1133 ## 1134 # @brief Get a point inside a polygon that is close to an edge. 1135 # @param polygon List of vertices of polygon. 1136 # @param delta Maximum distance from an edge is delta * sqrt(2). 1137 # @return A point that is inside polgon and close to the polygon edge. 1107 1138 1108 def point_in_polygon(polygon, delta=1e-8): 1139 1109 """Return a point inside a given polygon which will be close to the … … 1186 1156 return point 1187 1157 1188 ## 1189 # @brief Calculate approximate number of triangles inside a bounding polygon. 1190 # @param interior_regions 1191 # @param bounding_poly 1192 # @param remainder_res 1193 # @return The number of triangles. 1158 1194 1159 def number_mesh_triangles(interior_regions, bounding_poly, remainder_res): 1195 1160 """Calculate the approximate number of triangles inside the … … 1247 1212 return int(total_number_of_triangles) 1248 1213 1214 1215 def decimate_polygon(polygon, factor=10): 1216 """Reduce number of points in polygon by the specified 1217 factor (default=10, hence the name of the function) such that 1218 the extrema in both axes are preserved. 1219 1249 1220 ## 1250 1221 # @brief Reduce number of points in polygon by the specified factor. 1251 1222 # @param polygon The polygon to reduce. 1252 1223 # @param factor The factor to reduce polygon points by (default 10). 1253 # @return The reduced polygon points list.1254 1224 # @note The extrema of both axes are preserved. 1255 def decimate_polygon(polygon, factor=10):1256 """Reduce number of points in polygon by the specified1257 factor (default=10, hence the name of the function) such that1258 the extrema in both axes are preserved.1259 1225 1260 1226 Return reduced polygon … … 1285 1251 return reduced_polygon 1286 1252 1287 ## 1288 # @brief Interpolate linearly from polyline nodes to midpoints of triangles. 1289 # @param data The data on the polyline nodes. 1290 # @param polyline_nodes ?? 1291 # @param gauge_neighbour_id ?? FIXME(Ole): I want to get rid of this 1292 # @param point_coordinates ?? 1293 # @param verbose True if this function is to be verbose. 1253 1294 1254 def interpolate_polyline(data, 1295 1255 polyline_nodes, … … 1370 1330 1371 1331 return points, vertices 1372 ##1373 # @brief1374 # @param data1375 # @param polyline_nodes1376 # @param gauge_neighbour_id1377 # @param interpolation_points1378 # @param interpolated_values1379 # @param rtol1380 # @param atol1381 # @return1382 # @note OBSOLETED BY C-EXTENSION1383 def _interpolate_polyline(data,1384 polyline_nodes,1385 gauge_neighbour_id,1386 interpolation_points,1387 interpolated_values,1388 rtol=1.0e-6,1389 atol=1.0e-8):1390 """Auxiliary function used by interpolate_polyline1391 1392 NOTE: OBSOLETED BY C-EXTENSION1393 """1394 1395 number_of_nodes = len(polyline_nodes)1396 number_of_points = len(interpolation_points)1397 1398 for j in range(number_of_nodes):1399 neighbour_id = gauge_neighbour_id[j]1400 1401 # FIXME(Ole): I am convinced that gauge_neighbour_id can be discarded,1402 # but need to check with John J.1403 # Keep it for now (17 Jan 2009)1404 # When gone, we can simply interpolate between neighbouring nodes,1405 # i.e. neighbour_id = j+1.1406 # and the test below becomes something like: if j < number_of_nodes...1407 1408 if neighbour_id >= 0:1409 x0, y0 = polyline_nodes[j,:]1410 x1, y1 = polyline_nodes[neighbour_id,:]1411 1412 segment_len = sqrt((x1-x0)**2 + (y1-y0)**2)1413 segment_delta = data[neighbour_id] - data[j]1414 slope = segment_delta/segment_len1415 1416 for i in range(number_of_points):1417 x, y = interpolation_points[i,:]1418 if point_on_line([x, y], [[x0, y0], [x1, y1]],1419 rtol=rtol, atol=atol):1420 dist = sqrt((x-x0)**2 + (y-y0)**2)1421 interpolated_values[i] = slope*dist + data[j]1422 1332 1423 1333 -
trunk/anuga_core/source/anuga/pmesh/mesh_quadtree.py
r7751 r7778 11 11 from anuga.utilities.numerical_tools import ensure_numeric 12 12 from anuga.config import max_float 13 from quad import Cell 14 from aabb import AABB 13 14 from anuga.geometry.quad import Cell 15 from anuga.geometry.aabb import AABB 15 16 16 17 from anuga.utilities import compile -
trunk/anuga_core/source/anuga/shallow_water/__init__.py
r7736 r7778 1 """Make directory available as a Python package 1 """ Shallow Water Wave Module. 2 3 This module performs the shallow water wave simulation, and is a 4 specialisation of the ANUGA domain. It contains supporting modules and 5 extra boundary classes to do with this specific domain. 2 6 """ 3 7 … … 6 10 sys.path += __path__ 7 11 8 # Make selected classes available directly9 from boundaries import Reflective_boundary,\10 Transmissive_momentum_set_stage_boundary,\11 Dirichlet_discharge_boundary,\12 Field_boundary,\13 Transmissive_stage_zero_momentum_boundary,\14 Transmissive_n_momentum_zero_t_momentum_set_stage_boundary15 16 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\17 import Transmissive_boundary, Dirichlet_boundary, \18 Time_boundary, File_boundary, AWI_boundary19 20 from shallow_water_domain import Domain21 22 23 #from shallow_water_balanced_domain import Swb_domain24 25 26 12 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r7776 r7778 511 511 512 512 513 514 ##515 # @brief Get the total flow through an arbitrary poly line.516 # @param polyline Representation of desired cross section.517 # @param verbose True if this method is to be verbose.518 # @note 'polyline' may contain multiple sections allowing complex shapes.519 # @note Assume absolute UTM coordinates.520 513 def get_flow_through_cross_section(self, polyline, verbose=False): 521 514 """Get the total flow through an arbitrary poly line. 522 515 523 516 This is a run-time equivalent of the function with same name 524 in data_manager.py517 in sww_interrogate.py 525 518 526 519 Input: … … 540 533 541 534 542 543 544 ##545 # @brief546 # @param polyline Representation of desired cross section.547 # @param kind Select energy type to compute ('specific' or 'total').548 # @param verbose True if this method is to be verbose.549 # @note 'polyline' may contain multiple sections allowing complex shapes.550 # @note Assume absolute UTM coordinates.551 535 def get_energy_through_cross_section(self, polyline, 552 536 kind='total', -
trunk/anuga_core/source/anuga/shallow_water/sww_interrogate.py
r7771 r7778 9 9 from anuga.coordinate_transforms.geo_reference import Geo_reference 10 10 from anuga.abstract_2d_finite_volumes.util import file_function 11 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a12 11 from anuga.geometry.polygon import is_inside_polygon 13 12 from anuga.file.sww import get_mesh_and_quantities_from_file 14 13 from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints 15 from anuga.config import g16 14 17 15 ## … … 374 372 maximal_runup_location = None 375 373 376 for file, swwfile in enumerate (iterate_over):374 for _, swwfile in enumerate (iterate_over): 377 375 # Read sww file 378 376 filename = os.path.join(dir, swwfile+'.sww') … … 387 385 try: 388 386 geo_reference = Geo_reference(NetCDFObject=fid) 389 except AttributeError , e:387 except AttributeError: 390 388 geo_reference = Geo_reference() # Default georef object 391 389 392 390 xllcorner = geo_reference.get_xllcorner() 393 391 yllcorner = geo_reference.get_yllcorner() 394 zone = geo_reference.get_zone()395 392 396 393 # Get extent … … 417 414 # FIXME (Ole): Make a generic polygon input check in polygon.py 418 415 # and call it here 419 points = num.ascontiguousarray(num.concatenate((x[:, num.newaxis],420 y[:, num.newaxis]),416 points = num.ascontiguousarray(num.concatenate((x[:, num.newaxis], 417 y[:, num.newaxis]), 421 418 axis=1)) 422 419 point_indices = inside_polygon(points, polygon) … … 497 494 wet_x = num.take(x, wet_nodes, axis=0) 498 495 wet_y = num.take(y, wet_nodes, axis=0) 499 maximal_runup_location = [wet_x[runup_index],wet_y[runup_index]] 496 maximal_runup_location = [wet_x[runup_index], \ 497 wet_y[runup_index]] 500 498 501 499 return maximal_runup, maximal_runup_location 502 500 503 504 505 def test_get_maximum_inundation_from_sww(self):506 """test_get_maximum_inundation_from_sww(self)507 508 Test of get_maximum_inundation_elevation()509 and get_maximum_inundation_location() from data_manager.py510 511 This is based on test_get_maximum_inundation_3(self) but works with the512 stored results instead of with the internal data structure.513 514 This test uses the underlying get_maximum_inundation_data for tests515 """516 517 from anuga.abstract_2d_finite_volumes.mesh_factory \518 import rectangular_cross519 from data_manager import get_maximum_inundation_elevation520 from data_manager import get_maximum_inundation_location521 from data_manager import get_maximum_inundation_data522 523 initial_runup_height = -0.4524 final_runup_height = -0.3525 526 #--------------------------------------------------------------527 # Setup computational domain528 #--------------------------------------------------------------529 N = 10530 points, vertices, boundary = rectangular_cross(N, N)531 domain = Domain(points, vertices, boundary)532 domain.set_name('runup_test')533 domain.set_maximum_allowed_speed(1.0)534 535 # FIXME: This works better with old limiters so far536 domain.tight_slope_limiters = 0537 538 #--------------------------------------------------------------539 # Setup initial conditions540 #--------------------------------------------------------------541 def topography(x, y):542 return -x/2 # linear bed slope543 544 # Use function for elevation545 domain.set_quantity('elevation', topography)546 domain.set_quantity('friction', 0.) # Zero friction547 # Constant negative initial stage548 domain.set_quantity('stage', initial_runup_height)549 550 #--------------------------------------------------------------551 # Setup boundary conditions552 #--------------------------------------------------------------553 Br = Reflective_boundary(domain) # Reflective wall554 Bd = Dirichlet_boundary([final_runup_height, 0, 0]) # Constant inflow555 556 # All reflective to begin with (still water)557 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})558 559 #--------------------------------------------------------------560 # Test initial inundation height561 #--------------------------------------------------------------562 indices = domain.get_wet_elements()563 z = domain.get_quantity('elevation').\564 get_values(location='centroids', indices=indices)565 assert num.alltrue(z < initial_runup_height)566 567 q_ref = domain.get_maximum_inundation_elevation()568 # First order accuracy569 assert num.allclose(q_ref, initial_runup_height, rtol=1.0/N)570 571 #--------------------------------------------------------------572 # Let triangles adjust573 #--------------------------------------------------------------574 for t in domain.evolve(yieldstep = 0.1, finaltime = 1.0):575 pass576 577 #--------------------------------------------------------------578 # Test inundation height again579 #--------------------------------------------------------------580 q_ref = domain.get_maximum_inundation_elevation()581 q = get_maximum_inundation_elevation('runup_test.sww')582 msg = 'We got %f, should have been %f' % (q, q_ref)583 assert num.allclose(q, q_ref, rtol=1.0/N), msg584 585 q = get_maximum_inundation_elevation('runup_test.sww')586 msg = 'We got %f, should have been %f' % (q, initial_runup_height)587 assert num.allclose(q, initial_runup_height, rtol = 1.0/N), msg588 589 # Test error condition if time interval is out590 try:591 q = get_maximum_inundation_elevation('runup_test.sww',592 time_interval=[2.0, 3.0])593 except ValueError:594 pass595 else:596 msg = 'should have caught wrong time interval'597 raise Exception, msg598 599 # Check correct time interval600 q, loc = get_maximum_inundation_data('runup_test.sww',601 time_interval=[0.0, 3.0])602 msg = 'We got %f, should have been %f' % (q, initial_runup_height)603 assert num.allclose(q, initial_runup_height, rtol = 1.0/N), msg604 assert num.allclose(-loc[0]/2, q) # From topography formula605 606 #--------------------------------------------------------------607 # Update boundary to allow inflow608 #--------------------------------------------------------------609 domain.set_boundary({'right': Bd})610 611 #--------------------------------------------------------------612 # Evolve system through time613 #--------------------------------------------------------------614 q_max = None615 for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0,616 skip_initial_step = True):617 q = domain.get_maximum_inundation_elevation()618 if q > q_max:619 q_max = q620 621 #--------------------------------------------------------------622 # Test inundation height again623 #--------------------------------------------------------------624 indices = domain.get_wet_elements()625 z = domain.get_quantity('elevation').\626 get_values(location='centroids', indices=indices)627 628 assert num.alltrue(z < final_runup_height)629 630 q = domain.get_maximum_inundation_elevation()631 # First order accuracy632 assert num.allclose(q, final_runup_height, rtol=1.0/N)633 634 q, loc = get_maximum_inundation_data('runup_test.sww',635 time_interval=[3.0, 3.0])636 msg = 'We got %f, should have been %f' % (q, final_runup_height)637 assert num.allclose(q, final_runup_height, rtol=1.0/N), msg638 assert num.allclose(-loc[0]/2, q) # From topography formula639 640 q = get_maximum_inundation_elevation('runup_test.sww')641 loc = get_maximum_inundation_location('runup_test.sww')642 msg = 'We got %f, should have been %f' % (q, q_max)643 assert num.allclose(q, q_max, rtol=1.0/N), msg644 assert num.allclose(-loc[0]/2, q) # From topography formula645 646 q = get_maximum_inundation_elevation('runup_test.sww',647 time_interval=[0, 3])648 msg = 'We got %f, should have been %f' % (q, q_max)649 assert num.allclose(q, q_max, rtol=1.0/N), msg650 651 # Check polygon mode652 # Runup region653 polygon = [[0.3, 0.0], [0.9, 0.0], [0.9, 1.0], [0.3, 1.0]]654 q = get_maximum_inundation_elevation('runup_test.sww',655 polygon = polygon,656 time_interval=[0, 3])657 msg = 'We got %f, should have been %f' % (q, q_max)658 assert num.allclose(q, q_max, rtol=1.0/N), msg659 660 # Offshore region661 polygon = [[0.9, 0.0], [1.0, 0.0], [1.0, 1.0], [0.9, 1.0]]662 q, loc = get_maximum_inundation_data('runup_test.sww',663 polygon = polygon,664 time_interval=[0, 3])665 msg = 'We got %f, should have been %f' % (q, -0.475)666 assert num.allclose(q, -0.475, rtol=1.0/N), msg667 assert is_inside_polygon(loc, polygon)668 assert num.allclose(-loc[0]/2, q) # From topography formula669 670 # Dry region671 polygon = [[0.0, 0.0], [0.4, 0.0], [0.4, 1.0], [0.0, 1.0]]672 q, loc = get_maximum_inundation_data('runup_test.sww',673 polygon = polygon,674 time_interval=[0, 3])675 msg = 'We got %s, should have been None' % (q)676 assert q is None, msg677 msg = 'We got %s, should have been None' % (loc)678 assert loc is None, msg679 680 # Check what happens if no time point is within interval681 try:682 q = get_maximum_inundation_elevation('runup_test.sww',683 time_interval=[2.75, 2.75])684 except AssertionError:685 pass686 else:687 msg = 'Time interval should have raised an exception'688 raise Exception, msg689 690 # Cleanup691 try:692 os.remove(domain.get_name() + '.sww')693 except:694 pass695 #FIXME(Ole): Windows won't allow removal of this696 -
trunk/anuga_core/source/anuga/shallow_water/test_data_manager.py
r7776 r7778 33 33 from anuga.config import netcdf_float, epsilon, g 34 34 35 from anuga.file.csv_file import load_csv_as_dict, load_csv_as_array 35 from anuga.file.csv_file import load_csv_as_dict, load_csv_as_array, \ 36 load_csv_as_building_polygons, \ 37 load_csv_as_polygons 36 38 from anuga.file.sts import create_sts_boundary 37 39 … … 1288 1290 1289 1291 1290 1291 ##################################1292 #Import the file as a new domain1293 ##################################1294 from data_manager import load_sww_as_domain1295 import os1296 1297 1292 filename = domain.datadir + os.sep + domain.get_name() + '.sww' 1298 1293 … … 1486 1481 assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit)) 1487 1482 1488 1489 def test_decimate_dem(self):1490 """Test decimation of dem file1491 """1492 1493 import os1494 from Scientific.IO.NetCDF import NetCDFFile1495 1496 #Write test dem file1497 root = 'decdemtest'1498 1499 filename = root + '.dem'1500 fid = NetCDFFile(filename, netcdf_mode_w)1501 1502 fid.institution = 'Geoscience Australia'1503 fid.description = 'NetCDF DEM format for compact and portable ' +\1504 'storage of spatial point data'1505 1506 nrows = 151507 ncols = 181508 1509 fid.ncols = ncols1510 fid.nrows = nrows1511 fid.xllcorner = 2000.51512 fid.yllcorner = 3000.51513 fid.cellsize = 251514 fid.NODATA_value = -99991515 1516 fid.zone = 561517 fid.false_easting = 0.01518 fid.false_northing = 0.01519 fid.projection = 'UTM'1520 fid.datum = 'WGS84'1521 fid.units = 'METERS'1522 1523 fid.createDimension('number_of_points', nrows*ncols)1524 1525 fid.createVariable('elevation', netcdf_float, ('number_of_points',))1526 1527 elevation = fid.variables['elevation']1528 1529 elevation[:] = (num.arange(nrows*ncols))1530 1531 fid.close()1532 1533 #generate the elevation values expected in the decimated file1534 ref_elevation = [( 0+ 1+ 2+ 18+ 19+ 20+ 36+ 37+ 38) / 9.0,1535 ( 4+ 5+ 6+ 22+ 23+ 24+ 40+ 41+ 42) / 9.0,1536 ( 8+ 9+ 10+ 26+ 27+ 28+ 44+ 45+ 46) / 9.0,1537 ( 12+ 13+ 14+ 30+ 31+ 32+ 48+ 49+ 50) / 9.0,1538 ( 72+ 73+ 74+ 90+ 91+ 92+108+109+110) / 9.0,1539 ( 76+ 77+ 78+ 94+ 95+ 96+112+113+114) / 9.0,1540 ( 80+ 81+ 82+ 98+ 99+100+116+117+118) / 9.0,1541 ( 84+ 85+ 86+102+103+104+120+121+122) / 9.0,1542 (144+145+146+162+163+164+180+181+182) / 9.0,1543 (148+149+150+166+167+168+184+185+186) / 9.0,1544 (152+153+154+170+171+172+188+189+190) / 9.0,1545 (156+157+158+174+175+176+192+193+194) / 9.0,1546 (216+217+218+234+235+236+252+253+254) / 9.0,1547 (220+221+222+238+239+240+256+257+258) / 9.0,1548 (224+225+226+242+243+244+260+261+262) / 9.0,1549 (228+229+230+246+247+248+264+265+266) / 9.0]1550 1551 # generate a stencil for computing the decimated values1552 stencil = num.ones((3,3), num.float) / 9.01553 1554 decimate_dem(root, stencil=stencil, cellsize_new=100)1555 1556 # Open decimated NetCDF file1557 fid = NetCDFFile(root + '_100.dem', netcdf_mode_r)1558 1559 # Get decimated elevation1560 elevation = fid.variables['elevation']1561 1562 # Check values1563 assert num.allclose(elevation, ref_elevation)1564 1565 # Cleanup1566 fid.close()1567 1568 os.remove(root + '.dem')1569 os.remove(root + '_100.dem')1570 1571 def test_decimate_dem_NODATA(self):1572 """Test decimation of dem file that includes NODATA values1573 """1574 1575 import os1576 from Scientific.IO.NetCDF import NetCDFFile1577 1578 # Write test dem file1579 root = 'decdemtest'1580 1581 filename = root + '.dem'1582 fid = NetCDFFile(filename, netcdf_mode_w)1583 1584 fid.institution = 'Geoscience Australia'1585 fid.description = 'NetCDF DEM format for compact and portable ' +\1586 'storage of spatial point data'1587 1588 nrows = 151589 ncols = 181590 NODATA_value = -99991591 1592 fid.ncols = ncols1593 fid.nrows = nrows1594 fid.xllcorner = 2000.51595 fid.yllcorner = 3000.51596 fid.cellsize = 251597 fid.NODATA_value = NODATA_value1598 1599 fid.zone = 561600 fid.false_easting = 0.01601 fid.false_northing = 0.01602 fid.projection = 'UTM'1603 fid.datum = 'WGS84'1604 fid.units = 'METERS'1605 1606 fid.createDimension('number_of_points', nrows*ncols)1607 1608 fid.createVariable('elevation', netcdf_float, ('number_of_points',))1609 1610 elevation = fid.variables['elevation']1611 1612 # Generate initial elevation values1613 elevation_tmp = (num.arange(nrows*ncols))1614 1615 # Add some NODATA values1616 elevation_tmp[0] = NODATA_value1617 elevation_tmp[95] = NODATA_value1618 elevation_tmp[188] = NODATA_value1619 elevation_tmp[189] = NODATA_value1620 elevation_tmp[190] = NODATA_value1621 elevation_tmp[209] = NODATA_value1622 elevation_tmp[252] = NODATA_value1623 1624 elevation[:] = elevation_tmp1625 1626 fid.close()1627 1628 # Generate the elevation values expected in the decimated file1629 ref_elevation = [NODATA_value,1630 ( 4+ 5+ 6+ 22+ 23+ 24+ 40+ 41+ 42) / 9.0,1631 ( 8+ 9+ 10+ 26+ 27+ 28+ 44+ 45+ 46) / 9.0,1632 ( 12+ 13+ 14+ 30+ 31+ 32+ 48+ 49+ 50) / 9.0,1633 ( 72+ 73+ 74+ 90+ 91+ 92+108+109+110) / 9.0,1634 NODATA_value,1635 ( 80+ 81+ 82+ 98+ 99+100+116+117+118) / 9.0,1636 ( 84+ 85+ 86+102+103+104+120+121+122) / 9.0,1637 (144+145+146+162+163+164+180+181+182) / 9.0,1638 (148+149+150+166+167+168+184+185+186) / 9.0,1639 NODATA_value,1640 (156+157+158+174+175+176+192+193+194) / 9.0,1641 NODATA_value,1642 (220+221+222+238+239+240+256+257+258) / 9.0,1643 (224+225+226+242+243+244+260+261+262) / 9.0,1644 (228+229+230+246+247+248+264+265+266) / 9.0]1645 1646 # Generate a stencil for computing the decimated values1647 stencil = num.ones((3,3), num.float) / 9.01648 1649 decimate_dem(root, stencil=stencil, cellsize_new=100)1650 1651 # Open decimated NetCDF file1652 fid = NetCDFFile(root + '_100.dem', netcdf_mode_r)1653 1654 # Get decimated elevation1655 elevation = fid.variables['elevation']1656 1657 # Check values1658 assert num.allclose(elevation, ref_elevation)1659 1660 # Cleanup1661 fid.close()1662 1663 os.remove(root + '.dem')1664 os.remove(root + '_100.dem')1665 1666 1667 1483 def test_file_boundary_stsIV_sinewave_ordering(self): 1668 1484 """test_file_boundary_stsIV_sinewave_ordering(self): … … 1671 1487 """ 1672 1488 1673 from anuga.shallow_water import Domain1489 from anuga.shallow_water.shallow_water_domain import Domain 1674 1490 from anuga.shallow_water import Reflective_boundary 1675 1491 from anuga.shallow_water import Dirichlet_boundary … … 1867 1683 """ 1868 1684 1869 from anuga.shallow_water import Domain1685 from anuga.shallow_water.shallow_water_domain import Domain 1870 1686 from anuga.shallow_water import Reflective_boundary 1871 1687 from anuga.shallow_water import Dirichlet_boundary -
trunk/anuga_core/source/anuga/shallow_water/test_forcing.py
r7744 r7778 3 3 4 4 import unittest, os 5 from anuga.shallow_water import Domain5 from anuga.shallow_water.shallow_water_domain import Domain 6 6 from boundaries import Reflective_boundary 7 7 from anuga.coordinate_transforms.geo_reference import Geo_reference -
trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r7771 r7778 5 5 from math import pi, sqrt 6 6 import tempfile 7 8 from anuga.shallow_water import Domain9 7 10 8 from Scientific.IO.NetCDF import NetCDFFile … … 31 29 from anuga.shallow_water.sww_interrogate import get_flow_through_cross_section 32 30 31 from shallow_water_domain import Domain 32 33 33 # boundary functions 34 from anuga.shallow_water.boundaries import Reflective_boundary, \34 from boundaries import Reflective_boundary, \ 35 35 Field_boundary, Transmissive_momentum_set_stage_boundary, \ 36 36 Transmissive_stage_zero_momentum_boundary … … 1548 1548 from anuga.abstract_2d_finite_volumes.mesh_factory \ 1549 1549 import rectangular_cross 1550 from anuga.shallow_water import Domain1550 from anuga.shallow_water.shallow_water_domain import Domain 1551 1551 from anuga.shallow_water import Reflective_boundary 1552 1552 from anuga.shallow_water import Dirichlet_boundary … … 5359 5359 verbose = False 5360 5360 5361 from anuga.shallow_water import Domain5361 from anuga.shallow_water.shallow_water_domain import Domain 5362 5362 from anuga.pmesh.mesh_interface import create_mesh_from_regions 5363 5363 from anuga.geospatial_data.geospatial_data import Geospatial_data … … 5472 5472 verbose = False 5473 5473 5474 from anuga.shallow_water import Domain5474 from anuga.shallow_water.shallow_water_domain import Domain 5475 5475 from anuga.pmesh.mesh_interface import create_mesh_from_regions 5476 5476 from anuga.geospatial_data import Geospatial_data … … 5536 5536 from anuga.abstract_2d_finite_volumes.mesh_factory \ 5537 5537 import rectangular_cross 5538 from anuga.shallow_water import Domain5538 from anuga.shallow_water.shallow_water_domain import Domain 5539 5539 5540 5540 #---------------------------------------------------------------------- … … 5601 5601 from anuga.abstract_2d_finite_volumes.mesh_factory \ 5602 5602 import rectangular_cross 5603 from anuga.shallow_water import Domain5603 from anuga.shallow_water.shallow_water_domain import Domain 5604 5604 from anuga.shallow_water.forcing import Inflow 5605 5605 … … 5690 5690 #--------------------------------------------------------------------- 5691 5691 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 5692 from anuga.shallow_water import Domain5692 from anuga.shallow_water.shallow_water_domain import Domain 5693 5693 5694 5694 #---------------------------------------------------------------------- … … 5887 5887 #--------------------------------------------------------------------- 5888 5888 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 5889 from anuga.shallow_water import Domain5889 from anuga.shallow_water.shallow_water_domain import Domain 5890 5890 from anuga.shallow_water.boundaries import Reflective_boundary 5891 5891 from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary … … 6003 6003 #--------------------------------------------------------------------- 6004 6004 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 6005 from anuga.shallow_water import Domain6005 from anuga.shallow_water.shallow_water_domain import Domain 6006 6006 from anuga.shallow_water import Reflective_boundary 6007 6007 from anuga.shallow_water import Dirichlet_boundary … … 6254 6254 6255 6255 6256 #----------------------------------------------------------------------6257 # Import necessary modules6258 #----------------------------------------------------------------------6259 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross6260 from anuga.shallow_water.data_manager import get_flow_through_cross_section6261 from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs6262 6263 6256 6264 6257 #---------------------------------------------------------------------- … … 6391 6384 from anuga.abstract_2d_finite_volumes.mesh_factory \ 6392 6385 import rectangular_cross 6393 from anuga.shallow_water import Domain6386 from anuga.shallow_water.shallow_water_domain import Domain 6394 6387 from anuga.shallow_water.shallow_water_domain import Reflective_boundary 6395 6388 from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary -
trunk/anuga_core/source/anuga/shallow_water/test_sww_interrogate.py
r7771 r7778 694 694 pass 695 695 #FIXME(Ole): Windows won't allow removal of this 696 696 697 698 def test_get_maximum_inundation_from_sww(self): 699 """test_get_maximum_inundation_from_sww(self) 700 701 Test of get_maximum_inundation_elevation() 702 and get_maximum_inundation_location(). 703 704 This is based on test_get_maximum_inundation_3(self) but works with the 705 stored results instead of with the internal data structure. 706 707 This test uses the underlying get_maximum_inundation_data for tests 708 """ 709 710 initial_runup_height = -0.4 711 final_runup_height = -0.3 712 713 #-------------------------------------------------------------- 714 # Setup computational domain 715 #-------------------------------------------------------------- 716 N = 10 717 points, vertices, boundary = rectangular_cross(N, N) 718 domain = Domain(points, vertices, boundary) 719 domain.set_name('runup_test') 720 domain.set_maximum_allowed_speed(1.0) 721 722 # FIXME: This works better with old limiters so far 723 domain.tight_slope_limiters = 0 724 725 #-------------------------------------------------------------- 726 # Setup initial conditions 727 #-------------------------------------------------------------- 728 def topography(x, y): 729 return -x/2 # linear bed slope 730 731 # Use function for elevation 732 domain.set_quantity('elevation', topography) 733 domain.set_quantity('friction', 0.) # Zero friction 734 # Constant negative initial stage 735 domain.set_quantity('stage', initial_runup_height) 736 737 #-------------------------------------------------------------- 738 # Setup boundary conditions 739 #-------------------------------------------------------------- 740 Br = Reflective_boundary(domain) # Reflective wall 741 Bd = Dirichlet_boundary([final_runup_height, 0, 0]) # Constant inflow 742 743 # All reflective to begin with (still water) 744 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 745 746 #-------------------------------------------------------------- 747 # Test initial inundation height 748 #-------------------------------------------------------------- 749 indices = domain.get_wet_elements() 750 z = domain.get_quantity('elevation').\ 751 get_values(location='centroids', indices=indices) 752 assert num.alltrue(z < initial_runup_height) 753 754 q_ref = domain.get_maximum_inundation_elevation() 755 # First order accuracy 756 assert num.allclose(q_ref, initial_runup_height, rtol=1.0/N) 757 758 #-------------------------------------------------------------- 759 # Let triangles adjust 760 #-------------------------------------------------------------- 761 for t in domain.evolve(yieldstep = 0.1, finaltime = 1.0): 762 pass 763 764 #-------------------------------------------------------------- 765 # Test inundation height again 766 #-------------------------------------------------------------- 767 q_ref = domain.get_maximum_inundation_elevation() 768 q = get_maximum_inundation_elevation('runup_test.sww') 769 msg = 'We got %f, should have been %f' % (q, q_ref) 770 assert num.allclose(q, q_ref, rtol=1.0/N), msg 771 772 q = get_maximum_inundation_elevation('runup_test.sww') 773 msg = 'We got %f, should have been %f' % (q, initial_runup_height) 774 assert num.allclose(q, initial_runup_height, rtol = 1.0/N), msg 775 776 # Test error condition if time interval is out 777 try: 778 q = get_maximum_inundation_elevation('runup_test.sww', 779 time_interval=[2.0, 3.0]) 780 except ValueError: 781 pass 782 else: 783 msg = 'should have caught wrong time interval' 784 raise Exception, msg 785 786 # Check correct time interval 787 q, loc = get_maximum_inundation_data('runup_test.sww', 788 time_interval=[0.0, 3.0]) 789 msg = 'We got %f, should have been %f' % (q, initial_runup_height) 790 assert num.allclose(q, initial_runup_height, rtol = 1.0/N), msg 791 assert num.allclose(-loc[0]/2, q) # From topography formula 792 793 #-------------------------------------------------------------- 794 # Update boundary to allow inflow 795 #-------------------------------------------------------------- 796 domain.set_boundary({'right': Bd}) 797 798 #-------------------------------------------------------------- 799 # Evolve system through time 800 #-------------------------------------------------------------- 801 q_max = None 802 for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0, 803 skip_initial_step = True): 804 q = domain.get_maximum_inundation_elevation() 805 if q > q_max: 806 q_max = q 807 808 #-------------------------------------------------------------- 809 # Test inundation height again 810 #-------------------------------------------------------------- 811 indices = domain.get_wet_elements() 812 z = domain.get_quantity('elevation').\ 813 get_values(location='centroids', indices=indices) 814 815 assert num.alltrue(z < final_runup_height) 816 817 q = domain.get_maximum_inundation_elevation() 818 # First order accuracy 819 assert num.allclose(q, final_runup_height, rtol=1.0/N) 820 821 q, loc = get_maximum_inundation_data('runup_test.sww', 822 time_interval=[3.0, 3.0]) 823 msg = 'We got %f, should have been %f' % (q, final_runup_height) 824 assert num.allclose(q, final_runup_height, rtol=1.0/N), msg 825 assert num.allclose(-loc[0]/2, q) # From topography formula 826 827 q = get_maximum_inundation_elevation('runup_test.sww') 828 loc = get_maximum_inundation_location('runup_test.sww') 829 msg = 'We got %f, should have been %f' % (q, q_max) 830 assert num.allclose(q, q_max, rtol=1.0/N), msg 831 assert num.allclose(-loc[0]/2, q) # From topography formula 832 833 q = get_maximum_inundation_elevation('runup_test.sww', 834 time_interval=[0, 3]) 835 msg = 'We got %f, should have been %f' % (q, q_max) 836 assert num.allclose(q, q_max, rtol=1.0/N), msg 837 838 # Check polygon mode 839 # Runup region 840 polygon = [[0.3, 0.0], [0.9, 0.0], [0.9, 1.0], [0.3, 1.0]] 841 q = get_maximum_inundation_elevation('runup_test.sww', 842 polygon = polygon, 843 time_interval=[0, 3]) 844 msg = 'We got %f, should have been %f' % (q, q_max) 845 assert num.allclose(q, q_max, rtol=1.0/N), msg 846 847 # Offshore region 848 polygon = [[0.9, 0.0], [1.0, 0.0], [1.0, 1.0], [0.9, 1.0]] 849 q, loc = get_maximum_inundation_data('runup_test.sww', 850 polygon = polygon, 851 time_interval=[0, 3]) 852 msg = 'We got %f, should have been %f' % (q, -0.475) 853 assert num.allclose(q, -0.475, rtol=1.0/N), msg 854 assert is_inside_polygon(loc, polygon) 855 assert num.allclose(-loc[0]/2, q) # From topography formula 856 857 # Dry region 858 polygon = [[0.0, 0.0], [0.4, 0.0], [0.4, 1.0], [0.0, 1.0]] 859 q, loc = get_maximum_inundation_data('runup_test.sww', 860 polygon = polygon, 861 time_interval=[0, 3]) 862 msg = 'We got %s, should have been None' % (q) 863 assert q is None, msg 864 msg = 'We got %s, should have been None' % (loc) 865 assert loc is None, msg 866 867 # Check what happens if no time point is within interval 868 try: 869 q = get_maximum_inundation_elevation('runup_test.sww', 870 time_interval=[2.75, 2.75]) 871 except AssertionError: 872 pass 873 else: 874 msg = 'Time interval should have raised an exception' 875 raise Exception, msg 876 877 # Cleanup 878 try: 879 os.remove(domain.get_name() + '.sww') 880 except: 881 pass 882 #FIXME(Ole): Windows won't allow removal of this 883 884 885 697 886 698 887 if __name__ == "__main__": -
trunk/anuga_core/source/anuga/shallow_water/test_system.py
r7736 r7778 9 9 import numpy as num 10 10 11 from anuga.shallow_water import Domain 12 from anuga.shallow_water import Dirichlet_boundary, Time_boundary 13 from anuga.shallow_water import File_boundary 11 import anuga 14 12 from anuga.pmesh.mesh import Mesh 15 13 from anuga.abstract_2d_finite_volumes.pmesh2domain import \ … … 47 45 mesh.generate_mesh(verbose=False) 48 46 49 domain = pmesh_to_domain_instance(mesh, Domain)47 domain = pmesh_to_domain_instance(mesh, anuga.Domain) 50 48 domain.set_name(boundary_name) 51 49 domain.set_datadir(dir) … … 57 55 58 56 # Setup boundary conditions 59 Bd = Dirichlet_boundary([tide,0.,0.]) # Constant boundary values60 Bd = Time_boundary(domain=domain, # Time dependent boundary57 Bd = anuga.Dirichlet_boundary([tide,0.,0.]) # Constant boundary values 58 Bd = anuga.Time_boundary(domain=domain, # Time dependent boundary 61 59 f=lambda t: [t, 0.0, 0.0]) 62 60 domain.set_boundary({'exterior': Bd}) … … 96 94 mesh.generate_mesh(verbose=False) 97 95 98 domain = pmesh_to_domain_instance(mesh, Domain)96 domain = pmesh_to_domain_instance(mesh, anuga.Domain) 99 97 domain.set_name(senario_name) 100 98 domain.set_datadir(dir) … … 103 101 domain.set_quantity('elevation', 0.0) 104 102 domain.set_quantity('stage', 0.0) 105 Bf = File_boundary(boundary_filename,103 Bf = anuga.File_boundary(boundary_filename, 106 104 domain, use_cache=False, verbose=False) 107 105 … … 146 144 mesh.generate_mesh(verbose=False) 147 145 148 domain = pmesh_to_domain_instance(mesh, Domain)146 domain = pmesh_to_domain_instance(mesh, anuga.Domain) 149 147 domain.set_name(senario_name) 150 148 domain.set_datadir(dir) … … 155 153 domain.set_quantity('elevation', 0.0) 156 154 domain.set_quantity('stage', 0.0) 157 Bf = File_boundary(boundary_filename,155 Bf = anuga.File_boundary(boundary_filename, 158 156 domain, use_cache=False, verbose=False) 159 157 -
trunk/anuga_core/source/anuga/utilities/file_utils.py
r7765 r7778 9 9 import shutil 10 10 11 ##12 # @brief Convert a possible filename into a standard form.13 # @param s Filename to process.14 # @return The new filename string.15 11 def make_filename(s): 16 """Transform argument string into a Sexsuitable filename 12 """Transform argument string into a standard filename 13 14 Convert a possible filename into a standard form. 15 s Filename to process. 16 The new filename string. 17 17 """ 18 18 … … 26 26 27 27 28 ##29 # @brief Check that a specified filesystem directory path exists.30 # @param path The dirstory path to check.31 # @param verbose True if this function is to be verbose.32 # @note If directory path doesn't exist, it will be created.33 28 def check_dir(path, verbose=None): 34 29 """Check that specified path exists.
Note: See TracChangeset
for help on using the changeset viewer.