mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Migrate FieldConversion filters
This commit is contained in:
parent
4fa5f2f29c
commit
f08a3185f8
@ -27,10 +27,8 @@
|
||||
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/FieldSelection.h>
|
||||
#include <vtkm/filter/Gradient.h>
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
#include <vtkm/filter/PolicyBase.h>
|
||||
#include <vtkm/filter/Tetrahedralize.h>
|
||||
#include <vtkm/filter/Triangulate.h>
|
||||
@ -42,6 +40,8 @@
|
||||
#include <vtkm/filter/entity_extraction/ExternalFaces.h>
|
||||
#include <vtkm/filter/entity_extraction/Threshold.h>
|
||||
#include <vtkm/filter/entity_extraction/ThresholdPoints.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/PointAverage.h>
|
||||
|
||||
#include <vtkm/io/VTKDataSetReader.h>
|
||||
|
||||
@ -252,7 +252,7 @@ void BenchCellAverage(::benchmark::State& state)
|
||||
{
|
||||
const vtkm::cont::DeviceAdapterId device = Config.Device;
|
||||
|
||||
vtkm::filter::CellAverage filter;
|
||||
vtkm::filter::field_conversion::CellAverage filter;
|
||||
filter.SetActiveField(PointScalarsName, vtkm::cont::Field::Association::POINTS);
|
||||
|
||||
vtkm::cont::Timer timer{ device };
|
||||
@ -273,7 +273,7 @@ void BenchPointAverage(::benchmark::State& state)
|
||||
{
|
||||
const vtkm::cont::DeviceAdapterId device = Config.Device;
|
||||
|
||||
vtkm::filter::PointAverage filter;
|
||||
vtkm::filter::field_conversion::PointAverage filter;
|
||||
filter.SetActiveField(CellScalarsName, vtkm::cont::Field::Association::CELL_SET);
|
||||
|
||||
vtkm::cont::Timer timer{ device };
|
||||
@ -692,7 +692,7 @@ void CreateMissingFields()
|
||||
{
|
||||
if (!CellScalarsName.empty())
|
||||
{ // Generate from found cell field:
|
||||
vtkm::filter::PointAverage avg;
|
||||
vtkm::filter::field_conversion::PointAverage avg;
|
||||
avg.SetActiveField(CellScalarsName, vtkm::cont::Field::Association::CELL_SET);
|
||||
avg.SetOutputFieldName("GeneratedPointScalars");
|
||||
auto outds = avg.Execute(InputDataSet);
|
||||
@ -721,7 +721,7 @@ void CreateMissingFields()
|
||||
if (CellScalarsName.empty())
|
||||
{ // Attempt to construct them from a point field:
|
||||
VTKM_ASSERT(!PointScalarsName.empty());
|
||||
vtkm::filter::CellAverage avg;
|
||||
vtkm::filter::field_conversion::CellAverage avg;
|
||||
avg.SetActiveField(PointScalarsName, vtkm::cont::Field::Association::POINTS);
|
||||
avg.SetOutputFieldName("GeneratedCellScalars");
|
||||
auto outds = avg.Execute(InputDataSet);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/worklet/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/CellAverage.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
|
||||
namespace vtkm
|
||||
|
@ -17,8 +17,7 @@
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
#include <vtkm/filter/PointAverage.hxx>
|
||||
#include <vtkm/filter/field_conversion/PointAverage.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/worklet/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/CellAverage.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
|
||||
namespace
|
||||
|
@ -11,6 +11,7 @@
|
||||
vtkm_add_instantiations(GradientInstantiations FILTER Gradient)
|
||||
|
||||
set(deprecated_headers
|
||||
CellAverage.h
|
||||
CellSetConnectivity.h
|
||||
CleanGrid.h
|
||||
ClipWithField.h
|
||||
@ -33,6 +34,7 @@ set(deprecated_headers
|
||||
NDHistogram.h
|
||||
ParticleDensityCloudInCell.h
|
||||
ParticleDensityNearestGridPoint.h
|
||||
PointAverage.h
|
||||
Slice.h
|
||||
Threshold.h
|
||||
ThresholdPoints.h
|
||||
@ -41,7 +43,6 @@ set(deprecated_headers
|
||||
vtkm_declare_headers(${deprecated_headers})
|
||||
|
||||
set(common_headers
|
||||
CellAverage.h
|
||||
CellMeasures.h
|
||||
FieldMetadata.h
|
||||
FilterCell.h
|
||||
@ -57,9 +58,9 @@ set(common_headers
|
||||
TaskQueue.h
|
||||
Instantiations.h
|
||||
)
|
||||
vtkm_declare_headers(${common_headers})
|
||||
|
||||
set(common_header_template_sources
|
||||
CellAverage.hxx
|
||||
CellMeasures.hxx
|
||||
FilterDataSet.hxx
|
||||
FilterDataSetWithField.hxx
|
||||
@ -67,13 +68,8 @@ set(common_header_template_sources
|
||||
Filter.hxx
|
||||
FilterParticleAdvection.hxx
|
||||
FilterTemporalParticleAdvection.hxx
|
||||
PointAverage.hxx
|
||||
)
|
||||
|
||||
set(common_sources_device
|
||||
CellAverage.cxx
|
||||
PointAverage.cxx
|
||||
)
|
||||
vtkm_declare_headers(${common_header_template_sources})
|
||||
|
||||
set(extra_headers
|
||||
AmrArrays.h
|
||||
@ -95,7 +91,6 @@ set(extra_headers
|
||||
ParticleAdvection.h
|
||||
Pathline.h
|
||||
PathParticle.h
|
||||
PointAverage.h
|
||||
PointElevation.h
|
||||
PointTransform.h
|
||||
Probe.h
|
||||
@ -202,14 +197,6 @@ vtkm_library(
|
||||
|
||||
add_library(vtkm_filter INTERFACE)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_common
|
||||
TEMPLATE_SOURCES ${common_header_template_sources}
|
||||
HEADERS ${common_headers}
|
||||
DEVICE_SOURCES ${common_sources_device}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_extra
|
||||
TEMPLATE_SOURCES ${extra_header_template_sources}
|
||||
@ -227,7 +214,6 @@ vtkm_library(
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
vtkm_filter_common
|
||||
vtkm_filter_core
|
||||
vtkm_filter_extra
|
||||
vtkm_filter_gradient
|
||||
@ -236,19 +222,16 @@ set_target_properties(
|
||||
UNITY_BUILD_MODE BATCH
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_common PUBLIC vtkm_filter_core vtkm_worklet) # TODO: deprecate vtkm_filter_common
|
||||
target_link_libraries(vtkm_filter_core PUBLIC vtkm_cont vtkm_worklet)
|
||||
target_link_libraries(vtkm_filter_extra PUBLIC vtkm_filter_common)
|
||||
target_link_libraries(vtkm_filter_gradient PUBLIC vtkm_filter_common)
|
||||
target_link_libraries(vtkm_filter_extra PUBLIC vtkm_cont vtkm_worklet)
|
||||
target_link_libraries(vtkm_filter_gradient PUBLIC vtkm_cont vtkm_worklet)
|
||||
if (VTKm_ENABLE_MPI)
|
||||
target_link_libraries(vtkm_filter_common PUBLIC MPI::MPI_CXX)
|
||||
target_link_libraries(vtkm_filter_extra PUBLIC MPI::MPI_CXX)
|
||||
target_link_libraries(vtkm_filter_gradient PUBLIC MPI::MPI_CXX)
|
||||
endif()
|
||||
target_link_libraries(vtkm_filter PUBLIC INTERFACE
|
||||
vtkm_filter_extra
|
||||
vtkm_filter_gradient
|
||||
vtkm_filter_common
|
||||
vtkm_filter_core
|
||||
)
|
||||
|
||||
@ -261,6 +244,7 @@ add_subdirectory(density_estimate)
|
||||
add_subdirectory(entity_extraction)
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(particleadvection)
|
||||
add_subdirectory(field_conversion)
|
||||
add_subdirectory(field_transform)
|
||||
add_subdirectory(vector_calculus)
|
||||
|
||||
|
@ -1,21 +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.
|
||||
//============================================================================
|
||||
#define vtkm_filter_CellAverage_cxx
|
||||
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_FILTER_COMMON_INSTANTIATE_EXECUTE_METHOD(CellAverage);
|
||||
}
|
||||
}
|
@ -7,46 +7,34 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_CellAverage_h
|
||||
#define vtk_m_filter_CellAverage_h
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_common_export.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/filter/FilterField.h>
|
||||
#include <vtkm/worklet/CellAverage.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
/// \brief Point to cell interpolation filter.
|
||||
///
|
||||
/// CellAverage is a filter that transforms point data (i.e., data
|
||||
/// specified at cell points) into cell data (i.e., data specified per cell).
|
||||
/// The method of transformation is based on averaging the data
|
||||
/// values of all points used by particular cell.
|
||||
///
|
||||
class VTKM_FILTER_COMMON_EXPORT CellAverage : public vtkm::filter::FilterField<CellAverage>
|
||||
{
|
||||
public:
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
vtkm::worklet::CellAverage Worklet;
|
||||
VTKM_DEPRECATED(
|
||||
1.8,
|
||||
"Use vtkm/filter/field_conversion/CellAverage.h instead of vtkm/filter/CellAverage.h.")
|
||||
inline void CellAverage_deprecated() {}
|
||||
|
||||
inline void CellAverage_deprecated_warning()
|
||||
{
|
||||
CellAverage_deprecated();
|
||||
}
|
||||
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_conversion::CellAverage.") CellAverage
|
||||
: public vtkm::filter::field_conversion::CellAverage
|
||||
{
|
||||
using field_conversion::CellAverage::CellAverage;
|
||||
};
|
||||
|
||||
#ifndef vtkm_filter_CellAverage_cxx
|
||||
VTKM_FILTER_COMMON_EXPORT_EXECUTE_METHOD(CellAverage);
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#include <vtkm/filter/CellAverage.hxx>
|
||||
|
||||
#endif // vtk_m_filter_CellAverage_h
|
||||
#endif //vtk_m_filter_CellAverage_h
|
||||
|
@ -1,54 +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_CellAverage_hxx
|
||||
#define vtk_m_filter_CellAverage_hxx
|
||||
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
vtkm::cont::DataSet CellAverage::DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
||||
const vtkm::filter::FieldMetadata& fieldMetadata,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (!fieldMetadata.IsPointField())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
||||
}
|
||||
|
||||
vtkm::cont::UnknownCellSet cellSet = input.GetCellSet();
|
||||
|
||||
//todo: we need to ask the policy what storage type we should be using
|
||||
//If the input is implicit, we should know what to fall back to
|
||||
vtkm::cont::ArrayHandle<T> outArray;
|
||||
|
||||
this->Invoke(
|
||||
this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), inField, outArray);
|
||||
|
||||
std::string outputName = this->GetOutputFieldName();
|
||||
if (outputName.empty())
|
||||
{
|
||||
// Default name is name of input.
|
||||
outputName = fieldMetadata.GetName();
|
||||
}
|
||||
|
||||
return CreateResultFieldCell(input, outArray, outputName);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif
|
@ -1,21 +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.
|
||||
//============================================================================
|
||||
#define vtkm_filter_PointAverage_cxx
|
||||
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_FILTER_COMMON_INSTANTIATE_EXECUTE_METHOD(PointAverage);
|
||||
}
|
||||
}
|
@ -7,51 +7,34 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_filter_PointAverage_h
|
||||
#define vtk_m_filter_PointAverage_h
|
||||
|
||||
#include <vtkm/filter/vtkm_filter_extra_export.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CellSetExtrude.h>
|
||||
#include <vtkm/filter/FilterField.h>
|
||||
#include <vtkm/worklet/PointAverage.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/field_conversion/PointAverage.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
/// \brief Cell to Point interpolation filter.
|
||||
///
|
||||
/// PointAverage is a filter that transforms cell data (i.e., data
|
||||
/// specified per cell) into point data (i.e., data specified at cell
|
||||
/// points). The method of transformation is based on averaging the data
|
||||
/// values of all cells using a particular point.
|
||||
class VTKM_FILTER_COMMON_EXPORT PointAverage : public vtkm::filter::FilterField<PointAverage>
|
||||
|
||||
VTKM_DEPRECATED(
|
||||
1.8,
|
||||
"Use vtkm/filter/field_conversion/PointAverage.h instead of vtkm/filter/PointAverage.h.")
|
||||
inline void PointAverage_deprecated() {}
|
||||
|
||||
inline void PointAverage_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
PointAverage_deprecated();
|
||||
}
|
||||
|
||||
// PointAverage is a simple filter that is used to test custom filter types.
|
||||
using AdditionalFieldStorage = vtkm::List<vtkm::cont::StorageTagXGCCoordinates>;
|
||||
using SupportedCellSets =
|
||||
vtkm::ListAppend<vtkm::List<vtkm::cont::CellSetExtrude>, VTKM_DEFAULT_CELL_SET_LIST>;
|
||||
|
||||
private:
|
||||
vtkm::worklet::PointAverage Worklet;
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::field_conversion::PointAverage.") PointAverage
|
||||
: public vtkm::filter::field_conversion::PointAverage
|
||||
{
|
||||
using field_conversion::PointAverage::PointAverage;
|
||||
};
|
||||
|
||||
#ifndef vtkm_filter_PointAverage_cxx
|
||||
VTKM_FILTER_COMMON_EXPORT_EXECUTE_METHOD(PointAverage);
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#include <vtkm/filter/PointAverage.hxx>
|
||||
|
||||
#endif // vtk_m_filter_PointAverage_h
|
||||
#endif //vtk_m_filter_PointAverage_h
|
||||
|
@ -1,53 +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_PointAverage_hxx
|
||||
#define vtk_m_filter_PointAverage_hxx
|
||||
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
vtkm::cont::DataSet PointAverage::DoExecute(const vtkm::cont::DataSet& input,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& inField,
|
||||
const vtkm::filter::FieldMetadata& fieldMetadata,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (!fieldMetadata.IsCellField())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Cell field expected.");
|
||||
}
|
||||
|
||||
vtkm::cont::UnknownCellSet cellSet = input.GetCellSet();
|
||||
|
||||
//todo: we need to ask the policy what storage type we should be using
|
||||
//If the input is implicit, we should know what to fall back to
|
||||
vtkm::cont::ArrayHandle<T> outArray;
|
||||
this->Invoke(
|
||||
this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), inField, outArray);
|
||||
|
||||
std::string outputName = this->GetOutputFieldName();
|
||||
if (outputName.empty())
|
||||
{
|
||||
// Default name is name of input.
|
||||
outputName = fieldMetadata.GetName();
|
||||
}
|
||||
|
||||
return CreateResultFieldPoint(input, outArray, outputName);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
#endif
|
34
vtkm/filter/field_conversion/CMakeLists.txt
Normal file
34
vtkm/filter/field_conversion/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
##============================================================================
|
||||
## 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(field_conversion_headers
|
||||
CellAverage.h
|
||||
PointAverage.h
|
||||
)
|
||||
set(field_conversion_sources
|
||||
CellAverage.cxx
|
||||
PointAverage.cxx
|
||||
)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_field_conversion
|
||||
HEADERS ${field_conversion_headers}
|
||||
SOURCES ${field_conversion_sources}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_field_conversion PUBLIC vtkm_worklet vtkm_filter_core)
|
||||
target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_field_conversion)
|
||||
|
||||
add_subdirectory(worklet)
|
||||
|
||||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
||||
if (VTKm_ENABLE_TESTING)
|
||||
add_subdirectory(testing)
|
||||
endif ()
|
53
vtkm/filter/field_conversion/CellAverage.cxx
Normal file
53
vtkm/filter/field_conversion/CellAverage.cxx
Normal file
@ -0,0 +1,53 @@
|
||||
//============================================================================
|
||||
// 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/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/CellAverage.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace field_conversion
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
vtkm::cont::DataSet CellAverage::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
auto field = GetFieldFromDataSet(input);
|
||||
if (!field.IsFieldPoint())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
|
||||
}
|
||||
|
||||
vtkm::cont::UnknownCellSet inputCellSet = input.GetCellSet();
|
||||
vtkm::cont::UnknownArrayHandle outArray;
|
||||
|
||||
auto resolveType = [&, this](const auto& concrete) {
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
vtkm::cont::ArrayHandle<T> result;
|
||||
this->Invoke(vtkm::worklet::CellAverage{}, inputCellSet, concrete, result);
|
||||
outArray = result;
|
||||
};
|
||||
field.GetData()
|
||||
.CastAndCallForTypesWithFloatFallback<vtkm::TypeListField, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
resolveType);
|
||||
|
||||
std::string outputName = this->GetOutputFieldName();
|
||||
if (outputName.empty())
|
||||
{
|
||||
// Default name is name of input.
|
||||
outputName = field.GetName();
|
||||
}
|
||||
return this->CreateResultFieldCell(input, outputName, outArray);
|
||||
}
|
||||
} // namespace field_conversion
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
39
vtkm/filter/field_conversion/CellAverage.h
Normal file
39
vtkm/filter/field_conversion/CellAverage.h
Normal file
@ -0,0 +1,39 @@
|
||||
//============================================================================
|
||||
// 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_field_conversion_CellAverage_h
|
||||
#define vtk_m_filter_field_conversion_CellAverage_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/field_conversion/vtkm_filter_field_conversion_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace field_conversion
|
||||
{
|
||||
/// \brief Point to cell interpolation filter.
|
||||
///
|
||||
/// CellAverage is a filter that transforms point data (i.e., data
|
||||
/// specified at cell points) into cell data (i.e., data specified per cell).
|
||||
/// The method of transformation is based on averaging the data
|
||||
/// values of all points used by particular cell.
|
||||
///
|
||||
class VTKM_FILTER_FIELD_CONVERSION_EXPORT CellAverage : public vtkm::filter::NewFilterField
|
||||
{
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
};
|
||||
} // namespace field_conversion
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_field_conversion_CellAverage_h
|
62
vtkm/filter/field_conversion/PointAverage.cxx
Normal file
62
vtkm/filter/field_conversion/PointAverage.cxx
Normal file
@ -0,0 +1,62 @@
|
||||
//============================================================================
|
||||
// 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/CellSetExtrude.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/UncertainCellSet.h>
|
||||
#include <vtkm/cont/UnknownCellSet.h>
|
||||
#include <vtkm/filter/field_conversion/PointAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/PointAverage.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace field_conversion
|
||||
{
|
||||
vtkm::cont::DataSet PointAverage::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
auto field = GetFieldFromDataSet(input);
|
||||
if (!field.IsFieldCell())
|
||||
{
|
||||
throw vtkm::cont::ErrorFilterExecution("Cell field expected.");
|
||||
}
|
||||
|
||||
vtkm::cont::UnknownCellSet cellSet = input.GetCellSet();
|
||||
vtkm::cont::UnknownArrayHandle outArray;
|
||||
|
||||
auto resolveType = [&, this](const auto& concrete) {
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
using SupportedCellSets =
|
||||
vtkm::ListAppend<vtkm::List<vtkm::cont::CellSetExtrude>, VTKM_DEFAULT_CELL_SET_LIST>;
|
||||
|
||||
vtkm::cont::ArrayHandle<T> result;
|
||||
this->Invoke(vtkm::worklet::PointAverage{},
|
||||
cellSet.ResetCellSetList<SupportedCellSets>(),
|
||||
concrete,
|
||||
result);
|
||||
outArray = result;
|
||||
};
|
||||
// TODO: Do we need to deal with XCG storage type explicitly?
|
||||
// using AdditionalFieldStorage = vtkm::List<vtkm::cont::StorageTagXGCCoordinates>;
|
||||
field.GetData()
|
||||
.CastAndCallForTypesWithFloatFallback<vtkm::TypeListField, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
resolveType);
|
||||
|
||||
std::string outputName = this->GetOutputFieldName();
|
||||
if (outputName.empty())
|
||||
{
|
||||
// Default name is name of input.
|
||||
outputName = field.GetName();
|
||||
}
|
||||
return this->CreateResultFieldPoint(input, outputName, outArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
vtkm/filter/field_conversion/PointAverage.h
Normal file
38
vtkm/filter/field_conversion/PointAverage.h
Normal file
@ -0,0 +1,38 @@
|
||||
//============================================================================
|
||||
// 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_field_conversion_PointAverage_h
|
||||
#define vtk_m_filter_field_conversion_PointAverage_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/field_conversion/vtkm_filter_field_conversion_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace field_conversion
|
||||
{
|
||||
/// \brief Cell to Point interpolation filter.
|
||||
///
|
||||
/// PointAverage is a filter that transforms cell data (i.e., data
|
||||
/// specified per cell) into point data (i.e., data specified at cell
|
||||
/// points). The method of transformation is based on averaging the data
|
||||
/// values of all cells using a particular point.
|
||||
class VTKM_FILTER_FIELD_CONVERSION_EXPORT PointAverage : public vtkm::filter::NewFilterField
|
||||
{
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
};
|
||||
} // namespace field_conversion
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_field_conversion_PointAverage_h
|
25
vtkm/filter/field_conversion/testing/CMakeLists.txt
Normal file
25
vtkm/filter/field_conversion/testing/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
##============================================================================
|
||||
## 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
|
||||
UnitTestCellAverageFilter.cxx
|
||||
UnitTestPointAverageCellSetExtrude.cxx
|
||||
UnitTestPointAverageFilter.cxx
|
||||
)
|
||||
|
||||
set(libraries
|
||||
vtkm_filter_field_conversion
|
||||
)
|
||||
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES ${libraries}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -22,7 +22,7 @@ void TestCellAverageRegular3D()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DUniformDataSet0();
|
||||
|
||||
vtkm::filter::CellAverage cellAverage;
|
||||
vtkm::filter::field_conversion::CellAverage cellAverage;
|
||||
cellAverage.SetOutputFieldName("avgvals");
|
||||
cellAverage.SetActiveField("pointvar");
|
||||
vtkm::cont::DataSet result = cellAverage.Execute(dataSet);
|
||||
@ -71,7 +71,7 @@ void TestCellAverageRegular2D()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DUniformDataSet0();
|
||||
|
||||
vtkm::filter::CellAverage cellAverage;
|
||||
vtkm::filter::field_conversion::CellAverage cellAverage;
|
||||
cellAverage.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = cellAverage.Execute(dataSet);
|
||||
@ -97,7 +97,7 @@ void TestCellAverageExplicit()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
|
||||
|
||||
vtkm::filter::CellAverage cellAverage;
|
||||
vtkm::filter::field_conversion::CellAverage cellAverage;
|
||||
cellAverage.SetActiveField("pointvar");
|
||||
|
||||
vtkm::cont::DataSet result = cellAverage.Execute(dataSet);
|
@ -14,7 +14,7 @@
|
||||
#include <vtkm/cont/CellSetExtrude.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
#include <vtkm/filter/field_conversion/PointAverage.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -50,7 +50,7 @@ int TestCellSetExtrude()
|
||||
"cfield", vtkm::cont::Field::Association::CELL_SET, cvalues, vtkm::CopyFlag::Off);
|
||||
dataset.AddField(cfield);
|
||||
|
||||
vtkm::filter::PointAverage avg;
|
||||
vtkm::filter::field_conversion::PointAverage avg;
|
||||
try
|
||||
{
|
||||
avg.SetActiveField("cfield");
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/PointAverage.h>
|
||||
#include <vtkm/filter/field_conversion/PointAverage.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -22,7 +22,7 @@ void TestPointAverageUniform3D()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DUniformDataSet0();
|
||||
|
||||
vtkm::filter::PointAverage pointAverage;
|
||||
vtkm::filter::field_conversion::PointAverage pointAverage;
|
||||
pointAverage.SetOutputFieldName("avgvals");
|
||||
pointAverage.SetActiveField("cellvar");
|
||||
auto result = pointAverage.Execute(dataSet);
|
||||
@ -47,7 +47,7 @@ void TestPointAverageRegular3D()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DRectilinearDataSet0();
|
||||
|
||||
vtkm::filter::PointAverage pointAverage;
|
||||
vtkm::filter::field_conversion::PointAverage pointAverage;
|
||||
pointAverage.SetActiveField("cellvar");
|
||||
auto result = pointAverage.Execute(dataSet);
|
||||
|
||||
@ -73,7 +73,7 @@ void TestPointAverageExplicit1()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet1();
|
||||
|
||||
vtkm::filter::PointAverage pointAverage;
|
||||
vtkm::filter::field_conversion::PointAverage pointAverage;
|
||||
pointAverage.SetActiveField("cellvar");
|
||||
auto result = pointAverage.Execute(dataSet);
|
||||
|
||||
@ -96,7 +96,7 @@ void TestPointAverageExplicit2()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet5();
|
||||
|
||||
vtkm::filter::PointAverage pointAverage;
|
||||
vtkm::filter::field_conversion::PointAverage pointAverage;
|
||||
pointAverage.SetActiveField("cellvar");
|
||||
auto result = pointAverage.Execute(dataSet);
|
||||
|
17
vtkm/filter/field_conversion/worklet/CMakeLists.txt
Normal file
17
vtkm/filter/field_conversion/worklet/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
##============================================================================
|
||||
## 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
|
||||
CellAverage.h
|
||||
PointAverage.h
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
vtkm_declare_headers(${headers})
|
@ -13,7 +13,6 @@ set(headers
|
||||
)
|
||||
|
||||
set(unit_tests
|
||||
UnitTestCellAverageFilter.cxx
|
||||
UnitTestCellMeasuresFilter.cxx
|
||||
UnitTestContourTreeUniformFilter.cxx
|
||||
UnitTestContourTreeUniformAugmentedFilter.cxx
|
||||
@ -35,8 +34,6 @@ set(unit_tests
|
||||
UnitTestMIRFilter.cxx
|
||||
UnitTestMultiBlockFilter.cxx
|
||||
UnitTestPartitionedDataSetFilters.cxx
|
||||
UnitTestPointAverageFilter.cxx
|
||||
UnitTestPointAverageCellSetExtrude.cxx
|
||||
UnitTestPointElevationFilter.cxx
|
||||
UnitTestPointTransform.cxx
|
||||
UnitTestProbe.cxx
|
||||
|
@ -8,9 +8,8 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/FieldMetadata.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <vtkm/exec/ConnectivityStructured.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
|
||||
|
||||
template <typename T>
|
||||
@ -109,7 +109,7 @@ void TestPartitionedDataSetFilters()
|
||||
vtkm::cont::PartitionedDataSet partitions;
|
||||
|
||||
partitions = PartitionedDataSetBuilder<vtkm::FloatDefault>(partitionNum, "pointvar");
|
||||
vtkm::filter::CellAverage cellAverage;
|
||||
vtkm::filter::field_conversion::CellAverage cellAverage;
|
||||
cellAverage.SetOutputFieldName("average");
|
||||
cellAverage.SetActiveField("pointvar");
|
||||
result = cellAverage.Execute(partitions);
|
||||
|
@ -7,10 +7,10 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/SplitSharpEdges.h>
|
||||
#include <vtkm/filter/SurfaceNormals.h>
|
||||
#include <vtkm/filter/contour/Contour.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
|
||||
#include <vtkm/cont/DataSetBuilderExplicit.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -236,7 +236,7 @@ void TestWithStructuredData()
|
||||
dataSet = contour.Execute(dataSet);
|
||||
|
||||
// Compute cell normals:
|
||||
vtkm::filter::CellAverage cellNormals;
|
||||
vtkm::filter::field_conversion::CellAverage cellNormals;
|
||||
cellNormals.SetActiveField("normals", vtkm::cont::Field::Association::POINTS);
|
||||
dataSet = cellNormals.Execute(dataSet);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
#include <vtkm/filter/AmrArrays.h>
|
||||
#include <vtkm/filter/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/CellAverage.h>
|
||||
#include <vtkm/source/Amr.h>
|
||||
#include <vtkm/source/Wavelet.h>
|
||||
|
||||
@ -61,7 +61,7 @@ vtkm::cont::DataSet Amr::GenerateDataSet(unsigned int level, unsigned int amrInd
|
||||
waveletSource.SetStandardDeviation(deviation);
|
||||
vtkm::cont::DataSet wavelet = waveletSource.Execute();
|
||||
|
||||
vtkm::filter::CellAverage cellAverage;
|
||||
vtkm::filter::field_conversion::CellAverage cellAverage;
|
||||
cellAverage.SetActiveField("RTData", vtkm::cont::Field::Association::POINTS);
|
||||
cellAverage.SetOutputFieldName("RTDataCells");
|
||||
return cellAverage.Execute(wavelet);
|
||||
|
@ -12,7 +12,6 @@ set(headers
|
||||
AverageByKey.h
|
||||
BoundaryTypes.h
|
||||
AveragePointNeighborhood.h
|
||||
CellAverage.h
|
||||
CellDeepCopy.h
|
||||
CellMeasure.h
|
||||
ContourTreeUniform.h
|
||||
@ -44,7 +43,6 @@ set(headers
|
||||
OrientPointNormals.h
|
||||
OrientPointAndCellNormals.h
|
||||
ParticleAdvection.h
|
||||
PointAverage.h
|
||||
PointElevation.h
|
||||
PointTransform.h
|
||||
Probe.h
|
||||
|
@ -16,7 +16,6 @@ set(headers
|
||||
set(unit_tests
|
||||
UnitTestAverageByKey.cxx
|
||||
UnitTestBoundingIntervalHierarchy.cxx
|
||||
UnitTestCellAverage.cxx
|
||||
UnitTestCellDeepCopy.cxx
|
||||
UnitTestCellGradient.cxx
|
||||
UnitTestCellMeasure.cxx
|
||||
|
@ -1,92 +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/CellAverage.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void TestCellAverageUniform3D()
|
||||
{
|
||||
std::cout << "Testing CellAverage Worklet on 3D structured data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DUniformDataSet0();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetCellSet(), dataSet.GetField("pointvar"), result);
|
||||
|
||||
vtkm::Float32 expected[4] = { 60.1875f, 70.2125f, 120.3375f, 130.3625f };
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellAverage worklet on 3D uniform data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestCellAverageUniform2D()
|
||||
{
|
||||
std::cout << "Testing CellAverage Worklet on 2D structured data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DUniformDataSet0();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetCellSet(), dataSet.GetField("pointvar"), result);
|
||||
|
||||
vtkm::Float32 expected[2] = { 30.1f, 40.1f };
|
||||
std::cout << std::endl;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellAverage worklet on 2D uniform data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestCellAverageExplicit()
|
||||
{
|
||||
std::cout << "Testing CellAverage Worklet on Explicit data" << std::endl;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DExplicitDataSet0();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||
dispatcher.Invoke(dataSet.GetCellSet(), dataSet.GetField("pointvar"), result);
|
||||
|
||||
vtkm::Float32 expected[2] = { 20.1333f, 35.2f };
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(i), expected[i]),
|
||||
"Wrong result for CellAverage worklet on 3D explicit data");
|
||||
}
|
||||
}
|
||||
|
||||
void TestCellAverage()
|
||||
{
|
||||
TestCellAverageUniform2D();
|
||||
TestCellAverageUniform3D();
|
||||
TestCellAverageExplicit();
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestCellAverage(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestCellAverage, argc, argv);
|
||||
}
|
@ -11,8 +11,8 @@
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
|
||||
#include <vtkm/worklet/CellAverage.h>
|
||||
#include <vtkm/worklet/PointAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/PointAverage.h>
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
|
||||
#include <vtkm/worklet/CellAverage.h>
|
||||
#include <vtkm/worklet/PointAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/CellAverage.h>
|
||||
#include <vtkm/filter/field_conversion/worklet/PointAverage.h>
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user