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

This commit is contained in:
Abhishek Yenpure 2019-08-08 14:21:29 -07:00
commit f5db0e85a0
219 changed files with 4217 additions and 4359 deletions

@ -115,11 +115,12 @@ if(VTKm_ENABLE_CUDA)
message(FATAL_ERROR "VTK-m CUDA support requires version 9.2+")
endif()
if (NOT TARGET vtkm_cuda OR NOT TARGET vtkm::cuda)
if (NOT TARGET vtkm::cuda)
add_library(vtkm_cuda INTERFACE)
add_library(vtkm::cuda ALIAS vtkm_cuda)
set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME vtkm::cuda)
install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME})
install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME})
# Reserve `INTERFACE_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
@ -248,11 +249,6 @@ if(VTKm_ENABLE_CUDA)
set_target_properties(vtkm_cuda PROPERTIES INTERFACE_CUDA_Architecture_Flags "${arch_flags}")
endif()
if (NOT TARGET vtkm::cuda)
add_library(vtkm::cuda ALIAS vtkm_cuda)
endif()
endif()
if(NOT TARGET Threads::Threads)

@ -130,4 +130,5 @@ function(vtkm_test_against_install dir)
set_tests_properties(${build_name} PROPERTIES LABELS ${test_label} )
set_tests_properties(${build_name} PROPERTIES FIXTURES_REQUIRED vtkm_installed)
set_tests_properties(${build_name} PROPERTIES TIMEOUT 600)
endfunction()

@ -62,6 +62,7 @@ VTK-m Requires:
+ Clang 3.3+
+ XCode 5.0+
+ MSVC 2015+
+ Intel 17.0.4+
+ [CMake](http://www.cmake.org/download/)
+ CMake 3.8+
+ CMake 3.9+ (for OpenMP support)
@ -98,7 +99,7 @@ Optional dependencies are:
VTK-m has been tested on the following configurations:c
+ On Linux
+ GCC 4.8.5, 5.4.0, 6.4.0, 7.3.0, Clang 5.0, 6.0, 7.0, Intel 17.0.4
+ GCC 4.8.5, 5.4.0, 6.4.0, 7.3.0, Clang 5.0, 6.0, 7.0, Intel 17.0.4, Intel 19.0.0
+ CMake 3.13.3, 3.14.1
+ CUDA 9.2.148, 10.0.130, 10.1.105
+ TBB 4.4 U2, 2017 U7
@ -120,13 +121,17 @@ to generate all the build rules for the project. The VTK-m source code is
available from the [VTK-m download page] or by directly cloning the [VTK-m
git repository].
```
$ git clone https://gitlab.kitware.com/vtk/vtk-m.git
The basic procedure for building VTK-m is to unpack the source, create a
build directory, run CMake in that build directory (pointing to the source)
and then build. Here are some example *nix commands for the process
(individual commands may vary).
```sh
$ tar xvzf ~/Downloads/vtk-m-v1.4.0.tar.gz
$ mkdir vtkm-build
$ cd vtkm-build
$ cmake-gui ../vtk-m
$ make -j<N>
$ make test
$ cmake-gui ../vtk-m-v1.4.0
$ cmake --build -j . # Runs make (or other build program)
```
A more detailed description of building VTK-m is available in the [VTK-m

@ -17,11 +17,9 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/ImplicitFunctionHandle.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/Invoker.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
@ -189,7 +187,7 @@ public:
}
};
class GenerateEdges : public vtkm::worklet::WorkletMapPointToCell
class GenerateEdges : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset, WholeArrayOut edgeIds);
@ -529,7 +527,7 @@ private:
Timer timer{ DeviceAdapter() };
timer.Start();
vtkm::worklet::Invoker invoke(DeviceAdapter{});
vtkm::cont::Invoker invoke(DeviceAdapter{});
invoke(Mag{}, this->InputHandle, tempHandle1);
invoke(Sin{}, tempHandle1, tempHandle2);
invoke(Square{}, tempHandle2, tempHandle1);
@ -567,7 +565,7 @@ private:
Timer timer{ DeviceAdapter() };
timer.Start();
vtkm::worklet::Invoker invoke(DeviceAdapter{});
vtkm::cont::Invoker invoke(DeviceAdapter{});
invoke(Mag{}, dinput, dtemp1);
invoke(Sin{}, dtemp1, dtemp2);
invoke(Square{}, dtemp2, dtemp1);
@ -595,7 +593,7 @@ private:
Timer timer{ DeviceAdapter() };
timer.Start();
vtkm::worklet::Invoker invoke(DeviceAdapter{});
vtkm::cont::Invoker invoke(DeviceAdapter{});
invoke(Mag{}, mInput, mTemp1);
invoke(Sin{}, mTemp1, mTemp2);
invoke(Square{}, mTemp2, mTemp1);
@ -632,7 +630,7 @@ private:
Timer timer{ DeviceAdapter() };
timer.Start();
vtkm::worklet::Invoker invoke(DeviceAdapter{});
vtkm::cont::Invoker invoke(DeviceAdapter{});
invoke(Mag{}, mInput, mTemp1);
invoke(Sin{}, mTemp1, mTemp2);
invoke(Square{}, mTemp2, mTemp1);

@ -655,14 +655,14 @@ class BenchmarkFilters
{ // Why does CastAndCall insist on making the cellset const?
using CellSetT = vtkm::cont::CellSetExplicit<T1, T2, T3, T4>;
CellSetT& mcellSet = const_cast<CellSetT&>(cellSet);
mcellSet.ResetConnectivity(vtkm::TopologyElementTagCell{},
vtkm::TopologyElementTagPoint{});
mcellSet.ResetConnectivity(vtkm::TopologyElementTagPoint{},
vtkm::TopologyElementTagCell{});
}
Timer timer{ DeviceAdapter() };
timer.Start();
cellSet.PrepareForInput(
DeviceAdapter(), vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{});
DeviceAdapter(), vtkm::TopologyElementTagPoint{}, vtkm::TopologyElementTagCell{});
this->Time = timer.GetElapsedTime();
}
};

@ -42,7 +42,7 @@ enum BenchmarkName
ALL = CELL_TO_POINT | POINT_TO_CELL | MC_CLASSIFY
};
class AveragePointToCell : public vtkm::worklet::WorkletMapPointToCell
class AveragePointToCell : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(FieldInPoint inPoints, CellSetIn cellset, FieldOutCell outCells);
@ -64,7 +64,7 @@ public:
}
};
class AverageCellToPoint : public vtkm::worklet::WorkletMapCellToPoint
class AverageCellToPoint : public vtkm::worklet::WorkletVisitPointsWithCells
{
public:
using ControlSignature = void(FieldInCell inCells, CellSetIn topology, FieldOut outPoints);
@ -91,7 +91,7 @@ public:
// -----------------------------------------------------------------------------
template <typename T>
class Classification : public vtkm::worklet::WorkletMapPointToCell
class Classification : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(FieldInPoint inNodes, CellSetIn cellset, FieldOutCell outCaseId);

@ -0,0 +1,15 @@
# Updating structured cell locators
VTK-m will mow allow locating containing cells for a point using `CellLocatorUniformGrid`
and `CellLocatorRectilinearGrid` for 2D grids.
Users are required to create the locator objects as they normally would.
However, the `FindCell` method in `vtkm::exec::CellLocator` still requires users
to pass a 3D point as an input.
Further, the structured grid locators no longer use the `vtkm::exec::WorldToParametricCoordinates`
method to return parametric coordinates, instead they use fast paths for locating
points in a cell of an axis-aligned grid.
Another change for the `CellLocatorRectilinearGrid` is that now it uses binary search
on individual component arrays to search for a point.

@ -0,0 +1,6 @@
# Invoker moved to vtkm::cont
Previously, `Invoker` was located in the `vtkm::worklet` namespace to convey
it was a replacement for using `vtkm::worklet::Dispatcher*`. In actuality
it should be in `vtkm::cont` as it is the proper way to launch worklets
for execution, and that shouldn't exist inside the `worklet` namespace.

@ -0,0 +1,18 @@
# `SurfaceNormals` filter can now orient normals.
The `OrientNormals` worklet has been added to the `SurfaceNormals` filter, and
is enabled by turning on the `AutoOrientNormals` option. This feature ensures
that all normals generated by the filter will point out of the dataset (or
inward if the `FlipNormals` option is true). In addition,
`SurfaceNormals` now has a `Consistency` option that forces all triangle
windings to be consistent with the cell normal direction (the cell points are
specified in counter-clockwise order around the normal).
This functionality is provided by the following new worklets:
* OrientNormals
* RunOrientCellNormals
* RunOrientPointNormals
* RunOrientPointAndCellNormals
* RunFlipNormals
* TriangleWinding

@ -0,0 +1,20 @@
# Updating particle status for advection
There are now special statuses for Particle, Integrator, and Evaluator.
The particle advection modules only supported statuses for particles and made it
difficult to handle advanced integtator statuses.
Now each of the three important modules return their own statuses
Particles have `vtkm::worklet::particleadvection::ParticleStatus`,
Integrators have `vtkm::worklet::particleadvection::IntegratorStatus`, and
Evaluators have `vtkm::worklet::particleadvection::EvaluatorStatus`.
Further, names of the statuses in `vtkm::worklet::particleadvection::ParticleStatus`
have changed
`ParticleStatus::STATUS_OK` is now `ParticleStatus::SUCCESS`, and there is another
status `ParticleStatus::TOOK_ANY_STEPS` which is active if the particle has taken
at least one step with the current data.
There are few more changes that allow particle advection in 2D structured grids.

@ -0,0 +1,35 @@
# Refactor topology mappings to clarify meaning.
The `From` and `To` nomenclature for topology mapping has been confusing for
both users and developers, especially at lower levels where the intention of
mapping attributes from one element to another is easily conflated with the
concept of mapping indices (which maps in the exact opposite direction).
These identifiers have been renamed to `VisitTopology` and `IncidentTopology`
to clarify the direction of the mapping. The order in which these template
parameters are specified for `WorkletMapTopology` have also been reversed,
since eventually there may be more than one `IncidentTopology`, and having
`IncidentTopology` at the end will allow us to replace it with a variadic
template parameter pack in the future.
Other implementation details supporting these worklets, include `Fetch` tags,
`Connectivity` classes, and methods on the various `CellSet` classes (such as
`PrepareForInput` have also reversed their template arguments. These will need
to be cautiously updated.
The convenience implementations of `WorkletMapTopology` have been renamed for
clarity as follows:
```
WorkletMapPointToCell --> WorkletVisitCellsWithPoints
WorkletMapCellToPoint --> WorkletVisitPointsWithCells
```
The `ControlSignature` tags have been renamed as follows:
```
FieldInTo --> FieldInVisit
FieldInFrom --> FieldInMap
FromCount --> IncidentElementCount
FromIndices --> IncidentElementIndices
```

@ -0,0 +1,7 @@
# Simplify examples
Lots of the examples were out of date or way too verbose. The examples have
been simplified and brought up to modern VTK-m conventions.
We have also added a "hello worklet" example to be a minimal example of
creating a working algorithm (wrapped in a filter) in VTK-m (and used).

@ -0,0 +1,31 @@
# Provide a simplified way to state allowed value types for VTK-m filters
Previously VTK-m filters used a specialization of `vtkm::filter::FilterTraits<>` to control
the acceptable input value types. For example if the `WarpVector` filter want to only allow
`vtkm::Vec3f_32` and `vtkm::Vec3f_64` it would use:
```cpp
namespace vtkm { namespace filter {
template <>
class FilterTraits<WarpVector>
{
public:
// WarpVector can only applies to Float and Double Vec3 arrays
using InputFieldTypeList = vtkm::TypeListTagFieldVec3;
};
}}
```
This increase the complexity of writing filters. To make this easier VTK-m now looks for
a `SupportedTypes` define on the filter when a `vtkm::filter::FilterTraits` specialization
doesn't exist. This allows filters to succinctly specify supported types, such as seen below
for the `WarpVector` filter.
```cpp
class WarpVector : public vtkm::filter::FilterField<WarpVector>
{
public:
using SupportedTypes = vtkm::TypeListTagFieldVec3;
...
};
```

@ -19,9 +19,8 @@ if(VTKm_ENABLE_EXAMPLES)
add_subdirectory(cosmotools)
add_subdirectory(demo)
add_subdirectory(game_of_life)
add_subdirectory(hello_world)
add_subdirectory(hello_worklet)
add_subdirectory(histogram)
add_subdirectory(isosurface)
add_subdirectory(lagrangian)
add_subdirectory(mesh_quality)
add_subdirectory(multi_backend)
@ -29,8 +28,6 @@ if(VTKm_ENABLE_EXAMPLES)
add_subdirectory(particle_advection)
add_subdirectory(polyline_archimedean_helix)
add_subdirectory(redistribute_points)
add_subdirectory(rendering)
add_subdirectory(streamline)
add_subdirectory(temporal_advection)
add_subdirectory(tetrahedra)
endif()
@ -38,6 +35,6 @@ endif()
if (VTKm_ENABLE_TESTING)
# These need to be fast to build as they will
# be built each time we run the test
vtkm_test_against_install(rendering)
vtkm_test_against_install(demo)
vtkm_test_against_install(histogram)
endif()

@ -7,137 +7,26 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
#include <vtkm/worklet/Clip.h>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
using FloatVec3 = vtkm::Vec3f_32;
namespace
{
struct FieldMapper
{
vtkm::cont::VariantArrayHandle& Output;
vtkm::worklet::Clip& Worklet;
bool IsCellField;
FieldMapper(vtkm::cont::VariantArrayHandle& output,
vtkm::worklet::Clip& worklet,
bool isCellField)
: Output(output)
, Worklet(worklet)
, IsCellField(isCellField)
{
}
template <typename ArrayType>
void operator()(const ArrayType& input) const
{
if (this->IsCellField)
{
this->Output = this->Worklet.ProcessCellField(input);
}
else
{
this->Output = this->Worklet.ProcessPointField(input);
}
}
};
} // end anon namespace
#include <vtkm/filter/ClipWithField.h>
int main(int argc, char* argv[])
{
auto opts = vtkm::cont::InitializeOptions::DefaultAnyDevice;
vtkm::cont::InitializeResult config = vtkm::cont::Initialize(argc, argv, opts);
if (argc < 4)
{
std::cout << "Usage: " << std::endl
<< "$ " << argv[0]
<< " [-d device] <input_vtk_file> [fieldName] <isoval> <output_vtk_file>"
<< std::endl;
return 1;
}
vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict);
vtkm::io::reader::VTKDataSetReader reader(argv[1]);
vtkm::cont::DataSet input = reader.ReadDataSet();
vtkm::cont::DataSet input = vtkm::cont::testing::MakeTestDataSet().Make3DExplicitDataSetCowNose();
vtkm::cont::Field scalarField = (argc == 5) ? input.GetField(argv[2]) : input.GetField(0);
vtkm::filter::ClipWithField clipFilter;
clipFilter.SetActiveField("pointvar");
clipFilter.SetClipValue(20.0);
vtkm::cont::DataSet output = clipFilter.Execute(input);
vtkm::Float32 clipValue = std::stof(argv[argc - 2]);
vtkm::worklet::Clip clip;
vtkm::cont::Timer total;
total.Start();
vtkm::cont::Timer timer;
timer.Start();
bool invertClip = false;
vtkm::cont::CellSetExplicit<> outputCellSet =
clip.Run(input.GetCellSet(0),
scalarField.GetData().ResetTypes(vtkm::TypeListTagScalarAll()),
clipValue,
invertClip);
vtkm::Float64 clipTime = timer.GetElapsedTime();
vtkm::cont::DataSet output;
output.AddCellSet(outputCellSet);
auto inCoords = input.GetCoordinateSystem(0).GetData();
timer.Start();
auto outCoords = clip.ProcessCellField(inCoords);
vtkm::Float64 processCoordinatesTime = timer.GetElapsedTime();
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", outCoords));
timer.Start();
for (vtkm::Id i = 0; i < input.GetNumberOfFields(); ++i)
{
vtkm::cont::Field inField = input.GetField(i);
bool isCellField;
switch (inField.GetAssociation())
{
case vtkm::cont::Field::Association::POINTS:
isCellField = false;
break;
case vtkm::cont::Field::Association::CELL_SET:
isCellField = true;
break;
default:
continue;
}
vtkm::cont::VariantArrayHandle outField;
FieldMapper fieldMapper(outField, clip, isCellField);
inField.GetData().CastAndCall(fieldMapper);
output.AddField(vtkm::cont::Field(inField.GetName(), inField.GetAssociation(), outField));
}
vtkm::Float64 processScalarsTime = timer.GetElapsedTime();
vtkm::Float64 totalTime = total.GetElapsedTime();
std::cout << "Timings: " << std::endl
<< "clip: " << clipTime << std::endl
<< "process coordinates: " << processCoordinatesTime << std::endl
<< "process scalars: " << processScalarsTime << std::endl
<< "Total: " << totalTime << std::endl;
vtkm::io::writer::VTKDataSetWriter writer(argv[argc - 1]);
vtkm::io::writer::VTKDataSetWriter writer("out_data.vtk");
writer.WriteDataSet(output);
return 0;

@ -8,10 +8,8 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/rendering/Actor.h>
#include <vtkm/rendering/CanvasRayTracer.h>
@ -19,57 +17,21 @@
#include <vtkm/rendering/Scene.h>
#include <vtkm/rendering/View3D.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/filter/MarchingCubes.h>
#include <iostream>
void makeScene(const vtkm::cont::DataSet& inputData,
const vtkm::cont::ColorTable& colorTable,
const std::string& fieldName,
vtkm::rendering::Scene& scene)
{
scene.AddActor(vtkm::rendering::Actor(inputData.GetCellSet(),
inputData.GetCoordinateSystem(),
inputData.GetField(fieldName),
colorTable));
}
// This example reads an input vtk file specified on the command-line (or generates a default
// input data set if none is provided), uses VTK-m's rendering engine to render it to an
// output file using OS Mesa, instantiates an isosurface filter using VTK-m's filter
// mechanism, computes an isosurface on the input data set, packages the output of the filter
// in a new data set, and renders this output data set in a separate iamge file, again
// using VTK-m's rendering engine with OS Mesa.
// This example creates a simple data set and uses VTK-m's rendering engine to render an image and
// write that image to a file. It then computes an isosurface on the input data set and renders
// this output data set in a separate image file
int main(int argc, char* argv[])
{
auto opts = vtkm::cont::InitializeOptions::DefaultAnyDevice;
vtkm::cont::InitializeResult config = vtkm::cont::Initialize(argc, argv, opts);
vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict);
// Input variable declarations
vtkm::cont::DataSet inputData;
vtkm::Float32 isovalue;
std::string fieldName;
// Get input data from specified file, or generate test data set
if (argc < 3)
{
vtkm::cont::testing::MakeTestDataSet maker;
inputData = maker.Make3DUniformDataSet0();
isovalue = 100.0f;
fieldName = "pointvar";
}
else
{
std::cout << "using: " << argv[1] << " as MarchingCubes input file" << std::endl;
vtkm::io::reader::VTKDataSetReader reader(argv[1]);
inputData = reader.ReadDataSet();
isovalue = static_cast<vtkm::Float32>(atof(argv[2]));
fieldName = "pointvar";
}
vtkm::cont::DataSet inputData = maker.Make3DUniformDataSet0();
vtkm::Float32 isovalue = 100.0f;
std::string fieldName = "pointvar";
using Mapper = vtkm::rendering::MapperRayTracer;
using Canvas = vtkm::rendering::CanvasRayTracer;
@ -77,7 +39,7 @@ int main(int argc, char* argv[])
// Set up a camera for rendering the input data
const vtkm::cont::CoordinateSystem coords = inputData.GetCoordinateSystem();
Mapper mapper;
vtkm::rendering::Camera camera = vtkm::rendering::Camera();
vtkm::rendering::Camera camera;
//Set3DView
vtkm::Bounds coordsBounds = coords.GetBounds();
@ -85,9 +47,9 @@ int main(int argc, char* argv[])
camera.ResetToBounds(coordsBounds);
vtkm::Vec3f_32 totalExtent;
totalExtent[0] = vtkm::Float32(coordsBounds.X.Max - coordsBounds.X.Min);
totalExtent[1] = vtkm::Float32(coordsBounds.Y.Max - coordsBounds.Y.Min);
totalExtent[2] = vtkm::Float32(coordsBounds.Z.Max - coordsBounds.Z.Min);
totalExtent[0] = vtkm::Float32(coordsBounds.X.Length());
totalExtent[1] = vtkm::Float32(coordsBounds.Y.Length());
totalExtent[2] = vtkm::Float32(coordsBounds.Z.Length());
vtkm::Float32 mag = vtkm::Magnitude(totalExtent);
vtkm::Normalize(totalExtent);
camera.SetLookAt(totalExtent * (mag * .5f));
@ -102,7 +64,11 @@ int main(int argc, char* argv[])
vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f);
Canvas canvas(512, 512);
makeScene(inputData, colorTable, fieldName, scene);
vtkm::rendering::Actor actor(inputData.GetCellSet(),
inputData.GetCoordinateSystem(),
inputData.GetField(fieldName),
colorTable);
scene.AddActor(actor);
// Create a view and use it to render the input data using OS Mesa
vtkm::rendering::View3D view(scene, mapper, canvas, camera, bg);
view.Initialize();
@ -119,7 +85,15 @@ int main(int argc, char* argv[])
// Render a separate image with the output isosurface
std::cout << "about to render the results of the MarchingCubes filter" << std::endl;
vtkm::rendering::Scene scene2;
makeScene(outputData, colorTable, fieldName, scene2);
vtkm::rendering::Actor actor2(outputData.GetCellSet(),
outputData.GetCoordinateSystem(),
outputData.GetField(fieldName),
colorTable);
// By default, the actor will automatically scale the scalar range of the color table to match
// that of the data. However, we are coloring by the scalar that we just extracted a contour
// from, so we want the scalar range to match that of the previous image.
actor2.SetScalarRange(actor.GetScalarRange());
scene2.AddActor(actor2);
vtkm::rendering::View3D view2(scene2, mapper, canvas, camera, bg);
view2.Initialize();

@ -7,15 +7,15 @@
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##============================================================================
cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(UnifiedMemory CXX)
cmake_minimum_required(VERSION 3.9...3.14 FATAL_ERROR)
project(HelloWorklet CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
if(TARGET vtkm::cuda)
add_executable(UnifiedMemory_CUDA UnifiedMemory.cu)
target_link_libraries(UnifiedMemory_CUDA PRIVATE vtkm_filter)
vtkm_add_target_information(UnifiedMemory_CUDA MODIFY_CUDA_FLAGS)
endif()
add_executable(HelloWorklet HelloWorklet.cxx)
target_link_libraries(HelloWorklet PRIVATE vtkm_filter)
vtkm_add_target_information(HelloWorklet
MODIFY_CUDA_FLAGS
DEVICE_SOURCES HelloWorklet.cxx)

@ -0,0 +1,103 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/filter/FilterField.h>
#include <vtkm/filter/internal/CreateResult.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/VectorAnalysis.h>
namespace vtkm
{
namespace worklet
{
struct HelloWorklet : public vtkm::worklet::WorkletMapField
{
using ControlSignature = void(FieldIn inVector, FieldOut outMagnitude);
using ExecutionSignature = void(_1, _2);
VTKM_EXEC void operator()(const vtkm::Vec3f& inVector, vtkm::FloatDefault& outMagnitude) const
{
outMagnitude = vtkm::Magnitude(inVector);
}
};
}
} // namespace vtkm::worklet
namespace vtkm
{
namespace filter
{
class HelloField : public vtkm::filter::FilterField<HelloField>
{
public:
// Specify that this filter operates on 3-vectors
using SupportedTypes = vtkm::TypeListTagFieldVec3;
template <typename FieldType, typename Policy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inDataSet,
const FieldType& inField,
const vtkm::filter::FieldMetadata& fieldMetadata,
vtkm::filter::PolicyBase<Policy>)
{
VTKM_IS_ARRAY_HANDLE(FieldType);
//construct our output
vtkm::cont::ArrayHandle<vtkm::FloatDefault> outField;
//construct our invoker to launch worklets
vtkm::cont::Invoker invoker;
vtkm::worklet::HelloWorklet mag;
invoker(mag, inField, outField); //launch mag worklets
//construct output field information
if (this->GetOutputFieldName().empty())
{
this->SetOutputFieldName(fieldMetadata.GetName() + "_magnitude");
}
//return the result, which is the input data with the computed field added to it
return vtkm::filter::internal::CreateResult(inDataSet,
outField,
this->GetOutputFieldName(),
fieldMetadata.GetAssociation(),
fieldMetadata.GetCellSetName());
}
};
}
} // vtkm::filter
int main(int argc, char** argv)
{
vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict);
vtkm::cont::testing::MakeTestDataSet testDataMaker;
vtkm::cont::DataSet inputData = testDataMaker.Make3DExplicitDataSetCowNose();
vtkm::filter::HelloField helloField;
helloField.SetActiveField("point_vectors");
vtkm::cont::DataSet outputData = helloField.Execute(inputData);
vtkm::io::writer::VTKDataSetWriter writer("out_data.vtk");
writer.WriteDataSet(outputData);
return 0;
}

@ -1,29 +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.
##============================================================================
cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(HelloWorld CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
set(gl_libs OpenGL::GL GLEW::GLEW GLUT::GLUT)
add_executable(HelloWorld HelloWorld.cxx LoadShaders.h)
target_link_libraries(HelloWorld PRIVATE vtkm_filter ${gl_libs})
vtkm_add_target_information(HelloWorld
MODIFY_CUDA_FLAGS
DEVICE_SOURCES HelloWorld.cxx)
endif()

@ -1,220 +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.
//============================================================================
// Must be included before any other GL includes:
#include <GL/glew.h>
#include <iostream>
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/interop/TransferToOpenGL.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
//OpenGL Graphics includes
//glew needs to go before glut
//that is why this is after the TransferToOpenGL include
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "LoadShaders.h"
template <typename T>
struct HelloVTKMInterop
{
vtkm::Vec2i_32 Dims;
GLuint ProgramId;
GLuint VAOId;
vtkm::interop::BufferState VBOState;
vtkm::interop::BufferState ColorState;
vtkm::cont::Timer Timer;
std::vector<vtkm::Vec<T, 3>> InputData;
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> InHandle;
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> OutCoords;
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> OutColors;
HelloVTKMInterop(vtkm::Int32 width, vtkm::Int32 height)
: Dims(256, 256)
, ProgramId()
, VAOId()
, VBOState()
, ColorState()
, Timer()
, InputData()
, InHandle()
, OutCoords()
, OutColors()
{
Timer.Start();
int dim = 256;
this->InputData.reserve(static_cast<std::size_t>(dim * dim));
for (int i = 0; i < dim; ++i)
{
for (int j = 0; j < dim; ++j)
{
vtkm::Vec<T, 3> t(2.f * (static_cast<T>(i) / static_cast<T>(dim)) - 1.f,
0.f,
2.f * (static_cast<T>(j) / static_cast<T>(dim)) - 1.f);
this->InputData.push_back(t);
}
}
this->Dims = vtkm::Vec2i_32(dim, dim);
this->InHandle = vtkm::cont::make_ArrayHandle(this->InputData);
glGenVertexArrays(1, &this->VAOId);
glBindVertexArray(this->VAOId);
this->ProgramId = LoadShaders();
glUseProgram(this->ProgramId);
glClearColor(.08f, .08f, .08f, 0.f);
glViewport(0, 0, width, height);
}
void render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
vtkm::Int32 arraySize = this->Dims[0] * this->Dims[1];
//precomputed based on 1027x768 render window size
vtkm::Float32 mvp[16] = { -1.79259f, 0.f, 0.f, 0.f, 0.f, 1.26755f,
-0.721392f, -0.707107f, 0.f, 1.26755f, 0.721392f, 0.707107f,
0.f, 0.f, 1.24076f, 1.41421f };
GLint unifLoc = glGetUniformLocation(this->ProgramId, "MVP");
glUniformMatrix4fv(unifLoc, 1, GL_FALSE, mvp);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, *this->VBOState.GetHandle());
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, *this->ColorState.GetHandle());
glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
glDrawArrays(GL_POINTS, 0, arraySize);
glDisableClientState(GL_COLOR_ARRAY);
glDisableVertexAttribArray(0);
}
struct GenerateSurfaceWorklet : public vtkm::worklet::WorkletMapField
{
vtkm::Float32 t;
GenerateSurfaceWorklet(vtkm::Float32 st)
: t(st)
{
}
using ControlSignature = void(FieldIn, FieldOut, FieldOut);
using ExecutionSignature = void(_1, _2, _3);
VTKM_EXEC
void operator()(const vtkm::Vec<T, 3>& input,
vtkm::Vec<T, 3>& output,
vtkm::Vec4ui_8& color) const
{
output[0] = input[0];
output[1] = 0.25f * vtkm::Sin(input[0] * 10.f + t) * vtkm::Cos(input[2] * 10.f + t);
output[2] = input[2];
color[0] = 0;
color[1] = static_cast<vtkm::UInt8>(160 + 96 * vtkm::Sin(input[0] * 10.f + t));
color[2] = static_cast<vtkm::UInt8>(160 + 96 * vtkm::Cos(input[2] * 5.f + t));
color[3] = 255;
}
};
void renderFrame()
{
using DispatcherType = vtkm::worklet::DispatcherMapField<GenerateSurfaceWorklet>;
vtkm::Float32 t = static_cast<vtkm::Float32>(this->Timer.GetElapsedTime());
GenerateSurfaceWorklet worklet(t);
DispatcherType(worklet).Invoke(this->InHandle, this->OutCoords, this->OutColors);
vtkm::interop::TransferToOpenGL(this->OutCoords, this->VBOState);
vtkm::interop::TransferToOpenGL(this->OutColors, this->ColorState);
this->render();
if (t > 10)
{
//after 10seconds quit the demo
exit(0);
}
}
};
//global static so that glut callback can access it
HelloVTKMInterop<vtkm::Float32>* helloWorld = nullptr;
// Render the output using simple OpenGL
void run()
{
helloWorld->renderFrame();
glutSwapBuffers();
}
void idle()
{
glutPostRedisplay();
}
int main(int argc, char** argv)
{
auto opts =
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
vtkm::cont::Initialize(argc, argv, opts);
std::cout << "Running Hello World example: " << std::endl;
glewExperimental = GL_TRUE;
glutInit(&argc, argv);
const vtkm::UInt32 width = 1024;
const vtkm::UInt32 height = 768;
glutInitWindowSize(width, height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("VTK-m Hello World OpenGL Interop");
GLenum err = glewInit();
if (GLEW_OK != err)
{
std::cout << "glewInit failed\n";
}
HelloVTKMInterop<vtkm::Float32> hw(width, height);
helloWorld = &hw;
glutDisplayFunc(run);
glutIdleFunc(idle);
glutMainLoop();
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -1,119 +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 LOAD_SHADERS
#define LOAD_SHADERS
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
namespace shaders
{
static std::string const& make_fragment_shader_code()
{
static std::string const data = "#version 120\n"
"void main(void)"
"{"
" gl_FragColor = gl_Color;"
"}";
return data;
}
static std::string const& make_vertex_shader_code()
{
static std::string const data = "#version 120\n"
"attribute vec3 posAttr;"
"uniform mat4 MVP;"
"void main()"
"{"
" vec4 pos = vec4( posAttr, 1.0 );"
" gl_FrontColor = gl_Color;"
" gl_Position = MVP * pos;"
"}";
return data;
}
}
inline GLuint LoadShaders()
{
// Create the shaders
GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
// Get the Vertex Shader code
std::string VertexShaderCode = shaders::make_vertex_shader_code();
// Get the Fragment Shader code
std::string FragmentShaderCode = shaders::make_fragment_shader_code();
GLint Result = GL_FALSE;
int InfoLogLength;
// Compile Vertex Shader
std::cout << "Compiling vertex shader" << std::endl;
char const* VertexSourcePointer = VertexShaderCode.c_str();
glShaderSource(VertexShaderID, 1, &VertexSourcePointer, nullptr);
glCompileShader(VertexShaderID);
// Check Vertex Shader
glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result);
glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> VertexShaderErrorMessage(static_cast<std::size_t>(InfoLogLength));
if (VertexShaderErrorMessage.size() > 0)
{
glGetShaderInfoLog(VertexShaderID, InfoLogLength, nullptr, &VertexShaderErrorMessage[0]);
std::cout << &VertexShaderErrorMessage[0] << std::endl;
}
// Compile Fragment Shader
std::cout << "Compiling fragment shader" << std::endl;
char const* FragmentSourcePointer = FragmentShaderCode.c_str();
glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer, nullptr);
glCompileShader(FragmentShaderID);
// Check Fragment Shader
glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result);
glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> FragmentShaderErrorMessage(static_cast<std::size_t>(InfoLogLength));
if (FragmentShaderErrorMessage.size() > 0)
{
glGetShaderInfoLog(FragmentShaderID, InfoLogLength, nullptr, &FragmentShaderErrorMessage[0]);
std::cout << &FragmentShaderErrorMessage[0] << std::endl;
}
// Link the program
std::cout << "Linking program" << std::endl;
GLuint ProgramID = glCreateProgram();
glAttachShader(ProgramID, VertexShaderID);
glAttachShader(ProgramID, FragmentShaderID);
glLinkProgram(ProgramID);
// Check the program
glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> ProgramErrorMessage(static_cast<std::size_t>(InfoLogLength));
if (ProgramErrorMessage.size() > 0)
{
glGetProgramInfoLog(ProgramID, InfoLogLength, nullptr, &ProgramErrorMessage[0]);
std::cout << &ProgramErrorMessage[0] << std::endl;
}
glDeleteShader(VertexShaderID);
glDeleteShader(FragmentShaderID);
return ProgramID;
}
#endif

@ -11,7 +11,6 @@
#define vtk_m_examples_histogram_HistogramMPI_h
#include <vtkm/filter/FilterField.h>
#include <vtkm/filter/FilterTraits.h>
namespace example
{
@ -23,6 +22,11 @@ namespace example
class HistogramMPI : public vtkm::filter::FilterField<HistogramMPI>
{
public:
//currently the HistogramMPI filter only works on scalar data.
//this mainly has to do with getting the ranges for each bin
//would require returning a more complex value type
using SupportedTypes = vtkm::TypeListTagScalarAll;
//Construct a HistogramMPI with a default of 10 bins
VTKM_CONT
HistogramMPI();
@ -82,23 +86,6 @@ private:
};
} // namespace example
namespace vtkm
{
namespace filter
{
template <>
class FilterTraits<example::HistogramMPI>
{ //currently the HistogramMPI filter only works on scalar data.
//this mainly has to do with getting the ranges for each bin
//would require returning a more complex value type
public:
using InputFieldTypeList = vtkm::TypeListTagScalarAll;
};
}
} // namespace vtkm::filter
#include "HistogramMPI.hxx"
#endif // vtk_m_filter_Histogram_h

@ -1,28 +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.
##============================================================================
cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(IsoSurface CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
set(gl_libs OpenGL::GL OpenGL::GLU GLEW::GLEW GLUT::GLUT)
add_executable(IsosurfaceUniformGrid IsosurfaceUniformGrid.cxx quaternion.h)
target_link_libraries(IsosurfaceUniformGrid PRIVATE vtkm_filter ${gl_libs})
vtkm_add_target_information(IsosurfaceUniformGrid
MODIFY_CUDA_FLAGS
DEVICE_SOURCES IsosurfaceUniformGrid.cxx)
endif()

@ -1,284 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/filter/MarchingCubes.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "quaternion.h"
#include <vector>
static vtkm::Id3 dims(256, 256, 256);
static vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray, normalsArray;
static vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
static Quaternion qrot;
static int lastx, lasty;
static int mouse_state = 1;
namespace
{
// Define the tangle field for the input data
class TangleField : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn vertexId, FieldOut v);
using ExecutionSignature = void(_1, _2);
using InputDomain = _1;
const vtkm::Id xdim, ydim, zdim;
const vtkm::Float32 xmin, ymin, zmin, xmax, ymax, zmax;
const vtkm::Id cellsPerLayer;
VTKM_CONT
TangleField(const vtkm::Id3 dims, const vtkm::Float32 mins[3], const vtkm::Float32 maxs[3])
: xdim(dims[0])
, ydim(dims[1])
, zdim(dims[2])
, xmin(mins[0])
, ymin(mins[1])
, zmin(mins[2])
, xmax(maxs[0])
, ymax(maxs[1])
, zmax(maxs[2])
, cellsPerLayer((xdim) * (ydim)){};
VTKM_EXEC
void operator()(const vtkm::Id& vertexId, vtkm::Float32& v) const
{
const vtkm::Id x = vertexId % (xdim);
const vtkm::Id y = (vertexId / (xdim)) % (ydim);
const vtkm::Id z = vertexId / cellsPerLayer;
const vtkm::Float32 fx = static_cast<vtkm::Float32>(x) / static_cast<vtkm::Float32>(xdim - 1);
const vtkm::Float32 fy = static_cast<vtkm::Float32>(y) / static_cast<vtkm::Float32>(xdim - 1);
const vtkm::Float32 fz = static_cast<vtkm::Float32>(z) / static_cast<vtkm::Float32>(xdim - 1);
const vtkm::Float32 xx = 3.0f * (xmin + (xmax - xmin) * (fx));
const vtkm::Float32 yy = 3.0f * (ymin + (ymax - ymin) * (fy));
const vtkm::Float32 zz = 3.0f * (zmin + (zmax - zmin) * (fz));
v = (xx * xx * xx * xx - 5.0f * xx * xx + yy * yy * yy * yy - 5.0f * yy * yy +
zz * zz * zz * zz - 5.0f * zz * zz + 11.8f) *
0.2f +
0.5f;
}
};
// Construct an input data set using the tangle field worklet
vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
{
vtkm::cont::DataSet dataSet;
const vtkm::Id3 vdims(dims[0] + 1, dims[1] + 1, dims[2] + 1);
vtkm::Float32 mins[3] = { -1.0f, -1.0f, -1.0f };
vtkm::Float32 maxs[3] = { 1.0f, 1.0f, 1.0f };
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
vtkm::cont::ArrayHandleCounting<vtkm::Id> vertexCountImplicitArray(
0, 1, vdims[0] * vdims[1] * vdims[2]);
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(
TangleField(vdims, mins, maxs));
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, fieldArray);
vtkm::Vec3f origin(0.0f, 0.0f, 0.0f);
vtkm::Vec3f spacing(1.0f / static_cast<vtkm::FloatDefault>(dims[0]),
1.0f / static_cast<vtkm::FloatDefault>(dims[2]),
1.0f / static_cast<vtkm::FloatDefault>(dims[1]));
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
dataSet.AddField(
vtkm::cont::Field("nodevar", vtkm::cont::Field::Association::POINTS, fieldArray));
static const vtkm::IdComponent ndim = 3;
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
cellSet.SetPointDimensions(vdims);
dataSet.AddCellSet(cellSet);
return dataSet;
}
}
// Initialize the OpenGL state
void initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
vtkm::Float32 white[] = { 0.8f, 0.8f, 0.8f, 1.0f };
vtkm::Float32 black[] = { 0.0f, 0.0f, 0.0f, 1.0f };
vtkm::Float32 lightPos[] = { 10.0f, 10.0f, 10.5f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, white);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
glLightfv(GL_LIGHT0, GL_SPECULAR, black);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
// Render the output using simple OpenGL
void displayCall()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.0f, 1.0f, 20.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glPushMatrix();
float rotationMatrix[16];
qrot.getRotMat(rotationMatrix);
glMultMatrixf(rotationMatrix);
glTranslatef(-0.5f, -0.5f, -0.5f);
glColor3f(0.1f, 0.1f, 0.6f);
glBegin(GL_TRIANGLES);
for (vtkm::IdComponent i = 0; i < verticesArray.GetNumberOfValues(); i++)
{
vtkm::Vec3f_32 curNormal = normalsArray.GetPortalConstControl().Get(i);
vtkm::Vec3f_32 curVertex = verticesArray.GetPortalConstControl().Get(i);
glNormal3f(curNormal[0], curNormal[1], curNormal[2]);
glVertex3f(curVertex[0], curVertex[1], curVertex[2]);
}
glEnd();
glPopMatrix();
glutSwapBuffers();
}
// Allow rotations of the view
void mouseMove(int x, int y)
{
vtkm::Float32 dx = static_cast<vtkm::Float32>(x - lastx);
vtkm::Float32 dy = static_cast<vtkm::Float32>(y - lasty);
if (mouse_state == 0)
{
Quaternion newRotX;
newRotX.setEulerAngles(-0.2f * dx * vtkm::Pi_180f(), 0.0f, 0.0f);
qrot.mul(newRotX);
Quaternion newRotY;
newRotY.setEulerAngles(0.0f, 0.0f, -0.2f * dy * vtkm::Pi_180f());
qrot.mul(newRotY);
}
lastx = x;
lasty = y;
glutPostRedisplay();
}
// Respond to mouse button
void mouseCall(int button, int state, int x, int y)
{
if (button == 0)
mouse_state = state;
if ((button == 0) && (state == 0))
{
lastx = x;
lasty = y;
}
}
// Compute and render an isosurface for a uniform grid example
int main(int argc, char* argv[])
{
//parse out all vtk-m related command line options
auto opts =
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
vtkm::cont::Initialize(argc, argv, opts);
vtkm::cont::DataSet dataSet = MakeIsosurfaceTestDataSet(dims);
vtkm::filter::MarchingCubes filter;
filter.SetGenerateNormals(true);
filter.SetMergeDuplicatePoints(false);
filter.SetIsoValue(0, 0.1);
filter.SetActiveField("nodevar");
filter.SetFieldsToPass({ "nodevar" });
vtkm::cont::DataSet outputData = filter.Execute(dataSet);
//need to extract vertices, normals, and scalars
using VertType = vtkm::cont::ArrayHandle<vtkm::Vec3f_32>;
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
verticesArray = coords.GetData().Cast<VertType>();
normalsArray = outputData.GetField("normals").GetData().Cast<VertType>();
scalarsArray =
outputData.GetField("nodevar").GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32>>();
std::cout << "Number of output vertices: " << verticesArray.GetNumberOfValues() << std::endl;
std::cout << "vertices: ";
vtkm::cont::printSummary_ArrayHandle(verticesArray, std::cout);
std::cout << std::endl;
std::cout << "normals: ";
vtkm::cont::printSummary_ArrayHandle(normalsArray, std::cout);
std::cout << std::endl;
std::cout << "scalars: ";
vtkm::cont::printSummary_ArrayHandle(scalarsArray, std::cout);
std::cout << std::endl;
lastx = lasty = 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(1000, 1000);
glutCreateWindow("VTK-m Isosurface");
initializeGL();
glutDisplayFunc(displayCall);
glutMotionFunc(mouseMove);
glutMouseFunc(mouseCall);
glutMainLoop();
verticesArray.ReleaseResources();
normalsArray.ReleaseResources();
scalarsArray.ReleaseResources();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -1,107 +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.
//============================================================================
/*
* quaternion.h
*
* Created on: Oct 10, 2014
* Author: csewell
*/
#ifndef QUATERNION_H_
#define QUATERNION_H_
#include <math.h>
#include <stdlib.h>
class Quaternion
{
public:
Quaternion()
{
x = y = z = 0.0;
w = 1.0;
}
Quaternion(double ax, double ay, double az, double aw)
: x(ax)
, y(ay)
, z(az)
, w(aw){};
void set(double ax, double ay, double az, double aw)
{
x = ax;
y = ay;
z = az;
w = aw;
}
void normalize()
{
float norm = static_cast<float>(sqrt(x * x + y * y + z * z + w * w));
if (norm > 0.00001)
{
x /= norm;
y /= norm;
z /= norm;
w /= norm;
}
}
void mul(Quaternion q)
{
double tx, ty, tz, tw;
tx = w * q.x + x * q.w + y * q.z - z * q.y;
ty = w * q.y + y * q.w + z * q.x - x * q.z;
tz = w * q.z + z * q.w + x * q.y - y * q.x;
tw = w * q.w - x * q.x - y * q.y - z * q.z;
x = tx;
y = ty;
z = tz;
w = tw;
}
void setEulerAngles(float pitch, float yaw, float roll)
{
w = cos(pitch / 2.0) * cos(yaw / 2.0) * cos(roll / 2.0) -
sin(pitch / 2.0) * sin(yaw / 2.0) * sin(roll / 2.0);
x = sin(pitch / 2.0) * sin(yaw / 2.0) * cos(roll / 2.0) +
cos(pitch / 2.0) * cos(yaw / 2.0) * sin(roll / 2.0);
y = sin(pitch / 2.0) * cos(yaw / 2.0) * cos(roll / 2.0) +
cos(pitch / 2.0) * sin(yaw / 2.0) * sin(roll / 2.0);
z = cos(pitch / 2.0) * sin(yaw / 2.0) * cos(roll / 2.0) -
sin(pitch / 2.0) * cos(yaw / 2.0) * sin(roll / 2.0);
normalize();
}
void getRotMat(float* m) const
{
for (int i = 0; i < 16; i++)
{
m[i] = 0.0;
}
m[0] = static_cast<float>(1.0 - 2.0 * y * y - 2.0 * z * z);
m[1] = static_cast<float>(2.0 * x * y - 2.0 * z * w);
m[2] = static_cast<float>(2.0 * x * z + 2.0 * y * w);
m[4] = static_cast<float>(2.0 * x * y + 2.0 * z * w);
m[5] = static_cast<float>(1.0 - 2.0 * x * x - 2.0 * z * z);
m[6] = static_cast<float>(2.0 * y * z - 2.0 * x * w);
m[8] = static_cast<float>(2.0 * x * z - 2.0 * y * w);
m[9] = static_cast<float>(2.0 * y * z + 2.0 * x * w);
m[10] = static_cast<float>(1.0 - 2.0 * x * x - 2.0 * y * y);
m[15] = 1.0;
}
double x, y, z, w;
};
#endif /* QUATERNION_H_ */

@ -97,7 +97,8 @@ void multiblock_processing(TaskQueue<vtkm::cont::MultiBlock>& queue)
}
catch (const vtkm::cont::ErrorBadValue& error)
{
std::cerr << "gradient filter failed!" << std::endl;
std::cerr << "Gradient filter failed!" << std::endl;
std::cerr << error.GetMessage() << std::endl;
break;
}
}

@ -10,9 +10,7 @@
#ifndef vtk_m_examples_multibackend_MultiDeviceGradient_h
#define vtk_m_examples_multibackend_MultiDeviceGradient_h
#include <vtkm/filter/FilterField.h>
#include <vtkm/filter/FilterTraits.h>
#include "TaskQueue.h"
@ -27,6 +25,9 @@ using RuntimeTaskQueue = TaskQueue<std::function<void()>>;
class MultiDeviceGradient : public vtkm::filter::FilterField<MultiDeviceGradient>
{
public:
using SupportedTypes =
vtkm::ListTagBase<vtkm::Float32, vtkm::Float64, vtkm::Vec3f_32, vtkm::Vec3f_64>;
//Construct a MultiDeviceGradient and worker pool
VTKM_CONT
MultiDeviceGradient();
@ -54,25 +55,6 @@ private:
std::vector<std::thread> Workers;
};
namespace vtkm
{
namespace filter
{
template <>
class FilterTraits<MultiDeviceGradient>
{
public:
struct TypeListTagGradientInputs
: vtkm::ListTagBase<vtkm::Float32, vtkm::Float64, vtkm::Vec3f_32, vtkm::Vec3f_64>
{
};
using InputFieldTypeList = TypeListTagGradientInputs;
};
}
} // namespace vtkm::filter
#ifndef vtk_m_examples_multibackend_MultiDeviceGradient_cxx
extern template vtkm::cont::MultiBlock MultiDeviceGradient::PrepareForExecution<
vtkm::filter::PolicyDefault>(const vtkm::cont::MultiBlock&,

@ -11,8 +11,10 @@ cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(PolyLineArchimedeanHelix CXX)
find_package(VTKm REQUIRED QUIET)
if (VTKm_ENABLE_RENDERING)
add_executable(PolyLineArchimedeanHelix PolyLineArchimedeanHelix.cxx)
if(TARGET vtkm::cuda)
set_source_files_properties(PolyLineArchimedeanHelix.cxx PROPERTIES LANGUAGE "CUDA")
endif()
target_link_libraries(PolyLineArchimedeanHelix PRIVATE vtkm_filter vtkm_cont vtkm_rendering)
endif()

@ -99,7 +99,7 @@ void TubeThatSpiral(vtkm::FloatDefault radius, vtkm::Id numLineSegments, vtkm::I
vtkm::cont::DataSetFieldAdd dsfa;
std::vector<vtkm::FloatDefault> v(tubePoints.GetNumberOfValues());
std::vector<vtkm::FloatDefault> v(static_cast<std::size_t>(tubePoints.GetNumberOfValues()));
// The first value is a cap:
v[0] = 0;
for (vtkm::Id i = 1; i < vtkm::Id(v.size()); i += numSides)
@ -108,7 +108,7 @@ void TubeThatSpiral(vtkm::FloatDefault radius, vtkm::Id numLineSegments, vtkm::I
vtkm::FloatDefault r = a + b * t;
for (vtkm::Id j = i; j < i + numSides && j < vtkm::Id(v.size()); ++j)
{
v[j] = r;
v[static_cast<std::size_t>(j)] = r;
}
}
// Point at the end cap should be the same color as the surroundings:

@ -1,26 +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.
##============================================================================
cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(RenderingExample CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
if(NOT TARGET vtkm_rendering OR NOT VTKm_ENABLE_GL_CONTEXT)
return()
endif()
vtkm_find_gl(OPTIONAL GLUT)
if(NOT TARGET GLUT::GLUT)
return()
endif()
add_executable(RenderingExample Rendering.cxx)
target_link_libraries(RenderingExample PRIVATE vtkm_rendering GLUT::GLUT)

@ -1,144 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <vtkm/rendering/internal/OpenGLHeaders.h> //Required for compile....
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <vtkm/cont/ColorTable.h>
#include <vtkm/rendering/CanvasGL.h>
#include <vtkm/rendering/MapperGL.h>
#include <vtkm/rendering/View3D.h>
vtkm::rendering::View3D* view = nullptr;
const vtkm::Int32 W = 512, H = 512;
int buttonStates[3] = { GLUT_UP, GLUT_UP, GLUT_UP };
bool shiftKey = false;
int lastx = -1, lasty = -1;
void reshape(int, int)
{
//Don't allow resizing window.
glutReshapeWindow(W, H);
}
// Render the output using simple OpenGL
void displayCall()
{
view->Paint();
glutSwapBuffers();
}
// Allow rotations of the camera
void mouseMove(int x, int y)
{
const vtkm::Id width = view->GetCanvas().GetWidth();
const vtkm::Id height = view->GetCanvas().GetHeight();
//Map to XY
y = static_cast<int>(height - y);
if (lastx != -1 && lasty != -1)
{
vtkm::Float32 x1 = vtkm::Float32(lastx * 2) / vtkm::Float32(width) - 1.0f;
vtkm::Float32 y1 = vtkm::Float32(lasty * 2) / vtkm::Float32(height) - 1.0f;
vtkm::Float32 x2 = vtkm::Float32(x * 2) / vtkm::Float32(width) - 1.0f;
vtkm::Float32 y2 = vtkm::Float32(y * 2) / vtkm::Float32(height) - 1.0f;
if (buttonStates[0] == GLUT_DOWN)
{
if (shiftKey)
view->GetCamera().Pan(x2 - x1, y2 - y1);
else
view->GetCamera().TrackballRotate(x1, y1, x2, y2);
}
else if (buttonStates[1] == GLUT_DOWN)
view->GetCamera().Zoom(y2 - y1);
}
lastx = x;
lasty = y;
glutPostRedisplay();
}
// Respond to mouse button
void mouseCall(int button, int state, int vtkmNotUsed(x), int vtkmNotUsed(y))
{
int modifiers = glutGetModifiers();
shiftKey = modifiers & GLUT_ACTIVE_SHIFT;
buttonStates[button] = state;
//std::cout<<"Buttons: "<<buttonStates[0]<<" "<<buttonStates[1]<<" "<<buttonStates[2]<<" SHIFT= "<<shiftKey<<std::endl;
//mouse down, reset.
if (buttonStates[button] == GLUT_DOWN)
{
lastx = -1;
lasty = -1;
}
}
// Compute and render an isosurface for a uniform grid example
int main(int argc, char* argv[])
{
auto opts =
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
vtkm::cont::Initialize(argc, argv, opts);
vtkm::cont::testing::MakeTestDataSet maker;
vtkm::cont::DataSet ds = maker.Make3DUniformDataSet0();
lastx = lasty = -1;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(W, H);
glutCreateWindow("VTK-m Rendering");
glutDisplayFunc(displayCall);
glutMotionFunc(mouseMove);
glutMouseFunc(mouseCall);
glutReshapeFunc(reshape);
vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f);
vtkm::rendering::CanvasGL canvas;
vtkm::rendering::MapperGL mapper;
vtkm::rendering::Scene scene;
scene.AddActor(vtkm::rendering::Actor(ds.GetCellSet(),
ds.GetCoordinateSystem(),
ds.GetField("pointvar"),
vtkm::cont::ColorTable("inferno")));
//Create vtkm rendering stuff.
view = new vtkm::rendering::View3D(scene, mapper, canvas, bg);
view->Initialize();
glutMainLoop();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -1,28 +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.
##============================================================================
cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(Streamline CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
set(gl_libs OpenGL::GL OpenGL::GLU GLEW::GLEW GLUT::GLUT)
add_executable(StreamLineUniformGrid StreamLineUniformGrid.cxx)
target_link_libraries(StreamLineUniformGrid PRIVATE vtkm_filter ${gl_libs})
vtkm_add_target_information(StreamLineUniformGrid
MODIFY_CUDA_FLAGS
DEVICE_SOURCES StreamLineUniformGrid.cxx)
endif()

@ -1,283 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/StreamLineUniformGrid.h>
#include <vtkm/cont/testing/Testing.h>
#include <fstream>
#include <math.h>
#include <vector>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "../isosurface/quaternion.h"
// Output data set shared with opengl
static vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32>* streamLineFilter;
static vtkm::cont::DataSet outDataSet;
// Input parameters
const vtkm::Id nSeeds = 25;
const vtkm::Id nSteps = 2000;
const vtkm::Float32 tStep = 0.5f;
const vtkm::Id direction = vtkm::worklet::streamline::BOTH;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec3f_32> vertexArray;
// OpenGL display variables
Quaternion qrot;
int lastx, lasty;
int mouse_state = 1;
//
// Initialize the OpenGL state
//
void initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
float white[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float black[] = { 0.0f, 0.0f, 0.0f, 1.0f };
float lightPos[] = { 10.0f, 10.0f, 10.5f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, white);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
glLightfv(GL_LIGHT0, GL_SPECULAR, black);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
//
// Render the output using simple OpenGL
//
void displayCall()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, 1.0f, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glLineWidth(1.0f);
glPushMatrix();
float rotationMatrix[16];
qrot.getRotMat(rotationMatrix);
glMultMatrixf(rotationMatrix);
glTranslatef(-0.5f, -0.5f, -0.5f);
// Get the cell set, coordinate system and coordinate data
vtkm::cont::CellSetExplicit<> cellSet;
outDataSet.GetCellSet(0).CopyTo(cellSet);
auto coordArray = outDataSet.GetCoordinateSystem().GetData();
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
vtkm::cont::ArrayCopy(coordArray, vertexArray);
// Each cell is a polyline
glColor3f(1.0f, 0.0f, 0.0f);
for (vtkm::Id polyline = 0; polyline < numberOfCells; polyline++)
{
vtkm::Vec<vtkm::Id, nSteps> polylineIndices;
vtkm::IdComponent numIndices = cellSet.GetNumberOfPointsInCell(polyline);
cellSet.GetIndices(polyline, polylineIndices);
glBegin(GL_LINE_STRIP);
for (vtkm::IdComponent i = 0; i < numIndices; i++)
{
vtkm::Vec3f_32 pt = vertexArray.GetPortalConstControl().Get(polylineIndices[i]);
glVertex3f(pt[0], pt[1], pt[2]);
}
glEnd();
}
glPopMatrix();
glutSwapBuffers();
}
// Allow rotations of the view
void mouseMove(int x, int y)
{
vtkm::Float32 dx = static_cast<vtkm::Float32>(x - lastx);
vtkm::Float32 dy = static_cast<vtkm::Float32>(y - lasty);
if (mouse_state == 0)
{
Quaternion newRotX;
newRotX.setEulerAngles(-0.2f * dx * vtkm::Pi_180f(), 0.0f, 0.0f);
qrot.mul(newRotX);
Quaternion newRotY;
newRotY.setEulerAngles(0.0f, 0.0f, -0.2f * dy * vtkm::Pi_180f());
qrot.mul(newRotY);
}
lastx = x;
lasty = y;
glutPostRedisplay();
}
// Respond to mouse button
void mouseCall(int button, int state, int x, int y)
{
if (button == 0)
mouse_state = state;
if ((button == 0) && (state == 0))
{
lastx = x;
lasty = y;
}
}
namespace
{
template <typename T>
VTKM_EXEC_CONT vtkm::Vec<T, 3> Normalize(vtkm::Vec<T, 3> v)
{
T magnitude = static_cast<T>(sqrt(vtkm::dot(v, v)));
T zero = static_cast<T>(0.0);
T one = static_cast<T>(1.0);
if (magnitude == zero)
return vtkm::make_Vec(zero, zero, zero);
else
return one / magnitude * v;
}
}
// Run streamlines on a uniform grid of vector data
int main(int argc, char* argv[])
{
auto opts = vtkm::cont::InitializeOptions::DefaultAnyDevice;
auto config = vtkm::cont::Initialize(argc, argv, opts);
std::cout << "StreamLineUniformGrid Example" << std::endl;
std::cout << "Parameters are [options] fileName [numSeeds maxSteps timeStep direction]"
<< std::endl
<< std::endl;
std::cout << "Direction is FORWARD=0 BACKWARD=1 BOTH=2" << std::endl << std::endl;
std::cout << "File is expected to be binary with xdim ydim zdim as 32 bit integers " << std::endl;
std::cout << "followed by vector data per dimension point as 32 bit float" << std::endl;
std::cout << config.Usage << std::endl;
// Read in the vector data for testing
FILE* pFile = fopen(argv[1], "rb");
if (pFile == nullptr)
perror("Error opening file");
size_t ret_code = 0;
// Size of the dataset
int dims[3];
ret_code = fread(dims, sizeof(int), 3, pFile);
if (ret_code != 3)
{
perror("Error reading size of data");
fclose(pFile);
return 0;
}
const vtkm::Id3 vdims(dims[0], dims[1], dims[2]);
// Read vector data at each point of the uniform grid and store
vtkm::Id nElements = vdims[0] * vdims[1] * vdims[2] * 3;
float* data = new float[static_cast<std::size_t>(nElements)];
ret_code = fread(data, sizeof(float), static_cast<std::size_t>(nElements), pFile);
if (ret_code != static_cast<size_t>(nElements))
{
perror("Error reading vector data");
fclose(pFile);
return 0;
}
//We are done with the file now, so release the file descriptor
fclose(pFile);
std::vector<vtkm::Vec3f_32> field;
for (vtkm::Id i = 0; i < nElements; i++)
{
vtkm::Float32 x = data[i];
vtkm::Float32 y = data[++i];
vtkm::Float32 z = data[++i];
vtkm::Vec3f_32 vecData(x, y, z);
field.push_back(Normalize(vecData));
}
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> fieldArray;
fieldArray = vtkm::cont::make_ArrayHandle(field);
// Construct the input dataset (uniform) to hold the input and set vector data
vtkm::cont::DataSet inDataSet;
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims);
inDataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
inDataSet.AddField(
vtkm::cont::Field("vecData", vtkm::cont::Field::Association::POINTS, fieldArray));
vtkm::cont::CellSetStructured<3> inCellSet("cells");
inCellSet.SetPointDimensions(vtkm::make_Vec(vdims[0], vdims[1], vdims[2]));
inDataSet.AddCellSet(inCellSet);
// Create and run the filter
streamLineFilter = new vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32>();
outDataSet = streamLineFilter->Run(inDataSet, direction, nSeeds, nSteps, tStep);
// Render the output dataset of polylines
lastx = lasty = 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(1000, 1000);
glutCreateWindow("VTK-m Uniform 3D StreamLines");
initializeGL();
glutDisplayFunc(displayCall);
glutMotionFunc(mouseMove);
glutMouseFunc(mouseCall);
glutMainLoop();
delete streamLineFilter;
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

Binary file not shown.

@ -1,23 +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.
##============================================================================
cmake_minimum_required(VERSION 3.8...3.14 FATAL_ERROR)
project(TauTiming CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
if(TARGET vtkm_rendering)
add_executable(Tau_timing TauTiming.cxx)
vtkm_add_target_information(Tau_timing
MODIFY_CUDA_FLAGS
DEVICE_SOURCES TauTiming.cxx)
target_link_libraries(Tau_timing vtkm_cont)
endif()

@ -1,478 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/filter/MarchingCubes.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/ExternalFaces.h>
#include <vtkm/worklet/StreamLineUniformGrid.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/Initiailize.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/rendering/Actor.h>
#include <vtkm/rendering/CanvasRayTracer.h>
#include <vtkm/rendering/MapperRayTracer.h>
#include <vtkm/rendering/MapperVolume.h>
#include <vtkm/rendering/Scene.h>
#include <vtkm/rendering/View3D.h>
#include <vtkm/rendering/testing/RenderTest.h>
#include <vtkm/worklet/StreamLineUniformGrid.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
static bool printProgress = true;
template <typename T>
VTKM_EXEC_CONT vtkm::Vec<T, 3> Normalize(vtkm::Vec<T, 3> v)
{
T magnitude = static_cast<T>(sqrt(vtkm::dot(v, v)));
T zero = static_cast<T>(0.0);
T one = static_cast<T>(1.0);
if (magnitude == zero)
return vtkm::make_Vec(zero, zero, zero);
else
return one / magnitude * v;
}
class TangleField : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn vertexId, FieldOut v);
using ExecutionSignature = void(_1, _2);
using InputDomain = _1;
const vtkm::Id xdim, ydim, zdim;
const vtkm::FloatDefault xmin, ymin, zmin, xmax, ymax, zmax;
const vtkm::Id cellsPerLayer;
VTKM_CONT
TangleField(const vtkm::Id3 dims,
const vtkm::FloatDefault mins[3],
const vtkm::FloatDefault maxs[3])
: xdim(dims[0])
, ydim(dims[1])
, zdim(dims[2])
, xmin(mins[0])
, ymin(mins[1])
, zmin(mins[2])
, xmax(maxs[0])
, ymax(maxs[1])
, zmax(maxs[2])
, cellsPerLayer((xdim) * (ydim))
{
}
VTKM_EXEC
void operator()(const vtkm::Id& vertexId, vtkm::Float32& v) const
{
const vtkm::Id x = vertexId % (xdim);
const vtkm::Id y = (vertexId / (xdim)) % (ydim);
const vtkm::Id z = vertexId / cellsPerLayer;
const vtkm::FloatDefault fx =
static_cast<vtkm::FloatDefault>(x) / static_cast<vtkm::FloatDefault>(xdim - 1);
const vtkm::FloatDefault fy =
static_cast<vtkm::FloatDefault>(y) / static_cast<vtkm::FloatDefault>(xdim - 1);
const vtkm::FloatDefault fz =
static_cast<vtkm::FloatDefault>(z) / static_cast<vtkm::FloatDefault>(xdim - 1);
const vtkm::Float32 xx = 3.0f * vtkm::Float32(xmin + (xmax - xmin) * (fx));
const vtkm::Float32 yy = 3.0f * vtkm::Float32(ymin + (ymax - ymin) * (fy));
const vtkm::Float32 zz = 3.0f * vtkm::Float32(zmin + (zmax - zmin) * (fz));
v = (xx * xx * xx * xx - 5.0f * xx * xx + yy * yy * yy * yy - 5.0f * yy * yy +
zz * zz * zz * zz - 5.0f * zz * zz + 11.8f) *
0.2f +
0.5f;
}
};
vtkm::cont::DataSet CreateTestDataSet(vtkm::Id3 dims)
{
vtkm::cont::DataSet dataSet;
const vtkm::Id3 vdims(dims[0] + 1, dims[1] + 1, dims[2] + 1);
vtkm::FloatDefault mins[3] = { -1.0f, -1.0f, -1.0f };
vtkm::FloatDefault maxs[3] = { 1.0f, 1.0f, 1.0f };
static const vtkm::IdComponent ndim = 3;
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
cellSet.SetPointDimensions(vdims);
dataSet.AddCellSet(cellSet);
vtkm::Vec3f origin(0.0f, 0.0f, 0.0f);
vtkm::Vec3f spacing(1.0f / static_cast<vtkm::FloatDefault>(dims[0]),
1.0f / static_cast<vtkm::FloatDefault>(dims[2]),
1.0f / static_cast<vtkm::FloatDefault>(dims[1]));
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
vtkm::cont::ArrayHandle<vtkm::Float32> scalarVar;
vtkm::cont::ArrayHandleIndex vertexCountImplicitArray(vdims[0] * vdims[1] * vdims[2]);
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(
TangleField(vdims, mins, maxs));
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, scalarVar);
dataSet.AddField(
vtkm::cont::Field(std::string("scalar"), vtkm::cont::Field::Association::POINTS, scalarVar));
return dataSet;
}
void TestMarchingCubesUniformGrid(int d)
{
vtkm::Id3 dims(d, d, d);
std::cout << "Marching cubes with gridsize = " << dims << std::endl;
vtkm::cont::DataSet dataSet = CreateTestDataSet(dims);
//vtkm::io::writer::VTKDataSetWriter wrt("ds.vtk");
//wrt.WriteDataSet(dataSet);
int N = 100;
vtkm::Float32 v0 = -.8f, v1 = 24.0f;
vtkm::Float32 dv = (v1 - v0) / (vtkm::Float32)(N - 1);
for (int i = 0; i < N; i++)
{
vtkm::filter::ResultDataSet result;
vtkm::filter::MarchingCubes mc;
mc.SetGenerateNormals(true);
vtkm::Float32 val = v0 + i * dv;
//std::cout<<i<<": "<<val<<std::endl;
if (N == 1)
val = 0.5f;
mc.SetIsoValue(val);
//mc.SetMergeDuplicatePoints(false);
result = mc.Execute(dataSet, dataSet.GetField("nodevar"));
const vtkm::cont::DataSet& out = result.GetDataSet();
}
//std::cout<<"Number of points in isosurface: "<<out.GetCoordinateSystem().GetData().GetNumberOfValues()<<std::endl;
}
void TestStreamlineUniformGrid(int d)
{
/*
vtkm::Id3 dims(d,d,d);
std::cout<<"Streamline with gridsize = "<<dims<<std::endl;
vtkm::cont::DataSet dataSet = MakeIsosurfaceTestDataSet(dims);
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> result;
PointGrad<vtkm::Float32> func(dataSet, "nodevar", result);
vtkm::cont::CastAndCall(dataSet.GetCellSet(), func);
printSummary_ArrayHandle(result, std::cout);
*/
}
void CreateData(int d)
{
vtkm::Id3 dims(d, d, d);
vtkm::cont::DataSet dataSet = CreateTestDataSet(dims);
char tmp[64];
sprintf(tmp, "regular_%d.vtk", d);
std::string fname = tmp;
std::cout << fname << std::endl;
vtkm::io::writer::VTKDataSetWriter wrt(fname);
wrt.WriteDataSet(dataSet);
}
void MarchingCubesTest(const vtkm::cont::DataSet& ds, int N)
{
std::cout << "Marching Cubes test: " << N << std::endl;
vtkm::Range range;
ds.GetField(0).GetRange(&range, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
int nv = 10;
vtkm::Float32 v0 = range.Min, v1 = range.Max;
vtkm::Float32 dv = (v1 - v0) / (vtkm::Float32)(nv - 1);
std::cout << "Field range: (" << v0 << "," << v1 << ") dv= " << dv << std::endl;
vtkm::filter::MarchingCubes mc;
mc.SetGenerateNormals(true);
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout << " " << i << " of " << N << std::endl;
for (int j = 0; j < nv; j++)
{
vtkm::filter::ResultDataSet result;
//vtkm::Float32 val = v0 + i*dv;
//std::cout<<i<<": "<<val<<std::endl;
mc.SetIsoValue(v0 + j * dv);
//mc.SetMergeDuplicatePoints(false);
result = mc.Execute(ds, ds.GetField(0));
const vtkm::cont::DataSet& out = result.GetDataSet();
}
}
#if 0
vtkm::Float32 v0 = range.Min, v1 = range.Max;
vtkm::Float32 dv = (v1-v0)/(vtkm::Float32)(N-1);
std::cout<<"Field range: ("<<v0<<","<<v1<<") dv= "<<dv<<std::endl;
#if 0
vtkm::filter::MarchingCubes mc;
mc.SetGenerateNormals(true);
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout<<" "<<i<<" of "<<N<<std::endl;
vtkm::filter::ResultDataSet result;
//vtkm::Float32 val = v0 + i*dv;
//std::cout<<i<<": "<<val<<std::endl;
mc.SetIsoValue(v0 + i*dv);
//mc.SetMergeDuplicatePoints(false);
result = mc.Execute(ds, ds.GetField(0));
const vtkm::cont::DataSet &out = result.GetDataSet();
}
#endif
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout<<" "<<i<<" of "<<N<<std::endl;
vtkm::filter::ResultDataSet result;
vtkm::filter::MarchingCubes mc;
mc.SetGenerateNormals(true);
//vtkm::Float32 val = v0 + i*dv;
//std::cout<<i<<": "<<val<<std::endl;
mc.SetIsoValue(v0 + i*dv);
//mc.SetMergeDuplicatePoints(false);
result = mc.Execute(ds, ds.GetField(0));
const vtkm::cont::DataSet &out = result.GetDataSet();
}
#endif
/*
vtkm::filter::ResultDataSet result;
vtkm::filter::MarchingCubes mc;
mc.SetGenerateNormals(true);
//vtkm::Float32 val = v0 + i*dv;
//std::cout<<i<<": "<<val<<std::endl;
mc.SetIsoValue(0.5f);
result = mc.Execute(ds, ds.GetField(0));
const vtkm::cont::DataSet &out = result.GetDataSet();
vtkm::io::writer::VTKDataSetWriter wrt("iso.vtk");
wrt.WriteDataSet(out);
*/
}
static vtkm::cont::DataSet createUniform(const vtkm::cont::DataSet& ds)
{
vtkm::cont::DataSetBuilderUniform builder;
vtkm::cont::DataSetFieldAdd fieldAdd;
vtkm::cont::DataSet out = builder.Create(vtkm::Id3(50, 50, 50));
fieldAdd.AddPointField(out, ds.GetField(0).GetName(), ds.GetField(0).GetData());
out.PrintSummary(std::cout);
return out;
}
void StreamlineTest(vtkm::cont::DataSet& ds, int N)
{
const vtkm::Id nSeeds = 25000;
const vtkm::Id nSteps = 20000;
const vtkm::Float32 tStep = 0.05f;
const vtkm::Id direction = vtkm::worklet::internal::FORWARD; //vtkm::worklet::internal::BOTH;
vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32>* streamLineFilter;
streamLineFilter = new vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32>();
std::cout << "Streamline test: " << N << std::endl;
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout << " " << i << " of " << N << std::endl;
vtkm::cont::DataSet out;
out = streamLineFilter->Run(ds, direction, nSeeds, nSteps, tStep);
}
}
void RenderRTTest(const vtkm::cont::DataSet& ds, int N)
{
std::cout << "Ray Tracing test: " << N << std::endl;
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout << " " << i << " of " << N << std::endl;
using M = vtkm::rendering::MapperRayTracer;
using C = vtkm::rendering::CanvasRayTracer;
using V3 = vtkm::rendering::View3D;
//std::cout<<"Render: "<<i<<std::endl;
vtkm::cont::ColorTable colorTable("inferno");
vtkm::rendering::testing::Render<M, C, V3>(ds, "scalar", colorTable);
}
}
void RenderVolTest(const vtkm::cont::DataSet& ds, int N)
{
std::cout << "Volume Rendering test :" << N << std::endl;
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout << " " << i << " of " << N << std::endl;
using M = vtkm::rendering::MapperVolume;
using C = vtkm::rendering::CanvasRayTracer;
using V3 = vtkm::rendering::View3D;
//std::cout<<"Render: "<<i<<std::endl;
vtkm::cont::ColorTable colorTable("inferno");
vtkm::rendering::testing::Render<M, C, V3>(ds, "scalar", colorTable);
}
}
void ExternalFacesTest(const vtkm::cont::DataSet& ds, int N)
{
std::cout << "External Face test: " << N << std::endl;
for (int i = 0; i < N; i++)
{
if (printProgress && i % 10 == 0)
std::cout << " " << i << " of " << N << std::endl;
vtkm::cont::CellSetExplicit<> inCellSet;
//vtkm::cont::CellSetSingleType<> inCellSet;
ds.GetCellSet(0).CopyTo(inCellSet);
vtkm::cont::CellSetExplicit<> outCellSet("cells");
//vtkm::cont::CellSetSingleType<> outCellSet("cells");
//Run the External Faces worklet
vtkm::worklet::ExternalFaces().Run(inCellSet, outCellSet, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
vtkm::cont::DataSet outDataSet;
for (vtkm::IdComponent i = 0; i < ds.GetNumberOfCoordinateSystems(); ++i)
outDataSet.AddCoordinateSystem(ds.GetCoordinateSystem(i));
outDataSet.AddCellSet(outCellSet);
}
}
/*
Notes:
render: 256 reg and rect. 100 iterations.
expl: external faces requires non-SingleType explicit. Forced reader to use this.
streamlines: vector field must be named "vecData"
*/
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);
if (argc != 5)
{
std::cout << "Error: " << argv[0]
<< " [options] <algo:iso/sl/ext/rt/vol> N SZ <ftype:reg/rect/expl>" << std::endl;
std::cout << "General Options: \n" << config.Usage << std::endl;
return -1;
}
std::string alg = argv[1];
int N = atoi(argv[2]);
if (alg == "sl")
{
char fname[64];
sprintf(fname, "../data/tornado.vec");
std::cout << "Reading file: " << fname << std::endl;
FILE* pFile = fopen(fname, "rb");
int dims[3];
size_t ret_code = fread(dims, sizeof(int), 3, pFile);
const vtkm::Id3 vdims(dims[0], dims[1], dims[2]);
vtkm::Id nElements = vdims[0] * vdims[1] * vdims[2] * 3;
float* data = new float[static_cast<std::size_t>(nElements)];
ret_code = fread(data, sizeof(float), static_cast<std::size_t>(nElements), pFile);
fclose(pFile);
std::vector<vtkm::Vec3f_32> field;
for (vtkm::Id i = 0; i < nElements; i++)
{
vtkm::Float32 x = data[i];
vtkm::Float32 y = data[++i];
vtkm::Float32 z = data[++i];
vtkm::Vec3f_32 vecData(x, y, z);
field.push_back(Normalize(vecData));
}
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> fieldArray;
fieldArray = vtkm::cont::make_ArrayHandle(field);
// Construct the input dataset (uniform) to hold the input and set vector data
vtkm::cont::DataSet ds;
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims);
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
ds.AddField(vtkm::cont::Field("vec", vtkm::cont::Field::Association::POINTS, fieldArray));
vtkm::cont::CellSetStructured<3> inCellSet("cells");
inCellSet.SetPointDimensions(vtkm::make_Vec(vdims[0], vdims[1], vdims[2]));
ds.AddCellSet(inCellSet);
StreamlineTest(ds, N);
return 0;
}
else
{
int sz = atoi(argv[3]);
std::string ftype = argv[4];
char fname[64];
sprintf(fname, "../data/s%s_%d.vtk", ftype.c_str(), sz);
std::cout << "FNAME= " << fname << std::endl;
vtkm::cont::DataSet ds;
if (sz < 0)
{
vtkm::cont::testing::MakeTestDataSet dataSetMaker;
ds = dataSetMaker.Make3DExplicitDataSet5();
}
else
{
std::cout << "Reading file: " << fname << std::endl;
vtkm::io::reader::VTKDataSetReader rdr(fname);
ds = rdr.ReadDataSet();
}
if (alg == "iso")
MarchingCubesTest(ds, N);
else if (alg == "ext")
ExternalFacesTest(ds, N);
else if (alg == "rt")
RenderRTTest(ds, N);
else if (alg == "vol")
RenderVolTest(ds, N);
return 0;
}
}

@ -12,35 +12,17 @@ project(Tetrahedra CXX)
#Find the VTK-m package
find_package(VTKm REQUIRED QUIET)
vtkm_find_gl(OPTIONAL GL GLUT GLEW)
if(TARGET OpenGL::GL AND
TARGET GLUT::GLUT AND
TARGET GLEW::GLEW)
add_executable(Tetrahedralize Tetrahedralize.cxx)
target_link_libraries(Tetrahedralize PRIVATE vtkm_filter)
set(gl_libs OpenGL::GL OpenGL::GLU GLEW::GLEW GLUT::GLUT)
add_executable(TetrahedralizeExplicitGrid TetrahedralizeExplicitGrid.cxx)
add_executable(TriangulateExplicitGrid TriangulateExplicitGrid.cxx)
add_executable(TetrahedralizeUniformGrid TetrahedralizeUniformGrid.cxx)
add_executable(TriangulateUniformGrid TriangulateUniformGrid.cxx)
target_link_libraries(TetrahedralizeExplicitGrid PRIVATE vtkm_filter ${gl_libs})
target_link_libraries(TriangulateExplicitGrid PRIVATE vtkm_filter ${gl_libs})
target_link_libraries(TetrahedralizeUniformGrid PRIVATE vtkm_filter ${gl_libs})
target_link_libraries(TriangulateUniformGrid PRIVATE vtkm_filter ${gl_libs})
vtkm_add_target_information(TetrahedralizeExplicitGrid
vtkm_add_target_information(Tetrahedralize
MODIFY_CUDA_FLAGS
DEVICE_SOURCES TetrahedralizeExplicitGrid.cxx)
vtkm_add_target_information(TriangulateExplicitGrid
MODIFY_CUDA_FLAGS
DEVICE_SOURCES TriangulateExplicitGrid.cxx)
vtkm_add_target_information(TetrahedralizeUniformGrid
MODIFY_CUDA_FLAGS
DEVICE_SOURCES TetrahedralizeUniformGrid.cxx)
vtkm_add_target_information(TriangulateUniformGrid
MODIFY_CUDA_FLAGS
DEVICE_SOURCES TriangulateUniformGrid.cxx)
DEVICE_SOURCES Tetrahedralize.cxx)
endif()
add_executable(Triangulate Triangulate.cxx)
target_link_libraries(Triangulate PRIVATE vtkm_filter)
vtkm_add_target_information(Triangulate
MODIFY_CUDA_FLAGS
DEVICE_SOURCES Triangulate.cxx)

@ -0,0 +1,32 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
#include <vtkm/filter/Tetrahedralize.h>
int main(int argc, char* argv[])
{
vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict);
vtkm::cont::DataSet input =
vtkm::cont::testing::MakeTestDataSet().Make3DUniformDataSet3(vtkm::Id3(25, 25, 25));
vtkm::filter::Tetrahedralize tetrahedralizeFilter;
vtkm::cont::DataSet output = tetrahedralizeFilter.Execute(input);
vtkm::io::writer::VTKDataSetWriter writer("out_tets.vtk");
writer.WriteDataSet(output);
return 0;
}

@ -1,284 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/filter/Tetrahedralize.h>
#include <vtkm/cont/testing/Testing.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "../isosurface/quaternion.h"
namespace
{
// Takes input uniform grid and outputs unstructured grid of tets
static vtkm::cont::DataSet outDataSet;
// OpenGL display variables
Quaternion qrot;
int lastx, lasty;
int mouse_state = 1;
} // anonymous namespace
//
// Test 3D explicit dataset
//
vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
{
vtkm::cont::DataSetBuilderExplicitIterative builder;
builder.Begin();
builder.AddPoint(0, 0, 0);
builder.AddPoint(1, 0, 0);
builder.AddPoint(2, 0, 0);
builder.AddPoint(3, 0, 0);
builder.AddPoint(0, 1, 0);
builder.AddPoint(1, 1, 0);
builder.AddPoint(2, 1, 0);
builder.AddPoint(2.5, 1.0, 0.0);
builder.AddPoint(0, 2, 0);
builder.AddPoint(1, 2, 0);
builder.AddPoint(0.5, 0.5, 1.0);
builder.AddPoint(1, 0, 1);
builder.AddPoint(2, 0, 1);
builder.AddPoint(3, 0, 1);
builder.AddPoint(1, 1, 1);
builder.AddPoint(2, 1, 1);
builder.AddPoint(2.5, 1.0, 1.0);
builder.AddPoint(0.5, 1.5, 1.0);
builder.AddCell(vtkm::CELL_SHAPE_TETRA);
builder.AddCellPoint(0);
builder.AddCellPoint(1);
builder.AddCellPoint(5);
builder.AddCellPoint(10);
builder.AddCell(vtkm::CELL_SHAPE_HEXAHEDRON);
builder.AddCellPoint(1);
builder.AddCellPoint(2);
builder.AddCellPoint(6);
builder.AddCellPoint(5);
builder.AddCellPoint(11);
builder.AddCellPoint(12);
builder.AddCellPoint(15);
builder.AddCellPoint(14);
builder.AddCell(vtkm::CELL_SHAPE_WEDGE);
builder.AddCellPoint(2);
builder.AddCellPoint(3);
builder.AddCellPoint(7);
builder.AddCellPoint(12);
builder.AddCellPoint(13);
builder.AddCellPoint(16);
builder.AddCell(vtkm::CELL_SHAPE_PYRAMID);
builder.AddCellPoint(4);
builder.AddCellPoint(5);
builder.AddCellPoint(9);
builder.AddCellPoint(8);
builder.AddCellPoint(17);
return builder.Create();
}
//
// Initialize the OpenGL state
//
void initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
float white[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float black[] = { 0.0f, 0.0f, 0.0f, 1.0f };
float lightPos[] = { 10.0f, 10.0f, 10.5f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, white);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
glLightfv(GL_LIGHT0, GL_SPECULAR, black);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
//
// Render the output using simple OpenGL
//
void displayCall()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.0f, 1.0f, 40.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(1.5f, 2.0f, 6.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glPushMatrix();
float rotationMatrix[16];
qrot.getRotMat(rotationMatrix);
glMultMatrixf(rotationMatrix);
glTranslatef(-0.5f, -0.5f, -0.5f);
// Get cell set and the number of cells and vertices
vtkm::cont::CellSetSingleType<> cellSet;
outDataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
auto vertexArray = outDataSet.GetCoordinateSystem().GetData();
// Draw the five tetrahedra belonging to each hexadron
vtkm::Float32 color[5][3] = { { 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 1.0f, 0.0f } };
for (vtkm::Id tetra = 0; tetra < numberOfCells; tetra++)
{
vtkm::Id indx = tetra % 5;
glColor3f(color[indx][0], color[indx][1], color[indx][2]);
// Get the indices of the vertices that make up this tetrahedron
vtkm::Id4 tetIndices;
cellSet.GetIndices(tetra, tetIndices);
// Get the vertex points for this tetrahedron
auto pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
auto pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
auto pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
auto pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
// Draw the tetrahedron filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_TRIANGLE_STRIP);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glVertex3d(pt2[0], pt2[1], pt2[2]);
glVertex3d(pt3[0], pt3[1], pt3[2]);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glEnd();
// Draw the tetrahedron wireframe
glColor3f(1.0f, 1.0f, 1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_TRIANGLE_STRIP);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glVertex3d(pt2[0], pt2[1], pt2[2]);
glVertex3d(pt3[0], pt3[1], pt3[2]);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glEnd();
}
glPopMatrix();
glutSwapBuffers();
}
// Allow rotations of the view
void mouseMove(int x, int y)
{
vtkm::Float32 dx = static_cast<vtkm::Float32>(x - lastx);
vtkm::Float32 dy = static_cast<vtkm::Float32>(y - lasty);
if (mouse_state == 0)
{
Quaternion newRotX;
newRotX.setEulerAngles(-0.2f * dx * vtkm::Pi_180f(), 0.0f, 0.0f);
qrot.mul(newRotX);
Quaternion newRotY;
newRotY.setEulerAngles(0.0f, 0.0f, -0.2f * dy * vtkm::Pi_180f());
qrot.mul(newRotY);
}
lastx = x;
lasty = y;
glutPostRedisplay();
}
// Respond to mouse button
void mouseCall(int button, int state, int x, int y)
{
if (button == 0)
mouse_state = state;
if ((button == 0) && (state == 0))
{
lastx = x;
lasty = y;
}
}
// Tetrahedralize and render uniform grid example
int main(int argc, char* argv[])
{
auto opts =
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
vtkm::cont::Initialize(argc, argv, opts);
std::cout << "TetrahedralizeExplicitGrid Example" << std::endl;
// Create the input explicit cell set
vtkm::cont::DataSet inDataSet = MakeTetrahedralizeExplicitDataSet();
vtkm::cont::CellSetExplicit<> inCellSet;
inDataSet.GetCellSet(0).CopyTo(inCellSet);
// Convert cells to tetrahedra
vtkm::filter::Tetrahedralize tetrahedralize;
outDataSet = tetrahedralize.Execute(inDataSet);
// Render the output dataset of tets
lastx = lasty = 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(1000, 1000);
glutCreateWindow("VTK-m Explicit Tetrahedralize");
initializeGL();
glutDisplayFunc(displayCall);
glutMotionFunc(mouseMove);
glutMouseFunc(mouseCall);
glutMainLoop();
outDataSet.Clear();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -1,268 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/filter/Tetrahedralize.h>
#include <vtkm/cont/testing/Testing.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "../isosurface/quaternion.h"
// Default size of the example
static vtkm::Id3 dims(4, 4, 4);
static vtkm::Id cellsToDisplay = 64;
// Takes input uniform grid and outputs unstructured grid of tets
static vtkm::cont::DataSet tetDataSet;
// OpenGL display variables
static Quaternion qrot;
static int lastx, lasty;
static int mouse_state = 1;
//
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing
//
vtkm::cont::DataSet MakeTetrahedralizeTestDataSet(vtkm::Id3 dim)
{
vtkm::cont::DataSet dataSet;
// Place uniform grid on a set physical space so OpenGL drawing is easier
const vtkm::Id3 vdims(dim[0] + 1, dim[1] + 1, dim[2] + 1);
const vtkm::Vec3f_32 origin = vtkm::make_Vec(0.0f, 0.0f, 0.0f);
const vtkm::Vec3f_32 spacing = vtkm::make_Vec(1.0f / static_cast<vtkm::Float32>(dim[0]),
1.0f / static_cast<vtkm::Float32>(dim[1]),
1.0f / static_cast<vtkm::Float32>(dim[2]));
// Generate coordinate system
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
// Generate cell set
vtkm::cont::CellSetStructured<3> cellSet("cells");
cellSet.SetPointDimensions(vdims);
dataSet.AddCellSet(cellSet);
return dataSet;
}
//
// Initialize the OpenGL state
//
void initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
float white[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float black[] = { 0.0f, 0.0f, 0.0f, 1.0f };
float lightPos[] = { 10.0f, 10.0f, 10.5f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, white);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
glLightfv(GL_LIGHT0, GL_SPECULAR, black);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
//
// Render the output using simple OpenGL
//
void displayCall()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.0f, 1.0f, 20.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
glLineWidth(3.0f);
glPushMatrix();
float rotationMatrix[16];
qrot.getRotMat(rotationMatrix);
glMultMatrixf(rotationMatrix);
glTranslatef(-0.5f, -0.5f, -0.5f);
// Get the cell set, coordinate system and coordinate data
vtkm::cont::CellSetSingleType<> cellSet;
tetDataSet.GetCellSet(0).CopyTo(cellSet);
auto vertexArray = tetDataSet.GetCoordinateSystem().GetData();
// Draw the five tetrahedra belonging to each hexadron
vtkm::Id tetra = 0;
vtkm::Float32 color[5][3] = { { 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 1.0f, 0.0f } };
for (vtkm::Id hex = 0; hex < cellsToDisplay; hex++)
{
for (vtkm::Id j = 0; j < 5; j++)
{
vtkm::Id indx = tetra % 5;
glColor3f(color[indx][0], color[indx][1], color[indx][2]);
// Get the indices of the vertices that make up this tetrahedron
vtkm::Id4 tetIndices;
cellSet.GetIndices(tetra, tetIndices);
// Get the vertex points for this tetrahedron
auto pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
auto pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
auto pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
auto pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
// Draw the tetrahedron filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_TRIANGLE_STRIP);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glVertex3d(pt2[0], pt2[1], pt2[2]);
glVertex3d(pt3[0], pt3[1], pt3[2]);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glEnd();
// Draw the tetrahedron wireframe
glColor3f(1.0f, 1.0f, 1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_TRIANGLE_STRIP);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glVertex3d(pt2[0], pt2[1], pt2[2]);
glVertex3d(pt3[0], pt3[1], pt3[2]);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glEnd();
tetra++;
}
}
glPopMatrix();
glutSwapBuffers();
}
// Allow rotations of the view
void mouseMove(int x, int y)
{
vtkm::Float32 dx = static_cast<vtkm::Float32>(x - lastx);
vtkm::Float32 dy = static_cast<vtkm::Float32>(y - lasty);
if (mouse_state == 0)
{
Quaternion newRotX;
newRotX.setEulerAngles(-0.2f * dx * vtkm::Pi_180f(), 0.0f, 0.0f);
qrot.mul(newRotX);
Quaternion newRotY;
newRotY.setEulerAngles(0.0f, 0.0f, -0.2f * dy * vtkm::Pi_180f());
qrot.mul(newRotY);
}
lastx = x;
lasty = y;
glutPostRedisplay();
}
// Respond to mouse button
void mouseCall(int button, int state, int x, int y)
{
if (button == 0)
mouse_state = state;
if ((button == 0) && (state == 0))
{
lastx = x;
lasty = y;
}
}
// Tetrahedralize and render uniform grid example
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);
std::cout << "TetrahedralizeUniformGrid Example" << std::endl;
std::cout << "Parameters are [options] [xdim ydim zdim [# of cellsToDisplay]]" << std::endl;
std::cout << config.Usage << std::endl << std::endl;
// Set the problem size and number of cells to display from command line
if (argc >= 4)
{
dims[0] = atoi(argv[1]);
dims[1] = atoi(argv[2]);
dims[2] = atoi(argv[3]);
cellsToDisplay = dims[0] * dims[1] * dims[2];
}
if (argc == 5)
{
cellsToDisplay = atoi(argv[4]);
}
// Create the input uniform cell set
vtkm::cont::DataSet inDataSet = MakeTetrahedralizeTestDataSet(dims);
vtkm::filter::Tetrahedralize tetrahedralize;
tetDataSet = tetrahedralize.Execute(inDataSet);
// Render the output dataset of tets
lastx = lasty = 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(1000, 1000);
glutCreateWindow("VTK-m Uniform Tetrahedralize");
initializeGL();
glutDisplayFunc(displayCall);
glutMotionFunc(mouseMove);
glutMouseFunc(mouseCall);
glutMainLoop();
tetDataSet.Clear();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -0,0 +1,31 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
#include <vtkm/filter/Triangulate.h>
int main(int argc, char* argv[])
{
vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict);
vtkm::cont::DataSet input = vtkm::cont::testing::MakeTestDataSet().Make2DUniformDataSet2();
vtkm::filter::Triangulate triangulateFilter;
vtkm::cont::DataSet output = triangulateFilter.Execute(input);
vtkm::io::writer::VTKDataSetWriter writer("out_tris.vtk");
writer.WriteDataSet(output);
return 0;
}

@ -1,201 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/filter/Triangulate.h>
#include <vtkm/cont/testing/Testing.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
namespace
{
// Takes input uniform grid and outputs unstructured grid of triangles
static vtkm::cont::DataSet outDataSet;
} // anonymous namespace
//
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing
//
vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
{
vtkm::cont::DataSetBuilderExplicitIterative builder;
builder.Begin();
builder.AddPoint(0, 0, 0); // 0
builder.AddPoint(1, 0, 0); // 1
builder.AddPoint(2, 0, 0); // 2
builder.AddPoint(3, 0, 0); // 3
builder.AddPoint(0, 1, 0); // 4
builder.AddPoint(1, 1, 0); // 5
builder.AddPoint(2, 1, 0); // 6
builder.AddPoint(3, 1, 0); // 7
builder.AddPoint(0, 2, 0); // 8
builder.AddPoint(1, 2, 0); // 9
builder.AddPoint(2, 2, 0); // 10
builder.AddPoint(3, 2, 0); // 11
builder.AddPoint(0, 3, 0); // 12
builder.AddPoint(3, 3, 0); // 13
builder.AddPoint(1, 4, 0); // 14
builder.AddPoint(2, 4, 0); // 15
builder.AddCell(vtkm::CELL_SHAPE_TRIANGLE);
builder.AddCellPoint(0);
builder.AddCellPoint(1);
builder.AddCellPoint(5);
builder.AddCell(vtkm::CELL_SHAPE_QUAD);
builder.AddCellPoint(1);
builder.AddCellPoint(2);
builder.AddCellPoint(6);
builder.AddCellPoint(5);
builder.AddCell(vtkm::CELL_SHAPE_QUAD);
builder.AddCellPoint(5);
builder.AddCellPoint(6);
builder.AddCellPoint(10);
builder.AddCellPoint(9);
builder.AddCell(vtkm::CELL_SHAPE_QUAD);
builder.AddCellPoint(4);
builder.AddCellPoint(5);
builder.AddCellPoint(9);
builder.AddCellPoint(8);
builder.AddCell(vtkm::CELL_SHAPE_TRIANGLE);
builder.AddCellPoint(2);
builder.AddCellPoint(3);
builder.AddCellPoint(7);
builder.AddCell(vtkm::CELL_SHAPE_QUAD);
builder.AddCellPoint(6);
builder.AddCellPoint(7);
builder.AddCellPoint(11);
builder.AddCellPoint(10);
builder.AddCell(vtkm::CELL_SHAPE_POLYGON);
builder.AddCellPoint(9);
builder.AddCellPoint(10);
builder.AddCellPoint(13);
builder.AddCellPoint(15);
builder.AddCellPoint(14);
builder.AddCellPoint(12);
return builder.Create();
}
//
// Initialize the OpenGL state
//
void initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5f, 3.5f, -0.5f, 4.5f, -1.0f, 1.0f);
}
//
// Render the output using simple OpenGL
//
void displayCall()
{
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(3.0f);
// Get cell set and the number of cells and vertices
vtkm::cont::CellSetSingleType<> cellSet;
outDataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
auto vertexArray = outDataSet.GetCoordinateSystem().GetData();
// Draw the two triangles belonging to each quad
vtkm::Float32 color[4][3] = {
{ 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 0.0f }
};
for (vtkm::Id triangle = 0; triangle < numberOfCells; triangle++)
{
vtkm::Id indx = triangle % 4;
glColor3f(color[indx][0], color[indx][1], color[indx][2]);
// Get the indices of the vertices that make up this triangle
vtkm::Id3 triIndices;
cellSet.GetIndices(triangle, triIndices);
// Get the vertex points for this triangle
vtkm::Vec3f_64 pt0 = vertexArray.GetPortalConstControl().Get(triIndices[0]);
vtkm::Vec3f_64 pt1 = vertexArray.GetPortalConstControl().Get(triIndices[1]);
vtkm::Vec3f_64 pt2 = vertexArray.GetPortalConstControl().Get(triIndices[2]);
// Draw the triangle filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_TRIANGLES);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glVertex3d(pt2[0], pt2[1], pt2[2]);
glEnd();
}
glFlush();
}
// Triangulate and render explicit grid example
int main(int argc, char* argv[])
{
auto opts =
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
vtkm::cont::Initialize(argc, argv, opts);
std::cout << "TrianguleExplicitGrid Example" << std::endl;
// Create the input uniform cell set
vtkm::cont::DataSet inDataSet = MakeTriangulateExplicitDataSet();
vtkm::cont::CellSetExplicit<> inCellSet;
inDataSet.GetCellSet(0).CopyTo(inCellSet);
// Convert 2D explicit cells to triangles
vtkm::filter::Triangulate triangulate;
outDataSet = triangulate.Execute(inDataSet);
// Render the output dataset of tets
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(100, 100);
glutCreateWindow("VTK-m Explicit Triangulate");
initializeGL();
glutDisplayFunc(displayCall);
glutMainLoop();
outDataSet.Clear();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -1,171 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/filter/Triangulate.h>
#include <vtkm/cont/testing/Testing.h>
//Suppress warnings about glut being deprecated on OSX
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
// Default size of the example
static vtkm::Id2 dims(4, 4);
static vtkm::Id cellsToDisplay = 16;
// Takes input uniform grid and outputs unstructured grid of triangles
static vtkm::cont::DataSet triDataSet;
//
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing
//
vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim)
{
vtkm::cont::DataSet dataSet;
// Place uniform grid on a set physical space so OpenGL drawing is easier
const vtkm::Id3 vdims(dim[0] + 1, dim[1] + 1, 1);
const vtkm::Vec3f_32 origin = vtkm::make_Vec(0.0f, 0.0f, 0.0f);
const vtkm::Vec3f_32 spacing = vtkm::make_Vec(
1.0f / static_cast<vtkm::Float32>(dim[0]), 1.0f / static_cast<vtkm::Float32>(dim[1]), 0.0f);
// Generate coordinate system
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
// Generate cell set
vtkm::cont::CellSetStructured<2> cellSet("cells");
cellSet.SetPointDimensions(vtkm::make_Vec(dim[0] + 1, dim[1] + 1));
dataSet.AddCellSet(cellSet);
return dataSet;
}
//
// Initialize the OpenGL state
//
void initializeGL()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5f, 1.5f, -0.5f, 1.5f, -1.0f, 1.0f);
}
//
// Render the output using simple OpenGL
//
void displayCall()
{
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(3.0f);
// Get the cellset, coordinate system and coordinate data
vtkm::cont::CellSetSingleType<> cellSet;
triDataSet.GetCellSet(0).CopyTo(cellSet);
auto vertexArray = triDataSet.GetCoordinateSystem().GetData();
// Draw the two triangles belonging to each quad
vtkm::Id triangle = 0;
vtkm::Float32 color[4][3] = {
{ 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 0.0f }
};
for (vtkm::Id quad = 0; quad < cellsToDisplay; quad++)
{
for (vtkm::Id j = 0; j < 2; j++)
{
vtkm::Id indx = triangle % 4;
glColor3f(color[indx][0], color[indx][1], color[indx][2]);
// Get the indices of the vertices that make up this triangle
vtkm::Id3 triIndices;
cellSet.GetIndices(triangle, triIndices);
// Get the vertex points for this triangle
vtkm::Vec3f_64 pt0 = vertexArray.GetPortalConstControl().Get(triIndices[0]);
vtkm::Vec3f_64 pt1 = vertexArray.GetPortalConstControl().Get(triIndices[1]);
vtkm::Vec3f_64 pt2 = vertexArray.GetPortalConstControl().Get(triIndices[2]);
// Draw the triangle filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_TRIANGLES);
glVertex3d(pt0[0], pt0[1], pt0[2]);
glVertex3d(pt1[0], pt1[1], pt1[2]);
glVertex3d(pt2[0], pt2[1], pt2[2]);
glEnd();
triangle++;
}
}
glFlush();
}
// Triangulate and render uniform grid example
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);
std::cout << "TrianguleUniformGrid Example" << std::endl;
std::cout << "Parameters are [options] [xdim ydim [# of cellsToDisplay]]" << std::endl;
std::cout << config.Usage << std::endl << std::endl;
// Set the problem size and number of cells to display from command line
if (argc >= 3)
{
dims[0] = atoi(argv[1]);
dims[1] = atoi(argv[2]);
cellsToDisplay = dims[0] * dims[1];
}
if (argc == 4)
{
cellsToDisplay = atoi(argv[3]);
}
// Create the input uniform cell set
vtkm::cont::DataSet inDataSet = MakeTriangulateTestDataSet(dims);
// Convert uniform quad to triangle
vtkm::filter::Triangulate triangulate;
triDataSet = triangulate.Execute(inDataSet);
// Render the output dataset of tets
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(100, 100);
glutCreateWindow("VTK-m Uniform Triangulate");
initializeGL();
glutDisplayFunc(displayCall);
glutMainLoop();
triDataSet.Clear();
return 0;
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif

@ -1,126 +0,0 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/ArrayHandleStreaming.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Logging.h> //for GetHumanReadableSize
#include <vtkm/filter/MarchingCubes.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherStreamingMapField.h>
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/cuda/internal/CudaAllocator.h>
namespace vtkm
{
namespace worklet
{
class SineWorklet : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn, FieldOut);
using ExecutionSignature = _2(_1, WorkIndex);
VTKM_EXEC
vtkm::Float32 operator()(vtkm::Int64 x, vtkm::Id&) const
{
return (vtkm::Sin(static_cast<vtkm::Float32>(x)));
}
};
}
}
// Run a simple worklet, and compute an isosurface
int main(int argc, char* argv[])
{
auto opts =
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
vtkm::cont::Initialize(argc, argv, opts);
vtkm::Int64 N = 4 * 512 * 512 * 512;
if (argc > 1)
{
N = atoi(argv[1]);
}
std::cout << "Testing streaming worklet on "
<< vtkm::cont::GetHumanReadableSize(N * sizeof(vtkm::Int64)) << std::endl;
std::vector<vtkm::Int64> data(N);
for (vtkm::Int64 i = 0; i < N; i++)
data[i] = i;
using DeviceTag = vtkm::cont::DeviceAdapterTagCuda;
const bool usingManagedMemory = vtkm::cont::cuda::internal::CudaAllocator::UsingManagedMemory();
vtkm::worklet::SineWorklet sineWorklet;
if (usingManagedMemory)
{
vtkm::cont::ArrayHandle<vtkm::Int64> input = vtkm::cont::make_ArrayHandle(data);
vtkm::cont::ArrayHandle<vtkm::Float32> output;
std::cout << "Testing with unified memory" << std::endl;
vtkm::worklet::DispatcherMapField<vtkm::worklet::SineWorklet> dispatcher(sineWorklet);
dispatcher.SetDevice(DeviceTag{});
//run once to get the CUDA code warmed up
dispatcher.Invoke(input, output);
vtkm::cont::Timer timer{ DeviceTag() };
timer.Start();
for (int i = 0; i < 3; ++i)
{
dispatcher.Invoke(input, output);
std::cout << output.GetPortalConstControl().Get(output.GetNumberOfValues() - 1) << std::endl;
}
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
std::cout << "Time for 3 iterations with managed memory: " << elapsedTime << std::endl;
}
if (usingManagedMemory)
{ //disable managed memory if it is enabled to get
//the correct performance numbers on GPU's that support managed memory
vtkm::cont::cuda::internal::CudaAllocator::ForceManagedMemoryOff();
}
vtkm::Id NBlocks = (N * sizeof(vtkm::Int64)) / (1 << 25);
NBlocks = std::max(vtkm::Id(1), NBlocks);
vtkm::worklet::DispatcherStreamingMapField<vtkm::worklet::SineWorklet> dispatcher(sineWorklet);
dispatcher.SetNumberOfBlocks(NBlocks);
vtkm::cont::ArrayHandle<vtkm::Int64> input = vtkm::cont::make_ArrayHandle(data);
vtkm::cont::ArrayHandle<vtkm::Float32> output;
std::cout << "Testing with streaming (without unified memory) with " << NBlocks << " blocks"
<< std::endl;
//run once to get the CUDA code warmed up
dispatcher.Invoke(input, output);
vtkm::cont::Timer timer{ DeviceTag() };
timer.Start();
for (int i = 0; i < 3; ++i)
{
dispatcher.Invoke(input, output);
std::cout << output.GetPortalConstControl().Get(output.GetNumberOfValues() - 1) << std::endl;
}
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
std::cout << "Time for 3 iterations: " << elapsedTime << std::endl;
return 0;
}

@ -89,6 +89,7 @@ set(headers
FieldRangeGlobalCompute.h
ImplicitFunctionHandle.h
Initialize.h
Invoker.h
Logging.h
MultiBlock.h
PointLocator.h

@ -22,9 +22,8 @@
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorBadDevice.h>
#include <vtkm/exec/CellLocatorBoundingIntervalHierarchyExec.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/Invoker.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
@ -87,7 +86,7 @@ void CalculatePlaneSplitCost(vtkm::IdComponent planeIndex,
vtkm::IdComponent index,
vtkm::IdComponent numTotalPlanes)
{
vtkm::worklet::Invoker invoker;
vtkm::cont::Invoker invoker;
// Make candidate split plane array
vtkm::cont::ArrayHandle<vtkm::FloatDefault> splitPlanes;
@ -182,7 +181,7 @@ IdArrayHandle CalculateSplitScatterIndices(const IdArrayHandle& cellIds,
const IdArrayHandle& leqFlags,
const IdArrayHandle& segmentIds)
{
vtkm::worklet::Invoker invoker;
vtkm::cont::Invoker invoker;
// Count total number of true flags preceding in segment
IdArrayHandle trueFlagCounts;
@ -230,7 +229,7 @@ CellLocatorBoundingIntervalHierarchy::~CellLocatorBoundingIntervalHierarchy() =
void CellLocatorBoundingIntervalHierarchy::Build()
{
vtkm::worklet::Invoker invoker;
vtkm::cont::Invoker invoker;
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
vtkm::Id numCells = cellSet.GetNumberOfCells();

@ -35,7 +35,7 @@ void CellLocatorRectilinearGrid::Build()
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
if (!coords.GetData().IsType<RectilinearType>())
throw vtkm::cont::ErrorInternal("Coordinates are not rectilinear.");
throw vtkm::cont::ErrorBadType("Coordinates are not rectilinear type.");
if (cellSet.IsSameType(Structured2DType()))
{
@ -55,7 +55,7 @@ void CellLocatorRectilinearGrid::Build()
}
else
{
throw vtkm::cont::ErrorInternal("Cells are not structured.");
throw vtkm::cont::ErrorBadType("Cells are not 2D or 3D structured type.");
}
}

@ -14,7 +14,7 @@
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/worklet/Invoker.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
@ -135,7 +135,7 @@ private:
bool DoneFlag;
};
class CountBinsL1 : public vtkm::worklet::WorkletMapPointToCell
class CountBinsL1 : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset, FieldInPoint coords, FieldOutCell bincount);
@ -158,7 +158,7 @@ private:
Grid L1Grid;
};
class FindBinsL1 : public vtkm::worklet::WorkletMapPointToCell
class FindBinsL1 : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset,
@ -218,7 +218,7 @@ private:
vtkm::FloatDefault Density;
};
class CountBinsL2 : public vtkm::worklet::WorkletMapPointToCell
class CountBinsL2 : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset,
@ -253,7 +253,7 @@ private:
Grid L1Grid;
};
class FindBinsL2 : public vtkm::worklet::WorkletMapPointToCell
class FindBinsL2 : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset,
@ -346,7 +346,7 @@ namespace cont
///
VTKM_CONT void CellLocatorUniformBins::Build()
{
vtkm::worklet::Invoker invoke;
vtkm::cont::Invoker invoke;
auto cellset = this->GetCellSet();
const auto& coords = this->GetCoordinates();

@ -99,8 +99,8 @@ private:
using CellSetP2CExecType =
decltype(std::declval<CellSetType>().PrepareForInput(DeviceAdapter{},
vtkm::TopologyElementTagPoint{},
vtkm::TopologyElementTagCell{}));
vtkm::TopologyElementTagCell{},
vtkm::TopologyElementTagPoint{}));
// TODO: This function may return false positives for non 3D cells as the
// tests are done on the projection of the point on the cell. Extra checks
@ -140,8 +140,8 @@ public:
, CellCount(cellCount.PrepareForInput(DeviceAdapter{}))
, CellIds(cellIds.PrepareForInput(DeviceAdapter{}))
, CellSet(cellSet.PrepareForInput(DeviceAdapter{},
vtkm::TopologyElementTagPoint{},
vtkm::TopologyElementTagCell{}))
vtkm::TopologyElementTagCell{},
vtkm::TopologyElementTagPoint{}))
, Coords(coords.GetData().PrepareForInput(DeviceAdapter{}))
{
}

@ -33,7 +33,7 @@ void CellLocatorUniformGrid::Build()
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
if (!coords.GetData().IsType<UniformType>())
throw vtkm::cont::ErrorInternal("Coordinates are not uniform.");
throw vtkm::cont::ErrorBadType("Coordinates are not uniform type.");
if (cellSet.IsSameType(Structured2DType()))
{
@ -50,26 +50,26 @@ void CellLocatorUniformGrid::Build()
}
else
{
throw vtkm::cont::ErrorInternal("Cells are not structured.");
throw vtkm::cont::ErrorBadType("Cells are not 2D or 3D structured type.");
}
UniformType uniformCoords = coords.GetData().Cast<UniformType>();
this->Origin = uniformCoords.GetPortalConstControl().GetOrigin();
vtkm::Vec<vtkm::FloatDefault, 3> spacing = uniformCoords.GetPortalConstControl().GetSpacing();
vtkm::Vec<vtkm::FloatDefault, 3> unitLength;
unitLength[0] = static_cast<vtkm::FloatDefault>(PointDims[0] - 1);
unitLength[1] = static_cast<vtkm::FloatDefault>(PointDims[1] - 1);
unitLength[2] = static_cast<vtkm::FloatDefault>(PointDims[2] - 1);
vtkm::Vec3f spacing = uniformCoords.GetPortalConstControl().GetSpacing();
vtkm::Vec3f unitLength;
unitLength[0] = static_cast<vtkm::FloatDefault>(this->PointDims[0] - 1);
unitLength[1] = static_cast<vtkm::FloatDefault>(this->PointDims[1] - 1);
unitLength[2] = static_cast<vtkm::FloatDefault>(this->PointDims[2] - 1);
this->MaxPoint = Origin + spacing * unitLength;
this->MaxPoint = this->Origin + spacing * unitLength;
this->InvSpacing[0] = 1.f / spacing[0];
this->InvSpacing[1] = 1.f / spacing[1];
this->InvSpacing[2] = 1.f / spacing[2];
this->CellDims[0] = PointDims[0] - 1;
this->CellDims[1] = PointDims[1] - 1;
this->CellDims[2] = PointDims[2] - 1;
this->CellDims[0] = this->PointDims[0] - 1;
this->CellDims[1] = this->PointDims[1] - 1;
this->CellDims[2] = this->PointDims[2] - 1;
}
namespace

@ -34,9 +34,9 @@ protected:
private:
vtkm::Id3 CellDims;
vtkm::Id3 PointDims;
vtkm::Vec<vtkm::FloatDefault, 3> Origin;
vtkm::Vec<vtkm::FloatDefault, 3> InvSpacing;
vtkm::Vec<vtkm::FloatDefault, 3> MaxPoint;
vtkm::Vec3f Origin;
vtkm::Vec3f InvSpacing;
vtkm::Vec3f MaxPoint;
bool Is3D = true;
mutable vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator> ExecutionObjectHandle;

@ -28,7 +28,7 @@ namespace cont
namespace detail
{
template <typename CellSetType, typename FromTopology, typename ToTopology>
template <typename CellSetType, typename VisitTopology, typename IncidentTopology>
struct CellSetExplicitConnectivityChooser
{
using ConnectivityType = vtkm::cont::internal::ConnectivityExplicitInternals<>;
@ -63,13 +63,13 @@ class VTKM_ALWAYS_EXPORT CellSetExplicit : public CellSet
ConnectivityStorageTag,
OffsetsStorageTag>;
template <typename FromTopology, typename ToTopology>
template <typename VisitTopology, typename IncidentTopology>
struct ConnectivityChooser
{
using ConnectivityType =
typename detail::CellSetExplicitConnectivityChooser<Thisclass,
FromTopology,
ToTopology>::ConnectivityType;
VisitTopology,
IncidentTopology>::ConnectivityType;
using ShapeArrayType = typename ConnectivityType::ShapeArrayType;
using NumIndicesArrayType = typename ConnectivityType::NumIndicesArrayType;
@ -77,25 +77,26 @@ class VTKM_ALWAYS_EXPORT CellSetExplicit : public CellSet
using IndexOffsetArrayType = typename ConnectivityType::IndexOffsetArrayType;
};
using PointToCellInternalsType =
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ConnectivityType;
using CellToPointInternalsType =
using VisitCellsWithPointsInternalsType =
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ConnectivityType;
using VisitPointsWithCellsInternalsType =
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ConnectivityType;
public:
using SchedulingRangeType = vtkm::Id;
//point to cell is used when iterating cells and asking for point properties
using PointToCellConnectivityType =
ConnectivityChooser<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>;
using VisitCellsWithPointsConnectivityType =
ConnectivityChooser<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>;
using ShapeArrayType = typename PointToCellConnectivityType::ShapeArrayType;
using NumIndicesArrayType = typename PointToCellConnectivityType::NumIndicesArrayType;
using ConnectivityArrayType = typename PointToCellConnectivityType::ConnectivityArrayType;
using IndexOffsetArrayType = typename PointToCellConnectivityType::IndexOffsetArrayType;
using ShapeArrayType = typename VisitCellsWithPointsConnectivityType::ShapeArrayType;
using NumIndicesArrayType = typename VisitCellsWithPointsConnectivityType::NumIndicesArrayType;
using ConnectivityArrayType =
typename VisitCellsWithPointsConnectivityType::ConnectivityArrayType;
using IndexOffsetArrayType = typename VisitCellsWithPointsConnectivityType::IndexOffsetArrayType;
VTKM_CONT CellSetExplicit(const std::string& name = std::string());
VTKM_CONT CellSetExplicit(const Thisclass& src);
@ -148,14 +149,14 @@ public:
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>& offsets =
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>());
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
struct ExecutionTypes
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
using ConnectivityTypes = ConnectivityChooser<FromTopology, ToTopology>;
using ConnectivityTypes = ConnectivityChooser<VisitTopology, IncidentTopology>;
using ShapePortalType = typename ConnectivityTypes::ShapeArrayType::template ExecutionTypes<
DeviceAdapter>::PortalConst;
@ -175,82 +176,85 @@ public:
IndexOffsetPortalType>;
};
template <typename Device, typename FromTopology, typename ToTopology>
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType
PrepareForInput(Device, FromTopology, ToTopology) const;
template <typename Device, typename VisitTopology, typename IncidentTopology>
typename ExecutionTypes<Device, VisitTopology, IncidentTopology>::ExecObjectType
PrepareForInput(Device, VisitTopology, IncidentTopology) const;
template <typename FromTopology, typename ToTopology>
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
GetShapesArray(FromTopology, ToTopology) const;
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT const typename ConnectivityChooser<VisitTopology, IncidentTopology>::ShapeArrayType&
GetShapesArray(VisitTopology, IncidentTopology) const;
template <typename FromTopology, typename ToTopology>
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
GetNumIndicesArray(FromTopology, ToTopology) const;
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT const typename ConnectivityChooser<VisitTopology,
IncidentTopology>::NumIndicesArrayType&
GetNumIndicesArray(VisitTopology, IncidentTopology) const;
template <typename FromTopology, typename ToTopology>
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
GetConnectivityArray(FromTopology, ToTopology) const;
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT const typename ConnectivityChooser<VisitTopology,
IncidentTopology>::ConnectivityArrayType&
GetConnectivityArray(VisitTopology, IncidentTopology) const;
template <typename FromTopology, typename ToTopology>
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
GetIndexOffsetArray(FromTopology, ToTopology) const;
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT const typename ConnectivityChooser<VisitTopology,
IncidentTopology>::IndexOffsetArrayType&
GetIndexOffsetArray(VisitTopology, IncidentTopology) const;
// Can be used to check if e.g. CellToPoint table is built.
template <typename FromTopology, typename ToTopology>
VTKM_CONT bool HasConnectivity(FromTopology from, ToTopology to) const
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT bool HasConnectivity(VisitTopology from, IncidentTopology to) const
{
return this->HasConnectivityImpl(from, to);
}
// Can be used to reset a connectivity table, mostly useful for benchmarking.
template <typename FromTopology, typename ToTopology>
VTKM_CONT void ResetConnectivity(FromTopology from, ToTopology to)
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT void ResetConnectivity(VisitTopology from, IncidentTopology to)
{
this->ResetConnectivityImpl(from, to);
}
protected:
VTKM_CONT void BuildConnectivity(vtkm::cont::DeviceAdapterId,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const;
VTKM_CONT void BuildConnectivity(vtkm::cont::DeviceAdapterId,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const;
VTKM_CONT bool HasConnectivityImpl(vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
return this->Data->PointToCell.ElementsValid;
}
VTKM_CONT void BuildConnectivity(vtkm::cont::DeviceAdapterId,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const;
VTKM_CONT bool HasConnectivityImpl(vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
{
return this->Data->CellToPoint.ElementsValid;
return this->Data->VisitCellsWithPoints.ElementsValid;
}
VTKM_CONT void ResetConnectivityImpl(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell)
VTKM_CONT bool HasConnectivityImpl(vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
return this->Data->VisitPointsWithCells.ElementsValid;
}
VTKM_CONT void ResetConnectivityImpl(vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint)
{
// Reset entire cell set
this->Data->PointToCell = PointToCellInternalsType{};
this->Data->CellToPoint = CellToPointInternalsType{};
this->Data->VisitCellsWithPoints = VisitCellsWithPointsInternalsType{};
this->Data->VisitPointsWithCells = VisitPointsWithCellsInternalsType{};
this->Data->ConnectivityAdded = -1;
this->Data->NumberOfCellsAdded = -1;
this->Data->NumberOfPoints = 0;
}
VTKM_CONT void ResetConnectivityImpl(vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint)
VTKM_CONT void ResetConnectivityImpl(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell)
{
this->Data->CellToPoint = CellToPointInternalsType{};
this->Data->VisitPointsWithCells = VisitPointsWithCellsInternalsType{};
}
// Store internals in a shared pointer so shallow copies stay consistent.
// See #2268.
struct Internals
{
PointToCellInternalsType PointToCell;
CellToPointInternalsType CellToPoint;
VisitCellsWithPointsInternalsType VisitCellsWithPoints;
VisitPointsWithCellsInternalsType VisitPointsWithCells;
// These are used in the AddCell and related methods to incrementally add
// cells. They need to be protected as subclasses of CellSetExplicit
@ -271,28 +275,28 @@ protected:
std::shared_ptr<Internals> Data;
private:
const PointToCellInternalsType& GetConnectivity(vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
return this->Data->PointToCell;
}
const PointToCellInternalsType& GetConnectivity(vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell)
{
return this->Data->PointToCell;
}
const CellToPointInternalsType& GetConnectivity(vtkm::TopologyElementTagCell,
const VisitCellsWithPointsInternalsType& GetConnectivity(vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
{
return this->Data->CellToPoint;
return this->Data->VisitCellsWithPoints;
}
const CellToPointInternalsType& GetConnectivity(vtkm::TopologyElementTagCell,
const VisitCellsWithPointsInternalsType& GetConnectivity(vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint)
{
return this->Data->CellToPoint;
return this->Data->VisitCellsWithPoints;
}
const VisitPointsWithCellsInternalsType& GetConnectivity(vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
return this->Data->VisitPointsWithCells;
}
const VisitPointsWithCellsInternalsType& GetConnectivity(vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell)
{
return this->Data->VisitPointsWithCells;
}
};
@ -302,8 +306,8 @@ namespace detail
template <typename Storage1, typename Storage2, typename Storage3, typename Storage4>
struct CellSetExplicitConnectivityChooser<
vtkm::cont::CellSetExplicit<Storage1, Storage2, Storage3, Storage4>,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>
{
using ConnectivityType =
vtkm::cont::internal::ConnectivityExplicitInternals<Storage1, Storage2, Storage3, Storage4>;
@ -311,8 +315,8 @@ struct CellSetExplicitConnectivityChooser<
template <typename CellSetType>
struct CellSetExplicitConnectivityChooser<CellSetType,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>
{
//only specify the shape type as it will be constant as everything
//is a vertex. otherwise use the defaults.
@ -376,13 +380,13 @@ public:
vtkmdiy::save(bb, cs.GetName());
vtkmdiy::save(bb, cs.GetNumberOfPoints());
vtkmdiy::save(
bb, cs.GetShapesArray(vtkm::TopologyElementTagPoint{}, vtkm::TopologyElementTagCell{}));
bb, cs.GetShapesArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}));
vtkmdiy::save(
bb, cs.GetNumIndicesArray(vtkm::TopologyElementTagPoint{}, vtkm::TopologyElementTagCell{}));
bb, cs.GetNumIndicesArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}));
vtkmdiy::save(
bb, cs.GetConnectivityArray(vtkm::TopologyElementTagPoint{}, vtkm::TopologyElementTagCell{}));
bb, cs.GetConnectivityArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}));
vtkmdiy::save(
bb, cs.GetIndexOffsetArray(vtkm::TopologyElementTagPoint{}, vtkm::TopologyElementTagCell{}));
bb, cs.GetIndexOffsetArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}));
}
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)

@ -104,10 +104,10 @@ void CellSetExplicit<ShapeStorageTag,
OffsetsStorageTag>::PrintSummary(std::ostream& out) const
{
out << " ExplicitCellSet: " << this->Name << std::endl;
out << " PointToCell: " << std::endl;
this->Data->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->Data->CellToPoint.PrintSummary(out);
out << " VisitCellsWithPoints: " << std::endl;
this->Data->VisitCellsWithPoints.PrintSummary(out);
out << " VisitPointsWithCells: " << std::endl;
this->Data->VisitPointsWithCells.PrintSummary(out);
}
template <typename ShapeStorageTag,
@ -119,8 +119,8 @@ void CellSetExplicit<ShapeStorageTag,
ConnectivityStorageTag,
OffsetStorageTag>::ReleaseResourcesExecution()
{
this->Data->PointToCell.ReleaseResourcesExecution();
this->Data->CellToPoint.ReleaseResourcesExecution();
this->Data->VisitCellsWithPoints.ReleaseResourcesExecution();
this->Data->VisitPointsWithCells.ReleaseResourcesExecution();
}
//----------------------------------------------------------------------------
@ -134,7 +134,7 @@ vtkm::Id CellSetExplicit<ShapeStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::GetNumberOfCells() const
{
return this->Data->PointToCell.GetNumberOfElements();
return this->Data->VisitCellsWithPoints.GetNumberOfElements();
}
template <typename ShapeStorageTag,
@ -224,7 +224,7 @@ VTKM_CONT vtkm::IdComponent
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
GetNumberOfPointsInCell(vtkm::Id cellIndex) const
{
return this->Data->PointToCell.NumIndices.GetPortalConstControl().Get(cellIndex);
return this->Data->VisitCellsWithPoints.NumIndices.GetPortalConstControl().Get(cellIndex);
}
template <typename ShapeStorageTag,
@ -236,7 +236,7 @@ VTKM_CONT vtkm::UInt8 CellSetExplicit<ShapeStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::GetCellShape(vtkm::Id cellIndex) const
{
return this->Data->PointToCell.Shapes.GetPortalConstControl().Get(cellIndex);
return this->Data->VisitCellsWithPoints.Shapes.GetPortalConstControl().Get(cellIndex);
}
template <typename ShapeStorageTag,
@ -248,12 +248,12 @@ VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const
{
this->Data->PointToCell.BuildIndexOffsets(vtkm::cont::DeviceAdapterTagAny{});
this->Data->VisitCellsWithPoints.BuildIndexOffsets(vtkm::cont::DeviceAdapterTagAny{});
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
vtkm::Id start = this->Data->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
vtkm::Id start = this->Data->VisitCellsWithPoints.IndexOffsets.GetPortalConstControl().Get(index);
for (vtkm::IdComponent i = 0; i < numIndices && i < ItemTupleLength; i++)
{
ids[i] = this->Data->PointToCell.Connectivity.GetPortalConstControl().Get(start + i);
ids[i] = this->Data->VisitCellsWithPoints.Connectivity.GetPortalConstControl().Get(start + i);
}
}
@ -265,16 +265,18 @@ VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const
{
this->Data->PointToCell.BuildIndexOffsets(vtkm::cont::DeviceAdapterTagAny{});
this->Data->VisitCellsWithPoints.BuildIndexOffsets(vtkm::cont::DeviceAdapterTagAny{});
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
ids.Allocate(numIndices);
vtkm::Id start = this->Data->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
vtkm::Id start = this->Data->VisitCellsWithPoints.IndexOffsets.GetPortalConstControl().Get(index);
vtkm::cont::ArrayHandle<vtkm::Id>::PortalControl idPortal = ids.GetPortalControl();
auto PtCellPortal = this->Data->PointToCell.Connectivity.GetPortalConstControl();
auto PtCellPortal = this->Data->VisitCellsWithPoints.Connectivity.GetPortalConstControl();
for (vtkm::IdComponent i = 0; i < numIndices && i < numIndices; i++)
{
idPortal.Set(i, PtCellPortal.Get(start + i));
}
}
//----------------------------------------------------------------------------
@ -288,10 +290,10 @@ VTKM_CONT void CellSetExplicit<ShapeStorageTag,
OffsetsStorageTag>::PrepareToAddCells(vtkm::Id numCells,
vtkm::Id connectivityMaxLen)
{
this->Data->PointToCell.Shapes.Allocate(numCells);
this->Data->PointToCell.NumIndices.Allocate(numCells);
this->Data->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->Data->PointToCell.IndexOffsets.Allocate(numCells);
this->Data->VisitCellsWithPoints.Shapes.Allocate(numCells);
this->Data->VisitCellsWithPoints.NumIndices.Allocate(numCells);
this->Data->VisitCellsWithPoints.Connectivity.Allocate(connectivityMaxLen);
this->Data->VisitCellsWithPoints.IndexOffsets.Allocate(numCells);
this->Data->NumberOfCellsAdded = 0;
this->Data->ConnectivityAdded = 0;
}
@ -314,27 +316,28 @@ CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, O
throw vtkm::cont::ErrorBadValue("Not enough indices given to CellSetSingleType::AddCell.");
}
if (this->Data->NumberOfCellsAdded >= this->Data->PointToCell.Shapes.GetNumberOfValues())
if (this->Data->NumberOfCellsAdded >= this->Data->VisitCellsWithPoints.Shapes.GetNumberOfValues())
{
throw vtkm::cont::ErrorBadValue("Added more cells then expected.");
}
if (this->Data->ConnectivityAdded + numVertices >
this->Data->PointToCell.Connectivity.GetNumberOfValues())
this->Data->VisitCellsWithPoints.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorBadValue(
"Connectivity increased passed estimated maximum connectivity.");
}
this->Data->PointToCell.Shapes.GetPortalControl().Set(this->Data->NumberOfCellsAdded, cellType);
this->Data->PointToCell.NumIndices.GetPortalControl().Set(this->Data->NumberOfCellsAdded,
this->Data->VisitCellsWithPoints.Shapes.GetPortalControl().Set(this->Data->NumberOfCellsAdded,
cellType);
this->Data->VisitCellsWithPoints.NumIndices.GetPortalControl().Set(this->Data->NumberOfCellsAdded,
numVertices);
for (vtkm::IdComponent iVec = 0; iVec < numVertices; ++iVec)
{
this->Data->PointToCell.Connectivity.GetPortalControl().Set(
this->Data->VisitCellsWithPoints.Connectivity.GetPortalControl().Set(
this->Data->ConnectivityAdded + iVec, Traits::GetComponent(ids, iVec));
}
this->Data->PointToCell.IndexOffsets.GetPortalControl().Set(this->Data->NumberOfCellsAdded,
this->Data->ConnectivityAdded);
this->Data->VisitCellsWithPoints.IndexOffsets.GetPortalControl().Set(
this->Data->NumberOfCellsAdded, this->Data->ConnectivityAdded);
this->Data->NumberOfCellsAdded++;
this->Data->ConnectivityAdded += numVertices;
}
@ -349,9 +352,9 @@ VTKM_CONT void CellSetExplicit<ShapeStorageTag,
OffsetsStorageTag>::CompleteAddingCells(vtkm::Id numPoints)
{
this->Data->NumberOfPoints = numPoints;
this->Data->PointToCell.Connectivity.Shrink(this->Data->ConnectivityAdded);
this->Data->PointToCell.ElementsValid = true;
this->Data->PointToCell.IndexOffsetsValid = true;
this->Data->VisitCellsWithPoints.Connectivity.Shrink(this->Data->ConnectivityAdded);
this->Data->VisitCellsWithPoints.ElementsValid = true;
this->Data->VisitCellsWithPoints.IndexOffsetsValid = true;
if (this->Data->NumberOfCellsAdded != this->GetNumberOfCells())
{
@ -377,20 +380,20 @@ CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, O
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>& offsets)
{
this->Data->NumberOfPoints = numPoints;
this->Data->PointToCell.Shapes = cellTypes;
this->Data->PointToCell.NumIndices = numIndices;
this->Data->PointToCell.Connectivity = connectivity;
this->Data->VisitCellsWithPoints.Shapes = cellTypes;
this->Data->VisitCellsWithPoints.NumIndices = numIndices;
this->Data->VisitCellsWithPoints.Connectivity = connectivity;
this->Data->PointToCell.ElementsValid = true;
this->Data->VisitCellsWithPoints.ElementsValid = true;
if (offsets.GetNumberOfValues() == cellTypes.GetNumberOfValues())
{
this->Data->PointToCell.IndexOffsets = offsets;
this->Data->PointToCell.IndexOffsetsValid = true;
this->Data->VisitCellsWithPoints.IndexOffsets = offsets;
this->Data->VisitCellsWithPoints.IndexOffsetsValid = true;
}
else
{
this->Data->PointToCell.IndexOffsetsValid = false;
this->Data->VisitCellsWithPoints.IndexOffsetsValid = false;
if (offsets.GetNumberOfValues() != 0)
{
throw vtkm::cont::ErrorBadValue("Explicit cell offsets array unexpected size. "
@ -398,7 +401,7 @@ CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, O
}
}
this->ResetConnectivity(TopologyElementTagCell{}, TopologyElementTagPoint{});
this->ResetConnectivity(TopologyElementTagPoint{}, TopologyElementTagCell{});
}
//----------------------------------------------------------------------------
@ -407,19 +410,22 @@ template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetsStorageTag>
template <typename Device, typename FromTopology, typename ToTopology>
template <typename Device, typename VisitTopology, typename IncidentTopology>
auto CellSetExplicit<ShapeStorageTag,
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::PrepareForInput(Device, FromTopology, ToTopology) const ->
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType
OffsetsStorageTag>::PrepareForInput(Device,
VisitTopology,
IncidentTopology) const ->
typename ExecutionTypes<Device, VisitTopology, IncidentTopology>::ExecObjectType
{
this->BuildConnectivity(Device{}, FromTopology(), ToTopology());
this->BuildConnectivity(Device{}, VisitTopology(), IncidentTopology());
const auto& connectivity = this->GetConnectivity(FromTopology(), ToTopology());
const auto& connectivity = this->GetConnectivity(VisitTopology(), IncidentTopology());
VTKM_ASSERT(connectivity.ElementsValid);
using ExecObjType = typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType;
using ExecObjType =
typename ExecutionTypes<Device, VisitTopology, IncidentTopology>::ExecObjectType;
return ExecObjType(connectivity.Shapes.PrepareForInput(Device()),
connectivity.NumIndices.PrepareForInput(Device()),
connectivity.Connectivity.PrepareForInput(Device()),
@ -432,63 +438,64 @@ template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetsStorageTag>
template <typename FromTopology, typename ToTopology>
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::GetShapesArray(FromTopology, ToTopology) const
-> const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
OffsetsStorageTag>::GetShapesArray(VisitTopology,
IncidentTopology) const -> const
typename ConnectivityChooser<VisitTopology, IncidentTopology>::ShapeArrayType&
{
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
return this->GetConnectivity(FromTopology(), ToTopology()).Shapes;
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, VisitTopology(), IncidentTopology());
return this->GetConnectivity(VisitTopology(), IncidentTopology()).Shapes;
}
template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetsStorageTag>
template <typename FromTopology, typename ToTopology>
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::GetNumIndicesArray(FromTopology,
ToTopology) const -> const
typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
OffsetsStorageTag>::GetNumIndicesArray(VisitTopology,
IncidentTopology) const
-> const typename ConnectivityChooser<VisitTopology, IncidentTopology>::NumIndicesArrayType&
{
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
return this->GetConnectivity(FromTopology(), ToTopology()).NumIndices;
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, VisitTopology(), IncidentTopology());
return this->GetConnectivity(VisitTopology(), IncidentTopology()).NumIndices;
}
template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetsStorageTag>
template <typename FromTopology, typename ToTopology>
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::GetConnectivityArray(FromTopology,
ToTopology) const -> const
typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
OffsetsStorageTag>::GetConnectivityArray(VisitTopology,
IncidentTopology) const
-> const typename ConnectivityChooser<VisitTopology, IncidentTopology>::ConnectivityArrayType&
{
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
return this->GetConnectivity(FromTopology(), ToTopology()).Connectivity;
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, VisitTopology(), IncidentTopology());
return this->GetConnectivity(VisitTopology(), IncidentTopology()).Connectivity;
}
template <typename ShapeStorageTag,
typename NumIndicesStorageTag,
typename ConnectivityStorageTag,
typename OffsetsStorageTag>
template <typename FromTopology, typename ToTopology>
template <typename VisitTopology, typename IncidentTopology>
VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
NumIndicesStorageTag,
ConnectivityStorageTag,
OffsetsStorageTag>::GetIndexOffsetArray(FromTopology,
ToTopology) const -> const
typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
OffsetsStorageTag>::GetIndexOffsetArray(VisitTopology,
IncidentTopology) const
-> const typename ConnectivityChooser<VisitTopology, IncidentTopology>::IndexOffsetArrayType&
{
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, VisitTopology(), IncidentTopology());
return this->GetConnectivity(VisitTopology(), IncidentTopology()).IndexOffsets;
}
//----------------------------------------------------------------------------
@ -521,13 +528,13 @@ void CellSetExplicit<ShapeStorageTag,
}
// TODO: implement actual deep-copy of the arrays
auto pt = vtkm::TopologyElementTagPoint{};
auto ct = vtkm::TopologyElementTagCell{};
auto pt = vtkm::TopologyElementTagPoint{};
this->Fill(other->GetNumberOfPoints(),
other->GetShapesArray(pt, ct),
other->GetNumIndicesArray(pt, ct),
other->GetConnectivityArray(pt, ct),
other->GetIndexOffsetArray(pt, ct));
other->GetShapesArray(ct, pt),
other->GetNumIndicesArray(ct, pt),
other->GetConnectivityArray(ct, pt),
other->GetIndexOffsetArray(ct, pt));
}
//----------------------------------------------------------------------------
@ -535,32 +542,33 @@ void CellSetExplicit<ShapeStorageTag,
namespace detail
{
template <typename PointToCellConnectivity>
struct BuildPointToCellConnectivityFunctor
template <typename VisitCellsWithPointsConnectivity>
struct BuildVisitCellsWithPointsConnectivityFunctor
{
explicit BuildPointToCellConnectivityFunctor(PointToCellConnectivity& pointToCell)
: PointToCell(&pointToCell)
explicit BuildVisitCellsWithPointsConnectivityFunctor(VisitCellsWithPointsConnectivity& obj)
: VisitCellsWithPoints(&obj)
{
}
template <typename Device>
bool operator()(Device) const
{
this->PointToCell->BuildIndexOffsets(Device());
this->VisitCellsWithPoints->BuildIndexOffsets(Device());
return true;
}
PointToCellConnectivity* PointToCell;
VisitCellsWithPointsConnectivity* VisitCellsWithPoints;
};
template <typename PointToCellConnectivity, typename CellToPointConnectivity>
struct BuildCellToPointConnectivityFunctor
template <typename VisitCellsWithPointsConnectivity, typename VisitPointsWithCellsConnectivity>
struct BuildVisitPointsWithCellsConnectivityFunctor
{
BuildCellToPointConnectivityFunctor(PointToCellConnectivity& pointToCell,
CellToPointConnectivity& cellToPoint,
BuildVisitPointsWithCellsConnectivityFunctor(
VisitCellsWithPointsConnectivity& visitCellsWithPoints,
VisitPointsWithCellsConnectivity& visitPointsWithCells,
vtkm::Id numberOfPoints)
: PointToCell(&pointToCell)
, CellToPoint(&cellToPoint)
: VisitCellsWithPoints(&visitCellsWithPoints)
, VisitPointsWithCells(&visitPointsWithCells)
, NumberOfPoints(numberOfPoints)
{
}
@ -568,15 +576,15 @@ struct BuildCellToPointConnectivityFunctor
template <typename Device>
bool operator()(Device) const
{
this->PointToCell->BuildIndexOffsets(Device());
internal::ComputeCellToPointConnectivity(
*this->CellToPoint, *this->PointToCell, this->NumberOfPoints, Device());
this->CellToPoint->BuildIndexOffsets(Device());
this->VisitCellsWithPoints->BuildIndexOffsets(Device());
internal::ComputeVisitPointsWithCellsConnectivity(
*this->VisitPointsWithCells, *this->VisitCellsWithPoints, this->NumberOfPoints, Device());
this->VisitPointsWithCells->BuildIndexOffsets(Device());
return true;
}
PointToCellConnectivity* PointToCell;
CellToPointConnectivity* CellToPoint;
VisitCellsWithPointsConnectivity* VisitCellsWithPoints;
VisitPointsWithCellsConnectivity* VisitPointsWithCells;
vtkm::Id NumberOfPoints;
};
@ -589,19 +597,20 @@ template <typename ShapeStorageTag,
VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
BuildConnectivity(vtkm::cont::DeviceAdapterId device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
{
using PointToCellConnectivity =
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ConnectivityType;
using VisitCellsWithPointsConnectivity =
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ConnectivityType;
VTKM_ASSERT(this->Data->PointToCell.ElementsValid);
if (!this->Data->PointToCell.IndexOffsetsValid)
VTKM_ASSERT(this->Data->VisitCellsWithPoints.ElementsValid);
if (!this->Data->VisitCellsWithPoints.IndexOffsetsValid)
{
auto self = const_cast<Thisclass*>(this);
auto functor =
detail::BuildPointToCellConnectivityFunctor<PointToCellConnectivity>(self->Data->PointToCell);
detail::BuildVisitCellsWithPointsConnectivityFunctor<VisitCellsWithPointsConnectivity>(
self->Data->VisitCellsWithPoints);
if (!vtkm::cont::TryExecuteOnDevice(device, functor))
{
throw vtkm::cont::ErrorExecution("Failed to run BuildConnectivity.");
@ -616,22 +625,26 @@ template <typename ShapeStorageTag,
VTKM_CONT void
CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag, OffsetsStorageTag>::
BuildConnectivity(vtkm::cont::DeviceAdapterId device,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
using PointToCellConnectivity =
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ConnectivityType;
using CellToPointConnectivity =
using VisitCellsWithPointsConnectivity =
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ConnectivityType;
using VisitPointsWithCellsConnectivity =
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ConnectivityType;
if (!this->Data->CellToPoint.ElementsValid || !this->Data->CellToPoint.IndexOffsetsValid)
if (!this->Data->VisitPointsWithCells.ElementsValid ||
!this->Data->VisitPointsWithCells.IndexOffsetsValid)
{
auto self = const_cast<Thisclass*>(this);
auto functor =
detail::BuildCellToPointConnectivityFunctor<PointToCellConnectivity, CellToPointConnectivity>(
self->Data->PointToCell, self->Data->CellToPoint, this->Data->NumberOfPoints);
detail::BuildVisitPointsWithCellsConnectivityFunctor<VisitCellsWithPointsConnectivity,
VisitPointsWithCellsConnectivity>(
self->Data->VisitCellsWithPoints,
self->Data->VisitPointsWithCells,
this->Data->NumberOfPoints);
if (!vtkm::cont::TryExecuteOnDevice(device, functor))
{
throw vtkm::cont::ErrorExecution("Failed to run BuildConnectivity.");

@ -95,8 +95,8 @@ vtkm::IdComponent CellSetExtrude::GetNumberOfPointsInCell(vtkm::Id) const
void CellSetExtrude::GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const
{
auto conn = this->PrepareForInput(vtkm::cont::DeviceAdapterTagSerial{},
vtkm::TopologyElementTagPoint{},
vtkm::TopologyElementTagCell{});
vtkm::TopologyElementTagCell{},
vtkm::TopologyElementTagPoint{});
auto indices = conn.GetIndices(id);
for (int i = 0; i < 6; ++i)
{

@ -16,9 +16,9 @@
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/ArrayHandleExtrudeCoords.h>
#include <vtkm/cont/CellSet.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/exec/ConnectivityExtrude.h>
#include <vtkm/exec/arg/ThreadIndicesExtrude.h>
#include <vtkm/worklet/Invoker.h>
#include <vtkm/worklet/WorkletMapField.h>
namespace vtkm
@ -68,30 +68,30 @@ public:
template <typename DeviceAdapter>
using ConnectivityC2P = vtkm::exec::ReverseConnectivityExtrude<DeviceAdapter>;
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
struct ExecutionTypes;
template <typename DeviceAdapter>
struct ExecutionTypes<DeviceAdapter, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
struct ExecutionTypes<DeviceAdapter, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
{
using ExecObjectType = ConnectivityP2C<DeviceAdapter>;
};
template <typename DeviceAdapter>
struct ExecutionTypes<DeviceAdapter, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
struct ExecutionTypes<DeviceAdapter, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
{
using ExecObjectType = ConnectivityC2P<DeviceAdapter>;
};
template <typename Device>
ConnectivityP2C<Device> PrepareForInput(Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const;
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const;
template <typename Device>
ConnectivityC2P<Device> PrepareForInput(Device,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const;
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const;
private:
template <typename Device>

@ -50,7 +50,7 @@ namespace cont
template <typename Device>
VTKM_CONT void CellSetExtrude::BuildReverseConnectivity(Device)
{
vtkm::worklet::Invoker invoke(Device{});
vtkm::cont::Invoker invoke(Device{});
// create a mapping of where each key is the point id and the value
// is the cell id. We
@ -87,8 +87,8 @@ VTKM_CONT void CellSetExtrude::BuildReverseConnectivity(Device)
template <typename Device>
CellSetExtrude::ConnectivityP2C<Device> CellSetExtrude::PrepareForInput(
Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
{
return ConnectivityP2C<Device>(this->Connectivity.PrepareForInput(Device{}),
this->NextNode.PrepareForInput(Device{}),
@ -102,8 +102,8 @@ CellSetExtrude::ConnectivityP2C<Device> CellSetExtrude::PrepareForInput(
template <typename Device>
VTKM_CONT CellSetExtrude::ConnectivityC2P<Device> CellSetExtrude::PrepareForInput(
Device,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
if (!this->ReverseConnectivityBuilt)
{

@ -35,10 +35,10 @@ namespace cont
namespace internal
{
class CellSetPermutationPointToCellHelpers
class CellSetPermutationVisitCellsWithPointsHelpers
{
public:
struct WriteNumIndices : public vtkm::worklet::WorkletMapPointToCell
struct WriteNumIndices : public vtkm::worklet::WorkletVisitCellsWithPoints
{
using ControlSignature = void(CellSetIn cellset, FieldOutCell numIndices);
using ExecutionSignature = void(PointCount, _2);
@ -50,7 +50,7 @@ public:
}
};
struct WriteConnectivity : public vtkm::worklet::WorkletMapPointToCell
struct WriteConnectivity : public vtkm::worklet::WorkletVisitCellsWithPoints
{
using ControlSignature = void(CellSetIn cellset, FieldOutCell connectivity);
using ExecutionSignature = void(PointCount, PointIndices, _2);
@ -112,7 +112,7 @@ public:
// default for CellSetPermutations of any cell type
template <typename CellSetPermutationType>
class CellSetPermutationPointToCell
class CellSetPermutationVisitCellsWithPoints
{
public:
using ConnectivityArrays = vtkm::cont::internal::ConnectivityExplicitInternals<>;
@ -123,10 +123,11 @@ public:
ConnectivityArrays conn;
vtkm::Id connectivityLength = 0;
conn.NumIndices = CellSetPermutationPointToCellHelpers::GetNumIndicesArray(cellset, Device{});
conn.IndexOffsets = CellSetPermutationPointToCellHelpers::GetIndexOffsetsArray(
conn.NumIndices =
CellSetPermutationVisitCellsWithPointsHelpers::GetNumIndicesArray(cellset, Device{});
conn.IndexOffsets = CellSetPermutationVisitCellsWithPointsHelpers::GetIndexOffsetsArray(
conn.NumIndices, connectivityLength, Device{});
conn.Connectivity = CellSetPermutationPointToCellHelpers::GetConnectivityArray(
conn.Connectivity = CellSetPermutationVisitCellsWithPointsHelpers::GetConnectivityArray(
cellset, conn.IndexOffsets, connectivityLength, Device{});
return conn;
@ -135,7 +136,7 @@ public:
// Specialization for CellSetExplicit/CellSetSingleType
template <typename S1, typename S2, typename S3, typename S4, typename PermutationArrayHandleType>
class CellSetPermutationPointToCell<
class CellSetPermutationVisitCellsWithPoints<
CellSetPermutation<CellSetExplicit<S1, S2, S3, S4>, PermutationArrayHandleType>>
{
private:
@ -160,10 +161,10 @@ public:
conn.NumIndices =
NumIndicesArrayType(cellset.GetValidCellIds(),
cellset.GetFullCellSet().GetNumIndicesArray(
vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell()));
conn.IndexOffsets = CellSetPermutationPointToCellHelpers::GetIndexOffsetsArray(
vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint()));
conn.IndexOffsets = CellSetPermutationVisitCellsWithPointsHelpers::GetIndexOffsetsArray(
conn.NumIndices, connectivityLength, Device{});
conn.Connectivity = CellSetPermutationPointToCellHelpers::GetConnectivityArray(
conn.Connectivity = CellSetPermutationVisitCellsWithPointsHelpers::GetConnectivityArray(
cellset, conn.IndexOffsets, connectivityLength, Device{});
return conn;
@ -172,7 +173,7 @@ public:
// Specialization for CellSetStructured
template <vtkm::IdComponent DIMENSION, typename PermutationArrayHandleType>
class CellSetPermutationPointToCell<
class CellSetPermutationVisitCellsWithPoints<
CellSetPermutation<CellSetStructured<DIMENSION>, PermutationArrayHandleType>>
{
private:
@ -197,7 +198,7 @@ public:
ConnectivityArrays conn;
conn.NumIndices = make_ArrayHandleConstant(numPointsInCell, numberOfCells);
conn.IndexOffsets = ArrayHandleCounting<vtkm::Id>(0, numPointsInCell, numberOfCells);
conn.Connectivity = CellSetPermutationPointToCellHelpers::GetConnectivityArray(
conn.Connectivity = CellSetPermutationVisitCellsWithPointsHelpers::GetConnectivityArray(
cellset, conn.IndexOffsets, connectivityLength, Device{});
return conn;
@ -281,7 +282,7 @@ public:
{
this->ValidCellIds.ReleaseResourcesExecution();
this->FullCellSet.ReleaseResourcesExecution();
this->CellToPoint.ReleaseResourcesExecution();
this->VisitPointsWithCells.ReleaseResourcesExecution();
}
VTKM_CONT
@ -337,11 +338,11 @@ public:
return this->FullCellSet.GetNumberOfPoints();
}
template <typename Device, typename FromTopology, typename ToTopology>
template <typename Device, typename VisitTopology, typename IncidentTopology>
struct ExecutionTypes;
template <typename Device>
struct ExecutionTypes<Device, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
struct ExecutionTypes<Device, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
@ -349,15 +350,15 @@ public:
typename PermutationArrayHandleType::template ExecutionTypes<Device>::PortalConst;
using OrigExecObjectType = typename OriginalCellSetType::template ExecutionTypes<
Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType;
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ExecObjectType;
using ExecObjectType =
vtkm::exec::ConnectivityPermutedPointToCell<ExecPortalType, OrigExecObjectType>;
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints<ExecPortalType, OrigExecObjectType>;
};
template <typename Device>
struct ExecutionTypes<Device, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint>
struct ExecutionTypes<Device, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
@ -368,47 +369,48 @@ public:
using IndexOffsetPortalType =
typename vtkm::cont::ArrayHandle<vtkm::Id>::template ExecutionTypes<Device>::PortalConst;
using ExecObjectType = vtkm::exec::ConnectivityPermutedCellToPoint<ConnectiviyPortalType,
using ExecObjectType =
vtkm::exec::ConnectivityPermutedVisitPointsWithCells<ConnectiviyPortalType,
NumIndicesPortalType,
IndexOffsetPortalType>;
};
template <typename Device>
VTKM_CONT typename ExecutionTypes<Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ExecObjectType
PrepareForInput(Device device,
vtkm::TopologyElementTagPoint from,
vtkm::TopologyElementTagCell to) const
vtkm::TopologyElementTagCell from,
vtkm::TopologyElementTagPoint to) const
{
using ConnectivityType = typename ExecutionTypes<Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType;
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ExecObjectType;
return ConnectivityType(this->ValidCellIds.PrepareForInput(device),
this->FullCellSet.PrepareForInput(device, from, to));
}
template <typename Device>
VTKM_CONT typename ExecutionTypes<Device,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ExecObjectType
PrepareForInput(Device device, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint) const
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType
PrepareForInput(Device device, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const
{
if (!this->CellToPoint.ElementsValid)
if (!this->VisitPointsWithCells.ElementsValid)
{
auto pointToCell =
internal::CellSetPermutationPointToCell<CellSetPermutation>::Get(*this, device);
internal::ComputeCellToPointConnectivity(
this->CellToPoint, pointToCell, this->GetNumberOfPoints(), device);
this->CellToPoint.BuildIndexOffsets(device);
internal::CellSetPermutationVisitCellsWithPoints<CellSetPermutation>::Get(*this, device);
internal::ComputeVisitPointsWithCellsConnectivity(
this->VisitPointsWithCells, pointToCell, this->GetNumberOfPoints(), device);
this->VisitPointsWithCells.BuildIndexOffsets(device);
}
using ConnectivityType = typename ExecutionTypes<Device,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ExecObjectType;
return ConnectivityType(this->CellToPoint.Connectivity.PrepareForInput(device),
this->CellToPoint.NumIndices.PrepareForInput(device),
this->CellToPoint.IndexOffsets.PrepareForInput(device));
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType;
return ConnectivityType(this->VisitPointsWithCells.Connectivity.PrepareForInput(device),
this->VisitPointsWithCells.NumIndices.PrepareForInput(device),
this->VisitPointsWithCells.IndexOffsets.PrepareForInput(device));
}
VTKM_CONT
@ -421,12 +423,12 @@ public:
}
private:
using CellToPointConnectivity = vtkm::cont::internal::ConnectivityExplicitInternals<
using VisitPointsWithCellsConnectivity = vtkm::cont::internal::ConnectivityExplicitInternals<
typename ArrayHandleConstant<vtkm::UInt8>::StorageTag>;
PermutationArrayHandleType ValidCellIds;
OriginalCellSetType FullCellSet;
mutable CellToPointConnectivity CellToPoint;
mutable VisitPointsWithCellsConnectivity VisitPointsWithCells;
};
template <typename CellSetType,

@ -80,7 +80,7 @@ public:
{
this->CellShapeAsId = vtkm::CELL_SHAPE_EMPTY;
this->Data->PointToCell.Connectivity.Allocate(connectivityMaxLen);
this->Data->VisitCellsWithPoints.Connectivity.Allocate(connectivityMaxLen);
this->Data->NumberOfCellsAdded = 0;
this->Data->ConnectivityAdded = 0;
@ -101,7 +101,7 @@ public:
}
if (this->Data->ConnectivityAdded + numVertices >
this->Data->PointToCell.Connectivity.GetNumberOfValues())
this->Data->VisitCellsWithPoints.Connectivity.GetNumberOfValues())
{
throw vtkm::cont::ErrorBadValue(
"Connectivity increased passed estimated maximum connectivity.");
@ -131,7 +131,7 @@ public:
}
for (vtkm::IdComponent iVert = 0; iVert < numVertices; ++iVert)
{
this->Data->PointToCell.Connectivity.GetPortalControl().Set(
this->Data->VisitCellsWithPoints.Connectivity.GetPortalControl().Set(
this->Data->ConnectivityAdded + iVert, Traits::GetComponent(ids, iVert));
}
this->Data->NumberOfCellsAdded++;
@ -143,19 +143,19 @@ public:
void CompleteAddingCells(vtkm::Id numPoints)
{
this->Data->NumberOfPoints = numPoints;
this->PointToCell.Connectivity.Shrink(this->ConnectivityAdded);
this->VisitCellsWithPoints.Connectivity.Shrink(this->ConnectivityAdded);
vtkm::Id numCells = this->NumberOfCellsAdded;
this->PointToCell.Shapes =
this->VisitCellsWithPoints.Shapes =
vtkm::cont::make_ArrayHandleConstant(this->GetCellShape(0), numCells);
this->PointToCell.NumIndices =
this->VisitCellsWithPoints.NumIndices =
vtkm::cont::make_ArrayHandleConstant(this->NumberOfPointsPerCell, numCells);
this->PointToCell.IndexOffsets = vtkm::cont::make_ArrayHandleCounting(
this->VisitCellsWithPoints.IndexOffsets = vtkm::cont::make_ArrayHandleCounting(
vtkm::Id(0), static_cast<vtkm::Id>(this->NumberOfPointsPerCell), numCells);
this->PointToCell.ElementsValid = true;
this->PointToCell.IndexOffsetsValid = true;
this->VisitCellsWithPoints.ElementsValid = true;
this->VisitCellsWithPoints.IndexOffsetsValid = true;
if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
{
@ -179,17 +179,18 @@ public:
this->CheckNumberOfPointsPerCell(numberOfPointsPerCell);
const vtkm::Id numCells = connectivity.GetNumberOfValues() / numberOfPointsPerCell;
VTKM_ASSERT((connectivity.GetNumberOfValues() % numberOfPointsPerCell) == 0);
this->Data->PointToCell.Shapes = vtkm::cont::make_ArrayHandleConstant(shapeId, numCells);
this->Data->PointToCell.NumIndices =
this->Data->VisitCellsWithPoints.Shapes =
vtkm::cont::make_ArrayHandleConstant(shapeId, numCells);
this->Data->VisitCellsWithPoints.NumIndices =
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell, numCells);
this->Data->PointToCell.IndexOffsets = vtkm::cont::make_ArrayHandleCounting(
this->Data->VisitCellsWithPoints.IndexOffsets = vtkm::cont::make_ArrayHandleCounting(
vtkm::Id(0), static_cast<vtkm::Id>(numberOfPointsPerCell), numCells);
this->Data->PointToCell.Connectivity = connectivity;
this->Data->VisitCellsWithPoints.Connectivity = connectivity;
this->Data->PointToCell.ElementsValid = true;
this->Data->PointToCell.IndexOffsetsValid = true;
this->Data->VisitCellsWithPoints.ElementsValid = true;
this->Data->VisitCellsWithPoints.IndexOffsetsValid = true;
this->ResetConnectivity(TopologyElementTagCell{}, TopologyElementTagPoint{});
this->ResetConnectivity(TopologyElementTagPoint{}, TopologyElementTagCell{});
}
VTKM_CONT
@ -224,10 +225,10 @@ public:
virtual void PrintSummary(std::ostream& out) const override
{
out << " CellSetSingleType: " << this->Name << " Type " << this->CellShapeAsId << std::endl;
out << " PointToCell: " << std::endl;
this->Data->PointToCell.PrintSummary(out);
out << " CellToPoint: " << std::endl;
this->Data->CellToPoint.PrintSummary(out);
out << " VisitCellsWithPoints: " << std::endl;
this->Data->VisitCellsWithPoints.PrintSummary(out);
out << " VisitPointsWithCells: " << std::endl;
this->Data->VisitPointsWithCells.PrintSummary(out);
}
private:
@ -308,7 +309,7 @@ public:
vtkmdiy::save(bb, cs.GetCellShape(0));
vtkmdiy::save(bb, cs.GetNumberOfPointsInCell(0));
vtkmdiy::save(
bb, cs.GetConnectivityArray(vtkm::TopologyElementTagPoint{}, vtkm::TopologyElementTagCell{}));
bb, cs.GetConnectivityArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{}));
}
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)

@ -115,18 +115,19 @@ public:
template <typename TopologyElement>
SchedulingRangeType GetSchedulingRange(TopologyElement) const;
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
struct ExecutionTypes
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
using ExecObjectType = vtkm::exec::ConnectivityStructured<FromTopology, ToTopology, Dimension>;
VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
using ExecObjectType =
vtkm::exec::ConnectivityStructured<VisitTopology, IncidentTopology, Dimension>;
};
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
typename ExecutionTypes<DeviceAdapter, FromTopology, ToTopology>::ExecObjectType
PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const;
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
typename ExecutionTypes<DeviceAdapter, VisitTopology, IncidentTopology>::ExecObjectType
PrepareForInput(DeviceAdapter, VisitTopology, IncidentTopology) const;
void PrintSummary(std::ostream& out) const override;

@ -57,13 +57,16 @@ typename CellSetStructured<DIMENSION>::SchedulingRangeType
}
template <vtkm::IdComponent DIMENSION>
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
typename CellSetStructured<
DIMENSION>::template ExecutionTypes<DeviceAdapter, FromTopology, ToTopology>::ExecObjectType
CellSetStructured<DIMENSION>::PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
typename CellSetStructured<DIMENSION>::template ExecutionTypes<DeviceAdapter,
VisitTopology,
IncidentTopology>::ExecObjectType
CellSetStructured<DIMENSION>::PrepareForInput(DeviceAdapter,
VisitTopology,
IncidentTopology) const
{
using ConnectivityType =
typename ExecutionTypes<DeviceAdapter, FromTopology, ToTopology>::ExecObjectType;
typename ExecutionTypes<DeviceAdapter, VisitTopology, IncidentTopology>::ExecObjectType;
return ConnectivityType(this->Structure);
}

@ -15,7 +15,7 @@
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/VirtualObjectHandle.h>
#include <vtkm/worklet/Invoker.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/worklet/colorconversion/LookupTable.h>
#include <vtkm/worklet/colorconversion/Portals.h>
#include <vtkm/worklet/colorconversion/TransferFunction.h>
@ -79,7 +79,7 @@ struct map_color_table
inline bool operator()(DeviceAdapter device, ColorTable&& colors, Args&&... args) const
{
vtkm::worklet::colorconversion::TransferFunction transfer(colors->PrepareForExecution(device));
vtkm::worklet::Invoker invoke(device);
vtkm::cont::Invoker invoke(device);
invoke(transfer, std::forward<Args>(args)...);
return true;
}
@ -97,7 +97,7 @@ bool ColorTable::Map(const vtkm::cont::ArrayHandle<T, S>& values,
return false;
}
vtkm::worklet::colorconversion::LookupTable lookupTable(samples);
vtkm::worklet::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
vtkm::cont::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
invoke(lookupTable, values, samples.Samples, rgbaOut);
return true;
}
@ -112,7 +112,7 @@ bool ColorTable::Map(const vtkm::cont::ArrayHandle<T, S>& values,
return false;
}
vtkm::worklet::colorconversion::LookupTable lookupTable(samples);
vtkm::worklet::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
vtkm::cont::Invoker invoke(vtkm::cont::DeviceAdapterTagAny{});
invoke(lookupTable, values, samples.Samples, rgbOut);
return true;
}

@ -7,8 +7,8 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_worklet_Invoker_h
#define vtk_m_worklet_Invoker_h
#ifndef vtk_m_cont_Invoker_h
#define vtk_m_cont_Invoker_h
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
@ -19,7 +19,7 @@
namespace vtkm
{
namespace worklet
namespace cont
{
@ -56,15 +56,16 @@ struct Invoker
/// Optional second parameter is the scatter type associated with the worklet.
/// Any additional parameters are the ControlSignature arguments for the worklet.
///
template <typename Worklet,
template <
typename Worklet,
typename T,
typename... Args,
typename std::enable_if<
std::is_base_of<internal::ScatterBase, internal::detail::remove_cvref<T>>::value,
typename std::enable_if<std::is_base_of<worklet::internal::ScatterBase,
worklet::internal::detail::remove_cvref<T>>::value,
int>::type* = nullptr>
inline void operator()(Worklet&& worklet, T&& scatter, Args&&... args) const
{
using WorkletType = internal::detail::remove_cvref<Worklet>;
using WorkletType = worklet::internal::detail::remove_cvref<Worklet>;
using DispatcherType = typename WorkletType::template Dispatcher<WorkletType>;
DispatcherType dispatcher(worklet, scatter);
@ -76,15 +77,16 @@ struct Invoker
/// Optional second parameter is the scatter type associated with the worklet.
/// Any additional parameters are the ControlSignature arguments for the worklet.
///
template <typename Worklet,
template <
typename Worklet,
typename T,
typename... Args,
typename std::enable_if<
!std::is_base_of<internal::ScatterBase, internal::detail::remove_cvref<T>>::value,
typename std::enable_if<!std::is_base_of<worklet::internal::ScatterBase,
worklet::internal::detail::remove_cvref<T>>::value,
int>::type* = nullptr>
inline void operator()(Worklet&& worklet, T&& t, Args&&... args) const
{
using WorkletType = internal::detail::remove_cvref<Worklet>;
using WorkletType = worklet::internal::detail::remove_cvref<Worklet>;
using DispatcherType = typename WorkletType::template Dispatcher<WorkletType>;
DispatcherType dispatcher(worklet);

@ -191,6 +191,18 @@
/// \param deviceId The device tag / id for the device on which the functor
/// failed.
/// \def VTKM_DEFINE_USER_LOG_LEVEL(name, offset)
/// \brief Convenience macro for creating a custom log level that is usable
/// in the other macros. If logging is disabled this macro does nothing.
/// \param name The name to give the new log level
/// \param offset The offset from the vtkm::cont::LogLevel::UserFirst value
/// from the LogLevel enum. Additionally moduloed against the
/// vtkm::cont::LogLevel::UserLast value
/// \note This macro is to be used for quickly setting log levels. For a
/// more maintainable solution it is recommended to create a custom enum class
/// and then cast appropriately, as described here:
/// https://gitlab.kitware.com/vtk/vtk-m/issues/358#note_550157
#if defined(VTKM_ENABLE_LOGGING)
#define VTKM_LOG_S(level, ...) VLOG_S(static_cast<loguru::Verbosity>(level)) << __VA_ARGS__
@ -237,6 +249,14 @@
VTKM_LOG_S(vtkm::cont::LogLevel::Error, "Failing device: " << deviceId.GetName()); \
VTKM_LOG_S(vtkm::cont::LogLevel::Error, "The failing device has been disabled.")
// Custom log level
#define VTKM_DEFINE_USER_LOG_LEVEL(name, offset) \
static constexpr vtkm::cont::LogLevel name = static_cast<vtkm::cont::LogLevel>( \
static_cast<typename std::underlying_type<vtkm::cont::LogLevel>::type>( \
vtkm::cont::LogLevel::UserFirst) + \
offset % static_cast<typename std::underlying_type<vtkm::cont::LogLevel>::type>( \
vtkm::cont::LogLevel::UserLast))
#else // VTKM_ENABLE_LOGGING
#define VTKM_LOG_S(level, ...)
@ -248,6 +268,7 @@
#define VTKM_LOG_ERROR_CONTEXT(desc, data)
#define VTKM_LOG_CAST_SUCC(inObj, outObj)
#define VTKM_LOG_CAST_FAIL(inObj, outType)
#define VTKM_DEFINE_USER_LOG_LEVEL(name, offset)
// Always emitted. When logging is disabled, std::cerr is used.

@ -28,26 +28,29 @@ namespace arg
/// \c TransportTagCellSetIn is a tag used with the \c Transport class to
/// transport topology objects for input data.
///
template <typename FromTopology, typename ToTopology>
template <typename VisitTopology, typename IncidentTopology>
struct TransportTagCellSetIn
{
};
template <typename FromTopology, typename ToTopology, typename ContObjectType, typename Device>
struct Transport<vtkm::cont::arg::TransportTagCellSetIn<FromTopology, ToTopology>,
template <typename VisitTopology,
typename IncidentTopology,
typename ContObjectType,
typename Device>
struct Transport<vtkm::cont::arg::TransportTagCellSetIn<VisitTopology, IncidentTopology>,
ContObjectType,
Device>
{
VTKM_IS_CELL_SET(ContObjectType);
using ExecObjectType = decltype(
std::declval<ContObjectType>().PrepareForInput(Device(), FromTopology(), ToTopology()));
std::declval<ContObjectType>().PrepareForInput(Device(), VisitTopology(), IncidentTopology()));
template <typename InputDomainType>
VTKM_CONT ExecObjectType
operator()(const ContObjectType& object, const InputDomainType&, vtkm::Id, vtkm::Id) const
{
return object.PrepareForInput(Device(), FromTopology(), ToTopology());
return object.PrepareForInput(Device(), VisitTopology(), IncidentTopology());
}
};
}

@ -59,15 +59,14 @@ void TransportWholeCellSetIn(Device)
contObject.AddCell(vtkm::CELL_SHAPE_QUAD, 4, vtkm::make_Vec<vtkm::Id>(2, 1, 3, 4));
contObject.CompleteAddingCells(nVerts);
using FromType = vtkm::TopologyElementTagPoint;
using ToType = vtkm::TopologyElementTagCell;
using IncidentTopology = vtkm::TopologyElementTagPoint;
using VisitTopology = vtkm::TopologyElementTagCell;
using ExecObjectType =
typename vtkm::cont::CellSetExplicit<>::template ExecutionTypes<Device,
FromType,
ToType>::ExecObjectType;
using ExecObjectType = typename vtkm::cont::CellSetExplicit<>::
template ExecutionTypes<Device, VisitTopology, IncidentTopology>::ExecObjectType;
vtkm::cont::arg::Transport<vtkm::cont::arg::TransportTagCellSetIn<FromType, ToType>,
vtkm::cont::arg::Transport<
vtkm::cont::arg::TransportTagCellSetIn<VisitTopology, IncidentTopology>,
vtkm::cont::CellSetExplicit<>,
Device>
transport;

@ -320,7 +320,11 @@ private:
vtkm::Int32 rVal = this->LocalPopCount;
for (int delta = 1; delta < activeSize; delta *= 2)
{
rVal += activeLanes.shfl_down(rVal, delta);
const vtkm::Int32 shflVal = activeLanes.shfl_down(rVal, delta);
if (activeRank + delta < activeSize)
{
rVal += shflVal;
}
}
if (activeRank == 0)
@ -511,7 +515,11 @@ private:
vtkm::Int32 rVal = this->LocalPopCount;
for (int delta = 1; delta < activeSize; delta *= 2)
{
rVal += activeLanes.shfl_down(rVal, delta);
const vtkm::Int32 shflVal = activeLanes.shfl_down(rVal, delta);
if (activeRank + delta < activeSize)
{
rVal += shflVal;
}
}
if (activeRank == 0)

@ -225,9 +225,9 @@ struct ConnIdxToCellIdCalcSingleType
vtkm::Id operator()(vtkm::Id inIdx) const { return inIdx / this->CellSize; }
};
template <typename PointToCell, typename CellToPoint, typename Device>
void ComputeCellToPointConnectivity(CellToPoint& cell2Point,
const PointToCell& point2Cell,
template <typename VisitCellsWithPoints, typename VisitPointsWithCells, typename Device>
void ComputeVisitPointsWithCellsConnectivity(VisitPointsWithCells& cell2Point,
const VisitCellsWithPoints& point2Cell,
vtkm::Id numberOfPoints,
Device)
{
@ -258,7 +258,7 @@ void ComputeCellToPointConnectivity(CellToPoint& cell2Point,
rConnSize,
Device());
// Set the CellToPoint information
// Set the VisitPointsWithCells information
cell2Point.Shapes = vtkm::cont::make_ArrayHandleConstant(
static_cast<vtkm::UInt8>(CELL_SHAPE_VERTEX), numberOfPoints);
cell2Point.ElementsValid = true;
@ -269,10 +269,10 @@ void ComputeCellToPointConnectivity(CellToPoint& cell2Point,
template <typename ShapeStorageTag,
typename ConnectivityStorageTag,
typename IndexOffsetStorageTag,
typename CellToPoint,
typename VisitPointsWithCells,
typename Device>
void ComputeCellToPointConnectivity(
CellToPoint& cell2Point,
void ComputeVisitPointsWithCellsConnectivity(
VisitPointsWithCells& cell2Point,
const ConnectivityExplicitInternals<
ShapeStorageTag,
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag, // nIndices
@ -309,7 +309,7 @@ void ComputeCellToPointConnectivity(
rConnSize,
Device());
// Set the CellToPoint information
// Set the VisitPointsWithCells information
cell2Point.Shapes = vtkm::cont::make_ArrayHandleConstant(
static_cast<vtkm::UInt8>(CELL_SHAPE_VERTEX), numberOfPoints);
cell2Point.ElementsValid = true;

@ -18,6 +18,8 @@
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/testing/Testing.h>
#include <numeric>
namespace vtkm
@ -1551,9 +1553,19 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DExplicitDataSetCowNose()
std::vector<vtkm::Float32> cellvar(connectivitySize / 3);
std::iota(cellvar.begin(), cellvar.end(), 132.f);
vtkm::cont::ArrayHandle<vtkm::Vec3f> pointvec;
pointvec.Allocate(nVerts);
SetPortal(pointvec.GetPortalControl());
vtkm::cont::ArrayHandle<vtkm::Vec3f> cellvec;
cellvec.Allocate(connectivitySize / 3);
SetPortal(cellvec.GetPortalControl());
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddPointField(dataSet, "pointvar", pointvar);
dsf.AddCellField(dataSet, "cellvar", cellvar, "cells");
dsf.AddPointField(dataSet, "point_vectors", pointvec);
dsf.AddCellField(dataSet, "cell_vectors", cellvec, "cells");
return dataSet;
}

@ -235,8 +235,8 @@ struct TestEqualCellSet
const vtkm::cont::CellSetExplicit<ShapeST, CountST, ConnectivityST, OffsetST>& cs2,
TestEqualResult& result) const
{
vtkm::TopologyElementTagPoint p2cFrom{};
vtkm::TopologyElementTagCell p2cTo{};
vtkm::TopologyElementTagCell visitTopo{};
vtkm::TopologyElementTagPoint incidentTopo{};
if (cs1.GetName() != cs2.GetName())
{
@ -249,30 +249,30 @@ struct TestEqualCellSet
return;
}
result = test_equal_ArrayHandles(cs1.GetShapesArray(p2cFrom, p2cTo),
cs2.GetShapesArray(p2cFrom, p2cTo));
result = test_equal_ArrayHandles(cs1.GetShapesArray(visitTopo, incidentTopo),
cs2.GetShapesArray(visitTopo, incidentTopo));
if (!result)
{
result.PushMessage("shapes arrays don't match");
return;
}
result = test_equal_ArrayHandles(cs1.GetNumIndicesArray(p2cFrom, p2cTo),
cs2.GetNumIndicesArray(p2cFrom, p2cTo));
result = test_equal_ArrayHandles(cs1.GetNumIndicesArray(visitTopo, incidentTopo),
cs2.GetNumIndicesArray(visitTopo, incidentTopo));
if (!result)
{
result.PushMessage("counts arrays don't match");
return;
}
result = test_equal_ArrayHandles(cs1.GetConnectivityArray(p2cFrom, p2cTo),
cs2.GetConnectivityArray(p2cFrom, p2cTo));
result = test_equal_ArrayHandles(cs1.GetConnectivityArray(visitTopo, incidentTopo),
cs2.GetConnectivityArray(visitTopo, incidentTopo));
if (!result)
{
result.PushMessage("connectivity arrays don't match");
return;
}
result = test_equal_ArrayHandles(cs1.GetIndexOffsetArray(p2cFrom, p2cTo),
cs2.GetIndexOffsetArray(p2cFrom, p2cTo));
result = test_equal_ArrayHandles(cs1.GetIndexOffsetArray(visitTopo, incidentTopo),
cs2.GetIndexOffsetArray(visitTopo, incidentTopo));
if (!result)
{
result.PushMessage("offsets arrays don't match");

@ -14,14 +14,13 @@
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/BitField.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/exec/FunctorBase.h>
#include <vtkm/worklet/Invoker.h>
#include <cstdio>
#define DEVICE_ASSERT_MSG(cond, message) \
@ -599,7 +598,7 @@ struct TestingBitField
auto falseArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(13, 2, NUM_BITS);
vtkm::cont::ArrayHandle<vtkm::Id> output;
vtkm::worklet::Invoker invoke;
vtkm::cont::Invoker invoke;
invoke(ConditionalMergeWorklet{}, condArray, trueArray, falseArray, output);
auto condVals = condArray.GetPortalConstControl();
@ -625,7 +624,7 @@ struct TestingBitField
auto falseArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(13, 2, NUM_BITS);
vtkm::cont::ArrayHandle<vtkm::Id> output;
vtkm::worklet::Invoker invoke;
vtkm::cont::Invoker invoke;
invoke(ConditionalMergeWorklet2{}, condBits, trueArray, falseArray, output);
auto condVals = condBits.GetPortalConstControl();
@ -672,4 +671,4 @@ public:
}
} // namespace vtkm::cont::testing
#endif //vtk_m_cont_testing_TestingArrayHandles_h
#endif // vtk_m_cont_testing_TestingBitFields_h

@ -37,7 +37,7 @@ using PointType = vtkm::Vec3f;
std::default_random_engine RandomGenerator;
class ParametricToWorldCoordinates : public vtkm::worklet::WorkletMapPointToCell
class ParametricToWorldCoordinates : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset,

@ -103,11 +103,11 @@ private:
vtkm::Id correctConnectivity[] = { 0, 0, 1, 0, 1, 1, 1 };
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapes =
cellset.GetShapesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
cellset.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices =
cellset.GetNumIndicesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
cellset.GetNumIndicesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
vtkm::cont::ArrayHandle<vtkm::Id> conn =
cellset.GetConnectivityArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
cellset.GetConnectivityArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
VTKM_TEST_ASSERT(TestArrayHandle(shapes, correctShapes, numPoints), "Got incorrect shapes");
VTKM_TEST_ASSERT(TestArrayHandle(numIndices, correctNumIndices, numPoints),

@ -104,11 +104,11 @@ private:
//verify that the point to cell connectivity types are correct
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapesPointToCell =
cellset.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
cellset.GetShapesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
vtkm::cont::ArrayHandleConstant<vtkm::IdComponent> numIndicesPointToCell =
cellset.GetNumIndicesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
cellset.GetNumIndicesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
vtkm::cont::ArrayHandle<vtkm::Id> connPointToCell =
cellset.GetConnectivityArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
cellset.GetConnectivityArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
VTKM_TEST_ASSERT(shapesPointToCell.GetNumberOfValues() == 3, "Wrong number of shapes");
VTKM_TEST_ASSERT(numIndicesPointToCell.GetNumberOfValues() == 3, "Wrong number of indices");
@ -117,11 +117,11 @@ private:
//verify that the cell to point connectivity types are correct
//note the handle storage types differ compared to point to cell
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapesCellToPoint =
cellset.GetShapesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
cellset.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndicesCellToPoint =
cellset.GetNumIndicesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
cellset.GetNumIndicesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
vtkm::cont::ArrayHandle<vtkm::Id> connCellToPoint =
cellset.GetConnectivityArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
cellset.GetConnectivityArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
VTKM_TEST_ASSERT(shapesCellToPoint.GetNumberOfValues() == 5, "Wrong number of shapes");
VTKM_TEST_ASSERT(numIndicesCellToPoint.GetNumberOfValues() == 5, "Wrong number of indices");

@ -2483,6 +2483,17 @@ private:
testRandomMask(0xffffffff);
testRandomMask(0x1c0fd395);
testRandomMask(0xdeadbeef);
// This case was causing issues on CUDA:
{
BitField bits;
Algorithm::Fill(bits, false, 32 * 32);
auto portal = bits.GetPortalControl();
portal.SetWord(2, 0x00100000ul);
portal.SetWord(8, 0x00100010ul);
portal.SetWord(11, 0x10000000ul);
testIndexArray(bits);
}
}
static VTKM_CONT void TestCountSetBits()
@ -2562,6 +2573,17 @@ private:
testRandomMask(0xffffffff);
testRandomMask(0x1c0fd395);
testRandomMask(0xdeadbeef);
// This case was causing issues on CUDA:
{
BitField bits;
Algorithm::Fill(bits, false, 32 * 32);
auto portal = bits.GetPortalControl();
portal.SetWord(2, 0x00100000ul);
portal.SetWord(8, 0x00100010ul);
portal.SetWord(11, 0x10000000ul);
verifyPopCount(bits);
}
}
template <typename WordType>

@ -37,8 +37,8 @@ namespace implicit_function_detail
class EvaluateImplicitFunction : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn, FieldOut);
using ExecutionSignature = void(_1, _2);
using ControlSignature = void(FieldIn, FieldOut, FieldOut);
using ExecutionSignature = void(_1, _2, _3);
EvaluateImplicitFunction(const vtkm::ImplicitFunction* function)
: Function(function)
@ -46,9 +46,10 @@ public:
}
template <typename VecType, typename ScalarType>
VTKM_EXEC void operator()(const VecType& point, ScalarType& val) const
VTKM_EXEC void operator()(const VecType& point, ScalarType& val, VecType& gradient) const
{
val = this->Function->Value(point);
gradient = this->Function->Gradient(point);
}
private:
@ -59,6 +60,7 @@ template <typename DeviceAdapter>
void EvaluateOnCoordinates(vtkm::cont::CoordinateSystem points,
const vtkm::cont::ImplicitFunctionHandle& function,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>& values,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>>& gradients,
DeviceAdapter device)
{
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvaluateImplicitFunction>;
@ -66,12 +68,12 @@ void EvaluateOnCoordinates(vtkm::cont::CoordinateSystem points,
EvaluateImplicitFunction eval(function.PrepareForExecution(device));
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(points, values);
dispatcher.Invoke(points, values, gradients);
}
template <std::size_t N>
bool TestArrayEqual(const vtkm::cont::ArrayHandle<vtkm::FloatDefault>& result,
const std::array<vtkm::FloatDefault, N>& expected)
template <typename ItemType, std::size_t N>
bool TestArrayEqual(const vtkm::cont::ArrayHandle<ItemType>& result,
const std::array<ItemType, N>& expected)
{
bool success = false;
auto portal = result.GetPortalConstControl();
@ -103,6 +105,12 @@ bool TestArrayEqual(const vtkm::cont::ArrayHandle<vtkm::FloatDefault>& result,
std::cout << ", " << portal.Get(i);
}
std::cout << "\n";
std::cout << "expected: " << expected[0];
for (vtkm::Id i = 1; i < count; ++i)
{
std::cout << ", " << expected[static_cast<std::size_t>(i)];
}
std::cout << "\n";
}
}
@ -137,18 +145,32 @@ private:
<< vtkm::cont::DeviceAdapterTraits<DeviceAdapter>::GetName() << "\n";
vtkm::cont::ArrayHandle<vtkm::FloatDefault> values;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> gradients;
implicit_function_detail::EvaluateOnCoordinates(
this->Input.GetCoordinateSystem(0),
vtkm::cont::make_ImplicitFunctionHandle(
vtkm::Box({ 0.0f, -0.5f, -0.5f }, { 1.5f, 1.5f, 0.5f })),
values,
gradients,
device);
std::array<vtkm::FloatDefault, 8> expected = {
{ 0.0f, -0.5f, 0.5f, 0.5f, 0.0f, -0.5f, 0.5f, 0.5f }
};
std::array<vtkm::Vec<vtkm::FloatDefault, 3>, 8> expectedGradients = {
{ { -1.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 1.0f },
{ -1.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 1.0f } }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected),
"Result does not match expected values");
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(gradients, expectedGradients),
"Result does not match expected gradients values");
}
template <typename DeviceAdapter>
@ -163,17 +185,31 @@ private:
cylinder.SetRadius(1.0f);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> values;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> gradients;
implicit_function_detail::EvaluateOnCoordinates(
this->Input.GetCoordinateSystem(0),
vtkm::cont::ImplicitFunctionHandle(&cylinder, false),
values,
gradients,
device);
std::array<vtkm::FloatDefault, 8> expected = {
{ 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f }
};
std::array<vtkm::Vec<vtkm::FloatDefault, 3>, 8> expectedGradients = {
{ { 0.0f, 0.0f, -2.0f },
{ 2.0f, 0.0f, -2.0f },
{ 2.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, -2.0f },
{ 2.0f, 0.0f, -2.0f },
{ 2.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f } }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected),
"Result does not match expected values");
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(gradients, expectedGradients),
"Result does not match expected gradients values");
}
template <typename DeviceAdapter>
@ -196,17 +232,31 @@ private:
frustum.CreateFromPoints(points);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> values;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> gradients;
implicit_function_detail::EvaluateOnCoordinates(
this->Input.GetCoordinateSystem(0),
vtkm::cont::make_ImplicitFunctionHandle(frustum),
values,
gradients,
device);
std::array<vtkm::FloatDefault, 8> expected = {
{ 0.0f, 0.0f, 0.0f, 0.0f, 0.316228f, 0.316228f, -0.316228f, 0.316228f }
};
std::array<vtkm::Vec<vtkm::FloatDefault, 3>, 8> expectedGradients = {
{ { 0.0f, -1.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f },
{ 0.0f, 0.316228f, -0.948683f },
{ 0.0f, 0.316228f, -0.948683f },
{ 0.948683f, -0.316228f, 0.0f },
{ -0.948683f, 0.316228f, 0.0f } }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected),
"Result does not match expected values");
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(gradients, expectedGradients),
"Result does not match expected gradients values");
}
template <typename DeviceAdapter>
@ -220,22 +270,43 @@ private:
auto plane = static_cast<vtkm::Plane*>(planeHandle.Get());
vtkm::cont::ArrayHandle<vtkm::FloatDefault> values;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> gradients;
implicit_function_detail::EvaluateOnCoordinates(
this->Input.GetCoordinateSystem(0), planeHandle, values, device);
std::array<vtkm::FloatDefault, 8> expected1 = {
this->Input.GetCoordinateSystem(0), planeHandle, values, gradients, device);
std::array<vtkm::FloatDefault, 8> expected = {
{ -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected1),
std::array<vtkm::Vec<vtkm::FloatDefault, 3>, 8> expectedGradients = {
{ { 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f } }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected),
"Result does not match expected values");
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(gradients, expectedGradients),
"Result does not match expected gradients values");
plane->SetNormal({ -1.0f, 0.0f, -1.0f });
implicit_function_detail::EvaluateOnCoordinates(
this->Input.GetCoordinateSystem(0), planeHandle, values, device);
std::array<vtkm::FloatDefault, 8> expected2 = {
{ 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected2),
this->Input.GetCoordinateSystem(0), planeHandle, values, gradients, device);
expected = { { 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f } };
expectedGradients = { { { -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f },
{ -1.0f, 0.0f, -1.0f } } };
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected),
"Result does not match expected values");
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(gradients, expectedGradients),
"Result does not match expected gradients values");
}
template <typename DeviceAdapter>
@ -245,17 +316,31 @@ private:
<< vtkm::cont::DeviceAdapterTraits<DeviceAdapter>::GetName() << "\n";
vtkm::cont::ArrayHandle<vtkm::FloatDefault> values;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> gradients;
implicit_function_detail::EvaluateOnCoordinates(
this->Input.GetCoordinateSystem(0),
vtkm::cont::make_ImplicitFunctionHandle<vtkm::Sphere>(vtkm::make_Vec(0.0f, 0.0f, 0.0f), 1.0f),
values,
gradients,
device);
std::array<vtkm::FloatDefault, 8> expected = {
{ -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 2.0f, 1.0f }
};
std::array<vtkm::Vec<vtkm::FloatDefault, 3>, 8> expectedGradients = {
{ { 0.0f, 0.0f, 0.0f },
{ 2.0f, 0.0f, 0.0f },
{ 2.0f, 0.0f, 2.0f },
{ 0.0f, 0.0f, 2.0f },
{ 0.0f, 2.0f, 0.0f },
{ 2.0f, 2.0f, 0.0f },
{ 2.0f, 2.0f, 2.0f },
{ 0.0f, 2.0f, 2.0f } }
};
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(values, expected),
"Result does not match expected values");
VTKM_TEST_ASSERT(implicit_function_detail::TestArrayEqual(gradients, expectedGradients),
"Result does not match expected gradients values");
}
vtkm::cont::DataSet Input;

@ -82,7 +82,7 @@ vtkm::cont::DataSet MakeTestDataSetCurvilinear()
}
//-----------------------------------------------------------------------------
class ParametricToWorldCoordinates : public vtkm::worklet::WorkletMapPointToCell
class ParametricToWorldCoordinates : public vtkm::worklet::WorkletVisitCellsWithPoints
{
public:
using ControlSignature = void(CellSetIn cellset,

@ -65,7 +65,7 @@ vtkm::cont::CellSetExplicit<> MakeTestCellSet2()
return cs;
}
struct WorkletPointToCell : public vtkm::worklet::WorkletMapPointToCell
struct WorkletPointToCell : public vtkm::worklet::WorkletVisitCellsWithPoints
{
using ControlSignature = void(CellSetIn cellset, FieldOutCell numPoints);
using ExecutionSignature = void(PointIndices, _2);
@ -78,7 +78,7 @@ struct WorkletPointToCell : public vtkm::worklet::WorkletMapPointToCell
}
};
struct WorkletCellToPoint : public vtkm::worklet::WorkletMapCellToPoint
struct WorkletCellToPoint : public vtkm::worklet::WorkletVisitPointsWithCells
{
using ControlSignature = void(CellSetIn cellset, FieldOutPoint numCells);
using ExecutionSignature = void(CellIndices, _2);
@ -159,24 +159,24 @@ void TestCellSetExplicit()
std::cout << "\tTesting CellToPoint table caching\n";
cellset = MakeTestCellSet2();
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(cellset.HasConnectivity(PointTag{}, CellTag{})),
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(cellset.HasConnectivity(CellTag{}, PointTag{})),
"PointToCell table missing.");
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(!cellset.HasConnectivity(CellTag{}, PointTag{})),
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(!cellset.HasConnectivity(PointTag{}, CellTag{})),
"CellToPoint table exists before PrepareForInput.");
// Test a raw PrepareForInput call:
cellset.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial{}, CellTag{}, PointTag{});
cellset.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial{}, PointTag{}, CellTag{});
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(cellset.HasConnectivity(CellTag{}, PointTag{})),
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(cellset.HasConnectivity(PointTag{}, CellTag{})),
"CellToPoint table missing after PrepareForInput.");
cellset.ResetConnectivity(CellTag{}, PointTag{});
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(!cellset.HasConnectivity(CellTag{}, PointTag{})),
cellset.ResetConnectivity(PointTag{}, CellTag{});
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(!cellset.HasConnectivity(PointTag{}, CellTag{})),
"CellToPoint table exists after resetting.");
// Test a PrepareForInput wrapped inside a dispatch (See #268)
vtkm::worklet::DispatcherMapTopology<WorkletCellToPoint>().Invoke(cellset, result);
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(cellset.HasConnectivity(CellTag{}, PointTag{})),
VTKM_TEST_ASSERT(VTKM_PASS_COMMAS(cellset.HasConnectivity(PointTag{}, CellTag{})),
"CellToPoint table missing after CellToPoint worklet exec.");
}

@ -25,7 +25,7 @@ std::vector<int> topology = { 0, 2, 1 };
std::vector<int> nextNode = { 0, 1, 2 };
struct CopyTopo : public vtkm::worklet::WorkletMapPointToCell
struct CopyTopo : public vtkm::worklet::WorkletVisitCellsWithPoints
{
typedef void ControlSignature(CellSetIn, FieldOutCell);
typedef _2 ExecutionSignature(CellShape, PointIndices);
@ -36,7 +36,7 @@ struct CopyTopo : public vtkm::worklet::WorkletMapPointToCell
}
};
struct CopyReverseCellCount : public vtkm::worklet::WorkletMapCellToPoint
struct CopyReverseCellCount : public vtkm::worklet::WorkletVisitPointsWithCells
{
typedef void ControlSignature(CellSetIn, FieldOutPoint);
typedef _2 ExecutionSignature(CellShape, CellCount, CellIndices);

@ -20,7 +20,7 @@
namespace
{
struct WorkletPointToCell : public vtkm::worklet::WorkletMapPointToCell
struct WorkletPointToCell : public vtkm::worklet::WorkletVisitCellsWithPoints
{
using ControlSignature = void(CellSetIn cellset, FieldOutCell numPoints);
using ExecutionSignature = void(PointIndices, _2);
@ -33,7 +33,7 @@ struct WorkletPointToCell : public vtkm::worklet::WorkletMapPointToCell
}
};
struct WorkletCellToPoint : public vtkm::worklet::WorkletMapCellToPoint
struct WorkletCellToPoint : public vtkm::worklet::WorkletVisitPointsWithCells
{
using ControlSignature = void(CellSetIn cellset, FieldOutPoint numCells);
using ExecutionSignature = void(CellIndices, _2);
@ -46,7 +46,7 @@ struct WorkletCellToPoint : public vtkm::worklet::WorkletMapCellToPoint
}
};
struct CellsOfPoint : public vtkm::worklet::WorkletMapCellToPoint
struct CellsOfPoint : public vtkm::worklet::WorkletVisitPointsWithCells
{
using ControlSignature = void(CellSetIn cellset, FieldInPoint offset, WholeArrayOut cellIds);
using ExecutionSignature = void(CellIndices, _2, _3);

@ -105,13 +105,13 @@ void TestDataSet_Explicit()
subset.PrintSummary(std::cout);
using ExecObjectType = SubsetType::ExecutionTypes<vtkm::cont::DeviceAdapterTagSerial,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell>::ExecObjectType;
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint>::ExecObjectType;
ExecObjectType execConnectivity;
execConnectivity = subset.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
@ -154,7 +154,7 @@ void TestDataSet_Structured2D()
//verify that PrepareForInput exists
subset.PrepareForInput(
DeviceAdapterTag(), vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
DeviceAdapterTag(), vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
@ -193,8 +193,8 @@ void TestDataSet_Structured3D()
//verify that PrepareForInput exists
subset.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;

@ -77,14 +77,14 @@ static void TwoDimRectilinearTest()
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Incorrect element type.");
}
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 2>
pointToCell = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 2>
cellToPoint = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
pointToCell = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 2>
cellToPoint = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::Id cells[2][4] = { { 0, 1, 4, 3 }, { 1, 2, 5, 4 } };
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
@ -164,10 +164,10 @@ static void ThreeDimRectilinearTest()
}
//Test regular connectivity.
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 3>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 3>
pointToCell = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::Id expectedPointIds[8] = { 0, 1, 4, 3, 6, 7, 10, 9 };
vtkm::Vec<vtkm::Id, 8> retrievedPointIds = pointToCell.GetIndices(vtkm::Id3(0));
for (vtkm::IdComponent localPointIndex = 0; localPointIndex < 8; localPointIndex++)
@ -176,10 +176,10 @@ static void ThreeDimRectilinearTest()
"Incorrect point ID for cell");
}
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 3>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 3>
cellToPoint = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::Id retrievedCellIds[6] = { 0, -1, -1, -1, -1, -1 };
vtkm::VecVariable<vtkm::Id, 6> expectedCellIds = cellToPoint.GetIndices(vtkm::Id3(0));
VTKM_TEST_ASSERT(expectedCellIds.GetNumberOfComponents() <= 6,

@ -80,14 +80,14 @@ static void TwoDimUniformTest()
VTKM_TEST_ASSERT(shape == vtkm::CELL_SHAPE_QUAD, "Incorrect element type.");
}
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 2>
pointToCell = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 2>
cellToPoint = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
pointToCell = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 2>
cellToPoint = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::Id cells[2][4] = { { 0, 1, 4, 3 }, { 1, 2, 5, 4 } };
for (vtkm::Id cellIndex = 0; cellIndex < 2; cellIndex++)
@ -174,10 +174,10 @@ static void ThreeDimUniformTest()
}
//Test uniform connectivity.
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 3>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 3>
pointToCell = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::Id expectedPointIds[8] = { 0, 1, 4, 3, 6, 7, 10, 9 };
vtkm::Vec<vtkm::Id, 8> retrievedPointIds = pointToCell.GetIndices(vtkm::Id3(0));
for (vtkm::IdComponent localPointIndex = 0; localPointIndex < 8; localPointIndex++)
@ -186,10 +186,10 @@ static void ThreeDimUniformTest()
"Incorrect point ID for cell");
}
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 3>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 3>
cellToPoint = cellSet.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial(),
vtkm::TopologyElementTagCell(),
vtkm::TopologyElementTagPoint());
vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell());
vtkm::Id retrievedCellIds[6] = { 0, -1, -1, -1, -1, -1 };
vtkm::VecVariable<vtkm::Id, 6> expectedCellIds = cellToPoint.GetIndices(vtkm::Id3(0));
VTKM_TEST_ASSERT(expectedCellIds.GetNumberOfComponents() <= 6,

@ -59,6 +59,25 @@ void ErrorContext()
std::cerr << vtkm::cont::GetLogErrorContext() << "\n";
}
void UserDefined()
{
VTKM_DEFINE_USER_LOG_LEVEL(CustomLevel, 0);
VTKM_DEFINE_USER_LOG_LEVEL(CustomLevel2, 2);
VTKM_DEFINE_USER_LOG_LEVEL(AnotherCustomLevel2, 2);
VTKM_DEFINE_USER_LOG_LEVEL(BigLevel, 300);
vtkm::cont::SetStderrLogLevel(vtkm::cont::LogLevel::UserLast);
VTKM_LOG_S(CustomLevel, "CustomLevel");
VTKM_LOG_S(CustomLevel2, "CustomLevel2");
VTKM_LOG_S(AnotherCustomLevel2, "AnotherCustomLevel2");
vtkm::cont::SetStderrLogLevel(vtkm::cont::LogLevel::UserFirst);
VTKM_LOG_S(BigLevel, "BigLevel"); // should log nothing
vtkm::cont::SetStderrLogLevel(vtkm::cont::LogLevel::UserLast);
VTKM_LOG_S(BigLevel, "BigLevel");
}
void RunTests()
{
VTKM_LOG_F(vtkm::cont::LogLevel::Info, "Running tests.");
@ -68,6 +87,9 @@ void RunTests()
VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Running ErrorContext test...");
ErrorContext();
VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Running UserDefined test...");
UserDefined();
}
} // end anon namespace

@ -15,7 +15,7 @@ using namespace vtkm::cont::testing::serialization;
namespace
{
using FieldTypeList = vtkm::ListTagBase<vtkm::Float32>;
using FieldTypeList = vtkm::ListTagBase<vtkm::Float32, vtkm::Vec3f>;
using CellSetTypes = vtkm::ListTagBase<vtkm::cont::CellSetExplicit<>,
vtkm::cont::CellSetSingleType<>,
vtkm::cont::CellSetStructured<1>,

@ -71,7 +71,7 @@ public:
DeviceAdapter)
: Nodes(nodes.PrepareForInput(DeviceAdapter()))
, CellIds(cellIds.PrepareForInput(DeviceAdapter()))
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), FromType(), ToType()))
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), VisitType(), IncidentType()))
, Coords(coords.PrepareForInput(DeviceAdapter()))
{
}
@ -243,13 +243,14 @@ private:
return success && vtkm::exec::CellInside(parametric, cellShape);
}
using FromType = vtkm::TopologyElementTagPoint;
using ToType = vtkm::TopologyElementTagCell;
using VisitType = vtkm::TopologyElementTagCell;
using IncidentType = vtkm::TopologyElementTagPoint;
using NodePortal = typename NodeArrayHandle::template ExecutionTypes<DeviceAdapter>::PortalConst;
using CellIdPortal =
typename CellIdArrayHandle::template ExecutionTypes<DeviceAdapter>::PortalConst;
using CellSetPortal =
typename CellSetType::template ExecutionTypes<DeviceAdapter, FromType, ToType>::ExecObjectType;
using CellSetPortal = typename CellSetType::template ExecutionTypes<DeviceAdapter,
VisitType,
IncidentType>::ExecObjectType;
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
DeviceAdapter>::PortalConst;

@ -32,11 +32,10 @@ template <typename DeviceAdapter, vtkm::IdComponent dimensions>
class VTKM_ALWAYS_EXPORT CellLocatorRectilinearGrid final : public vtkm::exec::CellLocator
{
private:
using FromType = vtkm::TopologyElementTagPoint;
using ToType = vtkm::TopologyElementTagCell;
using CellSetPortal = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
dimensions>;
using VisitType = vtkm::TopologyElementTagCell;
using IncidentType = vtkm::TopologyElementTagPoint;
using CellSetPortal = vtkm::exec::ConnectivityStructured<VisitType, IncidentType, dimensions>;
using AxisHandle = vtkm::cont::ArrayHandle<vtkm::FloatDefault>;
using RectilinearType =
vtkm::cont::ArrayHandleCartesianProduct<AxisHandle, AxisHandle, AxisHandle>;
@ -53,24 +52,25 @@ public:
DeviceAdapter)
: PlaneSize(planeSize)
, RowSize(rowSize)
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), FromType(), ToType()))
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), VisitType(), IncidentType()))
, Coords(coords.PrepareForInput(DeviceAdapter()))
, PointDimensions(cellSet.GetPointDimensions())
{
this->AxisPortals[0] = Coords.GetFirstPortal();
this->AxisPortals[0] = this->Coords.GetFirstPortal();
this->MinPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(0);
this->MaxPoint[0] = coords.GetPortalConstControl().GetFirstPortal().Get(PointDimensions[0] - 1);
this->MaxPoint[0] =
coords.GetPortalConstControl().GetFirstPortal().Get(this->PointDimensions[0] - 1);
this->AxisPortals[1] = Coords.GetSecondPortal();
this->AxisPortals[1] = this->Coords.GetSecondPortal();
this->MinPoint[1] = coords.GetPortalConstControl().GetSecondPortal().Get(0);
this->MaxPoint[1] =
coords.GetPortalConstControl().GetSecondPortal().Get(PointDimensions[1] - 1);
coords.GetPortalConstControl().GetSecondPortal().Get(this->PointDimensions[1] - 1);
if (dimensions == 3)
{
this->AxisPortals[2] = Coords.GetThirdPortal();
this->AxisPortals[2] = this->Coords.GetThirdPortal();
this->MinPoint[2] = coords.GetPortalConstControl().GetThirdPortal().Get(0);
this->MaxPoint[2] =
coords.GetPortalConstControl().GetThirdPortal().Get(PointDimensions[2] - 1);
coords.GetPortalConstControl().GetThirdPortal().Get(this->PointDimensions[2] - 1);
}
}
}
@ -89,10 +89,11 @@ inline bool IsInside(const vtkm::Vec3f& point) const
inside = false;
if (point[1] < this->MinPoint[1] || point[1] > this->MaxPoint[1])
inside = false;
if (dimensions == 2)
return inside;
if (dimensions == 3)
{
if (point[2] < this->MinPoint[2] || point[2] > this->MaxPoint[2])
inside = false;
}
return inside;
}
@ -103,7 +104,7 @@ void FindCell(const vtkm::Vec3f& point,
const vtkm::exec::FunctorBase& worklet) const override
{
(void)worklet; //suppress unused warning
if (!IsInside(point))
if (!this->IsInside(point))
{
cellId = -1;
return;
@ -120,12 +121,12 @@ void FindCell(const vtkm::Vec3f& point,
//
if (point[dim] == MaxPoint[dim])
{
logicalCell[dim] = PointDimensions[dim] - 2;
logicalCell[dim] = this->PointDimensions[dim] - 2;
continue;
}
vtkm::Id minIndex = 0;
vtkm::Id maxIndex = PointDimensions[dim] - 1;
vtkm::Id maxIndex = this->PointDimensions[dim] - 1;
vtkm::FloatDefault minVal;
vtkm::FloatDefault maxVal;
minVal = this->AxisPortals[dim].Get(minIndex);
@ -146,9 +147,6 @@ void FindCell(const vtkm::Vec3f& point,
}
}
logicalCell[dim] = minIndex;
//printf("Min Index [%d] : %lld\n", dim, minIndex);
//printf("Max Index [%d] : %lld\n", dim, maxIndex);
//printf("Logical [%d] : %lld\n", dim, logicalCell[dim]);
parametric[dim] = (point[dim] - minVal) / (maxVal - minVal);
}
// Get the actual cellId, from the logical cell index of the cell

@ -31,11 +31,9 @@ template <typename DeviceAdapter, vtkm::IdComponent dimensions>
class VTKM_ALWAYS_EXPORT CellLocatorUniformGrid final : public vtkm::exec::CellLocator
{
private:
using FromType = vtkm::TopologyElementTagPoint;
using ToType = vtkm::TopologyElementTagCell;
using CellSetPortal = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
dimensions>;
using VisitType = vtkm::TopologyElementTagCell;
using IncidentType = vtkm::TopologyElementTagPoint;
using CellSetPortal = vtkm::exec::ConnectivityStructured<VisitType, IncidentType, dimensions>;
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
DeviceAdapter>::PortalConst;
@ -43,9 +41,9 @@ public:
VTKM_CONT
CellLocatorUniformGrid(const vtkm::Id3 cellDims,
const vtkm::Id3 pointDims,
const vtkm::Vec<vtkm::FloatDefault, 3> origin,
const vtkm::Vec<vtkm::FloatDefault, 3> invSpacing,
const vtkm::Vec<vtkm::FloatDefault, 3> maxPoint,
const vtkm::Vec3f origin,
const vtkm::Vec3f invSpacing,
const vtkm::Vec3f maxPoint,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
DeviceAdapter)
: CellDims(cellDims)
@ -63,8 +61,7 @@ public:
// troublesome with CUDA __host__ __device__ markup.
}
template <typename T>
VTKM_EXEC inline bool IsInside(const vtkm::Vec<T, 3>& point) const
VTKM_EXEC inline bool IsInside(const vtkm::Vec3f& point) const
{
bool inside = true;
if (point[0] < this->Origin[0] || point[0] > this->MaxPoint[0])
@ -83,7 +80,7 @@ public:
const vtkm::exec::FunctorBase& worklet) const override
{
(void)worklet; //suppress unused warning
if (!IsInside(point))
if (!this->IsInside(point))
{
cellId = -1;
return;
@ -91,9 +88,9 @@ public:
// Get the Cell Id from the point.
vtkm::Id3 logicalCell(0, 0, 0);
vtkm::Vec<vtkm::FloatDefault, 3> temp;
temp = point - Origin;
temp = temp * InvSpacing;
vtkm::Vec3f temp;
temp = point - this->Origin;
temp = temp * this->InvSpacing;
//make sure that if we border the upper edge, we sample the correct cell
logicalCell = temp;
@ -119,9 +116,9 @@ public:
private:
vtkm::Id3 CellDims;
vtkm::Id3 PointDims;
vtkm::Vec<vtkm::FloatDefault, 3> Origin;
vtkm::Vec<vtkm::FloatDefault, 3> InvSpacing;
vtkm::Vec<vtkm::FloatDefault, 3> MaxPoint;
vtkm::Vec3f Origin;
vtkm::Vec3f InvSpacing;
vtkm::Vec3f MaxPoint;
CoordsPortal Coords;
};
}

@ -22,28 +22,29 @@ namespace exec
{
template <typename PermutationPortal, typename OriginalConnectivity>
class ConnectivityPermutedPointToCell
class ConnectivityPermutedVisitCellsWithPoints
{
public:
using SchedulingRangeType = typename OriginalConnectivity::SchedulingRangeType;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC_CONT
ConnectivityPermutedPointToCell()
ConnectivityPermutedVisitCellsWithPoints()
: Portal()
, Connectivity()
{
}
VTKM_EXEC_CONT
ConnectivityPermutedPointToCell(const PermutationPortal& portal, const OriginalConnectivity& src)
ConnectivityPermutedVisitCellsWithPoints(const PermutationPortal& portal,
const OriginalConnectivity& src)
: Portal(portal)
, Connectivity(src)
{
}
VTKM_EXEC_CONT
ConnectivityPermutedPointToCell(const ConnectivityPermutedPointToCell& src)
ConnectivityPermutedVisitCellsWithPoints(const ConnectivityPermutedVisitCellsWithPoints& src)
: Portal(src.Portal)
, Connectivity(src.Connectivity)
{
@ -82,16 +83,16 @@ public:
template <typename ConnectivityPortalType,
typename NumIndicesPortalType,
typename IndexOffsetPortalType>
class ConnectivityPermutedCellToPoint
class ConnectivityPermutedVisitPointsWithCells
{
public:
using SchedulingRangeType = vtkm::Id;
using IndicesType = vtkm::VecFromPortal<ConnectivityPortalType>;
using CellShapeTag = vtkm::CellShapeTagVertex;
ConnectivityPermutedCellToPoint() = default;
ConnectivityPermutedVisitPointsWithCells() = default;
ConnectivityPermutedCellToPoint(const ConnectivityPortalType& connectivity,
ConnectivityPermutedVisitPointsWithCells(const ConnectivityPortalType& connectivity,
const NumIndicesPortalType& numIndices,
const IndexOffsetPortalType& indexOffset)
: Connectivity(connectivity)

@ -20,16 +20,16 @@ namespace vtkm
namespace exec
{
template <typename FromTopology, typename ToTopology, vtkm::IdComponent Dimension>
template <typename VisitTopology, typename IncidentTopology, vtkm::IdComponent Dimension>
class ConnectivityStructured
{
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
using InternalsType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
using Helper =
vtkm::internal::ConnectivityStructuredIndexHelper<FromTopology, ToTopology, Dimension>;
vtkm::internal::ConnectivityStructuredIndexHelper<VisitTopology, IncidentTopology, Dimension>;
public:
using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
@ -53,7 +53,8 @@ public:
}
VTKM_EXEC_CONT
ConnectivityStructured(const ConnectivityStructured<ToTopology, FromTopology, Dimension>& src)
ConnectivityStructured(
const ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>& src)
: Internals(src.Internals)
{
}
@ -115,7 +116,7 @@ public:
return this->Internals.GetGlobalPointIndexStart();
}
friend class ConnectivityStructured<ToTopology, FromTopology, Dimension>;
friend class ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>;
private:
InternalsType Internals;

@ -27,7 +27,7 @@ namespace exec
/// This class contains a public method named RaiseError that can be called in
/// the execution environment to signal a problem.
///
class VTKM_NEVER_EXPORT FunctorBase
class VTKM_ALWAYS_EXPORT FunctorBase
{
public:
VTKM_EXEC_CONT

@ -25,8 +25,8 @@ set(headers
FetchTagCellSetIn.h
FetchTagKeysIn.h
FetchTagWholeCellSetIn.h
FromCount.h
FromIndices.h
IncidentElementCount.h
IncidentElementIndices.h
InputIndex.h
OutputIndex.h
ThreadIndices.h

@ -13,7 +13,7 @@
#include <vtkm/exec/ConnectivityExtrude.h>
#include <vtkm/exec/arg/FetchTagArrayDirectIn.h>
#include <vtkm/exec/arg/FetchTagArrayTopologyMapIn.h>
#include <vtkm/exec/arg/FromIndices.h>
#include <vtkm/exec/arg/IncidentElementIndices.h>
//optimized fetches for ArrayPortalExtrude for
// - 3D Scheduling
@ -28,7 +28,7 @@ namespace arg
//Optimized fetch for point ids when iterating the cells ConnectivityExtrude
template <typename FetchType, typename Device, typename ExecObjectType>
struct Fetch<FetchType,
vtkm::exec::arg::AspectTagFromIndices,
vtkm::exec::arg::AspectTagIncidentElementIndices,
vtkm::exec::arg::ThreadIndicesTopologyMap<vtkm::exec::ConnectivityExtrude<Device>>,
ExecObjectType>
{
@ -42,7 +42,7 @@ struct Fetch<FetchType,
ValueType Load(const ThreadIndicesType& indices, const ExecObjectType&) const
{
// std::cout << "opimized fetch for point ids" << std::endl;
const auto& xgcidx = indices.GetIndicesFrom();
const auto& xgcidx = indices.GetIndicesIncident();
const vtkm::Id offset1 = (xgcidx.Planes[0] * xgcidx.NumberOfPointsPerPlane);
const vtkm::Id offset2 = (xgcidx.Planes[1] * xgcidx.NumberOfPointsPerPlane);
ValueType result;
@ -78,7 +78,7 @@ struct Fetch<vtkm::exec::arg::FetchTagArrayTopologyMapIn,
ValueType Load(const ThreadIndicesType& indices, const PortalType& portal)
{
// std::cout << "opimized fetch for point values" << std::endl;
const auto& xgcidx = indices.GetIndicesFrom();
const auto& xgcidx = indices.GetIndicesIncident();
const vtkm::Id offset1 = (xgcidx.Planes[0] * xgcidx.NumberOfPointsPerPlane);
const vtkm::Id offset2 = (xgcidx.Planes[1] * xgcidx.NumberOfPointsPerPlane);
ValueType result;
@ -115,7 +115,7 @@ struct Fetch<vtkm::exec::arg::FetchTagArrayTopologyMapIn,
ValueType Load(const ThreadIndicesType& indices, const vtkm::exec::ArrayPortalExtrude<T>& points)
{
// std::cout << "opimized fetch for point coordinates" << std::endl;
return points.GetWedge(indices.GetIndicesFrom());
return points.GetWedge(indices.GetIndicesIncident());
}
VTKM_EXEC
@ -144,7 +144,7 @@ struct Fetch<vtkm::exec::arg::FetchTagArrayTopologyMapIn,
const vtkm::exec::ArrayPortalExtrudePlane<T>& portal)
{
// std::cout << "opimized fetch for point coordinates" << std::endl;
return portal.GetWedge(indices.GetIndicesFrom());
return portal.GetWedge(indices.GetIndicesIncident());
}
VTKM_EXEC

@ -56,9 +56,9 @@ struct FetchArrayTopologyMapInImplementation
{
using ThreadIndicesType = vtkm::exec::arg::ThreadIndicesTopologyMap<ConnectivityType>;
// ThreadIndicesTopologyMap has special "from" indices that are stored in a
// Vec-like object.
using IndexVecType = typename ThreadIndicesType::IndicesFromType;
// ThreadIndicesTopologyMap has special incident element indices that are
// stored in a Vec-like object.
using IndexVecType = typename ThreadIndicesType::IndicesIncidentType;
// The FieldExecObjectType is expected to behave like an ArrayPortal.
using PortalType = FieldExecObjectType;
@ -73,7 +73,7 @@ struct FetchArrayTopologyMapInImplementation
// pointer that will stay around during the time the Vec is valid. Thus, we
// should make sure that indices is a reference that goes up the stack at
// least as far as the returned VecFromPortalPermute is used.
return ValueType(indices.GetIndicesFromPointer(), field);
return ValueType(indices.GetIndicesIncidentPointer(), field);
}
VTKM_SUPPRESS_EXEC_WARNINGS
@ -84,7 +84,7 @@ struct FetchArrayTopologyMapInImplementation
// pointer that will stay around during the time the Vec is valid. Thus, we
// should make sure that indices is a reference that goes up the stack at
// least as far as the returned VecFromPortalPermute is used.
return ValueType(indices.GetIndicesFromPointer(), field);
return ValueType(indices.GetIndicesIncidentPointer(), field);
}
};
@ -130,14 +130,14 @@ static inline VTKM_EXEC vtkm::VecAxisAlignedPointCoordinates<3> make_VecAxisAlig
template <vtkm::IdComponent NumDimensions>
struct FetchArrayTopologyMapInImplementation<
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
NumDimensions>,
vtkm::internal::ArrayPortalUniformPointCoordinates>
{
using ConnectivityType = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
using ConnectivityType = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
NumDimensions>;
using ThreadIndicesType = vtkm::exec::arg::ThreadIndicesTopologyMap<ConnectivityType>;
@ -157,18 +157,18 @@ struct FetchArrayTopologyMapInImplementation<
template <typename PermutationPortal, vtkm::IdComponent NumDimensions>
struct FetchArrayTopologyMapInImplementation<
vtkm::exec::ConnectivityPermutedPointToCell<
vtkm::exec::ConnectivityPermutedVisitCellsWithPoints<
PermutationPortal,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
NumDimensions>>,
vtkm::internal::ArrayPortalUniformPointCoordinates>
{
using ConnectivityType = vtkm::exec::ConnectivityPermutedPointToCell<
using ConnectivityType = vtkm::exec::ConnectivityPermutedVisitCellsWithPoints<
PermutationPortal,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
NumDimensions>>;
using ThreadIndicesType = vtkm::exec::arg::ThreadIndicesTopologyMap<ConnectivityType>;

@ -7,8 +7,8 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_exec_arg_FromCount_h
#define vtk_m_exec_arg_FromCount_h
#ifndef vtk_m_exec_arg_IncidentElementCount_h
#define vtk_m_exec_arg_IncidentElementCount_h
#include <vtkm/exec/arg/ExecutionSignatureTagBase.h>
#include <vtkm/exec/arg/Fetch.h>
@ -21,32 +21,32 @@ namespace exec
namespace arg
{
/// \brief Aspect tag to use for getting the from count.
/// \brief Aspect tag to use for getting the incident element count.
///
/// The \c AspectTagFromCount aspect tag causes the \c Fetch class to obtain
/// the number of indices that map to the current topology element.
/// The \c AspectTagIncidentElementCount aspect tag causes the \c Fetch class to
/// obtain the number of indices that map to the current topology element.
///
struct AspectTagFromCount
struct AspectTagIncidentElementCount
{
};
/// \brief The \c ExecutionSignature tag to get the number of from elements.
/// \brief The \c ExecutionSignature tag to get the number of incident elements.
///
/// In a topology map, there are \em from and \em to topology elements
/// specified. The scheduling occurs on the \em to elements, and for each \em
/// to element there is some number of incident \em from elements that are
/// accessible. This \c ExecutionSignature tag provides the number of these \em
/// from elements that are accessible.
/// In a topology map, there are \em visited and \em incident topology elements
/// specified. The scheduling occurs on the \em visited elements, and for each
/// \em visited element there is some number of incident \em incident elements
/// that are accessible. This \c ExecutionSignature tag provides the number of
/// these \em incident elements that are accessible.
///
struct FromCount : vtkm::exec::arg::ExecutionSignatureTagBase
struct IncidentElementCount : vtkm::exec::arg::ExecutionSignatureTagBase
{
static constexpr vtkm::IdComponent INDEX = 1;
using AspectTag = vtkm::exec::arg::AspectTagFromCount;
using AspectTag = vtkm::exec::arg::AspectTagIncidentElementCount;
};
template <typename FetchTag, typename ConnectivityType, typename ExecObjectType>
struct Fetch<FetchTag,
vtkm::exec::arg::AspectTagFromCount,
vtkm::exec::arg::AspectTagIncidentElementCount,
vtkm::exec::arg::ThreadIndicesTopologyMap<ConnectivityType>,
ExecObjectType>
{
@ -58,7 +58,7 @@ struct Fetch<FetchTag,
VTKM_EXEC
ValueType Load(const ThreadIndicesType& indices, const ExecObjectType&) const
{
return indices.GetIndicesFrom().GetNumberOfComponents();
return indices.GetIndicesIncident().GetNumberOfComponents();
}
VTKM_EXEC
@ -71,4 +71,4 @@ struct Fetch<FetchTag,
}
} // namespace vtkm::exec::arg
#endif //vtk_m_exec_arg_FromCount_h
#endif //vtk_m_exec_arg_IncidentElementCount_h

@ -7,8 +7,8 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_exec_arg_FromIndices_h
#define vtk_m_exec_arg_FromIndices_h
#ifndef vtk_m_exec_arg_IncidentElementIndices_h
#define vtk_m_exec_arg_IncidentElementIndices_h
#include <vtkm/exec/arg/ExecutionSignatureTagBase.h>
#include <vtkm/exec/arg/Fetch.h>
@ -21,44 +21,45 @@ namespace exec
namespace arg
{
/// \brief Aspect tag to use for getting the from indices.
/// \brief Aspect tag to use for getting the visited indices.
///
/// The \c AspectTagFromIndices aspect tag causes the \c Fetch class to obtain
/// the indices that map to the current topology element.
/// The \c AspectTagIncidentElementIndices aspect tag causes the \c Fetch class
/// to obtain the indices that map to the current topology element.
///
struct AspectTagFromIndices
struct AspectTagIncidentElementIndices
{
};
/// \brief The \c ExecutionSignature tag to get the indices of from elements.
/// \brief The \c ExecutionSignature tag to get the indices of visited elements.
///
/// In a topology map, there are \em from and \em to topology elements
/// specified. The scheduling occurs on the \em to elements, and for each \em
/// to element there is some number of incident \em from elements that are
/// accessible. This \c ExecutionSignature tag provides the indices of these
/// \em from elements that are accessible.
/// In a topology map, there are \em visited and \em incident topology elements
/// specified. The scheduling occurs on the \em visited elements, and for each
/// \em visited element there is some number of incident \em incident elements
/// that are accessible. This \c ExecutionSignature tag provides the indices of
/// the \em incident elements that are incident to the current \em visited
/// element.
///
struct FromIndices : vtkm::exec::arg::ExecutionSignatureTagBase
struct IncidentElementIndices : vtkm::exec::arg::ExecutionSignatureTagBase
{
static constexpr vtkm::IdComponent INDEX = 1;
using AspectTag = vtkm::exec::arg::AspectTagFromIndices;
using AspectTag = vtkm::exec::arg::AspectTagIncidentElementIndices;
};
template <typename FetchTag, typename ConnectivityType, typename ExecObjectType>
struct Fetch<FetchTag,
vtkm::exec::arg::AspectTagFromIndices,
vtkm::exec::arg::AspectTagIncidentElementIndices,
vtkm::exec::arg::ThreadIndicesTopologyMap<ConnectivityType>,
ExecObjectType>
{
using ThreadIndicesType = vtkm::exec::arg::ThreadIndicesTopologyMap<ConnectivityType>;
using ValueType = typename ThreadIndicesType::IndicesFromType;
using ValueType = typename ThreadIndicesType::IndicesIncidentType;
VTKM_SUPPRESS_EXEC_WARNINGS
VTKM_EXEC
ValueType Load(const ThreadIndicesType& indices, const ExecObjectType&) const
{
return indices.GetIndicesFrom();
return indices.GetIndicesIncident();
}
VTKM_EXEC
@ -71,4 +72,4 @@ struct Fetch<FetchTag,
}
} // namespace vtkm::exec::arg
#endif //vtk_m_exec_arg_FromIndices_h
#endif //vtk_m_exec_arg_IncidentElementIndices_h

@ -29,7 +29,7 @@ class ThreadIndicesTopologyMap<vtkm::exec::ConnectivityExtrude<Device>>
public:
using CellShapeTag = typename ConnectivityType::CellShapeTag;
using IndicesFromType = typename ConnectivityType::IndicesType;
using IndicesIncidentType = typename ConnectivityType::IndicesType;
using LogicalIndexType = typename ConnectivityType::SchedulingRangeType;
@ -49,7 +49,7 @@ public:
this->OutputIndex = index;
this->VisitIndex = 0;
this->LogicalIndex = logicalIndex;
this->IndicesFrom = connectivity.GetIndices(logicalIndex);
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
//this->CellShape = connectivity.GetCellShape(index);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -70,7 +70,7 @@ public:
this->OutputIndex = index;
this->VisitIndex = 0;
this->LogicalIndex = logicalIndex;
this->IndicesFrom = connectivity.GetIndices(logicalIndex);
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
//this->CellShape = connectivity.GetCellShape(index);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -128,7 +128,7 @@ public:
/// containing the indices to the "from" elements.
///
VTKM_EXEC
const IndicesFromType& GetIndicesFrom() const { return this->IndicesFrom; }
const IndicesIncidentType& GetIndicesIncident() const { return this->IndicesIncident; }
/// \brief The input indices of the "from" elements in pointer form.
///
@ -140,7 +140,7 @@ public:
/// not go out of scope, at which time the returned pointer becomes invalid.
///
VTKM_EXEC
const IndicesFromType* GetIndicesFromPointer() const { return &this->IndicesFrom; }
const IndicesIncidentType* GetIndicesIncidentPointer() const { return &this->IndicesIncident; }
/// \brief The shape of the input cell.
///
@ -158,7 +158,7 @@ private:
vtkm::IdComponent VisitIndex;
vtkm::Id OutputIndex;
LogicalIndexType LogicalIndex;
IndicesFromType IndicesFrom;
IndicesIncidentType IndicesIncident;
//CellShapeTag CellShape;
vtkm::Id GlobalThreadIndexOffset;
};
@ -171,7 +171,7 @@ class ThreadIndicesTopologyMap<vtkm::exec::ReverseConnectivityExtrude<Device>>
public:
using CellShapeTag = typename ConnectivityType::CellShapeTag;
using IndicesFromType = typename ConnectivityType::IndicesType;
using IndicesIncidentType = typename ConnectivityType::IndicesType;
using LogicalIndexType = typename ConnectivityType::SchedulingRangeType;
VTKM_SUPPRESS_EXEC_WARNINGS
@ -191,7 +191,7 @@ public:
this->OutputIndex = index;
this->VisitIndex = 0;
this->LogicalIndex = logicalIndex;
this->IndicesFrom = connectivity.GetIndices(logicalIndex);
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
//this->CellShape = connectivity.GetCellShape(index);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -209,7 +209,7 @@ public:
this->OutputIndex = index;
this->VisitIndex = 0;
this->LogicalIndex = logicalIndex;
this->IndicesFrom = connectivity.GetIndices(logicalIndex);
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
//this->CellShape = connectivity.GetCellShape(index);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -266,7 +266,7 @@ public:
/// containing the indices to the "from" elements.
///
VTKM_EXEC
const IndicesFromType& GetIndicesFrom() const { return this->IndicesFrom; }
const IndicesIncidentType& GetIndicesIncident() const { return this->IndicesIncident; }
/// \brief The input indices of the "from" elements in pointer form.
///
@ -278,7 +278,7 @@ public:
/// not go out of scope, at which time the returned pointer becomes invalid.
///
VTKM_EXEC
const IndicesFromType* GetIndicesFromPointer() const { return &this->IndicesFrom; }
const IndicesIncidentType* GetIndicesIncidentPointer() const { return &this->IndicesIncident; }
/// \brief The shape of the input cell.
///
@ -296,7 +296,7 @@ private:
vtkm::IdComponent VisitIndex;
vtkm::Id OutputIndex;
LogicalIndexType LogicalIndex;
IndicesFromType IndicesFrom;
IndicesIncidentType IndicesIncident;
//CellShapeTag CellShape;
vtkm::Id GlobalThreadIndexOffset;
};

@ -58,15 +58,15 @@ public:
template <vtkm::IdComponent Dimension>
VTKM_EXEC ThreadIndicesPointNeighborhood(
const vtkm::Id3& outIndex,
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
Dimension>& connectivity,
vtkm::Id globalThreadIndexOffset = 0)
: State(outIndex, detail::To3D(connectivity.GetPointDimensions()))
, GlobalThreadIndexOffset(globalThreadIndexOffset)
{
using ConnectivityType = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
using ConnectivityType = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
Dimension>;
using ConnRangeType = typename ConnectivityType::SchedulingRangeType;
const ConnRangeType index = detail::Deflate(outIndex, ConnRangeType());
@ -82,8 +82,8 @@ public:
vtkm::Id inputIndex,
vtkm::IdComponent visitIndex,
vtkm::Id outputIndex,
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
Dimension>& connectivity,
vtkm::Id globalThreadIndexOffset = 0)
: State(detail::To3D(connectivity.FlatToLogicalToIndex(inputIndex)),

@ -73,9 +73,9 @@ static inline VTKM_EXEC vtkm::Id2 Deflate(const vtkm::Id3& index, vtkm::Id2)
/// \brief Container for thread indices in a topology map
///
/// This specialization of \c ThreadIndices adds extra indices that deal with
/// topology maps. In particular, it saves the indices used to map the "from"
/// elements in the map. The input and output indices from the superclass are
/// considered to be indexing the "to" elements.
/// topology maps. In particular, it saves the incident element indices. The
/// input and output indices from the superclass are considered to be indexing
/// the visited elements.
///
/// This class is templated on the type that stores the connectivity (such
/// as \c ConnectivityExplicit or \c ConnectivityStructured).
@ -86,7 +86,7 @@ class ThreadIndicesTopologyMap : public vtkm::exec::arg::ThreadIndicesBasic
using Superclass = vtkm::exec::arg::ThreadIndicesBasic;
public:
using IndicesFromType = typename ConnectivityType::IndicesType;
using IndicesIncidentType = typename ConnectivityType::IndicesType;
using CellShapeTag = typename ConnectivityType::CellShapeTag;
VTKM_SUPPRESS_EXEC_WARNINGS
@ -102,24 +102,24 @@ public:
// of the domain will match the connectivity type used here. If there is
// a compile error here about a type mismatch, chances are a worklet has
// set its input domain incorrectly.
, IndicesFrom(connectivity.GetIndices(inputIndex))
, IndicesIncident(connectivity.GetIndices(inputIndex))
, CellShape(connectivity.GetCellShape(inputIndex))
{
}
/// \brief The input indices of the "from" elements.
/// \brief The indices of the incident elements.
///
/// A topology map has "from" and "to" elements (for example from points to
/// cells). For each worklet invocation, there is exactly one "to" element,
/// but can be several "from" element. This method returns a Vec-like object
/// containing the indices to the "from" elements.
/// A topology map has "visited" and "incident" elements (e.g. points, cells,
/// etc). For each worklet invocation, there is exactly one visited element,
/// but there can be several incident elements. This method returns a Vec-like
/// object containing the indices to the incident elements.
///
VTKM_EXEC
const IndicesFromType& GetIndicesFrom() const { return this->IndicesFrom; }
const IndicesIncidentType& GetIndicesIncident() const { return this->IndicesIncident; }
/// \brief The input indices of the "from" elements in pointer form.
/// \brief The input indices of the incident elements in pointer form.
///
/// Returns the same object as GetIndicesFrom except that it returns a
/// Returns the same object as GetIndicesIncident except that it returns a
/// pointer to the internally held object rather than a reference or copy.
/// Since the from indices can be a sizeable Vec (8 entries is common), it is
/// best not to have a bunch a copies. Thus, you can pass around a pointer
@ -127,7 +127,7 @@ public:
/// not go out of scope, at which time the returned pointer becomes invalid.
///
VTKM_EXEC
const IndicesFromType* GetIndicesFromPointer() const { return &this->IndicesFrom; }
const IndicesIncidentType* GetIndicesIncidentPointer() const { return &this->IndicesIncident; }
/// \brief The shape of the input cell.
///
@ -140,19 +140,20 @@ public:
CellShapeTag GetCellShape() const { return this->CellShape; }
private:
IndicesFromType IndicesFrom;
IndicesIncidentType IndicesIncident;
CellShapeTag CellShape;
};
// Specialization for structured connectivity types.
template <typename FromTopology, typename ToTopology, vtkm::IdComponent Dimension>
template <typename VisitTopology, typename IncidentTopology, vtkm::IdComponent Dimension>
class ThreadIndicesTopologyMap<
vtkm::exec::ConnectivityStructured<FromTopology, ToTopology, Dimension>>
vtkm::exec::ConnectivityStructured<VisitTopology, IncidentTopology, Dimension>>
{
using ConnectivityType = vtkm::exec::ConnectivityStructured<FromTopology, ToTopology, Dimension>;
using ConnectivityType =
vtkm::exec::ConnectivityStructured<VisitTopology, IncidentTopology, Dimension>;
public:
using IndicesFromType = typename ConnectivityType::IndicesType;
using IndicesIncidentType = typename ConnectivityType::IndicesType;
using CellShapeTag = typename ConnectivityType::CellShapeTag;
using LogicalIndexType = typename ConnectivityType::SchedulingRangeType;
@ -168,7 +169,7 @@ public:
this->VisitIndex = visitIndex;
this->OutputIndex = outIndex;
this->LogicalIndex = connectivity.FlatToLogicalToIndex(this->InputIndex);
this->IndicesFrom = connectivity.GetIndices(this->LogicalIndex);
this->IndicesIncident = connectivity.GetIndices(this->LogicalIndex);
this->CellShape = connectivity.GetCellShape(this->InputIndex);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -188,7 +189,7 @@ public:
this->OutputIndex = index;
this->VisitIndex = 0;
this->LogicalIndex = logicalIndex;
this->IndicesFrom = connectivity.GetIndices(logicalIndex);
this->IndicesIncident = connectivity.GetIndices(logicalIndex);
this->CellShape = connectivity.GetCellShape(index);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -247,19 +248,19 @@ public:
VTKM_EXEC
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
/// \brief The input indices of the "from" elements.
/// \brief The indices of the incident elements.
///
/// A topology map has "from" and "to" elements (for example from points to
/// cells). For each worklet invocation, there is exactly one "to" element,
/// but can be several "from" element. This method returns a Vec-like object
/// containing the indices to the "from" elements.
/// A topology map has "visited" and "incident" elements (e.g. points, cells,
/// etc). For each worklet invocation, there is exactly one visited element,
/// but there can be several incident elements. This method returns a
/// Vec-like object containing the indices to the incident elements.
///
VTKM_EXEC
const IndicesFromType& GetIndicesFrom() const { return this->IndicesFrom; }
const IndicesIncidentType& GetIndicesIncident() const { return this->IndicesIncident; }
/// \brief The input indices of the "from" elements in pointer form.
/// \brief The input indices of the incident elements in pointer form.
///
/// Returns the same object as GetIndicesFrom except that it returns a
/// Returns the same object as GetIndicesIncident except that it returns a
/// pointer to the internally held object rather than a reference or copy.
/// Since the from indices can be a sizeable Vec (8 entries is common), it is
/// best not to have a bunch a copies. Thus, you can pass around a pointer
@ -267,7 +268,7 @@ public:
/// not go out of scope, at which time the returned pointer becomes invalid.
///
VTKM_EXEC
const IndicesFromType* GetIndicesFromPointer() const { return &this->IndicesFrom; }
const IndicesIncidentType* GetIndicesIncidentPointer() const { return &this->IndicesIncident; }
/// \brief The shape of the input cell.
///
@ -285,29 +286,29 @@ private:
vtkm::IdComponent VisitIndex;
vtkm::Id OutputIndex;
LogicalIndexType LogicalIndex;
IndicesFromType IndicesFrom;
IndicesIncidentType IndicesIncident;
CellShapeTag CellShape;
vtkm::Id GlobalThreadIndexOffset;
};
// Specialization for permuted structured connectivity types.
template <typename PermutationPortal, vtkm::IdComponent Dimension>
class ThreadIndicesTopologyMap<vtkm::exec::ConnectivityPermutedPointToCell<
class ThreadIndicesTopologyMap<vtkm::exec::ConnectivityPermutedVisitCellsWithPoints<
PermutationPortal,
vtkm::exec::
ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, Dimension>>>
ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, Dimension>>>
{
using PermutedConnectivityType = vtkm::exec::ConnectivityPermutedPointToCell<
using PermutedConnectivityType = vtkm::exec::ConnectivityPermutedVisitCellsWithPoints<
PermutationPortal,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
Dimension>>;
using ConnectivityType = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
using ConnectivityType = vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
Dimension>;
public:
using IndicesFromType = typename ConnectivityType::IndicesType;
using IndicesIncidentType = typename ConnectivityType::IndicesType;
using CellShapeTag = typename ConnectivityType::CellShapeTag;
using LogicalIndexType = typename ConnectivityType::SchedulingRangeType;
@ -325,7 +326,7 @@ public:
const vtkm::Id permutedIndex = permutation.Portal.Get(this->InputIndex);
this->LogicalIndex = permutation.Connectivity.FlatToLogicalToIndex(permutedIndex);
this->IndicesFrom = permutation.Connectivity.GetIndices(this->LogicalIndex);
this->IndicesIncident = permutation.Connectivity.GetIndices(this->LogicalIndex);
this->CellShape = permutation.Connectivity.GetCellShape(permutedIndex);
this->GlobalThreadIndexOffset = globalThreadIndexOffset;
}
@ -384,19 +385,19 @@ public:
VTKM_EXEC
vtkm::Id GetGlobalIndex() const { return (this->GlobalThreadIndexOffset + this->OutputIndex); }
/// \brief The input indices of the "from" elements.
/// \brief The indices of the incident elements.
///
/// A topology map has "from" and "to" elements (for example from points to
/// cells). For each worklet invocation, there is exactly one "to" element,
/// but can be several "from" element. This method returns a Vec-like object
/// containing the indices to the "from" elements.
/// A topology map has "visited" and "incident" elements (e.g. points, cells,
/// etc). For each worklet invocation, there is exactly one visited element,
/// but there can be several incident elements. This method returns a
/// Vec-like object containing the indices to the incident elements.
///
VTKM_EXEC
const IndicesFromType& GetIndicesFrom() const { return this->IndicesFrom; }
const IndicesIncidentType& GetIndicesIncident() const { return this->IndicesIncident; }
/// \brief The input indices of the "from" elements in pointer form.
/// \brief The input indices of the incident elements in pointer form.
///
/// Returns the same object as GetIndicesFrom except that it returns a
/// Returns the same object as GetIndicesIncident except that it returns a
/// pointer to the internally held object rather than a reference or copy.
/// Since the from indices can be a sizeable Vec (8 entries is common), it is
/// best not to have a bunch a copies. Thus, you can pass around a pointer
@ -404,7 +405,7 @@ public:
/// not go out of scope, at which time the returned pointer becomes invalid.
///
VTKM_EXEC
const IndicesFromType* GetIndicesFromPointer() const { return &this->IndicesFrom; }
const IndicesIncidentType* GetIndicesIncidentPointer() const { return &this->IndicesIncident; }
/// \brief The shape of the input cell.
///
@ -422,7 +423,7 @@ private:
vtkm::IdComponent VisitIndex;
vtkm::Id OutputIndex;
LogicalIndexType LogicalIndex;
IndicesFromType IndicesFrom;
IndicesIncidentType IndicesIncident;
CellShapeTag CellShape;
vtkm::Id GlobalThreadIndexOffset;
};

@ -105,8 +105,8 @@ struct FetchArrayNeighborhoodInTests
vtkm::internal::ConnectivityStructuredInternals<3> connectivityInternals;
connectivityInternals.SetPointDimensions(POINT_DIMS);
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
3>
connectivity(connectivityInternals);

@ -107,8 +107,8 @@ struct FetchArrayTopologyMapInTests
vtkm::internal::ConnectivityStructuredInternals<3> connectivityInternals;
connectivityInternals.SetPointDimensions(vtkm::Id3(2, 2, 2));
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
3>
connectivity(connectivityInternals);
@ -182,8 +182,8 @@ void TryStructuredPointCoordinatesInvocation(const Invocation& invocation)
template <vtkm::IdComponent NumDimensions>
void TryStructuredPointCoordinates(
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell,
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint,
NumDimensions>& connectivity,
const vtkm::internal::ArrayPortalUniformPointCoordinates& coordinates)
{
@ -221,21 +221,21 @@ void TryStructuredPointCoordinates()
std::cout << "3D" << std::endl;
vtkm::internal::ConnectivityStructuredInternals<3> connectivityInternals3d;
connectivityInternals3d.SetPointDimensions(vtkm::Id3(3, 2, 2));
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 3>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 3>
connectivity3d(connectivityInternals3d);
TryStructuredPointCoordinates(connectivity3d, coordinates);
std::cout << "2D" << std::endl;
vtkm::internal::ConnectivityStructuredInternals<2> connectivityInternals2d;
connectivityInternals2d.SetPointDimensions(vtkm::Id2(3, 2));
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 2>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 2>
connectivity2d(connectivityInternals2d);
TryStructuredPointCoordinates(connectivity2d, coordinates);
std::cout << "1D" << std::endl;
vtkm::internal::ConnectivityStructuredInternals<1> connectivityInternals1d;
connectivityInternals1d.SetPointDimensions(3);
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, 1>
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, 1>
connectivity1d(connectivityInternals1d);
TryStructuredPointCoordinates(connectivity1d, coordinates);
}

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