Changeset 3021


Ignore:
Timestamp:
May 30, 2006, 4:17:18 PM (19 years ago)
Author:
steve
Message:

updated timestep using only full cells

Location:
inundation/pyvolution
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/advection.py

    r2813 r3021  
    218218
    219219                #Update optimal_timestep
    220                 try:
    221                     optimal_timestep = min(optimal_timestep, radii[k]/max_speed)
    222                 except ZeroDivisionError:
    223                     pass
     220                if  self.tri_full_flag == 1 :
     221                    try:
     222                        optimal_timestep = min(optimal_timestep, radii[k]/max_speed)
     223                    except ZeroDivisionError:
     224                        pass
    224225
    225226            #Normalise by area and store for when all conserved
     
    275276        radii           = self.radii
    276277        edgelengths     = self.edgelengths
     278        tri_full_flag   = self.tri_full_flag
    277279
    278280        stage_edge      = Stage.edge_values
     
    333335
    334336                //Update optimal_timestep
    335                 if (max_speed != 0.0) {
    336                     optimal_timestep = (optimal_timestep>radii(k)/max_speed) ? radii(k)/max_speed : optimal_timestep;
     337                if (tri_full_flag(k) == 1) {
     338                    if (max_speed != 0.0) {
     339                        optimal_timestep = (optimal_timestep>radii(k)/max_speed) ? radii(k)/max_speed : optimal_timestep;
     340                    }
    337341                }
    338342
     
    351355        weave.inline(code, ['stage_edge','stage_bdry','stage_update',
    352356                             'neighbours','neighbour_edges','normals',
    353                              'areas','radii','edgelengths','huge_timestep',
     357                             'areas','radii','edgelengths','tri_full_flag',
     358                             'huge_timestep',
    354359                             'timestep','v1','v2','N'],
    355360                             type_converters = converters.blitz, compiler='gcc');
  • inundation/pyvolution/domain.py

    r2866 r3021  
    7979                      verbose=verbose)
    8080
    81         if verbose: print 'Initialising Domain'       
    82         from Numeric import zeros, Float, Int
     81        if verbose: print 'Initialising Domain'
     82        from Numeric import zeros, Float, Int, ones
    8383        from quantity import Quantity, Conserved_quantity
    8484
     
    117117        # List of other quantity names
    118118        if ghost_recv_dict  is None:
    119             self.ghost_recv_dict  = []
     119            self.ghost_recv_dict  = {}
    120120        else:
    121121            self.ghost_recv_dict  = ghost_recv_dict
     
    125125
    126126        # Setup Communication Buffers
    127            
     127
    128128        if verbose: print 'Domain: Set up communication buffers (parallel)'
    129129        self.nsys = len(self.conserved_quantities)
     
    136136            buffer_shape = self.ghost_recv_dict[key][0].shape[0]
    137137            self.ghost_recv_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     138
     139
     140        # Setup cell full flag
     141        # =1 for full
     142        # =0 for ghost
     143        N=self.number_of_elements
     144        self.tri_full_flag = ones(N, Int)
     145        for i in self.ghost_recv_dict.keys():
     146            for id in self.ghost_recv_dict[i][0]:
     147                self.tri_full_flag[id] = 0
     148
    138149
    139150        #Defaults
     
    186197            self.set_quantity_vertices_dict(vertex_quantity_dict)
    187198
    188            
     199
    189200        if verbose: print 'Domain: Done'
    190201
    191            
     202
    192203
    193204
     
    730741                self.number_of_steps = 0
    731742                self.number_of_first_order_steps = 0
    732                
     743
    733744
    734745    def evolve_to_end(self, finaltime = 1.0):
  • inundation/pyvolution/shallow_water.py

    r2814 r3021  
    549549            flux -= edgeflux * domain.edgelengths[k,i]
    550550
    551             #Update optimal_timestep
    552             try:
    553                 timestep = min(timestep, 0.5*domain.radii[k]/max_speed)
    554             except ZeroDivisionError:
    555                 pass
     551            #Update optimal_timestep on full cells
     552            if  domain.tri_full_flag[k] == 1:
     553                try:
     554                    timestep = min(timestep, 0.5*domain.radii[k]/max_speed)
     555                except ZeroDivisionError:
     556                    pass
    556557
    557558        #Normalise by area and store for when all conserved
     
    615616                                     domain.radii,
    616617                                     domain.areas,
     618                                     domain.tri_full_flag,
    617619                                     Stage.edge_values,
    618620                                     Xmom.edge_values,
  • inundation/pyvolution/shallow_water_ext.c

    r2731 r3021  
    980980  PyArrayObject *neighbours, *neighbour_edges,
    981981    *normals, *edgelengths, *radii, *areas,
     982    *tri_full_flag,
    982983    *stage_edge_values,
    983984    *xmom_edge_values,
     
    10041005
    10051006  // Convert Python arguments to C
    1006   if (!PyArg_ParseTuple(args, "dddOOOOOOOOOOOOOOOOO",
     1007  if (!PyArg_ParseTuple(args, "dddOOOOOOOOOOOOOOOOOO",
    10071008                        &timestep,
    10081009                        &epsilon,
     
    10121013                        &normals,
    10131014                        &edgelengths, &radii, &areas,
     1015            &tri_full_flag,
    10141016                        &stage_edge_values,
    10151017                        &xmom_edge_values,
     
    10901092        //timestep = min(timestep, domain.radii[k]/max_speed)
    10911093        //FIXME: SR Add parameter for CFL condition
    1092         if (max_speed > epsilon) {
    1093           timestep = min(timestep, ((double *) radii -> data)[k]/max_speed);
    1094           //maxspeed in flux_function is calculated as max(|u+a|,|u-a|)
    1095           if (n>=0)
    1096             timestep = min(timestep, ((double *) radii -> data)[n]/max_speed);
    1097         }
     1094    if ( ((long *) tri_full_flag -> data)[k] == 1) {
     1095            if (max_speed > epsilon) {
     1096                timestep = min(timestep, ((double *) radii -> data)[k]/max_speed);
     1097                //maxspeed in flux_function is calculated as max(|u+a|,|u-a|)
     1098                if (n>=0)
     1099                    timestep = min(timestep, ((double *) radii -> data)[n]/max_speed);
     1100            }
     1101    }
    10981102    } // end for i
    10991103    //Normalise by area and store for when all conserved
Note: See TracChangeset for help on using the changeset viewer.