Changeset 3631


Ignore:
Timestamp:
Sep 20, 2006, 12:51:15 PM (18 years ago)
Author:
ole
Message:

Added modify_boundary - this is e.g. useful for codes using the parallel_api,
but could also be used to change boundaries on the fly.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r3612 r3631  
    355355
    356356
     357    def modify_boundary(self, boundary_map):
     358        """Modify existing boundary by elements in boundary map
     359
     360        Input:
     361
     362        boundary_map: Dictionary mapping tags to boundary objects
     363
     364        See set_boundary for more details on how this works
     365        """
     366
     367        for key in boundary_map.keys():
     368            self.boundary_map[key] = boundary_map[key]
     369
     370        self.set_boundary(self.boundary_map)
     371       
     372       
    357373
    358374    def set_boundary(self, boundary_map):
  • anuga_work/production/karratha_2006/run_karratha.py

    r3627 r3631  
    1 """Script for running a tsunami inundation scenario for Broome, WA, Australia.
     1"""Script for running tsunami inundation scenario for Karratha, WA, Australia.
    22
    33Source data such as elevation and boundary data is assumed to be available in
     
    88the elevation data and a simulated submarine landslide.
    99
    10 Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006
     10Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
    1111"""
    1212#------------------------------------------------------------------------------
     
    1717from os import sep
    1818from os.path import dirname, basename
     19from os import mkdir, access, F_OK
     20from shutil import copy
    1921import time
     22import sys
     23
    2024
    2125# Related major packages
     
    2731from anuga.pmesh.mesh_interface import create_mesh_from_regions
    2832
    29 from shutil import copy
    30 from os import mkdir, access, F_OK
    3133from anuga.geospatial_data.geospatial_data import *
    32 import sys
    33 from anuga.abstract_2d_finite_volumes.util import Screen_Catcher
    3434
    3535# Application specific imports
     
    5858    print 'project.outputtimedir',project.outputtimedir
    5959
    60     # normal screen output is stored in
    61     screen_output_name = project.outputtimedir + 'screen_output.txt'
    62     screen_error_name = project.outputtimedir + 'screen_error.txt'
    63 
    64     # used to catch screen output to file
    65     #sys.stdout = Screen_Catcher(screen_output_name)
    66     #sys.stderr = Screen_Catcher(screen_error_name)
    67     print 'USER:    ', project.user
    68 
    6960
    7061    #--------------------------------------------------------------------------
    71     # Create the triangular mesh based on overall clipping polygon with a tagged
     62    # Create the triangular mesh based on overall clipping polygon with a
     63    # tagged
    7264    # boundary and interior regions defined in project.py along with
    7365    # resolutions (maximal area of per triangle) for each polygon
     
    7567
    7668
    77     resolution = 4000
    78     interior_regions = [[project.neil1_polygon, resolution],
    79                         [project.neil2_polygon, 64000]]
    80 
    81     print 'number of interior regions', len(interior_regions)
    82 
    83 
    8469    print 'start create mesh from regions'
    8570    from caching import cache
    86 
    8771    meshname = project.meshname + '_%d.msh' %myid
    8872    _ = cache(create_mesh_from_regions,
     
    9074              {'boundary_tags': {'back': [7, 8], 'side': [0, 6],
    9175                                 'ocean': [1, 2, 3, 4, 5]},
    92                'maximum_triangle_area': 100000,
     76               'maximum_triangle_area': 200000,
    9377               'filename': meshname},
    94               #'interior_regions': interior_regions},
    9578              verbose = True,
    9679              evaluate = False)
    9780
    98     #------------------------------------------------------------------------- 
     81    #-------------------------------------------------------------------------
    9982    # Setup computational domain
    10083    #-------------------------------------------------------------------------
    101 
    10284    domain = Domain(meshname, use_cache = True, verbose = True)
    10385    print domain.statistics()
    104 
    105 
    10686    domain.set_name(project.basename)
    10787    domain.set_datadir(project.outputtimedir)
     
    11191    # Setup initial conditions
    11292    #-------------------------------------------------------------------------
    113 
    11493    tide = 0.
    115    
    11694    domain.set_quantity('stage', tide)
    11795    domain.set_quantity('friction', 0.0)
     
    12098                        use_cache = False,
    12199                        verbose = True,
    122                         alpha = 0.1
    123                         )
     100                        alpha = 0.1)
    124101   
    125102    #-------------------------------------------------------------------------
     
    128105
    129106    print 'Available boundary tags', domain.get_boundary_tags()
    130 
    131107    Bf = File_boundary(source_dir + project.boundary_basename + '.sww',
    132108                       domain, verbose = True)
     
    135111    domain.set_boundary({'back': Br,
    136112                         'side': Bd,
    137                          #'ocean': None}) # Bind this one later
    138                          'ocean': Bf}) # Bind this one later   
     113                         'ocean': None}) # Bind this one later
    139114else:
    140115    domain = None
     
    146121domain = distribute(domain, verbose=True)
    147122
    148 
    149123# Set those boundaries that can't be communicated automatically
    150124Bf = File_boundary(source_dir + project.boundary_basename + '.sww',
     
    152126boundary_map = domain.boundary_map
    153127boundary_map['ocean'] = Bf
    154 
    155 print boundary_map
    156128domain.set_boundary(boundary_map)
    157 
    158129
    159130
  • anuga_work/production/wollongong_2006/run_flagstaff_parallel_api.py

    r3624 r3631  
    3232
    3333# Parallelism
    34 import pypar   # The Python-MPI interface
    35 from anuga_parallel.pmesh_divide  import pmesh_divide_metis
    36 from anuga_parallel.build_submesh import build_submesh
    37 from anuga_parallel.build_local   import build_local_mesh
    38 from anuga_parallel.build_commun  import send_submesh, rec_submesh, extract_hostmesh
    39 from anuga_parallel.parallel_shallow_water import Parallel_Domain
    40 
    4134from anuga_parallel.parallel_api import *
    4235
     
    8982                        verbose=True)
    9083
    91     #------------------------------------------------------------------------------
     84    #-------------------------------------------------------------------------
    9285    # Setup boundary conditions
    93     #------------------------------------------------------------------------------
     86    #-------------------------------------------------------------------------
    9487
    9588   
     
    108101
    109102
    110 
    111103# Set those boundaries that can't be pickled here using boundary_map.
    112104W = Time_boundary(domain = domain,
    113105                  f=lambda t: [project.initial_sealevel + (60<t<480)*6, 0, 0])
    114106
    115 boundary_map = domain.boundary_map
    116 boundary_map['ocean'] = W
    117 domain.set_boundary(boundary_map)
     107domain.modify_boundary({'ocean': W})
    118108
    119109
Note: See TracChangeset for help on using the changeset viewer.