# Computing flux of vector field numerically with regular grids

I would like to compute the flow rate (mL/s) of a pipe flow given the 3D velocity field $\mathbf{v} = (v_x, v_y, v_z)$ over the computational domain (a curved pipe). The field is represented in the form of a voxel grid with uniform sampling distances along each dimension. The flow field is a result of a numerical simulation of the flow.

In general the flow rate can be computed as the flux of the velocity field over a cut plane of the 3D domain (pipe).

$Q = \int_S v \mathbf{n} dA$

Using this approach however the solution only depends on samples from a subset of the available results, and in order to improve the accuracy of the computation I would like to use all available data. This could be achieved by computing the flow rate as an average of multiple flux values based on different sampling planes.

Given that the considered domain is a pipe, it is possible to estimate the centerline in the form of a curve $z$, and then using test surfaces that are planes perpendicular to the curve along equally spaced locations $z_i, i\in(1,\dots, N)$ and taking $N\to\infty$, we get the following expression

$Q = \frac{1}{L}\int_Z\int_S v \mathbf{n} dAdz$, with L the length of the curve z

In order to make the computations simpler I would like to avoid the explicit computations of the flux values for the test surfaces (cutting planes). What I am aiming for is to express the solution as a volume integral of some kind, that could be trivially evaluated without any knowledge of the topology of the domain in 3D.

I was trying to use the divergence theorem first, however when applied to the computational domain (pipe interior) it would basically contain the difference of fluxes at the inlet and outlet (assuming no flux through the walls) and I could not get anything meaningful out of this.

Any ideas / hints are very much appreciated!

-