Commit b225ae97 authored by Dave Pugmire's avatar Dave Pugmire
Browse files

Rectilinear coordinates (created with DataSetBuilderRectilinear) are now...

Rectilinear coordinates (created with DataSetBuilderRectilinear) are now converted to vtkm::FloatDefault.
This reduces the number of types to consider when casting inside CoordinateSystem, and was felt by all to be a reasonable restriction.
parent d755e43d
......@@ -22,6 +22,7 @@
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
#include <vtkm/cont/Field.h>
#ifndef VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG
......@@ -63,7 +64,11 @@ struct StorageListTagCoordinateSystemDefault
VTKM_DEFAULT_STORAGE_LIST_TAG,
vtkm::ListTagBase<vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
detail::ArrayHandleCompositeVectorFloat32_3Default::StorageTag,
detail::ArrayHandleCompositeVectorFloat64_3Default::StorageTag> >
detail::ArrayHandleCompositeVectorFloat64_3Default::StorageTag,
vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > > >
{ };
typedef vtkm::cont::DynamicArrayHandleBase<
......
......@@ -47,6 +47,25 @@ public:
T zvals = 0;
return Create(2, nx,ny, 1, xvals, yvals, &zvals, coordNm, cellNm);
}
template<typename T>
VTKM_CONT_EXPORT
vtkm::cont::DataSet
Create(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
T *xvals, T *yvals, T *zvals,
std::string coordNm, std::string cellNm)
{
VTKM_ASSERT_CONT(nx>1 && ny>1 &&
((dim==2 && nz==1)||(dim==3 && nz>=1)));
vtkm::cont::ArrayHandle<vtkm::FloatDefault> Xc, Yc, Zc;
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals,nx), Xc);
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals,ny), Yc);
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals,nz), Zc);
return BuildDataSet(dim, Xc,Yc,Zc, coordNm, cellNm);
}
template<typename T>
VTKM_CONT_EXPORT
vtkm::cont::DataSet
......@@ -54,7 +73,7 @@ public:
std::string coordNm="coords", std::string cellNm="cells")
{
std::vector<T> zvals(1,0);
return Create(2, xvals, yvals, zvals, coordNm, cellNm);
return BuildDataSet(2, xvals,yvals,zvals, coordNm,cellNm);
}
template<typename T>
VTKM_CONT_EXPORT
......@@ -88,7 +107,7 @@ public:
const std::vector<T> &zvals,
std::string coordNm="coords", std::string cellNm="cells")
{
return Create(3, xvals, yvals, zvals, coordNm, cellNm);
return BuildDataSet(3, xvals, yvals, zvals, coordNm, cellNm);
}
template<typename T>
VTKM_CONT_EXPORT
......@@ -108,34 +127,16 @@ private:
template<typename T>
VTKM_CONT_EXPORT
vtkm::cont::DataSet
Create(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
T *xvals, T *yvals, T *zvals,
std::string coordNm, std::string cellNm)
{
VTKM_ASSERT_CONT(nx>1 && ny>1 &&
((dim==2 && nz==1)||(dim==3 && nz>=1)));
vtkm::cont::ArrayHandle<T> Xc, Yc, Zc;
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals,nx), Xc);
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals,ny), Yc);
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals,nz), Zc);
return BuildDataSet(dim, Xc,Yc,Zc, coordNm, cellNm);
}
template<typename T>
VTKM_CONT_EXPORT
vtkm::cont::DataSet
Create(int dim,
const std::vector<T> &xvals,
const std::vector<T> &yvals,
const std::vector<T> &zvals,
std::string coordNm, std::string cellNm)
BuildDataSet(int dim,
const std::vector<T> &xvals,
const std::vector<T> &yvals,
const std::vector<T> &zvals,
std::string coordNm, std::string cellNm)
{
VTKM_ASSERT_CONT(xvals.size()>1 && yvals.size()>1 &&
((dim==2 && zvals.size()==1)||(dim==3 && zvals.size()>=1)));
vtkm::cont::ArrayHandle<T> Xc, Yc, Zc;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> Xc, Yc, Zc;
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), Xc);
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Yc);
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Zc);
......@@ -154,16 +155,17 @@ private:
{
vtkm::cont::DataSet dataSet;
//Convert all coordinates to floatDefault.
vtkm::cont::ArrayHandleCartesianProduct<
vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandle<T> > coords;
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > coords;
vtkm::cont::ArrayHandle<T> Xc, Yc, Zc;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> Xc, Yc, 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);
dataSet.AddCoordinateSystem(cs);
......@@ -185,7 +187,6 @@ private:
}
return dataSet;
}
};
......
......@@ -38,7 +38,7 @@ typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
void ValidateDataSet(const vtkm::cont::DataSet &ds,
int dim,
vtkm::Id numPoints, vtkm::Id numCells,
vtkm::Float64 */*bounds*/)
vtkm::Float64 *)
{
//Verify basics..
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1,
......@@ -62,7 +62,6 @@ void ValidateDataSet(const vtkm::cont::DataSet &ds,
bounds[4]==res[4] && bounds[5]==res[5],
"Bounds of coordinates do not match");
*/
if (dim == 2)
{
typedef vtkm::cont::CellSetStructured<2> CellSetType;
......@@ -99,15 +98,16 @@ void FillArray(std::vector<T> &arr, std::size_t sz, int fillMethod)
}
}
template <typename T>
void
TestDataSetBuilderRectilinear()
RectilinearTests()
{
vtkm::cont::DataSetBuilderRectilinear dsb;
vtkm::cont::DataSet ds;
std::size_t nx = 15, ny = 15, nz = 15;
int nm = 5;
std::vector<vtkm::Float32> xvals, yvals, zvals;
std::vector<T> xvals, yvals, zvals;
for (std::size_t i = 2; i < nx; i++)
for (std::size_t j = 2; j < ny; j++)
......@@ -126,7 +126,7 @@ TestDataSetBuilderRectilinear()
ds = dsb.Create(xvals, yvals);
ValidateDataSet(ds, 2, np, nc, bounds);
//Test vtkm::Float *
//Test T *
ds = dsb.Create(i,j, &xvals[0],&yvals[0]);
ValidateDataSet(ds, 2, np, nc, bounds);
......@@ -147,7 +147,7 @@ TestDataSetBuilderRectilinear()
ds = dsb.Create(xvals, yvals, zvals);
ValidateDataSet(ds, 3, np, nc, bounds);
//Test vtkm::Float *
//Test T *
ds = dsb.Create(i,j,k, &xvals[0],&yvals[0], &zvals[0]);
ValidateDataSet(ds, 3, np, nc, bounds);
......@@ -161,6 +161,13 @@ TestDataSetBuilderRectilinear()
}
}
void
TestDataSetBuilderRectilinear()
{
RectilinearTests<vtkm::Float32>();
RectilinearTests<vtkm::Float64>();
}
} // namespace DataSetBuilderRectilinearNamespace
int UnitTestDataSetBuilderRectilinear(int, char *[])
......
Supports Markdown
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