2017-03-23 17:58:00 +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).
|
2017-03-23 17:58:00 +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,
|
2017-03-23 17:58:00 +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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtkm_m_worklet_Tetrahedralize_h
|
|
|
|
#define vtkm_m_worklet_Tetrahedralize_h
|
|
|
|
|
|
|
|
#include <vtkm/worklet/tetrahedralize/TetrahedralizeExplicit.h>
|
|
|
|
#include <vtkm/worklet/tetrahedralize/TetrahedralizeStructured.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
2017-03-23 17:58:00 +00:00
|
|
|
|
2017-10-02 21:20:08 +00:00
|
|
|
class Tetrahedralize
|
2017-03-24 22:34:53 +00:00
|
|
|
{
|
2017-10-02 21:20:08 +00:00
|
|
|
public:
|
|
|
|
//
|
|
|
|
// Distribute multiple copies of cell data depending on cells create from original
|
|
|
|
//
|
|
|
|
struct DistributeCellData : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
2018-05-25 21:18:41 +00:00
|
|
|
using ControlSignature = void(FieldIn<> inIndices, FieldOut<> outIndices);
|
|
|
|
using ExecutionSignature = void(_1, _2);
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2018-02-22 13:29:13 +00:00
|
|
|
using ScatterType = vtkm::worklet::ScatterCounting;
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2017-10-02 21:20:08 +00:00
|
|
|
template <typename CountArrayType, typename DeviceAdapter>
|
Move Scatter from Worklet to Dispatcher
Previously, when a Worklet needed a scatter, the scatter object was
stored in the Worklet object. That was problematic because that means
the Scatter, which is a control object, was shoved into the execution
environment.
To prevent that, move the Scatter into the Dispatcher object. The
worklet still declares a ScatterType alias, but no longer has a
GetScatter method. Instead, the Dispatcher now takes a Scatter object in
its constructor. If using the default scatter (ScatterIdentity), the
default constructor is used. If using another type of Scatter that
requires data to set up its state, then the caller of the worklet needs
to provide that to the dispatcher. For convenience, worklets are
encouraged to have a MakeScatter method to help construct a proper
scatter object.
2018-04-27 04:43:51 +00:00
|
|
|
VTKM_CONT static ScatterType MakeScatter(const CountArrayType& countArray, DeviceAdapter device)
|
2017-10-02 21:20:08 +00:00
|
|
|
{
|
Move Scatter from Worklet to Dispatcher
Previously, when a Worklet needed a scatter, the scatter object was
stored in the Worklet object. That was problematic because that means
the Scatter, which is a control object, was shoved into the execution
environment.
To prevent that, move the Scatter into the Dispatcher object. The
worklet still declares a ScatterType alias, but no longer has a
GetScatter method. Instead, the Dispatcher now takes a Scatter object in
its constructor. If using the default scatter (ScatterIdentity), the
default constructor is used. If using another type of Scatter that
requires data to set up its state, then the caller of the worklet needs
to provide that to the dispatcher. For convenience, worklets are
encouraged to have a MakeScatter method to help construct a proper
scatter object.
2018-04-27 04:43:51 +00:00
|
|
|
return ScatterType(countArray, device);
|
2017-10-02 21:20:08 +00:00
|
|
|
}
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2017-10-02 21:20:08 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC void operator()(T inputIndex, T& outputIndex) const
|
|
|
|
{
|
|
|
|
outputIndex = inputIndex;
|
|
|
|
}
|
|
|
|
};
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
Tetrahedralize()
|
|
|
|
: OutCellsPerCell()
|
|
|
|
{
|
|
|
|
}
|
2017-03-23 17:58:00 +00:00
|
|
|
|
2017-03-24 22:34:53 +00:00
|
|
|
// Tetrahedralize explicit data set, save number of tetra cells per input
|
2018-08-28 20:36:50 +00:00
|
|
|
template <typename CellSetType>
|
|
|
|
vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet)
|
2017-03-23 17:58:00 +00:00
|
|
|
{
|
2018-08-28 20:36:50 +00:00
|
|
|
TetrahedralizeExplicit worklet;
|
2017-04-17 20:21:29 +00:00
|
|
|
return worklet.Run(cellSet, this->OutCellsPerCell);
|
2017-03-23 17:58:00 +00:00
|
|
|
}
|
|
|
|
|
2017-03-24 22:34:53 +00:00
|
|
|
// Tetrahedralize structured data set, save number of tetra cells per input
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<3>& cellSet)
|
2017-03-23 17:58:00 +00:00
|
|
|
{
|
2018-08-28 20:36:50 +00:00
|
|
|
TetrahedralizeStructured worklet;
|
2017-04-17 20:21:29 +00:00
|
|
|
return worklet.Run(cellSet, this->OutCellsPerCell);
|
2017-03-24 22:34:53 +00:00
|
|
|
}
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<2>&)
|
2017-03-27 17:41:37 +00:00
|
|
|
{
|
2017-03-27 22:25:38 +00:00
|
|
|
throw vtkm::cont::ErrorBadType("CellSetStructured<2> can't be tetrahedralized");
|
2017-03-27 17:41:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-24 22:34:53 +00:00
|
|
|
// Using the saved input to output cells, expand cell data
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename StorageType, typename DeviceAdapter>
|
2017-06-15 18:14:27 +00:00
|
|
|
vtkm::cont::ArrayHandle<T> ProcessCellField(const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
|
|
|
const DeviceAdapter& device) const
|
2017-03-24 22:34:53 +00:00
|
|
|
{
|
2017-06-15 18:14:27 +00:00
|
|
|
vtkm::cont::ArrayHandle<T> output;
|
2017-03-24 22:34:53 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<DistributeCellData> dispatcher(
|
Move Scatter from Worklet to Dispatcher
Previously, when a Worklet needed a scatter, the scatter object was
stored in the Worklet object. That was problematic because that means
the Scatter, which is a control object, was shoved into the execution
environment.
To prevent that, move the Scatter into the Dispatcher object. The
worklet still declares a ScatterType alias, but no longer has a
GetScatter method. Instead, the Dispatcher now takes a Scatter object in
its constructor. If using the default scatter (ScatterIdentity), the
default constructor is used. If using another type of Scatter that
requires data to set up its state, then the caller of the worklet needs
to provide that to the dispatcher. For convenience, worklets are
encouraged to have a MakeScatter method to help construct a proper
scatter object.
2018-04-27 04:43:51 +00:00
|
|
|
DistributeCellData::MakeScatter(this->OutCellsPerCell, device));
|
2018-08-28 20:36:50 +00:00
|
|
|
dispatcher.SetDevice(DeviceAdapter());
|
2017-03-24 22:34:53 +00:00
|
|
|
dispatcher.Invoke(input, output);
|
|
|
|
|
|
|
|
return output;
|
2017-03-23 17:58:00 +00:00
|
|
|
}
|
2017-03-24 22:34:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> OutCellsPerCell;
|
2017-03-23 17:58:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
} // namespace vtkm::worklet
|
|
|
|
|
|
|
|
#endif // vtkm_m_worklet_Tetrahedralize_h
|