# Calculating volume of a discretised diffuse interface object

Suppose I have a spherical object projected onto a discrete square mesh. The dicretised circle can be represented by filling a logical matrix such that voxels in the interior of the sphere are filled with 1's where outside of the sphere the voxels are filled with 0's. Calculating the volume is easy as you simply add up the voxels filled with 1's to get the volume.

In the phase field (diffuse interface) formalism however, the edges of the sphere are diffuse interfaces, ie. the value varies smoothly 0 < value < 1 over several mesh points. How does one go about calculating the volume for such an object?

The only way I could think of was defining an artificial discrete boundary at value=0.5 and then summing as in the first case. Any ideas?

What I have understood is that you have a solid phase (sphere within a cube, represented by $\Omega$) with a continuous solid fraction called $\alpha\in[0,1]$, $\alpha=1$ when solid $\alpha=0$ when void.
The volume of the solid $V$ is written as: $$V=\int_{\Omega}\alpha\,dV\approx\sum_{e=1}^{Ne}\int_{\Omega^{e}}\alpha^{e}\,dV\tag{*}$$ Where $Ne$ is the number of elements and $\alpha^{e}$ is a function that interpolates the function from the vertices of the $e-th$ cubic element: $$\alpha^{e}=\sum_{i=1}^{8}\alpha^{e}_i\varphi_i(\vec{x})\tag{**}$$ Where $\varphi(\vec{x})$ are the interpolant basis functions ($\varphi_i(\vec{x}_k) = \delta_{ik}$), and $\alpha^{e}_i$ are the nodal values.
The integral in $(*)$ applying $(**)$ is then: $$V \approx \sum_{e=1}^{Ne}\sum_{i=1}^{8}\alpha^{e}_i\int_{\Omega^{e}}\varphi(\vec{x})\,dV$$
For the sake of simplicity you can take (if they are cubes) $\varphi_{i}(\vec{x}) = \frac{1}{8}$, therefore: $$V \approx \sum_{e=1}^{Ne}\frac{V^{e}}{8}\sum_{i=1}^{8}\alpha^{e}_i$$