The generated initial mesh has sharp edges and corners and must be smoothed in order to find contact angles and other related parameters such as curvatures. The vertices on the three-phase contact lines belong to both the solid–fluid and the fluid–fluid meshes which must be smoothed consistently through smoothing iterations. Different smoothing techniques have been proposed; for instance, Akai et al. (2019) fitted surfaces on triangular meshes; and AlRatrout et. al. (2017) changed positions of vertices by performing either Gaussian or curvature smoothing while keeping the global phase volumes approximately constant. Our approach is similar to the work by AlRatrout et al. (2017), in the sense that vertices are displaced to minimize the curvatures. However, weights of displacements and the way we use neighborhood of vertices are different in this work. Our methodology is mainly based on isotropic smoothing flow by Meyer et al. (2003). We displace the vertices along their unit normal vectors with mean curvature as the weight of disparagement. The constraint on the displacements is based on voxel length and imaging uncertainty as opposed to the phase volume constraint used by AlRatrout et al. (2017). Furthermore, we represent the surfaces by triangular cells whereas AlRatrout et al. (2017) used square cells. The details of smoothing are explained in this section.
In principle, smoothing a surface involves solving Laplace’s equation, \(\nabla ^{2}f=0\) in general, or the Young–Laplace equation, \(-2\kappa _H=\nabla .(\nabla f / |\nabla f |)=\hbox {const}\) in particular for fluid–fluid surfaces. Here f is the function expressing the surface. For the Laplace’s equation, smoothing is also equivalent to Euler–Lagrange equation, \(\kappa _H=0\) used for surface area minimization (Meyer et al. 2003). In absence of a function, the surface is discretized and the Laplace’s equation is solved by a numerical method, e.g., finite difference. A 2-manifold—a mesh—is represented by vertices and discrete triangles rather than by an ordinary continuous surface. Generalization of Laplace’s equation from surfaces to manifolds is known as Laplace–Beltrami method which can be discretized using cotangent scheme in order to calculate Voronoi area (see Fig. 1), Laplace–Beltrami operator and mean curvature in Eqs. (4)–(6).
Smoothing is an iterative procedure where in each iteration, all vertices are displaced simultaneously after calculating the displacements. A vertex \(x_i\) is displaced a distance \(\varDelta x_i\) along the surface unit normal vector \(\hat{n}(x_i)\) with \(\kappa _H(x_i)\) as the weight of displacement. Smoothing the solid–fluid and the fluid–fluid meshes are performed in a similar manner, except for the vertices lying on the three-phase contact line.
$$\begin{aligned} x_{i,new} &= x_{i,previous} - \varDelta x_i \end{aligned}$$
(9)
$$\begin{aligned} \varDelta x_{i,s} &= t_s \kappa _{H,s}(x_{i,s}) \hat{n}_s(x_{i,s}) \nonumber \\ \varDelta x_{i,f} &= t_f (\kappa _{H,f}(x_{i,f}) - \overline{\kappa _{H,f}}) \hat{n}_f(x_{i,f}) \nonumber \\ \varDelta x_{i,3} &= t_s \kappa _{H,s}(x_{i,3}) \hat{n}_s(x_{i,3}) + t_f (\kappa _{H,f}(x_{i,3}) -\overline{\kappa _{H,f}}) \hat{n}_f(x_{i,3}) \end{aligned}$$
(10)
The average mean curvature for individual fluid–fluid surfaces, \(\overline{\kappa _{H,f}}\) is updated for each iteration using Eq. (7). The coefficients \(0<t_s<1\) and \(0<t_f<1\) in (10) are tuning parameters used mainly to avoid too much displacement which can cause smoothing to diverge in meshes imitating complex porous structures. We start the smoothing with \(t_s=0.15\) and \(t_f=0.3\) and change the values in the iterations following a reward/penalty strategy, meaning that if for instance, solid–fluid mesh improves in one step \(t_s\) is multiplied by 1.05, and if it worsens, \(t_s\) is multiplied by 0.8 for the next step. Coefficient \(t_f\) is tuned with the same rule. This procedure was fixed after several test runs, and there is no theoretical reason for the choice of values for the coefficients. One can perform the iterations with both different initial values and multipliers for \(t_s\) and \(t_f\) and obtain smooth meshes as long as the smoothing does not diverge.
The displacement of all vertices is subject to the following two constraints.
$$ \begin{aligned} |\varDelta x_i |= \min(|\varDelta x_i |, 0.2) \\ |x_i - x_{i,{\rm initial}} |< \sqrt{3} \end{aligned}$$
(11)
First constraint in (11) ensures that \(x_i\) does not displace more than 0.2 voxel length at each iteration. The displacement is reduced to 0.2 voxel length, if it is larger than that. Second constraint ensures that \(x_i\) does not move farther than \(\sqrt{3}\) voxel length from its initial position. This value is the longest distance inside a voxel in the voxel grid. Maximum displacement of \(\sqrt{3}\) is associated with the uncertainty in the experimental images such that \(x_i\) could in reality be anywhere inside one voxel. In the images investigated, only a minor fraction of the vertices are moved a distance close to \(\sqrt{3}\) in voxel length. For instance, after smoothing a tomography image, mean displacements of vertices in solid–fluid surfaces, fluid–fluid surfaces, and three-phase contact lines were approximately 0.30, 0.30, 0.52 voxel length, respectively; vertices displaced more than \(0.95\sqrt{3}\) were only 0.20, 0.03, 0.02 percent of all vertices in those entities.
As mentioned earlier, for a smooth solid–fluid surface, mean curvatures are being minimized \(\kappa _{H,s}(x_i) \rightarrow 0\). It should be noted that \(\kappa _{H,s}(x_i)\) values are not becoming exactly zero because of the constraint in Eq. (11). The geometric implication is that for a solid–fluid surface throughout the iteration steps, the unit normal vectors of neighbor vertices align more parallel to each other once the surface is being smoothed, and their dot products approach unity. Therefore, we use \(\tau _s\),
$$\begin{aligned} \tau _s = 1-\frac{1}{E_s} \sum _{i=1}^{V_s} \sum _{j \in N_1(i)} \hat{n}_s(x_i). \hat{n}_s(x_j) \rightarrow 0 \end{aligned}$$
(12)
as the target of smoothing for the solid–fluid mesh, where \(V_s\) and \(E_s\) are the number of vertices and edges in the solid–fluid mesh.
For a smooth fluid–fluid surface, the mean curvatures approach an unknown constant value \(\kappa _{H,f}(x_i) \rightarrow \overline{\kappa _{H,f}}\). The standard deviation of \(\kappa _{H,f}(x_i)\) should be locally minimized for each interface. Therefore, the target for the entire domain can be minimizing average of the standard deviations, std, for all fluid–fluid surfaces, and Eq. (13) serves as the target for smoothing the fluid–fluid mesh.
$$\begin{aligned} \tau _f=\frac{1}{M} \sum _{m=1}^M std(\kappa _{H,f}) \rightarrow 0 \end{aligned}$$
(13)
In Eq. (13), M is the number of fluid–fluid interfaces in the mesh grid.
We use \(\tau \) and t variables to stop the iteration. Smoothing iterations continue as long as both \(\tau _s\) and \(\tau _f\) are reducing. If their minimum values are at the latest step, it means that they have not reached a minimum and smoothing is continued. The solid–fluid mesh often improves faster, and \(\tau _s\) can reach a minimum before \(\tau _f\). At this point, \(\tau _f\) has not reached a minimum and the iterations must be continued. In these conditions, the quality of solid–fluid mesh may degrade as \(\tau _s\) will start to increase. Therefore, the coefficient \(t_s\) in Eq. (10) reduces automatically to keep the changes in the solid–fluid mesh to a minimum. The reason we do not immediately set \(t_s=0\) is that the solid–fluid mesh in every iteration needs to be readjusted in the vicinity of the three-phase contact line when fluid–fluid mesh improves. With \(t_s=0\) and a changing fluid–fluid mesh, the line will be pulled out of the solid–fluid mesh. Once \(\tau _f\) has also passed a minimum and starts to increase, \(t_f\) in Eq. (10) will automatically reduce. At last, when both \(\tau _s\) and \(\tau _f\) have passed minima, and one of the tuning coefficients is \(t < 10^{-3}\), the smoothing stops after five more iterations, and the results of iteration with least \(\tau _f\) is picked up as the final result. At the end, the number of iterations is approximately in the range of 50–100. Figure 5 shows variations of contact angle, \(\tau _s\) and \(\tau _f\), as smoothing progresses in an analytical model of a sphere–plane geometry explained in the next section.
In a smooth mesh grid, \(\tau _s\) value is approximately in the order of \(10^{-3}\) with variations between two steps in the order of \(10^{-5}\); \(\tau _f\) is approximately in the order of \(10^{-2}\) with step variations in the order of \(10^{-3}\). Smoothing several experimental images showed that although cotangent discretization smoothes surfaces, it is not convergent in the sense that despite the point-wise values of \(\kappa _H\) become more uniform, they are not equal (Meyer et al. 2003; Xu 2013). Improvement slows down as smoothing progresses. The point-wise convergence may depend on the voxel grid resolution. In the next section, using analytical examples with known curvature and contact angles, we show that although point-wise \(\kappa _H\) is not convergent, average mean curvatures \(\overline{\kappa _H}\) and point-wise contact angles \(\theta \) are convergent when grid resolution is sufficient.