Ignore:
Timestamp:
Sep 7, 2004, 5:24:43 PM (20 years ago)
Author:
steve
Message:

Working on Quantities

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution-1d/domain.py

    r256 r279  
    2626
    2727        #Allocate space for geometric quantities
    28         self.vertex_coordinates   = zeros((N, 2), Float)
    29         self.centroid_coordinates = zeros(N, Float)
    30         self.areas                = zeros(N, Float)
     28        self.vertices  = zeros((N, 2), Float)
     29        self.centroids = zeros(N, Float)
     30        self.areas     = zeros(N, Float)
    3131        for i in range(N):
    3232            xl = self.coordinates[i]
    3333            xr = self.coordinates[i+1]
    34             self.vertex_coordinates[i,0] = xl
    35             self.vertex_coordinates[i,1] = xr
     34            self.vertices[i,0] = xl
     35            self.vertices[i,1] = xr
    3636           
    3737            centroid = (xl+xr)/2
    38             self.centroid_coordinates[i] = centroid
     38            self.centroids[i] = centroid
    3939
    4040            msg = 'Coordinates should be ordered, smallest to largest'
     
    4343            self.areas[i] = (xr-xl)
    4444
     45##         print 'N', N
     46##         print 'Centroid', self.centroids
     47##         print 'Areas', self.areas
     48##         print 'Vertex_Coordinates', self.vertices
     49       
     50    def get_centroids(self):
     51        """Return all coordinates of centroids
     52        Return x coordinate of centroid for each element as a N array
     53        """
     54       
     55        return self.centroids
    4556
    46         print 'N', N
    47         print 'Coordinates', self.coordinates
    48         print 'Centroid', self.centroid_coordinates
    49         print 'Areas', self.areas
    50         print 'Vertex_Coordinates', self.vertex_coordinates
    51        
    52     def get_centroid_coordinates(self):
     57    def get_vertices(self):
    5358        """Return all coordinates of centroids
    5459        Return x coordinate of centroid for each element as a N array
    5560        """
    5661
    57         return self.centroid_coordinates
     62        return self.vertices
    5863
    5964    def get_coordinate(self, elem_id, vertex=None):
     
    6469
    6570        if vertex is None:
    66             return self.centroid_coordinates[elem_id]
     71            return self.centroids[elem_id]
    6772        else:
    68             return self.vertex_coordinates[elem_id,vertex]
    69        
     73            return self.vertices[elem_id,vertex]
     74
     75    def get_area(self, elem_id):
     76        """Return area of element id
     77        """
     78
     79        return self.areas[elem_id]
     80   
    7081
    7182if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.