Remove VTKM_EXEC_CONSTANT

If a global static array is declared with VTKM_EXEC_CONSTANT and the code
is compiled by nvcc (for multibackend code) then the array is only accesible
on the GPU. If for some reason a worklet fails on the cuda backend and it is
re-executed on any of the CPU backends, it will continue to fail.

We couldn't find a simple way to declare the array once and have it available
on both CPU and GPU. The approach we are using here is to declare the arrays
as static inside some "Get" function which is marked as VTKM_EXEC_CONT.
This commit is contained in:
Sujin Philip 2017-12-05 13:42:03 -05:00
parent 1d58eeaa9e
commit e28309f09b
15 changed files with 795 additions and 711 deletions

@ -56,12 +56,6 @@ struct VecAxisAlignedPointCoordinatesNumComponents<3>
static const vtkm::IdComponent NUM_COMPONENTS = 8;
};
VTKM_EXEC_CONSTANT
const vtkm::FloatDefault VecAxisAlignedPointCoordinatesOffsetTable[8][3] = {
{ 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f }
};
} // namespace detail
/// \brief An implicit vector for point coordinates in axis aligned cells. For
@ -110,7 +104,12 @@ public:
VTKM_EXEC_CONT
ComponentType operator[](vtkm::IdComponent index) const
{
const vtkm::FloatDefault* offset = detail::VecAxisAlignedPointCoordinatesOffsetTable[index];
static const vtkm::FloatDefault VecAxisAlignedPointCoordinatesOffsetTable[8][3] = {
{ 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f }
};
const auto& offset = VecAxisAlignedPointCoordinatesOffsetTable[index];
return ComponentType(this->Origin[0] + offset[0] * this->Spacing[0],
this->Origin[1] + offset[1] * this->Spacing[1],
this->Origin[2] + offset[2] * this->Spacing[2]);

@ -17,8 +17,8 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_exec_CellFaces_h
#define vtk_m_exec_CellFaces_h
#ifndef vtk_m_exec_CellEdge_h
#define vtk_m_exec_CellEdge_h
#include <vtkm/Assert.h>
#include <vtkm/CellShape.h>
@ -35,224 +35,241 @@ namespace exec
namespace detail
{
static const vtkm::IdComponent MAX_NUM_EDGES = 12;
class CellEdgeTables
{
public:
static const vtkm::IdComponent MAX_NUM_EDGES = 12;
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent NumEdges[vtkm::NUMBER_OF_CELL_SHAPES] = {
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
3, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
-1, // 7: CELL_SHAPE_POLYGON ---special case---
0, // 8: Unused
4, // 9: CELL_SHAPE_QUAD
6, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
12, // 12: CELL_SHAPE_HEXAHEDRON
9, // 13: CELL_SHAPE_WEDGE
8 // 14: CELL_SHAPE_PYRAMID
};
private:
struct Tables
{
vtkm::IdComponent NumEdges[vtkm::NUMBER_OF_CELL_SHAPES];
vtkm::IdComponent PointsInEdge[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_EDGES][2];
};
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent PointsInEdge[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_EDGES][2] = {
// 0: CELL_SHAPE_EMPTY
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 1: CELL_SHAPE_VERTEX
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 2: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 3: CELL_SHAPE_LINE
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 4: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 5: CELL_SHAPE_TRIANGLE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 6: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 7: CELL_SHAPE_POLYGON --- special case ---
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 8: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 9: CELL_SHAPE_QUAD
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 10: CELL_SHAPE_TETRA
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 0, 3 },
{ 1, 3 },
{ 2, 3 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 11: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 12: CELL_SHAPE_HEXAHEDRON
{ { 0, 1 },
{ 1, 2 },
{ 3, 2 },
{ 0, 3 },
{ 4, 5 },
{ 5, 6 },
{ 7, 6 },
{ 4, 7 },
{ 0, 4 },
{ 1, 5 },
{ 3, 7 },
{ 2, 6 } },
// 13: CELL_SHAPE_WEDGE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 3, 4 },
{ 4, 5 },
{ 5, 3 },
{ 0, 3 },
{ 1, 4 },
{ 2, 5 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 14: CELL_SHAPE_PYRAMID
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ 0, 4 },
{ 1, 4 },
{ 2, 4 },
{ 3, 4 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
public:
VTKM_EXEC_CONT static const Tables& Get()
{
static const Tables table = { {
// NumEdges
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
3, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
-1, // 7: CELL_SHAPE_POLYGON ---special case---
0, // 8: Unused
4, // 9: CELL_SHAPE_QUAD
6, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
12, // 12: CELL_SHAPE_HEXAHEDRON
9, // 13: CELL_SHAPE_WEDGE
8 // 14: CELL_SHAPE_PYRAMID
},
{
// PointsInEdge
// 0: CELL_SHAPE_EMPTY
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 1: CELL_SHAPE_VERTEX
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 2: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 3: CELL_SHAPE_LINE
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 4: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 5: CELL_SHAPE_TRIANGLE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 6: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 7: CELL_SHAPE_POLYGON --- special case ---
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 8: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 9: CELL_SHAPE_QUAD
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 10: CELL_SHAPE_TETRA
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 0, 3 },
{ 1, 3 },
{ 2, 3 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 11: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 12: CELL_SHAPE_HEXAHEDRON
{ { 0, 1 },
{ 1, 2 },
{ 3, 2 },
{ 0, 3 },
{ 4, 5 },
{ 5, 6 },
{ 7, 6 },
{ 4, 7 },
{ 0, 4 },
{ 1, 5 },
{ 3, 7 },
{ 2, 6 } },
// 13: CELL_SHAPE_WEDGE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 3, 4 },
{ 4, 5 },
{ 5, 3 },
{ 0, 3 },
{ 1, 4 },
{ 2, 5 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 14: CELL_SHAPE_PYRAMID
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ 0, 4 },
{ 1, 4 },
{ 2, 4 },
{ 3, 4 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
} };
return table;
}
};
} // namespace detail
@ -264,7 +281,7 @@ static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(vtkm::IdComponen
{
(void)numPoints; // Silence compiler warnings.
VTKM_ASSERT(numPoints == vtkm::CellTraits<CellShapeTag>::NUM_POINTS);
return detail::NumEdges[CellShapeTag::Id];
return detail::CellEdgeTables::Get().NumEdges[CellShapeTag::Id];
}
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
@ -286,7 +303,7 @@ static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
}
else
{
return detail::NumEdges[shape.Id];
return detail::CellEdgeTables::Get().NumEdges[shape.Id];
}
}
@ -298,15 +315,15 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
const vtkm::exec::FunctorBase& worklet)
{
VTKM_ASSUME(edgeIndex >= 0);
VTKM_ASSUME(edgeIndex < detail::MAX_NUM_EDGES);
VTKM_ASSUME(edgeIndex < detail::CellEdgeTables::MAX_NUM_EDGES);
if (edgeIndex >= vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, worklet))
{
worklet.RaiseError("Invalid edge number.");
return vtkm::Vec<vtkm::IdComponent, 2>(0);
}
return vtkm::make_Vec(detail::PointsInEdge[CellShapeTag::Id][edgeIndex][0],
detail::PointsInEdge[CellShapeTag::Id][edgeIndex][1]);
return vtkm::make_Vec(detail::CellEdgeTables::Get().PointsInEdge[CellShapeTag::Id][edgeIndex][0],
detail::CellEdgeTables::Get().PointsInEdge[CellShapeTag::Id][edgeIndex][1]);
}
static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
@ -336,7 +353,7 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
const vtkm::exec::FunctorBase& worklet)
{
VTKM_ASSUME(edgeIndex >= 0);
VTKM_ASSUME(edgeIndex < detail::MAX_NUM_EDGES);
VTKM_ASSUME(edgeIndex < detail::CellEdgeTables::MAX_NUM_EDGES);
if (shape.Id == vtkm::CELL_SHAPE_POLYGON)
{
@ -344,14 +361,14 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
}
else
{
if (edgeIndex >= detail::NumEdges[shape.Id])
if (edgeIndex >= detail::CellEdgeTables::Get().NumEdges[shape.Id])
{
worklet.RaiseError("Invalid edge number.");
return vtkm::Vec<vtkm::IdComponent, 2>(0);
}
return vtkm::make_Vec(detail::PointsInEdge[shape.Id][edgeIndex][0],
detail::PointsInEdge[shape.Id][edgeIndex][1]);
return vtkm::make_Vec(detail::CellEdgeTables::Get().PointsInEdge[shape.Id][edgeIndex][0],
detail::CellEdgeTables::Get().PointsInEdge[shape.Id][edgeIndex][1]);
}
}

@ -34,157 +34,174 @@ namespace exec
namespace detail
{
static const vtkm::IdComponent MAX_FACE_SIZE = 4;
static const vtkm::IdComponent MAX_NUM_FACES = 6;
class CellFaceTables
{
public:
static const vtkm::IdComponent MAX_FACE_SIZE = 4;
static const vtkm::IdComponent MAX_NUM_FACES = 6;
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent NumFaces[vtkm::NUMBER_OF_CELL_SHAPES] = {
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
0, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
0, // 7: CELL_SHAPE_POLYGON
0, // 8: Unused
0, // 9: CELL_SHAPE_QUAD
4, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
6, // 12: CELL_SHAPE_HEXAHEDRON
5, // 13: CELL_SHAPE_WEDGE
5 // 14: CELL_SHAPE_PYRAMID
private:
struct Tables
{
vtkm::IdComponent NumFaces[vtkm::NUMBER_OF_CELL_SHAPES];
vtkm::IdComponent NumPointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES];
vtkm::IdComponent PointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES][MAX_FACE_SIZE];
};
public:
VTKM_EXEC_CONT
static const Tables& Get()
{
static const Tables table = { // NumFaces
{
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
0, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
0, // 7: CELL_SHAPE_POLYGON
0, // 8: Unused
0, // 9: CELL_SHAPE_QUAD
4, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
6, // 12: CELL_SHAPE_HEXAHEDRON
5, // 13: CELL_SHAPE_WEDGE
5 // 14: CELL_SHAPE_PYRAMID
},
// NumPointsInFace
{
{ -1, -1, -1, -1, -1, -1 }, // 0: CELL_SHAPE_EMPTY
{ -1, -1, -1, -1, -1, -1 }, // 1: CELL_SHAPE_VERTEX
{ -1, -1, -1, -1, -1, -1 }, // 2: Unused
{ -1, -1, -1, -1, -1, -1 }, // 3: CELL_SHAPE_LINE
{ -1, -1, -1, -1, -1, -1 }, // 4: Unused
{ -1, -1, -1, -1, -1, -1 }, // 5: CELL_SHAPE_TRIANGLE
{ -1, -1, -1, -1, -1, -1 }, // 6: Unused
{ -1, -1, -1, -1, -1, -1 }, // 7: CELL_SHAPE_POLYGON
{ -1, -1, -1, -1, -1, -1 }, // 8: Unused
{ -1, -1, -1, -1, -1, -1 }, // 9: CELL_SHAPE_QUAD
{ 3, 3, 3, 3, -1, -1 }, // 10: CELL_SHAPE_TETRA
{ -1, -1, -1, -1, -1, -1 }, // 11: Unused
{ 4, 4, 4, 4, 4, 4 }, // 12: CELL_SHAPE_HEXAHEDRON
{ 3, 3, 4, 4, 4, -1 }, // 13: CELL_SHAPE_WEDGE
{ 4, 3, 3, 3, 3, -1 } // 14: CELL_SHAPE_PYRAMID
},
// PointsInFace
{ // 0: CELL_SHAPE_EMPTY
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 1: CELL_SHAPE_VERTEX
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 2: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 3: CELL_SHAPE_LINE
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 4: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 5: CELL_SHAPE_TRIANGLE
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 6: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 7: CELL_SHAPE_POLYGON
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 8: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 9: CELL_SHAPE_QUAD
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 10: CELL_SHAPE_TETRA
{ { 0, 1, 3, -1 },
{ 1, 2, 3, -1 },
{ 2, 0, 3, -1 },
{ 0, 2, 1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 11: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 12: CELL_SHAPE_HEXAHEDRON
{ { 0, 4, 7, 3 },
{ 1, 2, 6, 5 },
{ 0, 1, 5, 4 },
{ 3, 7, 6, 2 },
{ 0, 3, 2, 1 },
{ 4, 5, 6, 7 } },
// 13: CELL_SHAPE_WEDGE
{ { 0, 1, 2, -1 },
{ 3, 5, 4, -1 },
{ 0, 3, 4, 1 },
{ 1, 4, 5, 2 },
{ 2, 5, 3, 0 },
{ -1, -1, -1, -1 } },
// 14: CELL_SHAPE_PYRAMID
{ { 0, 3, 2, 1 },
{ 0, 1, 4, -1 },
{ 1, 2, 4, -1 },
{ 2, 3, 4, -1 },
{ 3, 0, 4, -1 },
{ -1, -1, -1, -1 } } }
};
return table;
}
};
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent NumPointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES] = {
{ -1, -1, -1, -1, -1, -1 }, // 0: CELL_SHAPE_EMPTY
{ -1, -1, -1, -1, -1, -1 }, // 1: CELL_SHAPE_VERTEX
{ -1, -1, -1, -1, -1, -1 }, // 2: Unused
{ -1, -1, -1, -1, -1, -1 }, // 3: CELL_SHAPE_LINE
{ -1, -1, -1, -1, -1, -1 }, // 4: Unused
{ -1, -1, -1, -1, -1, -1 }, // 5: CELL_SHAPE_TRIANGLE
{ -1, -1, -1, -1, -1, -1 }, // 6: Unused
{ -1, -1, -1, -1, -1, -1 }, // 7: CELL_SHAPE_POLYGON
{ -1, -1, -1, -1, -1, -1 }, // 8: Unused
{ -1, -1, -1, -1, -1, -1 }, // 9: CELL_SHAPE_QUAD
{ 3, 3, 3, 3, -1, -1 }, // 10: CELL_SHAPE_TETRA
{ -1, -1, -1, -1, -1, -1 }, // 11: Unused
{ 4, 4, 4, 4, 4, 4 }, // 12: CELL_SHAPE_HEXAHEDRON
{ 3, 3, 4, 4, 4, -1 }, // 13: CELL_SHAPE_WEDGE
{ 4, 3, 3, 3, 3, -1 } // 14: CELL_SHAPE_PYRAMID
};
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent PointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES]
[MAX_FACE_SIZE] = {
// 0: CELL_SHAPE_EMPTY
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 1: CELL_SHAPE_VERTEX
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 2: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 3: CELL_SHAPE_LINE
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 4: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 5: CELL_SHAPE_TRIANGLE
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 6: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 7: CELL_SHAPE_POLYGON
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 8: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 9: CELL_SHAPE_QUAD
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 10: CELL_SHAPE_TETRA
{ { 0, 1, 3, -1 },
{ 1, 2, 3, -1 },
{ 2, 0, 3, -1 },
{ 0, 2, 1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 11: Unused
{ { -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 },
{ -1, -1, -1, -1 } },
// 12: CELL_SHAPE_HEXAHEDRON
{ { 0, 4, 7, 3 },
{ 1, 2, 6, 5 },
{ 0, 1, 5, 4 },
{ 3, 7, 6, 2 },
{ 0, 3, 2, 1 },
{ 4, 5, 6, 7 } },
// 13: CELL_SHAPE_WEDGE
{ { 0, 1, 2, -1 },
{ 3, 5, 4, -1 },
{ 0, 3, 4, 1 },
{ 1, 4, 5, 2 },
{ 2, 5, 3, 0 },
{ -1, -1, -1, -1 } },
// 14: CELL_SHAPE_PYRAMID
{ { 0, 3, 2, 1 },
{ 0, 1, 4, -1 },
{ 1, 2, 4, -1 },
{ 2, 3, 4, -1 },
{ 3, 0, 4, -1 },
{ -1, -1, -1, -1 } }
};
} // namespace detail
template <typename CellShapeTag>
@ -192,7 +209,7 @@ static inline VTKM_EXEC vtkm::IdComponent CellFaceNumberOfFaces(CellShapeTag sha
const vtkm::exec::FunctorBase&)
{
(void)shape; //C4100 false positive workaround
return detail::NumFaces[shape.Id];
return detail::CellFaceTables::Get().NumFaces[shape.Id];
}
template <typename CellShapeTag>
@ -202,14 +219,14 @@ static inline VTKM_EXEC vtkm::IdComponent CellFaceNumberOfPoints(
const vtkm::exec::FunctorBase& worklet)
{
VTKM_ASSUME(faceIndex >= 0);
VTKM_ASSUME(faceIndex < detail::MAX_NUM_FACES);
VTKM_ASSUME(faceIndex < detail::CellFaceTables::MAX_NUM_FACES);
if (faceIndex >= vtkm::exec::CellFaceNumberOfFaces(shape, worklet))
{
worklet.RaiseError("Invalid face number.");
return 0;
}
return detail::NumPointsInFace[shape.Id][faceIndex];
return detail::CellFaceTables::Get().NumPointsInFace[shape.Id][faceIndex];
}
template <typename CellShapeTag>
@ -218,7 +235,7 @@ static inline VTKM_EXEC vtkm::UInt8 CellFaceShape(vtkm::IdComponent faceIndex,
const vtkm::exec::FunctorBase& worklet)
{
VTKM_ASSUME(faceIndex >= 0);
VTKM_ASSUME(faceIndex < detail::MAX_NUM_FACES);
VTKM_ASSUME(faceIndex < detail::CellFaceTables::MAX_NUM_FACES);
switch (CellFaceNumberOfPoints(faceIndex, shape, worklet))
{
case 3:
@ -244,7 +261,8 @@ static inline VTKM_EXEC vtkm::VecCConst<vtkm::IdComponent> CellFaceLocalIndices(
return vtkm::VecCConst<vtkm::IdComponent>();
}
return vtkm::make_VecC(detail::PointsInFace[shape.Id][faceIndex], numPointsInFace);
return vtkm::make_VecC(detail::CellFaceTables::Get().PointsInFace[shape.Id][faceIndex],
numPointsInFace);
}
/// \brief Returns a canonical identifer for a cell face

@ -34,12 +34,10 @@
#else
#define VTKM_SUPPRESS_EXEC_WARNINGS #pragma hd_warning_disable
#endif
#define VTKM_EXEC_CONSTANT __device__ __constant__
#else
#define VTKM_EXEC
#define VTKM_EXEC_CONT
#define VTKM_SUPPRESS_EXEC_WARNINGS
#define VTKM_EXEC_CONSTANT
#endif
#define VTKM_CONT

@ -47,8 +47,10 @@ VTKM_EXEC_CONT inline void IntersectZoo(T xpoints[8],
vtkm::Int32 kx, ky, kz;
WaterTight<T> intersector;
intersector.FindDir(dir, sx, sy, sz, kx, ky, kz);
const vtkm::Int32 tableOffset = ZooLookUp[CellTypeLookUp[shapeType]][0];
const vtkm::Int32 numTriangles = ZooLookUp[CellTypeLookUp[shapeType]][1];
const vtkm::Int32 tableOffset =
CellTables::Get().ZooLookUp[CellTables::Get().CellTypeLookUp[shapeType]][0];
const vtkm::Int32 numTriangles =
CellTables::Get().ZooLookUp[CellTables::Get().CellTypeLookUp[shapeType]][1];
// Decompose each face into two triangles
for (int i = 0; i < 6; ++i)
distances[i] = -1.;
@ -56,16 +58,16 @@ VTKM_EXEC_CONT inline void IntersectZoo(T xpoints[8],
{
const vtkm::Int32 offset = tableOffset + i;
vtkm::Vec<T, 3> a, c, b;
a[0] = xpoints[ZooTable[offset][1]];
a[1] = ypoints[ZooTable[offset][1]];
a[2] = zpoints[ZooTable[offset][1]];
b[0] = xpoints[ZooTable[offset][2]];
b[1] = ypoints[ZooTable[offset][2]];
b[2] = zpoints[ZooTable[offset][2]];
c[0] = xpoints[ZooTable[offset][3]];
c[1] = ypoints[ZooTable[offset][3]];
c[2] = zpoints[ZooTable[offset][3]];
const vtkm::Int32 faceId = ZooTable[offset][0];
a[0] = xpoints[CellTables::Get().ZooTable[offset][1]];
a[1] = ypoints[CellTables::Get().ZooTable[offset][1]];
a[2] = zpoints[CellTables::Get().ZooTable[offset][1]];
b[0] = xpoints[CellTables::Get().ZooTable[offset][2]];
b[1] = ypoints[CellTables::Get().ZooTable[offset][2]];
b[2] = zpoints[CellTables::Get().ZooTable[offset][2]];
c[0] = xpoints[CellTables::Get().ZooTable[offset][3]];
c[1] = ypoints[CellTables::Get().ZooTable[offset][3]];
c[2] = zpoints[CellTables::Get().ZooTable[offset][3]];
const vtkm::Int32 faceId = CellTables::Get().ZooTable[offset][0];
T distance = -1.f;
T uNotUsed, vNotUsed;
@ -111,18 +113,18 @@ VTKM_EXEC_CONT inline void IntersectHex(T xpoints[8],
for (int i = 0; i < 6; ++i)
{
vtkm::Vec<T, 3> a, c, b, d;
a[0] = xpoints[ShapesFaceList[i][1]];
a[1] = ypoints[ShapesFaceList[i][1]];
a[2] = zpoints[ShapesFaceList[i][1]];
b[0] = xpoints[ShapesFaceList[i][2]];
b[1] = ypoints[ShapesFaceList[i][2]];
b[2] = zpoints[ShapesFaceList[i][2]];
c[0] = xpoints[ShapesFaceList[i][3]];
c[1] = ypoints[ShapesFaceList[i][3]];
c[2] = zpoints[ShapesFaceList[i][3]];
d[0] = xpoints[ShapesFaceList[i][4]];
d[1] = ypoints[ShapesFaceList[i][4]];
d[2] = zpoints[ShapesFaceList[i][4]];
a[0] = xpoints[CellTables::Get().ShapesFaceList[i][1]];
a[1] = ypoints[CellTables::Get().ShapesFaceList[i][1]];
a[2] = zpoints[CellTables::Get().ShapesFaceList[i][1]];
b[0] = xpoints[CellTables::Get().ShapesFaceList[i][2]];
b[1] = ypoints[CellTables::Get().ShapesFaceList[i][2]];
b[2] = zpoints[CellTables::Get().ShapesFaceList[i][2]];
c[0] = xpoints[CellTables::Get().ShapesFaceList[i][3]];
c[1] = ypoints[CellTables::Get().ShapesFaceList[i][3]];
c[2] = zpoints[CellTables::Get().ShapesFaceList[i][3]];
d[0] = xpoints[CellTables::Get().ShapesFaceList[i][4]];
d[1] = ypoints[CellTables::Get().ShapesFaceList[i][4]];
d[2] = zpoints[CellTables::Get().ShapesFaceList[i][4]];
T distance = -1.f;
distances[i] = distance; //init to -1
@ -189,19 +191,20 @@ VTKM_EXEC_CONT inline void IntersectTet(T xpoints[8],
WaterTight<T> intersector;
intersector.FindDir(dir, sx, sy, sz, kx, ky, kz);
const vtkm::Int32 tableOffset = FaceLookUp[CellTypeLookUp[CELL_SHAPE_TETRA]][0];
const vtkm::Int32 tableOffset =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[CELL_SHAPE_TETRA]][0];
for (vtkm::Int32 i = 0; i < 4; ++i)
{
vtkm::Vec<T, 3> a, c, b;
a[0] = xpoints[ShapesFaceList[i + tableOffset][1]];
a[1] = ypoints[ShapesFaceList[i + tableOffset][1]];
a[2] = zpoints[ShapesFaceList[i + tableOffset][1]];
b[0] = xpoints[ShapesFaceList[i + tableOffset][2]];
b[1] = ypoints[ShapesFaceList[i + tableOffset][2]];
b[2] = zpoints[ShapesFaceList[i + tableOffset][2]];
c[0] = xpoints[ShapesFaceList[i + tableOffset][3]];
c[1] = ypoints[ShapesFaceList[i + tableOffset][3]];
c[2] = zpoints[ShapesFaceList[i + tableOffset][3]];
a[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][1]];
a[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][1]];
a[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][1]];
b[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][2]];
b[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][2]];
b[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][2]];
c[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][3]];
c[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][3]];
c[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][3]];
T distance = -1.f;
distances[i] = distance; //init to -1
@ -245,23 +248,24 @@ VTKM_EXEC_CONT inline void IntersectWedge(T xpoints[8],
WaterTight<T> intersector;
intersector.FindDir(dir, sx, sy, sz, kx, ky, kz);
// TODO: try two sepate loops to see performance impact
const vtkm::Int32 tableOffset = FaceLookUp[CellTypeLookUp[CELL_SHAPE_WEDGE]][0];
const vtkm::Int32 tableOffset =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[CELL_SHAPE_WEDGE]][0];
// Decompose each face into two triangles
for (int i = 0; i < 5; ++i)
{
vtkm::Vec<T, 3> a, c, b, d;
a[0] = xpoints[ShapesFaceList[i + tableOffset][1]];
a[1] = ypoints[ShapesFaceList[i + tableOffset][1]];
a[2] = zpoints[ShapesFaceList[i + tableOffset][1]];
b[0] = xpoints[ShapesFaceList[i + tableOffset][2]];
b[1] = ypoints[ShapesFaceList[i + tableOffset][2]];
b[2] = zpoints[ShapesFaceList[i + tableOffset][2]];
c[0] = xpoints[ShapesFaceList[i + tableOffset][3]];
c[1] = ypoints[ShapesFaceList[i + tableOffset][3]];
c[2] = zpoints[ShapesFaceList[i + tableOffset][3]];
d[0] = xpoints[ShapesFaceList[i + tableOffset][4]];
d[1] = ypoints[ShapesFaceList[i + tableOffset][4]];
d[2] = zpoints[ShapesFaceList[i + tableOffset][4]];
a[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][1]];
a[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][1]];
a[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][1]];
b[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][2]];
b[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][2]];
b[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][2]];
c[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][3]];
c[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][3]];
c[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][3]];
d[0] = xpoints[CellTables::Get().ShapesFaceList[i + tableOffset][4]];
d[1] = ypoints[CellTables::Get().ShapesFaceList[i + tableOffset][4]];
d[2] = zpoints[CellTables::Get().ShapesFaceList[i + tableOffset][4]];
T distance = -1.f;
distances[i] = distance; //init to -1

@ -30,100 +30,114 @@ namespace rendering
namespace raytracing
{
//LookUp of Shapes to FaceLookUp
VTKM_EXEC_CONSTANT
static vtkm::Int32 CellTypeLookUp[15] = {
4, // 0 Nothing
4, // 1 Vertex
4, // 2 (Not Used) Poly Vertex
4, // 3 Line
4, // 4 (Not Used) Poly Line
4, // 5 Triangle
4, // 6 (not used) triangle strip
4, // 7 Polygon
4, // 8 (Not used)Pixel
4, // 9 Quad
1, // 10 Tetra
4, // 11 (Not used) Voxel
0, // 12 Hex
2, // 13 Wedge
3 // 14 Pyramid
};
class CellTables
{
private:
struct Tables
{
vtkm::Int32 CellTypeLookUp[15];
vtkm::Int32 FaceLookUp[5][3];
vtkm::Int32 ShapesFaceList[20][5];
vtkm::Int32 ZooTable[30][4];
vtkm::Int32 ZooLookUp[5][2];
};
VTKM_EXEC_CONSTANT
static vtkm::Int32 FaceLookUp[5][3] = {
{ 0, 6, 8 }, //hex offset into shapes face list, num faces and number of Indices
{ 6, 4, 4 }, //tet
{ 10, 5, 6 }, //wedge
{ 15, 5, 5 }, //pyramid
{ -1, 0, 0 } //unsupported shape
};
public:
VTKM_EXEC_CONT static const Tables& Get()
{
static const Tables tables = {
// CellTypeLookUp: LookUp of Shapes to FaceLookUp
{
4, // 0 Nothing
4, // 1 Vertex
4, // 2 (Not Used) Poly Vertex
4, // 3 Line
4, // 4 (Not Used) Poly Line
4, // 5 Triangle
4, // 6 (not used) triangle strip
4, // 7 Polygon
4, // 8 (Not used)Pixel
4, // 9 Quad
1, // 10 Tetra
4, // 11 (Not used) Voxel
0, // 12 Hex
2, // 13 Wedge
3 // 14 Pyramid
},
// The convention for the faces is that looking from the outside of
// the shape at a face, triangles should wind CCW.
// Quads are broken up by {4=quad,a,b,c,d}:
// t1 = abc and t2 = acd. Indices of the face are ordered CW, and the mapping
// of t1 and t2 become CCW.
// Since we know the triangle winding, we could tell
// if we hit an inside face or outside face.
VTKM_EXEC_CONSTANT
static vtkm::Int32 ShapesFaceList[20][5] = {
//hex
{ 4, 0, 1, 5, 4 }, //face 0
{ 4, 1, 2, 6, 5 },
{ 4, 3, 7, 6, 2 },
{ 4, 0, 4, 7, 3 },
{ 4, 0, 3, 2, 1 },
{ 4, 4, 5, 6, 7 }, //face 5
// FaceLookUp
{
{ 0, 6, 8 }, //hex offset into shapes face list, num faces and number of Indices
{ 6, 4, 4 }, //tet
{ 10, 5, 6 }, //wedge
{ 15, 5, 5 }, //pyramid
{ -1, 0, 0 } //unsupported shape
},
//tet
{ 3, 0, 3, 1, -1 },
{ 3, 1, 2, 3, -1 },
{ 3, 0, 2, 3, -1 },
{ 3, 0, 2, 1, -1 },
// ShapesFaceList:
// The convention for the faces is that looking from the outside of
// the shape at a face, triangles should wind CCW.
// Quads are broken up by {4=quad,a,b,c,d}:
// t1 = abc and t2 = acd. Indices of the face are ordered CW, and the mapping
// of t1 and t2 become CCW.
// Since we know the triangle winding, we could tell
// if we hit an inside face or outside face.
{ //hex
{ 4, 0, 1, 5, 4 }, //face 0
{ 4, 1, 2, 6, 5 },
{ 4, 3, 7, 6, 2 },
{ 4, 0, 4, 7, 3 },
{ 4, 0, 3, 2, 1 },
{ 4, 4, 5, 6, 7 }, //face 5
//wedge
{ 3, 0, 1, 2, -1 },
{ 3, 3, 5, 4, -1 },
{ 4, 3, 0, 2, 5 },
{ 4, 1, 4, 5, 2 },
{ 4, 0, 3, 4, 1 },
//tet
{ 3, 0, 3, 1, -1 },
{ 3, 1, 2, 3, -1 },
{ 3, 0, 2, 3, -1 },
{ 3, 0, 2, 1, -1 },
//pyramid
{ 3, 0, 4, 1, -1 },
{ 3, 1, 2, 4, -1 },
{ 3, 2, 3, 4, -1 },
{ 3, 0, 4, 3, -1 },
{ 4, 3, 2, 1, 0 }
//wedge
{ 3, 0, 1, 2, -1 },
{ 3, 3, 5, 4, -1 },
{ 4, 3, 0, 2, 5 },
{ 4, 1, 4, 5, 2 },
{ 4, 0, 3, 4, 1 },
};
//pyramid
{ 3, 0, 4, 1, -1 },
{ 3, 1, 2, 4, -1 },
{ 3, 2, 3, 4, -1 },
{ 3, 0, 4, 3, -1 },
{ 4, 3, 2, 1, 0 } },
// Test of zoo table.
// Format (faceNumber, triangle)
//
VTKM_EXEC_CONSTANT
static vtkm::Int32 ZooTable[30][4] = {
{ 0, 0, 1, 5 }, // hex
{ 0, 0, 5, 4 }, { 1, 1, 2, 6 }, { 1, 1, 6, 5 }, { 2, 3, 7, 6 }, { 2, 3, 6, 2 },
{ 3, 0, 4, 7 }, { 3, 0, 7, 3 }, { 4, 0, 3, 2 }, { 4, 0, 2, 1 }, { 5, 4, 5, 6 },
{ 5, 4, 6, 7 }, { 0, 0, 3, 1 }, // Tet
{ 1, 1, 2, 3 }, { 2, 0, 2, 3 }, { 3, 0, 2, 1 }, { 0, 0, 1, 2 }, // Wedge
{ 1, 3, 5, 4 }, { 2, 3, 0, 2 }, { 2, 3, 2, 5 }, { 3, 1, 4, 5 }, { 3, 1, 5, 2 },
{ 4, 0, 3, 4 }, { 4, 0, 4, 1 }, { 0, 0, 4, 1 }, // Pyramid
{ 1, 1, 2, 4 }, { 2, 2, 3, 4 }, { 3, 0, 4, 3 }, { 4, 3, 2, 1 }, { 4, 3, 1, 0 }
};
// ZooTable:
// Test of zoo table.
// Format (faceNumber, triangle)
//
{ { 0, 0, 1, 5 }, // hex
{ 0, 0, 5, 4 }, { 1, 1, 2, 6 }, { 1, 1, 6, 5 }, { 2, 3, 7, 6 }, { 2, 3, 6, 2 },
{ 3, 0, 4, 7 }, { 3, 0, 7, 3 }, { 4, 0, 3, 2 }, { 4, 0, 2, 1 }, { 5, 4, 5, 6 },
{ 5, 4, 6, 7 }, { 0, 0, 3, 1 }, // Tet
{ 1, 1, 2, 3 }, { 2, 0, 2, 3 }, { 3, 0, 2, 1 }, { 0, 0, 1, 2 }, // Wedge
{ 1, 3, 5, 4 }, { 2, 3, 0, 2 }, { 2, 3, 2, 5 }, { 3, 1, 4, 5 }, { 3, 1, 5, 2 },
{ 4, 0, 3, 4 }, { 4, 0, 4, 1 }, { 0, 0, 4, 1 }, // Pyramid
{ 1, 1, 2, 4 }, { 2, 2, 3, 4 }, { 3, 0, 4, 3 }, { 4, 3, 2, 1 }, { 4, 3, 1, 0 } },
//
// Offset into zoo table and the
// number of triangles for the shape
//
VTKM_EXEC_CONSTANT
static vtkm::Int32 ZooLookUp[5][2] = {
{ 0, 12 }, //hex offset into shapes face list, num faces and number of Indices
{ 12, 4 }, //tet
{ 16, 8 }, //wedge
{ 24, 6 }, //pyramid
{ -1, 0 } //unsupported shape
// ZooLookUp:
// Offset into zoo table and the
// number of triangles for the shape
//
{
{ 0, 12 }, //hex offset into shapes face list, num faces and number of Indices
{ 12, 4 }, //tet
{ 16, 8 }, //wedge
{ 24, 6 }, //pyramid
{ -1, 0 } //unsupported shape
}
};
return tables;
}
};
} // namespace raytracing

@ -281,7 +281,8 @@ public:
}
const vtkm::UInt8 cellShape = MeshConn.GetCellShape(currentCell);
Intersector.IntersectCell(xpoints, ypoints, zpoints, dir, origin, distances, cellShape);
const vtkm::Int32 numFaces = FaceLookUp[CellTypeLookUp[cellShape]][1];
const vtkm::Int32 numFaces =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[cellShape]][1];
//vtkm::Int32 minFace = 6;
vtkm::Int32 maxFace = -1;
@ -415,7 +416,8 @@ public:
const vtkm::UInt8 cellShape = MeshConn.GetCellShape(currentCell);
Intersector.IntersectCell(xpoints, ypoints, zpoints, dir, origin, distances, cellShape);
const vtkm::Int32 numFaces = FaceLookUp[CellTypeLookUp[cellShape]][1];
const vtkm::Int32 numFaces =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[cellShape]][1];
//vtkm::Int32 minFace = 6;
vtkm::Int32 maxFace = -1;

@ -110,19 +110,19 @@ public:
vtkm::Int32 tableOffset = 0;
if (shapeType == vtkm::CELL_SHAPE_TETRA)
{
tableOffset = FaceLookUp[1][0];
tableOffset = CellTables::Get().FaceLookUp[1][0];
}
else if (shapeType == vtkm::CELL_SHAPE_HEXAHEDRON)
{
tableOffset = FaceLookUp[0][0];
tableOffset = CellTables::Get().FaceLookUp[0][0];
}
else if (shapeType == vtkm::CELL_SHAPE_WEDGE)
{
tableOffset = FaceLookUp[2][0];
tableOffset = CellTables::Get().FaceLookUp[2][0];
}
else if (shapeType == vtkm::CELL_SHAPE_PYRAMID)
{
tableOffset = FaceLookUp[3][0];
tableOffset = CellTables::Get().FaceLookUp[3][0];
}
else
printf("Error shape not recognized %d\n", (int)shapeType);
@ -190,8 +190,8 @@ public:
vtkm::Id shape2Offset =
GetShapeOffset(shapes.Get(cellId2)) + faceIdPairs.Get(currentIndex)[1];
vtkm::Int32 icount1 = ShapesFaceList[shape1Offset][0];
vtkm::Int32 icount2 = ShapesFaceList[shape2Offset][0];
vtkm::Int32 icount1 = CellTables::Get().ShapesFaceList[shape1Offset][0];
vtkm::Int32 icount2 = CellTables::Get().ShapesFaceList[shape2Offset][0];
//Check to see if we have the same number of idices
if (icount1 != icount2)
continue;
@ -201,22 +201,24 @@ public:
vtkm::Vec<vtkm::Id, 4> indices1;
vtkm::Vec<vtkm::Id, 4> indices2;
for (vtkm::Int32 i = 1; i <= ShapesFaceList[shape1Offset][0]; ++i)
for (vtkm::Int32 i = 1; i <= CellTables::Get().ShapesFaceList[shape1Offset][0]; ++i)
{
BOUNDS_CHECK(offsets, cellId1);
BOUNDS_CHECK(offsets, cellId2);
BOUNDS_CHECK(connectivity, (offsets.Get(cellId1) + ShapesFaceList[shape1Offset][i]));
BOUNDS_CHECK(connectivity, (offsets.Get(cellId2) + ShapesFaceList[shape2Offset][i]));
indices1[i - 1] =
connectivity.Get(offsets.Get(cellId1) + ShapesFaceList[shape1Offset][i]);
indices2[i - 1] =
connectivity.Get(offsets.Get(cellId2) + ShapesFaceList[shape2Offset][i]);
BOUNDS_CHECK(connectivity,
(offsets.Get(cellId1) + CellTables::Get().ShapesFaceList[shape1Offset][i]));
BOUNDS_CHECK(connectivity,
(offsets.Get(cellId2) + CellTables::Get().ShapesFaceList[shape2Offset][i]));
indices1[i - 1] = connectivity.Get(offsets.Get(cellId1) +
CellTables::Get().ShapesFaceList[shape1Offset][i]);
indices2[i - 1] = connectivity.Get(offsets.Get(cellId2) +
CellTables::Get().ShapesFaceList[shape2Offset][i]);
}
bool isEqual = true;
for (vtkm::Int32 i = 0; i < ShapesFaceList[shape1Offset][0]; ++i)
for (vtkm::Int32 i = 0; i < CellTables::Get().ShapesFaceList[shape1Offset][0]; ++i)
{
if (!IsIn(indices1[i], indices2, ShapesFaceList[shape1Offset][0]))
if (!IsIn(indices1[i], indices2, CellTables::Get().ShapesFaceList[shape1Offset][0]))
isEqual = false;
}
@ -285,7 +287,8 @@ public:
vtkm::Id offset = shapeOffsets.Get(cellId);
BOUNDS_CHECK(shapes, cellId);
vtkm::Int32 shapeId = static_cast<vtkm::Int32>(shapes.Get(cellId));
vtkm::Int32 shapesFaceOffset = FaceLookUp[CellTypeLookUp[shapeId]][0];
vtkm::Int32 shapesFaceOffset =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[shapeId]][0];
if (shapesFaceOffset == -1)
{
printf("Unsupported Shape Type %d\n", shapeId);
@ -294,12 +297,12 @@ public:
vtkm::Vec<vtkm::Id, 4> faceIndices(-1, -1, -1, -1);
vtkm::Int32 tableIndex = static_cast<vtkm::Int32>(shapesFaceOffset + faceIdPair[1]);
const vtkm::Int32 numIndices = ShapesFaceList[tableIndex][0];
const vtkm::Int32 numIndices = CellTables::Get().ShapesFaceList[tableIndex][0];
for (vtkm::Int32 i = 1; i <= numIndices; ++i)
{
BOUNDS_CHECK(indices, offset + ShapesFaceList[tableIndex][i]);
faceIndices[i - 1] = indices.Get(offset + ShapesFaceList[tableIndex][i]);
BOUNDS_CHECK(indices, offset + CellTables::Get().ShapesFaceList[tableIndex][i]);
faceIndices[i - 1] = indices.Get(offset + CellTables::Get().ShapesFaceList[tableIndex][i]);
}
vtkm::Vec<vtkm::Id, 4> triangle;
triangle[0] = cellId;
@ -344,18 +347,6 @@ public:
}
}; //class WriteFaceConn
// Each one of size segments will process
// one face of the hex and domain
VTKM_EXEC_CONSTANT
static vtkm::Int32 SegmentToFace[6] = { 0, 2, 1, 3, 4, 5 };
// Each face/segment has 2 varying dimensions
VTKM_EXEC_CONSTANT
static vtkm::Int32 SegmentDirections[6][2] = { { 0, 2 }, //face 0 and 2 have the same directions
{ 0, 2 }, { 1, 2 }, //1 and 3
{ 1, 2 }, { 0, 1 }, // 4 and 5
{ 0, 1 } };
class StructuredExternalTriangles : public vtkm::worklet::WorkletMapField
{
protected:
@ -395,6 +386,18 @@ public:
template <typename TrianglePortalType>
VTKM_EXEC inline void operator()(const vtkm::Id& index, TrianglePortalType& triangles) const
{
// Each one of size segments will process
// one face of the hex and domain
static const vtkm::Int32 SegmentToFace[6] = { 0, 2, 1, 3, 4, 5 };
// Each face/segment has 2 varying dimensions
static const vtkm::Int32 SegmentDirections[6][2] = {
{ 0, 2 }, //face 0 and 2 have the same directions
{ 0, 2 }, { 1, 2 }, //1 and 3
{ 1, 2 }, { 0, 1 }, // 4 and 5
{ 0, 1 }
};
//
// We get one index per extenal face
//
@ -449,7 +452,8 @@ public:
// Look up the offset into the face list for each cell type
// This should always be zero, but in case this table changes I don't
// want to break anything.
vtkm::Int32 shapesFaceOffset = FaceLookUp[CellTypeLookUp[CELL_SHAPE_HEXAHEDRON]][0];
vtkm::Int32 shapesFaceOffset =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[CELL_SHAPE_HEXAHEDRON]][0];
vtkm::Vec<vtkm::Id, 4> faceIndices;
vtkm::Int32 tableIndex = shapesFaceOffset + cellFace;
@ -457,7 +461,7 @@ public:
// Load the face
for (vtkm::Int32 i = 1; i <= 4; ++i)
{
faceIndices[i - 1] = cellIndices[ShapesFaceList[tableIndex][i]];
faceIndices[i - 1] = cellIndices[CellTables::Get().ShapesFaceList[tableIndex][i]];
}
const vtkm::Id outputOffset = index * 2;
vtkm::Vec<vtkm::Id, 4> triangle;
@ -492,14 +496,15 @@ public:
vtkm::Id cellId = faceIdPair[0];
vtkm::Id cellFace = faceIdPair[1];
vtkm::Int32 shapeType = static_cast<vtkm::Int32>(shapes.Get(cellId));
vtkm::Int32 faceStartIndex = FaceLookUp[CellTypeLookUp[shapeType]][0];
vtkm::Int32 faceStartIndex =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[shapeType]][0];
if (faceStartIndex == -1)
{
//Unsupported Shape Type this should never happen
triangleCount = 0;
return;
}
vtkm::Int32 faceType = ShapesFaceList[faceStartIndex + cellFace][0];
vtkm::Int32 faceType = CellTables::Get().ShapesFaceList[faceStartIndex + cellFace][0];
// The face will either have 4 or 3 indices, so quad or tri
triangleCount = (faceType == 4) ? 2 : 1;

@ -278,7 +278,8 @@ public:
inline vtkm::Int32 GetCellIndices(vtkm::Id cellIndices[8], const vtkm::Id& cellId) const
{
const vtkm::Int32 shapeId = static_cast<vtkm::Int32>(ShapesPortal.Get(cellId));
const vtkm::Int32 numIndices = FaceLookUp[CellTypeLookUp[shapeId]][2];
const vtkm::Int32 numIndices =
CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[shapeId]][2];
BOUNDS_CHECK(CellOffsetsPortal, cellId);
const vtkm::Id cellOffset = CellOffsetsPortal.Get(cellId);
@ -367,7 +368,7 @@ public:
Cellset.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
ShapeId = shapes.GetPortalConstControl().Get(0);
NumIndices = FaceLookUp[CellTypeLookUp[ShapeId]][2];
NumIndices = CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[ShapeId]][2];
if (NumIndices == 0)
{
@ -377,7 +378,7 @@ public:
throw vtkm::cont::ErrorBadValue(message.str());
}
vtkm::Id start = 0;
NumFaces = FaceLookUp[CellTypeLookUp[ShapeId]][1];
NumFaces = CellTables::Get().FaceLookUp[CellTables::Get().CellTypeLookUp[ShapeId]][1];
vtkm::Id numCells = CellConnectivity.GetPortalConstControl().GetNumberOfValues();
CellOffsets = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(start, NumIndices, numCells);

@ -172,30 +172,26 @@ public:
{
vtkm::Int32 faceCount;
vtkm::Int32 tableOffset;
// suppress some unused variables warnings
(void)(CellTypeLookUp);
(void)(ZooTable);
(void)(ZooLookUp);
if (cellShape.Id == vtkm::CELL_SHAPE_TETRA)
{
faceCount = FaceLookUp[1][1];
tableOffset = FaceLookUp[1][0];
faceCount = CellTables::Get().FaceLookUp[1][1];
tableOffset = CellTables::Get().FaceLookUp[1][0];
}
else if (cellShape.Id == vtkm::CELL_SHAPE_HEXAHEDRON)
{
faceCount = FaceLookUp[0][1];
tableOffset = FaceLookUp[0][0];
faceCount = CellTables::Get().FaceLookUp[0][1];
tableOffset = CellTables::Get().FaceLookUp[0][0];
}
else if (cellShape.Id == vtkm::CELL_SHAPE_WEDGE)
{
faceCount = FaceLookUp[2][1];
tableOffset = FaceLookUp[2][0];
faceCount = CellTables::Get().FaceLookUp[2][1];
tableOffset = CellTables::Get().FaceLookUp[2][0];
}
else if (cellShape.Id == vtkm::CELL_SHAPE_PYRAMID)
{
faceCount = FaceLookUp[3][1];
tableOffset = FaceLookUp[3][0];
faceCount = CellTables::Get().FaceLookUp[3][1];
tableOffset = CellTables::Get().FaceLookUp[3][0];
}
else
{
@ -218,11 +214,11 @@ public:
// we currently check for.
vtkm::Vec<vtkm::Id, 4> faceIndices;
faceIndices[3] = -1;
const vtkm::Id indiceCount =
ShapesFaceList[tableOffset + i][0]; //Number of indices this face has
//Number of indices this face has
const vtkm::Id indiceCount = CellTables::Get().ShapesFaceList[tableOffset + i][0];
for (vtkm::Int32 j = 1; j <= indiceCount; j++)
{
faceIndices[j - 1] = cellIndices[ShapesFaceList[tableOffset + i][j]];
faceIndices[j - 1] = cellIndices[CellTables::Get().ShapesFaceList[tableOffset + i][j]];
}
//sort the indices in descending order
Sort4(faceIndices);

@ -38,8 +38,11 @@ namespace raytracing
namespace
{
VTKM_EXEC_CONSTANT static vtkm::Int32 END_FLAG2 = -1000000000;
VTKM_EXEC_CONSTANT static vtkm::Float32 EPSILON2 = 0.0001f;
enum : vtkm::Int32
{
END_FLAG2 = -1000000000
};
}
template <typename TriIntersector>
@ -99,6 +102,8 @@ public:
const Precision& originY,
const Precision& originZ) const
{
const vtkm::Float32 EPSILON2 = 0.0001f;
vtkm::Vec<Precision, 3> e1 = b - a;
vtkm::Vec<Precision, 3> e2 = c - a;
@ -774,7 +779,7 @@ public:
vtkm::Int32 todo[64];
vtkm::Int32 stackptr = 0;
vtkm::Int32 barrier = (vtkm::Int32)END_FLAG2;
vtkm::Int32 barrier = END_FLAG2;
currentNode = 0;
todo[stackptr] = barrier;
@ -923,7 +928,7 @@ public:
vtkm::Int32 todo[64];
vtkm::Int32 stackptr = 0;
vtkm::Int32 barrier = (vtkm::Int32)END_FLAG2;
vtkm::Int32 barrier = END_FLAG2;
currentNode = 0;
todo[stackptr] = barrier;

@ -43,56 +43,88 @@
namespace UnitTestMathNamespace
{
const vtkm::IdComponent NUM_NUMBERS = 5;
VTKM_EXEC_CONSTANT
const vtkm::Float64 NumberList[NUM_NUMBERS] = { 0.25, 0.5, 1.0, 2.0, 3.75 };
class Lists
{
public:
static const vtkm::IdComponent NUM_NUMBERS = 5;
VTKM_EXEC_CONSTANT
const vtkm::Float64 AngleList[NUM_NUMBERS] = { 0.643501108793284, // angle for 3, 4, 5 triangle.
0.78539816339745, // pi/4
0.5235987755983, // pi/6
1.0471975511966, // pi/3
0.0 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 OppositeList[NUM_NUMBERS] = { 3.0,
1.0,
1.0,
1.732050807568877 /*sqrt(3)*/,
0.0 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 AdjacentList[NUM_NUMBERS] = { 4.0,
1.0,
1.732050807568877 /*sqrt(3)*/,
1.0,
1.0 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 HypotenuseList[NUM_NUMBERS] = { 5.0,
1.414213562373095 /*sqrt(2)*/,
2.0,
2.0,
1.0 };
private:
struct Data
{
vtkm::Float64 NumberList[NUM_NUMBERS];
vtkm::Float64 AngleList[NUM_NUMBERS];
vtkm::Float64 OppositeList[NUM_NUMBERS];
vtkm::Float64 AdjacentList[NUM_NUMBERS];
vtkm::Float64 HypotenuseList[NUM_NUMBERS];
vtkm::Float64 NumeratorList[NUM_NUMBERS];
vtkm::Float64 DenominatorList[NUM_NUMBERS];
vtkm::Float64 FModRemainderList[NUM_NUMBERS];
vtkm::Float64 RemainderList[NUM_NUMBERS];
vtkm::Int64 QuotientList[NUM_NUMBERS];
vtkm::Float64 XList[NUM_NUMBERS];
vtkm::Float64 FractionalList[NUM_NUMBERS];
vtkm::Float64 FloorList[NUM_NUMBERS];
vtkm::Float64 CeilList[NUM_NUMBERS];
vtkm::Float64 RoundList[NUM_NUMBERS];
};
VTKM_EXEC_CONSTANT
const vtkm::Float64 NumeratorList[NUM_NUMBERS] = { 6.5, 5.8, 9.3, 77.0, 0.1 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 DenominatorList[NUM_NUMBERS] = { 2.3, 1.6, 3.1, 19.0, 0.4 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 FModRemainderList[NUM_NUMBERS] = { 1.9, 1.0, 0.0, 1.0, 0.1 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 RemainderList[NUM_NUMBERS] = { -0.4, -0.6, 0.0, 1.0, 0.1 };
VTKM_EXEC_CONSTANT
const vtkm::Int64 QuotientList[NUM_NUMBERS] = { 3, 4, 3, 4, 0 };
public:
VTKM_EXEC_CONT static const Data& Get()
{
static const Data data = {
// NumberList
{ 0.25, 0.5, 1.0, 2.0, 3.75 },
VTKM_EXEC_CONSTANT
const vtkm::Float64 XList[NUM_NUMBERS] = { 4.6, 0.1, 73.4, 55.0, 3.75 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 FractionalList[NUM_NUMBERS] = { 0.6, 0.1, 0.4, 0.0, 0.75 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 FloorList[NUM_NUMBERS] = { 4.0, 0.0, 73.0, 55.0, 3.0 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 CeilList[NUM_NUMBERS] = { 5.0, 1.0, 74.0, 55.0, 4.0 };
VTKM_EXEC_CONSTANT
const vtkm::Float64 RoundList[NUM_NUMBERS] = { 5.0, 0.0, 73.0, 55.0, 4.0 };
// AngleList
{ 0.643501108793284, // angle for 3, 4, 5 triangle.
0.78539816339745, // pi/4
0.5235987755983, // pi/6
1.0471975511966, // pi/3
0.0 },
// OppositeList
{ 3.0, 1.0, 1.0, 1.732050807568877 /*sqrt(3)*/, 0.0 },
// AdjacentList
{ 4.0, 1.0, 1.732050807568877 /*sqrt(3)*/, 1.0, 1.0 },
// HypotenuseList
{ 5.0, 1.414213562373095 /*sqrt(2)*/, 2.0, 2.0, 1.0 },
// NumeratorList
{ 6.5, 5.8, 9.3, 77.0, 0.1 },
// DenominatorList
{ 2.3, 1.6, 3.1, 19.0, 0.4 },
// FModRemainderList
{ 1.9, 1.0, 0.0, 1.0, 0.1 },
// RemainderList
{ -0.4, -0.6, 0.0, 1.0, 0.1 },
// QuotientList
{ 3, 4, 3, 4, 0 },
// XList
{ 4.6, 0.1, 73.4, 55.0, 3.75 },
// FractionalList
{ 0.6, 0.1, 0.4, 0.0, 0.75 },
// FloorList
{ 4.0, 0.0, 73.0, 55.0, 3.0 },
// CeilList
{ 5.0, 1.0, 74.0, 55.0, 4.0 },
// RoundList
{ 5.0, 0.0, 73.0, 55.0, 4.0 },
};
return data;
}
};
//-----------------------------------------------------------------------------
template <typename T>
@ -130,9 +162,9 @@ struct ScalarFieldTests : public vtkm::exec::FunctorBase
void TestPow() const
{
// std::cout << "Running power tests." << std::endl;
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS; index++)
{
T x = static_cast<T>(NumberList[index]);
T x = static_cast<T>(Lists::Get().NumberList[index]);
T powx = vtkm::Pow(x, static_cast<T>(2.0));
T sqrx = x * x;
VTKM_MATH_ASSERT(test_equal(powx, sqrx), "Power gave wrong result.");
@ -206,13 +238,13 @@ struct ScalarFieldTests : public vtkm::exec::FunctorBase
void TestRemainders() const
{
// std::cout << "Testing remainders." << std::endl;
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS; index++)
{
T numerator = static_cast<T>(NumeratorList[index]);
T denominator = static_cast<T>(DenominatorList[index]);
T fmodremainder = static_cast<T>(FModRemainderList[index]);
T remainder = static_cast<T>(RemainderList[index]);
vtkm::Int64 quotient = QuotientList[index];
T numerator = static_cast<T>(Lists::Get().NumeratorList[index]);
T denominator = static_cast<T>(Lists::Get().DenominatorList[index]);
T fmodremainder = static_cast<T>(Lists::Get().FModRemainderList[index]);
T remainder = static_cast<T>(Lists::Get().RemainderList[index]);
vtkm::Int64 quotient = Lists::Get().QuotientList[index];
VTKM_MATH_ASSERT(test_equal(vtkm::FMod(numerator, denominator), fmodremainder),
"Bad FMod remainder.");
@ -229,13 +261,13 @@ struct ScalarFieldTests : public vtkm::exec::FunctorBase
void TestRound() const
{
// std::cout << "Testing round." << std::endl;
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS; index++)
{
T x = static_cast<T>(XList[index]);
T fractional = static_cast<T>(FractionalList[index]);
T floor = static_cast<T>(FloorList[index]);
T ceil = static_cast<T>(CeilList[index]);
T round = static_cast<T>(RoundList[index]);
T x = static_cast<T>(Lists::Get().XList[index]);
T fractional = static_cast<T>(Lists::Get().FractionalList[index]);
T floor = static_cast<T>(Lists::Get().FloorList[index]);
T ceil = static_cast<T>(Lists::Get().CeilList[index]);
T round = static_cast<T>(Lists::Get().RoundList[index]);
T intPart;
VTKM_MATH_ASSERT(test_equal(vtkm::ModF(x, intPart), fractional),
@ -312,7 +344,7 @@ struct ScalarVectorFieldTests : public vtkm::exec::FunctorBase
{
// std::cout << "Testing normal trig functions." << std::endl;
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
{
VectorType angle;
VectorType opposite;
@ -321,16 +353,21 @@ struct ScalarVectorFieldTests : public vtkm::exec::FunctorBase
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
{
Traits::SetComponent(
angle, componentIndex, static_cast<ComponentType>(AngleList[componentIndex + index]));
Traits::SetComponent(opposite,
componentIndex,
static_cast<ComponentType>(OppositeList[componentIndex + index]));
Traits::SetComponent(adjacent,
componentIndex,
static_cast<ComponentType>(AdjacentList[componentIndex + index]));
Traits::SetComponent(hypotenuse,
componentIndex,
static_cast<ComponentType>(HypotenuseList[componentIndex + index]));
angle,
componentIndex,
static_cast<ComponentType>(Lists::Get().AngleList[componentIndex + index]));
Traits::SetComponent(
opposite,
componentIndex,
static_cast<ComponentType>(Lists::Get().OppositeList[componentIndex + index]));
Traits::SetComponent(
adjacent,
componentIndex,
static_cast<ComponentType>(Lists::Get().AdjacentList[componentIndex + index]));
Traits::SetComponent(
hypotenuse,
componentIndex,
static_cast<ComponentType>(Lists::Get().HypotenuseList[componentIndex + index]));
}
VTKM_MATH_ASSERT(test_equal(vtkm::Sin(angle), opposite / hypotenuse), "Sin failed test.");
@ -364,13 +401,15 @@ struct ScalarVectorFieldTests : public vtkm::exec::FunctorBase
const VectorType zero(0);
const VectorType half(0.5);
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
{
VectorType x;
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
{
Traits::SetComponent(
x, componentIndex, static_cast<ComponentType>(AngleList[componentIndex + index]));
x,
componentIndex,
static_cast<ComponentType>(Lists::Get().AngleList[componentIndex + index]));
}
const VectorType minusX = zero - x;
@ -391,13 +430,14 @@ struct ScalarVectorFieldTests : public vtkm::exec::FunctorBase
template <typename FunctionType>
VTKM_EXEC void RaiseToTest(FunctionType function, ComponentType exponent) const
{
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
{
VectorType original;
VectorType raiseresult;
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
{
ComponentType x = static_cast<ComponentType>(NumberList[componentIndex + index]);
ComponentType x =
static_cast<ComponentType>(Lists::Get().NumberList[componentIndex + index]);
Traits::SetComponent(original, componentIndex, x);
Traits::SetComponent(raiseresult, componentIndex, vtkm::Pow(x, exponent));
}
@ -462,13 +502,14 @@ struct ScalarVectorFieldTests : public vtkm::exec::FunctorBase
ComponentType exponentbias = 0.0,
ComponentType resultbias = 0.0) const
{
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
{
VectorType original;
VectorType raiseresult;
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
{
ComponentType x = static_cast<ComponentType>(NumberList[componentIndex + index]);
ComponentType x =
static_cast<ComponentType>(Lists::Get().NumberList[componentIndex + index]);
Traits::SetComponent(original, componentIndex, x);
Traits::SetComponent(
raiseresult, componentIndex, vtkm::Pow(base, x + exponentbias) + resultbias);
@ -533,14 +574,15 @@ struct ScalarVectorFieldTests : public vtkm::exec::FunctorBase
ComponentType base,
ComponentType bias = 0.0) const
{
for (vtkm::IdComponent index = 0; index < NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
for (vtkm::IdComponent index = 0; index < Lists::NUM_NUMBERS - NUM_COMPONENTS + 1; index++)
{
VectorType basevector(base);
VectorType original;
VectorType biased;
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
{
ComponentType x = static_cast<ComponentType>(NumberList[componentIndex + index]);
ComponentType x =
static_cast<ComponentType>(Lists::Get().NumberList[componentIndex + index]);
Traits::SetComponent(original, componentIndex, x);
Traits::SetComponent(biased, componentIndex, x + bias);
}

@ -19456,26 +19456,6 @@ static vtkm::UInt8 CellEdges[CELL_EDGES_SIZE] = {
};
#undef X
// index into ClipTablesIndices for each shape
VTKM_EXEC_CONSTANT
static vtkm::Int16 CellIndexLookup[vtkm::NUMBER_OF_CELL_SHAPES] = {
-1, // 0 = vtkm::CELL_SHAPE_EMPTY_CELL
0, // 1 = vtkm::CELL_SHAPE_VERTEX
-1, // 2 = vtkm::CELL_SHAPE_POLY_VERTEX
2, // 3 = vtkm::CELL_SHAPE_LINE
-1, // 4 = vtkm::CELL_SHAPE_POLY_LINE
6, // 5 = vtkm::CELL_SHAPE_TRIANGLE
-1, // 6 = vtkm::CELL_SHAPE_TRIANGLE_STRIP
-1, // 7 = vtkm::CELL_SHAPE_POLYGON
-1, // 8 = vtkm::CELL_SHAPE_PIXEL
14, // 9 = vtkm::CELL_SHAPE_QUAD
30, // 10 = vtkm::CELL_SHAPE_TETRA
-1, // 11 = vtkm::CELL_SHAPE_VOXEL
46, // 12 = vtkm::CELL_SHAPE_HEXAHEDRON
302, // 13 = vtkm::CELL_SHAPE_WEDGE
366 // 14 = vtkm::CELL_SHAPE_PYRAMID
};
class ClipTables
{
public:
@ -19488,6 +19468,25 @@ public:
VTKM_EXEC
vtkm::Id GetCaseIndex(vtkm::Id shape, vtkm::Id caseId) const
{
// index into ClipTablesIndices for each shape
static vtkm::Int16 CellIndexLookup[vtkm::NUMBER_OF_CELL_SHAPES] = {
-1, // 0 = vtkm::CELL_SHAPE_EMPTY_CELL
0, // 1 = vtkm::CELL_SHAPE_VERTEX
-1, // 2 = vtkm::CELL_SHAPE_POLY_VERTEX
2, // 3 = vtkm::CELL_SHAPE_LINE
-1, // 4 = vtkm::CELL_SHAPE_POLY_LINE
6, // 5 = vtkm::CELL_SHAPE_TRIANGLE
-1, // 6 = vtkm::CELL_SHAPE_TRIANGLE_STRIP
-1, // 7 = vtkm::CELL_SHAPE_POLYGON
-1, // 8 = vtkm::CELL_SHAPE_PIXEL
14, // 9 = vtkm::CELL_SHAPE_QUAD
30, // 10 = vtkm::CELL_SHAPE_TETRA
-1, // 11 = vtkm::CELL_SHAPE_VOXEL
46, // 12 = vtkm::CELL_SHAPE_HEXAHEDRON
302, // 13 = vtkm::CELL_SHAPE_WEDGE
366 // 14 = vtkm::CELL_SHAPE_PYRAMID
};
vtkm::Id index = CellIndexLookup[shape];
return this->ClipTablesIndicesPortal.Get(index + caseId);
}

@ -40,17 +40,6 @@ namespace vtkm
namespace worklet
{
namespace detail
{
VTKM_EXEC_CONSTANT
const static vtkm::IdComponent StructuredTetrahedronIndices[2][5][4] = {
{ { 0, 1, 3, 4 }, { 1, 4, 5, 6 }, { 1, 4, 6, 3 }, { 1, 3, 6, 2 }, { 3, 6, 7, 4 } },
{ { 2, 1, 5, 0 }, { 0, 2, 3, 7 }, { 2, 5, 6, 7 }, { 0, 7, 4, 5 }, { 0, 2, 7, 5 } }
};
} // namespace detail
/// \brief Compute the tetrahedralize cells for a uniform grid data set
template <typename DeviceAdapter>
class TetrahedralizeStructured
@ -82,6 +71,11 @@ public:
ConnectivityOutVec& connectivityOut,
const ThreadIndicesType threadIndices) const
{
const static vtkm::IdComponent StructuredTetrahedronIndices[2][5][4] = {
{ { 0, 1, 3, 4 }, { 1, 4, 5, 6 }, { 1, 4, 6, 3 }, { 1, 3, 6, 2 }, { 3, 6, 7, 4 } },
{ { 2, 1, 5, 0 }, { 0, 2, 3, 7 }, { 2, 5, 6, 7 }, { 0, 7, 4, 5 }, { 0, 2, 7, 5 } }
};
vtkm::Id3 inputIndex = threadIndices.GetInputIndex3D();
// Calculate the type of tetrahedron generated because it alternates
@ -89,14 +83,10 @@ public:
vtkm::IdComponent visitIndex = threadIndices.GetVisitIndex();
connectivityOut[0] =
connectivityIn[detail::StructuredTetrahedronIndices[indexType][visitIndex][0]];
connectivityOut[1] =
connectivityIn[detail::StructuredTetrahedronIndices[indexType][visitIndex][1]];
connectivityOut[2] =
connectivityIn[detail::StructuredTetrahedronIndices[indexType][visitIndex][2]];
connectivityOut[3] =
connectivityIn[detail::StructuredTetrahedronIndices[indexType][visitIndex][3]];
connectivityOut[0] = connectivityIn[StructuredTetrahedronIndices[indexType][visitIndex][0]];
connectivityOut[1] = connectivityIn[StructuredTetrahedronIndices[indexType][visitIndex][1]];
connectivityOut[2] = connectivityIn[StructuredTetrahedronIndices[indexType][visitIndex][2]];
connectivityOut[3] = connectivityIn[StructuredTetrahedronIndices[indexType][visitIndex][3]];
}
};

@ -40,14 +40,6 @@ namespace vtkm
namespace worklet
{
namespace detail
{
VTKM_EXEC_CONSTANT
const static vtkm::IdComponent StructuredTriangleIndices[2][3] = { { 0, 1, 2 }, { 0, 2, 3 } };
} // namespace detail
/// \brief Compute the triangulate cells for a uniform grid data set
template <typename DeviceAdapter>
class TriangulateStructured
@ -79,9 +71,11 @@ public:
ConnectivityOutVec& connectivityOut,
vtkm::IdComponent visitIndex) const
{
connectivityOut[0] = connectivityIn[detail::StructuredTriangleIndices[visitIndex][0]];
connectivityOut[1] = connectivityIn[detail::StructuredTriangleIndices[visitIndex][1]];
connectivityOut[2] = connectivityIn[detail::StructuredTriangleIndices[visitIndex][2]];
const static vtkm::IdComponent StructuredTriangleIndices[2][3] = { { 0, 1, 2 }, { 0, 2, 3 } };
connectivityOut[0] = connectivityIn[StructuredTriangleIndices[visitIndex][0]];
connectivityOut[1] = connectivityIn[StructuredTriangleIndices[visitIndex][1]];
connectivityOut[2] = connectivityIn[StructuredTriangleIndices[visitIndex][2]];
}
};