2017-07-12 02:22:28 +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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2017-07-12 02:22:28 +00:00
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
|
|
|
// Copyright 2014 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2017-07-12 02:22:28 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef vtk_m_worklet_ParticleAdvection_h
|
|
|
|
#define vtk_m_worklet_ParticleAdvection_h
|
|
|
|
|
|
|
|
#include <vtkm/Types.h>
|
2017-09-25 22:54:46 +00:00
|
|
|
#include <vtkm/cont/ArrayCopy.h>
|
2017-07-12 02:22:28 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
|
|
#include <vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace worklet
|
|
|
|
{
|
|
|
|
|
2017-07-20 11:36:57 +00:00
|
|
|
template <typename FieldType>
|
|
|
|
struct ParticleAdvectionResult
|
|
|
|
{
|
|
|
|
ParticleAdvectionResult()
|
|
|
|
: positions()
|
|
|
|
, status()
|
|
|
|
, stepsTaken()
|
2018-03-23 07:49:32 +00:00
|
|
|
, times()
|
2017-07-20 11:36:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ParticleAdvectionResult(const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>>& pos,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& stat,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& steps)
|
|
|
|
: positions(pos)
|
|
|
|
, status(stat)
|
|
|
|
, stepsTaken(steps)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-23 07:49:32 +00:00
|
|
|
ParticleAdvectionResult(const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>>& pos,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& stat,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& steps,
|
|
|
|
const vtkm::cont::ArrayHandle<FieldType>& timeArray)
|
|
|
|
: positions(pos)
|
|
|
|
, status(stat)
|
|
|
|
, stepsTaken(steps)
|
|
|
|
, times(timeArray)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-07-20 11:36:57 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> positions;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> status;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> stepsTaken;
|
2018-03-23 07:49:32 +00:00
|
|
|
vtkm::cont::ArrayHandle<FieldType> times;
|
2017-07-20 11:36:57 +00:00
|
|
|
};
|
|
|
|
|
2017-07-12 02:22:28 +00:00
|
|
|
class ParticleAdvection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ParticleAdvection() {}
|
|
|
|
|
|
|
|
template <typename IntegratorType,
|
|
|
|
typename FieldType,
|
|
|
|
typename PointStorage,
|
2017-07-12 04:33:29 +00:00
|
|
|
typename DeviceAdapter>
|
2017-07-20 11:36:57 +00:00
|
|
|
ParticleAdvectionResult<FieldType> Run(
|
|
|
|
const IntegratorType& it,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& pts,
|
|
|
|
const vtkm::Id& nSteps,
|
2018-05-07 17:48:26 +00:00
|
|
|
DeviceAdapter tag)
|
2017-07-12 02:22:28 +00:00
|
|
|
{
|
2018-04-19 04:01:08 +00:00
|
|
|
vtkm::Id numSeeds = static_cast<vtkm::Id>(pts.GetNumberOfValues());
|
2017-07-12 02:22:28 +00:00
|
|
|
|
2018-04-19 04:01:08 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> stepsTaken;
|
2018-03-23 07:49:32 +00:00
|
|
|
vtkm::cont::ArrayHandle<FieldType> timeArray;
|
|
|
|
|
2017-07-26 20:35:43 +00:00
|
|
|
//Allocate status and steps arrays.
|
2017-08-10 20:28:48 +00:00
|
|
|
vtkm::cont::ArrayHandleConstant<vtkm::Id> init(0, numSeeds);
|
|
|
|
stepsTaken.Allocate(numSeeds);
|
2018-05-07 17:48:26 +00:00
|
|
|
vtkm::cont::ArrayCopy(init, stepsTaken, tag);
|
2017-08-10 20:28:48 +00:00
|
|
|
|
2018-04-19 04:01:08 +00:00
|
|
|
//Allocate memory to store the time for temporal integration.
|
|
|
|
vtkm::cont::ArrayHandleConstant<FieldType> time(0, numSeeds);
|
|
|
|
timeArray.Allocate(numSeeds);
|
2018-05-07 17:48:26 +00:00
|
|
|
vtkm::cont::ArrayCopy(time, timeArray, tag);
|
2018-04-19 04:01:08 +00:00
|
|
|
|
2018-05-07 17:48:26 +00:00
|
|
|
return Run(it, pts, stepsTaken, timeArray, nSteps, tag);
|
2018-04-19 04:01:08 +00:00
|
|
|
}
|
2017-09-14 15:16:29 +00:00
|
|
|
|
2018-04-19 04:01:08 +00:00
|
|
|
template <typename IntegratorType,
|
|
|
|
typename FieldType,
|
|
|
|
typename PointStorage,
|
|
|
|
typename DeviceAdapter>
|
|
|
|
ParticleAdvectionResult<FieldType> Run(
|
|
|
|
const IntegratorType& it,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& pts,
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id>& inputSteps,
|
|
|
|
const vtkm::Id& nSteps,
|
2018-05-07 17:48:26 +00:00
|
|
|
DeviceAdapter tag)
|
2018-04-19 04:01:08 +00:00
|
|
|
{
|
|
|
|
vtkm::Id numSeeds = static_cast<vtkm::Id>(pts.GetNumberOfValues());
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<FieldType> timeArray;
|
2018-03-23 07:49:32 +00:00
|
|
|
//Allocate memory to store the time for temporal integration.
|
|
|
|
vtkm::cont::ArrayHandleConstant<FieldType> time(0, numSeeds);
|
|
|
|
timeArray.Allocate(numSeeds);
|
2018-05-07 17:48:26 +00:00
|
|
|
vtkm::cont::ArrayCopy(time, timeArray, tag);
|
2017-08-10 20:28:48 +00:00
|
|
|
|
2018-05-07 17:48:26 +00:00
|
|
|
return Run(it, pts, inputSteps, timeArray, nSteps, tag);
|
2018-04-19 04:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename IntegratorType,
|
|
|
|
typename FieldType,
|
|
|
|
typename PointStorage,
|
|
|
|
typename DeviceAdapter>
|
|
|
|
ParticleAdvectionResult<FieldType> Run(
|
|
|
|
const IntegratorType& it,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& pts,
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id>& inputSteps,
|
|
|
|
vtkm::cont::ArrayHandle<FieldType>& inputTime,
|
|
|
|
const vtkm::Id& nSteps,
|
2018-05-07 17:48:26 +00:00
|
|
|
DeviceAdapter tag)
|
2018-04-19 04:01:08 +00:00
|
|
|
{
|
2018-05-07 17:48:26 +00:00
|
|
|
vtkm::worklet::particleadvection::ParticleAdvectionWorklet<IntegratorType, FieldType> worklet;
|
2018-04-19 04:01:08 +00:00
|
|
|
|
|
|
|
vtkm::Id numSeeds = static_cast<vtkm::Id>(pts.GetNumberOfValues());
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> status;
|
|
|
|
//Allocate status arrays.
|
|
|
|
vtkm::cont::ArrayHandleConstant<vtkm::Id> statusOK(static_cast<vtkm::Id>(1), numSeeds);
|
|
|
|
status.Allocate(numSeeds);
|
2018-05-07 17:48:26 +00:00
|
|
|
vtkm::cont::ArrayCopy(statusOK, status, tag);
|
2018-04-19 04:01:08 +00:00
|
|
|
|
2018-05-07 17:48:26 +00:00
|
|
|
worklet.Run(it, pts, nSteps, status, inputSteps, inputTime, tag);
|
2017-07-20 11:36:57 +00:00
|
|
|
//Create output.
|
2018-04-19 04:01:08 +00:00
|
|
|
ParticleAdvectionResult<FieldType> res(pts, status, inputSteps, inputTime);
|
2017-07-20 11:36:57 +00:00
|
|
|
return res;
|
2017-07-12 02:22:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-21 18:37:20 +00:00
|
|
|
template <typename FieldType>
|
|
|
|
struct StreamlineResult
|
|
|
|
{
|
|
|
|
StreamlineResult()
|
|
|
|
: positions()
|
|
|
|
, polyLines()
|
|
|
|
, status()
|
|
|
|
, stepsTaken()
|
2018-04-19 04:01:08 +00:00
|
|
|
, times()
|
2017-07-21 18:37:20 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamlineResult(const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>>& pos,
|
|
|
|
const vtkm::cont::CellSetExplicit<>& lines,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& stat,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& steps)
|
|
|
|
: positions(pos)
|
|
|
|
, polyLines(lines)
|
|
|
|
, status(stat)
|
|
|
|
, stepsTaken(steps)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-04-19 04:01:08 +00:00
|
|
|
StreamlineResult(const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>>& pos,
|
|
|
|
const vtkm::cont::CellSetExplicit<>& lines,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& stat,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Id>& steps,
|
|
|
|
const vtkm::cont::ArrayHandle<FieldType>& timeArray)
|
|
|
|
|
|
|
|
: positions(pos)
|
|
|
|
, polyLines(lines)
|
|
|
|
, status(stat)
|
|
|
|
, stepsTaken(steps)
|
|
|
|
, times(timeArray)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:37:20 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> positions;
|
|
|
|
vtkm::cont::CellSetExplicit<> polyLines;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> status;
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> stepsTaken;
|
2018-04-19 04:01:08 +00:00
|
|
|
vtkm::cont::ArrayHandle<FieldType> times;
|
2017-07-21 18:37:20 +00:00
|
|
|
};
|
|
|
|
|
2017-07-12 02:22:28 +00:00
|
|
|
class Streamline
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Streamline() {}
|
|
|
|
|
|
|
|
template <typename IntegratorType,
|
|
|
|
typename FieldType,
|
|
|
|
typename PointStorage,
|
2017-07-12 04:33:29 +00:00
|
|
|
typename DeviceAdapter>
|
2017-07-21 18:37:20 +00:00
|
|
|
StreamlineResult<FieldType> Run(
|
|
|
|
const IntegratorType& it,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& seedArray,
|
|
|
|
const vtkm::Id& nSteps,
|
2018-05-07 17:48:26 +00:00
|
|
|
DeviceAdapter tag)
|
2017-07-12 02:22:28 +00:00
|
|
|
{
|
2018-02-22 13:29:13 +00:00
|
|
|
using DeviceAlgorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
2017-07-21 18:37:20 +00:00
|
|
|
|
|
|
|
vtkm::Id numSeeds = seedArray.GetNumberOfValues();
|
2018-03-23 07:49:32 +00:00
|
|
|
|
2018-04-19 04:01:08 +00:00
|
|
|
//Allocate status and steps arrays.
|
2017-08-28 20:58:44 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> status, steps;
|
|
|
|
|
2018-03-23 07:49:32 +00:00
|
|
|
vtkm::cont::ArrayHandleConstant<vtkm::Id> statusOK(static_cast<vtkm::Id>(1), numSeeds);
|
|
|
|
status.Allocate(numSeeds);
|
|
|
|
DeviceAlgorithm::Copy(statusOK, status);
|
2017-07-21 18:37:20 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandleConstant<vtkm::Id> zero(0, numSeeds);
|
|
|
|
steps.Allocate(numSeeds);
|
|
|
|
DeviceAlgorithm::Copy(zero, steps);
|
|
|
|
|
2018-03-23 07:49:32 +00:00
|
|
|
//Allocate memory to store the time for temporal integration.
|
2018-04-19 04:01:08 +00:00
|
|
|
vtkm::cont::ArrayHandle<FieldType> timeArray;
|
|
|
|
vtkm::cont::ArrayHandleConstant<FieldType> time(0, numSeeds);
|
|
|
|
timeArray.Allocate(numSeeds);
|
|
|
|
DeviceAlgorithm::Copy(time, timeArray);
|
|
|
|
|
2018-05-07 17:48:26 +00:00
|
|
|
return Run(it, seedArray, steps, timeArray, nSteps, tag);
|
2018-04-19 04:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename IntegratorType,
|
|
|
|
typename FieldType,
|
|
|
|
typename PointStorage,
|
|
|
|
typename DeviceAdapter>
|
|
|
|
StreamlineResult<FieldType> Run(
|
|
|
|
const IntegratorType& it,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& seedArray,
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id>& inputSteps,
|
|
|
|
const vtkm::Id& nSteps,
|
2018-05-07 17:48:26 +00:00
|
|
|
DeviceAdapter tag)
|
2018-04-19 04:01:08 +00:00
|
|
|
{
|
|
|
|
using DeviceAlgorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
|
|
|
|
|
|
|
vtkm::Id numSeeds = seedArray.GetNumberOfValues();
|
|
|
|
|
|
|
|
//Allocate and initializr status array.
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> status;
|
|
|
|
vtkm::cont::ArrayHandleConstant<vtkm::Id> statusOK(static_cast<vtkm::Id>(1), numSeeds);
|
|
|
|
status.Allocate(numSeeds);
|
|
|
|
DeviceAlgorithm::Copy(statusOK, status);
|
|
|
|
|
|
|
|
//Allocate memory to store the time for temporal integration.
|
|
|
|
vtkm::cont::ArrayHandle<FieldType> timeArray;
|
2018-03-23 07:49:32 +00:00
|
|
|
vtkm::cont::ArrayHandleConstant<FieldType> time(0, numSeeds);
|
|
|
|
timeArray.Allocate(numSeeds);
|
|
|
|
DeviceAlgorithm::Copy(time, timeArray);
|
|
|
|
|
2018-05-07 17:48:26 +00:00
|
|
|
return Run(it, seedArray, inputSteps, timeArray, nSteps, tag);
|
2018-04-19 04:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename IntegratorType,
|
|
|
|
typename FieldType,
|
|
|
|
typename PointStorage,
|
|
|
|
typename DeviceAdapter>
|
|
|
|
StreamlineResult<FieldType> Run(
|
|
|
|
const IntegratorType& it,
|
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage>& seedArray,
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id>& inputSteps,
|
|
|
|
vtkm::cont::ArrayHandle<FieldType>& inputTime,
|
|
|
|
const vtkm::Id& nSteps,
|
2018-05-07 17:48:26 +00:00
|
|
|
DeviceAdapter tag)
|
2018-04-19 04:01:08 +00:00
|
|
|
{
|
|
|
|
using DeviceAlgorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
2018-05-07 17:48:26 +00:00
|
|
|
vtkm::worklet::particleadvection::StreamlineWorklet<IntegratorType, FieldType> worklet;
|
2018-04-19 04:01:08 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>, PointStorage> positions;
|
|
|
|
vtkm::cont::CellSetExplicit<> polyLines;
|
|
|
|
|
|
|
|
//Allocate and initialize status array.
|
|
|
|
vtkm::Id numSeeds = seedArray.GetNumberOfValues();
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> status;
|
|
|
|
vtkm::cont::ArrayHandleConstant<vtkm::Id> statusOK(static_cast<vtkm::Id>(1), numSeeds);
|
|
|
|
status.Allocate(numSeeds);
|
|
|
|
DeviceAlgorithm::Copy(statusOK, status);
|
|
|
|
|
2018-05-07 17:48:26 +00:00
|
|
|
worklet.Run(it, seedArray, nSteps, positions, polyLines, status, inputSteps, inputTime, tag);
|
2017-07-21 18:37:20 +00:00
|
|
|
|
2018-04-19 04:01:08 +00:00
|
|
|
StreamlineResult<FieldType> res(positions, polyLines, status, inputSteps, inputTime);
|
2017-07-21 18:37:20 +00:00
|
|
|
return res;
|
2017-07-12 02:22:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // vtk_m_worklet_ParticleAdvection_h
|