Changeset 1995


Ignore:
Timestamp:
Nov 3, 2005, 3:07:06 PM (19 years ago)
Author:
steve
Message:
 
Location:
inundation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/analytical solutions/Analytical_solution_circular_hydraulic_jump.py

    r1929 r1995  
    141141import time
    142142
     143f = open("output.txt","w")
     144
    143145t0 = time.time()
    144 for t in domain.evolve(yieldstep = .01, finaltime = 10):
     146for t in domain.evolve(yieldstep = .01, finaltime = 0.1):
    145147    domain.write_time()
    146148
     
    158160    print '      radial mom ', \
    159161          radial_momentum.get_values(location='centroids',
    160                                      indices=[typical_inner[0]])   
    161    
     162                                     indices=[typical_inner[0]])
    162163
    163    
    164164
    165    
    166    
     165    f.write('time = %25.15e wall clock time %g \n' % (domain.time, time.time()))
     166    f.write('%g \n' % w.get_values(location='centroids',
     167                                   indices=[typical_outer[0]])[0])
     168
     169
     170f.close()
     171
     172
    167173    #vxmom.update_quantity('xmomentum')
    168174    #vymom.update_quantity('ymomentum')
  • inundation/pyvolution/quantity.py

    r1928 r1995  
    5656
    5757
    58     #Methods for operator overloading   
     58    #Methods for operator overloading
    5959    def __len__(self):
    6060        return self.centroid_values.shape[0]
     
    6969        Q.set_values(-self.vertex_values)
    7070        return Q
    71    
     71
    7272
    7373    def __add__(self, other):
    7474        """Add to self anything that could populate a quantity
    75        
     75
    7676        E.g other can be a constant, an array, a function, another quantity
    7777        (except for a filename or points, attributes (for now))
     
    8080
    8181        Q = Quantity(self.domain)
    82         Q.set_values(other)       
     82        Q.set_values(other)
    8383
    8484        result = Quantity(self.domain)
     
    9090        """
    9191        return self + other
    92    
    93    
    94     def __sub__(self, other):   
     92
     93
     94    def __sub__(self, other):
    9595        return self + -other  #Invoke __neg__
    9696
    9797    def __mul__(self, other):
    9898        """Multiply self with anything that could populate a quantity
    99        
     99
    100100        E.g other can be a constant, an array, a function, another quantity
    101101        (except for a filename or points, attributes (for now))
     
    111111        Q = Quantity(self.domain)
    112112        Q.set_values(other)
    113        
     113
    114114        result = Quantity(self.domain)
    115115        result.set_values(self.vertex_values * Q.vertex_values)
    116116        return result
    117        
     117
    118118    def __rmul__(self, other):
    119119        """Handle cases like 3*Q, where Q is an instance of class Quantity
     
    135135        result.set_values(self.vertex_values**other)
    136136        return result
    137        
    138    
     137
     138
    139139
    140140    def interpolate(self):
     
    166166                   numeric = None,    # List, numeric array or constant
    167167                   quantity = None,   # Another quantity
    168                    function = None,   # Callable object: f(x,y) 
     168                   function = None,   # Callable object: f(x,y)
    169169                   points = None, values = None, #Input for least squares
    170170                   filename = None, attribute_name = None, #Input from file
    171171                   alpha = None,
    172                    location = 'vertices',                   
     172                   location = 'vertices',
    173173                   indices = None,
    174174                   verbose = None,
    175175                   use_cache = False):
    176        
     176
    177177        """Set values for quantity based on different sources.
    178        
     178
    179179        numeric:
    180180          Compatible list, Numeric array (see below) or constant.
    181           If callable it will treated as a function 
     181          If callable it will treated as a function
    182182          If instance of another Quantity it will be treated as such.
    183183
     
    209209          Alpha will only be used with points, values or filename.
    210210          Otherwise it will be ignored.
    211                
    212          
     211
     212
    213213        location: Where values are to be stored.
    214214                  Permissible options are: vertices, edges, centroids
     
    239239        use_cache: True means that caching of intermediate results is
    240240                   attempted for least squares fit.
    241                    
    242                    
    243        
     241
     242
     243
    244244
    245245        Exactly one of the arguments
     
    252252
    253253        #General input checks
    254         L = [numeric, quantity, function, points, filename]       
     254        L = [numeric, quantity, function, points, filename]
    255255        msg = 'Exactly one of the arguments '+\
    256256              'numeric, quantity, function, points, or filename '+\
     
    267267        msg = 'Indices must be a list or None'
    268268        assert type(indices) in [ListType, NoneType, ArrayType], msg
    269                
    270 
    271        
     269
     270
     271
    272272        #Determine which 'set_values_from_...' to use
    273273
     
    288288                msg = 'Illegal type for argument numeric: %s' %str(numeric)
    289289                raise msg
    290            
     290
    291291        elif quantity is not None:
    292292            self.set_values_from_quantity(quantity,
     
    294294        elif function is not None:
    295295            msg = 'Argument function must be callable'
    296             assert callable(function), msg           
     296            assert callable(function), msg
    297297            self.set_values_from_function(function,
    298298                                          location, indices, verbose)
     
    320320            self.extrapolate_first_order()
    321321
    322                
     322
    323323
    324324    #Specific functions for setting values
     
    372372                    self.vertex_values[i_vertex,:] = X
    373373
    374    
    375 
    376    
     374
     375
     376
    377377
    378378
     
    479479        """Set quantity values from specified quantity instance q
    480480
    481         Location is ignored 
    482         """
    483        
    484        
     481        Location is ignored
     482        """
     483
     484
    485485        A = q.vertex_values
    486486
     
    517517        else:
    518518            is_subset = True
    519            
     519
    520520        if location == 'centroids':
    521521            P = take(self.domain.centroid_coordinates, indices)
     
    546546        """
    547547
    548         from Numeric import Float 
     548        from Numeric import Float
    549549        from util import ensure_numeric
    550550        from least_squares import fit_to_mesh
    551        
     551
    552552        points = ensure_numeric(points, Float)
    553553        values = ensure_numeric(values, Float)
     
    568568                      'could not be imported'
    569569                raise msg
    570            
     570
    571571            args = (coordinates, triangles, points, values)
    572572            kwargs = {'alpha': alpha, 'verbose': verbose}
     
    574574                                      args, kwargs,
    575575                                      verbose = verbose)
    576         else:   
     576        else:
    577577            vertex_attributes = fit_to_mesh(coordinates,
    578578                                            triangles,
     
    581581                                            alpha = alpha,
    582582                                            verbose = verbose)
    583            
    584        
     583
     584
    585585        self.set_values_from_array(vertex_attributes,
    586                                    location, indices, verbose)       
    587        
    588 
    589        
    590        
    591    
     586                                   location, indices, verbose)
     587
     588
     589
     590
     591
    592592    def set_values_from_file(self, filename, attribute_name, alpha,
    593593                             location, indices, verbose, use_cache):
    594594        """Set quantity based on arbitrary points in .pts file
    595595        using least_squares attribute_name selects name of attribute
    596         present in file. 
     596        present in file.
    597597        If not specified try to use whatever is available in file.
    598598        """
     
    609609        points = points_dict['pointlist']
    610610        attributes = points_dict['attributelist']
    611        
     611
    612612        if attribute_name is None:
    613613            names = attributes.keys()
     
    615615
    616616        msg = 'Attribute_name must be a text string'
    617         assert type(attribute_name) == StringType, msg           
     617        assert type(attribute_name) == StringType, msg
    618618
    619619
     
    629629            raise msg
    630630
    631            
    632         #Call least squares method   
     631
     632        #Call least squares method
    633633        self.set_values_from_points(points, z, alpha,
    634634                                    location, indices, verbose, use_cache)
     
    896896    def get_integral(self):
    897897        """Compute the integral of quantity across entire domain
    898         """
    899         integral = 0
    900         for k in range(self.domain.number_of_elements):
     898        """
     899        integral = 0
     900        for k in range(self.domain.number_of_elements):
    901901            area = self.domain.areas[k]
    902902            qc = self.centroid_values[k]
    903903            integral += qc*area
    904904
    905         return integral
    906 
    907 
    908    
     905        return integral
     906
     907
     908
    909909
    910910class Conserved_quantity(Quantity):
  • inundation/zeus/anuga-workspace.zwi

    r1967 r1995  
    22<workspace name="anuga-workspace">
    33    <mode>Debug</mode>
    4     <active>steve</active>
     4    <active>analytic_solutions</active>
    55    <project name="analytic_solutions">analytic_solutions.zpi</project>
    66    <project name="euler">euler.zpi</project>
Note: See TracChangeset for help on using the changeset viewer.