Changeset 1563


Ignore:
Timestamp:
Jun 30, 2005, 5:41:44 PM (19 years ago)
Author:
steve
Message:
 
Location:
inundation/ga/storm_surge
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/parallel/build_local.py

    r1549 r1563  
    103103    for c in ghostc:
    104104        if not ghost_recv.has_key(c[1]):
    105             ghost_recv[c[1]] = [0, 0, 0]
     105            ghost_recv[c[1]] = [0, 0]
    106106            ghost_recv[c[1]][0] = []
    107107            ghost_recv[c[1]][1] = []
    108             ghost_recv[c[1]][2] = []
    109108        ghost_recv[c[1]][0].append(index[c[0]])
    110109        ghost_recv[c[1]][1].append(c[0])
    111         ghost_recv[c[1]][2].append(0.0)
     110
    112111
    113112    # build a temporary copy of the full_send dictionary
     
    129128        neigh_commun = tmp_send[neigh]
    130129        neigh_commun.sort(sort_tup)
    131         full_send[neigh] = [0, 0, 0]
     130        full_send[neigh] = [0, 0]
    132131        full_send[neigh][0] = []
    133132        full_send[neigh][1] = []
    134         full_send[neigh][2] = []
    135133        for t in neigh_commun:
    136134            full_send[neigh][0].append(t[1])
    137135            full_send[neigh][1].append(t[0])
    138             full_send[neigh][2].append(0.0)
     136
    139137
    140138
     
    143141        full_send[key][0] = array(full_send[key][0],Int)
    144142        full_send[key][1] = array(full_send[key][1],Int)
    145         full_send[key][2] = array(full_send[key][2],Float)
     143
    146144
    147145    for key in ghost_recv:
    148146        ghost_recv[key][0] = array(ghost_recv[key][0],Int)
    149147        ghost_recv[key][1] = array(ghost_recv[key][1],Int)
    150         ghost_recv[key][2] = array(ghost_recv[key][2],Float)
     148
    151149
    152150
  • inundation/ga/storm_surge/parallel/parallel_advection.py

    r1558 r1563  
    1111
    1212Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
    13 Geoscience Australia, 2004
     13Geoscience Australia, 2004-2005
    1414"""
    1515
     
    3737        self.processor = pypar.rank()
    3838        self.numproc   = pypar.size()
    39         #print 'Processor %d'%self.processor
    40         #velocity = [(self.processor+1),0.0]
    41 
    42         #print 'velocity',velocity
    4339
    4440        Advection_Domain.__init__(self, coordinates, vertices, boundary,
     
    5046        self.numproc   = pypar.size()
    5147
     48
     49        # Setup Communication Buffers
     50        self.nsys = 1
     51        for key in full_send_dict:
     52            buffer_shape = full_send_dict[key][0].shape[0]
     53            full_send_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     54
     55
     56        for key in ghost_recv_dict:
     57            buffer_shape = ghost_recv_dict[key][0].shape[0]
     58            ghost_recv_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     59
    5260        self.full_send_dict  = full_send_dict
    53 #        for key in self.full_send_dict:
    54 #            self.full_send_dict[key][0] = array(self.full_send_dict[key][0],Int)
    55 #            self.full_send_dict[key][2] = array(self.full_send_dict[key][2],Float)
    56 
    57 
    5861        self.ghost_recv_dict = ghost_recv_dict
    59 #        for key in self.ghost_recv_dict:
    60 #            self.ghost_recv_dict[key][0] = array(self.ghost_recv_dict[key][0],Int)
    61 #            self.ghost_recv_dict[key][2] = array(self.ghost_recv_dict[key][2],Float)
    6262
    6363        self.communication_time = 0.0
    6464        self.communication_reduce_time = 0.0
    6565
    66         #print self.full_send_dict
    67         #print self.ghost_recv_dict
    68 
    6966    def check_integrity(self):
    7067        Advection_Domain.check_integrity(self)
     
    7269        msg = 'Will need to check global and local numbering'
    7370        assert self.conserved_quantities[0] == 'stage', msg
    74 
    75 
    7671
    7772    def update_timestep(self, yieldstep, finaltime):
     
    10095        self.communication_reduce_time += time.time()-t0
    10196
     97
    10298    def update_ghosts(self):
    103 
    104         self.update_ghosts_second()
    105 
    106 
    107     def update_ghosts_second(self):
    10899
    109100        # We must send the information from the full cells and
     
    132123                        Xout = self.full_send_dict[send_proc][2]
    133124
    134                         N = len(Xout)
     125                        N = len(Idf)
    135126
    136127
     
    138129                        # Original python Code
    139130                        for i in range(N):
    140                             Xout[i] = stage_cv[Idf[i]]
     131                            Xout[i,0] = stage_cv[Idf[i]]
    141132                        #==============================
    142133
     
    147138                        code1 = """
    148139                        for (int i=0; i<N ; i++){
    149                             Xout(i) = stage_cv(Idf(i));
     140                            Xout(i,0) = stage_cv(Idf(i));
    150141                        }
    151142                        """
     
    166157
    167158                    X = pypar.receive(iproc,X)
    168                     N = len(X)
     159                    N = len(Idg)
    169160
    170161                    #LINDA: had problems getting C code to work
     
    174165                    # Origin Python Code
    175166                    for i in range(N):
    176                         stage_cv[Idg[i]] = X[i]
     167                        stage_cv[Idg[i]] = X[i,0]
    177168                    #===========================
    178169
     
    180171                    code2 = """
    181172                    for (int i=0; i<N; i++){
    182                         stage_cv(Idg(i)) = X(i);
     173                        stage_cv(Idg(i)) = X(i,0);
    183174                    }
    184175                    """
     
    216207            #weave.inline(code3, ['stage_cv','Idg','Idf','N'],
    217208            #                     type_converters = converters.blitz, compiler='gcc');
    218 
    219         self.communication_time += time.time()-t0
    220 
    221 
    222 #        if self.ghosts is not None:
    223 #            stage_cv = self.quantities['stage'].centroid_values
    224 #            for triangle in self.ghosts:
    225 #                stage_cv[triangle] = stage_cv[self.ghosts[triangle]]
    226 
    227     def update_ghosts_first(self):
    228 
    229         # We must send the information from the full cells and
    230         # receive the information for the ghost cells
    231         # We have a dictionary of lists with ghosts expecting updates from
    232         # the separate processors
    233 
    234         import weave
    235         from weave import converters
    236 
    237         import time
    238         t0 = time.time()
    239 
    240 
    241         stage_cv = self.quantities['stage'].centroid_values
    242 
    243         for send_proc in self.full_send_dict:
    244             if send_proc != self.processor:
    245                 Idf  = self.full_send_dict[send_proc][0]
    246                 Xout = self.full_send_dict[send_proc][1]
    247                 N = len(Xout)
    248 
    249 
    250                 #==============================
    251                 # Original python Code
    252                 for i in range(N):
    253                     Xout[i] = stage_cv[Idf[i]]
    254                 #==============================
    255 
    256 
    257 #                code1 = """
    258 #                for (int i=0; i<N ; i++){
    259 #                     Xout(i) = stage_cv(Idf(i));
    260 #                }
    261 #                """
    262 #                weave.inline(code1, ['stage_cv','Idf','Xout','N'],
    263 #                             type_converters = converters.blitz, compiler='gcc');
    264 
    265                 pypar.send(Xout,send_proc)
    266 
    267 
    268         #Receive data from the iproc processor
    269         for recv_proc in self.ghost_recv_dict:
    270             if recv_proc != self.processor:
    271                 Idg = self.ghost_recv_dict[recv_proc][0]
    272                 X   = self.ghost_recv_dict[recv_proc][1]
    273 
    274                 X = pypar.receive(recv_proc,X)
    275                 N = len(X)
    276 
    277 
    278                 #===========================
    279                 # Origin Python Code
    280                 for i in range(N):
    281                     stage_cv[Idg[i]] = X[i]
    282                 #===========================
    283 
    284 
    285 #                code2 = """
    286 #                for (int i=0; i<N; i++){
    287 #                    stage_cv(Idg(i)) = X(i);
    288 #                }
    289 #                """
    290 #                weave.inline(code2, ['stage_cv','Idg','X','N'],
    291 #                             type_converters = converters.blitz, compiler='gcc');
    292 
    293 
    294         #local update of ghost cells
    295         iproc = self.processor
    296         if self.full_send_dict.has_key(iproc):
    297             Idf  = self.full_send_dict[iproc][0]
    298             #print Idf
    299             Idg  = self.ghost_recv_dict[iproc][0]
    300             N = len(Idg)
    301             #print Idg
    302 
    303 
    304             #======================================
    305             # Original python loop
    306             for i in range(N):
    307                 #print i,Idg[i],Idf[i]
    308                 stage_cv[Idg[i]] = stage_cv[Idf[i]]
    309             #======================================
    310 
    311 
    312 #            code3 = """
    313 #            for (int i=0; i<N; i++){
    314 #                stage_cv(Idg(i)) = stage_cv(Idf(i));
    315 #            }
    316 #            """
    317 #            weave.inline(code3, ['stage_cv','Idg','Idf','N'],
    318 #                                 type_converters = converters.blitz, compiler='gcc');
    319 
    320209
    321210        self.communication_time += time.time()-t0
     
    353242            yield(t)
    354243
    355 
  • inundation/ga/storm_surge/parallel/parallel_meshes.py

    r1520 r1563  
    1717
    1818
    19 def parallel_rectangular(m_g, n_g, len1_g=1.0, len2_g=1.0, origin_g = (0.0, 0.0)):
     19def parallel_rectangle(m_g, n_g, len1_g=1.0, len2_g=1.0, origin_g = (0.0, 0.0)):
    2020
    2121
     
    9292    boundary = {}
    9393    Idgl = []
    94     Xgl  = []
    9594    Idfl = []
    96     Xfl  = []
    9795    Idgr = []
    98     Xgr  = []
    9996    Idfr = []
    100     Xfr  = []
    10197
    10298    full_send_dict = {}
     
    152148
    153149    if numproc==1:
    154         #print Idfl
    155         #print Idfr
    156150        Idfl.extend(Idfr)
    157         #print Idfl
    158151        Idgr.extend(Idgl)
    159152        Idfl = array(Idfl,Int)
    160153        Idgr = array(Idgr,Int)
    161         Xf   = zeros(Idfl.shape,Float)
    162         Xg   = zeros(Idgr.shape,Float)
    163         full_send_dict[processor]  = [Idfl, Idfl, Xf]
    164         ghost_recv_dict[processor] = [Idgr, Idgr, Xg]
     154        full_send_dict[processor]  = [Idfl, Idfl]
     155        ghost_recv_dict[processor] = [Idgr, Idgr]
    165156    elif numproc == 2:
    166157        Idfl.extend(Idfr)
    167158        Idgr.extend(Idgl)
    168         #print Idfl
    169159        Idfl = array(Idfl,Int)
    170160        Idgr = array(Idgr,Int)
    171         Xf   = zeros(Idfl.shape,Float)
    172         Xg   = zeros(Idgr.shape,Float)
    173         full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl, Xf]
    174         ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr, Xg]
     161        full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl]
     162        ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr]
    175163    else:
    176164        Idfl = array(Idfl,Int)
    177165        Idgl = array(Idgl,Int)
    178         Xfl  = zeros(Idfl.shape,Float)
    179         Xgl  = zeros(Idgl.shape,Float)
    180166
    181167        Idfr = array(Idfr,Int)
    182168        Idgr = array(Idgr,Int)
    183         Xfr  = zeros(Idfr.shape,Float)
    184         Xgr  = zeros(Idgr.shape,Float)
    185 
    186         full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl, Xfl]
    187         ghost_recv_dict[(processor-1)%numproc] = [Idgl, Idgl, Xgl]
    188         full_send_dict[(processor+1)%numproc]  = [Idfr, Idfr, Xfr]
    189         ghost_recv_dict[(processor+1)%numproc] = [Idgr, Idgr, Xgr]
     169
     170        full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl]
     171        ghost_recv_dict[(processor-1)%numproc] = [Idgl, Idgl]
     172        full_send_dict[(processor+1)%numproc]  = [Idfr, Idfr]
     173        ghost_recv_dict[(processor+1)%numproc] = [Idgr, Idgr]
    190174
    191175    return  points, elements, boundary, full_send_dict, ghost_recv_dict
  • inundation/ga/storm_surge/parallel/parallel_shallow_water.py

    r1558 r1563  
    3333
    3434    def __init__(self, coordinates, vertices, boundary = None,
    35                  full_send_dict = None, ghost_recv_dict = None,
    36                  velocity = None):
     35                 full_send_dict = None, ghost_recv_dict = None):
    3736
    3837        self.processor = pypar.rank()
    3938        self.numproc   = pypar.size()
    40         #print 'Processor %d'%self.processor
    41         #velocity = [(self.processor+1),0.0]
    42 
    43         #print 'velocity',velocity
    44 
    45         Advection_Domain.__init__(self, coordinates, vertices, boundary,
    46                                   velocity = velocity)
     39
     40        Shallow_Water_Domain.__init__(self, coordinates, vertices, boundary)
    4741
    4842        N = self.number_of_elements
     
    5145        self.numproc   = pypar.size()
    5246
     47        # Setup Communication Buffers
     48        self.nsys = 3
     49        for key in full_send_dict:
     50            buffer_shape = full_send_dict[key][0].shape[0]
     51            full_send_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     52
     53
     54        for key in ghost_recv_dict:
     55            buffer_shape = ghost_recv_dict[key][0].shape[0]
     56            ghost_recv_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     57
    5358        self.full_send_dict  = full_send_dict
    54 #        for key in self.full_send_dict:
    55 #            self.full_send_dict[key][0] = array(self.full_send_dict[key][0],Int)
    56 #            self.full_send_dict[key][2] = array(self.full_send_dict[key][2],Float)
    57 
    58 
    5959        self.ghost_recv_dict = ghost_recv_dict
    60 #        for key in self.ghost_recv_dict:
    61 #            self.ghost_recv_dict[key][0] = array(self.ghost_recv_dict[key][0],Int)
    62 #            self.ghost_recv_dict[key][2] = array(self.ghost_recv_dict[key][2],Float)
     60
    6361
    6462        self.communication_time = 0.0
    6563        self.communication_reduce_time = 0.0
    6664
    67         #print self.full_send_dict
    68         #print self.ghost_recv_dict
     65
    6966
    7067    def check_integrity(self):
    71         Advection_Domain.check_integrity(self)
     68        Shallow_Water_Domain.check_integrity(self)
    7269
    7370        msg = 'Will need to check global and local numbering'
    7471        assert self.conserved_quantities[0] == 'stage', msg
     72        assert self.conserved_quantities[1] == 'xmomentum', msg
     73        assert self.conserved_quantities[2] == 'ymomentum', msg
    7574
    7675
     
    7978
    8079        # Calculate local timestep
    81         Advection_Domain.update_timestep(self, yieldstep, finaltime)
     80        Shallow_Water_Domain.update_timestep(self, yieldstep, finaltime)
    8281
    8382        import time
     
    101100        self.communication_reduce_time += time.time()-t0
    102101
     102
    103103    def update_ghosts(self):
    104 
    105         self.update_ghosts_second()
    106 
    107 
    108     def update_ghosts_second(self):
    109104
    110105        # We must send the information from the full cells and
     
    119114        t0 = time.time()
    120115
    121         stage_cv = self.quantities['stage'].centroid_values
     116        stage_cv     = self.quantities['stage'].centroid_values
     117        xmomentum_cv = self.quantities['xmomentum'].centroid_values
     118        ymomentum_cv = self.quantities['ymomentum'].centroid_values
    122119
    123120        # update of non-local ghost cells
     
    127124                for send_proc in self.full_send_dict:
    128125                    if send_proc != iproc:
    129                         # LINDA:
    130                         # now store full as local id, global_id, value
    131126
    132127                        Idf  = self.full_send_dict[send_proc][0]
    133128                        Xout = self.full_send_dict[send_proc][2]
    134129
    135                         N = len(Xout)
    136 
    137 
    138                         #==============================
    139                         # Original python Code
     130                        N = len(Idf)
     131
    140132                        for i in range(N):
    141                             Xout[i] = stage_cv[Idf[i]]
    142                         #==============================
    143 
    144 
    145                         #LINDA:
    146                         #could not get the code below to work, kept on complaining about error: no match for call to `(py::list) (int&)'
    147 
    148                         code1 = """
    149                         for (int i=0; i<N ; i++){
    150                             Xout(i) = stage_cv(Idf(i));
    151                         }
    152                         """
    153                         #weave.inline(code1, ['stage_cv','Idf','Xout','N'],
    154                         #             type_converters = converters.blitz, compiler='gcc');
     133                            Xout[i,0] = stage_cv[Idf[i]]
     134                            Xout[i,1] = xmomentum_cv[Idf[i]]
     135                            Xout[i,2] = ymomentum_cv[Idf[i]]
     136
    155137
    156138                        pypar.send(Xout,send_proc)
     
    161143                if  self.ghost_recv_dict.has_key(iproc):
    162144
    163                     # LINDA:
    164                     # now store ghost as local id, global id, value
    165145                    Idg = self.ghost_recv_dict[iproc][0]
    166146                    X = self.ghost_recv_dict[iproc][2]
    167147
    168148                    X = pypar.receive(iproc,X)
    169                     N = len(X)
    170 
    171                     #LINDA: had problems getting C code to work
    172 
    173 
    174                     #===========================
    175                     # Origin Python Code
     149                    N = len(Idg)
     150
    176151                    for i in range(N):
    177                         stage_cv[Idg[i]] = X[i]
    178                     #===========================
    179 
    180 
    181                     code2 = """
    182                     for (int i=0; i<N; i++){
    183                         stage_cv(Idg(i)) = X(i);
    184                     }
    185                     """
    186 #                    weave.inline(code2, ['stage_cv','Idg','X','N'],
    187 #                                 type_converters = converters.blitz, compiler='gcc');
     152                        stage_cv[Idg[i]]     = X[i,0]
     153                        xmomentum_cv[Idg[i]] = X[i,1]
     154                        ymomentum_cv[Idg[i]] = X[i,2]
     155
    188156
    189157        #local update of ghost cells
     
    201169            N = len(Idg)
    202170
    203 
    204             #======================================
    205             # Original python loop
    206171            for i in range(N):
    207                 #print i,Idg[i],Idf[i]
    208                 stage_cv[Idg[i]] = stage_cv[Idf[i]]
    209             #======================================
    210 
    211 
    212             code3 = """
    213             for (int i=0; i<N; i++){
    214                 stage_cv(Idg(i)) = stage_cv(Idf(i));
    215             }
    216             """
    217             #weave.inline(code3, ['stage_cv','Idg','Idf','N'],
    218             #                     type_converters = converters.blitz, compiler='gcc');
    219 
    220         self.communication_time += time.time()-t0
    221 
    222 
    223 #        if self.ghosts is not None:
    224 #            stage_cv = self.quantities['stage'].centroid_values
    225 #            for triangle in self.ghosts:
    226 #                stage_cv[triangle] = stage_cv[self.ghosts[triangle]]
    227 
    228     def update_ghosts_first(self):
    229 
    230         # We must send the information from the full cells and
    231         # receive the information for the ghost cells
    232         # We have a dictionary of lists with ghosts expecting updates from
    233         # the separate processors
    234 
    235         import weave
    236         from weave import converters
    237 
    238         import time
    239         t0 = time.time()
    240 
    241 
    242         stage_cv = self.quantities['stage'].centroid_values
    243 
    244         for send_proc in self.full_send_dict:
    245             if send_proc != self.processor:
    246                 Idf  = self.full_send_dict[send_proc][0]
    247                 Xout = self.full_send_dict[send_proc][1]
    248                 N = len(Xout)
    249 
    250 
    251                 #==============================
    252                 # Original python Code
    253                 for i in range(N):
    254                     Xout[i] = stage_cv[Idf[i]]
    255                 #==============================
    256 
    257 
    258 #                code1 = """
    259 #                for (int i=0; i<N ; i++){
    260 #                     Xout(i) = stage_cv(Idf(i));
    261 #                }
    262 #                """
    263 #                weave.inline(code1, ['stage_cv','Idf','Xout','N'],
    264 #                             type_converters = converters.blitz, compiler='gcc');
    265 
    266                 pypar.send(Xout,send_proc)
    267 
    268 
    269         #Receive data from the iproc processor
    270         for recv_proc in self.ghost_recv_dict:
    271             if recv_proc != self.processor:
    272                 Idg = self.ghost_recv_dict[recv_proc][0]
    273                 X   = self.ghost_recv_dict[recv_proc][1]
    274 
    275                 X = pypar.receive(recv_proc,X)
    276                 N = len(X)
    277 
    278 
    279                 #===========================
    280                 # Origin Python Code
    281                 for i in range(N):
    282                     stage_cv[Idg[i]] = X[i]
    283                 #===========================
    284 
    285 
    286 #                code2 = """
    287 #                for (int i=0; i<N; i++){
    288 #                    stage_cv(Idg(i)) = X(i);
    289 #                }
    290 #                """
    291 #                weave.inline(code2, ['stage_cv','Idg','X','N'],
    292 #                             type_converters = converters.blitz, compiler='gcc');
    293 
    294 
    295         #local update of ghost cells
    296         iproc = self.processor
    297         if self.full_send_dict.has_key(iproc):
    298             Idf  = self.full_send_dict[iproc][0]
    299             #print Idf
    300             Idg  = self.ghost_recv_dict[iproc][0]
    301             N = len(Idg)
    302             #print Idg
    303 
    304 
    305             #======================================
    306             # Original python loop
    307             for i in range(N):
    308                 #print i,Idg[i],Idf[i]
    309                 stage_cv[Idg[i]] = stage_cv[Idf[i]]
    310             #======================================
    311 
    312 
    313 #            code3 = """
    314 #            for (int i=0; i<N; i++){
    315 #                stage_cv(Idg(i)) = stage_cv(Idf(i));
    316 #            }
    317 #            """
    318 #            weave.inline(code3, ['stage_cv','Idg','Idf','N'],
    319 #                                 type_converters = converters.blitz, compiler='gcc');
    320 
     172                stage_cv[Idg[i]]     = stage_cv[Idf[i]]
     173                xmomentum_cv[Idg[i]] = xmomentum_cv[Idf[i]]
     174                ymomentum_cv[Idg[i]] = ymomentum_cv[Idf[i]]
    321175
    322176        self.communication_time += time.time()-t0
     
    339193
    340194
    341 
    342195    def evolve(self, yieldstep = None, finaltime = None):
    343196        """Specialisation of basic evolve method from parent class
     
    349202
    350203        #Call basic machinery from parent class
    351         for t in Advection_Domain.evolve(self, yieldstep, finaltime):
     204        for t in Shallow_Water_Domain.evolve(self, yieldstep, finaltime):
    352205
    353206            #Pass control on to outer loop for more specific actions
     
    355208
    356209
    357 
  • inundation/ga/storm_surge/parallel/run_parallel_advection.py

    r1520 r1563  
    66from config import g, epsilon
    77from Numeric import allclose, array, zeros, ones, Float
    8 from parallel_advection import *
    9 from Numeric import array
    10 from parallel_meshes import *
     8from parallel_meshes import parallel_rectangle
     9
     10from advection import Domain as Advection_Domain
     11from parallel_advection import Parallel_Advection_Domain
     12from parallel_advection import Transmissive_boundary, Dirichlet_boundary
    1113
    1214import pypar
     
    2325
    2426points, vertices, boundary, full_send_dict, ghost_recv_dict =  \
    25     parallel_rectangular(N, M, len1_g=1.0)
     27    parallel_rectangle(N, M, len1_g=1.0)
    2628
    2729#Create advection domain with direction (1,-1)
    28 domain = Parallel_Domain(points, vertices, boundary,
     30domain = Parallel_Advection_Domain(points, vertices, boundary,
    2931                         full_send_dict, ghost_recv_dict, velocity=[1.0, 0.0])
    3032
  • inundation/ga/storm_surge/parallel/run_parallel_merimbula.py

    r1559 r1563  
    4949sys.path.append('..'+sep+'pyvolution')
    5050
    51 from Numeric import array
     51from Numeric import array, zeros, Float
    5252# pmesh
    5353
     
    6060# mesh partition routines
    6161
    62 from pmesh_divide import pmesh_divide
    63 from build_submesh import *
    64 from build_local import *
    65 from build_commun import *
     62from pmesh_divide  import pmesh_divide
     63from build_submesh import build_submesh, extract_hostmesh
     64from build_local   import build_local_mesh
     65from build_commun  import send_submesh, rec_submesh
    6666
    6767# read in the processor information
     
    8181#    filename = 'test-100.tsh'
    8282    filename = 'merimbula_10785.tsh'
    83     nx = 3
     83    nx = 2
    8484    ny = 1
    8585    if nx*ny != numprocs:
    8686        print "WARNING: number of subboxes is not equal to the number of proc"
    87        
     87
    8888    [nodes, triangles, boundary, triangles_per_proc, rect] =\
    8989            pmesh_divide(filename, Advection_Domain, nx, ny)
    90    
     90
    9191    # subdivide the mesh
    9292
     
    9898
    9999    # send the mesh partition to the appropriate processor
    100    
     100
    101101    for p in range(1, numprocs):
    102102      send_submesh(submesh, triangles_per_proc, p)
     
    105105    [points, vertices, boundary, ghost_recv_dict, full_send_dict] = \
    106106             build_local_mesh(hostmesh, 0, triangles_per_proc[0], numprocs)
    107    
     107
    108108# read in the mesh partition that belongs to this
    109109# processor (note that the information is in the
     
    165165        domain.write_time()
    166166
    167 print 'That took %.2f seconds' %(time.time()-t0)
     167if myid == 0:
     168    print 'That took %.2f seconds' %(time.time()-t0)
  • inundation/ga/storm_surge/parallel/run_parallel_sw_merimbula.py

    r1558 r1563  
    1717# grid partitioning are
    1818#    +) mg2ga.py: read in the test files.
     19#    +) pmesh_divide.py: subdivide a pmesh
    1920#    +) build_submesh.py: build the submeshes on the host
    2021# processor.
     
    2526#
    2627# *) Things still to do:
    27 #    +) Fix host commun: The host processor (processor 0)
    28 # currently uses MPI to communicate the submesh to itself.
    29 # This is good for testing the communication but is very
    30 # inefficient and should be removed.
    3128#    +) Overlap the communication and computation: The
    3229# communication routines in build_commun.py should be
     
    5754#from shallow_water import Domain
    5855
    59 from advection import Domain
    60 from parallel_advection import Parallel_Domain as Parallel_Advection_Domain
     56from shallow_water import Domain as Shallow_Water_Domain
     57from parallel_shallow_water import Parallel_Shallow_Water_Domain
    6158
    62 from generic_boundary_conditions import Transmissive_boundary
    6359# mesh partition routines
    6460
     
    8278    # read in the test files
    8379
    84     filename = 'test-100.tsh'
    85     [nodes, triangles, boundary, triangles_per_proc, rect] = \
    86                        pmesh_divide(filename, Domain, 2, 1)
     80    #filename = 'test-100.tsh'
     81    filename = 'merimbula_10785.tsh'
     82    nx = 2
     83    ny = 1
     84    if nx*ny != numprocs:
     85        print "WARNING: number of subboxes is not equal to the number of proc"
     86
     87    [nodes, triangles, boundary, triangles_per_proc, rect] =\
     88            pmesh_divide(filename, Shallow_Water_Domain, nx, ny)
    8789
    8890    # subdivide the mesh
     
    9698    # send the mesh partition to the appropriate processor
    9799
    98     for p in range(numprocs):
     100    for p in range(1, numprocs):
    99101      send_submesh(submesh, triangles_per_proc, p)
     102
     103    hostmesh = extract_hostmesh(submesh)
     104    [points, vertices, boundary, ghost_recv_dict, full_send_dict] = \
     105             build_local_mesh(hostmesh, 0, triangles_per_proc[0], numprocs)
    100106
    101107# read in the mesh partition that belongs to this
     
    103109# correct form for the GA data structure
    104110
    105 
    106 
    107 
    108 [points, vertices, boundary, ghost_recv_dict, full_send_dict] = rec_submesh(0)
     111else:
     112    [points, vertices, boundary, ghost_recv_dict, full_send_dict] = \
     113             rec_submesh(0)
    109114
    110115#if myid == 0:
     
    120125print rect
    121126
    122 domain = Parallel_Advection_Domain(points, vertices, boundary,
     127domain = Parallel_Shallow_Water_Domain(points, vertices, boundary,
    123128                                   full_send_dict  = full_send_dict,
    124                                    ghost_recv_dict = ghost_recv_dict,
    125                                    velocity = [0.1,0.0])
     129                                   ghost_recv_dict = ghost_recv_dict)
    126130
    127131domain.initialise_visualiser(rect=rect)
     132domain.default_order = 2
    128133
    129134#Boundaries
     135from parallel_shallow_water import Transmissive_boundary, Reflective_boundary
    130136
    131137T = Transmissive_boundary(domain)
    132 domain.set_boundary( {'outflow': T, 'inflow': T, 'inner':T, 'exterior': T} )
     138R = Reflective_boundary(domain)
     139domain.set_boundary( {'outflow': R, 'inflow': R, 'inner':R, 'exterior': R, 'open':R} )
    133140
    134141class Set_Stage:
     
    144151        return self.h*((x>self.x0)&(x<self.x1))
    145152
    146 domain.set_quantity('stage', Set_Stage(250.0,300.0,1.0))
     153#domain.set_quantity('stage', Set_Stage(250.0,300.0,1.0))
     154domain.set_quantity('stage', Set_Stage(756000.0,756500.0,4.0))
    147155
    148156#---------
     
    150158t0 = time.time()
    151159domain.visualise = True
    152 yieldstep = 1
    153 finaltime = 4000
     160#yieldstep = 0.1
     161#finaltime = 1000
     162
     163yieldstep = 10
     164finaltime = 2000
     165
    154166for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
    155167    if myid == 0:
    156168        domain.write_time()
    157169
    158 print 'That took %.2f seconds' %(time.time()-t0)
     170if myid == 0:
     171    print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracChangeset for help on using the changeset viewer.