Xcompact3d is a high-performance CFD code for simulating turbulent flows. These flows require resolving a wide range of scales for which compact finite differences are well suited with so-called ‘quasi-spectral’ accuracy, combined with a compact stencil making them computationally efficient. As part of an EPCC-funded project to implement a free-surface solver in Xcompact3d, new differencing schemes capable of resolving the discontinuous changes in field variables without introducing spurious oscillations were required, to this end a fifth-order WENO scheme was implemented.
In this talk I will present the approach followed to implement the WENO scheme, rather than write it directly in the Xcompact3d source code, it was written as a ‘literate program’. This allows the description of the program and its implementation to be interleaved, easing review and understanding of the code. Furthermore by developing it externally it was trivial to develop it as a stand-alone module which could then be wrapped with f2py to quickly test the implementation – this all implemented within the same document. Once satisfied with the implementation, the exported Fortran code could then be integrated with the Xcompact3d code base with minimal changes.