diff --git a/vtkm/cont/ArrayHandle.h b/vtkm/cont/ArrayHandle.h index bd324048a..be5f75c17 100644 --- a/vtkm/cont/ArrayHandle.h +++ b/vtkm/cont/ArrayHandle.h @@ -736,9 +736,40 @@ printSummary_ArrayHandle(const vtkm::cont::ArrayHandle &array, } else { - out< +VTKM_CONT_EXPORT +void +printSummary_ArrayHandle(const vtkm::cont::ArrayHandle &array, + std::ostream &out) +{ + vtkm::Id sz = array.GetNumberOfValues(); + out<<"sz= "<(array.GetPortalConstControl().Get(i)); + if (i != (sz-1)) out<<" "; + } + else + { + out<(array.GetPortalConstControl().Get(0))<<" "; + out<(array.GetPortalConstControl().Get(1))<<" "; + out<(array.GetPortalConstControl().Get(2)); + out<<" ... "; + out<(array.GetPortalConstControl().Get(sz-3))<<" "; + out<(array.GetPortalConstControl().Get(sz-2))<<" "; + out<(array.GetPortalConstControl().Get(sz-1)); } out<<"]"; } diff --git a/vtkm/cont/ArrayHandleCartesianProduct.h b/vtkm/cont/ArrayHandleCartesianProduct.h new file mode 100644 index 000000000..9d33b3f8b --- /dev/null +++ b/vtkm/cont/ArrayHandleCartesianProduct.h @@ -0,0 +1,500 @@ +//============================================================================ +// 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. +// +// Copyright 2014 Sandia Corporation. +// Copyright 2014 UT-Battelle, LLC. +// Copyright 2014 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_cont_ArrayHandleCartesianProduct_h +#define vtk_m_cont_ArrayHandleCartesianProduct_h + +#include +#include +#include + +namespace vtkm { +namespace exec { +namespace internal { + +/// \brief An array portal that acts as a 3D cartesian product of 3 arrays. +/// for the execution environment + +template +class ArrayPortalExecCartesianProduct +{ +public: + typedef ValueType_ ValueType; + typedef ValueType_ IteratorType; + typedef PortalTypeFirst_ PortalTypeFirst; + typedef PortalTypeSecond_ PortalTypeSecond; + typedef PortalTypeThird_ PortalTypeThird; + + VTKM_EXEC_CONT_EXPORT + ArrayPortalExecCartesianProduct() + : PortalFirst(), PortalSecond(), PortalThird() + { } //needs to be host and device so that cuda can create lvalue of these + + VTKM_CONT_EXPORT + ArrayPortalExecCartesianProduct(const PortalTypeFirst &portalfirst, + const PortalTypeSecond &portalsecond, + const PortalTypeThird &portalthird) + : PortalFirst(portalfirst), PortalSecond(portalsecond), PortalThird(portalthird) + { } + + /// Copy constructor for any other ArrayPortalExecCartesianProduct with an iterator + /// type that can be copied to this iterator type. This allows us to do any + /// type casting that the iterators do (like the non-const to const cast). + /// + + template + VTKM_CONT_EXPORT + ArrayPortalExecCartesianProduct(const ArrayPortalExecCartesianProduct &src) + : PortalFirst(src.GetPortalFirst()), + PortalSecond(src.GetPortalSecond()), + PortalThird(src.GetPortalThird()) + { } + + + VTKM_EXEC_CONT_EXPORT + vtkm::Id GetNumberOfValues() const + { + return this->PortalFirst.GetNumberOfValues() * + this->PortalSecond.GetNumberOfValues() * + this->PortalThird.GetNumberOfValues(); + } + + VTKM_EXEC_EXPORT + ValueType Get(vtkm::Id index) const + { + vtkm::Id dim1 = this->PortalFirst.GetNumberOfValues(); + vtkm::Id dim2 = this->PortalSecond.GetNumberOfValues(); + vtkm::Id dim12 = dim1*dim2; + vtkm::Id idx12 = index % dim12; + vtkm::Id i1 = idx12 % dim1; + vtkm::Id i2 = idx12 / dim1; + vtkm::Id i3 = index / dim12; + + return vtkm::make_Vec(this->PortalFirst.Get(i1), + this->PortalSecond.Get(i2), + this->PortalThird.Get(i3)); + } + + VTKM_EXEC_EXPORT + void Set(vtkm::Id index, const ValueType &value) const + { + vtkm::Id dim1 = this->PortalFirst.GetNumberOfValues(); + vtkm::Id dim2 = this->PortalSecond.GetNumberOfValues(); + vtkm::Id dim12 = dim1*dim2; + vtkm::Id idx12 = index % dim12; + + vtkm::Id i1 = idx12 % dim1; + vtkm::Id i2 = idx12 / dim1; + vtkm::Id i3 = index / dim12; + + this->PortalFirst.Set(i1, value[0]); + this->PortalSecond.Set(i2, value[1]); + this->PortalThird.Set(i3, value[2]); + } + + VTKM_EXEC_CONT_EXPORT + const PortalTypeFirst &GetFirstPortal() const { return this->PortalFirst; } + + VTKM_EXEC_CONT_EXPORT + const PortalTypeSecond &GetSecondPortal() const { return this->PortalSecond; } + + VTKM_EXEC_CONT_EXPORT + const PortalTypeThird &GetThirdPortal() const { return this->PortalThird; } + + +private: + PortalTypeFirst PortalFirst; + PortalTypeSecond PortalSecond; + PortalTypeThird PortalThird; +}; + +} +} +} // namespace vtkm::exec::internal + + +namespace vtkm { +namespace cont { + +namespace internal { + +/// \brief An array portal that zips two portals together into a single value +/// for the control environment +template +class ArrayPortalContCartesianProduct +{ +public: + typedef ValueType_ ValueType; + typedef ValueType_ IteratorType; + + VTKM_CONT_EXPORT + ArrayPortalContCartesianProduct(const PortalTypeFirst &portalfirst = PortalTypeFirst(), + const PortalTypeSecond &portalsecond = PortalTypeSecond(), + const PortalTypeSecond &portalthird = PortalTypeThird()) + : PortalFirst(portalfirst), PortalSecond(portalsecond), PortalThird(portalthird) + { } + + /// Copy constructor for any other ArrayPortalContCartesianProduct with an iterator + /// type that can be copied to this iterator type. This allows us to do any + /// type casting that the iterators do (like the non-const to const cast). + /// + template + VTKM_CONT_EXPORT + ArrayPortalContCartesianProduct(const ArrayPortalContCartesianProduct &src) + : PortalFirst(src.GetPortalFirst()), + PortalSecond(src.GetPortalSecond()), + PortalThird(src.GetPortalThird()) + { } + + VTKM_CONT_EXPORT + vtkm::Id GetNumberOfValues() const + { + return this->PortalFirst.GetNumberOfValues() * + this->PortalSecond.GetNumberOfValues() * + this->PortalThird.GetNumberOfValues(); + } + + VTKM_CONT_EXPORT + ValueType Get(vtkm::Id index) const + { + vtkm::Id dim1 = this->PortalFirst.GetNumberOfValues(); + vtkm::Id dim2 = this->PortalSecond.GetNumberOfValues(); + vtkm::Id dim12 = dim1*dim2; + vtkm::Id idx12 = index % dim12; + vtkm::Id i1 = idx12 % dim1; + vtkm::Id i2 = idx12 / dim1; + vtkm::Id i3 = index / dim12; + return vtkm::make_Vec(this->PortalFirst.Get(i1), + this->PortalSecond.Get(i2), + this->PortalThird.Get(i3)); + } + + VTKM_CONT_EXPORT + void Set(vtkm::Id index, const ValueType &value) const + { + vtkm::Id dim1 = this->PortalFirst.GetNumberOfValues(); + vtkm::Id dim2 = this->PortalSecond.GetNumberOfValues(); + vtkm::Id dim12 = dim1*dim2; + vtkm::Id idx12 = index % dim12; + + vtkm::Id i1 = idx12 % dim1; + vtkm::Id i2 = idx12 / dim1; + vtkm::Id i3 = index / dim12; + + this->PortalFirst.Set(i1, value[0]); + this->PortalSecond.Set(i2, value[1]); + this->PortalThird.Set(i3, value[2]); + } + + VTKM_CONT_EXPORT + const PortalTypeFirst &GetFirstPortal() const { return this->PortalFirst; } + + VTKM_CONT_EXPORT + const PortalTypeSecond &GetSecondPortal() const { return this->PortalSecond; } + + VTKM_CONT_EXPORT + const PortalTypeSecond &GetThirdPortal() const { return this->PortalThird; } + + +private: + PortalTypeFirst PortalFirst; + PortalTypeSecond PortalSecond; + PortalTypeThird PortalThird; +}; + +template +struct StorageTagCartesianProduct { }; + +/// This helper struct defines the value type for a zip container containing +/// the given two array handles. +/// +template +struct ArrayHandleCartesianProductTraits { + /// The ValueType (a pair containing the value types of the two arrays). + /// + typedef vtkm::Vec ValueType; + + /// The appropriately templated tag. + /// + typedef StorageTagCartesianProduct Tag; + + /// The superclass for ArrayHandleCartesianProduct. + /// + typedef vtkm::cont::ArrayHandle Superclass; +}; + + +template +class Storage > +{ + VTKM_IS_ARRAY_HANDLE(FirstHandleType); + VTKM_IS_ARRAY_HANDLE(SecondHandleType); + VTKM_IS_ARRAY_HANDLE(ThirdHandleType); + +public: + typedef T ValueType; + + typedef ArrayPortalContCartesianProduct< ValueType, + typename FirstHandleType::PortalControl, + typename SecondHandleType::PortalControl, + typename ThirdHandleType::PortalControl> PortalType; + typedef ArrayPortalContCartesianProduct< ValueType, + typename FirstHandleType::PortalConstControl, + typename SecondHandleType::PortalConstControl, + typename ThirdHandleType::PortalConstControl> + PortalConstType; + + VTKM_CONT_EXPORT + Storage() : FirstArray(), SecondArray(), ThirdArray() { } + + VTKM_CONT_EXPORT + Storage(const FirstHandleType &array1, const SecondHandleType &array2, const ThirdHandleType &array3) + : FirstArray(array1), SecondArray(array2), ThirdArray(array3) + { + + } + + VTKM_CONT_EXPORT + PortalType GetPortal() + { + return PortalType(this->FirstArray.GetPortalControl(), + this->SecondArray.GetPortalControl(), + this->ThirdArray.GetPortalControl()); + } + + VTKM_CONT_EXPORT + PortalConstType GetPortalConst() const + { + return PortalConstType(this->FirstArray.GetPortalConstControl(), + this->SecondArray.GetPortalConstControl(), + this->ThirdArray.GetPortalConstControl()); + } + + VTKM_CONT_EXPORT + vtkm::Id GetNumberOfValues() const + { + return this->FirstArray.GetNumberOfValues() * + this->SecondArray.GetNumberOfValues() * + this->ThirdArray.GetNumberOfValues(); + } + + VTKM_CONT_EXPORT + void Allocate(vtkm::Id /*numberOfValues*/) + { + throw vtkm::cont::ErrorControlBadAllocation("Does not make sense."); + } + + VTKM_CONT_EXPORT + void Shrink(vtkm::Id /*numberOfValues*/) + { + throw vtkm::cont::ErrorControlBadAllocation("Does not make sense."); + } + + VTKM_CONT_EXPORT + void ReleaseResources() + { + // This request is ignored since it is asking to release the resources + // of the arrays, which may be used elsewhere. + } + + VTKM_CONT_EXPORT + const FirstHandleType &GetFirstArray() const + { + return this->FirstArray; + } + + VTKM_CONT_EXPORT + const SecondHandleType &GetSecondArray() const + { + return this->SecondArray; + } + + VTKM_CONT_EXPORT + const ThirdHandleType &GetThirdArray() const + { + return this->ThirdArray; + } + +private: + FirstHandleType FirstArray; + SecondHandleType SecondArray; + ThirdHandleType ThirdArray; +}; + +template +class ArrayTransfer< + T, StorageTagCartesianProduct, Device> +{ + typedef StorageTagCartesianProduct StorageTag; + typedef vtkm::cont::internal::Storage StorageType; + +public: + typedef T ValueType; + + typedef typename StorageType::PortalType PortalControl; + typedef typename StorageType::PortalConstType PortalConstControl; + + typedef vtkm::exec::internal::ArrayPortalExecCartesianProduct< + ValueType, + typename FirstHandleType::template ExecutionTypes::Portal, + typename SecondHandleType::template ExecutionTypes::Portal, + typename ThirdHandleType::template ExecutionTypes::Portal + > PortalExecution; + + typedef vtkm::exec::internal::ArrayPortalExecCartesianProduct< + ValueType, + typename FirstHandleType::template ExecutionTypes::PortalConst, + typename SecondHandleType::template ExecutionTypes::PortalConst, + typename ThirdHandleType::template ExecutionTypes::PortalConst + > PortalConstExecution; + + VTKM_CONT_EXPORT + ArrayTransfer(StorageType *storage) + : FirstArray(storage->GetFirstArray()), + SecondArray(storage->GetSecondArray()), + ThirdArray(storage->GetThirdArray()) + { } + + + VTKM_CONT_EXPORT + vtkm::Id GetNumberOfValues() const + { + return this->FirstArray.GetNumberOfValues() * + this->SecondArray.GetNumberOfValues() * + this->ThirdArray.GetNumberOfValues(); + + } + + VTKM_CONT_EXPORT + PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) { + return PortalConstExecution(this->FirstArray.PrepareForInput(Device()), + this->SecondArray.PrepareForInput(Device()), + this->ThirdArray.PrepareForInput(Device())); + } + + VTKM_CONT_EXPORT + PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData)) + { + throw vtkm::cont::ErrorControlBadAllocation( + "Cannot write to an ArrayHandleCartesianProduct. It does not make " + "sense because there is overlap in the data."); + } + + VTKM_CONT_EXPORT + PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues)) + { + throw vtkm::cont::ErrorControlBadAllocation( + "Cannot write to an ArrayHandleCartesianProduct. It does not make " + "sense because there is overlap in the data."); + } + + VTKM_CONT_EXPORT + void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const + { + // Implementation of this method should be unnecessary. The internal + // first and second array handles should automatically retrieve the + // output data as necessary. + } + + VTKM_CONT_EXPORT + void Shrink(vtkm::Id /*numberOfValues*/) + { + throw vtkm::cont::ErrorControlBadAllocation("Does not make sense."); + } + + VTKM_CONT_EXPORT + void ReleaseResources() + { + this->FirstArray.ReleaseResourcesExecution(); + this->SecondArray.ReleaseResourcesExecution(); + this->ThirdArray.ReleaseResourcesExecution(); + } + + +private: + FirstHandleType FirstArray; + SecondHandleType SecondArray; + ThirdHandleType ThirdArray; +}; +} // namespace internal + +/// ArrayHandleCartesianProduct is a specialization of ArrayHandle. It takes two delegate +/// array handle and makes a new handle that access the corresponding entries +/// in these arrays as a pair. +/// +template +class ArrayHandleCartesianProduct + : public internal::ArrayHandleCartesianProductTraits::Superclass +{ + // If the following line gives a compile error, then the FirstHandleType + // template argument is not a valid ArrayHandle type. + VTKM_IS_ARRAY_HANDLE(FirstHandleType); + VTKM_IS_ARRAY_HANDLE(SecondHandleType); + VTKM_IS_ARRAY_HANDLE(ThirdHandleType); + +public: + VTKM_ARRAY_HANDLE_SUBCLASS( + ArrayHandleCartesianProduct, + (ArrayHandleCartesianProduct), + (typename internal::ArrayHandleCartesianProductTraits< + FirstHandleType,SecondHandleType,ThirdHandleType>::Superclass)); + +private: + typedef vtkm::cont::internal::Storage StorageType; + +public: + VTKM_CONT_EXPORT + ArrayHandleCartesianProduct(const FirstHandleType &firstArray, + const SecondHandleType &secondArray, + const ThirdHandleType &thirdArray) + : Superclass(StorageType(firstArray, secondArray, thirdArray)) { } +}; + +/// A convenience function for creating an ArrayHandleCartesianProduct. It takes the two +/// arrays to be zipped together. +/// +template +VTKM_CONT_EXPORT +vtkm::cont::ArrayHandleCartesianProduct +make_ArrayHandleCartesianProduct(const FirstHandleType &first, + const SecondHandleType &second, + const ThirdHandleType &third) +{ + return ArrayHandleCartesianProduct(first, second,third); +} + +} +} // namespace vtkm::cont + +#endif //vtk_m_cont_ArrayHandleCartesianProduct_h diff --git a/vtkm/cont/CMakeLists.txt b/vtkm/cont/CMakeLists.txt index 5528ed01b..a8972957e 100644 --- a/vtkm/cont/CMakeLists.txt +++ b/vtkm/cont/CMakeLists.txt @@ -23,6 +23,7 @@ include_directories(${Boost_INCLUDE_DIRS}) set(headers ArrayHandle.h ArrayHandleCast.h + ArrayHandleCartesianProduct.h ArrayHandleCompositeVector.h ArrayHandleConstant.h ArrayHandleCounting.h @@ -44,6 +45,10 @@ set(headers CellSetPermutation.h CoordinateSystem.h DataSet.h + DataSetBuilderExplicit.h + DataSetBuilderRectilinear.h + DataSetBuilderRegular.h + DataSetFieldAdd.h DeviceAdapter.h DeviceAdapterAlgorithm.h DeviceAdapterSerial.h diff --git a/vtkm/cont/CellSetExplicit.h b/vtkm/cont/CellSetExplicit.h index d1a959476..166c40f4c 100644 --- a/vtkm/cont/CellSetExplicit.h +++ b/vtkm/cont/CellSetExplicit.h @@ -232,6 +232,7 @@ public: { this->PointToCell.Connectivity.Shrink(ConnectivityLength); this->PointToCell.ElementsValid = true; + this->PointToCell.IndexOffsetsValid = true; this->NumberOfCells = this->ConnectivityLength = -1; } @@ -364,6 +365,7 @@ public: NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag> CSE; + CSE *self = const_cast(this); self->CreateConnectivity(Device(), FromTopology(), ToTopology()); @@ -420,7 +422,7 @@ public: // // PointToCell numIndices array using expansion will be // transformed into the CellToPoint connectivity array - + if (this->CellToPoint.ElementsValid) { return; @@ -441,6 +443,7 @@ public: cellIndices.Allocate(connectivityLength); vtkm::cont::ArrayHandleCounting index(0, 1, numberOfCells); + this->PointToCell.BuildIndexOffsets(Device()); vtkm::worklet::DispatcherMapField expandDispatcher; expandDispatcher.Invoke(index, this->PointToCell.IndexOffsets, @@ -454,7 +457,7 @@ public: { this->NumberOfPoints = pointIndices.GetPortalControl().Get(connectivityLength - 1) + 1; } - vtkm::Id numberOfPoints = this->GetNumberOfPoints(); + vtkm::Id numberOfPoints = this->GetNumberOfPoints(); // CellToPoint numIndices from the now sorted PointToCell connectivity vtkm::cont::ArrayHandleConstant numArray(1, connectivityLength); diff --git a/vtkm/cont/CoordinateSystem.h b/vtkm/cont/CoordinateSystem.h index 915e89ce8..d042f61da 100644 --- a/vtkm/cont/CoordinateSystem.h +++ b/vtkm/cont/CoordinateSystem.h @@ -21,6 +21,8 @@ #define vtk_m_cont_CoordinateSystem_h #include +#include +#include #include #ifndef VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG @@ -36,6 +38,22 @@ namespace vtkm { namespace cont { +namespace detail { + +typedef vtkm::cont::ArrayHandleCompositeVectorType< + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type + ArrayHandleCompositeVectorFloat32_3Default; + +typedef vtkm::cont::ArrayHandleCompositeVectorType< + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::type + ArrayHandleCompositeVectorFloat64_3Default; + +} // namespace detail + /// \brief Default storage list for CoordinateSystem arrays. /// /// \c VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG is set to this value @@ -44,7 +62,13 @@ namespace cont { struct StorageListTagCoordinateSystemDefault : vtkm::ListTagJoin< VTKM_DEFAULT_STORAGE_LIST_TAG, - vtkm::ListTagBase > + vtkm::ListTagBase, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle >::StorageTag > > { }; typedef vtkm::cont::DynamicArrayHandleBase< diff --git a/vtkm/cont/DataSet.h b/vtkm/cont/DataSet.h index e9c6f845e..40cb3a243 100644 --- a/vtkm/cont/DataSet.h +++ b/vtkm/cont/DataSet.h @@ -75,7 +75,7 @@ public: return this->Fields[i]; } } - throw vtkm::cont::ErrorControlBadValue("No field with requested name"); + throw vtkm::cont::ErrorControlBadValue("No field with requested name: "+name); } VTKM_CONT_EXPORT diff --git a/vtkm/cont/DataSetBuilderExplicit.h b/vtkm/cont/DataSetBuilderExplicit.h new file mode 100644 index 000000000..f19fdcb74 --- /dev/null +++ b/vtkm/cont/DataSetBuilderExplicit.h @@ -0,0 +1,443 @@ +//============================================================================ +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_cont_DataSetBuilderExplicit_h +#define vtk_m_cont_DataSetBuilderExplicit_h + +#include +#include +#include +#include + +namespace vtkm { +namespace cont { + +typedef vtkm::cont::DeviceAdapterAlgorithm DFA; + +//Coordinates builder?? +//Need a singlecellset handler. + +class DataSetBuilderExplicit +{ +public: + VTKM_CONT_EXPORT + DataSetBuilderExplicit() {} + + //Single cell explicits. + //TODO + + //Zoo explicit cell + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const std::vector &xVals, + const std::vector &yVals, + const std::vector &shapes, + const std::vector &numIndices, + const std::vector &connectivity, + const std::string &coordsNm="coords", + const std::string &cellNm="cells") + { + std::vector zVals(xVals.size(),0); + return Create(xVals,yVals,zVals, + shapes,numIndices,connectivity, + coordsNm,cellNm); + } + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const std::vector &xVals, + const std::vector &yVals, + const std::vector &zVals, + const std::vector &shapes, + const std::vector &numIndices, + const std::vector &connectivity, + const std::string &coordsNm="coords", + const std::string &cellNm="cells"); + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const vtkm::cont::ArrayHandle &xVals, + const vtkm::cont::ArrayHandle &yVals, + const vtkm::cont::ArrayHandle &zVals, + const vtkm::cont::ArrayHandle &shapes, + const vtkm::cont::ArrayHandle &numIndices, + const vtkm::cont::ArrayHandle &connectivity, + const std::string &coordsNm="coords", + const std::string &cellNm="cells") + { + return BuildDataSet(xVals,yVals,zVals, + shapes,numIndices,connectivity, + coordsNm,cellNm); + } + + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const std::vector > &coords, + const std::vector &shapes, + const std::vector &numIndices, + const std::vector &connectivity, + const std::string &coordsNm="coords", + const std::string &cellNm="cells"); + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const vtkm::cont::ArrayHandle > &coords, + const vtkm::cont::ArrayHandle &shapes, + const vtkm::cont::ArrayHandle &numIndices, + const vtkm::cont::ArrayHandle &connectivity, + const std::string &coordsNm="coords", + const std::string &cellNm="cells") + { + return BuildDataSet(coords, shapes, numIndices, connectivity, + coordsNm, cellNm); + } + +private: + template + vtkm::cont::DataSet + BuildDataSet(const vtkm::cont::ArrayHandle &X, + const vtkm::cont::ArrayHandle &Y, + const vtkm::cont::ArrayHandle &Z, + const vtkm::cont::ArrayHandle &shapes, + const vtkm::cont::ArrayHandle &numIndices, + const vtkm::cont::ArrayHandle &connectivity, + const std::string &coordsNm, + const std::string &cellNm); + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + BuildDataSet(const vtkm::cont::ArrayHandle > &coords, + const vtkm::cont::ArrayHandle &shapes, + const vtkm::cont::ArrayHandle &numIndices, + const vtkm::cont::ArrayHandle &connectivity, + const std::string &coordsNm, + const std::string &cellNm); +}; + +template +vtkm::cont::DataSet +DataSetBuilderExplicit::Create(const std::vector &xVals, + const std::vector &yVals, + const std::vector &zVals, + const std::vector &shapes, + const std::vector &numIndices, + const std::vector &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + VTKM_ASSERT_CONT(xVals.size() == yVals.size() && + yVals.size() == zVals.size() && + xVals.size() > 0); + + vtkm::cont::ArrayHandle Xc, Yc, Zc; + DFA::Copy(vtkm::cont::make_ArrayHandle(xVals), Xc); + DFA::Copy(vtkm::cont::make_ArrayHandle(yVals), Yc); + DFA::Copy(vtkm::cont::make_ArrayHandle(zVals), Zc); + + vtkm::cont::ArrayHandle Sc; + vtkm::cont::ArrayHandle Nc; + vtkm::cont::ArrayHandle Cc; + DFA::Copy(vtkm::cont::make_ArrayHandle(shapes), Sc); + DFA::Copy(vtkm::cont::make_ArrayHandle(numIndices), Nc); + DFA::Copy(vtkm::cont::make_ArrayHandle(connectivity), Cc); + + return BuildDataSet(Xc,Yc,Zc, Sc,Nc,Cc, coordsNm, cellNm); +} + +template +vtkm::cont::DataSet +DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle &X, + const vtkm::cont::ArrayHandle &Y, + const vtkm::cont::ArrayHandle &Z, + const vtkm::cont::ArrayHandle &shapes, + const vtkm::cont::ArrayHandle &numIndices, + const vtkm::cont::ArrayHandle &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + VTKM_ASSERT_CONT(X.GetNumberOfValues() == Y.GetNumberOfValues() && + Y.GetNumberOfValues() == Z.GetNumberOfValues() && + X.GetNumberOfValues() > 0 && + shapes.GetNumberOfValues() == numIndices.GetNumberOfValues()); + + vtkm::cont::DataSet dataSet; + dataSet.AddCoordinateSystem( + vtkm::cont::CoordinateSystem(coordsNm, 1, + make_ArrayHandleCompositeVector(X,0, Y,0, Z,0))); + vtkm::Id nPts = X.GetNumberOfValues(); + vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, 3); + + cellSet.Fill(shapes, numIndices, connectivity); + dataSet.AddCellSet(cellSet); + + return dataSet; +} + +template +vtkm::cont::DataSet +DataSetBuilderExplicit::Create(const std::vector > &coords, + const std::vector &shapes, + const std::vector &numIndices, + const std::vector &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + vtkm::cont::DataSet dataSet; + + vtkm::cont::ArrayHandle > coordsArray; + DFA::Copy(vtkm::cont::make_ArrayHandle(coords), coordsArray); + + dataSet.AddCoordinateSystem( + vtkm::cont::CoordinateSystem(coordsNm, 1, coordsArray)); + + vtkm::cont::ArrayHandle Sc; + vtkm::cont::ArrayHandle Nc; + vtkm::cont::ArrayHandle Cc; + DFA::Copy(vtkm::cont::make_ArrayHandle(shapes), Sc); + DFA::Copy(vtkm::cont::make_ArrayHandle(numIndices), Nc); + DFA::Copy(vtkm::cont::make_ArrayHandle(connectivity), Cc); + + return Create(coordsArray, Sc, Nc, Cc, coordsNm, cellNm); +} + +template +VTKM_CONT_EXPORT +vtkm::cont::DataSet +DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle > &coords, + const vtkm::cont::ArrayHandle &shapes, + const vtkm::cont::ArrayHandle &numIndices, + const vtkm::cont::ArrayHandle &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + vtkm::cont::DataSet dataSet; + + dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, + 1, coords)); + vtkm::Id nPts = static_cast(coords.GetNumberOfValues()); + vtkm::cont::CellSetExplicit<> cellSet(nPts, cellNm, 3); + + cellSet.Fill(shapes, numIndices, connectivity); + dataSet.AddCellSet(cellSet); + + return dataSet; +} + +class DataSetBuilderExplicitIterative +{ +public: + VTKM_CONT_EXPORT + DataSetBuilderExplicitIterative() {} + + VTKM_CONT_EXPORT + void Begin(const std::string &_coordNm="coords", + const std::string &_cellNm="cells") + { + this->coordNm = _coordNm; + this->cellNm = _cellNm; + this->points.resize(0); + this->shapes.resize(0); + this->numIdx.resize(0); + this->connectivity.resize(0); + } + + //Define points. + VTKM_CONT_EXPORT + vtkm::cont::DataSet Create(); + + VTKM_CONT_EXPORT + vtkm::Id AddPoint(const vtkm::Vec &pt) + { + points.push_back(pt); + vtkm::Id id = static_cast(points.size()); + return id; + } + VTKM_CONT_EXPORT + vtkm::Id AddPoint(const vtkm::Float32 &x, + const vtkm::Float32 &y, + const vtkm::Float32 &z=0) + { + points.push_back(vtkm::make_Vec(x,y,z)); + vtkm::Id id = static_cast(points.size()); + return id; + } + + template + VTKM_CONT_EXPORT + vtkm::Id AddPoint(const T &x, const T &y, const T &z=0) + { + return AddPoint(static_cast(x), + static_cast(y), + static_cast(z)); + } + + template + VTKM_CONT_EXPORT + vtkm::Id AddPoint(const vtkm::Vec &pt) + { + return AddPoint(static_cast >(pt)); + } + + //Define cells. + VTKM_CONT_EXPORT + void AddCell(vtkm::UInt8 shape) + { + this->shapes.push_back(shape); + this->numIdx.push_back(0); + } + VTKM_CONT_EXPORT + void AddCell(const vtkm::UInt8 &shape, const std::vector &conn) + { + this->shapes.push_back(shape); + this->numIdx.push_back(static_cast(conn.size())); + connectivity.insert(connectivity.end(), conn.begin(), conn.end()); + } + VTKM_CONT_EXPORT + void AddCell(const vtkm::UInt8 &shape, const vtkm::Id *conn, const vtkm::IdComponent &n) + { + this->shapes.push_back(shape); + this->numIdx.push_back(n); + for (int i = 0; i < n; i++) + connectivity.push_back(conn[i]); + } + VTKM_CONT_EXPORT + void AddCellPoint(vtkm::Id pointIndex) + { + VTKM_ASSERT_CONT(this->numIdx.size() > 0); + this->connectivity.push_back(pointIndex); + this->numIdx.back() += 1; + } + +private: + std::string coordNm, cellNm; + + std::vector > points; + std::vector shapes; + std::vector numIdx; + std::vector connectivity; +}; + +vtkm::cont::DataSet +DataSetBuilderExplicitIterative::Create() +{ + DataSetBuilderExplicit dsb; + return dsb.Create(points, shapes, numIdx, connectivity, coordNm, cellNm); +} + + + +#if 0 +template +vtkm::cont::DataSet +DataSetBuilderExplicit::Create(const std::vector &xVals, + const std::vector &yVals, + const std::vector &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + VTKM_CONT_ASSERT(xVals.size() == yVals.size() && xVals.size() > 0); + vtkm::cont::DataSet dataSet; + + typedef vtkm::Vec CoordType; + std::vector coords(xVals.size()); + + for (size_t i=0; i < coords.size(); i++) + { + coords[i][0] = xVals[i]; + coords[i][1] = yVals[i]; + coords[i][2] = 0; + } + dataSet.AddCoordinateSystem( + vtkm::cont::CoordinateSystem(coordsNm, 1, coords)); + + vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm); + cellSet.FillViaCopy(connectivity); + dataSet.AddCellSet(cellSet); + + return dataSet; +} + +template +vtkm::cont::DataSet +DataSetBuilderExplicit::Create(const std::vector &xVals, + const std::vector &yVals, + const std::vector &zVals, + const std::vector &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + VTKM_CONT_ASSERT(xVals.size() == yVals.size() && + yVals.size() == zVals.size() && + xVals.size() > 0); + vtkm::cont::DataSet dataSet; + + typedef vtkm::Vec CoordType; + std::vector coords(xVals.size()); + + vtkm::Id nPts = static_cast(coords.size()); + for (vtkm::Id i=0; i < nPts; i++) + { + coords[i][0] = xVals[i]; + coords[i][1] = yVals[i]; + coords[i][2] = zVals[i]; + } + dataSet.AddCoordinateSystem( + vtkm::cont::CoordinateSystem(coordsNm, 1, coords)); + + vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm); + cellSet.FillViaCopy(connectivity); + dataSet.AddCellSet(cellSet); + + return dataSet; +} + +template +vtkm::cont::DataSet +DataSetBuilderExplicit::Create(const std::vector > &coords, + const std::vector &connectivity, + const std::string &coordsNm, + const std::string &cellNm) +{ + vtkm::cont::DataSet dataSet; + + vtkm::cont::ArrayHandle > coordsArray; + DFA::Copy(vtkm::cont::make_ArrayHandle(coords), coordsArray); + + dataSet.AddCoordinateSystem( + vtkm::cont::CoordinateSystem(coordsNm, 1, coordsArray)); + + vtkm::cont::CellSetSingleType< > cellSet(CellType(), cellNm); + cellSet.FillViaCopy(connectivity); + dataSet.AddCellSet(cellSet); + + return dataSet; +} +#endif + +} +} + +#endif //vtk_m_cont_DataSetBuilderExplicit_h diff --git a/vtkm/cont/DataSetBuilderRectilinear.h b/vtkm/cont/DataSetBuilderRectilinear.h new file mode 100644 index 000000000..8e662c802 --- /dev/null +++ b/vtkm/cont/DataSetBuilderRectilinear.h @@ -0,0 +1,196 @@ +//============================================================================ +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_cont_DataSetBuilderRectilinear_h +#define vtk_m_cont_DataSetBuilderRectilinear_h + +#include +#include +#include +#include + +namespace vtkm { +namespace cont { + +typedef vtkm::cont::DeviceAdapterAlgorithm DFA; + +class DataSetBuilderRectilinear +{ +public: + VTKM_CONT_EXPORT + DataSetBuilderRectilinear() {} + + //2D grids. + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(vtkm::Id nx, vtkm::Id ny, + T *xvals, T *yvals, + std::string coordNm="coords", std::string cellNm="cells") + { + T zvals = 0; + return Create(2, nx,ny, 1, xvals, yvals, &zvals, coordNm, cellNm); + } + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz, + T *xvals, T *yvals, T *zvals, + std::string coordNm, std::string cellNm) + { + VTKM_ASSERT_CONT(nx>1 && ny>1 && + ((dim==2 && nz==1)||(dim==3 && nz>=1))); + + vtkm::cont::ArrayHandle Xc, Yc, Zc; + DFA::Copy(vtkm::cont::make_ArrayHandle(xvals,nx), Xc); + DFA::Copy(vtkm::cont::make_ArrayHandle(yvals,ny), Yc); + DFA::Copy(vtkm::cont::make_ArrayHandle(zvals,nz), Zc); + + return BuildDataSet(dim, Xc,Yc,Zc, coordNm, cellNm); + } + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const std::vector &xvals, const std::vector &yvals, + std::string coordNm="coords", std::string cellNm="cells") + { + std::vector zvals(1,0); + return BuildDataSet(2, xvals,yvals,zvals, coordNm,cellNm); + } + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const vtkm::cont::ArrayHandle &xvals, + const vtkm::cont::ArrayHandle &yvals, + std::string coordNm="coords", std::string cellNm="cells") + { + VTKM_ASSERT_CONT(xvals.GetNumberOfValues()>1 && yvals.GetNumberOfValues()>1); + + vtkm::cont::ArrayHandle zvals; + DFA::Copy(vtkm::cont::make_ArrayHandle(std::vector(1,0)), zvals); + return BuildDataSet(2, xvals,yvals,zvals, coordNm, cellNm); + } + + //3D grids. + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(vtkm::Id nx, vtkm::Id ny, vtkm::Id nz, + T *xvals, T *yvals, T *zvals, + std::string coordNm="coords", std::string cellNm="cells") + { + return Create(3, nx,ny,nz, xvals, yvals, zvals, coordNm, cellNm); + } + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const std::vector &xvals, + const std::vector &yvals, + const std::vector &zvals, + std::string coordNm="coords", std::string cellNm="cells") + { + return BuildDataSet(3, xvals, yvals, zvals, coordNm, cellNm); + } + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const vtkm::cont::ArrayHandle &xvals, + const vtkm::cont::ArrayHandle &yvals, + const vtkm::cont::ArrayHandle &zvals, + std::string coordNm="coords", std::string cellNm="cells") + { + VTKM_ASSERT_CONT(xvals.GetNumberOfValues()>1 && + yvals.GetNumberOfValues()>1 && + zvals.GetNumberOfValues()>1); + return BuildDataSet(3, xvals,yvals,zvals, coordNm, cellNm); + } + +private: + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + BuildDataSet(int dim, + const std::vector &xvals, + const std::vector &yvals, + const std::vector &zvals, + std::string coordNm, std::string cellNm) + { + VTKM_ASSERT_CONT(xvals.size()>1 && yvals.size()>1 && + ((dim==2 && zvals.size()==1)||(dim==3 && zvals.size()>=1))); + + vtkm::cont::ArrayHandle Xc, Yc, Zc; + DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), Xc); + DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Yc); + DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Zc); + + return BuildDataSet(dim, Xc,Yc,Zc, coordNm, cellNm); + } + + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + BuildDataSet(int dim, + const vtkm::cont::ArrayHandle &X, + const vtkm::cont::ArrayHandle &Y, + const vtkm::cont::ArrayHandle &Z, + std::string coordNm, std::string cellNm) + { + vtkm::cont::DataSet dataSet; + + //Convert all coordinates to floatDefault. + vtkm::cont::ArrayHandleCartesianProduct< + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle > coords; + + vtkm::cont::ArrayHandle Xc, Yc, Zc; + DFA::Copy(X, Xc); + DFA::Copy(Y, Yc); + DFA::Copy(Z, Zc); + + coords = vtkm::cont::make_ArrayHandleCartesianProduct(Xc,Yc,Zc); + vtkm::cont::CoordinateSystem cs(coordNm, 1, coords); + dataSet.AddCoordinateSystem(cs); + + if (dim == 2) + { + vtkm::cont::CellSetStructured<2> cellSet(cellNm); + cellSet.SetPointDimensions(vtkm::make_Vec(Xc.GetNumberOfValues(), + Yc.GetNumberOfValues())); + dataSet.AddCellSet(cellSet); + } + else + { + vtkm::cont::CellSetStructured<3> cellSet(cellNm); + cellSet.SetPointDimensions(vtkm::make_Vec(Xc.GetNumberOfValues(), + Yc.GetNumberOfValues(), + Zc.GetNumberOfValues())); + dataSet.AddCellSet(cellSet); + } + + return dataSet; + } +}; + +} // namespace cont +} // namespace vtkm + +#endif //vtk_m_cont_DataSetBuilderRectilinear_h diff --git a/vtkm/cont/DataSetBuilderRegular.h b/vtkm/cont/DataSetBuilderRegular.h new file mode 100644 index 000000000..ed1832ff1 --- /dev/null +++ b/vtkm/cont/DataSetBuilderRegular.h @@ -0,0 +1,108 @@ +//============================================================================ +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_cont_DataSetBuilderRegular_h +#define vtk_m_cont_DataSetBuilderRegular_h + +#include +#include +#include + +namespace vtkm { +namespace cont { + +class DataSetBuilderRegular +{ +public: + VTKM_CONT_EXPORT + DataSetBuilderRegular() {} + + //2D regular grids. + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const vtkm::Id2 &dimensions, + const vtkm::Vec &origin = vtkm::Vec(0.0f), + const vtkm::Vec &spacing = vtkm::Vec(1.0f), + std::string coordNm="coords", std::string cellNm="cells") + { + return CreateDS(2, + dimensions[0],dimensions[1],1, origin[0],origin[1],0.0f, + spacing[0],spacing[1],1.0f, + coordNm, cellNm); + } + + //3D regular grids. + VTKM_CONT_EXPORT + vtkm::cont::DataSet + Create(const vtkm::Id3 &dimensions, + const vtkm::Vec &origin = vtkm::Vec(0.0f), + const vtkm::Vec &spacing = vtkm::Vec(1.0f), + std::string coordNm="coords", std::string cellNm="cells") + { + return CreateDS(3, + dimensions[0],dimensions[1],dimensions[2], + origin[0],origin[1],origin[2], + spacing[0],spacing[1],spacing[2], + coordNm, cellNm); + } + +private: + template + VTKM_CONT_EXPORT + vtkm::cont::DataSet + CreateDS(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz, + T originX, T originY, T originZ, + T spacingX, T spacingY, T spacingZ, + std::string coordNm, std::string cellNm) + { + VTKM_ASSERT_CONT(nx>1 && ny>1 && ((dim==2 && nz==1)||(dim==3 && nz>=1))); + VTKM_ASSERT_CONT(spacingX>0 && spacingY>0 && spacingZ>0); + vtkm::cont::DataSet dataSet; + + vtkm::cont::ArrayHandleUniformPointCoordinates + coords(vtkm::Id3(nx, ny, nz), + vtkm::Vec(originX, originY,originZ), + vtkm::Vec(spacingX, spacingY,spacingZ)); + + vtkm::cont::CoordinateSystem cs(coordNm, 1, coords); + dataSet.AddCoordinateSystem(cs); + + if (dim == 2) + { + vtkm::cont::CellSetStructured<2> cellSet(cellNm); + cellSet.SetPointDimensions(vtkm::make_Vec(nx,ny)); + dataSet.AddCellSet(cellSet); + } + else + { + vtkm::cont::CellSetStructured<3> cellSet(cellNm); + cellSet.SetPointDimensions(vtkm::make_Vec(nx,ny,nz)); + dataSet.AddCellSet(cellSet); + } + + return dataSet; + } + +}; + +} // namespace cont +} // namespace vtkm + + +#endif //vtk_m_cont_DataSetBuilderRegular_h diff --git a/vtkm/cont/DataSetFieldAdd.h b/vtkm/cont/DataSetFieldAdd.h new file mode 100644 index 000000000..6b6d29258 --- /dev/null +++ b/vtkm/cont/DataSetFieldAdd.h @@ -0,0 +1,143 @@ +//============================================================================ +// 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. +// +// Copyright 2014 Sandia Corporation. +// Copyright 2014 UT-Battelle, LLC. +// Copyright 2014 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ + +#ifndef vtk_m_cont_DataSetFieldAdd_h +#define vtk_m_cont_DataSetFieldAdd_h + +#include +#include + +namespace vtkm { +namespace cont { + +class DataSetFieldAdd +{ +public: + VTKM_CONT_EXPORT + DataSetFieldAdd() {} + + //Point centered fields. + template + VTKM_CONT_EXPORT + void AddPointField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + vtkm::cont::ArrayHandle &field) + { + dataSet.AddField(Field(fieldName, 1, vtkm::cont::Field::ASSOC_POINTS, + field)); + } + + template + VTKM_CONT_EXPORT + void AddPointField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + const std::vector &field) + { + dataSet.AddField(Field(fieldName, 1, vtkm::cont::Field::ASSOC_POINTS, + field)); + } + + template + VTKM_CONT_EXPORT + void AddPointField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + const T *field, const vtkm::Id &n) + { + dataSet.AddField(Field(fieldName, 1, vtkm::cont::Field::ASSOC_POINTS, + field, n)); + } + + //Cell centered field + template + VTKM_CONT_EXPORT + void AddCellField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + vtkm::cont::ArrayHandle &field, + const std::string &cellSetName) + { + dataSet.AddField(Field(fieldName, 1, vtkm::cont::Field::ASSOC_CELL_SET, + cellSetName, field)); + } + + template + VTKM_CONT_EXPORT + void AddCellField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + const std::vector &field, + const std::string &cellSetName) + { + dataSet.AddField(Field(fieldName, 1, vtkm::cont::Field::ASSOC_CELL_SET, + cellSetName, field)); + } + + template + VTKM_CONT_EXPORT + void AddCellField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + const T *field, const vtkm::Id &n, + const std::string &cellSetName) + { + dataSet.AddField(Field(fieldName, 1, vtkm::cont::Field::ASSOC_CELL_SET, + cellSetName, field, n)); + } + + template + VTKM_CONT_EXPORT + void AddCellField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + vtkm::cont::ArrayHandle &field, + vtkm::Id cellSetIndex = 0) + { + std::string cellSetName = + dataSet.GetCellSet(cellSetIndex).GetCellSet().GetName(); + this->AddCellField(dataSet, fieldName, field, cellSetName); + } + template + VTKM_CONT_EXPORT + void AddCellField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + const std::vector &field, + vtkm::Id cellSetIndex = 0) + { + std::string cellSetName = + dataSet.GetCellSet(cellSetIndex).GetCellSet().GetName(); + this->AddCellField(dataSet, fieldName, field, cellSetName); + } + + template + VTKM_CONT_EXPORT + void AddCellField(vtkm::cont::DataSet &dataSet, + const std::string &fieldName, + const T *field, const vtkm::Id &n, + vtkm::Id cellSetIndex = 0) + { + std::string cellSetName = + dataSet.GetCellSet(cellSetIndex).GetCellSet().GetName(); + this->AddCellField(dataSet, fieldName, field, n, cellSetName); + } + + +}; + +} +}//namespace vtkm::cont + + +#endif //vtk_m_cont_DataSetFieldAdd_h diff --git a/vtkm/cont/testing/CMakeLists.txt b/vtkm/cont/testing/CMakeLists.txt index 8859924f4..699683bf9 100644 --- a/vtkm/cont/testing/CMakeLists.txt +++ b/vtkm/cont/testing/CMakeLists.txt @@ -19,6 +19,7 @@ ##============================================================================ set(headers + ExplicitTestData.h MakeTestDataSet.h Testing.h TestingArrayHandles.h @@ -33,6 +34,7 @@ vtkm_declare_headers(${headers}) set(unit_tests UnitTestArrayHandle.cxx + UnitTestArrayHandleCartesianProduct.cxx UnitTestArrayHandleCompositeVector.cxx UnitTestArrayHandleCounting.cxx UnitTestArrayHandleFancy.cxx @@ -44,7 +46,11 @@ set(unit_tests UnitTestArrayPortalToIterators.cxx UnitTestContTesting.cxx UnitTestComputeBoundsSerial.cxx + UnitTestDataSetBuilderExplicit.cxx + UnitTestDataSetBuilderRectilinear.cxx + UnitTestDataSetBuilderRegular.cxx UnitTestDataSetRegular.cxx + UnitTestDataSetRectilinear.cxx UnitTestDataSetExplicit.cxx UnitTestDataSetSingleType.cxx UnitTestDataSetPermutation.cxx diff --git a/vtkm/cont/testing/ExplicitTestData.h b/vtkm/cont/testing/ExplicitTestData.h new file mode 100644 index 000000000..93f93a8c6 --- /dev/null +++ b/vtkm/cont/testing/ExplicitTestData.h @@ -0,0 +1,878 @@ +//============================================================================= +// +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +// +//============================================================================= + +#include +#include + +namespace vtkm { +namespace cont { +namespace testing { + +// VTK dataset created from noise.silo in VisIt. +// Resample(5,5,5), IsoVolume(hardglobal [3.8,max]) +namespace ExplicitData0 { + +static const std::size_t numPoints = 48; +vtkm::Float32 coords[numPoints*3] = { + -5.000f, 0.000f, -10.000f, + 5.000f, 0.000f, -5.000f, 0.000f, 5.000f, -5.000f, + 5.000f, 5.000f, -5.000f, 10.000f, 5.000f, -5.000f, + 5.000f, 5.000f, 0.000f, 5.000f, 0.000f, 0.000f, + 5.000f, 5.000f, 5.000f, -5.000f, -1.227f, -10.000f, + -6.101f, 0.000f, -10.000f, -5.000f, 0.000f, -7.102f, + -1.656f, 0.000f, -10.000f, 5.000f, -3.541f, -5.000f, + 5.000f, 0.000f, -6.985f, 1.451f, 0.000f, -5.000f, + 7.666f, 0.000f, -5.000f, -5.000f, 1.987f, -10.000f, + 0.000f, 5.000f, -6.763f, -1.197f, 5.000f, -5.000f, + 0.000f, 1.663f, -5.000f, 5.000f, 5.000f, -6.749f, + 10.000f, 5.000f, -5.900f, 10.000f, 3.188f, -5.000f, + 0.000f, 6.828f, -5.000f, 5.000f, 7.036f, -5.000f, + 10.000f, 5.958f, -5.000f, 2.119f, 0.000f, 0.000f, + 5.000f, -4.680f, 0.000f, 9.847f, 0.000f, 0.000f, + 0.000f, 5.000f, -0.505f, 0.373f, 5.000f, 0.000f, + 10.000f, 5.000f, -3.573f, 7.394f, 5.000f, 0.000f, + 5.000f, 7.425f, 0.000f, 5.000f, 0.000f, 4.298f, + 4.414f, 5.000f, 5.000f, 5.000f, 3.063f, 5.000f, + 7.478f, 5.000f, 5.000f, 5.000f, 5.283f, 5.000f, + 5.000f, 5.000f, 5.321f, 2.290f, 2.333f, -6.099f, + 7.533f, 2.638f, -5.927f, 0.789f, 2.333f, -2.101f, + 8.981f, 2.638f, -2.715f, 2.075f, 6.258f, -2.101f, + 7.479f, 6.084f, -2.715f, 3.381f, 2.613f, 2.860f, + 6.944f, 2.613f, 2.860f, +}; + +static const std::size_t numCells = 74; +static const std::size_t numConn = 336; +vtkm::Id conn[numConn] = { + 8, 9, 10, 0, + 10, 11, 8, 0, + 12, 13, 14, 1, + 12, 15, 13, 1, + 16, 10, 9, 0, + 11, 10, 16, 0, + 17, 18, 19, 2, + 2, 19, 17, 40, + 14, 1, 13, 40, + 2, 3, 1, 40, + 1, 15, 13, 41, + 22, 4, 21, 41, + 1, 3, 4, 41, + 17, 23, 18, 2, + 19, 18, 29, 2, + 5, 42, 2, 3, + 2, 1, 3, 42, + 2, 29, 19, 42, + 5, 4, 43, 3, + 4, 3, 1, 43, + 4, 22, 31, 43, + 23, 29, 18, 2, + 2, 23, 29, 44, + 30, 33, 5, 44, + 2, 5, 3, 44, + 4, 31, 25, 45, + 32, 5, 33, 45, + 4, 3, 5, 45, + 27, 26, 34, 6, + 34, 28, 27, 6, + 6, 26, 34, 46, + 36, 35, 7, 46, + 6, 7, 5, 46, + 6, 34, 28, 47, + 36, 7, 37, 47, + 6, 5, 7, 47, + 36, 35, 39, 7, + 39, 37, 36, 7, + 38, 39, 35, 7, + 38, 37, 39, 7, + 3, 2, 17, 20, 40, + 1, 3, 20, 13, 40, + 19, 2, 1, 14, 40, + 3, 1, 13, 20, 41, + 4, 3, 20, 21, 41, + 15, 1, 4, 22, 41, + 1, 6, 5, 3, 42, + 6, 26, 30, 5, 42, + 14, 26, 6, 1, 42, + 2, 19, 14, 1, 42, + 30, 29, 2, 5, 42, + 1, 3, 5, 6, 43, + 6, 5, 32, 28, 43, + 15, 1, 6, 28, 43, + 4, 1, 15, 22, 43, + 32, 5, 4, 31, 43, + 3, 24, 23, 2, 44, + 5, 33, 24, 3, 44, + 29, 30, 5, 2, 44, + 3, 4, 25, 24, 45, + 5, 3, 24, 33, 45, + 31, 4, 5, 32, 45, + 5, 30, 26, 6, 46, + 7, 35, 30, 5, 46, + 34, 36, 7, 6, 46, + 5, 6, 28, 32, 47, + 7, 5, 32, 37, 47, + 34, 6, 7, 36, 47, + 3, 20, 24, 2, 17, 23, + 4, 21, 25, 3, 20, 24, + 6, 26, 27, 1, 14, 12, + 6, 27, 28, 1, 12, 15, + 5, 30, 33, 7, 35, 38, + 7, 37, 38, 5, 32, 33, +}; + +vtkm::IdComponent numIndices[numCells] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, + 6, 6, +}; + +vtkm::UInt8 shapes[numCells] = { + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, +}; + +vtkm::Float32 pointData[numPoints] = { + 4.078f, 4.368f, 4.266f, 4.356f, 4.083f, 4.450f, 4.373f, 3.859f, + 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, + 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, + 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, + 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, + 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, 3.800f, +}; +} //ExplicitData0 + +// VTK dataset created from noise.silo in VisIt. +// Resample(5,5,5), CylinderSlice((-10,-10,-10),(10,10,10), r=6), field=hardyglobal +namespace ExplicitData1 { +static const std::size_t numPoints = 107; +vtkm::Float32 coords[numPoints*3] = { + -5.000f, -10.000f, -10.000f, + -10.000f, -5.000f, -10.000f, -10.000f, -10.000f, -5.000f, + -5.000f, -5.000f, -10.000f, -10.000f, -5.000f, -5.000f, + -5.000f, -10.000f, -5.000f, 0.000f, -5.000f, -5.000f, + -5.000f, -5.000f, -5.000f, -5.000f, 0.000f, -5.000f, + 0.000f, 0.000f, -5.000f, -5.000f, -5.000f, 0.000f, + 5.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, + 0.000f, -5.000f, 0.000f, -5.000f, 0.000f, 0.000f, + 0.000f, 5.000f, 0.000f, 5.000f, 5.000f, 0.000f, + 0.000f, 0.000f, 5.000f, 10.000f, 5.000f, 5.000f, + 5.000f, 5.000f, 5.000f, 5.000f, 0.000f, 5.000f, + 0.000f, 5.000f, 5.000f, 5.000f, 10.000f, 5.000f, + 5.000f, 5.000f, 10.000f, 5.000f, 10.000f, 10.000f, + 10.000f, 10.000f, 5.000f, 10.000f, 5.000f, 10.000f, + -10.000f, -10.000f, -10.000f, -10.000f, -10.000f, -10.000f, + -10.000f, -10.000f, -10.000f, -3.540f, -10.000f, -5.000f, + -4.570f, -10.000f, -10.000f, 0.000f, -7.260f, -5.000f, + 0.000f, -5.000f, -7.260f, -3.540f, -5.000f, -10.000f, + 1.368f, -5.000f, -5.000f, -5.000f, -3.540f, -10.000f, + -10.000f, -4.570f, -10.000f, -5.000f, 0.000f, -7.260f, + -7.260f, 0.000f, -5.000f, -10.000f, -3.540f, -5.000f, + 0.000f, 0.000f, -6.600f, 2.538f, 0.000f, -5.000f, + -5.000f, 1.368f, -5.000f, 0.000f, 2.538f, -5.000f, + -5.000f, -10.000f, -3.540f, -10.000f, -10.000f, -4.570f, + -5.000f, -7.260f, 0.000f, -7.260f, -5.000f, 0.000f, + -10.000f, -5.000f, -3.540f, 0.000f, -6.600f, 0.000f, + 2.538f, -5.000f, 0.000f, -6.600f, 0.000f, 0.000f, + 5.000f, -2.900f, 0.000f, 5.000f, 0.000f, -2.900f, + 6.933f, 0.000f, 0.000f, -5.000f, 2.538f, 0.000f, + 0.000f, 5.000f, -2.900f, -2.900f, 5.000f, 0.000f, + 5.000f, 5.000f, -1.933f, 7.900f, 5.000f, 0.000f, + 0.000f, 6.933f, 0.000f, 5.000f, 7.900f, 0.000f, + -5.000f, -5.000f, 1.368f, 0.000f, -5.000f, 2.538f, + -5.000f, 0.000f, 2.538f, 0.000f, -2.900f, 5.000f, + -2.900f, 0.000f, 5.000f, 5.000f, -1.933f, 5.000f, + 7.900f, 0.000f, 5.000f, -1.933f, 5.000f, 5.000f, + 10.000f, 2.100f, 5.000f, 10.000f, 5.000f, 2.100f, + 0.000f, 7.900f, 5.000f, 5.000f, 10.000f, 2.100f, + 2.100f, 10.000f, 5.000f, 10.000f, 10.000f, 3.067f, + 0.000f, 0.000f, 6.933f, 5.000f, 0.000f, 7.900f, + 0.000f, 5.000f, 7.900f, 5.000f, 2.100f, 10.000f, + 2.100f, 5.000f, 10.000f, 10.000f, 3.067f, 10.000f, + 3.067f, 10.000f, 10.000f, 10.000f, 10.000f, 10.000f, + 10.000f, 10.000f, 10.000f, 10.000f, 10.000f, 10.000f, + -7.143f, -7.143f, -7.143f, -2.330f, -7.452f, -7.452f, + -7.452f, -2.330f, -7.452f, -2.708f, -2.708f, -8.224f, + -7.452f, -7.452f, -2.330f, -2.708f, -8.224f, -2.708f, + -8.224f, -2.708f, -2.708f, 3.289f, -2.580f, -2.580f, + -2.580f, 3.289f, -2.580f, 2.508f, 2.508f, -3.547f, + -2.580f, -2.580f, 3.289f, 2.508f, -3.547f, 2.508f, + -3.547f, 2.508f, 2.508f, 8.547f, 2.420f, 2.420f, + 2.420f, 8.547f, 2.420f, 7.580f, 7.580f, 1.453f, + 2.420f, 2.420f, 8.547f, 7.580f, 1.453f, 7.580f, + 1.453f, 7.580f, 7.580f, 7.143f, 7.143f, 7.143f, +}; + +static const std::size_t numCells = 186; +static const std::size_t numConn = 876; +vtkm::Id conn[numConn] = { + 0, 1, 2, 87, + 0, 3, 1, 87, + 1, 4, 2, 87, + 2, 5, 0, 87, + 3, 88, 6, 7, + 6, 5, 7, 88, + 6, 33, 32, 88, + 32, 35, 33, 6, + 4, 89, 8, 7, + 8, 3, 7, 89, + 8, 39, 38, 89, + 6, 90, 3, 7, + 3, 8, 7, 90, + 3, 34, 36, 90, + 38, 43, 39, 8, + 44, 41, 42, 9, + 4, 10, 91, 7, + 10, 7, 5, 91, + 10, 47, 48, 91, + 6, 5, 92, 7, + 5, 7, 10, 92, + 5, 45, 30, 92, + 10, 4, 93, 7, + 4, 7, 8, 93, + 4, 40, 49, 93, + 9, 94, 11, 12, + 11, 13, 12, 94, + 11, 54, 53, 94, + 53, 55, 54, 11, + 14, 95, 15, 12, + 15, 9, 12, 95, + 15, 58, 57, 95, + 11, 96, 9, 12, + 9, 15, 12, 96, + 9, 42, 44, 96, + 57, 61, 58, 15, + 62, 59, 60, 16, + 47, 48, 63, 10, + 64, 51, 50, 13, + 14, 17, 97, 12, + 17, 12, 13, 97, + 17, 66, 67, 97, + 11, 13, 98, 12, + 13, 12, 17, 98, + 13, 64, 51, 98, + 56, 65, 52, 14, + 17, 14, 99, 12, + 14, 12, 15, 99, + 14, 56, 65, 99, + 16, 100, 18, 19, + 18, 20, 19, 100, + 18, 72, 71, 100, + 21, 101, 22, 19, + 22, 16, 19, 101, + 22, 75, 74, 101, + 18, 102, 16, 19, + 16, 22, 19, 102, + 16, 60, 62, 102, + 66, 67, 77, 17, + 78, 69, 68, 20, + 21, 23, 103, 19, + 23, 19, 20, 103, + 23, 80, 81, 103, + 18, 20, 104, 19, + 20, 19, 23, 104, + 20, 78, 69, 104, + 73, 79, 70, 21, + 23, 21, 105, 19, + 21, 19, 22, 105, + 21, 73, 79, 105, + 24, 25, 26, 106, + 24, 26, 23, 106, + 26, 25, 18, 106, + 25, 24, 22, 106, + 7, 4, 1, 3, 87, + 5, 7, 3, 0, 87, + 2, 4, 7, 5, 87, + 5, 0, 3, 7, 88, + 0, 31, 34, 3, 88, + 30, 31, 0, 5, 88, + 6, 32, 30, 5, 88, + 34, 33, 6, 3, 88, + 3, 1, 4, 7, 89, + 1, 37, 40, 4, 89, + 36, 37, 1, 3, 89, + 8, 38, 36, 3, 89, + 40, 39, 8, 4, 89, + 8, 9, 6, 7, 90, + 9, 41, 33, 6, 90, + 38, 41, 9, 8, 90, + 3, 36, 38, 8, 90, + 33, 34, 3, 6, 90, + 5, 7, 4, 2, 91, + 2, 4, 49, 46, 91, + 45, 5, 2, 46, 91, + 10, 5, 45, 47, 91, + 49, 4, 10, 48, 91, + 10, 7, 6, 13, 92, + 13, 6, 32, 50, 92, + 47, 10, 13, 50, 92, + 5, 10, 47, 45, 92, + 32, 6, 5, 30, 92, + 8, 7, 10, 14, 93, + 14, 10, 48, 52, 93, + 39, 8, 14, 52, 93, + 4, 8, 39, 40, 93, + 48, 10, 4, 49, 93, + 13, 6, 9, 12, 94, + 6, 35, 42, 9, 94, + 51, 35, 6, 13, 94, + 11, 53, 51, 13, 94, + 42, 54, 11, 9, 94, + 9, 8, 14, 12, 95, + 8, 43, 56, 14, 95, + 44, 43, 8, 9, 95, + 15, 57, 44, 9, 95, + 56, 58, 15, 14, 95, + 15, 16, 11, 12, 96, + 16, 59, 54, 11, 96, + 57, 59, 16, 15, 96, + 9, 44, 57, 15, 96, + 54, 42, 9, 11, 96, + 13, 12, 14, 10, 97, + 10, 14, 65, 63, 97, + 64, 13, 10, 63, 97, + 17, 13, 64, 66, 97, + 65, 14, 17, 67, 97, + 17, 12, 11, 20, 98, + 20, 11, 53, 68, 98, + 66, 17, 20, 68, 98, + 13, 17, 66, 64, 98, + 53, 11, 13, 51, 98, + 15, 12, 17, 21, 99, + 21, 17, 67, 70, 99, + 58, 15, 21, 70, 99, + 14, 15, 58, 56, 99, + 67, 17, 14, 65, 99, + 20, 11, 16, 19, 100, + 11, 55, 60, 16, 100, + 69, 55, 11, 20, 100, + 18, 71, 69, 20, 100, + 60, 72, 18, 16, 100, + 16, 15, 21, 19, 101, + 15, 61, 73, 21, 101, + 62, 61, 15, 16, 101, + 22, 74, 62, 16, 101, + 73, 75, 22, 21, 101, + 22, 25, 18, 19, 102, + 25, 76, 72, 18, 102, + 74, 76, 25, 22, 102, + 16, 62, 74, 22, 102, + 72, 60, 16, 18, 102, + 20, 19, 21, 17, 103, + 17, 21, 79, 77, 103, + 78, 20, 17, 77, 103, + 23, 20, 78, 80, 103, + 79, 21, 23, 81, 103, + 23, 19, 18, 26, 104, + 26, 18, 71, 82, 104, + 80, 23, 26, 82, 104, + 20, 23, 80, 78, 104, + 71, 18, 20, 69, 104, + 22, 19, 23, 24, 105, + 24, 23, 81, 83, 105, + 75, 22, 24, 83, 105, + 21, 22, 75, 73, 105, + 81, 23, 21, 79, 105, + 19, 23, 26, 18, 106, + 22, 24, 23, 19, 106, + 25, 22, 19, 18, 106, + 0, 1, 2, 27, 28, 29, + 6, 33, 35, 9, 41, 42, + 9, 41, 44, 8, 38, 43, + 13, 50, 51, 6, 32, 35, + 8, 39, 43, 14, 52, 56, + 11, 54, 55, 16, 59, 60, + 16, 59, 62, 15, 57, 61, + 10, 47, 63, 13, 50, 64, + 14, 52, 65, 10, 48, 63, + 20, 68, 69, 11, 53, 55, + 15, 58, 61, 21, 70, 73, + 17, 66, 77, 20, 68, 78, + 21, 70, 79, 17, 67, 77, + 84, 85, 86, 24, 26, 25, + 7, 6, 9, 8, 10, 13, 12, 14, + 12, 11, 16, 15, 17, 20, 19, 21, +}; + +vtkm::IdComponent numIndices[numCells] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 8, 8, +}; + +vtkm::UInt8 shapes[numCells] = { + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, +}; + +vtkm::Float32 pointData[numPoints] = { + 2.235f, 2.609f, 2.448f, 2.944f, 3.198f, 2.609f, 3.015f, 3.392f, + 3.598f, 3.568f, 2.812f, 4.373f, 3.379f, 3.462f, 3.018f, 3.748f, + 4.450f, 3.485f, 3.740f, 3.859f, 3.706f, 3.354f, 2.815f, 2.937f, + 2.460f, 2.368f, 2.759f, 2.085f, 2.085f, 2.085f, 2.507f, 2.234f, + 2.672f, 2.907f, 2.895f, 3.165f, 3.275f, 2.626f, 3.815f, 3.392f, + 3.182f, 3.598f, 3.974f, 3.248f, 3.922f, 2.620f, 2.496f, 2.737f, + 3.065f, 3.249f, 3.093f, 3.614f, 3.026f, 4.018f, 4.370f, 4.144f, + 2.801f, 4.048f, 3.076f, 4.414f, 3.662f, 3.530f, 3.673f, 2.889f, + 3.578f, 2.995f, 3.604f, 3.188f, 3.608f, 3.432f, 3.326f, 3.446f, + 3.364f, 3.133f, 2.986f, 2.906f, 2.391f, 3.423f, 3.470f, 3.237f, + 3.147f, 3.062f, 2.796f, 2.553f, 2.206f, 2.206f, 2.206f, 2.776f, + 2.643f, 3.258f, 3.298f, 2.834f, 2.726f, 3.183f, 3.828f, 3.419f, + 4.146f, 3.251f, 3.684f, 3.077f, 3.610f, 3.245f, 3.215f, 3.268f, + 3.258f, 2.978f, 2.991f, +}; +} //ExplicitData1 + +// VTK dataset created from noise.silo in VisIt. +// Resample(6,6,6), CylinderClip((0,0,0) r=8), field=hardyglobal +namespace ExplicitData2 { +static const std::size_t numPoints = 104; +vtkm::Float32 coords[numPoints*3] = { + -2.000f, -2.000f, -6.000f, + 2.000f, -2.000f, -6.000f, -2.000f, 2.000f, -6.000f, + 2.000f, 2.000f, -6.000f, -2.000f, -6.000f, -2.000f, + 2.000f, -6.000f, -2.000f, -6.000f, -2.000f, -2.000f, + -2.000f, -2.000f, -2.000f, 6.000f, -2.000f, -2.000f, + 2.000f, -2.000f, -2.000f, -6.000f, 2.000f, -2.000f, + -2.000f, 6.000f, -2.000f, -2.000f, 2.000f, -2.000f, + 2.000f, 6.000f, -2.000f, 2.000f, 2.000f, -2.000f, + 6.000f, 2.000f, -2.000f, -2.000f, -6.000f, 2.000f, + 2.000f, -6.000f, 2.000f, -6.000f, -2.000f, 2.000f, + -2.000f, -2.000f, 6.000f, -2.000f, -2.000f, 2.000f, + 2.000f, -2.000f, 6.000f, 2.000f, -2.000f, 2.000f, + 6.000f, -2.000f, 2.000f, -6.000f, 2.000f, 2.000f, + -2.000f, 6.000f, 2.000f, -2.000f, 2.000f, 2.000f, + -2.000f, 2.000f, 6.000f, 2.000f, 6.000f, 2.000f, + 2.000f, 2.000f, 2.000f, 6.000f, 2.000f, 2.000f, + 2.000f, 2.000f, 6.000f, -2.000f, -4.500f, -6.000f, + -2.000f, -2.000f, -7.250f, -4.500f, -2.000f, -6.000f, + 2.000f, -2.000f, -7.250f, 2.000f, -4.500f, -6.000f, + 4.500f, -2.000f, -6.000f, -4.500f, 2.000f, -6.000f, + -2.000f, 2.000f, -7.250f, 2.000f, 2.000f, -7.250f, + 4.500f, 2.000f, -6.000f, -2.000f, 4.500f, -6.000f, + 2.000f, 4.500f, -6.000f, -2.000f, -7.250f, -2.000f, + -2.000f, -6.000f, -4.500f, -4.500f, -6.000f, -2.000f, + 2.000f, -6.000f, -4.500f, 2.000f, -7.250f, -2.000f, + 4.500f, -6.000f, -2.000f, -6.000f, -4.500f, -2.000f, + -6.000f, -2.000f, -4.500f, -7.250f, -2.000f, -2.000f, + 6.000f, -4.500f, -2.000f, 6.000f, -2.000f, -4.500f, + 7.250f, -2.000f, -2.000f, -7.250f, 2.000f, -2.000f, + -6.000f, 2.000f, -4.500f, 6.000f, 2.000f, -4.500f, + 7.250f, 2.000f, -2.000f, -6.000f, 4.500f, -2.000f, + -2.000f, 6.000f, -4.500f, -4.500f, 6.000f, -2.000f, + 2.000f, 6.000f, -4.500f, 6.000f, 4.500f, -2.000f, + 4.500f, 6.000f, -2.000f, -2.000f, 7.250f, -2.000f, + 2.000f, 7.250f, -2.000f, -4.500f, -6.000f, 2.000f, + -2.000f, -7.250f, 2.000f, 2.000f, -7.250f, 2.000f, + 4.500f, -6.000f, 2.000f, -7.250f, -2.000f, 2.000f, + -6.000f, -4.500f, 2.000f, 6.000f, -4.500f, 2.000f, + 7.250f, -2.000f, 2.000f, -7.250f, 2.000f, 2.000f, + 7.250f, 2.000f, 2.000f, -6.000f, 4.500f, 2.000f, + -4.500f, 6.000f, 2.000f, 4.500f, 6.000f, 2.000f, + 6.000f, 4.500f, 2.000f, -2.000f, 7.250f, 2.000f, + 2.000f, 7.250f, 2.000f, -2.000f, -6.000f, 4.500f, + 2.000f, -6.000f, 4.500f, -6.000f, -2.000f, 4.500f, + -2.000f, -4.500f, 6.000f, -4.500f, -2.000f, 6.000f, + 2.000f, -4.500f, 6.000f, 6.000f, -2.000f, 4.500f, + 4.500f, -2.000f, 6.000f, -6.000f, 2.000f, 4.500f, + -4.500f, 2.000f, 6.000f, 6.000f, 2.000f, 4.500f, + 4.500f, 2.000f, 6.000f, -2.000f, 4.500f, 6.000f, + -2.000f, 6.000f, 4.500f, 2.000f, 4.500f, 6.000f, + 2.000f, 6.000f, 4.500f, -2.000f, -2.000f, 7.250f, + 2.000f, -2.000f, 7.250f, -2.000f, 2.000f, 7.250f, + 2.000f, 2.000f, 7.250f, +}; + +static const std::size_t numCells = 125; +static const std::size_t numConn = 704; +vtkm::Id conn[numConn] = { + 32, 33, 34, 0, + 36, 37, 35, 1, + 39, 42, 38, 2, + 43, 40, 41, 3, + 44, 45, 46, 4, + 48, 49, 47, 5, + 50, 51, 52, 6, + 4, 6, 7, 0, + 8, 9, 1, 5, + 53, 55, 54, 8, + 57, 60, 56, 10, + 11, 12, 10, 2, + 13, 14, 3, 15, + 64, 58, 59, 15, + 61, 66, 62, 11, + 67, 63, 65, 13, + 69, 68, 84, 16, + 85, 71, 70, 17, + 73, 72, 86, 18, + 19, 18, 20, 16, + 21, 17, 22, 23, + 90, 75, 74, 23, + 78, 92, 76, 24, + 25, 24, 26, 27, + 28, 29, 30, 31, + 81, 77, 94, 30, + 82, 97, 79, 25, + 83, 80, 99, 28, + 87, 88, 100, 19, +101, 91, 89, 21, + 96, 102, 93, 27, + 98, 95, 103, 31, + 34, 0, 6, 51, 50, + 32, 45, 4, 0, 46, + 6, 4, 46, 50, 0, + 50, 46, 32, 34, 0, + 47, 36, 1, 5, 37, + 49, 5, 8, 53, 54, + 1, 37, 54, 8, 5, + 37, 47, 49, 54, 5, + 38, 57, 10, 2, 60, + 42, 2, 11, 61, 62, + 10, 60, 62, 11, 2, + 60, 38, 42, 62, 2, + 58, 41, 3, 15, 43, + 64, 15, 13, 65, 63, + 3, 43, 63, 13, 15, + 43, 58, 64, 63, 15, + 68, 16, 18, 73, 86, + 84, 87, 19, 16, 88, + 18, 19, 88, 86, 16, + 86, 88, 84, 68, 16, + 74, 23, 17, 71, 85, + 90, 91, 21, 23, 89, + 17, 21, 89, 85, 23, + 85, 89, 90, 74, 23, + 93, 27, 24, 92, 78, + 96, 97, 25, 27, 79, + 24, 25, 79, 78, 27, + 78, 79, 96, 93, 27, + 95, 94, 30, 31, 81, + 98, 31, 28, 99, 80, + 30, 81, 80, 28, 31, + 81, 95, 98, 80, 31, + 0, 33, 32, 1, 35, 36, + 0, 34, 33, 2, 38, 39, + 1, 35, 37, 3, 40, 41, + 3, 40, 43, 2, 39, 42, + 4, 45, 44, 5, 47, 48, + 1, 9, 5, 0, 7, 4, + 6, 52, 51, 10, 56, 57, + 10, 12, 2, 6, 7, 0, + 3, 14, 15, 1, 9, 8, + 8, 54, 55, 15, 58, 59, + 2, 12, 11, 3, 14, 13, + 13, 63, 67, 11, 61, 66, + 16, 68, 69, 4, 46, 44, + 17, 70, 71, 5, 48, 49, + 18, 72, 73, 6, 52, 50, + 6, 7, 4, 18, 20, 16, + 5, 9, 8, 17, 22, 23, + 23, 74, 75, 8, 53, 55, + 10, 56, 60, 24, 76, 78, + 24, 26, 25, 10, 12, 11, + 15, 14, 13, 30, 29, 28, + 30, 77, 81, 15, 59, 64, + 11, 62, 66, 25, 79, 82, + 28, 80, 83, 13, 65, 67, + 16, 69, 84, 17, 70, 85, + 17, 22, 21, 16, 20, 19, + 24, 76, 92, 18, 72, 86, + 18, 20, 19, 24, 26, 27, + 30, 29, 31, 23, 22, 21, + 23, 75, 90, 30, 77, 94, + 31, 29, 28, 27, 26, 25, + 25, 97, 82, 28, 99, 83, + 19, 87, 100, 21, 89, 101, + 27, 93, 102, 19, 88, 100, + 21, 91, 101, 31, 95, 103, + 27, 102, 96, 31, 103, 98, + 33, 35, 40, 39, 0, 1, 3, 2, + 36, 1, 0, 32, 47, 5, 4, 45, + 57, 10, 6, 51, 38, 2, 0, 34, + 0, 1, 3, 2, 7, 9, 14, 12, + 41, 3, 1, 37, 58, 15, 8, 54, + 63, 13, 11, 61, 43, 3, 2, 42, + 4, 5, 17, 16, 44, 48, 70, 69, + 68, 16, 4, 46, 73, 18, 6, 50, + 4, 5, 9, 7, 16, 17, 22, 20, + 74, 23, 8, 53, 71, 17, 5, 49, + 6, 18, 24, 10, 52, 72, 76, 56, + 6, 7, 12, 10, 18, 20, 26, 24, + 7, 9, 14, 12, 20, 22, 29, 26, + 9, 8, 15, 14, 22, 23, 30, 29, + 55, 75, 77, 59, 8, 23, 30, 15, + 78, 24, 10, 60, 79, 25, 11, 62, + 12, 14, 13, 11, 26, 29, 28, 25, + 80, 28, 13, 65, 81, 30, 15, 64, + 66, 67, 83, 82, 11, 13, 28, 25, + 85, 17, 16, 84, 89, 21, 19, 87, + 93, 27, 19, 88, 92, 24, 18, 86, + 20, 22, 29, 26, 19, 21, 31, 27, + 94, 30, 23, 90, 95, 31, 21, 91, + 98, 31, 27, 96, 99, 28, 25, 97, + 19, 21, 31, 27, 100, 101, 103, 102, +}; + +vtkm::IdComponent numIndices[numCells] = { + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, +}; + +vtkm::UInt8 shapes[numCells] = { + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_TETRA, vtkm::CELL_SHAPE_TETRA, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_PYRAMID, vtkm::CELL_SHAPE_PYRAMID, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_WEDGE, vtkm::CELL_SHAPE_WEDGE, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, vtkm::CELL_SHAPE_HEXAHEDRON, + vtkm::CELL_SHAPE_HEXAHEDRON, +}; + +vtkm::Float32 pointData[numPoints] = { + 3.558f, 3.219f, 3.738f, 5.246f, 3.204f, 3.535f, 3.536f, 2.668f, + 5.001f, 3.375f, 3.336f, 3.141f, 3.824f, 4.556f, 4.097f, 4.969f, + 3.164f, 3.306f, 2.031f, 3.613f, 3.084f, 3.958f, 3.583f, 3.748f, + 3.036f, 3.112f, 3.331f, 3.297f, 3.821f, 3.758f, 4.511f, 3.389f, + 4.000f, 3.518f, 3.905f, 3.150f, 2.684f, 3.079f, 3.081f, 3.707f, + 4.622f, 4.555f, 3.523f, 4.312f, 2.990f, 3.867f, 3.187f, 2.803f, + 3.362f, 3.730f, 3.311f, 3.897f, 3.448f, 4.280f, 3.747f, 4.339f, + 3.685f, 2.930f, 4.451f, 4.661f, 2.849f, 3.299f, 2.776f, 4.053f, + 4.511f, 4.356f, 3.117f, 4.159f, 3.348f, 2.650f, 3.015f, 3.547f, + 2.188f, 2.923f, 3.713f, 3.605f, 2.992f, 4.290f, 2.941f, 2.970f, + 3.878f, 4.137f, 3.047f, 3.633f, 3.226f, 4.029f, 2.443f, 3.395f, + 3.037f, 4.274f, 4.132f, 4.211f, 3.076f, 3.174f, 3.925f, 3.504f, + 3.308f, 3.239f, 3.468f, 3.630f, 3.648f, 3.817f, 3.276f, 3.312f, +}; + +} //ExplicitData2 + + +} //testing +} //cont +} //vtkm diff --git a/vtkm/cont/testing/MakeTestDataSet.h b/vtkm/cont/testing/MakeTestDataSet.h index 2e060a14a..fba3b0896 100644 --- a/vtkm/cont/testing/MakeTestDataSet.h +++ b/vtkm/cont/testing/MakeTestDataSet.h @@ -23,6 +23,10 @@ #include #include +#include +#include +#include +#include namespace vtkm { namespace cont { @@ -37,6 +41,12 @@ public: // 3D regular datasets. vtkm::cont::DataSet Make3DRegularDataSet0(); + //2D rectilinear + vtkm::cont::DataSet Make2DRectilinearDataSet0(); + + //3D rectilinear + vtkm::cont::DataSet Make3DRectilinearDataSet0(); + // 3D explicit datasets. vtkm::cont::DataSet Make3DExplicitDataSet0(); vtkm::cont::DataSet Make3DExplicitDataSet1(); @@ -49,27 +59,18 @@ public: inline vtkm::cont::DataSet MakeTestDataSet::Make2DRegularDataSet0() { - vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderRegular dsb; + vtkm::Id2 dimensions(3,2); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); - const int nVerts = 6; - vtkm::cont::ArrayHandleUniformPointCoordinates - coordinates(vtkm::Id3(3, 2, 1)); - vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f}; + vtkm::cont::DataSetFieldAdd dsf; + const vtkm::Id nVerts = 6; + vtkm::Float32 var[nVerts] = {10.1f, 20.1f, 30.1f, 40.1f, 50.1f, 60.1f}; + + dsf.AddPointField(dataSet, "pointvar", var, nVerts); - dataSet.AddCoordinateSystem( - vtkm::cont::CoordinateSystem("coordinates", 1, coordinates)); - - //set point scalar. - dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts)); - - //create scalar. vtkm::Float32 cellvar[2] = {100.1f, 200.1f}; - dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2)); - - vtkm::cont::CellSetStructured<2> cellSet("cells"); - //Set regular structure - cellSet.SetPointDimensions( vtkm::make_Vec(3,2) ); - dataSet.AddCellSet(cellSet); + dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells"); return dataSet; } @@ -77,60 +78,105 @@ MakeTestDataSet::Make2DRegularDataSet0() inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet0() { - vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderRegular dsb; + vtkm::Id3 dimensions(3,2,3); + vtkm::cont::DataSet dataSet = dsb.Create(dimensions); + vtkm::cont::DataSetFieldAdd dsf; 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}; + 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", 1, coordinates)); + //Set point and cell scalar + dsf.AddPointField(dataSet, "pointvar", vars, nVerts); - //Set point scalar - dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts)); - - //Set cell scalar vtkm::Float32 cellvar[4] = {100.1f, 100.2f, 100.3f, 100.4f}; - dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 4)); - - static const vtkm::IdComponent dim = 3; - vtkm::cont::CellSetStructured cellSet("cells"); - cellSet.SetPointDimensions( vtkm::make_Vec(3,2,3) ); - dataSet.AddCellSet(cellSet); + dsf.AddCellField(dataSet, "cellvar", cellvar, 4, "cells"); return dataSet; } +inline vtkm::cont::DataSet +MakeTestDataSet::Make2DRectilinearDataSet0() +{ + vtkm::cont::DataSetBuilderRectilinear dsb; + std::vector X(3), Y(2); + + X[0] = 0.0; + X[1] = 1.0; + X[2] = 2.0; + Y[0] = 0.0; + Y[1] = 1.0; + + vtkm::cont::DataSet dataSet = dsb.Create(X, Y); + + vtkm::cont::DataSetFieldAdd dsf; + const vtkm::Id nVerts = 6; + vtkm::Float32 var[nVerts]; + for (int i = 0; i < nVerts; i++) + var[i] = (vtkm::Float32)i; + dsf.AddPointField(dataSet, "pointvar", var, nVerts); + + const vtkm::Id nCells = 2; + vtkm::Float32 cellvar[nCells]; + for (int i = 0; i < nCells; i++) + cellvar[i] = (vtkm::Float32)i; + dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells"); + + return dataSet; +} + +inline vtkm::cont::DataSet +MakeTestDataSet::Make3DRectilinearDataSet0() +{ + vtkm::cont::DataSetBuilderRectilinear dsb; + std::vector X(3), Y(2), Z(3); + + X[0] = 0.0; + X[1] = 1.0; + X[2] = 2.0; + Y[0] = 0.0; + Y[1] = 1.0; + Z[0] = 0.0; + Z[1] = 1.0; + Z[2] = 2.0; + + vtkm::cont::DataSet dataSet = dsb.Create(X, Y, Z); + + vtkm::cont::DataSetFieldAdd dsf; + const vtkm::Id nVerts = 18; + vtkm::Float32 var[nVerts]; + for (int i = 0; i < nVerts; i++) + var[i] = (vtkm::Float32)i; + dsf.AddPointField(dataSet, "pointvar", var, nVerts); + + const vtkm::Id nCells = 4; + vtkm::Float32 cellvar[nCells]; + for (int i = 0; i < nCells; i++) + cellvar[i] = (vtkm::Float32)i; + dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells"); + + return dataSet; + } + inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet0() { vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; const int nVerts = 5; typedef vtkm::Vec CoordType; - 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::CoordinateSystem("coordinates", 1, coordinates, nVerts)); - - //Set point scalar - dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts)); - - //Set cell scalar - vtkm::Float32 cellvar[2] = {100.1f, 100.2f}; - dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2)); - - //Add connectivity + 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); @@ -150,21 +196,68 @@ MakeTestDataSet::Make3DExplicitDataSet0() conn.push_back(3); conn.push_back(4); - vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2); - cellSet.FillViaCopy(shapes, numindices, conn); + //Create the dataset. + dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells"); - dataSet.AddCellSet(cellSet); + vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f}; + vtkm::Float32 cellvar[2] = {100.1f, 100.2f}; + + vtkm::cont::DataSetFieldAdd dsf; + dsf.AddPointField(dataSet, "pointvar", vars, nVerts); + dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells"); return dataSet; } + /* +inline vtkm::cont::DataSet +MakeTestDataSet::Make3DExplicitDataSet1() +{ + vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetIterativeBuilderExplicit dsb; + vtkm::Id id0, id1, id2, id3, id4; + + dsb.Begin("coords", "cells"); + + id0 = dsb.AddPoint(0,0,0); + id1 = dsb.AddPoint(1,0,0); + id2 = dsb.AddPoint(1,1,0); + id3 = dsb.AddPoint(2,1,0); + id4 = dsb.AddPoint(2,2,0); + + vtkm::Id ids0[3] = {id0, id1, id2}; + dsb.AddCell(vtkm::CELL_SHAPE_TRIANGLE, ids0, 3); + + vtkm::Id ids1[4] = {id2, id1, id3, id4}; + dsb.AddCell(vtkm::CELL_SHAPE_QUAD, ids1, 4); + dataSet = dsb.Create(); + + vtkm::Float32 vars[5] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f}; + vtkm::Float32 cellvar[2] = {100.1f, 100.2f}; + + vtkm::cont::DataSetFieldAdd dsf; + dsf.AddPointField(dataSet, "pointvar", vars, 5); + dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells"); + + return dataSet; +} + */ + inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1() { vtkm::cont::DataSet dataSet; + vtkm::cont::DataSetBuilderExplicit dsb; const int nVerts = 5; typedef vtkm::Vec CoordType; + 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), @@ -176,6 +269,12 @@ MakeTestDataSet::Make3DExplicitDataSet1() dataSet.AddCoordinateSystem( vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts)); + vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2); + 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(); + dataSet.AddCellSet(cellSet); //Set point scalar dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts)); @@ -184,15 +283,6 @@ MakeTestDataSet::Make3DExplicitDataSet1() vtkm::Float32 cellvar[2] = {100.1f, 100.2f}; dataSet.AddField(Field("cellvar", 1, vtkm::cont::Field::ASSOC_CELL_SET, "cells", cellvar, 2)); - vtkm::cont::CellSetExplicit<> cellSet(nVerts, "cells", 2); - - 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(); - - dataSet.AddCellSet(cellSet); - return dataSet; } @@ -273,6 +363,7 @@ MakeTestDataSet::Make3DExplicitDataSetCowNose(double *pBounds) return dataSet; } + } } } // namespace vtkm::cont::testing diff --git a/vtkm/cont/testing/TestingDataSetExplicit.h b/vtkm/cont/testing/TestingDataSetExplicit.h index 22861b945..caef0ac45 100644 --- a/vtkm/cont/testing/TestingDataSetExplicit.h +++ b/vtkm/cont/testing/TestingDataSetExplicit.h @@ -62,8 +62,8 @@ private: static void TestDataSet_Explicit() { vtkm::cont::testing::MakeTestDataSet tds; - vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet1(); - + vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0(); + VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, "Incorrect number of cell sets"); @@ -74,7 +74,6 @@ private: const vtkm::cont::Field &f1 = ds.GetField("pointvar"); VTKM_TEST_ASSERT(f1.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS, "Association of 'pointvar' was not ASSOC_POINTS"); - try { //const vtkm::cont::Field &f2 = @@ -103,13 +102,10 @@ private: // test cell-to-point connectivity vtkm::cont::CellSetExplicit<> &cellset = ds.GetCellSet(0).CastTo >(); - cellset.BuildConnectivity(DeviceAdapterTag(), vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint()); - ds.PrintSummary(std::cout); - vtkm::Id connectivitySize = 7; vtkm::Id numPoints = 5; @@ -166,7 +162,6 @@ private: connectivityIndex += numIncidentCells; } - //verify that GetIndices works properly vtkm::Id expectedPointIds[4] = {2,1,3,4}; vtkm::Vec retrievedPointIds; diff --git a/vtkm/cont/testing/UnitTestArrayHandleCartesianProduct.cxx b/vtkm/cont/testing/UnitTestArrayHandleCartesianProduct.cxx new file mode 100644 index 000000000..b71e1d022 --- /dev/null +++ b/vtkm/cont/testing/UnitTestArrayHandleCartesianProduct.cxx @@ -0,0 +1,117 @@ +//============================================================================= +// +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +// +//============================================================================= + +#include +#include +#include +#include + +#include + +#include + +namespace ArrayHandleCartesianProductNamespace { + +typedef vtkm::cont::DeviceAdapterAlgorithm DFA; + +template +void ArrayHandleCPBasic(vtkm::cont::ArrayHandle x, + vtkm::cont::ArrayHandle y, + vtkm::cont::ArrayHandle z) + +{ + vtkm::cont::ArrayHandleCartesianProduct< + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle > cpArray; + + vtkm::Id nx = x.GetNumberOfValues(); + vtkm::Id ny = y.GetNumberOfValues(); + vtkm::Id nz = z.GetNumberOfValues(); + vtkm::Id n = nx*ny*nz; + + cpArray = vtkm::cont::make_ArrayHandleCartesianProduct(x,y,z); + + //Make sure we have the right number of values. + VTKM_TEST_ASSERT(cpArray.GetNumberOfValues() == (nx*ny*nz), + "Cartesian array constructor has wrong number of values"); + + //Make sure the values are correct. + vtkm::Vec val; + for (vtkm::Id i = 0; i < n; i++) + { + vtkm::Id idx0 = (i % (nx*ny)) % nx; + vtkm::Id idx1 = (i % (nx*ny)) / nx; + vtkm::Id idx2 = i / (nx*ny); + + val = vtkm::Vec(x.GetPortalConstControl().Get(idx0), + y.GetPortalConstControl().Get(idx1), + z.GetPortalConstControl().Get(idx2)); + VTKM_TEST_ASSERT(test_equal(cpArray.GetPortalConstControl().Get(i), val), + "Wrong value in array"); + } +} + +template +void createArr(std::vector &arr, std::size_t n) +{ + arr.resize(n); + for (std::size_t i = 0; i < n; i++) + arr[i] = static_cast(i); +} + +template +void +RunTest() +{ + std::size_t nX = 10, nY = 10, nZ = 10; + + for (std::size_t i = 1; i < nX; i++) + for (std::size_t j = 1; j < nY; j++) + for (std::size_t k = 1; k < nZ; k++) + { + std::vector X,Y,Z; + createArr(X, nX); + createArr(Y, nY); + createArr(Z, nZ); + + ArrayHandleCPBasic(vtkm::cont::make_ArrayHandle(X), + vtkm::cont::make_ArrayHandle(Y), + vtkm::cont::make_ArrayHandle(Z)); + } +} + +void +TestArrayHandleCartesianProduct() +{ + RunTest(); + RunTest(); + RunTest(); +} + +} // namespace ArrayHandleCartesianProductNamespace + +int UnitTestArrayHandleCartesianProduct(int, char *[]) +{ + using namespace ArrayHandleCartesianProductNamespace; + return vtkm::cont::testing::Testing::Run(TestArrayHandleCartesianProduct); +} diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx new file mode 100644 index 000000000..87ec26126 --- /dev/null +++ b/vtkm/cont/testing/UnitTestDataSetBuilderExplicit.cxx @@ -0,0 +1,241 @@ +//============================================================================= +// +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +// +//============================================================================= + +#include +#include +#include +#include +#include + +#include + +namespace DataSetBuilderExplicitNamespace { + +typedef vtkm::cont::DeviceAdapterAlgorithm DFA; +typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; + +template +void ComputeBounds(std::size_t numPoints, const T *coords, + vtkm::Float64 *bounds) +{ + bounds[0] = bounds[1] = coords[0*3 +0]; + bounds[2] = bounds[3] = coords[0*3 +1]; + bounds[4] = bounds[5] = coords[0*3 +2]; + + for (std::size_t i = 0; i < numPoints; i++) + { + bounds[0] = std::min(bounds[0], static_cast(coords[i*3+0])); + bounds[1] = std::max(bounds[1], static_cast(coords[i*3+0])); + bounds[2] = std::min(bounds[2], static_cast(coords[i*3+1])); + bounds[3] = std::max(bounds[3], static_cast(coords[i*3+1])); + bounds[4] = std::min(bounds[4], static_cast(coords[i*3+2])); + bounds[5] = std::max(bounds[5], static_cast(coords[i*3+2])); + } +} + +void ValidateDataSet(const vtkm::cont::DataSet &ds, + vtkm::Id numPoints, vtkm::Id numCells, + vtkm::Float64 *bounds) +{ + //Verify basics.. + VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, + "Wrong number of cell sets."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 0, + "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, + "Wrong number of coordinate systems."); + VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints, + "Wrong number of coordinates."); + VTKM_TEST_ASSERT(ds.GetCellSet().GetCellSet().GetNumberOfCells() == numCells, + "Wrong number of cells."); + + //Make sure bounds are correct. + vtkm::Float64 res[6]; + ds.GetCoordinateSystem().GetBounds(res, DeviceAdapter()); + VTKM_TEST_ASSERT(test_equal(bounds[0], res[0]) && test_equal(bounds[1], res[1]) && + test_equal(bounds[2], res[2]) && test_equal(bounds[3], res[3]) && + test_equal(bounds[4], res[4]) && test_equal(bounds[5], res[5]), + "Bounds of coordinates do not match"); +} + +template +std::vector +createVec(std::size_t n, const T *data) +{ + std::vector vec(n); + for (std::size_t i = 0; i < n; i++) + vec[i] = data[i]; + return vec; +} + +template +vtkm::cont::ArrayHandle +createAH(std::size_t n, const T *data) +{ + vtkm::cont::ArrayHandle arr; + DFA::Copy(vtkm::cont::make_ArrayHandle(data, static_cast(n)), arr); + return arr; +} + +template +vtkm::cont::DataSet +CreateDataSetArr(bool useSeparatedCoords, + std::size_t numPoints, const T *coords, + std::size_t numCells, std::size_t numConn, + const vtkm::Id *conn, + const vtkm::IdComponent *indices, + const vtkm::UInt8 *shape) +{ + vtkm::cont::DataSetBuilderExplicit dsb; + if (useSeparatedCoords) + { + std::vector xvals(numPoints), yvals(numPoints), zvals(numPoints); + for (std::size_t i = 0; i < numPoints; i++) + { + xvals[i] = coords[i*3 + 0]; + yvals[i] = coords[i*3 + 1]; + zvals[i] = coords[i*3 + 2]; + } + vtkm::cont::ArrayHandle X,Y,Z; + DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), X); + DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Y); + DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Z); + return dsb.Create(X,Y,Z, + createAH(numCells, shape), + createAH(numCells, indices), + createAH(numConn, conn)); + } + else + { + std::vector > tmp(numPoints); + for (std::size_t i = 0; i < numPoints; i++) + { + tmp[i][0] = coords[i*3 + 0]; + tmp[i][1] = coords[i*3 + 1]; + tmp[i][2] = coords[i*3 + 2]; + } + + vtkm::cont::ArrayHandle > pts; + DFA::Copy(vtkm::cont::make_ArrayHandle(tmp), pts); + return dsb.Create(pts, + createAH(numCells, shape), + createAH(numCells, indices), + createAH(numConn, conn)); + } +} + +template +vtkm::cont::DataSet +CreateDataSetVec(bool useSeparatedCoords, + std::size_t numPoints, const T *coords, + std::size_t numCells, std::size_t numConn, + const vtkm::Id *conn, + const vtkm::IdComponent *indices, + const vtkm::UInt8 *shape) +{ + vtkm::cont::DataSetBuilderExplicit dsb; + + if (useSeparatedCoords) + { + std::vector X(numPoints), Y(numPoints), Z(numPoints); + for (std::size_t i = 0; i < numPoints; i++) + { + X[i] = coords[i*3 + 0]; + Y[i] = coords[i*3 + 1]; + Z[i] = coords[i*3 + 2]; + } + return dsb.Create(X,Y,Z, + createVec(numCells, shape), + createVec(numCells, indices), + createVec(numConn, conn)); + } + else + { + std::vector > pts(numPoints); + for (std::size_t i = 0; i < numPoints; i++) + { + pts[i][0] = coords[i*3 + 0]; + pts[i][1] = coords[i*3 + 1]; + pts[i][2] = coords[i*3 + 2]; + } + return dsb.Create(pts, + createVec(numCells, shape), + createVec(numCells, indices), + createVec(numConn, conn)); + } +} + +#define TEST_DATA(num) \ + vtkm::cont::testing::ExplicitData##num::numPoints, \ + vtkm::cont::testing::ExplicitData##num::coords, \ + vtkm::cont::testing::ExplicitData##num::numCells, \ + vtkm::cont::testing::ExplicitData##num::numConn, \ + vtkm::cont::testing::ExplicitData##num::conn, \ + vtkm::cont::testing::ExplicitData##num::numIndices, \ + vtkm::cont::testing::ExplicitData##num::shapes +#define TEST_NUMS(num) \ + vtkm::cont::testing::ExplicitData##num::numPoints, \ + vtkm::cont::testing::ExplicitData##num::numCells +#define TEST_BOUNDS(num) \ + vtkm::cont::testing::ExplicitData##num::numPoints, \ + vtkm::cont::testing::ExplicitData##num::coords + +void +TestDataSetBuilderExplicit() +{ + vtkm::cont::DataSetBuilderExplicit dsb; + vtkm::cont::DataSet ds; + vtkm::Float64 bounds[6]; + + //Iterate over organization of coordinates. + for (int i = 0; i < 2; i++) + { + //Test ExplicitData0 + ComputeBounds(TEST_BOUNDS(0), bounds); + ds = CreateDataSetArr(i==0,TEST_DATA(0)); + ValidateDataSet(ds, TEST_NUMS(0), bounds); + ds = CreateDataSetVec(i==0, TEST_DATA(0)); + ValidateDataSet(ds, TEST_NUMS(0), bounds); + + //Test ExplicitData1 + ComputeBounds(TEST_BOUNDS(1), bounds); + ds = CreateDataSetArr(i==0,TEST_DATA(1)); + ValidateDataSet(ds, TEST_NUMS(1), bounds); + ds = CreateDataSetVec(i==0, TEST_DATA(1)); + ValidateDataSet(ds, TEST_NUMS(1), bounds); + + //Test ExplicitData2 + ComputeBounds(TEST_BOUNDS(2), bounds); + ds = CreateDataSetArr(i==0,TEST_DATA(2)); + ValidateDataSet(ds, TEST_NUMS(2), bounds); + ds = CreateDataSetVec(i==0, TEST_DATA(2)); + ValidateDataSet(ds, TEST_NUMS(2), bounds); + } +} + +} // namespace DataSetBuilderExplicitNamespace + +int UnitTestDataSetBuilderExplicit(int, char *[]) +{ + using namespace DataSetBuilderExplicitNamespace; + return vtkm::cont::testing::Testing::Run(TestDataSetBuilderExplicit); +} diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx new file mode 100644 index 000000000..59d51f621 --- /dev/null +++ b/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx @@ -0,0 +1,175 @@ +//============================================================================= +// +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +// +//============================================================================= + +#include +#include +#include +#include +#include + +#include + +#include + +namespace DataSetBuilderRectilinearNamespace { + +typedef vtkm::cont::DeviceAdapterAlgorithm DFA; +typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; + +void ValidateDataSet(const vtkm::cont::DataSet &ds, + int dim, + vtkm::Id numPoints, vtkm::Id numCells, + vtkm::Float64 *bounds) +{ + //Verify basics.. + VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, + "Wrong number of cell sets."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 0, + "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, + "Wrong number of coordinate systems."); + VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints, + "Wrong number of coordinates."); + VTKM_TEST_ASSERT(ds.GetCellSet().GetCellSet().GetNumberOfCells() == numCells, + "Wrong number of cells."); + + //Make sure the bounds are correct. + vtkm::Float64 res[6]; + ds.GetCoordinateSystem().GetBounds(res, DeviceAdapter()); + VTKM_TEST_ASSERT(test_equal(bounds[0], res[0]) && test_equal(bounds[1], res[1]) && + test_equal(bounds[2], res[2]) && test_equal(bounds[3], res[3]) && + test_equal(bounds[4], res[4]) && test_equal(bounds[5], res[5]), + "Bounds of coordinates do not match"); + if (dim == 2) + { + typedef vtkm::cont::CellSetStructured<2> CellSetType; + CellSetType cellSet = ds.GetCellSet(0).CastTo(); + vtkm::IdComponent shape = cellSet.GetCellShape(); + VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type"); + } + else if (dim == 3) + { + typedef vtkm::cont::CellSetStructured<3> CellSetType; + CellSetType cellSet = ds.GetCellSet(0).CastTo(); + vtkm::IdComponent shape = cellSet.GetCellShape(); + VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type"); + } +} + +template +void FillArray(std::vector &arr, std::size_t sz, int fillMethod) +{ + arr.resize(sz); + for (size_t i = 0; i < sz; i++) + { + T xi; + + switch (fillMethod) + { + case 0: xi = static_cast(i); break; + case 1: xi = static_cast(i) / static_cast(sz-1); break; + case 2: xi = static_cast(i*2); break; + case 3: xi = static_cast(i*0.1f); break; + case 4: xi = static_cast(i*i); break; + } + arr[i] = xi; + } +} + +template +void +RectilinearTests() +{ + vtkm::cont::DataSetBuilderRectilinear dsb; + vtkm::cont::DataSet ds; + + std::size_t nx = 15, ny = 15, nz = 15; + int nm = 5; + std::vector xvals, yvals, zvals; + + for (std::size_t i = 2; i < nx; i++) + for (std::size_t j = 2; j < ny; j++) + for (int mx = 0; mx < nm; mx++) + for (int my = 0; my < nm; my++) + { + //Do the 2D cases. + vtkm::Id np = i*j, nc = (i-1)*(j-1); + FillArray(xvals, i, mx); + FillArray(yvals, j, my); + + vtkm::Float64 bounds[6] = {xvals[0], xvals[i-1], + yvals[0], yvals[j-1], + 0.0, 0.0}; + //Test std::vector + ds = dsb.Create(xvals, yvals); + ValidateDataSet(ds, 2, np, nc, bounds); + + //Test T * + ds = dsb.Create(i,j, &xvals[0],&yvals[0]); + ValidateDataSet(ds, 2, np, nc, bounds); + + //Test ArrayHandle + ds = dsb.Create(vtkm::cont::make_ArrayHandle(xvals), + vtkm::cont::make_ArrayHandle(yvals)); + ValidateDataSet(ds, 2, np, nc, bounds); + + //Do the 3D cases. + for (std::size_t k = 2; k < nz; k++) + for (int mz = 0; mz < nm; mz++) + { + np = i*j*k; + nc = (i-1)*(j-1)*(k-1); + FillArray(zvals, k, mz); + bounds[4] = zvals[0]; + bounds[5] = zvals[k-1]; + + //Test std::vector + ds = dsb.Create(xvals, yvals, zvals); + ValidateDataSet(ds, 3, np, nc, bounds); + + //Test T * + ds = dsb.Create(i,j,k, &xvals[0],&yvals[0], &zvals[0]); + ValidateDataSet(ds, 3, np, nc, bounds); + + //Test ArrayHandle + ds = dsb.Create(vtkm::cont::make_ArrayHandle(xvals), + vtkm::cont::make_ArrayHandle(yvals), + vtkm::cont::make_ArrayHandle(zvals)); + ValidateDataSet(ds, 3, np, nc, bounds); + } + } +} + +void +TestDataSetBuilderRectilinear() +{ + RectilinearTests(); + RectilinearTests(); +} + +} // namespace DataSetBuilderRectilinearNamespace + +int UnitTestDataSetBuilderRectilinear(int, char *[]) +{ + using namespace DataSetBuilderRectilinearNamespace; + return vtkm::cont::testing::Testing::Run(TestDataSetBuilderRectilinear); +} diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderRegular.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderRegular.cxx new file mode 100644 index 000000000..12d92d788 --- /dev/null +++ b/vtkm/cont/testing/UnitTestDataSetBuilderRegular.cxx @@ -0,0 +1,156 @@ +//============================================================================= +// +// 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +// +//============================================================================= + +#include +#include +#include +#include +#include + +#include + +#include + +namespace DataSetBuilderRegularNamespace { + +typedef vtkm::cont::DeviceAdapterAlgorithm DFA; +typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; + +void ValidateDataSet(const vtkm::cont::DataSet &ds, + int dim, + vtkm::Id numPoints, vtkm::Id numCells, + vtkm::Float64 *bounds) +{ + //Verify basics.. + VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, + "Wrong number of cell sets."); + VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 0, + "Wrong number of fields."); + VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, + "Wrong number of coordinate systems."); + VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetData().GetNumberOfValues() == numPoints, + "Wrong number of coordinates."); + VTKM_TEST_ASSERT(ds.GetCellSet().GetCellSet().GetNumberOfCells() == numCells, + "Wrong number of cells."); + + + //Make sure bounds are correct. + vtkm::Float64 res[6]; + ds.GetCoordinateSystem().GetBounds(res, DeviceAdapter()); + VTKM_TEST_ASSERT(test_equal(bounds[0], res[0]) && test_equal(bounds[1], res[1]) && + test_equal(bounds[2], res[2]) && test_equal(bounds[3], res[3]) && + test_equal(bounds[4], res[4]) && test_equal(bounds[5], res[5]), + "Bounds of coordinates do not match"); + + if (dim == 2) + { + typedef vtkm::cont::CellSetStructured<2> CellSetType; + CellSetType cellSet = ds.GetCellSet(0).CastTo(); + vtkm::IdComponent shape = cellSet.GetCellShape(); + VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type"); + } + else if (dim == 3) + { + typedef vtkm::cont::CellSetStructured<3> CellSetType; + CellSetType cellSet = ds.GetCellSet(0).CastTo(); + vtkm::IdComponent shape = cellSet.GetCellShape(); + VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type"); + } +} + +template +void FillMethod(int method, vtkm::Id n, T &o, T &s, + vtkm::Float64 &b0, vtkm::Float64 &b1) +{ + switch (method) + { + case 0 : o = 0; s = 1; break; + case 1 : o = 0; s = static_cast(1.0/n); break; + case 2 : o = 0; s = 2; break; + case 3 : o = static_cast(-(n-1)); s = 1; break; + case 4 : o = static_cast(2.780941); s = static_cast(182.381901); break; + } + + b0 = static_cast(o); + b1 = static_cast(o + (n-1)*s); +} + +template +void +RegularTests() +{ + vtkm::cont::DataSetBuilderRegular dsb; + vtkm::cont::DataSet ds; + + vtkm::Id nx = 12, ny = 12, nz = 12; + int nm = 5; + vtkm::Float64 bounds[6]; + + for (vtkm::Id i = 2; i < nx; i++) + for (vtkm::Id j = 2; j < ny; j++) + for (int mi = 0; mi < nm; mi++) + for (int mj = 0; mj < nm; mj++) + { + //2D cases + vtkm::Id np = i*j, nc = (i-1)*(j-1); + + vtkm::Id2 dims2(i,j); + T oi, oj, si, sj; + FillMethod(mi, dims2[0], oi, si, bounds[0],bounds[1]); + FillMethod(mj, dims2[1], oj, sj, bounds[2],bounds[3]); + bounds[4] = bounds[5] = 0; + vtkm::Vec o2(oi,oj), sp2(si,sj); + + ds = dsb.Create(dims2, o2, sp2); + ValidateDataSet(ds, 2, np, nc, bounds); + + //3D cases + for (vtkm::Id k = 2; k < nz; k++) + for (int mk = 0; mk < nm; mk++) + { + np = i*j*k; + nc = (i-1)*(j-1)*(k-1); + + vtkm::Id3 dims3(i,j,k); + T ok, sk; + FillMethod(mk, dims3[2], ok, sk, bounds[4],bounds[5]); + vtkm::Vec o3(oi,oj,ok), sp3(si,sj,sk); + ds = dsb.Create(dims3, o3, sp3); + ValidateDataSet(ds, 3, np, nc, bounds); + } + } +} + +void +TestDataSetBuilderRegular() +{ + RegularTests(); + RegularTests(); +} + +} // namespace DataSetBuilderRegularNamespace + +int UnitTestDataSetBuilderRegular(int, char *[]) +{ + using namespace DataSetBuilderRegularNamespace; + return vtkm::cont::testing::Testing::Run(TestDataSetBuilderRegular); +} diff --git a/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx b/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx new file mode 100644 index 000000000..47f88355d --- /dev/null +++ b/vtkm/cont/testing/UnitTestDataSetRectilinear.cxx @@ -0,0 +1,272 @@ +//============================================================================ +// 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. +// +// Copyright 2014 Sandia Corporation. +// Copyright 2014 UT-Battelle, LLC. +// Copyright 2014 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +static void TwoDimRectilinearTest(); +static void ThreeDimRectilinearTest(); + +void TestDataSet_Rectilinear() +{ + std::cout << std::endl; + std::cout << "--TestDataSet_Rectilinear--" << std::endl << std::endl; + + TwoDimRectilinearTest(); + ThreeDimRectilinearTest(); +} + +static void +TwoDimRectilinearTest() +{ + std::cout<<"2D Rectilinear data set"< CellSetType; + CellSetType cellSet = dataSet.GetCellSet(0).CastTo(); + + VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1, + "Incorrect number of cell sets"); + VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, + "Incorrect number of fields"); + VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1, + "Incorrect number of coordinate systems"); + VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, + "Incorrect number of points"); + VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 2, + "Incorrect number of cells"); + + // test various field-getting methods and associations + try + { + dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET); + } + catch (...) + { + VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET."); + } + + try + { + dataSet.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS); + } + catch (...) + { + VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET."); + } + + vtkm::Id numCells = cellSet.GetNumberOfCells(); + for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++) + { + VTKM_TEST_ASSERT(cellSet.GetNumberOfPointsInCell(cellIndex) == 4, + "Incorrect number of cell indices"); + vtkm::IdComponent shape = cellSet.GetCellShape(); + VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, + "Incorrect element type."); + } + + vtkm::exec::ConnectivityStructured< + vtkm::TopologyElementTagPoint, + vtkm::TopologyElementTagCell, + 2> pointToCell = + cellSet.PrepareForInput( + vtkm::cont::DeviceAdapterTagSerial(), + vtkm::TopologyElementTagPoint(), + vtkm::TopologyElementTagCell()); + vtkm::exec::ConnectivityStructured< + vtkm::TopologyElementTagCell, + vtkm::TopologyElementTagPoint, + 2> cellToPoint = + cellSet.PrepareForInput( + vtkm::cont::DeviceAdapterTagSerial(), + vtkm::TopologyElementTagCell(), + vtkm::TopologyElementTagPoint()); + + + vtkm::Id cells[2][4] = {{0,1,4,3}, {1,2,5,4}}; + for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++) + { + vtkm::Vec pointIds = + pointToCell.GetIndices(pointToCell.FlatToLogicalToIndex(cellIndex)); + for (vtkm::IdComponent localPointIndex = 0; + localPointIndex < 4; + localPointIndex++) + { + VTKM_TEST_ASSERT( + pointIds[localPointIndex] == cells[cellIndex][localPointIndex], + "Incorrect point ID for cell"); + } + } + + vtkm::Id expectedCellIds[6][4] = {{0,-1,-1,-1}, + {0,1,-1,-1}, + {1,-1,-1,-1}, + {0,-1,-1,-1}, + {0,1,-1,-1}, + {1,-1,-1,-1}}; + + for (vtkm::Id pointIndex = 0; pointIndex < 6; pointIndex++) + { + vtkm::VecVariable retrievedCellIds = + cellToPoint.GetIndices(cellToPoint.FlatToLogicalToIndex(pointIndex)); + VTKM_TEST_ASSERT(retrievedCellIds.GetNumberOfComponents() <= 4, + "Got wrong number of cell ids."); + for (vtkm::IdComponent cellIndex = 0; + cellIndex < retrievedCellIds.GetNumberOfComponents(); + cellIndex++) + { + VTKM_TEST_ASSERT( + retrievedCellIds[cellIndex] == expectedCellIds[pointIndex][cellIndex], + "Incorrect cell ID for point"); + } + } +} + +static void +ThreeDimRectilinearTest() +{ + std::cout<<"3D Rectilinear data set"<, + vtkm::cont::ArrayHandle, + vtkm::cont::ArrayHandle > coords; + dcs.CastToArrayHandle(coords); + vtkm::Id n = dcs.GetNumberOfValues(); + vtkm::Vec pt(0,0,0); + for (int i = 0; i < n; i++) + { + pt = coords.GetPortalConstControl().Get(i); + std::cout< CellSetType; + CellSetType cellSet = dataSet.GetCellSet(0).CastTo(); + + VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1, + "Incorrect number of cell sets"); + + VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, + "Incorrect number of fields"); + + VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1, + "Incorrect number of coordinate systems"); + + VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 18, + "Incorrect number of points"); + + VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 4, + "Incorrect number of cells"); + + try + { + dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET); + } + catch (...) + { + VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET."); + } + + try + { + dataSet.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS); + } + catch (...) + { + VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET."); + } + + vtkm::Id numCells = cellSet.GetNumberOfCells(); + for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++) + { + VTKM_TEST_ASSERT(cellSet.GetNumberOfPointsInCell(cellIndex) == 8, + "Incorrect number of cell indices"); + vtkm::IdComponent shape = cellSet.GetCellShape(); + VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, + "Incorrect element type."); + } + + //Test regular connectivity. + vtkm::exec::ConnectivityStructured< + vtkm::TopologyElementTagPoint, + vtkm::TopologyElementTagCell, + 3> pointToCell = + cellSet.PrepareForInput( + vtkm::cont::DeviceAdapterTagSerial(), + vtkm::TopologyElementTagPoint(), + vtkm::TopologyElementTagCell()); + vtkm::Id expectedPointIds[8] = {0,1,4,3,6,7,10,9}; + vtkm::Vec retrievedPointIds = + pointToCell.GetIndices(vtkm::Id3(0)); + for (vtkm::IdComponent localPointIndex = 0; + localPointIndex < 8; + localPointIndex++) + { + VTKM_TEST_ASSERT( + retrievedPointIds[localPointIndex] == expectedPointIds[localPointIndex], + "Incorrect point ID for cell"); + } + + vtkm::exec::ConnectivityStructured< + vtkm::TopologyElementTagCell, + vtkm::TopologyElementTagPoint, + 3> cellToPoint = + cellSet.PrepareForInput( + vtkm::cont::DeviceAdapterTagSerial(), + vtkm::TopologyElementTagCell(), + vtkm::TopologyElementTagPoint()); + vtkm::Id retrievedCellIds[6] = {0,-1,-1,-1,-1,-1}; + vtkm::VecVariable expectedCellIds = + cellToPoint.GetIndices(vtkm::Id3(0)); + VTKM_TEST_ASSERT(expectedCellIds.GetNumberOfComponents() <= 6, + "Got unexpected number of cell ids"); + for (vtkm::IdComponent localPointIndex = 0; + localPointIndex < expectedCellIds.GetNumberOfComponents(); + localPointIndex++) + { + VTKM_TEST_ASSERT( + expectedCellIds[localPointIndex] == retrievedCellIds[localPointIndex], + "Incorrect cell ID for point"); + } +} + +int UnitTestDataSetRectilinear(int, char *[]) +{ + return vtkm::cont::testing::Testing::Run(TestDataSet_Rectilinear); +} diff --git a/vtkm/cont/testing/UnitTestDataSetRegular.cxx b/vtkm/cont/testing/UnitTestDataSetRegular.cxx index 2f8df92b9..bd9212c8f 100644 --- a/vtkm/cont/testing/UnitTestDataSetRegular.cxx +++ b/vtkm/cont/testing/UnitTestDataSetRegular.cxx @@ -49,8 +49,6 @@ TwoDimRegularTest() vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0(); - dataSet.PrintSummary(std::cout); - typedef vtkm::cont::CellSetStructured<2> CellSetType; CellSetType cellSet = dataSet.GetCellSet(0).CastTo(); @@ -66,30 +64,22 @@ TwoDimRegularTest() "Incorrect number of cells"); // test various field-getting methods and associations - const vtkm::cont::Field &f1 = dataSet.GetField("pointvar"); - VTKM_TEST_ASSERT(f1.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS, - "Association of 'pointvar' was not ASSOC_POINTS"); - try { - //const vtkm::cont::Field &f2 = - dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET); + dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET); } catch (...) { - VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET."); + VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET."); } try { - //const vtkm::cont::Field &f3 = - dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_POINTS); - VTKM_TEST_FAIL("Failed to get expected error for association mismatch."); + dataSet.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS); } - catch (vtkm::cont::ErrorControlBadValue error) + catch (...) { - std::cout << "Caught expected error for association mismatch: " - << std::endl << " " << error.GetMessage() << std::endl; + VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET."); } vtkm::Id numCells = cellSet.GetNumberOfCells(); @@ -167,8 +157,6 @@ ThreeDimRegularTest() vtkm::cont::DataSet dataSet = testDataSet.Make3DRegularDataSet0(); - dataSet.PrintSummary(std::cout); - typedef vtkm::cont::CellSetStructured<3> CellSetType; CellSetType cellSet = dataSet.GetCellSet(0).CastTo(); @@ -187,34 +175,25 @@ ThreeDimRegularTest() VTKM_TEST_ASSERT(cellSet.GetNumberOfCells() == 4, "Incorrect number of cells"); - // test various field-getting methods and associations - const vtkm::cont::Field &f1 = dataSet.GetField("pointvar"); - VTKM_TEST_ASSERT(f1.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS, - "Association of 'pointvar' was not ASSOC_POINTS"); - try { - //const vtkm::cont::Field &f2 = - dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET); + dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_CELL_SET); } catch (...) { - VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET."); + VTKM_TEST_FAIL("Failed to get field 'cellvar' with ASSOC_CELL_SET."); } try { - //const vtkm::cont::Field &f3 = - dataSet.GetField("cellvar", vtkm::cont::Field::ASSOC_POINTS); - VTKM_TEST_FAIL("Failed to get expected error for association mismatch."); + dataSet.GetField("pointvar", vtkm::cont::Field::ASSOC_POINTS); } - catch (vtkm::cont::ErrorControlBadValue error) + catch (...) { - std::cout << "Caught expected error for association mismatch: " - << std::endl << " " << error.GetMessage() << std::endl; + VTKM_TEST_FAIL("Failed to get field 'pointvar' with ASSOC_POINT_SET."); } - vtkm::Id numCells = cellSet.GetNumberOfCells(); + vtkm::Id numCells = cellSet.GetNumberOfCells(); for (vtkm::Id cellIndex = 0; cellIndex < numCells; cellIndex++) { VTKM_TEST_ASSERT(cellSet.GetNumberOfPointsInCell(cellIndex) == 8, diff --git a/vtkm/io/writer/testing/UnitTestVTKDataSetWriter.cxx b/vtkm/io/writer/testing/UnitTestVTKDataSetWriter.cxx index c26cadd59..d22b905b6 100644 --- a/vtkm/io/writer/testing/UnitTestVTKDataSetWriter.cxx +++ b/vtkm/io/writer/testing/UnitTestVTKDataSetWriter.cxx @@ -50,7 +50,7 @@ void TestVTKExplicitWrite() std::ofstream out3("fileA3.vtk"); vtkm::io::writer::VTKDataSetWriter::Write(out3, - tds.Make3DExplicitDataSet1()); + tds.Make3DExplicitDataSet0()); out3.close(); std::ofstream out4("fileA4.vtk"); diff --git a/vtkm/worklet/testing/UnitTestThreshold.cxx b/vtkm/worklet/testing/UnitTestThreshold.cxx index 279c482cf..0ea564e5f 100644 --- a/vtkm/worklet/testing/UnitTestThreshold.cxx +++ b/vtkm/worklet/testing/UnitTestThreshold.cxx @@ -129,7 +129,7 @@ public: vtkm::cont::ArrayHandle, vtkm::cont::ArrayHandle > OutCellFieldArrayHandleType; - vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DExplicitDataSet1(); + vtkm::cont::DataSet dataset = MakeTestDataSet().Make3DExplicitDataSet0(); CellSetType cellset = dataset.GetCellSet(0).CastTo(CellSetType()); diff --git a/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx b/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx index 6bbc04756..c99a1616e 100644 --- a/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx +++ b/vtkm/worklet/testing/UnitTestWorkletMapTopologyExplicit.cxx @@ -152,7 +152,7 @@ TestMaxPointOrCell() { std::cout<<"Testing MaxPointOfCell worklet"<