Streamline CellSetExplicit
1) Don't require a DeviceAdapter for the BuildConnectivity function (#131) 2) Explicitly instantiate default CellSetExplicit and CellSetSingleType
This commit is contained in:
parent
23a56dd771
commit
4e1b026c8a
@ -81,6 +81,7 @@ set(headers
|
||||
|
||||
set(header_impls
|
||||
ArrayHandle.hxx
|
||||
CellSetExplicit.hxx
|
||||
CellSetStructured.hxx
|
||||
ImplicitFunction.hxx
|
||||
StorageBasic.hxx
|
||||
@ -89,6 +90,7 @@ set(header_impls
|
||||
set(sources
|
||||
ArrayHandle.cxx
|
||||
CellSet.cxx
|
||||
CellSetExplicit.cxx
|
||||
CellSetStructured.cxx
|
||||
CoordinateSystem.cxx
|
||||
DynamicArrayHandle.cxx
|
||||
|
36
vtkm/cont/CellSetExplicit.cxx
Normal file
36
vtkm/cont/CellSetExplicit.cxx
Normal file
@ -0,0 +1,36 @@
|
||||
//============================================================================
|
||||
// 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 2017 Sandia Corporation.
|
||||
// Copyright 2017 UT-Battelle, LLC.
|
||||
// Copyright 2017 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
#define vtk_m_cont_CellSetExplicit_cxx
|
||||
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template class VTKM_CONT_EXPORT CellSetExplicit<>; // default
|
||||
template class VTKM_CONT_EXPORT
|
||||
CellSetExplicit<typename vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag,
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag,
|
||||
VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
|
||||
typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag>;
|
||||
}
|
||||
}
|
@ -23,12 +23,12 @@
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/internal/ConnectivityExplicitInternals.h>
|
||||
#include <vtkm/exec/ConnectivityExplicit.h>
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -99,148 +99,36 @@ public:
|
||||
typedef typename PointToCellConnectivityType::ConnectivityArrayType ConnectivityArrayType;
|
||||
typedef typename PointToCellConnectivityType::IndexOffsetArrayType IndexOffsetArrayType;
|
||||
|
||||
VTKM_CONT
|
||||
CellSetExplicit(const std::string& name = std::string())
|
||||
: CellSet(name)
|
||||
, ConnectivityAdded(-1)
|
||||
, NumberOfCellsAdded(-1)
|
||||
, NumberOfPoints(0)
|
||||
{
|
||||
}
|
||||
VTKM_CONT CellSetExplicit(const std::string& name = std::string());
|
||||
VTKM_CONT CellSetExplicit(const Thisclass& src);
|
||||
|
||||
VTKM_CONT
|
||||
CellSetExplicit(const Thisclass& src)
|
||||
: CellSet(src)
|
||||
, PointToCell(src.PointToCell)
|
||||
, CellToPoint(src.CellToPoint)
|
||||
, ConnectivityAdded(src.ConnectivityAdded)
|
||||
, NumberOfCellsAdded(src.NumberOfCellsAdded)
|
||||
, NumberOfPoints(src.NumberOfPoints)
|
||||
{
|
||||
}
|
||||
VTKM_CONT Thisclass& operator=(const Thisclass& src);
|
||||
|
||||
VTKM_CONT
|
||||
Thisclass& operator=(const Thisclass& src)
|
||||
{
|
||||
this->CellSet::operator=(src);
|
||||
this->PointToCell = src.PointToCell;
|
||||
this->CellToPoint = src.CellToPoint;
|
||||
this->ConnectivityAdded = src.ConnectivityAdded;
|
||||
this->NumberOfCellsAdded = src.NumberOfCellsAdded;
|
||||
this->NumberOfPoints = src.NumberOfPoints;
|
||||
return *this;
|
||||
}
|
||||
virtual ~CellSetExplicit();
|
||||
|
||||
virtual ~CellSetExplicit() {}
|
||||
vtkm::Id GetNumberOfCells() const VTKM_OVERRIDE;
|
||||
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE;
|
||||
vtkm::Id GetNumberOfFaces() const VTKM_OVERRIDE;
|
||||
vtkm::Id GetNumberOfEdges() const VTKM_OVERRIDE;
|
||||
void PrintSummary(std::ostream& out) const VTKM_OVERRIDE;
|
||||
|
||||
vtkm::Id GetNumberOfCells() const VTKM_OVERRIDE
|
||||
{
|
||||
return this->PointToCell.GetNumberOfElements();
|
||||
}
|
||||
VTKM_CONT vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const;
|
||||
VTKM_CONT vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const;
|
||||
|
||||
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE { return this->NumberOfPoints; }
|
||||
VTKM_CONT vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id cellIndex) const;
|
||||
|
||||
vtkm::Id GetNumberOfFaces() const VTKM_OVERRIDE { return -1; }
|
||||
|
||||
vtkm::Id GetNumberOfEdges() const VTKM_OVERRIDE { return -1; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const
|
||||
{
|
||||
return this->GetNumberOfCells();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const
|
||||
{
|
||||
return this->GetNumberOfPoints();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id cellIndex) const
|
||||
{
|
||||
return this->PointToCell.NumIndices.GetPortalConstControl().Get(cellIndex);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::UInt8 GetCellShape(vtkm::Id cellIndex) const
|
||||
{
|
||||
return this->PointToCell.Shapes.GetPortalConstControl().Get(cellIndex);
|
||||
}
|
||||
VTKM_CONT vtkm::UInt8 GetCellShape(vtkm::Id cellIndex) const;
|
||||
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const
|
||||
{
|
||||
this->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
|
||||
vtkm::Id start = this->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
|
||||
for (vtkm::IdComponent i = 0; i < numIndices && i < ItemTupleLength; i++)
|
||||
ids[i] = this->PointToCell.Connectivity.GetPortalConstControl().Get(start + i);
|
||||
}
|
||||
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const;
|
||||
|
||||
/// First method to add cells -- one at a time.
|
||||
VTKM_CONT
|
||||
void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen)
|
||||
{
|
||||
this->PointToCell.Shapes.Allocate(numCells);
|
||||
this->PointToCell.NumIndices.Allocate(numCells);
|
||||
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
|
||||
this->PointToCell.IndexOffsets.Allocate(numCells);
|
||||
this->NumberOfCellsAdded = 0;
|
||||
this->ConnectivityAdded = 0;
|
||||
}
|
||||
VTKM_CONT void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen);
|
||||
|
||||
template <typename IdVecType>
|
||||
VTKM_CONT void AddCell(vtkm::UInt8 cellType, vtkm::IdComponent numVertices, const IdVecType& ids)
|
||||
{
|
||||
using Traits = vtkm::VecTraits<IdVecType>;
|
||||
VTKM_STATIC_ASSERT_MSG((std::is_same<typename Traits::ComponentType, vtkm::Id>::value),
|
||||
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
|
||||
VTKM_CONT void AddCell(vtkm::UInt8 cellType, vtkm::IdComponent numVertices, const IdVecType& ids);
|
||||
|
||||
if (Traits::GetNumberOfComponents(ids) < numVertices)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Not enough indices given to CellSetSingleType::AddCell.");
|
||||
}
|
||||
|
||||
if (this->NumberOfCellsAdded >= this->PointToCell.Shapes.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Added more cells then expected.");
|
||||
}
|
||||
if (this->ConnectivityAdded + numVertices > this->PointToCell.Connectivity.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Connectivity increased passed estimated maximum connectivity.");
|
||||
}
|
||||
|
||||
this->PointToCell.Shapes.GetPortalControl().Set(this->NumberOfCellsAdded, cellType);
|
||||
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCellsAdded, numVertices);
|
||||
for (vtkm::IdComponent iVec = 0; iVec < numVertices; ++iVec)
|
||||
{
|
||||
this->PointToCell.Connectivity.GetPortalControl().Set(this->ConnectivityAdded + iVec,
|
||||
Traits::GetComponent(ids, iVec));
|
||||
}
|
||||
this->PointToCell.IndexOffsets.GetPortalControl().Set(this->NumberOfCellsAdded,
|
||||
this->ConnectivityAdded);
|
||||
this->NumberOfCellsAdded++;
|
||||
this->ConnectivityAdded += numVertices;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void CompleteAddingCells(vtkm::Id numPoints)
|
||||
{
|
||||
this->NumberOfPoints = numPoints;
|
||||
this->PointToCell.Connectivity.Shrink(ConnectivityAdded);
|
||||
this->PointToCell.ElementsValid = true;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
|
||||
if (this->NumberOfCellsAdded != this->GetNumberOfCells())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Did not add as many cells as expected.");
|
||||
}
|
||||
|
||||
this->NumberOfCellsAdded = -1;
|
||||
this->ConnectivityAdded = -1;
|
||||
}
|
||||
VTKM_CONT void CompleteAddingCells(vtkm::Id numPoints);
|
||||
|
||||
/// Second method to add cells -- all at once.
|
||||
/// Assigns the array handles to the explicit connectivity. This is
|
||||
@ -251,30 +139,7 @@ public:
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag>& connectivity,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>& offsets =
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>())
|
||||
{
|
||||
this->NumberOfPoints = numPoints;
|
||||
this->PointToCell.Shapes = cellTypes;
|
||||
this->PointToCell.NumIndices = numIndices;
|
||||
this->PointToCell.Connectivity = connectivity;
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
|
||||
if (offsets.GetNumberOfValues() == cellTypes.GetNumberOfValues())
|
||||
{
|
||||
this->PointToCell.IndexOffsets = offsets;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
if (offsets.GetNumberOfValues() != 0)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Explicit cell offsets array unexpected size. "
|
||||
"Use an empty array to automatically generate.");
|
||||
}
|
||||
}
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>());
|
||||
|
||||
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||
struct ExecutionTypes
|
||||
@ -303,135 +168,72 @@ public:
|
||||
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType
|
||||
PrepareForInput(Device, FromTopology, ToTopology) const
|
||||
{
|
||||
this->BuildConnectivity(Device(), FromTopology(), ToTopology());
|
||||
|
||||
const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityType& connectivity =
|
||||
this->GetConnectivity(FromTopology(), ToTopology());
|
||||
|
||||
VTKM_ASSERT(connectivity.ElementsValid);
|
||||
|
||||
typedef typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType ExecObjType;
|
||||
return ExecObjType(connectivity.Shapes.PrepareForInput(Device()),
|
||||
connectivity.NumIndices.PrepareForInput(Device()),
|
||||
connectivity.Connectivity.PrepareForInput(Device()),
|
||||
connectivity.IndexOffsets.PrepareForInput(Device()));
|
||||
}
|
||||
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT void BuildConnectivity(Device, FromTopology, ToTopology) const
|
||||
{
|
||||
typedef CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>
|
||||
CSE;
|
||||
|
||||
CSE* self = const_cast<CSE*>(this);
|
||||
|
||||
self->CreateConnectivity(Device(), FromTopology(), ToTopology());
|
||||
|
||||
self->GetConnectivity(FromTopology(), ToTopology()).BuildIndexOffsets(Device());
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT void CreateConnectivity(Device,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT void CreateConnectivity(Device,
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint)
|
||||
{
|
||||
this->PointToCell.BuildIndexOffsets(Device());
|
||||
internal::ComputeCellToPointConnectivity(
|
||||
this->CellToPoint, this->PointToCell, this->GetNumberOfPoints(), Device());
|
||||
}
|
||||
|
||||
void PrintSummary(std::ostream& out) const VTKM_OVERRIDE
|
||||
{
|
||||
out << " ExplicitCellSet: " << this->Name << std::endl;
|
||||
out << " PointToCell: " << std::endl;
|
||||
this->PointToCell.PrintSummary(out);
|
||||
out << " CellToPoint: " << std::endl;
|
||||
this->CellToPoint.PrintSummary(out);
|
||||
}
|
||||
PrepareForInput(Device, FromTopology, ToTopology) const;
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
|
||||
GetShapesArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).Shapes;
|
||||
}
|
||||
GetShapesArray(FromTopology, ToTopology) const;
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
|
||||
GetNumIndicesArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).NumIndices;
|
||||
}
|
||||
GetNumIndicesArray(FromTopology, ToTopology) const;
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
|
||||
GetConnectivityArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).Connectivity;
|
||||
}
|
||||
GetConnectivityArray(FromTopology, ToTopology) const;
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
|
||||
GetIndexOffsetArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
||||
}
|
||||
GetIndexOffsetArray(FromTopology, ToTopology) const;
|
||||
|
||||
protected:
|
||||
VTKM_CONT void BuildConnectivity(
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker()) const;
|
||||
|
||||
VTKM_CONT void BuildConnectivity(
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker()) const;
|
||||
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell>::ConnectivityType PointToCell;
|
||||
|
||||
// TODO: Actually implement CellToPoint and other connectivity. (That is,
|
||||
// derive the connectivity from PointToCell.
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint>::ConnectivityType CellToPoint;
|
||||
|
||||
private:
|
||||
// A set of overloaded methods to get the connectivity from a pair of
|
||||
// topology element types.
|
||||
#define VTKM_GET_CONNECTIVITY_METHOD(FromTopology, ToTopology, Ivar) \
|
||||
VTKM_CONT \
|
||||
const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityType& GetConnectivity( \
|
||||
FromTopology, ToTopology) const \
|
||||
{ \
|
||||
return this->Ivar; \
|
||||
} \
|
||||
VTKM_CONT \
|
||||
typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityType& GetConnectivity( \
|
||||
FromTopology, ToTopology) \
|
||||
{ \
|
||||
return this->Ivar; \
|
||||
}
|
||||
|
||||
VTKM_GET_CONNECTIVITY_METHOD(vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
PointToCell)
|
||||
VTKM_GET_CONNECTIVITY_METHOD(vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
CellToPoint)
|
||||
|
||||
#undef VTKM_GET_CONNECTIVITY_METHOD
|
||||
|
||||
protected:
|
||||
// These are used in the AddCell and related methods to incrementally add
|
||||
// cells. They need to be protected as subclasses of CellSetExplicit
|
||||
// need to set these values when implementing Fill()
|
||||
vtkm::Id ConnectivityAdded;
|
||||
vtkm::Id NumberOfCellsAdded;
|
||||
vtkm::Id NumberOfPoints;
|
||||
|
||||
private:
|
||||
auto GetConnectivity(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const -> const
|
||||
decltype(Thisclass::PointToCell)&
|
||||
{
|
||||
return this->PointToCell;
|
||||
}
|
||||
|
||||
auto GetConnectivity(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell)
|
||||
-> decltype(Thisclass::PointToCell)&
|
||||
{
|
||||
return this->PointToCell;
|
||||
}
|
||||
|
||||
auto GetConnectivity(vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint) const -> const
|
||||
decltype(Thisclass::CellToPoint)&
|
||||
{
|
||||
return this->CellToPoint;
|
||||
}
|
||||
|
||||
auto GetConnectivity(vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint)
|
||||
-> decltype(Thisclass::CellToPoint)&
|
||||
{
|
||||
return this->CellToPoint;
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail
|
||||
@ -461,7 +263,18 @@ struct CellSetExplicitConnectivityChooser<CellSetType,
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#ifndef vtk_m_cont_CellSetExplicit_cxx
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetExplicit<>; // default
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetExplicit<
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag,
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag,
|
||||
VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
|
||||
typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag>; // CellSetSingleType base
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#include <vtkm/cont/CellSetExplicit.hxx>
|
||||
|
||||
#endif //vtk_m_cont_CellSetExplicit_h
|
||||
|
539
vtkm/cont/CellSetExplicit.hxx
Normal file
539
vtkm/cont/CellSetExplicit.hxx
Normal file
@ -0,0 +1,539 @@
|
||||
//============================================================================
|
||||
// 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 2017 Sandia Corporation.
|
||||
// Copyright 2017 UT-Battelle, LLC.
|
||||
// Copyright 2017 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::CellSetExplicit(const std::string& name)
|
||||
: CellSet(name)
|
||||
, ConnectivityAdded(-1)
|
||||
, NumberOfCellsAdded(-1)
|
||||
, NumberOfPoints(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::CellSetExplicit(const Thisclass& src)
|
||||
: CellSet(src)
|
||||
, PointToCell(src.PointToCell)
|
||||
, CellToPoint(src.CellToPoint)
|
||||
, ConnectivityAdded(src.ConnectivityAdded)
|
||||
, NumberOfCellsAdded(src.NumberOfCellsAdded)
|
||||
, NumberOfPoints(src.NumberOfPoints)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT auto
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
operator=(const Thisclass& src) -> Thisclass&
|
||||
{
|
||||
this->CellSet::operator=(src);
|
||||
this->PointToCell = src.PointToCell;
|
||||
this->CellToPoint = src.CellToPoint;
|
||||
this->ConnectivityAdded = src.ConnectivityAdded;
|
||||
this->NumberOfCellsAdded = src.NumberOfCellsAdded;
|
||||
this->NumberOfPoints = src.NumberOfPoints;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
~CellSetExplicit() = default;
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
void CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
out << " ExplicitCellSet: " << this->Name << std::endl;
|
||||
out << " PointToCell: " << std::endl;
|
||||
this->PointToCell.PrintSummary(out);
|
||||
out << " CellToPoint: " << std::endl;
|
||||
this->CellToPoint.PrintSummary(out);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
vtkm::Id CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetNumberOfCells() const
|
||||
{
|
||||
return this->PointToCell.GetNumberOfElements();
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
vtkm::Id CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetNumberOfPoints() const
|
||||
{
|
||||
return this->NumberOfPoints;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
vtkm::Id CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetNumberOfFaces() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
vtkm::Id CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetNumberOfEdges() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT vtkm::Id
|
||||
CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetSchedulingRange(vtkm::TopologyElementTagCell) const
|
||||
{
|
||||
return this->GetNumberOfCells();
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT vtkm::Id
|
||||
CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetSchedulingRange(vtkm::TopologyElementTagPoint) const
|
||||
{
|
||||
return this->GetNumberOfPoints();
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT vtkm::IdComponent
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
GetNumberOfPointsInCell(vtkm::Id cellIndex) const
|
||||
{
|
||||
return this->PointToCell.NumIndices.GetPortalConstControl().Get(cellIndex);
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT vtkm::UInt8 CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetCellShape(vtkm::Id cellIndex) const
|
||||
{
|
||||
return this->PointToCell.Shapes.GetPortalConstControl().Get(cellIndex);
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
VTKM_CONT void
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const
|
||||
{
|
||||
this->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
|
||||
vtkm::Id start = this->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
|
||||
for (vtkm::IdComponent i = 0; i < numIndices && i < ItemTupleLength; i++)
|
||||
{
|
||||
ids[i] = this->PointToCell.Connectivity.GetPortalConstControl().Get(start + i);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT void CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::PrepareToAddCells(vtkm::Id numCells,
|
||||
vtkm::Id connectivityMaxLen)
|
||||
{
|
||||
this->PointToCell.Shapes.Allocate(numCells);
|
||||
this->PointToCell.NumIndices.Allocate(numCells);
|
||||
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
|
||||
this->PointToCell.IndexOffsets.Allocate(numCells);
|
||||
this->NumberOfCellsAdded = 0;
|
||||
this->ConnectivityAdded = 0;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <typename IdVecType>
|
||||
VTKM_CONT void
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
AddCell(vtkm::UInt8 cellType, vtkm::IdComponent numVertices, const IdVecType& ids)
|
||||
{
|
||||
using Traits = vtkm::VecTraits<IdVecType>;
|
||||
VTKM_STATIC_ASSERT_MSG((std::is_same<typename Traits::ComponentType, vtkm::Id>::value),
|
||||
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
|
||||
|
||||
if (Traits::GetNumberOfComponents(ids) < numVertices)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Not enough indices given to CellSetSingleType::AddCell.");
|
||||
}
|
||||
|
||||
if (this->NumberOfCellsAdded >= this->PointToCell.Shapes.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Added more cells then expected.");
|
||||
}
|
||||
if (this->ConnectivityAdded + numVertices > this->PointToCell.Connectivity.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Connectivity increased passed estimated maximum connectivity.");
|
||||
}
|
||||
|
||||
this->PointToCell.Shapes.GetPortalControl().Set(this->NumberOfCellsAdded, cellType);
|
||||
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCellsAdded, numVertices);
|
||||
for (vtkm::IdComponent iVec = 0; iVec < numVertices; ++iVec)
|
||||
{
|
||||
this->PointToCell.Connectivity.GetPortalControl().Set(this->ConnectivityAdded + iVec,
|
||||
Traits::GetComponent(ids, iVec));
|
||||
}
|
||||
this->PointToCell.IndexOffsets.GetPortalControl().Set(this->NumberOfCellsAdded,
|
||||
this->ConnectivityAdded);
|
||||
this->NumberOfCellsAdded++;
|
||||
this->ConnectivityAdded += numVertices;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT void CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::CompleteAddingCells(vtkm::Id numPoints)
|
||||
{
|
||||
this->NumberOfPoints = numPoints;
|
||||
this->PointToCell.Connectivity.Shrink(ConnectivityAdded);
|
||||
this->PointToCell.ElementsValid = true;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
|
||||
if (this->NumberOfCellsAdded != this->GetNumberOfCells())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Did not add as many cells as expected.");
|
||||
}
|
||||
|
||||
this->NumberOfCellsAdded = -1;
|
||||
this->ConnectivityAdded = -1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT void
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
Fill(vtkm::Id numPoints,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag>& cellTypes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag>& connectivity,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>& offsets)
|
||||
{
|
||||
this->NumberOfPoints = numPoints;
|
||||
this->PointToCell.Shapes = cellTypes;
|
||||
this->PointToCell.NumIndices = numIndices;
|
||||
this->PointToCell.Connectivity = connectivity;
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
|
||||
if (offsets.GetNumberOfValues() == cellTypes.GetNumberOfValues())
|
||||
{
|
||||
this->PointToCell.IndexOffsets = offsets;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
if (offsets.GetNumberOfValues() != 0)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Explicit cell offsets array unexpected size. "
|
||||
"Use an empty array to automatically generate.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
auto CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::PrepareForInput(Device, FromTopology, ToTopology) const ->
|
||||
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType
|
||||
{
|
||||
this->BuildConnectivity(FromTopology(), ToTopology());
|
||||
|
||||
const auto& connectivity = this->GetConnectivity(FromTopology(), ToTopology());
|
||||
VTKM_ASSERT(connectivity.ElementsValid);
|
||||
|
||||
typedef typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType ExecObjType;
|
||||
return ExecObjType(connectivity.Shapes.PrepareForInput(Device()),
|
||||
connectivity.NumIndices.PrepareForInput(Device()),
|
||||
connectivity.Connectivity.PrepareForInput(Device()),
|
||||
connectivity.IndexOffsets.PrepareForInput(Device()));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetShapesArray(FromTopology, ToTopology) const
|
||||
-> const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
|
||||
{
|
||||
this->BuildConnectivity(FromTopology(), ToTopology());
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).Shapes;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetNumIndicesArray(FromTopology,
|
||||
ToTopology) const -> const
|
||||
typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
|
||||
{
|
||||
this->BuildConnectivity(FromTopology(), ToTopology());
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).NumIndices;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetConnectivityArray(FromTopology,
|
||||
ToTopology) const -> const
|
||||
typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
|
||||
{
|
||||
this->BuildConnectivity(FromTopology(), ToTopology());
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).Connectivity;
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::GetIndexOffsetArray(FromTopology,
|
||||
ToTopology) const -> const
|
||||
typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
|
||||
{
|
||||
this->BuildConnectivity(FromTopology(), ToTopology());
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename PointToCellConnectivity>
|
||||
struct BuildPointToCellConnectivityFunctor
|
||||
{
|
||||
explicit BuildPointToCellConnectivityFunctor(PointToCellConnectivity& pointToCell)
|
||||
: PointToCell(&pointToCell)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
bool operator()(Device) const
|
||||
{
|
||||
this->PointToCell->BuildIndexOffsets(Device());
|
||||
return true;
|
||||
}
|
||||
|
||||
PointToCellConnectivity* PointToCell;
|
||||
};
|
||||
|
||||
template <typename PointToCellConnectivity, typename CellToPointConnectivity>
|
||||
struct BuildCellToPointConnectivityFunctor
|
||||
{
|
||||
BuildCellToPointConnectivityFunctor(PointToCellConnectivity& pointToCell,
|
||||
CellToPointConnectivity& cellToPoint,
|
||||
vtkm::Id numberOfPoints)
|
||||
: PointToCell(&pointToCell)
|
||||
, CellToPoint(&cellToPoint)
|
||||
, NumberOfPoints(numberOfPoints)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
bool operator()(Device) const
|
||||
{
|
||||
this->PointToCell->BuildIndexOffsets(Device());
|
||||
internal::ComputeCellToPointConnectivity(
|
||||
*this->CellToPoint, *this->PointToCell, this->NumberOfPoints, Device());
|
||||
this->CellToPoint->BuildIndexOffsets(Device());
|
||||
return true;
|
||||
}
|
||||
|
||||
PointToCellConnectivity* PointToCell;
|
||||
CellToPointConnectivity* CellToPoint;
|
||||
vtkm::Id NumberOfPoints;
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT void
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
BuildConnectivity(vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker) const
|
||||
{
|
||||
using PointToCellConnectivity =
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell>::ConnectivityType;
|
||||
|
||||
VTKM_ASSERT(this->PointToCell.ElementsValid);
|
||||
if (!this->PointToCell.IndexOffsetsValid)
|
||||
{
|
||||
auto self = const_cast<Thisclass*>(this);
|
||||
auto functor =
|
||||
detail::BuildPointToCellConnectivityFunctor<PointToCellConnectivity>(self->PointToCell);
|
||||
if (!vtkm::cont::TryExecute(functor, tracker))
|
||||
{
|
||||
throw vtkm::cont::ErrorExecution("Failed to run BuildConnectivity on any device.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ShapeStorageTag,
|
||||
typename NumIndicesStorageTag,
|
||||
typename ConnectivityStorageTag,
|
||||
typename OffsetsStorageTag>
|
||||
VTKM_CONT void
|
||||
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
|
||||
BuildConnectivity(vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker) const
|
||||
{
|
||||
using PointToCellConnectivity =
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell>::ConnectivityType;
|
||||
using CellToPointConnectivity =
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint>::ConnectivityType;
|
||||
|
||||
if (!this->CellToPoint.ElementsValid || !this->CellToPoint.IndexOffsetsValid)
|
||||
{
|
||||
auto self = const_cast<Thisclass*>(this);
|
||||
auto functor =
|
||||
detail::BuildCellToPointConnectivityFunctor<PointToCellConnectivity, CellToPointConnectivity>(
|
||||
self->PointToCell, self->CellToPoint, this->NumberOfPoints);
|
||||
if (!vtkm::cont::TryExecute(functor, tracker))
|
||||
{
|
||||
throw vtkm::cont::ErrorExecution("Failed to run BuildConnectivity on any device.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // vtkm::cont
|
@ -105,9 +105,6 @@ private:
|
||||
vtkm::cont::CellSetExplicit<> cellset;
|
||||
ds.GetCellSet(0).CopyTo(cellset);
|
||||
|
||||
cellset.BuildConnectivity(
|
||||
DeviceAdapterTag(), vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
|
||||
|
||||
vtkm::Id connectivitySize = 7;
|
||||
vtkm::Id numPoints = 5;
|
||||
|
||||
|
@ -112,12 +112,6 @@ private:
|
||||
vtkm::cont::CellSetSingleType<> cellset;
|
||||
dataSet.GetCellSet(0).CopyTo(cellset);
|
||||
|
||||
//verify that we can compute the cell to point connectivity
|
||||
cellset.BuildConnectivity(
|
||||
DeviceAdapterTag(), vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
|
||||
|
||||
dataSet.PrintSummary(std::cout);
|
||||
|
||||
//verify that the point to cell connectivity types are correct
|
||||
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapesPointToCell =
|
||||
cellset.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
|
||||
|
Loading…
Reference in New Issue
Block a user