2015-06-03 19:06:43 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2015-06-03 19:06:43 +00:00
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2015-06-03 19:06:43 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2015-04-15 16:43:12 +00:00
|
|
|
#ifndef vtk_m_cont_CellSetExplicit_h
|
|
|
|
#define vtk_m_cont_CellSetExplicit_h
|
|
|
|
|
2015-08-16 18:53:44 +00:00
|
|
|
#include <vtkm/CellShape.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/TopologyElementTag.h>
|
2017-07-21 16:15:54 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleConstant.h>
|
2017-08-10 20:13:58 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleCounting.h>
|
2015-04-15 16:43:12 +00:00
|
|
|
#include <vtkm/cont/CellSet.h>
|
2015-08-11 18:42:34 +00:00
|
|
|
#include <vtkm/cont/internal/ConnectivityExplicitInternals.h>
|
2015-08-02 21:59:44 +00:00
|
|
|
#include <vtkm/exec/ConnectivityExplicit.h>
|
2015-04-15 16:43:12 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
#include <vtkm/cont/vtkm_cont_export.h>
|
2015-08-28 17:51:42 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2015-04-15 16:43:12 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace detail
|
|
|
|
{
|
2015-08-11 18:42:34 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CellSetType, typename FromTopology, typename ToTopology>
|
2015-08-11 18:42:34 +00:00
|
|
|
struct CellSetExplicitConnectivityChooser
|
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ConnectivityType = vtkm::cont::internal::ConnectivityExplicitInternals<>;
|
2015-08-11 18:42:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
2015-09-23 17:52:58 +00:00
|
|
|
#ifndef VTKM_DEFAULT_SHAPE_STORAGE_TAG
|
|
|
|
#define VTKM_DEFAULT_SHAPE_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG
|
|
|
|
#define VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG
|
|
|
|
#define VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
|
|
|
#endif
|
|
|
|
|
2015-09-23 21:42:12 +00:00
|
|
|
#ifndef VTKM_DEFAULT_OFFSETS_STORAGE_TAG
|
|
|
|
#define VTKM_DEFAULT_OFFSETS_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
|
|
|
#endif
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
|
|
|
|
typename NumIndicesStorageTag = VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG,
|
|
|
|
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
|
|
|
|
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG>
|
2017-03-01 22:11:23 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT CellSetExplicit : public CellSet
|
2015-04-15 16:43:12 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using Thisclass = CellSetExplicit<ShapeStorageTag,
|
|
|
|
NumIndicesStorageTag,
|
|
|
|
ConnectivityStorageTag,
|
|
|
|
OffsetsStorageTag>;
|
2015-10-21 22:27:09 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename FromTopology, typename ToTopology>
|
2015-08-11 18:42:34 +00:00
|
|
|
struct ConnectivityChooser
|
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ConnectivityType =
|
|
|
|
typename detail::CellSetExplicitConnectivityChooser<Thisclass,
|
|
|
|
FromTopology,
|
|
|
|
ToTopology>::ConnectivityType;
|
|
|
|
|
|
|
|
using ShapeArrayType = typename ConnectivityType::ShapeArrayType;
|
|
|
|
using NumIndicesArrayType = typename ConnectivityType::NumIndicesArrayType;
|
|
|
|
using ConnectivityArrayType = typename ConnectivityType::ConnectivityArrayType;
|
|
|
|
using IndexOffsetArrayType = typename ConnectivityType::IndexOffsetArrayType;
|
2015-08-11 18:42:34 +00:00
|
|
|
};
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2015-05-12 13:39:00 +00:00
|
|
|
public:
|
2017-08-16 15:34:21 +00:00
|
|
|
using SchedulingRangeType = vtkm::Id;
|
2015-05-12 13:39:00 +00:00
|
|
|
|
2015-09-28 17:15:26 +00:00
|
|
|
//point to cell is used when iterating cells and asking for point properties
|
2017-08-16 15:34:21 +00:00
|
|
|
using PointToCellConnectivityType =
|
|
|
|
ConnectivityChooser<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>;
|
2015-10-21 22:27:09 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ShapeArrayType = typename PointToCellConnectivityType::ShapeArrayType;
|
|
|
|
using NumIndicesArrayType = typename PointToCellConnectivityType::NumIndicesArrayType;
|
|
|
|
using ConnectivityArrayType = typename PointToCellConnectivityType::ConnectivityArrayType;
|
|
|
|
using IndexOffsetArrayType = typename PointToCellConnectivityType::IndexOffsetArrayType;
|
2015-10-21 22:27:09 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT CellSetExplicit(const std::string& name = std::string());
|
|
|
|
VTKM_CONT CellSetExplicit(const Thisclass& src);
|
2015-05-12 13:39:00 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT Thisclass& operator=(const Thisclass& src);
|
2015-08-28 17:51:42 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
virtual ~CellSetExplicit();
|
2016-12-16 22:04:58 +00:00
|
|
|
|
2017-11-02 12:36:05 +00:00
|
|
|
vtkm::Id GetNumberOfCells() const override;
|
|
|
|
vtkm::Id GetNumberOfPoints() const override;
|
|
|
|
vtkm::Id GetNumberOfFaces() const override;
|
|
|
|
vtkm::Id GetNumberOfEdges() const override;
|
|
|
|
void PrintSummary(std::ostream& out) const override;
|
2018-05-30 18:32:06 +00:00
|
|
|
void ReleaseResourcesExecution() override;
|
2016-12-16 22:04:58 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const;
|
|
|
|
VTKM_CONT vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const;
|
2015-08-28 17:51:42 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id cellIndex) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT vtkm::UInt8 GetCellShape(vtkm::Id cellIndex) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2015-11-02 18:05:12 +00:00
|
|
|
template <vtkm::IdComponent ItemTupleLength>
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-08-28 20:58:44 +00:00
|
|
|
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const;
|
2017-08-28 18:50:46 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
/// First method to add cells -- one at a time.
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen);
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2016-12-20 23:14:50 +00:00
|
|
|
template <typename IdVecType>
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT void AddCell(vtkm::UInt8 cellType, vtkm::IdComponent numVertices, const IdVecType& ids);
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
VTKM_CONT void CompleteAddingCells(vtkm::Id numPoints);
|
2015-07-28 23:33:52 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
/// Second method to add cells -- all at once.
|
|
|
|
/// Assigns the array handles to the explicit connectivity. This is
|
|
|
|
/// the way you can fill the memory from another system without copying
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-12-20 23:14:50 +00:00
|
|
|
void Fill(vtkm::Id numPoints,
|
2017-05-18 14:29:41 +00:00
|
|
|
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 =
|
2017-08-10 20:13:58 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>());
|
2015-08-02 21:59:44 +00:00
|
|
|
|
|
|
|
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
|
|
|
struct ExecutionTypes
|
|
|
|
{
|
|
|
|
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
|
|
|
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
|
|
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ConnectivityTypes = ConnectivityChooser<FromTopology, ToTopology>;
|
|
|
|
|
|
|
|
using ShapePortalType = typename ConnectivityTypes::ShapeArrayType::template ExecutionTypes<
|
|
|
|
DeviceAdapter>::PortalConst;
|
|
|
|
using IndicePortalType =
|
|
|
|
typename ConnectivityTypes::NumIndicesArrayType::template ExecutionTypes<
|
|
|
|
DeviceAdapter>::PortalConst;
|
|
|
|
using ConnectivityPortalType =
|
|
|
|
typename ConnectivityTypes::ConnectivityArrayType::template ExecutionTypes<
|
|
|
|
DeviceAdapter>::PortalConst;
|
|
|
|
using IndexOffsetPortalType =
|
|
|
|
typename ConnectivityTypes::IndexOffsetArrayType::template ExecutionTypes<
|
|
|
|
DeviceAdapter>::PortalConst;
|
|
|
|
|
|
|
|
using ExecObjectType = vtkm::exec::ConnectivityExplicit<ShapePortalType,
|
|
|
|
IndicePortalType,
|
|
|
|
ConnectivityPortalType,
|
|
|
|
IndexOffsetPortalType>;
|
2015-08-02 21:59:44 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Device, typename FromTopology, typename ToTopology>
|
2017-05-26 17:53:28 +00:00
|
|
|
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType
|
2017-08-10 20:13:58 +00:00
|
|
|
PrepareForInput(Device, FromTopology, ToTopology) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename FromTopology, typename ToTopology>
|
|
|
|
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
|
2017-08-10 20:13:58 +00:00
|
|
|
GetShapesArray(FromTopology, ToTopology) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename FromTopology, typename ToTopology>
|
|
|
|
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
|
2017-08-10 20:13:58 +00:00
|
|
|
GetNumIndicesArray(FromTopology, ToTopology) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename FromTopology, typename ToTopology>
|
|
|
|
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
|
2017-08-10 20:13:58 +00:00
|
|
|
GetConnectivityArray(FromTopology, ToTopology) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename FromTopology, typename ToTopology>
|
|
|
|
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
|
2017-08-10 20:13:58 +00:00
|
|
|
GetIndexOffsetArray(FromTopology, ToTopology) const;
|
2015-05-20 19:26:10 +00:00
|
|
|
|
2015-09-23 21:42:12 +00:00
|
|
|
protected:
|
2017-08-10 20:13:58 +00:00
|
|
|
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;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
|
|
|
|
vtkm::TopologyElementTagCell>::ConnectivityType PointToCell;
|
2015-08-11 18:42:34 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
|
|
|
|
vtkm::TopologyElementTagPoint>::ConnectivityType CellToPoint;
|
2015-08-11 18:42:34 +00:00
|
|
|
|
|
|
|
// These are used in the AddCell and related methods to incrementally add
|
2016-02-22 18:29:00 +00:00
|
|
|
// cells. They need to be protected as subclasses of CellSetExplicit
|
|
|
|
// need to set these values when implementing Fill()
|
2016-12-20 23:14:50 +00:00
|
|
|
vtkm::Id ConnectivityAdded;
|
|
|
|
vtkm::Id NumberOfCellsAdded;
|
2015-08-28 17:51:42 +00:00
|
|
|
vtkm::Id NumberOfPoints;
|
2017-08-10 20:13:58 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2015-04-15 16:43:12 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace detail
|
|
|
|
{
|
2015-08-11 18:42:34 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Storage1, typename Storage2, typename Storage3, typename Storage4>
|
2015-08-11 18:42:34 +00:00
|
|
|
struct CellSetExplicitConnectivityChooser<
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::CellSetExplicit<Storage1, Storage2, Storage3, Storage4>,
|
2017-05-26 17:53:28 +00:00
|
|
|
vtkm::TopologyElementTagPoint,
|
|
|
|
vtkm::TopologyElementTagCell>
|
2015-08-11 18:42:34 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ConnectivityType =
|
|
|
|
vtkm::cont::internal::ConnectivityExplicitInternals<Storage1, Storage2, Storage3, Storage4>;
|
2015-08-11 18:42:34 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CellSetType>
|
2017-05-26 17:53:28 +00:00
|
|
|
struct CellSetExplicitConnectivityChooser<CellSetType,
|
|
|
|
vtkm::TopologyElementTagCell,
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::TopologyElementTagPoint>
|
2016-11-29 19:17:02 +00:00
|
|
|
{
|
|
|
|
//only specify the shape type as it will be constant as everything
|
|
|
|
//is a vertex. otherwise use the defaults.
|
2017-08-16 15:34:21 +00:00
|
|
|
using ConnectivityType = vtkm::cont::internal::ConnectivityExplicitInternals<
|
|
|
|
typename ArrayHandleConstant<vtkm::UInt8>::StorageTag>;
|
2016-11-29 19:17:02 +00:00
|
|
|
};
|
|
|
|
|
2015-08-11 18:42:34 +00:00
|
|
|
} // namespace detail
|
2017-08-10 20:13:58 +00:00
|
|
|
|
2017-09-21 23:14:55 +00:00
|
|
|
/// \cond
|
|
|
|
/// Make doxygen ignore this section
|
2017-08-10 20:13:58 +00:00
|
|
|
#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
|
2017-09-21 23:14:55 +00:00
|
|
|
/// \endcond
|
2015-04-15 16:43:12 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
2017-08-10 20:13:58 +00:00
|
|
|
#include <vtkm/cont/CellSetExplicit.hxx>
|
|
|
|
|
2015-04-15 16:43:12 +00:00
|
|
|
#endif //vtk_m_cont_CellSetExplicit_h
|