diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index 0e70840f4..9b075372c 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -21,6 +21,8 @@ set(common_headers FilterDataSetWithField.h FilterField.h Filter.h + FilterParticleAdvection.h + FilterTemporalParticleAdvection.h FilterTraits.h MapFieldMergeAverage.h MapFieldPermutation.h @@ -41,6 +43,8 @@ set(common_header_template_sources FilterDataSetWithField.hxx FilterField.hxx Filter.hxx + FilterParticleAdvection.hxx + FilterTemporalParticleAdvection.hxx PointAverage.hxx Threshold.hxx ThresholdPoints.hxx @@ -88,6 +92,7 @@ set(extra_headers ParticleDensityNearestGridPoint.h ParticleAdvection.h Pathline.h + PathParticle.h PointAverage.h PointElevation.h PointTransform.h @@ -141,6 +146,7 @@ set(extra_header_template_sources ParticleDensityNearestGridPoint.hxx ParticleAdvection.hxx Pathline.hxx + PathParticle.hxx PointElevation.hxx PointTransform.hxx Probe.hxx @@ -179,7 +185,6 @@ set(contour_headers ContourTreeUniformAugmented.h ContourTreeUniformDistributed.h ContourTreeUniform.h - Slice.h ) set(contour_header_template_sources @@ -187,14 +192,12 @@ set(contour_header_template_sources ContourTreeUniformAugmented.hxx ContourTreeUniformDistributed.hxx ContourTreeUniform.hxx - Slice.hxx ) set(contour_sources_device Contour.cxx ContourInteger.cxx ContourScalar.cxx - Slice.cxx ) set(gradient_headers @@ -281,6 +284,4 @@ add_subdirectory(internal) add_subdirectory(particleadvection) #----------------------------------------------------------------------------- -if (VTKm_ENABLE_TESTING) - add_subdirectory(testing) -endif () +add_subdirectory(testing) diff --git a/vtkm/filter/FilterParticleAdvection.h b/vtkm/filter/FilterParticleAdvection.h new file mode 100644 index 000000000..d7fc5444c --- /dev/null +++ b/vtkm/filter/FilterParticleAdvection.h @@ -0,0 +1,93 @@ +//============================================================================ +// 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. +//============================================================================ + +#ifndef vtk_m_filter_FilterParticleAdvection_h +#define vtk_m_filter_FilterParticleAdvection_h + +#include +#include +#include +#include + +namespace vtkm +{ +namespace filter +{ +/// \brief base class for advecting particles in a vector field. + +/// Takes as input a vector field and seed locations and advects the seeds +/// through the flow field. + +template +class FilterParticleAdvection : public vtkm::filter::FilterDataSetWithField +{ +public: + using SupportedTypes = vtkm::TypeListFieldVec3; + + VTKM_CONT + FilterParticleAdvection(); + + VTKM_CONT + void SetStepSize(vtkm::FloatDefault s) { this->StepSize = s; } + + VTKM_CONT + void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; } + + VTKM_CONT + void SetSeeds(const std::vector& seeds, + vtkm::CopyFlag copyFlag = vtkm::CopyFlag::On) + { + this->Seeds = vtkm::cont::make_ArrayHandle(seeds, copyFlag); + } + + VTKM_CONT + void SetSeeds(vtkm::cont::ArrayHandle& seeds) { this->Seeds = seeds; } + + VTKM_CONT + bool GetUseThreadedAlgorithm() { return this->UseThreadedAlgorithm; } + + VTKM_CONT + void SetUseThreadedAlgorithm(bool val) { this->UseThreadedAlgorithm = val; } + + template + VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, + vtkm::filter::PolicyBase policy); + + template + VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet&, + const vtkm::cont::Field&, + vtkm::filter::PolicyBase) + { + return false; + } + +protected: + VTKM_CONT virtual void ValidateOptions(const vtkm::cont::PartitionedDataSet& input) const; + + using DSIType = vtkm::filter::particleadvection::DataSetIntegrator; + VTKM_CONT std::vector CreateDataSetIntegrators( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::particleadvection::BoundsMap& boundsMap) const; + + vtkm::Id NumberOfSteps; + vtkm::FloatDefault StepSize; + vtkm::cont::ArrayHandle Seeds; + bool UseThreadedAlgorithm; + +private: +}; +} +} // namespace vtkm::filter + +#ifndef vtk_m_filter_FilterParticleAdvection_hxx +#include +#endif + +#endif // vtk_m_filter_FilterParticleAdvection_h diff --git a/vtkm/filter/FilterParticleAdvection.hxx b/vtkm/filter/FilterParticleAdvection.hxx new file mode 100644 index 000000000..849e51471 --- /dev/null +++ b/vtkm/filter/FilterParticleAdvection.hxx @@ -0,0 +1,80 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_filter_FilterParticleAdvection_hxx +#define vtk_m_filter_FilterParticleAdvection_hxx + +#include + +namespace vtkm +{ +namespace filter +{ + +//----------------------------------------------------------------------------- +template +inline VTKM_CONT FilterParticleAdvection::FilterParticleAdvection() + : vtkm::filter::FilterDataSetWithField() + , NumberOfSteps(0) + , StepSize(0) + , UseThreadedAlgorithm(false) +{ +} + +template +void FilterParticleAdvection::ValidateOptions( + const vtkm::cont::PartitionedDataSet& input) const +{ + if (input.GetNumberOfPartitions() == 0) + throw vtkm::cont::ErrorFilterExecution("No input dataset provided."); + if (this->GetUseCoordinateSystemAsField()) + throw vtkm::cont::ErrorFilterExecution("Coordinate system as field not supported"); + if (this->Seeds.GetNumberOfValues() == 0) + throw vtkm::cont::ErrorFilterExecution("No seeds provided."); + if (this->NumberOfSteps == 0) + throw vtkm::cont::ErrorFilterExecution("Number of steps not specified."); + if (this->StepSize == 0) + throw vtkm::cont::ErrorFilterExecution("Step size not specified."); +} + +template +std::vector +FilterParticleAdvection::CreateDataSetIntegrators( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::particleadvection::BoundsMap& boundsMap) const +{ + std::vector dsi; + + std::string activeField = this->GetActiveFieldName(); + + for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++) + { + vtkm::Id blockId = boundsMap.GetLocalBlockId(i); + auto ds = input.GetPartition(i); + if (!ds.HasPointField(activeField)) + throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation"); + dsi.push_back(DSIType(ds, blockId, activeField)); + } + + return dsi; +} + +//----------------------------------------------------------------------------- +template +template +inline VTKM_CONT vtkm::cont::DataSet FilterParticleAdvection::PrepareForExecution( + const vtkm::cont::DataSet& input, + vtkm::filter::PolicyBase policy) +{ + return (static_cast(this))->DoExecute(input, policy); +} + +} +} // namespace vtkm::filter +#endif diff --git a/vtkm/filter/FilterTemporalParticleAdvection.h b/vtkm/filter/FilterTemporalParticleAdvection.h new file mode 100644 index 000000000..a21948a46 --- /dev/null +++ b/vtkm/filter/FilterTemporalParticleAdvection.h @@ -0,0 +1,74 @@ +//============================================================================ +// 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. +//============================================================================ + +#ifndef vtk_m_filter_TemporalFilterParticleAdvection_h +#define vtk_m_filter_TemporalFilterParticleAdvection_h + +#include +#include +#include +#include + +namespace vtkm +{ +namespace filter +{ +/// \brief base class for advecting particles in a vector field. + +/// Takes as input a vector field and seed locations and advects the seeds +/// through the flow field. + +template +class FilterTemporalParticleAdvection : public vtkm::filter::FilterParticleAdvection +{ +public: + VTKM_CONT + FilterTemporalParticleAdvection(); + + VTKM_CONT + void SetPreviousTime(vtkm::FloatDefault t) { this->PreviousTime = t; } + VTKM_CONT + void SetNextTime(vtkm::FloatDefault t) { this->NextTime = t; } + + VTKM_CONT + void SetNextDataSet(const vtkm::cont::DataSet& ds) + { + this->NextDataSet = vtkm::cont::PartitionedDataSet(ds); + } + + VTKM_CONT + void SetNextDataSet(const vtkm::cont::PartitionedDataSet& pds) { this->NextDataSet = pds; } + + template + VTKM_CONT vtkm::cont::DataSet PrepareForExecution(const vtkm::cont::DataSet& input, + vtkm::filter::PolicyBase policy); + +protected: + VTKM_CONT void ValidateOptions(const vtkm::cont::PartitionedDataSet& input) const override; + + using DSIType = vtkm::filter::particleadvection::TemporalDataSetIntegrator; + VTKM_CONT std::vector CreateDataSetIntegrators( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::particleadvection::BoundsMap& boundsMap) const; + + vtkm::FloatDefault PreviousTime; + vtkm::FloatDefault NextTime; + vtkm::cont::PartitionedDataSet NextDataSet; + +private: +}; +} +} // namespace vtkm::filter + +#ifndef vtk_m_filter_FilterTemporalParticleAdvection_hxx +#include +#endif + +#endif // vtk_m_filter_FilterTemporalParticleAdvection_h diff --git a/vtkm/filter/FilterTemporalParticleAdvection.hxx b/vtkm/filter/FilterTemporalParticleAdvection.hxx new file mode 100644 index 000000000..c844026b0 --- /dev/null +++ b/vtkm/filter/FilterTemporalParticleAdvection.hxx @@ -0,0 +1,78 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_filter_FilterTemporalParticleAdvection_hxx +#define vtk_m_filter_FilterTemporalParticleAdvection_hxx + +#include + +namespace vtkm +{ +namespace filter +{ + +//----------------------------------------------------------------------------- +template +inline VTKM_CONT FilterTemporalParticleAdvection::FilterTemporalParticleAdvection() + : vtkm::filter::FilterParticleAdvection() + , PreviousTime(0) + , NextTime(0) +{ +} + +template +void FilterTemporalParticleAdvection::ValidateOptions( + const vtkm::cont::PartitionedDataSet& input) const +{ + this->vtkm::filter::FilterParticleAdvection::ValidateOptions(input); + + if (this->NextDataSet.GetNumberOfPartitions() != input.GetNumberOfPartitions()) + throw vtkm::cont::ErrorFilterExecution("Number of partitions do not match"); + if (!(this->PreviousTime < this->NextTime)) + throw vtkm::cont::ErrorFilterExecution("Previous time must be less than Next time."); +} + +template +std::vector +FilterTemporalParticleAdvection::CreateDataSetIntegrators( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::particleadvection::BoundsMap& boundsMap) const +{ + // using DSIType = vtkm::filter::particleadvection::TemporalDataSetIntegrator; + + std::vector dsi; + std::string activeField = this->GetActiveFieldName(); + + for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++) + { + vtkm::Id blockId = boundsMap.GetLocalBlockId(i); + auto dsPrev = input.GetPartition(i); + auto dsNext = this->NextDataSet.GetPartition(i); + if (!dsPrev.HasPointField(activeField) || !dsNext.HasPointField(activeField)) + throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation"); + dsi.push_back( + DSIType(dsPrev, this->PreviousTime, dsNext, this->NextTime, blockId, activeField)); + } + + return dsi; +} + +//----------------------------------------------------------------------------- +template +template +inline VTKM_CONT vtkm::cont::DataSet FilterTemporalParticleAdvection::PrepareForExecution( + const vtkm::cont::DataSet& input, + vtkm::filter::PolicyBase policy) +{ + return (static_cast(this))->DoExecute(input, policy); +} + +} +} // namespace vtkm::filter +#endif diff --git a/vtkm/filter/ParticleAdvection.h b/vtkm/filter/ParticleAdvection.h index 89241b7fe..4a6d19046 100644 --- a/vtkm/filter/ParticleAdvection.h +++ b/vtkm/filter/ParticleAdvection.h @@ -12,7 +12,7 @@ #define vtk_m_filter_ParticleAdvection_h #include -#include +#include namespace vtkm { @@ -22,44 +22,16 @@ namespace filter /// Takes as input a vector field and seed locations and generates the /// end points for each seed through the vector field. -class ParticleAdvection : public vtkm::filter::FilterDataSetWithField + +class ParticleAdvection : public vtkm::filter::FilterParticleAdvection { public: - using SupportedTypes = vtkm::TypeListFieldVec3; - - VTKM_CONT - ParticleAdvection(); - - VTKM_CONT - void SetStepSize(vtkm::FloatDefault s) { this->StepSize = s; } - - VTKM_CONT - void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; } - - VTKM_CONT - void SetSeeds(vtkm::cont::ArrayHandle& seeds); - - VTKM_CONT - bool GetUseThreadedAlgorithm() { return this->UseThreadedAlgorithm; } - - VTKM_CONT - void SetUseThreadedAlgorithm(bool val) { this->UseThreadedAlgorithm = val; } + VTKM_CONT ParticleAdvection(); template vtkm::cont::PartitionedDataSet PrepareForExecution( const vtkm::cont::PartitionedDataSet& input, const vtkm::filter::PolicyBase& policy); - - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - -private: - vtkm::Id NumberOfSteps; - vtkm::FloatDefault StepSize; - vtkm::cont::ArrayHandle Seeds; - bool UseThreadedAlgorithm; }; } } // namespace vtkm::filter diff --git a/vtkm/filter/ParticleAdvection.hxx b/vtkm/filter/ParticleAdvection.hxx index 57f1690a7..431a6c43e 100644 --- a/vtkm/filter/ParticleAdvection.hxx +++ b/vtkm/filter/ParticleAdvection.hxx @@ -10,13 +10,8 @@ #ifndef vtk_m_filter_ParticleAdvection_hxx #define vtk_m_filter_ParticleAdvection_hxx -#include - -#include -#include -#include #include -#include +#include #include #include #include @@ -28,46 +23,23 @@ namespace filter //----------------------------------------------------------------------------- inline VTKM_CONT ParticleAdvection::ParticleAdvection() - : vtkm::filter::FilterDataSetWithField() - , UseThreadedAlgorithm(false) + : vtkm::filter::FilterParticleAdvection() { } -//----------------------------------------------------------------------------- -inline VTKM_CONT void ParticleAdvection::SetSeeds(vtkm::cont::ArrayHandle& seeds) -{ - this->Seeds = seeds; -} - - //----------------------------------------------------------------------------- template inline VTKM_CONT vtkm::cont::PartitionedDataSet ParticleAdvection::PrepareForExecution( const vtkm::cont::PartitionedDataSet& input, const vtkm::filter::PolicyBase&) { - if (this->GetUseCoordinateSystemAsField()) - throw vtkm::cont::ErrorFilterExecution("Coordinate system as field not supported"); - if (this->Seeds.GetNumberOfValues() == 0) - throw vtkm::cont::ErrorFilterExecution("No seeds provided."); - - std::string activeField = this->GetActiveFieldName(); - vtkm::filter::particleadvection::BoundsMap boundsMap(input); - using DSIType = vtkm::filter::particleadvection::DataSetIntegrator; - std::vector dsi; - - for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++) - { - vtkm::Id blockId = boundsMap.GetLocalBlockId(i); - auto ds = input.GetPartition(i); - if (!ds.HasPointField(activeField)) - throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation"); - dsi.push_back(DSIType(ds, blockId, activeField)); - } - using AlgorithmType = vtkm::filter::particleadvection::ParticleAdvectionAlgorithm; using ThreadedAlgorithmType = vtkm::filter::particleadvection::ParticleAdvectionThreadedAlgorithm; + this->ValidateOptions(input); + vtkm::filter::particleadvection::BoundsMap boundsMap(input); + auto dsi = this->CreateDataSetIntegrators(input, boundsMap); + if (this->GetUseThreadedAlgorithm()) return vtkm::filter::particleadvection::RunAlgo( boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); @@ -76,14 +48,6 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet ParticleAdvection::PrepareForExe boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); } -//----------------------------------------------------------------------------- -template -inline VTKM_CONT bool ParticleAdvection::MapFieldOntoOutput(vtkm::cont::DataSet&, - const vtkm::cont::Field&, - vtkm::filter::PolicyBase) -{ - return false; -} } } // namespace vtkm::filter #endif diff --git a/vtkm/filter/PathParticle.h b/vtkm/filter/PathParticle.h new file mode 100644 index 000000000..6c562cf9d --- /dev/null +++ b/vtkm/filter/PathParticle.h @@ -0,0 +1,46 @@ +//============================================================================ +// 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. +//============================================================================ + +#ifndef vtk_m_filter_PathParticle_h +#define vtk_m_filter_PathParticle_h + +#include + +namespace vtkm +{ +namespace filter +{ +/// \brief generate streamlines from a vector field. + +/// Takes as input a vector field and seed locations and generates the +/// paths taken by the seeds through the vector field. +class PathParticle : public vtkm::filter::FilterTemporalParticleAdvection +{ +public: + VTKM_CONT + PathParticle(); + + template + vtkm::cont::PartitionedDataSet PrepareForExecution( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::PolicyBase& policy); + +protected: +private: +}; + +} +} // namespace vtkm::filter + +#ifndef vtk_m_filter_PathParticle_hxx +#include +#endif + +#endif // vtk_m_filter_PathParticle_h diff --git a/vtkm/filter/PathParticle.hxx b/vtkm/filter/PathParticle.hxx new file mode 100644 index 000000000..6760b2775 --- /dev/null +++ b/vtkm/filter/PathParticle.hxx @@ -0,0 +1,55 @@ +//============================================================================ +// 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. +//============================================================================ + +#ifndef vtk_m_filter_PathParticle_hxx +#define vtk_m_filter_PathParticle_hxx + +#include +#include +#include +#include +#include + +namespace vtkm +{ +namespace filter +{ + +//----------------------------------------------------------------------------- +inline VTKM_CONT PathParticle::PathParticle() + : vtkm::filter::FilterTemporalParticleAdvection() +{ +} + +//----------------------------------------------------------------------------- +template +inline VTKM_CONT vtkm::cont::PartitionedDataSet PathParticle::PrepareForExecution( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::PolicyBase&) +{ + using AlgorithmType = vtkm::filter::particleadvection::PathParticleAlgorithm; + using ThreadedAlgorithmType = vtkm::filter::particleadvection::PathParticleThreadedAlgorithm; + + this->ValidateOptions(input); + + vtkm::filter::particleadvection::BoundsMap boundsMap(input); + auto dsi = this->CreateDataSetIntegrators(input, boundsMap); + + if (this->GetUseThreadedAlgorithm()) + return vtkm::filter::particleadvection::RunAlgo( + boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); + else + return vtkm::filter::particleadvection::RunAlgo( + boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); +} + +} +} // namespace vtkm::filter +#endif diff --git a/vtkm/filter/Pathline.h b/vtkm/filter/Pathline.h index baed55be8..52ef57a62 100644 --- a/vtkm/filter/Pathline.h +++ b/vtkm/filter/Pathline.h @@ -11,10 +11,7 @@ #ifndef vtk_m_filter_Pathline_h #define vtk_m_filter_Pathline_h -#include -#include -#include -#include +#include namespace vtkm { @@ -24,66 +21,26 @@ namespace filter /// Takes as input a vector field and seed locations and generates the /// paths taken by the seeds through the vector field. -class Pathline : public vtkm::filter::FilterDataSetWithField +class Pathline : public vtkm::filter::FilterTemporalParticleAdvection { public: - using SupportedTypes = vtkm::TypeListFieldVec3; - VTKM_CONT Pathline(); - VTKM_CONT - void SetPreviousTime(vtkm::FloatDefault t) { this->PreviousTime = t; } - VTKM_CONT - void SetNextTime(vtkm::FloatDefault t) { this->NextTime = t; } - - VTKM_CONT - void SetNextDataSet(const vtkm::cont::DataSet& ds) - { - this->NextDataSet = vtkm::cont::PartitionedDataSet(ds); - } - - VTKM_CONT - void SetNextDataSet(const vtkm::cont::PartitionedDataSet& pds) { this->NextDataSet = pds; } - - - VTKM_CONT - void SetStepSize(vtkm::FloatDefault s) { this->StepSize = s; } - - VTKM_CONT - void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; } - - VTKM_CONT - void SetSeeds(vtkm::cont::ArrayHandle& seeds); - - VTKM_CONT - bool GetUseThreadedAlgorithm() { return this->UseThreadedAlgorithm; } - - VTKM_CONT - void SetUseThreadedAlgorithm(bool val) { this->UseThreadedAlgorithm = val; } - template vtkm::cont::PartitionedDataSet PrepareForExecution( const vtkm::cont::PartitionedDataSet& input, const vtkm::filter::PolicyBase& policy); - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - +protected: private: - vtkm::FloatDefault StepSize; - vtkm::FloatDefault PreviousTime; - vtkm::FloatDefault NextTime; - vtkm::cont::PartitionedDataSet NextDataSet; - vtkm::Id NumberOfSteps; - vtkm::cont::ArrayHandle Seeds; - bool UseThreadedAlgorithm; }; + } } // namespace vtkm::filter +#ifndef vtk_m_filter_Pathline_hxx #include +#endif #endif // vtk_m_filter_Pathline_h diff --git a/vtkm/filter/Pathline.hxx b/vtkm/filter/Pathline.hxx index a525a6a14..693f8a9e3 100644 --- a/vtkm/filter/Pathline.hxx +++ b/vtkm/filter/Pathline.hxx @@ -11,14 +11,11 @@ #ifndef vtk_m_filter_Pathline_hxx #define vtk_m_filter_Pathline_hxx -#include - -#include -#include #include +#include #include #include -#include +#include namespace vtkm { @@ -27,51 +24,24 @@ namespace filter //----------------------------------------------------------------------------- inline VTKM_CONT Pathline::Pathline() - : vtkm::filter::FilterDataSetWithField() - , UseThreadedAlgorithm(false) + : vtkm::filter::FilterTemporalParticleAdvection() { } -//----------------------------------------------------------------------------- -inline VTKM_CONT void Pathline::SetSeeds(vtkm::cont::ArrayHandle& seeds) -{ - this->Seeds = seeds; -} - //----------------------------------------------------------------------------- template inline VTKM_CONT vtkm::cont::PartitionedDataSet Pathline::PrepareForExecution( const vtkm::cont::PartitionedDataSet& input, const vtkm::filter::PolicyBase&) { - if (this->GetUseCoordinateSystemAsField()) - throw vtkm::cont::ErrorFilterExecution("Coordinate system as field not supported"); - if (this->Seeds.GetNumberOfValues() == 0) - throw vtkm::cont::ErrorFilterExecution("No seeds provided."); - if (this->NextDataSet.GetNumberOfPartitions() != input.GetNumberOfPartitions()) - throw vtkm::cont::ErrorFilterExecution("Number of partitions do not match"); - if (!(this->PreviousTime < this->NextTime)) - throw vtkm::cont::ErrorFilterExecution("Previous time must be less than Next time."); - - std::string activeField = this->GetActiveFieldName(); - vtkm::filter::particleadvection::BoundsMap boundsMap(input); - using DSIType = vtkm::filter::particleadvection::TemporalDataSetIntegrator; - std::vector dsi; - - for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++) - { - vtkm::Id blockId = boundsMap.GetLocalBlockId(i); - auto dsPrev = input.GetPartition(i); - auto dsNext = this->NextDataSet.GetPartition(i); - if (!dsPrev.HasPointField(activeField) || !dsNext.HasPointField(activeField)) - throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation"); - dsi.push_back( - DSIType(dsPrev, this->PreviousTime, dsNext, this->NextTime, blockId, activeField)); - } - using AlgorithmType = vtkm::filter::particleadvection::PathlineAlgorithm; using ThreadedAlgorithmType = vtkm::filter::particleadvection::PathlineThreadedAlgorithm; + this->ValidateOptions(input); + + vtkm::filter::particleadvection::BoundsMap boundsMap(input); + auto dsi = this->CreateDataSetIntegrators(input, boundsMap); + if (this->GetUseThreadedAlgorithm()) return vtkm::filter::particleadvection::RunAlgo( boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); @@ -80,14 +50,6 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet Pathline::PrepareForExecution( boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); } -//----------------------------------------------------------------------------- -template -inline VTKM_CONT bool Pathline::MapFieldOntoOutput(vtkm::cont::DataSet&, - const vtkm::cont::Field&, - vtkm::filter::PolicyBase) -{ - return false; -} } } // namespace vtkm::filter #endif diff --git a/vtkm/filter/Streamline.h b/vtkm/filter/Streamline.h index c067ea3ca..5009472d2 100644 --- a/vtkm/filter/Streamline.h +++ b/vtkm/filter/Streamline.h @@ -11,8 +11,7 @@ #ifndef vtk_m_filter_Streamline_h #define vtk_m_filter_Streamline_h -#include -#include +#include namespace vtkm { @@ -22,44 +21,18 @@ namespace filter /// Takes as input a vector field and seed locations and generates the /// paths taken by the seeds through the vector field. -class Streamline : public vtkm::filter::FilterDataSetWithField +class Streamline : public vtkm::filter::FilterParticleAdvection { public: - using SupportedTypes = vtkm::TypeListFieldVec3; - VTKM_CONT Streamline(); - VTKM_CONT - void SetStepSize(vtkm::FloatDefault s) { this->StepSize = s; } - - VTKM_CONT - void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; } - - VTKM_CONT - void SetSeeds(vtkm::cont::ArrayHandle& seeds); - - VTKM_CONT - bool GetUseThreadedAlgorithm() { return this->UseThreadedAlgorithm; } - - VTKM_CONT - void SetUseThreadedAlgorithm(bool val) { this->UseThreadedAlgorithm = val; } - template vtkm::cont::PartitionedDataSet PrepareForExecution( const vtkm::cont::PartitionedDataSet& input, const vtkm::filter::PolicyBase& policy); - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - vtkm::filter::PolicyBase policy); - private: - vtkm::Id NumberOfSteps; - vtkm::FloatDefault StepSize; - vtkm::cont::ArrayHandle Seeds; - bool UseThreadedAlgorithm; }; } } // namespace vtkm::filter diff --git a/vtkm/filter/Streamline.hxx b/vtkm/filter/Streamline.hxx index 0a4bcd349..2c4333865 100644 --- a/vtkm/filter/Streamline.hxx +++ b/vtkm/filter/Streamline.hxx @@ -10,16 +10,11 @@ #ifndef vtk_m_filter_Streamline_hxx #define vtk_m_filter_Streamline_hxx -#include - -#include -#include #include -#include +#include #include #include - -#include +#include namespace vtkm { @@ -28,45 +23,23 @@ namespace filter //----------------------------------------------------------------------------- inline VTKM_CONT Streamline::Streamline() - : vtkm::filter::FilterDataSetWithField() - , UseThreadedAlgorithm(false) + : vtkm::filter::FilterParticleAdvection() { } -//----------------------------------------------------------------------------- -inline VTKM_CONT void Streamline::SetSeeds(vtkm::cont::ArrayHandle& seeds) -{ - this->Seeds = seeds; -} - //----------------------------------------------------------------------------- template inline VTKM_CONT vtkm::cont::PartitionedDataSet Streamline::PrepareForExecution( const vtkm::cont::PartitionedDataSet& input, const vtkm::filter::PolicyBase&) { - if (this->GetUseCoordinateSystemAsField()) - throw vtkm::cont::ErrorFilterExecution("Coordinate system as field not supported"); - if (this->Seeds.GetNumberOfValues() == 0) - throw vtkm::cont::ErrorFilterExecution("No seeds provided."); - - std::string activeField = this->GetActiveFieldName(); - vtkm::filter::particleadvection::BoundsMap boundsMap(input); - using DSIType = vtkm::filter::particleadvection::DataSetIntegrator; - std::vector dsi; - - for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++) - { - vtkm::Id blockId = boundsMap.GetLocalBlockId(i); - auto ds = input.GetPartition(i); - if (!ds.HasPointField(activeField)) - throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation"); - dsi.push_back(DSIType(ds, blockId, activeField)); - } - using AlgorithmType = vtkm::filter::particleadvection::StreamlineAlgorithm; using ThreadedAlgorithmType = vtkm::filter::particleadvection::StreamlineThreadedAlgorithm; + this->ValidateOptions(input); + vtkm::filter::particleadvection::BoundsMap boundsMap(input); + auto dsi = this->CreateDataSetIntegrators(input, boundsMap); + if (this->GetUseThreadedAlgorithm()) return vtkm::filter::particleadvection::RunAlgo( boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); @@ -75,14 +48,6 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet Streamline::PrepareForExecution( boundsMap, dsi, this->NumberOfSteps, this->StepSize, this->Seeds); } -//----------------------------------------------------------------------------- -template -inline VTKM_CONT bool Streamline::MapFieldOntoOutput(vtkm::cont::DataSet&, - const vtkm::cont::Field&, - vtkm::filter::PolicyBase) -{ - return false; -} } } // namespace vtkm::filter #endif diff --git a/vtkm/filter/particleadvection/CMakeLists.txt b/vtkm/filter/particleadvection/CMakeLists.txt index 23e4ed608..765954149 100644 --- a/vtkm/filter/particleadvection/CMakeLists.txt +++ b/vtkm/filter/particleadvection/CMakeLists.txt @@ -18,7 +18,6 @@ set(headers Messenger.h ParticleAdvectionAlgorithm.h ParticleMessenger.h - StreamlineAlgorithm.h ) #----------------------------------------------------------------------------- diff --git a/vtkm/filter/particleadvection/DataSetIntegrator.hxx b/vtkm/filter/particleadvection/DataSetIntegrator.hxx index 620c2fdbe..da3893277 100644 --- a/vtkm/filter/particleadvection/DataSetIntegrator.hxx +++ b/vtkm/filter/particleadvection/DataSetIntegrator.hxx @@ -34,12 +34,12 @@ template <> template <> inline void DataSetIntegratorBase::DoAdvect( vtkm::cont::ArrayHandle& seeds, - const Stepper& rk4, + const Stepper& stepper, vtkm::Id maxSteps, vtkm::worklet::ParticleAdvectionResult& result) const { vtkm::worklet::ParticleAdvection Worklet; - result = Worklet.Run(rk4, seeds, maxSteps); + result = Worklet.Run(stepper, seeds, maxSteps); } //----- @@ -48,12 +48,26 @@ template <> template <> inline void DataSetIntegratorBase::DoAdvect( vtkm::cont::ArrayHandle& seeds, - const Stepper& rk4, + const Stepper& stepper, vtkm::Id maxSteps, vtkm::worklet::StreamlineResult& result) const { vtkm::worklet::Streamline Worklet; - result = Worklet.Run(rk4, seeds, maxSteps); + result = Worklet.Run(stepper, seeds, maxSteps); +} + +//----- +// Specialization for PathParticle worklet +template <> +template <> +inline void DataSetIntegratorBase::DoAdvect( + vtkm::cont::ArrayHandle& seeds, + const TemporalStepper& stepper, + vtkm::Id maxSteps, + vtkm::worklet::ParticleAdvectionResult& result) const +{ + vtkm::worklet::ParticleAdvection Worklet; + result = Worklet.Run(stepper, seeds, maxSteps); } //----- @@ -62,12 +76,12 @@ template <> template <> inline void DataSetIntegratorBase::DoAdvect( vtkm::cont::ArrayHandle& seeds, - const TemporalStepper& rk4, + const TemporalStepper& stepper, vtkm::Id maxSteps, vtkm::worklet::StreamlineResult& result) const { vtkm::worklet::Streamline Worklet; - result = Worklet.Run(rk4, seeds, maxSteps); + result = Worklet.Run(stepper, seeds, maxSteps); } } diff --git a/vtkm/filter/particleadvection/ParticleAdvectionAlgorithm.h b/vtkm/filter/particleadvection/ParticleAdvectionAlgorithm.h index cd9b477ed..d75cb9237 100644 --- a/vtkm/filter/particleadvection/ParticleAdvectionAlgorithm.h +++ b/vtkm/filter/particleadvection/ParticleAdvectionAlgorithm.h @@ -23,7 +23,12 @@ namespace particleadvection { using DSIType = vtkm::filter::particleadvection::DataSetIntegrator; +using TDSIType = vtkm::filter::particleadvection::TemporalDataSetIntegrator; +//------------------------------------------------------------------------------------------- +//Steady state advection algorithms + +//Particle advection class VTKM_ALWAYS_EXPORT ParticleAdvectionAlgorithm : public AdvectorBaseAlgorithm> { @@ -36,6 +41,7 @@ public: } }; +//Threaded particle advection class VTKM_ALWAYS_EXPORT ParticleAdvectionThreadedAlgorithm : public AdvectorBaseThreadedAlgorithm> @@ -50,6 +56,94 @@ public: } }; +//Streamline +class VTKM_ALWAYS_EXPORT StreamlineAlgorithm + : public AdvectorBaseAlgorithm> +{ +public: + StreamlineAlgorithm(const vtkm::filter::particleadvection::BoundsMap& bm, + const std::vector& blocks) + : AdvectorBaseAlgorithm>(bm, blocks) + { + } +}; + +//Threaded streamline + +class VTKM_ALWAYS_EXPORT StreamlineThreadedAlgorithm + : public AdvectorBaseThreadedAlgorithm> +{ +public: + StreamlineThreadedAlgorithm(const vtkm::filter::particleadvection::BoundsMap& bm, + const std::vector& blocks) + : AdvectorBaseThreadedAlgorithm>( + bm, + blocks) + { + } +}; + +//------------------------------------------------------------------------------------------- +//Unsteady state advection algorithms + +//PathParticle +class VTKM_ALWAYS_EXPORT PathParticleAlgorithm + : public AdvectorBaseAlgorithm> +{ +public: + PathParticleAlgorithm(const vtkm::filter::particleadvection::BoundsMap& bm, + const std::vector& blocks) + : AdvectorBaseAlgorithm>( + bm, + blocks) + { + } +}; + + +//Threaded PathParticle +class VTKM_ALWAYS_EXPORT PathParticleThreadedAlgorithm + : public AdvectorBaseThreadedAlgorithm> +{ +public: + PathParticleThreadedAlgorithm(const vtkm::filter::particleadvection::BoundsMap& bm, + const std::vector& blocks) + : AdvectorBaseThreadedAlgorithm>(bm, + blocks) + { + } +}; + +//Pathline +class VTKM_ALWAYS_EXPORT PathlineAlgorithm + : public AdvectorBaseAlgorithm> +{ +public: + PathlineAlgorithm(const vtkm::filter::particleadvection::BoundsMap& bm, + const std::vector& blocks) + : AdvectorBaseAlgorithm>(bm, blocks) + { + } +}; + +//Threaded pathline +class VTKM_ALWAYS_EXPORT PathlineThreadedAlgorithm + : public AdvectorBaseThreadedAlgorithm> +{ +public: + PathlineThreadedAlgorithm(const vtkm::filter::particleadvection::BoundsMap& bm, + const std::vector& blocks) + : AdvectorBaseThreadedAlgorithm>( + bm, + blocks) + { + } +}; + + + } } } // namespace vtkm::filter::particleadvection diff --git a/vtkm/filter/testing/UnitTestStreamlineFilter.cxx b/vtkm/filter/testing/UnitTestStreamlineFilter.cxx index 446a4d331..054fdf00c 100644 --- a/vtkm/filter/testing/UnitTestStreamlineFilter.cxx +++ b/vtkm/filter/testing/UnitTestStreamlineFilter.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,14 @@ namespace { +enum FilterType +{ + PARTICLE_ADVECTION, + STREAMLINE, + PATHLINE, + PATH_PARTICLE +}; + vtkm::cont::ArrayHandle CreateConstantVectorField(vtkm::Id num, const vtkm::Vec3f& vec) { vtkm::cont::ArrayHandleConstant vecConst; @@ -75,89 +84,77 @@ void TestStreamline() } } -void TestPathlineSimple() -{ - vtkm::cont::DataSetBuilderUniform dataSetBuilder; - vtkm::cont::DataSet inData1 = dataSetBuilder.Create(vtkm::Id3(5, 5, 5)); - vtkm::cont::DataSet inData2 = dataSetBuilder.Create(vtkm::Id3(5, 5, 5)); - vtkm::Id numPoints = inData1.GetCellSet().GetNumberOfPoints(); - vtkm::cont::ArrayHandle vectorField1; - vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleConstant(vtkm::Vec3f(1, 0, 0), numPoints), - vectorField1); - inData1.AddPointField("vectorvar", vectorField1); - vtkm::cont::ArrayHandle vectorField2; - vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleConstant(vtkm::Vec3f(0, 1, 0), numPoints), - vectorField2); - inData2.AddPointField("vectorvar", vectorField2); - - vtkm::filter::Pathline pathlines; - // Specify the seeds. - vtkm::cont::ArrayHandle seedArray; - seedArray.Allocate(2); - seedArray.WritePortal().Set(0, vtkm::Particle({ 0, 0, 0 }, 0)); - seedArray.WritePortal().Set(1, vtkm::Particle({ 1, 1, 1 }, 1)); - pathlines.SetActiveField("vectorvar"); - pathlines.SetStepSize(0.1f); - pathlines.SetNumberOfSteps(100); - pathlines.SetSeeds(seedArray); - pathlines.SetPreviousTime(0.0f); - pathlines.SetNextTime(1.0f); - pathlines.SetNextDataSet(inData2); - auto output = pathlines.Execute(inData1); - - //Validate the result is correct. - vtkm::cont::CoordinateSystem coords = output.GetCoordinateSystem(); - VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == 77, "Wrong number of coordinates"); - - vtkm::cont::DynamicCellSet dcells = output.GetCellSet(); - VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == 2, "Wrong number of cells"); -} - void TestPathline() { const vtkm::Id3 dims(5, 5, 5); const vtkm::Vec3f vecX(1, 0, 0); const vtkm::Vec3f vecY(0, 1, 0); const vtkm::Bounds bounds(0, 4, 0, 4, 0, 4); - std::string fieldName = "vec"; + std::string var = "vec"; - auto dataSets1 = vtkm::worklet::testing::CreateAllDataSets(bounds, dims, false); - auto dataSets2 = vtkm::worklet::testing::CreateAllDataSets(bounds, dims, false); - - std::size_t numDS = dataSets1.size(); - for (std::size_t i = 0; i < numDS; i++) + //test pathline and pathparticle filters. + for (int fType = 0; fType < 2; fType++) { - auto ds1 = dataSets1[i]; - auto ds2 = dataSets2[i]; + auto dataSets1 = vtkm::worklet::testing::CreateAllDataSets(bounds, dims, false); + auto dataSets2 = vtkm::worklet::testing::CreateAllDataSets(bounds, dims, false); - auto vecField1 = CreateConstantVectorField(ds1.GetNumberOfPoints(), vecX); - auto vecField2 = CreateConstantVectorField(ds1.GetNumberOfPoints(), vecY); - ds1.AddPointField(fieldName, vecField1); - ds2.AddPointField(fieldName, vecField2); + std::size_t numDS = dataSets1.size(); + for (std::size_t i = 0; i < numDS; i++) + { + auto ds1 = dataSets1[i]; + auto ds2 = dataSets2[i]; - vtkm::cont::ArrayHandle seedArray = - vtkm::cont::make_ArrayHandle({ vtkm::Particle(vtkm::Vec3f(.2f, 1.0f, .2f), 0), - vtkm::Particle(vtkm::Vec3f(.2f, 2.0f, .2f), 1), - vtkm::Particle(vtkm::Vec3f(.2f, 3.0f, .2f), 2) }); + auto vecField1 = CreateConstantVectorField(ds1.GetNumberOfPoints(), vecX); + auto vecField2 = CreateConstantVectorField(ds1.GetNumberOfPoints(), vecY); + ds1.AddPointField(var, vecField1); + ds2.AddPointField(var, vecField2); - vtkm::filter::Pathline pathline; + vtkm::cont::ArrayHandle seedArray = + vtkm::cont::make_ArrayHandle({ vtkm::Particle(vtkm::Vec3f(.2f, 1.0f, .2f), 0), + vtkm::Particle(vtkm::Vec3f(.2f, 2.0f, .2f), 1), + vtkm::Particle(vtkm::Vec3f(.2f, 3.0f, .2f), 2) }); - pathline.SetPreviousTime(0.0f); - pathline.SetNextTime(1.0f); - pathline.SetNextDataSet(ds2); - pathline.SetStepSize(static_cast(0.05f)); - pathline.SetNumberOfSteps(20); - pathline.SetSeeds(seedArray); + const vtkm::FloatDefault stepSize = 0.1; + const vtkm::FloatDefault t0 = 0, t1 = 1; + const vtkm::Id numSteps = 20; - pathline.SetActiveField(fieldName); - auto output = pathline.Execute(ds1); + vtkm::cont::DataSet output; + vtkm::Id numExpectedPoints; + if (fType == 0) + { + vtkm::filter::Pathline filt; + filt.SetActiveField(var); + filt.SetStepSize(stepSize); + filt.SetNumberOfSteps(numSteps); + filt.SetSeeds(seedArray); + filt.SetPreviousTime(t0); + filt.SetNextTime(t1); + filt.SetNextDataSet(ds2); + output = filt.Execute(ds1); + numExpectedPoints = 63; + } + else + { + vtkm::filter::PathParticle filt; + filt.SetActiveField(var); + filt.SetStepSize(stepSize); + filt.SetNumberOfSteps(numSteps); + filt.SetSeeds(seedArray); + filt.SetPreviousTime(t0); + filt.SetNextTime(t1); + filt.SetNextDataSet(ds2); + output = filt.Execute(ds1); + numExpectedPoints = 3; + } - //Validate the result is correct. - vtkm::cont::CoordinateSystem coords = output.GetCoordinateSystem(); - VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == 63, "Wrong number of coordinates"); + //Validate the result is correct. + vtkm::cont::CoordinateSystem coords = output.GetCoordinateSystem(); + VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == numExpectedPoints, + "Wrong number of coordinates"); - vtkm::cont::DynamicCellSet dcells = output.GetCellSet(); - VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == 3, "Wrong number of cells"); + vtkm::cont::DynamicCellSet dcells = output.GetCellSet(); + VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == 3, "Wrong number of cells"); + } } } @@ -225,7 +222,7 @@ void TestAMRStreamline(bool useSL) { vtkm::filter::Streamline filter; filter.SetStepSize(0.1f); - filter.SetNumberOfSteps(1000); + filter.SetNumberOfSteps(100000); filter.SetSeeds(seedArray); filter.SetActiveField(fieldName); @@ -297,7 +294,7 @@ void TestAMRStreamline(bool useSL) { vtkm::filter::ParticleAdvection filter; filter.SetStepSize(0.1f); - filter.SetNumberOfSteps(1000); + filter.SetNumberOfSteps(100000); filter.SetSeeds(seedArray); filter.SetActiveField(fieldName); @@ -325,7 +322,7 @@ void TestAMRStreamline(bool useSL) } } -void TestPartitionedDataSet(vtkm::Id num, bool useGhost, bool useSL) +void TestPartitionedDataSet(vtkm::Id num, bool useGhost, FilterType fType) { vtkm::Id numDims = 5; vtkm::FloatDefault x0 = 0; @@ -354,14 +351,17 @@ void TestPartitionedDataSet(vtkm::Id num, bool useGhost, bool useSL) x1 += dx; } - std::vector allPDs; + std::vector allPDs, allPDs2; const vtkm::Id3 dims(numDims, numDims, numDims); allPDs = vtkm::worklet::testing::CreateAllDataSets(bounds, dims, useGhost); + if (fType == FilterType::PATHLINE || fType == FilterType::PATH_PARTICLE) + allPDs2 = vtkm::worklet::testing::CreateAllDataSets(bounds, dims, useGhost); vtkm::Vec3f vecX(1, 0, 0); std::string fieldName = "vec"; - for (auto& pds : allPDs) + for (std::size_t idx = 0; idx < allPDs.size(); idx++) { + auto pds = allPDs[idx]; AddVectorFields(pds, fieldName, vecX); vtkm::cont::ArrayHandle seedArray; @@ -369,20 +369,38 @@ void TestPartitionedDataSet(vtkm::Id num, bool useGhost, bool useSL) vtkm::Particle(vtkm::Vec3f(.2f, 2.0f, .2f), 1) }); vtkm::Id numSeeds = seedArray.GetNumberOfValues(); - if (useSL) + if (fType == FilterType::STREAMLINE || fType == FilterType::PATHLINE) { - vtkm::filter::Streamline streamline; + vtkm::cont::PartitionedDataSet out; + if (fType == FilterType::STREAMLINE) + { + vtkm::filter::Streamline streamline; + streamline.SetStepSize(0.1f); + streamline.SetNumberOfSteps(100000); + streamline.SetSeeds(seedArray); - streamline.SetStepSize(0.1f); - streamline.SetNumberOfSteps(1000); - streamline.SetSeeds(seedArray); + streamline.SetActiveField(fieldName); + out = streamline.Execute(pds); + } + else + { + auto pds2 = allPDs2[idx]; + AddVectorFields(pds2, fieldName, vecX); - streamline.SetActiveField(fieldName); - auto out = streamline.Execute(pds); + vtkm::filter::Pathline pathline; + pathline.SetPreviousTime(0); + pathline.SetNextTime(1000); + pathline.SetNextDataSet(pds2); + pathline.SetStepSize(0.1f); + pathline.SetNumberOfSteps(100000); + pathline.SetSeeds(seedArray); + + pathline.SetActiveField(fieldName); + out = pathline.Execute(pds); + } for (vtkm::Id i = 0; i < num; i++) { - auto inputDS = pds.GetPartition(i); auto outputDS = out.GetPartition(i); VTKM_TEST_ASSERT(outputDS.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems in the output dataset"); @@ -415,16 +433,36 @@ void TestPartitionedDataSet(vtkm::Id num, bool useGhost, bool useSL) } } } - else + else if (fType == FilterType::PARTICLE_ADVECTION || fType == FilterType::PATH_PARTICLE) { - vtkm::filter::ParticleAdvection particleAdvection; + vtkm::cont::PartitionedDataSet out; + if (fType == FilterType::PARTICLE_ADVECTION) + { + vtkm::filter::ParticleAdvection particleAdvection; - particleAdvection.SetStepSize(0.1f); - particleAdvection.SetNumberOfSteps(1000); - particleAdvection.SetSeeds(seedArray); + particleAdvection.SetStepSize(0.1f); + particleAdvection.SetNumberOfSteps(100000); + particleAdvection.SetSeeds(seedArray); - particleAdvection.SetActiveField(fieldName); - auto out = particleAdvection.Execute(pds); + particleAdvection.SetActiveField(fieldName); + out = particleAdvection.Execute(pds); + } + else + { + auto pds2 = allPDs2[idx]; + AddVectorFields(pds2, fieldName, vecX); + + vtkm::filter::PathParticle pathParticle; + pathParticle.SetPreviousTime(0); + pathParticle.SetNextTime(1000); + pathParticle.SetNextDataSet(pds2); + pathParticle.SetStepSize(0.1f); + pathParticle.SetNumberOfSteps(100000); + pathParticle.SetSeeds(seedArray); + + pathParticle.SetActiveField(fieldName); + out = pathParticle.Execute(pds); + } VTKM_TEST_ASSERT(out.GetNumberOfPartitions() == 1, "Wrong number of partitions in output"); auto ds = out.GetPartition(0); @@ -541,18 +579,21 @@ void TestStreamlineFile(const std::string& fname, void TestStreamlineFilters() { std::vector flags = { true, false }; + std::vector fTypes = { FilterType::PARTICLE_ADVECTION, + FilterType::STREAMLINE, + FilterType::PATHLINE, + FilterType::PATH_PARTICLE }; + for (int n = 1; n < 3; n++) { for (auto useGhost : flags) - for (auto useSL : flags) + for (auto ft : fTypes) { - useSL = false; - TestPartitionedDataSet(n, useGhost, useSL); + TestPartitionedDataSet(n, useGhost, ft); } } TestStreamline(); - TestPathlineSimple(); TestPathline(); for (auto useSL : flags)