Changeset 1192


Ignore:
Timestamp:
Apr 4, 2005, 11:27:27 AM (20 years ago)
Author:
prow
Message:

set_to_inc. now returns min and max ratio between new and old radii.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/mesh.py

    r1191 r1192  
    152152
    153153
    154     def set_to_incribed_circle(self):
     154    def set_to_incribed_circle(self,safety_factor = 1):
    155155        #FIXME phase out eventually
    156156        from math import sqrt
    157157        N = self.number_of_elements
    158158        V = self.vertex_coordinates
    159         for i in range(N):
     159
     160        #initialising min and max ratio
     161        i=0
     162        old_rad = self.radii[i]
     163        x0 = V[i, 0]; y0 = V[i, 1]
     164        x1 = V[i, 2]; y1 = V[i, 3]
     165        x2 = V[i, 4]; y2 = V[i, 5]
     166        a = sqrt((x0-x1)**2+(y0-y1)**2)
     167        b = sqrt((x1-x2)**2+(y1-y2)**2)
     168        c = sqrt((x2-x0)**2+(y2-y0)**2)
     169        ratio = old_rad/self.radii[i]
     170        max_ratio = ratio
     171        min_ratio = ratio
     172
     173        for i in range(N):
     174            old_rad = self.radii[i]
    160175            x0 = V[i, 0]; y0 = V[i, 1]
    161176            x1 = V[i, 2]; y1 = V[i, 3]
     
    164179            b = sqrt((x1-x2)**2+(y1-y2)**2)
    165180            c = sqrt((x2-x0)**2+(y2-y0)**2)
    166 
    167             self.radii[i]=self.areas[i]/(2*(a+b+c))
     181            self.radii[i]=self.areas[i]/(2*(a+b+c))*safety_factor
     182            ratio = old_rad/self.radii[i]
     183            if ratio >= max_ratio: max_ratio = ratio
     184            if ratio <= min_ratio: min_ratio = ratio
     185        return max_ratio,min_ratio
    168186
    169187    def build_neighbour_structure(self):
Note: See TracChangeset for help on using the changeset viewer.