> On Feb 23, 2020, at 8:43 AM, A A wrote:
>
> Uncommenting line 7 of the above code reveals that resetting the cell type
> from 41 to 7 of the UniformGrid2D's underlying tvtk object allows the mesh to
> appear in the plotter.
>
> I recall from previous discussions that failure of cell type 41 to plot was
> attributed to incorrect ordering of the cell vertices, but this would be in
> contradiction with the results of the code above.
>From the [VTK
>documentation](https://vtk.org/doc/release/4.2/html/classvtkConvexPointSet.html),
> "vtkConvexPointSet is a concrete implementation that represents a 3D cell
>defined by a convex set of points." FiPy does not output vertices correctly
>for this 3D object. The fact that a Grid2D outputs its vertices in the correct
>order for a VTK_POLYGON does not change the fact that the ordering is wrong
>for VTK_CONVEX_POINT_SET.
The docstring for UniformGrid2D._calcOrderedCellVertexIDs says "Correct
ordering for VTK_PIXEL", but it does not do this. It produces the ordering for
VTK_QUAD (which also works for VTK_POLYGON).
The docstring for UniformGrid3D._calcOrderedCellVertexIDs correctly states
"Correct ordering for `VTK_VOXEL`".
The proper interim fix is to make the following changes:
diff --git a/fipy/meshes/nonUniformGrid3D.py b/fipy/meshes/nonUniformGrid3D.py
index 8e78c5319..03097e2b7 100644
--- a/fipy/meshes/nonUniformGrid3D.py
+++ b/fipy/meshes/nonUniformGrid3D.py
@@ -116,6 +116,14 @@ class NonUniformGrid3D(Mesh):
faceTangents2[2, self.numberOfXYFaces + self.numberOfXZFaces:] = 1.
return faceTangents1, faceTangents2
+@property
+def _VTKCellType(self):
+try:
+from tvtk.api import tvtk
+except ImportError as e:
+from enthought.tvtk.api import tvtk
+return tvtk.Voxel().cell_type
+
## The following method is broken when dx, dy or dz are not scalar. Simpler to
use the generic
## _calcFaceAreas rather than do the required type checking, resizing and
outer product.
##
diff --git a/fipy/meshes/uniformGrid1D.py b/fipy/meshes/uniformGrid1D.py
index 041f8ed9d..931f3f708 100644
--- a/fipy/meshes/uniformGrid1D.py
+++ b/fipy/meshes/uniformGrid1D.py
@@ -288,6 +288,14 @@ class UniformGrid1D(UniformGrid):
c1 = numerix.arange(self.numberOfCells)
return numerix.array((c1 + 1, c1))
+@property
+def _VTKCellType(self):
+try:
+from tvtk.api import tvtk
+except ImportError as e:
+from enthought.tvtk.api import tvtk
+return tvtk.Line().cell_type
+
def _getNearestCellID(self, points):
"""
Test cases
diff --git a/fipy/meshes/uniformGrid2D.py b/fipy/meshes/uniformGrid2D.py
index 16815c689..37d3ebfa6 100644
--- a/fipy/meshes/uniformGrid2D.py
+++ b/fipy/meshes/uniformGrid2D.py
@@ -560,6 +560,14 @@ class UniformGrid2D(UniformGrid):
return ids.reshape((4, self.numberOfCells), order='F')
+@property
+def _VTKCellType(self):
+try:
+from tvtk.api import tvtk
+except ImportError as e:
+from enthought.tvtk.api import tvtk
+return tvtk.Quad().cell_type
+
def _getNearestCellID(self, points):
"""
Test cases
diff --git a/fipy/meshes/uniformGrid3D.py b/fipy/meshes/uniformGrid3D.py
index 4ad7a3b69..29990f53e 100644
--- a/fipy/meshes/uniformGrid3D.py
+++ b/fipy/meshes/uniformGrid3D.py
@@ -491,6 +491,14 @@ class UniformGrid3D(UniformGrid):
return numerix.reshape(ids.swapaxes(1, 3), (8, self.numberOfCells))
+@property
+def _VTKCellType(self):
+try:
+from tvtk.api import tvtk
+except ImportError as e:
+from enthought.tvtk.api import tvtk
+return tvtk.Voxel().cell_type
+
## scaling
def _getNearestCellID(self, points):
This will fix the Grid classes. It definitely doesn't fix arbitrary 3D meshes.
___
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]