Changeset 3928


Ignore:
Timestamp:
Nov 7, 2006, 1:13:03 PM (16 years ago)
Author:
ole
Message:

Parallel domains now store only full triangles in sww files.
Still need to remove ghost nodes.

Location:
anuga_core/source
Files:
12 edited

Legend:

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

    r3926 r3928  
    4747                 processor=0,
    4848                 numproc=1,
    49                  number_of_full_nodes=0,
    50                  number_of_full_triangles=0):
     49                 number_of_full_nodes=None,
     50                 number_of_full_triangles=None):
    5151
    5252
     
    8787
    8888        # Initialise underlying mesh structure
    89         Mesh.__init__(self, coordinates, triangles, boundary,
    90                       tagged_elements, geo_reference, use_inscribed_circle,
     89        Mesh.__init__(self, coordinates, triangles,
     90                      boundary=boundary,
     91                      tagged_elements=tagged_elements,
     92                      geo_reference=geo_reference,
     93                      use_inscribed_circle=use_inscribed_circle,
     94                      number_of_full_nodes=number_of_full_nodes,
     95                      number_of_full_triangles=number_of_full_triangles,
    9196                      verbose=verbose)
    9297
     
    136141        self.numproc = numproc
    137142
    138         self.number_of_full_nodes=number_of_full_nodes
    139         self.number_of_full_triangles=number_of_full_triangles
    140        
    141143
    142144        # Setup Communication Buffers
     
    156158        # =1 for full
    157159        # =0 for ghost
    158         N=self.number_of_elements
     160        N = len(self) #number_of_elements
    159161        self.tri_full_flag = ones(N, Int)
    160162        for i in self.ghost_recv_dict.keys():
     
    206208        #MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array,
    207209        #to be used during the flux calculation
    208         N=self.number_of_elements
     210        N = len(self) #number_of_triangles
    209211        self.already_computed_flux = zeros((N, 3), Int)
    210212
     
    923925        from Numeric import ones, sum, equal, Float
    924926
    925         N = self.number_of_elements
     927        N = len(self) #number_of_triangles
    926928        d = len(self.conserved_quantities)
    927929
  • anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py

    r3689 r3928  
    5656    #input
    5757    def __init__(self, coordinates, triangles,
     58                 number_of_full_nodes=None,
     59                 number_of_full_triangles=None,                 
    5860                 geo_reference=None,
    5961                 verbose=False):
     
    6567        origin is a 3-tuple consisting of UTM zone, easting and northing.
    6668        If specified coordinates are assumed to be relative to this origin.
     69
     70
     71        number_of_full_nodes and number_of_full_triangles relate to
     72        parallelism when each mesh has an extra layer of ghost points and
     73        ghost triangles attached to the end of the two arrays.
     74        In this case it is usefull to specify the number of real (called full)
     75        nodes and triangles. If omitted they will default to all.
    6776        """
    6877
     
    7180        self.triangles = array(triangles,Int)
    7281        self.coordinates = array(coordinates,Float)
    73        
     82
     83        # Register number of elements and nodes
     84        self.number_of_triangles = N = self.triangles.shape[0]
     85        self.number_of_nodes = self.coordinates.shape[0]       
     86
     87       
     88
     89        if number_of_full_nodes is None:
     90            self.number_of_full_nodes=self.number_of_nodes
     91        else:
     92            assert int(number_of_full_nodes)
     93            self.number_of_full_nodes=number_of_full_nodes           
     94
     95
     96        if number_of_full_triangles is None:
     97            self.number_of_full_triangles=self.number_of_triangles           
     98        else:
     99            assert int(number_of_full_triangles)           
     100            self.number_of_full_triangles=number_of_full_triangles
     101       
     102       
     103        #print self.number_of_full_nodes, self.number_of_nodes
     104        #print self.number_of_full_triangles, self.number_of_triangles
     105       
     106           
    74107
    75108        # FIXME: this stores a geo_reference, but when coords are returned
     
    94127        assert max(max(self.triangles)) <= self.coordinates.shape[0], msg
    95128
    96 
    97         # Register number of elements (N)
    98         self.number_of_elements = N = self.triangles.shape[0]
    99129
    100130        # FIXME: Maybe move to statistics?
     
    175205
    176206    def __len__(self):
    177         return self.number_of_elements
     207        return self.number_of_triangles
     208   
    178209
    179210    def __repr__(self):
     
    213244        """
    214245
     246        N = self.number_of_full_nodes
     247
    215248        if unique is True:
    216             V = self.coordinates
     249            V = self.coordinates[:N,:]
    217250            if absolute is True:
    218251                if not self.geo_reference.is_absolute():
     
    227260            if not self.geo_reference.is_absolute():
    228261           
    229                 V0 = self.geo_reference.get_absolute(V[:,0:2])
    230                 V1 = self.geo_reference.get_absolute(V[:,2:4])
    231                 V2 = self.geo_reference.get_absolute(V[:,4:6])
     262                V0 = self.geo_reference.get_absolute(V[:N,0:2])
     263                V1 = self.geo_reference.get_absolute(V[:N,2:4])
     264                V2 = self.geo_reference.get_absolute(V[:N,4:6])
    232265
    233266                # This does double the memory need
     
    262295        #FIXME (Ole) - oh yes they should
    263296
    264         N = self.number_of_elements
     297        N = self.number_of_triangles
    265298        vertex_coordinates = zeros((N, 6), Float)
    266299
     
    279312        """
    280313
    281         if (indices ==  None):
    282             indices = range(len(self))  #len(self)=number of elements
     314        N = self.number_of_full_triangles
     315
     316        if indices is None:
     317            #indices = range(len(self))  #len(self)=number of elements
     318            indices = range(N)
    283319
    284320        return  take(self.triangles, indices)
     321   
    285322
    286323    #FIXME - merge these two (get_vertices and get_triangles)
     
    314351        return unique_verts.keys()
    315352
     353
    316354    def build_vertexlist(self):
    317355        """Build vertexlist index by vertex ids and for each entry (point id)
     
    327365
    328366        vertexlist = [None]*len(self.coordinates)
    329         for i in range(self.number_of_elements):
     367        for i in range(self.number_of_triangles):
    330368
    331369            a = self.triangles[i, 0]
  • anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r3689 r3928  
    6767                 tagged_elements=None,
    6868                 geo_reference=None,
     69                 number_of_full_nodes=None,
     70                 number_of_full_triangles=None,
    6971                 use_inscribed_circle=False,
    7072                 verbose=False):
     
    8082
    8183        General_mesh.__init__(self, coordinates, triangles,
    82                               geo_reference, verbose=verbose)
     84                              number_of_full_nodes=\
     85                              number_of_full_nodes,
     86                              number_of_full_triangles=\
     87                              number_of_full_triangles,
     88                              geo_reference=geo_reference,
     89                              verbose=verbose)
    8390
    8491        if verbose: print 'Initialising mesh'         
    8592
    86         N = self.number_of_elements
     93        N = len(self) #Number_of_triangles
    8794
    8895        self.use_inscribed_circle = use_inscribed_circle
     
    181188    def set_to_inscribed_circle(self,safety_factor = 1):
    182189        #FIXME phase out eventually
    183         N = self.number_of_elements
     190        N = self.number_of_triangles
    184191        V = self.vertex_coordinates
    185192
     
    225232        #to left hand side edge (facing neighbouring triangle)
    226233
    227         N = self.number_of_elements
     234        N = len(self) #Number_of_triangles
    228235        neighbourdict = {}
    229236        for i in range(N):
     
    289296        """
    290297
    291         N = self.number_of_elements
     298        N = len(self) #Number of triangles
    292299        for i in range(N):
    293300            #Find all neighbouring volumes that are not boundaries
     
    314321        if boundary is None:
    315322            boundary = {}
    316             for vol_id in range(self.number_of_elements):
     323            for vol_id in range(len(self)):
    317324                for edge_id in range(0, 3):
    318325                    if self.neighbours[vol_id, edge_id] < 0:
     
    330337
    331338            #Check that all boundary segments are assigned a tag
    332             for vol_id in range(self.number_of_elements):
     339            for vol_id in range(len(self)):
    333340                for edge_id in range(0, 3):
    334341                    if self.neighbours[vol_id, edge_id] < 0:
     
    374381
    375382                msg = 'Not all elements exist. '
    376                 assert max(tagged_elements[tag]) < self.number_of_elements, msg
     383                assert max(tagged_elements[tag]) < len(self), msg
    377384        #print "tagged_elements", tagged_elements
    378385        self.tagged_elements = tagged_elements
     
    584591        from anuga.utilities.numerical_tools import anglediff
    585592
    586         N = self.number_of_elements
     593        N = len(self)
    587594        #Get x,y coordinates for all vertices for all triangles
    588595        V = self.get_vertex_coordinates()
     
    732739        str =  '------------------------------------------------\n'
    733740        str += 'Mesh statistics:\n'
    734         str += '  Number of triangles = %d\n' %self.number_of_elements
     741        str += '  Number of triangles = %d\n' %len(self)
    735742        str += '  Extent [m]:\n'
    736743        str += '    x in [%f, %f]\n' %(min(x), max(x))
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r3918 r3928  
    2929
    3030        if vertex_values is None:
    31             N = domain.number_of_elements
     31            N = len(domain) # number_of_elements
    3232            self.vertex_values = zeros((N, 3), Float)
    3333        else:
     
    4242                  %N
    4343            msg += 'number of elements in specified domain (%d).'\
    44                    %domain.number_of_elements
    45 
    46             assert N == domain.number_of_elements, msg
     44                   %len(domain)
     45
     46            assert N == len(domain), msg
    4747
    4848        self.domain = domain
     
    11351135        """
    11361136        integral = 0
    1137         for k in range(self.domain.number_of_elements):
     1137        for k in range(len(self.domain)):
    11381138            area = self.domain.areas[k]
    11391139            qc = self.centroid_values[k]
     
    11651165        #flux calculations and forcing functions
    11661166
    1167         N = domain.number_of_elements
     1167        N = len(domain) # number_of_triangles
    11681168        self.explicit_update = zeros(N, Float )
    11691169        self.semi_implicit_update = zeros(N, Float )
     
    12931293
    12941294    #Check each triangle
    1295     for k in range(quantity.domain.number_of_elements):
     1295    for k in range(len(quantity.domain)):
    12961296        #Centroid coordinates
    12971297        x, y = quantity.domain.centroid_coordinates[k]
     
    13891389    from Numeric import zeros, Float
    13901390
    1391     N = quantity.domain.number_of_elements
     1391    N = len(quantity.domain)
    13921392
    13931393    beta_w = quantity.domain.beta_w
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r3927 r3928  
    2828        domain = General_mesh(points, vertices)
    2929
    30         print domain.__class__
    3130
    3231        assert allclose(domain.get_vertex_coordinates(unique=True), domain.coordinates)
  • anuga_core/source/anuga/advection/advection.py

    r3567 r3928  
    169169        from anuga.config import max_timestep
    170170
    171         N = self.number_of_elements
     171        N = len(self)
    172172
    173173        neighbours = self.neighbours
     
    260260        from weave import converters
    261261
    262         N = self.number_of_elements
     262        N = len(self)
    263263
    264264
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r3926 r3928  
    213213        #Create filename
    214214        self.filename = create_filename(domain.get_datadir(),
    215             domain.get_name(), extension)
     215                                        domain.get_name(), extension)
    216216
    217217        #print 'F', self.filename
    218218        self.timestep = 0
    219         self.number_of_volumes = len(domain)
    220219        self.domain = domain
     220       
     221
     222
     223        # Exclude ghosts in case this is a parallel domain
     224        self.number_of_nodes = domain.number_of_full_nodes       
     225        self.number_of_volumes = domain.number_of_full_triangles
     226        #self.number_of_volumes = len(domain)       
     227
     228
    221229
    222230
     
    277285            if hasattr(domain, 'texture'):
    278286                fid.texture = domain.texture
    279         #else:
     287            #else:
    280288            #    fid.texture = 'None'
    281289
     
    291299            if domain.smooth is True:
    292300                fid.createDimension('number_of_points', len(domain.vertexlist))
     301                #fid.createDimension('number_of_points', self.number_of_nodes)
     302
     303                # FIXME(Ole): This will cause sww files for paralle domains to
     304                # have ghost nodes stored (but not used by triangles).
     305                # To clean this up, we have to change get_vertex_values and friends in
     306                # quantity.py (but I can't be bothered right now)
    293307            else:
    294308                fid.createDimension('number_of_points', 3*self.number_of_volumes)
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r3926 r3928  
    112112                 processor=0,
    113113                 numproc=1,
    114                  number_of_full_nodes=0,
    115                  number_of_full_triangles=0):
     114                 number_of_full_nodes=None,
     115                 number_of_full_triangles=None):
    116116
    117117
     
    746746    import sys
    747747
    748     N = domain.number_of_elements
     748    N = len(domain) # number_of_triangles
    749749
    750750    #Shortcuts
     
    820820    import sys
    821821
    822     N = domain.number_of_elements
     822    N = len(domain) # number_of_triangles
    823823
    824824    #Shortcuts
     
    848848    import sys
    849849
    850     N = domain.number_of_elements
     850    N = len(domain) # number_of_triangles
    851851
    852852    #Shortcuts
     
    960960
    961961    #Update
    962     #FIXME: Modify accroditg to c-version - or discard altogether.
    963     for k in range(domain.number_of_elements):
     962    #FIXME: Modify according to c-version - or discard altogether.
     963    for k in range(len(domain)):
    964964
    965965        if hc[k] < domain.minimum_allowed_height:
     
    999999    """
    10001000
    1001     N = domain.number_of_elements
     1001    N = len(domain)
    10021002    beta_h = domain.beta_h
    10031003
     
    10691069    """
    10701070
    1071     N = domain.number_of_elements
     1071    N = len(domain) # number_of_triangles
    10721072    beta_h = domain.beta_h
    10731073
     
    11141114    hvbar = h_limiter(domain)
    11151115
    1116     for k in range(domain.number_of_elements):
     1116    for k in range(len(domain)):
    11171117        #Compute maximal variation in bed elevation
    11181118        #  This quantitiy is
     
    14021402    g = domain.g
    14031403
    1404     for k in range(domain.number_of_elements):
     1404    for k in range(len(domain)):
    14051405        avg_h = sum( h[k,:] )/3
    14061406
     
    14541454    ymom_update = domain.quantities['ymomentum'].semi_implicit_update
    14551455
    1456     N = domain.number_of_elements
     1456    N = len(domain)
    14571457    eps = domain.minimum_allowed_height
    14581458    g = domain.g
     
    14891489    ymom_update = ymom.semi_implicit_update
    14901490
    1491     N = domain.number_of_elements
     1491    N = len(domain)
    14921492    eps = domain.minimum_allowed_height
    14931493    g = domain.g
     
    15161516    ymom_update = ymom.explicit_update
    15171517
    1518     N = domain.number_of_elements
     1518    N = len(domain)
    15191519    eps = domain.minimum_allowed_height
    15201520    g = domain.g
     
    15431543    ymom_update = domain.quantities['ymomentum'].semi_implicit_update
    15441544
    1545     N = domain.number_of_elements
     1545    N = len(domain) # number_of_triangles
    15461546    eps = domain.minimum_allowed_height
    15471547    g = domain.g #Not necessary? Why was this added?
     
    16811681        ymom_update = domain.quantities['ymomentum'].explicit_update
    16821682
    1683         N = domain.number_of_elements
     1683        N = len(domain) # number_of_triangles
    16841684        t = domain.time
    16851685
     
    17671767    #Computed linear combination between constant stages and and
    17681768    #stages parallel to the bed elevation.
    1769     for k in range(domain.number_of_elements):
     1769    for k in range(len(domain)):
    17701770        #Compute maximal variation in bed elevation
    17711771        #  This quantitiy is
     
    20342034    from Numeric import zeros, Float
    20352035
    2036     N = domain.number_of_elements
     2036    N = len(domain) # number_of_triangles
    20372037
    20382038    #Shortcuts
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r3847 r3928  
    13111311        const = eta_w*rho_a/rho_w
    13121312
    1313         N = domain.number_of_elements
     1313        N = len(domain) # number_of_triangles
    13141314
    13151315        xc = domain.get_centroid_coordinates()
     
    14271427        const = eta_w*rho_a/rho_w
    14281428
    1429         N = domain.number_of_elements
     1429        N = len(domain) # number_of_triangles
    14301430
    14311431        t = domain.time
     
    19221922        #Assert that quantities are conserved
    19231923        from Numeric import sum
    1924         for k in range(mesh.number_of_elements):
     1924        for k in range(len(mesh)):
    19251925            assert allclose (ref_centroid_values[k],
    19261926                             sum(stage.vertex_values[k,:])/3)
     
    19441944
    19451945        #Assert that all vertex quantities have changed
    1946         for k in range(mesh.number_of_elements):
     1946        for k in range(len(mesh)):
    19471947            #print ref_vertex_values[k,:], stage.vertex_values[k,:]
    19481948            assert not allclose (ref_vertex_values[k,:], stage.vertex_values[k,:])
    19491949        #and assert that quantities are still conserved
    19501950        from Numeric import sum
    1951         for k in range(mesh.number_of_elements):
     1951        for k in range(len(mesh)):
    19521952            assert allclose (ref_centroid_values[k],
    19531953                             sum(stage.vertex_values[k,:])/3)
     
    22122212
    22132213            #print t, volume, initial_volume
    2214 
    2215 
    2216             #if not allclose (volume, initial_volume):
    2217             #    print 't==4.05'
    2218             #    for k in range(domain.number_of_elements):
    2219             #       pass
    2220             #       print domain.quantities['stage'].centroid_values[k] -\
    2221             #             ref_centroid_values[k]
    22222214
    22232215            assert allclose (volume, initial_volume)
  • anuga_core/source/anuga_parallel/parallel_api.py

    r3926 r3928  
    171171
    172172    for p in range(numprocs):
     173        N = len(submesh['ghost_nodes'][p])               
    173174        M = len(submesh['ghost_triangles'][p])
    174         print 'There are %d ghost triangles on proc %d' %(M, p)
    175         N = len(submesh['ghost_nodes'][p])
    176         print 'There are %d ghost nodes on proc %d' %(N, p)
     175        print 'There are %d ghost nodes and %d ghost triangles on proc %d'\
     176              %(N, M, p)
    177177
    178178
  • anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r3926 r3928  
    3434                 full_send_dict=None,
    3535                 ghost_recv_dict=None,
    36                  number_of_full_nodes=0,
    37                  number_of_full_triangles=0):
     36                 number_of_full_nodes=None,
     37                 number_of_full_triangles=None):
    3838
    3939        Domain.__init__(self,
     
    4848                        number_of_full_triangles=number_of_full_triangles)
    4949
    50         N = self.number_of_elements
     50        N = len(self) # number_of_triangles
    5151
    5252#        self.processor = pypar.rank()
  • anuga_core/source/anuga_parallel/test_parallel_sw_runup.py

    r3926 r3928  
    9696        local_interpolation_points.append(i)
    9797
    98 # Hack
     98# Hack before we excluded ghosts.
    9999if numprocs == 2:
    100100    if myid == 0:
    101101        del local_interpolation_points[0]               
    102102        #local_interpolation_points = [1,2,3]
    103 
    104103if numprocs == 3:
    105104    if myid == 1:
    106105        del local_interpolation_points[0]
    107 
    108 
    109106if numprocs == 4:
    110107    if myid == 0:
     
    122119
    123120for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0):
    124     #domain.write_time()
    125 
     121    domain.write_time()
    126122   
    127123    # Record time series at known points
Note: See TracChangeset for help on using the changeset viewer.