Dear PyFR developers,
In our in-house Spectral-Differences (SD) code, we have recently found a small bug related to the gradient computation. This bug was discovered by testing the k-exact properties of the gradient operator.
I first implemented this test in PyFR to better understand if our error was related to the implementation or the formulation of the method.
This allowed to verify that the error we observed was indeed a bug and not a consequence of the method formulation.
I think that PyFR could benefit from the addition of such tests to help debug future issues, to ease the implementation of new features (ie non-linear cells), to assess very bad-quality meshes, etc.
Let me first briefly describe what a mean by k-exactness of the operators.
Suppose that the solution points of all mesh elements are initialized with a polynomial of the type P(x, y, z) = (x + y + z)^p, where (x, y, z) represents the solution points position in physical space.
A FR scheme which presents local p+1 degree interpolation errors, should be capable of reconstructing the value of this polynomial at any point of the domain from the value of the polynomial at the solution points.
This also implies that the gradient \nabla P should also be exactly reconstructed at any point.
One can validate the numerical implementation of the operators by using the previously described properties.
In particular the following checks seem interesting to me:
- Computation of the gradient at the solution points (operator M4)
- Interpolation from solution points to flux points (operator M0)
- Computation of the divergence at solution points from the values at the flux points (operator M3). Here one should use a vector of polynomials.
- Testing the connectivity of the face elements by assessing if the left and right reconstruction states of connected flux points are the same up to machine precision (there is a small caveat for periodic boundaries which I can further describe in future comments). This allows to validate the connectivity of the local and MPI flux points.
Would you be interested in adding these kind of tests to PyFR? I have already implemented some of them. However, I’m sure that there a lot of implementation details to be discussed before including these tests in the code suite.
Regards,
Gonzalo