I was running a 2D simulation that kept diverging over and over again (divergence occured after only a few time steps). I finally find out that it had to do with the mesh orientation in the z direction. simulation is in the xy plane but the surface normal vector was oriented in the negative z direction rather than the positive. flipping the orientation fixed the issue.
I think there should be some of warning when the orientation is wrong. or even better, an automatic fixing mechanism.
Thank you for your answer Freddie,
You say that Pyfr has code to detect flipped mesh orientation, but in my simulations an error was not raised. do you have any idea why? or any hunch?
I am asking because I found this error very difficult to trace, as the simulation simply diverged.
Hi Nigel
I am using GMSH 4.8.0, with openCASCADE (I am using the GUI)
the text of the geo file is at the bottom of the message and the geometry file can be found here.
The process I went through to generate the mesh was:
Set the “global model scaling” to 1e-3
Merge the geo file
Generate the mesh
Recombine using “recombine 2d”
I am sure there is a better way to do this but this is what i did.
Geo file:
Looking at the .geo and .msh files (and the resulting extremely small quads) any chance the offending Jacobian determinants might have had negative values, but “less negative” than the hard-wired [-1.0e-5]… that is to say, did some have values in the range (-1e-5 : 0] ?
Which makes me wonder, should the code also trap zero-valued dets?
when looking at the surface orientation in GMSH, it seems the orientation is simply negative, not near zero. also as I said flipping the surface orientation fixed the issue
I had a look at this and everything seems as is should in terms of the determinant, the lowest value is small but positive. And inspecting the smats, its seems to be performing as expected.
I think this issue is that in the code that finds the surface norms, _pnorm_fpts, I think there might be an assumption baked in that the mesh surface normal is in z +. And so I think, in 2D, it is possible that element have a positive jacobian, but the normals at the flux points are in the wrong direction. Does that seems possible @fdw? It should be possible to test the mesh surface normal by computing the cross product of two edge vectors and testing the sign.
Ok, that is alot clearer, disregaurd all of what I said previously. The determinants are negative, but small enough to slip by the test.
It is probably worth looking at modifying this test, maybe scaling it by some value from the mesh. Although a completely robust way of doing this is not easy.
Picking these kinds of numbers can be tricky. I’m open to suggestions. Generally, I am suspicious of elements with small Jacobian’s as they often cause issues in terms of numerical precision.