Move streamsurface into flow
This commit is contained in:
parent
e786874a77
commit
6a934167c2
@ -1,70 +0,0 @@
|
||||
//============================================================================
|
||||
// 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_StreamSurface_h
|
||||
#define vtk_m_filter_StreamSurface_h
|
||||
|
||||
#include <vtkm/filter/FilterDataSetWithField.h>
|
||||
#include <vtkm/filter/flow/worklet/GridEvaluators.h>
|
||||
#include <vtkm/filter/flow/worklet/ParticleAdvection.h>
|
||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||
#include <vtkm/worklet/StreamSurface.h>
|
||||
|
||||
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 StreamSurface : public vtkm::filter::FilterDataSetWithField<StreamSurface>
|
||||
{
|
||||
public:
|
||||
using SupportedTypes = vtkm::TypeListFieldVec3;
|
||||
|
||||
VTKM_CONT
|
||||
StreamSurface();
|
||||
|
||||
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<vtkm::Particle>& seeds) { this->Seeds = seeds; }
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet 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>& policy);
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
vtkm::Id NumberOfSteps;
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> Seeds;
|
||||
vtkm::FloatDefault StepSize;
|
||||
vtkm::worklet::StreamSurface Worklet;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_StreamSurface_hxx
|
||||
#include <vtkm/filter/StreamSurface.hxx>
|
||||
#endif
|
||||
|
||||
#endif // vtk_m_filter_StreamSurface_h
|
@ -25,6 +25,7 @@ set(flow_headers
|
||||
Pathline.h
|
||||
PathParticle.h
|
||||
Streamline.h
|
||||
StreamSurface.h
|
||||
)
|
||||
|
||||
set(flow_sources
|
||||
@ -33,6 +34,7 @@ set(flow_sources
|
||||
Pathline.cxx
|
||||
PathParticle.cxx
|
||||
Streamline.cxx
|
||||
StreamSurface.cxx
|
||||
)
|
||||
|
||||
vtkm_library(
|
||||
|
@ -8,13 +8,9 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_StreamSurface_hxx
|
||||
#define vtk_m_filter_StreamSurface_hxx
|
||||
|
||||
#include <vtkm/filter/StreamSurface.h>
|
||||
#include <vtkm/filter/flow/StreamSurface.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/filter/flow/worklet/Field.h>
|
||||
#include <vtkm/filter/flow/worklet/GridEvaluators.h>
|
||||
@ -22,57 +18,53 @@
|
||||
#include <vtkm/filter/flow/worklet/Particles.h>
|
||||
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
|
||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||
#include <vtkm/filter/flow/worklet/StreamSurface.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT StreamSurface::StreamSurface()
|
||||
: vtkm::filter::FilterDataSetWithField<StreamSurface>()
|
||||
, Worklet()
|
||||
namespace flow
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet StreamSurface::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>&)
|
||||
VTKM_CONT vtkm::cont::DataSet StreamSurface::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
//Check for some basics.
|
||||
if (this->Seeds.GetNumberOfValues() == 0)
|
||||
throw vtkm::cont::ErrorFilterExecution("No seeds provided.");
|
||||
this->ValidateOptions();
|
||||
|
||||
if (!this->Seeds.IsBaseComponentType<vtkm::Particle>())
|
||||
throw vtkm::cont::ErrorFilterExecution("Unsupported seed type in StreamSurface filter.");
|
||||
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
const vtkm::cont::CoordinateSystem& coords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>;
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec3f>;
|
||||
using FieldType = vtkm::worklet::flow::VelocityField<FieldHandle>;
|
||||
using GridEvalType = vtkm::worklet::flow::GridEvaluator<FieldType>;
|
||||
using RK4Type = vtkm::worklet::flow::RK4Integrator<GridEvalType>;
|
||||
using Stepper = vtkm::worklet::flow::Stepper<RK4Type, GridEvalType>;
|
||||
|
||||
//compute streamlines
|
||||
FieldType velocities(field, fieldMeta.GetAssociation());
|
||||
const auto& field = input.GetField(this->GetActiveFieldName());
|
||||
FieldHandle arr;
|
||||
vtkm::cont::ArrayCopyShallowIfPossible(field.GetData(), arr);
|
||||
FieldType velocities(arr, field.GetAssociation());
|
||||
GridEvalType eval(coords, cells, velocities);
|
||||
Stepper rk4(eval, this->StepSize);
|
||||
|
||||
vtkm::worklet::flow::Streamline streamline;
|
||||
|
||||
using ParticleArray = vtkm::cont::ArrayHandle<vtkm::Particle>;
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> seedArray;
|
||||
vtkm::cont::ArrayCopy(this->Seeds, seedArray);
|
||||
vtkm::cont::ArrayCopy(this->Seeds.AsArrayHandle<ParticleArray>(), seedArray);
|
||||
auto res = streamline.Run(rk4, seedArray, this->NumberOfSteps);
|
||||
|
||||
//compute surface from streamlines
|
||||
vtkm::worklet::flow::StreamSurface streamSurface;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> srfPoints;
|
||||
vtkm::cont::CellSetSingleType<> srfCells;
|
||||
vtkm::cont::CoordinateSystem slCoords("coordinates", res.Positions);
|
||||
this->Worklet.Run(slCoords, res.PolyLines, srfPoints, srfCells);
|
||||
streamSurface.Run(slCoords, res.PolyLines, srfPoints, srfCells);
|
||||
|
||||
vtkm::cont::DataSet outData;
|
||||
vtkm::cont::CoordinateSystem outputCoords("coordinates", srfPoints);
|
||||
@ -82,14 +74,6 @@ inline VTKM_CONT vtkm::cont::DataSet StreamSurface::DoExecute(
|
||||
return outData;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT bool StreamSurface::MapFieldOntoOutput(vtkm::cont::DataSet&,
|
||||
const vtkm::cont::Field&,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
#endif
|
||||
} // namespace vtkm::filter::flow
|
48
vtkm/filter/flow/StreamSurface.h
Normal file
48
vtkm/filter/flow/StreamSurface.h
Normal file
@ -0,0 +1,48 @@
|
||||
//============================================================================
|
||||
// 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_flow_StreamSurface_h
|
||||
#define vtk_m_filter_flow_StreamSurface_h
|
||||
|
||||
#include <vtkm/Particle.h>
|
||||
#include <vtkm/filter/flow/FlowTypes.h>
|
||||
#include <vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.h>
|
||||
#include <vtkm/filter/flow/vtkm_filter_flow_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
/// \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 VTKM_FILTER_FLOW_EXPORT StreamSurface
|
||||
: public vtkm::filter::flow::NewFilterParticleAdvectionSteadyState
|
||||
{
|
||||
public:
|
||||
VTKM_CONT StreamSurface()
|
||||
: NewFilterParticleAdvectionSteadyState(vtkm::filter::flow::FlowResultType::STREAMLINE_TYPE)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::filter::flow
|
||||
|
||||
#endif // vtk_m_filter_flow_StreamSurface_h
|
@ -8,8 +8,8 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_Streamline_h
|
||||
#define vtk_m_filter_Streamline_h
|
||||
#ifndef vtk_m_filter_flow_Streamline_h
|
||||
#define vtk_m_filter_flow_Streamline_h
|
||||
|
||||
#include <vtkm/Particle.h>
|
||||
#include <vtkm/filter/flow/FlowTypes.h>
|
||||
@ -46,4 +46,4 @@ protected:
|
||||
}
|
||||
} // namespace vtkm::filter::flow
|
||||
|
||||
#endif // vtk_m_filter_Streamline_h
|
||||
#endif // vtk_m_filter_flow_Streamline_h
|
||||
|
@ -12,6 +12,8 @@ set(unit_tests
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestWorkletParticleAdvection.cxx
|
||||
UnitTestWorkletTemporalAdvection.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
UnitTestStreamSurfaceWorklet.cxx
|
||||
)
|
||||
|
||||
set(libraries
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/StreamSurface.h>
|
||||
#include <vtkm/filter/flow/StreamSurface.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -44,7 +44,7 @@ void TestStreamSurface()
|
||||
vtkm::Particle(vtkm::Vec3f(.1f, 3.0f, .3f), 2),
|
||||
vtkm::Particle(vtkm::Vec3f(.1f, 3.5f, .2f), 3) });
|
||||
|
||||
vtkm::filter::StreamSurface streamSrf;
|
||||
vtkm::filter::flow::StreamSurface streamSrf;
|
||||
|
||||
streamSrf.SetStepSize(0.1f);
|
||||
streamSrf.SetNumberOfSteps(20);
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/flow/worklet/StreamSurface.h>
|
||||
#include <vtkm/io/VTKDataSetWriter.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/StreamSurface.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -53,7 +53,7 @@ void TestSameNumPolylines()
|
||||
dsb.AddCell(vtkm::CELL_SHAPE_POLY_LINE, ids);
|
||||
|
||||
vtkm::cont::DataSet ds = dsb.Create();
|
||||
vtkm::worklet::StreamSurface streamSurfaceWorklet;
|
||||
vtkm::worklet::flow::StreamSurface streamSurfaceWorklet;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> newPoints;
|
||||
vtkm::cont::CellSetSingleType<> newCells;
|
||||
streamSurfaceWorklet.Run(ds.GetCoordinateSystem(0), ds.GetCellSet(), newPoints, newCells);
|
||||
@ -111,7 +111,7 @@ void TestUnequalNumPolylines(int unequalType)
|
||||
dsb.AddCell(vtkm::CELL_SHAPE_POLY_LINE, ids);
|
||||
|
||||
vtkm::cont::DataSet ds = dsb.Create();
|
||||
vtkm::worklet::StreamSurface streamSurfaceWorklet;
|
||||
vtkm::worklet::flow::StreamSurface streamSurfaceWorklet;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> newPoints;
|
||||
vtkm::cont::CellSetSingleType<> newCells;
|
||||
streamSurfaceWorklet.Run(ds.GetCoordinateSystem(0), ds.GetCellSet(), newPoints, newCells);
|
||||
@ -124,7 +124,7 @@ void TestUnequalNumPolylines(int unequalType)
|
||||
"Wrong number of cells in StreamSurface worklet");
|
||||
}
|
||||
|
||||
void TestStreamSurface()
|
||||
void TestStreamSurfaceWorklet()
|
||||
{
|
||||
std::cout << "Testing Stream Surface Worklet" << std::endl;
|
||||
TestSameNumPolylines();
|
||||
@ -134,7 +134,7 @@ void TestStreamSurface()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestStreamSurface(int argc, char* argv[])
|
||||
int UnitTestStreamSurfaceWorklet(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamSurface, argc, argv);
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamSurfaceWorklet, argc, argv);
|
||||
}
|
@ -21,6 +21,7 @@ set(headers
|
||||
ParticleAdvectionWorklets.h
|
||||
RK4Integrator.h
|
||||
TemporalGridEvaluators.h
|
||||
StreamSurface.h
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -7,8 +7,8 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_worklet_streamsurface_h
|
||||
#define vtk_m_worklet_streamsurface_h
|
||||
#ifndef vtk_m_filter_flow_worklet_streamsurface_h
|
||||
#define vtk_m_filter_flow_worklet_streamsurface_h
|
||||
|
||||
#include <typeinfo>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
@ -24,6 +24,8 @@ namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
{
|
||||
namespace flow
|
||||
{
|
||||
|
||||
class StreamSurface
|
||||
{
|
||||
@ -276,7 +278,9 @@ public:
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // vtk_m_worklet_streamsurface_h
|
||||
}
|
||||
}
|
||||
} //vtkm::worklet::flow
|
||||
|
||||
#endif // vtk_m_filter_flow_worklet_streamsurface_h
|
@ -25,7 +25,6 @@ set(unit_tests
|
||||
UnitTestMIRFilter.cxx
|
||||
UnitTestMultiBlockFilter.cxx
|
||||
UnitTestPartitionedDataSetFilters.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
)
|
||||
|
||||
set(libraries
|
||||
@ -54,8 +53,6 @@ if ((TARGET vtkm::cuda) OR (TARGET vtkm::kokkos_cuda))
|
||||
set(large_kernel_sources
|
||||
RegressionTestStreamline.cxx
|
||||
UnitTestLagrangianFilter.cxx
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
)
|
||||
set_source_files_properties(${large_kernel_sources} PROPERTIES
|
||||
COMPILE_OPTIONS "-Xptxas;--disable-optimizer-constants"
|
||||
|
@ -40,7 +40,6 @@ set(headers
|
||||
StableSortIndices.h
|
||||
DescriptiveStatistics.h
|
||||
StreamLineUniformGrid.h
|
||||
StreamSurface.h
|
||||
TriangleWinding.h
|
||||
WaveletCompressor.h
|
||||
WorkletMapField.h
|
||||
|
@ -35,7 +35,6 @@ set(unit_tests
|
||||
UnitTestSplatKernels.cxx
|
||||
UnitTestScatterAndMaskWithTopology.cxx
|
||||
UnitTestStreamLineUniformGrid.cxx
|
||||
UnitTestStreamSurface.cxx
|
||||
UnitTestTriangleWinding.cxx
|
||||
UnitTestWholeCellSetIn.cxx
|
||||
UnitTestWorkletMapField.cxx
|
||||
|
Loading…
Reference in New Issue
Block a user