Commit 8127093a authored by Kenneth Moreland's avatar Kenneth Moreland

Add CellLocator to name of BoundingIntervalHierarchy

This will help identify the nature of this object as well as find cell
locator implementations.
parent c008df90
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_BoundingIntervalHierarchyNode_h
#define vtk_m_cont_BoundingIntervalHierarchyNode_h
#include <vtkm/Types.h>
namespace vtkm
{
namespace cont
{
struct BoundingIntervalHierarchyNode
{
vtkm::IdComponent Dimension;
vtkm::Id ParentIndex;
vtkm::Id ChildIndex;
union {
struct
{
vtkm::FloatDefault LMax;
vtkm::FloatDefault RMin;
} Node;
struct
{
vtkm::Id Start;
vtkm::Id Size;
} Leaf;
};
VTKM_EXEC_CONT
BoundingIntervalHierarchyNode()
: Dimension()
, ParentIndex()
, ChildIndex()
, Node{ 0, 0 }
{
}
}; // struct BoundingIntervalHierarchyNode
} // namespace cont
} // namespace vtkm
#endif // vtk_m_cont_BoundingIntervalHierarchyNode_h
......@@ -49,11 +49,10 @@ set(headers
ArrayRangeCompute.h
AssignerMultiBlock.h
AtomicArray.h
BoundingIntervalHierarchy.h
BoundingIntervalHierarchyNode.h
BoundsCompute.h
BoundsGlobalCompute.h
CellLocator.h
CellLocatorBoundingIntervalHierarchy.h
CellLocatorHelper.h
CellLocatorRectilinearGrid.h
CellLocatorTwoLevelUniformGrid.h
......@@ -115,7 +114,7 @@ set(template_sources
ArrayHandle.hxx
ArrayHandleVirtual.hxx
ArrayRangeCompute.hxx
BoundingIntervalHierarchy.hxx
CellLocatorBoundingIntervalHierarchy.hxx
CellSetExplicit.hxx
CellSetStructured.hxx
ColorTable.hxx
......
......@@ -18,14 +18,12 @@
// this software.
//============================================================================
#ifndef vtk_m_cont_BoundingIntervalHierarchy_h
#define vtk_m_cont_BoundingIntervalHierarchy_h
#ifndef vtk_m_cont_CellLocatorBoundingIntervalHierarchy_h
#define vtk_m_cont_CellLocatorBoundingIntervalHierarchy_h
#include <vtkm/Types.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/BoundingIntervalHierarchyNode.h>
#include <vtkm/cont/CellLocator.h>
#include <vtkm/worklet/spatialstructure/BoundingIntervalHierarchy.h>
......@@ -35,7 +33,7 @@ namespace vtkm
namespace cont
{
class BoundingIntervalHierarchy : public vtkm::cont::CellLocator
class CellLocatorBoundingIntervalHierarchy : public vtkm::cont::CellLocator
{
private:
using IdArrayHandle = vtkm::cont::ArrayHandle<vtkm::Id>;
......@@ -83,7 +81,8 @@ private:
public:
VTKM_CONT
BoundingIntervalHierarchy(vtkm::IdComponent numPlanes = 4, vtkm::IdComponent maxLeafSize = 5)
CellLocatorBoundingIntervalHierarchy(vtkm::IdComponent numPlanes = 4,
vtkm::IdComponent maxLeafSize = 5)
: NumPlanes(numPlanes)
, MaxLeafSize(maxLeafSize)
, Nodes()
......@@ -122,7 +121,7 @@ protected:
private:
vtkm::IdComponent NumPlanes;
vtkm::IdComponent MaxLeafSize;
vtkm::cont::ArrayHandle<BoundingIntervalHierarchyNode> Nodes;
vtkm::cont::ArrayHandle<vtkm::exec::CellLocatorBoundingIntervalHierarchyNode> Nodes;
IdArrayHandle ProcessedCellIds;
mutable HandleType ExecHandle;
};
......@@ -130,4 +129,4 @@ private:
} // namespace cont
} // namespace vtkm
#endif // vtk_m_cont_BoundingIntervalHierarchy_h
#endif // vtk_m_cont_CellLocatorBoundingIntervalHierarchy_h
......@@ -26,12 +26,12 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleReverse.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/BoundingIntervalHierarchy.h>
#include <vtkm/cont/BoundingIntervalHierarchyNode.h>
#include <vtkm/cont/CellLocatorBoundingIntervalHierarchy.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorBadDevice.h>
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>
#include <vtkm/exec/BoundingIntervalHierarchyExec.h>
#include <vtkm/exec/CellLocatorBoundingIntervalHierarchyExec.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/Invoker.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
......@@ -62,7 +62,8 @@ using HandleType = vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>;
template <typename DeviceAdapter>
VTKM_CONT IdArrayHandle
BoundingIntervalHierarchy::CalculateSegmentSizes(const IdArrayHandle& segmentIds, vtkm::Id numCells)
CellLocatorBoundingIntervalHierarchy::CalculateSegmentSizes(const IdArrayHandle& segmentIds,
vtkm::Id numCells)
{
using Algorithms = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
IdArrayHandle discardKeys;
......@@ -77,7 +78,8 @@ BoundingIntervalHierarchy::CalculateSegmentSizes(const IdArrayHandle& segmentIds
template <typename DeviceAdapter>
VTKM_CONT IdArrayHandle
BoundingIntervalHierarchy::GenerateSegmentIds(const IdArrayHandle& segmentSizes, vtkm::Id numCells)
CellLocatorBoundingIntervalHierarchy::GenerateSegmentIds(const IdArrayHandle& segmentSizes,
vtkm::Id numCells)
{
// Compact segment ids, removing non-contiguous values.
using Algorithms = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
......@@ -92,7 +94,7 @@ BoundingIntervalHierarchy::GenerateSegmentIds(const IdArrayHandle& segmentSizes,
}
template <typename DeviceAdapter>
VTKM_CONT void BoundingIntervalHierarchy::CalculateSplitCosts(
VTKM_CONT void CellLocatorBoundingIntervalHierarchy::CalculateSplitCosts(
RangePermutationArrayHandle& segmentRanges,
RangeArrayHandle& ranges,
CoordsArrayHandle& coords,
......@@ -118,7 +120,7 @@ VTKM_CONT void BoundingIntervalHierarchy::CalculateSplitCosts(
}
template <typename DeviceAdapter>
VTKM_CONT void BoundingIntervalHierarchy::CalculatePlaneSplitCost(
VTKM_CONT void CellLocatorBoundingIntervalHierarchy::CalculatePlaneSplitCost(
vtkm::IdComponent planeIndex,
vtkm::IdComponent numPlanes,
RangePermutationArrayHandle& segmentRanges,
......@@ -197,10 +199,10 @@ VTKM_CONT void BoundingIntervalHierarchy::CalculatePlaneSplitCost(
template <typename DeviceAdapter>
VTKM_CONT IdArrayHandle
BoundingIntervalHierarchy::CalculateSplitScatterIndices(const IdArrayHandle& cellIds,
const IdArrayHandle& leqFlags,
const IdArrayHandle& segmentIds,
DeviceAdapter)
CellLocatorBoundingIntervalHierarchy::CalculateSplitScatterIndices(const IdArrayHandle& cellIds,
const IdArrayHandle& leqFlags,
const IdArrayHandle& segmentIds,
DeviceAdapter)
{
using Algorithms = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
vtkm::worklet::Invoker invoker(DeviceAdapter{});
......@@ -242,14 +244,14 @@ BoundingIntervalHierarchy::CalculateSplitScatterIndices(const IdArrayHandle& cel
return scatterIndices;
}
class BoundingIntervalHierarchy::BuildFunctor
class CellLocatorBoundingIntervalHierarchy::BuildFunctor
{
protected:
BoundingIntervalHierarchy* Self;
CellLocatorBoundingIntervalHierarchy* Self;
public:
VTKM_CONT
BuildFunctor(BoundingIntervalHierarchy* self)
BuildFunctor(CellLocatorBoundingIntervalHierarchy* self)
: Self(self)
{
}
......@@ -437,7 +439,7 @@ public:
//START_TIMER(s43);
// Make a new nodes with enough nodes for the current level, copying over the old one
vtkm::Id nodesSize = Self->Nodes.GetNumberOfValues() + numSegments;
vtkm::cont::ArrayHandle<BoundingIntervalHierarchyNode> newTree;
vtkm::cont::ArrayHandle<vtkm::exec::CellLocatorBoundingIntervalHierarchyNode> newTree;
newTree.Allocate(nodesSize);
Algorithms::CopySubRange(Self->Nodes, 0, Self->Nodes.GetNumberOfValues(), newTree);
......@@ -480,19 +482,20 @@ public:
}
};
class BoundingIntervalHierarchy::PrepareForExecutionFunctor
class CellLocatorBoundingIntervalHierarchy::PrepareForExecutionFunctor
{
public:
template <typename DeviceAdapter>
VTKM_CONT bool operator()(DeviceAdapter,
const vtkm::cont::BoundingIntervalHierarchy& bih,
const vtkm::cont::CellLocatorBoundingIntervalHierarchy& bih,
HandleType& bihExec) const
{
vtkm::cont::DynamicCellSet cellSet = bih.GetCellSet();
if (cellSet.IsType<vtkm::cont::CellSetExplicit<>>())
{
using CellSetType = vtkm::cont::CellSetExplicit<>;
using ExecutionType = vtkm::exec::BoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
using ExecutionType =
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
ExecutionType* execObject = new ExecutionType(bih.Nodes,
bih.ProcessedCellIds,
bih.GetCellSet().Cast<CellSetType>(),
......@@ -503,7 +506,8 @@ public:
else if (cellSet.IsType<vtkm::cont::CellSetStructured<2>>())
{
using CellSetType = vtkm::cont::CellSetStructured<2>;
using ExecutionType = vtkm::exec::BoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
using ExecutionType =
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
ExecutionType* execObject = new ExecutionType(bih.Nodes,
bih.ProcessedCellIds,
bih.GetCellSet().Cast<CellSetType>(),
......@@ -514,7 +518,8 @@ public:
else if (cellSet.IsType<vtkm::cont::CellSetStructured<3>>())
{
using CellSetType = vtkm::cont::CellSetStructured<3>;
using ExecutionType = vtkm::exec::BoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
using ExecutionType =
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
ExecutionType* execObject = new ExecutionType(bih.Nodes,
bih.ProcessedCellIds,
bih.GetCellSet().Cast<CellSetType>(),
......@@ -525,7 +530,8 @@ public:
else if (cellSet.IsType<vtkm::cont::CellSetSingleType<>>())
{
using CellSetType = vtkm::cont::CellSetSingleType<>;
using ExecutionType = vtkm::exec::BoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
using ExecutionType =
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
ExecutionType* execObject = new ExecutionType(bih.Nodes,
bih.ProcessedCellIds,
bih.GetCellSet().Cast<CellSetType>(),
......@@ -542,14 +548,14 @@ public:
};
VTKM_CONT
void BoundingIntervalHierarchy::Build()
void CellLocatorBoundingIntervalHierarchy::Build()
{
BuildFunctor functor(this);
vtkm::cont::TryExecute(functor);
}
VTKM_CONT
const HandleType BoundingIntervalHierarchy::PrepareForExecutionImpl(
const HandleType CellLocatorBoundingIntervalHierarchy::PrepareForExecutionImpl(
const vtkm::cont::DeviceAdapterId deviceId) const
{
const bool success =
......
......@@ -19,17 +19,17 @@
##============================================================================
set(headers
BoundingIntervalHierarchyExec.h
BoundaryState.h
AtomicArrayExecutionObject.h
BoundaryState.h
CellDerivative.h
CellEdge.h
CellFace.h
CellInside.h
CellInterpolate.h
CellLocator.h
CellLocatorUniformGrid.h
CellLocatorBoundingIntervalHierarchyExec.h
CellLocatorRectilinearGrid.h
CellLocatorUniformGrid.h
CellMeasure.h
ColorTable.h
ConnectivityExplicit.h
......
......@@ -17,14 +17,13 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_BoundingIntervalHierarchyExec_h
#define vtk_m_cont_BoundingIntervalHierarchyExec_h
#ifndef vtk_m_cont_CellLocatorBoundingIntervalHierarchyExec_h
#define vtk_m_cont_CellLocatorBoundingIntervalHierarchyExec_h
#include <vtkm/TopologyElementTag.h>
#include <vtkm/VecFromPortalPermute.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
#include <vtkm/cont/BoundingIntervalHierarchyNode.h>
#include <vtkm/exec/CellInside.h>
#include <vtkm/exec/CellLocator.h>
#include <vtkm/exec/ParametricCoordinates.h>
......@@ -33,31 +32,57 @@ namespace vtkm
{
namespace exec
{
namespace
struct CellLocatorBoundingIntervalHierarchyNode
{
using NodeArrayHandle = vtkm::cont::ArrayHandle<vtkm::cont::BoundingIntervalHierarchyNode>;
using CellIdArrayHandle = vtkm::cont::ArrayHandle<vtkm::Id>;
vtkm::IdComponent Dimension;
vtkm::Id ParentIndex;
vtkm::Id ChildIndex;
union {
struct
{
vtkm::FloatDefault LMax;
vtkm::FloatDefault RMin;
} Node;
struct
{
vtkm::Id Start;
vtkm::Id Size;
} Leaf;
};
} // namespace
VTKM_EXEC_CONT
CellLocatorBoundingIntervalHierarchyNode()
: Dimension()
, ParentIndex()
, ChildIndex()
, Node{ 0, 0 }
{
}
}; // struct CellLocatorBoundingIntervalHierarchyNode
template <typename DeviceAdapter, typename CellSetType>
class BoundingIntervalHierarchyExec : public vtkm::exec::CellLocator
class CellLocatorBoundingIntervalHierarchyExec : public vtkm::exec::CellLocator
{
using NodeArrayHandle =
vtkm::cont::ArrayHandle<vtkm::exec::CellLocatorBoundingIntervalHierarchyNode>;
using CellIdArrayHandle = vtkm::cont::ArrayHandle<vtkm::Id>;
public:
VTKM_CONT
BoundingIntervalHierarchyExec() {}
CellLocatorBoundingIntervalHierarchyExec() {}
VTKM_CONT
BoundingIntervalHierarchyExec(const NodeArrayHandle& nodes,
const CellIdArrayHandle& cellIds,
const CellSetType& cellSet,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
DeviceAdapter)
CellLocatorBoundingIntervalHierarchyExec(const NodeArrayHandle& nodes,
const CellIdArrayHandle& cellIds,
const CellSetType& cellSet,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
DeviceAdapter)
: Nodes(nodes.PrepareForInput(DeviceAdapter()))
, CellIds(cellIds.PrepareForInput(DeviceAdapter()))
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), FromType(), ToType()))
, Coords(coords.PrepareForInput(DeviceAdapter()))
{
CellSet = cellSet.PrepareForInput(DeviceAdapter(), FromType(), ToType());
Coords = coords.PrepareForInput(DeviceAdapter());
}
VTKM_EXEC
......@@ -109,7 +134,7 @@ private:
{
VTKM_ASSERT(state == FindCellState::EnterNode);
const vtkm::cont::BoundingIntervalHierarchyNode& node = this->Nodes.Get(nodeIndex);
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& node = this->Nodes.Get(nodeIndex);
if (node.ChildIndex < 0)
{
......@@ -129,9 +154,11 @@ private:
VTKM_ASSERT(state == FindCellState::AscendFromNode);
vtkm::Id childNodeIndex = nodeIndex;
const vtkm::cont::BoundingIntervalHierarchyNode& childNode = this->Nodes.Get(childNodeIndex);
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& childNode =
this->Nodes.Get(childNodeIndex);
nodeIndex = childNode.ParentIndex;
const vtkm::cont::BoundingIntervalHierarchyNode& parentNode = this->Nodes.Get(nodeIndex);
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& parentNode =
this->Nodes.Get(nodeIndex);
if (parentNode.ChildIndex == childNodeIndex)
{
......@@ -152,7 +179,7 @@ private:
{
VTKM_ASSERT(state == FindCellState::DescendLeftChild);
const vtkm::cont::BoundingIntervalHierarchyNode& node = this->Nodes.Get(nodeIndex);
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& node = this->Nodes.Get(nodeIndex);
const vtkm::FloatDefault& coordinate = point[node.Dimension];
if (coordinate <= node.Node.LMax)
{
......@@ -174,7 +201,7 @@ private:
{
VTKM_ASSERT(state == FindCellState::DescendRightChild);
const vtkm::cont::BoundingIntervalHierarchyNode& node = this->Nodes.Get(nodeIndex);
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& node = this->Nodes.Get(nodeIndex);
const vtkm::FloatDefault& coordinate = point[node.Dimension];
if (coordinate >= node.Node.RMin)
{
......@@ -191,16 +218,17 @@ private:
VTKM_EXEC vtkm::Id FindInLeaf(const vtkm::Vec<vtkm::FloatDefault, 3>& point,
vtkm::Vec<vtkm::FloatDefault, 3>& parametric,
const vtkm::cont::BoundingIntervalHierarchyNode& node,
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& node,
const vtkm::exec::FunctorBase& worklet) const
{
using IndicesType = typename CellSetPortal::IndicesType;
for (vtkm::Id i = node.Leaf.Start; i < node.Leaf.Start + node.Leaf.Size; ++i)
{
vtkm::Id cellId = CellIds.Get(i);
IndicesType cellPointIndices = CellSet.GetIndices(cellId);
vtkm::VecFromPortalPermute<IndicesType, CoordsPortal> cellPoints(&cellPointIndices, Coords);
if (IsPointInCell(point, parametric, CellSet.GetCellShape(cellId), cellPoints, worklet))
vtkm::Id cellId = this->CellIds.Get(i);
IndicesType cellPointIndices = this->CellSet.GetIndices(cellId);
vtkm::VecFromPortalPermute<IndicesType, CoordsPortal> cellPoints(&cellPointIndices,
this->Coords);
if (IsPointInCell(point, parametric, this->CellSet.GetCellShape(cellId), cellPoints, worklet))
{
return cellId;
}
......@@ -235,10 +263,10 @@ private:
CellIdPortal CellIds;
CellSetPortal CellSet;
CoordsPortal Coords;
}; // class BoundingIntervalHierarchyExec
}; // class CellLocatorBoundingIntervalHierarchyExec
} // namespace exec
} // namespace vtkm
#endif //vtk_m_cont_BoundingIntervalHierarchyExec_h
#endif //vtk_m_cont_CellLocatorBoundingIntervalHierarchyExec_h
......@@ -31,9 +31,9 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleReverse.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/BoundingIntervalHierarchyNode.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>
#include <vtkm/exec/CellLocatorBoundingIntervalHierarchyExec.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
......@@ -533,7 +533,7 @@ struct TreeLevelAdder : public vtkm::worklet::WorkletMapField
BoundingIntervalHierarchyPortal& treePortal,
NextParentPortal& nextParentPortal) const
{
vtkm::cont::BoundingIntervalHierarchyNode node;
vtkm::exec::CellLocatorBoundingIntervalHierarchyNode node;
node.ParentIndex = parentIndex;
if (count > this->MaxLeafSize)
{
......
......@@ -20,7 +20,7 @@
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandleConcatenate.h>
#include <vtkm/cont/BoundingIntervalHierarchy.hxx>
#include <vtkm/cont/CellLocatorBoundingIntervalHierarchy.hxx>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/internal/DeviceAdapterTag.h>
......@@ -79,7 +79,8 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet,
std::cout << "Using numPlanes: " << numPlanes << "\n";
std::cout << "Building Bounding Interval Hierarchy Tree" << std::endl;
vtkm::cont::BoundingIntervalHierarchy bih = vtkm::cont::BoundingIntervalHierarchy(numPlanes, 5);
vtkm::cont::CellLocatorBoundingIntervalHierarchy bih =
vtkm::cont::CellLocatorBoundingIntervalHierarchy(numPlanes, 5);
bih.SetCellSet(cellSet);
bih.SetCoordinates(dataSet.GetCoordinateSystem());
bih.Update();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment