Changeset 4568


Ignore:
Timestamp:
Jun 28, 2007, 5:28:24 PM (18 years ago)
Author:
ole
Message:

Thoughts on centroid values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r4541 r4568  
    1515
    1616from anuga.utilities.numerical_tools import ensure_numeric
    17 from Numeric import arange, choose
     17from Numeric import arange, choose, zeros, Float
    1818   
    1919from anuga.geospatial_data.geospatial_data import ensure_absolute
     
    14821482        #print "triangles after", triangles
    14831483    return verts, triangles
     1484
    14841485 
     1486def get_centroid_values(x, triangles):
     1487    """Compute centroid values from vertex values
     1488   
     1489    x: Values at vertices of triangular mesh
     1490    triangles: Nx3 integer array pointing to vertex information
     1491    for each of the N triangels. Elements of triangles are
     1492    indices into x
     1493    """
     1494
     1495       
     1496    xc = zeros(triangles.shape[0], Float) # Space for centroid info
     1497   
     1498    for k in range(triangles.shape[0]):
     1499        # Indices of vertices
     1500        i0 = triangles[k][0]
     1501        i1 = triangles[k][1]
     1502        i2 = triangles[k][2]       
     1503       
     1504        xc[k] = (x[i0] + x[i1] + x[i2])/3
     1505
     1506
     1507    return xc
     1508
     1509       
Note: See TracChangeset for help on using the changeset viewer.