mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 03:18:58 +00:00
Clarify dimension values for 2d, 1d. fix test
This commit is contained in:
parent
651345b491
commit
3bd15950bd
@ -35,7 +35,7 @@ public:
|
|||||||
vtkm::Id dim = static_cast<vtkm::Id>(xVals.size());
|
vtkm::Id dim = static_cast<vtkm::Id>(xVals.size());
|
||||||
auto coords = vtkm::cont::make_ArrayHandleSOA<vtkm::Vec<T, 3>>({ xVals, yVals, zVals });
|
auto coords = vtkm::cont::make_ArrayHandleSOA<vtkm::Vec<T, 3>>({ xVals, yVals, zVals });
|
||||||
|
|
||||||
return DataSetBuilderCurvilinear::Create(coords, { dim, 1, 1 }, 1, coordsNm);
|
return DataSetBuilderCurvilinear::Create(coords, { dim, 0, 0 }, 1, coordsNm);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
std::vector<T> zVals(xVals.size(), 0);
|
std::vector<T> zVals(xVals.size(), 0);
|
||||||
auto coords = vtkm::cont::make_ArrayHandleSOA<vtkm::Vec<T, 3>>({ xVals, yVals, zVals });
|
auto coords = vtkm::cont::make_ArrayHandleSOA<vtkm::Vec<T, 3>>({ xVals, yVals, zVals });
|
||||||
|
|
||||||
return DataSetBuilderCurvilinear::Create(coords, { dims[0], dims[1], 1 }, 2, coordsNm);
|
return DataSetBuilderCurvilinear::Create(coords, { dims[0], dims[1], 0 }, 2, coordsNm);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
const vtkm::Id2& dims,
|
const vtkm::Id2& dims,
|
||||||
const std::string& coordsNm = "coords")
|
const std::string& coordsNm = "coords")
|
||||||
{
|
{
|
||||||
return DataSetBuilderCurvilinear::Create(coords, { dims[0], dims[1], 1 }, 2, coordsNm);
|
return DataSetBuilderCurvilinear::Create(coords, { dims[0], dims[1], 0 }, 2, coordsNm);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename CoordsType>
|
template <typename CoordsType>
|
||||||
@ -97,7 +97,7 @@ public:
|
|||||||
const std::string& coordsNm = "coords")
|
const std::string& coordsNm = "coords")
|
||||||
{
|
{
|
||||||
return DataSetBuilderCurvilinear::Create(
|
return DataSetBuilderCurvilinear::Create(
|
||||||
coords, { coords.GetNumberOfValues(), 1, 1 }, 1, coordsNm);
|
coords, { coords.GetNumberOfValues(), 0, 0 }, 1, coordsNm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -107,26 +107,32 @@ private:
|
|||||||
const vtkm::Id& cellSetDim,
|
const vtkm::Id& cellSetDim,
|
||||||
const std::string& coordsNm = "coords")
|
const std::string& coordsNm = "coords")
|
||||||
{
|
{
|
||||||
VTKM_ASSERT(dims[0] >= 1 && dims[1] >= 1 && dims[2] >= 1);
|
|
||||||
VTKM_ASSERT(coords.GetNumberOfValues() == dims[0] * dims[1] * dims[2]);
|
|
||||||
|
|
||||||
vtkm::cont::DataSet ds;
|
vtkm::cont::DataSet ds;
|
||||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
||||||
|
|
||||||
if (cellSetDim == 3)
|
if (cellSetDim == 3)
|
||||||
{
|
{
|
||||||
|
VTKM_ASSERT(dims[0] >= 1 && dims[1] >= 1 && dims[2] >= 1);
|
||||||
|
VTKM_ASSERT(coords.GetNumberOfValues() == dims[0] * dims[1] * dims[2]);
|
||||||
|
|
||||||
vtkm::cont::CellSetStructured<3> cellSet;
|
vtkm::cont::CellSetStructured<3> cellSet;
|
||||||
cellSet.SetPointDimensions(dims);
|
cellSet.SetPointDimensions(dims);
|
||||||
ds.SetCellSet(cellSet);
|
ds.SetCellSet(cellSet);
|
||||||
}
|
}
|
||||||
else if (cellSetDim == 2)
|
else if (cellSetDim == 2)
|
||||||
{
|
{
|
||||||
|
VTKM_ASSERT(dims[0] >= 1 && dims[1] >= 1 && dims[2] == 0);
|
||||||
|
VTKM_ASSERT(coords.GetNumberOfValues() == dims[0] * dims[1]);
|
||||||
|
|
||||||
vtkm::cont::CellSetStructured<2> cellSet;
|
vtkm::cont::CellSetStructured<2> cellSet;
|
||||||
cellSet.SetPointDimensions({ dims[0], dims[1] });
|
cellSet.SetPointDimensions({ dims[0], dims[1] });
|
||||||
ds.SetCellSet(cellSet);
|
ds.SetCellSet(cellSet);
|
||||||
}
|
}
|
||||||
else if (cellSetDim == 1)
|
else if (cellSetDim == 1)
|
||||||
{
|
{
|
||||||
|
VTKM_ASSERT(dims[0] >= 1 && dims[1] == 0 && dims[2] == 0);
|
||||||
|
VTKM_ASSERT(coords.GetNumberOfValues() == dims[0]);
|
||||||
|
|
||||||
vtkm::cont::CellSetStructured<1> cellSet;
|
vtkm::cont::CellSetStructured<1> cellSet;
|
||||||
cellSet.SetPointDimensions(dims[0]);
|
cellSet.SetPointDimensions(dims[0]);
|
||||||
ds.SetCellSet(cellSet);
|
ds.SetCellSet(cellSet);
|
||||||
|
@ -55,7 +55,10 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
|||||||
|
|
||||||
//Make sure bounds are correct.
|
//Make sure bounds are correct.
|
||||||
vtkm::Bounds res = ds.GetCoordinateSystem().GetBounds();
|
vtkm::Bounds res = ds.GetCoordinateSystem().GetBounds();
|
||||||
VTKM_TEST_ASSERT(test_equal(bounds, res), "Bounds of coordinates do not match");
|
VTKM_TEST_ASSERT(bounds.Contains(vtkm::Vec3f_64(res.X.Min, res.Y.Min, res.Z.Min)) &&
|
||||||
|
bounds.Contains(vtkm::Vec3f_64(res.X.Max, res.Y.Max, res.Z.Max)),
|
||||||
|
test_equal(bounds, res),
|
||||||
|
"Bounds of coordinates do not match");
|
||||||
if (dim == 1)
|
if (dim == 1)
|
||||||
{
|
{
|
||||||
vtkm::cont::CellSetStructured<1> cellSet;
|
vtkm::cont::CellSetStructured<1> cellSet;
|
||||||
@ -95,39 +98,50 @@ void CurvilinearTests()
|
|||||||
std::uniform_real_distribution<T> randomVal(minReal, maxReal);
|
std::uniform_real_distribution<T> randomVal(minReal, maxReal);
|
||||||
std::uniform_int_distribution<vtkm::Id> randomDim(2, 20);
|
std::uniform_int_distribution<vtkm::Id> randomDim(2, 20);
|
||||||
|
|
||||||
|
vtkm::Bounds bounds(minReal, maxReal, minReal, maxReal, minReal, maxReal);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
vtkm::Id3 dims(
|
vtkm::Id3 dims(
|
||||||
randomDim(g_RandomGenerator), randomDim(g_RandomGenerator), randomDim(g_RandomGenerator));
|
randomDim(g_RandomGenerator), randomDim(g_RandomGenerator), randomDim(g_RandomGenerator));
|
||||||
vtkm::Id numPoints = dims[0] * dims[1] * dims[2];
|
|
||||||
vtkm::Id numCells = (dims[0] - 1) * (dims[1] - 1) * (dims[2] - 1);
|
|
||||||
std::vector<T> x, y, z;
|
|
||||||
for (vtkm::Id j = 0; j < numPoints; j++)
|
|
||||||
{
|
|
||||||
x.push_back(randomVal(g_RandomGenerator));
|
|
||||||
y.push_back(randomVal(g_RandomGenerator));
|
|
||||||
z.push_back(randomVal(g_RandomGenerator));
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkm::Bounds bounds(minReal, maxReal, minReal, maxReal, minReal, maxReal);
|
vtkm::Id numPoints = 1;
|
||||||
|
vtkm::Id numCells = 1;
|
||||||
|
|
||||||
//test 3d
|
for (int ndim = 0; ndim < 3; ndim++)
|
||||||
{
|
{
|
||||||
auto ds = vtkm::cont::DataSetBuilderCurvilinear::Create(x, y, z, dims);
|
numPoints *= dims[ndim];
|
||||||
AddFields<T>(ds, numPoints, numCells);
|
numCells *= (dims[ndim] - 1);
|
||||||
ValidateDataSet(ds, 3, numPoints, numCells, bounds);
|
|
||||||
}
|
std::vector<T> x, y, z;
|
||||||
//test 2d
|
for (vtkm::Id j = 0; j < numPoints; j++)
|
||||||
{
|
{
|
||||||
auto ds = vtkm::cont::DataSetBuilderCurvilinear::Create(x, y, { dims[0], dims[1] });
|
x.push_back(randomVal(g_RandomGenerator));
|
||||||
AddFields<T>(ds, numPoints, numCells);
|
y.push_back(randomVal(g_RandomGenerator));
|
||||||
ValidateDataSet(ds, 2, numPoints, numCells, bounds);
|
z.push_back(randomVal(g_RandomGenerator));
|
||||||
}
|
}
|
||||||
//test 1d
|
|
||||||
{
|
//test 3d
|
||||||
auto ds = vtkm::cont::DataSetBuilderCurvilinear::Create(x);
|
if (ndim == 2)
|
||||||
AddFields<T>(ds, numPoints, numCells);
|
{
|
||||||
ValidateDataSet(ds, 1, numPoints, numCells, bounds);
|
auto ds = vtkm::cont::DataSetBuilderCurvilinear::Create(x, y, z, dims);
|
||||||
|
AddFields<T>(ds, numPoints, numCells);
|
||||||
|
ValidateDataSet(ds, 3, numPoints, numCells, bounds);
|
||||||
|
}
|
||||||
|
//test 2d
|
||||||
|
else if (ndim == 1)
|
||||||
|
{
|
||||||
|
auto ds = vtkm::cont::DataSetBuilderCurvilinear::Create(x, y, { dims[0], dims[1] });
|
||||||
|
AddFields<T>(ds, numPoints, numCells);
|
||||||
|
ValidateDataSet(ds, 2, numPoints, numCells, bounds);
|
||||||
|
}
|
||||||
|
//test 1d
|
||||||
|
else if (ndim == 0)
|
||||||
|
{
|
||||||
|
auto ds = vtkm::cont::DataSetBuilderCurvilinear::Create(x);
|
||||||
|
AddFields<T>(ds, numPoints, numCells);
|
||||||
|
ValidateDataSet(ds, 1, numPoints, numCells, bounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user