mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-19 02:25:42 +00:00
map cell is now map topology -- the type of map depends on the passed-in topology.
This commit is contained in:
parent
6d7e2012ab
commit
d807c1d865
@ -35,6 +35,11 @@ public:
|
||||
for (int i=0; i<n && i<ItemTupleLength; i++)
|
||||
ids[i] = Connectivity.GetPortalControl().Get(start+i);
|
||||
}
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
void AddShape(vtkm::CellType cellType, int numVertices, vtkm::Vec<vtkm::Id,ItemTupleLength> &ids)
|
||||
{
|
||||
///\todo: how do I modify an array handle?
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic> Shapes;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic> NumIndices;
|
||||
|
@ -21,18 +21,18 @@
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/worklet/WorkletMapCell.h>
|
||||
#include <vtkm/worklet/DispatcherMapCell.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/exec/arg/TopologyIdSet.h>
|
||||
#include <vtkm/exec/arg/TopologyIdCount.h>
|
||||
#include <vtkm/exec/arg/TopologyElementType.h>
|
||||
|
||||
static const int LEN_IDS = 6;
|
||||
|
||||
class CellType : public vtkm::worklet::WorkletMapCell
|
||||
class CellType : public vtkm::worklet::WorkletMapTopology
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldCellIn<Scalar> inCells, FieldNodeIn<Scalar> inNodes, TopologyIn<LEN_IDS> topology, FieldCellOut<Scalar> outCells);
|
||||
typedef void ControlSignature(FieldDestIn<Scalar> inCells, FieldSrcIn<Scalar> inNodes, TopologyIn<LEN_IDS> topology, FieldDestOut<Scalar> outCells);
|
||||
typedef _4 ExecutionSignature(_1, _2, vtkm::exec::arg::TopologyIdCount, vtkm::exec::arg::TopologyElementType, vtkm::exec::arg::TopologyIdSet);
|
||||
typedef _3 InputDomain;
|
||||
|
||||
@ -151,7 +151,7 @@ void TestDataSet_Explicit()
|
||||
vtkm::Float32 outcellVals[2] = {-1.4, -1.7};
|
||||
ds.AddFieldViaCopy(outcellVals, 2);
|
||||
|
||||
vtkm::worklet::DispatcherMapCell<CellType> dispatcher;
|
||||
vtkm::worklet::DispatcherMapTopology<CellType> dispatcher;
|
||||
dispatcher.Invoke(ds.GetField(4).GetData(), ds.GetField(3).GetData(), ds.conn, ds.GetField(5).GetData());
|
||||
|
||||
#if 0
|
||||
@ -218,7 +218,7 @@ void TestDataSet_Regular()
|
||||
vtkm::Float32 cellVals[4] = {-1.1, -1.2, -1.3, -1.4};
|
||||
ds.AddFieldViaCopy(cellVals, 4);
|
||||
|
||||
vtkm::worklet::DispatcherMapCell<CellType> dispatcher;
|
||||
vtkm::worklet::DispatcherMapTopology<CellType> dispatcher;
|
||||
dispatcher.Invoke(ds.GetField(4).GetData(), ds.GetField(3).GetData(), ds.reg, ds.GetField(5).GetData());
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
set(headers
|
||||
DispatcherMapField.h
|
||||
WorkletMapField.h
|
||||
DispatcherMapCell.h
|
||||
WorkletMapCell.h
|
||||
DispatcherMapTopology.h
|
||||
WorkletMapTopology.h
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
94
vtkm/worklet/DispatcherMapTopology.h
Normal file
94
vtkm/worklet/DispatcherMapTopology.h
Normal file
@ -0,0 +1,94 @@
|
||||
//============================================================================
|
||||
// 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_worklet_Dispatcher_MapTopology_h
|
||||
#define vtk_m_worklet_Dispatcher_MapTopology_h
|
||||
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
#include <vtkm/worklet/internal/DispatcherBase.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace worklet {
|
||||
|
||||
/// \brief Dispatcher for worklets that inherit from \c WorkletMapTopology.
|
||||
///
|
||||
template<typename WorkletType,
|
||||
typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
||||
class DispatcherMapTopology :
|
||||
public vtkm::worklet::internal::DispatcherBase<
|
||||
DispatcherMapTopology<WorkletType,Device>,
|
||||
WorkletType,
|
||||
vtkm::worklet::WorkletMapTopology,
|
||||
Device>
|
||||
{
|
||||
typedef vtkm::worklet::internal::DispatcherBase<
|
||||
DispatcherMapTopology<WorkletType,Device>,
|
||||
WorkletType,
|
||||
vtkm::worklet::WorkletMapTopology,
|
||||
Device> Superclass;
|
||||
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
DispatcherMapTopology(const WorkletType &worklet = WorkletType())
|
||||
: Superclass(worklet) { }
|
||||
|
||||
template<typename Invocation>
|
||||
VTKM_CONT_EXPORT
|
||||
void DoInvoke(const Invocation &invocation) const
|
||||
{
|
||||
// The parameter for the input domain is stored in the Invocation. (It is
|
||||
// also in the worklet, but it is safer to get it from the Invocation
|
||||
// in case some other dispatch operation had to modify it.)
|
||||
static const vtkm::IdComponent InputDomainIndex =
|
||||
Invocation::InputDomainIndex;
|
||||
|
||||
// ParameterInterface (from Invocation) is a FunctionInterface type
|
||||
// containing types for all objects passed to the Invoke method (with
|
||||
// some dynamic casting performed so objects like DynamicArrayHandle get
|
||||
// cast to ArrayHandle).
|
||||
typedef typename Invocation::ParameterInterface ParameterInterface;
|
||||
|
||||
// This is the type for the input domain (derived from the last two things
|
||||
// we got from the Invocation).
|
||||
typedef typename ParameterInterface::
|
||||
template ParameterType<InputDomainIndex>::type InputDomainType;
|
||||
|
||||
// We can pull the input domain parameter (the data specifying the input
|
||||
// domain) from the invocation object.
|
||||
InputDomainType inputDomain =
|
||||
invocation.Parameters.template GetParameter<InputDomainIndex>();
|
||||
|
||||
// For a DispatcherMapTopology, the inputDomain must be an ArrayHandle (or
|
||||
// a DynamicArrayHandle that gets cast to one). The size of the domain
|
||||
// (number of threads/worklet instances) is equal to the size of the
|
||||
// array.
|
||||
|
||||
///\todo: GetNumberOfCells
|
||||
vtkm::Id numInstances = inputDomain.GetNumberOfElements();
|
||||
|
||||
///\todo:
|
||||
this->BasicInvoke(invocation, numInstances);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::worklet
|
||||
|
||||
#endif //vtk_m_worklet_Dispatcher_MapTopology_h
|
102
vtkm/worklet/WorkletMapTopology.h
Normal file
102
vtkm/worklet/WorkletMapTopology.h
Normal file
@ -0,0 +1,102 @@
|
||||
//============================================================================
|
||||
// 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_worklet_WorkletMapTopology_h
|
||||
#define vtk_m_worklet_WorkletMapTopology_h
|
||||
|
||||
#include <vtkm/worklet/internal/WorkletBase.h>
|
||||
|
||||
#include <vtkm/TypeListTag.h>
|
||||
|
||||
#include <vtkm/cont/arg/ControlSignatureTagBase.h>
|
||||
#include <vtkm/cont/arg/TransportTagArrayIn.h>
|
||||
#include <vtkm/cont/arg/TransportTagArrayOut.h>
|
||||
#include <vtkm/cont/arg/TransportTagTopologyIn.h>
|
||||
#include <vtkm/cont/arg/TypeCheckTagArray.h>
|
||||
#include <vtkm/cont/arg/TypeCheckTagTopology.h>
|
||||
|
||||
#include <vtkm/exec/arg/FetchTagArrayDirectIn.h>
|
||||
#include <vtkm/exec/arg/FetchTagArrayDirectOut.h>
|
||||
#include <vtkm/exec/arg/FetchTagTopologyIn.h>
|
||||
#include <vtkm/exec/arg/FetchTagArrayTopologyMapIn.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace worklet {
|
||||
|
||||
/// Base class for worklets that do a simple mapping of field arrays. All
|
||||
/// inputs and outputs are on the same domain. That is, all the arrays are the
|
||||
/// same size.
|
||||
///
|
||||
class WorkletMapTopology : public vtkm::worklet::internal::WorkletBase
|
||||
{
|
||||
public:
|
||||
/// \brief A control signature tag for input fields.
|
||||
///
|
||||
/// This tag takes a template argument that is a type list tag that limits
|
||||
/// the possible value types in the array.
|
||||
///
|
||||
template<typename TypeList = AllTypes>
|
||||
struct FieldDestIn : vtkm::cont::arg::ControlSignatureTagBase {
|
||||
typedef vtkm::cont::arg::TypeCheckTagArray<TypeList> TypeCheckTag;
|
||||
typedef vtkm::cont::arg::TransportTagArrayIn TransportTag;
|
||||
typedef vtkm::exec::arg::FetchTagArrayDirectIn FetchTag;
|
||||
};
|
||||
|
||||
/// \brief A control signature tag for input connectivity.
|
||||
///
|
||||
/// This tag takes a template argument that is a type list tag that limits
|
||||
/// the possible value types in the array.
|
||||
///
|
||||
template<typename TypeList = AllTypes>
|
||||
struct FieldSrcIn : vtkm::cont::arg::ControlSignatureTagBase {
|
||||
typedef vtkm::cont::arg::TypeCheckTagArray<TypeList> TypeCheckTag;
|
||||
typedef vtkm::cont::arg::TransportTagArrayIn TransportTag;
|
||||
typedef vtkm::exec::arg::FetchTagArrayTopologyMapIn FetchTag;
|
||||
};
|
||||
|
||||
/// \brief A control signature tag for input connectivity.
|
||||
///
|
||||
/// This tag takes a template argument that is a type list tag that limits
|
||||
/// the possible value types in the array.
|
||||
///
|
||||
template< vtkm::IdComponent ItemTupleLength>
|
||||
struct TopologyIn : vtkm::cont::arg::ControlSignatureTagBase {
|
||||
typedef vtkm::cont::arg::TypeCheckTagTopology TypeCheckTag;
|
||||
typedef vtkm::cont::arg::TransportTagTopologyIn TransportTag;
|
||||
typedef vtkm::exec::arg::FetchTagTopologyIn FetchTag;
|
||||
static const int ITEM_TUPLE_LENGTH = ItemTupleLength;
|
||||
};
|
||||
|
||||
/// \brief A control signature tag for output fields.
|
||||
///
|
||||
/// This tag takes a template argument that is a type list tag that limits
|
||||
/// the possible value types in the array.
|
||||
///
|
||||
template<typename TypeList = AllTypes>
|
||||
struct FieldDestOut : vtkm::cont::arg::ControlSignatureTagBase {
|
||||
typedef vtkm::cont::arg::TypeCheckTagArray<TypeList> TypeCheckTag;
|
||||
typedef vtkm::cont::arg::TransportTagArrayOut TransportTag;
|
||||
typedef vtkm::exec::arg::FetchTagArrayDirectOut FetchTag;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::worklet
|
||||
|
||||
#endif //vtk_m_worklet_WorkletMapTopology_h
|
Loading…
Reference in New Issue
Block a user