Ignore:
Timestamp:
Jul 18, 2008, 4:37:03 PM (16 years ago)
Author:
steve
Message:

Added unit test files for quantity and shallow water

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anuga_1d/quantity.py

    r5535 r5536  
    2222        #from domain import Domain
    2323        #from domain_order2 import Domain
    24         from domain_t2 import Domain
     24        from domain import Domain
    2525        from Numeric import array, zeros, Float
    2626
     
    5656        #Intialise centroid values
    5757        self.interpolate()
     58
     59
     60        from Numeric import zeros, Float
     61       
     62        #Allocate space for boundary values
     63        #L = len(domain.boundary)
     64        self.boundary_values = zeros(2, Float) #assumes no parrellism
     65
     66        #Allocate space for updates of conserved quantities by
     67        #flux calculations and forcing functions
     68       
     69        N = domain.number_of_elements
     70        self.explicit_update = zeros(N, Float )
     71        self.semi_implicit_update = zeros(N, Float )
     72
     73        self.gradients = zeros(N, Float)
     74        self.qmax = zeros(self.centroid_values.shape, Float)
     75        self.qmin = zeros(self.centroid_values.shape, Float)
     76
     77        self.beta = domain.beta       
    5878
    5979    #Methods for operator overloading
     
    381401        return integral
    382402
    383 class Conserved_quantity(Quantity):
    384     """Class conserved quantity adds to Quantity:
    385 
    386     storage and method for updating, and
    387     methods for extrapolation from centropid to vertices inluding
    388     gradients and limiters
    389     """
    390 
    391     def __init__(self, domain, vertex_values=None):
    392         Quantity.__init__(self, domain, vertex_values)
    393 
    394         from Numeric import zeros, Float
    395        
    396         #Allocate space for boundary values
    397         #L = len(domain.boundary)
    398         self.boundary_values = zeros(2, Float) #assumes no parrellism
    399 
    400         #Allocate space for updates of conserved quantities by
    401         #flux calculations and forcing functions
    402        
    403         N = domain.number_of_elements
    404         self.explicit_update = zeros(N, Float )
    405         self.semi_implicit_update = zeros(N, Float )
    406 
    407         self.gradients = zeros(N, Float)
    408         self.qmax = zeros(self.centroid_values.shape, Float)
    409         self.qmin = zeros(self.centroid_values.shape, Float)
    410 
    411         self.beta = domain.beta
    412403
    413404    def update(self, timestep):
     
    863854                else:
    864855                    qv[k,i] = qc[k]
     856   
     857
     858class Conserved_quantity(Quantity):
     859    """Class conserved quantity adds to Quantity:
     860
     861    storage and method for updating, and
     862    methods for extrapolation from centropid to vertices inluding
     863    gradients and limiters
     864    """
     865
     866    def __init__(self, domain, vertex_values=None):
     867        Quantity.__init__(self, domain, vertex_values)
     868
     869        print "Use Quantity instead of Conserved_quantity"
     870
    865871                   
    866872
     
    884890if __name__ == "__main__":
    885891    #from domain import Domain
    886     from shallow_water_1d import Domain     
     892    from shallow_water_domain import Domain     
    887893    from Numeric import arange
    888894   
     
    892898    D1 = Domain(points1)
    893899
    894     Q1 = Conserved_quantity(D1, vertex_values)
     900    Q1 = Quantity(D1, vertex_values)
    895901
    896902    print Q1.vertex_values
     
    941947    D2 = Domain(points2)
    942948
    943     Q2 = Conserved_quantity(D2)
     949    Q2 = Quantity(D2)
    944950    Q2.set_values(fun,'vertices')
    945951    Xc = Q2.domain.vertices
Note: See TracChangeset for help on using the changeset viewer.