Changeset 6190


Ignore:
Timestamp:
Jan 18, 2009, 12:53:50 PM (10 years ago)
Author:
ole
Message:

Started anuga.interface module

Files:
1 added
4 edited

Legend:

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

    r6178 r6190  
    88# Make selected classes available directly
    99from shallow_water_domain import Domain,\
    10      create_domain_from_regions,\
    1110     Transmissive_boundary, Reflective_boundary,\
    1211     Dirichlet_boundary, Time_boundary, File_boundary,\
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r6178 r6190  
    115115from types import IntType, FloatType
    116116from warnings import warn
    117 
    118 
    119 
    120 #---------------------------
    121 # Create domain from regions
    122 #---------------------------
    123 
    124 def create_domain_from_regions(bounding_polygon,
    125                                boundary_tags,
    126                                maximum_triangle_area=None,
    127                                mesh_filename=None,
    128                                interior_regions=None,
    129                                interior_holes=None,
    130                                poly_geo_reference=None,
    131                                mesh_geo_reference=None,
    132                                minimum_triangle_angle=28.0,
    133                                fail_if_polygons_outside=True,
    134                                use_cache=False,
    135                                verbose=True):
    136     """Create domain from bounding polygons and resolutions.
    137 
    138     bounding_polygon is a list of points in Eastings and Northings,
    139     relative to the poly_geo_reference.
    140 
    141     Boundary tags is a dictionary of symbolic tags. For every tag there
    142     is a list of indices referring to segments associated with that tag.
    143     If a segment is omitted it will be assigned the default tag ''.
    144 
    145     maximum_triangle_area is the maximal area per triangle
    146     for the bounding polygon, excluding the  interior regions.
    147 
    148     Interior_regions is a list of tuples consisting of (polygon,
    149     resolution) for each region to be separately refined. Do not have
    150     polygon lines cross or be on-top of each other.  Also do not have
    151     polygon close to each other.
    152    
    153     NOTE: If a interior_region is outside the bounding_polygon it should
    154     throw an error
    155    
    156     Interior_holes is a list of ploygons for each hole.
    157 
    158     This function does not allow segments to share points - use underlying
    159     pmesh functionality for that
    160 
    161     poly_geo_reference is the geo_reference of the bounding polygon and
    162     the interior polygons.
    163     If none, assume absolute.  Please pass one though, since absolute
    164     references have a zone.
    165    
    166     mesh_geo_reference is the geo_reference of the mesh to be created.
    167     If none is given one will be automatically generated.  It was use
    168     the lower left hand corner of  bounding_polygon (absolute)
    169     as the x and y values for the geo_ref.
    170    
    171     Returns the shallow water domain instance
    172 
    173     Note, interior regions should be fully nested, as overlaps may cause
    174     unintended resolutions.
    175 
    176     fail_if_polygons_outside: If True (the default) Exception in thrown
    177     where interior polygons fall outside bounding polygon. If False, these
    178     will be ignored and execution continued.
    179        
    180    
    181     """
    182 
    183 
    184     # Build arguments and keyword arguments for use with caching or apply.
    185     args = (bounding_polygon,
    186             boundary_tags)
    187    
    188     kwargs = {'maximum_triangle_area': maximum_triangle_area,
    189               'mesh_filename': mesh_filename,
    190               'interior_regions': interior_regions,
    191               'interior_holes': interior_holes,
    192               'poly_geo_reference': poly_geo_reference,
    193               'mesh_geo_reference': mesh_geo_reference,
    194               'minimum_triangle_angle': minimum_triangle_angle,
    195               'fail_if_polygons_outside': fail_if_polygons_outside,
    196               'verbose': verbose} #FIXME (Ole): See ticket:14
    197 
    198     # Call underlying engine with or without caching
    199     if use_cache is True:
    200         try:
    201             from anuga.caching import cache
    202         except:
    203             msg = 'Caching was requested, but caching module'+\
    204                   'could not be imported'
    205             raise msg
    206 
    207 
    208         domain = cache(_create_domain_from_regions,
    209                        args, kwargs,
    210                        verbose=verbose,
    211                        compression=False)
    212     else:
    213         domain = apply(_create_domain_from_regions,
    214                        args, kwargs)
    215 
    216     return domain
    217 
    218        
    219 def _create_domain_from_regions(bounding_polygon,
    220                                 boundary_tags,
    221                                 maximum_triangle_area=None,
    222                                 mesh_filename=None,                           
    223                                 interior_regions=None,
    224                                 interior_holes=None,
    225                                 poly_geo_reference=None,
    226                                 mesh_geo_reference=None,
    227                                 minimum_triangle_angle=28.0,
    228                                 fail_if_polygons_outside=True,
    229                                 verbose=True):
    230     """_create_domain_from_regions - internal function.
    231 
    232     See create_domain_from_regions for documentation.
    233     """
    234 
    235     create_mesh_from_regions(bounding_polygon,
    236                              boundary_tags,
    237                              maximum_triangle_area=maximum_triangle_area,
    238                              interior_regions=interior_regions,
    239                              filename=mesh_filename,
    240                              interior_holes=interior_holes,
    241                              poly_geo_reference=poly_geo_reference,
    242                              mesh_geo_reference=mesh_geo_reference,
    243                              minimum_triangle_angle=minimum_triangle_angle,
    244                              fail_if_polygons_outside=fail_if_polygons_outside,
    245                              use_cache=False,
    246                              verbose=verbose)
    247 
    248     domain = Domain(mesh_filename, use_cache=False, verbose=verbose)
    249 
    250 
    251     return domain
    252    
    253 
    254 
    255117
    256118
  • anuga_work/production/patong/build_patong.py

    r6028 r6190  
    8484G1_clip = G1.clip(project.extent_elev_dir4, verbose=True)
    8585G3_clip1 = G3.clip_outside(project.extent_elev_dir4, verbose=True)
    86 G3_clip2 =G3_clip1.clip_outside(project.extent_elev_dir2, verbose=True)
     86G3_clip2 = G3_clip1.clip_outside(project.extent_elev_dir2, verbose=True)
    8787G4_clip = G4.clip_outside(project.extent_elev_dir3, verbose=True)
    8888
  • anuga_work/production/patong/run_patong.py

    r6178 r6190  
    1 """Script for running a tsunami inundation scenario for Perth, WA, Australia.
     1"""Script for running a tsunami inundation scenario for Patong Beach, Thailand.
    22
    33The scenario is defined by a triangular mesh created from project.polygon,
    4 the elevation data is compiled into a pts file through build_perth.py
    5 and a simulated tsunami is generated through an sts file from build_boundary.py.
     4the elevation data is compiled into a pts file through build_patong.py
     5and a simulated tsunami for the 2004 event is generated through
     6an sts file from build_boundary.py.
    67
    78Input: sts file (build_boundary.py)
    8        pts file (build_perth.py)
     9       pts file (build_patong.py)
    910       information from project file
    1011Outputs: sww file stored in project.output_run_time_dir
     
    1213on the outputs of this script
    1314
    14 Ole Nielsen and Duncan Gray, GA - 2005, Jane Sexton, Nick Bartzis, GA - 2006
    15 Ole Nielsen, Jane Sexton and Kristy Van Putten - 2008
    1615"""
    1716
     
    2726
    2827# Related major packages
    29 from anuga.shallow_water import Domain
    30 from anuga.shallow_water import Dirichlet_boundary
    31 from anuga.shallow_water import File_boundary
    32 from anuga.shallow_water import Reflective_boundary
    33 from anuga.shallow_water import Field_boundary
    34 from anuga.shallow_water.data_manager import export_grid, create_sts_boundary, csv2building_polygons
    35 from anuga.shallow_water import create_domain_from_regions
     28from anuga.interface import create_domain_from_regions
     29from anuga.interface import Domain
     30from anuga.interface import Dirichlet_boundary
     31from anuga.interface import File_boundary
     32from anuga.interface import Reflective_boundary
     33from anuga.interface import Field_boundary
     34from anuga.interface import export_grid, create_sts_boundary
     35from anuga.interface import csv2building_polygons
     36
    3637from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files,store_parameters
    37 from anuga.caching import myhash
    38 from anuga.damage_modelling.inundation_damage import add_depth_and_momentum2csv, inundation_damage
    3938from anuga.fit_interpolate.benchmark_least_squares import mem_usage
    4039from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon
     
    178177
    179178for t in domain.evolve(yieldstep=project.yieldstep,
    180                        finaltime=project.finaltime)
     179                       finaltime=project.finaltime):
    181180    print domain.timestepping_statistics()
    182181    print domain.boundary_statistics(tags='ocean')
Note: See TracChangeset for help on using the changeset viewer.