mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 21:33:55 +00:00
Merge branch 'master' into mir_filter
This commit is contained in:
commit
911c663774
@ -48,14 +48,6 @@ set(benchmarks
|
||||
BenchmarkTopologyAlgorithms
|
||||
)
|
||||
|
||||
#Taking too long to compile with HIPCC
|
||||
if(HIP IN_LIST Kokkos_DEVICES)
|
||||
list(REMOVE_ITEM benchmarks
|
||||
BenchmarkDeviceAdapter
|
||||
BenchmarkODEIntegrators
|
||||
)
|
||||
endif()
|
||||
|
||||
set(VTKm_BENCHS_RANGE_LOWER_BOUNDARY 4096 CACHE STRING "Smallest sample for input size bench for BenchmarkDeviceAdapter")
|
||||
set(VTKm_BENCHS_RANGE_UPPER_BOUNDARY 134217728 CACHE STRING "Biggest sample for input size bench for BenchmarkDeviceAdapter")
|
||||
mark_as_advanced(VTKm_BENCHS_RANGE_LOWER_BOUNDARY VTKm_BENCHS_RANGE_UPPER_BOUNDARY)
|
||||
@ -64,10 +56,8 @@ foreach (benchmark ${benchmarks})
|
||||
add_benchmark(NAME ${benchmark} FILE ${benchmark}.cxx LIBS vtkm_source vtkm_filter vtkm_io)
|
||||
endforeach ()
|
||||
|
||||
if(NOT HIP IN_LIST Kokkos_DEVICES)
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY})
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY})
|
||||
endif()
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY})
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY})
|
||||
|
||||
if(TARGET vtkm_rendering)
|
||||
add_benchmark(NAME BenchmarkRayTracing FILE BenchmarkRayTracing.cxx LIBS vtkm_rendering vtkm_source)
|
||||
|
@ -16,7 +16,4 @@ find_package(VTKm REQUIRED QUIET)
|
||||
if(TARGET vtkm_rendering)
|
||||
add_executable(Demo Demo.cxx)
|
||||
target_link_libraries(Demo PRIVATE vtkm_filter vtkm_rendering vtkm_source)
|
||||
vtkm_add_target_information(Demo
|
||||
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
|
||||
DEVICE_SOURCES Demo.cxx)
|
||||
endif()
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
#include <vtkm/filter/vector_analysis/Gradient.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include <vtkm/internal/Meta.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
|
@ -46,6 +46,7 @@ set(deprecated_headers
|
||||
PointAverage.h
|
||||
PointElevation.h
|
||||
PointTransform.h
|
||||
Probe.h
|
||||
Slice.h
|
||||
SplitSharpEdges.h
|
||||
SurfaceNormals.h
|
||||
@ -106,7 +107,6 @@ set(extra_headers
|
||||
ParticleAdvection.h
|
||||
Pathline.h
|
||||
PathParticle.h
|
||||
Probe.h
|
||||
Streamline.h
|
||||
StreamSurface.h
|
||||
)
|
||||
@ -121,7 +121,6 @@ set(extra_header_template_sources
|
||||
ParticleAdvection.hxx
|
||||
Pathline.hxx
|
||||
PathParticle.hxx
|
||||
Probe.hxx
|
||||
Streamline.hxx
|
||||
StreamSurface.hxx
|
||||
)
|
||||
@ -199,6 +198,7 @@ add_subdirectory(field_conversion)
|
||||
add_subdirectory(field_transform)
|
||||
add_subdirectory(geometry_refinement)
|
||||
add_subdirectory(mesh_info)
|
||||
add_subdirectory(resampling)
|
||||
add_subdirectory(vector_analysis)
|
||||
add_subdirectory(zfp)
|
||||
|
||||
|
@ -420,9 +420,6 @@ protected:
|
||||
const vtkm::cont::PartitionedDataSet& inData);
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
|
||||
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
||||
vtkm::cont::DataSet& output,
|
||||
@ -438,6 +435,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
|
||||
|
||||
|
||||
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
||||
bool RunFilterWithMultipleThreads = false;
|
||||
};
|
||||
|
@ -10,53 +10,23 @@
|
||||
#ifndef vtk_m_filter_Probe_h
|
||||
#define vtk_m_filter_Probe_h
|
||||
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
#include <vtkm/worklet/Probe.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/resampling //Probe.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
class Probe : public vtkm::filter::FilterDataSet<Probe>
|
||||
VTKM_DEPRECATED(1.8, "Use vtkm/filter/resampling/Probe.h instead of vtkm/filter/Probe.h.")
|
||||
inline void Probe_deprecated() {}
|
||||
|
||||
inline void Probe_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
void SetGeometry(const vtkm::cont::DataSet& geometry);
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& GetGeometry() const;
|
||||
|
||||
VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; }
|
||||
VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; }
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid after calling DoExecute.
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>);
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
vtkm::cont::DataSet Geometry;
|
||||
vtkm::worklet::Probe Worklet;
|
||||
vtkm::Float64 InvalidValue = vtkm::Nan64();
|
||||
};
|
||||
Probe_deprecated();
|
||||
}
|
||||
} // vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_Probe_hxx
|
||||
#include <vtkm/filter/Probe.hxx>
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif // vtk_m_filter_Probe_h
|
||||
#endif //vtk_m_filter_Probe_h
|
||||
|
@ -1,111 +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_Probe_hxx
|
||||
#define vtk_m_filter_Probe_hxx
|
||||
|
||||
#include <vtkm/filter/Probe.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
|
||||
#include <vtkm/cont/internal/CastInvalidValue.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
|
||||
{
|
||||
this->Geometry = vtkm::cont::DataSet();
|
||||
this->Geometry.SetCellSet(geometry.GetCellSet());
|
||||
this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
inline const vtkm::cont::DataSet& Probe::GetGeometry() const
|
||||
{
|
||||
return this->Geometry;
|
||||
}
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this),
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
||||
this->Geometry.GetCoordinateSystem().GetData());
|
||||
|
||||
auto output = this->Geometry;
|
||||
auto hpf = this->Worklet.GetHiddenPointsField();
|
||||
auto hcf = this->Worklet.GetHiddenCellsField(
|
||||
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy, *this));
|
||||
|
||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
|
||||
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT inline bool Probe::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
// If the field is a point field, then we need to do a custom interpolation of the points.
|
||||
// In this case, we need to call the superclass's MapFieldOntoOutput, which will in turn
|
||||
// call our DoMapField.
|
||||
return this->FilterDataSet<Probe>::MapFieldOntoOutput(result, field, policy);
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
vtkm::cont::Field outField;
|
||||
if (vtkm::filter::MapFieldPermutation(
|
||||
field, this->Worklet.GetCellIds(), outField, this->InvalidValue))
|
||||
{
|
||||
// output field should be associated with points
|
||||
outField = vtkm::cont::Field(
|
||||
field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData());
|
||||
result.AddField(outField);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT inline bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
VTKM_ASSERT(fieldMeta.IsPointField());
|
||||
auto fieldArray =
|
||||
this->Worklet.ProcessPointField(input,
|
||||
vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue),
|
||||
typename DerivedPolicy::AllCellSetList());
|
||||
result.AddField(fieldMeta.AsField(fieldArray));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // vtkm::filter
|
||||
#endif
|
32
vtkm/filter/resampling/CMakeLists.txt
Normal file
32
vtkm/filter/resampling/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
##============================================================================
|
||||
## 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.
|
||||
##============================================================================
|
||||
set(resampling_headers
|
||||
Probe.h
|
||||
)
|
||||
|
||||
set(resampling_sources
|
||||
Probe.cxx)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_resampling
|
||||
HEADERS ${resampling_headers}
|
||||
DEVICE_SOURCES ${resampling_sources}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_resampling PUBLIC vtkm_worklet vtkm_filter_core)
|
||||
target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_resampling)
|
||||
|
||||
add_subdirectory(worklet)
|
||||
|
||||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
||||
if (VTKm_ENABLE_TESTING)
|
||||
add_subdirectory(testing)
|
||||
endif ()
|
83
vtkm/filter/resampling/Probe.cxx
Normal file
83
vtkm/filter/resampling/Probe.cxx
Normal file
@ -0,0 +1,83 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/internal/CastInvalidValue.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/filter/resampling/Probe.h>
|
||||
#include <vtkm/filter/resampling/worklet/Probe.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace resampling
|
||||
{
|
||||
vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
vtkm::worklet::Probe worklet;
|
||||
worklet.Run(input.GetCellSet(),
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
||||
this->Geometry.GetCoordinateSystem().GetData());
|
||||
|
||||
auto mapper = [&](auto& outDataSet, const auto& f) { this->DoMapField(outDataSet, f, worklet); };
|
||||
auto output = this->CreateResult(
|
||||
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper);
|
||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField()));
|
||||
output.AddField(
|
||||
vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet())));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::worklet::Probe& worklet)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
auto resolve = [&](const auto& concrete) {
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
vtkm::cont::ArrayHandle<T> outputArray = worklet.ProcessPointField(
|
||||
concrete, vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue));
|
||||
result.AddPointField(field.GetName(), outputArray);
|
||||
};
|
||||
field.GetData()
|
||||
.CastAndCallForTypesWithFloatFallback<vtkm::TypeListField, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
resolve);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
vtkm::cont::Field outField;
|
||||
if (vtkm::filter::MapFieldPermutation(
|
||||
field, worklet.GetCellIds(), outField, this->InvalidValue))
|
||||
{
|
||||
// output field should be associated with points
|
||||
outField = vtkm::cont::Field(
|
||||
field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData());
|
||||
result.AddField(outField);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace resampling
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
65
vtkm/filter/resampling/Probe.h
Normal file
65
vtkm/filter/resampling/Probe.h
Normal file
@ -0,0 +1,65 @@
|
||||
//============================================================================
|
||||
// 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_Probe_h
|
||||
#define vtk_m_filter_Probe_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/resampling/vtkm_filter_resampling_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
{
|
||||
class Probe;
|
||||
}
|
||||
|
||||
namespace filter
|
||||
{
|
||||
namespace resampling
|
||||
{
|
||||
class VTKM_FILTER_RESAMPLING_EXPORT Probe : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
void SetGeometry(const vtkm::cont::DataSet& geometry)
|
||||
{
|
||||
this->Geometry = vtkm::cont::DataSet();
|
||||
this->Geometry.CopyStructure(geometry);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& GetGeometry() const { return this->Geometry; }
|
||||
|
||||
VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; }
|
||||
VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; }
|
||||
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
|
||||
bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::worklet::Probe& worklet);
|
||||
|
||||
vtkm::cont::DataSet Geometry;
|
||||
|
||||
vtkm::Float64 InvalidValue = vtkm::Nan64();
|
||||
};
|
||||
} // namespace resampling
|
||||
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::resampling::Probe.") Probe
|
||||
: public vtkm::filter::resampling::Probe
|
||||
{
|
||||
using resampling::Probe::Probe;
|
||||
};
|
||||
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_Probe_h
|
24
vtkm/filter/resampling/testing/CMakeLists.txt
Normal file
24
vtkm/filter/resampling/testing/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
##============================================================================
|
||||
## 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.
|
||||
##============================================================================
|
||||
|
||||
set(unit_tests
|
||||
UnitTestProbe.cxx
|
||||
)
|
||||
|
||||
set(libraries
|
||||
vtkm_filter_clean_grid
|
||||
vtkm_filter_resampling
|
||||
)
|
||||
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES ${libraries}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
@ -7,13 +7,12 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/filter/Probe.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/worklet/CellDeepCopy.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/resampling/Probe.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -46,22 +45,9 @@ vtkm::cont::DataSet MakeGeometryDataSet()
|
||||
|
||||
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
||||
{
|
||||
vtkm::cont::DataSet eds;
|
||||
vtkm::cont::CellSetExplicit<> cs;
|
||||
vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs);
|
||||
eds.SetCellSet(cs);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> points;
|
||||
vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points);
|
||||
eds.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points));
|
||||
|
||||
for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i)
|
||||
{
|
||||
eds.AddField(uds.GetField(i));
|
||||
}
|
||||
|
||||
return eds;
|
||||
vtkm::filter::clean_grid::CleanGrid toUnstructured;
|
||||
toUnstructured.SetMergePoints(true);
|
||||
return toUnstructured.Execute(uds);
|
||||
}
|
||||
|
||||
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
||||
@ -153,7 +139,7 @@ private:
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = MakeGeometryDataSet();
|
||||
|
||||
vtkm::filter::Probe probe;
|
||||
vtkm::filter::resampling::Probe probe;
|
||||
probe.SetGeometry(geometry);
|
||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||
auto output = probe.Execute(input);
|
||||
@ -175,7 +161,7 @@ private:
|
||||
auto input = MakeInputDataSet();
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::filter::Probe probe;
|
||||
vtkm::filter::resampling::Probe probe;
|
||||
probe.SetGeometry(geometry);
|
||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||
auto output = probe.Execute(input);
|
||||
@ -197,7 +183,7 @@ private:
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::filter::Probe probe;
|
||||
vtkm::filter::resampling::Probe probe;
|
||||
probe.SetGeometry(geometry);
|
||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||
auto output = probe.Execute(input);
|
15
vtkm/filter/resampling/worklet/CMakeLists.txt
Normal file
15
vtkm/filter/resampling/worklet/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
##============================================================================
|
||||
## 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.
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
Probe.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
@ -24,21 +24,10 @@ set(unit_tests
|
||||
UnitTestMapFieldPermutation.cxx
|
||||
UnitTestMultiBlockFilter.cxx
|
||||
UnitTestPartitionedDataSetFilters.cxx
|
||||
UnitTestProbe.cxx
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
)
|
||||
|
||||
#Taking too long to compile with HIPCC
|
||||
if(HIP IN_LIST Kokkos_DEVICES)
|
||||
list(REMOVE_ITEM unit_tests
|
||||
UnitTestLagrangianFilter.cxx
|
||||
UnitTestLagrangianStructuresFilter.cxx
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
)
|
||||
endif()
|
||||
|
||||
set(libraries
|
||||
vtkm_filter
|
||||
vtkm_io
|
||||
|
@ -32,7 +32,6 @@ set(headers
|
||||
NDimsHistMarginalization.h
|
||||
Normalize.h
|
||||
ParticleAdvection.h
|
||||
Probe.h
|
||||
ScalarsToColors.h
|
||||
ScatterCounting.h
|
||||
ScatterIdentity.h
|
||||
|
@ -8,11 +8,8 @@
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
|
||||
#Failing on HIP backend(crash)
|
||||
if(NOT HIP IN_LIST Kokkos_DEVICES)
|
||||
set(unit_tests
|
||||
UnitTestDispatcherBase.cxx
|
||||
set(unit_tests
|
||||
UnitTestDispatcherBase.cxx
|
||||
)
|
||||
|
||||
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)
|
||||
endif()
|
||||
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <vtkm/worklet/internal/WorkletBase.h>
|
||||
|
||||
#include <vtkm/cont/internal/Buffer.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
@ -111,45 +113,44 @@ namespace arg
|
||||
{
|
||||
|
||||
template <>
|
||||
struct TypeCheck<TestTypeCheckTag, std::vector<vtkm::Id>>
|
||||
struct TypeCheck<TestTypeCheckTag, vtkm::cont::internal::Buffer>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template <typename Device>
|
||||
struct Transport<TestTransportTagIn, std::vector<vtkm::Id>, Device>
|
||||
struct Transport<TestTransportTagIn, vtkm::cont::internal::Buffer, Device>
|
||||
{
|
||||
using ExecObjectType = TestExecObjectIn;
|
||||
|
||||
VTKM_CONT
|
||||
ExecObjectType operator()(const std::vector<vtkm::Id>& contData,
|
||||
const std::vector<vtkm::Id>&,
|
||||
ExecObjectType operator()(const vtkm::cont::internal::Buffer& contData,
|
||||
const vtkm::cont::internal::Buffer&,
|
||||
vtkm::Id inputRange,
|
||||
vtkm::Id outputRange,
|
||||
vtkm::cont::Token&) const
|
||||
vtkm::cont::Token& token) const
|
||||
{
|
||||
VTKM_TEST_ASSERT(inputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
VTKM_TEST_ASSERT(outputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
return ExecObjectType(contData.data());
|
||||
return reinterpret_cast<const vtkm::Id*>(contData.ReadPointerDevice(Device{}, token));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Device>
|
||||
struct Transport<TestTransportTagOut, std::vector<vtkm::Id>, Device>
|
||||
struct Transport<TestTransportTagOut, vtkm::cont::internal::Buffer, Device>
|
||||
{
|
||||
using ExecObjectType = TestExecObjectOut;
|
||||
|
||||
VTKM_CONT
|
||||
ExecObjectType operator()(const std::vector<vtkm::Id>& contData,
|
||||
const std::vector<vtkm::Id>&,
|
||||
ExecObjectType operator()(const vtkm::cont::internal::Buffer& contData,
|
||||
const vtkm::cont::internal::Buffer&,
|
||||
vtkm::Id inputRange,
|
||||
vtkm::Id outputRange,
|
||||
vtkm::cont::Token&) const
|
||||
vtkm::cont::Token& token) const
|
||||
{
|
||||
VTKM_TEST_ASSERT(inputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
VTKM_TEST_ASSERT(outputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
auto ptr = const_cast<vtkm::Id*>(contData.data());
|
||||
return ExecObjectType(ptr);
|
||||
return reinterpret_cast<vtkm::Id*>(contData.WritePointerDevice(Device{}, token));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -283,15 +284,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline vtkm::Id SchedulingRange(const std::vector<T>& inputDomain)
|
||||
inline vtkm::Id SchedulingRange(const vtkm::cont::internal::Buffer& inputDomain)
|
||||
{
|
||||
return static_cast<vtkm::Id>(inputDomain.size());
|
||||
return static_cast<vtkm::Id>(inputDomain.GetNumberOfBytes() / sizeof(vtkm::Id));
|
||||
}
|
||||
template <typename T>
|
||||
inline vtkm::Id SchedulingRange(const std::vector<T>* const inputDomain)
|
||||
inline vtkm::Id SchedulingRange(const vtkm::cont::internal::Buffer* inputDomain)
|
||||
{
|
||||
return static_cast<vtkm::Id>(inputDomain->size());
|
||||
return static_cast<vtkm::Id>(inputDomain->GetNumberOfBytes() / sizeof(vtkm::Id));
|
||||
}
|
||||
|
||||
template <typename WorkletType>
|
||||
@ -345,28 +344,41 @@ void TestBasicInvoke()
|
||||
{
|
||||
std::cout << "Test basic invoke" << std::endl;
|
||||
std::cout << " Set up data." << std::endl;
|
||||
std::vector<vtkm::Id> inputArray(ARRAY_SIZE);
|
||||
std::vector<vtkm::Id> outputArray(ARRAY_SIZE);
|
||||
vtkm::cont::internal::Buffer inputBuffer;
|
||||
vtkm::cont::internal::Buffer outputBuffer;
|
||||
TestExecObjectType execObject;
|
||||
execObject.Value = EXPECTED_EXEC_OBJECT_VALUE;
|
||||
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
vtkm::cont::Token token;
|
||||
inputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
outputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
auto inputArray = reinterpret_cast<vtkm::Id*>(inputBuffer.WritePointerHost(token));
|
||||
auto outputArray = reinterpret_cast<vtkm::Id*>(outputBuffer.WritePointerHost(token));
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " Create and run dispatcher." << std::endl;
|
||||
TestDispatcher<TestWorklet> dispatcher;
|
||||
dispatcher.Invoke(inputArray, execObject, &outputArray);
|
||||
dispatcher.Invoke(inputBuffer, execObject, &outputBuffer);
|
||||
|
||||
std::cout << " Check output of invoke." << std::endl;
|
||||
i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(outputArray[i] == TestValue(index, vtkm::Id()) + 1000,
|
||||
"Got bad value from testing.");
|
||||
vtkm::cont::Token token;
|
||||
auto outputArray = reinterpret_cast<const vtkm::Id*>(outputBuffer.ReadPointerHost(token));
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(outputArray[i] == TestValue(index, vtkm::Id()) + 1000,
|
||||
"Got bad value from testing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,23 +386,32 @@ void TestInvokeWithError()
|
||||
{
|
||||
std::cout << "Test invoke with error raised" << std::endl;
|
||||
std::cout << " Set up data." << std::endl;
|
||||
std::vector<vtkm::Id> inputArray(ARRAY_SIZE);
|
||||
std::vector<vtkm::Id> outputArray(ARRAY_SIZE);
|
||||
vtkm::cont::internal::Buffer inputBuffer;
|
||||
vtkm::cont::internal::Buffer outputBuffer;
|
||||
TestExecObjectType execObject;
|
||||
execObject.Value = EXPECTED_EXEC_OBJECT_VALUE;
|
||||
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, ++i)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
vtkm::cont::Token token;
|
||||
inputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
outputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
auto inputArray = reinterpret_cast<vtkm::Id*>(inputBuffer.WritePointerHost(token));
|
||||
auto outputArray = reinterpret_cast<vtkm::Id*>(outputBuffer.WritePointerHost(token));
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
std::cout << " Create and run dispatcher that raises error." << std::endl;
|
||||
TestDispatcher<TestErrorWorklet> dispatcher;
|
||||
dispatcher.Invoke(&inputArray, execObject, outputArray);
|
||||
dispatcher.Invoke(&inputBuffer, execObject, outputBuffer);
|
||||
VTKM_TEST_FAIL("Exception not thrown.");
|
||||
}
|
||||
catch (vtkm::cont::ErrorExecution& error)
|
||||
|
@ -29,7 +29,6 @@ set(unit_tests
|
||||
UnitTestNormalize.cxx
|
||||
UnitTestNDimsHistMarginalization.cxx
|
||||
UnitTestParticleAdvection.cxx
|
||||
UnitTestProbe.cxx
|
||||
UnitTestScalarsToColors.cxx
|
||||
UnitTestScatterAndMask.cxx
|
||||
UnitTestScatterCounting.cxx
|
||||
@ -53,13 +52,6 @@ set(unit_tests
|
||||
UnitTestWaveletCompressor.cxx
|
||||
)
|
||||
|
||||
if(HIP IN_LIST Kokkos_DEVICES)
|
||||
list(REMOVE_ITEM unit_tests
|
||||
UnitTestParticleAdvection.cxx # Taking too long to compile with HIPCC
|
||||
UnitTestScalarsToColors.cxx # Failing: incorrect results
|
||||
)
|
||||
endif()
|
||||
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES vtkm_source vtkm_worklet vtkm_filter vtkm_io
|
||||
|
@ -1,211 +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.
|
||||
//============================================================================
|
||||
#include <vtkm/worklet/Probe.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/worklet/CellDeepCopy.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
vtkm::cont::DataSet MakeInputDataSet()
|
||||
{
|
||||
auto input = vtkm::cont::DataSetBuilderUniform::Create(
|
||||
vtkm::Id2(4, 4), vtkm::make_Vec(0.0f, 0.0f), vtkm::make_Vec(1.0f, 1.0f));
|
||||
input.AddPointField("pointdata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.3f, 16));
|
||||
input.AddCellField("celldata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.7f, 9));
|
||||
return input;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet MakeGeometryDataSet()
|
||||
{
|
||||
auto geometry = vtkm::cont::DataSetBuilderUniform::Create(
|
||||
vtkm::Id2(9, 9), vtkm::make_Vec(0.7f, 0.7f), vtkm::make_Vec(0.35f, 0.35f));
|
||||
return geometry;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
||||
{
|
||||
vtkm::cont::DataSet eds;
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cs;
|
||||
vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs);
|
||||
eds.SetCellSet(cs);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> points;
|
||||
vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points);
|
||||
eds.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points));
|
||||
|
||||
for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i)
|
||||
{
|
||||
eds.AddField(uds.GetField(i));
|
||||
}
|
||||
|
||||
return eds;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
||||
{
|
||||
static std::vector<vtkm::Float32> expected = {
|
||||
1.05f, 1.155f, 1.26f, 1.365f, 1.47f, 1.575f, 1.68f, 0.0f, 0.0f, 1.47f, 1.575f, 1.68f,
|
||||
1.785f, 1.89f, 1.995f, 2.1f, 0.0f, 0.0f, 1.89f, 1.995f, 2.1f, 2.205f, 2.31f, 2.415f,
|
||||
2.52f, 0.0f, 0.0f, 2.31f, 2.415f, 2.52f, 2.625f, 2.73f, 2.835f, 2.94f, 0.0f, 0.0f,
|
||||
2.73f, 2.835f, 2.94f, 3.045f, 3.15f, 3.255f, 3.36f, 0.0f, 0.0f, 3.15f, 3.255f, 3.36f,
|
||||
3.465f, 3.57f, 3.675f, 3.78f, 0.0f, 0.0f, 3.57f, 3.675f, 3.78f, 3.885f, 3.99f, 4.095f,
|
||||
4.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
||||
};
|
||||
return expected;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::Float32>& GetExpectedCellData()
|
||||
{
|
||||
static std::vector<vtkm::Float32> expected = {
|
||||
0.0f, 0.7f, 0.7f, 0.7f, 1.4f, 1.4f, 1.4f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f,
|
||||
3.5f, 3.5f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 2.1f,
|
||||
2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f,
|
||||
5.6f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 4.2f, 4.9f,
|
||||
4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
||||
};
|
||||
return expected;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::UInt8>& GetExpectedHiddenPoints()
|
||||
{
|
||||
static std::vector<vtkm::UInt8> expected = { 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2,
|
||||
2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
||||
return expected;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::UInt8>& GetExpectedHiddenCells()
|
||||
{
|
||||
static std::vector<vtkm::UInt8> expected = { 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
||||
return expected;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TestResultArray(const vtkm::cont::ArrayHandle<T>& result, const std::vector<T>& expected)
|
||||
{
|
||||
vtkm::cont::printSummary_ArrayHandle(result, std::cout);
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
|
||||
"Incorrect field size");
|
||||
|
||||
auto portal = result.ReadPortal();
|
||||
vtkm::Id size = portal.GetNumberOfValues();
|
||||
for (vtkm::Id i = 0; i < size; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(portal.Get(i), expected[static_cast<std::size_t>(i)]),
|
||||
"Incorrect field value");
|
||||
}
|
||||
}
|
||||
|
||||
class TestProbe
|
||||
{
|
||||
private:
|
||||
using FieldArrayType = vtkm::cont::ArrayHandleCounting<vtkm::Float32>;
|
||||
|
||||
static void ExplicitToUnifrom()
|
||||
{
|
||||
std::cout << "Testing Probe Explicit to Uniform:\n";
|
||||
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = MakeGeometryDataSet();
|
||||
|
||||
vtkm::worklet::Probe probe;
|
||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
||||
|
||||
auto pf = probe.ProcessPointField(
|
||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto cf = probe.ProcessCellField(
|
||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto hp = probe.GetHiddenPointsField();
|
||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
||||
|
||||
TestResultArray(pf, GetExpectedPointData());
|
||||
TestResultArray(cf, GetExpectedCellData());
|
||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
||||
TestResultArray(hc, GetExpectedHiddenCells());
|
||||
}
|
||||
|
||||
static void UniformToExplict()
|
||||
{
|
||||
std::cout << "Testing Probe Uniform to Explicit:\n";
|
||||
|
||||
auto input = MakeInputDataSet();
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::worklet::Probe probe;
|
||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
||||
|
||||
auto pf = probe.ProcessPointField(
|
||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto cf = probe.ProcessCellField(
|
||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
|
||||
auto hp = probe.GetHiddenPointsField();
|
||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
||||
|
||||
TestResultArray(pf, GetExpectedPointData());
|
||||
TestResultArray(cf, GetExpectedCellData());
|
||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
||||
TestResultArray(hc, GetExpectedHiddenCells());
|
||||
}
|
||||
|
||||
static void ExplicitToExplict()
|
||||
{
|
||||
std::cout << "Testing Probe Explicit to Explicit:\n";
|
||||
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::worklet::Probe probe;
|
||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
||||
|
||||
auto pf = probe.ProcessPointField(
|
||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto cf = probe.ProcessCellField(
|
||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
|
||||
auto hp = probe.GetHiddenPointsField();
|
||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
||||
|
||||
TestResultArray(pf, GetExpectedPointData());
|
||||
TestResultArray(cf, GetExpectedCellData());
|
||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
||||
TestResultArray(hc, GetExpectedHiddenCells());
|
||||
}
|
||||
|
||||
public:
|
||||
static void Run()
|
||||
{
|
||||
ExplicitToUnifrom();
|
||||
UniformToExplict();
|
||||
ExplicitToExplict();
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestProbe(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestProbe::Run, argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user