DataSet now holds DynamicCellSet instead of smart_ptr<CellSet>
The Invoke of the topology dispatcher is also changed to expect a concrete cell set (which the DynamicCellSet is automatically cast to) rather than a connectivity structure. The dispatcher calls the GetNodeToCellConnectivity method for you. (That is currently the only one supported.)
This commit is contained in:
parent
6b68666d0c
commit
b8febd1c01
@ -69,8 +69,8 @@ struct IsValidArrayHandle {
|
||||
};
|
||||
|
||||
/// Checks to see if the given object is an array handle. This check is
|
||||
/// compatiable with the Boost meta-template programming library (MPL). It
|
||||
/// contains a typedef named type that is eitehr boost::mpl::true_ or
|
||||
/// compatible with the Boost meta-template programming 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.
|
||||
///
|
||||
@ -526,21 +526,21 @@ template<typename T, typename StorageT>
|
||||
VTKM_CONT_EXPORT
|
||||
void
|
||||
printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<T,StorageT> &array,
|
||||
std::ostream &out)
|
||||
std::ostream &out)
|
||||
{
|
||||
vtkm::Id sz = array.GetNumberOfValues();
|
||||
out<<"sz= "<<sz<<" [";
|
||||
if (sz <= 5)
|
||||
for (vtkm::Id i = 0 ; i < sz; i++)
|
||||
{
|
||||
out<<array.GetPortalConstControl().Get(i);
|
||||
if (i != (sz-1)) out<<" ";
|
||||
}
|
||||
for (vtkm::Id i = 0 ; i < sz; i++)
|
||||
{
|
||||
out<<array.GetPortalConstControl().Get(i);
|
||||
if (i != (sz-1)) out<<" ";
|
||||
}
|
||||
else
|
||||
{
|
||||
out<<array.GetPortalConstControl().Get(0)<<" "<<array.GetPortalConstControl().Get(1);
|
||||
out<<" ... ";
|
||||
out<<array.GetPortalConstControl().Get(sz-2)<<" "<<array.GetPortalConstControl().Get(sz-1);
|
||||
out<<array.GetPortalConstControl().Get(0)<<" "<<array.GetPortalConstControl().Get(1);
|
||||
out<<" ... ";
|
||||
out<<array.GetPortalConstControl().Get(sz-2)<<" "<<array.GetPortalConstControl().Get(sz-1);
|
||||
}
|
||||
out<<"]";
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
@ -72,6 +74,25 @@ protected:
|
||||
vtkm::cont::LogicalStructure LogicalStructure;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
/// Checks to see if the given object is a cell set. This check is compatible
|
||||
/// with the Boost meta-template programming 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 CellSetCheck
|
||||
{
|
||||
typedef typename boost::is_base_of<vtkm::cont::CellSet, T>::type type;
|
||||
};
|
||||
|
||||
#define VTKM_IS_CELL_SET(type) \
|
||||
BOOST_MPL_ASSERT(( ::vtkm::cont::internal::CellSetCheck<type> ))
|
||||
|
||||
} // namespace internal
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/ExplicitConnectivity.h>
|
||||
#include <vtkm/cont/TopologyType.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
@ -55,6 +56,18 @@ public:
|
||||
return this->NodesOfCellsConnectivity.GetNumberOfElements();
|
||||
}
|
||||
|
||||
template<vtkm::cont::TopologyType FromTopology, vtkm::cont::TopologyType ToTopoogy>
|
||||
struct ConnectivityType {
|
||||
// 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;
|
||||
};
|
||||
|
||||
const ExplicitConnectivityType &GetNodeToCellConnectivity() const
|
||||
{
|
||||
return this->NodesOfCellsConnectivity;
|
||||
}
|
||||
|
||||
ExplicitConnectivityType &GetNodeToCellConnectivity()
|
||||
{
|
||||
return this->NodesOfCellsConnectivity;
|
||||
|
@ -33,7 +33,7 @@ template<vtkm::IdComponent DIMENSION>
|
||||
class CellSetStructured : public CellSet
|
||||
{
|
||||
public:
|
||||
static const int Dimension=DIMENSION;
|
||||
static const vtkm::IdComponent Dimension=DIMENSION;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
CellSetStructured(const std::string &name = "")
|
||||
@ -47,6 +47,12 @@ public:
|
||||
return this->Structure.GetNumberOfCells();
|
||||
}
|
||||
|
||||
template<vtkm::cont::TopologyType FromTopology,
|
||||
vtkm::cont::TopologyType ToTopology>
|
||||
struct ConnectivityType {
|
||||
typedef vtkm::RegularConnectivity<FromTopology,ToTopology,Dimension> Type;
|
||||
};
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE,vtkm::cont::CELL,Dimension>
|
||||
GetNodeToCellConnectivity() const
|
||||
|
@ -24,17 +24,13 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/DynamicCellSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/ExplicitConnectivity.h>
|
||||
#include <vtkm/RegularConnectivity.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
@ -74,7 +70,7 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
boost::shared_ptr<vtkm::cont::CellSet> GetCellSet(vtkm::Id index=0) const
|
||||
vtkm::cont::DynamicCellSet GetCellSet(vtkm::Id index=0) const
|
||||
{
|
||||
VTKM_ASSERT_CONT((index >= 0) &&
|
||||
(index <= static_cast<vtkm::Id>(this->CellSets.size())));
|
||||
@ -88,9 +84,17 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void AddCellSet(boost::shared_ptr<vtkm::cont::CellSet> cs)
|
||||
void AddCellSet(vtkm::cont::DynamicCellSet cellSet)
|
||||
{
|
||||
this->CellSets.push_back(cs);
|
||||
this->CellSets.push_back(cellSet);
|
||||
}
|
||||
|
||||
template<typename CellSetType>
|
||||
VTKM_CONT_EXPORT
|
||||
void AddCellSet(const CellSetType &cellSet)
|
||||
{
|
||||
VTKM_IS_CELL_SET(CellSetType);
|
||||
this->CellSets.push_back(vtkm::cont::DynamicCellSet(cellSet));
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -118,7 +122,7 @@ public:
|
||||
out<<" CellSets["<<this->GetNumberOfCellSets()<<"]\n";
|
||||
for (vtkm::Id i = 0; i < this->GetNumberOfCellSets(); i++)
|
||||
{
|
||||
this->GetCellSet(i)->PrintSummary(out);
|
||||
this->GetCellSet(i).GetCellSet().PrintSummary(out);
|
||||
}
|
||||
|
||||
out<<" Fields["<<this->GetNumberOfFields()<<"]\n";
|
||||
@ -131,7 +135,7 @@ public:
|
||||
private:
|
||||
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
||||
std::vector<vtkm::cont::Field> Fields;
|
||||
std::vector< boost::shared_ptr<vtkm::cont::CellSet> > CellSets;
|
||||
std::vector<vtkm::cont::DynamicCellSet> CellSets;
|
||||
};
|
||||
|
||||
} // namespace cont
|
||||
|
@ -100,8 +100,7 @@ public:
|
||||
new vtkm::cont::internal::SimplePolymorphicContainer<CellSetType>(
|
||||
cellSet))
|
||||
{
|
||||
// TODO: Would be good to check that CellSetType is really a subclass of
|
||||
// CellSet.
|
||||
VTKM_IS_CELL_SET(CellSetType);
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
|
@ -22,7 +22,8 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
#include <vtkm/cont/TopologyType.h>
|
||||
|
||||
#include <vtkm/cont/arg/Transport.h>
|
||||
|
||||
@ -40,15 +41,18 @@ struct TransportTagTopologyIn { };
|
||||
template<typename ContObjectType, typename Device>
|
||||
struct Transport<vtkm::cont::arg::TransportTagTopologyIn, ContObjectType, Device>
|
||||
{
|
||||
///\todo: something like VTKM_IS_ARRAY_HANDLE(ContObjectType), but for topology
|
||||
typedef typename ContObjectType::template ExecutionTypes<Device>::ExecObjectType
|
||||
ExecObjectType;
|
||||
VTKM_IS_CELL_SET(ContObjectType);
|
||||
|
||||
typedef typename ContObjectType
|
||||
::template ConnectivityType<vtkm::cont::NODE,vtkm::cont::CELL>::Type
|
||||
::template ExecutionTypes<Device>
|
||||
::ExecObjectType ExecObjectType;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
ExecObjectType operator()(const ContObjectType &object, vtkm::Id) const
|
||||
{
|
||||
//create CUDA version of connectivity array.
|
||||
return object.PrepareForInput(Device());
|
||||
return object.GetNodeToCellConnectivity().PrepareForInput(Device());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -22,9 +22,7 @@
|
||||
|
||||
#include <vtkm/cont/arg/TypeCheck.h>
|
||||
|
||||
#include <vtkm/ListTag.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
@ -36,10 +34,11 @@ struct TypeCheckTagTopology
|
||||
{
|
||||
};
|
||||
|
||||
template<typename ArrayType>
|
||||
struct TypeCheck<TypeCheckTagTopology, ArrayType>
|
||||
template<typename CellSetType>
|
||||
struct TypeCheck<TypeCheckTagTopology, CellSetType>
|
||||
{
|
||||
static const bool value = true;
|
||||
static const bool value =
|
||||
vtkm::cont::internal::CellSetCheck<CellSetType>::type::value;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -66,11 +66,10 @@ MakeTestDataSet::Make2DRegularDataSet0()
|
||||
vtkm::Float32 cellvar[2] = {100.1f, 200.1f};
|
||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
||||
|
||||
boost::shared_ptr< vtkm::cont::CellSetStructured<2> > cs(
|
||||
new vtkm::cont::CellSetStructured<2>("cells"));
|
||||
vtkm::cont::CellSetStructured<2> cellSet("cells");
|
||||
//Set regular structure
|
||||
cs->Structure.SetNodeDimension( vtkm::make_Vec(3,2) );
|
||||
ds.AddCellSet(cs);
|
||||
cellSet.Structure.SetNodeDimension( vtkm::make_Vec(3,2) );
|
||||
ds.AddCellSet(cellSet);
|
||||
|
||||
return ds;
|
||||
}
|
||||
@ -101,12 +100,9 @@ MakeTestDataSet::Make3DRegularDataSet0()
|
||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 4));
|
||||
|
||||
static const vtkm::IdComponent dim = 3;
|
||||
boost::shared_ptr< vtkm::cont::CellSetStructured<dim> > cs(
|
||||
new vtkm::cont::CellSetStructured<dim>("cells"));
|
||||
ds.AddCellSet(cs);
|
||||
|
||||
//Set regular structure
|
||||
cs->Structure.SetNodeDimension( vtkm::make_Vec(3,2,3) );
|
||||
vtkm::cont::CellSetStructured<dim> cellSet("cells");
|
||||
cellSet.Structure.SetNodeDimension( vtkm::make_Vec(3,2,3) );
|
||||
ds.AddCellSet(cellSet);
|
||||
|
||||
return ds;
|
||||
}
|
||||
@ -154,12 +150,10 @@ MakeTestDataSet::Make3DExplicitDataSet0()
|
||||
conn.push_back(3);
|
||||
conn.push_back(4);
|
||||
|
||||
boost::shared_ptr< vtkm::cont::CellSetExplicit<> > cs(
|
||||
new vtkm::cont::CellSetExplicit<>("cells", 2));
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs->NodesOfCellsConnectivity;
|
||||
vtkm::cont::CellSetExplicit<> cs("cells", 2);
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs.NodesOfCellsConnectivity;
|
||||
ec.FillViaCopy(shapes, numindices, conn);
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
ds.AddCellSet(cs);
|
||||
|
||||
return ds;
|
||||
@ -188,9 +182,8 @@ MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
||||
ds.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2));
|
||||
|
||||
boost::shared_ptr< vtkm::cont::CellSetExplicit<> > cs(
|
||||
new vtkm::cont::CellSetExplicit<>("cells", 2));
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs->NodesOfCellsConnectivity;
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cellSet.NodesOfCellsConnectivity;
|
||||
|
||||
ec.PrepareToAddCells(2, 7);
|
||||
ec.AddCell(vtkm::VTKM_TRIANGLE, 3, make_Vec<vtkm::Id>(0,1,2));
|
||||
@ -198,7 +191,7 @@ MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
ec.CompleteAddingCells();
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
ds.AddCellSet(cs);
|
||||
ds.AddCellSet(cellSet);
|
||||
|
||||
return ds;
|
||||
}
|
||||
@ -231,9 +224,8 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds)
|
||||
ds.AddField(Field("z", 1, vtkm::cont::Field::ASSOC_POINTS, zVals, nVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
boost::shared_ptr< vtkm::cont::CellSetExplicit<> > cs(
|
||||
new vtkm::cont::CellSetExplicit<>("cells", 2));
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs->NodesOfCellsConnectivity;
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 2);
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cellSet.NodesOfCellsConnectivity;
|
||||
|
||||
ec.PrepareToAddCells(nPointIds/3, nPointIds);
|
||||
for (i=0; i<nPointIds/3; i++)
|
||||
@ -243,7 +235,7 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds)
|
||||
ec.CompleteAddingCells();
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
ds.AddCellSet(cs);
|
||||
ds.AddCellSet(cellSet);
|
||||
|
||||
// copy bounds
|
||||
if (pBounds != NULL)
|
||||
|
@ -42,64 +42,63 @@ static void
|
||||
TwoDimRegularTest()
|
||||
{
|
||||
std::cout<<"2D Regular data set"<<std::endl;
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
|
||||
vtkm::cont::DataSet ds = tds.Make2DRegularDataSet0();
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT( (cs!=NULL), "Invalid Cell Set");
|
||||
typedef vtkm::cont::CellSetStructured<2> CellSetType;
|
||||
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1,
|
||||
"Incorrect number of cell sets");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 4,
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 4,
|
||||
"Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(cs->Structure.GetNumberOfNodes() == 6,
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfNodes() == 6,
|
||||
"Incorrect number of nodes");
|
||||
VTKM_TEST_ASSERT(cs->Structure.GetNumberOfCells() == 2,
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfCells() == 2,
|
||||
"Incorrect number of cells");
|
||||
|
||||
vtkm::Id numCells = cs->Structure.GetNumberOfCells();
|
||||
for (int i = 0; i < numCells; i++)
|
||||
vtkm::Id numCells = cellSet.Structure.GetNumberOfCells();
|
||||
for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(cs->Structure.GetNumberOfIndices() == 4,
|
||||
"Incorrect number of cell indices");
|
||||
vtkm::CellType shape = cs->Structure.GetElementShapeType();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_PIXEL, "Incorrect element type.");
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfIndices() == 4,
|
||||
"Incorrect number of cell indices");
|
||||
vtkm::CellType shape = cellSet.Structure.GetElementShapeType();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_PIXEL, "Incorrect element type.");
|
||||
}
|
||||
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE,
|
||||
vtkm::cont::CELL,2> nodeToCell = cs->GetNodeToCellConnectivity();
|
||||
vtkm::RegularConnectivity<vtkm::cont::CELL,
|
||||
vtkm::cont::NODE,2> cellToNode = cs->GetCellToNodeConnectivity();
|
||||
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::Id cells[2][4] = {{0,1,3,4}, {1,2,4,5}};
|
||||
vtkm::Vec<vtkm::Id,4> nodeIds;
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
|
||||
{
|
||||
nodeToCell.GetIndices(i, nodeIds);
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(nodeIds[j] == cells[i][j],
|
||||
"Incorrect node ID for cell");
|
||||
}
|
||||
nodeToCell.GetIndices(cellIndex, nodeIds);
|
||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 4; nodeIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(nodeIds[nodeIndex] == cells[cellIndex][nodeIndex],
|
||||
"Incorrect node ID for cell");
|
||||
}
|
||||
}
|
||||
|
||||
vtkm::Id nodes[6][4] = {{0,-1,-1,-1},
|
||||
{0,1,-1,-1},
|
||||
{0,-1,-1,-1},
|
||||
{0,1,-1,-1},
|
||||
{2,-1,-1,-1},
|
||||
{2,3,-1,-1}};
|
||||
vtkm::Id expectedCellIds[6][4] = {{0,-1,-1,-1},
|
||||
{0,1,-1,-1},
|
||||
{0,-1,-1,-1},
|
||||
{0,1,-1,-1},
|
||||
{2,-1,-1,-1},
|
||||
{2,3,-1,-1}};
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++)
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,4> cellIds;
|
||||
cellToNode.GetIndices(i, cellIds);
|
||||
for (int j = 0; j < 4; j++)
|
||||
VTKM_TEST_ASSERT(cellIds[j] == nodes[i][j],
|
||||
"Incorrect cell ID for node");
|
||||
vtkm::Vec<vtkm::Id,4> retrievedCellIds;
|
||||
cellToNode.GetIndices(pointIndex, retrievedCellIds);
|
||||
for (vtkm::IdComponent cellIndex = 0; cellIndex < 4; cellIndex++)
|
||||
VTKM_TEST_ASSERT(
|
||||
retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex],
|
||||
"Incorrect cell ID for node");
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,55 +106,58 @@ static void
|
||||
ThreeDimRegularTest()
|
||||
{
|
||||
std::cout<<"3D Regular data set"<<std::endl;
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
|
||||
vtkm::cont::DataSet ds = tds.Make3DRegularDataSet0();
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DRegularDataSet0();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<3> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<3> *>(scs.get());
|
||||
typedef vtkm::cont::CellSetStructured<3> CellSetType;
|
||||
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
|
||||
|
||||
VTKM_TEST_ASSERT( (cs!=NULL), "Invalid Cell Set");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1,
|
||||
"Incorrect number of cell sets");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 5,
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 5,
|
||||
"Incorrect number of fields");
|
||||
|
||||
VTKM_TEST_ASSERT(cs->Structure.GetNumberOfNodes() == 18,
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfNodes() == 18,
|
||||
"Incorrect number of nodes");
|
||||
|
||||
VTKM_TEST_ASSERT(cs->Structure.GetNumberOfCells() == 4,
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfCells() == 4,
|
||||
"Incorrect number of cells");
|
||||
|
||||
vtkm::Id numCells = cs->Structure.GetNumberOfCells();
|
||||
for (int i = 0; i < numCells; i++)
|
||||
vtkm::Id numCells = cellSet.Structure.GetNumberOfCells();
|
||||
for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(cs->Structure.GetNumberOfIndices() == 8,
|
||||
"Incorrect number of cell indices");
|
||||
vtkm::CellType shape = cs->Structure.GetElementShapeType();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_VOXEL, "Incorrect element type.");
|
||||
VTKM_TEST_ASSERT(cellSet.Structure.GetNumberOfIndices() == 8,
|
||||
"Incorrect number of cell indices");
|
||||
vtkm::CellType shape = cellSet.Structure.GetElementShapeType();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::VTKM_VOXEL, "Incorrect element type.");
|
||||
}
|
||||
|
||||
//Test regular connectivity.
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE,
|
||||
vtkm::cont::CELL,3> nodeToCell = cs->GetNodeToCellConnectivity();
|
||||
vtkm::Id nodes[8] = {0,1,3,4,6,7,9,10};
|
||||
vtkm::Vec<vtkm::Id,8> nodeIds;
|
||||
nodeToCell.GetIndices(0, nodeIds);
|
||||
for (int i = 0; i < 8; i++)
|
||||
VTKM_TEST_ASSERT(nodeIds[i] == nodes[i],
|
||||
"Incorrect node ID for cell");
|
||||
vtkm::RegularConnectivity<vtkm::cont::NODE, vtkm::cont::CELL,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);
|
||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
retrievedPointIds[nodeIndex] == expectedPointIds[nodeIndex],
|
||||
"Incorrect node ID for cell");
|
||||
}
|
||||
|
||||
vtkm::RegularConnectivity<vtkm::cont::CELL,
|
||||
vtkm::cont::NODE,3> cellToNode = cs->GetCellToNodeConnectivity();
|
||||
vtkm::Vec<vtkm::Id,8> cellIds;
|
||||
vtkm::Id cells[8] = {0,-1,-1,-1,-1,-1,-1,-1};
|
||||
cellToNode.GetIndices(0, cellIds);
|
||||
for (int i = 0; i < 8; i++)
|
||||
VTKM_TEST_ASSERT(cellIds[i] == cells[i],
|
||||
"Incorrect cell ID for node");
|
||||
vtkm::RegularConnectivity<vtkm::cont::CELL, vtkm::cont::NODE,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);
|
||||
for (vtkm::IdComponent nodeIndex = 0; nodeIndex < 8; nodeIndex++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(
|
||||
expectedCellIds[nodeIndex] == retrievedCellIds[nodeIndex],
|
||||
"Incorrect cell ID for node");
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestDataSetRegular(int, char *[])
|
||||
|
@ -81,7 +81,8 @@ public:
|
||||
//we need to now template based on the input domain type. If the input
|
||||
//domain type is a regular or explicit grid we call GetSchedulingDimensions.
|
||||
//but in theory your input domain could be a permutation array
|
||||
this->InvokeBasedOnDomainType(invocation,inputDomain);
|
||||
this->InvokeBasedOnDomainType(invocation,
|
||||
inputDomain.GetNodeToCellConnectivity());
|
||||
}
|
||||
|
||||
template<typename Invocation, typename InputDomainType>
|
||||
|
@ -32,13 +32,8 @@ void TestCellAverageRegular3D()
|
||||
{
|
||||
std::cout << "Testing CellAverage Worklet on 3D strucutred data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DRegularDataSet0();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<3> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<3> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DRegularDataSet0();
|
||||
|
||||
vtkm::cont::Field result("avgvals",
|
||||
1,
|
||||
@ -47,8 +42,8 @@ void TestCellAverageRegular3D()
|
||||
vtkm::Float32());
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("nodevar").GetData(),
|
||||
cs->GetNodeToCellConnectivity(),
|
||||
dispatcher.Invoke(dataSet.GetField("nodevar").GetData(),
|
||||
dataSet.GetCellSet(),
|
||||
result.GetData());
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> resultArrayHandle =
|
||||
@ -66,13 +61,8 @@ void TestCellAverageRegular2D()
|
||||
{
|
||||
std::cout << "Testing CellAverage Worklet on 2D strucutred data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet1();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> ecs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetExplicit<> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<> *>(ecs.get());
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Explicit cell set not found");
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet1();
|
||||
|
||||
vtkm::cont::Field result("avgvals",
|
||||
1,
|
||||
@ -81,8 +71,8 @@ void TestCellAverageRegular2D()
|
||||
vtkm::Float32());
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("nodevar").GetData(),
|
||||
cs->GetNodeToCellConnectivity(),
|
||||
dispatcher.Invoke(dataSet.GetField("nodevar").GetData(),
|
||||
dataSet.GetCellSet(),
|
||||
result.GetData());
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> resultArrayHandle =
|
||||
@ -100,13 +90,8 @@ void TestCellAverageExplicit()
|
||||
{
|
||||
std::cout << "Testing CellAverage Worklet on Explicit data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make2DRegularDataSet0();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0();
|
||||
|
||||
vtkm::cont::Field result("avgvals",
|
||||
1,
|
||||
@ -115,8 +100,8 @@ void TestCellAverageExplicit()
|
||||
vtkm::Float32());
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("nodevar").GetData(),
|
||||
cs->GetNodeToCellConnectivity(),
|
||||
dispatcher.Invoke(dataSet.GetField("nodevar").GetData(),
|
||||
dataSet.GetCellSet(),
|
||||
result.GetData());
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> resultArrayHandle =
|
||||
|
@ -30,7 +30,7 @@ namespace {
|
||||
|
||||
vtkm::cont::DataSet MakePointElevationTestDataSet()
|
||||
{
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
std::vector<vtkm::Float32> xVals, yVals, zVals;
|
||||
const vtkm::Id dim = 5;
|
||||
@ -51,32 +51,33 @@ vtkm::cont::DataSet MakePointElevationTestDataSet()
|
||||
|
||||
vtkm::Id numVerts = dim * dim;
|
||||
vtkm::Id numCells = (dim - 1) * (dim - 1);
|
||||
ds.AddField(vtkm::cont::Field("x", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
dataSet.AddField(vtkm::cont::Field("x", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
&xVals[0], numVerts));
|
||||
ds.AddField(vtkm::cont::Field("y", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
dataSet.AddField(vtkm::cont::Field("y", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
&yVals[0], numVerts));
|
||||
ds.AddField(vtkm::cont::Field("z", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
dataSet.AddField(vtkm::cont::Field("z", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
&zVals[0], numVerts));
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("x","y","z"));
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSetExplicit<> > cs(
|
||||
new vtkm::cont::CellSetExplicit<>("cells", 3));
|
||||
vtkm::cont::ExplicitConnectivity<> &ec = cs->NodesOfCellsConnectivity;
|
||||
ec.PrepareToAddCells(numCells, numCells * 4);
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells", 3);
|
||||
vtkm::cont::ExplicitConnectivity<> &connectivity = cellSet.NodesOfCellsConnectivity;
|
||||
connectivity.PrepareToAddCells(numCells, numCells * 4);
|
||||
for (vtkm::Id j = 0; j < dim - 1; ++j)
|
||||
{
|
||||
for (vtkm::Id i = 0; i < dim - 1; ++i)
|
||||
{
|
||||
ec.AddCell(vtkm::VTKM_QUAD, 4, vtkm::make_Vec<vtkm::Id>(j * dim + i,
|
||||
j * dim + i + 1,
|
||||
(j + 1) * dim + i + 1,
|
||||
(j + 1) * dim + i));
|
||||
connectivity.AddCell(vtkm::VTKM_QUAD,
|
||||
4,
|
||||
vtkm::make_Vec<vtkm::Id>(j * dim + i,
|
||||
j * dim + i + 1,
|
||||
(j + 1) * dim + i + 1,
|
||||
(j + 1) * dim + i));
|
||||
}
|
||||
}
|
||||
ec.CompleteAddingCells();
|
||||
connectivity.CompleteAddingCells();
|
||||
|
||||
ds.AddCellSet(cs);
|
||||
return ds;
|
||||
dataSet.AddCellSet(cellSet);
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
}
|
||||
@ -85,9 +86,9 @@ void TestPointElevation()
|
||||
{
|
||||
std::cout << "Testing PointElevation Worklet" << std::endl;
|
||||
|
||||
vtkm::cont::DataSet ds = MakePointElevationTestDataSet();
|
||||
vtkm::cont::DataSet dataSet = MakePointElevationTestDataSet();
|
||||
|
||||
ds.AddField(vtkm::cont::Field("elevation", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
dataSet.AddField(vtkm::cont::Field("elevation", 1, vtkm::cont::Field::ASSOC_POINTS,
|
||||
vtkm::Float32()));
|
||||
|
||||
vtkm::worklet::PointElevation pointElevationWorklet;
|
||||
@ -97,16 +98,16 @@ void TestPointElevation()
|
||||
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointElevation>
|
||||
dispatcher(pointElevationWorklet);
|
||||
dispatcher.Invoke(ds.GetField("x").GetData(),
|
||||
ds.GetField("y").GetData(),
|
||||
ds.GetField("z").GetData(),
|
||||
ds.GetField("elevation").GetData());
|
||||
dispatcher.Invoke(dataSet.GetField("x").GetData(),
|
||||
dataSet.GetField("y").GetData(),
|
||||
dataSet.GetField("z").GetData(),
|
||||
dataSet.GetField("elevation").GetData());
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> yVals =
|
||||
ds.GetField("y").GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
dataSet.GetField("y").GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result =
|
||||
ds.GetField("elevation").GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
dataSet.GetField("elevation").GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
|
||||
for (vtkm::Id i = 0; i < result.GetNumberOfValues(); ++i)
|
||||
|
@ -49,19 +49,20 @@ vtkm::cont::ArrayHandle<T> copyFromImplicit( vtkm::cont::ArrayHandle<T, StorageT
|
||||
return result;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet RunVertexClustering(vtkm::cont::DataSet &ds,
|
||||
vtkm::cont::DataSet RunVertexClustering(vtkm::cont::DataSet &dataSet,
|
||||
const vtkm::Float64 bounds[6],
|
||||
vtkm::Id nDivisions)
|
||||
{
|
||||
typedef vtkm::Vec<vtkm::Float32,3> PointType;
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetExplicit<> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<> *>(scs.get());
|
||||
// TODO: The VertexClustering operation needs some work. You should not have
|
||||
// to cast the cell set yourself (I don't think).
|
||||
vtkm::cont::CellSetExplicit<> &cellSet =
|
||||
dataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> pointArray = ds.GetField("xyz").GetData().CastToArrayHandle<PointType, VTKM_DEFAULT_STORAGE_TAG>();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIdArray = cs->GetNodeToCellConnectivity().GetConnectivityArray();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellToConnectivityIndexArray = cs->GetNodeToCellConnectivity().GetCellToConnectivityIndexArray();
|
||||
vtkm::cont::ArrayHandle<PointType> pointArray = dataSet.GetField("xyz").GetData().CastToArrayHandle<PointType, VTKM_DEFAULT_STORAGE_TAG>();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pointIdArray = cellSet.GetNodeToCellConnectivity().GetConnectivityArray();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellToConnectivityIndexArray = cellSet.GetNodeToCellConnectivity().GetCellToConnectivityIndexArray();
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> output_pointArray ;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id3> output_pointId3Array ;
|
||||
@ -76,31 +77,29 @@ vtkm::cont::DataSet RunVertexClustering(vtkm::cont::DataSet &ds,
|
||||
output_pointArray,
|
||||
output_pointId3Array);
|
||||
|
||||
vtkm::cont::DataSet new_ds;
|
||||
vtkm::cont::DataSet newDataSet;
|
||||
|
||||
new_ds.AddField(vtkm::cont::Field("xyz", 0, vtkm::cont::Field::ASSOC_POINTS, output_pointArray));
|
||||
new_ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("xyz"));
|
||||
newDataSet.AddField(vtkm::cont::Field("xyz", 0, vtkm::cont::Field::ASSOC_POINTS, output_pointArray));
|
||||
newDataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("xyz"));
|
||||
|
||||
vtkm::Id cells = output_pointId3Array.GetNumberOfValues();
|
||||
if (cells > 0)
|
||||
{
|
||||
//typedef typename vtkm::cont::ArrayHandleConstant<vtkm::Id>::StorageTag ConstantStorage;
|
||||
//typedef typename vtkm::cont::ArrayHandleImplicit<vtkm::Id, CounterOfThree>::StorageTag CountingStorage;
|
||||
typedef vtkm::cont::CellSetExplicit<> Connectivity;
|
||||
|
||||
boost::shared_ptr< Connectivity > new_cs(
|
||||
new Connectivity("cells", 0) );
|
||||
vtkm::cont::CellSetExplicit<> newCellSet("cells", 0);
|
||||
|
||||
new_cs->GetNodeToCellConnectivity().Fill(
|
||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(vtkm::VTKM_TRIANGLE, cells)),
|
||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(3, cells)),
|
||||
copyFromVec(output_pointId3Array)
|
||||
);
|
||||
newCellSet.GetNodeToCellConnectivity().Fill(
|
||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(vtkm::VTKM_TRIANGLE, cells)),
|
||||
copyFromImplicit(vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(3, cells)),
|
||||
copyFromVec(output_pointId3Array)
|
||||
);
|
||||
|
||||
new_ds.AddCellSet(new_cs);
|
||||
newDataSet.AddCellSet(newCellSet);
|
||||
}
|
||||
|
||||
return new_ds;
|
||||
return newDataSet;
|
||||
}
|
||||
|
||||
void TestVertexClustering()
|
||||
@ -108,10 +107,10 @@ void TestVertexClustering()
|
||||
vtkm::Float64 bounds[6];
|
||||
const vtkm::Id divisions = 3;
|
||||
vtkm::cont::testing::MakeTestDataSet maker;
|
||||
vtkm::cont::DataSet ds = maker.Make3DExplicitDataSetCowNose(bounds);
|
||||
vtkm::cont::DataSet dataSet = maker.Make3DExplicitDataSetCowNose(bounds);
|
||||
|
||||
// run
|
||||
vtkm::cont::DataSet ds_out = RunVertexClustering(ds, bounds, divisions);
|
||||
vtkm::cont::DataSet outDataSet = RunVertexClustering(dataSet, bounds, divisions);
|
||||
|
||||
// test
|
||||
const vtkm::Id output_pointIds = 9;
|
||||
@ -119,10 +118,10 @@ void TestVertexClustering()
|
||||
const vtkm::Id output_points = 6;
|
||||
double output_point[output_points][3] = {{0.0174716003,0.0501927994,0.0930275023}, {0.0320714004,0.14704667,0.0952706337}, {0.0268670674,0.246195346,0.119720004}, {0.00215422804,0.0340906903,0.180881709}, {0.0108188,0.152774006,0.167914003}, {0.0202241503,0.225427493,0.140208006}};
|
||||
|
||||
VTKM_TEST_ASSERT(ds_out.GetNumberOfFields() == 1, "Number of output fields mismatch");
|
||||
VTKM_TEST_ASSERT(outDataSet.GetNumberOfFields() == 1, "Number of output fields mismatch");
|
||||
typedef vtkm::Vec<vtkm::Float32, 3> PointType;
|
||||
typedef vtkm::cont::ArrayHandle<PointType > PointArray;
|
||||
PointArray pointArray = ds_out.GetField(0).GetData().CastToArrayHandle<PointArray::ValueType, PointArray::StorageTag>();
|
||||
PointArray pointArray = outDataSet.GetField(0).GetData().CastToArrayHandle<PointArray::ValueType, PointArray::StorageTag>();
|
||||
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points, "Number of output points mismatch" );
|
||||
for (vtkm::Id i = 0; i < pointArray.GetNumberOfValues(); ++i)
|
||||
{
|
||||
@ -132,10 +131,10 @@ void TestVertexClustering()
|
||||
VTKM_TEST_ASSERT(test_equal(p1, p2), "Point Array mismatch");
|
||||
}
|
||||
|
||||
VTKM_TEST_ASSERT(ds_out.GetNumberOfCellSets() == 1, "Number of output cellsets mismatch");
|
||||
vtkm::cont::CellSetExplicit<> *cellset = dynamic_cast<vtkm::cont::CellSetExplicit<> *>(ds_out.GetCellSet(0).get());
|
||||
VTKM_TEST_ASSERT(cellset != NULL, "CellSet Cast fail");
|
||||
vtkm::cont::ExplicitConnectivity<> &conn = cellset->GetNodeToCellConnectivity();
|
||||
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCellSets() == 1, "Number of output cellsets mismatch");
|
||||
vtkm::cont::CellSetExplicit<> &cellSet =
|
||||
outDataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
|
||||
vtkm::cont::ExplicitConnectivity<> &conn = cellSet.GetNodeToCellConnectivity();
|
||||
VTKM_TEST_ASSERT(conn.GetConnectivityArray().GetNumberOfValues() == output_pointIds, "Number of connectivity array elements mismatch");
|
||||
for (vtkm::Id i=0; i<conn.GetConnectivityArray().GetNumberOfValues(); i++)
|
||||
{
|
||||
|
@ -142,8 +142,8 @@ static void
|
||||
TestMaxNodeOrCell()
|
||||
{
|
||||
std::cout<<"Testing MaxNodeOfCell worklet"<<std::endl;
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet1();
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet1();
|
||||
|
||||
//Run a worklet to populate a cell centered field.
|
||||
//Here, we're filling it with test values.
|
||||
@ -153,39 +153,29 @@ TestMaxNodeOrCell()
|
||||
std::string("cells"),
|
||||
vtkm::Float32());
|
||||
|
||||
ds.AddField(f);
|
||||
dataSet.AddField(f);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
|
||||
"Incorrect number of cell sets");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1,
|
||||
"Incorrect number of cell sets");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6,
|
||||
"Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 6,
|
||||
"Incorrect number of fields");
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> cs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetExplicit<> *cse =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<>*>(cs.get());
|
||||
|
||||
VTKM_TEST_ASSERT(cse != NULL, "Expected an explicit cell set");
|
||||
|
||||
//Todo:
|
||||
//the scheduling should just be passed a CellSet, and not the
|
||||
//derived implementation. The vtkm::cont::CellSet should have
|
||||
//a method that return the nodesOfCellsConnectivity / structure
|
||||
//for that derived type. ( talk to robert for how dax did this )
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::MaxNodeOrCellValue > dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("cellvar").GetData(),
|
||||
ds.GetField("nodevar").GetData(),
|
||||
cse->GetNodeToCellConnectivity(),
|
||||
ds.GetField("outcellvar").GetData());
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::MaxNodeOrCellValue >
|
||||
dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar").GetData(),
|
||||
dataSet.GetField("nodevar").GetData(),
|
||||
dataSet.GetCellSet(0),
|
||||
dataSet.GetField("outcellvar").GetData());
|
||||
|
||||
//Make sure we got the right answer.
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> res;
|
||||
res = ds.GetField(5).GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
res = dataSet.GetField(5).GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(0), 100.1f),
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(1), 100.2f),
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -193,8 +183,8 @@ TestAvgNodeToCell()
|
||||
{
|
||||
std::cout<<"Testing AvgNodeToCell worklet"<<std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet1();
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet1();
|
||||
|
||||
//Run a worklet to populate a cell centered field.
|
||||
//Here, we're filling it with test values.
|
||||
@ -204,34 +194,28 @@ TestAvgNodeToCell()
|
||||
std::string("cells"),
|
||||
vtkm::Float32());
|
||||
|
||||
ds.AddField(f);
|
||||
dataSet.AddField(f);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1,
|
||||
"Incorrect number of cell sets");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6,
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 6,
|
||||
"Incorrect number of fields");
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> cs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetExplicit<> *cse =
|
||||
dynamic_cast<vtkm::cont::CellSetExplicit<>*>(cs.get());
|
||||
|
||||
VTKM_TEST_ASSERT(cse != NULL, "Expected an explicit cell set");
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_explicit::AvgNodeToCellValue > dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("nodevar").GetData(),
|
||||
cse->GetNodeToCellConnectivity(),
|
||||
ds.GetField("outcellvar").GetData());
|
||||
dispatcher.Invoke(dataSet.GetField("nodevar").GetData(),
|
||||
dataSet.GetCellSet(),
|
||||
dataSet.GetField("outcellvar").GetData());
|
||||
|
||||
//make sure we got the right answer.
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> res;
|
||||
res = ds.GetField("outcellvar").GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
res = dataSet.GetField("outcellvar").GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(0), 20.1333f),
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(1), 35.2f),
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -143,13 +143,8 @@ static void
|
||||
TestMaxNodeOrCell()
|
||||
{
|
||||
std::cout<<"Testing MaxNodeOfCell worklet"<<std::endl;
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make2DRegularDataSet0();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0();
|
||||
|
||||
//Run a worklet to populate a cell centered field.
|
||||
//Here, we're filling it with test values.
|
||||
@ -159,46 +154,41 @@ TestMaxNodeOrCell()
|
||||
std::string("cells"),
|
||||
vtkm::Float32());
|
||||
|
||||
ds.AddField(f);
|
||||
dataSet.AddField(f);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(ds.GetNumberOfCellSets(), 1),
|
||||
VTKM_TEST_ASSERT(test_equal(dataSet.GetNumberOfCellSets(), 1),
|
||||
"Incorrect number of cell sets");
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(ds.GetNumberOfFields(), 5),
|
||||
VTKM_TEST_ASSERT(test_equal(dataSet.GetNumberOfFields(), 5),
|
||||
"Incorrect number of fields");
|
||||
//Todo:
|
||||
//the scheduling should just be passed a CellSet, and not the
|
||||
//derived implementation. The vtkm::cont::CellSet should have
|
||||
//a method that return the nodesOfCellsConnectivity / structure
|
||||
//for that derived type. ( talk to robert for how dax did this )
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_regular::MaxNodeOrCellValue > dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("cellvar").GetData(),
|
||||
ds.GetField("nodevar").GetData(),
|
||||
cs->GetNodeToCellConnectivity(),
|
||||
ds.GetField(4).GetData());
|
||||
dispatcher.Invoke(dataSet.GetField("cellvar").GetData(),
|
||||
dataSet.GetField("nodevar").GetData(),
|
||||
// We know that the cell set is a structured 2D grid and
|
||||
// The worklet does not work with general types because
|
||||
// of the way we get cell indices. We need to make that
|
||||
// part more flexible.
|
||||
dataSet.GetCellSet(0).ResetCellSetList(
|
||||
vtkm::cont::CellSetListTagStructured2D()),
|
||||
dataSet.GetField(4).GetData());
|
||||
|
||||
//make sure we got the right answer.
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> res;
|
||||
res = ds.GetField(4).GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
res = dataSet.GetField(4).GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(0), 100.1f),
|
||||
"Wrong result for MaxNodeOrCell worklet");
|
||||
"Wrong result for MaxNodeOrCell worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(1), 200.1f),
|
||||
"Wrong result for MaxNodeOrCell worklet");
|
||||
"Wrong result for MaxNodeOrCell worklet");
|
||||
}
|
||||
|
||||
static void
|
||||
TestAvgNodeToCell()
|
||||
{
|
||||
std::cout<<"Testing AvgNodeToCell worklet"<<std::endl;
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make2DRegularDataSet0();
|
||||
|
||||
boost::shared_ptr<vtkm::cont::CellSet> scs = ds.GetCellSet(0);
|
||||
vtkm::cont::CellSetStructured<2> *cs =
|
||||
dynamic_cast<vtkm::cont::CellSetStructured<2> *>(scs.get());
|
||||
VTKM_TEST_ASSERT(cs != NULL, "Structured cell set not found");
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0();
|
||||
|
||||
//Run a worklet to populate a cell centered field.
|
||||
//Here, we're filling it with test values.
|
||||
@ -208,32 +198,32 @@ TestAvgNodeToCell()
|
||||
std::string("cells"),
|
||||
vtkm::Float32());
|
||||
|
||||
ds.AddField(f);
|
||||
dataSet.AddField(f);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(ds.GetNumberOfCellSets(), 1),
|
||||
VTKM_TEST_ASSERT(test_equal(dataSet.GetNumberOfCellSets(), 1),
|
||||
"Incorrect number of cell sets");
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(ds.GetNumberOfFields(), 5),
|
||||
VTKM_TEST_ASSERT(test_equal(dataSet.GetNumberOfFields(), 5),
|
||||
"Incorrect number of fields");
|
||||
//Todo:
|
||||
//the scheduling should just be passed a CellSet, and not the
|
||||
//derived implementation. The vtkm::cont::CellSet should have
|
||||
//a method that return the nodesOfCellsConnectivity / structure
|
||||
//for that derived type. ( talk to robert for how dax did this )
|
||||
vtkm::worklet::DispatcherMapTopology< ::test_regular::AvgNodeToCellValue > dispatcher;
|
||||
dispatcher.Invoke(ds.GetField("nodevar").GetData(),
|
||||
cs->GetNodeToCellConnectivity(),
|
||||
ds.GetField("outcellvar").GetData());
|
||||
dispatcher.Invoke(dataSet.GetField("nodevar").GetData(),
|
||||
// We know that the cell set is a structured 2D grid and
|
||||
// The worklet does not work with general types because
|
||||
// of the way we get cell indices. We need to make that
|
||||
// part more flexible.
|
||||
dataSet.GetCellSet(0).ResetCellSetList(
|
||||
vtkm::cont::CellSetListTagStructured2D()),
|
||||
dataSet.GetField("outcellvar").GetData());
|
||||
|
||||
//make sure we got the right answer.
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> res;
|
||||
res = ds.GetField(4).GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
res = dataSet.GetField(4).GetData().CastToArrayHandle(vtkm::Float32(),
|
||||
VTKM_DEFAULT_STORAGE_TAG());
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(0), 30.1f),
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(res.GetPortalConstControl().Get(1), 40.1f),
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
"Wrong result for NodeToCellAverage worklet");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user