Skip to content

volume

volume(V, T)

Computes a vector containing the volumes of all tetrahedra in a mesh

Parameters:

Name Type Description Default
V numpy double array

Matrix of mesh vertex position coordinates

required
T numpy double array

Matrix of mesh tetrahedra indices into V

required

Returns:

Name Type Description
vols numpy double array

Vector of per-tetrahedron volumes

See Also

doublearea

Examples:

TODO

Source code in src/gpytoolbox/volume.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def volume(V,T):
    """Computes a vector containing the volumes of all tetrahedra in a mesh

    Parameters
    ----------
    V : numpy double array
        Matrix of mesh vertex position coordinates
    T : numpy double array
        Matrix of mesh tetrahedra indices into V

    Returns
    -------
    vols : numpy double array
        Vector of per-tetrahedron volumes

    See Also
    --------
    doublearea

    Examples
    --------
    TODO
    """


    # Dimension:
    a = V[T[:,0],:]
    b = V[T[:,1],:]
    c = V[T[:,2],:]
    d = V[T[:,3],:]

    vols = -np.sum(np.multiply(a-d,np.cross(b-c,c-d,axis=1)),axis=1)/6.

    return vols