mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-20 02:55:47 +00:00
Merge branch 'master' of gitlab.kitware.com:vtk/vtk-m into grid_eval_curvilinear_grids
This commit is contained in:
commit
f454912813
@ -87,10 +87,20 @@ endif()
|
||||
|
||||
# Load the library exports, but only if not compiling VTK-m itself
|
||||
set_and_check(VTKm_CONFIG_DIR "@PACKAGE_VTKm_INSTALL_CONFIG_DIR@")
|
||||
set(VTKM_FROM_INSTALL_DIR FALSE)
|
||||
if(NOT "${CMAKE_BINARY_DIR}" STREQUAL "@VTKm_BINARY_DIR@")
|
||||
set(VTKM_FROM_INSTALL_DIR TRUE)
|
||||
include(${VTKm_CONFIG_DIR}/VTKmTargets.cmake)
|
||||
endif()
|
||||
|
||||
# Once we can require CMake 3.15 for all cuda builds we can
|
||||
# replace this with setting `cuda_architecture_flags` as part of the
|
||||
# EXPORT_PROPERTIES of the vtkm_cuda target
|
||||
if(VTKm_ENABLE_CUDA AND VTKM_FROM_INSTALL_DIR)
|
||||
set_target_properties(vtkm::cuda PROPERTIES cuda_architecture_flags "@VTKm_CUDA_Architecture_Flags@")
|
||||
set_target_properties(vtkm::cuda PROPERTIES requires_static_builds TRUE)
|
||||
endif()
|
||||
|
||||
# VTKm requires some CMake Find modules not included with CMake, so
|
||||
# include the CMake modules distributed with VTKm.
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
|
||||
|
@ -121,14 +121,18 @@ if(VTKm_ENABLE_CUDA)
|
||||
set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME vtkm::cuda)
|
||||
|
||||
install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME})
|
||||
# Reserve `INTERFACE_REQUIRES_STATIC_BUILDS` to potential work around issues
|
||||
# Reserve `requires_static_builds` to potential work around issues
|
||||
# where VTK-m doesn't work when building shared as virtual functions fail
|
||||
# inside device code. We don't want to force BUILD_SHARED_LIBS to a specific
|
||||
# value as that could impact other projects that embed VTK-m. Instead what
|
||||
# we do is make sure that libraries built by vtkm_library() are static
|
||||
# if they use CUDA
|
||||
#
|
||||
# This needs to be lower-case for the property to be properly exported
|
||||
# CMake 3.15 we can add `requires_static_builds` to the EXPORT_PROPERTIES
|
||||
# target property to have this automatically exported for us
|
||||
set_target_properties(vtkm_cuda PROPERTIES
|
||||
INTERFACE_REQUIRES_STATIC_BUILDS TRUE
|
||||
requires_static_builds TRUE
|
||||
)
|
||||
|
||||
|
||||
@ -247,7 +251,11 @@ if(VTKm_ENABLE_CUDA)
|
||||
string(REPLACE ";" " " arch_flags "${arch_flags}")
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${arch_flags}")
|
||||
|
||||
set_target_properties(vtkm_cuda PROPERTIES INTERFACE_CUDA_Architecture_Flags "${arch_flags}")
|
||||
# This needs to be lower-case for the property to be properly exported
|
||||
# CMake 3.15 we can add `cuda_architecture_flags` to the EXPORT_PROPERTIES
|
||||
# target property to have this automatically exported for us
|
||||
set_target_properties(vtkm_cuda PROPERTIES cuda_architecture_flags "${arch_flags}")
|
||||
set(VTKm_CUDA_Architecture_Flags "${arch_flags}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -130,7 +130,7 @@ function(vtkm_get_cuda_flags settings_var)
|
||||
if(TARGET vtkm::cuda)
|
||||
get_property(arch_flags
|
||||
TARGET vtkm::cuda
|
||||
PROPERTY INTERFACE_CUDA_Architecture_Flags)
|
||||
PROPERTY cuda_architecture_flags)
|
||||
set(${settings_var} "${${settings_var}} ${arch_flags}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@ -166,7 +166,8 @@ endfunction()
|
||||
# need to be marked as going to a special compiler for certain device adapters
|
||||
# such as CUDA.
|
||||
#
|
||||
# EXTENDS_VTKM: Some programming models have restrictions on how types can be extended.
|
||||
# EXTENDS_VTKM: Some programming models have restrictions on how types can be used,
|
||||
# passed across library boundaries, and derived from.
|
||||
# For example CUDA doesn't allow device side calls across dynamic library boundaries,
|
||||
# and requires all polymorphic classes to be reachable at dynamic library/executable
|
||||
# link time.
|
||||
@ -177,10 +178,13 @@ endfunction()
|
||||
# Executable: do nothing, zero restrictions
|
||||
# Static library: do nothing, zero restrictions
|
||||
# Dynamic library:
|
||||
# -> Wanting to extend VTK-m and provide these types to consumers. This
|
||||
# is supported when CUDA isn't enabled. Otherwise we need to ERROR!
|
||||
# -> Wanting to use VTK-m as implementation detail, doesn't expose VTK-m
|
||||
# types to consumers. This is supported no matter if CUDA is enabled.
|
||||
# -> Wanting to extend VTK-m and provide these types to consumers.
|
||||
# This is only supported when CUDA isn't enabled. Otherwise we need to ERROR!
|
||||
# -> Wanting to pass known VTK-m types across library boundaries for others
|
||||
# to use in filters/worklets.
|
||||
# This is only supported when CUDA isn't enabled. Otherwise we need to ERROR!
|
||||
#
|
||||
# For most consumers they can ignore the `EXTENDS_VTKM` property as the default
|
||||
# will be correct.
|
||||
@ -203,9 +207,9 @@ function(vtkm_add_target_information uses_vtkm_target)
|
||||
# dynamic library boundaries.
|
||||
if(TARGET vtkm::cuda)
|
||||
get_target_property(lib_type ${uses_vtkm_target} TYPE)
|
||||
get_target_property(requires_static vtkm::cuda INTERFACE_REQUIRES_STATIC_BUILDS)
|
||||
get_target_property(requires_static vtkm::cuda requires_static_builds)
|
||||
|
||||
if(requires_static AND ${lib_type} STREQUAL "SHARED_LIBRARY")
|
||||
if(requires_static AND ${lib_type} STREQUAL "SHARED_LIBRARY" AND VTKm_TI_EXTENDS_VTKM)
|
||||
#We provide different error messages based on if we are building VTK-m
|
||||
#or being called by a consumer of VTK-m. We use PROJECT_NAME so that we
|
||||
#produce the correct error message when VTK-m is a subdirectory include
|
||||
@ -277,6 +281,7 @@ function(vtkm_library)
|
||||
${VTKm_LIB_DEVICE_SOURCES}
|
||||
)
|
||||
vtkm_add_target_information(${lib_name}
|
||||
EXTENDS_VTKM
|
||||
DEVICE_SOURCES ${VTKm_LIB_DEVICE_SOURCES}
|
||||
)
|
||||
if(NOT VTKm_USE_DEFAULT_SYMBOL_VISIBILITY)
|
||||
|
@ -56,7 +56,7 @@ function(vtkm_unit_tests)
|
||||
set(test_prog)
|
||||
|
||||
|
||||
set(per_device_command_line_arguments "")
|
||||
set(per_device_command_line_arguments "NONE")
|
||||
set(per_device_suffix "")
|
||||
set(per_device_timeout 180)
|
||||
set(per_device_serial FALSE)
|
||||
@ -65,7 +65,6 @@ function(vtkm_unit_tests)
|
||||
if(enable_all_backends)
|
||||
set(per_device_command_line_arguments --device=serial)
|
||||
set(per_device_suffix "SERIAL")
|
||||
|
||||
if (VTKm_ENABLE_CUDA)
|
||||
list(APPEND per_device_command_line_arguments --device=cuda)
|
||||
list(APPEND per_device_suffix "CUDA")
|
||||
@ -131,8 +130,14 @@ function(vtkm_unit_tests)
|
||||
|
||||
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_UT_LIBRARIES})
|
||||
|
||||
foreach(index RANGE per_device_command_line_arguments)
|
||||
if(per_device_command_line_arguments STREQUAL "")
|
||||
list(LENGTH per_device_command_line_arguments number_of_devices)
|
||||
foreach(index RANGE ${number_of_devices})
|
||||
if(index EQUAL number_of_devices)
|
||||
#RANGE is inclusive on both sides, and we want it to be
|
||||
#exclusive on the end ( e.g. for(i=0; i < n; ++i))
|
||||
break()
|
||||
endif()
|
||||
if(per_device_command_line_arguments STREQUAL "NONE")
|
||||
set(device_command_line_argument ${per_device_command_line_arguments})
|
||||
set(upper_backend ${per_device_suffix})
|
||||
set(timeout ${per_device_timeout})
|
||||
|
3
data/magField.vtk
Normal file
3
data/magField.vtk
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b947d66dbae99a1ebb392b200a9ea0d380cfccb7fcb3a3739615d0dde558d2f1
|
||||
size 238166
|
8
docs/changelog/cellsets-dont-have-names.md
Normal file
8
docs/changelog/cellsets-dont-have-names.md
Normal file
@ -0,0 +1,8 @@
|
||||
# CellSets now don't have a name
|
||||
|
||||
The requirement that `vtkm::cont::CellSets` have a name was so
|
||||
cell based `vtkm::cont::Field`'s could be associated with the
|
||||
correct CellSet in a `vtkm::cont::DataSet`.
|
||||
|
||||
Now that `DataSet`'s don't support multiple CellSets, we can remove
|
||||
the `CellSet` name member variable.
|
@ -1,6 +1,6 @@
|
||||
# DataSet queries for CellSet and Coordinate System Indices don't throw
|
||||
# DataSet queries for CoordinateSystem Indices don't throw
|
||||
|
||||
Asking for the index of a `vtkm::cont::CellSet` or `vtkm::cont::CoordinateSystem` by
|
||||
Asking for the index of a `vtkm::cont::CoordinateSystem` by
|
||||
name now returns a `-1` when no matching item has been found instead of throwing
|
||||
an exception.
|
||||
|
||||
|
29
docs/changelog/dataset-only-single-cellset.md
Normal file
29
docs/changelog/dataset-only-single-cellset.md
Normal file
@ -0,0 +1,29 @@
|
||||
# DataSet only has a single vtkm::cont::CellSet
|
||||
|
||||
Multiple `vtkm::cont::CellSets` on a datasets increased the
|
||||
complexity of using VTK-m correctly without any significant
|
||||
benefits.
|
||||
|
||||
It had the effect that `vtkm::cont::Fields` that representing
|
||||
cell fields needed to be associated with a given cellset. This
|
||||
has to be a loose coupling to allow for filters to generate
|
||||
new output cellsets. At the same time it introduced errors when
|
||||
that output had a different name.
|
||||
|
||||
It raised questions about how should filters propagate cell fields.
|
||||
Should a filter drop all cell fields not associated with the active
|
||||
CellSet, or is that too aggressive given the fact that maybe the
|
||||
algorithm just mistakenly named the field, or the IO routine added
|
||||
a field with the wrong cellset name.
|
||||
|
||||
It increased the complexity of filters, as the developer needed to
|
||||
determine if the algorithm should support execution on a single `CellSet` or
|
||||
execution over all `CellSets`.
|
||||
|
||||
Given these issues it was deemed that removing multiple `CellSets` was
|
||||
the correct way forward. People using multiple `CellSets` will need to
|
||||
move over to `vtkm::cont::MultiBlock` which supports shared points and
|
||||
fields between multiple blocks.
|
||||
|
||||
|
||||
|
5
docs/changelog/field-no-cellset-name-required.md
Normal file
5
docs/changelog/field-no-cellset-name-required.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Fields now don't require the associated CellSet name
|
||||
|
||||
Now that `vtkm::cont::DataSet` can only have a single `vtkm::cont::CellSet`
|
||||
the requirement that cell based `vtkm::cont::Field`s need a CellSet name
|
||||
has been lifted.
|
@ -1,6 +0,0 @@
|
||||
# FilterField now tries to be smart when selecting active cellset
|
||||
|
||||
Now when a calls a `vtkm::filter::FilterField` algorithm without an explicit
|
||||
active CellSet, if the field is cell based we set the active `vtkm::cont::CellSet`
|
||||
to be the one associated with that field. If that `vtkm::cont::CellSet` doesn't
|
||||
exist we default back to using the first CellSet in the input `vtkm::cont::DataSet`.
|
4
docs/changelog/filters-no-active-cellset.md
Normal file
4
docs/changelog/filters-no-active-cellset.md
Normal file
@ -0,0 +1,4 @@
|
||||
# vtkm::cont::Filter now don't have an active cell set
|
||||
|
||||
`vtkm::filter::FilterField` has removed the concept of `ActiveCellSetIndex`. This
|
||||
has been done as `vtkm::cont::DataSet` now only contains a single `vtkm::cont::CellSet`.
|
19
docs/changelog/fix-polygon-gradient.md
Normal file
19
docs/changelog/fix-polygon-gradient.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Fix cell derivatives for polygon cell shape
|
||||
|
||||
For polygon cell shapes (that are not triangles or quadrilaterals),
|
||||
interpolations are done by finding the center point and creating a triangle
|
||||
fan around that point. Previously, the gradient was computed in the same
|
||||
way as interpolation: identifying the correct triangle and computing the
|
||||
gradient for that triangle.
|
||||
|
||||
The problem with that approach is that makes the gradient discontinuous at
|
||||
the boundaries of this implicit triangle fan. To make things worse, this
|
||||
discontinuity happens right at each vertex where gradient calculations
|
||||
happen frequently. This means that when you ask for the gradient at the
|
||||
vertex, you might get wildly different answers based on floating point
|
||||
imprecision.
|
||||
|
||||
Get around this problem by creating a small triangle around the point in
|
||||
question, interpolating values to that triangle, and use that for the
|
||||
gradient. This makes for a smoother gradient transition around these
|
||||
internal boundaries.
|
16
docs/changelog/multiblock_renamed_partitioneddataset.md
Normal file
16
docs/changelog/multiblock_renamed_partitioneddataset.md
Normal file
@ -0,0 +1,16 @@
|
||||
# `MultiBlock` renamed to `PartitionedDataSet`
|
||||
|
||||
The `MultiBlock` class has been renamed to `PartitionedDataSet`, and its API
|
||||
has been refactored to refer to "partitions", rather than "blocks".
|
||||
Additionally, the `AddBlocks` method has been changed to `AppendPartitions` to
|
||||
more accurately reflect the operation performed. The associated
|
||||
`AssignerMultiBlock` class has also been renamed to
|
||||
`AssignerPartitionedDataSet`.
|
||||
|
||||
This change is motivated towards unifying VTK-m's data model with VTK. VTK has
|
||||
started to move away from `vtkMultiBlockDataSet`, which is a hierarchical tree
|
||||
of nested datasets, to `vtkPartitionedDataSet`, which is always a flat vector
|
||||
of datasets used to assist geometry distribution in multi-process environments.
|
||||
This simplifies traversal during processing and clarifies the intent of the
|
||||
container: The component datasets are partitions for distribution, not
|
||||
organizational groupings (e.g. materials).
|
10
docs/changelog/remove-array-portal-shrink.md
Normal file
10
docs/changelog/remove-array-portal-shrink.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Remove ArrayPortalShrink, behavior subsumed by ArrayHandleView
|
||||
|
||||
ArrayPortalShrink originaly allowed a user to pass in a delegate array portal
|
||||
and then shrink the reported array size without actually modifying the
|
||||
underlying allocation. An iterator was also provided that would
|
||||
correctly iterate over the shrunken size of the stored array.
|
||||
|
||||
Instead of directly shrinking the original array, it is prefered
|
||||
to create an ArrayHandleView from an ArrayHandle and then specify the
|
||||
number of values to use in the ArrayHandleView constructor.
|
29
docs/changelog/scan-extended.md
Normal file
29
docs/changelog/scan-extended.md
Normal file
@ -0,0 +1,29 @@
|
||||
# A `ScanExtended` device algorithm has been added.
|
||||
|
||||
This new scan algorithm produces an array that contains both an inclusive scan
|
||||
and an exclusive scan in the same array:
|
||||
|
||||
```
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayGetValue.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleView.h>
|
||||
|
||||
vtkm::cont::ArrayHandle<T> inputData = ...;
|
||||
const vtkm::Id size = inputData.GetNumberOfValues();
|
||||
|
||||
vtkm::cont::ArrayHandle<T> extendedScan;
|
||||
vtkm::cont::Algorithm::ScanExtended(inputData, extendedScan);
|
||||
|
||||
// The exclusive scan is the first `inputSize` values starting at index 0:
|
||||
auto exclusiveScan = vtkm::cont::make_ArrayHandleView(extendedScan, 0, size);
|
||||
|
||||
// The inclusive scan is the first `inputSize` values starting at index 1:
|
||||
auto inclusiveScan = vtkm::cont::make_ArrayHandleView(extendedScan, 1, size);
|
||||
|
||||
// The total sum of the input data is the last value in the extended scan.
|
||||
const T totalSum = vtkm::cont::ArrayGetValue(size, extendedScan);
|
||||
```
|
||||
|
||||
This can also be thought of as an exclusive scan that appends the total sum,
|
||||
rather than returning it.
|
@ -115,7 +115,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> colors;
|
||||
|
||||
//get the coordinate system we are using for the 2D area
|
||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
|
||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||
|
||||
//get the previous state of the game
|
||||
input.GetField("state", vtkm::cont::Field::Association::POINTS).GetData().CopyTo(prevstate);
|
||||
@ -126,15 +126,10 @@ public:
|
||||
|
||||
//save the results
|
||||
vtkm::cont::DataSet output;
|
||||
output.AddCellSet(input.GetCellSet(this->GetActiveCellSetIndex()));
|
||||
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
||||
|
||||
vtkm::cont::Field colorField("colors", vtkm::cont::Field::Association::POINTS, colors);
|
||||
output.AddField(colorField);
|
||||
|
||||
vtkm::cont::Field stateField("state", vtkm::cont::Field::Association::POINTS, state);
|
||||
output.AddField(stateField);
|
||||
output.CopyStructure(input);
|
||||
|
||||
output.AddField(vtkm::cont::make_FieldPoint("colors", colors));
|
||||
output.AddField(vtkm::cont::make_FieldPoint("state", state));
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -206,7 +201,7 @@ struct RenderGameOfLife
|
||||
void render(vtkm::cont::DataSet& data)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
vtkm::Int32 arraySize = (vtkm::Int32)data.GetCoordinateSystem().GetNumberOfPoints();
|
||||
vtkm::Int32 arraySize = (vtkm::Int32)data.GetNumberOfPoints();
|
||||
|
||||
UploadData task(&this->ColorState,
|
||||
data.GetField("colors", vtkm::cont::Field::Association::POINTS));
|
||||
|
@ -80,18 +80,18 @@ int main(int argc, char* argv[])
|
||||
const vtkm::Id num_bins = static_cast<vtkm::Id>(std::atoi(argv[1]));
|
||||
const vtkm::Id numVals = 1024;
|
||||
|
||||
vtkm::cont::MultiBlock mb;
|
||||
vtkm::cont::PartitionedDataSet pds;
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::DataSetFieldAdd::AddPointField(ds, "pointvar", CreateArray(-1024, 1024, numVals));
|
||||
mb.AddBlock(ds);
|
||||
pds.AppendPartition(ds);
|
||||
|
||||
example::HistogramMPI histogram;
|
||||
histogram.SetActiveField("pointvar");
|
||||
histogram.SetNumberOfBins(std::max<vtkm::Id>(1, num_bins));
|
||||
vtkm::cont::MultiBlock result = histogram.Execute(mb);
|
||||
vtkm::cont::PartitionedDataSet result = histogram.Execute(pds);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> bins;
|
||||
result.GetBlock(0).GetField("histogram").GetData().CopyTo(bins);
|
||||
result.GetPartition(0).GetField("histogram").GetData().CopyTo(bins);
|
||||
auto binPortal = bins.GetPortalConstControl();
|
||||
if (rank == 0)
|
||||
{
|
||||
|
@ -65,16 +65,16 @@ public:
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
||||
|
||||
//@{
|
||||
/// when operating on vtkm::cont::MultiBlock, we
|
||||
/// when operating on vtkm::cont::PartitionedDataSet, we
|
||||
/// want to do processing across ranks as well. Just adding pre/post handles
|
||||
/// for the same does the trick.
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT void PreExecute(const vtkm::cont::MultiBlock& input,
|
||||
VTKM_CONT void PreExecute(const vtkm::cont::PartitionedDataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT void PostExecute(const vtkm::cont::MultiBlock& input,
|
||||
vtkm::cont::MultiBlock& output,
|
||||
VTKM_CONT void PostExecute(const vtkm::cont::PartitionedDataSet& input,
|
||||
vtkm::cont::PartitionedDataSet& output,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>&);
|
||||
//@}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
#include <vtkm/cont/AssignerMultiBlock.h>
|
||||
#include <vtkm/cont/AssignerPartitionedDataSet.h>
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/FieldRangeGlobalCompute.h>
|
||||
@ -143,7 +143,7 @@ inline VTKM_CONT vtkm::cont::DataSet HistogramMPI::DoExecute(
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT void HistogramMPI::PreExecute(const vtkm::cont::MultiBlock& input,
|
||||
inline VTKM_CONT void HistogramMPI::PreExecute(const vtkm::cont::PartitionedDataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
||||
{
|
||||
if (this->Range.IsNonEmpty())
|
||||
@ -164,15 +164,15 @@ inline VTKM_CONT void HistogramMPI::PreExecute(const vtkm::cont::MultiBlock& inp
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT void HistogramMPI::PostExecute(const vtkm::cont::MultiBlock&,
|
||||
vtkm::cont::MultiBlock& result,
|
||||
inline VTKM_CONT void HistogramMPI::PostExecute(const vtkm::cont::PartitionedDataSet&,
|
||||
vtkm::cont::PartitionedDataSet& result,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>&)
|
||||
{
|
||||
// iterate and compute HistogramMPI for each local block.
|
||||
detail::DistributedHistogram helper(result.GetNumberOfBlocks());
|
||||
for (vtkm::Id cc = 0; cc < result.GetNumberOfBlocks(); ++cc)
|
||||
detail::DistributedHistogram helper(result.GetNumberOfPartitions());
|
||||
for (vtkm::Id cc = 0; cc < result.GetNumberOfPartitions(); ++cc)
|
||||
{
|
||||
auto& ablock = result.GetBlock(cc);
|
||||
auto& ablock = result.GetPartition(cc);
|
||||
helper.SetLocalHistogram(cc, ablock.GetField(this->GetOutputFieldName()));
|
||||
}
|
||||
|
||||
@ -182,6 +182,6 @@ inline VTKM_CONT void HistogramMPI::PostExecute(const vtkm::cont::MultiBlock&,
|
||||
helper.ReduceAll(this->NumberOfBins));
|
||||
output.AddField(rfield);
|
||||
|
||||
result = vtkm::cont::MultiBlock(output);
|
||||
result = vtkm::cont::PartitionedDataSet(output);
|
||||
}
|
||||
} // namespace example
|
||||
|
@ -194,7 +194,7 @@ inline vtkm::cont::DataSet Make3DExplicitDataSet()
|
||||
conn.push_back(7);
|
||||
conn.push_back(2);
|
||||
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
@ -51,46 +51,47 @@ vtkm::cont::DataSet make_test3DImageData(vtkm::Id3 dims)
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
void io_generator(TaskQueue<vtkm::cont::MultiBlock>& queue, std::size_t numberOfTasks)
|
||||
void io_generator(TaskQueue<vtkm::cont::PartitionedDataSet>& queue, std::size_t numberOfTasks)
|
||||
{
|
||||
//Step 1. We want to build an initial set of blocks
|
||||
//Step 1. We want to build an initial set of partitions
|
||||
//that vary in size. This way we can generate uneven
|
||||
//work to show off the vtk-m filter work distribution
|
||||
vtkm::Id3 small(128, 128, 128);
|
||||
vtkm::Id3 medium(256, 256, 128);
|
||||
vtkm::Id3 large(512, 256, 128);
|
||||
|
||||
std::vector<vtkm::Id3> block_sizes;
|
||||
block_sizes.push_back(small);
|
||||
block_sizes.push_back(medium);
|
||||
block_sizes.push_back(large);
|
||||
std::vector<vtkm::Id3> partition_sizes;
|
||||
partition_sizes.push_back(small);
|
||||
partition_sizes.push_back(medium);
|
||||
partition_sizes.push_back(large);
|
||||
|
||||
|
||||
std::mt19937 rng;
|
||||
//uniform_int_distribution is a closed interval [] so both the min and max
|
||||
//can be chosen values
|
||||
std::uniform_int_distribution<vtkm::Id> blockNumGen(6, 32);
|
||||
std::uniform_int_distribution<std::size_t> blockPicker(0, block_sizes.size() - 1);
|
||||
std::uniform_int_distribution<vtkm::Id> partitionNumGen(6, 32);
|
||||
std::uniform_int_distribution<std::size_t> partitionPicker(0, partition_sizes.size() - 1);
|
||||
for (std::size_t i = 0; i < numberOfTasks; ++i)
|
||||
{
|
||||
//Step 2. Construct a random number of blocks
|
||||
const vtkm::Id numberOfBlocks = blockNumGen(rng);
|
||||
//Step 2. Construct a random number of partitions
|
||||
const vtkm::Id numberOfPartitions = partitionNumGen(rng);
|
||||
|
||||
//Step 3. Randomly pick the blocks in the dataset
|
||||
vtkm::cont::MultiBlock mb(numberOfBlocks);
|
||||
for (vtkm::Id b = 0; b < numberOfBlocks; ++b)
|
||||
//Step 3. Randomly pick the partitions in the dataset
|
||||
vtkm::cont::PartitionedDataSet pds(numberOfPartitions);
|
||||
for (vtkm::Id p = 0; p < numberOfPartitions; ++p)
|
||||
{
|
||||
const auto& dims = block_sizes[blockPicker(rng)];
|
||||
auto block = make_test3DImageData(dims);
|
||||
mb.AddBlock(block);
|
||||
const auto& dims = partition_sizes[partitionPicker(rng)];
|
||||
auto partition = make_test3DImageData(dims);
|
||||
pds.AppendPartition(partition);
|
||||
}
|
||||
|
||||
std::cout << "adding multi-block with " << mb.GetNumberOfBlocks() << " blocks" << std::endl;
|
||||
std::cout << "adding partitioned dataset with " << pds.GetNumberOfPartitions() << " partitions"
|
||||
<< std::endl;
|
||||
|
||||
//Step 4. Add the multi-block to the queue. We explicitly
|
||||
//Step 4. Add the partitioned dataset to the queue. We explicitly
|
||||
//use std::move to signal that this thread can't use the
|
||||
//mb object after this call
|
||||
queue.push(std::move(mb));
|
||||
//pds object after this call
|
||||
queue.push(std::move(pds));
|
||||
|
||||
//Step 5. Go to sleep for a period of time to replicate
|
||||
//data stream in
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
#include "TaskQueue.h"
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
vtkm::cont::DataSet make_test3DImageData(int xdim, int ydim, int zdim);
|
||||
void io_generator(TaskQueue<vtkm::cont::MultiBlock>& queue, std::size_t numberOfTasks);
|
||||
void io_generator(TaskQueue<vtkm::cont::PartitionedDataSet>& queue, std::size_t numberOfTasks);
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <thread>
|
||||
|
||||
#include <vtkm/cont/Initialize.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
#include "IOGenerator.h"
|
||||
#include "MultiDeviceGradient.h"
|
||||
@ -22,9 +22,9 @@
|
||||
//
|
||||
//At a high level we have 2 primary threads, an IO thread and a Worker thread
|
||||
//The IO thread will generate all data using the vtk-m serial device, and
|
||||
//will post this data to a worker queue as a vtk-m multiblock.
|
||||
//The Worker thread will pull down these vtk-m multiblock data and run a
|
||||
//vtk-m filter on the multiblock.
|
||||
//will post this data to a worker queue as a vtk-m partitioned dataset.
|
||||
//The Worker thread will pull down these vtk-m data and run a
|
||||
//vtk-m filter on the partitions.
|
||||
//The vtk-m filter it runs will itself have a worker pool which it will
|
||||
//distribute work too. The number of workers is based on what device adapters
|
||||
//are enabled but uses the following logic:
|
||||
@ -38,7 +38,7 @@
|
||||
//and single GPU we should expect that we will have 2 primary 'main loop'
|
||||
//threads, and 5 threads for heavy 'task' work.
|
||||
|
||||
void multiblock_processing(TaskQueue<vtkm::cont::MultiBlock>& queue);
|
||||
void partition_processing(TaskQueue<vtkm::cont::PartitionedDataSet>& queue);
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
auto opts =
|
||||
@ -48,9 +48,9 @@ int main(int argc, char** argv)
|
||||
//Step 1. Construct the two primary 'main loops'. The threads
|
||||
//share a queue object so we need to explicitly pass it
|
||||
//by reference (the std::ref call)
|
||||
TaskQueue<vtkm::cont::MultiBlock> queue;
|
||||
TaskQueue<vtkm::cont::PartitionedDataSet> queue;
|
||||
std::thread io(io_generator, std::ref(queue), 6);
|
||||
std::thread worker(multiblock_processing, std::ref(queue));
|
||||
std::thread worker(partition_processing, std::ref(queue));
|
||||
|
||||
//Step N. Wait for the work to finish
|
||||
io.join();
|
||||
@ -59,7 +59,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
void multiblock_processing(TaskQueue<vtkm::cont::MultiBlock>& queue)
|
||||
void partition_processing(TaskQueue<vtkm::cont::PartitionedDataSet>& queue)
|
||||
{
|
||||
//Step 1. Construct the gradient filter outside the work loop
|
||||
//so that we can reuse the thread pool it constructs
|
||||
@ -67,42 +67,37 @@ void multiblock_processing(TaskQueue<vtkm::cont::MultiBlock>& queue)
|
||||
gradient.SetComputePointGradient(true);
|
||||
while (queue.hasTasks())
|
||||
{
|
||||
//Step 2. grab the next multi-block skipping any that are empty
|
||||
//Step 2. grab the next partition skipping any that are empty
|
||||
//as empty ones can be returned when the queue is about
|
||||
//to say it has no work
|
||||
vtkm::cont::MultiBlock mb = queue.pop();
|
||||
if (mb.GetNumberOfBlocks() == 0)
|
||||
vtkm::cont::PartitionedDataSet pds = queue.pop();
|
||||
if (pds.GetNumberOfPartitions() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Step 3. Get the first field name from the multi-block
|
||||
std::string fieldName = mb.GetBlock(0).GetField(0).GetName();
|
||||
//Step 3. Get the first field name from the partition
|
||||
std::string fieldName = pds.GetPartition(0).GetField(0).GetName();
|
||||
|
||||
//Step 4. Run a multi device gradient
|
||||
gradient.SetActiveField(fieldName);
|
||||
vtkm::cont::MultiBlock result = gradient.Execute(mb);
|
||||
std::cout << "finished processing a multi-block" << std::endl;
|
||||
vtkm::cont::PartitionedDataSet result = gradient.Execute(pds);
|
||||
std::cout << "finished processing a partitioned dataset" << std::endl;
|
||||
|
||||
//Step 5. Verify each block has a "Gradients" field
|
||||
for (auto&& block : result)
|
||||
//Step 5. Verify each partition has a "Gradients" field
|
||||
for (auto&& partition : result)
|
||||
{
|
||||
// std::cout << std::endl << std::endl << std::endl;
|
||||
// std::cout << "block: " << std::endl;
|
||||
// block.PrintSummary(std::cout);
|
||||
try
|
||||
{
|
||||
const auto& field = block.GetField("Gradients", vtkm::cont::Field::Association::POINTS);
|
||||
(void)field;
|
||||
}
|
||||
catch (const vtkm::cont::ErrorBadValue& error)
|
||||
// std::cout << "partition: " << std::endl;
|
||||
// partition.PrintSummary(std::cout);
|
||||
if (!partition.HasField("Gradients", vtkm::cont::Field::Association::POINTS))
|
||||
{
|
||||
std::cerr << "Gradient filter failed!" << std::endl;
|
||||
std::cerr << error.GetMessage() << std::endl;
|
||||
std::cerr << "Missing Gradient field on output partition." << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "multiblock_processing finished" << std::endl;
|
||||
std::cout << "partition_processing finished" << std::endl;
|
||||
}
|
||||
|
@ -13,6 +13,6 @@
|
||||
#include "MultiDeviceGradient.h"
|
||||
#include "MultiDeviceGradient.hxx"
|
||||
|
||||
template vtkm::cont::MultiBlock MultiDeviceGradient::PrepareForExecution<
|
||||
vtkm::filter::PolicyDefault>(const vtkm::cont::MultiBlock&,
|
||||
template vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForExecution<
|
||||
vtkm::filter::PolicyDefault>(const vtkm::cont::PartitionedDataSet&,
|
||||
const vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>&);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
using RuntimeTaskQueue = TaskQueue<std::function<void()>>;
|
||||
|
||||
/// \brief Construct a MultiDeviceGradient for a given multiblock dataset
|
||||
/// \brief Construct a MultiDeviceGradient for a given partitioned dataset
|
||||
///
|
||||
/// The Policy used with MultiDeviceGradient must include the TBB and CUDA
|
||||
/// backends.
|
||||
@ -45,8 +45,8 @@ public:
|
||||
/// Will submit each block to a work queue that the threads will
|
||||
/// pull work from
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::MultiBlock PrepareForExecution(
|
||||
const vtkm::cont::MultiBlock&,
|
||||
VTKM_CONT vtkm::cont::PartitionedDataSet PrepareForExecution(
|
||||
const vtkm::cont::PartitionedDataSet&,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>&);
|
||||
|
||||
private:
|
||||
@ -56,8 +56,8 @@ private:
|
||||
};
|
||||
|
||||
#ifndef vtk_m_examples_multibackend_MultiDeviceGradient_cxx
|
||||
extern template vtkm::cont::MultiBlock MultiDeviceGradient::PrepareForExecution<
|
||||
vtkm::filter::PolicyDefault>(const vtkm::cont::MultiBlock&,
|
||||
extern template vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForExecution<
|
||||
vtkm::filter::PolicyDefault>(const vtkm::cont::PartitionedDataSet&,
|
||||
const vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>&);
|
||||
#endif
|
||||
|
||||
|
@ -32,7 +32,7 @@ int determine_cuda_gpu_count()
|
||||
return count;
|
||||
}
|
||||
|
||||
void process_block_tbb(RuntimeTaskQueue& queue)
|
||||
void process_partition_tbb(RuntimeTaskQueue& queue)
|
||||
{
|
||||
//Step 1. Set the device adapter to this thread to TBB.
|
||||
//This makes sure that any vtkm::filters used by our
|
||||
@ -56,11 +56,11 @@ void process_block_tbb(RuntimeTaskQueue& queue)
|
||||
|
||||
//Step 4. Notify the queue that we finished processing this task
|
||||
queue.completedTask();
|
||||
std::cout << "finished a block on tbb (" << std::this_thread::get_id() << ")" << std::endl;
|
||||
std::cout << "finished a partition on tbb (" << std::this_thread::get_id() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void process_block_openMP(RuntimeTaskQueue& queue)
|
||||
void process_partition_openMP(RuntimeTaskQueue& queue)
|
||||
{
|
||||
//Step 1. Set the device adapter to this thread to TBB.
|
||||
//This makes sure that any vtkm::filters used by our
|
||||
@ -84,11 +84,11 @@ void process_block_openMP(RuntimeTaskQueue& queue)
|
||||
|
||||
//Step 4. Notify the queue that we finished processing this task
|
||||
queue.completedTask();
|
||||
std::cout << "finished a block on tbb (" << std::this_thread::get_id() << ")" << std::endl;
|
||||
std::cout << "finished a partition on tbb (" << std::this_thread::get_id() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void process_block_cuda(RuntimeTaskQueue& queue, int gpuId)
|
||||
void process_partition_cuda(RuntimeTaskQueue& queue, int gpuId)
|
||||
{
|
||||
//Step 1. Set the device adapter to this thread to cuda.
|
||||
//This makes sure that any vtkm::filters used by our
|
||||
@ -113,7 +113,7 @@ void process_block_cuda(RuntimeTaskQueue& queue, int gpuId)
|
||||
|
||||
//Step 4. Notify the queue that we finished processing this task
|
||||
queue.completedTask();
|
||||
std::cout << "finished a block on cuda (" << std::this_thread::get_id() << ")" << std::endl;
|
||||
std::cout << "finished a partition on cuda (" << std::this_thread::get_id() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,10 +149,10 @@ VTKM_CONT MultiDeviceGradient::MultiDeviceGradient()
|
||||
//The number of workers per GPU is purely arbitrary currently,
|
||||
//but in general we want multiple of them so we can overlap compute
|
||||
//and transfer
|
||||
this->Workers.emplace_back(std::bind(process_block_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_block_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_block_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_block_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_partition_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_partition_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_partition_cuda, std::ref(this->Queue), i));
|
||||
this->Workers.emplace_back(std::bind(process_partition_cuda, std::ref(this->Queue), i));
|
||||
}
|
||||
}
|
||||
//Step 3. Launch a worker that will use openMP (if enabled).
|
||||
@ -161,7 +161,7 @@ VTKM_CONT MultiDeviceGradient::MultiDeviceGradient()
|
||||
else if (runOnOpenMP)
|
||||
{
|
||||
std::cout << "adding a openMP worker" << std::endl;
|
||||
this->Workers.emplace_back(std::bind(process_block_openMP, std::ref(this->Queue)));
|
||||
this->Workers.emplace_back(std::bind(process_partition_openMP, std::ref(this->Queue)));
|
||||
}
|
||||
//Step 4. Launch a worker that will use tbb (if enabled).
|
||||
//The threads share a queue object so we need to explicitly pass it
|
||||
@ -169,7 +169,7 @@ VTKM_CONT MultiDeviceGradient::MultiDeviceGradient()
|
||||
else if (runOnTbb)
|
||||
{
|
||||
std::cout << "adding a tbb worker" << std::endl;
|
||||
this->Workers.emplace_back(std::bind(process_block_tbb, std::ref(this->Queue)));
|
||||
this->Workers.emplace_back(std::bind(process_partition_tbb, std::ref(this->Queue)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,49 +187,50 @@ VTKM_CONT MultiDeviceGradient::~MultiDeviceGradient()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::MultiBlock MultiDeviceGradient::PrepareForExecution(
|
||||
const vtkm::cont::MultiBlock& mb,
|
||||
inline VTKM_CONT vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForExecution(
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
||||
{
|
||||
//Step 1. Say that we have no more to submit for this multi block
|
||||
//Step 1. Say that we have no more to submit for this PartitionedDataSet
|
||||
//This is needed to happen for each execute as we want to support
|
||||
//the same filter being used for multiple inputs
|
||||
this->Queue.reset();
|
||||
|
||||
//Step 2. Construct the multi-block we are going to fill. The size signature
|
||||
//to MultiBlock just reserves size
|
||||
vtkm::cont::MultiBlock output;
|
||||
output.AddBlocks(std::vector<vtkm::cont::DataSet>(static_cast<size_t>(mb.GetNumberOfBlocks())));
|
||||
vtkm::cont::MultiBlock* outPtr = &output;
|
||||
//Step 2. Construct the PartitionedDataSet we are going to fill. The size
|
||||
//signature to PartitionedDataSet just reserves size
|
||||
vtkm::cont::PartitionedDataSet output;
|
||||
output.AppendPartitions(
|
||||
std::vector<vtkm::cont::DataSet>(static_cast<size_t>(pds.GetNumberOfPartitions())));
|
||||
vtkm::cont::PartitionedDataSet* outPtr = &output;
|
||||
|
||||
|
||||
//Step 3. Construct the filter we want to run on each block
|
||||
//Step 3. Construct the filter we want to run on each partition
|
||||
vtkm::filter::Gradient gradient;
|
||||
gradient.SetComputePointGradient(this->GetComputePointGradient());
|
||||
gradient.SetActiveField(this->GetActiveFieldName());
|
||||
|
||||
//Step 3b. Post 1 block up as work and block intil it is
|
||||
//Step 3b. Post 1 partition up as work and block until it is
|
||||
//complete. This is needed as currently constructing the virtual
|
||||
//Point Coordinates is not thread safe.
|
||||
auto block = mb.cbegin();
|
||||
auto partition = pds.cbegin();
|
||||
{
|
||||
vtkm::cont::DataSet input = *block;
|
||||
vtkm::cont::DataSet input = *partition;
|
||||
this->Queue.push( //build a lambda that is the work to do
|
||||
[=]() {
|
||||
vtkm::filter::Gradient perThreadGrad = gradient;
|
||||
|
||||
vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy);
|
||||
outPtr->ReplaceBlock(0, result);
|
||||
outPtr->ReplacePartition(0, result);
|
||||
});
|
||||
this->Queue.waitForAllTasksToComplete();
|
||||
block++;
|
||||
partition++;
|
||||
}
|
||||
|
||||
vtkm::Id index = 1;
|
||||
for (; block != mb.cend(); ++block)
|
||||
for (; partition != pds.cend(); ++partition)
|
||||
{
|
||||
vtkm::cont::DataSet input = *block;
|
||||
//Step 4. For each input block construct a lambda
|
||||
vtkm::cont::DataSet input = *partition;
|
||||
//Step 4. For each input partition construct a lambda
|
||||
//and add it to the queue for workers to take. This
|
||||
//will allows us to have multiple works execute in a non
|
||||
//blocking manner
|
||||
@ -238,7 +239,7 @@ inline VTKM_CONT vtkm::cont::MultiBlock MultiDeviceGradient::PrepareForExecution
|
||||
vtkm::filter::Gradient perThreadGrad = gradient;
|
||||
|
||||
vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy);
|
||||
outPtr->ReplaceBlock(index, result);
|
||||
outPtr->ReplacePartition(index, result);
|
||||
});
|
||||
index++;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#ifndef vtk_m_examples_multibackend_TaskQueue_h
|
||||
#define vtk_m_examples_multibackend_TaskQueue_h
|
||||
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
@ -9,297 +9,76 @@
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/Initialize.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
#include <vtkm/filter/Streamline.h>
|
||||
#include <vtkm/io/reader/VTKDataSetReader.h>
|
||||
#include <vtkm/io/writer/VTKDataSetWriter.h>
|
||||
|
||||
#include <vtkm/worklet/ParticleAdvection.h>
|
||||
#include <vtkm/worklet/particleadvection/GridEvaluators.h>
|
||||
#include <vtkm/worklet/particleadvection/Integrators.h>
|
||||
#include <vtkm/worklet/particleadvection/ParticleAdvectionWorklets.h>
|
||||
#include <vtkm/worklet/particleadvection/Particles.h>
|
||||
|
||||
#include <vtkm/io/reader/BOVDataSetReader.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
|
||||
#ifdef BUILDING_TBB_VERSION
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
#endif
|
||||
|
||||
const vtkm::Id SPARSE = 0;
|
||||
const vtkm::Id DENSE = 1;
|
||||
const vtkm::Id MEDIUM = 2;
|
||||
|
||||
template <typename T>
|
||||
static vtkm::Range subRange(vtkm::Range& range, T a, T b)
|
||||
{
|
||||
vtkm::Float32 arg1, arg2, len;
|
||||
arg1 = static_cast<vtkm::Float32>(a);
|
||||
arg2 = static_cast<vtkm::Float32>(b);
|
||||
len = static_cast<vtkm::Float32>(range.Length());
|
||||
return vtkm::Range(range.Min + arg1 * len, range.Min + arg2 * len);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ignore(T&&)
|
||||
{
|
||||
}
|
||||
|
||||
void RunTest(const std::string& fname,
|
||||
vtkm::Id numSeeds,
|
||||
vtkm::Id numSteps,
|
||||
vtkm::Float32 stepSize,
|
||||
vtkm::Id numThreads,
|
||||
vtkm::Id advectType,
|
||||
vtkm::Id seeding)
|
||||
{
|
||||
using FieldType = vtkm::Float32;
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>>;
|
||||
|
||||
vtkm::io::reader::BOVDataSetReader rdr(fname);
|
||||
vtkm::cont::DataSet ds = rdr.ReadDataSet();
|
||||
|
||||
using RGEvalType = vtkm::worklet::particleadvection::GridEvaluator<FieldHandle>;
|
||||
using RK4RGType = vtkm::worklet::particleadvection::RK4Integrator<RGEvalType>;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> fieldArray;
|
||||
ds.GetField(0).GetData().CopyTo(fieldArray);
|
||||
|
||||
RGEvalType eval(ds.GetCoordinateSystem(), ds.GetCellSet(0), fieldArray);
|
||||
RK4RGType rk4(eval, stepSize);
|
||||
|
||||
std::vector<vtkm::Vec<FieldType, 3>> seeds;
|
||||
srand(314);
|
||||
|
||||
vtkm::Bounds bounds = ds.GetCoordinateSystem().GetBounds();
|
||||
if (seeding == SPARSE)
|
||||
bounds = ds.GetCoordinateSystem().GetBounds();
|
||||
else if (seeding == DENSE)
|
||||
{
|
||||
if (fname.find("astro") != std::string::npos)
|
||||
{
|
||||
bounds.X = subRange(bounds.X, .1, .15);
|
||||
bounds.Y = subRange(bounds.Y, .1, .15);
|
||||
bounds.Z = subRange(bounds.Z, .1, .15);
|
||||
}
|
||||
else if (fname.find("fusion") != std::string::npos)
|
||||
{
|
||||
bounds.X = subRange(bounds.X, .8, .85);
|
||||
bounds.Y = subRange(bounds.Y, .55, .60);
|
||||
bounds.Z = subRange(bounds.Z, .55, .60);
|
||||
}
|
||||
else if (fname.find("fishtank") != std::string::npos)
|
||||
{
|
||||
bounds.X = subRange(bounds.X, .1, .15);
|
||||
bounds.Y = subRange(bounds.Y, .1, .15);
|
||||
bounds.Z = subRange(bounds.Z, .55, .60);
|
||||
}
|
||||
}
|
||||
else if (seeding == MEDIUM)
|
||||
{
|
||||
if (fname.find("astro") != std::string::npos)
|
||||
{
|
||||
bounds.X = subRange(bounds.X, .4, .6);
|
||||
bounds.Y = subRange(bounds.Y, .4, .6);
|
||||
bounds.Z = subRange(bounds.Z, .4, .6);
|
||||
}
|
||||
else if (fname.find("fusion") != std::string::npos)
|
||||
{
|
||||
bounds.X = subRange(bounds.X, .01, .99);
|
||||
bounds.Y = subRange(bounds.Y, .01, .99);
|
||||
bounds.Z = subRange(bounds.Z, .45, .55);
|
||||
}
|
||||
else if (fname.find("fishtank") != std::string::npos)
|
||||
{
|
||||
bounds.X = subRange(bounds.X, .4, .6);
|
||||
bounds.Y = subRange(bounds.Y, .4, .6);
|
||||
bounds.Z = subRange(bounds.Z, .4, .6);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < numSeeds; i++)
|
||||
{
|
||||
vtkm::Vec<FieldType, 3> p;
|
||||
vtkm::Float32 rx = (vtkm::Float32)rand() / (vtkm::Float32)RAND_MAX;
|
||||
vtkm::Float32 ry = (vtkm::Float32)rand() / (vtkm::Float32)RAND_MAX;
|
||||
vtkm::Float32 rz = (vtkm::Float32)rand() / (vtkm::Float32)RAND_MAX;
|
||||
p[0] = static_cast<FieldType>(bounds.X.Min + rx * bounds.X.Length());
|
||||
p[1] = static_cast<FieldType>(bounds.Y.Min + ry * bounds.Y.Length());
|
||||
p[2] = static_cast<FieldType>(bounds.Z.Min + rz * bounds.Z.Length());
|
||||
seeds.push_back(p);
|
||||
}
|
||||
|
||||
#ifdef BUILDING_TBB_VERSION
|
||||
int nT = tbb::task_scheduler_init::default_num_threads();
|
||||
if (numThreads != -1)
|
||||
nT = (int)numThreads;
|
||||
//make sure the task_scheduler_init object is in scope when running sth w/ TBB
|
||||
tbb::task_scheduler_init init(nT);
|
||||
#else
|
||||
ignore(numThreads);
|
||||
#endif
|
||||
|
||||
//time only the actual run
|
||||
auto t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<FieldType, 3>> seedArray;
|
||||
seedArray = vtkm::cont::make_ArrayHandle(seeds);
|
||||
|
||||
if (advectType == 0)
|
||||
{
|
||||
vtkm::worklet::ParticleAdvection particleAdvection;
|
||||
particleAdvection.Run(rk4, seedArray, numSteps);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::Streamline streamline;
|
||||
streamline.Run(rk4, seedArray, numSteps);
|
||||
}
|
||||
|
||||
auto t1 = std::chrono::high_resolution_clock::now() - t0;
|
||||
auto runtime = std::chrono::duration_cast<std::chrono::milliseconds>(t1).count();
|
||||
std::cerr << "Runtime = " << runtime << " ms " << std::endl;
|
||||
}
|
||||
|
||||
bool ParseArgs(int argc,
|
||||
char** argv,
|
||||
const vtkm::cont::InitializeResult& config,
|
||||
vtkm::Id& numSeeds,
|
||||
vtkm::Id& numSteps,
|
||||
vtkm::Float32& stepSize,
|
||||
vtkm::Id& advectType,
|
||||
vtkm::Id& stepsPerRound,
|
||||
vtkm::Id& particlesPerRound,
|
||||
vtkm::Id& numThreads,
|
||||
std::string& dataFile,
|
||||
std::string& pgmType,
|
||||
bool& dumpOutput,
|
||||
vtkm::Id& seeding)
|
||||
{
|
||||
numSeeds = 100;
|
||||
numSteps = 100;
|
||||
stepSize = 0.1f;
|
||||
advectType = 0;
|
||||
stepsPerRound = -1;
|
||||
particlesPerRound = -1;
|
||||
numThreads = -1;
|
||||
dataFile = "";
|
||||
pgmType = config.Device.GetName();
|
||||
dumpOutput = false;
|
||||
seeding = SPARSE;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
std::cerr << "Usage " << argv[0] << std::endl;
|
||||
std::cerr << " -seeds #seeds" << std::endl;
|
||||
std::cerr << " -steps maxSteps" << std::endl;
|
||||
std::cerr << " -h stepSize" << std::endl;
|
||||
std::cerr << " -particle : particle push" << std::endl;
|
||||
std::cerr << " -streamline steps_per_round (-1 = 0 rounds): particle history" << std::endl;
|
||||
std::cerr << " -t #numThreads" << std::endl;
|
||||
std::cerr << " -file dataFile" << std::endl;
|
||||
std::cerr << " -dump : dump output points" << std::endl << std::endl;
|
||||
std::cerr << "General VTK-m Options" << std::endl;
|
||||
std::cerr << config.Usage << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
std::string arg = argv[i];
|
||||
if (arg == "-seeds")
|
||||
numSeeds = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
else if (arg == "-steps")
|
||||
numSteps = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
else if (arg == "-h")
|
||||
stepSize = static_cast<vtkm::Float32>(atof(argv[++i]));
|
||||
else if (arg == "-particle")
|
||||
advectType = 0;
|
||||
else if (arg == "-streamline")
|
||||
{
|
||||
advectType = 1;
|
||||
}
|
||||
else if (arg == "-streamlineS")
|
||||
{
|
||||
advectType = 1;
|
||||
stepsPerRound = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
}
|
||||
else if (arg == "-streamlineP")
|
||||
{
|
||||
advectType = 1;
|
||||
particlesPerRound = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
}
|
||||
else if (arg == "-streamlineSP")
|
||||
{
|
||||
advectType = 1;
|
||||
stepsPerRound = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
particlesPerRound = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
}
|
||||
else if (arg == "-file")
|
||||
dataFile = argv[++i];
|
||||
else if (arg == "-t")
|
||||
numThreads = static_cast<vtkm::Id>(atoi(argv[++i]));
|
||||
else if (arg == "-dump")
|
||||
dumpOutput = true;
|
||||
else if (arg == "-sparse")
|
||||
seeding = SPARSE;
|
||||
else if (arg == "-dense")
|
||||
seeding = DENSE;
|
||||
else if (arg == "-medium")
|
||||
seeding = MEDIUM;
|
||||
else
|
||||
std::cerr << "Unexpected argument: " << arg << std::endl;
|
||||
}
|
||||
|
||||
if (dataFile.size() == 0)
|
||||
{
|
||||
std::cerr << "Error: no data file specified" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Congratulations user, we have a valid run:
|
||||
std::cerr << pgmType << ": " << numSeeds << " " << numSteps << " " << stepSize << " ";
|
||||
if (advectType == 0)
|
||||
std::cerr << "PP ";
|
||||
else
|
||||
std::cerr << "SL ";
|
||||
std::cerr << numThreads << " ";
|
||||
std::cerr << dataFile << std::endl;
|
||||
return true;
|
||||
}
|
||||
// Example computing streamlines.
|
||||
// An example vector field is available in the vtk-m data directory: magField.vtk
|
||||
// Example usage:
|
||||
// this will advect 200 particles 50 steps using a step size of 0.01
|
||||
//
|
||||
// Particle_Advection <path-to-data-dir>/magField.vtk vec 200 50 0.01 output.vtk
|
||||
//
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Process vtk-m general args
|
||||
auto opts = vtkm::cont::InitializeOptions::DefaultAnyDevice;
|
||||
auto config = vtkm::cont::Initialize(argc, argv, opts);
|
||||
|
||||
vtkm::Id numSeeds = 100, numSteps = 100, advectType = 0, numThreads = -1, stepsPerRound = -1,
|
||||
particlesPerRound = -1;
|
||||
vtkm::Float32 stepSize = 0.1f;
|
||||
std::string dataFile, pgmType;
|
||||
vtkm::Id seeding = SPARSE;
|
||||
bool dumpOutput = false;
|
||||
|
||||
if (!ParseArgs(argc,
|
||||
argv,
|
||||
config,
|
||||
numSeeds,
|
||||
numSteps,
|
||||
stepSize,
|
||||
advectType,
|
||||
stepsPerRound,
|
||||
particlesPerRound,
|
||||
numThreads,
|
||||
dataFile,
|
||||
pgmType,
|
||||
dumpOutput,
|
||||
seeding))
|
||||
if (argc != 7)
|
||||
{
|
||||
std::cerr << "Usage: " << argv[0] << " dataFile varName numSeeds numSteps stepSize outputFile"
|
||||
<< std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
RunTest(dataFile, numSeeds, numSteps, stepSize, numThreads, advectType, seeding);
|
||||
std::string dataFile = argv[1];
|
||||
std::string varName = argv[2];
|
||||
vtkm::Id numSeeds = std::stoi(argv[3]);
|
||||
vtkm::Id numSteps = std::stoi(argv[4]);
|
||||
vtkm::FloatDefault stepSize = std::stof(argv[5]);
|
||||
std::string outputFile = argv[6];
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
|
||||
if (dataFile.find(".vtk") != std::string::npos)
|
||||
{
|
||||
vtkm::io::reader::VTKDataSetReader rdr(dataFile);
|
||||
ds = rdr.ReadDataSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unsupported data file: " << dataFile << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//create seeds randomly placed withing the bounding box of the data.
|
||||
vtkm::Bounds bounds = ds.GetCoordinateSystem().GetBounds();
|
||||
std::vector<vtkm::Vec3f> seeds;
|
||||
|
||||
for (int i = 0; i < numSeeds; i++)
|
||||
{
|
||||
vtkm::Vec3f p;
|
||||
vtkm::FloatDefault rx = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX;
|
||||
vtkm::FloatDefault ry = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX;
|
||||
vtkm::FloatDefault rz = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX;
|
||||
p[0] = static_cast<vtkm::FloatDefault>(bounds.X.Min + rx * bounds.X.Length());
|
||||
p[1] = static_cast<vtkm::FloatDefault>(bounds.Y.Min + ry * bounds.Y.Length());
|
||||
p[2] = static_cast<vtkm::FloatDefault>(bounds.Z.Min + rz * bounds.Z.Length());
|
||||
seeds.push_back(p);
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> seedArray = vtkm::cont::make_ArrayHandle(seeds);
|
||||
|
||||
//compute streamlines
|
||||
vtkm::filter::Streamline streamline;
|
||||
|
||||
streamline.SetStepSize(stepSize);
|
||||
streamline.SetNumberOfSteps(numSteps);
|
||||
streamline.SetSeeds(seedArray);
|
||||
|
||||
streamline.SetActiveField(varName);
|
||||
auto output = streamline.Execute(ds);
|
||||
|
||||
vtkm::io::writer::VTKDataSetWriter wrt(outputFile);
|
||||
wrt.WriteDataSet(output);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ void TubeThatSpiral(vtkm::FloatDefault radius, vtkm::Id numLineSegments, vtkm::I
|
||||
// This generates a new pointset, and new cell set.
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> tubePoints;
|
||||
vtkm::cont::CellSetSingleType<> tubeCells;
|
||||
tubeWorklet.Run(ds.GetCoordinateSystem(0), ds.GetCellSet(0), tubePoints, tubeCells);
|
||||
tubeWorklet.Run(ds.GetCoordinateSystem(), ds.GetCellSet(), tubePoints, tubeCells);
|
||||
|
||||
vtkm::cont::DataSet tubeDataset;
|
||||
tubeDataset.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coords", tubePoints));
|
||||
tubeDataset.AddCellSet(tubeCells);
|
||||
tubeDataset.SetCellSet(tubeCells);
|
||||
|
||||
vtkm::Bounds coordsBounds = tubeDataset.GetCoordinateSystem().GetBounds();
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <vtkm/ImplicitFunction.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/AssignerMultiBlock.h>
|
||||
#include <vtkm/cont/AssignerPartitionedDataSet.h>
|
||||
#include <vtkm/cont/BoundsGlobalCompute.h>
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/Serialization.h>
|
||||
@ -204,14 +204,14 @@ public:
|
||||
~RedistributePoints() {}
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::MultiBlock PrepareForExecution(
|
||||
const vtkm::cont::MultiBlock& input,
|
||||
VTKM_CONT vtkm::cont::PartitionedDataSet PrepareForExecution(
|
||||
const vtkm::cont::PartitionedDataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
|
||||
};
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::MultiBlock RedistributePoints::PrepareForExecution(
|
||||
const vtkm::cont::MultiBlock& input,
|
||||
inline VTKM_CONT vtkm::cont::PartitionedDataSet RedistributePoints::PrepareForExecution(
|
||||
const vtkm::cont::PartitionedDataSet& input,
|
||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
||||
{
|
||||
auto comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
|
||||
@ -219,7 +219,7 @@ inline VTKM_CONT vtkm::cont::MultiBlock RedistributePoints::PrepareForExecution(
|
||||
// let's first get the global bounds of the domain
|
||||
vtkm::Bounds gbounds = vtkm::cont::BoundsGlobalCompute(input);
|
||||
|
||||
vtkm::cont::AssignerMultiBlock assigner(input.GetNumberOfBlocks());
|
||||
vtkm::cont::AssignerPartitionedDataSet assigner(input.GetNumberOfPartitions());
|
||||
vtkmdiy::RegularDecomposer<vtkmdiy::ContinuousBounds> decomposer(
|
||||
/*dim*/ 3, internal::convert(gbounds), assigner.nblocks());
|
||||
|
||||
@ -230,19 +230,19 @@ inline VTKM_CONT vtkm::cont::MultiBlock RedistributePoints::PrepareForExecution(
|
||||
[](void* ptr) { delete static_cast<vtkm::cont::DataSet*>(ptr); });
|
||||
decomposer.decompose(comm.rank(), assigner, master);
|
||||
|
||||
assert(static_cast<vtkm::Id>(master.size()) == input.GetNumberOfBlocks());
|
||||
assert(static_cast<vtkm::Id>(master.size()) == input.GetNumberOfPartitions());
|
||||
// let's populate local blocks
|
||||
master.foreach ([&input](vtkm::cont::DataSet* ds, const vtkmdiy::Master::ProxyWithLink& proxy) {
|
||||
auto lid = proxy.master()->lid(proxy.gid());
|
||||
*ds = input.GetBlock(lid);
|
||||
*ds = input.GetPartition(lid);
|
||||
});
|
||||
|
||||
internal::Redistributor<DerivedPolicy> redistributor(decomposer, policy);
|
||||
vtkmdiy::all_to_all(master, assigner, redistributor, /*k=*/2);
|
||||
|
||||
vtkm::cont::MultiBlock result;
|
||||
vtkm::cont::PartitionedDataSet result;
|
||||
master.foreach ([&result](vtkm::cont::DataSet* ds, const vtkmdiy::Master::ProxyWithLink&) {
|
||||
result.AddBlock(*ds);
|
||||
result.AppendPartition(*ds);
|
||||
});
|
||||
|
||||
return result;
|
||||
|
@ -62,11 +62,11 @@ void RunTest(vtkm::Id numSteps, vtkm::Float32 stepSize, vtkm::Id advectType)
|
||||
using Integrator = vtkm::worklet::particleadvection::EulerIntegrator<GridEvaluator>;
|
||||
|
||||
GridEvaluator eval(ds1.GetCoordinateSystem(),
|
||||
ds1.GetCellSet(0),
|
||||
ds1.GetCellSet(),
|
||||
fieldArray1,
|
||||
0,
|
||||
ds2.GetCoordinateSystem(),
|
||||
ds2.GetCellSet(0),
|
||||
ds2.GetCellSet(),
|
||||
fieldArray2,
|
||||
10.0);
|
||||
|
||||
@ -99,7 +99,7 @@ void RunTest(vtkm::Id numSteps, vtkm::Float32 stepSize, vtkm::Id advectType)
|
||||
vtkm::worklet::StreamlineResult res = streamline.Run(integrator, seedArray, numSteps);
|
||||
vtkm::cont::DataSet outData;
|
||||
vtkm::cont::CoordinateSystem outputCoords("coordinates", res.positions);
|
||||
outData.AddCellSet(res.polyLines);
|
||||
outData.SetCellSet(res.polyLines);
|
||||
outData.AddCoordinateSystem(outputCoords);
|
||||
renderAndWriteDataSet(outData);
|
||||
}
|
||||
|
@ -317,6 +317,19 @@ struct ScanExclusiveByKeyFunctor
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ScanExtendedFunctor
|
||||
{
|
||||
template <typename Device, typename... Args>
|
||||
VTKM_CONT bool operator()(Device, Args&&... args)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::ScanExtended(
|
||||
PrepareArgForExec<Device>(std::forward<Args>(args))...);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct ScheduleFunctor
|
||||
{
|
||||
template <typename Device, typename... Args>
|
||||
@ -976,6 +989,42 @@ struct Algorithm
|
||||
}
|
||||
|
||||
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static void ScanExtended(vtkm::cont::DeviceAdapterId devId,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
detail::ScanExtendedFunctor<T> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
|
||||
}
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static void ScanExtended(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
ScanExtended(vtkm::cont::DeviceAdapterTagAny(), input, output);
|
||||
}
|
||||
|
||||
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static void ScanExtended(vtkm::cont::DeviceAdapterId devId,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binaryFunctor,
|
||||
const T& initialValue)
|
||||
{
|
||||
detail::ScanExtendedFunctor<T> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binaryFunctor, initialValue);
|
||||
}
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static void ScanExtended(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binaryFunctor,
|
||||
const T& initialValue)
|
||||
{
|
||||
ScanExtended(vtkm::cont::DeviceAdapterTagAny(), input, output, binaryFunctor, initialValue);
|
||||
}
|
||||
|
||||
|
||||
template <class Functor>
|
||||
VTKM_CONT static void Schedule(vtkm::cont::DeviceAdapterId devId,
|
||||
Functor functor,
|
||||
|
@ -1,80 +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/cont/AssignerMultiBlock.h>
|
||||
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
|
||||
|
||||
#include <vtkm/thirdparty/diy/diy.h>
|
||||
|
||||
#include <algorithm> // std::lower_bound
|
||||
#include <numeric> // std::iota
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
AssignerMultiBlock::AssignerMultiBlock(const vtkm::cont::MultiBlock& mb)
|
||||
: AssignerMultiBlock(mb.GetNumberOfBlocks())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
AssignerMultiBlock::AssignerMultiBlock(vtkm::Id num_blocks)
|
||||
: vtkmdiy::StaticAssigner(vtkm::cont::EnvironmentTracker::GetCommunicator().size(), 1)
|
||||
, IScanBlockCounts()
|
||||
{
|
||||
auto comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
|
||||
if (comm.size() > 1)
|
||||
{
|
||||
vtkm::Id iscan;
|
||||
vtkmdiy::mpi::scan(comm, num_blocks, iscan, std::plus<vtkm::Id>());
|
||||
vtkmdiy::mpi::all_gather(comm, iscan, this->IScanBlockCounts);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->IScanBlockCounts.push_back(num_blocks);
|
||||
}
|
||||
|
||||
this->set_nblocks(static_cast<int>(this->IScanBlockCounts.back()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AssignerMultiBlock::local_gids(int my_rank, std::vector<int>& gids) const
|
||||
{
|
||||
const size_t s_rank = static_cast<size_t>(my_rank);
|
||||
if (my_rank == 0)
|
||||
{
|
||||
assert(this->IScanBlockCounts.size() > 0);
|
||||
gids.resize(static_cast<size_t>(this->IScanBlockCounts[s_rank]));
|
||||
std::iota(gids.begin(), gids.end(), 0);
|
||||
}
|
||||
else if (my_rank > 0 && s_rank < this->IScanBlockCounts.size())
|
||||
{
|
||||
gids.resize(
|
||||
static_cast<size_t>(this->IScanBlockCounts[s_rank] - this->IScanBlockCounts[s_rank - 1]));
|
||||
std::iota(gids.begin(), gids.end(), static_cast<int>(this->IScanBlockCounts[s_rank - 1]));
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
int AssignerMultiBlock::rank(int gid) const
|
||||
{
|
||||
return static_cast<int>(
|
||||
std::lower_bound(this->IScanBlockCounts.begin(), this->IScanBlockCounts.end(), gid + 1) -
|
||||
this->IScanBlockCounts.begin());
|
||||
}
|
||||
|
||||
|
||||
} // vtkm::cont
|
||||
} // vtkm
|
81
vtkm/cont/AssignerPartitionedDataSet.cxx
Normal file
81
vtkm/cont/AssignerPartitionedDataSet.cxx
Normal file
@ -0,0 +1,81 @@
|
||||
//============================================================================
|
||||
// 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/AssignerPartitionedDataSet.h>
|
||||
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
|
||||
#include <vtkm/thirdparty/diy/diy.h>
|
||||
|
||||
#include <algorithm> // std::lower_bound
|
||||
#include <numeric> // std::iota
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
AssignerPartitionedDataSet::AssignerPartitionedDataSet(const vtkm::cont::PartitionedDataSet& pds)
|
||||
: AssignerPartitionedDataSet(pds.GetNumberOfPartitions())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
AssignerPartitionedDataSet::AssignerPartitionedDataSet(vtkm::Id num_partitions)
|
||||
: vtkmdiy::StaticAssigner(vtkm::cont::EnvironmentTracker::GetCommunicator().size(), 1)
|
||||
, IScanPartitionCounts()
|
||||
{
|
||||
auto comm = vtkm::cont::EnvironmentTracker::GetCommunicator();
|
||||
if (comm.size() > 1)
|
||||
{
|
||||
vtkm::Id iscan;
|
||||
vtkmdiy::mpi::scan(comm, num_partitions, iscan, std::plus<vtkm::Id>());
|
||||
vtkmdiy::mpi::all_gather(comm, iscan, this->IScanPartitionCounts);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->IScanPartitionCounts.push_back(num_partitions);
|
||||
}
|
||||
|
||||
this->set_nblocks(static_cast<int>(this->IScanPartitionCounts.back()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AssignerPartitionedDataSet::local_gids(int my_rank, std::vector<int>& gids) const
|
||||
{
|
||||
const size_t s_rank = static_cast<size_t>(my_rank);
|
||||
if (my_rank == 0)
|
||||
{
|
||||
assert(this->IScanPartitionCounts.size() > 0);
|
||||
gids.resize(static_cast<size_t>(this->IScanPartitionCounts[s_rank]));
|
||||
std::iota(gids.begin(), gids.end(), 0);
|
||||
}
|
||||
else if (my_rank > 0 && s_rank < this->IScanPartitionCounts.size())
|
||||
{
|
||||
gids.resize(static_cast<size_t>(this->IScanPartitionCounts[s_rank] -
|
||||
this->IScanPartitionCounts[s_rank - 1]));
|
||||
std::iota(gids.begin(), gids.end(), static_cast<int>(this->IScanPartitionCounts[s_rank - 1]));
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
int AssignerPartitionedDataSet::rank(int gid) const
|
||||
{
|
||||
return static_cast<int>(std::lower_bound(this->IScanPartitionCounts.begin(),
|
||||
this->IScanPartitionCounts.end(),
|
||||
gid + 1) -
|
||||
this->IScanPartitionCounts.begin());
|
||||
}
|
||||
|
||||
|
||||
} // vtkm::cont
|
||||
} // vtkm
|
@ -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_cont_AssignerMultiBlock_h
|
||||
#define vtk_m_cont_AssignerMultiBlock_h
|
||||
#ifndef vtk_m_cont_AssignerPartitionedDataSet_h
|
||||
#define vtk_m_cont_AssignerPartitionedDataSet_h
|
||||
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
@ -31,31 +31,32 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class MultiBlock;
|
||||
class PartitionedDataSet;
|
||||
|
||||
/// \brief Assigner for `MultiBlock` blocks.
|
||||
/// \brief Assigner for PartitionedDataSet partitions.
|
||||
///
|
||||
/// `AssignerMultiBlock` is a `vtkmdiy::StaticAssigner` implementation that uses
|
||||
/// `MultiBlock`'s block distribution to build global-id/rank associations
|
||||
/// needed for several `diy` operations.
|
||||
/// It uses a contiguous assignment strategy to map blocks to global ids i.e.
|
||||
/// blocks on rank 0 come first, then rank 1, etc. Any rank may have 0 blocks.
|
||||
/// `AssignerPartitionedDataSet` is a `vtkmdiy::StaticAssigner` implementation
|
||||
/// that uses `PartitionedDataSet`'s partition distribution to build
|
||||
/// global-id/rank associations needed for several `diy` operations.
|
||||
/// It uses a contiguous assignment strategy to map partitions to global ids,
|
||||
/// i.e. partitions on rank 0 come first, then rank 1, etc. Any rank may have 0
|
||||
/// partitions.
|
||||
///
|
||||
/// AssignerMultiBlock uses collectives in the constructor hence it is
|
||||
/// AssignerPartitionedDataSet uses collectives in the constructor hence it is
|
||||
/// essential it gets created on all ranks irrespective of whether the rank has
|
||||
/// any blocks.
|
||||
/// any partitions.
|
||||
///
|
||||
class VTKM_CONT_EXPORT AssignerMultiBlock : public vtkmdiy::StaticAssigner
|
||||
class VTKM_CONT_EXPORT AssignerPartitionedDataSet : public vtkmdiy::StaticAssigner
|
||||
{
|
||||
public:
|
||||
/// Initialize the assigner using a multiblock dataset.
|
||||
/// Initialize the assigner using a partitioned dataset.
|
||||
/// This may initialize collective operations to populate the assigner with
|
||||
/// information about blocks on all ranks.
|
||||
/// information about partitions on all ranks.
|
||||
VTKM_CONT
|
||||
AssignerMultiBlock(const vtkm::cont::MultiBlock& mb);
|
||||
AssignerPartitionedDataSet(const vtkm::cont::PartitionedDataSet& pds);
|
||||
|
||||
VTKM_CONT
|
||||
AssignerMultiBlock(vtkm::Id num_blocks);
|
||||
AssignerPartitionedDataSet(vtkm::Id num_partitions);
|
||||
|
||||
///@{
|
||||
/// vtkmdiy::Assigner API implementation.
|
||||
@ -66,7 +67,7 @@ public:
|
||||
int rank(int gid) const override;
|
||||
//@}
|
||||
private:
|
||||
std::vector<vtkm::Id> IScanBlockCounts;
|
||||
std::vector<vtkm::Id> IScanPartitionCounts;
|
||||
};
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
#include <numeric> // for std::accumulate
|
||||
|
||||
@ -31,14 +31,15 @@ vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset, vtkm::Id coordina
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
vtkm::Id coordinate_system_index)
|
||||
{
|
||||
return std::accumulate(multiblock.begin(),
|
||||
multiblock.end(),
|
||||
return std::accumulate(pds.begin(),
|
||||
pds.end(),
|
||||
vtkm::Bounds(),
|
||||
[=](const vtkm::Bounds& val, const vtkm::cont::DataSet& block) {
|
||||
return val + vtkm::cont::BoundsCompute(block, coordinate_system_index);
|
||||
[=](const vtkm::Bounds& val, const vtkm::cont::DataSet& partition) {
|
||||
return val +
|
||||
vtkm::cont::BoundsCompute(partition, coordinate_system_index);
|
||||
});
|
||||
}
|
||||
|
||||
@ -59,13 +60,13 @@ vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset, const std::string
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::MultiBlock& multiblock, const std::string& name)
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::PartitionedDataSet& pds, const std::string& name)
|
||||
{
|
||||
return std::accumulate(multiblock.begin(),
|
||||
multiblock.end(),
|
||||
return std::accumulate(pds.begin(),
|
||||
pds.end(),
|
||||
vtkm::Bounds(),
|
||||
[=](const vtkm::Bounds& val, const vtkm::cont::DataSet& block) {
|
||||
return val + vtkm::cont::BoundsCompute(block, name);
|
||||
[=](const vtkm::Bounds& val, const vtkm::cont::DataSet& partition) {
|
||||
return val + vtkm::cont::BoundsCompute(partition, name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,19 +19,19 @@ namespace cont
|
||||
{
|
||||
|
||||
class DataSet;
|
||||
class MultiBlock;
|
||||
class PartitionedDataSet;
|
||||
|
||||
//@{
|
||||
/// \brief Functions to compute bounds for a dataset or multiblock
|
||||
/// \brief Functions to compute bounds for a single dataSset or partition dataset
|
||||
///
|
||||
/// These are utility functions that compute bounds for the dataset or
|
||||
/// multiblock. When VTK-m is operating in an distributed environment, these
|
||||
/// are bounds on the local process. To get global bounds across all ranks,
|
||||
/// use `vtkm::cont::BoundsGlobalCompute` instead.
|
||||
/// These are utility functions that compute bounds for a single dataset or
|
||||
/// partitioned dataset. When VTK-m is operating in an distributed environment,
|
||||
/// these are bounds on the local process. To get global bounds across all
|
||||
/// ranks, use `vtkm::cont::BoundsGlobalCompute` instead.
|
||||
///
|
||||
/// Note that if the provided CoordinateSystem does not exists, empty bounds
|
||||
/// are returned. Likewise, for MultiBlock, blocks without the chosen CoordinateSystem
|
||||
/// are skipped.
|
||||
/// are returned. Likewise, for PartitionedDataSet, partitions without the
|
||||
/// chosen CoordinateSystem are skipped.
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset,
|
||||
@ -39,7 +39,7 @@ vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset,
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
vtkm::Id coordinate_system_index = 0);
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -49,7 +49,7 @@ vtkm::Bounds BoundsCompute(const vtkm::cont::DataSet& dataset,
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::Bounds BoundsCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& coordinate_system_name);
|
||||
//@}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/FieldRangeGlobalCompute.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
#include <numeric> // for std::accumulate
|
||||
|
||||
@ -50,10 +50,10 @@ vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset,
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
vtkm::Id coordinate_system_index)
|
||||
{
|
||||
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(multiblock, coordinate_system_index));
|
||||
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(pds, coordinate_system_index));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -65,9 +65,9 @@ vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset, const std::
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::MultiBlock& multiblock, const std::string& name)
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::PartitionedDataSet& pds, const std::string& name)
|
||||
{
|
||||
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(multiblock, name));
|
||||
return detail::MergeBoundsGlobal(vtkm::cont::BoundsCompute(pds, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,19 +19,20 @@ namespace cont
|
||||
{
|
||||
|
||||
class DataSet;
|
||||
class MultiBlock;
|
||||
class PartitionedDataSet;
|
||||
|
||||
//@{
|
||||
/// \brief Functions to compute bounds for a dataset or multiblock globally
|
||||
/// \brief Functions to compute bounds for a single dataset or partitioned
|
||||
/// dataset globally
|
||||
///
|
||||
/// These are utility functions that compute bounds for the dataset or
|
||||
/// multiblock globally i.e. across all ranks when operating in a distributed
|
||||
/// environment. When VTK-m not operating in an distributed environment, these
|
||||
/// behave same as `vtkm::cont::BoundsCompute`.
|
||||
/// These are utility functions that compute bounds for a single dataset or
|
||||
/// partitioned dataset globally i.e. across all ranks when operating in a
|
||||
/// distributed environment. When VTK-m not operating in an distributed
|
||||
/// environment, these behave same as `vtkm::cont::BoundsCompute`.
|
||||
///
|
||||
/// Note that if the provided CoordinateSystem does not exists, empty bounds
|
||||
/// are returned. Likewise, for MultiBlock, blocks without the chosen CoordinateSystem
|
||||
/// are skipped.
|
||||
/// are returned. Likewise, for PartitionedDataSet, partitions without the
|
||||
/// chosen CoordinateSystem are skipped.
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset,
|
||||
@ -39,7 +40,7 @@ vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset,
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
vtkm::Id coordinate_system_index = 0);
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
@ -49,7 +50,7 @@ vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::DataSet& dataset,
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::Bounds BoundsGlobalCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& coordinate_system_name);
|
||||
//@}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ set(headers
|
||||
ArrayPortal.h
|
||||
ArrayPortalToIterators.h
|
||||
ArrayRangeCompute.h
|
||||
AssignerMultiBlock.h
|
||||
AssignerPartitionedDataSet.h
|
||||
AtomicArray.h
|
||||
BitField.h
|
||||
BoundsCompute.h
|
||||
@ -93,7 +93,7 @@ set(headers
|
||||
Initialize.h
|
||||
Invoker.h
|
||||
Logging.h
|
||||
MultiBlock.h
|
||||
PartitionedDataSet.h
|
||||
PointLocator.h
|
||||
PointLocatorUniformGrid.h
|
||||
RuntimeDeviceInformation.h
|
||||
@ -152,7 +152,7 @@ set(sources
|
||||
set(device_sources
|
||||
ArrayHandleVirtual.cxx
|
||||
ArrayRangeCompute.cxx
|
||||
AssignerMultiBlock.cxx
|
||||
AssignerPartitionedDataSet.cxx
|
||||
BoundsCompute.cxx
|
||||
BoundsGlobalCompute.cxx
|
||||
CellLocator.cxx
|
||||
@ -175,7 +175,7 @@ set(sources
|
||||
Field.cxx
|
||||
FieldRangeCompute.cxx
|
||||
FieldRangeGlobalCompute.cxx
|
||||
MultiBlock.cxx
|
||||
PartitionedDataSet.cxx
|
||||
PointLocator.cxx
|
||||
PointLocatorUniformGrid.cxx
|
||||
RuntimeDeviceInformation.cxx
|
||||
|
@ -27,29 +27,8 @@ namespace cont
|
||||
class VTKM_CONT_EXPORT CellSet
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
CellSet(const std::string& name)
|
||||
: Name(name)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSet(const vtkm::cont::CellSet& src)
|
||||
: Name(src.Name)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSet& operator=(const vtkm::cont::CellSet& src)
|
||||
{
|
||||
this->Name = src.Name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~CellSet();
|
||||
|
||||
std::string GetName() const { return this->Name; }
|
||||
|
||||
virtual vtkm::Id GetNumberOfCells() const = 0;
|
||||
|
||||
virtual vtkm::Id GetNumberOfFaces() const = 0;
|
||||
@ -68,9 +47,6 @@ public:
|
||||
virtual void PrintSummary(std::ostream&) const = 0;
|
||||
|
||||
virtual void ReleaseResourcesExecution() = 0;
|
||||
|
||||
protected:
|
||||
std::string Name;
|
||||
};
|
||||
|
||||
namespace internal
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
typename VisitCellsWithPointsConnectivityType::ConnectivityArrayType;
|
||||
using IndexOffsetArrayType = typename VisitCellsWithPointsConnectivityType::IndexOffsetArrayType;
|
||||
|
||||
VTKM_CONT CellSetExplicit(const std::string& name = std::string());
|
||||
VTKM_CONT CellSetExplicit();
|
||||
VTKM_CONT CellSetExplicit(const Thisclass& src);
|
||||
VTKM_CONT CellSetExplicit(Thisclass&& src) noexcept;
|
||||
|
||||
@ -377,7 +377,6 @@ private:
|
||||
public:
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetNumberOfPoints());
|
||||
vtkmdiy::save(
|
||||
bb, cs.GetShapesArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}));
|
||||
@ -391,8 +390,6 @@ public:
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkmdiy::load(bb, name);
|
||||
vtkm::Id numberOfPoints = 0;
|
||||
vtkmdiy::load(bb, numberOfPoints);
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeST> shapes;
|
||||
@ -404,7 +401,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, OffsetST> offsets;
|
||||
vtkmdiy::load(bb, offsets);
|
||||
|
||||
cs = Type(name);
|
||||
cs = Type{};
|
||||
cs.Fill(numberOfPoints, shapes, counts, connectivity, offsets);
|
||||
}
|
||||
};
|
||||
|
@ -25,8 +25,8 @@ template <typename ShapeStorageTag,
|
||||
VTKM_CONT CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::CellSetExplicit(const std::string& name)
|
||||
: CellSet(name)
|
||||
OffsetsStorageTag>::CellSetExplicit()
|
||||
: CellSet()
|
||||
, Data(std::make_shared<Internals>())
|
||||
{
|
||||
}
|
||||
@ -103,7 +103,7 @@ void CellSetExplicit<ShapeStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag>::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
out << " ExplicitCellSet: " << this->Name << std::endl;
|
||||
out << " ExplicitCellSet: " << std::endl;
|
||||
out << " VisitCellsWithPoints: " << std::endl;
|
||||
this->Data->VisitCellsWithPoints.PrintSummary(out);
|
||||
out << " VisitPointsWithCells: " << std::endl;
|
||||
|
@ -19,8 +19,8 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
CellSetExtrude::CellSetExtrude(const std::string& name)
|
||||
: vtkm::cont::CellSet(name)
|
||||
CellSetExtrude::CellSetExtrude()
|
||||
: vtkm::cont::CellSet()
|
||||
, IsPeriodic(false)
|
||||
, NumberOfPointsPerPlane(0)
|
||||
, NumberOfCellsPerPlane(0)
|
||||
@ -33,9 +33,8 @@ CellSetExtrude::CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn,
|
||||
vtkm::Int32 numberOfPointsPerPlane,
|
||||
vtkm::Int32 numberOfPlanes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
|
||||
bool periodic,
|
||||
const std::string& name)
|
||||
: vtkm::cont::CellSet(name)
|
||||
bool periodic)
|
||||
: vtkm::cont::CellSet()
|
||||
, IsPeriodic(periodic)
|
||||
, NumberOfPointsPerPlane(numberOfPointsPerPlane)
|
||||
, NumberOfCellsPerPlane(
|
||||
@ -47,6 +46,81 @@ CellSetExtrude::CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn,
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CellSetExtrude::CellSetExtrude(const CellSetExtrude& src)
|
||||
: CellSet(src)
|
||||
, IsPeriodic(src.IsPeriodic)
|
||||
, NumberOfPointsPerPlane(src.NumberOfPointsPerPlane)
|
||||
, NumberOfCellsPerPlane(src.NumberOfCellsPerPlane)
|
||||
, NumberOfPlanes(src.NumberOfPlanes)
|
||||
, Connectivity(src.Connectivity)
|
||||
, NextNode(src.NextNode)
|
||||
, ReverseConnectivityBuilt(src.ReverseConnectivityBuilt)
|
||||
, RConnectivity(src.RConnectivity)
|
||||
, ROffsets(src.ROffsets)
|
||||
, RCounts(src.RCounts)
|
||||
, PrevNode(src.PrevNode)
|
||||
{
|
||||
}
|
||||
|
||||
CellSetExtrude::CellSetExtrude(CellSetExtrude&& src) noexcept
|
||||
: CellSet(std::forward<CellSet>(src)),
|
||||
IsPeriodic(src.IsPeriodic),
|
||||
NumberOfPointsPerPlane(src.NumberOfPointsPerPlane),
|
||||
NumberOfCellsPerPlane(src.NumberOfCellsPerPlane),
|
||||
NumberOfPlanes(src.NumberOfPlanes),
|
||||
Connectivity(std::move(src.Connectivity)),
|
||||
NextNode(std::move(src.NextNode)),
|
||||
ReverseConnectivityBuilt(src.ReverseConnectivityBuilt),
|
||||
RConnectivity(std::move(src.RConnectivity)),
|
||||
ROffsets(std::move(src.ROffsets)),
|
||||
RCounts(std::move(src.RCounts)),
|
||||
PrevNode(std::move(src.PrevNode))
|
||||
{
|
||||
}
|
||||
|
||||
CellSetExtrude& CellSetExtrude::operator=(const CellSetExtrude& src)
|
||||
{
|
||||
this->CellSet::operator=(src);
|
||||
|
||||
this->IsPeriodic = src.IsPeriodic;
|
||||
this->NumberOfPointsPerPlane = src.NumberOfPointsPerPlane;
|
||||
this->NumberOfCellsPerPlane = src.NumberOfCellsPerPlane;
|
||||
this->NumberOfPlanes = src.NumberOfPlanes;
|
||||
this->Connectivity = src.Connectivity;
|
||||
this->NextNode = src.NextNode;
|
||||
this->ReverseConnectivityBuilt = src.ReverseConnectivityBuilt;
|
||||
this->RConnectivity = src.RConnectivity;
|
||||
this->ROffsets = src.ROffsets;
|
||||
this->RCounts = src.RCounts;
|
||||
this->PrevNode = src.PrevNode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CellSetExtrude& CellSetExtrude::operator=(CellSetExtrude&& src) noexcept
|
||||
{
|
||||
this->CellSet::operator=(std::forward<CellSet>(src));
|
||||
|
||||
this->IsPeriodic = src.IsPeriodic;
|
||||
this->NumberOfPointsPerPlane = src.NumberOfPointsPerPlane;
|
||||
this->NumberOfCellsPerPlane = src.NumberOfCellsPerPlane;
|
||||
this->NumberOfPlanes = src.NumberOfPlanes;
|
||||
this->Connectivity = std::move(src.Connectivity);
|
||||
this->NextNode = std::move(src.NextNode);
|
||||
this->ReverseConnectivityBuilt = src.ReverseConnectivityBuilt;
|
||||
this->RConnectivity = std::move(src.RConnectivity);
|
||||
this->ROffsets = std::move(src.ROffsets);
|
||||
this->RCounts = std::move(src.RCounts);
|
||||
this->PrevNode = std::move(src.PrevNode);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CellSetExtrude::~CellSetExtrude()
|
||||
{
|
||||
}
|
||||
|
||||
vtkm::Int32 CellSetExtrude::GetNumberOfPlanes() const
|
||||
{
|
||||
return this->NumberOfPlanes;
|
||||
@ -167,7 +241,7 @@ vtkm::Id2 CellSetExtrude::GetSchedulingRange(vtkm::TopologyElementTagPoint) cons
|
||||
|
||||
void CellSetExtrude::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
out << " vtkmCellSetSingleType: " << this->Name << std::endl;
|
||||
out << " vtkmCellSetSingleType: " << std::endl;
|
||||
out << " NumberOfCellsPerPlane: " << this->NumberOfCellsPerPlane << std::endl;
|
||||
out << " NumberOfPointsPerPlane: " << this->NumberOfPointsPerPlane << std::endl;
|
||||
out << " NumberOfPlanes: " << this->NumberOfPlanes << std::endl;
|
||||
|
@ -29,14 +29,21 @@ namespace cont
|
||||
class VTKM_CONT_EXPORT CellSetExtrude : public CellSet
|
||||
{
|
||||
public:
|
||||
VTKM_CONT CellSetExtrude(const std::string& name = "extrude");
|
||||
VTKM_CONT CellSetExtrude();
|
||||
|
||||
VTKM_CONT CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn,
|
||||
vtkm::Int32 numberOfPointsPerPlane,
|
||||
vtkm::Int32 numberOfPlanes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
|
||||
bool periodic,
|
||||
const std::string& name = "extrude");
|
||||
bool periodic);
|
||||
|
||||
VTKM_CONT CellSetExtrude(const CellSetExtrude& src);
|
||||
VTKM_CONT CellSetExtrude(CellSetExtrude&& src) noexcept;
|
||||
|
||||
VTKM_CONT CellSetExtrude& operator=(const CellSetExtrude& src);
|
||||
VTKM_CONT CellSetExtrude& operator=(CellSetExtrude&& src) noexcept;
|
||||
|
||||
virtual ~CellSetExtrude();
|
||||
|
||||
vtkm::Int32 GetNumberOfPlanes() const;
|
||||
|
||||
@ -126,11 +133,10 @@ template <typename T>
|
||||
CellSetExtrude make_CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn,
|
||||
const vtkm::cont::ArrayHandleExtrudeCoords<T>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode,
|
||||
bool periodic = true,
|
||||
const std::string name = "extrude")
|
||||
bool periodic = true)
|
||||
{
|
||||
return CellSetExtrude{
|
||||
conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic, name
|
||||
conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic
|
||||
};
|
||||
}
|
||||
|
||||
@ -138,15 +144,13 @@ template <typename T>
|
||||
CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn,
|
||||
const vtkm::cont::ArrayHandleExtrudeCoords<T>& coords,
|
||||
const std::vector<vtkm::Int32>& nextNode,
|
||||
bool periodic = true,
|
||||
const std::string name = "extrude")
|
||||
bool periodic = true)
|
||||
{
|
||||
return CellSetExtrude{ vtkm::cont::make_ArrayHandle(conn),
|
||||
static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
|
||||
coords.GetNumberOfPlanes(),
|
||||
vtkm::cont::make_ArrayHandle(nextNode),
|
||||
periodic,
|
||||
name };
|
||||
periodic };
|
||||
}
|
||||
}
|
||||
} // vtkm::cont
|
||||
@ -183,7 +187,6 @@ private:
|
||||
public:
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetNumberOfPointsPerPlane());
|
||||
vtkmdiy::save(bb, cs.GetNumberOfPlanes());
|
||||
vtkmdiy::save(bb, cs.GetIsPeriodic());
|
||||
@ -193,21 +196,19 @@ public:
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkm::Int32 numberOfPointsPerPlane;
|
||||
vtkm::Int32 numberOfPlanes;
|
||||
bool isPeriodic;
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> conn;
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> nextNode;
|
||||
|
||||
vtkmdiy::load(bb, name);
|
||||
vtkmdiy::load(bb, numberOfPointsPerPlane);
|
||||
vtkmdiy::load(bb, numberOfPlanes);
|
||||
vtkmdiy::load(bb, isPeriodic);
|
||||
vtkmdiy::load(bb, conn);
|
||||
vtkmdiy::load(bb, nextNode);
|
||||
|
||||
cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic, name };
|
||||
cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -243,17 +243,16 @@ public:
|
||||
|
||||
VTKM_CONT
|
||||
CellSetPermutation(const PermutationArrayHandleType& validCellIds,
|
||||
const OriginalCellSetType& cellset,
|
||||
const std::string& name = std::string())
|
||||
: CellSet(name)
|
||||
const OriginalCellSetType& cellset)
|
||||
: CellSet()
|
||||
, ValidCellIds(validCellIds)
|
||||
, FullCellSet(cellset)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetPermutation(const std::string& name = std::string())
|
||||
: CellSet(name)
|
||||
CellSetPermutation()
|
||||
: CellSet()
|
||||
, ValidCellIds()
|
||||
, FullCellSet()
|
||||
{
|
||||
@ -446,17 +445,15 @@ private:
|
||||
public:
|
||||
VTKM_CONT
|
||||
CellSetPermutation(const PermutationArrayHandleType2& validCellIds,
|
||||
const CellSetPermutation<CellSetType, PermutationArrayHandleType1>& cellset,
|
||||
const std::string& name = std::string())
|
||||
const CellSetPermutation<CellSetType, PermutationArrayHandleType1>& cellset)
|
||||
: Superclass(vtkm::cont::make_ArrayHandlePermutation(validCellIds, cellset.GetValidCellIds()),
|
||||
cellset.GetFullCellSet(),
|
||||
name)
|
||||
cellset.GetFullCellSet())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetPermutation(const std::string& name = std::string())
|
||||
: Superclass(name)
|
||||
CellSetPermutation()
|
||||
: Superclass()
|
||||
{
|
||||
}
|
||||
|
||||
@ -471,19 +468,6 @@ public:
|
||||
std::shared_ptr<CellSet> NewInstance() const { return std::make_shared<CellSetPermutation>(); }
|
||||
};
|
||||
|
||||
template <typename OriginalCellSet, typename PermutationArrayHandleType>
|
||||
vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType> make_CellSetPermutation(
|
||||
const PermutationArrayHandleType& cellIndexMap,
|
||||
const OriginalCellSet& cellSet,
|
||||
const std::string& name)
|
||||
{
|
||||
VTKM_IS_CELL_SET(OriginalCellSet);
|
||||
VTKM_IS_ARRAY_HANDLE(PermutationArrayHandleType);
|
||||
|
||||
return vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType>(
|
||||
cellIndexMap, cellSet, name);
|
||||
}
|
||||
|
||||
template <typename OriginalCellSet, typename PermutationArrayHandleType>
|
||||
vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType> make_CellSetPermutation(
|
||||
const PermutationArrayHandleType& cellIndexMap,
|
||||
@ -492,7 +476,8 @@ vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType> make
|
||||
VTKM_IS_CELL_SET(OriginalCellSet);
|
||||
VTKM_IS_ARRAY_HANDLE(PermutationArrayHandleType);
|
||||
|
||||
return vtkm::cont::make_CellSetPermutation(cellIndexMap, cellSet, cellSet.GetName());
|
||||
return vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType>(cellIndexMap,
|
||||
cellSet);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
@ -529,21 +514,18 @@ private:
|
||||
public:
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetFullCellSet());
|
||||
vtkmdiy::save(bb, cs.GetValidCellIds());
|
||||
}
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkmdiy::load(bb, name);
|
||||
CSType fullCS;
|
||||
vtkmdiy::load(bb, fullCS);
|
||||
AHValidCellIds validCellIds;
|
||||
vtkmdiy::load(bb, validCellIds);
|
||||
|
||||
cs = make_CellSetPermutation(validCellIds, fullCS, name);
|
||||
cs = make_CellSetPermutation(validCellIds, fullCS);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,8 +46,8 @@ class VTKM_ALWAYS_EXPORT CellSetSingleType
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
CellSetSingleType(const std::string& name = std::string())
|
||||
: Superclass(name)
|
||||
CellSetSingleType()
|
||||
: Superclass()
|
||||
, ExpectedNumberOfCellsAdded(-1)
|
||||
, CellShapeAsId(CellShapeTagEmpty::Id)
|
||||
, NumberOfPointsPerCell(0)
|
||||
@ -63,6 +63,15 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetSingleType(Thisclass&& src) noexcept : Superclass(std::forward<Superclass>(src)),
|
||||
ExpectedNumberOfCellsAdded(-1),
|
||||
CellShapeAsId(src.CellShapeAsId),
|
||||
NumberOfPointsPerCell(src.NumberOfPointsPerCell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
VTKM_CONT
|
||||
Thisclass& operator=(const Thisclass& src)
|
||||
{
|
||||
@ -72,6 +81,15 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Thisclass& operator=(Thisclass&& src) noexcept
|
||||
{
|
||||
this->Superclass::operator=(std::forward<Superclass>(src));
|
||||
this->CellShapeAsId = src.CellShapeAsId;
|
||||
this->NumberOfPointsPerCell = src.NumberOfPointsPerCell;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~CellSetSingleType() {}
|
||||
|
||||
/// First method to add cells -- one at a time.
|
||||
@ -224,7 +242,7 @@ public:
|
||||
|
||||
virtual void PrintSummary(std::ostream& out) const override
|
||||
{
|
||||
out << " CellSetSingleType: " << this->Name << " Type " << this->CellShapeAsId << std::endl;
|
||||
out << " CellSetSingleType ShapeType " << this->CellShapeAsId << std::endl;
|
||||
out << " VisitCellsWithPoints: " << std::endl;
|
||||
this->Data->VisitCellsWithPoints.PrintSummary(out);
|
||||
out << " VisitPointsWithCells: " << std::endl;
|
||||
@ -304,7 +322,6 @@ private:
|
||||
public:
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetNumberOfPoints());
|
||||
vtkmdiy::save(bb, cs.GetCellShape(0));
|
||||
vtkmdiy::save(bb, cs.GetNumberOfPointsInCell(0));
|
||||
@ -314,8 +331,6 @@ public:
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkmdiy::load(bb, name);
|
||||
vtkm::Id numberOfPoints = 0;
|
||||
vtkmdiy::load(bb, numberOfPoints);
|
||||
vtkm::UInt8 shape;
|
||||
@ -325,7 +340,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityST> connectivity;
|
||||
vtkmdiy::load(bb, connectivity);
|
||||
|
||||
cs = Type(name);
|
||||
cs = Type{};
|
||||
cs.Fill(numberOfPoints, shape, count, connectivity);
|
||||
}
|
||||
};
|
||||
|
@ -35,18 +35,6 @@ public:
|
||||
|
||||
using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
|
||||
|
||||
CellSetStructured(const std::string& name = std::string())
|
||||
: CellSet(name)
|
||||
, Structure()
|
||||
{
|
||||
}
|
||||
|
||||
CellSetStructured(const Thisclass& src);
|
||||
CellSetStructured(Thisclass&& src) noexcept;
|
||||
|
||||
Thisclass& operator=(const Thisclass& src);
|
||||
Thisclass& operator=(Thisclass&& src) noexcept;
|
||||
|
||||
vtkm::Id GetNumberOfCells() const override { return this->Structure.GetNumberOfCells(); }
|
||||
|
||||
vtkm::Id GetNumberOfPoints() const override { return this->Structure.GetNumberOfPoints(); }
|
||||
@ -174,20 +162,17 @@ private:
|
||||
public:
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetPointDimensions());
|
||||
vtkmdiy::save(bb, cs.GetGlobalPointIndexStart());
|
||||
}
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkmdiy::load(bb, name);
|
||||
typename Type::SchedulingRangeType dims, start;
|
||||
vtkmdiy::load(bb, dims);
|
||||
vtkmdiy::load(bb, start);
|
||||
|
||||
cs = Type(name);
|
||||
cs = Type{};
|
||||
cs.SetPointDimensions(dims);
|
||||
cs.SetGlobalPointIndexStart(start);
|
||||
}
|
||||
|
@ -15,38 +15,6 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
CellSetStructured<DIMENSION>::CellSetStructured(const CellSetStructured<DIMENSION>& src)
|
||||
: CellSet(src)
|
||||
, Structure(src.Structure)
|
||||
{
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
CellSetStructured<DIMENSION>::CellSetStructured(CellSetStructured<DIMENSION>&& src) noexcept
|
||||
: CellSet(std::forward<CellSet>(src)),
|
||||
Structure(std::move(src.Structure))
|
||||
{
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
CellSetStructured<DIMENSION>& CellSetStructured<DIMENSION>::operator=(
|
||||
const CellSetStructured<DIMENSION>& src)
|
||||
{
|
||||
this->CellSet::operator=(src);
|
||||
this->Structure = src.Structure;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
CellSetStructured<DIMENSION>& CellSetStructured<DIMENSION>::operator=(
|
||||
CellSetStructured<DIMENSION>&& src) noexcept
|
||||
{
|
||||
this->CellSet::operator=(std::forward<CellSet>(src));
|
||||
this->Structure = std::move(src.Structure);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
template <typename TopologyElement>
|
||||
typename CellSetStructured<DIMENSION>::SchedulingRangeType
|
||||
@ -73,7 +41,7 @@ typename CellSetStructured<DIMENSION>::template ExecutionTypes<DeviceAdapter,
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
void CellSetStructured<DIMENSION>::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
out << " StructuredCellSet: " << this->GetName() << std::endl;
|
||||
out << " StructuredCellSet: " << std::endl;
|
||||
this->Structure.PrintSummary(out);
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,27 @@ void DataSet::Clear()
|
||||
{
|
||||
this->CoordSystems.clear();
|
||||
this->Fields.clear();
|
||||
this->CellSets.clear();
|
||||
this->CellSet = this->CellSet.NewInstance();
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::GetNumberOfCells() const
|
||||
{
|
||||
return this->CellSet.GetNumberOfCells();
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::GetNumberOfPoints() const
|
||||
{
|
||||
if (this->CoordSystems.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return this->CoordSystems[0].GetNumberOfPoints();
|
||||
}
|
||||
|
||||
void DataSet::CopyStructure(const vtkm::cont::DataSet& source)
|
||||
{
|
||||
this->CoordSystems = source.CoordSystems;
|
||||
this->CellSets = source.CellSets;
|
||||
this->CellSet = source.CellSet;
|
||||
}
|
||||
|
||||
const vtkm::cont::Field& DataSet::GetField(vtkm::Id index) const
|
||||
@ -33,6 +47,12 @@ const vtkm::cont::Field& DataSet::GetField(vtkm::Id index) const
|
||||
return this->Fields[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
vtkm::cont::Field& DataSet::GetField(vtkm::Id index)
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfFields()));
|
||||
return this->Fields[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::GetFieldIndex(const std::string& name, vtkm::cont::Field::Association assoc) const
|
||||
{
|
||||
bool found;
|
||||
@ -53,6 +73,12 @@ const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(vtkm::Id index)
|
||||
return this->CoordSystems[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(vtkm::Id index)
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems()));
|
||||
return this->CoordSystems[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::GetCoordinateSystemIndex(const std::string& name) const
|
||||
{
|
||||
vtkm::Id index = -1;
|
||||
@ -83,39 +109,20 @@ const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::stri
|
||||
return this->GetCoordinateSystem(index);
|
||||
}
|
||||
|
||||
const vtkm::cont::DynamicCellSet& DataSet::GetCellSet(vtkm::Id index) const
|
||||
vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& name)
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCellSets()));
|
||||
return this->CellSets[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::GetCellSetIndex(const std::string& name) const
|
||||
{
|
||||
vtkm::Id index = -1;
|
||||
for (auto i = this->CellSets.begin(); i != this->CellSets.end(); ++i)
|
||||
{
|
||||
if (i->GetName() == name)
|
||||
{
|
||||
index = static_cast<vtkm::Id>(std::distance(this->CellSets.begin(), i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
const vtkm::cont::DynamicCellSet& DataSet::GetCellSet(const std::string& name) const
|
||||
{
|
||||
vtkm::Id index = this->GetCellSetIndex(name);
|
||||
vtkm::Id index = this->GetCoordinateSystemIndex(name);
|
||||
if (index < 0)
|
||||
{
|
||||
std::string error_message("No cell set with the name " + name + " valid names are: \n");
|
||||
for (const auto& cs : this->CellSets)
|
||||
std::string error_message("No coordinate system with the name " + name +
|
||||
" valid names are: \n");
|
||||
for (const auto& cs : this->CoordSystems)
|
||||
{
|
||||
error_message += cs.GetName() + "\n";
|
||||
}
|
||||
throw vtkm::cont::ErrorBadValue(error_message);
|
||||
}
|
||||
return this->GetCellSet(index);
|
||||
return this->GetCoordinateSystem(index);
|
||||
}
|
||||
|
||||
void DataSet::PrintSummary(std::ostream& out) const
|
||||
@ -127,17 +134,16 @@ void DataSet::PrintSummary(std::ostream& out) const
|
||||
this->CoordSystems[index].PrintSummary(out);
|
||||
}
|
||||
|
||||
out << " CellSets[" << this->GetNumberOfCellSets() << "]\n";
|
||||
for (vtkm::Id index = 0; index < this->GetNumberOfCellSets(); index++)
|
||||
{
|
||||
this->GetCellSet(index).PrintSummary(out);
|
||||
}
|
||||
out << " CellSet \n";
|
||||
this->GetCellSet().PrintSummary(out);
|
||||
|
||||
out << " Fields[" << this->GetNumberOfFields() << "]\n";
|
||||
for (vtkm::Id index = 0; index < this->GetNumberOfFields(); index++)
|
||||
{
|
||||
this->GetField(index).PrintSummary(out);
|
||||
}
|
||||
|
||||
out.flush();
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::FindFieldIndex(const std::string& name,
|
||||
|
@ -30,11 +30,23 @@ class VTKM_CONT_EXPORT DataSet
|
||||
public:
|
||||
VTKM_CONT void Clear();
|
||||
|
||||
/// Get the number of cells contained in this DataSet
|
||||
VTKM_CONT vtkm::Id GetNumberOfCells() const;
|
||||
|
||||
/// Get the number of points contained in this DataSet
|
||||
///
|
||||
/// Note: All coordinate systems for a DataSet are expected
|
||||
/// to have the same number of points.
|
||||
VTKM_CONT vtkm::Id GetNumberOfPoints() const;
|
||||
|
||||
VTKM_CONT void AddField(const Field& field) { this->Fields.push_back(field); }
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field& GetField(vtkm::Id index) const;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field& GetField(vtkm::Id index);
|
||||
|
||||
VTKM_CONT
|
||||
bool HasField(const std::string& name,
|
||||
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY) const
|
||||
@ -70,6 +82,7 @@ public:
|
||||
|
||||
/// Returns the first field that matches the provided name and association
|
||||
/// Will throw an exception if no match is found
|
||||
//@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field& GetField(
|
||||
const std::string& name,
|
||||
@ -78,22 +91,47 @@ public:
|
||||
return this->GetField(this->GetFieldIndex(name, assoc));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field& GetField(
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY)
|
||||
{
|
||||
return this->GetField(this->GetFieldIndex(name, assoc));
|
||||
}
|
||||
//@}
|
||||
|
||||
/// Returns the first cell field that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
//@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field& GetCellField(const std::string& name) const
|
||||
{
|
||||
return this->GetField(name, vtkm::cont::Field::Association::CELL_SET);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field& GetCellField(const std::string& name)
|
||||
{
|
||||
return this->GetField(name, vtkm::cont::Field::Association::CELL_SET);
|
||||
}
|
||||
//@}
|
||||
|
||||
/// Returns the first point field that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
//@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field& GetPointField(const std::string& name) const
|
||||
{
|
||||
return this->GetField(name, vtkm::cont::Field::Association::POINTS);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field& GetPointField(const std::string& name)
|
||||
{
|
||||
return this->GetField(name, vtkm::cont::Field::Association::POINTS);
|
||||
}
|
||||
//@}
|
||||
|
||||
VTKM_CONT
|
||||
void AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs)
|
||||
{
|
||||
@ -109,6 +147,9 @@ public:
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0);
|
||||
|
||||
/// Returns the index for the first CoordinateSystem whose
|
||||
/// name matches the provided string.
|
||||
/// Will return -1 if no match is found
|
||||
@ -117,44 +158,29 @@ public:
|
||||
|
||||
/// Returns the first CoordinateSystem that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
//@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) const;
|
||||
|
||||
VTKM_CONT
|
||||
void AddCellSet(const vtkm::cont::DynamicCellSet& cellSet) { this->CellSets.push_back(cellSet); }
|
||||
vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name);
|
||||
//@}
|
||||
|
||||
VTKM_CONT
|
||||
void SetCellSet(const vtkm::cont::DynamicCellSet& cellSet) { this->CellSet = cellSet; }
|
||||
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT void AddCellSet(const CellSetType& cellSet)
|
||||
VTKM_CONT void SetCellSet(const CellSetType& cellSet)
|
||||
{
|
||||
VTKM_IS_CELL_SET(CellSetType);
|
||||
this->CellSets.push_back(vtkm::cont::DynamicCellSet(cellSet));
|
||||
this->CellSet = vtkm::cont::DynamicCellSet(cellSet);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool HasCellSet(const std::string& name) const { return this->GetCellSetIndex(name) >= 0; }
|
||||
const vtkm::cont::DynamicCellSet& GetCellSet() const { return this->CellSet; }
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DynamicCellSet& GetCellSet(vtkm::Id index = 0) const;
|
||||
|
||||
|
||||
/// Returns the index for the first cell set whose
|
||||
/// name matches the provided string.
|
||||
/// Will return -1 if no match is found
|
||||
VTKM_CONT
|
||||
vtkm::Id GetCellSetIndex(const std::string& name) const;
|
||||
|
||||
|
||||
/// Returns the first DynamicCellSet that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DynamicCellSet& GetCellSet(const std::string& name) const;
|
||||
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::IdComponent GetNumberOfCellSets() const
|
||||
{
|
||||
return static_cast<vtkm::IdComponent>(this->CellSets.size());
|
||||
}
|
||||
vtkm::cont::DynamicCellSet& GetCellSet() { return this->CellSet; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::IdComponent GetNumberOfFields() const
|
||||
@ -168,7 +194,7 @@ public:
|
||||
return static_cast<vtkm::IdComponent>(this->CoordSystems.size());
|
||||
}
|
||||
|
||||
/// Copies the structure i.e. coordinates systems and cellsets from the source
|
||||
/// Copies the structure i.e. coordinates systems and cellset from the source
|
||||
/// dataset. The fields are left unchanged.
|
||||
VTKM_CONT
|
||||
void CopyStructure(const vtkm::cont::DataSet& source);
|
||||
@ -179,7 +205,7 @@ public:
|
||||
private:
|
||||
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
||||
std::vector<vtkm::cont::Field> Fields;
|
||||
std::vector<vtkm::cont::DynamicCellSet> CellSets;
|
||||
vtkm::cont::DynamicCellSet CellSet;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id FindFieldIndex(const std::string& name,
|
||||
@ -234,12 +260,7 @@ public:
|
||||
vtkmdiy::save(bb, dataset.GetCoordinateSystem(i));
|
||||
}
|
||||
|
||||
vtkm::IdComponent numberOfCellSets = dataset.GetNumberOfCellSets();
|
||||
vtkmdiy::save(bb, numberOfCellSets);
|
||||
for (vtkm::IdComponent i = 0; i < numberOfCellSets; ++i)
|
||||
{
|
||||
vtkmdiy::save(bb, dataset.GetCellSet(i).ResetCellSetList(CellSetTypesList{}));
|
||||
}
|
||||
vtkmdiy::save(bb, dataset.GetCellSet().ResetCellSetList(CellSetTypesList{}));
|
||||
|
||||
vtkm::IdComponent numberOfFields = dataset.GetNumberOfFields();
|
||||
vtkmdiy::save(bb, numberOfFields);
|
||||
@ -263,14 +284,9 @@ public:
|
||||
dataset.AddCoordinateSystem(coords);
|
||||
}
|
||||
|
||||
vtkm::IdComponent numberOfCellSets = 0;
|
||||
vtkmdiy::load(bb, numberOfCellSets);
|
||||
for (vtkm::IdComponent i = 0; i < numberOfCellSets; ++i)
|
||||
{
|
||||
vtkm::cont::DynamicCellSetBase<CellSetTypesList> cells;
|
||||
vtkmdiy::load(bb, cells);
|
||||
dataset.AddCellSet(vtkm::cont::DynamicCellSet(cells));
|
||||
}
|
||||
vtkm::cont::DynamicCellSetBase<CellSetTypesList> cells;
|
||||
vtkmdiy::load(bb, cells);
|
||||
dataset.SetCellSet(vtkm::cont::DynamicCellSet(cells));
|
||||
|
||||
vtkm::IdComponent numberOfFields = 0;
|
||||
vtkmdiy::load(bb, numberOfFields);
|
||||
|
@ -22,11 +22,9 @@ DataSetBuilderExplicitIterative::DataSetBuilderExplicitIterative()
|
||||
|
||||
|
||||
VTKM_CONT
|
||||
void DataSetBuilderExplicitIterative::Begin(const std::string& coordName,
|
||||
const std::string& cellName)
|
||||
void DataSetBuilderExplicitIterative::Begin(const std::string& coordName)
|
||||
{
|
||||
this->coordNm = coordName;
|
||||
this->cellNm = cellName;
|
||||
this->points.resize(0);
|
||||
this->shapes.resize(0);
|
||||
this->numIdx.resize(0);
|
||||
@ -38,7 +36,7 @@ VTKM_CONT
|
||||
vtkm::cont::DataSet DataSetBuilderExplicitIterative::Create()
|
||||
{
|
||||
DataSetBuilderExplicit dsb;
|
||||
return dsb.Create(points, shapes, numIdx, connectivity, coordNm, cellNm);
|
||||
return dsb.Create(points, shapes, numIdx, connectivity, coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
|
@ -45,12 +45,11 @@ public:
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
const std::string& coordsNm = "coords")
|
||||
{
|
||||
std::vector<T> yVals(xVals.size(), 0), zVals(xVals.size(), 0);
|
||||
return DataSetBuilderExplicit::Create(
|
||||
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm, cellNm);
|
||||
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -59,12 +58,11 @@ public:
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
const std::string& coordsNm = "coords")
|
||||
{
|
||||
std::vector<T> zVals(xVals.size(), 0);
|
||||
return DataSetBuilderExplicit::Create(
|
||||
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm, cellNm);
|
||||
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -74,8 +72,7 @@ public:
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells");
|
||||
const std::string& coordsNm = "coords");
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
@ -85,11 +82,10 @@ public:
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
const std::string& coordsNm = "coords")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm, cellNm);
|
||||
xVals, yVals, zVals, shapes, numIndices, connectivity, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -97,8 +93,7 @@ public:
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells");
|
||||
const std::string& coordsNm = "coords");
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
@ -106,11 +101,9 @@ public:
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
const std::string& coordsNm = "coords")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
coords, shapes, numIndices, connectivity, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::BuildDataSet(coords, shapes, numIndices, connectivity, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
@ -118,8 +111,7 @@ public:
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells");
|
||||
const std::string& coordsNm = "coords");
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
@ -127,11 +119,10 @@ public:
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
const std::string& coordsNm = "coords")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
coords, tag, numberOfPointsPerCell, connectivity, coordsNm, cellNm);
|
||||
coords, tag, numberOfPointsPerCell, connectivity, coordsNm);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -143,8 +134,7 @@ private:
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm);
|
||||
const std::string& coordsNm);
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
||||
@ -152,8 +142,7 @@ private:
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm);
|
||||
const std::string& coordsNm);
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
||||
@ -161,8 +150,7 @@ private:
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm);
|
||||
const std::string& coordsNm);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -173,8 +161,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
VTKM_ASSERT(xVals.size() == yVals.size() && yVals.size() == zVals.size() && xVals.size() > 0);
|
||||
|
||||
@ -190,7 +177,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
DataSetBuilderExplicit::CopyInto(numIndices, Nc);
|
||||
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
||||
|
||||
return DataSetBuilderExplicit::BuildDataSet(Xc, Yc, Zc, Sc, Nc, Cc, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::BuildDataSet(Xc, Yc, Zc, Sc, Nc, Cc, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -201,8 +188,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
VTKM_ASSERT(X.GetNumberOfValues() == Y.GetNumberOfValues() &&
|
||||
Y.GetNumberOfValues() == Z.GetNumberOfValues() && X.GetNumberOfValues() > 0 &&
|
||||
@ -212,10 +198,10 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(coordsNm, make_ArrayHandleCompositeVector(X, Y, Z)));
|
||||
vtkm::Id nPts = X.GetNumberOfValues();
|
||||
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
|
||||
cellSet.Fill(nPts, shapes, numIndices, connectivity);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -226,8 +212,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<Vec<T, 3>> coordsArray;
|
||||
DataSetBuilderExplicit::CopyInto(coords, coordsArray);
|
||||
@ -239,7 +224,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
DataSetBuilderExplicit::CopyInto(numIndices, Nc);
|
||||
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
||||
|
||||
return DataSetBuilderExplicit::Create(coordsArray, Sc, Nc, Cc, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::Create(coordsArray, Sc, Nc, Cc, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -248,17 +233,16 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
||||
vtkm::Id nPts = static_cast<vtkm::Id>(coords.GetNumberOfValues());
|
||||
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
|
||||
cellSet.Fill(nPts, shapes, numIndices, connectivity);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -269,8 +253,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<Vec<T, 3>> coordsArray;
|
||||
DataSetBuilderExplicit::CopyInto(coords, coordsArray);
|
||||
@ -278,8 +261,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
|
||||
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
||||
|
||||
return DataSetBuilderExplicit::Create(
|
||||
coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::Create(coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
@ -288,17 +270,16 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
(void)tag; //C4100 false positive workaround
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
||||
vtkm::cont::CellSetSingleType<> cellSet(cellNm);
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
|
||||
cellSet.Fill(coords.GetNumberOfValues(), tag.Id, numberOfPointsPerCell, connectivity);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -310,7 +291,7 @@ public:
|
||||
DataSetBuilderExplicitIterative();
|
||||
|
||||
VTKM_CONT
|
||||
void Begin(const std::string& coordName = "coords", const std::string& cellName = "cells");
|
||||
void Begin(const std::string& coordName = "coords");
|
||||
|
||||
//Define points.
|
||||
VTKM_CONT
|
||||
@ -349,7 +330,7 @@ public:
|
||||
void AddCellPoint(vtkm::Id pointIndex);
|
||||
|
||||
private:
|
||||
std::string coordNm, cellNm;
|
||||
std::string coordNm;
|
||||
|
||||
std::vector<vtkm::Vec3f_32> points;
|
||||
std::vector<vtkm::UInt8> shapes;
|
||||
|
@ -50,46 +50,41 @@ public:
|
||||
//1D grids.
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
std::vector<T> yvals(1, 0), zvals(1, 0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(vtkm::Id nx,
|
||||
T* xvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
T yvals = 0, zvals = 0;
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
nx, 1, 1, xvals, &yvals, &zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(nx, 1, 1, xvals, &yvals, &zvals, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::cont::ArrayHandle<T>& xvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> yvals, zvals;
|
||||
yvals.Allocate(1);
|
||||
yvals.GetPortalControl().Set(0, 0.0);
|
||||
zvals.Allocate(1);
|
||||
zvals.GetPortalControl().Set(0, 0.0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
//2D grids.
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xvals,
|
||||
const std::vector<T>& yvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
std::vector<T> zvals(1, 0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -97,24 +92,21 @@ public:
|
||||
vtkm::Id ny,
|
||||
T* xvals,
|
||||
T* yvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
T zvals = 0;
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
nx, ny, 1, xvals, yvals, &zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(nx, ny, 1, xvals, yvals, &zvals, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::cont::ArrayHandle<T>& xvals,
|
||||
const vtkm::cont::ArrayHandle<T>& yvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> zvals;
|
||||
zvals.Allocate(1);
|
||||
zvals.GetPortalControl().Set(0, 0.0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
//3D grids.
|
||||
@ -125,31 +117,27 @@ public:
|
||||
T* xvals,
|
||||
T* yvals,
|
||||
T* zvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
nx, ny, nz, xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(nx, ny, nz, xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xvals,
|
||||
const std::vector<T>& yvals,
|
||||
const std::vector<T>& zvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::cont::ArrayHandle<T>& xvals,
|
||||
const vtkm::cont::ArrayHandle<T>& yvals,
|
||||
const vtkm::cont::ArrayHandle<T>& zvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(xvals, yvals, zvals, coordNm);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -157,15 +145,14 @@ private:
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(const std::vector<T>& xvals,
|
||||
const std::vector<T>& yvals,
|
||||
const std::vector<T>& zvals,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> Xc, Yc, Zc;
|
||||
DataSetBuilderRectilinear::CopyInto(xvals, Xc);
|
||||
DataSetBuilderRectilinear::CopyInto(yvals, Yc);
|
||||
DataSetBuilderRectilinear::CopyInto(zvals, Zc);
|
||||
|
||||
return DataSetBuilderRectilinear::BuildDataSet(Xc, Yc, Zc, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(Xc, Yc, Zc, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -175,23 +162,21 @@ private:
|
||||
const T* xvals,
|
||||
const T* yvals,
|
||||
const T* zvals,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> Xc, Yc, Zc;
|
||||
DataSetBuilderRectilinear::CopyInto(xvals, nx, Xc);
|
||||
DataSetBuilderRectilinear::CopyInto(yvals, ny, Yc);
|
||||
DataSetBuilderRectilinear::CopyInto(zvals, nz, Zc);
|
||||
|
||||
return DataSetBuilderRectilinear::BuildDataSet(Xc, Yc, Zc, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(Xc, Yc, Zc, coordNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(const vtkm::cont::ArrayHandle<T>& X,
|
||||
const vtkm::cont::ArrayHandle<T>& Y,
|
||||
const vtkm::cont::ArrayHandle<T>& Z,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
@ -229,21 +214,21 @@ private:
|
||||
|
||||
if (ndims == 1)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<1> cellSet(cellNm);
|
||||
vtkm::cont::CellSetStructured<1> cellSet;
|
||||
cellSet.SetPointDimensions(dims[0]);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
}
|
||||
else if (ndims == 2)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<2> cellSet(cellNm);
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(dims[0], dims[1]));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
}
|
||||
else if (ndims == 3)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSet(cellNm);
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(dims[0], dims[1], dims[2]));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -22,39 +22,31 @@ DataSetBuilderUniform::DataSetBuilderUniform()
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DataSet DataSetBuilderUniform::Create(const vtkm::Id& dimension,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
return CreateDataSet(vtkm::Id3(dimension, 1, 1), VecType(0), VecType(1), coordNm, cellNm);
|
||||
return CreateDataSet(vtkm::Id3(dimension, 1, 1), VecType(0), VecType(1), coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DataSet DataSetBuilderUniform::Create(const vtkm::Id2& dimensions,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
return CreateDataSet(
|
||||
vtkm::Id3(dimensions[0], dimensions[1], 1), VecType(0), VecType(1), coordNm, cellNm);
|
||||
return CreateDataSet(vtkm::Id3(dimensions[0], dimensions[1], 1), VecType(0), VecType(1), coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DataSet DataSetBuilderUniform::Create(const vtkm::Id3& dimensions,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
return CreateDataSet(vtkm::Id3(dimensions[0], dimensions[1], dimensions[2]),
|
||||
VecType(0),
|
||||
VecType(1),
|
||||
coordNm,
|
||||
cellNm);
|
||||
return CreateDataSet(
|
||||
vtkm::Id3(dimensions[0], dimensions[1], dimensions[2]), VecType(0), VecType(1), coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DataSet DataSetBuilderUniform::CreateDataSet(const vtkm::Id3& dimensions,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing,
|
||||
std::string coordNm,
|
||||
std::string cellNm)
|
||||
const std::string& coordNm)
|
||||
{
|
||||
vtkm::Id dims[3] = { 1, 1, 1 };
|
||||
int ndims = 0;
|
||||
@ -77,21 +69,21 @@ vtkm::cont::DataSet DataSetBuilderUniform::CreateDataSet(const vtkm::Id3& dimens
|
||||
|
||||
if (ndims == 1)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<1> cellSet(cellNm);
|
||||
vtkm::cont::CellSetStructured<1> cellSet;
|
||||
cellSet.SetPointDimensions(dims[0]);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
}
|
||||
else if (ndims == 2)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<2> cellSet(cellNm);
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
cellSet.SetPointDimensions(vtkm::Id2(dims[0], dims[1]));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
}
|
||||
else if (ndims == 3)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSet(cellNm);
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
cellSet.SetPointDimensions(vtkm::Id3(dims[0], dims[1], dims[2]));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -31,29 +31,25 @@ public:
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id& dimension,
|
||||
const T& origin,
|
||||
const T& spacing,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
return DataSetBuilderUniform::CreateDataSet(
|
||||
vtkm::Id3(dimension, 1, 1),
|
||||
VecType(static_cast<vtkm::FloatDefault>(origin), 0, 0),
|
||||
VecType(static_cast<vtkm::FloatDefault>(spacing), 1, 1),
|
||||
coordNm,
|
||||
cellNm);
|
||||
coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static vtkm::cont::DataSet Create(const vtkm::Id& dimension,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells");
|
||||
const std::string& coordNm = "coords");
|
||||
|
||||
//2D uniform grids.
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id2& dimensions,
|
||||
const vtkm::Vec<T, 2>& origin,
|
||||
const vtkm::Vec<T, 2>& spacing,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
return DataSetBuilderUniform::CreateDataSet(vtkm::Id3(dimensions[0], dimensions[1], 1),
|
||||
VecType(static_cast<vtkm::FloatDefault>(origin[0]),
|
||||
@ -62,22 +58,19 @@ public:
|
||||
VecType(static_cast<vtkm::FloatDefault>(spacing[0]),
|
||||
static_cast<vtkm::FloatDefault>(spacing[1]),
|
||||
1),
|
||||
coordNm,
|
||||
cellNm);
|
||||
coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static vtkm::cont::DataSet Create(const vtkm::Id2& dimensions,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells");
|
||||
const std::string& coordNm = "coords");
|
||||
|
||||
//3D uniform grids.
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id3& dimensions,
|
||||
const vtkm::Vec<T, 3>& origin,
|
||||
const vtkm::Vec<T, 3>& spacing,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
const std::string& coordNm = "coords")
|
||||
{
|
||||
return DataSetBuilderUniform::CreateDataSet(
|
||||
vtkm::Id3(dimensions[0], dimensions[1], dimensions[2]),
|
||||
@ -87,22 +80,19 @@ public:
|
||||
VecType(static_cast<vtkm::FloatDefault>(spacing[0]),
|
||||
static_cast<vtkm::FloatDefault>(spacing[1]),
|
||||
static_cast<vtkm::FloatDefault>(spacing[2])),
|
||||
coordNm,
|
||||
cellNm);
|
||||
coordNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static vtkm::cont::DataSet Create(const vtkm::Id3& dimensions,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells");
|
||||
const std::string& coordNm = "coords");
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
static vtkm::cont::DataSet CreateDataSet(const vtkm::Id3& dimensions,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing,
|
||||
std::string coordNm,
|
||||
std::string cellNm);
|
||||
const std::string& coordNm);
|
||||
};
|
||||
|
||||
} // namespace cont
|
||||
|
@ -64,83 +64,36 @@ public:
|
||||
VTKM_CONT
|
||||
static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const vtkm::cont::VariantArrayHandle& field,
|
||||
const std::string& cellSetName)
|
||||
const vtkm::cont::VariantArrayHandle& field)
|
||||
{
|
||||
dataSet.AddField(make_FieldCell(fieldName, cellSetName, field));
|
||||
dataSet.AddField(make_FieldCell(fieldName, field));
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field,
|
||||
const std::string& cellSetName)
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field)
|
||||
{
|
||||
dataSet.AddField(make_FieldCell(fieldName, cellSetName, field));
|
||||
dataSet.AddField(make_FieldCell(fieldName, field));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const std::vector<T>& field,
|
||||
const std::string& cellSetName)
|
||||
const std::vector<T>& field)
|
||||
{
|
||||
dataSet.AddField(
|
||||
make_Field(fieldName, vtkm::cont::Field::Association::CELL_SET, field, vtkm::CopyFlag::On));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const T* field,
|
||||
const vtkm::Id& n)
|
||||
{
|
||||
dataSet.AddField(make_Field(
|
||||
fieldName, vtkm::cont::Field::Association::CELL_SET, cellSetName, field, vtkm::CopyFlag::On));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const T* field,
|
||||
const vtkm::Id& n,
|
||||
const std::string& cellSetName)
|
||||
{
|
||||
dataSet.AddField(make_Field(fieldName,
|
||||
vtkm::cont::Field::Association::CELL_SET,
|
||||
cellSetName,
|
||||
field,
|
||||
n,
|
||||
vtkm::CopyFlag::On));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const vtkm::cont::VariantArrayHandle& field,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
|
||||
}
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
|
||||
}
|
||||
template <typename T>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const std::vector<T>& field,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName,
|
||||
const T* field,
|
||||
const vtkm::Id& n,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, n, cellSetName);
|
||||
fieldName, vtkm::cont::Field::Association::CELL_SET, field, n, vtkm::CopyFlag::On));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -378,6 +378,55 @@ struct DeviceAdapterAlgorithm
|
||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||
vtkm::cont::ArrayHandle<U, VOut>& output);
|
||||
|
||||
/// \brief Compute an extended prefix sum operation on the input ArrayHandle.
|
||||
///
|
||||
/// Computes an extended prefix sum operation on the \c input ArrayHandle,
|
||||
/// storing the results in the \c output ArrayHandle. This produces an output
|
||||
/// array that contains both an inclusive scan (in elements [1, size)) and an
|
||||
/// exclusive scan (in elements [0, size-1)). By using ArrayHandleView,
|
||||
/// arrays containing both inclusive and exclusive scans can be generated
|
||||
/// from an extended scan with minimal memory usage.
|
||||
///
|
||||
/// This algorithm may also be more efficient than ScanInclusive and
|
||||
/// ScanExclusive on some devices, since it may be able to avoid copying the
|
||||
/// total sum to the control environment to return.
|
||||
///
|
||||
/// ScanExtended is similar to the stl partial sum function, exception that
|
||||
/// ScanExtended doesn't do a serial summation. This means that if you have
|
||||
/// defined a custom plus operator for T it must be associative, or you will
|
||||
/// get inconsistent results.
|
||||
///
|
||||
/// This overload of ScanExtended uses vtkm::Add for the binary functor, and
|
||||
/// uses zero for the initial value of the scan operation.
|
||||
///
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static void ScanExtended(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output);
|
||||
|
||||
/// \brief Compute an extended prefix sum operation on the input ArrayHandle.
|
||||
///
|
||||
/// Computes an extended prefix sum operation on the \c input ArrayHandle,
|
||||
/// storing the results in the \c output ArrayHandle. This produces an output
|
||||
/// array that contains both an inclusive scan (in elements [1, size)) and an
|
||||
/// exclusive scan (in elements [0, size-1)). By using ArrayHandleView,
|
||||
/// arrays containing both inclusive and exclusive scans can be generated
|
||||
/// from an extended scan with minimal memory usage.
|
||||
///
|
||||
/// This algorithm may also be more efficient than ScanInclusive and
|
||||
/// ScanExclusive on some devices, since it may be able to avoid copying the
|
||||
/// total sum to the control environment to return.
|
||||
///
|
||||
/// ScanExtended is similar to the stl partial sum function, exception that
|
||||
/// ScanExtended doesn't do a serial summation. This means that if you have
|
||||
/// defined a custom plus operator for T it must be associative, or you will
|
||||
/// get inconsistent results.
|
||||
///
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static void ScanExtended(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binaryFunctor,
|
||||
const T& initialValue);
|
||||
|
||||
/// \brief Schedule many instances of a function to run on concurrent threads.
|
||||
///
|
||||
/// Calls the \c functor on several threads. This is the function used in the
|
||||
|
@ -174,9 +174,6 @@ public:
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CellSet* GetCellSetBase() const { return this->CellSet.get(); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string GetName() const { return this->CellSet ? this->CellSet->GetName() : std::string{}; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfCells() const
|
||||
{
|
||||
|
@ -20,36 +20,16 @@ VTKM_CONT
|
||||
Field::Field(std::string name, Association association, const vtkm::cont::VariantArrayHandle& data)
|
||||
: Name(name)
|
||||
, FieldAssociation(association)
|
||||
, AssocCellSetName()
|
||||
, Data(data)
|
||||
, Range()
|
||||
, ModifiedFlag(true)
|
||||
{
|
||||
VTKM_ASSERT(this->FieldAssociation == Association::WHOLE_MESH ||
|
||||
this->FieldAssociation == Association::POINTS);
|
||||
}
|
||||
|
||||
/// constructors for cell set associations
|
||||
VTKM_CONT
|
||||
Field::Field(std::string name,
|
||||
Association association,
|
||||
const std::string& cellSetName,
|
||||
const vtkm::cont::VariantArrayHandle& data)
|
||||
: Name(name)
|
||||
, FieldAssociation(association)
|
||||
, AssocCellSetName(cellSetName)
|
||||
, Data(data)
|
||||
, Range()
|
||||
, ModifiedFlag(true)
|
||||
{
|
||||
VTKM_ASSERT(this->FieldAssociation == Association::CELL_SET);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Field::Field(const vtkm::cont::Field& src)
|
||||
: Name(src.Name)
|
||||
, FieldAssociation(src.FieldAssociation)
|
||||
, AssocCellSetName(src.AssocCellSetName)
|
||||
, Data(src.Data)
|
||||
, Range(src.Range)
|
||||
, ModifiedFlag(src.ModifiedFlag)
|
||||
@ -59,7 +39,6 @@ Field::Field(const vtkm::cont::Field& src)
|
||||
VTKM_CONT
|
||||
Field::Field(vtkm::cont::Field&& src) noexcept : Name(std::move(src.Name)),
|
||||
FieldAssociation(std::move(src.FieldAssociation)),
|
||||
AssocCellSetName(std::move(src.AssocCellSetName)),
|
||||
Data(std::move(src.Data)),
|
||||
Range(std::move(src.Range)),
|
||||
ModifiedFlag(std::move(src.ModifiedFlag))
|
||||
@ -71,7 +50,6 @@ Field& Field::operator=(const vtkm::cont::Field& src)
|
||||
{
|
||||
this->Name = src.Name;
|
||||
this->FieldAssociation = src.FieldAssociation;
|
||||
this->AssocCellSetName = src.AssocCellSetName;
|
||||
this->Data = src.Data;
|
||||
this->Range = src.Range;
|
||||
this->ModifiedFlag = src.ModifiedFlag;
|
||||
@ -83,7 +61,6 @@ Field& Field::operator=(vtkm::cont::Field&& src) noexcept
|
||||
{
|
||||
this->Name = std::move(src.Name);
|
||||
this->FieldAssociation = std::move(src.FieldAssociation);
|
||||
this->AssocCellSetName = std::move(src.AssocCellSetName);
|
||||
this->Data = std::move(src.Data);
|
||||
this->Range = std::move(src.Range);
|
||||
this->ModifiedFlag = std::move(src.ModifiedFlag);
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
VTKM_CONT
|
||||
Field() = default;
|
||||
|
||||
/// constructors for points / whole mesh
|
||||
VTKM_CONT
|
||||
Field(std::string name, Association association, const vtkm::cont::VariantArrayHandle& data);
|
||||
|
||||
@ -70,22 +69,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/// constructors for cell set associations
|
||||
VTKM_CONT
|
||||
Field(std::string name,
|
||||
Association association,
|
||||
const std::string& cellSetName,
|
||||
const vtkm::cont::VariantArrayHandle& data);
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT Field(std::string name,
|
||||
Association association,
|
||||
const std::string& cellSetName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& data)
|
||||
: Field(name, association, cellSetName, vtkm::cont::VariantArrayHandle{ data })
|
||||
{
|
||||
}
|
||||
|
||||
Field(const vtkm::cont::Field& src);
|
||||
Field(vtkm::cont::Field&& src) noexcept;
|
||||
|
||||
@ -96,7 +79,6 @@ public:
|
||||
|
||||
VTKM_CONT const std::string& GetName() const { return this->Name; }
|
||||
VTKM_CONT Association GetAssociation() const { return this->FieldAssociation; }
|
||||
VTKM_CONT std::string GetAssocCellSet() const { return this->AssocCellSetName; }
|
||||
const vtkm::cont::VariantArrayHandle& GetData() const;
|
||||
vtkm::cont::VariantArrayHandle& GetData();
|
||||
|
||||
@ -161,8 +143,6 @@ private:
|
||||
std::string Name; ///< name of field
|
||||
|
||||
Association FieldAssociation = Association::ANY;
|
||||
std::string AssocCellSetName; ///< only populate if assoc is cells
|
||||
|
||||
vtkm::cont::VariantArrayHandle Data;
|
||||
mutable vtkm::cont::ArrayHandle<vtkm::Range> Range;
|
||||
mutable bool ModifiedFlag = true;
|
||||
@ -211,50 +191,8 @@ vtkm::cont::Field make_Field(std::string name,
|
||||
return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandle(data, copy));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
const std::string& cellSetName,
|
||||
const T* data,
|
||||
vtkm::Id size,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
{
|
||||
return vtkm::cont::Field(
|
||||
name, association, cellSetName, vtkm::cont::make_ArrayHandle(data, size, copy));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
const std::string& cellSetName,
|
||||
const std::vector<T>& data,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
{
|
||||
return vtkm::cont::Field(
|
||||
name, association, cellSetName, vtkm::cont::make_ArrayHandle(data, copy));
|
||||
}
|
||||
|
||||
//@}
|
||||
|
||||
/// Convenience functions to build a point or cell field from vtkm::cont::ArrayHandle
|
||||
/// If \c association is CELL_SET it will
|
||||
template <typename T, typename S>
|
||||
vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
const std::string& cellSetName,
|
||||
const vtkm::cont::ArrayHandle<T, S>& data)
|
||||
{
|
||||
if (association == Field::Association::CELL_SET)
|
||||
{
|
||||
return vtkm::cont::Field(name, association, cellSetName, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vtkm::cont::Field(name, association, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Convenience function to build point fields from vtkm::cont::ArrayHandle
|
||||
template <typename T, typename S>
|
||||
vtkm::cont::Field make_FieldPoint(std::string name, const vtkm::cont::ArrayHandle<T, S>& data)
|
||||
@ -271,20 +209,17 @@ inline vtkm::cont::Field make_FieldPoint(std::string name,
|
||||
|
||||
/// Convenience function to build cell fields from vtkm::cont::ArrayHandle
|
||||
template <typename T, typename S>
|
||||
vtkm::cont::Field make_FieldCell(std::string name,
|
||||
const std::string& cellSetName,
|
||||
const vtkm::cont::ArrayHandle<T, S>& data)
|
||||
vtkm::cont::Field make_FieldCell(std::string name, const vtkm::cont::ArrayHandle<T, S>& data)
|
||||
{
|
||||
return vtkm::cont::Field(name, vtkm::cont::Field::Association::CELL_SET, cellSetName, data);
|
||||
return vtkm::cont::Field(name, vtkm::cont::Field::Association::CELL_SET, data);
|
||||
}
|
||||
|
||||
|
||||
/// Convenience function to build cell fields from vtkm::cont::VariantArrayHandle
|
||||
inline vtkm::cont::Field make_FieldCell(std::string name,
|
||||
const std::string& cellSetName,
|
||||
const vtkm::cont::VariantArrayHandle& data)
|
||||
{
|
||||
return vtkm::cont::Field(name, vtkm::cont::Field::Association::CELL_SET, cellSetName, data);
|
||||
return vtkm::cont::Field(name, vtkm::cont::Field::Association::CELL_SET, data);
|
||||
}
|
||||
|
||||
} // namespace cont
|
||||
@ -343,10 +278,6 @@ public:
|
||||
|
||||
vtkmdiy::save(bb, field.GetName());
|
||||
vtkmdiy::save(bb, static_cast<int>(field.GetAssociation()));
|
||||
if (field.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
|
||||
{
|
||||
vtkmdiy::save(bb, field.GetAssocCellSet());
|
||||
}
|
||||
vtkmdiy::save(bb, field.GetData().ResetTypes(TypeList{}));
|
||||
}
|
||||
|
||||
@ -361,19 +292,8 @@ public:
|
||||
|
||||
auto assoc = static_cast<vtkm::cont::Field::Association>(assocVal);
|
||||
vtkm::cont::VariantArrayHandleBase<TypeList> data;
|
||||
if (assoc == vtkm::cont::Field::Association::CELL_SET)
|
||||
{
|
||||
std::string assocCellSetName;
|
||||
vtkmdiy::load(bb, assocCellSetName);
|
||||
vtkmdiy::load(bb, data);
|
||||
field =
|
||||
vtkm::cont::Field(name, assoc, assocCellSetName, vtkm::cont::VariantArrayHandle(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkmdiy::load(bb, data);
|
||||
field = vtkm::cont::Field(name, assoc, vtkm::cont::VariantArrayHandle(data));
|
||||
}
|
||||
vtkmdiy::load(bb, data);
|
||||
field = vtkm::cont::Field(name, assoc, vtkm::cont::VariantArrayHandle(data));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -29,12 +29,11 @@ vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeCompute(const vtkm::cont::DataSet
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeCompute(const vtkm::cont::MultiBlock& multiblock,
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeCompute(const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc)
|
||||
{
|
||||
return vtkm::cont::detail::FieldRangeComputeImpl(
|
||||
multiblock, name, assoc, VTKM_DEFAULT_TYPE_LIST_TAG());
|
||||
return vtkm::cont::detail::FieldRangeComputeImpl(pds, name, assoc, VTKM_DEFAULT_TYPE_LIST_TAG());
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
#include <vtkm/cont/FieldRangeCompute.hxx>
|
||||
|
||||
@ -20,9 +20,10 @@ namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
/// \brief Compute ranges for fields in a DataSet or MultiBlock.
|
||||
/// \brief Compute ranges for fields in a DataSet or PartitionedDataSet.
|
||||
///
|
||||
/// These methods to compute ranges for fields in a dataset or a multiblock.
|
||||
/// These methods to compute ranges for fields in a single dataset or a
|
||||
/// partitioned dataset.
|
||||
/// When using VTK-m in a hybrid-parallel environment with distributed processing,
|
||||
/// this class uses ranges for locally available data alone. Use FieldRangeGlobalCompute
|
||||
/// to compute ranges globally across all ranks even in distributed mode.
|
||||
@ -51,28 +52,30 @@ VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeCompute(
|
||||
//@}
|
||||
|
||||
//{@
|
||||
/// Returns the range for a field from a multiblock. If the field is not present on any
|
||||
/// of the blocks, an empty ArrayHandle will be returned. If the field is present on some blocks,
|
||||
/// but not all, those blocks without the field are skipped.
|
||||
/// Returns the range for a field from a PartitionedDataSet. If the field is
|
||||
/// not present on any of the partitions, an empty ArrayHandle will be
|
||||
/// returned. If the field is present on some partitions, but not all, those
|
||||
/// partitions without the field are skipped.
|
||||
///
|
||||
/// The returned array handle will have as many values as the maximum number of
|
||||
/// components for the selected field across all partitions.
|
||||
///
|
||||
/// The returned array handle will have as many values as the maximum number of components for
|
||||
/// the selected field across all blocks.
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeCompute(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY);
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeCompute(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc,
|
||||
TypeList)
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
return vtkm::cont::detail::FieldRangeComputeImpl(multiblock, name, assoc, TypeList());
|
||||
return vtkm::cont::detail::FieldRangeComputeImpl(pds, name, assoc, TypeList());
|
||||
}
|
||||
|
||||
//@}
|
||||
|
@ -10,6 +10,12 @@
|
||||
#ifndef vtk_m_cont_FieldRangeCompute_hxx
|
||||
#define vtk_m_cont_FieldRangeCompute_hxx
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
#include <vtkm/Range.h>
|
||||
|
||||
#include <numeric> // for std::accumulate
|
||||
|
||||
namespace vtkm
|
||||
@ -42,26 +48,27 @@ VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeComputeImpl(
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeComputeImpl(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc,
|
||||
TypeList)
|
||||
{
|
||||
std::vector<vtkm::Range> result_vector = std::accumulate(
|
||||
multiblock.begin(),
|
||||
multiblock.end(),
|
||||
pds.begin(),
|
||||
pds.end(),
|
||||
std::vector<vtkm::Range>(),
|
||||
[&](const std::vector<vtkm::Range>& accumulated_value, const vtkm::cont::DataSet& dataset) {
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> block_range =
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> partition_range =
|
||||
vtkm::cont::detail::FieldRangeComputeImpl(dataset, name, assoc, TypeList());
|
||||
|
||||
std::vector<vtkm::Range> result = accumulated_value;
|
||||
|
||||
// if the current block has more components than we have seen so far,
|
||||
// if the current partition has more components than we have seen so far,
|
||||
// resize the result to fit all components.
|
||||
result.resize(std::max(result.size(), static_cast<size_t>(block_range.GetNumberOfValues())));
|
||||
result.resize(
|
||||
std::max(result.size(), static_cast<size_t>(partition_range.GetNumberOfValues())));
|
||||
|
||||
auto portal = block_range.GetPortalConstControl();
|
||||
auto portal = partition_range.GetPortalConstControl();
|
||||
std::transform(vtkm::cont::ArrayPortalToIteratorBegin(portal),
|
||||
vtkm::cont::ArrayPortalToIteratorEnd(portal),
|
||||
result.begin(),
|
||||
|
@ -33,11 +33,11 @@ vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalCompute(const vtkm::cont::D
|
||||
//-----------------------------------------------------------------------------
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalCompute(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc)
|
||||
{
|
||||
return detail::FieldRangeGlobalComputeImpl(multiblock, name, assoc, VTKM_DEFAULT_TYPE_LIST_TAG());
|
||||
return detail::FieldRangeGlobalComputeImpl(pds, name, assoc, VTKM_DEFAULT_TYPE_LIST_TAG());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -20,7 +20,8 @@ namespace cont
|
||||
{
|
||||
/// \brief utility functions to compute global ranges for dataset fields.
|
||||
///
|
||||
/// These functions compute global ranges for fields in a dataset or a multiblock.
|
||||
/// These functions compute global ranges for fields in a single DataSet or a
|
||||
/// PartitionedDataSet.
|
||||
/// In non-distributed environments, this is exactly same as `FieldRangeCompute`. In
|
||||
/// distributed environments, however, the range is computed locally on each rank
|
||||
/// and then a reduce-all collective is performed to reduces the ranges on all ranks.
|
||||
@ -49,28 +50,29 @@ VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalCompute(
|
||||
//@}
|
||||
|
||||
//{@
|
||||
/// Returns the range for a field from a multiblock. If the field is not present on any
|
||||
/// of the blocks, an empty ArrayHandle will be returned. If the field is present on some blocks,
|
||||
/// but not all, those blocks without the field are skipped.
|
||||
/// Returns the range for a field from a PartitionedDataSet. If the field is
|
||||
/// not present on any of the partitions, an empty ArrayHandle will be
|
||||
/// returned. If the field is present on some partitions, but not all, those
|
||||
/// partitions without the field are skipped.
|
||||
///
|
||||
/// The returned array handle will have as many values as the maximum number of components for
|
||||
/// the selected field across all blocks.
|
||||
/// The returned array handle will have as many values as the maximum number of
|
||||
/// components for the selected field across all partitions.
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalCompute(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc = vtkm::cont::Field::Association::ANY);
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalCompute(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc,
|
||||
TypeList)
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
return detail::FieldRangeGlobalComputeImpl(multiblock, name, assoc, TypeList());
|
||||
return detail::FieldRangeGlobalComputeImpl(pds, name, assoc, TypeList());
|
||||
}
|
||||
//@}
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalComputeImpl(
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> FieldRangeGlobalComputeImpl(
|
||||
const vtkm::cont::MultiBlock& multiblock,
|
||||
const vtkm::cont::PartitionedDataSet& pds,
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::Association assoc,
|
||||
TypeList)
|
||||
{
|
||||
auto lrange = vtkm::cont::FieldRangeCompute(multiblock, name, assoc, TypeList());
|
||||
auto lrange = vtkm::cont::FieldRangeCompute(pds, name, assoc, TypeList());
|
||||
return vtkm::cont::detail::MergeRangesGlobal(lrange);
|
||||
}
|
||||
}
|
||||
|
@ -431,6 +431,7 @@ VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
std::string GetStackTrace(vtkm::Int32 skip = 0);
|
||||
|
||||
//@{
|
||||
/// Convert a size in bytes to a human readable string (e.g. "64 bytes",
|
||||
/// "1.44 MiB", "128 GiB", etc). @a prec controls the fixed point precision
|
||||
/// of the stringified number.
|
||||
@ -438,12 +439,27 @@ VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
std::string GetHumanReadableSize(vtkm::UInt64 bytes, int prec = 2);
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT inline std::string GetHumanReadableSize(T&& bytes, int prec = 2)
|
||||
{
|
||||
return GetHumanReadableSize(static_cast<vtkm::UInt64>(std::forward<T>(bytes)), prec);
|
||||
}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// Returns "%1 (%2 bytes)" where %1 is the result from GetHumanReadableSize
|
||||
/// and two is the exact number of bytes.
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
std::string GetSizeString(vtkm::UInt64 bytes, int prec = 2);
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT inline std::string GetSizeString(T&& bytes, int prec = 2)
|
||||
{
|
||||
return GetSizeString(static_cast<vtkm::UInt64>(std::forward<T>(bytes)), prec);
|
||||
}
|
||||
//@}
|
||||
|
||||
/**
|
||||
* Use RTTI information to retrieve the name of the type T. If logging is
|
||||
* enabled and the platform supports it, the type name will also be demangled.
|
||||
|
@ -1,143 +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/StaticAssert.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/ErrorExecution.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/MultiBlock.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock::MultiBlock(const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
this->Blocks.insert(this->Blocks.end(), ds);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock::MultiBlock(const vtkm::cont::MultiBlock& src)
|
||||
{
|
||||
this->Blocks = src.GetBlocks();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock::MultiBlock(const std::vector<vtkm::cont::DataSet>& mblocks)
|
||||
{
|
||||
this->Blocks = mblocks;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock::MultiBlock(vtkm::Id size)
|
||||
{
|
||||
this->Blocks.reserve(static_cast<std::size_t>(size));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock::MultiBlock()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock::~MultiBlock()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock& MultiBlock::operator=(const vtkm::cont::MultiBlock& src)
|
||||
{
|
||||
this->Blocks = src.GetBlocks();
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field MultiBlock::GetField(const std::string& field_name, const int& block_index)
|
||||
{
|
||||
assert(block_index >= 0);
|
||||
assert(static_cast<std::size_t>(block_index) < this->Blocks.size());
|
||||
return this->Blocks[static_cast<std::size_t>(block_index)].GetField(field_name);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id MultiBlock::GetNumberOfBlocks() const
|
||||
{
|
||||
return static_cast<vtkm::Id>(this->Blocks.size());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& MultiBlock::GetBlock(vtkm::Id blockId) const
|
||||
{
|
||||
return this->Blocks[static_cast<std::size_t>(blockId)];
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const std::vector<vtkm::cont::DataSet>& MultiBlock::GetBlocks() const
|
||||
{
|
||||
return this->Blocks;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void MultiBlock::AddBlock(const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
this->Blocks.insert(this->Blocks.end(), ds);
|
||||
return;
|
||||
}
|
||||
|
||||
void MultiBlock::AddBlocks(const std::vector<vtkm::cont::DataSet>& mblocks)
|
||||
{
|
||||
this->Blocks.insert(this->Blocks.end(), mblocks.begin(), mblocks.end());
|
||||
return;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void MultiBlock::InsertBlock(vtkm::Id index, const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
if (index <= static_cast<vtkm::Id>(this->Blocks.size()))
|
||||
this->Blocks.insert(this->Blocks.begin() + index, ds);
|
||||
else
|
||||
{
|
||||
std::string msg = "invalid insert position\n ";
|
||||
throw ErrorExecution(msg);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void MultiBlock::ReplaceBlock(vtkm::Id index, const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
if (index < static_cast<vtkm::Id>(this->Blocks.size()))
|
||||
this->Blocks.at(static_cast<std::size_t>(index)) = ds;
|
||||
else
|
||||
{
|
||||
std::string msg = "invalid replace position\n ";
|
||||
throw ErrorExecution(msg);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void MultiBlock::PrintSummary(std::ostream& stream) const
|
||||
{
|
||||
stream << "block "
|
||||
<< "\n";
|
||||
|
||||
for (size_t block_index = 0; block_index < this->Blocks.size(); ++block_index)
|
||||
{
|
||||
stream << "block " << block_index << "\n";
|
||||
this->Blocks[block_index].PrintSummary(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
@ -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.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_MultiBlock_h
|
||||
#define vtk_m_cont_MultiBlock_h
|
||||
#include <limits>
|
||||
#include <vtkm/StaticAssert.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class VTKM_CONT_EXPORT MultiBlock
|
||||
{
|
||||
public:
|
||||
/// create a new MultiBlock containng a single DataSet "ds"
|
||||
VTKM_CONT
|
||||
MultiBlock(const vtkm::cont::DataSet& ds);
|
||||
/// create a new MultiBlock with the existing one "src"
|
||||
VTKM_CONT
|
||||
MultiBlock(const vtkm::cont::MultiBlock& src);
|
||||
/// create a new MultiBlock with a DataSet vector "mblocks"
|
||||
VTKM_CONT
|
||||
explicit MultiBlock(const std::vector<vtkm::cont::DataSet>& mblocks);
|
||||
/// create a new MultiBlock with the capacity set to be "size"
|
||||
VTKM_CONT
|
||||
explicit MultiBlock(vtkm::Id size);
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock();
|
||||
|
||||
VTKM_CONT
|
||||
MultiBlock& operator=(const vtkm::cont::MultiBlock& src);
|
||||
|
||||
VTKM_CONT
|
||||
~MultiBlock();
|
||||
/// get the field "field_name" from block "block_index"
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field GetField(const std::string& field_name, const int& block_index);
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfBlocks() const;
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& GetBlock(vtkm::Id blockId) const;
|
||||
|
||||
VTKM_CONT
|
||||
const std::vector<vtkm::cont::DataSet>& GetBlocks() const;
|
||||
/// add DataSet "ds" to the end of the contained DataSet vector
|
||||
VTKM_CONT
|
||||
void AddBlock(const vtkm::cont::DataSet& ds);
|
||||
/// add DataSet "ds" to position "index" of the contained DataSet vector
|
||||
VTKM_CONT
|
||||
void InsertBlock(vtkm::Id index, const vtkm::cont::DataSet& ds);
|
||||
/// replace the "index" positioned element of the contained DataSet vector with "ds"
|
||||
VTKM_CONT
|
||||
void ReplaceBlock(vtkm::Id index, const vtkm::cont::DataSet& ds);
|
||||
/// append the DataSet vector "mblocks" to the end of the contained one
|
||||
VTKM_CONT
|
||||
void AddBlocks(const std::vector<vtkm::cont::DataSet>& mblocks);
|
||||
|
||||
VTKM_CONT
|
||||
void PrintSummary(std::ostream& stream) const;
|
||||
|
||||
//@{
|
||||
/// API to support range-based for loops on blocks.
|
||||
std::vector<DataSet>::iterator begin() noexcept { return this->Blocks.begin(); }
|
||||
std::vector<DataSet>::iterator end() noexcept { return this->Blocks.end(); }
|
||||
std::vector<DataSet>::const_iterator begin() const noexcept { return this->Blocks.begin(); }
|
||||
std::vector<DataSet>::const_iterator end() const noexcept { return this->Blocks.end(); }
|
||||
std::vector<DataSet>::const_iterator cbegin() const noexcept { return this->Blocks.begin(); }
|
||||
std::vector<DataSet>::const_iterator cend() const noexcept { return this->Blocks.end(); }
|
||||
//@}
|
||||
private:
|
||||
std::vector<vtkm::cont::DataSet> Blocks;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#endif
|
143
vtkm/cont/PartitionedDataSet.cxx
Normal file
143
vtkm/cont/PartitionedDataSet.cxx
Normal file
@ -0,0 +1,143 @@
|
||||
//============================================================================
|
||||
// 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/StaticAssert.h>
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
#include <vtkm/cont/PartitionedDataSet.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet::PartitionedDataSet(const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
this->Partitions.insert(this->Partitions.end(), ds);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet::PartitionedDataSet(const vtkm::cont::PartitionedDataSet& src)
|
||||
{
|
||||
this->Partitions = src.GetPartitions();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet::PartitionedDataSet(const std::vector<vtkm::cont::DataSet>& partitions)
|
||||
{
|
||||
this->Partitions = partitions;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet::PartitionedDataSet(vtkm::Id size)
|
||||
{
|
||||
this->Partitions.reserve(static_cast<std::size_t>(size));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet::PartitionedDataSet()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet::~PartitionedDataSet()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet& PartitionedDataSet::operator=(const vtkm::cont::PartitionedDataSet& src)
|
||||
{
|
||||
this->Partitions = src.GetPartitions();
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field PartitionedDataSet::GetField(const std::string& field_name, int partition_index)
|
||||
{
|
||||
assert(partition_index >= 0);
|
||||
assert(static_cast<std::size_t>(partition_index) < this->Partitions.size());
|
||||
return this->Partitions[static_cast<std::size_t>(partition_index)].GetField(field_name);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id PartitionedDataSet::GetNumberOfPartitions() const
|
||||
{
|
||||
return static_cast<vtkm::Id>(this->Partitions.size());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& PartitionedDataSet::GetPartition(vtkm::Id blockId) const
|
||||
{
|
||||
return this->Partitions[static_cast<std::size_t>(blockId)];
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const std::vector<vtkm::cont::DataSet>& PartitionedDataSet::GetPartitions() const
|
||||
{
|
||||
return this->Partitions;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void PartitionedDataSet::AppendPartition(const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
this->Partitions.insert(this->Partitions.end(), ds);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void PartitionedDataSet::AppendPartitions(const std::vector<vtkm::cont::DataSet>& partitions)
|
||||
{
|
||||
this->Partitions.insert(this->Partitions.end(), partitions.begin(), partitions.end());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void PartitionedDataSet::InsertPartition(vtkm::Id index, const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
if (index <= static_cast<vtkm::Id>(this->Partitions.size()))
|
||||
{
|
||||
this->Partitions.insert(this->Partitions.begin() + index, ds);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string msg = "invalid insert position\n ";
|
||||
throw ErrorBadValue(msg);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void PartitionedDataSet::ReplacePartition(vtkm::Id index, const vtkm::cont::DataSet& ds)
|
||||
{
|
||||
if (index < static_cast<vtkm::Id>(this->Partitions.size()))
|
||||
this->Partitions.at(static_cast<std::size_t>(index)) = ds;
|
||||
else
|
||||
{
|
||||
std::string msg = "invalid replace position\n ";
|
||||
throw ErrorBadValue(msg);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void PartitionedDataSet::PrintSummary(std::ostream& stream) const
|
||||
{
|
||||
stream << "PartitionedDataSet [" << this->Partitions.size() << " partitions]:\n";
|
||||
|
||||
for (size_t part = 0; part < this->Partitions.size(); ++part)
|
||||
{
|
||||
stream << "Partition " << part << ":\n";
|
||||
this->Partitions[part].PrintSummary(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
111
vtkm/cont/PartitionedDataSet.h
Normal file
111
vtkm/cont/PartitionedDataSet.h
Normal file
@ -0,0 +1,111 @@
|
||||
//============================================================================
|
||||
// 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_cont_PartitionedDataSet_h
|
||||
#define vtk_m_cont_PartitionedDataSet_h
|
||||
#include <limits>
|
||||
#include <vtkm/StaticAssert.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class VTKM_CONT_EXPORT PartitionedDataSet
|
||||
{
|
||||
using StorageVec = std::vector<vtkm::cont::DataSet>;
|
||||
|
||||
public:
|
||||
using iterator = typename StorageVec::iterator;
|
||||
using const_iterator = typename StorageVec::const_iterator;
|
||||
using value_type = typename StorageVec::value_type;
|
||||
using reference = typename StorageVec::reference;
|
||||
using const_reference = typename StorageVec::const_reference;
|
||||
|
||||
/// create a new PartitionedDataSet containng a single DataSet @a ds
|
||||
VTKM_CONT
|
||||
PartitionedDataSet(const vtkm::cont::DataSet& ds);
|
||||
/// create a new PartitionedDataSet with the existing one @a src
|
||||
VTKM_CONT
|
||||
PartitionedDataSet(const vtkm::cont::PartitionedDataSet& src);
|
||||
/// create a new PartitionedDataSet with a DataSet vector @a partitions.
|
||||
VTKM_CONT
|
||||
explicit PartitionedDataSet(const std::vector<vtkm::cont::DataSet>& partitions);
|
||||
/// create a new PartitionedDataSet with the capacity set to be @a size
|
||||
VTKM_CONT
|
||||
explicit PartitionedDataSet(vtkm::Id size);
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet();
|
||||
|
||||
VTKM_CONT
|
||||
PartitionedDataSet& operator=(const vtkm::cont::PartitionedDataSet& src);
|
||||
|
||||
VTKM_CONT
|
||||
~PartitionedDataSet();
|
||||
/// get the field @a field_name from partition @a partition_index
|
||||
VTKM_CONT
|
||||
vtkm::cont::Field GetField(const std::string& field_name, int partition_index);
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfPartitions() const;
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& GetPartition(vtkm::Id partId) const;
|
||||
|
||||
VTKM_CONT
|
||||
const std::vector<vtkm::cont::DataSet>& GetPartitions() const;
|
||||
|
||||
/// add DataSet @a ds to the end of the contained DataSet vector
|
||||
VTKM_CONT
|
||||
void AppendPartition(const vtkm::cont::DataSet& ds);
|
||||
|
||||
/// add DataSet @a ds to position @a index of the contained DataSet vector
|
||||
VTKM_CONT
|
||||
void InsertPartition(vtkm::Id index, const vtkm::cont::DataSet& ds);
|
||||
|
||||
/// replace the @a index positioned element of the contained DataSet vector
|
||||
/// with @a ds
|
||||
VTKM_CONT
|
||||
void ReplacePartition(vtkm::Id index, const vtkm::cont::DataSet& ds);
|
||||
|
||||
/// append the DataSet vector "partitions" to the end of the contained one
|
||||
VTKM_CONT
|
||||
void AppendPartitions(const std::vector<vtkm::cont::DataSet>& partitions);
|
||||
|
||||
VTKM_CONT
|
||||
void PrintSummary(std::ostream& stream) const;
|
||||
|
||||
//@{
|
||||
/// API to support range-based for loops on partitions.
|
||||
VTKM_CONT
|
||||
iterator begin() noexcept { return this->Partitions.begin(); }
|
||||
VTKM_CONT
|
||||
iterator end() noexcept { return this->Partitions.end(); }
|
||||
VTKM_CONT
|
||||
const_iterator begin() const noexcept { return this->Partitions.begin(); }
|
||||
VTKM_CONT
|
||||
const_iterator end() const noexcept { return this->Partitions.end(); }
|
||||
VTKM_CONT
|
||||
const_iterator cbegin() const noexcept { return this->Partitions.cbegin(); }
|
||||
VTKM_CONT
|
||||
const_iterator cend() const noexcept { return this->Partitions.cend(); }
|
||||
//@}
|
||||
private:
|
||||
std::vector<vtkm::cont::DataSet> Partitions;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#endif
|
@ -169,6 +169,17 @@ void RuntimeDeviceTracker::ForceDevice(DeviceAdapterId deviceId)
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RuntimeDeviceTracker::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
for (vtkm::Int8 i = 1; i < VTKM_MAX_DEVICE_ADAPTER_ID; ++i)
|
||||
{
|
||||
auto dev = vtkm::cont::make_DeviceAdapterId(i);
|
||||
out << " - Device " << static_cast<vtkm::Int32>(i) << " (" << dev.GetName()
|
||||
<< "): Enabled=" << this->CanRunOn(dev) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ScopedRuntimeDeviceTracker::ScopedRuntimeDeviceTracker(vtkm::cont::DeviceAdapterId device,
|
||||
RuntimeDeviceTrackerMode mode)
|
||||
|
@ -110,6 +110,8 @@ public:
|
||||
///
|
||||
VTKM_CONT void ForceDevice(DeviceAdapterId deviceId);
|
||||
|
||||
VTKM_CONT void PrintSummary(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
friend struct ScopedRuntimeDeviceTracker;
|
||||
|
||||
|
@ -53,7 +53,7 @@ void TransportWholeCellSetIn(Device)
|
||||
{
|
||||
//build a fake cell set
|
||||
const int nVerts = 5;
|
||||
vtkm::cont::CellSetExplicit<> contObject("cells");
|
||||
vtkm::cont::CellSetExplicit<> contObject;
|
||||
contObject.PrepareToAddCells(2, 7);
|
||||
contObject.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, vtkm::make_Vec<vtkm::Id>(0, 1, 2));
|
||||
contObject.AddCell(vtkm::CELL_SHAPE_QUAD, 4, vtkm::make_Vec<vtkm::Id>(2, 1, 3, 4));
|
||||
|
@ -1,152 +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_cont_internal_ArrayPortalShrink_h
|
||||
#define vtk_m_cont_internal_ArrayPortalShrink_h
|
||||
|
||||
#include <vtkm/Assert.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/cont/ArrayPortal.h>
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// This ArrayPortal adapter is a utility that allows you to shrink the
|
||||
/// (reported) array size without actually modifying the underlying allocation.
|
||||
///
|
||||
template <class PortalT>
|
||||
class ArrayPortalShrink
|
||||
{
|
||||
public:
|
||||
using DelegatePortalType = PortalT;
|
||||
|
||||
using ValueType = typename DelegatePortalType::ValueType;
|
||||
|
||||
VTKM_CONT ArrayPortalShrink()
|
||||
: NumberOfValues(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT ArrayPortalShrink(const DelegatePortalType& delegatePortal)
|
||||
: DelegatePortal(delegatePortal)
|
||||
, NumberOfValues(delegatePortal.GetNumberOfValues())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT ArrayPortalShrink(const DelegatePortalType& delegatePortal, vtkm::Id numberOfValues)
|
||||
: DelegatePortal(delegatePortal)
|
||||
, NumberOfValues(numberOfValues)
|
||||
{
|
||||
VTKM_ASSERT(numberOfValues <= delegatePortal.GetNumberOfValues());
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalShrink with a delegate type
|
||||
/// that can be copied to this type. This allows us to do any type casting
|
||||
/// the delegates can do (like the non-const to const cast).
|
||||
///
|
||||
template <class OtherDelegateType>
|
||||
VTKM_CONT ArrayPortalShrink(const ArrayPortalShrink<OtherDelegateType>& src)
|
||||
: DelegatePortal(src.GetDelegatePortal())
|
||||
, NumberOfValues(src.GetNumberOfValues())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
||||
|
||||
VTKM_CONT
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
VTKM_ASSERT(index >= 0);
|
||||
VTKM_ASSERT(index < this->GetNumberOfValues());
|
||||
return this->DelegatePortal.Get(index);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
VTKM_ASSERT(index >= 0);
|
||||
VTKM_ASSERT(index < this->GetNumberOfValues());
|
||||
this->DelegatePortal.Set(index, value);
|
||||
}
|
||||
|
||||
/// Special method in this ArrayPortal that allows you to shrink the
|
||||
/// (exposed) array.
|
||||
///
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues)
|
||||
{
|
||||
VTKM_ASSERT(numberOfValues < this->GetNumberOfValues());
|
||||
this->NumberOfValues = numberOfValues;
|
||||
}
|
||||
|
||||
/// Get a copy of the delegate portal. Although safe, this is probably only
|
||||
/// useful internally. (It is exposed as public for the templated copy
|
||||
/// constructor.)
|
||||
///
|
||||
DelegatePortalType GetDelegatePortal() const { return this->DelegatePortal; }
|
||||
|
||||
private:
|
||||
DelegatePortalType DelegatePortal;
|
||||
vtkm::Id NumberOfValues;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont::internal
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename DelegatePortalType>
|
||||
class ArrayPortalToIterators<vtkm::cont::internal::ArrayPortalShrink<DelegatePortalType>>
|
||||
{
|
||||
using PortalType = vtkm::cont::internal::ArrayPortalShrink<DelegatePortalType>;
|
||||
using DelegateArrayPortalToIterators = vtkm::cont::ArrayPortalToIterators<DelegatePortalType>;
|
||||
|
||||
public:
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalToIterators(const PortalType& portal)
|
||||
: DelegateIterators(portal.GetDelegatePortal())
|
||||
, NumberOfValues(portal.GetNumberOfValues())
|
||||
{
|
||||
}
|
||||
|
||||
using IteratorType = typename DelegateArrayPortalToIterators::IteratorType;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
IteratorType GetBegin() const { return this->DelegateIterators.GetBegin(); }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
IteratorType GetEnd() const
|
||||
{
|
||||
IteratorType iterator = this->GetBegin();
|
||||
std::advance(iterator, this->NumberOfValues);
|
||||
return iterator;
|
||||
}
|
||||
|
||||
private:
|
||||
DelegateArrayPortalToIterators DelegateIterators;
|
||||
vtkm::Id NumberOfValues;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#endif //vtk_m_cont_internal_ArrayPortalShrink_h
|
@ -16,7 +16,6 @@ set(headers
|
||||
ArrayManagerExecution.h
|
||||
ArrayManagerExecutionShareWithControl.h
|
||||
ArrayPortalFromIterators.h
|
||||
ArrayPortalShrink.h
|
||||
ArrayTransfer.h
|
||||
AtomicInterfaceControl.h
|
||||
AtomicInterfaceExecution.h
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <vtkm/cont/ArrayHandleImplicit.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ArrayHandleStreaming.h>
|
||||
#include <vtkm/cont/ArrayHandleView.h>
|
||||
#include <vtkm/cont/ArrayHandleZip.h>
|
||||
#include <vtkm/cont/BitField.h>
|
||||
#include <vtkm/cont/Logging.h>
|
||||
@ -660,6 +661,7 @@ public:
|
||||
vtkm::Id numValues = input.GetNumberOfValues();
|
||||
if (numValues <= 0)
|
||||
{
|
||||
output.Shrink(0);
|
||||
return initialValue;
|
||||
}
|
||||
|
||||
@ -687,6 +689,50 @@ public:
|
||||
input, output, vtkm::Sum(), vtkm::TypeTraits<T>::ZeroInitialization());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Scan Exclusive Extend
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static void ScanExtended(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binaryFunctor,
|
||||
const T& initialValue)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
vtkm::Id numValues = input.GetNumberOfValues();
|
||||
if (numValues <= 0)
|
||||
{
|
||||
output.Allocate(1);
|
||||
output.GetPortalControl().Set(0, initialValue);
|
||||
return;
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic> inclusiveScan;
|
||||
T result = DerivedAlgorithm::ScanInclusive(input, inclusiveScan, binaryFunctor);
|
||||
|
||||
auto inputPortal = inclusiveScan.PrepareForInput(DeviceAdapterTag());
|
||||
auto outputPortal = output.PrepareForOutput(numValues + 1, DeviceAdapterTag());
|
||||
|
||||
InclusiveToExtendedKernel<decltype(inputPortal), decltype(outputPortal), BinaryFunctor>
|
||||
inclusiveToExtended(inputPortal,
|
||||
outputPortal,
|
||||
binaryFunctor,
|
||||
initialValue,
|
||||
binaryFunctor(initialValue, result));
|
||||
|
||||
DerivedAlgorithm::Schedule(inclusiveToExtended, numValues + 1);
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static void ScanExtended(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
DerivedAlgorithm::ScanExtended(
|
||||
input, output, vtkm::Sum(), vtkm::TypeTraits<T>::ZeroInitialization());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Scan Exclusive By Key
|
||||
template <typename KeyT,
|
||||
|
@ -1106,9 +1106,50 @@ struct InclusiveToExclusiveKernel : vtkm::exec::FunctorBase
|
||||
VTKM_EXEC
|
||||
void operator()(vtkm::Id index) const
|
||||
{
|
||||
ValueType result = (index == 0)
|
||||
const ValueType result = (index == 0)
|
||||
? this->InitialValue
|
||||
: this->BinaryOperator(this->InitialValue, this->InPortal.Get(index - 1));
|
||||
|
||||
this->OutPortal.Set(index, result);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename InPortalType, typename OutPortalType, typename BinaryFunctor>
|
||||
struct InclusiveToExtendedKernel : vtkm::exec::FunctorBase
|
||||
{
|
||||
using ValueType = typename InPortalType::ValueType;
|
||||
|
||||
InPortalType InPortal;
|
||||
OutPortalType OutPortal;
|
||||
BinaryFunctor BinaryOperator;
|
||||
ValueType InitialValue;
|
||||
ValueType FinalValue;
|
||||
|
||||
VTKM_CONT
|
||||
InclusiveToExtendedKernel(const InPortalType& inPortal,
|
||||
const OutPortalType& outPortal,
|
||||
BinaryFunctor& binaryOperator,
|
||||
ValueType initialValue,
|
||||
ValueType finalValue)
|
||||
: InPortal(inPortal)
|
||||
, OutPortal(outPortal)
|
||||
, BinaryOperator(binaryOperator)
|
||||
, InitialValue(initialValue)
|
||||
, FinalValue(finalValue)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
void operator()(vtkm::Id index) const
|
||||
{
|
||||
// The output array has one more value than the input, which holds the
|
||||
// total sum.
|
||||
const ValueType result =
|
||||
(index == 0) ? this->InitialValue : (index == this->InPortal.GetNumberOfValues())
|
||||
? this->FinalValue
|
||||
: this->BinaryOperator(this->InitialValue, this->InPortal.Get(index - 1));
|
||||
|
||||
this->OutPortal.Set(index, result);
|
||||
}
|
||||
};
|
||||
|
@ -19,6 +19,8 @@ void DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>::ScheduleTask(
|
||||
vtkm::exec::serial::internal::TaskTiling1D& functor,
|
||||
vtkm::Id size)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
const vtkm::Id MESSAGE_SIZE = 1024;
|
||||
char errorString[MESSAGE_SIZE];
|
||||
errorString[0] = '\0';
|
||||
@ -44,6 +46,8 @@ void DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>::ScheduleTask(
|
||||
vtkm::exec::serial::internal::TaskTiling3D& functor,
|
||||
vtkm::Id3 size)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
const vtkm::Id MESSAGE_SIZE = 1024;
|
||||
char errorString[MESSAGE_SIZE];
|
||||
errorString[0] = '\0';
|
||||
|
@ -69,6 +69,8 @@ public:
|
||||
VTKM_CONT static void Copy(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<U, COut>& output)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
const vtkm::Id inSize = input.GetNumberOfValues();
|
||||
auto inputPortal = input.PrepareForInput(DeviceAdapterTagSerial());
|
||||
auto outputPortal = output.PrepareForOutput(inSize, DeviceAdapterTagSerial());
|
||||
@ -92,6 +94,8 @@ public:
|
||||
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
::vtkm::NotZeroInitialized unary_predicate;
|
||||
CopyIf(input, stencil, output, unary_predicate);
|
||||
}
|
||||
@ -102,6 +106,8 @@ public:
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
UnaryPredicate predicate)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
vtkm::Id inputSize = input.GetNumberOfValues();
|
||||
VTKM_ASSERT(inputSize == stencil.GetNumberOfValues());
|
||||
|
||||
@ -131,6 +137,8 @@ public:
|
||||
vtkm::cont::ArrayHandle<U, COut>& output,
|
||||
vtkm::Id outputIndex = 0)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
const vtkm::Id inSize = input.GetNumberOfValues();
|
||||
|
||||
// Check if the ranges overlap and fail if they do.
|
||||
@ -191,6 +199,8 @@ public:
|
||||
template <typename T, typename U, class CIn>
|
||||
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
return Reduce(input, initialValue, vtkm::Add());
|
||||
}
|
||||
|
||||
@ -199,6 +209,8 @@ public:
|
||||
U initialValue,
|
||||
BinaryFunctor binary_functor)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
internal::WrappedBinaryOperator<U, BinaryFunctor> wrappedOp(binary_functor);
|
||||
auto inputPortal = input.PrepareForInput(Device());
|
||||
return std::accumulate(vtkm::cont::ArrayPortalToIteratorBegin(inputPortal),
|
||||
@ -220,6 +232,8 @@ public:
|
||||
vtkm::cont::ArrayHandle<U, VOut>& values_output,
|
||||
BinaryFunctor binary_functor)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
auto keysPortalIn = keys.PrepareForInput(Device());
|
||||
auto valuesPortalIn = values.PrepareForInput(Device());
|
||||
const vtkm::Id numberOfKeys = keys.GetNumberOfValues();
|
||||
@ -275,6 +289,8 @@ public:
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
internal::WrappedBinaryOperator<T, BinaryFunctor> wrappedBinaryOp(binary_functor);
|
||||
|
||||
vtkm::Id numberOfValues = input.GetNumberOfValues();
|
||||
@ -300,6 +316,8 @@ public:
|
||||
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
return ScanInclusive(input, output, vtkm::Sum());
|
||||
}
|
||||
|
||||
@ -309,6 +327,8 @@ public:
|
||||
BinaryFunctor binaryFunctor,
|
||||
const T& initialValue)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
internal::WrappedBinaryOperator<T, BinaryFunctor> wrappedBinaryOp(binaryFunctor);
|
||||
|
||||
vtkm::Id numberOfValues = input.GetNumberOfValues();
|
||||
@ -347,6 +367,8 @@ public:
|
||||
VTKM_CONT static T ScanExclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
return ScanExclusive(input, output, vtkm::Sum(), vtkm::TypeTraits<T>::ZeroInitialization());
|
||||
}
|
||||
|
||||
@ -358,6 +380,8 @@ public:
|
||||
template <class FunctorType>
|
||||
VTKM_CONT static inline void Schedule(FunctorType functor, vtkm::Id size)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
vtkm::exec::serial::internal::TaskTiling1D kernel(functor);
|
||||
ScheduleTask(kernel, size);
|
||||
}
|
||||
@ -365,6 +389,8 @@ public:
|
||||
template <class FunctorType>
|
||||
VTKM_CONT static inline void Schedule(FunctorType functor, vtkm::Id3 size)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
vtkm::exec::serial::internal::TaskTiling3D kernel(functor);
|
||||
ScheduleTask(kernel, size);
|
||||
}
|
||||
@ -380,6 +406,8 @@ private:
|
||||
vtkm::cont::ArrayHandle<I, StorageI>& index,
|
||||
vtkm::cont::ArrayHandle<Vout, StorageVout>& values_out)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
const vtkm::Id n = values.GetNumberOfValues();
|
||||
VTKM_ASSERT(n == index.GetNumberOfValues());
|
||||
|
||||
@ -400,6 +428,8 @@ private:
|
||||
vtkm::cont::ArrayHandle<U, StorageU>& values,
|
||||
BinaryCompare binary_compare)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
//combine the keys and values into a ZipArrayHandle
|
||||
//we than need to specify a custom compare function wrapper
|
||||
//that only checks for key side of the pair, using the custom compare
|
||||
@ -413,6 +443,8 @@ public:
|
||||
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||
vtkm::cont::ArrayHandle<U, StorageU>& values)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
SortByKey(keys, values, std::less<T>());
|
||||
}
|
||||
|
||||
@ -421,6 +453,8 @@ public:
|
||||
vtkm::cont::ArrayHandle<U, StorageU>& values,
|
||||
const BinaryCompare& binary_compare)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
|
||||
constexpr bool larger_than_64bits = sizeof(U) > sizeof(vtkm::Int64);
|
||||
if (larger_than_64bits)
|
||||
@ -444,6 +478,8 @@ public:
|
||||
template <typename T, class Storage>
|
||||
VTKM_CONT static void Sort(vtkm::cont::ArrayHandle<T, Storage>& values)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
Sort(values, std::less<T>());
|
||||
}
|
||||
|
||||
@ -451,6 +487,8 @@ public:
|
||||
VTKM_CONT static void Sort(vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||
BinaryCompare binary_compare)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
auto arrayPortal = values.PrepareForInPlace(Device());
|
||||
vtkm::cont::ArrayPortalToIterators<decltype(arrayPortal)> iterators(arrayPortal);
|
||||
|
||||
@ -461,6 +499,8 @@ public:
|
||||
template <typename T, class Storage>
|
||||
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
Unique(values, std::equal_to<T>());
|
||||
}
|
||||
|
||||
@ -468,6 +508,8 @@ public:
|
||||
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||
BinaryCompare binary_compare)
|
||||
{
|
||||
VTKM_LOG_SCOPE_FUNCTION(vtkm::cont::LogLevel::Perf);
|
||||
|
||||
auto arrayPortal = values.PrepareForInPlace(Device());
|
||||
vtkm::cont::ArrayPortalToIterators<decltype(arrayPortal)> iterators(arrayPortal);
|
||||
internal::WrappedBinaryOperator<bool, BinaryCompare> wrappedCompare(binary_compare);
|
||||
|
@ -72,7 +72,7 @@ set(unit_tests
|
||||
UnitTestInitialize.cxx
|
||||
UnitTestLogging.cxx
|
||||
UnitTestMoveConstructors.cxx
|
||||
UnitTestMultiBlock.cxx
|
||||
UnitTestPartitionedDataSet.cxx
|
||||
UnitTestRuntimeDeviceInformation.cxx
|
||||
UnitTestRuntimeDeviceNames.cxx
|
||||
UnitTestScopedRuntimeDeviceTracker.cxx
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
vtkm::cont::DataSet Make3DUniformDataSet0();
|
||||
vtkm::cont::DataSet Make3DUniformDataSet1();
|
||||
vtkm::cont::DataSet Make3DUniformDataSet2();
|
||||
vtkm::cont::DataSet Make3DUniformDataSet3(const vtkm::Id3 dims);
|
||||
vtkm::cont::DataSet Make3DUniformDataSet3(const vtkm::Id3 dims = vtkm::Id3(10));
|
||||
vtkm::cont::DataSet Make3DRegularDataSet0();
|
||||
vtkm::cont::DataSet Make3DRegularDataSet1();
|
||||
|
||||
@ -156,7 +156,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make1DExplicitDataSet0()
|
||||
vtkm::cont::DataSet dataSet;
|
||||
vtkm::cont::DataSetBuilderExplicit dsb;
|
||||
|
||||
dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), 2, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, vtkm::CellShapeTagLine(), 2, conn, "coordinates");
|
||||
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
constexpr vtkm::Float32 var[nVerts] = { -1.0f, .5f, -.2f, 1.7f, .8f };
|
||||
@ -179,7 +179,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet0()
|
||||
dsf.AddPointField(dataSet, "pointvar", var, nVerts);
|
||||
|
||||
constexpr vtkm::Float32 cellvar[2] = { 100.1f, 200.1f };
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 2);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -204,7 +204,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet1()
|
||||
};
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -259,7 +259,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet0()
|
||||
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
|
||||
|
||||
constexpr vtkm::Float32 cellvar[4] = { 100.1f, 100.2f, 100.3f, 100.4f };
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 4, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 4);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -305,7 +305,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet1()
|
||||
};
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -409,7 +409,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make2DRectilinearDataSet0()
|
||||
vtkm::Float32 cellvar[nCells];
|
||||
for (int i = 0; i < nCells; i++)
|
||||
cellvar[i] = (vtkm::Float32)i;
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -433,12 +433,12 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet0()
|
||||
//Set cell scalar
|
||||
vtkm::Float32 cellvar[4] = { 100.1f, 100.2f, 100.3f, 100.4f };
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, "cells", cellvar, 4, vtkm::CopyFlag::On));
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 4, vtkm::CopyFlag::On));
|
||||
|
||||
static constexpr vtkm::IdComponent dim = 3;
|
||||
vtkm::cont::CellSetStructured<dim> cellSet("cells");
|
||||
vtkm::cont::CellSetStructured<dim> cellSet;
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(3, 2, 3));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -460,12 +460,12 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DRegularDataSet1()
|
||||
//Set cell scalar
|
||||
vtkm::Float32 cellvar[1] = { 100.1f };
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, "cells", cellvar, 1, vtkm::CopyFlag::On));
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On));
|
||||
|
||||
static constexpr vtkm::IdComponent dim = 3;
|
||||
vtkm::cont::CellSetStructured<dim> cellSet("cells");
|
||||
vtkm::cont::CellSetStructured<dim> cellSet;
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(2, 2, 2));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -497,7 +497,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DRectilinearDataSet0()
|
||||
vtkm::Float32 cellvar[nCells];
|
||||
for (int i = 0; i < nCells; i++)
|
||||
cellvar[i] = (vtkm::Float32)i;
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -585,7 +585,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make2DExplicitDataSet0()
|
||||
conn.push_back(15);
|
||||
conn.push_back(14);
|
||||
conn.push_back(12);
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
// Field data
|
||||
vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 33.0f,
|
||||
@ -593,7 +593,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make2DExplicitDataSet0()
|
||||
vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -633,52 +633,18 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet0()
|
||||
conn.push_back(4);
|
||||
|
||||
//Create the dataset.
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
vtkm::Float32 vars[nVerts] = { 10.1f, 20.1f, 30.2f, 40.2f, 50.3f };
|
||||
vtkm::Float32 cellvar[2] = { 100.1f, 100.2f };
|
||||
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
dsf.AddPointField(dataSet, "pointvar", vars, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 2);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
/*
|
||||
inline vtkm::cont::DataSet
|
||||
MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
vtkm::cont::DataSetIterativeBuilderExplicit dsb;
|
||||
vtkm::Id id0, id1, id2, id3, id4;
|
||||
|
||||
dsb.Begin("coords", "cells");
|
||||
|
||||
id0 = dsb.AddPoint(0,0,0);
|
||||
id1 = dsb.AddPoint(1,0,0);
|
||||
id2 = dsb.AddPoint(1,1,0);
|
||||
id3 = dsb.AddPoint(2,1,0);
|
||||
id4 = dsb.AddPoint(2,2,0);
|
||||
|
||||
vtkm::Id ids0[3] = {id0, id1, id2};
|
||||
dsb.AddCell(vtkm::CELL_SHAPE_TRIANGLE, ids0, 3);
|
||||
|
||||
vtkm::Id ids1[4] = {id2, id1, id3, id4};
|
||||
dsb.AddCell(vtkm::CELL_SHAPE_QUAD, ids1, 4);
|
||||
dataSet = dsb.Create();
|
||||
|
||||
vtkm::Float32 vars[5] = {10.1f, 20.1f, 30.2f, 40.2f, 50.3f};
|
||||
vtkm::Float32 cellvar[2] = {100.1f, 100.2f};
|
||||
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
dsf.AddPointField(dataSet, "pointvar", vars, 5);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, 2, "cells");
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
*/
|
||||
|
||||
inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
@ -702,12 +668,12 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::make_CoordinateSystem("coordinates", coordinates, nVerts, vtkm::CopyFlag::On));
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells");
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
cellSet.PrepareToAddCells(2, 7);
|
||||
cellSet.AddCell(vtkm::CELL_SHAPE_TRIANGLE, 3, make_Vec<vtkm::Id>(0, 1, 2));
|
||||
cellSet.AddCell(vtkm::CELL_SHAPE_QUAD, 4, make_Vec<vtkm::Id>(2, 1, 3, 4));
|
||||
cellSet.CompleteAddingCells(nVerts);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
//Set point scalar
|
||||
dataSet.AddField(make_Field(
|
||||
@ -716,7 +682,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1()
|
||||
//Set cell scalar
|
||||
vtkm::Float32 cellvar[2] = { 100.1f, 100.2f };
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, "cells", cellvar, 2, vtkm::CopyFlag::On));
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 2, vtkm::CopyFlag::On));
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -749,9 +715,9 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet2()
|
||||
//Set cell scalar
|
||||
vtkm::Float32 cellvar[2] = { 100.1f };
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, "cells", cellvar, 1, vtkm::CopyFlag::On));
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On));
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells");
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
vtkm::Vec<vtkm::Id, 8> ids;
|
||||
ids[0] = 0;
|
||||
ids[1] = 1;
|
||||
@ -767,7 +733,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet2()
|
||||
cellSet.CompleteAddingCells(nVerts);
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -805,9 +771,9 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet4()
|
||||
//Set cell scalar
|
||||
vtkm::Float32 cellvar[2] = { 100.1f, 110.f };
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, "cells", cellvar, 2, vtkm::CopyFlag::On));
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 2, vtkm::CopyFlag::On));
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells");
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
vtkm::Vec<vtkm::Id, 8> ids;
|
||||
ids[0] = 0;
|
||||
ids[1] = 4;
|
||||
@ -832,7 +798,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet4()
|
||||
cellSet.CompleteAddingCells(nVerts);
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -858,9 +824,9 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet3()
|
||||
//Set cell scalar
|
||||
vtkm::Float32 cellvar[2] = { 100.1f };
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, "cells", cellvar, 1, vtkm::CopyFlag::On));
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, 1, vtkm::CopyFlag::On));
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells");
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
vtkm::Id4 ids;
|
||||
ids[0] = 0;
|
||||
ids[1] = 1;
|
||||
@ -872,7 +838,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet3()
|
||||
cellSet.CompleteAddingCells(nVerts);
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -909,14 +875,10 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet5()
|
||||
//Set cell scalar
|
||||
const int nCells = 4;
|
||||
vtkm::Float32 cellvar[nCells] = { 100.1f, 110.f, 120.2f, 130.5f };
|
||||
dataSet.AddField(make_Field("cellvar",
|
||||
vtkm::cont::Field::Association::CELL_SET,
|
||||
"cells",
|
||||
cellvar,
|
||||
nCells,
|
||||
vtkm::CopyFlag::On));
|
||||
dataSet.AddField(make_Field(
|
||||
"cellvar", vtkm::cont::Field::Association::CELL_SET, cellvar, nCells, vtkm::CopyFlag::On));
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cellSet("cells");
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
vtkm::Vec<vtkm::Id, 8> ids;
|
||||
|
||||
cellSet.PrepareToAddCells(nCells, 23);
|
||||
@ -955,7 +917,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet5()
|
||||
cellSet.CompleteAddingCells(nVerts);
|
||||
|
||||
//todo this need to be a reference/shared_ptr style class
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -1025,14 +987,14 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet6()
|
||||
conn.push_back(0);
|
||||
conn.push_back(7);
|
||||
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
// Field data
|
||||
vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f };
|
||||
vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f };
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -1266,7 +1228,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetZoo()
|
||||
conn.push_back(7);
|
||||
conn.push_back(16);
|
||||
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
// Field data
|
||||
vtkm::Float32 pointvar[nVerts] =
|
||||
@ -1280,7 +1242,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetZoo()
|
||||
6.1f, 7.1f, 7.2f, 7.3f, 7.4f, 9.1f, 9.2f, 9.3f, 5.4f, 9.5f, 9.6f, 6.7f };
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -1340,14 +1302,14 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet7()
|
||||
conn.push_back(7);
|
||||
|
||||
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
// Field data
|
||||
vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 10.f, 20.f, 33.f, 52.f };
|
||||
vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f };
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -1420,14 +1382,14 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet8()
|
||||
conn.push_back(5);
|
||||
conn.push_back(6);
|
||||
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
// Field data
|
||||
vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 57.0f };
|
||||
vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
@ -1503,14 +1465,14 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetPolygonal()
|
||||
conn.push_back(6);
|
||||
conn.push_back(2);
|
||||
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates", "cells");
|
||||
dataSet = dsb.Create(coords, shapes, numindices, conn, "coordinates");
|
||||
|
||||
// Field data
|
||||
vtkm::Float32 pointvar[nVerts] = { 100.0f, 78.0f, 49.0f, 17.0f, 94.0f, 71.0f, 47.0f, 33.0f };
|
||||
vtkm::Float32 cellvar[nCells] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f };
|
||||
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, nCells);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
@ -1549,9 +1511,9 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetCowNose()
|
||||
{
|
||||
connectivity.GetPortalControl().Set(i, pointId[i]);
|
||||
}
|
||||
vtkm::cont::CellSetSingleType<> cellSet("cells");
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
cellSet.Fill(nVerts, vtkm::CELL_SHAPE_TRIANGLE, 3, connectivity);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
std::vector<vtkm::Float32> pointvar(nVerts);
|
||||
std::iota(pointvar.begin(), pointvar.end(), 15.f);
|
||||
@ -1568,9 +1530,9 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetCowNose()
|
||||
|
||||
vtkm::cont::DataSetFieldAdd dsf;
|
||||
dsf.AddPointField(dataSet, "pointvar", pointvar);
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar, "cells");
|
||||
dsf.AddCellField(dataSet, "cellvar", cellvar);
|
||||
dsf.AddPointField(dataSet, "point_vectors", pointvec);
|
||||
dsf.AddCellField(dataSet, "cell_vectors", cellvec, "cells");
|
||||
dsf.AddCellField(dataSet, "cell_vectors", cellvec);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
@ -238,11 +238,6 @@ struct TestEqualCellSet
|
||||
vtkm::TopologyElementTagCell visitTopo{};
|
||||
vtkm::TopologyElementTagPoint incidentTopo{};
|
||||
|
||||
if (cs1.GetName() != cs2.GetName())
|
||||
{
|
||||
result.PushMessage("names don't match");
|
||||
return;
|
||||
}
|
||||
if (cs1.GetNumberOfPoints() != cs2.GetNumberOfPoints())
|
||||
{
|
||||
result.PushMessage("number of points don't match");
|
||||
@ -285,11 +280,6 @@ struct TestEqualCellSet
|
||||
const vtkm::cont::CellSetStructured<DIMENSION>& cs2,
|
||||
TestEqualResult& result) const
|
||||
{
|
||||
if (cs1.GetName() != cs2.GetName())
|
||||
{
|
||||
result.PushMessage("names don't match");
|
||||
return;
|
||||
}
|
||||
if (cs1.GetPointDimensions() != cs2.GetPointDimensions())
|
||||
{
|
||||
result.PushMessage("point dimensions don't match");
|
||||
@ -348,15 +338,6 @@ inline VTKM_CONT TestEqualResult test_equal_Fields(const vtkm::cont::Field& f1,
|
||||
return result;
|
||||
}
|
||||
|
||||
if (f1.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
|
||||
{
|
||||
if (f1.GetAssocCellSet() != f2.GetAssocCellSet())
|
||||
{
|
||||
result.PushMessage("associated cellset names don't match");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result =
|
||||
test_equal_ArrayHandles(f1.GetData().ResetTypes(fTtypes), f2.GetData().ResetTypes(fTtypes));
|
||||
if (!result)
|
||||
@ -392,21 +373,13 @@ inline VTKM_CONT TestEqualResult test_equal_DataSets(const vtkm::cont::DataSet&
|
||||
}
|
||||
}
|
||||
|
||||
if (ds1.GetNumberOfCellSets() != ds2.GetNumberOfCellSets())
|
||||
result = test_equal_CellSets(ds1.GetCellSet().ResetCellSetList(ctypes),
|
||||
ds2.GetCellSet().ResetCellSetList(ctypes));
|
||||
if (!result)
|
||||
{
|
||||
result.PushMessage("number of cellsets don't match");
|
||||
result.PushMessage(std::string("cellsets don't match"));
|
||||
return result;
|
||||
}
|
||||
for (vtkm::IdComponent i = 0; i < ds1.GetNumberOfCellSets(); ++i)
|
||||
{
|
||||
result = test_equal_CellSets(ds1.GetCellSet(i).ResetCellSetList(ctypes),
|
||||
ds2.GetCellSet(i).ResetCellSetList(ctypes));
|
||||
if (!result)
|
||||
{
|
||||
result.PushMessage(std::string("cellsets don't match at index ") + std::to_string(i));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (ds1.GetNumberOfFields() != ds2.GetNumberOfFields())
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
|
||||
vtkm::cont::ArrayHandle<PointType> points;
|
||||
vtkm::cont::ArrayCopy(uniformDs.GetCoordinateSystem().GetData(), points);
|
||||
|
||||
vtkm::Id numberOfCells = uniformDs.GetCellSet().GetNumberOfCells();
|
||||
vtkm::Id numberOfCells = uniformDs.GetNumberOfCells();
|
||||
vtkm::Id numberOfIndices = numberOfCells * PointsPerCell;
|
||||
|
||||
Connectivity structured;
|
||||
@ -135,7 +135,7 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
|
||||
// build dataset
|
||||
vtkm::cont::DataSet out;
|
||||
out.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coords", points));
|
||||
out.AddCellSet(cellset);
|
||||
out.SetCellSet(cellset);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
|
||||
vtkm::cont::ArrayHandle<PointType>& pcoords,
|
||||
vtkm::cont::ArrayHandle<PointType>& wcoords)
|
||||
{
|
||||
vtkm::Id numberOfCells = ds.GetCellSet().GetNumberOfCells();
|
||||
vtkm::Id numberOfCells = ds.GetNumberOfCells();
|
||||
|
||||
std::uniform_int_distribution<vtkm::Id> cellIdGen(0, numberOfCells - 1);
|
||||
|
||||
@ -201,8 +201,7 @@ void TestCellLocator(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dim, vtkm::Id number
|
||||
{
|
||||
auto ds = MakeTestDataSet(dim);
|
||||
|
||||
std::cout << "Testing " << DIMENSIONS << "D dataset with " << ds.GetCellSet().GetNumberOfCells()
|
||||
<< " cells\n";
|
||||
std::cout << "Testing " << DIMENSIONS << "D dataset with " << ds.GetNumberOfCells() << " cells\n";
|
||||
|
||||
vtkm::cont::CellLocatorUniformBins locator;
|
||||
locator.SetDensityL1(64.0f);
|
||||
|
@ -58,8 +58,6 @@ private:
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0();
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, "Incorrect number of cell sets");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
|
||||
// test various field-getting methods and associations
|
||||
@ -91,7 +89,7 @@ private:
|
||||
|
||||
// test cell-to-point connectivity
|
||||
vtkm::cont::CellSetExplicit<> cellset;
|
||||
ds.GetCellSet(0).CopyTo(cellset);
|
||||
ds.GetCellSet().CopyTo(cellset);
|
||||
|
||||
vtkm::Id connectivitySize = 7;
|
||||
vtkm::Id numPoints = 5;
|
||||
|
@ -100,7 +100,7 @@ private:
|
||||
|
||||
//verify that we can get a CellSetSingleType from a dataset
|
||||
vtkm::cont::CellSetSingleType<> cellset;
|
||||
dataSet.GetCellSet(0).CopyTo(cellset);
|
||||
dataSet.GetCellSet().CopyTo(cellset);
|
||||
|
||||
//verify that the point to cell connectivity types are correct
|
||||
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapesPointToCell =
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <vtkm/BinaryPredicates.h>
|
||||
#include <vtkm/TypeTraits.h>
|
||||
|
||||
#include <vtkm/cont/ArrayGetValues.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleConstant.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
@ -1985,6 +1986,108 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static VTKM_CONT void TestScanExtended()
|
||||
{
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Extended Scan" << std::endl;
|
||||
|
||||
{
|
||||
std::cout << " size " << ARRAY_SIZE << std::endl;
|
||||
|
||||
//construct the index array
|
||||
IdArrayHandle array;
|
||||
Algorithm::Schedule(ClearArrayKernel(array.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
|
||||
// we now have an array whose sum = (OFFSET * ARRAY_SIZE),
|
||||
// let's validate that
|
||||
Algorithm::ScanExtended(array, array);
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE + 1, "Output size incorrect.");
|
||||
auto portal = array.GetPortalConstControl();
|
||||
for (vtkm::Id i = 0; i < ARRAY_SIZE + 1; ++i)
|
||||
{
|
||||
const vtkm::Id value = portal.Get(i);
|
||||
VTKM_TEST_ASSERT(value == i * OFFSET, "Incorrect partial sum");
|
||||
}
|
||||
|
||||
std::cout << " size 1" << std::endl;
|
||||
array.Shrink(1);
|
||||
array.GetPortalControl().Set(0, OFFSET);
|
||||
Algorithm::ScanExtended(array, array);
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == 2);
|
||||
portal = array.GetPortalConstControl();
|
||||
VTKM_TEST_ASSERT(portal.Get(0) == 0, "Incorrect initial value");
|
||||
VTKM_TEST_ASSERT(portal.Get(1) == OFFSET, "Incorrect total sum");
|
||||
|
||||
std::cout << " size 0" << std::endl;
|
||||
array.Shrink(0);
|
||||
Algorithm::ScanExtended(array, array);
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == 1);
|
||||
portal = array.GetPortalConstControl();
|
||||
VTKM_TEST_ASSERT(portal.Get(0) == 0, "Incorrect initial value");
|
||||
}
|
||||
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Extended Scan with multiplication operator" << std::endl;
|
||||
{
|
||||
std::vector<vtkm::Float64> inputValues(ARRAY_SIZE);
|
||||
for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
|
||||
{
|
||||
inputValues[i] = 1.01;
|
||||
}
|
||||
|
||||
std::size_t mid = ARRAY_SIZE / 2;
|
||||
inputValues[mid] = 0.0;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> array =
|
||||
vtkm::cont::make_ArrayHandle(inputValues, vtkm::CopyFlag::On);
|
||||
|
||||
vtkm::Float64 initialValue = 2.00;
|
||||
Algorithm::ScanExtended(array, array, vtkm::Multiply(), initialValue);
|
||||
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE + 1,
|
||||
"ScanExtended output size incorrect.");
|
||||
|
||||
auto portal = array.GetPortalConstControl();
|
||||
VTKM_TEST_ASSERT(portal.Get(0) == initialValue,
|
||||
"ScanExtended result's first value != initialValue");
|
||||
|
||||
for (std::size_t i = 1; i <= mid; ++i)
|
||||
{
|
||||
vtkm::Id index = static_cast<vtkm::Id>(i);
|
||||
vtkm::Float64 expected = pow(1.01, static_cast<vtkm::Float64>(i)) * initialValue;
|
||||
vtkm::Float64 got = portal.Get(index);
|
||||
VTKM_TEST_ASSERT(test_equal(got, expected), "Incorrect results for ScanExtended");
|
||||
}
|
||||
for (std::size_t i = mid + 1; i < ARRAY_SIZE + 1; ++i)
|
||||
{
|
||||
vtkm::Id index = static_cast<vtkm::Id>(i);
|
||||
VTKM_TEST_ASSERT(portal.Get(index) == 0.0f, "Incorrect results for ScanExtended");
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Extended Scan with a vtkm::Vec" << std::endl;
|
||||
|
||||
{
|
||||
using Vec3 = vtkm::Vec3f_64;
|
||||
using Vec3ArrayHandle = vtkm::cont::ArrayHandle<Vec3, StorageTag>;
|
||||
|
||||
std::vector<Vec3> testValues(ARRAY_SIZE);
|
||||
|
||||
for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
|
||||
{
|
||||
testValues[i] = TestValue(1, Vec3());
|
||||
}
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues, vtkm::CopyFlag::On);
|
||||
|
||||
Algorithm::ScanExtended(values, values);
|
||||
VTKM_TEST_ASSERT(test_equal(vtkm::cont::ArrayGetValue(ARRAY_SIZE, values),
|
||||
(TestValue(1, Vec3()) * ARRAY_SIZE)),
|
||||
"Got bad sum from ScanExtended");
|
||||
}
|
||||
}
|
||||
|
||||
static VTKM_CONT void TestErrorExecution()
|
||||
{
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
@ -2763,6 +2866,7 @@ private:
|
||||
TestReduceByKeyWithFancyArrays();
|
||||
|
||||
TestScanExclusive();
|
||||
TestScanExtended();
|
||||
|
||||
TestScanInclusive();
|
||||
TestScanInclusiveWithComparisonObject();
|
||||
|
@ -99,6 +99,8 @@ void ScanTest()
|
||||
out = vtkm::cont::Algorithm::ScanExclusive(input, output, vtkm::Maximum(), vtkm::Id(0));
|
||||
vtkm::cont::Algorithm::ScanExclusiveByKey(keys, input, output, vtkm::Id(0), vtkm::Maximum());
|
||||
vtkm::cont::Algorithm::ScanExclusiveByKey(keys, input, output);
|
||||
vtkm::cont::Algorithm::ScanExtended(input, output);
|
||||
vtkm::cont::Algorithm::ScanExtended(input, output, vtkm::Maximum(), vtkm::Id(0));
|
||||
(void)out;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ vtkm::cont::DataSet MakeTestDataSetCurvilinear()
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet curvi;
|
||||
curvi.AddCellSet(recti.GetCellSet());
|
||||
curvi.SetCellSet(recti.GetCellSet());
|
||||
curvi.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coords", sheared));
|
||||
|
||||
return curvi;
|
||||
@ -115,7 +115,7 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
|
||||
vtkm::cont::ArrayHandle<PointType>& pcoords,
|
||||
vtkm::cont::ArrayHandle<PointType>& wcoords)
|
||||
{
|
||||
vtkm::Id numberOfCells = ds.GetCellSet().GetNumberOfCells();
|
||||
vtkm::Id numberOfCells = ds.GetNumberOfCells();
|
||||
|
||||
std::uniform_int_distribution<vtkm::Id> cellIdGen(0, numberOfCells - 1);
|
||||
std::uniform_real_distribution<vtkm::FloatDefault> pcoordGen(0.0f, 1.0f);
|
||||
|
@ -27,7 +27,7 @@ constexpr vtkm::Id3 BaseLinePointDimensions{ xdim, ydim, zdim };
|
||||
constexpr vtkm::Id BaseLineNumberOfPoints = xdim * ydim * zdim;
|
||||
constexpr vtkm::Id BaseLineNumberOfCells = (xdim - 1) * (ydim - 1) * (zdim - 1);
|
||||
|
||||
vtkm::cont::CellSetStructured<3> BaseLine{ "BaseLine" };
|
||||
vtkm::cont::CellSetStructured<3> BaseLine;
|
||||
|
||||
void InitializeBaseLine()
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ int TestCellSetExtrude()
|
||||
vtkm::cont::DataSet dataset;
|
||||
|
||||
dataset.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coords", coords));
|
||||
dataset.AddCellSet(cells);
|
||||
dataset.SetCellSet(cells);
|
||||
|
||||
// verify that a constant value point field can be accessed
|
||||
std::vector<float> pvalues(static_cast<size_t>(coords.GetNumberOfValues()), 42.0f);
|
||||
@ -136,7 +136,7 @@ int TestCellSetExtrude()
|
||||
// verify that a constant cell value can be accessed
|
||||
std::vector<float> cvalues(static_cast<size_t>(cells.GetNumberOfCells()), 42.0f);
|
||||
vtkm::cont::Field cfield =
|
||||
vtkm::cont::make_FieldCell("cfield", cells.GetName(), vtkm::cont::make_ArrayHandle(cvalues));
|
||||
vtkm::cont::make_FieldCell("cfield", vtkm::cont::make_ArrayHandle(cvalues));
|
||||
dataset.AddField(cfield);
|
||||
|
||||
vtkm::filter::PointAverage avg;
|
||||
|
@ -40,12 +40,10 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
const vtkm::Bounds& bounds)
|
||||
{
|
||||
//Verify basics..
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, "Wrong number of cell sets.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetNumberOfPoints() == numPoints,
|
||||
"Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
||||
// test various field-getting methods and associations
|
||||
try
|
||||
|
@ -30,12 +30,11 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
const vtkm::Bounds& bounds)
|
||||
{
|
||||
//Verify basics..
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, "Wrong number of cell sets.");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetNumberOfPoints() == numPoints,
|
||||
"Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
||||
// test various field-getting methods and associations
|
||||
try
|
||||
@ -62,21 +61,21 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
if (dim == 1)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<1> cellSet;
|
||||
ds.GetCellSet(0).CopyTo(cellSet);
|
||||
ds.GetCellSet().CopyTo(cellSet);
|
||||
vtkm::IdComponent shape = cellSet.GetCellShape();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_LINE, "Wrong element type");
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
ds.GetCellSet(0).CopyTo(cellSet);
|
||||
ds.GetCellSet().CopyTo(cellSet);
|
||||
vtkm::IdComponent shape = cellSet.GetCellShape();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type");
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
ds.GetCellSet(0).CopyTo(cellSet);
|
||||
ds.GetCellSet().CopyTo(cellSet);
|
||||
vtkm::IdComponent shape = cellSet.GetCellShape();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type");
|
||||
}
|
||||
|
@ -31,12 +31,11 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
vtkm::Bounds bounds)
|
||||
{
|
||||
//Verify basics..
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCellSets() == 1, "Wrong number of cell sets.");
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetCoordinateSystem().GetNumberOfPoints() == numPoints,
|
||||
"Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
||||
// test various field-getting methods and associations
|
||||
try
|
||||
@ -63,21 +62,21 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
if (dim == 1)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<1> cellSet;
|
||||
ds.GetCellSet(0).CopyTo(cellSet);
|
||||
ds.GetCellSet().CopyTo(cellSet);
|
||||
vtkm::IdComponent shape = cellSet.GetCellShape();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_LINE, "Wrong element type");
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
ds.GetCellSet(0).CopyTo(cellSet);
|
||||
ds.GetCellSet().CopyTo(cellSet);
|
||||
vtkm::IdComponent shape = cellSet.GetCellShape();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Wrong element type");
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
ds.GetCellSet(0).CopyTo(cellSet);
|
||||
ds.GetCellSet().CopyTo(cellSet);
|
||||
vtkm::IdComponent shape = cellSet.GetCellShape();
|
||||
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_HEXAHEDRON, "Wrong element type");
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void TestDataSet_Explicit()
|
||||
|
||||
//get the cellset single type from the dataset
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
//verify that we can create a subset of a singlset
|
||||
using SubsetType = vtkm::cont::CellSetPermutation<vtkm::cont::CellSetSingleType<>>;
|
||||
@ -141,7 +141,7 @@ void TestDataSet_Structured2D()
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds = vtkm::cont::make_ArrayHandle(validIds);
|
||||
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
//verify that we can create a subset of a 2d UniformDataSet
|
||||
vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<2>> subset;
|
||||
@ -183,7 +183,7 @@ void TestDataSet_Structured3D()
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds = vtkm::cont::make_ArrayHandle(validIds);
|
||||
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
//verify that we can create a subset of a 2d UniformDataSet
|
||||
vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<3>> subset;
|
||||
|
@ -40,9 +40,8 @@ static void TwoDimRectilinearTest()
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DRectilinearDataSet0();
|
||||
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1, "Incorrect number of cell sets");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Incorrect number of coordinate systems");
|
||||
@ -123,9 +122,7 @@ static void ThreeDimRectilinearTest()
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DRectilinearDataSet0();
|
||||
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1, "Incorrect number of cell sets");
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
|
||||
|
@ -41,9 +41,8 @@ static void TwoDimUniformTest()
|
||||
dataSet.PrintSummary(std::cout);
|
||||
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1, "Incorrect number of cell sets");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Incorrect number of coordinate systems");
|
||||
@ -128,9 +127,7 @@ static void ThreeDimUniformTest()
|
||||
dataSet.PrintSummary(std::cout);
|
||||
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet(0).CopyTo(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCellSets() == 1, "Incorrect number of cell sets");
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
|
||||
|
@ -45,7 +45,6 @@ void CheckEmptyDynamicCellSet()
|
||||
{
|
||||
vtkm::cont::DynamicCellSet empty;
|
||||
|
||||
VTKM_TEST_ASSERT(empty.GetName() == std::string{}, "DynamicCellSet should have no name");
|
||||
VTKM_TEST_ASSERT(empty.GetNumberOfCells() == 0, "DynamicCellSet should have no cells");
|
||||
VTKM_TEST_ASSERT(empty.GetNumberOfFaces() == 0, "DynamicCellSet should have no faces");
|
||||
VTKM_TEST_ASSERT(empty.GetNumberOfEdges() == 0, "DynamicCellSet should have no edges");
|
||||
|
@ -118,12 +118,12 @@ void TryRangeComputeDS(const ValueType& min, const ValueType& max)
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
void TryRangeComputeMB(const ValueType& min, const ValueType& max)
|
||||
void TryRangeComputePDS(const ValueType& min, const ValueType& max)
|
||||
{
|
||||
std::cout << "Trying type (multiblock): " << vtkm::testing::TypeName<ValueType>::Name()
|
||||
std::cout << "Trying type (PartitionedDataSet): " << vtkm::testing::TypeName<ValueType>::Name()
|
||||
<< std::endl;
|
||||
|
||||
vtkm::cont::MultiBlock mb;
|
||||
vtkm::cont::PartitionedDataSet mb;
|
||||
for (int cc = 0; cc < 5; cc++)
|
||||
{
|
||||
// let's create a dummy dataset with a bunch of fields.
|
||||
@ -132,7 +132,7 @@ void TryRangeComputeMB(const ValueType& min, const ValueType& max)
|
||||
dataset,
|
||||
"pointvar",
|
||||
CreateArray(min, max, ARRAY_SIZE, typename vtkm::TypeTraits<ValueType>::DimensionalityTag()));
|
||||
mb.AddBlock(dataset);
|
||||
mb.AppendPartition(dataset);
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ranges = vtkm::cont::FieldRangeCompute(mb, "pointvar");
|
||||
@ -148,10 +148,10 @@ static void TestFieldRangeCompute()
|
||||
TryRangeComputeDS<vtkm::Int32>(-1024, 1024);
|
||||
TryRangeComputeDS<vtkm::Vec3f_32>(vtkm::make_Vec(1024, 0, -1024),
|
||||
vtkm::make_Vec(2048, 2048, 2048));
|
||||
TryRangeComputeMB<vtkm::Float64>(0, 1000);
|
||||
TryRangeComputeMB<vtkm::Int32>(-1024, 1024);
|
||||
TryRangeComputeMB<vtkm::Vec3f_32>(vtkm::make_Vec(1024, 0, -1024),
|
||||
vtkm::make_Vec(2048, 2048, 2048));
|
||||
TryRangeComputePDS<vtkm::Float64>(0, 1000);
|
||||
TryRangeComputePDS<vtkm::Int32>(-1024, 1024);
|
||||
TryRangeComputePDS<vtkm::Vec3f_32>(vtkm::make_Vec(1024, 0, -1024),
|
||||
vtkm::make_Vec(2048, 2048, 2048));
|
||||
};
|
||||
|
||||
int UnitTestFieldRangeCompute(int argc, char* argv[])
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user