2015-09-28 17:15:26 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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>
|
2016-04-08 17:49:51 +00:00
|
|
|
|
|
|
|
#include <vtkm/exec/ConnectivityPermuted.h>
|
2015-09-28 17:15:26 +00:00
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace cont {
|
|
|
|
|
2016-04-08 17:49:51 +00:00
|
|
|
template< typename OriginalCellSet, typename ValidCellArrayHandleType> class CellSetPermutation;
|
2015-09-28 17:15:26 +00:00
|
|
|
|
2016-04-08 17:49:51 +00:00
|
|
|
namespace internal {
|
2015-09-28 17:15:26 +00:00
|
|
|
|
2016-04-08 17:49:51 +00:00
|
|
|
template< typename OriginalCellSet, typename PermutationArrayHandleType >
|
|
|
|
class CellSetGeneralPermutation : public CellSet
|
2015-09-28 17:15:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-04-08 17:49:51 +00:00
|
|
|
CellSetGeneralPermutation(const PermutationArrayHandleType& validCellIds,
|
|
|
|
const OriginalCellSet& cellset,
|
2016-05-13 18:26:59 +00:00
|
|
|
const std::string &name)
|
|
|
|
: CellSet(name),
|
2016-04-08 17:49:51 +00:00
|
|
|
ValidCellIds(validCellIds),
|
|
|
|
FullCellSet(cellset)
|
2015-09-28 17:15:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-05-13 18:26:59 +00:00
|
|
|
CellSetGeneralPermutation(const std::string &name)
|
|
|
|
: CellSet(name),
|
2015-09-28 17:15:26 +00:00
|
|
|
ValidCellIds(),
|
|
|
|
FullCellSet()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 17:15:26 +00:00
|
|
|
vtkm::Id GetNumberOfCells() const
|
|
|
|
{
|
|
|
|
return this->ValidCellIds.GetNumberOfValues();
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-12-22 00:27:54 +00:00
|
|
|
vtkm::Id GetNumberOfPoints() const
|
|
|
|
{
|
|
|
|
return this->FullCellSet.GetNumberOfPoints();
|
|
|
|
}
|
|
|
|
|
2015-09-28 17:15:26 +00:00
|
|
|
//This is the way you can fill the memory from another system without copying
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-04-08 17:49:51 +00:00
|
|
|
void Fill(const PermutationArrayHandleType &validCellIds,
|
|
|
|
const OriginalCellSet& cellset)
|
2015-09-28 17:15:26 +00:00
|
|
|
{
|
|
|
|
ValidCellIds = validCellIds;
|
|
|
|
FullCellSet = cellset;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TopologyElement>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 17:15:26 +00:00
|
|
|
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);
|
|
|
|
|
2016-04-08 17:49:51 +00:00
|
|
|
typedef typename PermutationArrayHandleType::template ExecutionTypes<Device>::PortalConst ExecPortalType;
|
2015-09-28 17:15:26 +00:00
|
|
|
|
2016-04-08 17:49:51 +00:00
|
|
|
typedef typename OriginalCellSet::template ExecutionTypes<
|
|
|
|
Device,
|
|
|
|
FromTopology,
|
|
|
|
ToTopology>::ExecObjectType OrigExecObjectType;
|
|
|
|
|
|
|
|
typedef vtkm::exec::ConnectivityPermuted< ExecPortalType, OrigExecObjectType> ExecObjectType;
|
2015-09-28 17:15:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2016-04-08 17:49:51 +00:00
|
|
|
out << " CellSetGeneralPermutation of: "<< std::endl;
|
|
|
|
this->FullCellSet.PrintSummary(out);
|
2015-09-28 17:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-04-08 17:49:51 +00:00
|
|
|
PermutationArrayHandleType ValidCellIds;
|
|
|
|
OriginalCellSet FullCellSet;
|
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace internal
|
|
|
|
|
|
|
|
#ifndef VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG
|
|
|
|
#define VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template< typename OriginalCellSet,
|
|
|
|
typename PermutationArrayHandleType = vtkm::cont::ArrayHandle< vtkm::Id, VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG > >
|
|
|
|
class CellSetPermutation : public vtkm::cont::internal::CellSetGeneralPermutation<OriginalCellSet, PermutationArrayHandleType>
|
|
|
|
{
|
|
|
|
typedef typename vtkm::cont::internal::CellSetGeneralPermutation<
|
|
|
|
OriginalCellSet, PermutationArrayHandleType> ParentType;
|
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-04-08 17:49:51 +00:00
|
|
|
CellSetPermutation(const PermutationArrayHandleType& validCellIds,
|
|
|
|
const OriginalCellSet& cellset,
|
2016-05-13 18:26:59 +00:00
|
|
|
const std::string &name = std::string())
|
|
|
|
: ParentType(validCellIds, cellset, name)
|
2016-04-08 17:49:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-05-13 18:26:59 +00:00
|
|
|
CellSetPermutation(const std::string &name = std::string())
|
|
|
|
: ParentType(name)
|
2016-04-08 17:49:51 +00:00
|
|
|
{
|
|
|
|
}
|
2015-09-28 17:15:26 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
|
|
|
#endif //vtk_m_cont_CellSetPermutation_h
|