diff --git a/vtkm/cont/CellSetExplicit.h b/vtkm/cont/CellSetExplicit.h index 0d8b5ba37..72c56206e 100644 --- a/vtkm/cont/CellSetExplicit.h +++ b/vtkm/cont/CellSetExplicit.h @@ -122,18 +122,7 @@ public: template VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec& ids) const; - VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle& 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::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)); - } + VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle& ids) const; /// First method to add cells -- one at a time. VTKM_CONT void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen); diff --git a/vtkm/cont/CellSetExplicit.hxx b/vtkm/cont/CellSetExplicit.hxx index 03dde4f1c..705b52f1b 100644 --- a/vtkm/cont/CellSetExplicit.hxx +++ b/vtkm/cont/CellSetExplicit.hxx @@ -216,6 +216,25 @@ CellSetExplicit +VTKM_CONT void +CellSetExplicit:: + GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle& 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::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 StreamlineResult Run( const IntegratorType& it, const vtkm::cont::ArrayHandle, PointStorage>& seedArray, - const vtkm::cont::ArrayHandle, FieldStorage>& fieldArray, const vtkm::Id& nSteps, const DeviceAdapter&) { @@ -165,17 +163,18 @@ public: //Allocate status and steps arrays. vtkm::Id numSeeds = seedArray.GetNumberOfValues(); - vtkm::Id val = vtkm::worklet::particleadvection::ParticleStatus::OK; - vtkm::cont::ArrayHandle status, steps; + vtkm::Id val = vtkm::worklet::particleadvection::ParticleStatus::STATUS_OK; + vtkm::cont::ArrayHandle status, steps; vtkm::cont::ArrayHandleConstant ok(val, numSeeds); status.Allocate(numSeeds); + DeviceAlgorithm::Copy(ok, status); vtkm::cont::ArrayHandleConstant zero(0, numSeeds); steps.Allocate(numSeeds); DeviceAlgorithm::Copy(zero, steps); - worklet.Run(it, seedArray, fieldArray, nSteps, positions, polyLines, status, steps); + worklet.Run(it, seedArray, nSteps, positions, polyLines, status, steps); StreamlineResult res(positions, polyLines, status, steps); return res; diff --git a/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h b/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h index 85991d5be..5a5451298 100644 --- a/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h +++ b/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h @@ -87,6 +87,7 @@ template DeviceAlgorithm; typedef vtkm::worklet::particleadvection::ParticleAdvectWorklet @@ -162,7 +163,6 @@ public: template void Run(const IntegratorType& it, const vtkm::cont::ArrayHandle, PointStorage>& pts, - const vtkm::cont::ArrayHandle, FieldStorage> fieldArray, const vtkm::Id& nSteps, vtkm::cont::ArrayHandle, PointStorage>& positions, vtkm::cont::CellSetExplicit<>& polyLines, @@ -172,7 +172,6 @@ public: integrator = it; seedArray = pts; maxSteps = nSteps; - field = fieldArray.PrepareForInput(DeviceAdapterTag()); run(positions, polyLines, statusArray, stepsTaken); } @@ -214,6 +213,7 @@ private: //Compact history into positions. vtkm::cont::ArrayHandle> history; StreamlineType streamlines(seedArray, history, stepsTaken, status, validPoint, maxSteps); + particleWorkletDispatch.Invoke(idxArray, streamlines); DeviceAlgorithm::CopyIf(history, validPoint, positions, IsOne()); @@ -241,7 +241,6 @@ private: vtkm::cont::ArrayHandle> seedArray; vtkm::cont::DataSet ds; vtkm::Id maxSteps; - FieldPortalConstType field; }; } } diff --git a/vtkm/worklet/particleadvection/Particles.h b/vtkm/worklet/particleadvection/Particles.h index 46cb04b22..ffc9d2ecd 100644 --- a/vtkm/worklet/particleadvection/Particles.h +++ b/vtkm/worklet/particleadvection/Particles.h @@ -242,15 +242,17 @@ public: vtkm::cont::ArrayHandle>& historyArray, vtkm::cont::ArrayHandle& stepsArray, vtkm::cont::ArrayHandle& statusArray, + vtkm::cont::ArrayHandle& validPointArray, const vtkm::Id& _maxSteps) { this->Pos = posArray.PrepareForInPlace(DeviceAdapterTag()); this->Steps = stepsArray.PrepareForInPlace(DeviceAdapterTag()); this->Status = statusArray.PrepareForInPlace(DeviceAdapterTag()); + this->ValidPoint = validPointArray.PrepareForInPlace(DeviceAdapterTag()); this->MaxSteps = _maxSteps; HistSize = _maxSteps; NumPos = posArray.GetNumberOfValues(); - History = HistoryArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag()); + History = historyArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag()); } VTKM_EXEC_CONT @@ -266,10 +268,11 @@ public: this->Pos = posArray.PrepareForInPlace(DeviceAdapterTag()); this->Steps = stepsArray.PrepareForInPlace(DeviceAdapterTag()); this->Status = statusArray.PrepareForInPlace(DeviceAdapterTag()); + this->ValidPoint = validPointArray.PrepareForInPlace(DeviceAdapterTag()); this->MaxSteps = _maxSteps; HistSize = _histSize; NumPos = posArray.GetNumberOfValues(); - History = HistoryArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag()); + History = historyArray.PrepareForOutput(NumPos * HistSize, DeviceAdapterTag()); } VTKM_EXEC_CONT @@ -296,10 +299,8 @@ public: private: vtkm::Id NumPos, HistSize; + IdPortal ValidPoint; PosPortal History; - -public: - vtkm::cont::ArrayHandle> HistoryArray; }; } //namespace particleadvection diff --git a/vtkm/worklet/testing/UnitTestParticleAdvection.cxx b/vtkm/worklet/testing/UnitTestParticleAdvection.cxx index 75ed9698a..dc6457888 100644 --- a/vtkm/worklet/testing/UnitTestParticleAdvection.cxx +++ b/vtkm/worklet/testing/UnitTestParticleAdvection.cxx @@ -456,14 +456,11 @@ void TestParticleWorklets() vtkm::cont::ArrayHandle> seeds; seeds = vtkm::cont::make_ArrayHandle(pts); - vtkm::cont::ArrayHandle> fieldArray; - fieldArray = vtkm::cont::make_ArrayHandle(field); - if (i == 0) { vtkm::worklet::ParticleAdvection particleAdvection; vtkm::worklet::ParticleAdvectionResult res; - res = particleAdvection.Run(rk4, seeds, fieldArray, 1000, DeviceAdapter()); + res = particleAdvection.Run(rk4, seeds, 1000, DeviceAdapter()); VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(), "Number of output particles does not match input."); } @@ -471,10 +468,11 @@ void TestParticleWorklets() { vtkm::worklet::Streamline streamline; vtkm::worklet::StreamlineResult res; - res = streamline.Run(rk4, seeds, fieldArray, 1000, DeviceAdapter()); - // VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(), - // "Number of output particles does not match input."); + res = streamline.Run(rk4, seeds, 1000, DeviceAdapter()); + VTKM_TEST_ASSERT(res.positions.GetNumberOfValues() == seeds.GetNumberOfValues(), + "Number of output particles does not match input."); + /* printSummary_ArrayHandle(res.positions, std::cout); printSummary_ArrayHandle(res.status, 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("steps", vtkm::cont::Field::ASSOC_POINTS, res.stepsTaken)); Output.PrintSummary(std::cout); - - vtkm::io::writer::VTKDataSetWriter writer("streamlines.vtk"); - writer.WriteDataSet(Output); + */ } } }