Merge branch 'master' of gitlab.kitware.com:Fasel/vtk-m into stat_histogram

This commit is contained in:
Patricia Kroll Fasel - 090207 2015-10-08 09:13:28 -06:00
commit 4aa57d5c64
35 changed files with 1406 additions and 128 deletions

@ -17,14 +17,6 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <stdexcept>
#include <boost/lexical_cast.hpp>
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
@ -32,6 +24,16 @@
#include <vtkm/worklet/Clip.h>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <stdexcept>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/lexical_cast.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
typedef vtkm::Vec<vtkm::Float32, 3> FloatVec3;
template<typename T>

@ -31,7 +31,7 @@ VTKM_THIRDPARTY_POST_INCLUDE
// pragmas. However, not all compiler support pragmas in code blocks (although
// fortunately clang does). Thus, only use these pragmas in the instance where
// we need it and know we can use it.
#if defined(VTKM_CLANG) && (__apple_build_version__ >= 7000072)
#if defined(VTKM_CLANG) && (__apple_build_version__ >= 7000072) && !defined(VTKM_CUDA)
#define VTKM_STATIC_ASSERT(condition) \
VTKM_THIRDPARTY_PRE_INCLUDE \

@ -28,7 +28,6 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleZip.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/StorageBasic.h>
#include <vtkm/cont/Timer.h>

@ -70,6 +70,28 @@ struct IsValidArrayHandle {
>::type type;
};
/// Checks to see if the ArrayHandle for the given DeviceAdatper allows
/// writing, as some ArrayHandles (Implicit) don't support writing.
/// This check is compatable with the Boost meta-template programming
/// library (MPL). It contains a typedef named type that is either
// boost::mpl::true_ or boost::mpl::false_.
/// Both of these have a typedef named value with the respective boolean value.
///
template<typename ArrayHandle, typename DeviceAdapterTag>
struct IsWriteableArrayHandle {
private:
typedef typename ArrayHandle:: template ExecutionTypes<
DeviceAdapterTag > ExecutionTypes;
typedef typename ExecutionTypes::Portal::ValueType ValueType;
//All ArrayHandles that use ImplicitStorage as the final writable location
//will have a value type of void*, which is what we are trying to detect
typedef typename boost::remove_pointer<ValueType>::type RawValueType;
typedef boost::is_void<RawValueType> IsVoidType;
public:
typedef typename boost::mpl::not_<IsVoidType>::type type;
};
/// Checks to see if the given object is an array handle. This check is
/// compatible with the Boost meta-template programming library (MPL). It
/// contains a typedef named \c type that is either boost::mpl::true_ or
@ -258,7 +280,7 @@ public:
///
/// The allocation may be done on an already existing array, but can wipe out
/// any data already in the array. This method can throw
/// ErrorControlOutOfMemory if the array cannot be allocated or
/// ErrorControlBadAllocation if the array cannot be allocated or
/// ErrorControlBadValue if the allocation is not feasible (for example, the
/// array storage is read-only).
///

@ -0,0 +1,356 @@
//============================================================================
// 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_ArrayHandleGroupVec_h
#define vtk_m_cont_ArrayHandleGroupVec_h
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayPortal.h>
#include <vtkm/cont/Assert.h>
#include <vtkm/cont/ErrorControlBadValue.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <boost/type_traits/remove_const.hpp>
VTKM_THIRDPARTY_POST_INCLUDE
namespace vtkm {
namespace cont {
namespace internal {
template<typename _SourcePortalType, vtkm::IdComponent _NUM_COMPONENTS>
class ArrayPortalGroupVec
{
public:
static const vtkm::IdComponent NUM_COMPONENTS = _NUM_COMPONENTS;
typedef _SourcePortalType SourcePortalType;
typedef typename
boost::remove_const<typename SourcePortalType::ValueType>::type
ComponentType;
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
ArrayPortalGroupVec() : SourcePortal() { }
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
ArrayPortalGroupVec(const SourcePortalType &sourcePortal)
: SourcePortal(sourcePortal) { }
/// Copy constructor for any other ArrayPortalConcatenate with a portal type
/// that can be copied to this portal type. This allows us to do any type
/// casting that the portals do (like the non-const to const cast).
VTKM_SUPPRESS_EXEC_WARNINGS
template<typename OtherSourcePortalType>
VTKM_EXEC_CONT_EXPORT
ArrayPortalGroupVec(
const ArrayPortalGroupVec<OtherSourcePortalType, NUM_COMPONENTS> &src)
: SourcePortal(src.GetPortal()) { }
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
vtkm::Id GetNumberOfValues() const
{
return this->SourcePortal.GetNumberOfValues()/NUM_COMPONENTS;
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
ValueType Get(vtkm::Id index) const
{
ValueType result;
vtkm::Id sourceIndex = index*NUM_COMPONENTS;
for (vtkm::IdComponent componentIndex = 0;
componentIndex < NUM_COMPONENTS;
componentIndex++)
{
result[componentIndex] = this->SourcePortal.Get(sourceIndex);
sourceIndex++;
}
return result;
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
void Set(vtkm::Id index, const ValueType &value) const
{
vtkm::Id sourceIndex = index*NUM_COMPONENTS;
for (vtkm::IdComponent componentIndex = 0;
componentIndex < NUM_COMPONENTS;
componentIndex++)
{
this->SourcePortal.Set(sourceIndex, value[componentIndex]);
sourceIndex++;
}
}
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT_EXPORT
const SourcePortalType &GetPortal() const { this->SourcePortal; }
private:
SourcePortalType SourcePortal;
};
template<typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
struct StorageTagGroupVec { };
template<typename SourceArrayHandleType,
vtkm::IdComponent NUM_COMPONENTS>
class Storage<
vtkm::Vec<typename SourceArrayHandleType::ValueType,NUM_COMPONENTS>,
vtkm::cont::internal::StorageTagGroupVec<
SourceArrayHandleType, NUM_COMPONENTS> >
{
typedef typename SourceArrayHandleType::ValueType ComponentType;
public:
typedef vtkm::Vec<ComponentType,NUM_COMPONENTS> ValueType;
typedef vtkm::cont::internal::ArrayPortalGroupVec<
typename SourceArrayHandleType::PortalControl,
NUM_COMPONENTS> PortalType;
typedef vtkm::cont::internal::ArrayPortalGroupVec<
typename SourceArrayHandleType::PortalConstControl,
NUM_COMPONENTS> PortalConstType;
VTKM_CONT_EXPORT
Storage() : Valid(false) { }
VTKM_CONT_EXPORT
Storage(const SourceArrayHandleType &sourceArray)
: SourceArray(sourceArray), Valid(true) { }
VTKM_CONT_EXPORT
PortalType GetPortal()
{
VTKM_ASSERT_CONT(this->Valid);
return PortalType(this->SourceArray.GetPortalControl());
}
VTKM_CONT_EXPORT
PortalConstType GetPortalConst() const
{
VTKM_ASSERT_CONT(this->Valid);
return PortalConstType(this->SourceArray.GetPortalConstControl());
}
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfValues() const
{
VTKM_ASSERT_CONT(this->Valid);
vtkm::Id sourceSize = this->SourceArray.GetNumberOfValues();
if(sourceSize%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return sourceSize/NUM_COMPONENTS;
}
VTKM_CONT_EXPORT
void Allocate(vtkm::Id numberOfValues)
{
VTKM_ASSERT_CONT(this->Valid);
this->SourceArray.Allocate(numberOfValues*NUM_COMPONENTS);
}
VTKM_CONT_EXPORT
void Shrink(vtkm::Id numberOfValues)
{
VTKM_ASSERT_CONT(this->Valid);
this->SourceArray.Shrink(numberOfValues*NUM_COMPONENTS);
}
VTKM_CONT_EXPORT
void ReleaseResources()
{
if (this->Valid)
{
this->SourceArray.ReleaseResources();
}
}
// Required for later use in ArrayTransfer class
VTKM_CONT_EXPORT
const SourceArrayHandleType &GetSourceArray() const
{
VTKM_ASSERT_CONT(this->Valid);
return this->SourceArray;
}
private:
SourceArrayHandleType SourceArray;
bool Valid;
};
template<typename SourceArrayHandleType,
vtkm::IdComponent NUM_COMPONENTS,
typename Device>
class ArrayTransfer<
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
vtkm::cont::internal::StorageTagGroupVec<
SourceArrayHandleType, NUM_COMPONENTS>,
Device>
{
public:
typedef typename SourceArrayHandleType::ValueType ComponentType;
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
private:
typedef vtkm::cont::internal::StorageTagGroupVec<
SourceArrayHandleType, NUM_COMPONENTS> StorageTag;
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
public:
typedef typename StorageType::PortalType PortalControl;
typedef typename StorageType::PortalConstType PortalConstControl;
typedef vtkm::cont::internal::ArrayPortalGroupVec<
typename SourceArrayHandleType::template ExecutionTypes<Device>::Portal,
NUM_COMPONENTS>
PortalExecution;
typedef vtkm::cont::internal::ArrayPortalGroupVec<
typename SourceArrayHandleType::template ExecutionTypes<Device>::PortalConst,
NUM_COMPONENTS>
PortalConstExecution;
VTKM_CONT_EXPORT
ArrayTransfer(StorageType *storage)
: SourceArray(storage->GetSourceArray()) { }
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfValues() const
{
vtkm::Id sourceSize = this->SourceArray.GetNumberOfValues();
if (sourceSize%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return sourceSize/NUM_COMPONENTS;
}
VTKM_CONT_EXPORT
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
{
if (this->SourceArray.GetNumberOfValues()%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return PortalConstExecution(this->SourceArray.PrepareForInput(Device()));
}
VTKM_CONT_EXPORT
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
{
if (this->SourceArray.GetNumberOfValues()%NUM_COMPONENTS != 0)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
}
return PortalExecution(this->SourceArray.PrepareForInPlace(Device()));
}
VTKM_CONT_EXPORT
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
{
return PortalExecution(this->SourceArray.PrepareForOutput(
numberOfValues*NUM_COMPONENTS, Device()));
}
VTKM_CONT_EXPORT
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const
{
// Implementation of this method should be unnecessary. The internal
// array handles should automatically retrieve the output data as
// necessary.
}
VTKM_CONT_EXPORT
void Shrink(vtkm::Id numberOfValues)
{
this->SourceArray.Shrink(numberOfValues*NUM_COMPONENTS);
}
VTKM_CONT_EXPORT
void ReleaseResources()
{
this->SourceArray.ReleaseResourcesExecution();
}
private:
SourceArrayHandleType SourceArray;
};
} // namespace internal
/// \brief Fancy array handle that groups values into vectors.
///
/// It is sometimes the case that an array is stored such that consecutive
/// entries are meant to form a group. This fancy array handle takes an array
/// of values and a size of groups and then groups the consecutive values
/// stored in a \c Vec.
///
/// For example, if you have an array handle with the six values 0,1,2,3,4,5
/// and give it to a \c ArrayHandleGroupVec with the number of components set
/// to 3, you get an array that looks like it contains two values of \c Vec
/// values of size 3 with the data [0,1,2], [3,4,5].
///
template<typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
class ArrayHandleGroupVec
: public vtkm::cont::ArrayHandle<
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
vtkm::cont::internal::StorageTagGroupVec<
SourceArrayHandleType, NUM_COMPONENTS> >
{
VTKM_IS_ARRAY_HANDLE(SourceArrayHandleType);
public:
typedef vtkm::cont::internal::StorageTagGroupVec<
SourceArrayHandleType, NUM_COMPONENTS> StorageTag;
typedef typename SourceArrayHandleType::ValueType ComponentType;
typedef vtkm::cont::ArrayHandle<
vtkm::Vec<ComponentType,NUM_COMPONENTS>, StorageTag> Superclass;
typedef typename Superclass::ValueType ValueType;
private:
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
public:
VTKM_CONT_EXPORT
ArrayHandleGroupVec() { }
VTKM_CONT_EXPORT
ArrayHandleGroupVec(const SourceArrayHandleType &sourceArray)
: Superclass(StorageType(sourceArray)) { }
VTKM_CONT_EXPORT
ArrayHandleGroupVec(
const vtkm::cont::ArrayHandle<ValueType,StorageTag> &source)
: Superclass(source) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ArrayHandleGroupVec_h

@ -145,9 +145,14 @@ class Storage<T, StorageTagTransform<T, ArrayHandleType, FunctorType > >
public:
typedef T ValueType;
typedef ArrayPortalContTransform<
ValueType, typename ArrayHandleType::PortalControl, FunctorType>
PortalType;
// This is meant to be invalid. Because Transform arrays are read only, you
// should only be able to use the const version.
struct PortalType
{
typedef void *ValueType;
typedef void *IteratorType;
};
typedef ArrayPortalContTransform<
ValueType, typename ArrayHandleType::PortalConstControl, FunctorType>
PortalConstType;
@ -205,6 +210,11 @@ public:
return this->Array;
}
VTKM_CONT_EXPORT
const FunctorType &GetFunctor() const {
return this->Functor;
}
private:
ArrayHandleType Array;
FunctorType Functor;
@ -227,17 +237,16 @@ public:
typedef typename StorageType::PortalType PortalControl;
typedef typename StorageType::PortalConstType PortalConstControl;
typedef vtkm::exec::internal::ArrayPortalExecTransform<
ValueType,
typename ArrayHandleType::template ExecutionTypes<Device>::Portal,
FunctorType> PortalExecution;
//meant to be an invalid writeable execution portal
typedef typename StorageType::PortalType PortalExecution;
typedef vtkm::exec::internal::ArrayPortalExecTransform<
ValueType,
typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst,
FunctorType> PortalConstExecution;
VTKM_CONT_EXPORT
ArrayTransfer(StorageType *storage) : Array(storage->GetArray()) { }
ArrayTransfer(StorageType *storage)
: Array(storage->GetArray()), Functor(storage->GetFunctor()) { }
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfValues() const {
@ -246,7 +255,7 @@ public:
VTKM_CONT_EXPORT
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) {
return PortalConstExecution(this->Array.PrepareForInput(Device()));
return PortalConstExecution(this->Array.PrepareForInput(Device()), this->Functor);
}
VTKM_CONT_EXPORT
@ -283,6 +292,7 @@ public:
private:
ArrayHandleType Array;
FunctorType Functor;
};
} // namespace internal

@ -26,6 +26,7 @@ set(headers
ArrayHandleCompositeVector.h
ArrayHandleConstant.h
ArrayHandleCounting.h
ArrayHandleGroupVec.h
ArrayHandleImplicit.h
ArrayHandleIndex.h
ArrayHandlePermutation.h
@ -37,9 +38,10 @@ set(headers
Assert.h
CellSet.h
CellSetExplicit.h
CellSetSingleType.h
CellSetListTag.h
CellSetSingleType.h
CellSetStructured.h
CellSetPermutation.h
CoordinateSystem.h
DataSet.h
DeviceAdapter.h
@ -50,10 +52,10 @@ set(headers
Error.h
ErrorControl.h
ErrorControlAssert.h
ErrorControlBadAllocation.h
ErrorControlBadType.h
ErrorControlBadValue.h
ErrorControlInternal.h
ErrorControlOutOfMemory.h
ErrorExecution.h
Field.h
LogicalStructure.h

@ -89,6 +89,15 @@ class CellSetExplicit : public CellSet
public:
typedef vtkm::Id SchedulingRangeType;
//point to cell is used when iterating cells and asking for point properties
typedef ConnectivityChooser< vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell > PointToCellConnectivityType;
typedef typename PointToCellConnectivityType::ShapeArrayType ShapeArrayType;
typedef typename PointToCellConnectivityType::NumIndicesArrayType NumIndicesArrayType;
typedef typename PointToCellConnectivityType::ConnectivityArrayType ConnectivityArrayType;
typedef typename PointToCellConnectivityType::IndexOffsetArrayType IndexOffsetArrayType;
VTKM_CONT_EXPORT
CellSetExplicit(vtkm::Id numpoints = 0,
const std::string &name = std::string(),
@ -244,6 +253,7 @@ public:
/// Second method to add cells -- all at once.
/// Assigns the array handles to the explicit connectivity. This is
/// the way you can fill the memory from another system without copying
VTKM_CONT_EXPORT
void Fill(const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity,
@ -352,7 +362,7 @@ public:
vtkm::Id pairCount = 0;
vtkm::Id maxNodeID = 0;
vtkm::Id numCells = GetNumberOfCells();
vtkm::Id numCells = this->GetNumberOfCells();
for (vtkm::Id cell = 0, cindex = 0; cell < numCells; ++cell)
{
vtkm::Id npts = this->PointToCell.NumIndices.GetPortalConstControl().Get(cell);
@ -368,12 +378,12 @@ public:
}
}
if(GetNumberOfPoints() <= 0)
if(this->GetNumberOfPoints() <= 0)
{
this->NumberOfPoints = maxNodeID + 1;
}
vtkm::Id numPoints = GetNumberOfPoints();
vtkm::Id numPoints = this->GetNumberOfPoints();
this->CellToPoint.Shapes.Allocate(numPoints);
this->CellToPoint.NumIndices.Allocate(numPoints);

@ -0,0 +1,271 @@
//============================================================================
// 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_CellSetPermutation_h
#define vtk_m_cont_CellSetPermutation_h
#include <vtkm/CellShape.h>
#include <vtkm/CellTraits.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/CellSet.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/exec/ConnectivityStructuredPermuted.h>
namespace vtkm {
namespace cont {
namespace internal{
template<typename ValidCellArrayHandleType, typename OriginalCellSet>
struct CellSetPermutationTraits
{
typedef typename OriginalCellSet::ShapeArrayType ShapeArrayType;
typedef typename OriginalCellSet::NumIndicesArrayType NumIndicesArrayType;
typedef typename OriginalCellSet::ConnectivityArrayType ConnectivityArrayType;
typedef typename OriginalCellSet::IndexOffsetArrayType IndexOffsetArrayType;
typedef vtkm::cont::ArrayHandlePermutation<ValidCellArrayHandleType,
ShapeArrayType> PermShapeArrayType;
typedef vtkm::cont::ArrayHandlePermutation<ValidCellArrayHandleType,
NumIndicesArrayType> PermNumIndicesArrayType;
typedef vtkm::cont::ArrayHandlePermutation<ValidCellArrayHandleType,
IndexOffsetArrayType> PermIndexOffsetArrayType;
typedef vtkm::cont::CellSetExplicit<
typename PermShapeArrayType::StorageTag,
typename PermNumIndicesArrayType::StorageTag,
typename ConnectivityArrayType::StorageTag,
typename PermIndexOffsetArrayType::StorageTag> PermutedCellSetType;
};
template<typename ValidCellArrayHandleType, vtkm::IdComponent DIMENSION>
struct CellSetPermutationTraits<ValidCellArrayHandleType, CellSetStructured<DIMENSION> >
{
};
}
template< typename ValidCellArrayHandleType,
typename OriginalCellSet >
class CellSetPermutation : public CellSet
{
public:
typedef typename vtkm::cont::internal::CellSetPermutationTraits<
ValidCellArrayHandleType,OriginalCellSet>::PermutedCellSetType PermutedCellSetType;
typedef typename PermutedCellSetType::ShapeArrayType ShapeArrayType;
typedef typename PermutedCellSetType::NumIndicesArrayType NumIndicesArrayType;
typedef typename PermutedCellSetType::ConnectivityArrayType ConnectivityArrayType;
typedef typename PermutedCellSetType::IndexOffsetArrayType IndexOffsetArrayType;
VTKM_CONT_EXPORT
CellSetPermutation(const ValidCellArrayHandleType& validCellIds,
const OriginalCellSet& cellset,
const std::string &name = std::string(),
vtkm::IdComponent dimensionality = 3)
: CellSet(name,dimensionality),
PermutedCellSet(0, name, dimensionality)
{
this->Fill(validCellIds, cellset);
}
VTKM_CONT_EXPORT
CellSetPermutation(const std::string &name = std::string(),
vtkm::IdComponent dimensionality = 3)
: CellSet(name,dimensionality),
ValidCellIds(),
PermutedCellSet(0, name, dimensionality)
{
}
//This is the way you can fill the memory from another system without copying
VTKM_CONT_EXPORT
void Fill(const ValidCellArrayHandleType &validCellIds,
const OriginalCellSet& cellset)
{
typedef vtkm::cont::internal::CellSetPermutationTraits<
ValidCellArrayHandleType, OriginalCellSet> Traits;
typedef vtkm::TopologyElementTagPoint ElemPointTag;
typedef vtkm::TopologyElementTagCell ElemCellTag;
PermutedCellSetType permutedCellSet(0,this->PermutedCellSet.GetName(),
cellset.GetDimensionality());
typename Traits::PermShapeArrayType shapeArray(validCellIds,
cellset.GetShapesArray(ElemPointTag(),ElemCellTag()));
typename Traits::PermNumIndicesArrayType numArray(validCellIds,
cellset.GetNumIndicesArray(ElemPointTag(),ElemCellTag()));
typename Traits::PermIndexOffsetArrayType offsArray(validCellIds,
cellset.GetIndexOffsetArray(ElemPointTag(),ElemCellTag()));
permutedCellSet.Fill( shapeArray,
numArray,
cellset.GetConnectivityArray(ElemPointTag(),ElemCellTag()),
offsArray);
this->ValidCellIds = validCellIds;
this->PermutedCellSet = permutedCellSet;
}
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfCells() const
{
return this->PermutedCellSet.GetNumberOfCells();
}
VTKM_CONT_EXPORT
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagCell) const
{
return this->PermutedCellSet.GetNumberOfCells();
}
VTKM_CONT_EXPORT
vtkm::Id GetSchedulingRange(vtkm::TopologyElementTagPoint) const
{
return this->PermutedCellSet.GetNumberOfPoints();
}
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
struct ExecutionTypes
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
typedef typename PermutedCellSetType::template ExecutionTypes<
DeviceAdapter,
FromTopology,
ToTopology>::ExecObjectType ExecObjectType;
};
template<typename Device, typename FromTopology, typename ToTopology>
typename ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
PrepareForInput(Device d, FromTopology f, ToTopology t) const
{
return this->PermutedCellSet.PrepareForInput(d,f,t);
}
virtual void PrintSummary(std::ostream &out) const
{
out << " CellSetPermutation<ExplicitCellType>: " <<std::endl;
PermutedCellSet.PrintSummary(out);
}
private:
ValidCellArrayHandleType ValidCellIds;
PermutedCellSetType PermutedCellSet;
};
template< typename ValidCellArrayHandleType,vtkm::IdComponent Dimension>
class CellSetPermutation<ValidCellArrayHandleType, CellSetStructured<Dimension> > : public CellSet
{
typedef vtkm::internal::ConnectivityStructuredInternals<Dimension>
InternalsType;
public:
VTKM_CONT_EXPORT
CellSetPermutation(const ValidCellArrayHandleType& validCellIds,
const CellSetStructured<Dimension>& cellset,
const std::string &name = std::string(),
vtkm::IdComponent dimensionality = Dimension)
: CellSet(name,dimensionality),
ValidCellIds(),
FullCellSet()
{
this->Fill(validCellIds, cellset);
}
VTKM_CONT_EXPORT
CellSetPermutation(const std::string &name = std::string(),
vtkm::IdComponent dimensionality = Dimension)
: CellSet(name,dimensionality),
ValidCellIds(),
FullCellSet()
{
}
VTKM_CONT_EXPORT
vtkm::Id GetNumberOfCells() const
{
return this->ValidCellIds.GetNumberOfValues();
}
//This is the way you can fill the memory from another system without copying
VTKM_CONT_EXPORT
void Fill(const ValidCellArrayHandleType &validCellIds,
const CellSetStructured<Dimension>& cellset)
{
ValidCellIds = validCellIds;
FullCellSet = cellset;
}
template<typename TopologyElement>
VTKM_CONT_EXPORT
vtkm::Id GetSchedulingRange(TopologyElement) const {
VTKM_IS_TOPOLOGY_ELEMENT_TAG(TopologyElement);
return this->ValidCellIds.GetNumberOfValues();
}
template<typename Device, typename FromTopology, typename ToTopology>
struct ExecutionTypes {
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
typedef typename ValidCellArrayHandleType::template ExecutionTypes<Device>::PortalConst ExecPortalType;
typedef vtkm::exec::ConnectivityStructuredPermuted< ExecPortalType,
FromTopology,ToTopology,Dimension> ExecObjectType;
};
template<typename Device, typename FromTopology, typename ToTopology>
typename ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
PrepareForInput(Device d, FromTopology f, ToTopology t) const
{
typedef typename
ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
ConnectivityType;
return ConnectivityType(this->ValidCellIds.PrepareForInput(d),
this->FullCellSet.PrepareForInput(d,f,t) );
}
virtual void PrintSummary(std::ostream &out) const
{
out << " CellSetPermutation<StructuredCellType<"<<Dimension<<"> >: " <<std::endl;
}
private:
std::string Name;
vtkm::Id Dimensionality;
ValidCellArrayHandleType ValidCellIds;
CellSetStructured<Dimension> FullCellSet;
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_CellSetPermutation_h

@ -67,11 +67,58 @@ public:
{
}
/// First method to add cells -- one at a time.
VTKM_CONT_EXPORT
void PrepareToAddCells(vtkm::Id numShapes, vtkm::Id connectivityMaxLen)
{
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);
this->PointToCell.Shapes =
vtkm::cont::make_ArrayHandleConstant(shapeTypeValue, numShapes);
this->PointToCell.NumIndices =
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
numShapes);
this->PointToCell.IndexOffsets =
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
static_cast<vtkm::Id>(numberOfPointsPerCell),
numShapes );
this->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->NumberOfCells = 0;
this->ConnectivityLength = 0;
}
/// Second method to add cells -- one at a time.
template <vtkm::IdComponent ItemTupleLength>
VTKM_CONT_EXPORT
void AddCell(vtkm::UInt8 vtkmNotUsed(cellType),
vtkm::IdComponent numVertices,
const vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
{
for (vtkm::IdComponent i=0; i < numVertices; ++i)
{
this->PointToCell.Connectivity.GetPortalControl().Set(
this->ConnectivityLength+i,ids[i]);
}
this->NumberOfCells++;
this->ConnectivityLength += numVertices;
}
/// Third and final method to add cells -- one at a time.
VTKM_CONT_EXPORT
void CompleteAddingCells()
{
this->PointToCell.Connectivity.Shrink(this->ConnectivityLength);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->NumberOfCells = this->ConnectivityLength = -1;
}
//This is the way you can fill the memory from another system without copying
VTKM_CONT_EXPORT
void Fill(const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity)
{
vtkm::IdComponent numberOfPointsPerCell = this->DetermineNumberOfPoints();
const vtkm::Id length = connectivity.GetNumberOfValues() / numberOfPointsPerCell;
const vtkm::UInt8 shapeTypeValue = static_cast<vtkm::UInt8>(this->CellTypeAsId);

@ -122,6 +122,20 @@ public:
return this->CellSets[static_cast<std::size_t>(index)];
}
VTKM_CONT_EXPORT
vtkm::cont::DynamicCellSet GetCellSet(const std::string &name)
const
{
for (std::size_t i=0; i < static_cast<size_t>(this->GetNumberOfCellSets()); ++i)
{
if (this->CellSets[i].GetCellSet().GetName() == name)
{
return this->CellSets[i];
}
}
throw vtkm::cont::ErrorControlBadValue("No cell set with requested name");
}
VTKM_CONT_EXPORT
vtkm::IdComponent GetNumberOfCellSets() const
{

@ -17,25 +17,25 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_cont_ErrorControlOutOfMemory_h
#define vtk_m_cont_ErrorControlOutOfMemory_h
#ifndef vtk_m_cont_ErrorControlBadAllocation_h
#define vtk_m_cont_ErrorControlBadAllocation_h
#include <vtkm/cont/ErrorControl.h>
namespace vtkm {
namespace cont {
/// This class is thrown when a vtkm function or method tries to allocate an
/// array and fails.
/// This class is thrown when VTK-m attempts to manipulate memory that it should
/// not.
///
class ErrorControlOutOfMemory : public ErrorControl
class ErrorControlBadAllocation : public ErrorControl
{
public:
ErrorControlOutOfMemory(const std::string &message)
ErrorControlBadAllocation(const std::string &message)
: ErrorControl(message) { }
};
}
} // namespace vtkm::cont
#endif //vtk_m_cont_ErrorControlOutOfMemory_h
#endif //vtk_m_cont_ErrorControlBadAllocation_h

@ -131,7 +131,7 @@ public:
///
/// The allocation may be done on an already existing array, but can wipe out
/// any data already in the array. This method can throw
/// ErrorControlOutOfMemory if the array cannot be allocated or
/// ErrorControlBadAllocation if the array cannot be allocated or
/// ErrorControlBadValue if the allocation is not feasible (for example, the
/// array storage is read-only).
///

@ -23,7 +23,7 @@
#include <vtkm/Types.h>
#include <vtkm/cont/Assert.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/Storage.h>
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
@ -284,7 +284,7 @@ public:
this->Array = NULL;
this->NumberOfValues = 0;
this->AllocatedSize = 0;
throw vtkm::cont::ErrorControlOutOfMemory(
throw vtkm::cont::ErrorControlBadAllocation(
"Could not allocate basic control array.");
}

@ -58,7 +58,7 @@ public:
{
return this->Superclass::PrepareForInput(updateData);
}
catch (vtkm::cont::ErrorControlOutOfMemory error)
catch (vtkm::cont::ErrorControlBadAllocation error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();
@ -77,7 +77,7 @@ public:
{
return this->Superclass::PrepareForInPlace(updateData);
}
catch (vtkm::cont::ErrorControlOutOfMemory error)
catch (vtkm::cont::ErrorControlBadAllocation error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();
@ -96,7 +96,7 @@ public:
{
return this->Superclass::PrepareForOutput(numberOfValues);
}
catch (vtkm::cont::ErrorControlOutOfMemory error)
catch (vtkm::cont::ErrorControlBadAllocation error)
{
// Thrust does not seem to be clearing the CUDA error, so do it here.
cudaError_t cudaError = cudaPeekAtLastError();

@ -21,7 +21,7 @@
#define vtk_m_cont_cuda_internal_ArrayManagerExecutionThrustDevice_h
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/Storage.h>
// Disable warnings we check vtkm for but Thrust does not.
@ -153,7 +153,7 @@ public:
}
catch (std::bad_alloc error)
{
throw vtkm::cont::ErrorControlOutOfMemory(error.what());
throw vtkm::cont::ErrorControlBadAllocation(error.what());
}
return PortalType(this->Array.data(),

@ -21,7 +21,7 @@
#define vtk_m_cont_cuda_interal_ThrustExecptionHandler_h
#include <vtkm/internal/ExportMacros.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
VTKM_THIRDPARTY_PRE_INCLUDE
@ -43,7 +43,7 @@ static inline void throwAsVTKmException()
}
catch(std::bad_alloc &error)
{
throw vtkm::cont::ErrorControlOutOfMemory(error.what());
throw vtkm::cont::ErrorControlBadAllocation(error.what());
}
catch(thrust::system_error &error)
{

@ -24,7 +24,7 @@
#include <vtkm/cont/ArrayPortal.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/Assert.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <iterator>
#include <limits>
@ -55,7 +55,7 @@ public:
#ifndef VTKM_USE_64BIT_IDS
if (numberOfValues > std::numeric_limits<vtkm::Id>::max())
{
throw vtkm::cont::ErrorControlOutOfMemory(
throw vtkm::cont::ErrorControlBadAllocation(
"Distance of iterators larger than maximum array size. "
"To support larger arrays, try turning on VTKM_USE_64BIT_IDS.");
}

@ -29,14 +29,14 @@ namespace vtkm {
namespace cont {
namespace internal {
template<typename NumIndicesStorageTag,
typename IndexOffsetStorageTag,
template<typename NumIndicesArrayType,
typename IndexOffsetArrayType,
typename DeviceAdapterTag>
void buildIndexOffsets(vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> numIndices,
vtkm::cont::ArrayHandle<vtkm::Id, IndexOffsetStorageTag> offsets,
DeviceAdapterTag)
void buildIndexOffsets(const NumIndicesArrayType& numIndices,
IndexOffsetArrayType& offsets,
DeviceAdapterTag,
boost::mpl::bool_<true>)
{
typedef vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> NumIndicesArrayType;
//We first need to make sure that NumIndices and IndexOffsetArrayType
//have the same type so we can call scane exclusive
typedef vtkm::cont::ArrayHandleCast< vtkm::Id,
@ -49,13 +49,13 @@ void buildIndexOffsets(vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStor
Algorithm::ScanExclusive( CastedNumIndicesType(numIndices), offsets);
}
template<typename NumIndicesStorageTag,
typename ImplicitPortalTag,
template<typename NumIndicesArrayType,
typename IndexOffsetArrayType,
typename DeviceAdapterTag>
void buildIndexOffsets(vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag>,
vtkm::cont::ArrayHandle<vtkm::Id,
vtkm::cont::StorageTagImplicit< ImplicitPortalTag > >,
DeviceAdapterTag)
void buildIndexOffsets(const NumIndicesArrayType&,
IndexOffsetArrayType&,
DeviceAdapterTag,
boost::mpl::bool_<false>)
{
//this is a no-op as the storage for the offsets is an implicit handle
//and should already be built. This signature exists so that
@ -64,6 +64,19 @@ void buildIndexOffsets(vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStor
//cause a compile time failure.
}
template<typename ArrayHandleIndices,
typename ArrayHandleOffsets,
typename DeviceAdapterTag>
void buildIndexOffsets(const ArrayHandleIndices& numIndices,
ArrayHandleOffsets offsets,
DeviceAdapterTag tag)
{
typedef vtkm::cont::internal::IsWriteableArrayHandle<ArrayHandleOffsets,
DeviceAdapterTag> IsWriteable;
buildIndexOffsets(numIndices, offsets, tag, typename IsWriteable::type());
}
template<typename ShapeStorageTag = VTKM_DEFAULT_STORAGE_TAG,
typename NumIndicesStorageTag = VTKM_DEFAULT_STORAGE_TAG,
typename ConnectivityStorageTag = VTKM_DEFAULT_STORAGE_TAG,

@ -45,6 +45,7 @@ set(unit_tests
UnitTestDataSetRegular.cxx
UnitTestDataSetExplicit.cxx
UnitTestDataSetSingleType.cxx
UnitTestDataSetPermutation.cxx
UnitTestDeviceAdapterAlgorithmDependency.cxx
UnitTestDeviceAdapterAlgorithmGeneral.cxx
UnitTestDeviceAdapterSerial.cxx

@ -28,7 +28,7 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleZip.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/StorageBasic.h>
#include <vtkm/cont/Timer.h>
@ -355,7 +355,7 @@ private:
"or the width of vtkm::Id is not large enough to express all "
"array sizes.");
}
catch (vtkm::cont::ErrorControlOutOfMemory error)
catch (vtkm::cont::ErrorControlBadAllocation error)
{
std::cout << "Got the expected error: " << error.GetMessage() << std::endl;
}

@ -27,6 +27,7 @@
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/ArrayHandleGroupVec.h>
#include <vtkm/cont/ArrayHandleImplicit.h>
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
@ -64,6 +65,35 @@ struct ValueSquared
{ return vtkm::dot(u, u); }
};
struct ValueScale
{
ValueScale() : Factor()
{ }
ValueScale(vtkm::Float64 factor) : Factor(factor)
{ }
template<typename ValueType>
VTKM_EXEC_CONT_EXPORT
ValueType operator()(const ValueType &v) const
{
typedef vtkm::VecTraits<ValueType> Traits;
typedef typename Traits::ComponentType ComponentType;
ValueType result;
for (vtkm::IdComponent i = 0; i < Traits::GetNumberOfComponents(v); ++i)
{
vtkm::Float64 vi = static_cast<vtkm::Float64>(Traits::GetComponent(v, i));
vtkm::Float64 ri = vi * this->Factor;
Traits::SetComponent(result, i, static_cast<ComponentType>(ri));
}
return result;
}
private:
vtkm::Float64 Factor;
};
}
namespace vtkm {
@ -292,19 +322,17 @@ private:
template< typename ValueType>
VTKM_CONT_EXPORT void operator()(const ValueType vtkmNotUsed(v)) const
{
typedef typename vtkm::VecTraits<ValueType>::ComponentType OutputValueType;
typedef fancy_array_detail::ValueSquared<OutputValueType> FunctorType;
typedef fancy_array_detail::ValueScale FunctorType;
const vtkm::Id length = ARRAY_SIZE;
FunctorType functor;
FunctorType functor(2.0);
vtkm::cont::ArrayHandle<ValueType> input;
vtkm::cont::ArrayHandleTransform<
OutputValueType,
ValueType,
vtkm::cont::ArrayHandle<ValueType>,
FunctorType> transformed =
vtkm::cont::make_ArrayHandleTransform<OutputValueType>(input,
functor);
vtkm::cont::make_ArrayHandleTransform<ValueType>(input, functor);
typedef typename vtkm::cont::ArrayHandle<ValueType>::PortalControl Portal;
input.Allocate(length);
@ -314,7 +342,7 @@ private:
portal.Set(i, TestValue(i, ValueType()) );
}
vtkm::cont::ArrayHandle< OutputValueType > result;
vtkm::cont::ArrayHandle< ValueType > result;
vtkm::worklet::DispatcherMapField< PassThrough, DeviceAdapterTag > dispatcher;
dispatcher.Invoke(transformed, result);
@ -322,10 +350,9 @@ private:
//verify that the control portal works
for(vtkm::Id i=0; i < length; ++i)
{
const OutputValueType result_v = result.GetPortalConstControl().Get(i);
const OutputValueType correct_value = functor(TestValue(i, ValueType()));
const OutputValueType control_value =
transformed.GetPortalConstControl().Get(i);
const ValueType result_v = result.GetPortalConstControl().Get(i);
const ValueType correct_value = functor(TestValue(i, ValueType()));
const ValueType control_value = transformed.GetPortalConstControl().Get(i);
VTKM_TEST_ASSERT(test_equal(result_v, correct_value),
"Transform Handle Failed");
VTKM_TEST_ASSERT(test_equal(result_v, control_value),
@ -413,6 +440,109 @@ private:
}
};
template<vtkm::IdComponent NUM_COMPONENTS>
struct TestGroupVecAsInput
{
template<typename ComponentType>
VTKM_CONT_EXPORT
void operator()(ComponentType) const
{
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
ComponentType testValues[ARRAY_SIZE*NUM_COMPONENTS];
for(vtkm::Id index = 0; index < ARRAY_SIZE*NUM_COMPONENTS; ++index)
{
testValues[index] = TestValue(index, ComponentType());
}
vtkm::cont::ArrayHandle<ComponentType> baseArray =
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE*NUM_COMPONENTS);
vtkm::cont::ArrayHandleGroupVec<
vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS> groupArray(
baseArray);
VTKM_TEST_ASSERT(groupArray.GetNumberOfValues() == ARRAY_SIZE,
"Group array reporting wrong array size.");
vtkm::cont::ArrayHandle<ValueType> resultArray;
vtkm::worklet::DispatcherMapField< PassThrough, DeviceAdapterTag > dispatcher;
dispatcher.Invoke(groupArray, resultArray);
VTKM_TEST_ASSERT(resultArray.GetNumberOfValues() == ARRAY_SIZE,
"Got bad result array size.");
//verify that the control portal works
vtkm::Id totalIndex = 0;
for(vtkm::Id index = 0; index < ARRAY_SIZE; ++index)
{
const ValueType result = resultArray.GetPortalConstControl().Get(index);
for (vtkm::IdComponent componentIndex = 0;
componentIndex < NUM_COMPONENTS;
componentIndex++)
{
const ComponentType expectedValue =
TestValue(totalIndex, ComponentType());
VTKM_TEST_ASSERT(test_equal(result[componentIndex], expectedValue),
"Result array got wrong value.");
totalIndex++;
}
}
}
};
template<vtkm::IdComponent NUM_COMPONENTS>
struct TestGroupVecAsOutput
{
template<typename ComponentType>
VTKM_CONT_EXPORT
void operator()(ComponentType) const
{
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
ValueType testValues[ARRAY_SIZE];
for(vtkm::Id index = 0; index < ARRAY_SIZE; ++index)
{
testValues[index] = TestValue(index, ValueType());
}
vtkm::cont::ArrayHandle<ValueType> baseArray =
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE);
vtkm::cont::ArrayHandle<ComponentType> resultArray;
vtkm::cont::ArrayHandleGroupVec<
vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS> groupArray(
resultArray);
vtkm::worklet::DispatcherMapField< PassThrough, DeviceAdapterTag > dispatcher;
dispatcher.Invoke(baseArray, groupArray);
VTKM_TEST_ASSERT(groupArray.GetNumberOfValues() == ARRAY_SIZE,
"Group array reporting wrong array size.");
VTKM_TEST_ASSERT(
resultArray.GetNumberOfValues() == ARRAY_SIZE*NUM_COMPONENTS,
"Got bad result array size.");
//verify that the control portal works
vtkm::Id totalIndex = 0;
for(vtkm::Id index = 0; index < ARRAY_SIZE; ++index)
{
const ValueType expectedValue = TestValue(index, ValueType());
for (vtkm::IdComponent componentIndex = 0;
componentIndex < NUM_COMPONENTS;
componentIndex++)
{
const ComponentType result =
resultArray.GetPortalConstControl().Get(totalIndex);
VTKM_TEST_ASSERT(test_equal(result, expectedValue[componentIndex]),
"Result array got wrong value.");
totalIndex++;
}
}
}
};
struct TestZipAsInput
{
@ -638,6 +768,30 @@ private:
TestingFancyArrayHandles<DeviceAdapterTag>::TestCastAsInput(),
CastTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleGroupVec<3> as Input" << std::endl;
vtkm::testing::Testing::TryTypes(
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsInput<3>(),
HandleTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleGroupVec<4> as Input" << std::endl;
vtkm::testing::Testing::TryTypes(
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsInput<4>(),
HandleTypesToTest());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleGroupVec<2> as Output" << std::endl;
vtkm::testing::Testing::TryTypes(
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsOutput<2>(),
vtkm::TypeListTagScalarAll());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleGroupVec<3> as Output" << std::endl;
vtkm::testing::Testing::TryTypes(
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsOutput<3>(),
vtkm::TypeListTagScalarAll());
std::cout << "-------------------------------------------" << std::endl;
std::cout << "Testing ArrayHandleZip as Input" << std::endl;
vtkm::testing::Testing::TryTypes(

@ -122,6 +122,18 @@ void TestDataSet_Explicit()
correctConnectivity,
connectivitySize),
"Got incorrect conectivity");
//verify that GetIndices works properly
vtkm::Id expectedPointIds[4] = {2,1,3,4};
vtkm::Vec<vtkm::Id,4> retrievedPointIds;
cellset.GetIndices(1, retrievedPointIds);
for (vtkm::IdComponent i = 0; i < 4; i++)
{
VTKM_TEST_ASSERT(
retrievedPointIds[i] == expectedPointIds[i],
"Incorrect point ID for quad cell");
}
}
}

@ -0,0 +1,262 @@
//============================================================================
// 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 <vtkm/cont/DataSet.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/worklet/CellAverage.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
namespace {
template<typename T, typename Storage>
bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *expected,
vtkm::Id size)
{
if (size != ah.GetNumberOfValues())
{
return false;
}
for (vtkm::Id i = 0; i < size; ++i)
{
if (ah.GetPortalConstControl().Get(i) != expected[i])
{
return false;
}
}
return true;
}
inline vtkm::cont::DataSet make_SingleTypeDataSet()
{
using vtkm::cont::Field;
vtkm::cont::DataSet dataSet;
const int nVerts = 5;
typedef vtkm::Vec<vtkm::Float32,3> CoordType;
CoordType coordinates[nVerts] = {
CoordType(0, 0, 0),
CoordType(1, 0, 0),
CoordType(1, 1, 0),
CoordType(2, 1, 0),
CoordType(2, 2, 0)
};
//Set coordinate system
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem("coordinates", 1, coordinates, nVerts));
//Set point scalar
vtkm::Float32 vars[nVerts] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
dataSet.AddField(Field("pointvar", 1, vtkm::cont::Field::ASSOC_POINTS, vars, nVerts));
std::vector<vtkm::Id> conn;
// First Cell
conn.push_back(0);
conn.push_back(1);
conn.push_back(2);
// Second Cell
conn.push_back(1);
conn.push_back(2);
conn.push_back(3);
// Third Cell
conn.push_back(2);
conn.push_back(3);
conn.push_back(4);
vtkm::cont::CellSetSingleType<> cellSet(vtkm::CellShapeTagTriangle(),
"cells");
cellSet.FillViaCopy(conn);
dataSet.AddCellSet(cellSet);
return dataSet;
}
void TestDataSet_Explicit()
{
vtkm::cont::DataSet dataSet = make_SingleTypeDataSet();
std::vector<vtkm::Id> validIds;
validIds.push_back(1); //iterate the 2nd cell 4 times
validIds.push_back(1);
validIds.push_back(1);
validIds.push_back(1);
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds =
vtkm::cont::make_ArrayHandle(validIds);
//get the cellset single type from the dataset
typedef vtkm::cont::CellSetSingleType<> CellSetType;
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
//verify that we can create a subset of a singlset
typedef vtkm::cont::CellSetPermutation<vtkm::cont::ArrayHandle<vtkm::Id>,
vtkm::cont::CellSetSingleType<> > SubsetType;
SubsetType subset;
subset.Fill(validCellIds,cellSet);
subset.PrintSummary(std::cout);
typedef SubsetType::ExecutionTypes<vtkm::cont::DeviceAdapterTagSerial,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType ExecObjectType;
ExecObjectType execConnectivity;
execConnectivity = subset.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
subset,
result);
//iterate same cell 4 times
vtkm::Float32 expected[4] = { 30.1667f, 30.1667f, 30.1667f, 30.1667f };
for (int i = 0; i < 4; ++i)
{
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(i),
expected[i]), "Wrong result for CellAverage worklet on explicit subset data");
}
}
void TestDataSet_Structured2D()
{
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make2DRegularDataSet0();
std::vector<vtkm::Id> validIds;
validIds.push_back(1); //iterate the 2nd cell 4 times
validIds.push_back(1);
validIds.push_back(1);
validIds.push_back(1);
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds =
vtkm::cont::make_ArrayHandle(validIds);
typedef vtkm::cont::CellSetStructured<2> CellSetType;
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
//verify that we can create a subset of a 2d RegularDataSet
vtkm::cont::CellSetPermutation<vtkm::cont::ArrayHandle<vtkm::Id>,
vtkm::cont::CellSetStructured<2> > subset;
subset.Fill(validCellIds,cellSet);
subset.PrintSummary(std::cout);
//verify that we can call PrepareForInput on CellSetSingleType
typedef vtkm::cont::DeviceAdapterTagSerial DeviceAdapterTag;
//verify that PrepareForInput exists
subset.PrepareForInput(DeviceAdapterTag(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
subset,
result);
vtkm::Float32 expected[4] = { 40.1f, 40.1f, 40.1f, 40.1f };
for (int i = 0; i < 4; ++i)
{
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(i),
expected[i]), "Wrong result for CellAverage worklet on 2d structured subset data");
}
}
void TestDataSet_Structured3D()
{
vtkm::cont::testing::MakeTestDataSet testDataSet;
vtkm::cont::DataSet dataSet = testDataSet.Make3DRegularDataSet0();
std::vector<vtkm::Id> validIds;
validIds.push_back(1); //iterate the 2nd cell 4 times
validIds.push_back(1);
validIds.push_back(1);
validIds.push_back(1);
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds =
vtkm::cont::make_ArrayHandle(validIds);
typedef vtkm::cont::CellSetStructured<3> CellSetType;
CellSetType cellSet = dataSet.GetCellSet(0).CastTo<CellSetType>();
//verify that we can create a subset of a 2d RegularDataSet
vtkm::cont::CellSetPermutation<vtkm::cont::ArrayHandle<vtkm::Id>,
vtkm::cont::CellSetStructured<3> > subset;
subset.Fill(validCellIds,cellSet);
subset.PrintSummary(std::cout);
//verify that PrepareForInput exists
subset.PrepareForInput(
vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
subset,
result);
vtkm::Float32 expected[4] = { 70.2125f, 70.2125f, 70.2125f, 70.2125f };
for (int i = 0; i < 4; ++i)
{
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(i),
expected[i]), "Wrong result for CellAverage worklet on 2d structured subset data");
}
}
void TestDataSet_Permutation()
{
std::cout << std::endl;
std::cout << "--TestDataSet_Permutation--" << std::endl << std::endl;
TestDataSet_Explicit();
TestDataSet_Structured2D();
TestDataSet_Structured3D();
}
}
int UnitTestDataSetPermutation(int, char *[])
{
return vtkm::cont::testing::Testing::Run(TestDataSet_Permutation);
}

@ -23,6 +23,9 @@
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/worklet/CellAverage.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
namespace {
template<typename T, typename Storage>
@ -45,7 +48,6 @@ bool TestArrayHandle(const vtkm::cont::ArrayHandle<T, Storage> &ah, const T *exp
return true;
}
inline vtkm::cont::DataSet make_SingleTypeDataSet()
{
using vtkm::cont::Field;
@ -96,13 +98,13 @@ inline vtkm::cont::DataSet make_SingleTypeDataSet()
void TestDataSet_Explicit()
{
vtkm::cont::DataSet ds = make_SingleTypeDataSet();
vtkm::cont::DataSet dataSet = make_SingleTypeDataSet();
ds.PrintSummary(std::cout);
dataSet.PrintSummary(std::cout);
//verify that we can get a CellSetSingleType from a dataset
vtkm::cont::CellSetSingleType<> &cellset =
ds.GetCellSet(0).CastTo<vtkm::cont::CellSetSingleType<> >();
dataSet.GetCellSet(0).CastTo<vtkm::cont::CellSetSingleType<> >();
//verify that we can compute the cell to point connectivity
@ -135,6 +137,21 @@ void TestDataSet_Explicit()
VTKM_TEST_ASSERT( numIndicesCellToPoint.GetNumberOfValues() == 5, "Wrong number of indices");
VTKM_TEST_ASSERT( connCellToPoint.GetNumberOfValues() == 9, "Wrong connectivity length");
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
dispatcher.Invoke(dataSet.GetField("pointvar").GetData(),
cellset,
result);
vtkm::Float32 expected[3] = { 20.1333f, 30.1667f, 40.2333f };
for (int i = 0; i < 3; ++i)
{
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(i),
expected[i]), "Wrong result for CellAverage worklet on explicit single type cellset data");
}
}
}

@ -27,6 +27,7 @@
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/ArrayHandleGroupVec.h>
#include <vtkm/cont/ArrayHandleImplicit.h>
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
@ -374,6 +375,11 @@ void TryCastToArrayHandle()
ARRAY_SIZE-1, -1, ARRAY_SIZE);
CheckCastToArrayHandle(countingArray);
std::cout << " Group vec array handle" << std::endl;
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<vtkm::Id>, 2>
groupVecArray(array);
CheckCastToArrayHandle(groupVecArray);
std::cout << " Implicit array handle." << std::endl;
CheckCastToArrayHandle(
vtkm::cont::make_ArrayHandleImplicit<vtkm::FloatDefault>(

@ -24,11 +24,13 @@ set(headers
CellInterpolate.h
ConnectivityExplicit.h
ConnectivityStructured.h
ConnectivityStructuredPermuted.h
ExecutionObjectBase.h
ExecutionWholeArray.h
FunctorBase.h
NewtonsMethod.h
ParametricCoordinates.h
)
#-----------------------------------------------------------------------------

@ -0,0 +1,99 @@
//============================================================================
// 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_exec_ConnectivityStructuredPermuted_h
#define vtk_m_exec_ConnectivityStructuredPermuted_h
#include <vtkm/TopologyElementTag.h>
#include <vtkm/Types.h>
#include <vtkm/exec/ConnectivityStructured.h>
namespace vtkm {
namespace exec {
template<typename PermutationPortal,
typename FromTopology,
typename ToTopology,
vtkm::IdComponent Dimension>
class ConnectivityStructuredPermuted
{
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
typedef vtkm::exec::ConnectivityStructured<FromTopology,
ToTopology,
Dimension> StructuredType;
public:
typedef vtkm::Id SchedulingRangeType;
VTKM_EXEC_CONT_EXPORT
ConnectivityStructuredPermuted():
Portal(),
FullStructuredGrid()
{
}
VTKM_EXEC_CONT_EXPORT
ConnectivityStructuredPermuted(const PermutationPortal& portal,
const StructuredType &src):
Portal(portal),
FullStructuredGrid(src)
{
}
VTKM_EXEC_CONT_EXPORT
ConnectivityStructuredPermuted(const ConnectivityStructuredPermuted &src):
Portal(src.Portal),
FullStructuredGrid(src.FullStructuredGrid)
{
}
VTKM_EXEC_EXPORT
vtkm::IdComponent GetNumberOfIndices(vtkm::Id index) const {
return this->FullStructuredGrid.GetNumberOfIndices( this->Portal.Get(index) );
}
// This needs some thought. What does cell shape mean when the to topology
// is not a cell?
typedef typename StructuredType::CellShapeTag CellShapeTag;
VTKM_EXEC_EXPORT
CellShapeTag GetCellShape(vtkm::Id=0) const {
return CellShapeTag();
}
typedef typename StructuredType::IndicesType IndicesType;
VTKM_EXEC_EXPORT
IndicesType GetIndices(vtkm::Id index) const
{
return this->FullStructuredGrid.GetIndices( this->Portal.Get(index) );
}
private:
PermutationPortal Portal;
StructuredType FullStructuredGrid;
};
}
} // namespace vtkm::exec
#endif //vtk_m_exec_ConnectivityStructuredPermuted_h

@ -46,14 +46,13 @@ struct Fetch<
typedef typename Invocation::ParameterInterface::
template ParameterType<ParameterIndex>::type ExecObjectType;
typedef vtkm::Id ValueType;
typedef typename ExecObjectType::CellShapeTag ValueType;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_EXPORT
ValueType Load(vtkm::Id index, const Invocation &invocation) const
{
return invocation.Parameters.template GetParameter<ParameterIndex>().
GetElementShapeType(index);
return invocation.Parameters.template GetParameter<ParameterIndex>.GetCellShape(index);
}
VTKM_EXEC_EXPORT

@ -317,6 +317,8 @@ public:
void SetPointDimensions(vtkm::Id3 dims)
{
this->PointDimensions = dims;
this->CellDimensions = dims - vtkm::Id3(1);
this->CellDim01 = (dims[0]-1) * (dims[1]-1);
}
VTKM_EXEC_CONT_EXPORT
@ -469,13 +471,12 @@ public:
VTKM_EXEC_CONT_EXPORT
vtkm::Id3 FlatToLogicalPointIndex(vtkm::Id flatPointIndex) const
{
vtkm::Id3 logicalPointIndex;
vtkm::Id pointDims01 = this->PointDimensions[0] * this->PointDimensions[1];
logicalPointIndex[2] = flatPointIndex / pointDims01;
vtkm::Id indexij = flatPointIndex % pointDims01;
logicalPointIndex[1] = indexij / this->PointDimensions[0];
logicalPointIndex[0] = indexij % this->PointDimensions[0];
return logicalPointIndex;
const vtkm::Id pointDims01 = this->PointDimensions[0] * this->PointDimensions[1];
const vtkm::Id indexij = flatPointIndex % pointDims01;
return vtkm::Id3(indexij % this->PointDimensions[0],
indexij / this->PointDimensions[0],
flatPointIndex / pointDims01);
}
VTKM_EXEC_CONT_EXPORT
@ -489,14 +490,11 @@ public:
VTKM_EXEC_CONT_EXPORT
vtkm::Id3 FlatToLogicalCellIndex(vtkm::Id flatCellIndex) const
{
vtkm::Id3 cellDimensions = this->GetCellDimensions();
vtkm::Id3 logicalCellIndex;
vtkm::Id cellDims01 = cellDimensions[0] * cellDimensions[1];
logicalCellIndex[2] = flatCellIndex / cellDims01;
vtkm::Id indexij = flatCellIndex % cellDims01;
logicalCellIndex[1] = indexij / cellDimensions[0];
logicalCellIndex[0] = indexij % cellDimensions[0];
return logicalCellIndex;
const vtkm::Id indexij = flatCellIndex % this->CellDim01;
return vtkm::Id3(indexij % this->CellDimensions[0],
indexij / this->CellDimensions[0],
flatCellIndex / this->CellDim01
);
}
VTKM_EXEC_CONT_EXPORT
@ -510,7 +508,8 @@ public:
private:
vtkm::Id3 PointDimensions;
vtkm::Id3 CellDimensions;
vtkm::Id CellDim01;
};
// We may want to generalize this class depending on how ConnectivityExplicit

@ -21,7 +21,7 @@
#define vtkm_opengl_cuda_internal_TransferToOpenGL_h
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/ErrorControlOutOfMemory.h>
#include <vtkm/cont/ErrorControlBadAllocation.h>
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
#include <vtkm/cont/cuda/internal/MakeThrustIterator.h>
@ -96,7 +96,7 @@ public:
cError =cudaGraphicsMapResources(1,&cudaResource);
if(cError != cudaSuccess)
{
throw vtkm::cont::ErrorControlOutOfMemory(
throw vtkm::cont::ErrorControlBadAllocation(
"Could not allocate enough memory in CUDA for OpenGL interop.");
}

@ -46,8 +46,9 @@ void CopyFromHandle(
//synchronizing the control array. Last, we steal the array and pass the
//iterator to the rendering system
const vtkm::Id numberOfValues = handle.GetNumberOfValues();
const std::size_t size =
sizeof(ValueType) * static_cast<std::size_t>(numberOfValues);
const GLsizeiptr size =
static_cast<GLsizeiptr>(sizeof(ValueType)) *
static_cast<GLsizeiptr>(numberOfValues);
//Copy the data from its specialized Storage container to a basic storage
vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagBasic> tmpHandle;
@ -82,8 +83,9 @@ void CopyFromHandle(
//from the portal to OpenGL to upload to the rendering system
//This also works because we know that this class isn't used for cuda interop,
//instead we are specialized
const std::size_t size =
sizeof(ValueType) * static_cast<std::size_t>(handle.GetNumberOfValues());
const GLsizeiptr size =
static_cast<GLsizeiptr>(sizeof(ValueType)) *
static_cast<GLsizeiptr>(handle.GetNumberOfValues());
//Detach the current buffer
glBufferData(type, size, 0, GL_DYNAMIC_DRAW);

@ -77,7 +77,7 @@ private:
{
vtkm::opengl::TransferToOpenGL(array,handle, DeviceAdapterTag());
}
catch (vtkm::cont::ErrorControlOutOfMemory error)
catch (vtkm::cont::ErrorControlBadAllocation error)
{
std::cout << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,
@ -99,7 +99,7 @@ private:
{
vtkm::opengl::TransferToOpenGL(array,handle,type, DeviceAdapterTag());
}
catch (vtkm::cont::ErrorControlOutOfMemory error)
catch (vtkm::cont::ErrorControlBadAllocation error)
{
std::cout << error.GetMessage() << std::endl;
VTKM_TEST_ASSERT(true==false,

@ -91,23 +91,6 @@ private:
vtkm::cont::DynamicArrayHandle *OutputValues;
};
template<typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag>
vtkm::cont::CellSetExplicit<
ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag>
make_CellSetExplicit(
const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag> &cellTypes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag> &numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag> &connectivity)
{
vtkm::cont::CellSetExplicit<
ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag> cellSet;
cellSet.Fill(cellTypes, numIndices, connectivity);
return cellSet;
}
} // namespace internal
template<typename DeviceAdapter>
@ -507,10 +490,10 @@ public:
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", 0, repPointArray));
output.AddCellSet(internal::make_CellSetExplicit(
vtkm::cont::make_ArrayHandleConstant<vtkm::UInt8>(vtkm::CELL_SHAPE_TRIANGLE, cells),
vtkm::cont::make_ArrayHandleConstant<vtkm::IdComponent>(3, cells),
internal::copyFromVec(pointId3Array, DeviceAdapter())));
vtkm::cont::CellSetSingleType< > triangles(vtkm::CellShapeTagTriangle(),
"cells");
triangles.Fill( internal::copyFromVec(pointId3Array, DeviceAdapter()) );
output.AddCellSet( triangles );
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
vtkm::Float64 t = timer.GetElapsedTime();

@ -67,13 +67,9 @@ void TestVertexClustering()
VTKM_TEST_ASSERT(test_equal(p1, p2), "Point Array mismatch");
}
typedef vtkm::cont::CellSetExplicit<
vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag,
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag,
VTKM_DEFAULT_STORAGE_TAG> CellSetType;
typedef vtkm::cont::CellSetSingleType<> CellSetType;
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCellSets() == 1, "Number of output cellsets mismatch");
CellSetType &cellSet = outDataSet.GetCellSet(0).CastTo<CellSetType>();
CellSetType cellSet = outDataSet.GetCellSet(0).CastTo<CellSetType>();
VTKM_TEST_ASSERT(
cellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell()).GetNumberOfValues() == output_pointIds,
"Number of connectivity array elements mismatch");