2015-02-10 20:01:27 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-02-10 20:01:27 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_worklet_WorkletMapTopology_h
|
|
|
|
#define vtk_m_worklet_WorkletMapTopology_h
|
|
|
|
|
|
|
|
#include <vtkm/worklet/internal/WorkletBase.h>
|
|
|
|
|
2015-08-25 19:37:53 +00:00
|
|
|
#include <vtkm/TopologyElementTag.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
|
|
|
|
#include <vtkm/cont/arg/ControlSignatureTagBase.h>
|
2015-08-12 18:58:53 +00:00
|
|
|
#include <vtkm/cont/arg/TransportTagArrayInOut.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
#include <vtkm/cont/arg/TransportTagArrayOut.h>
|
2016-05-17 17:36:23 +00:00
|
|
|
#include <vtkm/cont/arg/TransportTagCellSetIn.h>
|
2016-12-19 22:41:00 +00:00
|
|
|
#include <vtkm/cont/arg/TransportTagTopologyFieldIn.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
#include <vtkm/cont/arg/TypeCheckTagArray.h>
|
2016-05-17 17:36:23 +00:00
|
|
|
#include <vtkm/cont/arg/TypeCheckTagCellSet.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
|
2015-08-03 16:06:59 +00:00
|
|
|
#include <vtkm/exec/arg/CellShape.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
#include <vtkm/exec/arg/FetchTagArrayDirectIn.h>
|
2015-08-12 18:58:53 +00:00
|
|
|
#include <vtkm/exec/arg/FetchTagArrayDirectInOut.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
#include <vtkm/exec/arg/FetchTagArrayDirectOut.h>
|
|
|
|
#include <vtkm/exec/arg/FetchTagArrayTopologyMapIn.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/exec/arg/FetchTagCellSetIn.h>
|
2019-07-30 16:53:51 +00:00
|
|
|
#include <vtkm/exec/arg/IncidentElementCount.h>
|
|
|
|
#include <vtkm/exec/arg/IncidentElementIndices.h>
|
2015-10-07 18:14:00 +00:00
|
|
|
#include <vtkm/exec/arg/ThreadIndicesTopologyMap.h>
|
2015-02-10 20:01:27 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
2015-02-10 20:01:27 +00:00
|
|
|
|
2018-08-29 13:30:27 +00:00
|
|
|
template <typename WorkletType>
|
|
|
|
class DispatcherMapTopology;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace detail
|
|
|
|
{
|
2016-12-19 22:41:00 +00:00
|
|
|
|
|
|
|
struct WorkletMapTopologyBase : vtkm::worklet::internal::WorkletBase
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2018-08-29 13:30:27 +00:00
|
|
|
template <typename Worklet>
|
|
|
|
using Dispatcher = vtkm::worklet::DispatcherMapTopology<Worklet>;
|
2017-05-18 14:29:41 +00:00
|
|
|
};
|
2016-12-19 22:41:00 +00:00
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
/// @brief Base class for worklets that map topology elements onto each other.
|
2016-12-19 22:41:00 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
/// The template parameters for this class must be members of the
|
|
|
|
/// TopologyElementTag group. The VisitTopology indicates the elements of a
|
|
|
|
/// cellset that will be visited, and the IncidentTopology will be mapped onto
|
|
|
|
/// the VisitTopology.
|
|
|
|
///
|
|
|
|
/// For instance,
|
|
|
|
/// `WorkletMapTopology<TopologyElementTagPoint, TopologyElementCell>` will
|
|
|
|
/// execute one instance per point, and provides convenience methods for
|
|
|
|
/// gathering information about the cells incident to the current point.
|
|
|
|
///
|
|
|
|
template <typename VisitTopology, typename IncidentTopology>
|
2016-12-19 22:41:00 +00:00
|
|
|
class WorkletMapTopology : public detail::WorkletMapTopologyBase
|
2015-02-10 20:01:27 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-07-30 16:53:51 +00:00
|
|
|
using VisitTopologyType = VisitTopology;
|
|
|
|
using IncidentTopologyType = IncidentTopology;
|
2016-12-19 22:41:00 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
/// \brief A control signature tag for input fields from the \em visited
|
|
|
|
/// topology.
|
2015-02-10 20:01:27 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
struct FieldInVisit : vtkm::cont::arg::ControlSignatureTagBase
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2018-10-18 00:02:38 +00:00
|
|
|
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
|
2019-07-30 16:53:51 +00:00
|
|
|
using TransportTag = vtkm::cont::arg::TransportTagTopologyFieldIn<VisitTopologyType>;
|
2016-12-19 22:41:00 +00:00
|
|
|
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectIn;
|
2015-02-10 20:01:27 +00:00
|
|
|
};
|
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
/// \brief A control signature tag for input fields from the \em incident
|
|
|
|
/// topology.
|
2015-02-10 20:01:27 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
struct FieldInIncident : vtkm::cont::arg::ControlSignatureTagBase
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2018-10-18 00:02:38 +00:00
|
|
|
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
|
2019-07-30 16:53:51 +00:00
|
|
|
using TransportTag = vtkm::cont::arg::TransportTagTopologyFieldIn<IncidentTopologyType>;
|
2016-12-19 22:41:00 +00:00
|
|
|
using FetchTag = vtkm::exec::arg::FetchTagArrayTopologyMapIn;
|
2015-02-10 20:01:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief A control signature tag for output fields.
|
|
|
|
///
|
|
|
|
/// This tag takes a template argument that is a type list tag that limits
|
|
|
|
/// the possible value types in the array.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct FieldOut : vtkm::cont::arg::ControlSignatureTagBase
|
|
|
|
{
|
2018-10-18 00:02:38 +00:00
|
|
|
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
|
2016-12-19 22:41:00 +00:00
|
|
|
using TransportTag = vtkm::cont::arg::TransportTagArrayOut;
|
|
|
|
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectOut;
|
2015-02-10 20:01:27 +00:00
|
|
|
};
|
2015-08-03 16:06:59 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
/// \brief A control signature tag for input-output (in-place) fields from
|
|
|
|
/// the visited topology.
|
2015-08-12 18:58:53 +00:00
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct FieldInOut : vtkm::cont::arg::ControlSignatureTagBase
|
|
|
|
{
|
2018-10-18 00:02:38 +00:00
|
|
|
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagArray;
|
2016-12-19 22:41:00 +00:00
|
|
|
using TransportTag = vtkm::cont::arg::TransportTagArrayInOut;
|
|
|
|
using FetchTag = vtkm::exec::arg::FetchTagArrayDirectInOut;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief A control signature tag for input connectivity.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct CellSetIn : vtkm::cont::arg::ControlSignatureTagBase
|
|
|
|
{
|
2016-12-19 22:41:00 +00:00
|
|
|
using TypeCheckTag = vtkm::cont::arg::TypeCheckTagCellSet;
|
2019-07-30 16:53:51 +00:00
|
|
|
using TransportTag =
|
|
|
|
vtkm::cont::arg::TransportTagCellSetIn<VisitTopologyType, IncidentTopologyType>;
|
2016-12-19 22:41:00 +00:00
|
|
|
using FetchTag = vtkm::exec::arg::FetchTagCellSetIn;
|
2015-08-12 18:58:53 +00:00
|
|
|
};
|
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
/// \brief An execution signature tag for getting the cell shape. This only
|
|
|
|
/// makes sense when visiting cell topologies.
|
2015-08-03 16:06:59 +00:00
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct CellShape : vtkm::exec::arg::CellShape
|
|
|
|
{
|
|
|
|
};
|
2015-08-03 16:06:59 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
/// \brief An execution signature tag to get the number of \em incident
|
|
|
|
/// elements.
|
2015-08-03 16:06:59 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
/// In a topology map, there are \em visited and \em incident topology
|
|
|
|
/// elements specified. The scheduling occurs on the \em visited elements,
|
|
|
|
/// and for each \em visited element there is some number of incident \em
|
|
|
|
/// mapped elements that are accessible. This \c ExecutionSignature tag
|
|
|
|
/// provides the number of these \em mapped elements that are accessible.
|
2015-08-03 16:06:59 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
struct IncidentElementCount : vtkm::exec::arg::IncidentElementCount
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
};
|
2015-08-03 16:06:59 +00:00
|
|
|
|
|
|
|
/// \brief An execution signature tag to get the indices of from elements.
|
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
/// In a topology map, there are \em visited and \em incident topology
|
|
|
|
/// elements specified. The scheduling occurs on the \em visited elements,
|
|
|
|
/// and for each \em visited element there is some number of incident \em
|
|
|
|
/// mapped elements that are accessible. This \c ExecutionSignature tag
|
|
|
|
/// provides the indices of the \em mapped elements that are incident to the
|
|
|
|
/// current \em visited element.
|
2015-08-03 16:06:59 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
struct IncidentElementIndices : vtkm::exec::arg::IncidentElementIndices
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
};
|
2015-10-07 18:14:00 +00:00
|
|
|
|
|
|
|
/// Topology map worklets use topology map indices.
|
|
|
|
///
|
2016-06-29 15:56:24 +00:00
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2019-01-21 02:14:55 +00:00
|
|
|
template <typename OutToInArrayType,
|
2017-05-26 17:53:28 +00:00
|
|
|
typename VisitArrayType,
|
2019-01-21 02:14:55 +00:00
|
|
|
typename ThreadToOutArrayType,
|
|
|
|
typename InputDomainType>
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_EXEC vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType> GetThreadIndices(
|
2019-01-21 02:14:55 +00:00
|
|
|
vtkm::Id threadIndex,
|
2017-05-26 17:53:28 +00:00
|
|
|
const OutToInArrayType& outToIn,
|
|
|
|
const VisitArrayType& visit,
|
2019-01-21 02:14:55 +00:00
|
|
|
const ThreadToOutArrayType& threadToOut,
|
2017-05-26 17:53:28 +00:00
|
|
|
const InputDomainType& connectivity,
|
2019-01-21 02:14:55 +00:00
|
|
|
vtkm::Id globalThreadIndexOffset) const
|
2015-10-07 18:14:00 +00:00
|
|
|
{
|
2019-01-21 02:14:55 +00:00
|
|
|
const vtkm::Id outIndex = threadToOut.Get(threadIndex);
|
|
|
|
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(threadIndex,
|
|
|
|
outToIn.Get(outIndex),
|
|
|
|
visit.Get(outIndex),
|
|
|
|
outIndex,
|
|
|
|
connectivity,
|
|
|
|
globalThreadIndexOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename OutToInArrayType,
|
|
|
|
typename VisitArrayType,
|
|
|
|
typename ThreadToOutArrayType,
|
|
|
|
typename InputDomainType>
|
|
|
|
VTKM_EXEC vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType> GetThreadIndices(
|
|
|
|
const vtkm::Id3& threadIndex,
|
|
|
|
const OutToInArrayType& vtkmNotUsed(outToIn),
|
|
|
|
const VisitArrayType& vtkmNotUsed(visit),
|
|
|
|
const ThreadToOutArrayType& vtkmNotUsed(threadToOut),
|
|
|
|
const InputDomainType& connectivity,
|
|
|
|
vtkm::Id globalThreadIndexOffset = 0) const
|
|
|
|
{
|
|
|
|
using ScatterCheck = std::is_same<ScatterType, vtkm::worklet::ScatterIdentity>;
|
|
|
|
VTKM_STATIC_ASSERT_MSG(ScatterCheck::value,
|
|
|
|
"Scheduling on 3D topologies only works with default ScatterIdentity.");
|
|
|
|
using MaskCheck = std::is_same<MaskType, vtkm::worklet::MaskNone>;
|
|
|
|
VTKM_STATIC_ASSERT_MSG(MaskCheck::value,
|
|
|
|
"Scheduling on 3D topologies only works with default MaskNone.");
|
|
|
|
|
2016-04-19 20:47:37 +00:00
|
|
|
return vtkm::exec::arg::ThreadIndicesTopologyMap<InputDomainType>(
|
2019-01-21 02:14:55 +00:00
|
|
|
threadIndex, connectivity, globalThreadIndexOffset);
|
2015-10-07 18:14:00 +00:00
|
|
|
}
|
2015-02-10 20:01:27 +00:00
|
|
|
};
|
|
|
|
|
2015-10-23 13:49:44 +00:00
|
|
|
/// Base class for worklets that map from Points to Cells.
|
2015-10-07 18:14:00 +00:00
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
class WorkletVisitCellsWithPoints
|
|
|
|
: public WorkletMapTopology<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
|
2015-10-22 00:07:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-07-30 16:53:51 +00:00
|
|
|
using FieldInPoint = FieldInIncident;
|
2015-10-23 13:49:44 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
using FieldInCell = FieldInVisit;
|
2015-10-23 13:49:44 +00:00
|
|
|
|
2018-10-18 00:02:38 +00:00
|
|
|
using FieldOutCell = FieldOut;
|
2015-10-23 13:49:44 +00:00
|
|
|
|
2018-10-18 00:02:38 +00:00
|
|
|
using FieldInOutCell = FieldInOut;
|
2015-11-07 11:57:16 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
using PointCount = IncidentElementCount;
|
2016-01-07 22:26:29 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
using PointIndices = IncidentElementIndices;
|
2015-10-22 00:07:20 +00:00
|
|
|
};
|
2015-08-27 18:36:55 +00:00
|
|
|
|
2016-01-20 23:16:58 +00:00
|
|
|
/// Base class for worklets that map from Cells to Points.
|
|
|
|
///
|
2019-07-30 16:53:51 +00:00
|
|
|
class WorkletVisitPointsWithCells
|
|
|
|
: public WorkletMapTopology<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
|
2016-01-20 23:16:58 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-07-30 16:53:51 +00:00
|
|
|
using FieldInCell = FieldInIncident;
|
2016-01-20 23:16:58 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
using FieldInPoint = FieldInVisit;
|
2016-01-20 23:16:58 +00:00
|
|
|
|
2018-10-18 00:02:38 +00:00
|
|
|
using FieldOutPoint = FieldOut;
|
2016-01-20 23:16:58 +00:00
|
|
|
|
2018-10-18 00:02:38 +00:00
|
|
|
using FieldInOutPoint = FieldInOut;
|
2016-01-20 23:16:58 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
using CellCount = IncidentElementCount;
|
2016-01-20 23:16:58 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
using CellIndices = IncidentElementIndices;
|
2016-01-20 23:16:58 +00:00
|
|
|
};
|
2019-07-30 16:53:51 +00:00
|
|
|
|
|
|
|
// Deprecated signatures for legacy support. These will be removed at some
|
|
|
|
// point.
|
2019-08-06 20:05:02 +00:00
|
|
|
using WorkletMapCellToPoint = WorkletVisitPointsWithCells;
|
2019-07-30 16:53:51 +00:00
|
|
|
using WorkletMapPointToCell = WorkletVisitCellsWithPoints;
|
2015-02-10 20:01:27 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::worklet
|
|
|
|
|
|
|
|
#endif //vtk_m_worklet_WorkletMapTopology_h
|