If I create a fipy 2D grid using:
mesh = Grid2D(nx=3, ny=3, dx=1., dy=1.)
I get a reasonable grid of rectangular elements. However, if I take the values of this mesh and use them to construct a vanilla Mesh2D
:
mesh2d = Mesh2D(mesh.vertexCoords, mesh.faceVertexIDs, mesh.cellFaceIDs)
I get a mesh that is triangular, and some of the triangles seem to be invalid. If I do this:
model = CellVariable(mesh=mesh2d, value=1.)
and view it with the matplotlib viewer, some of the triangles are unfilled, which I assume means they are not valid.
Can I recreate the original rectangular grid using Mesh2D
? I would like to do this because I have distorted rectangular grid coordinates from another source that I'd like substitute for mesh.vectorCoords
in the call to Mesh2D
. The face vertices and the cell faces are the same, it's just the mesh fabric that has been distorted.