2019-03-25 20:10:58 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2019-03-25 20:10:58 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
2019-10-07 19:39:02 +00:00
|
|
|
#ifndef vtk_m_filter_Pathline_hxx
|
|
|
|
#define vtk_m_filter_Pathline_hxx
|
|
|
|
|
2019-03-25 20:10:58 +00:00
|
|
|
#include <vtkm/cont/ArrayCopy.h>
|
|
|
|
#include <vtkm/cont/ArrayHandleIndex.h>
|
|
|
|
#include <vtkm/cont/ErrorFilterExecution.h>
|
2020-07-21 01:15:46 +00:00
|
|
|
#include <vtkm/worklet/particleadvection/Field.h>
|
2019-03-25 20:10:58 +00:00
|
|
|
#include <vtkm/worklet/particleadvection/GridEvaluators.h>
|
2020-08-14 20:54:29 +00:00
|
|
|
#include <vtkm/worklet/particleadvection/IntegratorBase.h>
|
2019-03-25 20:10:58 +00:00
|
|
|
#include <vtkm/worklet/particleadvection/Particles.h>
|
2020-08-14 20:54:29 +00:00
|
|
|
#include <vtkm/worklet/particleadvection/RK4Integrator.h>
|
2019-03-25 20:10:58 +00:00
|
|
|
#include <vtkm/worklet/particleadvection/TemporalGridEvaluators.h>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
inline VTKM_CONT Pathline::Pathline()
|
|
|
|
: vtkm::filter::FilterDataSetWithField<Pathline>()
|
|
|
|
, Worklet()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2020-08-26 12:59:51 +00:00
|
|
|
inline VTKM_CONT void Pathline::SetSeeds(vtkm::cont::ArrayHandle<vtkm::Particle>& seeds)
|
2019-03-25 20:10:58 +00:00
|
|
|
{
|
|
|
|
this->Seeds = seeds;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
|
|
|
inline VTKM_CONT vtkm::cont::DataSet Pathline::DoExecute(
|
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
|
|
|
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
|
|
|
{
|
|
|
|
//Check for some basics.
|
|
|
|
if (this->Seeds.GetNumberOfValues() == 0)
|
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorFilterExecution("No seeds provided.");
|
|
|
|
}
|
|
|
|
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
|
|
|
const vtkm::cont::DynamicCellSet& cells2 = this->NextDataSet.GetCellSet();
|
2019-03-25 20:10:58 +00:00
|
|
|
const vtkm::cont::CoordinateSystem& coords =
|
|
|
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
|
|
|
const vtkm::cont::CoordinateSystem& coords2 =
|
2019-03-26 15:53:40 +00:00
|
|
|
this->NextDataSet.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
2019-03-25 20:10:58 +00:00
|
|
|
|
2019-03-26 13:48:17 +00:00
|
|
|
auto field2 = vtkm::cont::Cast<vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>>(
|
2019-03-26 15:53:40 +00:00
|
|
|
this->NextDataSet.GetField(this->GetActiveFieldName()).GetData());
|
2019-03-25 20:10:58 +00:00
|
|
|
|
|
|
|
if (!fieldMeta.IsPointField())
|
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
|
|
|
}
|
|
|
|
|
|
|
|
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>;
|
2020-07-21 01:15:46 +00:00
|
|
|
using FieldType = vtkm::worklet::particleadvection::VelocityField<FieldHandle>;
|
|
|
|
using GridEvalType = vtkm::worklet::particleadvection::TemporalGridEvaluator<FieldType>;
|
2019-03-25 20:10:58 +00:00
|
|
|
using RK4Type = vtkm::worklet::particleadvection::RK4Integrator<GridEvalType>;
|
|
|
|
|
2020-07-21 01:15:46 +00:00
|
|
|
FieldType velocities(field);
|
|
|
|
FieldType velocities2(field2);
|
2019-03-26 15:53:40 +00:00
|
|
|
GridEvalType eval(
|
2020-07-21 01:15:46 +00:00
|
|
|
coords, cells, velocities, this->PreviousTime, coords2, cells2, velocities2, this->NextTime);
|
2019-09-05 20:57:37 +00:00
|
|
|
RK4Type rk4(eval, this->StepSize);
|
2019-03-25 20:10:58 +00:00
|
|
|
|
|
|
|
vtkm::worklet::Streamline streamline;
|
2020-08-26 12:59:51 +00:00
|
|
|
vtkm::worklet::StreamlineResult<vtkm::Particle> res;
|
2019-03-25 20:10:58 +00:00
|
|
|
|
2020-08-26 12:59:51 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Particle> seedArray;
|
2019-03-25 20:10:58 +00:00
|
|
|
vtkm::cont::ArrayCopy(this->Seeds, seedArray);
|
|
|
|
res = Worklet.Run(rk4, seedArray, this->NumberOfSteps);
|
|
|
|
|
|
|
|
vtkm::cont::DataSet outData;
|
2019-12-11 17:01:47 +00:00
|
|
|
vtkm::cont::CoordinateSystem outputCoords("coordinates", res.Positions);
|
|
|
|
outData.SetCellSet(res.PolyLines);
|
2019-03-25 20:10:58 +00:00
|
|
|
outData.AddCoordinateSystem(outputCoords);
|
|
|
|
|
|
|
|
return outData;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2020-02-06 21:58:59 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
inline VTKM_CONT bool Pathline::MapFieldOntoOutput(vtkm::cont::DataSet&,
|
|
|
|
const vtkm::cont::Field&,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
2019-03-25 20:10:58 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::filter
|
2019-10-07 19:39:02 +00:00
|
|
|
#endif
|