Changeset 8538


Ignore:
Timestamp:
Aug 28, 2012, 4:06:09 PM (12 years ago)
Author:
steve
Message:

added variable ghost_layer_width which is set by the partitioning routine
(distribute) or set to 2

Location:
trunk
Files:
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/documentation/user_manual/demos/cairns/runcairns.py

    r8427 r8538  
    6969tide = 0.0
    7070domain.set_quantity('stage', tide)
    71 domain.set_quantity('friction', 0.0)
     71domain.set_quantity('friction', 0.0)
     72
     73
    7274domain.set_quantity('elevation',
    7375                    filename=project.name_stem + '.pts',
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r8486 r8538  
    3535        Evaluate boundary condition at edges of a domain in a list
    3636        defined by segment_edges
     37       
     38        segment_edges are a sublist of the list of edges definded by the
     39        arrays domain.boundary_cells  and domain.boundary_edges
    3740
    3841        Go through list of boundary objects and update boundary values
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r8505 r8538  
    5353                       numproc=1,
    5454                       number_of_full_nodes=None,
    55                        number_of_full_triangles=None):
     55                       number_of_full_triangles=None,
     56                       ghost_layer_width=2):
    5657
    5758        """Instantiate generic computational Domain.
     
    204205        self.processor = processor
    205206        self.numproc = numproc
     207        self.ghost_layer_width = ghost_layer_width
    206208
    207209        # Setup Communication Buffers
     
    15321534        #self.update_special_conditions()
    15331535
    1534         # Update ghosts
    1535         self.update_ghosts()
    1536 
    15371536        # Update time
    15381537        self.set_time(self.get_time() + self.timestep)
     1538
     1539        # Update ghosts
     1540        if self.ghost_layer_width < 4:
     1541            self.update_ghosts()
    15391542
    15401543        # Update vertex and edge values
     
    16051608        #self.update_special_conditions()
    16061609
     1610        # Update time
     1611        self.set_time(self.time + self.timestep)
     1612
    16071613        # Update ghosts
    16081614        self.update_ghosts()
    1609 
    1610         # Update time
    1611         self.set_time(self.time + self.timestep)
    16121615
    16131616        # Update vertex and edge values
     
    16411644        self.saxpy_conserved_quantities(0.25, 0.75)
    16421645
    1643 
    16441646        # Update special conditions
    16451647        #self.update_special_conditions()
    16461648
     1649        # Set substep time
     1650        self.set_time(initial_time + self.timestep*0.5)
     1651
    16471652        # Update ghosts
    16481653        self.update_ghosts()
    1649 
    1650         # Set substep time
    1651         self.set_time(initial_time + self.timestep*0.5)
    16521654
    16531655        # Update vertex and edge values
  • trunk/anuga_core/source/anuga/config.py

    r8418 r8538  
    9595
    9696# Option to setup compute_fluxes_method
    97 # Currently "original' and 'wb_1' to 'wb_3'
     97# Currently "original' and 'wb_1' to 'wb_3' and 'tsunami'
    9898compute_fluxes_method = 'wb_2'
     99
     100# Option to setup distribute_to_vertices_and_edges_method
     101# Currently "original' and 'tsunami'
     102distribute_to_vertices_and_edges_method = 'original'
    99103
    100104################################################################################
  • trunk/anuga_core/source/anuga/shallow_water/boundaries.py

    r8487 r8538  
    8989
    9090    def evaluate_segment(self, domain, segment_edges):
     91        """Apply reflective BC on the boundary edges defined by
     92        segment_edges
     93        """
    9194
    9295        if segment_edges is None:
     
    120123        n2  = Normals[vol_ids,2*edge_ids+1]
    121124
    122         # Transfer these quantities
     125        # Transfer these quantities to the boundary array
    123126        Stage.boundary_values[ids]  = Stage.edge_values[vol_ids,edge_ids]
    124127        Elev.boundary_values[ids]   = Elev.edge_values[vol_ids,edge_ids]
     
    128131        q1 = Xmom.edge_values[vol_ids,edge_ids]
    129132        q2 = Ymom.edge_values[vol_ids,edge_ids]
    130 
    131         # Rotate
    132         #q[1] = n1 * q1 - n2*q2;
    133         #q[2] = n2 * q1 + n1*q2;
    134133
    135134        r1 = -q1*n1 - q2*n2
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r8500 r8538  
    109109                 numproc=1,
    110110                 number_of_full_nodes=None,
    111                  number_of_full_triangles=None):
     111                 number_of_full_triangles=None,
     112                 ghost_layer_width=2):
    112113        """
    113114            Instantiate a shallow water domain.
     
    163164                            numproc,
    164165                            number_of_full_nodes=number_of_full_nodes,
    165                             number_of_full_triangles=number_of_full_triangles)
     166                            number_of_full_triangles=number_of_full_triangles,
     167                            ghost_layer_width=ghost_layer_width)
    166168
    167169        self.set_defaults()
     
    226228        from anuga.config import use_centroid_velocities
    227229        from anuga.config import compute_fluxes_method
     230        from anuga.config import distribute_to_vertices_and_edges_method
    228231        from anuga.config import sloped_mannings_function
    229232        from anuga.config import flow_algorithm
     
    255258
    256259    def get_algorithm_parameters(self):
    257         """Get the standard parameter that arecurently set (as a dictionary)
     260        """Get the standard parameter that are currently set (as a dictionary)
    258261        """
    259262
     
    271274        parameters['use_sloped_mannings']     = self.use_sloped_mannings
    272275        parameters['compute_fluxes_method']   = self.get_compute_fluxes_method()
     276        parameters['distribute_to_vertices_and_edges_method'] = \
     277                         self.get_distribute_to_vertices_and_edges_method()
    273278        parameters['flow_algorithm']          = self.get_flow_algorithm()
    274279        parameters['CFL']                     = self.get_CFL()
     
    352357           wb_2
    353358           wb_3
    354         """
    355         compute_fluxes_methods = ['original', 'wb_1', 'wb_2', 'wb_3']
     359           tsunami
     360        """
     361        compute_fluxes_methods = ['original', 'wb_1', 'wb_2', 'wb_3', 'tsunami']
    356362
    357363        if flag in compute_fluxes_methods:
     
    375381
    376382
     383
     384    def set_distribute_to_vertices_and_edges_method(self, flag='original'):
     385        """Set method for computing fluxes.
     386
     387        Currently
     388           original
     389           tsunami
     390        """
     391        distribute_to_vertices_and_edges_methods = ['original',  'tsunami']
     392
     393        if flag in distribute_to_vertices_and_edges_methods:
     394            self.distribute_to_vertices_and_edges_method = flag
     395        else:
     396            msg = 'Unknown distribute_to_vertices_and_edges_method. \nPossible choices are:\n'+ \
     397            ', '.join(distribute_to_vertices_and_edges_methods)+'.'
     398            raise Exception(msg)
     399
     400
     401
     402
     403
     404    def get_distribute_to_vertices_and_edges_method(self):
     405        """Get method for distribute_to_vertices_and_edges.
     406
     407        See set_distribute_to_vertices_and_edges_method for possible choices.
     408        """
     409
     410        return self.distribute_to_vertices_and_edges_method
     411
     412
     413
    377414    def set_flow_algorithm(self, flag=1.5):
    378415        """Set combination of slope limiting and time stepping
     
    383420           2
    384421           2.5
     422           tsunami
    385423        """
    386424
     
    390428            flag = str(float(str(flag))).replace(".","_")
    391429
    392         flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_5']
     430        flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_5', 'tsunami']
    393431
    394432        if flag in flow_algorithms:
     
    404442            self.set_default_order(1)
    405443            self.set_CFL(1.0)
     444
     445
    406446
    407447        if self.flow_algorithm == '1_5':
     
    416456            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
    417457            self.set_CFL(1.0)
     458            self.set_compute_fluxes_method('wb_2')
     459            self.set_extrapolate_velocity()
     460
    418461
    419462
     
    429472            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
    430473            self.set_CFL(0.75)
     474            self.set_compute_fluxes_method('wb_2')
     475            self.set_extrapolate_velocity()
    431476
    432477
     
    442487            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
    443488            self.set_CFL(1.0)
     489            self.set_compute_fluxes_method('wb_2')
     490            self.set_extrapolate_velocity()
     491
     492
     493        if self.flow_algorithm == 'tsunami':
     494            self.set_timestepping_method(2)
     495            self.set_default_order(2)
     496            beta_w      = 1.9
     497            beta_w_dry  = 0.2
     498            beta_uh     = 1.9
     499            beta_uh_dry = 0.2
     500            beta_vh     = 1.9
     501            beta_vh_dry = 0.2
     502            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
     503            self.set_CFL(1.0)
     504            self.set_compute_fluxes_method('wb_2')
     505            self.set_extrapolate_velocity()
     506            self.set_distribute_to_vertices_and_edges_method('tsunami')
     507
     508
    444509
    445510        if self.flow_algorithm == '2_5':
     
    454519            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
    455520            self.set_CFL(1.0)
    456 
     521            self.set_compute_fluxes_method('wb_2')
     522            self.set_extrapolate_velocity()
    457523
    458524
     
    469535    def set_gravity_method(self):
    470536        """Gravity method is determined by the compute_fluxes_method
     537        This is now not used, as gravity is combine in the compute_fluxes method
    471538        """
    472539
     
    513580        elif flag is False:
    514581            self.optimise_dry_cells = int(False)
    515 
    516582
    517583
  • trunk/anuga_core/source/anuga_parallel/distribute_mesh.py

    r8537 r8538  
    266266#########################################################
    267267
    268 def submesh_full(nodes, triangles, boundary, triangles_per_proc):
     268def submesh_full(mesh, triangles_per_proc):
    269269
    270270    # Initialise
     271
     272
     273    nodes = mesh.nodes
     274    triangles = mesh.triangles
     275    boundary = mesh.boundary
    271276
    272277    tlower = 0
     
    353358#########################################################
    354359
    355 def ghost_layer(submesh, mesh, p, tupper, tlower):
     360def ghost_layer(submesh, mesh, p, tupper, tlower, parameters = None):
    356361
    357362    ncoord = mesh.number_of_nodes
    358363    ntriangles = mesh.number_of_triangles
    359364
    360 
    361     layer_width = config.ghost_layer_width
    362 
    363     print layer_width
     365    if parameters is None:
     366        layer_width  = 2
     367    else:
     368        layer_width = parameters['ghost_layer_width']
     369
    364370
    365371    trianglemap = num.zeros(ntriangles, 'i')
     
    443449    # Return the triangles and vertices sitting on the boundary layer
    444450
    445     return subnodes, subtriangles
     451    return subnodes, subtriangles, layer_width
    446452
    447453#########################################################
     
    479485def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p):
    480486
     487
     488    boundary = mesh.boundary
     489
    481490    ghost_list = []
    482491    subboundary = {}
    483492
    484493
     494    # FIXME SR: For larger layers need to pass through the correct
     495    # boundary tag!
     496
    485497    for t in ghosttri:
    486498        ghost_list.append(t[0])
     
    490502        n = mesh.neighbours[t[0], 0]
    491503        if not is_in_processor(ghost_list, tlower, tupper, n):
    492             subboundary[t[0], 0] = 'ghost'
     504            if boundary.has_key( (t[0], 0) ):
     505                subboundary[t[0], 0] = boundary[t[0],0]
     506            else:
     507                subboundary[t[0], 0] = 'ghost'
     508
    493509
    494510        n = mesh.neighbours[t[0], 1]
    495511        if not is_in_processor(ghost_list, tlower, tupper, n):
    496             subboundary[t[0], 1] = 'ghost'
     512            if boundary.has_key( (t[0], 1) ):
     513                subboundary[t[0], 1] = boundary[t[0],1]
     514            else:
     515                subboundary[t[0], 1] = 'ghost'
     516
    497517
    498518        n = mesh.neighbours[t[0], 2]
    499519        if not is_in_processor(ghost_list, tlower, tupper, n):
    500             subboundary[t[0], 2] = 'ghost'
     520            if boundary.has_key( (t[0], 2) ):
     521                subboundary[t[0], 2] = boundary[t[0],2]
     522            else:
     523                subboundary[t[0], 2] = 'ghost'
    501524           
    502525    return subboundary
     
    629652#########################################################
    630653
    631 def submesh_ghost(submesh, mesh, triangles_per_proc):
     654def submesh_ghost(submesh, mesh, triangles_per_proc, parameters = None):
    632655
    633656    nproc = len(triangles_per_proc)
     
    637660    ghost_commun = []
    638661    ghost_bnd = []
     662    ghost_layer_width = []
    639663
    640664    # Loop over the processors
     
    648672        # Build the ghost boundary layer
    649673
    650         [subnodes, subtri] = \
    651                    ghost_layer(submesh, mesh, p, tupper, tlower)
     674        [subnodes, subtri, layer_width] = \
     675                   ghost_layer(submesh, mesh, p, tupper, tlower, parameters)
     676        ghost_layer_width.append(layer_width)
    652677        ghost_triangles.append(subtri)
    653678        ghost_nodes.append(subnodes)
     
    671696
    672697    # Record the ghost layer and communication pattern
    673 
     698    submesh["ghost_layer_width"] = ghost_layer_width
    674699    submesh["ghost_nodes"] = ghost_nodes
    675700    submesh["ghost_triangles"] = ghost_triangles
     
    760785#########################################################
    761786
    762 def build_submesh(nodes, triangles, edges, quantities,
    763                   triangles_per_proc):
     787def build_submesh(nodes, triangles, boundary, quantities,
     788                  triangles_per_proc, parameters = None):
    764789
    765790    # Temporarily build the mesh to find the neighbouring
    766791    # triangles and true boundary polygon
    767792
    768     mesh = Mesh(nodes, triangles)
     793    mesh = Mesh(nodes, triangles, boundary)
    769794    boundary_polygon = mesh.get_boundary_polygon()
    770795   
     
    772797    # Subdivide into non-overlapping partitions
    773798
    774     submeshf = submesh_full(nodes, triangles, edges, \
    775                             triangles_per_proc)
     799    submeshf = submesh_full(mesh, triangles_per_proc)
    776800   
    777801    # Add any extra ghost boundary layer information
    778802
    779     submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc)
     803    submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc, parameters)
    780804
    781805    # Order the quantities information to be the same as the triangle
     
    957981    nodes = num.concatenate((submesh["full_nodes"], \
    958982                         submesh["ghost_nodes"]))
     983
     984    ghost_layer_width = submesh["ghost_layer_width"]
    959985   
    960986    # Combine the full triangles and ghost triangles
     
    10091035
    10101036    return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \
    1011            full_send, tri_map, node_map
     1037           full_send, tri_map, node_map, ghost_layer_width
    10121038
    10131039
     
    10511077    myid = pypar.rank()
    10521078   
    1053     if verbose: print 'process %d sending submesh to process %d' %(myid, p)
     1079    if verbose: print 'P%d: Sending submesh to P%d' %(myid, p)
    10541080   
    10551081    # build and send the tagmap for the boundary conditions
     
    10781104    pypar.send(triangles_per_proc, p)
    10791105
     1106    # ghost layer width
     1107
     1108    pypar.send(submesh["ghost_layer_width"][p], p)
     1109
    10801110    # compress full_commun
    10811111
     
    11851215    triangles_per_proc = pypar.receive(p)
    11861216
     1217    # ghost layer width
     1218
     1219    submesh_cell["ghost_layer_width"] = pypar.receive(p)
     1220
    11871221    # recieve information about the array sizes
    11881222
     
    13031337
    13041338    [GAnodes, GAtriangles, boundary, quantities, \
    1305      ghost_rec, full_send, tri_map, node_map] = \
     1339     ghost_rec, full_send, tri_map, node_map, ghost_layer_width] = \
    13061340              build_local_mesh(submesh_cell, lower_t, upper_t, \
    13071341                               numproc)
     
    13091343    return GAnodes, GAtriangles, boundary, quantities,\
    13101344           ghost_rec, full_send,\
    1311            number_of_full_nodes, number_of_full_triangles, tri_map, node_map
     1345           number_of_full_nodes, number_of_full_triangles, tri_map, node_map,\
     1346           ghost_layer_width
    13121347         
    13131348
     
    13321367   
    13331368    submesh_cell = {}
     1369    submesh_cell["ghost_layer_width"] = submesh["ghost_layer_width"][0]
    13341370    submesh_cell["full_nodes"] = submesh["full_nodes"][0]
    13351371    submesh_cell["ghost_nodes"] = submesh["ghost_nodes"][0]
     
    13481384    numprocs = len(triangles_per_proc)
    13491385    points, vertices, boundary, quantities, ghost_recv_dict, \
    1350             full_send_dict, tri_map, node_map = \
     1386            full_send_dict, tri_map, node_map, ghost_layer_width = \
    13511387            build_local_mesh(submesh_cell, 0, triangles_per_proc[0], numprocs)
    13521388
    13531389
    13541390    return  points, vertices, boundary, quantities, ghost_recv_dict, \
    1355            full_send_dict, tri_map, node_map
     1391           full_send_dict, tri_map, node_map, ghost_layer_width
    13561392           
    13571393
  • trunk/anuga_core/source/anuga_parallel/parallel_api.py

    r8518 r8538  
    3636
    3737
    38 def distribute(domain, verbose=False, debug=False):
     38def distribute(domain, verbose=False, debug=False, parameters = None):
    3939    """ Distribute the domain to all processes
    4040    """
     
    112112                ghost_recv_dict, full_send_dict,\
    113113                number_of_full_nodes, number_of_full_triangles,\
    114                 s2p_map, p2s_map, tri_map, node_map =\
    115                 distribute_mesh(domain, verbose=verbose, debug=debug)
    116 
    117 
    118 
    119 
     114                s2p_map, p2s_map, tri_map, node_map, ghost_layer_width =\
     115                distribute_mesh(domain, verbose=verbose, debug=debug, parameters=parameters)
    120116           
    121117        # Extract l2g maps
     
    146142                ghost_recv_dict, full_send_dict,\
    147143                number_of_full_nodes, number_of_full_triangles, \
    148                 tri_map, node_map =\
     144                tri_map, node_map, ghost_layer_width =\
    149145                rec_submesh(0, verbose)
    150146
     
    178174                             p2s_map = p2s_map, ## jj added this
    179175                             tri_l2g = tri_l2g, ## SR added this
    180                              node_l2g = node_l2g)
     176                             node_l2g = node_l2g,
     177                             ghost_layer_width = ghost_layer_width)
    181178
    182179    #------------------------------------------------------------------------
     
    213210
    214211
    215 def distribute_mesh(domain, verbose=False, debug=False):
     212def distribute_mesh(domain, verbose=False, debug=False, parameters=None):
    216213
    217214
     
    236233    if verbose: print 'Build submeshes'   
    237234    submesh = build_submesh(nodes, triangles, boundary,\
    238                             quantities, triangles_per_proc)
     235                            quantities, triangles_per_proc, parameters)
    239236
    240237    if verbose:
     
    257254    # Build the local mesh for processor 0
    258255    points, vertices, boundary, quantities, \
    259             ghost_recv_dict, full_send_dict, tri_map, node_map =\
     256            ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\
    260257              extract_hostmesh(submesh, triangles_per_proc)
    261258
     
    294291           ghost_recv_dict, full_send_dict,\
    295292           number_of_full_nodes, number_of_full_triangles, \
    296            s2p_map, p2s_map, tri_map, node_map
     293           s2p_map, p2s_map, tri_map, node_map, ghost_layer_width
    297294   
    298295
  • trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r8513 r8538  
    4141                 p2s_map=None, #jj added this
    4242                 tri_l2g = None, ## SR added this
    43                  node_l2g = None): ## SR added this
     43                 node_l2g = None, #): ## SR added this
     44                 ghost_layer_width = 2):
    4445
    4546        Domain.__init__(self,
     
    5354                        number_of_full_nodes=number_of_full_nodes,
    5455                        number_of_full_triangles=number_of_full_triangles,
    55                         geo_reference=geo_reference) #jj added this
     56                        geo_reference=geo_reference, #) #jj added this
     57                        ghost_layer_width = ghost_layer_width)
    5658       
    57 
    5859
    5960        self.parallel = True
     
    8990        self.node_l2g = node_l2g
    9091
     92        self.ghost_counter = 0
     93
    9194
    9295    def set_name(self, name):
     
    122125        receive the information for the ghost cells
    123126        """
    124 
     127           
    125128        generic_comms.communicate_ghosts_asynchronous(self)
    126129        #generic_comms.communicate_ghosts_blocking(self)
  • trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py

    r8531 r8538  
    5252
    5353
    54 if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
    55 domain = distribute(domain,verbose=verbose)
     54if myid == 0 and verbose:
     55    print 'DISTRIBUTING DOMAIN'
     56    sys.stdout.flush()
     57   
     58barrier()
    5659
    57 print 'after parallel domain'
     60# setup parameters to test using different ghost_layer_widths
     61parameters = dict(ghost_layer_width = 4)
     62domain = distribute(domain,verbose=verbose, parameters=parameters)
     63
     64if myid == 0 : print 'after parallel domain'
    5865
    5966
     
    6976
    7077
    71 print 'after set_boundary'
     78if myid == 0 : print 'after set_boundary'
    7279
    7380
    7481
    7582domain.check_integrity()
    76 print 'after check_integrity'
     83
     84if myid == 0 : print 'after check_integrity'
    7785
    7886class Set_Stage:
     
    96104
    97105
    98 print 'after set quantity'
     106if myid == 0 : print 'after set quantity'
    99107
    100108# Set Evolve parameters
     
    142150
    143151
    144 
     152domain.dump_triangulation(filename="rectangular_cross_%g.png"% numprocs)
    145153
    146154finalize()
  • trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py

    r8011 r8538  
    4747
    4848
    49         true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
    50 
    51         true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
     49        true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], \
     50        [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], \
     51        [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
     52
     53        true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], \
     54        [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7],
     55        [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
    5256
    5357
     
    7074
    7175
    72         true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
    73 
    74         true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
     76        true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
     77        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
     78
     79        true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], \
     80        [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], \
     81        [7, 12, 4], [8, 12, 7], [5, 12, 8]]
    7582
    7683
     
    9097
    9198
    92         true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
    93 
    94         true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
     99        true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
     100        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
     101
     102        true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], \
     103        [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], \
     104        [7, 12, 4], [8, 12, 7], [5, 12, 8]]
    95105
    96106
     
    113123
    114124
    115         true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
    116 
    117 
    118         true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [4, 10, 1], [3, 11, 4], [4, 11, 7], [4, 12, 5], [1, 10, 2], [5, 10, 4], [2, 10, 5], [6, 11, 3], [7, 11, 6], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
     125        true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
     126        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
     127
     128
     129        true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [4, 10, 1], [3, 11, 4], \
     130        [4, 11, 7], [4, 12, 5], [1, 10, 2], [5, 10, 4], [2, 10, 5], [6, 11, 3], [7, 11, 6], \
     131        [7, 12, 4], [8, 12, 7], [5, 12, 8]]
    119132
    120133
     
    132145        """
    133146
    134         nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
    135 
    136 
    137         triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]
    138 
    139 
    140         edges = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
     147        nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], \
     148        [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
     149
     150
     151        triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], \
     152        [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], \
     153        [6, 11, 3], [7, 11, 6], [4, 11, 7]]
     154
     155
     156        boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', \
     157        (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
    141158
    142159        triangles_per_proc = [5, 6, 5]
     
    222239
    223240       
    224         true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'}, {(5, 1): 'left', (10, 1): 'top', (7, 1): 'left'}, {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}],
     241        true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'},\
     242        {(5, 1): 'left', (10, 1): 'top', (7, 1): 'left'}, \
     243        {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}],
    225244                        'ghost_nodes': [num.array([[  0.  ,   0.  ,   0.  ],
    226245       [  1.  ,   0.  ,   0.5 ],
     
    275294       [ 5,  0,  9,  1],
    276295       [ 6,  1,  9,  4]])],
    277                         'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}],
    278                         'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]],
    279                         'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}],
     296                        'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', \
     297                        (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, \
     298                        {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost',\
     299                        (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', \
     300                        (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}],
     301                        'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], \
     302                        [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], \
     303                        [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]],
     304                        'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, \
     305                        {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, \
     306                        {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}],
    280307                        'ghost_commun': [num.array([[ 5,  1],
    281308       [ 6,  1],
     
    462489        from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
    463490       
    464         mesh = Mesh(nodes, triangles)
     491        mesh = Mesh(nodes, triangles, boundary)
    465492        boundary_polygon = mesh.get_boundary_polygon()
    466493
     
    468495        # Subdivide into non-overlapping partitions
    469496
    470         submesh = submesh_full(nodes, triangles, edges, \
    471                             triangles_per_proc)
     497        submesh = submesh_full(mesh, triangles_per_proc)
    472498
    473499        #print submesh
     
    509535
    510536
    511         #print submesh
     537
     538    def test_build_submesh_3_layer_4(self):
     539        """
     540        Test 3 Layer 4 way build_submesh with ghost_layer_width = 4
     541        """
     542
     543        nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
     544        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
     545
     546
     547        triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], \
     548        [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], \
     549        [6, 11, 3], [7, 11, 6], [4, 11, 7]]
     550
     551
     552        boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', \
     553        (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
     554
     555        """
     556                     top
     557            (10,1)       (4,1)
     558        2 ---------- 5 ---------- 8
     559        | \   10   / | \   04   / |
     560        |   \    /   |   \    /   |
     561 (7,1)  | 07  10  09 | 01  12  03 | (3,1)
     562        |   /    \   |   /    \   |
     563        | /   08   \ | /   02   \ |
     564 left   1 ---------- 4 ---------- 7  right
     565        | \   06   / | \   15   / |
     566        |   \    /   |   \    /   |
     567 (5,1)  | 05  09  00 | 12  11  14 | (14,1)
     568        |   /    \   |   /    \   |
     569        | /   11   \ | /   13   \ |
     570        0 ---------- 3 ---------- 6
     571            (11,1)        (13,1)
     572                   bottom
     573
     574
     575        Processor 0 Full Triangles 00,01,02,03,04
     576        Processor 1 Full Triangles 05,06,07,08,09,10
     577        Processor 2 Full Triangles 11,12,13,14,15
     578        """
     579
     580
     581        triangles_per_proc = [5, 6, 5]
     582
     583
     584
     585
     586        true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'}, {(5, 1): 'left', \
     587        (10, 1): 'top', (7, 1): 'left'}, {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}],
     588                        'ghost_nodes': [num.array([[  0.  ,   0.  ,   0.  ],
     589       [  1.  ,   0.  ,   0.5 ],
     590       [  2.  ,   0.  ,   1.  ],
     591       [  6.  ,   1.  ,   0.  ],
     592       [ 10.  ,   0.25,   0.75],
     593       [ 11.  ,   0.75,   0.25]]), num.array([[  3.  ,   0.5 ,   0.  ],
     594       [  7.  ,   1.  ,   0.5 ],
     595       [  8.  ,   1.  ,   1.  ],
     596       [ 11.  ,   0.75,   0.25],
     597       [ 12.  ,   0.75,   0.75]]), num.array([[  1.  ,   0.  ,   0.5 ],
     598       [  5.  ,   0.5 ,   1.  ],
     599       [  8.  ,   1.  ,   1.  ],
     600       [ 12.  ,   0.75,   0.75]])],
     601                        'full_nodes': [num.array([[  3.  ,   0.5 ,   0.  ],
     602       [  4.  ,   0.5 ,   0.5 ],
     603       [  5.  ,   0.5 ,   1.  ],
     604       [  7.  ,   1.  ,   0.5 ],
     605       [  8.  ,   1.  ,   1.  ],
     606       [  9.  ,   0.25,   0.25],
     607       [ 12.  ,   0.75,   0.75]]), num.array([[  0.  ,   0.  ,   0.  ],
     608       [  1.  ,   0.  ,   0.5 ],
     609       [  2.  ,   0.  ,   1.  ],
     610       [  4.  ,   0.5 ,   0.5 ],
     611       [  5.  ,   0.5 ,   1.  ],
     612       [  9.  ,   0.25,   0.25],
     613       [ 10.  ,   0.25,   0.75]]), num.array([[  0.  ,   0.  ,   0.  ],
     614       [  3.  ,   0.5 ,   0.  ],
     615       [  4.  ,   0.5 ,   0.5 ],
     616       [  6.  ,   1.  ,   0.  ],
     617       [  7.  ,   1.  ,   0.5 ],
     618       [  9.  ,   0.25,   0.25],
     619       [ 11.  ,   0.75,   0.25]])],
     620                        'ghost_triangles': [num.array([[ 5,  0,  9,  1],
     621       [ 6,  1,  9,  4],
     622       [ 8,  4, 10,  1],
     623       [ 9,  5, 10,  4],
     624       [10,  2, 10,  5],
     625       [11,  3,  9,  0],
     626       [12,  3, 11,  4],
     627       [13,  6, 11,  3],
     628       [14,  7, 11,  6],
     629       [15,  4, 11,  7]]), num.array([[ 0,  4,  9,  3],
     630       [ 1,  4, 12,  5],
     631       [ 2,  7, 12,  4],
     632       [ 4,  5, 12,  8],
     633       [11,  3,  9,  0],
     634       [12,  3, 11,  4]]), num.array([[ 0,  4,  9,  3],
     635       [ 1,  4, 12,  5],
     636       [ 2,  7, 12,  4],
     637       [ 3,  8, 12,  7],
     638       [ 5,  0,  9,  1],
     639       [ 6,  1,  9,  4]])],
     640                        'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', \
     641                        (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', \
     642                        (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', \
     643                        (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', \
     644                        (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, \
     645                        {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', \
     646                        (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}],
     647                        'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], \
     648                        [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], \
     649                        [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], \
     650                        [6, 11, 3], [7, 11, 6], [4, 11, 7]]],
     651                        'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, \
     652                        {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, \
     653                        {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}],
     654                        'ghost_commun': [num.array([[ 5,  1],
     655       [ 6,  1],
     656       [ 8,  1],
     657       [ 9,  1],
     658       [10,  1],
     659       [11,  2],
     660       [12,  2],
     661       [13,  2],
     662       [14,  2],
     663       [15,  2]]), num.array([[ 0,  0],
     664       [ 1,  0],
     665       [ 2,  0],
     666       [ 4,  0],
     667       [11,  2],
     668       [12,  2]]), num.array([[0, 0],
     669       [1, 0],
     670       [2, 0],
     671       [3, 0],
     672       [5, 1],
     673       [6, 1]])],  'ghost_quan': {'stage': [num.array([[-0.   , -0.125, -0.   ],
     674       [-0.   , -0.125, -0.25 ],
     675       [-0.25 , -0.125, -0.   ],
     676       [-0.25 , -0.125, -0.25 ],
     677       [-0.   , -0.125, -0.25 ],
     678       [-0.25 , -0.125, -0.   ],
     679       [-0.25 , -0.375, -0.25 ],
     680       [-0.5  , -0.375, -0.25 ],
     681       [-0.5  , -0.375, -0.5  ],
     682       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.25 , -0.125, -0.25 ],
     683       [-0.25 , -0.375, -0.25 ],
     684       [-0.5  , -0.375, -0.25 ],
     685       [-0.25 , -0.375, -0.5  ],
     686       [-0.25 , -0.125, -0.   ],
     687       [-0.25 , -0.375, -0.25 ]]), num.array([[-0.25 , -0.125, -0.25 ],
     688       [-0.25 , -0.375, -0.25 ],
     689       [-0.5  , -0.375, -0.25 ],
     690       [-0.5  , -0.375, -0.5  ],
     691       [-0.   , -0.125, -0.   ],
     692       [-0.   , -0.125, -0.25 ]])],  'elevation': [num.array([[-0.   , -0.125, -0.   ],
     693       [-0.   , -0.125, -0.25 ],
     694       [-0.25 , -0.125, -0.   ],
     695       [-0.25 , -0.125, -0.25 ],
     696       [-0.   , -0.125, -0.25 ],
     697       [-0.25 , -0.125, -0.   ],
     698       [-0.25 , -0.375, -0.25 ],
     699       [-0.5  , -0.375, -0.25 ],
     700       [-0.5  , -0.375, -0.5  ],
     701       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.25 , -0.125, -0.25 ],
     702       [-0.25 , -0.375, -0.25 ],
     703       [-0.5  , -0.375, -0.25 ],
     704       [-0.25 , -0.375, -0.5  ],
     705       [-0.25 , -0.125, -0.   ],
     706       [-0.25 , -0.375, -0.25 ]]), num.array([[-0.25 , -0.125, -0.25 ],
     707       [-0.25 , -0.375, -0.25 ],
     708       [-0.5  , -0.375, -0.25 ],
     709       [-0.5  , -0.375, -0.5  ],
     710       [-0.   , -0.125, -0.   ],
     711       [-0.   , -0.125, -0.25 ]])],  'ymomentum': [num.array([[ 0.  ,  0.25,  0.5 ],
     712       [ 0.5 ,  0.25,  0.5 ],
     713       [ 0.5 ,  0.75,  0.5 ],
     714       [ 1.  ,  0.75,  0.5 ],
     715       [ 1.  ,  0.75,  1.  ],
     716       [ 0.  ,  0.25,  0.  ],
     717       [ 0.  ,  0.25,  0.5 ],
     718       [ 0.  ,  0.25,  0.  ],
     719       [ 0.5 ,  0.25,  0.  ],
     720       [ 0.5 ,  0.25,  0.5 ]]), num.array([[ 0.5 ,  0.25,  0.  ],
     721       [ 0.5 ,  0.75,  1.  ],
     722       [ 0.5 ,  0.75,  0.5 ],
     723       [ 1.  ,  0.75,  1.  ],
     724       [ 0.  ,  0.25,  0.  ],
     725       [ 0.  ,  0.25,  0.5 ]]), num.array([[ 0.5 ,  0.25,  0.  ],
     726       [ 0.5 ,  0.75,  1.  ],
     727       [ 0.5 ,  0.75,  0.5 ],
     728       [ 1.  ,  0.75,  0.5 ],
     729       [ 0.  ,  0.25,  0.5 ],
     730       [ 0.5 ,  0.25,  0.5 ]])],  'friction': [num.array([[ 0.,  0.,  0.],
     731       [ 0.,  0.,  0.],
     732       [ 0.,  0.,  0.],
     733       [ 0.,  0.,  0.],
     734       [ 0.,  0.,  0.],
     735       [ 0.,  0.,  0.],
     736       [ 0.,  0.,  0.],
     737       [ 0.,  0.,  0.],
     738       [ 0.,  0.,  0.],
     739       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
     740       [ 0.,  0.,  0.],
     741       [ 0.,  0.,  0.],
     742       [ 0.,  0.,  0.],
     743       [ 0.,  0.,  0.],
     744       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
     745       [ 0.,  0.,  0.],
     746       [ 0.,  0.,  0.],
     747       [ 0.,  0.,  0.],
     748       [ 0.,  0.,  0.],
     749       [ 0.,  0.,  0.]])], 'xmomentum': [num.array([[ 2.,  2.,  2.],
     750       [ 2.,  2.,  2.],
     751       [ 2.,  2.,  2.],
     752       [ 2.,  2.,  2.],
     753       [ 2.,  2.,  2.],
     754       [ 2.,  2.,  2.],
     755       [ 2.,  2.,  2.],
     756       [ 2.,  2.,  2.],
     757       [ 2.,  2.,  2.],
     758       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
     759       [ 2.,  2.,  2.],
     760       [ 2.,  2.,  2.],
     761       [ 2.,  2.,  2.],
     762       [ 2.,  2.,  2.],
     763       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
     764       [ 2.,  2.,  2.],
     765       [ 2.,  2.,  2.],
     766       [ 2.,  2.,  2.],
     767       [ 2.,  2.,  2.],
     768       [ 2.,  2.,  2.]])]},  'full_quan': {'stage': [num.array([[-0.25 , -0.125, -0.25 ],
     769       [-0.25 , -0.375, -0.25 ],
     770       [-0.5  , -0.375, -0.25 ],
     771       [-0.5  , -0.375, -0.5  ],
     772       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.   , -0.125, -0.   ],
     773       [-0.   , -0.125, -0.25 ],
     774       [-0.   , -0.125, -0.   ],
     775       [-0.25 , -0.125, -0.   ],
     776       [-0.25 , -0.125, -0.25 ],
     777       [-0.   , -0.125, -0.25 ]]), num.array([[-0.25 , -0.125, -0.   ],
     778       [-0.25 , -0.375, -0.25 ],
     779       [-0.5  , -0.375, -0.25 ],
     780       [-0.5  , -0.375, -0.5  ],
     781       [-0.25 , -0.375, -0.5  ]])],  'elevation': [num.array([[-0.25 , -0.125, -0.25 ],
     782       [-0.25 , -0.375, -0.25 ],
     783       [-0.5  , -0.375, -0.25 ],
     784       [-0.5  , -0.375, -0.5  ],
     785       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.   , -0.125, -0.   ],
     786       [-0.   , -0.125, -0.25 ],
     787       [-0.   , -0.125, -0.   ],
     788       [-0.25 , -0.125, -0.   ],
     789       [-0.25 , -0.125, -0.25 ],
     790       [-0.   , -0.125, -0.25 ]]), num.array([[-0.25 , -0.125, -0.   ],
     791       [-0.25 , -0.375, -0.25 ],
     792       [-0.5  , -0.375, -0.25 ],
     793       [-0.5  , -0.375, -0.5  ],
     794       [-0.25 , -0.375, -0.5  ]])],  'ymomentum': [num.array([[ 0.5 ,  0.25,  0.  ],
     795       [ 0.5 ,  0.75,  1.  ],
     796       [ 0.5 ,  0.75,  0.5 ],
     797       [ 1.  ,  0.75,  0.5 ],
     798       [ 1.  ,  0.75,  1.  ]]), num.array([[ 0.  ,  0.25,  0.5 ],
     799       [ 0.5 ,  0.25,  0.5 ],
     800       [ 0.5 ,  0.75,  1.  ],
     801       [ 0.5 ,  0.75,  0.5 ],
     802       [ 1.  ,  0.75,  0.5 ],
     803       [ 1.  ,  0.75,  1.  ]]), num.array([[ 0.  ,  0.25,  0.  ],
     804       [ 0.  ,  0.25,  0.5 ],
     805       [ 0.  ,  0.25,  0.  ],
     806       [ 0.5 ,  0.25,  0.  ],
     807       [ 0.5 ,  0.25,  0.5 ]])],  'friction': [num.array([[ 0.,  0.,  0.],
     808       [ 0.,  0.,  0.],
     809       [ 0.,  0.,  0.],
     810       [ 0.,  0.,  0.],
     811       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
     812       [ 0.,  0.,  0.],
     813       [ 0.,  0.,  0.],
     814       [ 0.,  0.,  0.],
     815       [ 0.,  0.,  0.],
     816       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
     817       [ 0.,  0.,  0.],
     818       [ 0.,  0.,  0.],
     819       [ 0.,  0.,  0.],
     820       [ 0.,  0.,  0.]])],  'xmomentum': [num.array([[ 2.,  2.,  2.],
     821       [ 2.,  2.,  2.],
     822       [ 2.,  2.,  2.],
     823       [ 2.,  2.,  2.],
     824       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
     825       [ 2.,  2.,  2.],
     826       [ 2.,  2.,  2.],
     827       [ 2.,  2.,  2.],
     828       [ 2.,  2.,  2.],
     829       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
     830       [ 2.,  2.,  2.],
     831       [ 2.,  2.,  2.],
     832       [ 2.,  2.,  2.],
     833       [ 2.,  2.,  2.]])]}}
     834
     835
     836        # setup parameters to test using different ghost_layer_widths
     837        parameters = dict(ghost_layer_width = 1)
     838
     839        from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
     840
     841        mesh = Mesh(nodes, triangles, boundary)
     842        boundary_polygon = mesh.get_boundary_polygon()
     843
     844
     845        # Subdivide into non-overlapping partitions
     846
     847        submesh = submesh_full(mesh, triangles_per_proc)
     848
     849
     850
     851        for i in range(3):
     852            assert num.allclose(true_submesh['full_triangles'][i],submesh['full_triangles'][i])
     853            assert num.allclose(true_submesh['full_nodes'][i],submesh['full_nodes'][i])
     854        assert true_submesh['full_boundary'] == submesh['full_boundary']
     855
     856        # Add any extra ghost boundary layer information
     857
     858        submesh = submesh_ghost(submesh, mesh, triangles_per_proc, parameters)
     859
     860        print submesh
     861
     862        print 'ghost_triangles', submesh['ghost_triangles']
     863        print 'ghost_boundary[0]', submesh['ghost_boundary'][0]
     864        print 'ghost_boundary[1]', submesh['ghost_boundary'][1]
     865        print 'ghost_boundary[2]', submesh['ghost_boundary'][2]
     866        print 'ghost_nodes', submesh['ghost_nodes']
     867        print 'ghost_commun', submesh['ghost_commun']
     868       
     869        for i in range(3):
     870            assert num.allclose(true_submesh['ghost_triangles'][i],submesh['ghost_triangles'][i])
     871            assert num.allclose(true_submesh['ghost_nodes'][i],submesh['ghost_nodes'][i])
     872            assert num.allclose(true_submesh['ghost_commun'][i],submesh['ghost_commun'][i])
     873
     874        assert true_submesh['full_commun'] == submesh['full_commun']
     875
     876
     877        # Order the quantities information to be the same as the triangle
     878        # information
     879
     880
     881        submesh = submesh_quantities(submesh, quantities, \
     882                                 triangles_per_proc)
     883
     884
     885
     886        for key, value in true_submesh['ghost_quan'].iteritems():
     887            for i in range(3):
     888                assert num.allclose(true_submesh['ghost_quan'][key][i],submesh['ghost_quan'][key][i])
     889                assert num.allclose(true_submesh['full_quan'][key][i],submesh['full_quan'][key][i])
     890
     891
     892        submesh["boundary_polygon"] = boundary_polygon
     893
     894
     895
     896
    512897
    513898#-------------------------------------------------------------
  • trunk/anuga_work/development/parallel/build_commun.py

    r3460 r8538  
    1717#########################################################
    1818
    19 from Numeric import array, Int, Float, zeros
    20 import logging, logging.config
     19
     20
     21import numpy as num
     22from anuga import indent
     23
     24from numpy import array, zeros
     25import logging
     26import logging.config
    2127logger = logging.getLogger('parallel')
    2228logger.setLevel(logging.WARNING)
     
    104110    # send the triangles
    105111
    106     pypar.send(array(submesh["full_triangles"][p], Int), p, use_buffer=True)
     112    pypar.send(array(submesh["full_triangles"][p], num.int), p, use_buffer=True)
    107113    pypar.send(submesh["ghost_triangles"][p], p, use_buffer=True)
    108114
     
    156162    submesh_cell = {}
    157163   
    158     print 'process %d receiving submesh from process %d' %(myid, p)
     164    print 'P%d: Receiving submesh from P%d' %(myid, p)
    159165
    160166    # receive the tagmap for the boundary conditions
     
    185191
    186192    no_full_nodes = setup_array[0]
    187     full_nodes = zeros((no_full_nodes, 3), Float)
     193    full_nodes = zeros((no_full_nodes, 3), num.float)
    188194    submesh_cell["full_nodes"] = pypar.receive(p, full_nodes)
    189195   
     
    191197
    192198    no_ghost_nodes = setup_array[1]
    193     ghost_nodes = zeros((no_ghost_nodes, 3), Float)
     199    ghost_nodes = zeros((no_ghost_nodes, 3), num.float)
    194200    submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes)
    195201
     
    255261
    256262    no_quantities = len(qkeys)
    257     new_quan = zeros((no_full_triangles, 3), Float)
     263    new_quan = zeros((no_full_triangles, 3), num.float)
    258264    submesh_cell["full_quan"]={}
    259265   
    260266    for i in range(no_quantities):
    261267        tmp = pypar.receive(p, new_quan)
    262         submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), Float)
     268        submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), num.float)
    263269        submesh_cell["full_quan"][qkeys[i]][:] = tmp[:]
    264270
    265     new_quan = zeros((no_ghost_triangles, 3), Float)
     271    new_quan = zeros((no_ghost_triangles, 3), num.float)
    266272    submesh_cell["ghost_quan"]={}
    267273    for i in range(no_quantities):
    268274        tmp = pypar.receive(p, new_quan)
    269         submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), Float)
     275        submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), num.float)
    270276        submesh_cell["ghost_quan"][qkeys[i]][:] = tmp[:]
    271277   
Note: See TracChangeset for help on using the changeset viewer.