Skip to content

2008%2F02%2F08%2F09.46

Jonathan Guyer edited this page Sep 26, 2014 · 1 revision

Backwards faceGrad on `Gmsh` meshes

Working on source:branches/version-1_2, although problem affects all current versions of FiPy.

Trying to diagnose what 's going on with backwards gradients on `Gmsh meshes, e.g., for $\phi = x$, we would expect the $\nabla \phi$ vectors to all be unit vectors pointing to the right (with some slop due to the non-orthogonality of the mesh)

Image(source:branches/version-1_2/normalsAndGrads.png@2458,50%)

[source:branches/version-1_2/fipy/meshes/numMesh/mesh.py@2458#L463] and [source:branches/version-1_2/fipy/meshes/numMesh/mesh2D.py@2458#L70] should definitely not assume so much about vertex ordering.

When the normal orientation is corrected (r2459), the gradient vectors become totally nonsensical, but only in some places, instead of just backwards:

Image(source:branches/version-1_2/normalsAndGrads.png@2459,50%)

The gradient on most faces seems properly reversed, but faces 6, 9, 10, & 11 are of substantially different magnitude and orientation from what is expected.

I think the problem may be that the exterior normals (3, 8 & 16) point in instead of out. This would lead to the wrong sign of contribution to the `Cell` gradient, which would give an erroneous contribution to the tangential part of the `Face` gradient. So, now to figure out how to flip it (noting that face 0 is pointed out for some reason).

That wasn't too bad: `Mesh.cellToFaceDistanceVectors` actually held `Face`-to-`Cell` distances. Fixed in r2460. `Face` 0 pointed out already because `Cell` 0 actually lies a tiny bit outside the square domain. Apparently doesn't matter for anything because `Cell` 0 has essentially zero volume.

Image(source:branches/version-1_2/normalsAndGrads.png@2460,50%)

Now to make sure that nothing else got broken and then port the fixes over to source:trunk and other branches.

is producing some new formatting errors. r2461 fixes that.

A variety of other meshes look good:

Image(source:branches/version-1_2/normalsAndGradsTri2D.png@2462,30%) Image(source:branches/version-1_2/normalsAndGradsGrid2D.png@2462,30%) Image(source:branches/version-1_2/normalsAndGradsGrid2D.png@2463,30%)

All (expected) tests pass.

Clone this wiki locally