vtk-m/vtkm/exec/ConnectivityStructured.h

194 lines
6.7 KiB
C
Raw Permalink Normal View History

2015-05-15 16:03:52 +00:00
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
2015-05-15 16:03:52 +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_exec_ConnectivityStructured_h
#define vtk_m_exec_ConnectivityStructured_h
2015-04-15 14:45:39 +00:00
#include <vtkm/Deprecated.h>
#include <vtkm/TopologyElementTag.h>
#include <vtkm/Types.h>
#include <vtkm/internal/ConnectivityStructuredInternals.h>
2015-04-15 14:45:39 +00:00
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace exec
{
2015-05-15 20:22:00 +00:00
/// @brief A class holding information about topology connections.
///
/// An object of `ConnectivityStructured` is provided to a worklet when the
/// `ControlSignature` argument is `WholeCellSetIn` and the `vtkm::cont::CellSet`
/// provided is a `vtkm::cont::CellSetStructured`.
template <typename VisitTopology, typename IncidentTopology, vtkm::IdComponent Dimension>
class ConnectivityStructured
{
VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
using InternalsType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
2017-05-18 14:29:41 +00:00
using Helper =
vtkm::internal::ConnectivityStructuredIndexHelper<VisitTopology, IncidentTopology, Dimension>;
public:
using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
ConnectivityStructured() = default;
VTKM_EXEC_CONT
2017-05-18 14:29:41 +00:00
ConnectivityStructured(const InternalsType& src)
: Internals(src)
{
}
ConnectivityStructured(const ConnectivityStructured& src) = default;
VTKM_EXEC_CONT
ConnectivityStructured(
const ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>& src)
: Internals(src.Internals)
{
}
2019-11-28 15:43:27 +00:00
ConnectivityStructured& operator=(const ConnectivityStructured& src) = default;
ConnectivityStructured& operator=(ConnectivityStructured&& src) = default;
/// @brief Provides the number of elements in the topology.
///
/// This number of elements is associated with the "visit" type of topology element,
/// which is the first template argument to `WholeCellSetIn`. The number of elements
/// defines the valid indices for the other methods of this class.
VTKM_EXEC
vtkm::Id GetNumberOfElements() const { return Helper::GetNumberOfElements(this->Internals); }
/// @brief The tag representing the cell shape of the visited elements.
///
/// If the "visit" element is cells, then the returned tag is `vtkm::CellShapeTagHexahedron`
/// for a 3D structured grid, `vtkm::CellShapeTagQuad` for a 2D structured grid, or
/// `vtkm::CellShapeLine` for a 1D structured grid.
using CellShapeTag = typename Helper::CellShapeTag;
/// @brief Returns a tag for the cell shape associated with the element at the given index.
///
/// If the "visit" element is cells, then the returned tag is `vtkm::CellShapeTagHexahedron`
/// for a 3D structured grid, `vtkm::CellShapeTagQuad` for a 2D structured grid, or
/// `vtkm::CellShapeLine` for a 1D structured grid.
VTKM_EXEC
2017-05-18 14:29:41 +00:00
CellShapeTag GetCellShape(vtkm::Id) const { return CellShapeTag(); }
/// Given the index of a visited element, returns the number of incident elements
/// touching it.
template <typename IndexType>
VTKM_EXEC vtkm::IdComponent GetNumberOfIndices(const IndexType& index) const
{
return Helper::GetNumberOfIndices(this->Internals, index);
}
/// @brief Type of variable that lists of incident indices will be put into.
using IndicesType = typename Helper::IndicesType;
/// Provides the indices of all elements incident to the visit element of the provided
/// index.
2017-05-18 14:29:41 +00:00
template <typename IndexType>
VTKM_EXEC IndicesType GetIndices(const IndexType& index) const
2015-05-14 20:26:59 +00:00
{
return Helper::GetIndices(this->Internals, index);
2015-05-14 20:26:59 +00:00
}
2015-05-18 21:08:15 +00:00
/// Convenience method that converts a flat, 1D index to the visited elements to a `vtkm::Vec`
/// containing the logical indices in the grid.
VTKM_EXEC_CONT SchedulingRangeType FlatToLogicalVisitIndex(vtkm::Id flatVisitIndex) const
{
return Helper::FlatToLogicalVisitIndex(this->Internals, flatVisitIndex);
}
/// Convenience method that converts a flat, 1D index to the incident elements to a `vtkm::Vec`
/// containing the logical indices in the grid.
VTKM_EXEC_CONT SchedulingRangeType FlatToLogicalIncidentIndex(vtkm::Id flatIncidentIndex) const
{
return Helper::FlatToLogicalIncidentIndex(this->Internals, flatIncidentIndex);
}
/// Convenience method that converts logical indices in a `vtkm::Vec` of a visited element
/// to a flat, 1D index.
VTKM_EXEC_CONT vtkm::Id LogicalToFlatVisitIndex(
const SchedulingRangeType& logicalVisitIndex) const
{
return Helper::LogicalToFlatVisitIndex(this->Internals, logicalVisitIndex);
}
/// Convenience method that converts logical indices in a `vtkm::Vec` of an incident element
/// to a flat, 1D index.
VTKM_EXEC_CONT vtkm::Id LogicalToFlatIncidentIndex(
const SchedulingRangeType& logicalIncidentIndex) const
{
return Helper::LogicalToFlatIncidentIndex(this->Internals, logicalIncidentIndex);
}
VTKM_EXEC_CONT
VTKM_DEPRECATED(2.1, "Use FlatToLogicalIncidentIndex.")
2017-05-18 14:29:41 +00:00
SchedulingRangeType FlatToLogicalFromIndex(vtkm::Id flatFromIndex) const
{
return this->FlatToLogicalIncidentIndex(flatFromIndex);
}
VTKM_EXEC_CONT
VTKM_DEPRECATED(2.1, "Use LogicalToFlatIncidentIndex.")
2017-05-18 14:29:41 +00:00
vtkm::Id LogicalToFlatFromIndex(const SchedulingRangeType& logicalFromIndex) const
{
return this->LogicalToFlatIncidentIndex(logicalFromIndex);
}
VTKM_EXEC_CONT
VTKM_DEPRECATED(2.1, "Use FlatToLogicalVisitIndex.")
2017-05-18 14:29:41 +00:00
SchedulingRangeType FlatToLogicalToIndex(vtkm::Id flatToIndex) const
{
return this->FlatToLogicalVisitIndex(flatToIndex);
}
VTKM_EXEC_CONT
VTKM_DEPRECATED(2.1, "Use LogicalToFlatVisitIndex.")
2017-05-18 14:29:41 +00:00
vtkm::Id LogicalToFlatToIndex(const SchedulingRangeType& logicalToIndex) const
{
return this->LogicalToFlatVisitIndex(logicalToIndex);
}
/// Return the dimensions of the points in the cell set.
VTKM_EXEC_CONT
2017-05-18 14:29:41 +00:00
vtkm::Vec<vtkm::Id, Dimension> GetPointDimensions() const
2016-01-20 22:40:54 +00:00
{
return this->Internals.GetPointDimensions();
}
/// Return the dimensions of the points in the cell set.
2020-07-15 20:41:32 +00:00
VTKM_EXEC_CONT
vtkm::Vec<vtkm::Id, Dimension> GetCellDimensions() const
{
return this->Internals.GetCellDimensions();
}
VTKM_EXEC_CONT
SchedulingRangeType GetGlobalPointIndexStart() const
{
return this->Internals.GetGlobalPointIndexStart();
}
friend class ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>;
private:
InternalsType Internals;
2015-04-15 14:45:39 +00:00
};
}
} // namespace vtkm::exec
2015-04-15 14:45:39 +00:00
#endif //vtk_m_exec_ConnectivityStructured_h