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.
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.
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?
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.