From c40356bc8ac3f02ca2b0e550451a91fe32dafa66 Mon Sep 17 00:00:00 2001 From: Dave Pugmire Date: Wed, 29 Jun 2022 10:02:42 -0400 Subject: [PATCH] Add pathparticle2 filter --- vtkm/filter/CMakeLists.txt | 2 + vtkm/filter/PathParticle2.h | 62 ++++++++++ vtkm/filter/PathParticle2.hxx | 110 ++++++++++++++++++ vtkm/filter/Pathline2.hxx | 2 +- .../testing/UnitTestStreamlineFilter.cxx | 6 +- 5 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 vtkm/filter/PathParticle2.h create mode 100644 vtkm/filter/PathParticle2.hxx diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index 14d24bb46..abeb07f3d 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -109,6 +109,7 @@ set(extra_headers Pathline.h Pathline2.h PathParticle.h + PathParticle2.h Streamline.h Streamline2.h StreamSurface.h @@ -127,6 +128,7 @@ set(extra_header_template_sources Pathline.hxx Pathline2.hxx PathParticle.hxx + PathParticle2.hxx Streamline.hxx Streamline2.hxx StreamSurface.hxx diff --git a/vtkm/filter/PathParticle2.h b/vtkm/filter/PathParticle2.h new file mode 100644 index 000000000..c9d8020de --- /dev/null +++ b/vtkm/filter/PathParticle2.h @@ -0,0 +1,62 @@ +//============================================================================ +// 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_PathParticle2_h +#define vtk_m_filter_PathParticle2_h + +#include +#include +#include +#include + +namespace vtkm +{ +namespace filter +{ +/// \brief Advect particles in a vector field. + +/// Takes as input a vector field and seed locations and generates the +/// end points for each seed through the vector field. + +class PathParticle2 + : public vtkm::filter::FilterTemporalParticleAdvection +{ +public: + VTKM_CONT PathParticle2(); + + template + vtkm::cont::PartitionedDataSet PrepareForExecution( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::PolicyBase& policy); + + vtkm::cont::UnknownArrayHandle SeedArray; +}; + +class PathParticle3 : public vtkm::filter::NewFilterField +{ +public: + // VTKM_CONT PathParticle3() {} + +protected: + VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override; + VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions( + const vtkm::cont::PartitionedDataSet& inData) override; + + vtkm::cont::UnknownArrayHandle SeedArray; +}; + +} +} // namespace vtkm::filter + +#ifndef vtk_m_filter_PathParticle2_hxx +#include +#endif + +#endif // vtk_m_filter_PathParticle2_h diff --git a/vtkm/filter/PathParticle2.hxx b/vtkm/filter/PathParticle2.hxx new file mode 100644 index 000000000..7bb200aa6 --- /dev/null +++ b/vtkm/filter/PathParticle2.hxx @@ -0,0 +1,110 @@ +//============================================================================ +// 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_PathParticle2_hxx +#define vtk_m_filter_PathParticle2_hxx + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace vtkm +{ +namespace filter +{ + +//----------------------------------------------------------------------------- +inline VTKM_CONT PathParticle2::PathParticle2() + : vtkm::filter::FilterTemporalParticleAdvection() +{ + this->ResultType = vtkm::filter::particleadvection::PARTICLE_ADVECT_TYPE; +} + +//----------------------------------------------------------------------------- +template +inline VTKM_CONT vtkm::cont::PartitionedDataSet PathParticle2::PrepareForExecution( + const vtkm::cont::PartitionedDataSet& input, + const vtkm::filter::PolicyBase&) +{ + // using AlgorithmType = vtkm::filter::particleadvection::ParticleAdvectionAlgorithm; + // using ThreadedAlgorithmType = vtkm::filter::particleadvection::ParticleAdvectionThreadedAlgorithm; + using DSIType = vtkm::filter::particleadvection::DSI; + + this->ValidateOptions(); + //Make sure everything matches up ok. + this->VecFieldType = vtkm::filter::particleadvection::VELOCITY_FIELD_TYPE; + + vtkm::filter::particleadvection::BoundsMap boundsMap(input); + std::string activeField = this->GetActiveFieldName(); + + 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) && !ds.HasCellField(activeField)) + throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation"); + + dsi.push_back(new DSIType( + ds, blockId, activeField, this->SolverType, this->VecFieldType, this->ResultType)); + } + + this->SeedArray = this->Seeds; + vtkm::filter::particleadvection::PAV pav( + boundsMap, dsi, this->UseThreadedAlgorithm, this->ResultType); + return pav.Execute(this->NumberOfSteps, this->StepSize, this->SeedArray); + +#if 0 + //std::vector ddsi; + /* + vtkm::filter::particleadvection::RunAlgo( + boundsMap, ddsi, this->NumberOfSteps, this->StepSize, this->Seeds); + */ + + vtkm::cont::PartitionedDataSet output; + return output; + + /* + //using DSIType = vtkm::filter::particleadvection::DataSetIntegrator; + //std::vector dsi; + 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); + */ +#endif +} + +VTKM_CONT vtkm::cont::DataSet PathParticle3::DoExecute(const vtkm::cont::DataSet& inData) +{ + std::cout << "Meow DS" << std::endl; + auto result = this->DoExecutePartitions(inData); + return result.GetPartition(0); +} + +VTKM_CONT vtkm::cont::PartitionedDataSet PathParticle3::DoExecutePartitions( + const vtkm::cont::PartitionedDataSet& inData) +{ + std::cout << "Meow pDS" << std::endl; + return inData; +} + +} +} // namespace vtkm::filter +#endif diff --git a/vtkm/filter/Pathline2.hxx b/vtkm/filter/Pathline2.hxx index 61c418f80..70a38b18e 100644 --- a/vtkm/filter/Pathline2.hxx +++ b/vtkm/filter/Pathline2.hxx @@ -29,7 +29,7 @@ namespace filter inline VTKM_CONT Pathline2::Pathline2() : vtkm::filter::FilterTemporalParticleAdvection() { - this->ResultType = vtkm::filter::particleadvection::PARTICLE_ADVECT_TYPE; + this->ResultType = vtkm::filter::particleadvection::STREAMLINE_TYPE; } //----------------------------------------------------------------------------- diff --git a/vtkm/filter/testing/UnitTestStreamlineFilter.cxx b/vtkm/filter/testing/UnitTestStreamlineFilter.cxx index 05bb71a00..03b51df01 100644 --- a/vtkm/filter/testing/UnitTestStreamlineFilter.cxx +++ b/vtkm/filter/testing/UnitTestStreamlineFilter.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -472,7 +473,7 @@ void TestPartitionedDataSet(vtkm::Id num, bool useGhost, FilterType fType) auto pds2 = allPDs2[idx]; AddVectorFields(pds2, fieldName, vecX); - vtkm::filter::PathParticle pathParticle; + vtkm::filter::PathParticle2 pathParticle; pathParticle.SetPreviousTime(0); pathParticle.SetNextTime(1000); pathParticle.SetNextDataSet(pds2); @@ -610,7 +611,8 @@ void TestStreamlineFilters() FilterType::PATHLINE, FilterType::PATH_PARTICLE }; - fTypes = { FilterType::PARTICLE_ADVECTION, FilterType::STREAMLINE }; + //fTypes = {FilterType::PARTICLE_ADVECTION,FilterType::STREAMLINE}; + //fTypes = {FilterType::PATH_PARTICLE}; for (int n = 1; n < 3; n++) { for (auto useGhost : flags)