Commit 25a1e3c3 authored by dpugmire's avatar dpugmire
Browse files

Cleanup and fix an issue in Explicit dataset testing with the initial merge.

parent ab268c2c
......@@ -75,7 +75,7 @@ public:
return this->Fields[i];
}
}
throw vtkm::cont::ErrorControlBadValue("No field with requested name");
throw vtkm::cont::ErrorControlBadValue("No field with requested name: "+name);
}
VTKM_CONT_EXPORT
......
......@@ -27,6 +27,8 @@
namespace vtkm {
namespace cont {
typedef vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> DFA;
//Coordinates builder??
//Need a singlecellset handler.
......@@ -155,13 +157,16 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
vtkm::cont::DataSet dataSet;
size_t nPts = coords.size();
vtkm::cont::ArrayHandle<Vec<T,3> > coordsArray;
DFA::Copy(vtkm::cont::make_ArrayHandle(coords), coordsArray);
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, 1, coords));
vtkm::cont::CoordinateSystem(coordsNm, 1, coordsArray));
vtkm::cont::CellSetExplicit<> cellSet((vtkm::Id)nPts, cellNm, 3);
cellSet.FillViaCopy(shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
return dataSet;
}
......
......@@ -28,6 +28,8 @@
namespace vtkm {
namespace cont {
typedef vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> DFA;
class DataSetBuilderRectilinear
{
public:
......@@ -128,11 +130,11 @@ private:
vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandle<T> > coords;
vtkm::cont::ArrayHandle<T> Xc, Yc, Zc;
vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Copy(X, Xc);
vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Copy(Y, Yc);
vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Copy(Z, Zc);
DFA::Copy(X, Xc);
DFA::Copy(Y, Yc);
DFA::Copy(Z, Zc);
coords = vtkm::cont::make_ArrayHandleCartesianProduct(Xc,Yc,Zc);
vtkm::cont::CoordinateSystem cs(coordNm, 1, coords);
......
......@@ -36,34 +36,27 @@ class MakeTestDataSet
{
public:
// 2D regular datasets.
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make2DRegularDataSet0();
// 3D regular datasets.
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make3DRegularDataSet0();
//2D rectilinear
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make2DRectilinearDataSet0();
//3D rectilinear
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make3DRectilinearDataSet0();
// 3D explicit datasets.
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make3DExplicitDataSet0();
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make3DExplicitDataSet1();
VTKM_CONT_EXPORT
vtkm::cont::DataSet Make3DExplicitDataSetCowNose(double *pBounds = NULL);
};
//Make a simple 2D, 2 cell regular dataset.
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make2DRegularDataSet0()
{
vtkm::cont::DataSetBuilderRegular dsb;
......@@ -81,7 +74,7 @@ MakeTestDataSet::Make2DRegularDataSet0()
return dataSet;
}
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make3DRegularDataSet0()
{
vtkm::cont::DataSetBuilderRegular dsb;
......@@ -103,7 +96,7 @@ MakeTestDataSet::Make3DRegularDataSet0()
return dataSet;
}
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make2DRectilinearDataSet0()
{
vtkm::cont::DataSetBuilderRectilinear dsb;
......@@ -133,7 +126,7 @@ MakeTestDataSet::Make2DRectilinearDataSet0()
return dataSet;
}
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make3DRectilinearDataSet0()
{
vtkm::cont::DataSetBuilderRectilinear dsb;
......@@ -166,7 +159,7 @@ MakeTestDataSet::Make3DRectilinearDataSet0()
return dataSet;
}
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make3DExplicitDataSet0()
{
vtkm::cont::DataSet dataSet;
......@@ -213,8 +206,8 @@ MakeTestDataSet::Make3DExplicitDataSet0()
return dataSet;
}
vtkm::cont::DataSet
/*
inline vtkm::cont::DataSet
MakeTestDataSet::Make3DExplicitDataSet1()
{
vtkm::cont::DataSet dataSet;
......@@ -245,9 +238,10 @@ MakeTestDataSet::Make3DExplicitDataSet1()
return dataSet;
}
*/
/*
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make3DExplicitDataSet1()
{
vtkm::cont::DataSet dataSet;
......@@ -292,9 +286,8 @@ MakeTestDataSet::Make3DExplicitDataSet1()
return dataSet;
}
*/
vtkm::cont::DataSet
inline vtkm::cont::DataSet
MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds)
{
// prepare data array
......
......@@ -74,7 +74,6 @@ private:
const vtkm::cont::Field &f1 = ds.GetField("pointvar");
VTKM_TEST_ASSERT(f1.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS,
"Association of 'pointvar' was not ASSOC_POINTS");
try
{
//const vtkm::cont::Field &f2 =
......@@ -103,13 +102,10 @@ private:
// test cell-to-point connectivity
vtkm::cont::CellSetExplicit<> &cellset =
ds.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
cellset.BuildConnectivity(DeviceAdapterTag(),
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
ds.PrintSummary(std::cout);
vtkm::Id connectivitySize = 7;
vtkm::Id numPoints = 5;
......
......@@ -20,120 +20,6 @@
#include <vtkm/cont/DeviceAdapterSerial.h>
#include <vtkm/cont/testing/TestingDataSetExplicit.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
namespace {
template<typename T, typename Storage>
bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *expected,
vtkm::Id size)
{
if (size != ah.GetNumberOfValues())
{
return false;
}
for (vtkm::Id i = 0; i < size; ++i)
{
if (ah.GetPortalConstControl().Get(i) != expected[i])
{
return false;
}
}
return true;
}
template<typename DeviceAdapterTag>
void TestDataSet_Explicit()
{
vtkm::cont::testing::MakeTestDataSet tds;
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0();
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
"Incorrect number of cell sets");
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2,
"Incorrect number of fields");
// test various field-getting methods and associations
const vtkm::cont::Field &f1 = ds.GetField("pointvar");
VTKM_TEST_ASSERT(f1.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS,
"Association of 'pointvar' was not ASSOC_POINTS");
try
{
ds.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET.");
}
try
{
ds.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS);
}
catch (...)
{
VTKM_TEST_FAIL("Failed to get expected error for association mismatch.");
}
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
"Incorrect number of coordinate systems");
// test cell-to-point connectivity
vtkm::cont::CellSetExplicit<> &cellset =
ds.GetCellSet(0).CastTo<vtkm::cont::CellSetExplicit<> >();
cellset.BuildConnectivity(DeviceAdapterTag(),
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::Id connectivitySize = 7;
vtkm::Id numPoints = 5;
vtkm::UInt8 correctShapes[] = {1, 1, 1, 1, 1};
vtkm::IdComponent correctNumIndices[] = {1, 2, 2, 1, 1};
vtkm::Id correctConnectivity[] = {0, 0, 1, 0, 1, 1, 1};
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes = cellset.GetShapesArray(
vtkm::TopologyElementTagCell(),vtkm::TopologyElementTagPoint());
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices = cellset.GetNumIndicesArray(
vtkm::TopologyElementTagCell(),vtkm::TopologyElementTagPoint());
vtkm::cont::ArrayHandle<vtkm::Id> conn = cellset.GetConnectivityArray(
vtkm::TopologyElementTagCell(),vtkm::TopologyElementTagPoint());
VTKM_TEST_ASSERT(TestArrayHandle(shapes,
correctShapes,
numPoints),
"Got incorrect shapes");
VTKM_TEST_ASSERT(TestArrayHandle(numIndices,
correctNumIndices,
numPoints),
"Got incorrect shapes");
VTKM_TEST_ASSERT(TestArrayHandle(conn,
correctConnectivity,
connectivitySize),
"Got incorrect conectivity");
//verify that GetIndices works properly
vtkm::Id expectedPointIds[4] = {2,1,3,4};
vtkm::Vec<vtkm::Id,4> retrievedPointIds;
cellset.GetIndices(1, retrievedPointIds);
for (vtkm::IdComponent i = 0; i < 4; i++)
{
VTKM_TEST_ASSERT(
retrievedPointIds[i] == expectedPointIds[i],
"Incorrect point ID for quad cell");
}
}
}
int UnitTestDataSetExplicit(int, char *[])
{
......
......@@ -50,24 +50,6 @@ TwoDimRectilinearTest()
vtkm::cont::DataSet dataSet = testDataSet.Make2DRectilinearDataSet0();
/*
dataSet.PrintSummary(std::cout);
vtkm::cont::CoordinateSystem cs = dataSet.GetCoordinateSystem();
vtkm::cont::DynamicArrayHandleCoordinateSystem dcs = cs.GetData();
vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32> > coords;
dcs.CastToArrayHandle(coords);
vtkm::Id n = dcs.GetNumberOfValues();
vtkm::Vec<vtkm::Float32, 3> pt(0,0,0);
for (int i = 0; i < n; i++)
{
pt = coords.GetPortalConstControl().Get(i);
std::cout<<i<<": ["<<pt[0]<<" "<<pt[1]<<" "<<pt[2]<<"]"<<std::endl;
}
*/
typedef vtkm::cont::CellSetStructured<2> CellSetType;
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment