Patch contributed by Juho Peltola, VTT. Resolves patch request https://bugs.openfoam.org/view.php?id=2521