Implementation errors in createBoxTurb utility
Dear ESI-OpenFOAM development team,
I use the OpenFOAM version 2112 and stumbled upon two implementation errors in the utility "createBoxTurb" which is used to initialize a homogeneous isotropic turbulent flow field based on the method published by Saad et al.
The first error is to be found here: /applications/utilities/preProcessing/createBoxTurb.C on the lines 63 and 64. In these lines, a random sample point on a unit sphere is created using spherical coordinates (s. Figure below).
However, the spherical coordinates provided here are wrong since they say
vector = (sin(thetam * cos(phim)), sin(thetam * sin(phim)), cos(thetam))
However, the correct spherical coordinates should be (also according to the original publication of Saad et al., equation 10):
vector = (sin(theta)*cos(phim), sin(thetam)*sin(phim), cos(thetam))
So it seems the brackets have been accidentally put into the wrong positions here.
The second error is to be found in the same file on line 155. Here, the vector sigmaHatm is to be normalized (s. Figure below)
Hence, the vector sigmaHatm is created via the equation: sigmaHatm = zetaHatm^kappaTildem/(mag(kappaTildem))
However, the correct normalization equation also provided by Saad et al. in equation 9 of the original publication would be:
sigmaHatm = zetaHatm^kappaTildem/(mag(zetaHatm^kappaTildem))
It would be great if the errors could be removed in a future release.
Furthermore, I have a suggestion for the further development of this utility. The method published by Saad et al. is specifically formulated for a staggered grid arrangement of the variables in the mesh in order to meet the the zero divergence criterion in a finite difference formulation. Hence, the vector kappaTildem is created from the vector kappaHatm in lines 144 to 148 of the code. However, since the velocity vectors U are initialized in the cell centres corresponding to a collocated grid arrangement, the formulation of the vector kappaTildem is not meaningful for the grid arrangement of OpenFOAM as far as I would say. Hence, I would suggest to simply delete the lines 144 to 148 in the code and replace all subsequent "kappaTildem" with "kappaHatm".
This is my first bug report and contribution to the OpenFOAM community so I am not quite firm in best practices for bug reporting. I hope that my bug report provides useful information and of course I am happy to respond if I have left anything unclear. Furthermore, I am very grateful for the utility createBoxTurb since it helps me a great deal with my research.
Best regards Mario Hermes