cape.cfdx.volcomp: Cell volume computation tools

This module is effectively the Chimera Grid Tools code volcomp.F converted to Python. It is used by pyOver.dataBook.DBTriqFMComp to calculate volumes of prism cells on the surface of a CFD solution, but since it simply calculates the volume of several types of polyhedra, it could be used for other applications.

cape.cfdx.volcomp.VOLPRIS(X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, X4, Y4, Z4, X5, Y5, Z5, X6, Y6, Z6)

Compute the volume of a triangular prism

The prism is constructed so that 1,2,3 are counterclockwise at the base and 4,5,6 at the top counterclockwise. The volumes of the three pyramids (V1,*V2*,*V3*), two tetrahedra (V4,*V5*), and prism (V) are returned.

All inputs can be either scalars or vectors, but each input that is a vector must have the same shape. The outputs are a scalar if and only if all 18 inputs are scalar.

Call:
>>> V1,V2,V3,V4,V5,V = VOLPRIS(X1,Y1,Z1,X2,Y2,Z2, ..., X6,Y6,Z6)
Inputs:
X1: float | np.ndarray

X-coordinate(s) of point(s) 1 at base of prism(s)

Y1: float | np.ndarray

Y-coordinate(s) of point(s) 1 at base of prism(s)

Z1: float | np.ndarray

Z-coordinate(s) of point(s) 1 at base of prism(s)

X2: float | np.ndarray

X-coordinate(s) of point(s) 2 at base of prism(s)

X3: float | np.ndarray

X-coordinate(s) of point(s) 3 at base of prism(s)

X4: float | np.ndarray

X-coordinate(s) of point(s) 1 at top of prism(s)

Outputs:
V1: float | np.ndarray

Volume(s) of first pyramid(s), nodes C,1,4,5,2

V2: float | np.ndarray

Volume(s) of second pyramid(s), nodes C,1,3,6,4

V3: float | np.ndarray

Volume(s) of third pyramid(s), nodes C,2,5,6,3

V4: float | np.ndarray

Volume(s) of first tetrahedron(s), nodes C,1,2,3

V5: float | np.ndarray

Volume(s) of first tetrahedron(s), nodes C,6,5,4

V: float | np.ndarray

Volume(s) of prism(s)

Versions:
  • 2017-02-12 @ddalle: Translated from lib/volcomp.F

cape.cfdx.volcomp.VOLPYM(XP, YP, ZP, XA, YA, ZA, XB, YB, ZB, XC, YC, ZC, XD, YD, ZD)

Compute the volume of a pentahedral pyramid

The base of the points are A,B,C,D counterclockwise viewed from apex P. All inputs can be either scalars or vectors, but each input that is a vector must have the same shape. The output is a scalar if and only if all 15 inputs are scalar.

Call:
>>> V = VOLPYM(XP,YP,ZP, XA,YA,ZA, XB,YB,ZB, XC,YC,ZC, XD,YD,ZD)
Inputs:
XP: float | np.ndarray

X-coordinates of vertex point(s)

YP: float | np.ndarray

Y-coordinates of vertex point(s)

ZP: float | np.ndarray

Z-coordinates of vertex point(s)

XA: float | np.ndarray

X-coordinates of base point(s) A

YA: float | np.ndarray

Y-coordinates of base point(s) A

ZA: float | np.ndarray

Z-coordinates of base point(s) A

Outputs:
V: float | np.ndarray

Volume of each pyramid(s)

Versions:
  • 2017-02-12 @ddalle: Translated from CGT lib/volcomp.F

cape.cfdx.volcomp.VOLTET(XA, YA, ZA, XB, YB, ZB, XC, YC, ZC, XD, YD, ZD)

Compute the volume of a tetrahedron

All inputs can be either scalars or vectors, but each input that is a vector must have the same shape. The output is a scalar if and only if all 15 inputs are scalar.

Call:
>>> V = VOLTET(XA,YA,ZA, XB,YB,ZB, XC,YC,ZC, XD,YD,ZD)
Inputs:
XA: float | np.ndarray

X-coordinates of base point(s) A

YA: float | np.ndarray

Y-coordinates of base point(s) A

ZA: float | np.ndarray

Z-coordinates of base point(s) A

Outputs:
V: float | np.ndarray

Volume of each pyramid(s)

Versions:
  • 2017-02-12 @ddalle: Translated from CGT lib/volcomp.F

cape.cfdx.volcomp.VolTriPrism(X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, X4, Y4, Z4, X5, Y5, Z5, X6, Y6, Z6)

Compute the volume of a triangular prism

The prism is constructed so that 1,2,3 are counterclockwise at the base and 4,5,6 at the top counterclockwise.

All inputs can be either scalars or vectors, but each input that is a vector must have the same shape. The outputs are a scalar if and only if all 18 inputs are scalar.

Call:
>>> V = VolTriPrism(X1,Y1,Z1,X2,Y2,Z2, ..., X6,Y6,Z6)
Inputs:
X1: float | np.ndarray

X-coordinate(s) of point(s) 1 at base of prism(s)

Y1: float | np.ndarray

Y-coordinate(s) of point(s) 1 at base of prism(s)

Z1: float | np.ndarray

Z-coordinate(s) of point(s) 1 at base of prism(s)

X2: float | np.ndarray

X-coordinate(s) of point(s) 2 at base of prism(s)

X3: float | np.ndarray

X-coordinate(s) of point(s) 3 at base of prism(s)

X4: float | np.ndarray

X-coordinate(s) of point(s) 1 at top of prism(s)

Outputs:
V: float | np.ndarray

Volume(s) of prism(s)

Versions:
  • 2017-02-12 @ddalle: Modified from lib/volcomp.F