mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Change TopologyType identifiers from enumeration to tags.
Previously, the items used to identify parts of topology like points, cells, faces, etc. were in an enumeration. However, they are only really used in template specialization, and it is easier to use tags in this case. So, change the enumeration to a set of tag structures. Also made the following changes: * Renamed TopologyType to TopologyElement, which is more indicative of what we are referring to. * Moved the structures from the vtkm::cont namespace to the vtkm namespace. There is no reason not to be able to use them from either the control or execution environments. * Added a VTKM_IS_TOPOLOGY_ELEMENT_TAG macro to do type checks on template arguments that are supposed to be topology element tags.
This commit is contained in:
parent
91ce7b12c1
commit
d6b8c8f510
@ -29,6 +29,7 @@ set(headers
|
||||
Pair.h
|
||||
RegularConnectivity.h
|
||||
RegularStructure.h
|
||||
TopologyElementTag.h
|
||||
TypeListTag.h
|
||||
Types.h
|
||||
TypeTraits.h
|
||||
|
@ -22,9 +22,9 @@
|
||||
#ifndef vtk_m_RegularConnectivity_h
|
||||
#define vtk_m_RegularConnectivity_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/RegularStructure.h>
|
||||
#include <vtkm/cont/TopologyType.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
|
||||
VTKM_BOOST_PRE_INCLUDE
|
||||
@ -33,37 +33,38 @@ VTKM_BOOST_POST_INCLUDE
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To, vtkm::IdComponent Dimension>
|
||||
template<vtkm::IdComponent Dimension>
|
||||
struct SchedulingDimension
|
||||
{
|
||||
typedef vtkm::Id ValueType;
|
||||
};
|
||||
|
||||
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To>
|
||||
struct SchedulingDimension<From,To, 2>
|
||||
template<>
|
||||
struct SchedulingDimension<2>
|
||||
{
|
||||
typedef vtkm::Id2 ValueType;
|
||||
};
|
||||
|
||||
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To>
|
||||
struct SchedulingDimension<From,To, 3>
|
||||
template<>
|
||||
struct SchedulingDimension<3>
|
||||
{
|
||||
typedef vtkm::Id3 ValueType;
|
||||
};
|
||||
|
||||
template<vtkm::cont::TopologyType From, vtkm::cont::TopologyType To, vtkm::IdComponent Dimension>
|
||||
template<typename From, typename To, vtkm::IdComponent Dimension>
|
||||
struct IndexLookupHelper
|
||||
{
|
||||
// We want an unconditional failure if this unspecialized class ever gets
|
||||
// instantiated, because it means someone missed a topology mapping type.
|
||||
// We need to create a test which depends on the templated types so
|
||||
// it doesn't get picked up without a concrete instantiation.
|
||||
BOOST_STATIC_ASSERT_MSG(From != To && From == To,
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(To) == static_cast<size_t>(-1),
|
||||
"Missing Specialization for Topologies");
|
||||
};
|
||||
|
||||
template<vtkm::IdComponent Dimension>
|
||||
struct IndexLookupHelper<vtkm::cont::NODE,vtkm::cont::CELL,Dimension>
|
||||
struct IndexLookupHelper<
|
||||
vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, Dimension>
|
||||
{
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
@ -75,7 +76,8 @@ struct IndexLookupHelper<vtkm::cont::NODE,vtkm::cont::CELL,Dimension>
|
||||
};
|
||||
|
||||
template<vtkm::IdComponent Dimension>
|
||||
struct IndexLookupHelper<vtkm::cont::CELL,vtkm::cont::NODE,Dimension>
|
||||
struct IndexLookupHelper<
|
||||
vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, Dimension>
|
||||
{
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
@ -86,14 +88,16 @@ struct IndexLookupHelper<vtkm::cont::CELL,vtkm::cont::NODE,Dimension>
|
||||
}
|
||||
};
|
||||
|
||||
template<vtkm::cont::TopologyType FromTopology, vtkm::cont::TopologyType ToTopoogy,
|
||||
template<typename FromTopology,
|
||||
typename ToTopology,
|
||||
vtkm::IdComponent Dimension>
|
||||
class RegularConnectivity
|
||||
{
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||
|
||||
public:
|
||||
typedef typename SchedulingDimension< FromTopology,
|
||||
ToTopoogy,
|
||||
Dimension >::ValueType SchedulingDimension;
|
||||
typedef typename SchedulingDimension<Dimension>::ValueType SchedulingDimension;
|
||||
RegularConnectivity():
|
||||
rs()
|
||||
{
|
||||
@ -124,14 +128,14 @@ public:
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
{
|
||||
IndexLookupHelper<FromTopology,ToTopoogy,Dimension>::GetIndices(rs,index,ids);
|
||||
IndexLookupHelper<FromTopology,ToTopology,Dimension>::GetIndices(rs,index,ids);
|
||||
}
|
||||
|
||||
template <typename DeviceAdapterTag>
|
||||
struct ExecutionTypes
|
||||
{ //Using this style so we can template the RegularConnecivity based on the
|
||||
//backend in the future without have to change the Transport logic
|
||||
typedef vtkm::RegularConnectivity<FromTopology,ToTopoogy,Dimension> ExecObjectType;
|
||||
typedef vtkm::RegularConnectivity<FromTopology,ToTopology,Dimension> ExecObjectType;
|
||||
};
|
||||
|
||||
template<typename DeviceAdapterTag>
|
||||
|
109
vtkm/TopologyElementTag.h
Normal file
109
vtkm/TopologyElementTag.h
Normal file
@ -0,0 +1,109 @@
|
||||
//============================================================================
|
||||
// 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 2015 Sandia Corporation.
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 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.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_TopologyElementTag_h
|
||||
#define vtk_m_TopologyElementTag_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
VTKM_BOOST_PRE_INCLUDE
|
||||
#include <boost/mpl/assert.hpp>
|
||||
VTKM_BOOST_POST_INCLUDE
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
/// \brief A tag used to identify the cell elements in a topology.
|
||||
///
|
||||
/// A topology element refers to some type of substructure of a topology. For
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagCell { };
|
||||
|
||||
/// \brief A tag used to identify the point elements in a topology.
|
||||
///
|
||||
/// A topology element refers to some type of substructure of a topology. For
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagPoint { };
|
||||
|
||||
/// \brief A tag used to identify the edge elements in a topology.
|
||||
///
|
||||
/// A topology element refers to some type of substructure of a topology. For
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagEdge { };
|
||||
|
||||
/// \brief A tag used to identify the face elements in a topology.
|
||||
///
|
||||
/// A topology element refers to some type of substructure of a topology. For
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagFace { };
|
||||
|
||||
|
||||
namespace internal {
|
||||
|
||||
/// Checks to see if the given object is a topology element tag. This check is
|
||||
/// compatible with the Boost meta-template programing library (MPL). It
|
||||
/// contains a typedef named \c type that is either boost::mpl::true_ or
|
||||
/// boost::mpl::false_. Both of these have a typedef named value with the
|
||||
/// respective boolean value.
|
||||
///
|
||||
template<typename T>
|
||||
struct TopologyElementTagCheck
|
||||
{
|
||||
typedef boost::mpl::false_ type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct TopologyElementTagCheck<vtkm::TopologyElementTagCell>
|
||||
{
|
||||
typedef boost::mpl::true_ type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct TopologyElementTagCheck<vtkm::TopologyElementTagPoint>
|
||||
{
|
||||
typedef boost::mpl::true_ type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct TopologyElementTagCheck<vtkm::TopologyElementTagEdge>
|
||||
{
|
||||
typedef boost::mpl::true_ type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct TopologyElementTagCheck<vtkm::TopologyElementTagFace>
|
||||
{
|
||||
typedef boost::mpl::true_ type;
|
||||
};
|
||||
|
||||
#define VTKM_IS_TOPOLOGY_ELEMENT_TAG(type) \
|
||||
BOOST_MPL_ASSERT(( ::vtkm::internal::TopologyElementTagCheck<type> ))
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_TopologyElementTag_h
|
@ -64,7 +64,6 @@ set(headers
|
||||
StorageImplicit.h
|
||||
StorageListTag.h
|
||||
Timer.h
|
||||
TopologyType.h
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -20,9 +20,9 @@
|
||||
#ifndef vtk_m_cont_CellSetExplicit_h
|
||||
#define vtk_m_cont_CellSetExplicit_h
|
||||
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/ExplicitConnectivity.h>
|
||||
#include <vtkm/cont/TopologyType.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
@ -56,8 +56,10 @@ public:
|
||||
return this->NodesOfCellsConnectivity.GetNumberOfElements();
|
||||
}
|
||||
|
||||
template<vtkm::cont::TopologyType FromTopology, vtkm::cont::TopologyType ToTopoogy>
|
||||
template<typename FromTopology, typename ToTopology>
|
||||
struct ConnectivityType {
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||
// This type is really only valid for Point to Cell connectivity. When
|
||||
// other connectivity types are supported, these will need to be added.
|
||||
typedef ExplicitConnectivityType Type;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/RegularConnectivity.h>
|
||||
#include <vtkm/RegularStructure.h>
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
@ -47,28 +48,31 @@ public:
|
||||
return this->Structure.GetNumberOfCells();
|
||||
}
|
||||
|
||||
template<vtkm::cont::TopologyType FromTopology,
|
||||
vtkm::cont::TopologyType ToTopology>
|
||||
template<typename FromTopology, typename ToTopology>
|
||||
struct ConnectivityType {
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||
typedef vtkm::RegularConnectivity<FromTopology,ToTopology,Dimension> Type;
|
||||
};
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE,vtkm::cont::CELL,Dimension>
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell,Dimension>
|
||||
GetNodeToCellConnectivity() const
|
||||
{
|
||||
typedef vtkm::RegularConnectivity<vtkm::cont::NODE,
|
||||
vtkm::cont::CELL,
|
||||
typedef vtkm::RegularConnectivity<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension> NodeToCellConnectivity;
|
||||
return NodeToCellConnectivity(this->Structure);
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::RegularConnectivity<vtkm::cont::CELL,vtkm::cont::NODE,Dimension>
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint,Dimension>
|
||||
GetCellToNodeConnectivity() const
|
||||
{
|
||||
typedef vtkm::RegularConnectivity<vtkm::cont::CELL,
|
||||
vtkm::cont::NODE,
|
||||
typedef vtkm::RegularConnectivity<vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
Dimension> CellToNodeConnectivity;
|
||||
return CellToNodeConnectivity(this->Structure);
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
//============================================================================
|
||||
// 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 2015 Sandia Corporation.
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 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.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_TopologyType_h
|
||||
#define vtk_m_cont_TopologyType_h
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
enum TopologyType
|
||||
{
|
||||
NODE,
|
||||
CELL,
|
||||
EDGE,
|
||||
FACE
|
||||
};
|
||||
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_cont_TopologyType_h
|
@ -20,10 +20,10 @@
|
||||
#ifndef vtk_m_cont_arg_TransportTagTopologyIn_h
|
||||
#define vtk_m_cont_arg_TransportTagTopologyIn_h
|
||||
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/TopologyType.h>
|
||||
|
||||
#include <vtkm/cont/arg/Transport.h>
|
||||
|
||||
@ -44,7 +44,8 @@ struct Transport<vtkm::cont::arg::TransportTagTopologyIn, ContObjectType, Device
|
||||
VTKM_IS_CELL_SET(ContObjectType);
|
||||
|
||||
typedef typename ContObjectType
|
||||
::template ConnectivityType<vtkm::cont::NODE,vtkm::cont::CELL>::Type
|
||||
::template ConnectivityType<
|
||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::Type
|
||||
::template ExecutionTypes<Device>
|
||||
::ExecObjectType ExecObjectType;
|
||||
|
||||
|
@ -18,14 +18,14 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/CellType.h>
|
||||
#include <vtkm/RegularConnectivity.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
|
||||
static void TwoDimRegularTest();
|
||||
static void ThreeDimRegularTest();
|
||||
|
||||
@ -67,10 +67,14 @@ TwoDimRegularTest()
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_PIXEL, "Incorrect element type.");
|
||||
}
|
||||
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE, vtkm::cont::CELL,2> nodeToCell =
|
||||
cellSet.GetNodeToCellConnectivity();
|
||||
vtkm::RegularConnectivity<vtkm::cont::CELL, vtkm::cont::NODE,2> cellToNode =
|
||||
cellSet.GetCellToNodeConnectivity();
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
2> nodeToCell = cellSet.GetNodeToCellConnectivity();
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
2> cellToNode = cellSet.GetCellToNodeConnectivity();
|
||||
|
||||
vtkm::Id cells[2][4] = {{0,1,3,4}, {1,2,4,5}};
|
||||
vtkm::Vec<vtkm::Id,4> nodeIds;
|
||||
@ -135,8 +139,10 @@ ThreeDimRegularTest()
|
||||
}
|
||||
|
||||
//Test regular connectivity.
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE, vtkm::cont::CELL,3> nodeToCell =
|
||||
cellSet.GetNodeToCellConnectivity();
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
3> nodeToCell = cellSet.GetNodeToCellConnectivity();
|
||||
vtkm::Id expectedPointIds[8] = {0,1,3,4,6,7,9,10};
|
||||
vtkm::Vec<vtkm::Id,8> retrievedPointIds;
|
||||
nodeToCell.GetIndices(0, retrievedPointIds);
|
||||
@ -147,8 +153,10 @@ ThreeDimRegularTest()
|
||||
"Incorrect node ID for cell");
|
||||
}
|
||||
|
||||
vtkm::RegularConnectivity<vtkm::cont::CELL, vtkm::cont::NODE,3> cellToNode =
|
||||
cellSet.GetCellToNodeConnectivity();
|
||||
vtkm::RegularConnectivity<
|
||||
vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
3> cellToNode = cellSet.GetCellToNodeConnectivity();
|
||||
vtkm::Vec<vtkm::Id,8> expectedCellIds;
|
||||
vtkm::Id retrievedCellIds[8] = {0,-1,-1,-1,-1,-1,-1,-1};
|
||||
cellToNode.GetIndices(0, expectedCellIds);
|
||||
|
@ -114,11 +114,12 @@ public:
|
||||
}
|
||||
|
||||
template<typename Invocation,
|
||||
vtkm::cont::TopologyType From,
|
||||
vtkm::cont::TopologyType To,
|
||||
typename From,
|
||||
typename To,
|
||||
vtkm::IdComponent Domain>
|
||||
VTKM_CONT_EXPORT
|
||||
void InvokeBasedOnDomainType(const Invocation &invocation,
|
||||
void InvokeBasedOnDomainType(
|
||||
const Invocation &invocation,
|
||||
const vtkm::RegularConnectivity<From,To,Domain>& domain) const
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user