- Timestamp:
- Oct 3, 2006, 5:47:08 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py
r3624 r3684 80 80 self.geo_reference = geo_reference 81 81 82 # Input checks82 # Input checks 83 83 msg = 'Triangles must an Nx3 Numeric array or a sequence of 3-tuples. ' 84 84 msg += 'The supplied array has the shape: %s'\ … … 95 95 96 96 97 # Register number of elements (N)97 # Register number of elements (N) 98 98 self.number_of_elements = N = self.triangles.shape[0] 99 99 … … 106 106 107 107 108 # Allocate space for geometric quantities108 # Allocate space for geometric quantities 109 109 self.normals = zeros((N, 6), Float) 110 110 self.areas = zeros(N, Float) 111 111 self.edgelengths = zeros((N, 3), Float) 112 112 113 # Get x,y coordinates for all triangles and store113 # Get x,y coordinates for all triangles and store 114 114 self.vertex_coordinates = V = self.compute_vertex_coordinates() 115 115 116 116 117 # Initialise each triangle117 # Initialise each triangle 118 118 if verbose: 119 119 print 'General_mesh: Computing areas, normals and edgelenghts' … … 127 127 x2 = V[i, 4]; y2 = V[i, 5] 128 128 129 # Area129 # Area 130 130 self.areas[i] = abs((x1*y0-x0*y1)+(x2*y1-x1*y2)+(x0*y2-x2*y0))/2 131 131 … … 135 135 136 136 137 # Normals138 # The normal vectors139 # - point outward from each edge140 # - are orthogonal to the edge141 # - have unit length142 # - Are enumerated according to the opposite corner:143 # (First normal is associated with the edge opposite144 # the first vertex, etc)145 # - Stored as six floats n0x,n0y,n1x,n1y,n2x,n2y per triangle137 # 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 146 146 147 147 n0 = array([x2 - x1, y2 - y1]) … … 154 154 l2 = sqrt(sum(n2**2)) 155 155 156 # Normalise156 # Normalise 157 157 n0 /= l0 158 158 n1 /= l1 159 159 n2 /= l2 160 160 161 # Compute and store161 # Compute and store 162 162 self.normals[i, :] = [n0[1], -n0[0], 163 163 n1[1], -n1[0], 164 164 n2[1], -n2[0]] 165 165 166 # Edgelengths166 # Edgelengths 167 167 self.edgelengths[i, :] = [l0, l1, l2] 168 168 169 169 170 # Build vertex list170 # Build vertex list 171 171 if verbose: print 'Building vertex list' 172 172 self.build_vertexlist() … … 178 178 179 179 def __repr__(self): 180 return 'Mesh: %d triangles, %d elements'\180 return 'Mesh: %d vertex coordinates, %d triangles'\ 181 181 %(self.coordinates.shape[0], len(self)) 182 182
Note: See TracChangeset
for help on using the changeset viewer.