diff --git a/vtkm/exec/CellLocatorRectilinearGrid.h b/vtkm/exec/CellLocatorRectilinearGrid.h index d57571341..82fd8b02d 100644 --- a/vtkm/exec/CellLocatorRectilinearGrid.h +++ b/vtkm/exec/CellLocatorRectilinearGrid.h @@ -171,7 +171,7 @@ private: CellSetPortal CellSet; RectilinearPortalType Coords; AxisPortalType AxisPortals[3]; - vtkm::Id3 PointDimensions; + vtkm::Vec PointDimensions; vtkm::Vec3f MinPoint; vtkm::Vec3f MaxPoint; }; diff --git a/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h b/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h index 33b4c35dc..7dac0220d 100644 --- a/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h +++ b/vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h @@ -74,7 +74,7 @@ public: else if (status == ParticleStatus::AT_SPATIAL_BOUNDARY) { status = integrator->SmallStep(inpos, time, outpos); - integralCurve.TakeStep(idx, outpos, status); + integralCurve.TakeStep(idx, outpos); integralCurve.SetTime(idx, time); if (status == ParticleStatus::AT_SPATIAL_BOUNDARY) { diff --git a/vtkm/worklet/particleadvection/Particles.h b/vtkm/worklet/particleadvection/Particles.h index 6cda31cf2..831dff681 100644 --- a/vtkm/worklet/particleadvection/Particles.h +++ b/vtkm/worklet/particleadvection/Particles.h @@ -108,254 +108,253 @@ public: { ClearBit(idx, STATUS_OK); SetBit(idx, AT_TEMPORAL_BOUNDARY); - void SetTookAnySteps(const vtkm::Id& idx, const bool& val) - { - if (val) - SetBit(idx, TOOK_ANY_STEPS); - else - ClearBit(idx, TOOK_ANY_STEPS); - } - VTKM_EXEC - void SetExitedSpatialBoundary(const vtkm::Id& idx) - { - ClearBit(idx, STATUS_OK); - SetBit(idx, EXITED_SPATIAL_BOUNDARY); - } - VTKM_EXEC - void SetExitedTemporalBoundary(const vtkm::Id& idx) - { - ClearBit(idx, STATUS_OK); - SetBit(idx, EXITED_TEMPORAL_BOUNDARY); - } - VTKM_EXEC - void SetError(const vtkm::Id& idx) - { - ClearBit(idx, STATUS_OK); - SetBit(idx, STATUS_ERROR); - } - - /* Check Status */ - VTKM_EXEC - bool OK(const vtkm::Id& idx) { return CheckBit(idx, STATUS_OK); } - VTKM_EXEC - bool Terminated(const vtkm::Id& idx) { return CheckBit(idx, TERMINATED); } - VTKM_EXEC - bool AtSpatialBoundary(const vtkm::Id& idx) { return CheckBit(idx, AT_SPATIAL_BOUNDARY); } - VTKM_EXEC - bool AtTemporalBoundary(const vtkm::Id& idx) { return CheckBit(idx, AT_TEMPORAL_BOUNDARY); } - VTKM_EXEC - bool ExitedSpatialBoundary(const vtkm::Id& idx) - { - return CheckBit(idx, EXITED_SPATIAL_BOUNDARY); - } - VTKM_EXEC - bool ExitedTemporalBoundary(const vtkm::Id& idx) - { - return CheckBit(idx, EXITED_TEMPORAL_BOUNDARY); - } - VTKM_EXEC - bool Error(const vtkm::Id& idx) { return CheckBit(idx, STATUS_ERROR); } - VTKM_EXEC - bool Integrateable(const vtkm::Id& idx) - { - return OK(idx) && !(Terminated(idx) || AtSpatialBoundary(idx) || AtTemporalBoundary(idx)); - } - VTKM_EXEC - bool Done(const vtkm::Id& idx) { return !Integrateable(idx); } - - /* Bit Operations */ - VTKM_EXEC - void Clear(const vtkm::Id& idx) { Status.Set(idx, 0); } - VTKM_EXEC - void SetBit(const vtkm::Id& idx, const ParticleStatus& b) - { - Status.Set(idx, Status.Get(idx) | b); - } - VTKM_EXEC - void ClearBit(const vtkm::Id& idx, const ParticleStatus& b) - { - Status.Set(idx, Status.Get(idx) & ~b); - } - VTKM_EXEC - bool CheckBit(const vtkm::Id& idx, const ParticleStatus& b) const - { - return (Status.Get(idx) & b) != 0; - } - - VTKM_EXEC - VectorType GetPos(const vtkm::Id& idx) const { return Pos.Get(idx); } - VTKM_EXEC - vtkm::Id GetStep(const vtkm::Id& idx) const { return Steps.Get(idx); } - VTKM_EXEC - vtkm::Id GetStatus(const vtkm::Id& idx) const { return Status.Get(idx); } - VTKM_EXEC - ScalarType GetTime(const vtkm::Id& idx) const { return Time.Get(idx); } - VTKM_EXEC - void SetTime(const vtkm::Id& idx, ScalarType time) const { Time.Set(idx, time); } - - protected: - using IdPortal = - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; - using PositionPortal = - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; - using FloatPortal = - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; - - PositionPortal Pos; - IdPortal Status; - IdPortal Steps; - FloatPortal Time; - vtkm::Id MaxSteps; - }; - - - class Particles : public vtkm::cont::ExecutionObjectBase + } + VTKM_EXEC + void SetTookAnySteps(const vtkm::Id& idx, const bool& val) { - private: - using ScalarType = vtkm::worklet::particleadvection::ScalarType; - using VectorType = vtkm::Vec; + if (val) + SetBit(idx, TOOK_ANY_STEPS); + else + ClearBit(idx, TOOK_ANY_STEPS); + } + VTKM_EXEC + void SetExitedSpatialBoundary(const vtkm::Id& idx) + { + ClearBit(idx, STATUS_OK); + SetBit(idx, EXITED_SPATIAL_BOUNDARY); + } + VTKM_EXEC + void SetExitedTemporalBoundary(const vtkm::Id& idx) + { + ClearBit(idx, STATUS_OK); + SetBit(idx, EXITED_TEMPORAL_BOUNDARY); + } + VTKM_EXEC + void SetError(const vtkm::Id& idx) + { + ClearBit(idx, STATUS_OK); + SetBit(idx, STATUS_ERROR); + } - public: - template - VTKM_CONT vtkm::worklet::particleadvection::ParticleExecutionObject PrepareForExecution( - Device) const - { + /* Check Status */ + VTKM_EXEC + bool OK(const vtkm::Id& idx) { return CheckBit(idx, STATUS_OK); } + VTKM_EXEC + bool Terminated(const vtkm::Id& idx) { return CheckBit(idx, TERMINATED); } + VTKM_EXEC + bool AtSpatialBoundary(const vtkm::Id& idx) { return CheckBit(idx, AT_SPATIAL_BOUNDARY); } + VTKM_EXEC + bool AtTemporalBoundary(const vtkm::Id& idx) { return CheckBit(idx, AT_TEMPORAL_BOUNDARY); } + VTKM_EXEC + bool ExitedSpatialBoundary(const vtkm::Id& idx) { return CheckBit(idx, EXITED_SPATIAL_BOUNDARY); } + VTKM_EXEC + bool ExitedTemporalBoundary(const vtkm::Id& idx) + { + return CheckBit(idx, EXITED_TEMPORAL_BOUNDARY); + } + VTKM_EXEC + bool Error(const vtkm::Id& idx) { return CheckBit(idx, STATUS_ERROR); } + VTKM_EXEC + bool Integrateable(const vtkm::Id& idx) + { + return OK(idx) && !(Terminated(idx) || AtSpatialBoundary(idx) || AtTemporalBoundary(idx)); + } + VTKM_EXEC + bool Done(const vtkm::Id& idx) { return !Integrateable(idx); } - return vtkm::worklet::particleadvection::ParticleExecutionObject( - this->PosArray, this->StepsArray, this->StatusArray, this->TimeArray, this->MaxSteps); - } + /* Bit Operations */ + VTKM_EXEC + void Clear(const vtkm::Id& idx) { Status.Set(idx, 0); } + VTKM_EXEC + void SetBit(const vtkm::Id& idx, const ParticleStatus& b) + { + Status.Set(idx, Status.Get(idx) | b); + } + VTKM_EXEC + void ClearBit(const vtkm::Id& idx, const ParticleStatus& b) + { + Status.Set(idx, Status.Get(idx) & ~b); + } + VTKM_EXEC + bool CheckBit(const vtkm::Id& idx, const ParticleStatus& b) const + { + return (Status.Get(idx) & b) != 0; + } - VTKM_CONT - Particles(vtkm::cont::ArrayHandle& posArray, - vtkm::cont::ArrayHandle& stepsArray, - vtkm::cont::ArrayHandle& statusArray, - vtkm::cont::ArrayHandle& timeArray, - const vtkm::Id& maxSteps) - : PosArray(posArray) - , StepsArray(stepsArray) - , StatusArray(statusArray) - , TimeArray(timeArray) - , MaxSteps(maxSteps) - { - } + VTKM_EXEC + VectorType GetPos(const vtkm::Id& idx) const { return Pos.Get(idx); } + VTKM_EXEC + vtkm::Id GetStep(const vtkm::Id& idx) const { return Steps.Get(idx); } + VTKM_EXEC + vtkm::Id GetStatus(const vtkm::Id& idx) const { return Status.Get(idx); } + VTKM_EXEC + ScalarType GetTime(const vtkm::Id& idx) const { return Time.Get(idx); } + VTKM_EXEC + void SetTime(const vtkm::Id& idx, ScalarType time) const { Time.Set(idx, time); } - Particles() {} +protected: + using IdPortal = + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; + using PositionPortal = + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; + using FloatPortal = + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; - protected: - bool fromArray = false; + PositionPortal Pos; + IdPortal Status; + IdPortal Steps; + FloatPortal Time; + vtkm::Id MaxSteps; +}; - protected: - vtkm::cont::ArrayHandle PosArray; - vtkm::cont::ArrayHandle StepsArray; - vtkm::cont::ArrayHandle StatusArray; - vtkm::cont::ArrayHandle TimeArray; - vtkm::Id MaxSteps; - }; +class Particles : public vtkm::cont::ExecutionObjectBase +{ +private: + using ScalarType = vtkm::worklet::particleadvection::ScalarType; + using VectorType = vtkm::Vec; + +public: + template + VTKM_CONT vtkm::worklet::particleadvection::ParticleExecutionObject PrepareForExecution( + Device) const + { + + return vtkm::worklet::particleadvection::ParticleExecutionObject( + this->PosArray, this->StepsArray, this->StatusArray, this->TimeArray, this->MaxSteps); + } + + VTKM_CONT + Particles(vtkm::cont::ArrayHandle& posArray, + vtkm::cont::ArrayHandle& stepsArray, + vtkm::cont::ArrayHandle& statusArray, + vtkm::cont::ArrayHandle& timeArray, + const vtkm::Id& maxSteps) + : PosArray(posArray) + , StepsArray(stepsArray) + , StatusArray(statusArray) + , TimeArray(timeArray) + , MaxSteps(maxSteps) + { + } + + Particles() {} + +protected: + bool fromArray = false; + +protected: + vtkm::cont::ArrayHandle PosArray; + vtkm::cont::ArrayHandle StepsArray; + vtkm::cont::ArrayHandle StatusArray; + vtkm::cont::ArrayHandle TimeArray; + vtkm::Id MaxSteps; +}; + + +template +class StateRecordingParticleExecutionObject : public ParticleExecutionObject +{ + using ScalarType = vtkm::worklet::particleadvection::ScalarType; + using VectorType = vtkm::Vec; + +public: + VTKM_EXEC_CONT + StateRecordingParticleExecutionObject() + : ParticleExecutionObject() + , History() + , Length(0) + , ValidPoint() + { + } + + StateRecordingParticleExecutionObject(vtkm::cont::ArrayHandle posArray, + vtkm::cont::ArrayHandle historyArray, + vtkm::cont::ArrayHandle stepsArray, + vtkm::cont::ArrayHandle statusArray, + vtkm::cont::ArrayHandle timeArray, + vtkm::cont::ArrayHandle validPointArray, + vtkm::Id maxSteps) + : ParticleExecutionObject(posArray, stepsArray, statusArray, timeArray, maxSteps) + { + Length = maxSteps; + vtkm::Id numPos = posArray.GetNumberOfValues(); + History = historyArray.PrepareForOutput(numPos * Length, Device()); + ValidPoint = validPointArray.PrepareForInPlace(Device()); + } + + VTKM_EXEC_CONT + void TakeStep(const vtkm::Id& idx, const VectorType& pt) + { + this->ParticleExecutionObject::TakeStep(idx, pt); + + //TakeStep incremented the step, so we want the PREV step value. + vtkm::Id nSteps = this->Steps.Get(idx) - 1; + + // Update the step for streamline storing portals. + // This includes updating the history and the valid points. + vtkm::Id loc = idx * Length + nSteps; + this->History.Set(loc, pt); + this->ValidPoint.Set(loc, 1); + } + + VectorType GetHistory(const vtkm::Id& idx, const vtkm::Id& step) const + { + return this->History.Get(idx * this->Length + step); + } + +protected: + using IdPortal = + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; + using PositionPortal = + typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; + + PositionPortal History; + vtkm::Id Length; + IdPortal ValidPoint; +}; + +class StateRecordingParticles : vtkm::cont::ExecutionObjectBase +{ +public: + using ScalarType = vtkm::worklet::particleadvection::ScalarType; + using VectorType = vtkm::Vec; template - class StateRecordingParticleExecutionObject : public ParticleExecutionObject + VTKM_CONT vtkm::worklet::particleadvection::StateRecordingParticleExecutionObject + PrepareForExecution(Device) const { - using ScalarType = vtkm::worklet::particleadvection::ScalarType; - using VectorType = vtkm::Vec; + return vtkm::worklet::particleadvection::StateRecordingParticleExecutionObject( + PosArray, HistoryArray, StepsArray, StatusArray, TimeArray, ValidPointArray, MaxSteps); + } - public: - VTKM_EXEC_CONT - StateRecordingParticleExecutionObject() - : ParticleExecutionObject() - , History() - , Length(0) - , ValidPoint() - { - } - - StateRecordingParticleExecutionObject(vtkm::cont::ArrayHandle posArray, - vtkm::cont::ArrayHandle historyArray, - vtkm::cont::ArrayHandle stepsArray, - vtkm::cont::ArrayHandle statusArray, - vtkm::cont::ArrayHandle timeArray, - vtkm::cont::ArrayHandle validPointArray, - vtkm::Id maxSteps) - : ParticleExecutionObject(posArray, stepsArray, statusArray, timeArray, maxSteps) - { - Length = maxSteps; - vtkm::Id numPos = posArray.GetNumberOfValues(); - History = historyArray.PrepareForOutput(numPos * Length, Device()); - ValidPoint = validPointArray.PrepareForInPlace(Device()); - } - - VTKM_EXEC_CONT - void TakeStep(const vtkm::Id& idx, const VectorType& pt) - { - this->ParticleExecutionObject::TakeStep(idx, pt); - - //TakeStep incremented the step, so we want the PREV step value. - vtkm::Id nSteps = this->Steps.Get(idx) - 1; - - // Update the step for streamline storing portals. - // This includes updating the history and the valid points. - vtkm::Id loc = idx * Length + nSteps; - this->History.Set(loc, pt); - this->ValidPoint.Set(loc, 1); - } - - VectorType GetHistory(const vtkm::Id& idx, const vtkm::Id& step) const - { - return this->History.Get(idx * this->Length + step); - } - - protected: - using IdPortal = - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; - using PositionPortal = - typename vtkm::cont::ArrayHandle::template ExecutionTypes::Portal; - - PositionPortal History; - vtkm::Id Length; - IdPortal ValidPoint; - }; - - class StateRecordingParticles : vtkm::cont::ExecutionObjectBase + VTKM_CONT + StateRecordingParticles(vtkm::cont::ArrayHandle& posArray, + vtkm::cont::ArrayHandle& historyArray, + vtkm::cont::ArrayHandle& stepsArray, + vtkm::cont::ArrayHandle& statusArray, + vtkm::cont::ArrayHandle& timeArray, + vtkm::cont::ArrayHandle& validPointArray, + const vtkm::Id& maxSteps) { - public: - using ScalarType = vtkm::worklet::particleadvection::ScalarType; - using VectorType = vtkm::Vec; + PosArray = posArray; + HistoryArray = historyArray; + StepsArray = stepsArray; + StatusArray = statusArray; + TimeArray = timeArray; + ValidPointArray = validPointArray; + MaxSteps = maxSteps; + } - template - VTKM_CONT vtkm::worklet::particleadvection::StateRecordingParticleExecutionObject - PrepareForExecution(Device) const - { - return vtkm::worklet::particleadvection::StateRecordingParticleExecutionObject( - PosArray, HistoryArray, StepsArray, StatusArray, TimeArray, ValidPointArray, MaxSteps); - } - - VTKM_CONT - StateRecordingParticles(vtkm::cont::ArrayHandle& posArray, - vtkm::cont::ArrayHandle& historyArray, - vtkm::cont::ArrayHandle& stepsArray, - vtkm::cont::ArrayHandle& statusArray, - vtkm::cont::ArrayHandle& timeArray, - vtkm::cont::ArrayHandle& validPointArray, - const vtkm::Id& maxSteps) - { - PosArray = posArray; - HistoryArray = historyArray; - StepsArray = stepsArray; - StatusArray = statusArray; - TimeArray = timeArray; - ValidPointArray = validPointArray; - MaxSteps = maxSteps; - } - - protected: - vtkm::cont::ArrayHandle StepsArray; - vtkm::cont::ArrayHandle StatusArray; - vtkm::cont::ArrayHandle TimeArray; - vtkm::cont::ArrayHandle ValidPointArray; - vtkm::cont::ArrayHandle HistoryArray; - vtkm::cont::ArrayHandle PosArray; - vtkm::Id MaxSteps; - }; +protected: + vtkm::cont::ArrayHandle StepsArray; + vtkm::cont::ArrayHandle StatusArray; + vtkm::cont::ArrayHandle TimeArray; + vtkm::cont::ArrayHandle ValidPointArray; + vtkm::cont::ArrayHandle HistoryArray; + vtkm::cont::ArrayHandle PosArray; + vtkm::Id MaxSteps; +}; } //namespace particleadvection