2021-06-11 12:00:25 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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 <vtkm/filter/FilterParticleAdvection.h>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2021-11-22 20:10:08 +00:00
|
|
|
template <typename Derived, typename ParticleType>
|
|
|
|
inline VTKM_CONT FilterParticleAdvection<Derived, ParticleType>::FilterParticleAdvection()
|
2021-06-11 12:00:25 +00:00
|
|
|
: vtkm::filter::FilterDataSetWithField<Derived>()
|
|
|
|
, NumberOfSteps(0)
|
|
|
|
, StepSize(0)
|
|
|
|
, UseThreadedAlgorithm(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-11-22 20:10:08 +00:00
|
|
|
template <typename Derived, typename ParticleType>
|
|
|
|
void FilterParticleAdvection<Derived, ParticleType>::ValidateOptions() const
|
2021-06-11 12:00:25 +00:00
|
|
|
{
|
|
|
|
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.");
|
|
|
|
}
|
|
|
|
|
2021-11-22 20:10:08 +00:00
|
|
|
template <typename Derived, typename ParticleType>
|
2021-06-11 12:00:25 +00:00
|
|
|
std::vector<vtkm::filter::particleadvection::DataSetIntegrator>
|
2021-11-22 20:10:08 +00:00
|
|
|
FilterParticleAdvection<Derived, ParticleType>::CreateDataSetIntegrators(
|
2021-06-11 12:00:25 +00:00
|
|
|
const vtkm::cont::PartitionedDataSet& input,
|
|
|
|
const vtkm::filter::particleadvection::BoundsMap& boundsMap) const
|
|
|
|
{
|
2021-11-22 20:10:08 +00:00
|
|
|
using DSIType = vtkm::filter::particleadvection::DataSetIntegrator;
|
|
|
|
|
|
|
|
std::vector<DSIType> dsi;
|
2021-06-11 12:00:25 +00:00
|
|
|
|
2021-06-23 17:53:56 +00:00
|
|
|
if (boundsMap.GetTotalNumBlocks() == 0)
|
|
|
|
throw vtkm::cont::ErrorFilterExecution("No input datasets.");
|
|
|
|
|
2021-06-11 12:00:25 +00:00
|
|
|
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);
|
2022-01-06 16:42:21 +00:00
|
|
|
if (!ds.HasPointField(activeField) && !ds.HasCellField(activeField))
|
2021-06-11 12:00:25 +00:00
|
|
|
throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation");
|
|
|
|
dsi.push_back(DSIType(ds, blockId, activeField));
|
|
|
|
}
|
|
|
|
|
|
|
|
return dsi;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2021-11-22 20:10:08 +00:00
|
|
|
template <typename Derived, typename ParticleType>
|
2021-06-11 12:00:25 +00:00
|
|
|
template <typename DerivedPolicy>
|
2021-11-22 20:10:08 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet
|
|
|
|
FilterParticleAdvection<Derived, ParticleType>::PrepareForExecution(
|
2021-06-11 12:00:25 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
|
|
|
{
|
|
|
|
return (static_cast<Derived*>(this))->DoExecute(input, policy);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
|
|
|
#endif
|