Fixing issues raised by Ken on Gitlab

This commit is contained in:
Abhishek Yenpure 2019-08-08 09:15:28 -07:00
parent a6df117321
commit 2798c737a2
6 changed files with 47 additions and 46 deletions

@ -35,7 +35,7 @@ void CellLocatorRectilinearGrid::Build()
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
if (!coords.GetData().IsType<RectilinearType>())
throw vtkm::cont::ErrorInternal("Coordinates are not rectilinear.");
throw vtkm::cont::ErrorBadType("Coordinates are not rectilinear type.");
if (cellSet.IsSameType(Structured2DType()))
{
@ -55,7 +55,7 @@ void CellLocatorRectilinearGrid::Build()
}
else
{
throw vtkm::cont::ErrorInternal("Cells are not structured.");
throw vtkm::cont::ErrorBadType("Cells are not 2D or 3D structured type.");
}
}

@ -33,7 +33,7 @@ void CellLocatorUniformGrid::Build()
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
if (!coords.GetData().IsType<UniformType>())
throw vtkm::cont::ErrorInternal("Coordinates are not uniform.");
throw vtkm::cont::ErrorBadType("Coordinates are not uniform type.");
if (cellSet.IsSameType(Structured2DType()))
{
@ -50,26 +50,26 @@ void CellLocatorUniformGrid::Build()
}
else
{
throw vtkm::cont::ErrorInternal("Cells are not structured.");
throw vtkm::cont::ErrorBadType("Cells are not 2D or 3D structured type.");
}
UniformType uniformCoords = coords.GetData().Cast<UniformType>();
this->Origin = uniformCoords.GetPortalConstControl().GetOrigin();
vtkm::Vec<vtkm::FloatDefault, 3> spacing = uniformCoords.GetPortalConstControl().GetSpacing();
vtkm::Vec<vtkm::FloatDefault, 3> unitLength;
unitLength[0] = static_cast<vtkm::FloatDefault>(PointDims[0] - 1);
unitLength[1] = static_cast<vtkm::FloatDefault>(PointDims[1] - 1);
unitLength[2] = static_cast<vtkm::FloatDefault>(PointDims[2] - 1);
vtkm::Vec3f spacing = uniformCoords.GetPortalConstControl().GetSpacing();
vtkm::Vec3f unitLength;
unitLength[0] = static_cast<vtkm::FloatDefault>(this->PointDims[0] - 1);
unitLength[1] = static_cast<vtkm::FloatDefault>(this->PointDims[1] - 1);
unitLength[2] = static_cast<vtkm::FloatDefault>(this->PointDims[2] - 1);
this->MaxPoint = Origin + spacing * unitLength;
this->MaxPoint = this->Origin + spacing * unitLength;
this->InvSpacing[0] = 1.f / spacing[0];
this->InvSpacing[1] = 1.f / spacing[1];
this->InvSpacing[2] = 1.f / spacing[2];
this->CellDims[0] = PointDims[0] - 1;
this->CellDims[1] = PointDims[1] - 1;
this->CellDims[2] = PointDims[2] - 1;
this->CellDims[0] = this->PointDims[0] - 1;
this->CellDims[1] = this->PointDims[1] - 1;
this->CellDims[2] = this->PointDims[2] - 1;
}
namespace

@ -34,9 +34,9 @@ protected:
private:
vtkm::Id3 CellDims;
vtkm::Id3 PointDims;
vtkm::Vec<vtkm::FloatDefault, 3> Origin;
vtkm::Vec<vtkm::FloatDefault, 3> InvSpacing;
vtkm::Vec<vtkm::FloatDefault, 3> MaxPoint;
vtkm::Vec3f Origin;
vtkm::Vec3f InvSpacing;
vtkm::Vec3f MaxPoint;
bool Is3D = true;
mutable vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator> ExecutionObjectHandle;

@ -56,20 +56,21 @@ public:
, Coords(coords.PrepareForInput(DeviceAdapter()))
, PointDimensions(cellSet.GetPointDimensions())
{
this->AxisPortals[0] = Coords.GetFirstPortal();
this->AxisPortals[0] = this->Coords.GetFirstPortal();
this->MinPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(0);
this->MaxPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(PointDimensions[0] - 1);
this->MaxPoint[0] =
coords.GetPortalConstControl().GetFirstPortal().Get(this->PointDimensions[0] - 1);
this->AxisPortals[1] = Coords.GetSecondPortal();
this->AxisPortals[1] = this->Coords.GetSecondPortal();
this->MinPoint[1] = coords.GetPortalConstControl().GetSecondPortal().Get(0);
this->MaxPoint[1] =
coords.GetPortalConstControl().GetSecondPortal().Get(PointDimensions[1] - 1);
coords.GetPortalConstControl().GetSecondPortal().Get(this->PointDimensions[1] - 1);
if (dimensions == 3)
{
this->AxisPortals[2] = Coords.GetThirdPortal();
this->AxisPortals[2] = this->Coords.GetThirdPortal();
this->MinPoint[2] = coords.GetPortalConstControl().GetThirdPortal().Get(0);
this->MaxPoint[2] =
coords.GetPortalConstControl().GetThirdPortal().Get(PointDimensions[2] - 1);
coords.GetPortalConstControl().GetThirdPortal().Get(this->PointDimensions[2] - 1);
}
}
@ -101,7 +102,7 @@ public:
const vtkm::exec::FunctorBase& worklet) const override
{
(void)worklet; //suppress unused warning
if (!IsInside(point))
if (!this->IsInside(point))
{
cellId = -1;
return;
@ -118,12 +119,12 @@ public:
//
if (point[dim] == MaxPoint[dim])
{
logicalCell[dim] = PointDimensions[dim] - 2;
logicalCell[dim] = this->PointDimensions[dim] - 2;
continue;
}
vtkm::Id minIndex = 0;
vtkm::Id maxIndex = PointDimensions[dim] - 1;
vtkm::Id maxIndex = this->PointDimensions[dim] - 1;
vtkm::FloatDefault minVal;
vtkm::FloatDefault maxVal;
minVal = this->AxisPortals[dim].Get(minIndex);

@ -41,9 +41,9 @@ public:
VTKM_CONT
CellLocatorUniformGrid(const vtkm::Id3 cellDims,
const vtkm::Id3 pointDims,
const vtkm::Vec<vtkm::FloatDefault, 3> origin,
const vtkm::Vec<vtkm::FloatDefault, 3> invSpacing,
const vtkm::Vec<vtkm::FloatDefault, 3> maxPoint,
const vtkm::Vec3f origin,
const vtkm::Vec3f invSpacing,
const vtkm::Vec3f maxPoint,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
DeviceAdapter)
: CellDims(cellDims)
@ -61,8 +61,7 @@ public:
// troublesome with CUDA __host__ __device__ markup.
}
template <typename T>
VTKM_EXEC inline bool IsInside(const vtkm::Vec<T, 3>& point) const
VTKM_EXEC inline bool IsInside(const vtkm::Vec3f& point) const
{
bool inside = true;
if (point[0] < this->Origin[0] || point[0] > this->MaxPoint[0])
@ -81,7 +80,7 @@ public:
const vtkm::exec::FunctorBase& worklet) const override
{
(void)worklet; //suppress unused warning
if (!IsInside(point))
if (!this->IsInside(point))
{
cellId = -1;
return;
@ -89,9 +88,9 @@ public:
// Get the Cell Id from the point.
vtkm::Id3 logicalCell(0, 0, 0);
vtkm::Vec<vtkm::FloatDefault, 3> temp;
temp = point - Origin;
temp = temp * InvSpacing;
vtkm::Vec3f temp;
temp = point - this->Origin;
temp = temp * this->InvSpacing;
//make sure that if we border the upper edge, we sample the correct cell
logicalCell = temp;
@ -117,9 +116,9 @@ public:
private:
vtkm::Id3 CellDims;
vtkm::Id3 PointDims;
vtkm::Vec<vtkm::FloatDefault, 3> Origin;
vtkm::Vec<vtkm::FloatDefault, 3> InvSpacing;
vtkm::Vec<vtkm::FloatDefault, 3> MaxPoint;
vtkm::Vec3f Origin;
vtkm::Vec3f InvSpacing;
vtkm::Vec3f MaxPoint;
CoordsPortal Coords;
};
}

@ -63,28 +63,29 @@ public:
vtkm::VecVariable<vtkm::Id, 8>& indices) const override
{
vtkm::Id3 logicalCellId;
logicalCellId[0] = cellId % CellDims[0];
logicalCellId[1] = (cellId / CellDims[0]) % CellDims[1];
logicalCellId[0] = cellId % this->CellDims[0];
logicalCellId[1] = (cellId / this->CellDims[0]) % this->CellDims[1];
if (this->Is3D)
{
logicalCellId[2] = cellId / (CellDims[0] * CellDims[1]);
indices.Append((logicalCellId[2] * PointDims[1] + logicalCellId[1]) * PointDims[0] +
logicalCellId[2] = cellId / (this->CellDims[0] * this->CellDims[1]);
indices.Append((logicalCellId[2] * this->PointDims[1] + logicalCellId[1]) *
this->PointDims[0] +
logicalCellId[0]);
indices.Append(indices[0] + 1);
indices.Append(indices[1] + PointDims[0]);
indices.Append(indices[1] + this->PointDims[0]);
indices.Append(indices[2] - 1);
indices.Append(indices[0] + PointDims[0] * PointDims[1]);
indices.Append(indices[0] + this->PointDims[0] * this->PointDims[1]);
indices.Append(indices[4] + 1);
indices.Append(indices[5] + PointDims[0]);
indices.Append(indices[5] + this->PointDims[0]);
indices.Append(indices[6] - 1);
cellShape = static_cast<vtkm::UInt8>(vtkm::CELL_SHAPE_HEXAHEDRON);
numVerts = 8;
}
else
{
indices.Append(logicalCellId[1] * PointDims[0] + logicalCellId[0]);
indices.Append(logicalCellId[1] * this->PointDims[0] + logicalCellId[0]);
indices.Append(indices[0] + 1);
indices.Append(indices[1] + PointDims[0]);
indices.Append(indices[1] + this->PointDims[0]);
indices.Append(indices[2] - 1);
cellShape = static_cast<vtkm::UInt8>(vtkm::CELL_SHAPE_QUAD);
numVerts = 4;