Ignore:
Timestamp:
Oct 3, 2006, 5:47:08 PM (18 years ago)
Author:
ole
Message:

Work on get_boundary_polygon using (discontinuous) example that fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py

    r3624 r3684  
    8080            self.geo_reference = geo_reference
    8181
    82         #Input checks
     82        # Input checks
    8383        msg = 'Triangles must an Nx3 Numeric array or a sequence of 3-tuples. '
    8484        msg += 'The supplied array has the shape: %s'\
     
    9595
    9696
    97         #Register number of elements (N)
     97        # Register number of elements (N)
    9898        self.number_of_elements = N = self.triangles.shape[0]
    9999
     
    106106
    107107
    108         #Allocate space for geometric quantities
     108        # Allocate space for geometric quantities
    109109        self.normals = zeros((N, 6), Float)
    110110        self.areas = zeros(N, Float)
    111111        self.edgelengths = zeros((N, 3), Float)
    112112
    113         #Get x,y coordinates for all triangles and store
     113        # Get x,y coordinates for all triangles and store
    114114        self.vertex_coordinates = V = self.compute_vertex_coordinates()
    115115
    116116
    117         #Initialise each triangle
     117        # Initialise each triangle
    118118        if verbose:
    119119            print 'General_mesh: Computing areas, normals and edgelenghts'
     
    127127            x2 = V[i, 4]; y2 = V[i, 5]
    128128
    129             #Area
     129            # Area
    130130            self.areas[i] = abs((x1*y0-x0*y1)+(x2*y1-x1*y2)+(x0*y2-x2*y0))/2
    131131
     
    135135
    136136
    137             #Normals
    138             #The normal vectors
    139             # - point outward from each edge
    140             # - are orthogonal to the edge
    141             # - have unit length
    142             # - Are enumerated according to the opposite corner:
    143             #   (First normal is associated with the edge opposite
    144             #    the first vertex, etc)
    145             # - Stored as six floats n0x,n0y,n1x,n1y,n2x,n2y per triangle
     137            # Normals
     138            # The normal vectors
     139            #   - point outward from each edge
     140            #   - are orthogonal to the edge
     141            #   - have unit length
     142            #   - Are enumerated according to the opposite corner:
     143            #     (First normal is associated with the edge opposite
     144            #     the first vertex, etc)
     145            #   - Stored as six floats n0x,n0y,n1x,n1y,n2x,n2y per triangle
    146146
    147147            n0 = array([x2 - x1, y2 - y1])
     
    154154            l2 = sqrt(sum(n2**2))
    155155
    156             #Normalise
     156            # Normalise
    157157            n0 /= l0
    158158            n1 /= l1
    159159            n2 /= l2
    160160
    161             #Compute and store
     161            # Compute and store
    162162            self.normals[i, :] = [n0[1], -n0[0],
    163163                                  n1[1], -n1[0],
    164164                                  n2[1], -n2[0]]
    165165
    166             #Edgelengths
     166            # Edgelengths
    167167            self.edgelengths[i, :] = [l0, l1, l2]
    168168
    169169       
    170         #Build vertex list
     170        # Build vertex list
    171171        if verbose: print 'Building vertex list'         
    172172        self.build_vertexlist()
     
    178178
    179179    def __repr__(self):
    180         return 'Mesh: %d triangles, %d elements'\
     180        return 'Mesh: %d vertex coordinates, %d triangles'\
    181181               %(self.coordinates.shape[0], len(self))
    182182
Note: See TracChangeset for help on using the changeset viewer.