diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 576e5d535..db75fcab0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -168,6 +168,10 @@ upper right. destination. * The `gitlab-push` script also pushes the `master` branch to your fork in GitLab to keep it in sync with the upstream `master`. + * If you have created or modified Git-LFS files, you will need to + push them separately using `git lfs push --all origin`. You will + need developer access to the VTK-m repository do this. If you do + not have developer access, ask the VTK-m group for help. The output will include a link to the topic branch in your fork in GitLab and a link to a page for creating a Merge Request. @@ -580,7 +584,7 @@ To find out if you have local commits on your master branch, check its status: $ git checkout master - $ git status + $ git status If status responds that your branch is up to date or that your branch is _behind_ the `origin/master` remote branch, then everything is fine. (If @@ -595,7 +599,7 @@ branch. $ git branch my-topic - Of course, replace `my-topic` with something that better describes your + Of course, replace `my-topic` with something that better describes your changes. 2. Reset the local master branch to the remote master branch: diff --git a/data/baseline/filter/amrArrays2D.png b/data/baseline/filter/amrArrays2D.png new file mode 100644 index 000000000..bc32f1d96 --- /dev/null +++ b/data/baseline/filter/amrArrays2D.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0994e1747beaddba1ab6e97a48e17956e64a12ebfdffac1c2ae8734f3578956f +size 20716 diff --git a/data/baseline/filter/amrArrays3D.png b/data/baseline/filter/amrArrays3D.png new file mode 100644 index 000000000..bca21202b --- /dev/null +++ b/data/baseline/filter/amrArrays3D.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a610fe2de049c6a2402f7b19ea5a03f2e637e90d62a6df38832e62b89a691bb +size 25953 diff --git a/vtkm/Bounds.h b/vtkm/Bounds.h index b72547e8d..cebb602ae 100644 --- a/vtkm/Bounds.h +++ b/vtkm/Bounds.h @@ -102,6 +102,42 @@ struct Bounds return (this->X.Contains(point[0]) && this->Y.Contains(point[1]) && this->Z.Contains(point[2])); } + /// \b Returns the volume of the bounds. + /// + /// \c Volume computes the product of the lengths of the ranges in each dimension. If the bounds + /// are empty, 0 is returned. + /// + VTKM_EXEC_CONT + vtkm::Float64 Volume() const + { + if (this->IsNonEmpty()) + { + return (this->X.Length() * this->Y.Length() * this->Z.Length()); + } + else + { + return 0.0; + } + } + + /// \b Returns the area of the bounds in the X-Y-plane. + /// + /// \c Area computes the product of the lengths of the ranges in dimensions X and Y. If the bounds + /// are empty, 0 is returned. + /// + VTKM_EXEC_CONT + vtkm::Float64 Area() const + { + if (this->IsNonEmpty()) + { + return (this->X.Length() * this->Y.Length()); + } + else + { + return 0.0; + } + } + /// \b Returns the center of the range. /// /// \c Center computes the point at the middle of the bounds. If the bounds @@ -152,6 +188,16 @@ struct Bounds return unionBounds; } + /// \b Return the intersection of this and another range. + /// + VTKM_EXEC_CONT + vtkm::Bounds Intersection(const vtkm::Bounds& otherBounds) const + { + return vtkm::Bounds(this->X.Intersection(otherBounds.X), + this->Y.Intersection(otherBounds.Y), + this->Z.Intersection(otherBounds.Z)); + } + /// \b Operator for union /// VTKM_EXEC_CONT diff --git a/vtkm/CellClassification.h b/vtkm/CellClassification.h index ccd414695..6ab306c6e 100644 --- a/vtkm/CellClassification.h +++ b/vtkm/CellClassification.h @@ -19,7 +19,7 @@ enum CellClassification : vtkm::UInt8 GHOST = 1 << 0, //Ghost cell INVALID = 1 << 1, //Cell is invalid UNUSED0 = 1 << 2, - UNUSED1 = 1 << 3, + BLANKED = 1 << 3, //Blanked cell in AMR UNUSED3 = 1 << 4, UNUSED4 = 1 << 5, UNUSED5 = 1 << 6, diff --git a/vtkm/Range.h b/vtkm/Range.h index 0be2c3557..27f45e9dc 100644 --- a/vtkm/Range.h +++ b/vtkm/Range.h @@ -153,6 +153,14 @@ struct Range return unionRange; } + /// \b Return the intersection of this and another range. + /// + VTKM_EXEC_CONT + vtkm::Range Intersection(const vtkm::Range& otherRange) const + { + return vtkm::Range(vtkm::Max(this->Min, otherRange.Min), vtkm::Min(this->Max, otherRange.Max)); + } + /// \b Operator for union /// VTKM_EXEC_CONT diff --git a/vtkm/cont/DataSetBuilderExplicit.h b/vtkm/cont/DataSetBuilderExplicit.h index 8450afba9..fa68f257c 100644 --- a/vtkm/cont/DataSetBuilderExplicit.h +++ b/vtkm/cont/DataSetBuilderExplicit.h @@ -10,7 +10,6 @@ #ifndef vtk_m_cont_DataSetBuilderExplicit_h #define vtk_m_cont_DataSetBuilderExplicit_h -#include #include #include #include diff --git a/vtkm/cont/DataSetBuilderRectilinear.h b/vtkm/cont/DataSetBuilderRectilinear.h index d8a716bd4..f5debe7b1 100644 --- a/vtkm/cont/DataSetBuilderRectilinear.h +++ b/vtkm/cont/DataSetBuilderRectilinear.h @@ -10,7 +10,6 @@ #ifndef vtk_m_cont_DataSetBuilderRectilinear_h #define vtk_m_cont_DataSetBuilderRectilinear_h -#include #include #include #include @@ -35,7 +34,7 @@ class VTKM_CONT_EXPORT DataSetBuilderRectilinear VTKM_CONT static void CopyInto(const vtkm::cont::ArrayHandle& input, vtkm::cont::ArrayHandle& output) { - vtkm::cont::ArrayCopy(input, output); + vtkm::cont::UnknownArrayHandle(output).DeepCopyFrom(input); } template diff --git a/vtkm/cont/testing/CMakeLists.txt b/vtkm/cont/testing/CMakeLists.txt index 7c97e0e17..9e8802f8b 100644 --- a/vtkm/cont/testing/CMakeLists.txt +++ b/vtkm/cont/testing/CMakeLists.txt @@ -98,6 +98,7 @@ set(unit_tests ) set(library_sources + MakeTestDataSet.cxx TestEqualArrayHandles.cxx ) diff --git a/vtkm/cont/testing/MakeTestDataSet.cxx b/vtkm/cont/testing/MakeTestDataSet.cxx new file mode 100644 index 000000000..5f7de03b1 --- /dev/null +++ b/vtkm/cont/testing/MakeTestDataSet.cxx @@ -0,0 +1,1520 @@ +//============================================================================ +// 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. +//============================================================================ + +#include +#include +#include +#include +#include +#include + +namespace vtkm +{ +namespace cont +{ +namespace testing +{ + +//Make a simple 1D dataset. +vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet0() +{ + vtkm::cont::DataSetBuilderUniform dsb; + const vtkm::Id nVerts = 6; + vtkm::cont::DataSet dataSet = dsb.Create(nVerts); + + constexpr vtkm::Float32 var[nVerts] = { -1.0f, .5f, -.2f, 1.7f, -.1f, .8f }; + constexpr vtkm::Float32 var2[nVerts] = { -1.1f, .7f, -.2f, 0.2f, -.1f, .4f }; + dataSet.AddPointField("pointvar", var, nVerts); + dataSet.AddPointField("pointvar2", var2, nVerts); + + return dataSet; +} + +//Make another simple 1D dataset. +vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet1() +{ + vtkm::cont::DataSetBuilderUniform dsb; + const vtkm::Id nVerts = 6; + vtkm::cont::DataSet dataSet = dsb.Create(nVerts); + + constexpr vtkm::Float32 var[nVerts] = { 1.0e3f, 5.e5f, 2.e8f, 1.e10f, 2e12f, 3e15f }; + dataSet.AddPointField("pointvar", var, nVerts); + + return dataSet; +} + + +//Make a simple 1D, 16 cell uniform dataset. +vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet2() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id dims = 256; + vtkm::cont::DataSet dataSet = dsb.Create(dims); + + vtkm::Float64 pointvar[dims]; + constexpr vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims - 1); + + vtkm::Id idx = 0; + for (vtkm::Id x = 0; x < dims; ++x) + { + vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi(); + vtkm::Float64 cv = vtkm::Sin(cx); + + pointvar[idx] = cv; + idx++; + } + + dataSet.AddPointField("pointvar", pointvar, dims); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make1DExplicitDataSet0() +{ + const int nVerts = 5; + using CoordType = vtkm::Vec3f_32; + std::vector coords(nVerts); + coords[0] = CoordType(0.0f, 0.f, 0.f); + coords[1] = CoordType(1.0f, 0.f, 0.f); + coords[2] = CoordType(1.1f, 0.f, 0.f); + coords[3] = CoordType(1.2f, 0.f, 0.f); + coords[4] = CoordType(4.0f, 0.f, 0.f); + + // Each line connects two consecutive vertices + std::vector conn; + for (int i = 0; i < nVerts - 1; i++) + { + conn.push_back(i); + conn.push_back(i + 1); + } + + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), 2, conn, "coordinates"); + + constexpr vtkm::Float32 var[nVerts] = { -1.0f, .5f, -.2f, 1.7f, .8f }; + dataSet.AddPointField("pointvar", var, nVerts); + return dataSet; +} + +//Make a simple 2D, 2 cell uniform dataset. +vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet0() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id2 dimensions(3, 2); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr vtkm::Id nVerts = 6; + constexpr vtkm::Float32 var[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f }; + + dataSet.AddPointField("pointvar", var, nVerts); + + constexpr vtkm::Float32 cellvar[2] = { 100.1f, 200.1f }; + dataSet.AddCellField("cellvar", cellvar, 2); + + return dataSet; +} + +//Make a simple 2D, 16 cell uniform dataset (5x5.txt) +vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet1() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id2 dimensions(5, 5); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr vtkm::Id nVerts = 25; + constexpr vtkm::Id nCells = 16; + constexpr vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 1.0f, 94.0f, 71.0f, + 47.0f, 33.0f, 6.0f, 52.0f, 44.0f, 50.0f, 45.0f, + 48.0f, 8.0f, 12.0f, 46.0f, 91.0f, 43.0f, 0.0f, + 5.0f, 51.0f, 76.0f, 83.0f }; + constexpr vtkm::Float32 cellvar[nCells] = { + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f + }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +//Make a simple 2D, 16 cell uniform dataset. +vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet2() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id2 dims(16, 16); + vtkm::cont::DataSet dataSet = dsb.Create(dims); + + constexpr vtkm::Id nVerts = 256; + vtkm::Float64 pointvar[nVerts]; + constexpr vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims[0] - 1); + constexpr vtkm::Float64 dy = vtkm::Float64(2.0 * vtkm::Pi()) / vtkm::Float64(dims[1] - 1); + + vtkm::Id idx = 0; + for (vtkm::Id y = 0; y < dims[1]; ++y) + { + vtkm::Float64 cy = vtkm::Float64(y) * dy - vtkm::Pi(); + for (vtkm::Id x = 0; x < dims[0]; ++x) + { + vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi(); + vtkm::Float64 cv = vtkm::Sin(cx) + vtkm::Sin(cy) + + 2.0 * vtkm::Cos(vtkm::Sqrt((cx * cx) / 2.0 + cy * cy) / 0.75) + + 4.0 * vtkm::Cos(cx * cy / 4.0); + + pointvar[idx] = cv; + idx++; + } + } // y + + dataSet.AddPointField("pointvar", pointvar, nVerts); + + return dataSet; +} + +//Make a simple 2D, 56 cell uniform dataset. (8x9test.txt) +vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet3() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id2 dimensions(9, 8); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr vtkm::Id nVerts = 72; + constexpr vtkm::Float32 pointvar[nVerts] = { + 29.0f, 37.0f, 39.0f, 70.0f, 74.0f, 84.0f, 38.0f, 36.0f, 26.0f, 27.0f, 100.0f, 49.0f, + 72.0f, 85.0f, 89.0f, 83.0f, 28.0f, 24.0f, 25.0f, 47.0f, 50.0f, 73.0f, 86.0f, 90.0f, + 71.0f, 82.0f, 22.0f, 23.0f, 75.0f, 79.0f, 48.0f, 69.0f, 87.0f, 88.0f, 81.0f, 18.0f, + 19.0f, 76.0f, 80.0f, 78.0f, 46.0f, 68.0f, 67.0f, 40.0f, 16.0f, 17.0f, 41.0f, 77.0f, + 45.0f, 35.0f, 20.0f, 21.0f, 32.0f, 15.0f, 13.0f, 42.0f, 43.0f, 44.0f, 34.0f, 33.0f, + 31.0f, 30.0f, 14.0f, 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f, 0.0f + }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + + return dataSet; +} + +//Make a simple 3D, 4 cell uniform dataset. +vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet0() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id3 dimensions(3, 2, 3); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr int nVerts = 18; + constexpr vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.2f, 60.2f, + 70.2f, 80.2f, 90.3f, 100.3f, 110.3f, 120.3f, + 130.4f, 140.4f, 150.4f, 160.4f, 170.5f, 180.5f }; + + //Set point and cell scalar + dataSet.AddPointField("pointvar", vars, nVerts); + + constexpr vtkm::Float32 cellvar[4] = { 100.1f, 100.2f, 100.3f, 100.4f }; + dataSet.AddCellField("cellvar", cellvar, 4); + + return dataSet; +} + +//Make a simple 3D, 64 cell uniform dataset. (5b 5x5x5) +vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet1() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id3 dimensions(5, 5, 5); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr vtkm::Id nVerts = 125; + constexpr vtkm::Id nCells = 64; + constexpr vtkm::Float32 pointvar[nVerts] = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 99.0f, 90.0f, 85.0f, 0.0f, 0.0f, 95.0f, 80.0f, + 95.0f, 0.0f, 0.0f, 85.0f, 90.0f, 99.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 75.0f, 50.0f, 65.0f, 0.0f, 0.0f, 55.0f, 15.0f, + 45.0f, 0.0f, 0.0f, 60.0f, 40.0f, 70.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 97.0f, 87.0f, 82.0f, 0.0f, 0.0f, 92.0f, 77.0f, + 92.0f, 0.0f, 0.0f, 82.0f, 87.0f, 97.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + constexpr vtkm::Float32 cellvar[nCells] = { + 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, + + 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, + 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, + + 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, + 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, + + 48.0f, 49.0f, 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, + 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f, 62.0f, 63.0f + }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet2() +{ + constexpr vtkm::Id base_size = 64; + vtkm::cont::DataSetBuilderUniform dsb; + vtkm::Id3 dimensions(base_size, base_size, base_size); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr vtkm::Id nVerts = base_size * base_size * base_size; + vtkm::Float32* pointvar = new vtkm::Float32[nVerts]; + + for (vtkm::Id z = 0; z < base_size; ++z) + for (vtkm::Id y = 0; y < base_size; ++y) + for (vtkm::Id x = 0; x < base_size; ++x) + { + std::size_t index = static_cast(z * base_size * base_size + y * base_size + x); + pointvar[index] = vtkm::Sqrt(vtkm::Float32(x * x + y * y + z * z)); + } + + dataSet.AddPointField("pointvar", pointvar, nVerts); + + delete[] pointvar; + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet3(const vtkm::Id3 dims) +{ + vtkm::cont::DataSetBuilderUniform dsb; + vtkm::cont::DataSet dataSet = dsb.Create(dims); + + // add point scalar field + vtkm::Id numPoints = dims[0] * dims[1] * dims[2]; + std::vector pointvar(static_cast(numPoints)); + + vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims[0] - 1); + vtkm::Float64 dy = vtkm::Float64(2.0 * vtkm::Pi()) / vtkm::Float64(dims[1] - 1); + vtkm::Float64 dz = vtkm::Float64(3.0 * vtkm::Pi()) / vtkm::Float64(dims[2] - 1); + + vtkm::Id idx = 0; + for (vtkm::Id z = 0; z < dims[2]; ++z) + { + vtkm::Float64 cz = vtkm::Float64(z) * dz - 1.5 * vtkm::Pi(); + for (vtkm::Id y = 0; y < dims[1]; ++y) + { + vtkm::Float64 cy = vtkm::Float64(y) * dy - vtkm::Pi(); + for (vtkm::Id x = 0; x < dims[0]; ++x) + { + vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi(); + vtkm::Float64 cv = vtkm::Sin(cx) + vtkm::Sin(cy) + + 2.0 * vtkm::Cos(vtkm::Sqrt((cx * cx) / 2.0 + cy * cy) / 0.75) + + 4.0 * vtkm::Cos(cx * cy / 4.0); + + if (dims[2] > 1) + { + cv += vtkm::Sin(cz) + 1.5 * vtkm::Cos(vtkm::Sqrt(cx * cx + cy * cy + cz * cz) / 0.75); + } + pointvar[static_cast(idx)] = cv; + idx++; + } + } // y + } // z + + dataSet.AddPointField("pointvar", pointvar); + + vtkm::Id numCells = (dims[0] - 1) * (dims[1] - 1) * (dims[2] - 1); + std::vector cellvar(numCells); + std::iota(cellvar.begin(), cellvar.end(), 0); + dataSet.AddCellField("cellvar", cellvar); + + return dataSet; +} + +//Make a simple 3D, 120 cell uniform dataset. (This is the data set from +//Make3DUniformDataSet1 upsampled from 5x5x to 5x6x7.) +vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet4() +{ + vtkm::cont::DataSetBuilderUniform dsb; + constexpr vtkm::Id3 dimensions(5, 6, 7); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + + constexpr vtkm::Id nVerts = 210; + constexpr vtkm::Float32 pointvar[nVerts] = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.53f, 0.48f, 0.45f, + 0.0f, 0.0f, 0.64f, 0.56f, 0.61f, 0.0f, 0.0f, 0.61f, 0.56f, 0.64f, 0.0f, 0.0f, 0.45f, + 0.48f, 0.53f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.73f, 0.61f, 0.63f, 0.0f, 0.0f, 0.85f, 0.66f, 0.78f, 0.0f, 0.0f, 0.80f, 0.64f, + 0.83f, 0.0f, 0.0f, 0.61f, 0.59f, 0.71f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.60f, 0.40f, 0.53f, 0.0f, 0.0f, 0.63f, 0.29f, 0.53f, + 0.0f, 0.0f, 0.57f, 0.25f, 0.55f, 0.0f, 0.0f, 0.48f, 0.32f, 0.56f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.72f, 0.60f, 0.61f, 0.0f, + 0.0f, 0.84f, 0.64f, 0.76f, 0.0f, 0.0f, 0.78f, 0.62f, 0.81f, 0.0f, 0.0f, 0.60f, 0.57f, + 0.70f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.52f, 0.46f, 0.44f, 0.0f, 0.0f, 0.63f, 0.54f, 0.59f, 0.0f, 0.0f, 0.59f, 0.54f, 0.63f, + 0.0f, 0.0f, 0.44f, 0.46f, 0.52f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f + }; + dataSet.AddPointField("pointvar", pointvar, nVerts); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make2DRectilinearDataSet0() +{ + vtkm::cont::DataSetBuilderRectilinear dsb; + std::vector X(3), Y(2); + + X[0] = 0.0f; + X[1] = 1.0f; + X[2] = 2.0f; + Y[0] = 0.0f; + Y[1] = 1.0f; + + vtkm::cont::DataSet dataSet = dsb.Create(X, Y); + + const vtkm::Id nVerts = 6; + vtkm::Float32 var[nVerts]; + for (int i = 0; i < nVerts; i++) + var[i] = (vtkm::Float32)i; + dataSet.AddPointField("pointvar", var, nVerts); + + const vtkm::Id nCells = 2; + vtkm::Float32 cellvar[nCells]; + for (int i = 0; i < nCells; i++) + cellvar[i] = (vtkm::Float32)i; + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet0() +{ + vtkm::cont::DataSet dataSet; + + const int nVerts = 18; + vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vtkm::Id3(3, 2, 3)); + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.2f, 60.2f, + 70.2f, 80.2f, 90.3f, 100.3f, 110.3f, 120.3f, + 130.4f, 140.4f, 150.4f, 160.4f, 170.5f, 180.5f }; + + dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + vtkm::Float32 cellvar[4] = { 100.1f, 100.2f, 100.3f, 100.4f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 4, vtkm::CopyFlag::On)); + + static constexpr vtkm::IdComponent dim = 3; + vtkm::cont::CellSetStructured cellSet; + cellSet.SetPointDimensions(vtkm::make_Vec(3, 2, 3)); + dataSet.SetCellSet(cellSet); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet1() +{ + vtkm::cont::DataSet dataSet; + + const int nVerts = 8; + vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vtkm::Id3(2, 2, 2)); + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.2f, 60.2f, 70.2f, 80.2f }; + + dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + vtkm::Float32 cellvar[1] = { 100.1f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On)); + + static constexpr vtkm::IdComponent dim = 3; + vtkm::cont::CellSetStructured cellSet; + cellSet.SetPointDimensions(vtkm::make_Vec(2, 2, 2)); + dataSet.SetCellSet(cellSet); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DRectilinearDataSet0() +{ + vtkm::cont::DataSetBuilderRectilinear dsb; + std::vector X(3), Y(2), Z(3); + + X[0] = 0.0f; + X[1] = 1.0f; + X[2] = 2.0f; + Y[0] = 0.0f; + Y[1] = 1.0f; + Z[0] = 0.0f; + Z[1] = 1.0f; + Z[2] = 2.0f; + + vtkm::cont::DataSet dataSet = dsb.Create(X, Y, Z); + + const vtkm::Id nVerts = 18; + vtkm::Float32 var[nVerts]; + for (int i = 0; i < nVerts; i++) + var[i] = (vtkm::Float32)i; + dataSet.AddPointField("pointvar", var, nVerts); + + const vtkm::Id nCells = 4; + vtkm::Float32 cellvar[nCells]; + for (int i = 0; i < nCells; i++) + cellvar[i] = (vtkm::Float32)i; + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +// Make a 2D explicit dataset +vtkm::cont::DataSet MakeTestDataSet::Make2DExplicitDataSet0() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + // Coordinates + const int nVerts = 16; + const int nCells = 7; + using CoordType = vtkm::Vec3f_32; + std::vector coords(nVerts); + + coords[0] = CoordType(0, 0, 0); + coords[1] = CoordType(1, 0, 0); + coords[2] = CoordType(2, 0, 0); + coords[3] = CoordType(3, 0, 0); + coords[4] = CoordType(0, 1, 0); + coords[5] = CoordType(1, 1, 0); + coords[6] = CoordType(2, 1, 0); + coords[7] = CoordType(3, 1, 0); + coords[8] = CoordType(0, 2, 0); + coords[9] = CoordType(1, 2, 0); + coords[10] = CoordType(2, 2, 0); + coords[11] = CoordType(3, 2, 0); + coords[12] = CoordType(0, 3, 0); + coords[13] = CoordType(3, 3, 0); + coords[14] = CoordType(1, 4, 0); + coords[15] = CoordType(2, 4, 0); + + // Connectivity + std::vector shapes; + std::vector numindices; + std::vector conn; + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(0); + conn.push_back(1); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(1); + conn.push_back(2); + conn.push_back(6); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(5); + conn.push_back(6); + conn.push_back(10); + conn.push_back(9); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(4); + conn.push_back(5); + conn.push_back(9); + conn.push_back(8); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(2); + conn.push_back(3); + conn.push_back(7); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(6); + conn.push_back(7); + conn.push_back(11); + conn.push_back(10); + + shapes.push_back(vtkm::CELL_SHAPE_POLYGON); + numindices.push_back(6); + conn.push_back(9); + conn.push_back(10); + conn.push_back(13); + conn.push_back(15); + conn.push_back(14); + conn.push_back(12); + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + // Field data + vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 33.0f, + 52.0f, 44.0f, 50.0f, 45.0f, 8.0f, 12.0f, 46.0f, 91.0f }; + vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet0() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + const int nVerts = 5; + using CoordType = vtkm::Vec3f_32; + std::vector coords(nVerts); + coords[0] = CoordType(0, 0, 0); + coords[1] = CoordType(1, 0, 0); + coords[2] = CoordType(1, 1, 0); + coords[3] = CoordType(2, 1, 0); + coords[4] = CoordType(2, 2, 0); + + //Connectivity + std::vector shapes; + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + + std::vector numindices; + numindices.push_back(3); + numindices.push_back(4); + + std::vector conn; + // First Cell: Triangle + conn.push_back(0); + conn.push_back(1); + conn.push_back(2); + // Second Cell: Quad + conn.push_back(2); + conn.push_back(1); + conn.push_back(3); + conn.push_back(4); + + //Create the dataset. + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f }; + vtkm::Float32 cellvar[2] = { 100.1f, 100.2f }; + + dataSet.AddPointField("pointvar", vars, nVerts); + dataSet.AddCellField("cellvar", cellvar, 2); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + const int nVerts = 5; + using CoordType = vtkm::Vec3f_32; + std::vector coords(nVerts); + + coords[0] = CoordType(0, 0, 0); + coords[1] = CoordType(1, 0, 0); + coords[2] = CoordType(1, 1, 0); + coords[3] = CoordType(2, 1, 0); + coords[4] = CoordType(2, 2, 0); + CoordType coordinates[nVerts] = { CoordType(0, 0, 0), + CoordType(1, 0, 0), + CoordType(1, 1, 0), + CoordType(2, 1, 0), + CoordType(2, 2, 0) }; + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f }; + + dataSet.AddCoordinateSystem( + vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); + vtkm::cont::CellSetExplicit<> cellSet; + cellSet.PrepareToAddCells(2, 7); + cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec(0, 1, 2)); + cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec(2, 1, 3, 4)); + cellSet.CompleteAddingCells(nVerts); + dataSet.SetCellSet(cellSet); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + vtkm::Float32 cellvar[2] = { 100.1f, 100.2f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 2, vtkm::CopyFlag::On)); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet2() +{ + vtkm::cont::DataSet dataSet; + + const int nVerts = 8; + using CoordType = vtkm::Vec3f_32; + CoordType coordinates[nVerts] = { + CoordType(0, 0, 0), // 0 + CoordType(1, 0, 0), // 1 + CoordType(1, 0, 1), // 2 + CoordType(0, 0, 1), // 3 + CoordType(0, 1, 0), // 4 + CoordType(1, 1, 0), // 5 + CoordType(1, 1, 1), // 6 + CoordType(0, 1, 1) // 7 + }; + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, 70.2f, 80.3f }; + + dataSet.AddCoordinateSystem( + vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + vtkm::Float32 cellvar[2] = { 100.1f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On)); + + vtkm::cont::CellSetExplicit<> cellSet; + vtkm::Vec ids; + ids[0] = 0; + ids[1] = 1; + ids[2] = 2; + ids[3] = 3; + ids[4] = 4; + ids[5] = 5; + ids[6] = 6; + ids[7] = 7; + + cellSet.PrepareToAddCells(1, 8); + cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); + cellSet.CompleteAddingCells(nVerts); + + //todo this need to be a reference/shared_ptr style class + dataSet.SetCellSet(cellSet); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet4() +{ + vtkm::cont::DataSet dataSet; + + const int nVerts = 12; + using CoordType = vtkm::Vec3f_32; + CoordType coordinates[nVerts] = { + CoordType(0, 0, 0), //0 + CoordType(1, 0, 0), //1 + CoordType(1, 0, 1), //2 + CoordType(0, 0, 1), //3 + CoordType(0, 1, 0), //4 + CoordType(1, 1, 0), //5 + CoordType(1, 1, 1), //6 + CoordType(0, 1, 1), //7 + CoordType(2, 0, 0), //8 + CoordType(2, 0, 1), //9 + CoordType(2, 1, 1), //10 + CoordType(2, 1, 0) //11 + }; + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, + 70.2f, 80.3f, 90.f, 10.f, 11.f, 12.f }; + + dataSet.AddCoordinateSystem( + vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + vtkm::Float32 cellvar[2] = { 100.1f, 110.f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 2, vtkm::CopyFlag::On)); + + vtkm::cont::CellSetExplicit<> cellSet; + vtkm::Vec ids; + ids[0] = 0; + ids[1] = 4; + ids[2] = 5; + ids[3] = 1; + ids[4] = 3; + ids[5] = 7; + ids[6] = 6; + ids[7] = 2; + + cellSet.PrepareToAddCells(2, 16); + cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); + ids[0] = 1; + ids[1] = 5; + ids[2] = 11; + ids[3] = 8; + ids[4] = 2; + ids[5] = 6; + ids[6] = 10; + ids[7] = 9; + cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); + cellSet.CompleteAddingCells(nVerts); + + //todo this need to be a reference/shared_ptr style class + dataSet.SetCellSet(cellSet); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet3() +{ + vtkm::cont::DataSet dataSet; + + const int nVerts = 4; + using CoordType = vtkm::Vec3f_32; + CoordType coordinates[nVerts] = { + CoordType(0, 0, 0), CoordType(1, 0, 0), CoordType(1, 0, 1), CoordType(0, 1, 0) + }; + vtkm::Float32 vars[nVerts] = { 10.1f, 10.1f, 10.2f, 30.2f }; + + dataSet.AddCoordinateSystem( + vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + vtkm::Float32 cellvar[2] = { 100.1f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On)); + + vtkm::cont::CellSetExplicit<> cellSet; + vtkm::Id4 ids; + ids[0] = 0; + ids[1] = 1; + ids[2] = 2; + ids[3] = 3; + + cellSet.PrepareToAddCells(1, 4); + cellSet.AddCell(vtkm::CELL_SHAPE_TETRA, 4, ids); + cellSet.CompleteAddingCells(nVerts); + + //todo this need to be a reference/shared_ptr style class + dataSet.SetCellSet(cellSet); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet5() +{ + vtkm::cont::DataSet dataSet; + + const int nVerts = 11; + using CoordType = vtkm::Vec3f_32; + CoordType coordinates[nVerts] = { + CoordType(0, 0, 0), //0 + CoordType(1, 0, 0), //1 + CoordType(1, 0, 1), //2 + CoordType(0, 0, 1), //3 + CoordType(0, 1, 0), //4 + CoordType(1, 1, 0), //5 + CoordType(1, 1, 1), //6 + CoordType(0, 1, 1), //7 + CoordType(2, 0.5, 0.5), //8 + CoordType(0, 2, 0), //9 + CoordType(1, 2, 0) //10 + }; + vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, + 70.2f, 80.3f, 90.f, 10.f, 11.f }; + + dataSet.AddCoordinateSystem( + vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); + + //Set point scalar + dataSet.AddField(make_Field( + "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); + + //Set cell scalar + const int nCells = 4; + vtkm::Float32 cellvar[nCells] = { 100.1f, 110.f, 120.2f, 130.5f }; + dataSet.AddField(make_Field( + "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, nCells, vtkm::CopyFlag::On)); + + vtkm::cont::CellSetExplicit<> cellSet; + vtkm::Vec ids; + + cellSet.PrepareToAddCells(nCells, 23); + + ids[0] = 0; + ids[1] = 1; + ids[2] = 5; + ids[3] = 4; + ids[4] = 3; + ids[5] = 2; + ids[6] = 6; + ids[7] = 7; + cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); + + ids[0] = 1; + ids[1] = 5; + ids[2] = 6; + ids[3] = 2; + ids[4] = 8; + cellSet.AddCell(vtkm::CELL_SHAPE_PYRAMID, 5, ids); + + ids[0] = 5; + ids[1] = 8; + ids[2] = 10; + ids[3] = 6; + cellSet.AddCell(vtkm::CELL_SHAPE_TETRA, 4, ids); + + ids[0] = 4; + ids[1] = 7; + ids[2] = 9; + ids[3] = 5; + ids[4] = 6; + ids[5] = 10; + cellSet.AddCell(vtkm::CELL_SHAPE_WEDGE, 6, ids); + + cellSet.CompleteAddingCells(nVerts); + + //todo this need to be a reference/shared_ptr style class + dataSet.SetCellSet(cellSet); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet6() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + // Coordinates + const int nVerts = 8; + const int nCells = 8; + using CoordType = vtkm::Vec3f_32; + std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, + { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, + { 10.0f, 10.0f, 10.0f }, { 5.0f, 5.0f, 5.0f }, + { 0.0f, 0.0f, 2.0f }, { 0.0f, 0.0f, -2.0f } }; + + // Connectivity + std::vector shapes; + std::vector numindices; + std::vector conn; + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(0); + conn.push_back(1); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(2); + conn.push_back(3); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(4); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(2); + conn.push_back(3); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(0); + conn.push_back(1); + conn.push_back(2); + conn.push_back(3); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(0); + conn.push_back(2); + conn.push_back(3); + conn.push_back(6); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(3); + conn.push_back(2); + conn.push_back(0); + conn.push_back(7); + + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + // Field data + vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f }; + vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetZoo() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + // Coordinates + constexpr int nVerts = 30; + constexpr int nCells = 25; + using CoordType = vtkm::Vec3f_32; + + std::vector coords = + + { { 0.00f, 0.00f, 0.00f }, { 1.00f, 0.00f, 0.00f }, { 2.00f, 0.00f, 0.00f }, + { 0.00f, 0.00f, 1.00f }, { 1.00f, 0.00f, 1.00f }, { 2.00f, 0.00f, 1.00f }, + { 0.00f, 1.00f, 0.00f }, { 1.00f, 1.00f, 0.00f }, { 2.00f, 1.00f, 0.00f }, + { 0.00f, 1.00f, 1.00f }, { 1.00f, 1.00f, 1.00f }, { 2.00f, 1.00f, 1.00f }, + { 0.00f, 2.00f, 0.00f }, { 1.00f, 2.00f, 0.00f }, { 2.00f, 2.00f, 0.00f }, + { 0.00f, 2.00f, 1.00f }, { 1.00f, 2.00f, 1.00f }, { 2.00f, 2.00f, 1.00f }, + { 1.00f, 3.00f, 1.00f }, { 2.75f, 0.00f, 1.00f }, { 3.00f, 0.00f, 0.75f }, + { 3.00f, 0.25f, 1.00f }, { 3.00f, 1.00f, 1.00f }, { 3.00f, 1.00f, 0.00f }, + { 2.57f, 2.00f, 1.00f }, { 3.00f, 1.75f, 1.00f }, { 3.00f, 1.75f, 0.75f }, + { 3.00f, 0.00f, 0.00f }, { 2.57f, 0.42f, 0.57f }, { 2.59f, 1.43f, 0.71f } }; + + // Connectivity + std::vector shapes; + std::vector numindices; + std::vector conn; + + shapes.push_back(vtkm::CELL_SHAPE_HEXAHEDRON); + numindices.push_back(8); + conn.push_back(0); + conn.push_back(3); + conn.push_back(4); + conn.push_back(1); + conn.push_back(6); + conn.push_back(9); + conn.push_back(10); + conn.push_back(7); + + shapes.push_back(vtkm::CELL_SHAPE_HEXAHEDRON); + numindices.push_back(8); + conn.push_back(1); + conn.push_back(4); + conn.push_back(5); + conn.push_back(2); + conn.push_back(7); + conn.push_back(10); + conn.push_back(11); + conn.push_back(8); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(23); + conn.push_back(26); + conn.push_back(24); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(24); + conn.push_back(26); + conn.push_back(25); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(8); + conn.push_back(17); + conn.push_back(11); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(17); + conn.push_back(24); + conn.push_back(25); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(24); + conn.push_back(17); + conn.push_back(8); + conn.push_back(23); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(23); + conn.push_back(8); + conn.push_back(11); + conn.push_back(22); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(25); + conn.push_back(22); + conn.push_back(11); + conn.push_back(17); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(26); + conn.push_back(23); + conn.push_back(22); + conn.push_back(25); + conn.push_back(29); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(23); + conn.push_back(8); + conn.push_back(2); + conn.push_back(27); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(22); + conn.push_back(11); + conn.push_back(8); + conn.push_back(23); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(11); + conn.push_back(5); + conn.push_back(2); + conn.push_back(8); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(21); + conn.push_back(19); + conn.push_back(5); + conn.push_back(11); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(11); + conn.push_back(22); + conn.push_back(21); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(5); + conn.push_back(19); + conn.push_back(20); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(23); + conn.push_back(27); + conn.push_back(20); + conn.push_back(21); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(20); + conn.push_back(27); + conn.push_back(2); + conn.push_back(5); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(19); + conn.push_back(21); + conn.push_back(20); + conn.push_back(28); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(7); + conn.push_back(6); + conn.push_back(12); + conn.push_back(13); + conn.push_back(16); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(6); + conn.push_back(9); + conn.push_back(15); + conn.push_back(12); + conn.push_back(16); + + shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); + numindices.push_back(5); + conn.push_back(6); + conn.push_back(7); + conn.push_back(10); + conn.push_back(9); + conn.push_back(16); + + shapes.push_back(vtkm::CELL_SHAPE_TETRA); + numindices.push_back(4); + conn.push_back(12); + conn.push_back(15); + conn.push_back(16); + conn.push_back(18); + + shapes.push_back(vtkm::CELL_SHAPE_WEDGE); + numindices.push_back(6); + conn.push_back(8); + conn.push_back(14); + conn.push_back(17); + conn.push_back(7); + conn.push_back(13); + conn.push_back(16); + + shapes.push_back(vtkm::CELL_SHAPE_WEDGE); + numindices.push_back(6); + conn.push_back(11); + conn.push_back(8); + conn.push_back(17); + conn.push_back(10); + conn.push_back(7); + conn.push_back(16); + + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + // Field data + vtkm::Float32 pointvar[nVerts] = + + { 4.0, 5.0f, 9.5f, 5.5f, 6.0f, 9.5f, 5.0f, 5.5f, 5.7f, 6.5f, 6.4f, 6.9f, 6.6f, 6.1f, 7.1f, + 7.2f, 7.3f, 7.4f, 9.1f, 9.2f, 9.3f, 5.4f, 9.5f, 9.6f, 6.7f, 9.8f, 6.0f, 4.3f, 4.9f, 4.1f }; + + vtkm::Float32 cellvar[nCells] = + + { 4.0f, 5.0f, 9.5f, 5.5f, 6.0f, 9.5f, 5.0f, 5.5f, 5.7f, 6.5f, 6.4f, 6.9f, 6.6f, + 6.1f, 7.1f, 7.2f, 7.3f, 7.4f, 9.1f, 9.2f, 9.3f, 5.4f, 9.5f, 9.6f, 6.7f }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet7() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + // Coordinates + const int nVerts = 8; + const int nCells = 8; + + using CoordType = vtkm::Vec3f_32; + std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, + { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, + { 10.0f, 10.0f, 10.0f }, { 5.0f, 5.0f, 5.0f }, + { 0.0f, 0.0f, 2.0f }, { 0.0f, 0.0f, -2.0f } }; + + // Connectivity + std::vector shapes; + std::vector numindices; + std::vector conn; + + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(0); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(1); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(2); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(3); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(4); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(6); + + shapes.push_back(vtkm::CELL_SHAPE_VERTEX); + numindices.push_back(1); + conn.push_back(7); + + + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + // Field data + vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 10.f, 20.f, 33.f, 52.f }; + vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet8() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + // Coordinates + const int nVerts = 8; + const int nCells = 10; + using CoordType = vtkm::Vec3f_32; + std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, + { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, + { 10.0f, 10.0f, 10.0f }, { 5.0f, 5.0f, 5.0f }, + { 0.0f, 0.0f, 2.0f }, { 0.0f, 0.0f, -2.0f } }; + + // Connectivity + std::vector shapes; + std::vector numindices; + std::vector conn; + + //I need two triangles because the leaf needs four nodes otherwise segfault? + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(0); + conn.push_back(1); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(1); + conn.push_back(2); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(2); + conn.push_back(3); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(3); + conn.push_back(4); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(4); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(5); + conn.push_back(6); + + shapes.push_back(vtkm::CELL_SHAPE_LINE); + numindices.push_back(2); + conn.push_back(6); + conn.push_back(7); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(2); + conn.push_back(5); + conn.push_back(4); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(4); + conn.push_back(5); + conn.push_back(6); + + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + // Field data + vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f }; + vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetPolygonal() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; + + // Coordinates + const int nVerts = 8; + const int nCells = 8; + using CoordType = vtkm::Vec3f_32; + std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, + { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, + { 0.000f, 0.146f, -0.854f }, { 0.000f, 0.854f, -0.146f }, + { 0.707f, 0.354f, 0.354f }, { 0.707f, -0.354f, -0.354f } }; + + // Connectivity + std::vector shapes; + std::vector numindices; + std::vector conn; + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(0); + conn.push_back(1); + conn.push_back(3); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(1); + conn.push_back(2); + conn.push_back(3); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(4); + conn.push_back(5); + conn.push_back(6); + conn.push_back(7); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(0); + conn.push_back(4); + conn.push_back(1); + + shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); + numindices.push_back(3); + conn.push_back(4); + conn.push_back(7); + conn.push_back(1); + + shapes.push_back(vtkm::CELL_SHAPE_POLYGON); + numindices.push_back(4); + conn.push_back(3); + conn.push_back(2); + conn.push_back(6); + conn.push_back(5); + + shapes.push_back(vtkm::CELL_SHAPE_QUAD); + numindices.push_back(4); + conn.push_back(0); + conn.push_back(3); + conn.push_back(5); + conn.push_back(4); + + shapes.push_back(vtkm::CELL_SHAPE_POLYGON); + numindices.push_back(4); + conn.push_back(1); + conn.push_back(7); + conn.push_back(6); + conn.push_back(2); + + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); + + // Field data + vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 33.0f }; + vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; + + dataSet.AddPointField("pointvar", pointvar, nVerts); + dataSet.AddCellField("cellvar", cellvar, nCells); + + return dataSet; +} + +vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetCowNose() +{ + // prepare data array + const int nVerts = 17; + using CoordType = vtkm::Vec3f_64; + CoordType coordinates[nVerts] = { + CoordType(0.0480879, 0.151874, 0.107334), CoordType(0.0293568, 0.245532, 0.125337), + CoordType(0.0224398, 0.246495, 0.1351), CoordType(0.0180085, 0.20436, 0.145316), + CoordType(0.0307091, 0.152142, 0.0539249), CoordType(0.0270341, 0.242992, 0.107567), + CoordType(0.000684071, 0.00272505, 0.175648), CoordType(0.00946217, 0.077227, 0.187097), + CoordType(-0.000168991, 0.0692243, 0.200755), CoordType(-0.000129414, 0.00247137, 0.176561), + CoordType(0.0174172, 0.137124, 0.124553), CoordType(0.00325994, 0.0797155, 0.184912), + CoordType(0.00191765, 0.00589327, 0.16608), CoordType(0.0174716, 0.0501928, 0.0930275), + CoordType(0.0242103, 0.250062, 0.126256), CoordType(0.0108188, 0.152774, 0.167914), + CoordType(5.41687e-05, 0.00137834, 0.175119) + }; + const int connectivitySize = 57; + vtkm::Id pointId[connectivitySize] = { 0, 1, 3, 2, 3, 1, 4, 5, 0, 1, 0, 5, 7, 8, 6, + 9, 6, 8, 0, 10, 7, 11, 7, 10, 0, 6, 13, 12, 13, 6, + 1, 5, 14, 1, 14, 2, 0, 3, 15, 0, 13, 4, 6, 16, 12, + 6, 9, 16, 7, 11, 8, 0, 15, 10, 7, 6, 0 }; + + // create DataSet + vtkm::cont::DataSet dataSet; + dataSet.AddCoordinateSystem( + vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); + + vtkm::cont::ArrayHandle connectivity; + connectivity.Allocate(connectivitySize); + + for (vtkm::Id i = 0; i < connectivitySize; ++i) + { + connectivity.WritePortal().Set(i, pointId[i]); + } + vtkm::cont::CellSetSingleType<> cellSet; + cellSet.Fill(nVerts, vtkm::CELL_SHAPE_TRIANGLE, 3, connectivity); + dataSet.SetCellSet(cellSet); + + std::vector pointvar(nVerts); + std::iota(pointvar.begin(), pointvar.end(), 15.f); + std::vector cellvar(connectivitySize / 3); + std::iota(cellvar.begin(), cellvar.end(), 132.f); + + vtkm::cont::ArrayHandle pointvec; + pointvec.Allocate(nVerts); + SetPortal(pointvec.WritePortal()); + + vtkm::cont::ArrayHandle cellvec; + cellvec.Allocate(connectivitySize / 3); + SetPortal(cellvec.WritePortal()); + + dataSet.AddPointField("pointvar", pointvar); + dataSet.AddCellField("cellvar", cellvar); + dataSet.AddPointField("point_vectors", pointvec); + dataSet.AddCellField("cell_vectors", cellvec); + + return dataSet; +} + +} // namespace testing +} // namespace cont +} // namespace vtkm diff --git a/vtkm/cont/testing/MakeTestDataSet.h b/vtkm/cont/testing/MakeTestDataSet.h index 4716580c6..6c3919c5a 100644 --- a/vtkm/cont/testing/MakeTestDataSet.h +++ b/vtkm/cont/testing/MakeTestDataSet.h @@ -11,13 +11,9 @@ #ifndef vtk_m_cont_testing_MakeTestDataSet_h #define vtk_m_cont_testing_MakeTestDataSet_h -#include #include -#include -#include -#include - #include +#include #include @@ -28,7 +24,7 @@ namespace cont namespace testing { -class MakeTestDataSet +class VTKM_CONT_TESTING_EXPORT MakeTestDataSet { public: // 1D uniform datasets. @@ -78,1501 +74,8 @@ public: vtkm::cont::DataSet Make3DExplicitDataSetCowNose(); }; -//Make a simple 1D dataset. -inline vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet0() -{ - vtkm::cont::DataSetBuilderUniform dsb; - const vtkm::Id nVerts = 6; - vtkm::cont::DataSet dataSet = dsb.Create(nVerts); - - constexpr vtkm::Float32 var[nVerts] = { -1.0f, .5f, -.2f, 1.7f, -.1f, .8f }; - constexpr vtkm::Float32 var2[nVerts] = { -1.1f, .7f, -.2f, 0.2f, -.1f, .4f }; - dataSet.AddPointField("pointvar", var, nVerts); - dataSet.AddPointField("pointvar2", var2, nVerts); - - return dataSet; -} - -//Make another simple 1D dataset. -inline vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet1() -{ - vtkm::cont::DataSetBuilderUniform dsb; - const vtkm::Id nVerts = 6; - vtkm::cont::DataSet dataSet = dsb.Create(nVerts); - - constexpr vtkm::Float32 var[nVerts] = { 1.0e3f, 5.e5f, 2.e8f, 1.e10f, 2e12f, 3e15f }; - dataSet.AddPointField("pointvar", var, nVerts); - - return dataSet; -} - - -//Make a simple 1D, 16 cell uniform dataset. -inline vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet2() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id dims = 256; - vtkm::cont::DataSet dataSet = dsb.Create(dims); - - vtkm::Float64 pointvar[dims]; - constexpr vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims - 1); - - vtkm::Id idx = 0; - for (vtkm::Id x = 0; x < dims; ++x) - { - vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi(); - vtkm::Float64 cv = vtkm::Sin(cx); - - pointvar[idx] = cv; - idx++; - } - - dataSet.AddPointField("pointvar", pointvar, dims); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make1DExplicitDataSet0() -{ - const int nVerts = 5; - using CoordType = vtkm::Vec3f_32; - std::vector coords(nVerts); - coords[0] = CoordType(0.0f, 0.f, 0.f); - coords[1] = CoordType(1.0f, 0.f, 0.f); - coords[2] = CoordType(1.1f, 0.f, 0.f); - coords[3] = CoordType(1.2f, 0.f, 0.f); - coords[4] = CoordType(4.0f, 0.f, 0.f); - - // Each line connects two consecutive vertices - std::vector conn; - for (int i = 0; i < nVerts - 1; i++) - { - conn.push_back(i); - conn.push_back(i + 1); - } - - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), 2, conn, "coordinates"); - - constexpr vtkm::Float32 var[nVerts] = { -1.0f, .5f, -.2f, 1.7f, .8f }; - dataSet.AddPointField("pointvar", var, nVerts); - return dataSet; -} - -//Make a simple 2D, 2 cell uniform dataset. -inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet0() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id2 dimensions(3, 2); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr vtkm::Id nVerts = 6; - constexpr vtkm::Float32 var[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f }; - - dataSet.AddPointField("pointvar", var, nVerts); - - constexpr vtkm::Float32 cellvar[2] = { 100.1f, 200.1f }; - dataSet.AddCellField("cellvar", cellvar, 2); - - return dataSet; -} - -//Make a simple 2D, 16 cell uniform dataset (5x5.txt) -inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet1() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id2 dimensions(5, 5); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr vtkm::Id nVerts = 25; - constexpr vtkm::Id nCells = 16; - constexpr vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 1.0f, 94.0f, 71.0f, - 47.0f, 33.0f, 6.0f, 52.0f, 44.0f, 50.0f, 45.0f, - 48.0f, 8.0f, 12.0f, 46.0f, 91.0f, 43.0f, 0.0f, - 5.0f, 51.0f, 76.0f, 83.0f }; - constexpr vtkm::Float32 cellvar[nCells] = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, - 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f - }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -//Make a simple 2D, 16 cell uniform dataset. -inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet2() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id2 dims(16, 16); - vtkm::cont::DataSet dataSet = dsb.Create(dims); - - constexpr vtkm::Id nVerts = 256; - vtkm::Float64 pointvar[nVerts]; - constexpr vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims[0] - 1); - constexpr vtkm::Float64 dy = vtkm::Float64(2.0 * vtkm::Pi()) / vtkm::Float64(dims[1] - 1); - - vtkm::Id idx = 0; - for (vtkm::Id y = 0; y < dims[1]; ++y) - { - vtkm::Float64 cy = vtkm::Float64(y) * dy - vtkm::Pi(); - for (vtkm::Id x = 0; x < dims[0]; ++x) - { - vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi(); - vtkm::Float64 cv = vtkm::Sin(cx) + vtkm::Sin(cy) + - 2.0 * vtkm::Cos(vtkm::Sqrt((cx * cx) / 2.0 + cy * cy) / 0.75) + - 4.0 * vtkm::Cos(cx * cy / 4.0); - - pointvar[idx] = cv; - idx++; - } - } // y - - dataSet.AddPointField("pointvar", pointvar, nVerts); - - return dataSet; -} - -//Make a simple 2D, 56 cell uniform dataset. (8x9test.txt) -inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet3() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id2 dimensions(9, 8); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr vtkm::Id nVerts = 72; - constexpr vtkm::Float32 pointvar[nVerts] = { - 29.0f, 37.0f, 39.0f, 70.0f, 74.0f, 84.0f, 38.0f, 36.0f, 26.0f, 27.0f, 100.0f, 49.0f, - 72.0f, 85.0f, 89.0f, 83.0f, 28.0f, 24.0f, 25.0f, 47.0f, 50.0f, 73.0f, 86.0f, 90.0f, - 71.0f, 82.0f, 22.0f, 23.0f, 75.0f, 79.0f, 48.0f, 69.0f, 87.0f, 88.0f, 81.0f, 18.0f, - 19.0f, 76.0f, 80.0f, 78.0f, 46.0f, 68.0f, 67.0f, 40.0f, 16.0f, 17.0f, 41.0f, 77.0f, - 45.0f, 35.0f, 20.0f, 21.0f, 32.0f, 15.0f, 13.0f, 42.0f, 43.0f, 44.0f, 34.0f, 33.0f, - 31.0f, 30.0f, 14.0f, 12.0f, 11.0f, 10.0f, 9.0f, 8.0f, 7.0f, 6.0f, 5.0f, 0.0f - }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - - return dataSet; -} - -//Make a simple 3D, 4 cell uniform dataset. -inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet0() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id3 dimensions(3, 2, 3); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr int nVerts = 18; - constexpr vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.2f, 60.2f, - 70.2f, 80.2f, 90.3f, 100.3f, 110.3f, 120.3f, - 130.4f, 140.4f, 150.4f, 160.4f, 170.5f, 180.5f }; - - //Set point and cell scalar - dataSet.AddPointField("pointvar", vars, nVerts); - - constexpr vtkm::Float32 cellvar[4] = { 100.1f, 100.2f, 100.3f, 100.4f }; - dataSet.AddCellField("cellvar", cellvar, 4); - - return dataSet; -} - -//Make a simple 3D, 64 cell uniform dataset. (5b 5x5x5) -inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet1() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id3 dimensions(5, 5, 5); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr vtkm::Id nVerts = 125; - constexpr vtkm::Id nCells = 64; - constexpr vtkm::Float32 pointvar[nVerts] = { - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 99.0f, 90.0f, 85.0f, 0.0f, 0.0f, 95.0f, 80.0f, - 95.0f, 0.0f, 0.0f, 85.0f, 90.0f, 99.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 75.0f, 50.0f, 65.0f, 0.0f, 0.0f, 55.0f, 15.0f, - 45.0f, 0.0f, 0.0f, 60.0f, 40.0f, 70.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 97.0f, 87.0f, 82.0f, 0.0f, 0.0f, 92.0f, 77.0f, - 92.0f, 0.0f, 0.0f, 82.0f, 87.0f, 97.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f - }; - constexpr vtkm::Float32 cellvar[nCells] = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, - 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, - - 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, - 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, - - 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, - 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, - - 48.0f, 49.0f, 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, - 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f, 62.0f, 63.0f - }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet2() -{ - constexpr vtkm::Id base_size = 64; - vtkm::cont::DataSetBuilderUniform dsb; - vtkm::Id3 dimensions(base_size, base_size, base_size); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr vtkm::Id nVerts = base_size * base_size * base_size; - vtkm::Float32* pointvar = new vtkm::Float32[nVerts]; - - for (vtkm::Id z = 0; z < base_size; ++z) - for (vtkm::Id y = 0; y < base_size; ++y) - for (vtkm::Id x = 0; x < base_size; ++x) - { - std::size_t index = static_cast(z * base_size * base_size + y * base_size + x); - pointvar[index] = vtkm::Sqrt(vtkm::Float32(x * x + y * y + z * z)); - } - - dataSet.AddPointField("pointvar", pointvar, nVerts); - - delete[] pointvar; - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet3(const vtkm::Id3 dims) -{ - vtkm::cont::DataSetBuilderUniform dsb; - vtkm::cont::DataSet dataSet = dsb.Create(dims); - - // add point scalar field - vtkm::Id numPoints = dims[0] * dims[1] * dims[2]; - std::vector pointvar(static_cast(numPoints)); - - vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims[0] - 1); - vtkm::Float64 dy = vtkm::Float64(2.0 * vtkm::Pi()) / vtkm::Float64(dims[1] - 1); - vtkm::Float64 dz = vtkm::Float64(3.0 * vtkm::Pi()) / vtkm::Float64(dims[2] - 1); - - vtkm::Id idx = 0; - for (vtkm::Id z = 0; z < dims[2]; ++z) - { - vtkm::Float64 cz = vtkm::Float64(z) * dz - 1.5 * vtkm::Pi(); - for (vtkm::Id y = 0; y < dims[1]; ++y) - { - vtkm::Float64 cy = vtkm::Float64(y) * dy - vtkm::Pi(); - for (vtkm::Id x = 0; x < dims[0]; ++x) - { - vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi(); - vtkm::Float64 cv = vtkm::Sin(cx) + vtkm::Sin(cy) + - 2.0 * vtkm::Cos(vtkm::Sqrt((cx * cx) / 2.0 + cy * cy) / 0.75) + - 4.0 * vtkm::Cos(cx * cy / 4.0); - - if (dims[2] > 1) - { - cv += vtkm::Sin(cz) + 1.5 * vtkm::Cos(vtkm::Sqrt(cx * cx + cy * cy + cz * cz) / 0.75); - } - pointvar[static_cast(idx)] = cv; - idx++; - } - } // y - } // z - - dataSet.AddPointField("pointvar", pointvar); - - vtkm::Id numCells = (dims[0] - 1) * (dims[1] - 1) * (dims[2] - 1); - vtkm::cont::ArrayHandle cellvar; - vtkm::cont::ArrayCopy( - vtkm::cont::make_ArrayHandleCounting(vtkm::Float64(0), vtkm::Float64(1), numCells), cellvar); - dataSet.AddCellField("cellvar", cellvar); - - return dataSet; -} - -//Make a simple 3D, 120 cell uniform dataset. (This is the data set from -//Make3DUniformDataSet1 upsampled from 5x5x to 5x6x7.) -inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet4() -{ - vtkm::cont::DataSetBuilderUniform dsb; - constexpr vtkm::Id3 dimensions(5, 6, 7); - vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - - constexpr vtkm::Id nVerts = 210; - constexpr vtkm::Float32 pointvar[nVerts] = { - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.53f, 0.48f, 0.45f, - 0.0f, 0.0f, 0.64f, 0.56f, 0.61f, 0.0f, 0.0f, 0.61f, 0.56f, 0.64f, 0.0f, 0.0f, 0.45f, - 0.48f, 0.53f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.73f, 0.61f, 0.63f, 0.0f, 0.0f, 0.85f, 0.66f, 0.78f, 0.0f, 0.0f, 0.80f, 0.64f, - 0.83f, 0.0f, 0.0f, 0.61f, 0.59f, 0.71f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.60f, 0.40f, 0.53f, 0.0f, 0.0f, 0.63f, 0.29f, 0.53f, - 0.0f, 0.0f, 0.57f, 0.25f, 0.55f, 0.0f, 0.0f, 0.48f, 0.32f, 0.56f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.72f, 0.60f, 0.61f, 0.0f, - 0.0f, 0.84f, 0.64f, 0.76f, 0.0f, 0.0f, 0.78f, 0.62f, 0.81f, 0.0f, 0.0f, 0.60f, 0.57f, - 0.70f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.52f, 0.46f, 0.44f, 0.0f, 0.0f, 0.63f, 0.54f, 0.59f, 0.0f, 0.0f, 0.59f, 0.54f, 0.63f, - 0.0f, 0.0f, 0.44f, 0.46f, 0.52f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f - }; - dataSet.AddPointField("pointvar", pointvar, nVerts); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make2DRectilinearDataSet0() -{ - vtkm::cont::DataSetBuilderRectilinear dsb; - std::vector X(3), Y(2); - - X[0] = 0.0f; - X[1] = 1.0f; - X[2] = 2.0f; - Y[0] = 0.0f; - Y[1] = 1.0f; - - vtkm::cont::DataSet dataSet = dsb.Create(X, Y); - - const vtkm::Id nVerts = 6; - vtkm::Float32 var[nVerts]; - for (int i = 0; i < nVerts; i++) - var[i] = (vtkm::Float32)i; - dataSet.AddPointField("pointvar", var, nVerts); - - const vtkm::Id nCells = 2; - vtkm::Float32 cellvar[nCells]; - for (int i = 0; i < nCells; i++) - cellvar[i] = (vtkm::Float32)i; - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet0() -{ - vtkm::cont::DataSet dataSet; - - const int nVerts = 18; - vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vtkm::Id3(3, 2, 3)); - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.2f, 60.2f, - 70.2f, 80.2f, 90.3f, 100.3f, 110.3f, 120.3f, - 130.4f, 140.4f, 150.4f, 160.4f, 170.5f, 180.5f }; - - dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - vtkm::Float32 cellvar[4] = { 100.1f, 100.2f, 100.3f, 100.4f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 4, vtkm::CopyFlag::On)); - - static constexpr vtkm::IdComponent dim = 3; - vtkm::cont::CellSetStructured cellSet; - cellSet.SetPointDimensions(vtkm::make_Vec(3, 2, 3)); - dataSet.SetCellSet(cellSet); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet1() -{ - vtkm::cont::DataSet dataSet; - - const int nVerts = 8; - vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vtkm::Id3(2, 2, 2)); - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.1f, 40.1f, 50.2f, 60.2f, 70.2f, 80.2f }; - - dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates)); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - vtkm::Float32 cellvar[1] = { 100.1f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On)); - - static constexpr vtkm::IdComponent dim = 3; - vtkm::cont::CellSetStructured cellSet; - cellSet.SetPointDimensions(vtkm::make_Vec(2, 2, 2)); - dataSet.SetCellSet(cellSet); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DRectilinearDataSet0() -{ - vtkm::cont::DataSetBuilderRectilinear dsb; - std::vector X(3), Y(2), Z(3); - - X[0] = 0.0f; - X[1] = 1.0f; - X[2] = 2.0f; - Y[0] = 0.0f; - Y[1] = 1.0f; - Z[0] = 0.0f; - Z[1] = 1.0f; - Z[2] = 2.0f; - - vtkm::cont::DataSet dataSet = dsb.Create(X, Y, Z); - - const vtkm::Id nVerts = 18; - vtkm::Float32 var[nVerts]; - for (int i = 0; i < nVerts; i++) - var[i] = (vtkm::Float32)i; - dataSet.AddPointField("pointvar", var, nVerts); - - const vtkm::Id nCells = 4; - vtkm::Float32 cellvar[nCells]; - for (int i = 0; i < nCells; i++) - cellvar[i] = (vtkm::Float32)i; - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -// Make a 2D explicit dataset -inline vtkm::cont::DataSet MakeTestDataSet::Make2DExplicitDataSet0() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - // Coordinates - const int nVerts = 16; - const int nCells = 7; - using CoordType = vtkm::Vec3f_32; - std::vector coords(nVerts); - - coords[0] = CoordType(0, 0, 0); - coords[1] = CoordType(1, 0, 0); - coords[2] = CoordType(2, 0, 0); - coords[3] = CoordType(3, 0, 0); - coords[4] = CoordType(0, 1, 0); - coords[5] = CoordType(1, 1, 0); - coords[6] = CoordType(2, 1, 0); - coords[7] = CoordType(3, 1, 0); - coords[8] = CoordType(0, 2, 0); - coords[9] = CoordType(1, 2, 0); - coords[10] = CoordType(2, 2, 0); - coords[11] = CoordType(3, 2, 0); - coords[12] = CoordType(0, 3, 0); - coords[13] = CoordType(3, 3, 0); - coords[14] = CoordType(1, 4, 0); - coords[15] = CoordType(2, 4, 0); - - // Connectivity - std::vector shapes; - std::vector numindices; - std::vector conn; - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(0); - conn.push_back(1); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(1); - conn.push_back(2); - conn.push_back(6); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(5); - conn.push_back(6); - conn.push_back(10); - conn.push_back(9); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(4); - conn.push_back(5); - conn.push_back(9); - conn.push_back(8); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(2); - conn.push_back(3); - conn.push_back(7); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(6); - conn.push_back(7); - conn.push_back(11); - conn.push_back(10); - - shapes.push_back(vtkm::CELL_SHAPE_POLYGON); - numindices.push_back(6); - conn.push_back(9); - conn.push_back(10); - conn.push_back(13); - conn.push_back(15); - conn.push_back(14); - conn.push_back(12); - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - // Field data - vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 33.0f, - 52.0f, 44.0f, 50.0f, 45.0f, 8.0f, 12.0f, 46.0f, 91.0f }; - vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet0() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - const int nVerts = 5; - using CoordType = vtkm::Vec3f_32; - std::vector coords(nVerts); - coords[0] = CoordType(0, 0, 0); - coords[1] = CoordType(1, 0, 0); - coords[2] = CoordType(1, 1, 0); - coords[3] = CoordType(2, 1, 0); - coords[4] = CoordType(2, 2, 0); - - //Connectivity - std::vector shapes; - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - - std::vector numindices; - numindices.push_back(3); - numindices.push_back(4); - - std::vector conn; - // First Cell: Triangle - conn.push_back(0); - conn.push_back(1); - conn.push_back(2); - // Second Cell: Quad - conn.push_back(2); - conn.push_back(1); - conn.push_back(3); - conn.push_back(4); - - //Create the dataset. - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f }; - vtkm::Float32 cellvar[2] = { 100.1f, 100.2f }; - - dataSet.AddPointField("pointvar", vars, nVerts); - dataSet.AddCellField("cellvar", cellvar, 2); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - const int nVerts = 5; - using CoordType = vtkm::Vec3f_32; - std::vector coords(nVerts); - - coords[0] = CoordType(0, 0, 0); - coords[1] = CoordType(1, 0, 0); - coords[2] = CoordType(1, 1, 0); - coords[3] = CoordType(2, 1, 0); - coords[4] = CoordType(2, 2, 0); - CoordType coordinates[nVerts] = { CoordType(0, 0, 0), - CoordType(1, 0, 0), - CoordType(1, 1, 0), - CoordType(2, 1, 0), - CoordType(2, 2, 0) }; - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f }; - - dataSet.AddCoordinateSystem( - vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); - vtkm::cont::CellSetExplicit<> cellSet; - cellSet.PrepareToAddCells(2, 7); - cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec(0, 1, 2)); - cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec(2, 1, 3, 4)); - cellSet.CompleteAddingCells(nVerts); - dataSet.SetCellSet(cellSet); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - vtkm::Float32 cellvar[2] = { 100.1f, 100.2f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 2, vtkm::CopyFlag::On)); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet2() -{ - vtkm::cont::DataSet dataSet; - - const int nVerts = 8; - using CoordType = vtkm::Vec3f_32; - CoordType coordinates[nVerts] = { - CoordType(0, 0, 0), // 0 - CoordType(1, 0, 0), // 1 - CoordType(1, 0, 1), // 2 - CoordType(0, 0, 1), // 3 - CoordType(0, 1, 0), // 4 - CoordType(1, 1, 0), // 5 - CoordType(1, 1, 1), // 6 - CoordType(0, 1, 1) // 7 - }; - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, 70.2f, 80.3f }; - - dataSet.AddCoordinateSystem( - vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - vtkm::Float32 cellvar[2] = { 100.1f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On)); - - vtkm::cont::CellSetExplicit<> cellSet; - vtkm::Vec ids; - ids[0] = 0; - ids[1] = 1; - ids[2] = 2; - ids[3] = 3; - ids[4] = 4; - ids[5] = 5; - ids[6] = 6; - ids[7] = 7; - - cellSet.PrepareToAddCells(1, 8); - cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); - cellSet.CompleteAddingCells(nVerts); - - //todo this need to be a reference/shared_ptr style class - dataSet.SetCellSet(cellSet); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet4() -{ - vtkm::cont::DataSet dataSet; - - const int nVerts = 12; - using CoordType = vtkm::Vec3f_32; - CoordType coordinates[nVerts] = { - CoordType(0, 0, 0), //0 - CoordType(1, 0, 0), //1 - CoordType(1, 0, 1), //2 - CoordType(0, 0, 1), //3 - CoordType(0, 1, 0), //4 - CoordType(1, 1, 0), //5 - CoordType(1, 1, 1), //6 - CoordType(0, 1, 1), //7 - CoordType(2, 0, 0), //8 - CoordType(2, 0, 1), //9 - CoordType(2, 1, 1), //10 - CoordType(2, 1, 0) //11 - }; - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, - 70.2f, 80.3f, 90.f, 10.f, 11.f, 12.f }; - - dataSet.AddCoordinateSystem( - vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - vtkm::Float32 cellvar[2] = { 100.1f, 110.f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 2, vtkm::CopyFlag::On)); - - vtkm::cont::CellSetExplicit<> cellSet; - vtkm::Vec ids; - ids[0] = 0; - ids[1] = 4; - ids[2] = 5; - ids[3] = 1; - ids[4] = 3; - ids[5] = 7; - ids[6] = 6; - ids[7] = 2; - - cellSet.PrepareToAddCells(2, 16); - cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); - ids[0] = 1; - ids[1] = 5; - ids[2] = 11; - ids[3] = 8; - ids[4] = 2; - ids[5] = 6; - ids[6] = 10; - ids[7] = 9; - cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); - cellSet.CompleteAddingCells(nVerts); - - //todo this need to be a reference/shared_ptr style class - dataSet.SetCellSet(cellSet); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet3() -{ - vtkm::cont::DataSet dataSet; - - const int nVerts = 4; - using CoordType = vtkm::Vec3f_32; - CoordType coordinates[nVerts] = { - CoordType(0, 0, 0), CoordType(1, 0, 0), CoordType(1, 0, 1), CoordType(0, 1, 0) - }; - vtkm::Float32 vars[nVerts] = { 10.1f, 10.1f, 10.2f, 30.2f }; - - dataSet.AddCoordinateSystem( - vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - vtkm::Float32 cellvar[2] = { 100.1f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On)); - - vtkm::cont::CellSetExplicit<> cellSet; - vtkm::Id4 ids; - ids[0] = 0; - ids[1] = 1; - ids[2] = 2; - ids[3] = 3; - - cellSet.PrepareToAddCells(1, 4); - cellSet.AddCell(vtkm::CELL_SHAPE_TETRA, 4, ids); - cellSet.CompleteAddingCells(nVerts); - - //todo this need to be a reference/shared_ptr style class - dataSet.SetCellSet(cellSet); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet5() -{ - vtkm::cont::DataSet dataSet; - - const int nVerts = 11; - using CoordType = vtkm::Vec3f_32; - CoordType coordinates[nVerts] = { - CoordType(0, 0, 0), //0 - CoordType(1, 0, 0), //1 - CoordType(1, 0, 1), //2 - CoordType(0, 0, 1), //3 - CoordType(0, 1, 0), //4 - CoordType(1, 1, 0), //5 - CoordType(1, 1, 1), //6 - CoordType(0, 1, 1), //7 - CoordType(2, 0.5, 0.5), //8 - CoordType(0, 2, 0), //9 - CoordType(1, 2, 0) //10 - }; - vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f, 60.2f, - 70.2f, 80.3f, 90.f, 10.f, 11.f }; - - dataSet.AddCoordinateSystem( - vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); - - //Set point scalar - dataSet.AddField(make_Field( - "pointvar", vtkm::cont::Field::Association::POINTS, vars, nVerts, vtkm::CopyFlag::On)); - - //Set cell scalar - const int nCells = 4; - vtkm::Float32 cellvar[nCells] = { 100.1f, 110.f, 120.2f, 130.5f }; - dataSet.AddField(make_Field( - "cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, nCells, vtkm::CopyFlag::On)); - - vtkm::cont::CellSetExplicit<> cellSet; - vtkm::Vec ids; - - cellSet.PrepareToAddCells(nCells, 23); - - ids[0] = 0; - ids[1] = 1; - ids[2] = 5; - ids[3] = 4; - ids[4] = 3; - ids[5] = 2; - ids[6] = 6; - ids[7] = 7; - cellSet.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON, 8, ids); - - ids[0] = 1; - ids[1] = 5; - ids[2] = 6; - ids[3] = 2; - ids[4] = 8; - cellSet.AddCell(vtkm::CELL_SHAPE_PYRAMID, 5, ids); - - ids[0] = 5; - ids[1] = 8; - ids[2] = 10; - ids[3] = 6; - cellSet.AddCell(vtkm::CELL_SHAPE_TETRA, 4, ids); - - ids[0] = 4; - ids[1] = 7; - ids[2] = 9; - ids[3] = 5; - ids[4] = 6; - ids[5] = 10; - cellSet.AddCell(vtkm::CELL_SHAPE_WEDGE, 6, ids); - - cellSet.CompleteAddingCells(nVerts); - - //todo this need to be a reference/shared_ptr style class - dataSet.SetCellSet(cellSet); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet6() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - // Coordinates - const int nVerts = 8; - const int nCells = 8; - using CoordType = vtkm::Vec3f_32; - std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, - { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, - { 10.0f, 10.0f, 10.0f }, { 5.0f, 5.0f, 5.0f }, - { 0.0f, 0.0f, 2.0f }, { 0.0f, 0.0f, -2.0f } }; - - // Connectivity - std::vector shapes; - std::vector numindices; - std::vector conn; - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(0); - conn.push_back(1); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(2); - conn.push_back(3); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(4); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(2); - conn.push_back(3); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(0); - conn.push_back(1); - conn.push_back(2); - conn.push_back(3); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(0); - conn.push_back(2); - conn.push_back(3); - conn.push_back(6); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(3); - conn.push_back(2); - conn.push_back(0); - conn.push_back(7); - - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - // Field data - vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f }; - vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetZoo() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - // Coordinates - constexpr int nVerts = 30; - constexpr int nCells = 25; - using CoordType = vtkm::Vec3f_32; - - std::vector coords = - - { { 0.00f, 0.00f, 0.00f }, { 1.00f, 0.00f, 0.00f }, { 2.00f, 0.00f, 0.00f }, - { 0.00f, 0.00f, 1.00f }, { 1.00f, 0.00f, 1.00f }, { 2.00f, 0.00f, 1.00f }, - { 0.00f, 1.00f, 0.00f }, { 1.00f, 1.00f, 0.00f }, { 2.00f, 1.00f, 0.00f }, - { 0.00f, 1.00f, 1.00f }, { 1.00f, 1.00f, 1.00f }, { 2.00f, 1.00f, 1.00f }, - { 0.00f, 2.00f, 0.00f }, { 1.00f, 2.00f, 0.00f }, { 2.00f, 2.00f, 0.00f }, - { 0.00f, 2.00f, 1.00f }, { 1.00f, 2.00f, 1.00f }, { 2.00f, 2.00f, 1.00f }, - { 1.00f, 3.00f, 1.00f }, { 2.75f, 0.00f, 1.00f }, { 3.00f, 0.00f, 0.75f }, - { 3.00f, 0.25f, 1.00f }, { 3.00f, 1.00f, 1.00f }, { 3.00f, 1.00f, 0.00f }, - { 2.57f, 2.00f, 1.00f }, { 3.00f, 1.75f, 1.00f }, { 3.00f, 1.75f, 0.75f }, - { 3.00f, 0.00f, 0.00f }, { 2.57f, 0.42f, 0.57f }, { 2.59f, 1.43f, 0.71f } }; - - // Connectivity - std::vector shapes; - std::vector numindices; - std::vector conn; - - shapes.push_back(vtkm::CELL_SHAPE_HEXAHEDRON); - numindices.push_back(8); - conn.push_back(0); - conn.push_back(3); - conn.push_back(4); - conn.push_back(1); - conn.push_back(6); - conn.push_back(9); - conn.push_back(10); - conn.push_back(7); - - shapes.push_back(vtkm::CELL_SHAPE_HEXAHEDRON); - numindices.push_back(8); - conn.push_back(1); - conn.push_back(4); - conn.push_back(5); - conn.push_back(2); - conn.push_back(7); - conn.push_back(10); - conn.push_back(11); - conn.push_back(8); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(23); - conn.push_back(26); - conn.push_back(24); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(24); - conn.push_back(26); - conn.push_back(25); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(8); - conn.push_back(17); - conn.push_back(11); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(17); - conn.push_back(24); - conn.push_back(25); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(24); - conn.push_back(17); - conn.push_back(8); - conn.push_back(23); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(23); - conn.push_back(8); - conn.push_back(11); - conn.push_back(22); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(25); - conn.push_back(22); - conn.push_back(11); - conn.push_back(17); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(26); - conn.push_back(23); - conn.push_back(22); - conn.push_back(25); - conn.push_back(29); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(23); - conn.push_back(8); - conn.push_back(2); - conn.push_back(27); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(22); - conn.push_back(11); - conn.push_back(8); - conn.push_back(23); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(11); - conn.push_back(5); - conn.push_back(2); - conn.push_back(8); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(21); - conn.push_back(19); - conn.push_back(5); - conn.push_back(11); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(11); - conn.push_back(22); - conn.push_back(21); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(5); - conn.push_back(19); - conn.push_back(20); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(23); - conn.push_back(27); - conn.push_back(20); - conn.push_back(21); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(20); - conn.push_back(27); - conn.push_back(2); - conn.push_back(5); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(19); - conn.push_back(21); - conn.push_back(20); - conn.push_back(28); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(7); - conn.push_back(6); - conn.push_back(12); - conn.push_back(13); - conn.push_back(16); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(6); - conn.push_back(9); - conn.push_back(15); - conn.push_back(12); - conn.push_back(16); - - shapes.push_back(vtkm::CELL_SHAPE_PYRAMID); - numindices.push_back(5); - conn.push_back(6); - conn.push_back(7); - conn.push_back(10); - conn.push_back(9); - conn.push_back(16); - - shapes.push_back(vtkm::CELL_SHAPE_TETRA); - numindices.push_back(4); - conn.push_back(12); - conn.push_back(15); - conn.push_back(16); - conn.push_back(18); - - shapes.push_back(vtkm::CELL_SHAPE_WEDGE); - numindices.push_back(6); - conn.push_back(8); - conn.push_back(14); - conn.push_back(17); - conn.push_back(7); - conn.push_back(13); - conn.push_back(16); - - shapes.push_back(vtkm::CELL_SHAPE_WEDGE); - numindices.push_back(6); - conn.push_back(11); - conn.push_back(8); - conn.push_back(17); - conn.push_back(10); - conn.push_back(7); - conn.push_back(16); - - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - // Field data - vtkm::Float32 pointvar[nVerts] = - - { 4.0, 5.0f, 9.5f, 5.5f, 6.0f, 9.5f, 5.0f, 5.5f, 5.7f, 6.5f, 6.4f, 6.9f, 6.6f, 6.1f, 7.1f, - 7.2f, 7.3f, 7.4f, 9.1f, 9.2f, 9.3f, 5.4f, 9.5f, 9.6f, 6.7f, 9.8f, 6.0f, 4.3f, 4.9f, 4.1f }; - - vtkm::Float32 cellvar[nCells] = - - { 4.0f, 5.0f, 9.5f, 5.5f, 6.0f, 9.5f, 5.0f, 5.5f, 5.7f, 6.5f, 6.4f, 6.9f, 6.6f, - 6.1f, 7.1f, 7.2f, 7.3f, 7.4f, 9.1f, 9.2f, 9.3f, 5.4f, 9.5f, 9.6f, 6.7f }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet7() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - // Coordinates - const int nVerts = 8; - const int nCells = 8; - - using CoordType = vtkm::Vec3f_32; - std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, - { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, - { 10.0f, 10.0f, 10.0f }, { 5.0f, 5.0f, 5.0f }, - { 0.0f, 0.0f, 2.0f }, { 0.0f, 0.0f, -2.0f } }; - - // Connectivity - std::vector shapes; - std::vector numindices; - std::vector conn; - - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(0); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(1); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(2); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(3); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(4); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(6); - - shapes.push_back(vtkm::CELL_SHAPE_VERTEX); - numindices.push_back(1); - conn.push_back(7); - - - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - // Field data - vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 10.f, 20.f, 33.f, 52.f }; - vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet8() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - // Coordinates - const int nVerts = 8; - const int nCells = 10; - using CoordType = vtkm::Vec3f_32; - std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, - { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, - { 10.0f, 10.0f, 10.0f }, { 5.0f, 5.0f, 5.0f }, - { 0.0f, 0.0f, 2.0f }, { 0.0f, 0.0f, -2.0f } }; - - // Connectivity - std::vector shapes; - std::vector numindices; - std::vector conn; - - //I need two triangles because the leaf needs four nodes otherwise segfault? - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(0); - conn.push_back(1); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(1); - conn.push_back(2); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(2); - conn.push_back(3); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(3); - conn.push_back(4); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(4); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(5); - conn.push_back(6); - - shapes.push_back(vtkm::CELL_SHAPE_LINE); - numindices.push_back(2); - conn.push_back(6); - conn.push_back(7); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(2); - conn.push_back(5); - conn.push_back(4); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(4); - conn.push_back(5); - conn.push_back(6); - - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - // Field data - vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f }; - vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetPolygonal() -{ - vtkm::cont::DataSet dataSet; - vtkm::cont::DataSetBuilderExplicit dsb; - - // Coordinates - const int nVerts = 8; - const int nCells = 8; - using CoordType = vtkm::Vec3f_32; - std::vector coords = { { -0.707f, -0.354f, -0.354f }, { 0.000f, -0.854f, 0.146f }, - { 0.000f, -0.146f, 0.854f }, { -0.707f, 0.354f, 0.354f }, - { 0.000f, 0.146f, -0.854f }, { 0.000f, 0.854f, -0.146f }, - { 0.707f, 0.354f, 0.354f }, { 0.707f, -0.354f, -0.354f } }; - - // Connectivity - std::vector shapes; - std::vector numindices; - std::vector conn; - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(0); - conn.push_back(1); - conn.push_back(3); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(1); - conn.push_back(2); - conn.push_back(3); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(4); - conn.push_back(5); - conn.push_back(6); - conn.push_back(7); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(0); - conn.push_back(4); - conn.push_back(1); - - shapes.push_back(vtkm::CELL_SHAPE_TRIANGLE); - numindices.push_back(3); - conn.push_back(4); - conn.push_back(7); - conn.push_back(1); - - shapes.push_back(vtkm::CELL_SHAPE_POLYGON); - numindices.push_back(4); - conn.push_back(3); - conn.push_back(2); - conn.push_back(6); - conn.push_back(5); - - shapes.push_back(vtkm::CELL_SHAPE_QUAD); - numindices.push_back(4); - conn.push_back(0); - conn.push_back(3); - conn.push_back(5); - conn.push_back(4); - - shapes.push_back(vtkm::CELL_SHAPE_POLYGON); - numindices.push_back(4); - conn.push_back(1); - conn.push_back(7); - conn.push_back(6); - conn.push_back(2); - - dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates"); - - // Field data - vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 33.0f }; - vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f }; - - dataSet.AddPointField("pointvar", pointvar, nVerts); - dataSet.AddCellField("cellvar", cellvar, nCells); - - return dataSet; -} - -inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetCowNose() -{ - // prepare data array - const int nVerts = 17; - using CoordType = vtkm::Vec3f_64; - CoordType coordinates[nVerts] = { - CoordType(0.0480879, 0.151874, 0.107334), CoordType(0.0293568, 0.245532, 0.125337), - CoordType(0.0224398, 0.246495, 0.1351), CoordType(0.0180085, 0.20436, 0.145316), - CoordType(0.0307091, 0.152142, 0.0539249), CoordType(0.0270341, 0.242992, 0.107567), - CoordType(0.000684071, 0.00272505, 0.175648), CoordType(0.00946217, 0.077227, 0.187097), - CoordType(-0.000168991, 0.0692243, 0.200755), CoordType(-0.000129414, 0.00247137, 0.176561), - CoordType(0.0174172, 0.137124, 0.124553), CoordType(0.00325994, 0.0797155, 0.184912), - CoordType(0.00191765, 0.00589327, 0.16608), CoordType(0.0174716, 0.0501928, 0.0930275), - CoordType(0.0242103, 0.250062, 0.126256), CoordType(0.0108188, 0.152774, 0.167914), - CoordType(5.41687e-05, 0.00137834, 0.175119) - }; - const int connectivitySize = 57; - vtkm::Id pointId[connectivitySize] = { 0, 1, 3, 2, 3, 1, 4, 5, 0, 1, 0, 5, 7, 8, 6, - 9, 6, 8, 0, 10, 7, 11, 7, 10, 0, 6, 13, 12, 13, 6, - 1, 5, 14, 1, 14, 2, 0, 3, 15, 0, 13, 4, 6, 16, 12, - 6, 9, 16, 7, 11, 8, 0, 15, 10, 7, 6, 0 }; - - // create DataSet - vtkm::cont::DataSet dataSet; - dataSet.AddCoordinateSystem( - vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On)); - - vtkm::cont::ArrayHandle connectivity; - connectivity.Allocate(connectivitySize); - - for (vtkm::Id i = 0; i < connectivitySize; ++i) - { - connectivity.WritePortal().Set(i, pointId[i]); - } - vtkm::cont::CellSetSingleType<> cellSet; - cellSet.Fill(nVerts, vtkm::CELL_SHAPE_TRIANGLE, 3, connectivity); - dataSet.SetCellSet(cellSet); - - std::vector pointvar(nVerts); - std::iota(pointvar.begin(), pointvar.end(), 15.f); - std::vector cellvar(connectivitySize / 3); - std::iota(cellvar.begin(), cellvar.end(), 132.f); - - vtkm::cont::ArrayHandle pointvec; - pointvec.Allocate(nVerts); - SetPortal(pointvec.WritePortal()); - - vtkm::cont::ArrayHandle cellvec; - cellvec.Allocate(connectivitySize / 3); - SetPortal(cellvec.WritePortal()); - - dataSet.AddPointField("pointvar", pointvar); - dataSet.AddCellField("cellvar", cellvar); - dataSet.AddPointField("point_vectors", pointvec); - dataSet.AddCellField("cell_vectors", cellvec); - - return dataSet; -} -} -} -} // namespace vtkm::cont::testing +} // namespace testing +} // namespace cont +} // namespace vtkm #endif //vtk_m_cont_testing_MakeTestDataSet_h diff --git a/vtkm/cont/testing/UnitTestDataSetPermutation.cxx b/vtkm/cont/testing/UnitTestDataSetPermutation.cxx index 2cba84263..d2449d8b1 100644 --- a/vtkm/cont/testing/UnitTestDataSetPermutation.cxx +++ b/vtkm/cont/testing/UnitTestDataSetPermutation.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/vtkm/filter/AmrArrays.h b/vtkm/filter/AmrArrays.h new file mode 100644 index 000000000..b706953e1 --- /dev/null +++ b/vtkm/filter/AmrArrays.h @@ -0,0 +1,86 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_filter_AmrArrays_h +#define vtk_m_filter_AmrArrays_h + +#include + +namespace vtkm +{ +namespace filter +{ + +class AmrArrays : public vtkm::filter::FilterDataSet +{ +public: + using SupportedTypes = vtkm::List; + + VTKM_CONT + AmrArrays(); + + template + vtkm::cont::PartitionedDataSet PrepareForExecution( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::PolicyBase&); + + template + VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, + const vtkm::cont::Field& field, + const vtkm::filter::PolicyBase&) + { + result.AddField(field); + return true; + } + +private: + /// the list of ids contains all amrIds of the level above/below that have an overlap + VTKM_CONT + void GenerateParentChildInformation(); + + /// the corresponding template function based on the dimension of this dataset + VTKM_CONT + template + void ComputeGenerateParentChildInformation(); + + /// generate the vtkGhostType array based on the overlap analogously to vtk + /// blanked cells: 8 normal cells: 0 + VTKM_CONT + void GenerateGhostType(); + + /// the corresponding template function based on the dimension of this dataset + VTKM_CONT + template + void ComputeGenerateGhostType(); + + /// Add helper arrays like in ParaView + VTKM_CONT + void GenerateIndexArrays(); + + /// the input partitioned dataset + vtkm::cont::PartitionedDataSet AmrDataSet; + + /// per level + /// contains the index where the PartitionIds start for each level + std::vector> PartitionIds; + + /// per partitionId + /// contains all PartitonIds of the level above that have an overlap + std::vector> ParentsIdsVector; + + /// per partitionId + /// contains all PartitonIds of the level below that have an overlap + std::vector> ChildrenIdsVector; +}; +} +} // namespace vtkm::filter + +#include + +#endif //vtk_m_filter_AmrArrays_h diff --git a/vtkm/filter/AmrArrays.hxx b/vtkm/filter/AmrArrays.hxx new file mode 100644 index 000000000..667dd86e2 --- /dev/null +++ b/vtkm/filter/AmrArrays.hxx @@ -0,0 +1,307 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_filter_AmrArrays_hxx +#define vtk_m_filter_AmrArrays_hxx + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace vtkm +{ +namespace worklet +{ +template +struct GenerateGhostTypeWorklet : vtkm::worklet::WorkletVisitCellsWithPoints +{ + using ControlSignature = void(CellSetIn cellSet, + FieldInPoint pointArray, + FieldInOutCell ghostArray); + using ExecutionSignature = void(PointCount, _2, _3); + using InputDomain = _1; + + GenerateGhostTypeWorklet(vtkm::Bounds boundsChild) + : BoundsChild(boundsChild) + { + } + + template + VTKM_EXEC void operator()(vtkm::IdComponent numPoints, + const pointArrayType pointArray, + cellArrayType& ghostArray) const + { + vtkm::Bounds boundsCell = vtkm::Bounds(); + for (vtkm::IdComponent pointId = 0; pointId < numPoints; pointId++) + { + boundsCell.Include(pointArray[pointId]); + } + vtkm::Bounds boundsIntersection = boundsCell.Intersection(BoundsChild); + if ((Dim == 2 && boundsIntersection.Area() > 0.5 * boundsCell.Area()) || + (Dim == 3 && boundsIntersection.Volume() > 0.5 * boundsCell.Volume())) + { + // std::cout<AmrDataSet); + if (bounds.Z.Max - bounds.Z.Min < vtkm::Epsilon()) + { + ComputeGenerateParentChildInformation<2>(); + } + else + { + ComputeGenerateParentChildInformation<3>(); + } +} + +template void AmrArrays::ComputeGenerateParentChildInformation<2>(); + +template void AmrArrays::ComputeGenerateParentChildInformation<3>(); + +VTKM_CONT +template +void AmrArrays::ComputeGenerateParentChildInformation() +{ + // read out spacings in decreasing order to infer levels + std::set> spacings; + for (vtkm::Id p = 0; p < this->AmrDataSet.GetNumberOfPartitions(); p++) + { + vtkm::cont::ArrayHandleUniformPointCoordinates uniformCoords = + this->AmrDataSet.GetPartition(p) + .GetCoordinateSystem() + .GetData() + .AsArrayHandle(); + spacings.insert(uniformCoords.GetSpacing()[0]); + } + std::set>::iterator itr; + // for (itr = spacings.begin(); itr != spacings.end(); itr++) + // { + // std::cout << *itr << "\n"; + // } + + /// contains the partitionIds of each level and blockId + this->PartitionIds.resize(spacings.size()); + for (vtkm::Id p = 0; p < this->AmrDataSet.GetNumberOfPartitions(); p++) + { + vtkm::cont::ArrayHandleUniformPointCoordinates uniformCoords = + this->AmrDataSet.GetPartition(p) + .GetCoordinateSystem() + .GetData() + .AsArrayHandle(); + int index = -1; + for (itr = spacings.begin(); itr != spacings.end(); itr++) + { + index++; + if (*itr == uniformCoords.GetSpacing()[0]) + { + break; + } + } + this->PartitionIds.at(index).push_back(p); + // std::cout <ParentsIdsVector.resize(this->AmrDataSet.GetNumberOfPartitions()); + this->ChildrenIdsVector.resize(this->AmrDataSet.GetNumberOfPartitions()); + for (unsigned int l = 0; l < this->PartitionIds.size() - 1; l++) + { + for (unsigned int bParent = 0; bParent < this->PartitionIds.at(l).size(); bParent++) + { + // std::cout << std::endl << "level " << l << " block " << bParent << std::endl; + vtkm::Bounds boundsParent = + this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(bParent)) + .GetCoordinateSystem() + .GetBounds(); + + // compute size of a cell to compare overlap against + auto coords = this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(bParent)) + .GetCoordinateSystem() + .GetDataAsMultiplexer(); + vtkm::cont::CellSetStructured cellset; + vtkm::Id ptids[8]; + this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(bParent)) + .GetCellSet() + .CopyTo(cellset); + cellset.GetCellPointIds(0, ptids); + vtkm::Bounds boundsCell = vtkm::Bounds(); + for (vtkm::IdComponent pointId = 0; pointId < cellset.GetNumberOfPointsInCell(0); pointId++) + { + boundsCell.Include(coords.ReadPortal().Get(ptids[pointId])); + } + + // see if there is overlap of at least one half of a cell + for (unsigned int bChild = 0; bChild < this->PartitionIds.at(l + 1).size(); bChild++) + { + vtkm::Bounds boundsChild = + this->AmrDataSet.GetPartition(this->PartitionIds.at(l + 1).at(bChild)) + .GetCoordinateSystem() + .GetBounds(); + vtkm::Bounds boundsIntersection = boundsParent.Intersection(boundsChild); + if ((Dim == 2 && boundsIntersection.Area() > 0.5 * boundsCell.Area()) || + (Dim == 3 && boundsIntersection.Volume() >= 0.5 * boundsCell.Volume())) + { + this->ParentsIdsVector.at(this->PartitionIds.at(l + 1).at(bChild)) + .push_back(this->PartitionIds.at(l).at(bParent)); + this->ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)) + .push_back(this->PartitionIds.at(l + 1).at(bChild)); + // std::cout << " overlaps with level " << l + 1 << " block " << bChild << " " + // << boundsParent << " " << boundsChild << " " << boundsIntersection << " " + // << boundsIntersection.Area() << " " << boundsIntersection.Volume() << std::endl; + } + // else + // { + // std::cout << " does not overlap with level " << l + 1 << " block " << bChild << " " + // << boundsParent << " " << boundsChild << " " << boundsIntersection << " " + // << boundsIntersection.Area() << " " << boundsIntersection.Volume() << std::endl; + // } + } + } + } +} + +VTKM_CONT +void AmrArrays::GenerateGhostType() +{ + vtkm::Bounds bounds = vtkm::cont::BoundsCompute(this->AmrDataSet); + if (bounds.Z.Max - bounds.Z.Min < vtkm::Epsilon()) + { + ComputeGenerateGhostType<2>(); + } + else + { + ComputeGenerateGhostType<3>(); + } +} + +template void AmrArrays::ComputeGenerateGhostType<2>(); + +template void AmrArrays::ComputeGenerateGhostType<3>(); + +VTKM_CONT +template +void AmrArrays::ComputeGenerateGhostType() +{ + for (unsigned int l = 0; l < this->PartitionIds.size(); l++) + { + for (unsigned int bParent = 0; bParent < this->PartitionIds.at(l).size(); bParent++) + { + // std::cout<ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)).size()<<" children"<AmrDataSet.GetPartition(this->PartitionIds.at(l).at(bParent)); + vtkm::cont::CellSetStructured cellset; + partition.GetCellSet().CopyTo(cellset); + vtkm::cont::ArrayHandle ghostField; + if (!partition.HasField("vtkGhostType", vtkm::cont::Field::Association::CELL_SET)) + { + vtkm::cont::ArrayCopy( + vtkm::cont::ArrayHandleConstant(0, partition.GetNumberOfCells()), + ghostField); + } + // leave field unchanged if it is the highest level + if (l < this->PartitionIds.size() - 1) + { + auto pointField = partition.GetCoordinateSystem().GetDataAsMultiplexer(); + + for (unsigned int bChild = 0; + bChild < this->ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)).size(); + bChild++) + { + vtkm::Bounds boundsChild = + this->AmrDataSet + .GetPartition( + this->ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)).at(bChild)) + .GetCoordinateSystem() + .GetBounds(); + // std::cout<<" is (partly) contained in level "<ChildrenIdsVector.at(this->PartitionIds.at(l).at(bParent)).at(bChild)<<" with bounds "<{ boundsChild }, + cellset, + pointField, + ghostField); + } + } + partition.AddCellField("vtkGhostType", ghostField); + this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(bParent), partition); + } + } +} + +// Add helper arrays like in ParaView +VTKM_CONT +void AmrArrays::GenerateIndexArrays() +{ + for (unsigned int l = 0; l < this->PartitionIds.size(); l++) + { + for (unsigned int b = 0; b < this->PartitionIds.at(l).size(); b++) + { + vtkm::cont::DataSet partition = this->AmrDataSet.GetPartition(this->PartitionIds.at(l).at(b)); + + vtkm::cont::ArrayHandle fieldAmrLevel; + vtkm::cont::ArrayCopy( + vtkm::cont::ArrayHandleConstant(l, partition.GetNumberOfCells()), fieldAmrLevel); + partition.AddCellField("vtkAmrLevel", fieldAmrLevel); + + vtkm::cont::ArrayHandle fieldBlockId; + vtkm::cont::ArrayCopy( + vtkm::cont::ArrayHandleConstant(b, partition.GetNumberOfCells()), fieldBlockId); + partition.AddCellField("vtkAmrIndex", fieldBlockId); + + vtkm::cont::ArrayHandle fieldPartitionIndex; + vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleConstant( + this->PartitionIds.at(l).at(b), partition.GetNumberOfCells()), + fieldPartitionIndex); + partition.AddCellField("vtkCompositeIndex", fieldPartitionIndex); + + this->AmrDataSet.ReplacePartition(this->PartitionIds.at(l).at(b), partition); + } + } +} + +template +vtkm::cont::PartitionedDataSet AmrArrays::PrepareForExecution( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::PolicyBase&) +{ + this->AmrDataSet = input; + this->GenerateParentChildInformation(); + this->GenerateGhostType(); + this->GenerateIndexArrays(); + return this->AmrDataSet; +} + +} +} +#endif diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index 234fd62c5..074bad60c 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -77,6 +77,7 @@ set(common_sources_device ) set(extra_headers + AmrArrays.h CellSetConnectivity.h ClipWithField.h ClipWithImplicitFunction.h @@ -134,6 +135,7 @@ set(extra_headers ) set(extra_header_template_sources + AmrArrays.hxx CellSetConnectivity.hxx ClipWithField.hxx ClipWithImplicitFunction.hxx diff --git a/vtkm/filter/testing/CMakeLists.txt b/vtkm/filter/testing/CMakeLists.txt index b1cca76c3..8bb6706a4 100644 --- a/vtkm/filter/testing/CMakeLists.txt +++ b/vtkm/filter/testing/CMakeLists.txt @@ -97,6 +97,7 @@ if (VTKm_ENABLE_RENDERING) list(APPEND libraries vtkm_rendering) list(APPEND unit_tests + RegressionTestAmrArrays.cxx RegressionTestContourFilter.cxx RegressionTestPointTransform.cxx RegressionTestSliceFilter.cxx diff --git a/vtkm/filter/testing/RegressionTestAmrArrays.cxx b/vtkm/filter/testing/RegressionTestAmrArrays.cxx new file mode 100644 index 000000000..1c3a1821e --- /dev/null +++ b/vtkm/filter/testing/RegressionTestAmrArrays.cxx @@ -0,0 +1,78 @@ +//============================================================================ +// 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. +//============================================================================ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace +{ + +void TestAmrArraysExecute(int dim, int numberOfLevels, int cellsPerDimension) +{ + std::cout << "Generate Image for AMR" << std::endl; + + using M = vtkm::rendering::MapperRayTracer; + using C = vtkm::rendering::CanvasRayTracer; + using V3 = vtkm::rendering::View3D; + + // Generate AMR + vtkm::source::Amr source(dim, cellsPerDimension, numberOfLevels); + vtkm::cont::PartitionedDataSet amrDataSet = source.Execute(); + // std::cout << "amr " << std::endl; + // amrDataSet.PrintSummary(std::cout); + + // Remove blanked cells + vtkm::filter::Threshold threshold; + threshold.SetLowerThreshold(0); + threshold.SetUpperThreshold(1); + threshold.SetActiveField("vtkGhostType"); + vtkm::cont::PartitionedDataSet derivedDataSet = threshold.Execute(amrDataSet); + // std::cout << "derived " << std::endl; + // derivedDataSet.PrintSummary(std::cout); + + // Extract surface for efficient 3D pipeline + vtkm::filter::ExternalFaces surface; + surface.SetFieldsToPass("RTDataCells"); + derivedDataSet = surface.Execute(derivedDataSet); + + // Merge dataset + vtkm::cont::DataSet result = vtkm::cont::MergePartitionedDataSet(derivedDataSet); + // std::cout << "merged " << std::endl; + // result.PrintSummary(std::cout); + + vtkm::rendering::testing::RenderAndRegressionTest(result, + "RTDataCells", + vtkm::cont::ColorTable("inferno"), + "filter/amrArrays" + + std::to_string(dim) + "D.png", + false); +} + +void TestAmrArrays() +{ + int numberOfLevels = 5; + int cellsPerDimension = 6; + TestAmrArraysExecute(2, numberOfLevels, cellsPerDimension); + TestAmrArraysExecute(3, numberOfLevels, cellsPerDimension); +} +} // namespace + +int RegressionTestAmrArrays(int argc, char* argv[]) +{ + return vtkm::cont::testing::Testing::Run(TestAmrArrays, argc, argv); +} diff --git a/vtkm/filter/testing/UnitTestClipWithFieldFilter.cxx b/vtkm/filter/testing/UnitTestClipWithFieldFilter.cxx index 4de985e71..f19787a88 100644 --- a/vtkm/filter/testing/UnitTestClipWithFieldFilter.cxx +++ b/vtkm/filter/testing/UnitTestClipWithFieldFilter.cxx @@ -8,10 +8,10 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include - +#include #include #include +#include namespace { diff --git a/vtkm/filter/testing/UnitTestClipWithImplicitFunctionFilter.cxx b/vtkm/filter/testing/UnitTestClipWithImplicitFunctionFilter.cxx index 95ec60b12..ec9199b73 100644 --- a/vtkm/filter/testing/UnitTestClipWithImplicitFunctionFilter.cxx +++ b/vtkm/filter/testing/UnitTestClipWithImplicitFunctionFilter.cxx @@ -10,7 +10,7 @@ #include -#include +#include #include namespace diff --git a/vtkm/filter/testing/UnitTestPartitionedDataSetFilters.cxx b/vtkm/filter/testing/UnitTestPartitionedDataSetFilters.cxx index b908790f1..12ab60d7f 100644 --- a/vtkm/filter/testing/UnitTestPartitionedDataSetFilters.cxx +++ b/vtkm/filter/testing/UnitTestPartitionedDataSetFilters.cxx @@ -13,12 +13,11 @@ #include #include #include - +#include #include #include #include -#include #include #include diff --git a/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx b/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx index d7cdd2c78..a39130512 100644 --- a/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx +++ b/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx b/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx index 3df30b9dd..94d1393f8 100644 --- a/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx +++ b/vtkm/io/testing/UnitTestVTKDataSetWriter.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/vtkm/rendering/testing/UnitTestMapperWireframer.cxx b/vtkm/rendering/testing/UnitTestMapperWireframer.cxx index 5c29cb658..4ba4a9380 100644 --- a/vtkm/rendering/testing/UnitTestMapperWireframer.cxx +++ b/vtkm/rendering/testing/UnitTestMapperWireframer.cxx @@ -9,6 +9,7 @@ //============================================================================ #include +#include #include #include #include diff --git a/vtkm/source/Amr.cxx b/vtkm/source/Amr.cxx new file mode 100644 index 000000000..a0a1c437e --- /dev/null +++ b/vtkm/source/Amr.cxx @@ -0,0 +1,111 @@ +//============================================================================ +// 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. +//============================================================================ + + +#include +#include +#include +#include +#include + + +namespace vtkm +{ +namespace source +{ + +Amr::Amr(vtkm::IdComponent dimension, + vtkm::IdComponent cellsPerDimension, + vtkm::IdComponent numberOfLevels) + : Dimension(dimension) + , CellsPerDimension(cellsPerDimension) + , NumberOfLevels(numberOfLevels) +{ +} + +Amr::~Amr() = default; + +template +vtkm::cont::DataSet Amr::GenerateDataSet(unsigned int level, unsigned int amrIndex) const +{ + vtkm::Id3 extent = { vtkm::Id(this->CellsPerDimension / 2) }; + vtkm::Id3 dimensions = { this->CellsPerDimension + 1 }; + vtkm::Vec3f origin = { float(1. / pow(2, level) * amrIndex) }; + vtkm::Vec3f spacing = { float(1. / this->CellsPerDimension / pow(2, level)) }; + vtkm::Vec3f center = 0.5f - (origin + spacing * extent); + vtkm::Vec3f frequency = { 60.f, 30.f, 40.f }; + frequency = frequency * this->CellsPerDimension; + vtkm::FloatDefault deviation = 0.5f / this->CellsPerDimension; + + if (Dim == 2) + { + extent[2] = 0; + dimensions[2] = 1; + origin[2] = 0; + spacing[2] = 1; + center[2] = 0; + } + + vtkm::source::Wavelet waveletSource(-extent, extent); + waveletSource.SetOrigin(origin); + waveletSource.SetSpacing(spacing); + waveletSource.SetCenter(center); + waveletSource.SetFrequency(frequency); + waveletSource.SetStandardDeviation(deviation); + vtkm::cont::DataSet wavelet = waveletSource.Execute(); + + vtkm::filter::CellAverage cellAverage; + cellAverage.SetActiveField("RTData", vtkm::cont::Field::Association::POINTS); + cellAverage.SetOutputFieldName("RTDataCells"); + return cellAverage.Execute(wavelet); +} + +vtkm::cont::PartitionedDataSet Amr::Execute() const +{ + assert(this->CellsPerDimension > 1); + assert(this->CellsPerDimension % 2 == 0); + + // Generate AMR + std::vector> blocksPerLevel(this->NumberOfLevels); + unsigned int counter = 0; + for (unsigned int l = 0; l < blocksPerLevel.size(); l++) + { + for (unsigned int b = 0; b < pow(2, l); b++) + { + blocksPerLevel.at(l).push_back(counter++); + } + } + vtkm::cont::PartitionedDataSet amrDataSet; + + // Fill AMR with data from the wavelet + for (unsigned int l = 0; l < blocksPerLevel.size(); l++) + { + for (unsigned int b = 0; b < blocksPerLevel.at(l).size(); b++) + { + if (this->Dimension == 2) + { + amrDataSet.AppendPartition(this->GenerateDataSet<2>(l, b)); + } + else if (this->Dimension == 3) + { + amrDataSet.AppendPartition(this->GenerateDataSet<3>(l, b)); + } + } + } + + // Generate helper arrays + vtkm::filter::AmrArrays amrArrays; + amrDataSet = amrArrays.Execute(amrDataSet); + + return amrDataSet; +} + +} // namespace source +} // namespace vtkm diff --git a/vtkm/source/Amr.h b/vtkm/source/Amr.h new file mode 100644 index 000000000..bd451f84a --- /dev/null +++ b/vtkm/source/Amr.h @@ -0,0 +1,81 @@ +//============================================================================ +// 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. +//============================================================================ + +#ifndef vtk_m_source_Amr_h +#define vtk_m_source_Amr_h + +#include +#include + +namespace vtkm +{ +namespace source +{ +/** + * @brief The Amr source creates a dataset similar to VTK's + * vtkRTAnalyticSource. + * + * This class generates a predictable structured dataset with a smooth yet + * interesting set of scalars, which is useful for testing and benchmarking. + * + * The Execute method creates a complete structured dataset that have a + * point field names 'scalars' + * + * The scalars are computed as: + * + * ``` + * MaxVal * Gauss + MagX * sin(FrqX*x) + MagY * sin(FrqY*y) + MagZ * cos(FrqZ*z) + * ``` + * + * The dataset properties are determined by: + * - `Minimum/MaximumExtent`: The logical point extents of the dataset. + * - `Spacing`: The distance between points of the dataset. + * - `Center`: The center of the dataset. + * + * The scalar functions is control via: + * - `Center`: The center of a Gaussian contribution to the scalars. + * - `StandardDeviation`: The unscaled width of a Gaussian contribution. + * - `MaximumValue`: Upper limit of the scalar range. + * - `Frequency`: The Frq[XYZ] parameters of the periodic contributions. + * - `Magnitude`: The Mag[XYZ] parameters of the periodic contributions. + * + * By default, the following parameters are used: + * - `Extents`: { -10, -10, -10 } `-->` { 10, 10, 10 } + * - `Spacing`: { 1, 1, 1 } + * - `Center`: { 0, 0, 0 } + * - `StandardDeviation`: 0.5 + * - `MaximumValue`: 255 + * - `Frequency`: { 60, 30, 40 } + * - `Magnitude`: { 10, 18, 5 } + */ +class VTKM_SOURCE_EXPORT Amr +{ +public: + VTKM_CONT + Amr(vtkm::IdComponent dimension = 2, + vtkm::IdComponent cellsPerDimension = 6, + vtkm::IdComponent numberOfLevels = 4); + VTKM_CONT + ~Amr(); + + vtkm::cont::PartitionedDataSet Execute() const; + +private: + template + vtkm::cont::DataSet GenerateDataSet(unsigned int level, unsigned int amrIndex) const; + + vtkm::IdComponent Dimension; + vtkm::IdComponent CellsPerDimension; + vtkm::IdComponent NumberOfLevels; +}; +} //namespace source +} //namespace vtkm + +#endif //vtk_m_source_Amr_h diff --git a/vtkm/source/CMakeLists.txt b/vtkm/source/CMakeLists.txt index 03de54190..2a1c61461 100644 --- a/vtkm/source/CMakeLists.txt +++ b/vtkm/source/CMakeLists.txt @@ -9,6 +9,7 @@ ##============================================================================ set(headers + Amr.h Oscillator.h Source.h Tangle.h @@ -17,6 +18,7 @@ set(headers ) set(device_sources + Amr.cxx Oscillator.cxx Source.cxx Tangle.cxx @@ -25,11 +27,12 @@ set(device_sources ) vtkm_library(NAME vtkm_source + SOURCES ${sources} DEVICE_SOURCES ${device_sources} HEADERS ${headers} ) -target_link_libraries(vtkm_source PUBLIC vtkm_cont) +target_link_libraries(vtkm_source PUBLIC vtkm_cont vtkm_filter) #----------------------------------------------------------------------------- if (VTKm_ENABLE_TESTING) diff --git a/vtkm/source/Wavelet.cxx b/vtkm/source/Wavelet.cxx index 3eb1b4b06..88e09fa34 100644 --- a/vtkm/source/Wavelet.cxx +++ b/vtkm/source/Wavelet.cxx @@ -98,6 +98,7 @@ struct WaveletField : public vtkm::worklet::WorkletVisitPointsWithCells Wavelet::Wavelet(vtkm::Id3 minExtent, vtkm::Id3 maxExtent) : Center{ minExtent - ((minExtent - maxExtent) / 2) } + , Origin{ minExtent } , Spacing{ 1. } , Frequency{ 60., 30., 40. } , Magnitude{ 10., 18., 5. } @@ -108,17 +109,16 @@ Wavelet::Wavelet(vtkm::Id3 minExtent, vtkm::Id3 maxExtent) { } -vtkm::cont::DataSet Wavelet::Execute() const +template +vtkm::cont::DataSet Wavelet::GenerateDataSet(vtkm::cont::CoordinateSystem coords) const { - VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf); - - // Create points: - const vtkm::Id3 dims{ this->MaximumExtent - this->MinimumExtent + vtkm::Id3{ 1 } }; - const vtkm::Vec3f origin{ this->MinimumExtent }; - vtkm::cont::CoordinateSystem coords{ "coordinates", dims, origin, this->Spacing }; - // And cells: - vtkm::cont::CellSetStructured<3> cellSet; + vtkm::Vec dims; + for (unsigned int d = 0; d < Dim; d++) + { + dims[d] = this->MaximumExtent[d] - this->MinimumExtent[d] + 1; + } + vtkm::cont::CellSetStructured cellSet; cellSet.SetPointDimensions(dims); // Compile the dataset: @@ -133,7 +133,27 @@ vtkm::cont::DataSet Wavelet::Execute() const return dataSet; } -vtkm::cont::Field Wavelet::GeneratePointField(const vtkm::cont::CellSetStructured<3>& cellset, +vtkm::cont::DataSet Wavelet::Execute() const +{ + VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf); + + // Create points: + const vtkm::Id3 dims{ this->MaximumExtent - this->MinimumExtent + vtkm::Id3{ 1 } }; + vtkm::cont::CoordinateSystem coords{ "coordinates", dims, this->Origin, this->Spacing }; + + // Compile the dataset: + if (this->MaximumExtent[2] - this->MinimumExtent[2] < vtkm::Epsilon()) + { + return this->GenerateDataSet<2>(coords); + } + else + { + return this->GenerateDataSet<3>(coords); + } +} + +template +vtkm::cont::Field Wavelet::GeneratePointField(const vtkm::cont::CellSetStructured& cellset, const std::string& name) const { const vtkm::Id3 dims{ this->MaximumExtent - this->MinimumExtent + vtkm::Id3{ 1 } }; diff --git a/vtkm/source/Wavelet.h b/vtkm/source/Wavelet.h index 8bd30cb73..001d3b2af 100644 --- a/vtkm/source/Wavelet.h +++ b/vtkm/source/Wavelet.h @@ -53,6 +53,8 @@ namespace source * - `MaximumValue`: 255 * - `Frequency`: { 60, 30, 40 } * - `Magnitude`: { 10, 18, 5 } + * + * If the extent has zero length in the z-direction, a 2D dataset is generated. */ class VTKM_SOURCE_EXPORT Wavelet final : public vtkm::source::Source { @@ -62,6 +64,8 @@ public: VTKM_CONT void SetCenter(const vtkm::Vec& center) { this->Center = center; } + VTKM_CONT void SetOrigin(const vtkm::Vec& origin) { this->Origin = origin; } + VTKM_CONT void SetSpacing(const vtkm::Vec& spacing) { this->Spacing = spacing; } VTKM_CONT void SetFrequency(const vtkm::Vec& frequency) @@ -94,10 +98,15 @@ public: vtkm::cont::DataSet Execute() const; private: - vtkm::cont::Field GeneratePointField(const vtkm::cont::CellSetStructured<3>& cellset, + template + vtkm::cont::Field GeneratePointField(const vtkm::cont::CellSetStructured& cellset, const std::string& name) const; + template + vtkm::cont::DataSet GenerateDataSet(vtkm::cont::CoordinateSystem coords) const; + vtkm::Vec3f Center; + vtkm::Vec3f Origin; vtkm::Vec3f Spacing; vtkm::Vec3f Frequency; vtkm::Vec3f Magnitude; diff --git a/vtkm/worklet/testing/UnitTestImageConnectivity.cxx b/vtkm/worklet/testing/UnitTestImageConnectivity.cxx index b2c623c53..3c1376b65 100644 --- a/vtkm/worklet/testing/UnitTestImageConnectivity.cxx +++ b/vtkm/worklet/testing/UnitTestImageConnectivity.cxx @@ -7,7 +7,7 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include +#include #include #include diff --git a/vtkm/worklet/testing/UnitTestSplitSharpEdges.cxx b/vtkm/worklet/testing/UnitTestSplitSharpEdges.cxx index cba6bd820..3d868816c 100644 --- a/vtkm/worklet/testing/UnitTestSplitSharpEdges.cxx +++ b/vtkm/worklet/testing/UnitTestSplitSharpEdges.cxx @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include