Changeset 9174


Ignore:
Timestamp:
Jun 17, 2014, 9:46:06 PM (11 years ago)
Author:
steve
Message:

Commiting all the validation tests

Location:
trunk/anuga_core
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/run_auto_validation_tests.py

    r9149 r9174  
    11import os
     2
    23
    34
  • trunk/anuga_core/source/anuga/shallow_water/boundaries.py

    r8920 r9174  
    346346        q[1] = q[2] = 0.0
    347347        return q
     348
     349class Characteristic_stage_boundary(Boundary):
     350    """Sets the stage via a function and the momentum is determined
     351    via assumption of simple incoming wave (uses Riemann invariant)
     352
     353
     354    Example:
     355
     356    def waveform(t):
     357        return sea_level + normalized_amplitude/cosh(t-25)**2
     358
     359    Bcs = Characteristic_stage_boundary(domain, waveform)
     360
     361    Underlying domain must be specified when boundary is instantiated
     362    """
     363
     364    def __init__(self, domain=None, function=None, default_stage = 0.0):
     365        """ Instantiate a
     366            Characteristic_stage_boundary.
     367            domain is the domain containing the boundary
     368            function is the function to apply the wave
     369            default_stage is the assumed stage pre the application of wave
     370        """
     371
     372        Boundary.__init__(self)
     373
     374        if domain is None:
     375            msg = 'Domain must be specified for this type boundary'
     376            raise Exception, msg
     377
     378        if function is None:
     379            msg = 'Function must be specified for this type boundary'
     380            raise Exception, msg
     381
     382        self.domain = domain
     383        self.function = function
     384        self.default_stage = default_stage
     385
     386        self.Elev  = domain.quantitis['elevation']
     387        self.Stage = domain.quantitis['stage']
     388        self.Height = domain.quantitis['height']
     389
     390    def __repr__(self):
     391        """ Return a representation of this instance. """
     392        msg = 'Characteristic_stage_boundary '
     393        msg += '(%s) ' % self.domain
     394        msg += '(%s) ' % self.default_stage
     395        return msg
     396
     397
     398    def evaluate(self, vol_id, edge_id):
     399        """Calculate reflections (reverse outward momentum).
     400
     401        vol_id   
     402        edge_id 
     403        """
     404       
     405        t = self.domain.get_time()
     406
     407
     408        value = self.function(t)
     409        try:
     410            stage = float(value)
     411        except:
     412            stage = float(value[0])
     413
     414
     415
     416        q = self.conserved_quantities
     417        #q[0] = self.stage[vol_id, edge_id]
     418        q[0] = stage
     419        q[1] = self.xmom[vol_id, edge_id]
     420        q[2] = self.ymom[vol_id, edge_id]
     421
     422        normal = self.normals[vol_id, 2*edge_id:2*edge_id+2]
     423
     424        r = rotate(q, normal, direction = 1)
     425        r[1] = -r[1]
     426        q = rotate(r, normal, direction = -1)
     427
     428
     429        return q
     430
     431
     432
     433
     434
     435
     436    def evaluate_segment(self, domain, segment_edges):
     437        """Apply reflective BC on the boundary edges defined by
     438        segment_edges
     439        """
     440
     441        if segment_edges is None:
     442            return
     443        if domain is None:
     444            return
     445
     446        t = self.domain.get_time()
     447
     448
     449        value = self.function(t)
     450        try:
     451            stage = float(value)
     452        except:
     453            stage = float(value[0])
     454                       
     455
     456        ids = segment_edges
     457        vol_ids  = domain.boundary_cells[ids]
     458        edge_ids = domain.boundary_edges[ids]
     459
     460        Stage = domain.quantities['stage']
     461        Elev  = domain.quantities['elevation']
     462        Height= domain.quantities['height']
     463        Xmom  = domain.quantities['xmomentum']
     464        Ymom  = domain.quantities['ymomentum']
     465        Xvel  = domain.quantities['xvelocity']
     466        Yvel  = domain.quantities['yvelocity']
     467
     468        Normals = domain.normals
     469
     470        #print vol_ids
     471        #print edge_ids
     472        #Normals.reshape((4,3,2))
     473        #print Normals.shape
     474        #print Normals[vol_ids, 2*edge_ids]
     475        #print Normals[vol_ids, 2*edge_ids+1]
     476       
     477        n1  = Normals[vol_ids,2*edge_ids]
     478        n2  = Normals[vol_ids,2*edge_ids+1]
     479
     480        # Transfer these quantities to the boundary array
     481        Stage.boundary_values[ids]  = Stage.edge_values[vol_ids,edge_ids]
     482        Elev.boundary_values[ids]   = Elev.edge_values[vol_ids,edge_ids]
     483        Height.boundary_values[ids] = Height.edge_values[vol_ids,edge_ids]
     484
     485        # Rotate and negate Momemtum
     486        q1 = Xmom.edge_values[vol_ids,edge_ids]
     487        q2 = Ymom.edge_values[vol_ids,edge_ids]
     488
     489        r1 = -q1*n1 - q2*n2
     490        r2 = -q1*n2 + q2*n1
     491
     492        Xmom.boundary_values[ids] = n1*r1 - n2*r2
     493        Ymom.boundary_values[ids] = n2*r1 + n1*r2
     494
     495        # Rotate and negate Velocity
     496        q1 = Xvel.edge_values[vol_ids,edge_ids]
     497        q2 = Yvel.edge_values[vol_ids,edge_ids]
     498
     499        r1 = q1*n1 + q2*n2
     500        r2 = q1*n2 - q2*n1
     501
     502        Xvel.boundary_values[ids] = n1*r1 - n2*r2
     503        Yvel.boundary_values[ids] = n2*r1 + n1*r2
     504
     505       
     506
    348507
    349508class Dirichlet_discharge_boundary(Boundary):
  • trunk/anuga_core/source/anuga/shallow_water/test_swb2_domain.py

    r8582 r9174  
    3636
    3737        domain=Domain(points,vertices,boundary)    # Create Domain
    38         domain.set_flow_algorithm('tsunami')
    39 
     38        domain.set_flow_algorithm('DE0')
     39       
    4040        domain.set_name('runup_sinusoid_v2')                         # Output to file runup.sww
    4141        domain.set_datadir('.')                          # Use current folder
     
    9191
    9292
     93        print vv.max()
    9394
    9495        assert num.all(vv<1.0e-02)
  • trunk/anuga_core/source/anuga_parallel/distribute_mesh.py

    r9126 r9174  
    645645
    646646
    647     #print ghosttri
    648 
    649     # FIXME SR: For larger layers need to pass through the correct
    650     # boundary tag!
    651 
    652 #    for t in ghosttri:
    653 #        ghost_list.append(t[0])
    654 #
    655 #
    656 #
    657 #    for t in ghosttri:
    658 #
    659 #        n = mesh.neighbours[t[0], 0]
    660 #        if not is_in_processor(ghost_list, tlower, tupper, n):
    661 #            if boundary.has_key( (t[0], 0) ):
    662 #                subboundary[t[0], 0] = boundary[t[0],0]
    663 #            else:
    664 #                subboundary[t[0], 0] = 'ghost'
    665 #
    666 #
    667 #        n = mesh.neighbours[t[0], 1]
    668 #        if not is_in_processor(ghost_list, tlower, tupper, n):
    669 #            if boundary.has_key( (t[0], 1) ):
    670 #                subboundary[t[0], 1] = boundary[t[0],1]
    671 #            else:
    672 #                subboundary[t[0], 1] = 'ghost'
    673 #
    674 #
    675 #        n = mesh.neighbours[t[0], 2]
    676 #        if not is_in_processor(ghost_list, tlower, tupper, n):
    677 #            if boundary.has_key( (t[0], 2) ):
    678 #                subboundary[t[0], 2] = boundary[t[0],2]
    679 #            else:
    680 #                subboundary[t[0], 2] = 'ghost'
    681 #
    682 
    683 
    684 
    685647    new_ghost_list = ghosttri[:,0]
    686648
     
    707669    values1 = ['ghost']*n1
    708670
    709     # 1 edge boundary
     671    # 2 edge boundary
    710672    nghb2 = mesh.neighbours[new_ghost_list,2]
    711673    gl2 = num.extract(num.logical_or(nghb2 < tlower, nghb2 >= tupper), new_ghost_list)
     
    12781240
    12791241
     1242
     1243    tri_l2g  = extract_l2g_map(tri_map)
     1244    node_l2g = extract_l2g_map(node_map)
     1245     
    12801246    return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \
    1281            full_send, tri_map, node_map, ghost_layer_width
     1247           full_send, tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width
    12821248
    12831249
     
    16151581
    16161582    [GAnodes, GAtriangles, boundary, quantities, \
    1617      ghost_rec, full_send, tri_map, node_map, ghost_layer_width] = \
    1618               build_local_mesh(submesh_cell, lower_t, upper_t, \
    1619                                numproc)
     1583     ghost_rec, full_send, \
     1584     tri_map, node_map, tri_l2g, node_l2g, \
     1585     ghost_layer_width] = \
     1586     build_local_mesh(submesh_cell, lower_t, upper_t, numproc)
    16201587   
    16211588    return GAnodes, GAtriangles, boundary, quantities,\
    16221589           ghost_rec, full_send,\
    16231590           number_of_full_nodes, number_of_full_triangles, tri_map, node_map,\
    1624            ghost_layer_width
    1625 
    1626 
    1627 
    1628 
    1629 
    1630 
    1631 
    1632 
    1633 
     1591           tri_l2g, node_l2g, ghost_layer_width
    16341592
    16351593
     
    16511609#
    16521610#########################################################
    1653 def extract_submesh(submesh, triangles_per_proc, p=0):
     1611def extract_submesh(submesh, triangles_per_proc, p2s_map=None, p=0):
    16541612
    16551613   
     
    16791637    numprocs = len(triangles_per_proc)
    16801638    points, vertices, boundary, quantities, ghost_recv_dict, \
    1681             full_send_dict, tri_map, node_map, ghost_layer_width = \
     1639            full_send_dict, tri_map, node_map, tri_l2g, node_l2g, \
     1640            ghost_layer_width = \
    16821641            build_local_mesh(submesh_cell, lower_t, upper_t, numprocs)
    16831642
     1643    if p2s_map is None:
     1644        pass
     1645    else:
     1646        tri_l2g = p2s_map[tri_l2g]
    16841647
    16851648    return  points, vertices, boundary, quantities, ghost_recv_dict, \
    1686            full_send_dict, tri_map, node_map, ghost_layer_width
     1649           full_send_dict, tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width
    16871650           
    16881651
    16891652
    1690 
    1691 
     1653def extract_l2g_map(map):
     1654    # Extract l2g data  from corresponding map
     1655    # Maps
     1656
     1657    import numpy as num
     1658
     1659    b = num.arange(len(map))
     1660
     1661    l_ids = num.extract(map>-1,map)
     1662    g_ids = num.extract(map>-1,b)
     1663
     1664
     1665#    print len(g_ids)
     1666#    print len(l_ids)
     1667#    print l_ids
     1668#    print g_ids
     1669
     1670    l2g = num.zeros_like(g_ids)
     1671    l2g[l_ids] = g_ids
     1672
     1673    return l2g
     1674
     1675
     1676
     1677
     1678
  • trunk/anuga_core/source/anuga_parallel/parallel_api.py

    r9126 r9174  
    3737
    3838
    39 
    4039def distribute(domain, verbose=False, debug=False, parameters = None):
     40    """ Distribute the domain to all processes
     41
     42    parameters allows user to change size of ghost layer
     43    """
     44
     45    if not pypar_available or numprocs == 1 : return domain # Bypass
     46
     47       
     48    if myid == 0:
     49        from sequential_distribute import Sequential_distribute
     50        partition = Sequential_distribute(domain, verbose, debug, parameters)
     51
     52        partition.distribute(numprocs)
     53
     54        kwargs, points, vertices, boundary, quantities, boundary_map, \
     55                domain_name, domain_dir, domain_store, domain_store_centroids, \
     56                domain_minimum_storable_height, domain_minimum_allowed_height, \
     57                domain_flow_algorithm, georef = partition.extract_submesh(0)
     58       
     59        for p in range(1, numprocs):
     60
     61            tostore = partition.extract_submesh(p)
     62
     63            send(tostore,p)
     64
     65    else:
     66
     67        kwargs, points, vertices, boundary, quantities, boundary_map, \
     68                       domain_name, domain_dir, domain_store, domain_store_centroids, \
     69                       domain_minimum_storable_height, domain_minimum_allowed_height, \
     70                       domain_flow_algorithm, georef = receive(0)
     71
     72    #---------------------------------------------------------------------------
     73    # Now Create parallel domain
     74    #---------------------------------------------------------------------------
     75    parallel_domain = Parallel_domain(points, vertices, boundary, **kwargs)
     76
     77
     78    #------------------------------------------------------------------------
     79    # Copy in quantity data
     80    #------------------------------------------------------------------------
     81    for q in quantities:
     82        parallel_domain.set_quantity(q, quantities[q])
     83
     84
     85    #------------------------------------------------------------------------
     86    # Transfer boundary conditions to each subdomain
     87    #------------------------------------------------------------------------
     88    boundary_map['ghost'] = None  # Add binding to ghost boundary
     89    parallel_domain.set_boundary(boundary_map)
     90
     91
     92    #------------------------------------------------------------------------
     93    # Transfer other attributes to each subdomain
     94    #------------------------------------------------------------------------
     95    parallel_domain.set_name(domain_name)
     96    parallel_domain.set_datadir(domain_dir)
     97    parallel_domain.set_store(domain_store)
     98    parallel_domain.set_store_centroids(domain_store_centroids)
     99    parallel_domain.set_minimum_storable_height(domain_minimum_storable_height)
     100    parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height)
     101    parallel_domain.set_flow_algorithm(domain_flow_algorithm)
     102    parallel_domain.geo_reference = georef
     103
     104
     105    return parallel_domain
     106
     107
     108       
     109       
     110
     111
     112
     113def old_distribute(domain, verbose=False, debug=False, parameters = None):
    41114    """ Distribute the domain to all processes
    42115
     
    125198                ghost_recv_dict, full_send_dict,\
    126199                number_of_full_nodes, number_of_full_triangles,\
    127                 s2p_map, p2s_map, tri_map, node_map, ghost_layer_width =\
     200                s2p_map, p2s_map, tri_map, node_map, tri_l2g, node_l2g, \
     201                ghost_layer_width =\
    128202                distribute_mesh(domain, verbose=verbose, debug=debug, parameters=parameters)
    129203           
    130204        # Extract l2g maps
    131         tri_l2g  = extract_l2g_map(tri_map)
    132         node_l2g = extract_l2g_map(node_map)
    133 
     205        #tri_l2g  = extract_l2g_map(tri_map)
     206        #node_l2g = extract_l2g_map(node_map)
     207        #tri_l2g = p2s_map[tri_l2g]
     208       
    134209        if debug:
    135210            print 'P%d' %myid
     
    183258                ghost_recv_dict, full_send_dict,\
    184259                number_of_full_nodes, number_of_full_triangles, \
    185                 tri_map, node_map, ghost_layer_width =\
     260                tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width =\
    186261                rec_submesh(0, verbose)
    187262
     
    189264
    190265        # Extract l2g maps
    191         tri_l2g  = extract_l2g_map(tri_map)
    192         node_l2g = extract_l2g_map(node_map)
    193        
    194         # Recieve serial to parallel (s2p) and parallel to serial (p2s) triangle mapping
     266        #tri_l2g  = extract_l2g_map(tri_map)
     267        #node_l2g = extract_l2g_map(node_map)
     268        #tri_l2g = p2s_map[tri_l2g]
     269       
     270        # Receive serial to parallel (s2p) and parallel to serial (p2s) triangle mapping
    195271        if send_s2p :
    196272            s2p_map_flat = receive(0)
     
    264340
    265341def distribute_mesh(domain, verbose=False, debug=False, parameters=None):
    266 
     342    """ Distribute andsend the mesh info to all the processors.
     343    Should only be run from processor 0 and will send info to the other
     344    processors.
     345    There should be a corresponding  rec_submesh called from all the other
     346    processors
     347    """
    267348
    268349    if debug:
     
    303384    if verbose: print 'Distribute submeshes'       
    304385    for p in range(1, numprocs):
    305         send_submesh(submesh, triangles_per_proc, p, verbose)
     386        send_submesh(submesh, triangles_per_proc, p2s_map, p, verbose)
    306387
    307388    # Build the local mesh for processor 0
    308389    points, vertices, boundary, quantities, \
    309             ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\
    310               extract_submesh(submesh, triangles_per_proc,0)
    311 
     390            ghost_recv_dict, full_send_dict, \
     391            tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width =\
     392              extract_submesh(submesh, triangles_per_proc, p2s_map, 0)
     393
     394
     395             
    312396    # Keep track of the number full nodes and triangles.
    313397    # This is useful later if one needs access to a ghost-free domain
     
    344428           ghost_recv_dict, full_send_dict,\
    345429           number_of_full_nodes, number_of_full_triangles, \
    346            s2p_map, p2s_map, tri_map, node_map, ghost_layer_width
    347    
    348 
    349 
    350 def extract_l2g_map(map):
    351     # Extract l2g data  from corresponding map
    352     # Maps
    353 
    354     import numpy as num
    355    
    356     # FIXME: this is where we loss the original order of
    357     # sequential domain
    358     b = num.arange(len(map))
    359 
    360     l_ids = num.extract(map>-1,map)
    361     g_ids = num.extract(map>-1,b)
    362 
    363 #    print len(g_ids)
    364 #    print len(l_ids)
    365 #    print l_ids
    366 
    367     l2g = num.zeros_like(g_ids)
    368     l2g[l_ids] = g_ids
    369 
    370     return l2g
    371 
     430           s2p_map, p2s_map, tri_map, node_map, tri_l2g, node_l2g, \
     431           ghost_layer_width
     432   
     433
     434
     435## def extract_l2g_map(map):
     436##     # Extract l2g data  from corresponding map
     437##     # Maps
     438
     439##     import numpy as num
     440   
     441##     # FIXME: this is where we loss the original order of
     442##     # sequential domain
     443##     b = num.arange(len(map))
     444
     445##     l_ids = num.extract(map>-1,map)
     446##     g_ids = num.extract(map>-1,b)
     447
     448## #    print len(g_ids)
     449## #    print len(l_ids)
     450## #    print l_ids
     451
     452##     l2g = num.zeros_like(g_ids)
     453##     l2g[l_ids] = g_ids
     454
     455##     return l2g
     456
  • trunk/anuga_core/source/anuga_parallel/sequential_distribute.py

    r8680 r9174  
    1818
    1919
    20 def sequential_distribute_dump(domain, numprocs=1, verbose=False, debug=False, parameters = None):
    21     """ Distribute the domain, create parallel domain and pickle result
    22     """
    23 
    24 
    25     if debug:
    26         verbose = True
    27 
    28 
    29 
    30     # FIXME: Dummy assignment (until boundaries are refactored to
    31     # be independent of domains until they are applied)
    32     bdmap = {}
    33     for tag in domain.get_boundary_tags():
    34         bdmap[tag] = None
    35 
    36     domain.set_boundary(bdmap)
    37 
    38 
    39     domain_name = domain.get_name()
    40     domain_dir = domain.get_datadir()
    41     domain_store = domain.get_store()
    42     domain_minimum_storable_height = domain.minimum_storable_height
    43     domain_flow_algorithm = domain.get_flow_algorithm()
    44     domain_minimum_allowed_height = domain.get_minimum_allowed_height()
    45     georef = domain.geo_reference
    46     number_of_global_triangles = domain.number_of_triangles
    47     number_of_global_nodes = domain.number_of_nodes
    48     boundary_map = domain.boundary_map
    49 
    50 
    51     #sequential_distribute_mesh(domain, numprocs, verbose=verbose, debug=debug, parameters=parameters)
    52 
    53 
    54     # Subdivide the mesh
    55     if verbose: print 'sequential_distribute: Subdivide mesh'
    56     new_nodes, new_triangles, new_boundary, triangles_per_proc, quantities, \
    57            s2p_map, p2s_map = \
    58            pmesh_divide_metis_with_map(domain, numprocs)
    59 
    60     #PETE: s2p_map (maps serial domain triangles to parallel domain triangles)
    61     #      sp2_map (maps parallel domain triangles to domain triangles)
    62 
    63 
    64 
    65     # Build the mesh that should be assigned to each processor,
    66     # this includes ghost nodes and the communication pattern
    67     if verbose: print 'sequential_distribute: Build submeshes'
    68     submesh = build_submesh(new_nodes, new_triangles, new_boundary, quantities, triangles_per_proc, parameters)
    69 
    70     if debug:
    71         for p in range(numprocs):
    72             N = len(submesh['ghost_nodes'][p])
    73             M = len(submesh['ghost_triangles'][p])
    74             print 'There are %d ghost nodes and %d ghost triangles on proc %d'\
    75                   %(N, M, p)
    76 
    77     #if debug:
    78     #    from pprint import pprint
    79     #    pprint(submesh)
    80 
    81 
    82     # extract data to create parallel domain
    83     if verbose: print 'sequential_distribute: Distribute submeshes'
    84     for p in range(0, numprocs):
    85 
    86         # Build the local mesh for processor 0
     20class Sequential_distribute(object):
     21
     22    def __init__(self, domain, verbose=False, debug=False, parameters=None):
     23
     24        if debug:
     25            verbose = True
     26           
     27        self.domain = domain
     28        self.verbose = verbose
     29        self.debug = debug
     30        self.parameters = parameters
     31
     32
     33    def distribute(self, numprocs=1):
     34
     35        self.numprocs = numprocs
     36       
     37        domain = self.domain
     38        verbose = self.verbose
     39        debug = self.debug
     40        parameters = self.parameters
     41
     42        # FIXME: Dummy assignment (until boundaries are refactored to
     43        # be independent of domains until they are applied)
     44        bdmap = {}
     45        for tag in domain.get_boundary_tags():
     46            bdmap[tag] = None
     47
     48        domain.set_boundary(bdmap)
     49
     50
     51        self.domain_name = domain.get_name()
     52        self.domain_dir = domain.get_datadir()
     53        self.domain_store = domain.get_store()
     54        self.domain_store_centroids = domain.get_store_centroids()
     55        self.domain_minimum_storable_height = domain.minimum_storable_height
     56        self.domain_flow_algorithm = domain.get_flow_algorithm()
     57        self.domain_minimum_allowed_height = domain.get_minimum_allowed_height()
     58        self.domain_georef = domain.geo_reference
     59        self.number_of_global_triangles = domain.number_of_triangles
     60        self.number_of_global_nodes = domain.number_of_nodes
     61        self.boundary_map = domain.boundary_map
     62
     63
     64        # Subdivide the mesh
     65        if verbose: print 'sequential_distribute: Subdivide mesh'
     66
     67        new_nodes, new_triangles, new_boundary, triangles_per_proc, quantities, \
     68               s2p_map, p2s_map = \
     69               pmesh_divide_metis_with_map(domain, numprocs)
     70
     71
     72        # Build the mesh that should be assigned to each processor,
     73        # this includes ghost nodes and the communication pattern
     74        if verbose: print 'sequential_distribute: Build submeshes'
     75        if verbose: print parameters
     76
     77        submesh = build_submesh(new_nodes, new_triangles, new_boundary, \
     78                                quantities, triangles_per_proc, parameters=parameters)
     79
     80        if verbose:
     81            for p in range(numprocs):
     82                N = len(submesh['ghost_nodes'][p])
     83                M = len(submesh['ghost_triangles'][p])
     84                print 'There are %d ghost nodes and %d ghost triangles on proc %d'\
     85                      %(N, M, p)
     86
     87
     88        self.submesh = submesh
     89        self.triangles_per_proc = triangles_per_proc
     90        self.p2s_map =  p2s_map
     91
     92
     93    def extract_submesh(self, p=0):
     94        """Build the local mesh for processor p
     95        """
     96
     97        submesh = self.submesh
     98        triangles_per_proc = self.triangles_per_proc
     99        p2s_map = self.p2s_map
     100        verbose = self.verbose
     101        debug = self.debug
     102
     103        assert p>=0
     104        assert p<self.numprocs
     105       
     106       
    87107        points, vertices, boundary, quantities, \
    88             ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\
    89               extract_submesh(submesh, triangles_per_proc, p)
    90 
    91 
    92 #        from pprint import pprint
    93 #        print '='*80
    94 #        print p
    95 #        print '='*80
    96 #        pprint(tri_map)
    97 #        print len(tri_map)
    98 
    99         # Keep track of the number full nodes and triangles.
    100         # This is useful later if one needs access to a ghost-free domain
    101         # Here, we do it for process 0. The others are done in rec_submesh.
     108            ghost_recv_dict, full_send_dict, \
     109            tri_map, node_map, tri_l2g, node_l2g, ghost_layer_width =\
     110              extract_submesh(submesh, triangles_per_proc, p2s_map, p)
     111             
     112
    102113        number_of_full_nodes = len(submesh['full_nodes'][p])
    103114        number_of_full_triangles = len(submesh['full_triangles'][p])
    104115
    105         # Extract l2g maps
    106         tri_l2g  = extract_l2g_map(tri_map)
    107         node_l2g = extract_l2g_map(node_map)
    108 
    109 
     116
     117        if debug:
     118            import pprint
     119            print  50*"="
     120            print 'NODE_L2G'
     121            pprint.pprint(node_l2g)
     122       
     123            pprint.pprint(node_l2g[vertices[:,0]])
     124       
     125            print 'VERTICES'
     126            pprint.pprint(vertices[:,0])
     127            pprint.pprint(new_triangles[tri_l2g,0])
     128       
     129            assert num.allclose(node_l2g[vertices[:,0]], new_triangles[tri_l2g,0])       
     130            assert num.allclose(node_l2g[vertices[:,1]], new_triangles[tri_l2g,1])
     131            assert num.allclose(node_l2g[vertices[:,2]], new_triangles[tri_l2g,2])
     132       
     133
     134            print 'POINTS'
     135            pprint.pprint(points)
     136       
     137            assert num.allclose(points[:,0], new_nodes[node_l2g,0])
     138            assert num.allclose(points[:,1], new_nodes[node_l2g,1])
     139
     140
     141            print 'TRI'
     142            pprint.pprint(tri_l2g)
     143            pprint.pprint(p2s_map[tri_l2g])
     144       
     145
     146            assert num.allclose(original_triangles[tri_l2orig,0],node_l2g[vertices[:,0]])
     147            assert num.allclose(original_triangles[tri_l2orig,1],node_l2g[vertices[:,1]])
     148            assert num.allclose(original_triangles[tri_l2orig,2],node_l2g[vertices[:,2]])
     149
     150            print 'NODES'
     151            pprint.pprint(node_map)
     152            pprint.pprint(node_l2g)     
     153       
     154        #tri_l2orig = p2s_map[tri_l2g]       
     155       
    110156        s2p_map = None
    111157        p2s_map = None
     
    118164            print 'sequential_distribute: P%g, no_full_nodes = %g, no_full_triangles = %g' % (p, number_of_full_nodes, number_of_full_triangles)
    119165
    120 
    121         #args = [points, vertices, boundary]
    122166
    123167        kwargs = {'full_send_dict': full_send_dict,
     
    125169                'number_of_full_nodes': number_of_full_nodes,
    126170                'number_of_full_triangles': number_of_full_triangles,
    127                 'geo_reference': georef,
    128                 'number_of_global_triangles':  number_of_global_triangles,
    129                 'number_of_global_nodes':  number_of_global_nodes,
     171                'geo_reference': self.domain_georef,
     172                'number_of_global_triangles':  self.number_of_global_triangles,
     173                'number_of_global_nodes':  self.number_of_global_nodes,
    130174                'processor':  p,
    131                 'numproc':  numprocs,
     175                'numproc':  self.numprocs,
    132176                's2p_map':  s2p_map,
    133177                'p2s_map':  p2s_map, ## jj added this
     
    136180                'ghost_layer_width':  ghost_layer_width}
    137181
    138         #-----------------------------------------------------------------------
    139         # Now let's store the data for a  parallel_domain via cPickle
    140         #-----------------------------------------------------------------------
    141 
    142         #Looks like we reduce storage by a factor of 4 by just
    143         # storing the data to create the parallel_domain instead of pickling
    144         # a created domain
     182
     183        boundary_map = self.boundary_map
     184        domain_name = self.domain_name
     185        domain_dir = self.domain_dir
     186        domain_store = self.domain_store
     187        domain_store_centroids = self.domain_store_centroids
     188        domain_minimum_storable_height = self.domain_minimum_storable_height
     189        domain_minimum_allowed_height = self.domain_minimum_allowed_height
     190        domain_flow_algorithm = self.domain_flow_algorithm
     191        domain_georef = self.domain_georef
     192           
     193        tostore = (kwargs, points, vertices, boundary, quantities, \
     194                   boundary_map, \
     195                   domain_name, domain_dir, domain_store, domain_store_centroids, \
     196                   domain_minimum_storable_height, \
     197                   domain_minimum_allowed_height, domain_flow_algorithm, \
     198                   domain_georef)
     199
     200
     201        return tostore
     202
     203
     204
     205                       
     206
     207   
     208def sequential_distribute_dump(domain, numprocs=1, verbose=False, debug=False, parameters = None):
     209    """ Distribute the domain, create parallel domain and pickle result
     210    """
     211
     212
     213    partition = Sequential_distribute(domain, verbose, debug, parameters)
     214
     215    partition.distribute(numprocs)
     216
     217   
     218    for p in range(0, numprocs):
     219
     220        tostore = partition.extract_submesh(p)
     221
    145222        import cPickle
    146         pickle_name = domain_name + '_P%g_%g.pickle'% (numprocs,p)
     223        pickle_name = partition.domain_name + '_P%g_%g.pickle'% (numprocs,p)
    147224        f = file(pickle_name, 'wb')
    148         tostore = (kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \
    149                    domain_minimum_allowed_height, domain_flow_algorithm, georef)
    150225        cPickle.dump( tostore, f, protocol=cPickle.HIGHEST_PROTOCOL)
    151226
     
    165240    pickle_name = filename+'_P%g_%g.pickle'% (numprocs,myid)
    166241    f = file(pickle_name, 'rb')
    167     kwargs, points, vertices, boundary, quantities, boundary_map, domain_name, domain_dir, domain_store, domain_minimum_storable_height, \
    168                    domain_minimum_allowed_height, domain_flow_algorithm, georef = cPickle.load(f)
     242
     243    kwargs, points, vertices, boundary, quantities, boundary_map, \
     244                   domain_name, domain_dir, domain_store, domain_store_centroids, \
     245                   domain_minimum_storable_height, domain_minimum_allowed_height, \
     246                   domain_flow_algorithm, georef = cPickle.load(f)
    169247    f.close()
    170248
     
    194272    parallel_domain.set_name(domain_name)
    195273    parallel_domain.set_datadir(domain_dir)
     274    parallel_domain.set_flow_algorithm(domain_flow_algorithm)
    196275    parallel_domain.set_store(domain_store)
     276    parallel_domain.set_store_centroids(domain_store_centroids)
    197277    parallel_domain.set_minimum_storable_height(domain_minimum_storable_height)
    198278    parallel_domain.set_minimum_allowed_height(domain_minimum_allowed_height)
    199     parallel_domain.set_flow_algorithm(domain_flow_algorithm)
    200279    parallel_domain.geo_reference = georef
    201280
     
    203282    return parallel_domain
    204283
    205 def extract_l2g_map(map):
    206     # Extract l2g data  from corresponding map
    207     # Maps
    208 
    209     import numpy as num
    210 
    211     b = num.arange(len(map))
    212 
    213     l_ids = num.extract(map>-1,map)
    214     g_ids = num.extract(map>-1,b)
    215 
    216 
    217 #    print len(g_ids)
    218 #    print len(l_ids)
    219 #    print l_ids
    220 #    print g_ids
    221 
    222     l2g = num.zeros_like(g_ids)
    223     l2g[l_ids] = g_ids
    224 
    225     return l2g
    226 
    227 
    228 
    229 
    230 
     284
     285
     286
     287
     288
     289
  • trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py

    r8608 r9174  
    15021502        # Now test the extract_submesh for the 3 processors
    15031503
    1504         submesh_cell_0 = extract_submesh(submesh,triangles_per_proc,0)
    1505         submesh_cell_1 = extract_submesh(submesh,triangles_per_proc,1)
    1506         submesh_cell_2 = extract_submesh(submesh,triangles_per_proc,2)
     1504        submesh_cell_0 = extract_submesh(submesh,triangles_per_proc,p=0)
     1505        submesh_cell_1 = extract_submesh(submesh,triangles_per_proc,p=1)
     1506        submesh_cell_2 = extract_submesh(submesh,triangles_per_proc,p=2)
    15071507
    15081508
  • trunk/anuga_core/source/anuga_parallel/test_parallel_distribute_mesh.py

    r8605 r9174  
    196196        #----------------------------------------------------------------------------------
    197197        points, vertices, boundary, quantities, \
    198                 ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\
     198                ghost_recv_dict, full_send_dict, tri_map, node_map, tri_l2g, node_l2g, \
     199                ghost_layer_width =\
    199200        extract_submesh(submesh, triangles_per_proc)
    200201
     
    226227        points, vertices, boundary, quantities, \
    227228                ghost_recv_dict, full_send_dict, \
    228                 no_full_nodes, no_full_trigs, tri_map, node_map, ghost_layer_width  = \
     229                no_full_nodes, no_full_trigs, tri_map, node_map, tri_l2g, node_l2g, \
     230                ghost_layer_width  = \
    229231                rec_submesh(0, verbose=False)   
    230232
  • trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py

    r9122 r9174  
    3838from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect
    3939
    40 from parallel_operator_factory import Inlet_operator, Boyd_box_operator
     40#from parallel_operator_factory import Inlet_operator, Boyd_box_operator
     41from anuga import Inlet_operator, Boyd_box_operator
    4142
    4243import random
     
    4849This test exercises the parallel culvert and checks values
    4950"""
     51
    5052verbose = False
    5153nprocs = 3
     
    7274    for i in range(N):
    7375
    74        # Sloping Embankment Across Channel
     76        # Sloping Embankment Across Channel
    7577        if 5.0 < x[i] < 10.1:
    7678            # Cut Out Segment for Culvert face               
    7779            if  1.0+(x[i]-5.0)/5.0 <  y[i]  < 4.0 - (x[i]-5.0)/5.0:
    78                z[i]=z[i]
     80                z[i]=z[i]
    7981            else:
    80                z[i] +=  0.5*(x[i] -5.0)    # Sloping Segment  U/S Face
     82                z[i] +=  0.5*(x[i] -5.0)    # Sloping Segment  U/S Face
    8183        if 10.0 < x[i] < 12.1:
    82            z[i] +=  2.5                    # Flat Crest of Embankment
     84            z[i] +=  2.5                    # Flat Crest of Embankment
    8385        if 12.0 < x[i] < 14.5:
    8486            # Cut Out Segment for Culvert face               
    8587            if  2.0-(x[i]-12.0)/2.5 <  y[i]  < 3.0 + (x[i]-12.0)/2.5:
    86                z[i]=z[i]
     88                z[i]=z[i]
    8789            else:
    88                z[i] +=  2.5-1.0*(x[i] -12.0) # Sloping D/S Face
     90                z[i] +=  2.5-1.0*(x[i] -12.0) # Sloping D/S Face
    8991                   
    90        
    9192    return z
    9293
     
    191192    if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
    192193
    193 #    if parallel:
    194 #        factory = Parallel_operator_factory(domain, verbose = True)
    195 #
    196 #        inlet0 = factory.inlet_operator_factory(line0, Q0)
    197 #        inlet1 = factory.inlet_operator_factory(line1, Q1)
    198 #       
    199 #        boyd_box0 = factory.boyd_box_operator_factory(end_points=[[9.0, 2.5],[19.0, 2.5]],
    200 #                                          losses=1.5,
    201 #                                          width=1.5,
    202 #                                          apron=5.0,
    203 #                                          use_momentum_jet=True,
    204 #                                          use_velocity_head=False,
    205 #                                          manning=0.013,
    206 #                                          verbose=False)
    207 #
    208 #    else:
    209 #        inlet0 = Inlet_operator(domain, line0, Q0)
    210 #        inlet1 = Inlet_operator(domain, line1, Q1)
    211 #
    212 #        # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
    213 #        boyd_box0 = Boyd_box_operator(domain,
    214 #                          end_points=[[9.0, 2.5],[19.0, 2.5]],
    215 #                          losses=1.5,
    216 #                          width=1.5,
    217 #                          apron=5.0,
    218 #                          use_momentum_jet=True,
    219 #                          use_velocity_head=False,
    220 #                          manning=0.013,
    221 #                          verbose=False)
    222    
    223     #######################################################################
    224194
    225195    ##-----------------------------------------------------------------------
     
    276246                if verbose:
    277247                    print 'P%d tri %d, control = %s, actual = %s, Success = %s' %(myid, i, control_data[i], stage.centroid_values[tri_ids[i]], local_success)
     248                assert local_success, 'Ouput P%d tri %d, control = %s, actual = %s, Success = %s' %(myid, i, control_data[i], stage.centroid_values[tri_ids[i]], local_success)
     249
     250
    278251               
    279252               
     
    299272
    300273
    301         assert(success)
     274        #assert(success)
    302275
    303276    return control_data
     
    322295
    323296if __name__=="__main__":
     297
    324298    if numprocs == 1:
    325299        runner = unittest.TextTestRunner()
  • trunk/anuga_core/source/anuga_parallel/test_parallel_inlet_operator.py

    r9108 r9174  
    7272    for i in range(N):
    7373
    74        # Sloping Embankment Across Channel
     74        # Sloping Embankment Across Channel
    7575        if 5.0 < x[i] < 10.1:
    7676            # Cut Out Segment for Culvert face               
    7777            if  1.0+(x[i]-5.0)/5.0 <  y[i]  < 4.0 - (x[i]-5.0)/5.0:
    78                z[i]=z[i]
     78                z[i]=z[i]
    7979            else:
    80                z[i] +=  0.5*(x[i] -5.0)    # Sloping Segment  U/S Face
     80                z[i] +=  0.5*(x[i] -5.0)    # Sloping Segment  U/S Face
    8181        if 10.0 < x[i] < 12.1:
    82            z[i] +=  2.5                    # Flat Crest of Embankment
     82            z[i] +=  2.5                    # Flat Crest of Embankment
    8383        if 12.0 < x[i] < 14.5:
    8484            # Cut Out Segment for Culvert face               
    8585            if  2.0-(x[i]-12.0)/2.5 <  y[i]  < 3.0 + (x[i]-12.0)/2.5:
    86                z[i]=z[i]
     86                z[i]=z[i]
    8787            else:
    88                z[i] +=  2.5-1.0*(x[i] -12.0) # Sloping D/S Face
     88                z[i] +=  2.5-1.0*(x[i] -12.0) # Sloping D/S Face
    8989                   
    9090       
     
    104104    success = True
    105105
    106 ##-----------------------------------------------------------------------
    107 ## Setup domain
    108 ##-----------------------------------------------------------------------
     106    ##-----------------------------------------------------------------------
     107    ## Setup domain
     108    ##-----------------------------------------------------------------------
    109109
    110110    points, vertices, boundary = rectangular_cross(int(length/dx),
     
    117117    domain.set_default_order(2)
    118118
    119 ##-----------------------------------------------------------------------
    120 ## Distribute domain
    121 ##-----------------------------------------------------------------------
     119    ##-----------------------------------------------------------------------
     120    ## Distribute domain
     121    ##-----------------------------------------------------------------------
    122122
    123123    if parallel:
     
    126126   
    127127
    128 ##-----------------------------------------------------------------------
    129 ## Setup boundary conditions
    130 ##-----------------------------------------------------------------------
     128    ##-----------------------------------------------------------------------
     129    ## Setup boundary conditions
     130    ##-----------------------------------------------------------------------
    131131   
    132132    domain.set_quantity('elevation', topography)
     
    141141
    142142
    143 ##-----------------------------------------------------------------------
    144 ## Determine triangle index coinciding with test points
    145 ##-----------------------------------------------------------------------
     143    ##-----------------------------------------------------------------------
     144    ## Determine triangle index coinciding with test points
     145    ##-----------------------------------------------------------------------
    146146
    147147    assert(test_points is not None)
     
    173173    inlet1 = Inlet_operator(domain, line1, Q1, verbose = False)
    174174   
    175     # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
    176    
    177     ## boyd_box0 = Boyd_box_operator(domain,
    178     ##                               end_points=[[9.0, 2.5],[19.0, 2.5]],
    179     ##                               losses=1.5,
    180     ##                               width=5.0,
    181     ##                               apron=5.0,
    182     ##                               use_momentum_jet=True,
    183     ##                               use_velocity_head=False,
    184     ##                               manning=0.013,
    185     ##                               verbose=False)
    186175       
    187176    if inlet0 is not None and verbose: inlet0.print_statistics()
     
    189178    #if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
    190179
    191 #    if parallel:
    192 #        factory = Parallel_operator_factory(domain, verbose = True)
    193 #
    194 #        inlet0 = factory.inlet_operator_factory(line0, Q0)
    195 #        inlet1 = factory.inlet_operator_factory(line1, Q1)
    196 #       
    197 #        boyd_box0 = factory.boyd_box_operator_factory(end_points=[[9.0, 2.5],[19.0, 2.5]],
    198 #                                          losses=1.5,
    199 #                                          width=1.5,
    200 #                                          apron=5.0,
    201 #                                          use_momentum_jet=True,
    202 #                                          use_velocity_head=False,
    203 #                                          manning=0.013,
    204 #                                          verbose=False)
    205 #
    206 #    else:
    207 #        inlet0 = Inlet_operator(domain, line0, Q0)
    208 #        inlet1 = Inlet_operator(domain, line1, Q1)
    209 #
    210 #        # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
    211 #        boyd_box0 = Boyd_box_operator(domain,
    212 #                          end_points=[[9.0, 2.5],[19.0, 2.5]],
    213 #                          losses=1.5,
    214 #                          width=1.5,
    215 #                          apron=5.0,
    216 #                          use_momentum_jet=True,
    217 #                          use_velocity_head=False,
    218 #                          manning=0.013,
    219 #                          verbose=False)
    220    
    221     #######################################################################
    222180
    223181    ##-----------------------------------------------------------------------
     
    246204    success = True
    247205
    248 ##-----------------------------------------------------------------------
    249 ## Assign/Test Control data
    250 ##-----------------------------------------------------------------------
     206    ##-----------------------------------------------------------------------
     207    ## Assign/Test Control data
     208    ##-----------------------------------------------------------------------
    251209
    252210    if not parallel:
  • trunk/anuga_core/source/anuga_parallel/test_sequential_dist_sw_flow.py

    r9127 r9174  
    3333from anuga_parallel.sequential_distribute import sequential_distribute_dump
    3434from anuga_parallel.sequential_distribute import sequential_distribute_load
     35
     36import anuga.utilities.plot_utils as util
    3537
    3638
     
    4547verbose = False
    4648
     49
     50new_parameters = {}
     51new_parameters['ghost_layer_width'] = 2
     52
    4753#---------------------------------
    4854# Setup Functions
     
    6167    if myid == 0:
    6268        domain = rectangular_cross_domain(M, N)
    63         domain.set_name('sequential_dist_runup')                    # Set sww filename
     69        domain.set_name('odomain')                    # Set sww filename
    6470        domain.set_datadir('.')   
    6571        domain.set_quantity('elevation', topography) # Use function for elevation
     
    7480    if myid == 0:
    7581        if verbose: print 'DUMPING PARTITION DATA'
    76         sequential_distribute_dump(domain, numprocs, verbose=verbose)   
     82        sequential_distribute_dump(domain, numprocs, verbose=verbose, parameters=new_parameters)   
    7783
    7884    #--------------------------------------------------------------------------
     
    8288       
    8389        if myid == 0 and verbose : print 'DISTRIBUTING TO PARALLEL DOMAIN'
    84         pdomain = distribute(domain, verbose=verbose)
     90        pdomain = distribute(domain, verbose=verbose, parameters=new_parameters)
     91        pdomain.set_name('pdomain')
    8592       
    8693        if myid == 0 and verbose : print 'LOADING IN PARALLEL DOMAIN'
    87         sdomain = sequential_distribute_load(filename='sequential_dist_runup', verbose = verbose)
    88        
     94        sdomain = sequential_distribute_load(filename='odomain', verbose = verbose)
     95        sdomain.set_name('sdomain')
    8996       
    9097    if myid == 0 and verbose: print 'EVOLVING pdomain'   
     
    94101    setup_and_evolve(sdomain, verbose=verbose)
    95102   
     103    if myid == 0:
     104        if verbose: print 'EVOLVING odomain'   
     105        setup_and_evolve(domain, verbose=verbose)
     106   
     107
     108    if myid == 0:
     109        parameter_file=open('odomain.txt', 'w')
     110        from pprint import pprint
     111        pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     112        parameter_file.close()
     113
     114        parameter_file=open('sdomain.txt', 'w')
     115        from pprint import pprint
     116        pprint(sdomain.get_algorithm_parameters(),parameter_file,indent=4)
     117        parameter_file.close()
     118
     119        parameter_file=open('pdomain.txt', 'w')
     120        from pprint import pprint
     121        pprint(pdomain.get_algorithm_parameters(),parameter_file,indent=4)
     122        parameter_file.close()       
    96123   
    97124    assert num.allclose(pdomain.quantities['stage'].centroid_values, sdomain.quantities['stage'].centroid_values)
     
    103130   
    104131
    105 
    106 
    107 
    108 
     132    #---------------------------------
     133    # Now compare the merged sww files
     134    #---------------------------------
     135    if myid == 0:
     136        if verbose: print 'COMPARING SWW FILES'
     137       
     138        odomain_v = util.get_output('odomain.sww')
     139        odomain_c = util.get_centroids(odomain_v)
     140
     141        pdomain_v = util.get_output('pdomain.sww')
     142        pdomain_c = util.get_centroids(pdomain_v)
     143       
     144        sdomain_v = util.get_output('sdomain.sww')
     145        sdomain_c = util.get_centroids(sdomain_v)
     146
     147        # Test some values against the original ordering
     148       
     149        if verbose:
     150           
     151            order = 0
     152            print 'PDOMAIN CENTROID VALUES'
     153            print num.linalg.norm(odomain_c.x-pdomain_c.x,ord=order)
     154            print num.linalg.norm(odomain_c.y-pdomain_c.y,ord=order)
     155            print num.linalg.norm(odomain_c.stage[-1]-pdomain_c.stage[-1],ord=order)
     156            print num.linalg.norm(odomain_c.xmom[-1]-pdomain_c.xmom[-1],ord=order)
     157            print num.linalg.norm(odomain_c.ymom[-1]-pdomain_c.ymom[-1],ord=order)
     158            print num.linalg.norm(odomain_c.xvel[-1]-pdomain_c.xvel[-1],ord=order)
     159            print num.linalg.norm(odomain_c.yvel[-1]-pdomain_c.yvel[-1],ord=order)       
     160           
     161             
     162            print 'SDOMAIN CENTROID VALUES'       
     163            print num.linalg.norm(odomain_c.x-sdomain_c.x,ord=order)
     164            print num.linalg.norm(odomain_c.y-sdomain_c.y,ord=order)
     165            print num.linalg.norm(odomain_c.stage[-1]-sdomain_c.stage[-1],ord=order)
     166            print num.linalg.norm(odomain_c.xmom[-1]-sdomain_c.xmom[-1],ord=order)
     167            print num.linalg.norm(odomain_c.ymom[-1]-sdomain_c.ymom[-1],ord=order)
     168            print num.linalg.norm(odomain_c.xvel[-1]-sdomain_c.xvel[-1],ord=order)
     169            print num.linalg.norm(odomain_c.yvel[-1]-sdomain_c.yvel[-1],ord=order)
     170           
     171            print 'PDOMAIN VERTEX VALUES'       
     172            print num.linalg.norm(odomain_v.stage[-1]-pdomain_v.stage[-1],ord=order)
     173            print num.linalg.norm(odomain_v.xmom[-1]-pdomain_v.xmom[-1],ord=order)
     174            print num.linalg.norm(odomain_v.ymom[-1]-pdomain_v.ymom[-1],ord=order)
     175            print num.linalg.norm(odomain_v.xvel[-1]-pdomain_v.xvel[-1],ord=order)
     176            print num.linalg.norm(odomain_v.yvel[-1]-pdomain_v.yvel[-1],ord=order)
     177           
     178            print 'SDOMAIN VERTEX VALUES'     
     179            print num.linalg.norm(odomain_v.stage[-1]-sdomain_v.stage[-1],ord=order)
     180            print num.linalg.norm(odomain_v.xmom[-1]-sdomain_v.xmom[-1],ord=order)
     181            print num.linalg.norm(odomain_v.ymom[-1]-sdomain_v.ymom[-1],ord=order)
     182            print num.linalg.norm(odomain_v.xvel[-1]-sdomain_v.xvel[-1],ord=order)
     183            print num.linalg.norm(odomain_v.yvel[-1]-sdomain_v.yvel[-1],ord=order)
     184           
     185           
     186           
     187
     188        assert num.allclose(odomain_c.stage,pdomain_c.stage)
     189        assert num.allclose(odomain_c.xmom,pdomain_c.xmom)
     190        assert num.allclose(odomain_c.ymom,pdomain_c.ymom)
     191        assert num.allclose(odomain_c.xvel,pdomain_c.xvel)
     192        assert num.allclose(odomain_c.yvel,pdomain_c.yvel)
     193       
     194        assert num.allclose(odomain_v.x,pdomain_v.x)
     195        assert num.allclose(odomain_v.y,pdomain_v.y)
     196               
     197        assert num.linalg.norm(odomain_v.x-pdomain_v.x,ord=0) == 0
     198        assert num.linalg.norm(odomain_v.y-pdomain_v.y,ord=0) == 0
     199        assert num.linalg.norm(odomain_v.stage[-1]-pdomain_v.stage[-1],ord=0) < 100
     200        assert num.linalg.norm(odomain_v.xmom[-1]-pdomain_v.xmom[-1],ord=0) < 100
     201        assert num.linalg.norm(odomain_v.ymom[-1]-pdomain_v.ymom[-1],ord=0) < 100
     202        assert num.linalg.norm(odomain_v.xvel[-1]-pdomain_v.xvel[-1],ord=0) < 100
     203        assert num.linalg.norm(odomain_v.yvel[-1]-pdomain_v.yvel[-1],ord=0) < 100     
     204       
     205        assert num.allclose(odomain_c.x,sdomain_c.x)
     206        assert num.allclose(odomain_c.y,sdomain_c.y)
     207        assert num.allclose(odomain_c.stage,sdomain_c.stage)
     208        assert num.allclose(odomain_c.xmom,sdomain_c.xmom)
     209        assert num.allclose(odomain_c.ymom,sdomain_c.ymom)
     210        assert num.allclose(odomain_c.xvel,sdomain_c.xvel)
     211        assert num.allclose(odomain_c.yvel,sdomain_c.yvel)
     212       
     213        assert num.allclose(odomain_v.x,sdomain_v.x)
     214        assert num.allclose(odomain_v.y,sdomain_v.y)
     215       
     216        order = 0
     217        assert num.linalg.norm(odomain_v.x-sdomain_v.x,ord=order) == 0
     218        assert num.linalg.norm(odomain_v.y-sdomain_v.y,ord=order) == 0
     219        assert num.linalg.norm(odomain_v.stage[-1]-sdomain_v.stage[-1],ord=order) < 100
     220        assert num.linalg.norm(odomain_v.xmom[-1]-sdomain_v.xmom[-1],ord=order) < 100
     221        assert num.linalg.norm(odomain_v.ymom[-1]-sdomain_v.ymom[-1],ord=order) < 100
     222        assert num.linalg.norm(odomain_v.xvel[-1]-sdomain_v.xvel[-1],ord=order) < 100
     223        assert num.linalg.norm(odomain_v.yvel[-1]-sdomain_v.yvel[-1],ord=order) < 100       
     224               
     225        # COMPARE CENTROID PDOMAIN SDOMAIN 
     226        assert num.allclose(pdomain_c.x,sdomain_c.x)
     227        assert num.allclose(pdomain_c.y,sdomain_c.y)
     228        assert num.allclose(pdomain_c.stage[-1],sdomain_c.stage[-1])
     229        assert num.allclose(pdomain_c.xmom[-1],sdomain_c.xmom[-1])
     230        assert num.allclose(pdomain_c.ymom[-1],sdomain_c.ymom[-1])
     231        assert num.allclose(pdomain_c.xvel[-1],sdomain_c.xvel[-1])
     232        assert num.allclose(pdomain_c.yvel[-1],sdomain_c.yvel[-1])
     233           
     234           
     235        # COMPARE VERTEX PDOMAIN SDOMAIN
     236        assert num.allclose(pdomain_v.x,sdomain_v.x)
     237        assert num.allclose(pdomain_v.y,sdomain_v.y)
     238        assert num.allclose(pdomain_v.stage[-1],sdomain_v.stage[-1])
     239        assert num.allclose(pdomain_v.xmom[-1],sdomain_v.xmom[-1])
     240        assert num.allclose(pdomain_v.ymom[-1],sdomain_v.ymom[-1])
     241        assert num.allclose(pdomain_v.xvel[-1],sdomain_v.xvel[-1])
     242        assert num.allclose(pdomain_v.yvel[-1],sdomain_v.yvel[-1])   
     243           
     244
     245       
     246       
    109247def setup_and_evolve(domain, verbose=False):
    110248
     
    113251    #--------------------------------------------------------------------------
    114252    domain.set_flow_algorithm('DE0')
    115     domain.set_quantities_to_be_stored(None)
     253    #domain.set_store_vertices_uniquely()
    116254
    117255    #------------------------------------------------------------------------------
     
    131269    for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    132270        if myid == 0 and verbose : domain.write_time()
    133 
    134 
     271        #if myid == 0 and verbose : print domain.quantities['stage'].get_maximum_value()
     272
     273
     274    domain.sww_merge()
     275   
    135276
    136277# Test an nprocs-way run of the shallow water equations
  • trunk/anuga_core/validation_tests/analytical_exact/avalanche_dry/numerical_avalanche_dry.py

    r9155 r9174  
    103103alg = args.alg
    104104cfl = args.cfl
    105 verbose = args.v
     105verbose = args.verbose
    106106
    107107if myid == 0:
  • trunk/anuga_core/validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py

    r9155 r9174  
    1111
    1212args = anuga.get_args()
    13 verbose = args.v
     13verbose = args.verbose
    1414
    1515class Test_results(unittest.TestCase):
  • trunk/anuga_core/validation_tests/analytical_exact/carrier_greenspan_transient/numerical_cg_transient.py

    r9155 r9174  
    2929alg = args.alg
    3030cfl = args.cfl
    31 verbose = args.v
     31verbose = args.verbose
    3232
    3333
  • trunk/anuga_core/validation_tests/analytical_exact/dam_break_dry/numerical_dam_break_dry.py

    r9155 r9174  
    5252alg = args.alg
    5353cfl = args.cfl
    54 verbose = args.v
     54verbose = args.verbose
    5555
    5656print args
  • trunk/anuga_core/validation_tests/analytical_exact/dam_break_dry/validate_dam_break_dry.py

    r9155 r9174  
    1313indent = anuga.indent
    1414
    15 verbose = args.v
     15verbose = args.verbose
    1616
    1717class Test_results(unittest.TestCase):
  • trunk/anuga_core/validation_tests/analytical_exact/dam_break_wet/validate_dam_break_wet.py

    r9155 r9174  
    1212indent = anuga.indent
    1313
    14 verbose = args.v
     14verbose = args.verbose
    1515
    1616class Test_results(unittest.TestCase):
  • trunk/anuga_core/validation_tests/analytical_exact/lake_at_rest_immersed_bump/numerical_immersed_bump.py

    r9155 r9174  
    3939args = anuga.get_args()
    4040alg = args.alg
    41 verbose = args.v
     41verbose = args.verbose
    4242
    4343if myid == 0:
  • trunk/anuga_core/validation_tests/analytical_exact/lake_at_rest_steep_island/numerical_steep_island.py

    r9155 r9174  
    2929args = anuga.get_args()
    3030alg = args.alg
    31 verbose = args.v
     31verbose = args.verbose
    3232
    3333dx = 1.
  • trunk/anuga_core/validation_tests/analytical_exact/landslide_tsunami/produce_results.py

    r9117 r9174  
    22# import modules
    33#--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     4import anuga
     5from anuga.validation_utilities import produce_report
    76
     7args = anuga.get_args()
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('runup.py')
    13     run_validation_script('plot_results.py')
    14     typeset_report()
     9produce_report('runup.py', args=args)
    1510
    16 def clean():
    17     autoclean()
    18 
    19 main()
  • trunk/anuga_core/validation_tests/analytical_exact/landslide_tsunami/runup.py

    r9155 r9174  
    55#--------
    66import anuga
     7from anuga import myid, finalize, distribute
    78
    89import numpy
     
    1112from math import sin, pi, exp
    1213
     14
     15args = anuga.get_args()
     16alg = args.alg
     17verbose = args.verbose
     18
    1319#timer = strftime('%Y%m%d_%H%M%S',localtime())
    1420#---------
     
    1622# --- Very inefficient mesh!
    1723#---------
    18 print ' Building mesh (alternative non-uniform mesh could be much more efficient)'
     24
    1925dx = dy = 25.
    2026l1 = 60.*1000.
     
    2228nx =int(l1/dx)
    2329ny =int(l2/dy)
    24 points, vertices, boundary = anuga.rectangular_cross(nx,ny, len1=l1,len2=l2, origin=(-200., 0.))
    2530
    26 print 'Creating Domain'
    27 domain=anuga.Domain(points,vertices,boundary)    # Create Domain
    28 domain.set_name('runup_v2')                         # Output to file runup.sww
    29 domain.set_datadir('.')                          # Use current folder
    30 domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
    31 
    32 #------------------------------------------------------------------------------
    33 # Setup Algorithm, either using command line arguments
    34 # or override manually yourself
    35 #------------------------------------------------------------------------------
    36 from anuga.utilities.argparsing import parse_standard_args
    37 alg, cfl = parse_standard_args()
    38 domain.set_flow_algorithm(alg)
    39 #domain.set_CFL(cfl)
    40 
    41 #------------------
    42 # Define topography
    43 #------------------
    4431
    4532# Beach slope of 1/10
     
    4734        return -(x-200.)/10.
    4835
    49 # Define initial condition using file
    50 initial_prof=scipy.genfromtxt('./DATA/initial_condition.txt', skip_header=13)
    51 initial_prof_fun=scipy.interpolate.interp1d(initial_prof[:,0], initial_prof[:,1], fill_value=0., bounds_error=False)
     36#--------------------------------------------------------------------------------
     37# Create Sequential Domain
     38#--------------------------------------------------------------------------------
     39if myid == 0:
     40        print ' Building mesh (alternative non-uniform mesh could be much more efficient)'
     41        points, vertices, boundary = anuga.rectangular_cross(nx,ny, len1=l1,len2=l2, origin=(-200., 0.))
     42       
     43        print 'Creating Domain'
     44        domain=anuga.Domain(points,vertices,boundary)    # Create Domain
     45        domain.set_name('runup_v2')                         # Output to file runup.sww
     46        domain.set_datadir('.')                          # Use current folder
     47        domain.set_quantities_to_be_stored({'stage': 2, 'xmomentum': 2, 'ymomentum': 2, 'elevation': 1})
     48       
    5249
    53 def stagefun(x,y):
    54     return initial_prof_fun(x-200.)
     50        domain.set_flow_algorithm(alg)
    5551
    56 domain.set_quantity('elevation',topography)     # Use function for elevation
     52        #------------------
     53        # Define Initial conditions
     54        #------------------
     55       
     56       
     57        # Define initial condition using file
     58        initial_prof=scipy.genfromtxt('./DATA/initial_condition.txt', skip_header=13)
     59        initial_prof_fun=scipy.interpolate.interp1d(initial_prof[:,0], initial_prof[:,1], fill_value=0., bounds_error=False)
     60       
     61        def stagefun(x,y):
     62            return initial_prof_fun(x-200.)
     63       
     64        domain.set_quantity('elevation',topography)     # Use function for elevation   
     65        domain.set_quantity('friction',0.000)             # Constant friction
     66        domain.set_quantity('stage', stagefun)             
    5767
    58 domain.set_quantity('friction',0.000)             # Constant friction
     68else:
     69       
     70        domain = None
    5971
    60 domain.set_quantity('stage', stagefun)             
    61 
     72#------------------------------------------------------------------------
     73# Parallel Domain
     74#------------------------------------------------------------------------       
     75domain = distribute(domain)
     76       
    6277#--------------------------
    6378# Setup boundary conditions
     
    7388# Produce a documentation of parameters
    7489#------------------------------------------------------------------------------
    75 parameter_file=open('parameters.tex', 'w')
    76 parameter_file.write('\\begin{verbatim}\n')
    77 from pprint import pprint
    78 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    79 parameter_file.write('\\end{verbatim}\n')
    80 parameter_file.close()
     90if myid == 0:
     91        parameter_file=open('parameters.tex', 'w')
     92        parameter_file.write('\\begin{verbatim}\n')
     93        from pprint import pprint
     94        pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     95        parameter_file.write('\\end{verbatim}\n')
     96        parameter_file.close()
    8197
    8298#------------------------------
     
    85101
    86102for t in domain.evolve(yieldstep=5.0,finaltime=350.0):
    87     print domain.timestepping_statistics()
     103        if myid == 0: print domain.timestepping_statistics()
    88104    #uh=domain.quantities['xmomentum'].centroid_values
    89105    #vh=domain.quantities['ymomentum'].centroid_values
     
    93109    #print 'peak speed is', vel.max()
    94110
     111
     112domain.sww_merge(delete_old=True)
     113
     114finalize()
  • trunk/anuga_core/validation_tests/analytical_exact/mac_donald_short_channel/numerical_MacDonald.py

    r9155 r9174  
    1010import anuga
    1111from anuga import Domain as Domain
     12from anuga import myid, finalize, distribute
     13from anuga import g
    1214from math import cos
    1315from numpy import zeros, ones, array
     
    2527output_file = 'MacDonald'
    2628
    27 #anuga.copy_code_files(output_dir,__file__)
    28 #start_screen_catcher(output_dir+'_')
     29args = anuga.get_args()
     30alg = args.alg
     31verbose = args.verbose
    2932
    3033
    31 #------------------------------------------------------------------------------
    32 # Setup domain
    33 #------------------------------------------------------------------------------
    3434dx = 0.25
    3535dy = dx
     
    3737W = 3*dx
    3838
    39 # structured mesh
    40 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))
    4139
    42 #domain = anuga.Domain(points, vertices, boundary)
    43 domain = Domain(points, vertices, boundary)
    44 
    45 domain.set_name(output_file)               
    46 domain.set_datadir(output_dir)
    47 
    48 #------------------------------------------------------------------------------
    49 # Setup Algorithm, either using command line arguments
    50 # or override manually yourself
    51 #------------------------------------------------------------------------------
    52 from anuga.utilities.argparsing import parse_standard_args
    53 from anuga import g
    54 alg, cfl = parse_standard_args()
    55 domain.set_flow_algorithm(alg)
    56 #domain.set_CFL(cfl)
    57 
    58 #------------------------------------------------------------------------------
    59 # Setup initial conditions
    60 #------------------------------------------------------------------------------
    6140L     = 100.  # Channel length
    6241q = q_s = 2.    # Steady discharge
     
    9675    return elevation
    9776
    98 domain.set_quantity('stage', 2.87870797)
    99 domain.set_quantity('elevation', bed)
    100 domain.set_quantity('friction', n)
    10177
     78#------------------------------------------------------------------------------
     79# Setup sequential domain
     80#------------------------------------------------------------------------------
     81if myid == 0:
     82    # structured mesh
     83    points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.0, 0.0))
     84   
     85    #domain = anuga.Domain(points, vertices, boundary)
     86    domain = Domain(points, vertices, boundary)
     87   
     88    domain.set_name(output_file)               
     89    domain.set_datadir(output_dir)
     90   
     91    domain.set_flow_algorithm(alg)
     92
     93   
     94    #------------------------------------------------------------------------------
     95    # Setup initial conditions
     96    #------------------------------------------------------------------------------
     97   
     98    domain.set_quantity('stage', 2.87870797)
     99    domain.set_quantity('elevation', bed)
     100    domain.set_quantity('friction', n)
     101else:
     102   
     103    domain = None
     104   
     105#--------------------------------------------------------------------
     106# Parallel Domain
     107#--------------------------------------------------------------------
     108domain = distribute(domain)
    102109
    103110#-----------------------------------------------------------------------------
     
    114121
    115122
    116 #===============================================================================
    117 ##from anuga.visualiser import RealtimeVisualiser
    118 ##vis = RealtimeVisualiser(domain)
    119 ##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
    120 ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
    121 ##vis.start()
    122 #===============================================================================
    123123
    124124
     
    126126# Produce a documentation of parameters
    127127#------------------------------------------------------------------------------
    128 parameter_file=open('parameters.tex', 'w')
    129 parameter_file.write('\\begin{verbatim}\n')
    130 from pprint import pprint
    131 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    132 parameter_file.write('\\end{verbatim}\n')
    133 parameter_file.close()
     128if myid == 0:
     129    parameter_file=open('parameters.tex', 'w')
     130    parameter_file.write('\\begin{verbatim}\n')
     131    from pprint import pprint
     132    pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     133    parameter_file.write('\\end{verbatim}\n')
     134    parameter_file.close()
    134135
    135136#------------------------------------------------------------------------------
     
    138139for t in domain.evolve(yieldstep = 1.0, finaltime = 100.):
    139140    #print domain.timestepping_statistics(track_speeds=True)
    140     print domain.timestepping_statistics()
     141    if myid == 0: print domain.timestepping_statistics()
    141142    #vis.update()
    142143
    143144
    144 #test against know data
    145    
    146 #vis.evolveFinished()
     145domain.sww_merge(delete_old=True)
    147146
     147finalize()
     148
  • trunk/anuga_core/validation_tests/analytical_exact/mac_donald_short_channel/produce_results.py

    r9117 r9174  
    22# import modules
    33#--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     4import anuga
     5from anuga.validation_utilities import produce_report
    76
     7args = anuga.get_args()
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('numerical_MacDonald.py')
    13     run_validation_script('plot_results.py')
    14     typeset_report()
     9produce_report('numerical_MacDonald.py', args=args)
    1510
    16 def clean():
    17     autoclean()
    18 
    19 main()
    20 
  • trunk/anuga_core/validation_tests/analytical_exact/parabolic_basin/numerical_parabolic_basin.py

    r9156 r9174  
    2525args = anuga.get_args()
    2626alg = args.alg
    27 verbose = args.v
     27verbose = args.verbose
    2828
    2929m = 200
  • trunk/anuga_core/validation_tests/analytical_exact/paraboloid_basin/numerical_paraboloid_basin.py

    r9158 r9174  
    3434args = anuga.get_args()
    3535alg = args.alg
    36 verbose = args.v
     36verbose = args.verbose
    3737
    3838#-------------------------------------------------------------------------------
  • trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/numerical_varying_width.py

    r9155 r9174  
    1010import sys
    1111import anuga
     12from anuga import myid, finalize, distribute
    1213from anuga import Domain as Domain
    1314from math import cos
     
    3334#start_screen_catcher(output_dir+'_')
    3435
     36args = anuga.get_args()
     37alg = args.alg
     38verbose = args.verbose
    3539
    3640#------------------------------------------------------------------------------
     
    4246W = 60.
    4347
    44 # structured mesh
    45 points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.,-W/2.))
    4648
    47 #domain = anuga.Domain(points, vertices, boundary)
    48 domain = Domain(points, vertices, boundary)
     49#===============================================================================
     50# Create sequential domain
     51#===============================================================================
     52if myid == 0:
     53    # structured mesh
     54    points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.,-W/2.))
     55   
     56    #domain = anuga.Domain(points, vertices, boundary)
     57    domain = Domain(points, vertices, boundary)
     58   
     59    domain.set_name(output_file)               
     60    domain.set_datadir(output_dir)
     61   
     62    #------------------------------------------------------------------------------
     63    # Setup Algorithm, either using command line arguments
     64    # or override manually yourself
     65    #------------------------------------------------------------------------------
     66    from anuga.utilities.argparsing import parse_standard_args
     67    alg, cfl = parse_standard_args()
     68    domain.set_flow_algorithm(alg)
     69    #domain.set_CFL(cfl)
     70   
     71    #------------------------------------------------------------------------------
     72    # Setup initial conditions
     73    #------------------------------------------------------------------------------
     74    domain.set_quantity('friction', 0.0)
     75    domain.set_quantity('stage', 12.0)
     76    XX = array([0.,50.,100.,150.,250.,300.,350.,400.,425.,435.,450.,470.,475.,500.,
     77                505.,530.,550.,565.,575.,600.,650.,700.,750.,800.,820.,900.,950.,
     78                1000.,1500.])
     79    ZZ = array([0.,0.,2.5,5.,5.,3.,5.,5.,7.5,8.,9.,9.,9.,9.1,9.,9.,6.,5.5,5.5,5.,
     80                4.,3.,3.,2.3,2.,1.2,0.4,0.,0.])
     81    WW = array([40.,40.,30.,30.,30.,30.,25.,25.,30.,35.,35.,40.,40.,40.,45.,45.,50.,
     82                45.,40.,40.,30.,40.,40.,5.,40.,35.,25.,40.,40.])/2.
     83   
     84   
     85    depth = interp1d(XX, ZZ)
     86    width = interp1d(XX, WW)
     87   
     88    def bed_elevation(x,y):
     89        z = 25.0*ones_like(x)
     90        wid = width(x)
     91        dep = depth(x)
     92        z = where( logical_and(y < wid, y>-wid), dep, z)
     93        return z
     94   
     95    domain.set_quantity('elevation', bed_elevation)
     96   
     97else:
     98   
     99    domain = None
     100   
    49101
    50 domain.set_name(output_file)               
    51 domain.set_datadir(output_dir)
    52 
    53 #------------------------------------------------------------------------------
    54 # Setup Algorithm, either using command line arguments
    55 # or override manually yourself
    56 #------------------------------------------------------------------------------
    57 from anuga.utilities.argparsing import parse_standard_args
    58 alg, cfl = parse_standard_args()
    59 domain.set_flow_algorithm(alg)
    60 #domain.set_CFL(cfl)
    61 
    62 #------------------------------------------------------------------------------
    63 # Setup initial conditions
    64 #------------------------------------------------------------------------------
    65 domain.set_quantity('friction', 0.0)
    66 domain.set_quantity('stage', 12.0)
    67 XX = array([0.,50.,100.,150.,250.,300.,350.,400.,425.,435.,450.,470.,475.,500.,
    68             505.,530.,550.,565.,575.,600.,650.,700.,750.,800.,820.,900.,950.,
    69             1000.,1500.])
    70 ZZ = array([0.,0.,2.5,5.,5.,3.,5.,5.,7.5,8.,9.,9.,9.,9.1,9.,9.,6.,5.5,5.5,5.,
    71             4.,3.,3.,2.3,2.,1.2,0.4,0.,0.])
    72 WW = array([40.,40.,30.,30.,30.,30.,25.,25.,30.,35.,35.,40.,40.,40.,45.,45.,50.,
    73             45.,40.,40.,30.,40.,40.,5.,40.,35.,25.,40.,40.])/2.
    74 
    75 
    76 depth = interp1d(XX, ZZ)
    77 width = interp1d(XX, WW)
    78 
    79 def bed_elevation(x,y):
    80     z = 25.0*ones_like(x)
    81     wid = width(x)
    82     dep = depth(x)
    83     z = where( logical_and(y < wid, y>-wid), dep, z)
    84     return z
    85 
    86 domain.set_quantity('elevation', bed_elevation)
    87 
     102#===========================================================================
     103# Create Parallel domain
     104#===========================================================================
     105domain = distribute(domain)
    88106
    89107#-----------------------------------------------------------------------------
     
    99117
    100118
    101 #===============================================================================
    102 ##from anuga.visualiser import RealtimeVisualiser
    103 ##vis = RealtimeVisualiser(domain)
    104 ##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
    105 ##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
    106 ##vis.start()
    107 #===============================================================================
    108 
    109 
    110 #---------------------------------------------
    111 # Find triangle that contains the point Point
    112 # and print to file
    113 #---------------------------------------------
    114 ##Point = (0.0, 0.0)
    115 ##for n in range(len(domain.triangles)):
    116 ##    tri = domain.get_vertex_coordinates(n)
    117 ##    if is_inside_triangle(Point,tri):
    118 ##        #print 'Point is within triangle with vertices '+'%s'%tri
    119 ##        n_point = n
    120 ##        break
    121 ##print 'n_point = ',n_point
    122 ##bla
    123 
    124 
    125 
    126 
    127119#------------------------------------------------------------------------------
    128120# Produce a documentation of parameters
    129121#------------------------------------------------------------------------------
    130 parameter_file=open('parameters.tex', 'w')
    131 parameter_file.write('\\begin{verbatim}\n')
    132 from pprint import pprint
    133 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    134 parameter_file.write('\\end{verbatim}\n')
    135 parameter_file.close()
     122if myid == 0:
     123    parameter_file=open('parameters.tex', 'w')
     124    parameter_file.write('\\begin{verbatim}\n')
     125    from pprint import pprint
     126    pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     127    parameter_file.write('\\end{verbatim}\n')
     128    parameter_file.close()
    136129
    137130#------------------------------------------------------------------------------
    138131# Evolve system through time
    139132#------------------------------------------------------------------------------
     133import time
     134t0 = time.time()
    140135for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0):
    141136    #print domain.timestepping_statistics(track_speeds=True)
    142     print domain.timestepping_statistics()
     137    if myid == 0 and verbose: print domain.timestepping_statistics()
    143138    #vis.update()
    144139
     140if myid == 0 and verbose : print 'That took %s sec' % str(time.time()-t0)
     141domain.sww_merge(delete_old=True)
    145142
    146 #test against know data
    147    
    148 #vis.evolveFinished()
     143finalize()
    149144
     145
  • trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/plot_results.py

    r8886 r9174  
    2727pyplot.ylabel('Stage')
    2828pyplot.xlim([0,1500])
     29pyplot.ylim([0,25])
    2930pyplot.savefig('stage_plot.png')
    3031
     
    5253pyplot.xlim([0,1500])
    5354pyplot.savefig('xvel_plot.png')
     55
     56
     57
     58
     59# Sweep in y direction
     60
     61v = p2_st.x[116]
     62v2=(p2_st.x==v)
     63
     64
     65#p_dev = util.get_output('dam_break.sww', 0.001)
     66#p2_dev=util.get_centroids(p_dev, velocity_extrapolation=True)
     67
     68#Plot stages
     69pyplot.clf()
     70pyplot.plot(p2_st.y[v2], p2_st.stage[-1,v2],'b.', label='numerical stage')
     71pyplot.plot(p2_st.y[v2], 12.*ones_like(p2_st.x[v2]),'r--', label='analytical stage')
     72pyplot.plot(p2_st.y[v2], p2_st.elev[v2],'k-', label='discretised bed')
     73pyplot.title('Stage at an instant in time')
     74pyplot.legend(loc='best')
     75pyplot.xlabel('Yposition')
     76pyplot.ylabel('Stage')
     77pyplot.xlim([-30,30])
     78pyplot.ylim([-1,26])
     79pyplot.savefig('stage_plot_y.png')
     80
     81
     82#Plot xmomentum
     83pyplot.clf()
     84pyplot.plot(p2_st.y[v2], p2_st.xmom[-1,v2], 'b.', label='numerical')
     85pyplot.plot(p2_st.y[v2], zeros(len(p2_st.x[v2])),'r-', label='analytical')
     86pyplot.title('Xmomentum at an instant in time')
     87pyplot.legend(loc='best')
     88pyplot.xlabel('Yposition')
     89pyplot.ylabel('Xmomentum')
     90pyplot.xlim([-30,30])
     91pyplot.savefig('xmom_plot_y.png')
     92
     93
     94#Plot velocities
     95pyplot.clf()
     96pyplot.plot(p2_st.y[v2], p2_st.xvel[-1,v2], 'b.', label='numerical')
     97pyplot.plot(p2_st.y[v2], zeros(len(p2_st.x[v2])),'r-', label='analytical')
     98pyplot.title('Xvelocity at an instant in time')
     99pyplot.legend(loc='best')
     100pyplot.xlabel('Yposition')
     101pyplot.ylabel('Xvelocity')
     102pyplot.xlim([-30,30])
     103pyplot.savefig('xvel_plot_y.png')
  • trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/produce_results.py

    r9117 r9174  
    22# import modules
    33#--------------------------------
    4 from anuga.validation_utilities.fabricate import *
    5 from anuga.validation_utilities import run_validation_script
    6 from anuga.validation_utilities import typeset_report
     4import anuga
     5from anuga.validation_utilities import produce_report
    76
     7args = anuga.get_args()
    88
    9 # Setup the python scripts which produce the output for this
    10 # validation test
    11 def build():
    12     run_validation_script('numerical_varying_width.py')
    13     run_validation_script('plot_results.py')
    14     typeset_report()
     9produce_report('numerical_varying_width.py', args=args)
    1510
    16 def clean():
    17     autoclean()
    18 
    19 main()
    20 
  • trunk/anuga_core/validation_tests/analytical_exact/river_at_rest_varying_topo_width/results.tex

    r9155 r9174  
    5050
    5151
    52 Current version of \anuga{} might not treat the wet/dry interface appropriately. The following three figures show the stage, $x$-momentum, and $x$-velocity respectively, after we run the simulation for some time. We should see excellent agreement between the analytical and numerical solutions if the method is well-balanced and if the wet/dry interface has been correctly treated.
     52Current version of \anuga{} might not treat the wet/dry interface appropriately.
     53The following figures show the stage, $x$-momentum, and $x$-velocity respectively,
     54after we run the simulation for some time. The first three show a slice in the x direction (down the river) and
     55the last three figures show a cross section across the river. We should see excellent agreement between
     56the analytical and numerical solutions if the method is well-balanced and if the wet/dry
     57interface has been correctly treated.
    5358
    5459\begin{figure}
     
    5661\includegraphics[width=0.9\textwidth]{stage_plot.png}
    5762\end{center}
    58 \caption{Stage results}
     63\caption{Stage results down the river}
    5964\end{figure}
    6065
     
    6469\includegraphics[width=0.9\textwidth]{xmom_plot.png}
    6570\end{center}
    66 \caption{Xmomentum results}
     71\caption{Xmomentum results down the river}
    6772\end{figure}
    6873
     
    7277\includegraphics[width=0.9\textwidth]{xvel_plot.png}
    7378\end{center}
    74 \caption{Xvelocity results}
     79\caption{Xvelocity results down the river}
     80\end{figure}
     81
     82\begin{figure}
     83\begin{center}
     84\includegraphics[width=0.9\textwidth]{stage_plot_y.png}
     85\end{center}
     86\caption{Stage results across the river}
    7587\end{figure}
    7688
    7789
     90\begin{figure}
     91\begin{center}
     92\includegraphics[width=0.9\textwidth]{xmom_plot_y.png}
     93\end{center}
     94\caption{Xmomentum results across the river}
     95\end{figure}
     96
     97
     98\begin{figure}
     99\begin{center}
     100\includegraphics[width=0.9\textwidth]{xvel_plot_y.png}
     101\end{center}
     102\caption{Xvelocity results accros the river}
     103\end{figure}
     104
    78105\endinput
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/numerical_rundown_channel.py

    r9155 r9174  
    1212from anuga.structures.inlet_operator import Inlet_operator
    1313from anuga import Domain
     14from anuga import myid, finalize, distribute
    1415
    15 #------------------------------------------------------------------------------
    16 # Setup computational domain
    17 #------------------------------------------------------------------------------
    18 points, vertices, boundary = rectangular_cross(50, 50, len1=100.0, len2=100.0)
    19 domain = Domain(points, vertices, boundary) # Create domain
    20 domain.set_name('channel') # Output name
    21 
    22 #------------------------------------------------------------------------------
    23 # Setup Algorithm, either using command line arguments
    24 # or override manually yourself
    25 #------------------------------------------------------------------------------
    26 from anuga.utilities.argparsing import parse_standard_args
    27 alg, cfl = parse_standard_args()
    28 domain.set_flow_algorithm(alg)
    29 #domain.set_CFL(cfl)
    30 
    31 #------------------------------------------------------------------------------
    32 # Setup initial conditions
    33 #------------------------------------------------------------------------------
     16#===============================================================================
     17# Setup flow conditions
     18#===============================================================================
    3419Qin=20.
    3520fluxin=Qin/100. #The momentum flux at the upstream boundary ( = discharge / width)
    3621uana= 2.15843634571 # analytical Xvelocity
    3722dana= 0.0926596702273 # analytical water depth
     23slope = -0.1
     24mannings = 0.03
    3825
    39 def topography(x, y):
    40         return -x/10. # linear bed slope
     26args = anuga.get_args()
     27alg = args.alg
     28verbose = args.verbose
    4129
    42 def init_stage(x,y):
    43     stg= -x/10.+0.01 # Constant depth: 1 cm.
    44     return stg
    45 #line0=[ [0.,0.], [0., 100.] ]
    46 #Uin=[uana, 0.0]
    47 #Inlet_operator(domain, line0, Q=Qin, velocity=Uin)
     30#------------------------------------------------------------------------------
     31# Setup sequential computational domain
     32#------------------------------------------------------------------------------
     33if myid == 0:
     34        points, vertices, boundary = rectangular_cross(50, 50, len1=100.0, len2=100.0)
     35        domain = Domain(points, vertices, boundary) # Create domain
     36        domain.set_name('channel') # Output name
    4837
    49 domain.set_quantity('elevation', topography) # Use function for elevation
    50 domain.set_quantity('friction', 0.03) # Constant friction
    51 domain.set_quantity('stage', init_stage)
     38        domain.set_flow_algorithm(alg)
     39        domain.set_store_centroids(True)
     40       
     41        #------------------------------------------------------------------------------
     42        # Setup initial conditions
     43        #------------------------------------------------------------------------------
     44       
     45        def topography(x, y):
     46                return x*slope # linear bed slope
     47       
     48        def init_stage(x,y):
     49                stg= x*slope+0.01 # Constant depth: 1 cm.
     50                return stg
     51       
     52        domain.set_quantity('elevation', topography) # Use function for elevation
     53        domain.set_quantity('friction', mannings) # Constant friction
     54        domain.set_quantity('stage', init_stage)
    5255
     56else:
     57       
     58        domain = None
     59
     60#===============================================================================
     61# Parallel Domain
     62#===============================================================================
     63domain = distribute(domain)
     64
     65#domain.set_store_centroids(True)
    5366#------------------------------------------------------------------------------
    5467# Setup boundary conditions
     
    6477# Produce a documentation of parameters
    6578#------------------------------------------------------------------------------
    66 parameter_file=open('parameters.tex', 'w')
    67 parameter_file.write('\\begin{verbatim}\n')
    68 from pprint import pprint
    69 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    70 parameter_file.write('\\end{verbatim}\n')
    71 parameter_file.close()
     79if myid == 0:
     80        parameter_file=open('parameters.tex', 'w')
     81        parameter_file.write('\\begin{verbatim}\n')
     82        from pprint import pprint
     83        pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     84        parameter_file.write('\\end{verbatim}\n')
     85        parameter_file.close()
    7286
    7387#------------------------------------------------------------------------------
     
    7589#------------------------------------------------------------------------------
    7690for t in domain.evolve(yieldstep=2.0, finaltime=200.0):
    77         print domain.timestepping_statistics()
     91        if myid ==0 and verbose: print domain.timestepping_statistics()
     92
     93
     94domain.sww_merge(delete_old=True)
     95
     96finalize()
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/plot_results.py

    r9155 r9174  
    2424#------------------
    2525#v=(y==2.5)
    26 v=(p2.y==p2.y[3])
     26#v=(p2.y==p2.y[3])
    2727
    2828#-------------------------------
     
    4545# Make plot animation
    4646#--------------------
     47# Find an y value close to y==50
     48tmp=(abs(p2.y-50.)).argmin()
     49#vx=(p2.y==p2.y[tmp])
     50vx=(abs(p2.y - p2.y[tmp])<1.5)
     51
    4752pyplot.clf()
     53pyplot.plot(p2.x[vx],p2.stage[-1,vx]-p2.elev[vx], 'o', label='numerical')
     54pyplot.plot((0,100),(dana,dana),label='analytical')
     55pyplot.ylim([0.05,0.1])
     56pyplot.xlabel('Xposition m')
     57pyplot.ylabel('Depth m')
     58pyplot.title('Depth down the slope (along y=50.)')
     59pyplot.legend(loc='best')
     60pyplot.savefig('depth_x.png')
    4861
    49 line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,( (p2.stage[:,v]-p2.elev[v]).max(),(p2.stage[:,v]-p2.elev[v]).min() ) )
    50 line.set_label('numerical')
    51 pyplot.plot( (0,100),(dana,dana), 'r',label='analytical' )
    52 pyplot.legend()
    53 #pyplot.plot(x[v],elev[v],'green')
    54 for i in range(p2.xmom.shape[0]):
    55     line.set_xdata(p2.x[v])
    56     line.set_ydata(p2.stage[i,v]-p2.elev[v])
    57     pyplot.draw()
    58     pyplot.title('Flow depth: should be converging to steady uniform flow ' )
    59     pyplot.xlabel('Xposition')
    60     pyplot.ylabel('Depth')
    61 pyplot.ylim([0.085,0.095])
    62 pyplot.legend(loc='best')
    63 pyplot.title('Flow depth at 400s')# -- there should be a central region with steady uniform flow ' )
    64 pyplot.savefig('final_depth.png')
     62
     63
     64
     65
    6566
    6667#--------------------------------------------
     
    6970# Find an x value close to x==50
    7071tmp=(abs(p2.x-50.)).argmin()
    71 v=(p2.x==p2.x[tmp])
     72v=(abs(p2.x - p2.x[tmp])<1.5)
    7273
    7374pyplot.clf()
    74 pyplot.plot(p2.y[v],p2.xvel[100,v], 'o', label='numerical')
     75pyplot.plot(p2.y[v],p2.stage[-1,v]-p2.elev[v], 'o', label='numerical')
     76pyplot.plot((0,100),(dana,dana),label='analytical')
     77pyplot.ylim([0.05,0.1])
     78pyplot.xlabel('Yposition m')
     79pyplot.ylabel('Depth m')
     80pyplot.title('Depth across the slope (x=50.)')
     81pyplot.legend(loc='best')
     82pyplot.savefig('depth_y.png')
     83
     84
     85pyplot.clf()
     86pyplot.plot(p2.y[v],p2.xvel[-1,v], 'o', label='numerical')
    7587pyplot.plot((0,100),(uana,uana),label='analytical')
    7688pyplot.ylim([1.0,3.0])
     
    8294
    8395pyplot.clf()
    84 pyplot.plot(p2.y[v],p2.yvel[100,v],'o', label='numerical')
     96pyplot.plot(p2.y[v],p2.yvel[-1,v],'o', label='numerical')
    8597pyplot.plot((0,100),(0.0, 0.0),label='analytical')
    8698pyplot.xlabel('Yposition along the line x=50')
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/produce_results.py

    r9117 r9174  
    33It was called "steep_slope" in an old validation test.
    44"""
    5 #--------------------------------
    6 # import modules
    7 #--------------------------------
    85
    9 from anuga.validation_utilities.fabricate import *
    10 from anuga.validation_utilities import run_validation_script
    11 from anuga.validation_utilities import typeset_report
     6import anuga
     7from anuga.validation_utilities import produce_report
    128
    13 # Setup the python scripts which produce the output for this
    14 # validation test
    15 def build():
    16     run_validation_script('numerical_rundown_channel.py')
    17     run_validation_script('plot_results.py')
    18     typeset_report()
     9args = anuga.get_args()
    1910
    20 def clean():
    21     autoclean()
     11produce_report('numerical_rundown_channel.py', args=args)
    2212
    23 main()
     13
     14
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope/results.tex

    r8801 r9174  
    99Suppose that we are given a one dimensional domain. The steady state conditions with a contant water depth everywhere make the shallow water equations to the single identity
    1010\begin{equation}
    11 z_x = - S_f.
     11z_x = - S_f,
    1212\end{equation}
    13 Here $q=uh$ is the momentum or water discharge and $S_f$ is the symbol for the force of bottom friction involving Manning's coefficient $n$. We take
     13where $z_x$ is the bed slope, and $S_f$ is the symbol for the force of bottom friction.  We take Manning's friction
    1414\begin{equation}
    15 S_f = n^2 \frac{q|q|}{h^{10/3}}.
     15S_f = n^2 \frac{q|q|}{h^{10/3}}
    1616\end{equation}
    17 If $q$, $n$, and $z_x$ are given, then the analytical solution is
     17where $n$ is the Manning's coefficient and $q$ is the discharge $uh$.
     18If $q$, $n$, and $z_x$ are given, then the analytical solution for $u$ and $h$ is
    1819\begin{equation}
    1920u(x)= \left[- n^{-2} q^{4/3} z_x\right]^{3/10},
     
    3536
    3637
    37 Some simualtion results are as follows.
    38 Figures~\ref{fig:depthdownchan} shows the steady state depth in the downstream direction. There should be a good agreement with the analytical solution, at least away from the boundaries. 
     38Some simulation results are as follows.
     39Figures~\ref{fig:depthdownchan} shows the steady state depth in the downstream direction.
     40There should be a good agreement with the analytical solution, at least away from the boundaries.
     41
     42Figures~\ref{fig:depthacrosschan} shows the steady state depth across the slope around the line x = 50m.
     43There should be a good agreement with the analytical solution, at least away from the boundaries.
     44
    3945Figures~\ref{fig:xvelscrosschan} and~\ref{fig:yvelscroschan} show the steady state $x$- and $y$-velocities, along a slice in the cross slope direction (near $x=50$). The $x$-velocities should agree well with the analytical solution, and the $y$-velocities should be zero.
    4046
    4147\begin{figure}
    4248\begin{center}
    43 \includegraphics[width=0.8\textwidth]{final_depth.png}
     49\includegraphics[width=0.8\textwidth]{depth_x.png}
    4450\caption{Depth in the downstream direction}
    4551\label{fig:depthdownchan}
     
    4753\end{figure}
    4854 
     55\begin{figure}
     56\begin{center}
     57\includegraphics[width=0.8\textwidth]{depth_y.png}
     58\caption{Depth across the slope around $x$ = 50m}
     59\label{fig:depthacrosschan}
     60\end{center}
     61\end{figure}
    4962
    5063\begin{figure}
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope_coarse/numerical_rundown_channel_coarse.py

    r9155 r9174  
    99#------------------------------------------------------------------------------
    1010import anuga
    11 from anuga import rectangular_cross as rectangular_cross
    12 from anuga.structures.inlet_operator import Inlet_operator
     11from anuga import rectangular_cross
     12from anuga import Inlet_operator
    1313from anuga import Domain
     14from anuga import myid, finalize, distribute
     15
     16Qin = 0.1
     17fluxin=Qin/100. #The momentum flux at the upstream boundary ( = discharge / width)
     18mann=0.03 # Manning's coef
     19bedslope=-0.1
     20uana= ( mann**(-2.)*abs(bedslope)*fluxin**(4./3.) )**(3./10.) # Velocity
     21dana= fluxin/uana # Depth
     22
     23
     24
     25args = anuga.get_args()
     26alg = args.alg
     27verbose = args.verbose
    1428
    1529#------------------------------------------------------------------------------
    16 # Setup computational domain
     30# Setup sequential computational domain
    1731#------------------------------------------------------------------------------
    18 points, vertices, boundary = rectangular_cross(14, 10, len1=140.0, len2=100.0)
    19 domain = Domain(points, vertices, boundary) # Create domain
    20 domain.set_name('channel') # Output name
     32if myid == 0:
     33        points, vertices, boundary = rectangular_cross(40, 10, len1=400.0, len2=100.0)
     34        domain = Domain(points, vertices, boundary) # Create domain
     35        domain.set_name('channel') # Output name
     36       
     37        domain.set_flow_algorithm(alg)
    2138
    22 #------------------------------------------------------------------------------
    23 # Setup Algorithm, either using command line arguments
    24 # or override manually yourself
    25 #------------------------------------------------------------------------------
    26 from anuga.utilities.argparsing import parse_standard_args
    27 alg, cfl = parse_standard_args()
    28 domain.set_flow_algorithm(alg)
    29 #domain.set_CFL(cfl)
     39       
     40        #------------------------------------------------------------------------------
     41        # Setup initial conditions
     42        #------------------------------------------------------------------------------
    3043
    31 #------------------------------------------------------------------------------
    32 # Setup initial conditions
    33 #------------------------------------------------------------------------------
    34 Qin=0.1
    35 #fluxin=Qin/100. #The momentum flux at the upstream boundary ( = discharge / width)
    36 #uana= 2.15843634571 # analytical Xvelocity
    37 #dana= 0.0926596702273 # analytical water depth
     44       
     45        def topography(x, y):
     46                return -x/10. # linear bed slope
     47       
     48        def init_stage(x,y):
     49                stg= -x/10.+0.004 # Constant depth: 10 cm.
     50                return stg
     51        #line0=[ [0.,0.], [0., 100.] ]
     52        #Uin=[uana, 0.0]
     53        #Inlet_operator(domain, line0, Q=Qin, velocity=Uin)
     54       
    3855
    39 def topography(x, y):
    40         return -x/10. # linear bed slope
    41 
    42 def init_stage(x,y):
    43     stg= -x/10.+0.10 # Constant depth: 10 cm.
    44     return stg
    45 #line0=[ [0.,0.], [0., 100.] ]
    46 #Uin=[uana, 0.0]
    47 #Inlet_operator(domain, line0, Q=Qin, velocity=Uin)
    48 
    49 line1=[ [0.,0.], [0., 100.] ]
    50 #Qin=0.1
    51 Inlet_operator(domain, line1,Qin)
    52 
    53 
    54 domain.set_quantity('elevation', topography) # Use function for elevation
    55 domain.set_quantity('friction', 0.03) # Constant friction
    56 domain.set_quantity('stage', init_stage)
     56       
     57        domain.set_quantity('elevation', topography) # Use function for elevation
     58        domain.set_quantity('friction', mann) # Constant friction
     59        domain.set_quantity('stage', init_stage)
     60        domain.set_quantity('xmomentum', dana*uana)
     61else:
     62       
     63        domain = None
     64       
     65#===========================================================================
     66# Create Parallel Domain
     67#===========================================================================
     68domain = distribute(domain)
    5769
    5870#------------------------------------------------------------------------------
     
    6072#------------------------------------------------------------------------------
    6173Bt = anuga.Transmissive_boundary(domain)
     74#Bts = anuga.Transmissive_momentum_set_stage_boundary(domain, dana-160.0)
     75Bts = anuga.Transmissive_n_momentum_zero_t_momentum_set_stage_boundary(domain, lambda t: dana-160.0)
    6276#BdIN = anuga.Dirichlet_boundary([dana, fluxin, 0.0])
    63 #BdOUT = anuga.Dirichlet_boundary([dana-10., fluxin, 0.0])
     77BdOUT = anuga.Dirichlet_boundary([dana-40., dana*uana, 0.0])
     78
     79print dana-40.
     80
    6481Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    65 domain.set_boundary({'left': Br, 'right': Bt, 'top': Br, 'bottom': Br})
     82domain.set_boundary({'left': Br, 'right': BdOUT, 'top': Br, 'bottom': Br})
     83
     84
     85line1=[ [0.0, 0.], [0.0, 100.] ]
     86Qin=0.1
     87inlet = Inlet_operator(domain, line1, Q = Qin)
     88
     89
     90#if inlet: print inlet.statistics()
     91
     92
     93stage = domain.quantities['stage']
     94elev  = domain.quantities['elevation']
     95
     96print (stage-elev).get_integral()
     97
     98
     99
     100       
    66101
    67102
     
    69104# Produce a documentation of parameters
    70105#------------------------------------------------------------------------------
    71 parameter_file=open('parameters.tex', 'w')
    72 parameter_file.write('\\begin{verbatim}\n')
    73 from pprint import pprint
    74 pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
    75 parameter_file.write('\\end{verbatim}\n')
    76 parameter_file.close()
     106if myid == 0:
     107        parameter_file=open('parameters.tex', 'w')
     108        parameter_file.write('\\begin{verbatim}\n')
     109        from pprint import pprint
     110        pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
     111        parameter_file.write('\\end{verbatim}\n')
     112        parameter_file.close()
    77113
    78114#------------------------------------------------------------------------------
    79115# Evolve system through time
    80116#------------------------------------------------------------------------------
    81 for t in domain.evolve(yieldstep=10.0, finaltime=2000.0):
    82     print domain.timestepping_statistics()
    83     print (domain.areas*(domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values)).sum()
    84     s3 = domain.get_flow_through_cross_section([[30., 0.0], [30., 100.]])
    85     s4 = domain.get_flow_through_cross_section([[32., 0.0], [32., 100.]])
    86     s5 = domain.get_flow_through_cross_section([[34., 0.0], [34., 100.]])
    87     s2 = domain.get_flow_through_cross_section([[45., 0.0], [45., 100.]])
    88     s1 = domain.get_flow_through_cross_section([[53., 0.0], [53., 100.]])
    89     s0 = domain.get_flow_through_cross_section([[60., 0.0], [60., 100.]])
    90     print 'Xsectional flow:', s0, s1, s2, s3, s4, s5
     117for t in domain.evolve(yieldstep=10.0, finaltime=3000.0):
     118        if myid == 0 and verbose: print domain.timestepping_statistics()
     119        #print (stage-elev).get_integral()
     120    #print (domain.areas*(domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values)).sum()
     121    #s3 = domain.get_flow_through_cross_section([[30., 0.0], [30., 100.]])
     122    #s4 = domain.get_flow_through_cross_section([[32., 0.0], [32., 100.]])
     123    #s5 = domain.get_flow_through_cross_section([[34., 0.0], [34., 100.]])
     124    #s2 = domain.get_flow_through_cross_section([[45., 0.0], [45., 100.]])
     125    #s1 = domain.get_flow_through_cross_section([[53., 0.0], [53., 100.]])
     126    #s0 = domain.get_flow_through_cross_section([[60., 0.0], [60., 100.]])
     127    #print 'Xsectional flow:', s0, s1, s2, s3, s4, s5
     128
     129
     130domain.sww_merge(delete_old=True)
     131
     132finalize()
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope_coarse/plot_results.py

    r9155 r9174  
    2626#v=(p2.y==p2.y[3])
    2727
    28 tmp = abs(p2.y-50.)
    29 n = tmp.argmin()
    30 v=(p2.y==p2.y[n])
    31 
    32 ll=p2.vel.shape[0]-1
    33 
    3428#-------------------------------
    3529# Define variables of case study
     
    5145# Make plot animation
    5246#--------------------
     47# Find an y value close to y==50
     48#tmp=(abs(p2.y-50.)).argmin()
     49#vx=(p2.y==p2.y[tmp])
     50vx=(abs(p2.y - 50.0)<10.0)
     51
    5352pyplot.clf()
     53pyplot.plot(p2.x[vx],p2.stage[-1,vx]-p2.elev[vx], 'o', label='numerical')
     54pyplot.plot((0,400),(dana,dana),label='analytical')
     55pyplot.ylim([0.0,0.01])
     56pyplot.xlabel('Xposition m')
     57pyplot.ylabel('Depth m')
     58pyplot.title('Depth down the slope (along y=50.)')
     59pyplot.legend(loc='best')
     60pyplot.savefig('depth_x.png')
    5461
    55 line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,( (p2.stage[:,v]-p2.elev[v]).max(),(p2.stage[:,v]-p2.elev[v]).min() ) )
    56 line.set_label('numerical')
    57 pyplot.plot( (0,140),(dana,dana), 'r',label='analytical' )
    58 pyplot.yscale('log')
    59 pyplot.legend()
    60 #pyplot.plot(x[v],elev[v],'green')
    61 for i in range(p2.xmom.shape[0]):
    62     line.set_xdata(p2.x[v])
    63     line.set_ydata(p2.stage[i,v]-p2.elev[v])
    64     pyplot.draw()
    65     pyplot.title('Flow depth: should be converging to steady uniform flow ' )
    66     pyplot.xlabel('Xposition')
    67     pyplot.ylabel('Depth')
    68 #pyplot.ylim([0.085,0.095])
     62
     63
     64pyplot.clf()
     65pyplot.plot(p2.x[vx],p2.xvel[-1,vx], 'o', label='numerical')
     66pyplot.plot((0,400),(uana,uana),label='analytical')
     67#pyplot.ylim([0.0,0.05])
     68pyplot.xlabel('Xposition m')
     69pyplot.ylabel('Depth m')
     70pyplot.title('Velocity down the slope (along y=50.)')
    6971pyplot.legend(loc='best')
    70 pyplot.title('Flow depth at 800s')# -- there should be a central region with steady uniform flow ' )
    71 pyplot.savefig('final_depth.png')
     72pyplot.savefig('xvelocity_x.png')
     73
     74
     75
    7276
    7377#--------------------------------------------
     
    7579#--------------------------------------------
    7680# Find an x value close to x==50
    77 tmp=(abs(p2.x-50.)).argmin()
    78 v=(p2.x==p2.x[tmp])
     81#tmp=(abs(p2.x-50.)).argmin()
     82v=(abs(p2.x - 50.0)<10.0)
    7983
    8084pyplot.clf()
    81 pyplot.plot(p2.y[v],p2.xvel[ll,v], 'o', label='numerical')
     85pyplot.plot(p2.y[v],p2.stage[-1,v]-p2.elev[v], 'o', label='numerical')
     86pyplot.plot((0,100),(dana,dana),label='analytical')
     87pyplot.ylim([0.0,0.005])
     88pyplot.xlabel('Yposition m')
     89pyplot.ylabel('Depth m')
     90pyplot.title('Depth across the slope (x=50.)')
     91pyplot.legend(loc='best')
     92pyplot.savefig('depth_y.png')
     93
     94
     95pyplot.clf()
     96pyplot.plot(p2.y[v],p2.xvel[-1,v], 'o', label='numerical')
    8297pyplot.plot((0,100),(uana,uana),label='analytical')
    83 #pyplot.ylim([1.0,3.0])
     98pyplot.ylim([0.0,0.35])
    8499pyplot.xlabel('Yposition along the line x=50')
    85100pyplot.ylabel('Xvelocity m/s')
    86101pyplot.title('Final Xvelocity around the line x=50.')
    87102pyplot.legend(loc='best')
    88 pyplot.ylim((0,1.5*uana))
    89103pyplot.savefig('x_velocity.png')
    90104
    91105pyplot.clf()
    92 pyplot.plot(p2.y[v],p2.yvel[ll,v],'o', label='numerical')
     106pyplot.plot(p2.y[v],p2.yvel[-1,v],'o', label='numerical')
    93107pyplot.plot((0,100),(0.0, 0.0),label='analytical')
     108#pyplot.ylim([0.0,0.3])
    94109pyplot.xlabel('Yposition along the line x=50')
    95110pyplot.ylabel('Yvelocity')
  • trunk/anuga_core/validation_tests/analytical_exact/rundown_mild_slope_coarse/produce_results.py

    r9117 r9174  
    33It was called "steep_slope" in an old validation test.
    44"""
    5 #--------------------------------
    6 # import modules
    7 #--------------------------------
    85
    9 from anuga.validation_utilities.fabricate import *
    10 from anuga.validation_utilities import run_validation_script
    11 from anuga.validation_utilities import typeset_report
     6import anuga
     7from anuga.validation_utilities import produce_report
    128
    13 # Setup the python scripts which produce the output for this
    14 # validation test
    15 def build():
    16     run_validation_script('numerical_rundown_channel_coarse.py')
    17     run_validation_script('plot_results.py')
    18     typeset_report()
     9args = anuga.get_args()
    1910
    20 def clean():
    21     autoclean()
     11produce_report('numerical_rundown_channel_coarse.py', args=args)
    2212
    23 main()
     13
     14
  • trunk/anuga_core/validation_tests/behaviour_only/lid_driven_cavity/numerical_lid_driven_cavity.py

    r9036 r9174  
    2323alg, cfl = parse_standard_args()
    2424domain.set_flow_algorithm(alg)
    25 domain.set_CFL(cfl)
     25#domain.set_CFL(cfl)
    2626
    2727domain.set_name('dimensional_lid_driven')   # Output to file runup.sww
  • trunk/anuga_core/validation_tests/behaviour_only/weir_1/runup.py

    r9121 r9174  
    6060alg, cfl = parse_standard_args()
    6161domain.set_flow_algorithm(alg)
    62 domain.set_CFL(cfl)
     62#domain.set_CFL(cfl)
    6363
    6464domain.set_name('runup_riverwall')                         
  • trunk/anuga_core/validation_tests/case_studies/okushiri/run_okushiri.py

    r9134 r9174  
    8484        alg, cfl = parse_standard_args()
    8585        domain.set_flow_algorithm(alg)
    86         domain.set_CFL(cfl)
     86        #domain.set_CFL(cfl)
    8787   
    8888   
  • trunk/anuga_core/validation_tests/case_studies/patong/run_model.py

    r9140 r9174  
    3838import shutil
    3939
    40 
    41 verbose = True
     40#--------------------------------------------------
     41# Pick up useful command line arguments (which over rides
     42# values set before
     43#--------------------------------------------------
     44cfl = anuga.args.cfl
     45alg = anuga.args.alg
     46verbose = anuga.args.verbose
     47np = anuga.args.np
     48
     49if myid == 0 and verbose:
     50    print 80*'#'
     51    print '#'
     52    print '# Long Validation Test, takes 10 minutes on my desktop'
     53    print '#'
     54    print '# Consider running in parallel'
     55    print '#'
     56    print 80*'#'
     57
    4258#-------------------------------------------------------------------------------
    4359# Copy scripts to time stamped output directory and capture screen
     
    133149    domain.set_name(project.scenario_name)
    134150    domain.set_datadir(project.output_run)
    135     print 'WARNING: FORCING FLOW ALGORITHM TO DE0 -- NEEDS TO BE CHANGED FOR INTEGRATION INTO VALIDATION TESTS'
    136     #domain.set_flow_algorithm('tsunami')
    137     domain.set_flow_algorithm('DE0')
     151
     152    domain.set_flow_algorithm(alg)
     153    #domain.set_CFL(cfl)
    138154
    139155    #-------------------------------------------------------------------------------
  • trunk/anuga_core/validation_tests/case_studies/towradgi/Towradgi_historic_flood.py

    r9076 r9174  
    225225    alg, cfl = parse_standard_args()
    226226    domain.set_flow_algorithm(alg)
    227     domain.set_CFL(cfl)
     227    #domain.set_CFL(cfl)
    228228    #domain.set_flow_algorithm('DE1')
    229229    #domain.set_store_vertices_smoothly()
  • trunk/anuga_core/validation_tests/experimental_data/dam_break_yeh_petroff/numerical_Yeh_Petroff.py

    r9038 r9174  
    5858
    5959domain.set_flow_algorithm(alg)
    60 domain.set_CFL(cfl)
     60#domain.set_CFL(cfl)
    6161#domain.set_minimum_allowed_height(0.01) # Avoid such statements in the validation tests
    6262
  • trunk/anuga_core/validation_tests/other_references/radial_dam_break_dry/radial_dam_break.py

    r8890 r9174  
    5050alg, cfl = parse_standard_args()
    5151domain.set_flow_algorithm(alg)
    52 domain.set_CFL(cfl)
     52#domain.set_CFL(cfl)
    5353#domain.set_minimum_allowed_height(0.002)
    5454
  • trunk/anuga_core/validation_tests/other_references/radial_dam_break_wet/radial_dam_break.py

    r8891 r9174  
    5050alg, cfl = parse_standard_args()
    5151domain.set_flow_algorithm(alg)
    52 domain.set_CFL(cfl)
     52#domain.set_CFL(cfl)
    5353
    5454#------------------------------------------------------------------------------
  • trunk/anuga_core/validation_tests/reports/all_tests_report.tex

    r9147 r9174  
    9191%======================
    9292
    93 \inputresults{analytical_exact/dam_break_dry}
    94 \inputresults{analytical_exact/dam_break_wet}
    95 \inputresults{analytical_exact/avalanche_dry}
    96 \inputresults{analytical_exact/avalanche_wet}
    97 \inputresults{analytical_exact/carrier_greenspan_periodic}
    98 \inputresults{analytical_exact/carrier_greenspan_transient}
    99 \inputresults{analytical_exact/deep_wave}
    100 \inputresults{analytical_exact/mac_donald_short_channel}
    101 \inputresults{analytical_exact/parabolic_basin}
    102 \inputresults{analytical_exact/paraboloid_basin}
    103 
    104 \inputresults{analytical_exact/runup_on_beach}
    105 \inputresults{analytical_exact/runup_on_sinusoid_beach}
    106 \inputresults{analytical_exact/landslide_tsunami}
    107 
    108 \inputresults{analytical_exact/lake_at_rest_immersed_bump}
    109 \inputresults{analytical_exact/lake_at_rest_steep_island}
    110 \inputresults{analytical_exact/river_at_rest_varying_topo_width}
    111 \inputresults{analytical_exact/rundown_mild_slope}
    112 \inputresults{analytical_exact/rundown_mild_slope_coarse}
    113 \inputresults{analytical_exact/subcritical_over_bump}
    114 \inputresults{analytical_exact/transcritical_with_shock}
    115 \inputresults{analytical_exact/transcritical_without_shock}
    116 \inputresults{analytical_exact/trapezoidal_channel}
     93\inputresults{../analytical_exact/dam_break_dry}
     94\inputresults{../analytical_exact/dam_break_wet}
     95\inputresults{../analytical_exact/avalanche_dry}
     96\inputresults{../analytical_exact/avalanche_wet}
     97\inputresults{../analytical_exact/carrier_greenspan_periodic}
     98\inputresults{../analytical_exact/carrier_greenspan_transient}
     99\inputresults{../analytical_exact/deep_wave}
     100\inputresults{../analytical_exact/mac_donald_short_channel}
     101\inputresults{../analytical_exact/parabolic_basin}
     102\inputresults{../analytical_exact/paraboloid_basin}
     103
     104\inputresults{../analytical_exact/runup_on_beach}
     105\inputresults{../analytical_exact/runup_on_sinusoid_beach}
     106\inputresults{../analytical_exact/landslide_tsunami}
     107
     108\inputresults{../analytical_exact/lake_at_rest_immersed_bump}
     109\inputresults{../analytical_exact/lake_at_rest_steep_island}
     110\inputresults{../analytical_exact/river_at_rest_varying_topo_width}
     111\inputresults{../analytical_exact/rundown_mild_slope}
     112\inputresults{../analytical_exact/rundown_mild_slope_coarse}
     113\inputresults{../analytical_exact/subcritical_over_bump}
     114\inputresults{../analytical_exact/transcritical_with_shock}
     115\inputresults{../analytical_exact/transcritical_without_shock}
     116\inputresults{../analytical_exact/trapezoidal_channel}
    117117
    118118%%======================
    119119\chapter{Tests against reference data or solutions} \label{ch:ref}
    120120%%======================
    121 \inputresults{experimental_data/dam_break_yeh_petroff}
    122 \inputresults{behaviour_only/lid_driven_cavity}
    123 
    124 \inputresults{other_references/radial_dam_break_dry}
    125 \inputresults{other_references/radial_dam_break_wet}
    126 
    127 \inputresults{case_studies/okushiri}
     121\inputresults{../experimental_data/dam_break_yeh_petroff}
     122\inputresults{../behaviour_only/lid_driven_cavity}
     123
     124\inputresults{../other_references/radial_dam_break_dry}
     125\inputresults{../other_references/radial_dam_break_wet}
     126
     127\inputresults{../case_studies/okushiri}
    128128
    129129
     
    151151\section{Algorithm Parameters}
    152152Note that parameters can be communicated from the \verb|local_parameters.py|
    153 file in the \verb|anuga_validation_tests| directory. If there is no file
     153file in the \verb|validation_tests/reports| directory. If there is no file
    154154\verb|local_parameters.py| then the parameters are taken from the
    155 \verb|parameters.py| file. You should not change this file.
     155\verb|anuga.validation_utilities.parameters|.
    156156
    157157In particular the
     
    160160test directories.
    161161
    162 You can pass though the parameters straight from the \verb|parameters.py| file as follows
     162You can pass though the standard parameters as follows
    163163\begin{verbatim}
    164 from anuga_validation_tests.parameters import alg
    165 from anuga_validation_tests.parameters import cfl
     164from anuga.validation_utilities.parameters import alg
     165from anuga.validation_utilities.parameters import cfl
    166166\end{verbatim}
    167167
     
    172172
    173173\begin{verbatim}
    174 from anuga_validation_test_utilities.fabricate import *
    175 from anuga_validation_test_utilities import run_validation_script
     174from anuga.validation_utilities.fabricate import *
     175from anuga.validation_utilities import run_validation_script
    176176
    177177# Setup the python scripts which produce the output for this
     
    180180    run_validation_script('run_problem.py')
    181181    run_validation_script('plot_problem.py')
    182     run('python','latex_report.py')
     182    run('python','typeset_report.py')
    183183    pass
    184184
  • trunk/anuga_core/validation_tests/reports/local-defs.tex

    r9112 r9174  
    33
    44
    5 \newcommand{\inputresults}[1]{\graphicspath{{#1/}}\input{#1/results}}
     5\newcommand{\inputresults}[1]{\graphicspath{{../}{#1/}}\input{#1/results}}
     6%\newcommand{\inputresults}[1]{\graphicspath{{../}}\input{#1/results}}
Note: See TracChangeset for help on using the changeset viewer.