Merge branch 'master' of gitlab.kitware.com:vtk/vtk-m into fix_temporal_example

This commit is contained in:
Abhishek Dilip Yenpure (-EXP) 2019-09-03 11:53:00 -06:00
commit 01d735e1aa
178 changed files with 1323 additions and 1967 deletions

@ -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

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b947d66dbae99a1ebb392b200a9ea0d380cfccb7fcb3a3739615d0dde558d2f1
size 238166

@ -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.

@ -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.

@ -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`.

@ -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`.

@ -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.

@ -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.

@ -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));

@ -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();

@ -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);

@ -215,7 +215,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
cellSet.Fill(nPts, shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
return dataSet;
}
@ -258,7 +258,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
cellSet.Fill(nPts, shapes, numIndices, connectivity);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
return dataSet;
}
@ -298,7 +298,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
vtkm::cont::CellSetSingleType<> cellSet(cellNm);
cellSet.Fill(coords.GetNumberOfValues(), tag.Id, numberOfPointsPerCell, connectivity);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
return dataSet;
}

@ -231,19 +231,19 @@ private:
{
vtkm::cont::CellSetStructured<1> cellSet(cellNm);
cellSet.SetPointDimensions(dims[0]);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
}
else if (ndims == 2)
{
vtkm::cont::CellSetStructured<2> cellSet(cellNm);
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);
cellSet.SetPointDimensions(vtkm::make_Vec(dims[0], dims[1], dims[2]));
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
}
else
{

@ -79,19 +79,19 @@ vtkm::cont::DataSet DataSetBuilderUniform::CreateDataSet(const vtkm::Id3& dimens
{
vtkm::cont::CellSetStructured<1> cellSet(cellNm);
cellSet.SetPointDimensions(dims[0]);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
}
else if (ndims == 2)
{
vtkm::cont::CellSetStructured<2> cellSet(cellNm);
cellSet.SetPointDimensions(vtkm::Id2(dims[0], dims[1]));
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
}
else if (ndims == 3)
{
vtkm::cont::CellSetStructured<3> cellSet(cellNm);
cellSet.SetPointDimensions(vtkm::Id3(dims[0], dims[1], dims[2]));
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
}
else
{

@ -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));
}
};
}

@ -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));
}
};

@ -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.

@ -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;

@ -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

@ -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();
@ -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");
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");
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;
}
@ -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;
}
@ -640,45 +640,11 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet0()
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;
@ -707,7 +673,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet1()
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,7 +715,7 @@ 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::Vec<vtkm::Id, 8> ids;
@ -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,7 +771,7 @@ 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::Vec<vtkm::Id, 8> ids;
@ -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,7 +824,7 @@ 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::Id4 ids;
@ -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,12 +875,8 @@ 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::Vec<vtkm::Id, 8> ids;
@ -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;
}
@ -1032,7 +994,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet6()
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;
}
@ -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;
}
@ -1347,7 +1309,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet7()
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;
}
@ -1427,7 +1389,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSet8()
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;
}
@ -1510,7 +1472,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetPolygonal()
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;
}
@ -1551,7 +1513,7 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetCowNose()
}
vtkm::cont::CellSetSingleType<> cellSet("cells");
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;
}

@ -348,15 +348,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 +383,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 =

@ -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);

@ -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");

@ -769,83 +769,86 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
return detail::TriangleDerivative(field, wpoints);
}
//-----------------------------------------------------------------------------
template <typename ParametricCoordType>
VTKM_EXEC void PolygonComputeIndices(const vtkm::Vec<ParametricCoordType, 3>& pcoords,
vtkm::IdComponent numPoints,
vtkm::IdComponent& firstPointIndex,
vtkm::IdComponent& secondPointIndex)
namespace detail
{
ParametricCoordType angle;
if ((vtkm::Abs(pcoords[0] - 0.5f) < 4 * vtkm::Epsilon<ParametricCoordType>()) &&
(vtkm::Abs(pcoords[1] - 0.5f) < 4 * vtkm::Epsilon<ParametricCoordType>()))
//-----------------------------------------------------------------------------
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
VTKM_EXEC void PolygonSubTriangle(const FieldVecType& inField,
const WorldCoordType& inWCoords,
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
vtkm::Vec<typename FieldVecType::ComponentType, 3>& outField,
vtkm::Vec<typename WorldCoordType::ComponentType, 3>& outWCoords,
const vtkm::exec::FunctorBase& worklet)
{
// To find the gradient in a polygon (of 5 or more points), we will extract a small triangle near
// the desired parameteric coordinates (pcoords). We return the field values (outField) and world
// coordinates (outWCoords) for this triangle, which is all that is needed to find the gradient
// in a triangle.
//
// The trangle will be "pointing" away from the center of the polygon, and pcoords will be placed
// at the apex of the triangle. This is because if pcoords is at or near the edge of the polygon,
// we do not want to push any of the points over the edge, and it is not trivial to determine
// exactly where the edge of the polygon is.
// First point is right at pcoords
outField[0] = vtkm::exec::CellInterpolate(inField, pcoords, vtkm::CellShapeTagPolygon{}, worklet);
outWCoords[0] =
vtkm::exec::CellInterpolate(inWCoords, pcoords, vtkm::CellShapeTagPolygon{}, worklet);
// Find the unit vector pointing from the center of the polygon to pcoords
vtkm::Vec<ParametricCoordType, 2> radialVector = { pcoords[0] - 0.5f, pcoords[1] - 0.5f };
ParametricCoordType magnitudeSquared = vtkm::MagnitudeSquared(radialVector);
if (magnitudeSquared > 8 * vtkm::Epsilon<ParametricCoordType>())
{
angle = 0;
radialVector = vtkm::RSqrt(magnitudeSquared) * radialVector;
}
else
{
angle = vtkm::ATan2(pcoords[1] - 0.5f, pcoords[0] - 0.5f);
if (angle < 0)
{
angle += static_cast<ParametricCoordType>(2 * vtkm::Pi());
}
// pcoords is in the center of the polygon. Just point in an arbitrary direction
radialVector = { 1.0, 0.0 };
}
const ParametricCoordType deltaAngle =
static_cast<ParametricCoordType>(2 * vtkm::Pi() / numPoints);
firstPointIndex = static_cast<vtkm::IdComponent>(vtkm::Floor(angle / deltaAngle));
secondPointIndex = firstPointIndex + 1;
if (secondPointIndex == numPoints)
{
secondPointIndex = 0;
}
// We want the two points away from pcoords to be back toward the center but moved at 45 degrees
// off the radius. Simple geometry shows us that the (not quite unit) vectors of those two
// directions are (-radialVector[1] - radialVector[0], radialVector[0] - radialVector[1]) and
// (radialVector[1] - radialVector[0], -radialVector[0] - radialVector[1]).
//
// *\ (-radialVector[1], radialVector[0]) //
// | \ //
// | \ (-radialVector[1] - radialVector[0], radialVector[0] - radialVector[1]) //
// | \ //
// +-------* radialVector //
// | / //
// | / (radialVector[1] - radialVector[0], -radialVector[0] - radialVector[1]) //
// | / //
// */ (radialVector[1], -radialVector[0]) //
// This scaling value is somewhat arbitrary. It is small enough to be "close" to the selected
// point and small enough to be guaranteed to be inside the polygon, but large enough to to
// get an accurate gradient.
static constexpr ParametricCoordType scale = 0.05f;
vtkm::Vec<ParametricCoordType, 3> backPcoord = {
pcoords[0] + scale * (-radialVector[1] - radialVector[0]),
pcoords[1] + scale * (radialVector[0] - radialVector[1]),
0
};
outField[1] =
vtkm::exec::CellInterpolate(inField, backPcoord, vtkm::CellShapeTagPolygon{}, worklet);
outWCoords[1] =
vtkm::exec::CellInterpolate(inWCoords, backPcoord, vtkm::CellShapeTagPolygon{}, worklet);
backPcoord = { pcoords[0] + scale * (radialVector[1] - radialVector[0]),
pcoords[1] + scale * (-radialVector[0] - radialVector[1]),
0 };
outField[2] =
vtkm::exec::CellInterpolate(inField, backPcoord, vtkm::CellShapeTagPolygon{}, worklet);
outWCoords[2] =
vtkm::exec::CellInterpolate(inWCoords, backPcoord, vtkm::CellShapeTagPolygon{}, worklet);
}
//-----------------------------------------------------------------------------
template <typename FieldVecType, typename WorldCoordType>
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> PolygonDerivative(
const FieldVecType& field,
const WorldCoordType& wCoords,
vtkm::IdComponent numPoints,
vtkm::IdComponent firstPointIndex,
vtkm::IdComponent secondPointIndex)
{
// If we are here, then there are 5 or more points on this polygon.
// Arrange the points such that they are on the circle circumscribed in the
// unit square from 0 to 1. That is, the point are on the circle centered at
// coordinate 0.5,0.5 with radius 0.5. The polygon is divided into regions
// defined by they triangle fan formed by the points around the center. This
// is C0 continuous but not necessarily C1 continuous. It is also possible to
// have a non 1 to 1 mapping between parametric coordinates world coordinates
// if the polygon is not planar or convex.
using FieldType = typename FieldVecType::ComponentType;
using WCoordType = typename WorldCoordType::ComponentType;
// Find the interpolation for the center point.
FieldType fieldCenter = field[0];
WCoordType wcoordCenter = wCoords[0];
for (vtkm::IdComponent pointIndex = 1; pointIndex < numPoints; pointIndex++)
{
fieldCenter = fieldCenter + field[pointIndex];
wcoordCenter = wcoordCenter + wCoords[pointIndex];
}
fieldCenter = fieldCenter * FieldType(1.0f / static_cast<float>(numPoints));
wcoordCenter = wcoordCenter * WCoordType(1.0f / static_cast<float>(numPoints));
// Set up parameters for triangle that pcoords is in
vtkm::Vec<FieldType, 3> triangleField(
fieldCenter, field[firstPointIndex], field[secondPointIndex]);
vtkm::Vec<WCoordType, 3> triangleWCoords(
wcoordCenter, wCoords[firstPointIndex], wCoords[secondPointIndex]);
// Now use the triangle derivative. pcoords is actually invalid for the
// triangle, but that does not matter as the derivative for a triangle does
// not depend on it.
return detail::TriangleDerivative(triangleField, triangleWCoords);
}
} // namespace detail
//-----------------------------------------------------------------------------
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
@ -873,9 +876,10 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagQuad(), worklet);
}
vtkm::IdComponent firstPointIndex, secondPointIndex;
PolygonComputeIndices(pcoords, numPoints, firstPointIndex, secondPointIndex);
return PolygonDerivative(field, wCoords, numPoints, firstPointIndex, secondPointIndex);
vtkm::Vec<typename FieldVecType::ComponentType, 3> triangleField;
vtkm::Vec<typename WorldCoordType::ComponentType, 3> triangleWCoords;
detail::PolygonSubTriangle(field, wCoords, pcoords, triangleField, triangleWCoords, worklet);
return detail::TriangleDerivative(triangleField, triangleWCoords);
}
//-----------------------------------------------------------------------------

@ -36,7 +36,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
}
vtkm::cont::DynamicCellSet cellSet = input.GetCellSet(this->GetActiveCellSetIndex());
vtkm::cont::DynamicCellSet cellSet = input.GetCellSet();
//todo: we need to ask the policy what storage type we should be using
//If the input is implicit, we should know what to fall back to
@ -51,7 +51,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
outputName = fieldMetadata.GetName();
}
return CreateResultFieldCell(input, outArray, outputName, cellSet);
return CreateResultFieldCell(input, outArray, outputName);
}
}
} // namespace vtkm::filter

@ -38,7 +38,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
throw vtkm::cont::ErrorFilterExecution("CellMeasures expects point field input.");
}
const auto& cellset = input.GetCellSet(this->GetActiveCellSetIndex());
const auto& cellset = input.GetCellSet();
vtkm::cont::ArrayHandle<T> outArray;
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
@ -52,7 +52,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
// Default name is name of input.
outputName = "measure";
}
return CreateResultFieldCell(input, outArray, outputName, cellset);
return CreateResultFieldCell(input, outArray, outputName);
}
}
} // namespace vtkm::filter

@ -34,7 +34,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellSetConnectivity::DoExecute(
vtkm::cont::ArrayHandle<vtkm::Id> component;
vtkm::worklet::connectivity::CellSetConnectivity().Run(
vtkm::filter::ApplyPolicy(input.GetCellSet(this->GetActiveCellSetIndex()), policy), component);
vtkm::filter::ApplyPolicy(input.GetCellSet(), policy), component);
return CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
}

@ -35,54 +35,49 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data
vtkm::filter::PolicyBase<Policy> policy)
{
using CellSetType = vtkm::cont::CellSetExplicit<>;
using VecId = std::vector<CellSetType>::size_type;
VecId numCellSets = static_cast<VecId>(inData.GetNumberOfCellSets());
std::vector<CellSetType> outputCellSets(numCellSets);
using VecId = std::size_t;
VecId activeCoordIndex = static_cast<VecId>(this->GetActiveCoordinateSystemIndex());
CellSetType outputCellSet;
// Do a deep copy of the cells to new CellSetExplicit structures
for (VecId cellSetIndex = 0; cellSetIndex < numCellSets; ++cellSetIndex)
const vtkm::cont::DynamicCellSet& inCellSet = inData.GetCellSet();
if (inCellSet.IsType<CellSetType>())
{
vtkm::cont::DynamicCellSet inCellSet =
inData.GetCellSet(static_cast<vtkm::IdComponent>(cellSetIndex));
if (inCellSet.IsType<CellSetType>())
{
// Is expected type, do a shallow copy
outputCellSets[cellSetIndex] = inCellSet.Cast<CellSetType>();
}
else
{ // Clean the grid
auto deducedCellSet = vtkm::filter::ApplyPolicy(inCellSet, policy);
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
this->Invoke(worklet::CellDeepCopy::CountCellPoints{}, deducedCellSet, numIndices);
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayHandle<vtkm::Id> offsets;
vtkm::Id connectivitySize;
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
numIndices.ReleaseResourcesExecution();
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
connectivity.Allocate(connectivitySize);
this->Invoke(worklet::CellDeepCopy::PassCellStructure{},
deducedCellSet,
shapes,
vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
shapes.ReleaseResourcesExecution();
offsets.ReleaseResourcesExecution();
connectivity.ReleaseResourcesExecution();
outputCellSets[cellSetIndex].Fill(
deducedCellSet.GetNumberOfPoints(), shapes, numIndices, connectivity, offsets);
//Release the input grid from the execution space
deducedCellSet.ReleaseResourcesExecution();
}
// Is expected type, do a shallow copy
outputCellSet = inCellSet.Cast<CellSetType>();
}
else
{ // Clean the grid
auto deducedCellSet = vtkm::filter::ApplyPolicy(inCellSet, policy);
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
this->Invoke(worklet::CellDeepCopy::CountCellPoints{}, deducedCellSet, numIndices);
vtkm::cont::ArrayHandle<vtkm::UInt8> shapes;
vtkm::cont::ArrayHandle<vtkm::Id> offsets;
vtkm::Id connectivitySize;
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
numIndices.ReleaseResourcesExecution();
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
connectivity.Allocate(connectivitySize);
this->Invoke(worklet::CellDeepCopy::PassCellStructure{},
deducedCellSet,
shapes,
vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
shapes.ReleaseResourcesExecution();
offsets.ReleaseResourcesExecution();
connectivity.ReleaseResourcesExecution();
outputCellSet.Fill(
deducedCellSet.GetNumberOfPoints(), shapes, numIndices, connectivity, offsets);
//Release the input grid from the execution space
deducedCellSet.ReleaseResourcesExecution();
}
VecId numCoordSystems = static_cast<VecId>(inData.GetNumberOfCoordinateSystems());
std::vector<vtkm::cont::CoordinateSystem> outputCoordinateSystems(numCoordSystems);
@ -98,16 +93,10 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data
if (this->GetCompactPointFields())
{
this->PointCompactor.FindPointsStart();
for (VecId cellSetIndex = 0; cellSetIndex < numCellSets; cellSetIndex++)
{
this->PointCompactor.FindPoints(outputCellSets[cellSetIndex]);
}
this->PointCompactor.FindPoints(outputCellSet);
this->PointCompactor.FindPointsEnd();
for (VecId cellSetIndex = 0; cellSetIndex < numCellSets; ++cellSetIndex)
{
outputCellSets[cellSetIndex] = this->PointCompactor.MapCellSet(outputCellSets[cellSetIndex]);
}
outputCellSet = this->PointCompactor.MapCellSet(outputCellSet);
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)
{
@ -149,24 +138,18 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data
}
}
for (VecId cellSetIndex = 0; cellSetIndex < numCellSets; ++cellSetIndex)
{
outputCellSets[cellSetIndex] = this->PointMerger.MapCellSet(outputCellSets[cellSetIndex]);
}
outputCellSet = this->PointMerger.MapCellSet(outputCellSet);
}
// Optionally remove degenerate cells
if (this->GetRemoveDegenerateCells())
{
outputCellSets[activeCoordIndex] = this->CellCompactor.Run(outputCellSets[activeCoordIndex]);
outputCellSet = this->CellCompactor.Run(outputCellSet);
}
// Construct resulting data set with new cell sets
vtkm::cont::DataSet outData;
for (VecId cellSetIndex = 0; cellSetIndex < numCellSets; cellSetIndex++)
{
outData.AddCellSet(outputCellSets[cellSetIndex]);
}
outData.SetCellSet(outputCellSet);
// Pass the coordinate systems
for (VecId coordSystemIndex = 0; coordSystemIndex < numCoordSystems; ++coordSystemIndex)

@ -42,7 +42,7 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
}
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& inputCoords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -52,7 +52,7 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
//create the output data
vtkm::cont::DataSet output;
output.AddCellSet(outputCellSet);
output.SetCellSet(outputCellSet);
// Compute the new boundary points and add them to the output:
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());

@ -29,7 +29,7 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& inputCoords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -43,7 +43,7 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
//create the output data
vtkm::cont::DataSet output;
output.AddCellSet(outputCellSet);
output.SetCellSet(outputCellSet);
output.AddCoordinateSystem(outputCoords);
return output;

@ -41,7 +41,7 @@ inline VTKM_CONT vtkm::cont::DataSet ComputeMoments::DoExecute(
auto worklet = vtkm::worklet::moments::ComputeMoments(this->Radius);
worklet.Run(input.GetCellSet(this->GetActiveCellSetIndex()), field, this->Order, output);
worklet.Run(input.GetCellSet(), field, this->Order, output);
return output;
}

@ -120,7 +120,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
}
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -190,7 +190,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
}
//assign the connectivity to the cell set
output.AddCellSet(outputCells);
output.SetCellSet(outputCells);
//add the coordinates to the output dataset
vtkm::cont::CoordinateSystem outputCoords("coordinates", vertices);

@ -84,7 +84,7 @@ vtkm::cont::DataSet ContourTreeMesh2D::DoExecute(
}
// Collect sizing information from the dataset
const auto& dynamicCellSet = input.GetCellSet(this->GetActiveCellSetIndex());
const auto& dynamicCellSet = input.GetCellSet();
vtkm::cont::CellSetStructured<2> cellSet;
dynamicCellSet.CopyTo(cellSet);
@ -97,7 +97,7 @@ vtkm::cont::DataSet ContourTreeMesh2D::DoExecute(
vtkm::worklet::ContourTreeMesh2D worklet;
worklet.Run(field, nRows, nCols, saddlePeak);
return CreateResultFieldCell(input, saddlePeak, this->GetOutputFieldName(), dynamicCellSet);
return CreateResultFieldCell(input, saddlePeak, this->GetOutputFieldName());
}
//-----------------------------------------------------------------------------
ContourTreeMesh3D::ContourTreeMesh3D()
@ -121,7 +121,7 @@ vtkm::cont::DataSet ContourTreeMesh3D::DoExecute(
// Collect sizing information from the dataset
vtkm::cont::CellSetStructured<3> cellSet;
input.GetCellSet(this->GetActiveCellSetIndex()).CopyTo(cellSet);
input.GetCellSet().CopyTo(cellSet);
vtkm::Id3 pointDimensions = cellSet.GetPointDimensions();
vtkm::Id nRows = pointDimensions[0];

@ -115,7 +115,7 @@ vtkm::cont::DataSet ContourTreePPP2::DoExecute(const vtkm::cont::DataSet& input,
vtkm::Id nRows;
vtkm::Id nCols;
vtkm::Id nSlices = 1;
const auto& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const auto& cells = input.GetCellSet();
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(GetRowsColsSlices(), nRows, nCols, nSlices);
// Run the worklet

@ -79,18 +79,17 @@ inline VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inD
/// Use this function if you want to explicit construct a Cell field and have a ArrayHandle
/// that holds the data for the field.
template <typename T, typename Storage, typename CellSetTags>
template <typename T, typename Storage>
inline VTKM_CONT vtkm::cont::DataSet CreateResultFieldCell(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<T, Storage>& fieldArray,
const std::string& fieldName,
const vtkm::cont::DynamicCellSetBase<CellSetTags>& cellSet)
const std::string& fieldName)
{
VTKM_ASSERT(!fieldName.empty());
vtkm::cont::DataSet clone;
clone.CopyStructure(inDataSet);
clone.AddField(vtkm::cont::make_FieldCell(fieldName, cellSet.GetName(), fieldArray));
clone.AddField(vtkm::cont::make_FieldCell(fieldName, fieldArray));
// Sanity check.
VTKM_ASSERT(clone.HasCellField(fieldName));
@ -99,18 +98,16 @@ inline VTKM_CONT vtkm::cont::DataSet CreateResultFieldCell(
/// Use this function if you want to explicit construct a Cell field and have a VariantArrayHandle
/// that holds the data for the field.
template <typename CellSetTags>
inline VTKM_CONT vtkm::cont::DataSet CreateResultFieldCell(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::VariantArrayHandle& fieldArray,
const std::string& fieldName,
const vtkm::cont::DynamicCellSetBase<CellSetTags>& cellSet)
const std::string& fieldName)
{
VTKM_ASSERT(!fieldName.empty());
vtkm::cont::DataSet clone;
clone.CopyStructure(inDataSet);
clone.AddField(vtkm::cont::make_FieldCell(fieldName, cellSet.GetName(), fieldArray));
clone.AddField(vtkm::cont::make_FieldCell(fieldName, fieldArray));
// Sanity check.
VTKM_ASSERT(clone.HasCellField(fieldName));

@ -47,7 +47,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
//1. extract the cell set
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
//2. using the policy convert the dynamic cell set, and run the
// external faces worklet
@ -81,7 +81,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
//4. create the output dataset
vtkm::cont::DataSet output;
output.AddCellSet(outCellSet);
output.SetCellSet(outCellSet);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
if (this->CompactPoints)

@ -78,7 +78,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractGeometry::DoExecute(
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
// extract the input cell set and coordinates
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -95,7 +95,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractGeometry::DoExecute(
// create the output dataset
vtkm::cont::DataSet output;
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
output.AddCellSet(outCells);
output.SetCellSet(outCells);
return output;
}

@ -48,7 +48,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
// extract the input cell set and coordinates
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -63,7 +63,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i
// create the output dataset
vtkm::cont::DataSet output;
output.AddCellSet(outCellSet);
output.SetCellSet(outCellSet);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
// compact the unused points in the output dataset

@ -30,9 +30,8 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::CoordinateSystem& coordinates =
input.GetCoordinateSystem(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem();
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyStructured(cells, policy),
this->VOI,
@ -44,7 +43,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
vtkm::cont::CoordinateSystem outputCoordinates(coordinates.GetName(), coords);
vtkm::cont::DataSet output;
output.AddCellSet(vtkm::cont::DynamicCellSet(cellset));
output.SetCellSet(vtkm::cont::DynamicCellSet(cellset));
output.AddCoordinateSystem(outputCoordinates);
return output;
}

@ -26,7 +26,6 @@ public:
FieldMetadata()
: Name()
, Association(vtkm::cont::Field::Association::ANY)
, CellSetName()
{
}
@ -34,7 +33,6 @@ public:
FieldMetadata(const vtkm::cont::Field& f)
: Name(f.GetName())
, Association(f.GetAssociation())
, CellSetName(f.GetAssocCellSet())
{
}
@ -42,7 +40,6 @@ public:
FieldMetadata(const vtkm::cont::CoordinateSystem& sys)
: Name(sys.GetName())
, Association(sys.GetAssociation())
, CellSetName(sys.GetAssocCellSet())
{
}
@ -58,23 +55,13 @@ public:
VTKM_CONT
vtkm::cont::Field::Association GetAssociation() const { return this->Association; }
VTKM_CONT
const std::string& GetCellSetName() const { return this->CellSetName; }
/// Construct a new field with the same association as stored in this FieldMetaData
/// but with a new name
template <typename T, typename StorageTag>
VTKM_CONT vtkm::cont::Field AsField(const std::string& name,
const vtkm::cont::ArrayHandle<T, StorageTag>& handle) const
{
if (this->IsCellField())
{
return vtkm::cont::Field(name, this->Association, this->CellSetName, handle);
}
else
{
return vtkm::cont::Field(name, this->Association, handle);
}
return vtkm::cont::Field(name, this->Association, handle);
}
/// Construct a new field with the same association as stored in this FieldMetaData
/// but with a new name
@ -82,14 +69,7 @@ public:
vtkm::cont::Field AsField(const std::string& name,
const vtkm::cont::VariantArrayHandle& handle) const
{
if (this->IsCellField())
{
return vtkm::cont::Field(name, this->Association, this->CellSetName, handle);
}
else
{
return vtkm::cont::Field(name, this->Association, handle);
}
return vtkm::cont::Field(name, this->Association, handle);
}
/// Construct a new field with the same association and name as stored in this FieldMetaData
@ -107,7 +87,6 @@ public:
private:
std::string Name; ///< name of field
vtkm::cont::Field::Association Association;
std::string CellSetName; ///< only populate if assoc is cells
};
}
}

@ -35,12 +35,6 @@ public:
VTKM_CONT
~FilterDataSet();
VTKM_CONT
void SetActiveCellSetIndex(vtkm::Id index) { this->CellSetIndex = index; }
VTKM_CONT
vtkm::Id GetActiveCellSetIndex() const { return this->CellSetIndex; }
VTKM_CONT
void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; }
@ -66,7 +60,6 @@ public:
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
private:
vtkm::Id CellSetIndex;
vtkm::Id CoordinateSystemIndex;
friend class vtkm::filter::Filter<Derived>;

@ -23,8 +23,7 @@ namespace filter
//----------------------------------------------------------------------------
template <typename Derived>
inline VTKM_CONT FilterDataSet<Derived>::FilterDataSet()
: CellSetIndex(0)
, CoordinateSystemIndex(0)
: CoordinateSystemIndex(0)
{
}

@ -35,12 +35,6 @@ public:
VTKM_CONT
~FilterDataSetWithField();
VTKM_CONT
void SetActiveCellSetIndex(vtkm::Id index) { this->CellSetIndex = index; }
VTKM_CONT
vtkm::Id GetActiveCellSetIndex() const { return this->CellSetIndex; }
VTKM_CONT
void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; }
@ -80,7 +74,6 @@ public:
// Association::WHOLE_MESH -> (I think this is points)
// Association::POINTS -> map using point mapping
// Association::CELL_SET -> how do we map this?
// Association::LOGICAL_DIM -> unable to map?
template <typename DerivedPolicy>
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
const vtkm::cont::Field& field,
@ -106,7 +99,6 @@ private:
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
std::string OutputFieldName;
vtkm::Id CellSetIndex;
vtkm::Id CoordinateSystemIndex;
std::string ActiveFieldName;
vtkm::cont::Field::Association ActiveFieldAssociation;

@ -31,7 +31,6 @@ namespace filter
template <typename Derived>
inline VTKM_CONT FilterDataSetWithField<Derived>::FilterDataSetWithField()
: OutputFieldName()
, CellSetIndex(0)
, CoordinateSystemIndex(0)
, ActiveFieldName()
, ActiveFieldAssociation(vtkm::cont::Field::Association::ANY)
@ -56,8 +55,7 @@ inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareFor
{
// we need to state that the field is actually a coordinate system, so that
// the filter uses the proper policy to convert the types.
return this->PrepareForExecution(
input, input.GetCoordinateSystem(this->GetActiveCellSetIndex()), policy);
return this->PrepareForExecution(input, input.GetCoordinateSystem(), policy);
}
else
{

@ -74,26 +74,13 @@ public:
/// DataSet. This is used primarily by the Filter to select the coordinate system
/// to use as a field when \c UseCoordinateSystemAsField is true.
VTKM_CONT
void SetActiveCoordinateSystem(vtkm::Id index)
{
this->DeduceCellSetIndex = false;
this->CoordinateSystemIndex = index;
}
void SetActiveCoordinateSystem(vtkm::Id index) { this->CoordinateSystemIndex = index; }
VTKM_CONT
vtkm::Id GetActiveCoordinateSystemIndex() const { return this->CoordinateSystemIndex; }
//@}
//@{
/// Override the cellSet index to be active when executing the filter. By default
/// When processing cell fields the active cellset is the one assoicated with the
/// provided field, otherwise it will default to 0.
VTKM_CONT
void SetActiveCellSetIndex(vtkm::Id index) { this->CellSetIndex = index; }
VTKM_CONT
vtkm::Id GetActiveCellSetIndex() const { return this->CellSetIndex; }
/// These are provided to satisfy the Filter API requirements.
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet PrepareForExecution(
@ -111,15 +98,14 @@ public:
const vtkm::cont::DataSet& input,
const vtkm::cont::CoordinateSystem& field,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
//@}
protected:
private:
std::string OutputFieldName;
vtkm::Id CellSetIndex;
vtkm::Id CoordinateSystemIndex;
std::string ActiveFieldName;
vtkm::cont::Field::Association ActiveFieldAssociation;
bool DeduceCellSetIndex;
bool UseCoordinateSystemAsField;
friend class vtkm::filter::Filter<Derived>;

@ -30,11 +30,9 @@ namespace filter
template <typename Derived>
inline VTKM_CONT FilterField<Derived>::FilterField()
: OutputFieldName()
, CellSetIndex(0)
, CoordinateSystemIndex(0)
, ActiveFieldName()
, ActiveFieldAssociation(vtkm::cont::Field::Association::ANY)
, DeduceCellSetIndex(true)
, UseCoordinateSystemAsField(false)
{
}
@ -74,17 +72,6 @@ inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
//If the user hasn't specified a field, try and deduce
//one based on the field. Once we are done executing we
//need to rollback the CellSetIndex so this isn't used on
//a subsequent execution by a non-cell field
if (this->DeduceCellSetIndex && field.IsFieldCell())
{
//If no cellset is found that matches the name, default to the first
//cellset
this->CellSetIndex = std::max(vtkm::Id{ 0 }, input.GetCellSetIndex(field.GetAssocCellSet()));
}
vtkm::filter::FieldMetadata metaData(field);
vtkm::cont::DataSet result;
@ -96,10 +83,6 @@ inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
metaData,
policy,
result);
if (this->DeduceCellSetIndex)
{
this->CellSetIndex = 0;
}
return result;
}

@ -136,7 +136,7 @@ template <typename Policy>
inline VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<Policy>)
{
const vtkm::cont::DynamicCellSet& cellset = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cellset = input.GetCellSet();
vtkm::Id numCells = cellset.GetNumberOfCells();
vtkm::cont::ArrayHandleIndex indexArray(numCells);
vtkm::cont::ArrayHandle<vtkm::UInt8> ghosts;
@ -176,7 +176,7 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::co
throw vtkm::cont::ErrorFilterExecution("Unsupported cellset type for GhostCellClassify.");
}
return CreateResultFieldCell(input, ghosts, "vtkmGhostCells", cellset);
return CreateResultFieldCell(input, ghosts, "vtkmGhostCells");
}
template <typename ValueType, typename Storage, typename Policy>

@ -305,7 +305,7 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
vtkm::cont::DynamicCellSet cellOut;
//Preserve structured output where possible.
@ -354,7 +354,7 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
vtkm::cont::DataSet output;
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
output.AddCellSet(cellOut);
output.SetCellSet(cellOut);
return output;
}

@ -49,7 +49,7 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
}
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -91,22 +91,22 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
: vtkm::cont::Field::Association::CELL_SET);
vtkm::cont::DataSet result;
result.CopyStructure(input);
result.AddField(vtkm::cont::make_Field(outputName, fieldAssociation, cells.GetName(), outArray));
result.AddField(vtkm::cont::Field{ outputName, fieldAssociation, outArray });
if (this->GetComputeDivergence() && isVector)
{
result.AddField(vtkm::cont::make_Field(
this->GetDivergenceName(), fieldAssociation, cells.GetName(), gradientfields.Divergence));
result.AddField(
vtkm::cont::Field{ this->GetDivergenceName(), fieldAssociation, gradientfields.Divergence });
}
if (this->GetComputeVorticity() && isVector)
{
result.AddField(vtkm::cont::make_Field(
this->GetVorticityName(), fieldAssociation, cells.GetName(), gradientfields.Vorticity));
result.AddField(
vtkm::cont::Field{ this->GetVorticityName(), fieldAssociation, gradientfields.Vorticity });
}
if (this->GetComputeQCriterion() && isVector)
{
result.AddField(vtkm::cont::make_Field(
this->GetQCriterionName(), fieldAssociation, cells.GetName(), gradientfields.QCriterion));
result.AddField(
vtkm::cont::Field{ this->GetQCriterionName(), fieldAssociation, gradientfields.QCriterion });
}
return result;
}

@ -33,9 +33,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageConnectivity::DoExecute(
vtkm::cont::ArrayHandle<vtkm::Id> component;
vtkm::worklet::connectivity::ImageConnectivity().Run(
vtkm::filter::ApplyPolicy(input.GetCellSet(this->GetActiveCellSetIndex()), policy),
field,
component);
vtkm::filter::ApplyPolicy(input.GetCellSet(), policy), field, component);
auto result = CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
return result;

@ -108,8 +108,7 @@ inline void Lagrangian::WriteDataSet(vtkm::Id cycle,
file << filename << cycle << ".vtk";
vtkm::io::writer::VTKDataSetWriter writer(file.str().c_str());
writer.WriteDataSet(dataset);
std::cout << "Number of flows in writedataset is : " << dataset.GetCellSet(0).GetNumberOfCells()
<< std::endl;
std::cout << "Number of flows in writedataset is : " << dataset.GetNumberOfCells() << std::endl;
}
//-----------------------------------------------------------------------------
@ -228,7 +227,7 @@ inline VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(
cycle += 1;
std::cout << "Cycle : " << cycle << std::endl;
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();

@ -127,7 +127,7 @@ inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
vtkm::cont::DataSet output;
vtkm::cont::DataSetFieldAdd fieldAdder;
output.AddCoordinateSystem(lcsInput.GetCoordinateSystem());
output.AddCellSet(lcsInput.GetCellSet());
output.SetCellSet(lcsInput.GetCellSet());
fieldAdder.AddPointField(output, this->GetOutputFieldName(), outputField);
return output;
}

@ -51,7 +51,7 @@ template <typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
vtkm::cont::DynamicCellSet cellOut;
CallWorklet workletCaller(this->Stride, cellOut, this->Worklet);
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(workletCaller);
@ -59,7 +59,7 @@ inline VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet&
// create the output dataset
vtkm::cont::DataSet output;
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
output.AddCellSet(cellOut);
output.SetCellSet(cellOut);
return output;
}

@ -46,7 +46,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
// extract the input cell set
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
// run the worklet on the cell set and input field
vtkm::cont::CellSetSingleType<> outCellSet;
@ -56,7 +56,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
// create the output dataset
vtkm::cont::DataSet output;
output.AddCellSet(outCellSet);
output.SetCellSet(outCellSet);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
// compact the unused points in the output dataset

@ -83,7 +83,7 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
//TODO: Should other cellset types be supported?
vtkm::cont::CellSetExplicit<> cellSet;
input.GetCellSet(this->GetActiveCellSetIndex()).CopyTo(cellSet);
input.GetCellSet().CopyTo(cellSet);
ShapeHandle cellShapes =
cellSet.GetShapesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
@ -229,7 +229,7 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
}
//Append the summary stats into the output dataset as a new field
result.AddField(vtkm::cont::make_FieldCell(fieldName, "cells", shapeMeshQuality));
result.AddField(vtkm::cont::make_FieldCell(fieldName, shapeMeshQuality));
#ifdef DEBUG_PRINT
std::cout << "-----------------------------------------------------\n"
@ -255,7 +255,7 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
//Append the metric values of all cells into the output
//dataset as a new field
const std::string s = "allCells-metricValues";
result.AddField(vtkm::cont::make_FieldCell(s, "cells", outArray));
result.AddField(vtkm::cont::make_FieldCell(s, outArray));
return result;
}

@ -48,9 +48,8 @@ inline VTKM_CONT vtkm::cont::DataSet Pathline::DoExecute(
throw vtkm::cont::ErrorFilterExecution("No seeds provided.");
}
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells2 =
this->NextDataSet.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::DynamicCellSet& cells2 = this->NextDataSet.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
const vtkm::cont::CoordinateSystem& coords2 =
@ -81,7 +80,7 @@ inline VTKM_CONT vtkm::cont::DataSet Pathline::DoExecute(
vtkm::cont::DataSet outData;
vtkm::cont::CoordinateSystem outputCoords("coordinates", res.positions);
outData.AddCellSet(res.polyLines);
outData.SetCellSet(res.polyLines);
outData.AddCoordinateSystem(outputCoords);
return outData;

@ -36,7 +36,7 @@ inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
throw vtkm::cont::ErrorFilterExecution("Cell field expected.");
}
vtkm::cont::DynamicCellSet cellSet = input.GetCellSet(this->GetActiveCellSetIndex());
vtkm::cont::DynamicCellSet cellSet = input.GetCellSet();
//todo: we need to ask the policy what storage type we should be using
//If the input is implicit, we should know what to fall back to

@ -21,8 +21,7 @@ namespace filter
/// \brief
///
/// Generate scalar field from a dataset.
template <typename S>
class PointTransform : public vtkm::filter::FilterField<PointTransform<S>>
class PointTransform : public vtkm::filter::FilterField<PointTransform>
{
public:
using SupportedTypes = vtkm::TypeListTagFieldVec3;
@ -30,27 +29,39 @@ public:
VTKM_CONT
PointTransform();
void SetTranslation(const S& tx, const S& ty, const S& tz);
void SetTranslation(const vtkm::FloatDefault& tx,
const vtkm::FloatDefault& ty,
const vtkm::FloatDefault& tz);
void SetTranslation(const vtkm::Vec<S, 3>& v);
void SetTranslation(const vtkm::Vec3f& v);
void SetRotation(const S& angleDegrees, const vtkm::Vec<S, 3>& axis);
void SetRotation(const vtkm::FloatDefault& angleDegrees, const vtkm::Vec3f& axis);
void SetRotation(const S& angleDegrees, const S& rx, const S& ry, const S& rz);
void SetRotation(const vtkm::FloatDefault& angleDegrees,
const vtkm::FloatDefault& rx,
const vtkm::FloatDefault& ry,
const vtkm::FloatDefault& rz);
void SetRotationX(const S& angleDegrees);
void SetRotationX(const vtkm::FloatDefault& angleDegrees);
void SetRotationY(const S& angleDegrees);
void SetRotationY(const vtkm::FloatDefault& angleDegrees);
void SetRotationZ(const S& angleDegrees);
void SetRotationZ(const vtkm::FloatDefault& angleDegrees);
void SetScale(const S& s);
void SetScale(const vtkm::FloatDefault& s);
void SetScale(const S& sx, const S& sy, const S& sz);
void SetScale(const vtkm::FloatDefault& sx,
const vtkm::FloatDefault& sy,
const vtkm::FloatDefault& sz);
void SetScale(const vtkm::Vec3f& v);
void SetTransform(const vtkm::Matrix<vtkm::FloatDefault, 4, 4>& mtx);
void SetChangeCoordinateSystem(bool flag);
bool GetChangeCoordinateSystem() const;
void SetScale(const vtkm::Vec<S, 3>& v);
void SetTransform(const vtkm::Matrix<S, 4, 4>& mtx);
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
@ -59,11 +70,14 @@ public:
vtkm::filter::PolicyBase<DerivedPolicy> policy);
private:
vtkm::worklet::PointTransform<S> Worklet;
vtkm::worklet::PointTransform<vtkm::FloatDefault> Worklet;
bool ChangeCoordinateSystem;
};
}
} // namespace vtkm::filter
#ifndef vtk_m_filter_PointTransform_hxx
#include <vtkm/filter/PointTransform.hxx>
#endif
#endif // vtk_m_filter_PointTransform_h

@ -8,105 +8,114 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_filter_PointTransform_hxx
#define vtk_m_filter_PointTransform_hxx
#include <vtkm/filter/PointTransform.h>
namespace vtkm
{
namespace filter
{
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT PointTransform<S>::PointTransform()
inline VTKM_CONT PointTransform::PointTransform()
: Worklet()
, ChangeCoordinateSystem(true)
{
this->SetOutputFieldName("transform");
this->SetUseCoordinateSystemAsField(true);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetTranslation(const S& tx, const S& ty, const S& tz)
inline VTKM_CONT void PointTransform::SetTranslation(const vtkm::FloatDefault& tx,
const vtkm::FloatDefault& ty,
const vtkm::FloatDefault& tz)
{
this->Worklet.SetTranslation(tx, ty, tz);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetTranslation(const vtkm::Vec<S, 3>& v)
inline VTKM_CONT void PointTransform::SetTranslation(const vtkm::Vec3f& v)
{
this->Worklet.SetTranslation(v);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetRotation(const S& angleDegrees,
const vtkm::Vec<S, 3>& axis)
inline VTKM_CONT void PointTransform::SetRotation(const vtkm::FloatDefault& angleDegrees,
const vtkm::Vec3f& axis)
{
this->Worklet.SetRotation(angleDegrees, axis);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetRotation(const S& angleDegrees,
const S& rx,
const S& ry,
const S& rz)
inline VTKM_CONT void PointTransform::SetRotation(const vtkm::FloatDefault& angleDegrees,
const vtkm::FloatDefault& rx,
const vtkm::FloatDefault& ry,
const vtkm::FloatDefault& rz)
{
this->Worklet.SetRotation(angleDegrees, rx, ry, rz);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetRotationX(const S& angleDegrees)
inline VTKM_CONT void PointTransform::SetRotationX(const vtkm::FloatDefault& angleDegrees)
{
this->Worklet.SetRotationX(angleDegrees);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetRotationY(const S& angleDegrees)
inline VTKM_CONT void PointTransform::SetRotationY(const vtkm::FloatDefault& angleDegrees)
{
this->Worklet.SetRotationY(angleDegrees);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetRotationZ(const S& angleDegrees)
inline VTKM_CONT void PointTransform::SetRotationZ(const vtkm::FloatDefault& angleDegrees)
{
this->Worklet.SetRotationZ(angleDegrees);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetScale(const S& s)
inline VTKM_CONT void PointTransform::SetScale(const vtkm::FloatDefault& s)
{
this->Worklet.SetScale(s);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetScale(const S& sx, const S& sy, const S& sz)
inline VTKM_CONT void PointTransform::SetScale(const vtkm::FloatDefault& sx,
const vtkm::FloatDefault& sy,
const vtkm::FloatDefault& sz)
{
this->Worklet.SetScale(sx, sy, sz);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetScale(const vtkm::Vec<S, 3>& v)
inline VTKM_CONT void PointTransform::SetScale(const vtkm::Vec3f& v)
{
this->Worklet.SetScale(v);
}
//-----------------------------------------------------------------------------
template <typename S>
inline VTKM_CONT void PointTransform<S>::SetTransform(const vtkm::Matrix<S, 4, 4>& mtx)
inline VTKM_CONT void PointTransform::SetTransform(
const vtkm::Matrix<vtkm::FloatDefault, 4, 4>& mtx)
{
this->Worklet.SetTransform(mtx);
}
//-----------------------------------------------------------------------------
inline VTKM_CONT void PointTransform::SetChangeCoordinateSystem(bool flag)
{
this->ChangeCoordinateSystem = flag;
}
//-----------------------------------------------------------------------------
inline VTKM_CONT bool PointTransform::GetChangeCoordinateSystem() const
{
return this->ChangeCoordinateSystem;
}
//-----------------------------------------------------------------------------
template <typename S>
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet PointTransform<S>::DoExecute(
inline VTKM_CONT vtkm::cont::DataSet PointTransform::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMetadata,
@ -115,7 +124,19 @@ inline VTKM_CONT vtkm::cont::DataSet PointTransform<S>::DoExecute(
vtkm::cont::ArrayHandle<T> outArray;
this->Invoke(this->Worklet, field, outArray);
return CreateResult(inDataSet, outArray, this->GetOutputFieldName(), fieldMetadata);
vtkm::cont::DataSet outData =
CreateResult(inDataSet, outArray, this->GetOutputFieldName(), fieldMetadata);
if (this->GetChangeCoordinateSystem())
{
vtkm::Id coordIndex =
this->GetUseCoordinateSystemAsField() ? this->GetActiveCoordinateSystemIndex() : 0;
outData.GetCoordinateSystem(coordIndex).SetData(outArray);
}
return outData;
}
}
} // namespace vtkm::filter
#endif //vtk_m_filter_PointTransform_hxx

@ -17,7 +17,7 @@ VTKM_CONT
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
{
this->Geometry = vtkm::cont::DataSet();
this->Geometry.AddCellSet(geometry.GetCellSet());
this->Geometry.SetCellSet(geometry.GetCellSet());
this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem());
}
@ -26,10 +26,9 @@ VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
this->Worklet.Run(
vtkm::filter::ApplyPolicy(input.GetCellSet(this->GetActiveCellSetIndex()), policy),
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
this->Geometry.GetCoordinateSystem().GetData());
this->Worklet.Run(vtkm::filter::ApplyPolicy(input.GetCellSet(), policy),
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
this->Geometry.GetCoordinateSystem().GetData());
auto output = this->Geometry;
auto hpf = this->Worklet.GetHiddenPointsField();
@ -37,7 +36,7 @@ VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
this->Worklet.GetHiddenCellsField(vtkm::filter::ApplyPolicy(output.GetCellSet(), policy));
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", output.GetCellSet().GetName(), hcf));
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
return output;
}

@ -34,7 +34,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
// Get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
vtkm::cont::ArrayHandle<vtkm::Vec3f> newCoords;
vtkm::cont::CellSetExplicit<> newCellset;
@ -46,7 +46,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
newCellset);
vtkm::cont::DataSet output;
output.AddCellSet(newCellset);
output.SetCellSet(newCellset);
output.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(input.GetCoordinateSystem().GetName(), newCoords));
return output;

@ -40,7 +40,7 @@ inline VTKM_CONT vtkm::cont::DataSet StreamSurface::DoExecute(
if (this->Seeds.GetNumberOfValues() == 0)
throw vtkm::cont::ErrorFilterExecution("No seeds provided.");
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -70,7 +70,7 @@ inline VTKM_CONT vtkm::cont::DataSet StreamSurface::DoExecute(
vtkm::cont::DataSet outData;
vtkm::cont::CoordinateSystem outputCoords("coordinates", srfPoints);
outData.AddCoordinateSystem(outputCoords);
outData.AddCellSet(srfCells);
outData.SetCellSet(srfCells);
return outData;
}

@ -47,7 +47,7 @@ inline VTKM_CONT vtkm::cont::DataSet Streamline::DoExecute(
throw vtkm::cont::ErrorFilterExecution("No seeds provided.");
}
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
@ -71,7 +71,7 @@ inline VTKM_CONT vtkm::cont::DataSet Streamline::DoExecute(
vtkm::cont::DataSet outData;
vtkm::cont::CoordinateSystem outputCoords("coordinates", res.positions);
outData.AddCellSet(res.polyLines);
outData.SetCellSet(res.polyLines);
outData.AddCoordinateSystem(outputCoords);
return outData;

@ -83,8 +83,7 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
throw vtkm::cont::ErrorFilterExecution("No normals selected.");
}
const auto cellset =
vtkm::filter::ApplyPolicyUnstructured(input.GetCellSet(this->GetActiveCellSetIndex()), policy);
const auto cellset = vtkm::filter::ApplyPolicyUnstructured(input.GetCellSet(), policy);
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetData();
vtkm::cont::ArrayHandle<vtkm::Vec3f> faceNormals;
@ -103,14 +102,13 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
result = CreateResultFieldPoint(input, pointNormals, internal::ComputePointNormalsName(this));
if (this->GenerateCellNormals)
{
result.AddField(vtkm::cont::make_FieldCell(
internal::ComputeCellNormalsName(this), cellset.GetName(), faceNormals));
result.AddField(
vtkm::cont::make_FieldCell(internal::ComputeCellNormalsName(this), faceNormals));
}
}
else
{
result =
CreateResultFieldCell(input, faceNormals, internal::ComputeCellNormalsName(this), cellset);
result = CreateResultFieldCell(input, faceNormals, internal::ComputeCellNormalsName(this));
}
if (this->AutoOrientNormals)
@ -146,31 +144,7 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
if (this->Consistency && this->GenerateCellNormals)
{
auto newCells = vtkm::worklet::TriangleWinding::Run(cellset, coords, faceNormals);
// Add the new cells into the result:
vtkm::cont::DataSet newResult;
for (vtkm::Id i = 0; i < result.GetNumberOfCoordinateSystems(); ++i)
{
newResult.AddCoordinateSystem(result.GetCoordinateSystem(i));
}
const vtkm::Id activeCells = this->GetActiveCellSetIndex();
for (vtkm::Id i = 0; i < result.GetNumberOfCellSets(); ++i)
{
if (i != activeCells)
{
newResult.AddCellSet(result.GetCellSet(i));
}
else
{
newResult.AddCellSet(newCells);
}
}
for (vtkm::Id i = 0; i < result.GetNumberOfFields(); ++i)
{
newResult.AddField(result.GetField(i));
}
result = newResult;
result.SetCellSet(newCells); // Overwrite the cellset in the result
}
return result;

@ -40,7 +40,7 @@ inline VTKM_CONT vtkm::cont::DataSet Tetrahedralize::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
vtkm::cont::CellSetSingleType<> outCellSet;
vtkm::cont::CastAndCall(
@ -48,7 +48,7 @@ inline VTKM_CONT vtkm::cont::DataSet Tetrahedralize::DoExecute(
// create the output dataset
vtkm::cont::DataSet output;
output.AddCellSet(outCellSet);
output.SetCellSet(outCellSet);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
return output;
}

@ -61,14 +61,14 @@ inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
ThresholdRange predicate(this->GetLowerThreshold(), this->GetUpperThreshold());
vtkm::cont::DynamicCellSet cellOut = this->Worklet.Run(
vtkm::filter::ApplyPolicy(cells, policy), field, fieldMeta.GetAssociation(), predicate);
vtkm::cont::DataSet output;
output.AddCellSet(cellOut);
output.SetCellSet(cellOut);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
return output;
}

@ -143,7 +143,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
// extract the input cell set
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
// field to threshold on must be a point field
if (fieldMeta.IsPointField() == false)
@ -181,7 +181,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
// create the output dataset
vtkm::cont::DataSet output;
output.AddCellSet(outCellSet);
output.SetCellSet(outCellSet);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
// compact the unused points in the output dataset

@ -65,7 +65,7 @@ inline VTKM_CONT vtkm::cont::DataSet Triangulate::DoExecute(
const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
vtkm::cont::CellSetSingleType<> outCellSet;
DeduceCellSet triangulate(this->Worklet, outCellSet);
@ -74,7 +74,7 @@ inline VTKM_CONT vtkm::cont::DataSet Triangulate::DoExecute(
// create the output dataset
vtkm::cont::DataSet output;
output.AddCellSet(outCellSet);
output.SetCellSet(outCellSet);
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
return output;

@ -36,13 +36,13 @@ inline VTKM_CONT vtkm::cont::DataSet Tube::DoExecute(const vtkm::cont::DataSet&
vtkm::cont::ArrayHandle<vtkm::Vec3f> newPoints;
vtkm::cont::CellSetSingleType<> newCells;
this->Worklet.Run(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
input.GetCellSet(this->GetActiveCellSetIndex()),
input.GetCellSet(),
newPoints,
newCells);
vtkm::cont::DataSet outData;
vtkm::cont::CoordinateSystem outCoords("coordinates", newPoints);
outData.AddCellSet(newCells);
outData.SetCellSet(newCells);
outData.AddCoordinateSystem(outCoords);
return outData;
}

@ -43,25 +43,11 @@ inline VTKM_CONT ZFPCompressor1D::ZFPCompressor1D()
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ZFPCompressor1D::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
auto compressed = compressor.Compress(field, rate, field.GetNumberOfValues());
vtkm::cont::DataSet dataset;

@ -47,28 +47,15 @@ inline VTKM_CONT vtkm::cont::DataSet ZFPCompressor2D::DoExecute(
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
vtkm::cont::CellSetStructured<2> cellSet;
input.GetCellSet(this->GetActiveCellSetIndex()).CopyTo(cellSet);
input.GetCellSet().CopyTo(cellSet);
vtkm::Id2 pointDimensions = cellSet.GetPointDimensions();
auto compressed = compressor.Compress(field, rate, pointDimensions);
vtkm::cont::DataSet dataset;
dataset.AddCellSet(cellSet);
dataset.SetCellSet(cellSet);
dataset.AddField(vtkm::cont::make_FieldPoint("compressed", compressed));
return dataset;

@ -47,28 +47,15 @@ inline VTKM_CONT vtkm::cont::DataSet ZFPCompressor3D::DoExecute(
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
vtkm::cont::CellSetStructured<3> cellSet;
input.GetCellSet(this->GetActiveCellSetIndex()).CopyTo(cellSet);
input.GetCellSet().CopyTo(cellSet);
vtkm::Id3 pointDimensions = cellSet.GetPointDimensions();
auto compressed = compressor.Compress(field, rate, pointDimensions);
vtkm::cont::DataSet dataset;
dataset.AddCellSet(cellSet);
dataset.SetCellSet(cellSet);
dataset.AddField(vtkm::cont::make_FieldPoint("compressed", compressed));
return dataset;

@ -39,25 +39,11 @@ inline VTKM_CONT vtkm::cont::DataSet ZFPDecompressor1D::DoExecute(
//-----------------------------------------------------------------------------
template <typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ZFPDecompressor1D::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<vtkm::Int64, StorageType>& field,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
vtkm::cont::ArrayHandle<vtkm::Float64> decompress;
decompressor.Decompress(field, decompress, rate, field.GetNumberOfValues());

@ -45,22 +45,8 @@ inline VTKM_CONT vtkm::cont::DataSet ZFPDecompressor2D::DoExecute(
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
vtkm::cont::CellSetStructured<2> cellSet;
input.GetCellSet(this->GetActiveCellSetIndex()).CopyTo(cellSet);
input.GetCellSet().CopyTo(cellSet);
vtkm::Id2 pointDimensions = cellSet.GetPointDimensions();
vtkm::cont::ArrayHandle<vtkm::Float64> decompress;

@ -44,22 +44,8 @@ inline VTKM_CONT vtkm::cont::DataSet ZFPDecompressor3D::DoExecute(
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
vtkm::cont::CellSetStructured<3> cellSet;
input.GetCellSet(this->GetActiveCoordinateSystemIndex()).CopyTo(cellSet);
input.GetCellSet().CopyTo(cellSet);
vtkm::Id3 pointDimensions = cellSet.GetPointDimensions();
vtkm::cont::ArrayHandle<vtkm::Float64> decompress;

@ -30,12 +30,9 @@ void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset,
vtkm::cont::DataSet outputData = vols.Execute(dataset);
VTKM_TEST_ASSERT(vols.GetCellMeasureName().empty(), "Default output field name should be empty.");
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() ==
static_cast<vtkm::Id>(expected.size()),
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == static_cast<vtkm::Id>(expected.size()),
"Wrong number of cells in the output dataset");
// Check that the empty measure name above produced a field with the expected name.

@ -101,10 +101,10 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
static constexpr vtkm::IdComponent ndim = 3;
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
cellSet.SetPointDimensions(vdims);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
dataSet.AddField(vtkm::cont::make_FieldPoint("nodevar", pointFieldArray));
dataSet.AddField(vtkm::cont::make_FieldCell("cellvar", "cells", cellFieldArray));
dataSet.AddField(vtkm::cont::make_FieldCell("cellvar", cellFieldArray));
return dataSet;
}

@ -80,7 +80,7 @@ void TestPointMerging()
constexpr vtkm::Id originalNumPoints = 228;
constexpr vtkm::Id originalNumCells = 76;
VTKM_TEST_ASSERT(inData.GetCellSet().GetNumberOfPoints() == originalNumPoints);
VTKM_TEST_ASSERT(inData.GetCellSet().GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(inData.GetNumberOfCells() == originalNumCells);
vtkm::filter::CleanGrid cleanGrid;
@ -89,9 +89,9 @@ void TestPointMerging()
cleanGrid.SetMergePoints(false);
cleanGrid.SetRemoveDegenerateCells(false);
vtkm::cont::DataSet noMerging = cleanGrid.Execute(inData);
VTKM_TEST_ASSERT(noMerging.GetCellSet().GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(noMerging.GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(noMerging.GetCellSet().GetNumberOfPoints() == originalNumPoints);
VTKM_TEST_ASSERT(noMerging.GetCoordinateSystem().GetNumberOfPoints() == originalNumPoints);
VTKM_TEST_ASSERT(noMerging.GetNumberOfPoints() == originalNumPoints);
VTKM_TEST_ASSERT(noMerging.GetField("pointvar").GetNumberOfValues() == originalNumPoints);
VTKM_TEST_ASSERT(noMerging.GetField("cellvar").GetNumberOfValues() == originalNumCells);
@ -100,18 +100,18 @@ void TestPointMerging()
cleanGrid.SetFastMerge(false);
vtkm::cont::DataSet closeMerge = cleanGrid.Execute(inData);
constexpr vtkm::Id closeMergeNumPoints = 62;
VTKM_TEST_ASSERT(closeMerge.GetCellSet().GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(closeMerge.GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(closeMerge.GetCellSet().GetNumberOfPoints() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeMerge.GetCoordinateSystem().GetNumberOfPoints() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeMerge.GetNumberOfPoints() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeMerge.GetField("pointvar").GetNumberOfValues() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeMerge.GetField("cellvar").GetNumberOfValues() == originalNumCells);
std::cout << "Clean grid by merging very close points with fast merge" << std::endl;
cleanGrid.SetFastMerge(true);
vtkm::cont::DataSet closeFastMerge = cleanGrid.Execute(inData);
VTKM_TEST_ASSERT(closeFastMerge.GetCellSet().GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(closeFastMerge.GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(closeFastMerge.GetCellSet().GetNumberOfPoints() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeFastMerge.GetCoordinateSystem().GetNumberOfPoints() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeFastMerge.GetNumberOfPoints() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeFastMerge.GetField("pointvar").GetNumberOfValues() == closeMergeNumPoints);
VTKM_TEST_ASSERT(closeFastMerge.GetField("cellvar").GetNumberOfValues() == originalNumCells);
@ -120,9 +120,9 @@ void TestPointMerging()
cleanGrid.SetTolerance(0.1);
vtkm::cont::DataSet farMerge = cleanGrid.Execute(inData);
constexpr vtkm::Id farMergeNumPoints = 36;
VTKM_TEST_ASSERT(farMerge.GetCellSet().GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(farMerge.GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(farMerge.GetCellSet().GetNumberOfPoints() == farMergeNumPoints);
VTKM_TEST_ASSERT(farMerge.GetCoordinateSystem().GetNumberOfPoints() == farMergeNumPoints);
VTKM_TEST_ASSERT(farMerge.GetNumberOfPoints() == farMergeNumPoints);
VTKM_TEST_ASSERT(farMerge.GetField("pointvar").GetNumberOfValues() == farMergeNumPoints);
VTKM_TEST_ASSERT(farMerge.GetField("cellvar").GetNumberOfValues() == originalNumCells);
@ -130,9 +130,9 @@ void TestPointMerging()
cleanGrid.SetFastMerge(true);
vtkm::cont::DataSet farFastMerge = cleanGrid.Execute(inData);
constexpr vtkm::Id farFastMergeNumPoints = 19;
VTKM_TEST_ASSERT(farFastMerge.GetCellSet().GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(farFastMerge.GetNumberOfCells() == originalNumCells);
VTKM_TEST_ASSERT(farFastMerge.GetCellSet().GetNumberOfPoints() == farFastMergeNumPoints);
VTKM_TEST_ASSERT(farFastMerge.GetCoordinateSystem().GetNumberOfPoints() == farFastMergeNumPoints);
VTKM_TEST_ASSERT(farFastMerge.GetNumberOfPoints() == farFastMergeNumPoints);
VTKM_TEST_ASSERT(farFastMerge.GetField("pointvar").GetNumberOfValues() == farFastMergeNumPoints);
VTKM_TEST_ASSERT(farFastMerge.GetField("cellvar").GetNumberOfValues() == originalNumCells);
@ -141,10 +141,9 @@ void TestPointMerging()
cleanGrid.SetRemoveDegenerateCells(true);
vtkm::cont::DataSet noDegenerateCells = cleanGrid.Execute(inData);
constexpr vtkm::Id numNonDegenerateCells = 33;
VTKM_TEST_ASSERT(noDegenerateCells.GetCellSet().GetNumberOfCells() == numNonDegenerateCells);
VTKM_TEST_ASSERT(noDegenerateCells.GetNumberOfCells() == numNonDegenerateCells);
VTKM_TEST_ASSERT(noDegenerateCells.GetCellSet().GetNumberOfPoints() == farFastMergeNumPoints);
VTKM_TEST_ASSERT(noDegenerateCells.GetCoordinateSystem().GetNumberOfPoints() ==
farFastMergeNumPoints);
VTKM_TEST_ASSERT(noDegenerateCells.GetNumberOfPoints() == farFastMergeNumPoints);
VTKM_TEST_ASSERT(noDegenerateCells.GetField("pointvar").GetNumberOfValues() ==
farFastMergeNumPoints);
VTKM_TEST_ASSERT(noDegenerateCells.GetField("cellvar").GetNumberOfValues() ==

@ -62,8 +62,6 @@ void TestClipExplicit()
const vtkm::cont::DataSet outputData = clip.Execute(ds);
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,

@ -56,13 +56,11 @@ void TestClipStructured()
vtkm::cont::DataSet outputData = clip.Execute(ds);
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() == 8,
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 8,
"Wrong number of cells in the output dataset");
vtkm::cont::VariantArrayHandle temp = outputData.GetField("scalars").GetData();
@ -96,13 +94,9 @@ void TestClipStructuredInverted()
clip.SetFieldsToPass("scalars");
auto outputData = clip.Execute(ds);
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() == 4,
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 4,
"Wrong number of cells in the output dataset");
vtkm::cont::VariantArrayHandle temp = outputData.GetField("scalars").GetData();

@ -103,7 +103,7 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
static constexpr vtkm::IdComponent ndim = 3;
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
cellSet.SetPointDimensions(vdims);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
return dataSet;
}
@ -263,7 +263,7 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
CellSet cellSet("cells");
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
return dataSet;
}
@ -284,8 +284,6 @@ void TestContourUniformGrid()
auto result = mc.Execute(dataSet);
{
VTKM_TEST_ASSERT(result.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
//since normals is on we have one field
@ -358,10 +356,6 @@ void TestContourCustomPolicy()
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
"Wrong number of fields in the output dataset");

@ -94,7 +94,7 @@ vtkm::cont::DataSet MakeTestDataSet(const CoordinateType& cType)
}
cellSet.CompleteAddingCells(vtkm::Id(coordinates.size()));
dataSet.AddCellSet(cellSet);
dataSet.SetCellSet(cellSet);
return dataSet;
}

Some files were not shown because too many files have changed in this diff Show More