Fix merges with master.

This commit is contained in:
Dave Pugmire 2017-08-28 16:58:44 -04:00
parent 1c0f721b96
commit 7e69b9606d
6 changed files with 38 additions and 35 deletions

@ -122,18 +122,7 @@ public:
template <vtkm::IdComponent ItemTupleLength> template <vtkm::IdComponent ItemTupleLength>
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const; VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const;
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const;
{
this->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
ids.Allocate(numIndices);
vtkm::Id start = this->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
vtkm::cont::ArrayHandle<vtkm::Id>::PortalControl idPortal = ids.GetPortalControl();
auto PtCellPortal = this->PointToCell.Connectivity.GetPortalConstControl();
for (vtkm::IdComponent i = 0; i < numIndices && i < numIndices; i++)
idPortal.Set(i, PtCellPortal.Get(start + i));
}
/// First method to add cells -- one at a time. /// First method to add cells -- one at a time.
VTKM_CONT void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen); VTKM_CONT void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen);

@ -216,6 +216,25 @@ CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, O
} }
} }
template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetsStorageTag>
VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const
{
this->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
ids.Allocate(numIndices);
vtkm::Id start = this->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
vtkm::cont::ArrayHandle<vtkm::Id>::PortalControl idPortal = ids.GetPortalControl();
auto PtCellPortal = this->PointToCell.Connectivity.GetPortalConstControl();
for (vtkm::IdComponent i = 0; i < numIndices && i < numIndices; i++)
idPortal.Set(i, PtCellPortal.Get(start + i));
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
template <typename ShapeStorageTag, template <typename ShapeStorageTag,

@ -147,12 +147,10 @@ public:
template <typename IntegratorType, template <typename IntegratorType,
typename FieldType, typename FieldType,
typename PointStorage, typename PointStorage,
typename FieldStorage,
typename DeviceAdapter> typename DeviceAdapter>
StreamlineResult<FieldType> Run( StreamlineResult<FieldType> Run(
const IntegratorType& it, const IntegratorType& it,
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& seedArray, const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& seedArray,
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, FieldStorage>& fieldArray,
const vtkm::Id& nSteps, const vtkm::Id& nSteps,
const DeviceAdapter&) const DeviceAdapter&)
{ {
@ -165,17 +163,18 @@ public:
//Allocate status and steps arrays. //Allocate status and steps arrays.
vtkm::Id numSeeds = seedArray.GetNumberOfValues(); vtkm::Id numSeeds = seedArray.GetNumberOfValues();
vtkm::Id val = vtkm::worklet::particleadvection::ParticleStatus::OK; vtkm::Id val = vtkm::worklet::particleadvection::ParticleStatus::STATUS_OK;
vtkm::cont::ArrayHandle<vtkm::Id, FieldStorage> status, steps; vtkm::cont::ArrayHandle<vtkm::Id> status, steps;
vtkm::cont::ArrayHandleConstant<vtkm::Id> ok(val, numSeeds); vtkm::cont::ArrayHandleConstant<vtkm::Id> ok(val, numSeeds);
status.Allocate(numSeeds); status.Allocate(numSeeds);
DeviceAlgorithm::Copy(ok, status); DeviceAlgorithm::Copy(ok, status);
vtkm::cont::ArrayHandleConstant<vtkm::Id> zero(0, numSeeds); vtkm::cont::ArrayHandleConstant<vtkm::Id> zero(0, numSeeds);
steps.Allocate(numSeeds); steps.Allocate(numSeeds);
DeviceAlgorithm::Copy(zero, steps); DeviceAlgorithm::Copy(zero, steps);
worklet.Run(it, seedArray, fieldArray, nSteps, positions, polyLines, status, steps); worklet.Run(it, seedArray, nSteps, positions, polyLines, status, steps);
StreamlineResult<FieldType> res(positions, polyLines, status, steps); StreamlineResult<FieldType> res(positions, polyLines, status, steps);
return res; return res;

@ -87,6 +87,7 @@ template <typename IntegratorType, typename FieldType, typename DeviceAdapterTag
class ParticleAdvectionWorklet class ParticleAdvectionWorklet
{ {
public: public:
typedef typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag> DeviceAlgorithm;
typedef vtkm::worklet::particleadvection::ParticleAdvectWorklet<IntegratorType, typedef vtkm::worklet::particleadvection::ParticleAdvectWorklet<IntegratorType,
FieldType, FieldType,
DeviceAdapterTag> DeviceAdapterTag>
@ -162,7 +163,6 @@ public:
template <typename PointStorage, typename FieldStorage> template <typename PointStorage, typename FieldStorage>
void Run(const IntegratorType& it, void Run(const IntegratorType& it,
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& pts, const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& pts,
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, FieldStorage> fieldArray,
const vtkm::Id& nSteps, const vtkm::Id& nSteps,
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& positions, vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& positions,
vtkm::cont::CellSetExplicit<>& polyLines, vtkm::cont::CellSetExplicit<>& polyLines,
@ -172,7 +172,6 @@ public:
integrator = it; integrator = it;
seedArray = pts; seedArray = pts;
maxSteps = nSteps; maxSteps = nSteps;
field = fieldArray.PrepareForInput(DeviceAdapterTag());
run(positions, polyLines, statusArray, stepsTaken); run(positions, polyLines, statusArray, stepsTaken);
} }
@ -214,6 +213,7 @@ private:
//Compact history into positions. //Compact history into positions.
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> history; vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> history;
StreamlineType streamlines(seedArray, history, stepsTaken, status, validPoint, maxSteps); StreamlineType streamlines(seedArray, history, stepsTaken, status, validPoint, maxSteps);
particleWorkletDispatch.Invoke(idxArray, streamlines); particleWorkletDispatch.Invoke(idxArray, streamlines);
DeviceAlgorithm::CopyIf(history, validPoint, positions, IsOne()); DeviceAlgorithm::CopyIf(history, validPoint, positions, IsOne());
@ -241,7 +241,6 @@ private:
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> seedArray; vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> seedArray;
vtkm::cont::DataSet ds; vtkm::cont::DataSet ds;
vtkm::Id maxSteps; vtkm::Id maxSteps;
FieldPortalConstType field;
}; };
} }
} }

@ -242,15 +242,17 @@ public:
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& historyArray, vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& historyArray,
vtkm::cont::ArrayHandle<vtkm::Id>& stepsArray, vtkm::cont::ArrayHandle<vtkm::Id>& stepsArray,
vtkm::cont::ArrayHandle<vtkm::Id>& statusArray, vtkm::cont::ArrayHandle<vtkm::Id>& statusArray,
vtkm::cont::ArrayHandle<vtkm::Id>& validPointArray,
const vtkm::Id& _maxSteps) const vtkm::Id& _maxSteps)
{ {
this->Pos = posArray.PrepareForInPlace(DeviceAdapterTag()); this->Pos = posArray.PrepareForInPlace(DeviceAdapterTag());
this->Steps = stepsArray.PrepareForInPlace(DeviceAdapterTag()); this->Steps = stepsArray.PrepareForInPlace(DeviceAdapterTag());
this->Status = statusArray.PrepareForInPlace(DeviceAdapterTag()); this->Status = statusArray.PrepareForInPlace(DeviceAdapterTag());
this->ValidPoint = validPointArray.PrepareForInPlace(DeviceAdapterTag());
this->MaxSteps = _maxSteps; this->MaxSteps = _maxSteps;
HistSize = _maxSteps; HistSize = _maxSteps;
NumPos = posArray.GetNumberOfValues(); NumPos = posArray.GetNumberOfValues();
History = HistoryArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag()); History = historyArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag());
} }
VTKM_EXEC_CONT VTKM_EXEC_CONT
@ -266,10 +268,11 @@ public:
this->Pos = posArray.PrepareForInPlace(DeviceAdapterTag()); this->Pos = posArray.PrepareForInPlace(DeviceAdapterTag());
this->Steps = stepsArray.PrepareForInPlace(DeviceAdapterTag()); this->Steps = stepsArray.PrepareForInPlace(DeviceAdapterTag());
this->Status = statusArray.PrepareForInPlace(DeviceAdapterTag()); this->Status = statusArray.PrepareForInPlace(DeviceAdapterTag());
this->ValidPoint = validPointArray.PrepareForInPlace(DeviceAdapterTag());
this->MaxSteps = _maxSteps; this->MaxSteps = _maxSteps;
HistSize = _histSize; HistSize = _histSize;
NumPos = posArray.GetNumberOfValues(); NumPos = posArray.GetNumberOfValues();
History = HistoryArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag()); History = historyArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag());
} }
VTKM_EXEC_CONT VTKM_EXEC_CONT
@ -296,10 +299,8 @@ public:
private: private:
vtkm::Id NumPos, HistSize; vtkm::Id NumPos, HistSize;
IdPortal ValidPoint;
PosPortal History; PosPortal History;
public:
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> HistoryArray;
}; };
} //namespace particleadvection } //namespace particleadvection

@ -456,14 +456,11 @@ void TestParticleWorklets()
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> seeds; vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> seeds;
seeds = vtkm::cont::make_ArrayHandle(pts); seeds = vtkm::cont::make_ArrayHandle(pts);
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> fieldArray;
fieldArray = vtkm::cont::make_ArrayHandle(field);
if (i == 0) if (i == 0)
{ {
vtkm::worklet::ParticleAdvection particleAdvection; vtkm::worklet::ParticleAdvection particleAdvection;
vtkm::worklet::ParticleAdvectionResult<FieldType> res; vtkm::worklet::ParticleAdvectionResult<FieldType> res;
res = particleAdvection.Run(rk4, seeds, fieldArray, 1000, DeviceAdapter()); res = particleAdvection.Run(rk4, seeds, 1000, DeviceAdapter());
VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(), VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(),
"Number of output particles does not match input."); "Number of output particles does not match input.");
} }
@ -471,10 +468,11 @@ void TestParticleWorklets()
{ {
vtkm::worklet::Streamline streamline; vtkm::worklet::Streamline streamline;
vtkm::worklet::StreamlineResult<FieldType> res; vtkm::worklet::StreamlineResult<FieldType> res;
res = streamline.Run(rk4, seeds, fieldArray, 1000, DeviceAdapter()); res = streamline.Run(rk4, seeds, 1000, DeviceAdapter());
// VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(), VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(),
// "Number of output particles does not match input."); "Number of output particles does not match input.");
/*
printSummary_ArrayHandle(res.positions, std::cout); printSummary_ArrayHandle(res.positions, std::cout);
printSummary_ArrayHandle(res.status, std::cout, true); printSummary_ArrayHandle(res.status, std::cout, true);
printSummary_ArrayHandle(res.stepsTaken, std::cout, true); printSummary_ArrayHandle(res.stepsTaken, std::cout, true);
@ -486,9 +484,7 @@ void TestParticleWorklets()
Output.AddField(vtkm::cont::Field("status", vtkm::cont::Field::ASSOC_POINTS, res.status)); Output.AddField(vtkm::cont::Field("status", vtkm::cont::Field::ASSOC_POINTS, res.status));
Output.AddField(vtkm::cont::Field("steps", vtkm::cont::Field::ASSOC_POINTS, res.stepsTaken)); Output.AddField(vtkm::cont::Field("steps", vtkm::cont::Field::ASSOC_POINTS, res.stepsTaken));
Output.PrintSummary(std::cout); Output.PrintSummary(std::cout);
*/
vtkm::io::writer::VTKDataSetWriter writer("streamlines.vtk");
writer.WriteDataSet(Output);
} }
} }
} }