2016-11-07 19:59:49 +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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2016-11-07 19:59:49 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
|
|
|
// Copyright 2014 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2016-11-07 19:59:49 +00:00
|
|
|
// 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/arg/TransportTagCellSetIn.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/CellSetExplicit.h>
|
|
|
|
|
|
|
|
#include <vtkm/exec/FunctorBase.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/testing/Testing.h>
|
2016-11-07 19:59:49 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2016-11-07 19:59:49 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CellSetInType>
|
2016-11-07 19:59:49 +00:00
|
|
|
struct TestKernel : public vtkm::exec::FunctorBase
|
|
|
|
{
|
|
|
|
CellSetInType CellSet;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2016-11-07 19:59:49 +00:00
|
|
|
void operator()(vtkm::Id) const
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
if (this->CellSet.GetNumberOfElements() != 2)
|
2016-11-07 19:59:49 +00:00
|
|
|
{
|
|
|
|
this->RaiseError("Got bad number of shapes in exec cellset object.");
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
if (this->CellSet.GetIndices(0).GetNumberOfComponents() != 3 ||
|
|
|
|
this->CellSet.GetIndices(1).GetNumberOfComponents() != 4)
|
2016-11-07 19:59:49 +00:00
|
|
|
{
|
|
|
|
this->RaiseError("Got bad number of Indices in exec cellset object.");
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
if (this->CellSet.GetCellShape(0).Id != 5 || this->CellSet.GetCellShape(1).Id != 9)
|
2016-11-07 19:59:49 +00:00
|
|
|
{
|
|
|
|
this->RaiseError("Got bad cell shape in exec cellset object.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Device>
|
2016-11-07 19:59:49 +00:00
|
|
|
void TransportWholeCellSetIn(Device)
|
|
|
|
{
|
|
|
|
//build a fake cell set
|
|
|
|
const int nVerts = 5;
|
2016-12-20 23:14:50 +00:00
|
|
|
vtkm::cont::CellSetExplicit<> contObject("cells");
|
2016-11-07 19:59:49 +00:00
|
|
|
contObject.PrepareToAddCells(2, 7);
|
2017-05-18 14:29:41 +00:00
|
|
|
contObject.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, vtkm::make_Vec<vtkm::Id>(0, 1, 2));
|
|
|
|
contObject.AddCell(vtkm::CELL_SHAPE_QUAD, 4, vtkm::make_Vec<vtkm::Id>(2, 1, 3, 4));
|
2016-12-20 23:14:50 +00:00
|
|
|
contObject.CompleteAddingCells(nVerts);
|
2016-11-07 19:59:49 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using FromType = vtkm::TopologyElementTagPoint;
|
|
|
|
using ToType = vtkm::TopologyElementTagCell;
|
2016-11-07 19:59:49 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ExecObjectType =
|
|
|
|
typename vtkm::cont::CellSetExplicit<>::template ExecutionTypes<Device,
|
|
|
|
FromType,
|
|
|
|
ToType>::ExecObjectType;
|
2016-11-07 19:59:49 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::arg::Transport<vtkm::cont::arg::TransportTagCellSetIn<FromType, ToType>,
|
2017-05-26 17:53:28 +00:00
|
|
|
vtkm::cont::CellSetExplicit<>,
|
|
|
|
Device>
|
2017-05-18 14:29:41 +00:00
|
|
|
transport;
|
2016-11-07 19:59:49 +00:00
|
|
|
|
|
|
|
TestKernel<ExecObjectType> kernel;
|
2017-03-24 20:51:46 +00:00
|
|
|
kernel.CellSet = transport(contObject, nullptr, 1, 1);
|
2016-11-07 19:59:49 +00:00
|
|
|
|
|
|
|
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnitTestCellSetIn()
|
|
|
|
{
|
|
|
|
std::cout << "Trying CellSetIn transport with serial device." << std::endl;
|
|
|
|
TransportWholeCellSetIn(vtkm::cont::DeviceAdapterTagSerial());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Anonymous namespace
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
int UnitTestTransportCellSetIn(int, char* [])
|
2016-11-07 19:59:49 +00:00
|
|
|
{
|
|
|
|
return vtkm::cont::testing::Testing::Run(UnitTestCellSetIn);
|
|
|
|
}
|