mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merged with master.
This commit is contained in:
commit
ad497e2619
@ -25,10 +25,8 @@ doxygen:
|
||||
- "cmake -V -P .gitlab/ci/config/gitlab_ci_setup.cmake"
|
||||
- "ctest -VV -S .gitlab/ci/ctest_configure.cmake"
|
||||
script:
|
||||
- eval `ssh-agent -s`
|
||||
- ssh-add <(echo "$DOC_API_KEY_BASE64" | base64 --decode)
|
||||
- doxygen build/docs/doxyfile
|
||||
- rsync -tv --recursive --delete -e "ssh -o StrictHostKeyChecking=no" build/docs/doxygen/html/ vtkm.documentation
|
||||
- rsync -tv --recursive --delete -e "ssh -i $DOC_KEY_FILE -o StrictHostKeyChecking=no" build/docs/doxygen/html/ kitware@public.kitware.com:vtkm_documentation/
|
||||
variables:
|
||||
CMAKE_BUILD_TYPE: Release
|
||||
VTKM_SETTINGS: "tbb+openmp+mpi+shared+docs"
|
||||
|
@ -97,8 +97,8 @@ void BenchContToExecRead(benchmark::State& state)
|
||||
state.SetLabel(desc.str());
|
||||
}
|
||||
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues));
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec);
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues), 2);
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec, vtkm::CopyFlag::On);
|
||||
|
||||
vtkm::cont::Invoker invoker{ device };
|
||||
vtkm::cont::Timer timer{ device };
|
||||
@ -181,8 +181,8 @@ void BenchContToExecReadWrite(benchmark::State& state)
|
||||
state.SetLabel(desc.str());
|
||||
}
|
||||
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues));
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec);
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues), 2);
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec, vtkm::CopyFlag::On);
|
||||
|
||||
vtkm::cont::Invoker invoker{ device };
|
||||
vtkm::cont::Timer timer{ device };
|
||||
@ -223,8 +223,8 @@ void BenchRoundTripRead(benchmark::State& state)
|
||||
state.SetLabel(desc.str());
|
||||
}
|
||||
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues));
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec);
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues), 2);
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec, vtkm::CopyFlag::On);
|
||||
|
||||
vtkm::cont::Invoker invoker{ device };
|
||||
vtkm::cont::Timer timer{ device };
|
||||
@ -277,7 +277,7 @@ void BenchRoundTripReadWrite(benchmark::State& state)
|
||||
}
|
||||
|
||||
std::vector<ValueType> vec(static_cast<std::size_t>(numValues));
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec);
|
||||
ArrayType array = vtkm::cont::make_ArrayHandle(vec, vtkm::CopyFlag::On);
|
||||
|
||||
vtkm::cont::Invoker invoker{ device };
|
||||
vtkm::cont::Timer timer{ device };
|
||||
|
@ -860,8 +860,12 @@ void InitDataSet(int& argc, char** argv)
|
||||
|
||||
if (options[HELP])
|
||||
{
|
||||
// FIXME: Print google benchmark usage too
|
||||
option::printUsage(std::cerr, usage.data());
|
||||
option::printUsage(std::cout, usage.data());
|
||||
// Print google benchmark usage too
|
||||
const char* helpstr = "--help";
|
||||
char* tmpargv[] = { argv[0], const_cast<char*>(helpstr), nullptr };
|
||||
int tmpargc = 2;
|
||||
VTKM_EXECUTE_BENCHMARKS(tmpargc, tmpargv);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -1014,16 +1018,12 @@ int main(int argc, char* argv[])
|
||||
// Parse VTK-m options:
|
||||
Config = vtkm::cont::Initialize(argc, args.data(), opts);
|
||||
|
||||
// This occurs when it is help
|
||||
if (opts == vtkm::cont::InitializeOptions::None)
|
||||
{
|
||||
std::cout << Config.Usage << std::endl;
|
||||
}
|
||||
else
|
||||
// This opts changes when it is help
|
||||
if (opts != vtkm::cont::InitializeOptions::None)
|
||||
{
|
||||
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(Config.Device);
|
||||
InitDataSet(argc, args.data());
|
||||
}
|
||||
InitDataSet(argc, args.data());
|
||||
|
||||
const std::string dataSetSummary = []() -> std::string {
|
||||
std::ostringstream out;
|
||||
|
39
docs/changelog/deprecate-arrayhandlevirtualcoordinates.md
Normal file
39
docs/changelog/deprecate-arrayhandlevirtualcoordinates.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Deprecate ArrayHandleVirtualCoordinates
|
||||
|
||||
As we port VTK-m to more types of accelerator architectures, supporting
|
||||
virtual methods is becoming more problematic. Thus, we are working to back
|
||||
out of using virtual methods in the execution environment.
|
||||
|
||||
One of the most widespread users of virtual methods in the execution
|
||||
environment is `ArrayHandleVirtual`. As a first step of deprecating this
|
||||
class, we first deprecate the `ArrayHandleVirtualCoordinates` subclass.
|
||||
|
||||
Not surprisingly, `ArrayHandleVirtualCoordinates` is used directly by
|
||||
`CoordinateSystem`. The biggest change necessary was that the `GetData`
|
||||
method returned an `ArrayHandleVirtualCoordinates`, which obviously would
|
||||
not work if that class is deprecated.
|
||||
|
||||
An oddness about this return type is that it is quite different from the
|
||||
superclass's method of the same name. Rather, `Field` returns a
|
||||
`VariantArrayHandle`. Since this had to be corrected anyway, it was decided
|
||||
to change `CoordinateSystem`'s `GetData` to also return a
|
||||
`VariantArrayHandle`, although its typelist is set to just `vtkm::Vec3f`.
|
||||
|
||||
To try to still support old code that expects the deprecated behavior of
|
||||
returning an `ArrayHandleVirtualCoordinates`, `CoordinateSystem::GetData`
|
||||
actually returns a "hidden" subclass of `VariantArrayHandle` that
|
||||
automatically converts itself to an `ArrayHandleVirtualCoordinates`. (A
|
||||
deprecation warning is given if this is done.)
|
||||
|
||||
This approach to support deprecated code is not perfect. The returned value
|
||||
for `CoordinateSystem::GetData` can only be used as an `ArrayHandle` if a
|
||||
method is directly called on it or if it is cast specifically to
|
||||
`ArrayHandleVirtualCoordinates` or its superclass. For example, if passing
|
||||
it to a method argument typed as `vtkm::cont::ArrayHandle<T, S>` where `T`
|
||||
and `S` are template parameters, then the conversion will fail.
|
||||
|
||||
To continue to support ease of use, `CoordinateSystem` now has a method
|
||||
named `GetDataAsMultiplexer` that returns the data as an
|
||||
`ArrayHandleMultiplexer`. This can be employed to quickly use the
|
||||
`CoordinateSystem` as an array without the overhead of a `CastAndCall`.
|
||||
|
120
docs/changelog/move-std-vector.md
Normal file
120
docs/changelog/move-std-vector.md
Normal file
@ -0,0 +1,120 @@
|
||||
# Improvements to moving data into ArrayHandle
|
||||
|
||||
We have made several improvements to adding data into an `ArrayHandle`.
|
||||
|
||||
## Moving data from an `std::vector`
|
||||
|
||||
For numerous reasons, it is convenient to define data in a `std::vector`
|
||||
and then wrap that into an `ArrayHandle`. There are two obvious ways to do
|
||||
this. First, you could deep copy the data into an `ArrayHandle`, which has
|
||||
obvious drawbacks. Second, you could take the pointer for the data in the
|
||||
`std::vector` and use that as user-allocated memory in the `ArrayHandle`
|
||||
without deep copying it. The problem with this shallow copy is that it is
|
||||
unsafe. If the `std::vector` goes out of scope (or gets resized), then the
|
||||
data the `ArrayHandle` is pointing to becomes unallocated, which will lead
|
||||
to unpredictable behavior.
|
||||
|
||||
However, there is a third option. It is often the case that an
|
||||
`std::vector` is filled and then becomes unused once it is converted to an
|
||||
`ArrayHandle`. In this case, what we really want is to pass the data off to
|
||||
the `ArrayHandle` so that the `ArrayHandle` is now managing the data and
|
||||
not the `std::vector`.
|
||||
|
||||
C++11 has a mechanism to do this: move semantics. You can now pass
|
||||
variables to functions as an "rvalue" (right-hand value). When something is
|
||||
passed as an rvalue, it can pull state out of that variable and move it
|
||||
somewhere else. `std::vector` implements this movement so that an rvalue
|
||||
can be moved to another `std::vector` without actually copying the data.
|
||||
`make_ArrayHandle` now also takes advantage of this feature to move rvalue
|
||||
`std::vector`s.
|
||||
|
||||
There is a special form of `make_ArrayHandle` named `make_ArrayHandleMove`
|
||||
that takes an rvalue. There is also a special overload of
|
||||
`make_ArrayHandle` itself that handles an rvalue `vector`. (However, using
|
||||
the explicit move version is better if you want to make sure the data is
|
||||
actually moved.)
|
||||
|
||||
So if you create the `std::vector` in the call to `make_ArrayHandle`, then
|
||||
the data only gets created once.
|
||||
|
||||
``` cpp
|
||||
auto array = vtkm::cont::make_ArrayHandleMove(std::vector<vtkm::Id>{ 2, 6, 1, 7, 4, 3, 9 });
|
||||
```
|
||||
|
||||
Note that there is now a better way to express an initializer list to
|
||||
`ArrayHandle` documented below. But this form of `ArrayHandleMove` can be
|
||||
particularly useful for initializing an array to all of a particular value.
|
||||
For example, an easy way to initialize an array of 1000 elements all to 1
|
||||
is
|
||||
|
||||
``` cpp
|
||||
auto array = vtkm::cont::make_ArrayHandleMove(std::vector<vtkm::Id>(1000, 1));
|
||||
```
|
||||
|
||||
You can also move the data from an already created `std::vector` by using
|
||||
the `std::move` function to convert it to an rvalue. When you do this, the
|
||||
`std::vector` becomes invalid after the call and any use will be undefined.
|
||||
|
||||
``` cpp
|
||||
std::vector<vtkm::Id> vector;
|
||||
// fill vector
|
||||
|
||||
auto array = vtkm::cont::make_ArrayHandleMove(std::move(vector));
|
||||
```
|
||||
|
||||
## Make `ArrayHandle` from initalizer list
|
||||
|
||||
A common use case for using `std::vector` (particularly in our unit tests)
|
||||
is to quickly add an initalizer list into an `ArrayHandle`. Repeating the
|
||||
example from above:
|
||||
|
||||
``` cpp
|
||||
auto array = vtkm::cont::make_ArrayHandleMove(std::vector<vtkm::Id>{ 2, 6, 1, 7, 4, 3, 9 });
|
||||
```
|
||||
|
||||
However, creating the `std::vector` should be unnecessary. Why not be able
|
||||
to create the `ArrayHandle` directly from an initializer list? Now you can
|
||||
by simply passing an initializer list to `make_ArrayHandle`.
|
||||
|
||||
``` cpp
|
||||
auto array = vtkm::cont::make_ArrayHandle({ 2, 6, 1, 7, 4, 3, 9 });
|
||||
```
|
||||
|
||||
There is an issue here. The type here can be a little ambiguous (for
|
||||
humans). In this case, `array` will be of type
|
||||
`vtkm::cont::ArrayHandleBasic<int>`, since that is what an integer literal
|
||||
defaults to. This could be a problem if, for example, you want to use
|
||||
`array` as an array of `vtkm::Id`, which could be of type `vtkm::Int64`.
|
||||
This is easily remedied by specifying the desired value type as a template
|
||||
argument to `make_ArrayHandle`.
|
||||
|
||||
``` cpp
|
||||
auto array = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 2, 6, 1, 7, 4, 3, 9 });
|
||||
```
|
||||
|
||||
## Deprecated `make_ArrayHandle` with default shallow copy
|
||||
|
||||
For historical reasons, passing an `std::vector` or a pointer to
|
||||
`make_ArrayHandle` does a shallow copy (i.e. `CopyFlag` defaults to `Off`).
|
||||
Although more efficient, this mode is inherintly unsafe, and making it the
|
||||
default is asking for trouble.
|
||||
|
||||
To combat this, calling `make_ArrayHandle` without a copy flag is
|
||||
deprecated. In this way, if you wish to do the faster but more unsafe
|
||||
creation of an `ArrayHandle` you should explicitly express that.
|
||||
|
||||
This requried quite a few changes through the VTK-m source (particularly in
|
||||
the tests).
|
||||
|
||||
## Similar changes to `Field`
|
||||
|
||||
`vtkm::cont::Field` has a `make_Field` helper function that is similar to
|
||||
`make_ArrayHandle`. It also features the ability to create fields from
|
||||
`std::vector`s and C arrays. It also likewise had the same unsafe behavior
|
||||
by default of not copying from the source of the arrays.
|
||||
|
||||
That behavior has similarly been depreciated. You now have to specify a
|
||||
copy flag.
|
||||
|
||||
The ability to construct a `Field` from an initializer list of values has
|
||||
also been added.
|
@ -22,6 +22,7 @@ if(VTKm_ENABLE_EXAMPLES)
|
||||
add_subdirectory(game_of_life)
|
||||
add_subdirectory(hello_worklet)
|
||||
add_subdirectory(histogram)
|
||||
add_subdirectory(ising)
|
||||
add_subdirectory(lagrangian)
|
||||
add_subdirectory(mesh_quality)
|
||||
add_subdirectory(multi_backend)
|
||||
|
@ -52,11 +52,11 @@ void TestCosmoCenterFinder(const char* fileName)
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> xLocArray =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(xLocation, nParticles);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(xLocation, nParticles, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> yLocArray =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(yLocation, nParticles);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(yLocation, nParticles, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> zLocArray =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(zLocation, nParticles);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(zLocation, nParticles, vtkm::CopyFlag::Off);
|
||||
|
||||
// Output MBP particleId pairs array
|
||||
vtkm::Pair<vtkm::Id, vtkm::Float32> nxnResult;
|
||||
|
@ -53,11 +53,11 @@ void TestCosmoHaloFinder(const char* fileName)
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> xLocArray =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(xLocation, nParticles);
|
||||
vtkm::cont::make_ArrayHandleMove<vtkm::Float32>(xLocation, nParticles);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> yLocArray =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(yLocation, nParticles);
|
||||
vtkm::cont::make_ArrayHandleMove<vtkm::Float32>(yLocation, nParticles);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> zLocArray =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Float32>(zLocation, nParticles);
|
||||
vtkm::cont::make_ArrayHandleMove<vtkm::Float32>(zLocation, nParticles);
|
||||
|
||||
// Output halo id, mbp id and min potential per particle
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> resultHaloId;
|
||||
@ -88,10 +88,6 @@ void TestCosmoHaloFinder(const char* fileName)
|
||||
xLocArray.ReleaseResources();
|
||||
yLocArray.ReleaseResources();
|
||||
zLocArray.ReleaseResources();
|
||||
|
||||
delete[] xLocation;
|
||||
delete[] yLocation;
|
||||
delete[] zLocation;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
@ -29,10 +28,8 @@
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
#include <vtkm/worklet/WorkletPointNeighborhood.h>
|
||||
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
|
||||
|
||||
//Suppress warnings about glut being deprecated on OSX
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
|
21
examples/ising/CMakeLists.txt
Normal file
21
examples/ising/CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
##============================================================================
|
||||
## 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.12...3.15 FATAL_ERROR)
|
||||
project(IsingModel CXX)
|
||||
|
||||
#Find the VTK-m package
|
||||
find_package(VTKm REQUIRED QUIET)
|
||||
|
||||
add_executable(Ising Ising.cxx)
|
||||
target_link_libraries(Ising PRIVATE vtkm_worklet vtkm_io vtkm_rendering)
|
||||
|
||||
vtkm_add_target_information(Ising
|
||||
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
|
||||
DEVICE_SOURCES Ising.cxx)
|
122
examples/ising/Ising.cxx
Normal file
122
examples/ising/Ising.cxx
Normal file
@ -0,0 +1,122 @@
|
||||
//
|
||||
// Created by ollie on 7/8/20.
|
||||
//
|
||||
//============================================================================
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
/// Simulation of ferromagnetism using the Ising Model
|
||||
/// Reference: Computational Physics 2nd Edition, Nicholas Giordano & Hisao Nakanishi
|
||||
|
||||
#include <iomanip>
|
||||
#include <vtkm/cont/ArrayHandleRandomUniformReal.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/Initialize.h>
|
||||
#include <vtkm/rendering/CanvasRayTracer.h>
|
||||
#include <vtkm/rendering/MapperRayTracer.h>
|
||||
#include <vtkm/rendering/Scene.h>
|
||||
#include <vtkm/rendering/View2D.h>
|
||||
#include <vtkm/worklet/WorkletCellNeighborhood.h>
|
||||
|
||||
struct UpDown
|
||||
{
|
||||
VTKM_EXEC_CONT vtkm::Float32 operator()(vtkm::Float32 p) const { return p > 0.5 ? 1.0f : -1.0f; }
|
||||
};
|
||||
|
||||
vtkm::cont::DataSet SpinField(vtkm::Id2 dims)
|
||||
{
|
||||
auto result =
|
||||
vtkm::cont::DataSetBuilderUniform::Create(dims, vtkm::Vec2f{ 0, 0 }, vtkm::Vec2f{ 1, 1 });
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> spins;
|
||||
vtkm::cont::ArrayCopy(
|
||||
vtkm::cont::make_ArrayHandleTransform(
|
||||
vtkm::cont::ArrayHandleRandomUniformReal<vtkm::Float32>(result.GetNumberOfCells()), UpDown{}),
|
||||
spins);
|
||||
result.AddCellField("spins", spins);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
struct UpdateSpins : public vtkm::worklet::WorkletCellNeighborhood
|
||||
{
|
||||
using ControlSignature = void(CellSetIn,
|
||||
FieldInNeighborhood prevspin,
|
||||
FieldIn prob,
|
||||
FieldOut spin);
|
||||
using ExecutionSignature = void(_2, _3, _4);
|
||||
|
||||
template <typename NeighIn>
|
||||
VTKM_EXEC_CONT void operator()(const NeighIn& prevspin,
|
||||
vtkm::Float32 p,
|
||||
vtkm::Float32& spin) const
|
||||
{
|
||||
// TODO: what is the real value and unit of the change constant J and Boltzmann constant kB?
|
||||
const vtkm::Float32 J = 1.f;
|
||||
const vtkm::Float32 kB = 1.f;
|
||||
// TODO: temperature in Kelvin
|
||||
const vtkm::Float32 T = 5.f;
|
||||
const auto mySpin = prevspin.Get(0, 0, 0);
|
||||
|
||||
// 1. Calculate the energy of flipping, E_flip
|
||||
vtkm::Float32 E_flip =
|
||||
J * mySpin * (prevspin.Get(-1, -1, 0) + prevspin.Get(-1, 0, 0) + prevspin.Get(-1, 1, 0) +
|
||||
prevspin.Get(0, -1, 0) + prevspin.Get(0, 1, 0) + prevspin.Get(1, -1, 0) +
|
||||
prevspin.Get(1, 0, 0) + prevspin.Get(1, 1, 0));
|
||||
|
||||
if (E_flip <= 0)
|
||||
{
|
||||
// 2. If E_flip <= 0, just flip the spin
|
||||
spin = -1.f * mySpin;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3. otherwise, flip the spin if the Boltzmann factor exp(-E_flip/kB*T) is larger than the
|
||||
// uniform real random number p.
|
||||
if (p <= vtkm::Exp(-E_flip / (kB * T)))
|
||||
spin = -1.f * mySpin;
|
||||
else
|
||||
spin = mySpin;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
auto opts =
|
||||
vtkm::cont::InitializeOptions::DefaultAnyDevice | vtkm::cont::InitializeOptions::Strict;
|
||||
vtkm::cont::Initialize(argc, argv, opts);
|
||||
|
||||
auto dataSet = SpinField({ 5, 5 });
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> spins;
|
||||
dataSet.GetCellField("spins").GetData().CopyTo(spins);
|
||||
|
||||
vtkm::rendering::Scene scene;
|
||||
vtkm::rendering::Actor actor(dataSet.GetCellSet(),
|
||||
dataSet.GetCoordinateSystem(),
|
||||
dataSet.GetCellField("spins"),
|
||||
vtkm::cont::ColorTable("Cool To Warm"));
|
||||
scene.AddActor(actor);
|
||||
vtkm::rendering::CanvasRayTracer canvas(1024, 1024);
|
||||
vtkm::rendering::MapperRayTracer mapper;
|
||||
mapper.SetShadingOn(false);
|
||||
vtkm::rendering::View2D view(scene, mapper, canvas);
|
||||
view.Paint();
|
||||
view.SaveAs("spin0.png");
|
||||
|
||||
vtkm::cont::Invoker invoker;
|
||||
for (vtkm::UInt32 i = 1; i < 10; ++i)
|
||||
{
|
||||
vtkm::cont::ArrayHandleRandomUniformReal<vtkm::Float32> prob(dataSet.GetNumberOfCells(), { i });
|
||||
invoker(UpdateSpins{}, dataSet.GetCellSet(), spins, prob, spins);
|
||||
view.Paint();
|
||||
view.SaveAs("spin" + std::to_string(i) + ".png");
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ vtkm::cont::DataSet make_test3DImageData(vtkm::Id3 dims)
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> field;
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(WaveField{}, ds.GetCoordinateSystem(), field);
|
||||
invoke(WaveField{}, ds.GetCoordinateSystem().GetDataAsMultiplexer(), field);
|
||||
|
||||
ds.AddPointField("vec_field", field);
|
||||
return ds;
|
||||
|
@ -57,11 +57,11 @@ int main(int argc, char** argv)
|
||||
|
||||
//create seeds randomly placed withing the bounding box of the data.
|
||||
vtkm::Bounds bounds = ds.GetCoordinateSystem().GetBounds();
|
||||
std::vector<vtkm::Particle> seeds;
|
||||
std::vector<vtkm::Massless> seeds;
|
||||
|
||||
for (vtkm::Id i = 0; i < numSeeds; i++)
|
||||
{
|
||||
vtkm::Particle p;
|
||||
vtkm::Massless p;
|
||||
vtkm::FloatDefault rx = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX;
|
||||
vtkm::FloatDefault ry = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX;
|
||||
vtkm::FloatDefault rz = (vtkm::FloatDefault)rand() / (vtkm::FloatDefault)RAND_MAX;
|
||||
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
||||
p.ID = i;
|
||||
seeds.push_back(p);
|
||||
}
|
||||
auto seedArray = vtkm::cont::make_ArrayHandle(seeds);
|
||||
auto seedArray = vtkm::cont::make_ArrayHandle(seeds, vtkm::CopyFlag::Off);
|
||||
|
||||
//compute streamlines
|
||||
vtkm::filter::Streamline streamline;
|
||||
|
@ -75,7 +75,7 @@ int main(int argc, char** argv)
|
||||
// Use the coordinate system as seeds for performing advection
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> pts;
|
||||
vtkm::cont::ArrayCopy(ds1.GetCoordinateSystem().GetData(), pts);
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> seeds;
|
||||
vtkm::cont::ArrayHandle<vtkm::Massless> seeds;
|
||||
|
||||
vtkm::Id numPts = pts.GetNumberOfValues();
|
||||
seeds.Allocate(numPts);
|
||||
@ -83,7 +83,7 @@ int main(int argc, char** argv)
|
||||
auto seedPortal = seeds.WritePortal();
|
||||
for (vtkm::Id i = 0; i < numPts; i++)
|
||||
{
|
||||
vtkm::Particle p;
|
||||
vtkm::Massless p;
|
||||
p.Pos = ptsPortal.Get(i);
|
||||
p.ID = i;
|
||||
seedPortal.Set(i, p);
|
||||
|
160
vtkm/Particle.h
160
vtkm/Particle.h
@ -11,6 +11,8 @@
|
||||
#define vtk_m_Particle_h
|
||||
|
||||
#include <vtkm/Bitset.h>
|
||||
#include <vtkm/VecVariable.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -68,6 +70,12 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
Particle() {}
|
||||
|
||||
VTKM_EXEC_CONT virtual ~Particle() noexcept
|
||||
{
|
||||
// This must not be defaulted, since defaulted virtual destructors are
|
||||
// troublesome with CUDA __host__ __device__ markup.
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Particle(const vtkm::Vec3f& p,
|
||||
const vtkm::Id& id,
|
||||
@ -92,7 +100,20 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
vtkm::Particle& operator=(const vtkm::Particle& p) = default;
|
||||
vtkm::Particle& operator=(const vtkm::Particle&) = default;
|
||||
|
||||
// The basic particle is only meant to be advected in a velocity
|
||||
// field. In that case it is safe to assume that the velocity value
|
||||
// will always be stored in the first location of vectors
|
||||
VTKM_EXEC_CONT
|
||||
virtual vtkm::Vec3f Next(const vtkm::VecVariable<vtkm::Vec3f, 2>&, const vtkm::FloatDefault&) = 0;
|
||||
|
||||
// The basic particle is only meant to be advected in a velocity
|
||||
// field. In that case it is safe to assume that the velocity value
|
||||
// will always be stored in the first location of vectors
|
||||
VTKM_EXEC_CONT
|
||||
virtual vtkm::Vec3f Velocity(const vtkm::VecVariable<vtkm::Vec3f, 2>&,
|
||||
const vtkm::FloatDefault&) = 0;
|
||||
|
||||
vtkm::Vec3f Pos;
|
||||
vtkm::Id ID = -1;
|
||||
@ -100,6 +121,141 @@ public:
|
||||
vtkm::ParticleStatus Status;
|
||||
vtkm::FloatDefault Time = 0;
|
||||
};
|
||||
}
|
||||
|
||||
class Massless : public vtkm::Particle
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
Massless() {}
|
||||
|
||||
VTKM_EXEC_CONT ~Massless() noexcept override
|
||||
{
|
||||
// This must not be defaulted, since defaulted virtual destructors are
|
||||
// troublesome with CUDA __host__ __device__ markup.
|
||||
}
|
||||
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Massless(const vtkm::Vec3f& p,
|
||||
const vtkm::Id& id,
|
||||
const vtkm::Id& numSteps = 0,
|
||||
const vtkm::ParticleStatus& status = vtkm::ParticleStatus(),
|
||||
const vtkm::FloatDefault& time = 0)
|
||||
: Particle(p, id, numSteps, status, time)
|
||||
{
|
||||
}
|
||||
|
||||
/*VTKM_EXEC_CONT
|
||||
Massless(const vtkm::Massless& p)
|
||||
: Particle(p)
|
||||
{
|
||||
}*/
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec3f Next(const vtkm::VecVariable<vtkm::Vec3f, 2>& vectors,
|
||||
const vtkm::FloatDefault& length) override
|
||||
{
|
||||
VTKM_ASSERT(vectors.GetNumberOfComponents() > 0);
|
||||
return this->Pos + length * vectors[0];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec3f Velocity(const vtkm::VecVariable<vtkm::Vec3f, 2>& vectors,
|
||||
const vtkm::FloatDefault& vtkmNotUsed(length)) override
|
||||
{
|
||||
// Velocity is evaluated from the Velocity field
|
||||
// and is not influenced by the particle
|
||||
VTKM_ASSERT(vectors.GetNumberOfComponents() > 0);
|
||||
return vectors[0];
|
||||
}
|
||||
};
|
||||
|
||||
class Electron : public vtkm::Particle
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT
|
||||
Electron() {}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Electron(const vtkm::Vec3f& position,
|
||||
const vtkm::Id& id,
|
||||
const vtkm::FloatDefault& mass,
|
||||
const vtkm::FloatDefault& charge,
|
||||
const vtkm::FloatDefault& weighting,
|
||||
const vtkm::Vec3f& momentum,
|
||||
const vtkm::Id& numSteps = 0,
|
||||
const vtkm::ParticleStatus& status = vtkm::ParticleStatus(),
|
||||
const vtkm::FloatDefault& time = 0)
|
||||
: Particle(position, id, numSteps, status, time)
|
||||
, Mass(mass)
|
||||
, Charge(charge)
|
||||
, Weighting(weighting)
|
||||
, Momentum(momentum)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::FloatDefault Beta(vtkm::Vec3f momentum) const
|
||||
{
|
||||
return static_cast<vtkm::FloatDefault>(vtkm::Magnitude(momentum / this->Mass) /
|
||||
vtkm::Pow(SPEED_OF_LIGHT, 2));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec3f Next(const vtkm::VecVariable<vtkm::Vec3f, 2>& vectors,
|
||||
const vtkm::FloatDefault& length) override
|
||||
{
|
||||
// TODO: implement Lorentz force calculation
|
||||
return this->Pos + length * this->Velocity(vectors, length);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec3f Velocity(const vtkm::VecVariable<vtkm::Vec3f, 2>& vectors,
|
||||
const vtkm::FloatDefault& length) override
|
||||
{
|
||||
VTKM_ASSERT(vectors.GetNumberOfComponents() == 2);
|
||||
|
||||
// Suppress unused warning
|
||||
(void)this->Weighting;
|
||||
|
||||
vtkm::Vec3f velocity;
|
||||
// Particle has a charge and a mass
|
||||
// Velocity updated using Lorentz force
|
||||
// Return velocity of the particle
|
||||
vtkm::Vec3f eField = vectors[0];
|
||||
vtkm::Vec3f bField = vectors[1];
|
||||
const vtkm::FloatDefault QoM = this->Charge / this->Mass;
|
||||
const vtkm::FloatDefault half = 0.5;
|
||||
const vtkm::Vec3f mom_ = this->Momentum + (half * this->Charge * eField * length);
|
||||
|
||||
//TODO : Calculate Gamma
|
||||
vtkm::Vec3f gamma_reci = vtkm::Sqrt(1 - this->Beta(mom_));
|
||||
// gamma(mom_, mass) -> needs velocity calculation
|
||||
const vtkm::Vec3f t = half * QoM * bField * gamma_reci * length;
|
||||
const vtkm::Vec3f s = 2.0f * t * (1 / 1 + vtkm::Magnitude(t));
|
||||
|
||||
const vtkm::Vec3f mom_pr = mom_ + vtkm::Cross(mom_, t);
|
||||
const vtkm::Vec3f mom_pl = mom_ + vtkm::Cross(mom_pr, s);
|
||||
|
||||
const vtkm::Vec3f mom_new = mom_pl + 0.5 * this->Charge * eField * length;
|
||||
|
||||
//TODO : this is a const method, figure a better way to update momentum
|
||||
|
||||
this->Momentum = mom_new;
|
||||
velocity = mom_new / this->Mass;
|
||||
|
||||
return velocity;
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::FloatDefault Mass;
|
||||
vtkm::FloatDefault Charge;
|
||||
vtkm::FloatDefault Weighting;
|
||||
vtkm::Vec3f Momentum;
|
||||
constexpr static vtkm::FloatDefault SPEED_OF_LIGHT =
|
||||
static_cast<vtkm::FloatDefault>(2.99792458e8);
|
||||
};
|
||||
|
||||
} //namespace vtkm
|
||||
|
||||
#endif // vtk_m_Particle_h
|
||||
|
@ -65,11 +65,16 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
inline const ComponentType& operator[](vtkm::IdComponent index) const
|
||||
{
|
||||
VTKM_ASSERT(index >= 0 && index < this->NumComponents);
|
||||
return this->Data[index];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
inline ComponentType& operator[](vtkm::IdComponent index) { return this->Data[index]; }
|
||||
inline ComponentType& operator[](vtkm::IdComponent index)
|
||||
{
|
||||
VTKM_ASSERT(index >= 0 && index < this->NumComponents);
|
||||
return this->Data[index];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void Append(ComponentType value)
|
||||
|
@ -110,6 +110,39 @@ VTKM_CONT void ArrayCopy(const vtkm::cont::ArrayHandle<InValueType, InStorage>&
|
||||
// Static dispatch cases 1 & 2
|
||||
detail::ArrayCopyImpl(source, destination, JustCopyStorage{});
|
||||
}
|
||||
|
||||
// Forward declaration
|
||||
// Cannot include VariantArrayHandle.h here due to circular dependency.
|
||||
template <typename TypeList>
|
||||
class VariantArrayHandleBase;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ArrayCopyFunctor
|
||||
{
|
||||
template <typename InValueType, typename InStorage, typename OutValueType, typename OutStorage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<InValueType, InStorage>& source,
|
||||
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination) const
|
||||
{
|
||||
vtkm::cont::ArrayCopy(source, destination);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// \brief Deep copies data in a `VariantArrayHandle` to an array of a known type.
|
||||
///
|
||||
/// This form of `ArrayCopy` can be used to copy data from an unknown array type to
|
||||
/// an array of a known type. Note that regardless of the source type, the data will
|
||||
/// be deep copied.
|
||||
///
|
||||
template <typename InTypeList, typename OutValueType, typename OutStorage>
|
||||
VTKM_CONT void ArrayCopy(const vtkm::cont::VariantArrayHandleBase<InTypeList>& source,
|
||||
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination)
|
||||
{
|
||||
source.CastAndCall(detail::ArrayCopyFunctor{}, destination);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -958,7 +958,7 @@ public:
|
||||
///
|
||||
VTKM_CONT ArrayHandleNewStyle(const std::vector<vtkm::cont::internal::Buffer>& buffers,
|
||||
const StorageType& storage = StorageType())
|
||||
: Internals(std::make_shared<InternalsStruct>(&buffers.front(), storage))
|
||||
: Internals(std::make_shared<InternalsStruct>(buffers.data(), storage))
|
||||
{
|
||||
VTKM_ASSERT(static_cast<vtkm::IdComponent>(this->Internals->Buffers.size()) ==
|
||||
GetNumberOfBuffers());
|
||||
@ -1304,7 +1304,7 @@ public:
|
||||
///
|
||||
VTKM_CONT vtkm::cont::internal::Buffer* GetBuffers() const
|
||||
{
|
||||
return &this->Internals->Buffers.front();
|
||||
return this->Internals->Buffers.data();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1409,8 +1409,8 @@ VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle(
|
||||
vtkm::Id sz = array.GetNumberOfValues();
|
||||
|
||||
out << "valueType=" << vtkm::cont::TypeToString<T>()
|
||||
<< " storageType=" << vtkm::cont::TypeToString<StorageT>() << sz << " values occupying "
|
||||
<< (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
|
||||
<< " storageType=" << vtkm::cont::TypeToString<StorageT>() << " " << sz
|
||||
<< " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
|
||||
|
||||
PortalType portal = array.ReadPortal();
|
||||
if (full || sz <= 7)
|
||||
|
@ -175,12 +175,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Deleter>
|
||||
ArrayHandleBasic(
|
||||
T* array,
|
||||
vtkm::Id numberOfValues,
|
||||
vtkm::cont::DeviceAdapterId device,
|
||||
Deleter deleter,
|
||||
vtkm::cont::internal::BufferInfo::Deleter deleter,
|
||||
vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
|
||||
: Superclass(std::vector<vtkm::cont::internal::Buffer>{
|
||||
vtkm::cont::internal::MakeBuffer(device,
|
||||
@ -192,6 +191,39 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
ArrayHandleBasic(
|
||||
T* array,
|
||||
void* container,
|
||||
vtkm::Id numberOfValues,
|
||||
vtkm::cont::internal::BufferInfo::Deleter deleter,
|
||||
vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
|
||||
: Superclass(std::vector<vtkm::cont::internal::Buffer>{
|
||||
vtkm::cont::internal::MakeBuffer(vtkm::cont::DeviceAdapterTagUndefined{},
|
||||
array,
|
||||
container,
|
||||
internal::detail::NumberOfBytes(numberOfValues, sizeof(T)),
|
||||
deleter,
|
||||
reallocater) })
|
||||
{
|
||||
}
|
||||
|
||||
ArrayHandleBasic(
|
||||
T* array,
|
||||
void* container,
|
||||
vtkm::Id numberOfValues,
|
||||
vtkm::cont::DeviceAdapterId device,
|
||||
vtkm::cont::internal::BufferInfo::Deleter deleter,
|
||||
vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
|
||||
: Superclass(std::vector<vtkm::cont::internal::Buffer>{
|
||||
vtkm::cont::internal::MakeBuffer(device,
|
||||
array,
|
||||
container,
|
||||
internal::detail::NumberOfBytes(numberOfValues, sizeof(T)),
|
||||
deleter,
|
||||
reallocater) })
|
||||
{
|
||||
}
|
||||
|
||||
/// @{
|
||||
/// \brief Gets raw access to the `ArrayHandle`'s data.
|
||||
///
|
||||
@ -238,11 +270,85 @@ public:
|
||||
/// @}
|
||||
};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
// Deletes a container object by casting it to a pointer of a given type (the template argument)
|
||||
// and then using delete[] on the object.
|
||||
template <typename T>
|
||||
VTKM_CONT inline void SimpleArrayDeleter(void* container_)
|
||||
{
|
||||
T* container = reinterpret_cast<T*>(container_);
|
||||
delete[] container;
|
||||
}
|
||||
|
||||
// Reallocates a standard C array. Note that the allocation method is different than the default
|
||||
// host allocation of vtkm::cont::internal::BufferInfo and may be less efficient.
|
||||
template <typename T>
|
||||
VTKM_CONT inline void SimpleArrayReallocater(void*& memory,
|
||||
void*& container,
|
||||
vtkm::BufferSizeType oldSize,
|
||||
vtkm::BufferSizeType newSize)
|
||||
{
|
||||
VTKM_ASSERT(memory == container);
|
||||
VTKM_ASSERT(static_cast<std::size_t>(newSize) % sizeof(T) == 0);
|
||||
|
||||
// If the new size is not much smaller than the old size, just reuse the buffer (and waste a
|
||||
// little memory).
|
||||
if ((newSize > ((3 * oldSize) / 4)) && (newSize <= oldSize))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void* newBuffer = new T[static_cast<std::size_t>(newSize) / sizeof(T)];
|
||||
std::memcpy(newBuffer, memory, static_cast<std::size_t>(newSize < oldSize ? newSize : oldSize));
|
||||
|
||||
if (memory != nullptr)
|
||||
{
|
||||
SimpleArrayDeleter<T>(memory);
|
||||
}
|
||||
|
||||
memory = container = newBuffer;
|
||||
}
|
||||
|
||||
// Deletes a container object by casting it to a pointer of a given type (the template argument)
|
||||
// and then using delete on the object.
|
||||
template <typename T>
|
||||
VTKM_CONT inline void CastDeleter(void* container_)
|
||||
{
|
||||
T* container = reinterpret_cast<T*>(container_);
|
||||
delete container;
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_CONT inline void StdVectorDeleter(void* container)
|
||||
{
|
||||
CastDeleter<std::vector<T, Allocator>>(container);
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_CONT inline void StdVectorReallocater(void*& memory,
|
||||
void*& container,
|
||||
vtkm::BufferSizeType oldSize,
|
||||
vtkm::BufferSizeType newSize)
|
||||
{
|
||||
using vector_type = std::vector<T, Allocator>;
|
||||
vector_type* vector = reinterpret_cast<vector_type*>(container);
|
||||
VTKM_ASSERT(vector->empty() || (memory == vector->data()));
|
||||
VTKM_ASSERT(oldSize == static_cast<vtkm::BufferSizeType>(vector->size()));
|
||||
|
||||
vector->resize(static_cast<std::size_t>(newSize));
|
||||
memory = vector->data();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
/// A convenience function for creating an ArrayHandle from a standard C array.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T>
|
||||
make_ArrayHandle(const T* array, vtkm::Id numberOfValues, vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(const T* array,
|
||||
vtkm::Id numberOfValues,
|
||||
vtkm::CopyFlag copy)
|
||||
{
|
||||
if (copy == vtkm::CopyFlag::On)
|
||||
{
|
||||
@ -258,16 +364,39 @@ make_ArrayHandle(const T* array, vtkm::Id numberOfValues, vtkm::CopyFlag copy =
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(const T* array, vtkm::Id numberOfValues)
|
||||
{
|
||||
return make_ArrayHandle(array, numberOfValues, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
/// A convenience function to move a user-allocated array into an `ArrayHandle`.
|
||||
/// The provided array pointer will be reset to `nullptr`.
|
||||
/// If the array was not allocated with the `new[]` operator, then deleter and reallocater
|
||||
/// functions must be provided.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandleMove(
|
||||
T*& array,
|
||||
vtkm::Id numberOfValues,
|
||||
vtkm::cont::internal::BufferInfo::Deleter deleter = internal::SimpleArrayDeleter<T>,
|
||||
vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::SimpleArrayReallocater<T>)
|
||||
{
|
||||
vtkm::cont::ArrayHandleBasic<T> arrayHandle(array, numberOfValues, deleter, reallocater);
|
||||
array = nullptr;
|
||||
return arrayHandle;
|
||||
}
|
||||
|
||||
/// A convenience function for creating an ArrayHandle from an std::vector.
|
||||
///
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(
|
||||
const std::vector<T, Allocator>& array,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(const std::vector<T, Allocator>& array,
|
||||
vtkm::CopyFlag copy)
|
||||
{
|
||||
if (!array.empty())
|
||||
{
|
||||
return make_ArrayHandle(&array.front(), static_cast<vtkm::Id>(array.size()), copy);
|
||||
return make_ArrayHandle(array.data(), static_cast<vtkm::Id>(array.size()), copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -275,6 +404,42 @@ VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(
|
||||
return vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(const std::vector<T, Allocator>& array)
|
||||
{
|
||||
return make_ArrayHandle(array, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
/// Move an std::vector into an ArrayHandle.
|
||||
///
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandleMove(std::vector<T, Allocator>&& array)
|
||||
{
|
||||
using vector_type = std::vector<T, Allocator>;
|
||||
vector_type* container = new vector_type(std::move(array));
|
||||
return vtkm::cont::ArrayHandleBasic<T>(container->data(),
|
||||
container,
|
||||
static_cast<vtkm::Id>(container->size()),
|
||||
internal::StdVectorDeleter<T, Allocator>,
|
||||
internal::StdVectorReallocater<T, Allocator>);
|
||||
}
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(std::vector<T, Allocator>&& array,
|
||||
vtkm::CopyFlag vtkmNotUsed(copy))
|
||||
{
|
||||
return make_ArrayHandleMove(array);
|
||||
}
|
||||
|
||||
/// Create an ArrayHandle directly from an initializer list of values.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleBasic<T> make_ArrayHandle(std::initializer_list<T>&& values)
|
||||
{
|
||||
return make_ArrayHandle(values.begin(), static_cast<vtkm::Id>(values.size()), vtkm::CopyFlag::On);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -63,16 +63,8 @@ vtkm::cont::ArrayHandleExtrudeCoords<T> make_ArrayHandleExtrudeCoords(
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
{
|
||||
using StorageType = vtkm::cont::internal::Storage<vtkm::Vec<T, 3>, internal::StorageTagExtrude>;
|
||||
if (copy == vtkm::CopyFlag::Off)
|
||||
{
|
||||
return ArrayHandleExtrudeCoords<T>(StorageType(array, length, numberOfPlanes, cylindrical));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto storage = StorageType(
|
||||
vtkm::cont::make_ArrayHandle(array, length, vtkm::CopyFlag::On), numberOfPlanes, cylindrical);
|
||||
return ArrayHandleExtrudeCoords<T>(storage);
|
||||
}
|
||||
return ArrayHandleExtrudeCoords<T>(
|
||||
StorageType(vtkm::cont::make_ArrayHandle(array, length, copy), numberOfPlanes, cylindrical));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -85,7 +77,7 @@ vtkm::cont::ArrayHandleExtrudeCoords<T> make_ArrayHandleExtrudeCoords(
|
||||
if (!array.empty())
|
||||
{
|
||||
return make_ArrayHandleExtrudeCoords(
|
||||
&array.front(), static_cast<vtkm::Id>(array.size()), numberOfPlanes, cylindrical, copy);
|
||||
array.data(), static_cast<vtkm::Id>(array.size()), numberOfPlanes, cylindrical, copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,8 +234,8 @@ public:
|
||||
|
||||
Storage() = default;
|
||||
|
||||
VTKM_CONT Storage(std::initializer_list<BaseArrayType>&& arrays)
|
||||
: Arrays{ std::move(arrays) }
|
||||
VTKM_CONT Storage(std::array<BaseArrayType, NUM_COMPONENTS>&& arrays)
|
||||
: Arrays(std::move(arrays))
|
||||
{
|
||||
VTKM_ASSERT(IsValid());
|
||||
}
|
||||
@ -433,11 +433,18 @@ public:
|
||||
(ArrayHandleSOA<ValueType_>),
|
||||
(ArrayHandle<ValueType_, vtkm::cont::StorageTagSOA>));
|
||||
|
||||
ArrayHandleSOA(std::initializer_list<BaseArrayType>&& componentArrays)
|
||||
ArrayHandleSOA(std::array<BaseArrayType, Traits::NUM_COMPONENTS>&& componentArrays)
|
||||
: Superclass(StorageType(std::move(componentArrays)))
|
||||
{
|
||||
}
|
||||
|
||||
ArrayHandleSOA(std::initializer_list<BaseArrayType>&& componentArrays)
|
||||
{
|
||||
VTKM_ASSERT(componentArrays.size() == Traits::NUM_COMPONENTS);
|
||||
std::copy(
|
||||
componentArrays.begin(), componentArrays.end(), this->GetStorage().GetArrays().begin());
|
||||
}
|
||||
|
||||
ArrayHandleSOA(std::initializer_list<std::vector<ComponentType>>&& componentVectors)
|
||||
{
|
||||
VTKM_ASSERT(componentVectors.size() == Traits::NUM_COMPONENTS);
|
||||
@ -456,26 +463,45 @@ public:
|
||||
template <typename... RemainingVectors>
|
||||
ArrayHandleSOA(vtkm::CopyFlag copy,
|
||||
const std::vector<ComponentType>& vector0,
|
||||
const RemainingVectors&... componentVectors)
|
||||
: Superclass(StorageType(vtkm::cont::make_ArrayHandle(vector0, copy),
|
||||
vtkm::cont::make_ArrayHandle(componentVectors, copy)...))
|
||||
RemainingVectors&&... componentVectors)
|
||||
: Superclass(StorageType(
|
||||
vtkm::cont::make_ArrayHandle(vector0, copy),
|
||||
vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors), copy)...))
|
||||
{
|
||||
VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == Traits::NUM_COMPONENTS);
|
||||
}
|
||||
|
||||
// This only works if all the templated arguments are of type std::vector<ComponentType>.
|
||||
template <typename... RemainingVectors>
|
||||
ArrayHandleSOA(const std::vector<ComponentType>& vector0,
|
||||
const RemainingVectors&... componentVectors)
|
||||
: Superclass(StorageType(vtkm::cont::make_ArrayHandle(vector0),
|
||||
vtkm::cont::make_ArrayHandle(componentVectors)...))
|
||||
ArrayHandleSOA(vtkm::CopyFlag copy,
|
||||
std::vector<ComponentType>&& vector0,
|
||||
RemainingVectors&&... componentVectors)
|
||||
: Superclass(StorageType(
|
||||
vtkm::cont::make_ArrayHandle(std::move(vector0), copy),
|
||||
vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors), copy)...))
|
||||
{
|
||||
VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == Traits::NUM_COMPONENTS);
|
||||
}
|
||||
|
||||
// This only works if all the templated arguments are of type std::vector<ComponentType>.
|
||||
template <typename... RemainingVectors>
|
||||
#ifndef VTKM_MSVC
|
||||
// For some reason, having VTKM_DEPRECATED here is causing a syntax error in some MSVC
|
||||
// compilers.
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
#endif
|
||||
ArrayHandleSOA(const std::vector<ComponentType>& vector0,
|
||||
const RemainingVectors&... componentVectors)
|
||||
: Superclass(
|
||||
StorageType(vtkm::cont::make_ArrayHandle(vector0, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(componentVectors, vtkm::CopyFlag::Off)...))
|
||||
{
|
||||
VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == Traits::NUM_COMPONENTS);
|
||||
}
|
||||
|
||||
ArrayHandleSOA(std::initializer_list<const ComponentType*> componentArrays,
|
||||
vtkm::Id length,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
vtkm::CopyFlag copy)
|
||||
{
|
||||
VTKM_ASSERT(componentArrays.size() == Traits::NUM_COMPONENTS);
|
||||
vtkm::IdComponent componentIndex = 0;
|
||||
@ -487,6 +513,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
ArrayHandleSOA(std::initializer_list<const ComponentType*> componentArrays, vtkm::Id length)
|
||||
{
|
||||
VTKM_ASSERT(componentArrays.size() == Traits::NUM_COMPONENTS);
|
||||
vtkm::IdComponent componentIndex = 0;
|
||||
for (auto&& vectorIter = componentArrays.begin(); vectorIter != componentArrays.end();
|
||||
++vectorIter)
|
||||
{
|
||||
this->SetArray(componentIndex,
|
||||
vtkm::cont::make_ArrayHandle(*vectorIter, length, vtkm::CopyFlag::Off));
|
||||
++componentIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// This only works if all the templated arguments are of type std::vector<ComponentType>.
|
||||
template <typename... RemainingArrays>
|
||||
ArrayHandleSOA(vtkm::Id length,
|
||||
@ -501,11 +541,17 @@ public:
|
||||
|
||||
// This only works if all the templated arguments are of type std::vector<ComponentType>.
|
||||
template <typename... RemainingArrays>
|
||||
ArrayHandleSOA(vtkm::Id length,
|
||||
const ComponentType* array0,
|
||||
const RemainingArrays&... componentArrays)
|
||||
: Superclass(StorageType(vtkm::cont::make_ArrayHandle(array0, length),
|
||||
vtkm::cont::make_ArrayHandle(componentArrays, length)...))
|
||||
#ifndef VTKM_MSVC
|
||||
// For some reason, having VTKM_DEPRECATED here is causing a syntax error in some MSVC
|
||||
// compilers.
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
#endif
|
||||
ArrayHandleSOA(vtkm::Id length,
|
||||
const ComponentType* array0,
|
||||
const RemainingArrays&... componentArrays)
|
||||
: Superclass(
|
||||
StorageType(vtkm::cont::make_ArrayHandle(array0, length, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(componentArrays, length, vtkm::CopyFlag::Off)...))
|
||||
{
|
||||
VTKM_STATIC_ASSERT(sizeof...(RemainingArrays) + 1 == Traits::NUM_COMPONENTS);
|
||||
}
|
||||
@ -558,34 +604,73 @@ VTKM_CONT
|
||||
ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>
|
||||
make_ArrayHandleSOA(vtkm::CopyFlag copy,
|
||||
const std::vector<ComponentType>& vector0,
|
||||
const RemainingVectors&... componentVectors)
|
||||
RemainingVectors&&... componentVectors)
|
||||
{
|
||||
return ArrayHandleSOA<
|
||||
vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>(
|
||||
vector0, componentVectors..., copy);
|
||||
// Convert std::vector to ArrayHandle first so that it correctly handles a mix of rvalue args.
|
||||
return { vtkm::cont::make_ArrayHandle(vector0, copy),
|
||||
vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors),
|
||||
copy)... };
|
||||
}
|
||||
|
||||
// This only works if all the templated arguments are of type std::vector<ComponentType>.
|
||||
template <typename ComponentType, typename... RemainingVectors>
|
||||
VTKM_CONT
|
||||
ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>
|
||||
make_ArrayHandleSOA(const std::vector<ComponentType>& vector0,
|
||||
const RemainingVectors&... componentVectors)
|
||||
make_ArrayHandleSOA(vtkm::CopyFlag copy,
|
||||
std::vector<ComponentType>&& vector0,
|
||||
RemainingVectors&&... componentVectors)
|
||||
{
|
||||
// Convert std::vector to ArrayHandle first so that it correctly handles a mix of rvalue args.
|
||||
return ArrayHandleSOA<
|
||||
vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>(
|
||||
vtkm::cont::make_ArrayHandle(std::move(vector0), copy),
|
||||
vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors), copy)...);
|
||||
}
|
||||
|
||||
template <typename ComponentType, typename... RemainingVectors>
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
VTKM_CONT ArrayHandleSOA<
|
||||
vtkm::Vec<ComponentType,
|
||||
vtkm::IdComponent(sizeof...(RemainingVectors) +
|
||||
1)>> make_ArrayHandleSOA(const std::vector<ComponentType>& vector0,
|
||||
const RemainingVectors&... componentVectors)
|
||||
{
|
||||
return ArrayHandleSOA<
|
||||
vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>(
|
||||
vector0, componentVectors...);
|
||||
}
|
||||
|
||||
// This only works if all the templated arguments are rvalues of std::vector<ComponentType>.
|
||||
template <typename ComponentType, typename... RemainingVectors>
|
||||
VTKM_CONT
|
||||
ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>
|
||||
make_ArrayHandleSOAMove(std::vector<ComponentType>&& vector0,
|
||||
RemainingVectors&&... componentVectors)
|
||||
{
|
||||
return { vtkm::cont::make_ArrayHandleMove(std::move(vector0)),
|
||||
vtkm::cont::make_ArrayHandleMove(std::forward<RemainingVectors>(componentVectors))... };
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
VTKM_CONT ArrayHandleSOA<ValueType> make_ArrayHandleSOA(
|
||||
std::initializer_list<const typename vtkm::VecTraits<ValueType>::ComponentType*>&&
|
||||
componentVectors,
|
||||
vtkm::Id length,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
vtkm::CopyFlag copy)
|
||||
{
|
||||
return ArrayHandleSOA<ValueType>(std::move(componentVectors), length, copy);
|
||||
}
|
||||
|
||||
template <typename ValueType>
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
VTKM_CONT ArrayHandleSOA<ValueType> make_ArrayHandleSOA(
|
||||
std::initializer_list<const typename vtkm::VecTraits<ValueType>::ComponentType*>&&
|
||||
componentVectors,
|
||||
vtkm::Id length)
|
||||
{
|
||||
return vtkm::cont::make_ArrayHandleSOA(std::move(componentVectors), length, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
// This only works if all the templated arguments are of type std::vector<ComponentType>.
|
||||
template <typename ComponentType, typename... RemainingArrays>
|
||||
VTKM_CONT
|
||||
@ -601,11 +686,13 @@ VTKM_CONT
|
||||
}
|
||||
|
||||
template <typename ComponentType, typename... RemainingArrays>
|
||||
VTKM_CONT
|
||||
ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingArrays) + 1)>>
|
||||
make_ArrayHandleSOA(vtkm::Id length,
|
||||
const ComponentType* array0,
|
||||
const RemainingArrays*... componentArrays)
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_ArrayHandle.")
|
||||
VTKM_CONT ArrayHandleSOA<
|
||||
vtkm::Vec<ComponentType,
|
||||
vtkm::IdComponent(sizeof...(RemainingArrays) +
|
||||
1)>> make_ArrayHandleSOA(vtkm::Id length,
|
||||
const ComponentType* array0,
|
||||
const RemainingArrays*... componentArrays)
|
||||
{
|
||||
return ArrayHandleSOA<
|
||||
vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingArrays) + 1)>>(
|
||||
|
@ -28,20 +28,24 @@ namespace cont
|
||||
{
|
||||
|
||||
/// ArrayHandleVirtualCoordinates is a specialization of ArrayHandle.
|
||||
class VTKM_ALWAYS_EXPORT ArrayHandleVirtualCoordinates final
|
||||
: public vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>
|
||||
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Virtual ArrayHandles are being phased out.")
|
||||
ArrayHandleVirtualCoordinates final : public vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandleVirtualCoordinates,
|
||||
(vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>));
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
template <typename T, typename S>
|
||||
explicit ArrayHandleVirtualCoordinates(const vtkm::cont::ArrayHandle<T, S>& ah)
|
||||
: vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>(vtkm::cont::make_ArrayHandleCast<ValueType>(ah))
|
||||
{
|
||||
}
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
};
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
|
||||
template <typename Functor, typename... Args>
|
||||
void CastAndCall(const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||
Functor&& f,
|
||||
@ -66,6 +70,8 @@ struct SerializableTypeString<vtkm::cont::ArrayHandleVirtualCoordinates>
|
||||
static VTKM_CONT const std::string Get() { return "AH_VirtualCoordinates"; }
|
||||
};
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
@ -75,6 +81,8 @@ struct SerializableTypeString<vtkm::cont::ArrayHandleVirtualCoordinates>
|
||||
namespace mangled_diy_namespace
|
||||
{
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
|
||||
template <>
|
||||
struct Serialization<vtkm::cont::ArrayHandleVirtualCoordinates>
|
||||
{
|
||||
@ -173,6 +181,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
} // diy
|
||||
/// @endcond SERIALIZATION
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtual.h>
|
||||
#include <vtkm/cont/DeviceAdapterTag.h>
|
||||
|
||||
namespace vtkm
|
||||
|
@ -128,9 +128,9 @@ set(template_sources
|
||||
CellSetExtrude.hxx
|
||||
CellSetStructured.hxx
|
||||
ColorTable.hxx
|
||||
CoordinateSystem.hxx
|
||||
FieldRangeCompute.hxx
|
||||
FieldRangeGlobalCompute.hxx
|
||||
ParticleArrayCopy.hxx
|
||||
StorageVirtual.hxx
|
||||
VirtualObjectHandle.hxx
|
||||
)
|
||||
@ -151,7 +151,6 @@ set(sources
|
||||
internal/VirtualObjectTransfer.cxx
|
||||
Initialize.cxx
|
||||
Logging.cxx
|
||||
ParticleArrayCopy.cxx
|
||||
RuntimeDeviceTracker.cxx
|
||||
Token.cxx
|
||||
TryExecute.cxx
|
||||
@ -185,7 +184,6 @@ set(sources
|
||||
Field.cxx
|
||||
FieldRangeCompute.cxx
|
||||
FieldRangeGlobalCompute.cxx
|
||||
ParticleArrayCopy.cxx
|
||||
PartitionedDataSet.cxx
|
||||
PointLocator.cxx
|
||||
PointLocatorUniformGrid.cxx
|
||||
|
@ -234,7 +234,7 @@ void CellLocatorBoundingIntervalHierarchy::Build()
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
vtkm::Id numCells = cellSet.GetNumberOfCells();
|
||||
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates points = coords.GetData();
|
||||
auto points = coords.GetDataAsMultiplexer();
|
||||
|
||||
//std::cout << "No of cells: " << numCells << "\n";
|
||||
//std::cout.precision(3);
|
||||
@ -457,7 +457,7 @@ struct CellLocatorBIHPrepareForExecutionFunctor
|
||||
vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>& bihExec,
|
||||
const vtkm::cont::ArrayHandle<vtkm::exec::CellLocatorBoundingIntervalHierarchyNode>& nodes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& processedCellIds,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords) const
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coords) const
|
||||
{
|
||||
using ExecutionType =
|
||||
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
|
||||
@ -501,7 +501,7 @@ const vtkm::exec::CellLocator* CellLocatorBoundingIntervalHierarchy::PrepareForE
|
||||
this->ExecutionObjectHandle,
|
||||
this->Nodes,
|
||||
this->ProcessedCellIds,
|
||||
this->GetCoordinates().GetData());
|
||||
this->GetCoordinates().GetDataAsMultiplexer());
|
||||
return this->ExecutionObjectHandle.PrepareForExecution(device, token);
|
||||
;
|
||||
}
|
||||
|
@ -94,9 +94,9 @@ private:
|
||||
using ArrayPortalConst =
|
||||
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapter>::PortalConst;
|
||||
|
||||
using CoordsPortalType = decltype(vtkm::cont::ArrayHandleVirtualCoordinates{}.PrepareForInput(
|
||||
DeviceAdapter{},
|
||||
std::declval<vtkm::cont::Token&>()));
|
||||
using CoordsPortalType =
|
||||
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
|
||||
using CellSetP2CExecType =
|
||||
decltype(std::declval<CellSetType>().PrepareForInput(DeviceAdapter{},
|
||||
@ -150,7 +150,7 @@ public:
|
||||
vtkm::TopologyElementTagCell{},
|
||||
vtkm::TopologyElementTagPoint{},
|
||||
token))
|
||||
, Coords(coords.GetData().PrepareForInput(DeviceAdapter{}, token))
|
||||
, Coords(coords.GetDataAsMultiplexer().PrepareForInput(DeviceAdapter{}, token))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -81,12 +81,10 @@ struct CellLocatorUniformGridPrepareForExecutionFunctor
|
||||
template <typename DeviceAdapter, typename... Args>
|
||||
VTKM_CONT bool operator()(DeviceAdapter,
|
||||
vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>& execLocator,
|
||||
vtkm::cont::Token& token,
|
||||
Args&&... args) const
|
||||
{
|
||||
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter, dimensions>;
|
||||
ExecutionType* execObject =
|
||||
new ExecutionType(std::forward<Args>(args)..., DeviceAdapter(), token);
|
||||
ExecutionType* execObject = new ExecutionType(std::forward<Args>(args)..., DeviceAdapter());
|
||||
execLocator.Reset(execObject);
|
||||
return true;
|
||||
}
|
||||
@ -103,26 +101,22 @@ const vtkm::exec::CellLocator* CellLocatorUniformGrid::PrepareForExecution(
|
||||
success = vtkm::cont::TryExecuteOnDevice(device,
|
||||
CellLocatorUniformGridPrepareForExecutionFunctor<3>(),
|
||||
this->ExecutionObjectHandle,
|
||||
token,
|
||||
this->CellDims,
|
||||
this->PointDims,
|
||||
this->Origin,
|
||||
this->InvSpacing,
|
||||
this->MaxPoint,
|
||||
this->GetCoordinates().GetData());
|
||||
this->MaxPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = vtkm::cont::TryExecuteOnDevice(device,
|
||||
CellLocatorUniformGridPrepareForExecutionFunctor<2>(),
|
||||
this->ExecutionObjectHandle,
|
||||
token,
|
||||
this->CellDims,
|
||||
this->PointDims,
|
||||
this->Origin,
|
||||
this->InvSpacing,
|
||||
this->MaxPoint,
|
||||
this->GetCoordinates().GetData());
|
||||
this->MaxPoint);
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
|
@ -168,10 +168,23 @@ CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn,
|
||||
const std::vector<vtkm::Int32>& nextNode,
|
||||
bool periodic = true)
|
||||
{
|
||||
return CellSetExtrude{ vtkm::cont::make_ArrayHandle(conn),
|
||||
return CellSetExtrude{ vtkm::cont::make_ArrayHandle(conn, vtkm::CopyFlag::On),
|
||||
static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
|
||||
coords.GetNumberOfPlanes(),
|
||||
vtkm::cont::make_ArrayHandle(nextNode),
|
||||
vtkm::cont::make_ArrayHandle(nextNode, vtkm::CopyFlag::On),
|
||||
periodic };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CellSetExtrude make_CellSetExtrude(std::vector<vtkm::Int32>&& conn,
|
||||
const vtkm::cont::ArrayHandleExtrudeCoords<T>& coords,
|
||||
std::vector<vtkm::Int32>&& nextNode,
|
||||
bool periodic = true)
|
||||
{
|
||||
return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)),
|
||||
static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()),
|
||||
coords.GetNumberOfPlanes(),
|
||||
vtkm::cont::make_ArrayHandleMove(std::move(nextNode)),
|
||||
periodic };
|
||||
}
|
||||
}
|
||||
|
@ -833,15 +833,20 @@ ColorTable::TransferState ColorTable::GetExecutionDataForTransfer() const
|
||||
|
||||
if (this->Impl->ColorArraysChanged)
|
||||
{
|
||||
this->Impl->ColorPosHandle = vtkm::cont::make_ArrayHandle(this->Impl->ColorNodePos);
|
||||
this->Impl->ColorRGBHandle = vtkm::cont::make_ArrayHandle(this->Impl->ColorRGB);
|
||||
this->Impl->ColorPosHandle =
|
||||
vtkm::cont::make_ArrayHandle(this->Impl->ColorNodePos, vtkm::CopyFlag::Off);
|
||||
this->Impl->ColorRGBHandle =
|
||||
vtkm::cont::make_ArrayHandle(this->Impl->ColorRGB, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
if (this->Impl->OpacityArraysChanged)
|
||||
{
|
||||
this->Impl->OpacityPosHandle = vtkm::cont::make_ArrayHandle(this->Impl->OpacityNodePos);
|
||||
this->Impl->OpacityAlphaHandle = vtkm::cont::make_ArrayHandle(this->Impl->OpacityAlpha);
|
||||
this->Impl->OpacityMidSharpHandle = vtkm::cont::make_ArrayHandle(this->Impl->OpacityMidSharp);
|
||||
this->Impl->OpacityPosHandle =
|
||||
vtkm::cont::make_ArrayHandle(this->Impl->OpacityNodePos, vtkm::CopyFlag::Off);
|
||||
this->Impl->OpacityAlphaHandle =
|
||||
vtkm::cont::make_ArrayHandle(this->Impl->OpacityAlpha, vtkm::CopyFlag::Off);
|
||||
this->Impl->OpacityMidSharpHandle =
|
||||
vtkm::cont::make_ArrayHandle(this->Impl->OpacityMidSharp, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
TransferState state = { (this->Impl->ColorArraysChanged || this->Impl->OpacityArraysChanged ||
|
||||
|
@ -10,22 +10,32 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/CoordinateSystem.hxx>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates CoordDataDepWrapper::ToArray() const
|
||||
{
|
||||
return this->Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
}
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
} // namespace detail
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem()
|
||||
: Superclass()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& data)
|
||||
: Superclass(name, Association::POINTS, data)
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::VariantArrayHandleCommon& data)
|
||||
: Superclass(name, Association::POINTS, vtkm::cont::VariantArrayHandle{ data })
|
||||
{
|
||||
}
|
||||
|
||||
@ -38,21 +48,19 @@ CoordinateSystem::CoordinateSystem(std::string name,
|
||||
vtkm::Vec3f spacing)
|
||||
: Superclass(name,
|
||||
Association::POINTS,
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates CoordinateSystem::GetData() const
|
||||
VTKM_CONT vtkm::cont::detail::CoordDataDepWrapper CoordinateSystem::GetData() const
|
||||
{
|
||||
return this->Superclass::GetData().Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
return vtkm::cont::detail::CoordDataDepWrapper(this->Superclass::GetData());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void CoordinateSystem::SetData(const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& newdata)
|
||||
VTKM_CONT vtkm::cont::CoordinateSystem::MultiplexerArrayType
|
||||
CoordinateSystem::GetDataAsMultiplexer() const
|
||||
{
|
||||
this->Superclass::SetData(newdata);
|
||||
return this->GetData().AsMultiplexer<MultiplexerArrayType>();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -103,14 +111,5 @@ template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>>::StorageTag>&);
|
||||
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::VariantArrayHandle&);
|
||||
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>>&);
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<double, 3>>&);
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(const vtkm::cont::VariantArrayHandle&);
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define vtk_m_cont_CoordinateSystem_h
|
||||
|
||||
#include <vtkm/Bounds.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCast.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
@ -21,25 +22,116 @@ namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// CoordinateSystem::GetData used to return an ArrayHandleVirtualCoordinates.
|
||||
// That behavior is deprecated, and CoordianteSystem::GetData now returns a
|
||||
// VariantArrayHandle similar (although slightly different than) its superclass.
|
||||
// This wrapper class supports the old deprecated behavior until it is no longer
|
||||
// supported. Once the behavior is removed (probably when
|
||||
// ArrayHandleVirtualCoordinates is removed), then this class should be removed.
|
||||
class VTKM_ALWAYS_EXPORT CoordDataDepWrapper
|
||||
: public vtkm::cont::VariantArrayHandleBase<vtkm::TypeListFieldVec3>
|
||||
{
|
||||
using Superclass = vtkm::cont::VariantArrayHandleBase<vtkm::TypeListFieldVec3>;
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates ToArray() const;
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
public:
|
||||
using Superclass::Superclass;
|
||||
|
||||
// Make the return also behave as ArrayHandleVirtualCoordiantes
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
operator vtkm::cont::ArrayHandleVirtualCoordinates() const
|
||||
{
|
||||
return this->ToArray();
|
||||
}
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
operator vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagVirtual>() const
|
||||
{
|
||||
return this->ToArray();
|
||||
}
|
||||
|
||||
using ValueType VTKM_DEPRECATED(1.6,
|
||||
"CoordinateSystem::GetData() now returns a VariantArrayHandle.") =
|
||||
vtkm::Vec3f;
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
ArrayHandleVirtualCoordinates::ReadPortalType ReadPortal() const
|
||||
{
|
||||
return this->ToArray().ReadPortal();
|
||||
}
|
||||
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
ArrayHandleVirtualCoordinates::WritePortalType WritePortal() const
|
||||
{
|
||||
return this->ToArray().WritePortal();
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::PortalConst
|
||||
PrepareForInput(Device device, vtkm::cont::Token& token) const
|
||||
{
|
||||
return this->ToArray().PrepareForInput(device, token);
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::Portal
|
||||
PrepareForInPlace(Device device, vtkm::cont::Token& token) const
|
||||
{
|
||||
return this->ToArray().PrepareForInPlace(device, token);
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
|
||||
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::Portal
|
||||
PrepareForOutput(vtkm::Id numberOfValues, Device device, vtkm::cont::Token& token) const
|
||||
{
|
||||
return this->ToArray().PrepareForOutput(numberOfValues, device, token);
|
||||
}
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
VTKM_CONT VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"CoordinateSystem::GetData() now returns a "
|
||||
"VariantArrayHandle.") inline void printSummary_ArrayHandle(const detail::CoordDataDepWrapper&
|
||||
array,
|
||||
std::ostream& out,
|
||||
bool full = false)
|
||||
{
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates coordArray = array;
|
||||
vtkm::cont::printSummary_ArrayHandle(coordArray, out, full);
|
||||
}
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
|
||||
{
|
||||
using Superclass = vtkm::cont::Field;
|
||||
using CoordinatesTypeList = vtkm::List<vtkm::cont::ArrayHandleVirtualCoordinates::ValueType>;
|
||||
using CoordinatesTypeList = vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
CoordinateSystem();
|
||||
|
||||
VTKM_CONT CoordinateSystem(std::string name,
|
||||
const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& data);
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT CoordinateSystem(std::string name,
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& data);
|
||||
VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::VariantArrayHandleCommon& data);
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
|
||||
: Superclass(name, Association::POINTS, vtkm::cont::ArrayHandleVirtualCoordinates(data))
|
||||
: Superclass(name, Association::POINTS, data)
|
||||
{
|
||||
}
|
||||
|
||||
@ -54,17 +146,54 @@ public:
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates GetData() const;
|
||||
VTKM_CONT detail::CoordDataDepWrapper GetData() const;
|
||||
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& newdata);
|
||||
private:
|
||||
#ifdef VTKM_USE_DOUBLE_PRECISION
|
||||
using FloatNonDefault = vtkm::Float32;
|
||||
#else
|
||||
using FloatNonDefault = vtkm::Float64;
|
||||
#endif
|
||||
using Vec3f_nd = vtkm::Vec<FloatNonDefault, 3>;
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata);
|
||||
struct StorageToArrayDefault
|
||||
{
|
||||
template <typename S>
|
||||
using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<vtkm::Vec3f, S>;
|
||||
|
||||
VTKM_CONT
|
||||
template <typename TypeList>
|
||||
void SetData(const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata);
|
||||
template <typename S>
|
||||
using Transform = vtkm::cont::ArrayHandle<vtkm::Vec3f, S>;
|
||||
};
|
||||
|
||||
struct StorageToArrayNonDefault
|
||||
{
|
||||
template <typename S>
|
||||
using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<Vec3f_nd, S>;
|
||||
|
||||
template <typename S>
|
||||
using Transform =
|
||||
vtkm::cont::ArrayHandleCast<vtkm::Vec3f, vtkm::cont::ArrayHandle<Vec3f_nd, S>>;
|
||||
};
|
||||
|
||||
using ArraysFloatDefault = vtkm::ListTransform<
|
||||
vtkm::ListRemoveIf<VTKM_DEFAULT_STORAGE_LIST, StorageToArrayDefault::IsInvalid>,
|
||||
StorageToArrayDefault::Transform>;
|
||||
using ArraysFloatNonDefault = vtkm::ListTransform<
|
||||
vtkm::ListRemoveIf<VTKM_DEFAULT_STORAGE_LIST, StorageToArrayNonDefault::IsInvalid>,
|
||||
StorageToArrayNonDefault::Transform>;
|
||||
|
||||
public:
|
||||
using MultiplexerArrayType = //
|
||||
vtkm::cont::ArrayHandleMultiplexerFromList<
|
||||
vtkm::ListAppend<ArraysFloatDefault, ArraysFloatNonDefault>>;
|
||||
|
||||
/// \brief Returns the data for the coordinate system as an `ArrayHandleMultiplexer`.
|
||||
///
|
||||
/// This array will handle all potential types supported by CoordinateSystem, so all types can be
|
||||
/// handled with one compile pass. However, using this precludes specialization for special
|
||||
/// arrays such as `ArrayHandleUniformPointCoordinates` that could have optimized code paths
|
||||
///
|
||||
VTKM_CONT MultiplexerArrayType GetDataAsMultiplexer() const;
|
||||
|
||||
VTKM_CONT
|
||||
void GetRange(vtkm::Range* range) const
|
||||
@ -138,6 +267,12 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct DynamicTransformTraits<vtkm::cont::detail::CoordDataDepWrapper>
|
||||
{
|
||||
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
@ -148,22 +283,32 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
namespace mangled_diy_namespace
|
||||
{
|
||||
|
||||
template <>
|
||||
struct Serialization<vtkm::cont::detail::CoordDataDepWrapper>
|
||||
: public Serialization<
|
||||
vtkm::cont::VariantArrayHandleBase<vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>>>
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Serialization<vtkm::cont::CoordinateSystem>
|
||||
{
|
||||
using CoordinatesTypeList = vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>;
|
||||
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const vtkm::cont::CoordinateSystem& cs)
|
||||
{
|
||||
vtkmdiy::save(bb, cs.GetName());
|
||||
vtkmdiy::save(bb, cs.GetData());
|
||||
vtkmdiy::save(
|
||||
bb, static_cast<vtkm::cont::VariantArrayHandleBase<CoordinatesTypeList>>(cs.GetData()));
|
||||
}
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::CoordinateSystem& cs)
|
||||
{
|
||||
std::string name;
|
||||
vtkmdiy::load(bb, name);
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates array;
|
||||
vtkmdiy::load(bb, array);
|
||||
cs = vtkm::cont::CoordinateSystem(name, array);
|
||||
vtkm::cont::VariantArrayHandleBase<CoordinatesTypeList> data;
|
||||
vtkmdiy::load(bb, data);
|
||||
cs = vtkm::cont::CoordinateSystem(name, data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,73 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_CoordinateSystem_hxx
|
||||
#define vtk_m_cont_CoordinateSystem_hxx
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct MakeArrayHandleVirtualCoordinatesFunctor
|
||||
{
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, StorageTag>& array,
|
||||
ArrayHandleVirtualCoordinates& output) const
|
||||
{
|
||||
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, StorageTag>& array,
|
||||
ArrayHandleVirtualCoordinates& output) const
|
||||
{
|
||||
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates MakeArrayHandleVirtualCoordinates(
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& array)
|
||||
{
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates output;
|
||||
vtkm::cont::CastAndCall(array.ResetTypes(vtkm::TypeListFieldVec3{}),
|
||||
MakeArrayHandleVirtualCoordinatesFunctor{},
|
||||
output);
|
||||
return output;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& data)
|
||||
: Superclass(name, Association::POINTS, detail::MakeArrayHandleVirtualCoordinates(data))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void CoordinateSystem::SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata)
|
||||
{
|
||||
this->SetData(vtkm::cont::ArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata)
|
||||
{
|
||||
this->SetData(detail::MakeArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -69,19 +69,29 @@ public:
|
||||
const std::string& coordsNm = "coords");
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
const vtkm::cont::ArrayHandle<T>& xVals,
|
||||
const vtkm::cont::ArrayHandle<T>& yVals,
|
||||
const vtkm::cont::ArrayHandle<T>& zVals,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords")
|
||||
VTKM_DEPRECATED(1.6,
|
||||
"Combine point coordinate arrays using most appropriate array (e.g. "
|
||||
"ArrayHandleCompositeVector, ArrayHandleSOA, ArrayHandleCartesianProduct")
|
||||
VTKM_CONT static vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<T>& xVals,
|
||||
const vtkm::cont::ArrayHandle<T>& yVals,
|
||||
const vtkm::cont::ArrayHandle<T>& zVals,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords")
|
||||
{
|
||||
VTKM_ASSERT(xVals.GetNumberOfValues() == yVals.GetNumberOfValues());
|
||||
VTKM_ASSERT(xVals.GetNumberOfValues() == zVals.GetNumberOfValues());
|
||||
|
||||
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
|
||||
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
xVals, yVals, zVals, shapes, offsets, connectivity, coordsNm);
|
||||
vtkm::cont::make_ArrayHandleCompositeVector(xVals, yVals, zVals),
|
||||
shapes,
|
||||
offsets,
|
||||
connectivity,
|
||||
coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -123,15 +133,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
static vtkm::cont::DataSet BuildDataSet(const vtkm::cont::ArrayHandle<T>& X,
|
||||
const vtkm::cont::ArrayHandle<T>& Y,
|
||||
const vtkm::cont::ArrayHandle<T>& Z,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& offsets,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm);
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
||||
@ -161,9 +162,16 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
{
|
||||
VTKM_ASSERT(xVals.size() == yVals.size() && yVals.size() == zVals.size() && xVals.size() > 0);
|
||||
|
||||
auto xArray = vtkm::cont::make_ArrayHandle(xVals, vtkm::CopyFlag::On);
|
||||
auto yArray = vtkm::cont::make_ArrayHandle(yVals, vtkm::CopyFlag::On);
|
||||
auto zArray = vtkm::cont::make_ArrayHandle(zVals, vtkm::CopyFlag::On);
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> coordsArray;
|
||||
coordsArray.Allocate(static_cast<vtkm::Id>(xVals.size()));
|
||||
auto coordsPortal = coordsArray.WritePortal();
|
||||
for (std::size_t index = 0; index < xVals.size(); ++index)
|
||||
{
|
||||
coordsPortal.Set(static_cast<vtkm::Id>(index),
|
||||
vtkm::make_Vec(static_cast<vtkm::FloatDefault>(xVals[index]),
|
||||
static_cast<vtkm::FloatDefault>(yVals[index]),
|
||||
static_cast<vtkm::FloatDefault>(zVals[index])));
|
||||
}
|
||||
|
||||
auto shapesArray = vtkm::cont::make_ArrayHandle(shapes, vtkm::CopyFlag::On);
|
||||
auto connArray = vtkm::cont::make_ArrayHandle(connectivity, vtkm::CopyFlag::On);
|
||||
@ -172,33 +180,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
vtkm::cont::make_ArrayHandle(numIndices, vtkm::CopyFlag::Off));
|
||||
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
xArray, yArray, zArray, shapesArray, offsetsArray, connArray, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<T>& X,
|
||||
const vtkm::cont::ArrayHandle<T>& Y,
|
||||
const vtkm::cont::ArrayHandle<T>& Z,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& offsets,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm)
|
||||
{
|
||||
VTKM_ASSERT(X.GetNumberOfValues() == Y.GetNumberOfValues() &&
|
||||
Y.GetNumberOfValues() == Z.GetNumberOfValues() && X.GetNumberOfValues() > 0 &&
|
||||
shapes.GetNumberOfValues() + 1 == offsets.GetNumberOfValues());
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(coordsNm, make_ArrayHandleCompositeVector(X, Y, Z)));
|
||||
vtkm::Id nPts = X.GetNumberOfValues();
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
|
||||
cellSet.Fill(nPts, shapes, connectivity, offsets);
|
||||
dataSet.SetCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
coordsArray, shapesArray, offsetsArray, connArray, coordsNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -27,7 +27,8 @@ class VTKM_CONT_EXPORT DataSetBuilderRectilinear
|
||||
template <typename T, typename U>
|
||||
VTKM_CONT static void CopyInto(const std::vector<T>& input, vtkm::cont::ArrayHandle<U>& output)
|
||||
{
|
||||
DataSetBuilderRectilinear::CopyInto(vtkm::cont::make_ArrayHandle(input), output);
|
||||
DataSetBuilderRectilinear::CopyInto(vtkm::cont::make_ArrayHandle(input, vtkm::CopyFlag::Off),
|
||||
output);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
@ -40,7 +41,8 @@ class VTKM_CONT_EXPORT DataSetBuilderRectilinear
|
||||
template <typename T, typename U>
|
||||
VTKM_CONT static void CopyInto(const T* input, vtkm::Id len, vtkm::cont::ArrayHandle<U>& output)
|
||||
{
|
||||
DataSetBuilderRectilinear::CopyInto(vtkm::cont::make_ArrayHandle(input, len), output);
|
||||
DataSetBuilderRectilinear::CopyInto(
|
||||
vtkm::cont::make_ArrayHandle(input, len, vtkm::CopyFlag::Off), output);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -126,10 +126,10 @@ public:
|
||||
this->ModifiedFlag = true;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetData(const vtkm::cont::VariantArrayHandle& newdata)
|
||||
template <typename TypeList>
|
||||
VTKM_CONT void SetData(const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata)
|
||||
{
|
||||
this->Data = newdata;
|
||||
this->Data = vtkm::cont::VariantArrayHandle(newdata);
|
||||
this->ModifiedFlag = true;
|
||||
}
|
||||
|
||||
@ -181,20 +181,61 @@ vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
const T* data,
|
||||
vtkm::Id size,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
vtkm::CopyFlag copy)
|
||||
{
|
||||
return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandle(data, size, copy));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_Field.")
|
||||
vtkm::cont::Field
|
||||
make_Field(std::string name, Field::Association association, const T* data, vtkm::Id size)
|
||||
{
|
||||
return make_Field(name, association, data, size, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
const std::vector<T>& data,
|
||||
vtkm::CopyFlag copy = vtkm::CopyFlag::Off)
|
||||
vtkm::CopyFlag copy)
|
||||
{
|
||||
return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandle(data, copy));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_DEPRECATED(1.6, "Specify a vtkm::CopyFlag or use a move version of make_Field.")
|
||||
vtkm::cont::Field
|
||||
make_Field(std::string name, Field::Association association, const std::vector<T>& data)
|
||||
{
|
||||
return make_Field(name, association, data, vtkm::CopyFlag::Off);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::Field make_FieldMove(std::string name,
|
||||
Field::Association association,
|
||||
std::vector<T>&& data)
|
||||
{
|
||||
return vtkm::cont::Field(name, association, vtkm::cont::make_ArrayHandleMove(data));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
std::vector<T>&& data,
|
||||
vtkm::CopyFlag vtkmNotUsed(copy))
|
||||
{
|
||||
return make_FieldMove(name, association, std::move(data));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::Field make_Field(std::string name,
|
||||
Field::Association association,
|
||||
std::initializer_list<T>&& data)
|
||||
{
|
||||
return make_FieldMove(name, association, vtkm::cont::make_ArrayHandle(std::move(data)));
|
||||
}
|
||||
|
||||
//@}
|
||||
|
||||
/// Convenience function to build point fields from vtkm::cont::ArrayHandle
|
||||
|
@ -10,10 +10,8 @@
|
||||
#ifndef vtk_m_cont_Invoker_h
|
||||
#define vtk_m_cont_Invoker_h
|
||||
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/DispatcherPointNeighborhood.h>
|
||||
#include <vtkm/worklet/DispatcherReduceByKey.h>
|
||||
#include <vtkm/worklet/internal/MaskBase.h>
|
||||
#include <vtkm/worklet/internal/ScatterBase.h>
|
||||
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
|
||||
|
@ -24,9 +24,10 @@ namespace cont
|
||||
/// Given an \c ArrayHandle of vtkm::Particle, this function copies the
|
||||
/// position field into an \c ArrayHandle of \c Vec3f objects.
|
||||
///
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT void ParticleArrayCopy(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Particle, vtkm::cont::StorageTagBasic>& inP,
|
||||
|
||||
template <typename ParticleType>
|
||||
VTKM_ALWAYS_EXPORT inline void ParticleArrayCopy(
|
||||
const vtkm::cont::ArrayHandle<ParticleType, vtkm::cont::StorageTagBasic>& inP,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagBasic>& outPos);
|
||||
|
||||
/// \brief Copy all fields in vtkm::Particle to standard types.
|
||||
@ -35,9 +36,10 @@ VTKM_CONT void ParticleArrayCopy(
|
||||
/// position, ID, number of steps, status and time into a separate
|
||||
/// \c ArrayHandle.
|
||||
///
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT void ParticleArrayCopy(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Particle, vtkm::cont::StorageTagBasic>& inP,
|
||||
|
||||
template <typename ParticleType>
|
||||
VTKM_ALWAYS_EXPORT inline void ParticleArrayCopy(
|
||||
const vtkm::cont::ArrayHandle<ParticleType, vtkm::cont::StorageTagBasic>& inP,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagBasic>& outPos,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>& outID,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>& outSteps,
|
||||
@ -46,4 +48,8 @@ VTKM_CONT void ParticleArrayCopy(
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#ifndef vtk_m_cont_ParticleArrayCopy_hxx
|
||||
#include <vtkm/cont/ParticleArrayCopy.hxx>
|
||||
#endif //vtk_m_cont_ParticleArrayCopy_hxx
|
||||
|
||||
#endif //vtk_m_cont_ParticleArrayCopy_h
|
||||
|
97
vtkm/cont/ParticleArrayCopy.hxx
Normal file
97
vtkm/cont/ParticleArrayCopy.hxx
Normal file
@ -0,0 +1,97 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#ifndef vtk_m_cont_ParticleArrayCopy_hxx
|
||||
#define vtk_m_cont_ParticleArrayCopy_hxx
|
||||
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/cont/ParticleArrayCopy.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct CopyParticlePositionWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
using ControlSignature = void(FieldIn inParticle, FieldOut outPos);
|
||||
|
||||
VTKM_EXEC void operator()(const vtkm::Particle& inParticle, vtkm::Vec3f& outPos) const
|
||||
{
|
||||
outPos = inParticle.Pos;
|
||||
}
|
||||
};
|
||||
|
||||
struct CopyParticleAllWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
using ControlSignature = void(FieldIn inParticle,
|
||||
FieldOut outPos,
|
||||
FieldOut outID,
|
||||
FieldOut outSteps,
|
||||
FieldOut outStatus,
|
||||
FieldOut outTime);
|
||||
|
||||
VTKM_EXEC void operator()(const vtkm::Particle& inParticle,
|
||||
vtkm::Vec3f& outPos,
|
||||
vtkm::Id& outID,
|
||||
vtkm::Id& outSteps,
|
||||
vtkm::ParticleStatus& outStatus,
|
||||
vtkm::FloatDefault& outTime) const
|
||||
{
|
||||
outPos = inParticle.Pos;
|
||||
outID = inParticle.ID;
|
||||
outSteps = inParticle.NumSteps;
|
||||
outStatus = inParticle.Status;
|
||||
outTime = inParticle.Time;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
template <typename ParticleType>
|
||||
VTKM_ALWAYS_EXPORT inline void ParticleArrayCopy(
|
||||
const vtkm::cont::ArrayHandle<ParticleType, vtkm::cont::StorageTagBasic>& inP,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagBasic>& outPos)
|
||||
{
|
||||
vtkm::cont::Invoker invoke;
|
||||
detail::CopyParticlePositionWorklet worklet;
|
||||
|
||||
invoke(worklet, inP, outPos);
|
||||
}
|
||||
|
||||
/// \brief Copy all fields in vtkm::Particle to standard types.
|
||||
///
|
||||
/// Given an \c ArrayHandle of vtkm::Particle, this function copies the
|
||||
/// position, ID, number of steps, status and time into a separate
|
||||
/// \c ArrayHandle.
|
||||
///
|
||||
|
||||
template <typename ParticleType>
|
||||
VTKM_ALWAYS_EXPORT inline void ParticleArrayCopy(
|
||||
const vtkm::cont::ArrayHandle<ParticleType, vtkm::cont::StorageTagBasic>& inP,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagBasic>& outPos,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>& outID,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagBasic>& outSteps,
|
||||
vtkm::cont::ArrayHandle<vtkm::ParticleStatus, vtkm::cont::StorageTagBasic>& outStatus,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>& outTime)
|
||||
{
|
||||
vtkm::cont::Invoker invoke;
|
||||
detail::CopyParticleAllWorklet worklet;
|
||||
|
||||
invoke(worklet, inP, outPos, outID, outSteps, outStatus, outTime);
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#endif //vtk_m_cont_ParticleArrayCopy_hxx
|
@ -115,7 +115,7 @@ struct PointLocatorUniformGrid::PrepareExecutionObjectFunctor
|
||||
rmin,
|
||||
rmax,
|
||||
self.Dims,
|
||||
self.GetCoordinates().GetData().PrepareForInput(DeviceAdapter(), token),
|
||||
self.GetCoordinates().GetDataAsMultiplexer().PrepareForInput(DeviceAdapter(), token),
|
||||
self.PointIds.PrepareForInput(DeviceAdapter(), token),
|
||||
self.CellLower.PrepareForInput(DeviceAdapter(), token),
|
||||
self.CellUpper.PrepareForInput(DeviceAdapter(), token));
|
||||
|
@ -395,15 +395,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// Create with externally managed memory
|
||||
Storage(const BaseT* array, vtkm::Id arrayLength, vtkm::Int32 numberOfPlanes, bool cylindrical)
|
||||
: Array(vtkm::cont::make_ArrayHandle(array, arrayLength))
|
||||
, NumberOfPlanes(numberOfPlanes)
|
||||
, UseCylindrical(cylindrical)
|
||||
{
|
||||
VTKM_ASSERT(this->Array.GetNumberOfValues() >= 0);
|
||||
}
|
||||
|
||||
Storage(const HandleType& array, vtkm::Int32 numberOfPlanes, bool cylindrical)
|
||||
: Array(array)
|
||||
, NumberOfPlanes(numberOfPlanes)
|
||||
|
@ -84,7 +84,18 @@ public:
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT ArrayHandleType Cast() const
|
||||
{
|
||||
// MSVC will issue deprecation warnings if this templated method is instantiated with
|
||||
// a deprecated class here even if the method is called from a section of code where
|
||||
// deprecation warnings are suppressed. This is annoying behavior since this templated
|
||||
// method has no control over what class it is used from. To get around it, we have to
|
||||
// suppress all deprecation warnings here.
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
#endif
|
||||
return internal::variant::Cast<ArrayHandleType>(this->ArrayContainer.get());
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
}
|
||||
|
||||
/// \brief Call a functor using the underlying array type.
|
||||
@ -202,7 +213,7 @@ public:
|
||||
|
||||
/// \brief Holds an array handle without having to specify template parameters.
|
||||
///
|
||||
/// \c VariantArrayHandle holds an \c ArrayHandle or \c ArrayHandleVirtual
|
||||
/// `VariantArrayHandle` holds an `ArrayHandle`
|
||||
/// object using runtime polymorphism to manage different value types and
|
||||
/// storage rather than compile-time templates. This adds a programming
|
||||
/// convenience that helps avoid a proliferation of templates. It also provides
|
||||
@ -210,24 +221,23 @@ public:
|
||||
/// will not be known until runtime.
|
||||
///
|
||||
/// To interface between the runtime polymorphism and the templated algorithms
|
||||
/// in VTK-m, \c VariantArrayHandle contains a method named \c CastAndCall that
|
||||
/// will determine the correct type from some known list of types. It returns
|
||||
/// an ArrayHandleVirtual which type erases the storage type by using polymorphism.
|
||||
/// in VTK-m, `VariantArrayHandle` contains a method named `CastAndCall` that
|
||||
/// will determine the correct type from some known list of types.
|
||||
/// This mechanism is used internally by VTK-m's worklet invocation
|
||||
/// mechanism to determine the type when running algorithms.
|
||||
///
|
||||
/// By default, \c VariantArrayHandle will assume that the value type in the
|
||||
/// array matches one of the types specified by \c VTKM_DEFAULT_TYPE_LIST
|
||||
/// This list can be changed by using the \c ResetTypes. It is
|
||||
/// By default, `VariantArrayHandle` will assume that the value type in the
|
||||
/// array matches one of the types specified by `VTKM_DEFAULT_TYPE_LIST`
|
||||
/// This list can be changed by using the `ResetTypes`. It is
|
||||
/// worthwhile to match these lists closely to the possible types that might be
|
||||
/// used. If a type is missing you will get a runtime error. If there are more
|
||||
/// types than necessary, then the template mechanism will create a lot of
|
||||
/// object code that is never used, and keep in mind that the number of
|
||||
/// combinations grows exponentially when using multiple \c VariantArrayHandle
|
||||
/// combinations grows exponentially when using multiple `VariantArrayHandle`
|
||||
/// objects.
|
||||
///
|
||||
/// The actual implementation of \c VariantArrayHandle is in a templated class
|
||||
/// named \c VariantArrayHandleBase, which is templated on the list of
|
||||
/// The actual implementation of `VariantArrayHandle` is in a templated class
|
||||
/// named `VariantArrayHandleBase`, which is templated on the list of
|
||||
/// component types.
|
||||
///
|
||||
template <typename TypeList>
|
||||
@ -301,16 +311,12 @@ public:
|
||||
/// `CastAndCall` attempts to cast the held array to a specific value type,
|
||||
/// then call the given functor with the cast array. The types
|
||||
/// tried in the cast are those in the lists defined by the TypeList.
|
||||
/// By default \c VariantArrayHandle set this to \c VTKM_DEFAULT_TYPE_LIST.
|
||||
/// By default `VariantArrayHandle` set this to `VTKM_DEFAULT_TYPE_LIST`.
|
||||
///
|
||||
/// In addition to the value type, an \c ArrayHandle also requires a storage tag.
|
||||
/// By default, \c CastAndCall attempts to cast the array using the storage tags
|
||||
/// listed in \c VTKM_DEFAULT_STORAGE_LIST. You can optionally give a custom
|
||||
/// list of storage tags as the second argument. If the storage of the underlying
|
||||
/// array does not match any of the storage tags given, then the array will
|
||||
/// be cast to an \c ArrayHandleVirtual, which can hold any array given the
|
||||
/// appropriate value type. To always use \c ArrayHandleVirtual, pass
|
||||
/// \c vtkm::ListEmpty as thefirst argument.
|
||||
/// In addition to the value type, an `ArrayHandle` also requires a storage tag.
|
||||
/// By default, `CastAndCall` attempts to cast the array using the storage tags
|
||||
/// listed in `VTKM_DEFAULT_STORAGE_LIST`. You can optionally give a custom
|
||||
/// list of storage tags as the second argument.
|
||||
///
|
||||
/// As previous stated, if a storage tag list is provided, it is given in the
|
||||
/// first argument. The functor to call with the cast array is given as the next
|
||||
@ -318,7 +324,7 @@ public:
|
||||
/// The remaning arguments, if any, are passed to the functor.
|
||||
///
|
||||
/// The functor will be called with the cast array as its first argument. Any
|
||||
/// remaining arguments are passed from the arguments to \c CastAndCall.
|
||||
/// remaining arguments are passed from the arguments to `CastAndCall`.
|
||||
///
|
||||
template <typename FunctorOrStorageList, typename... Args>
|
||||
VTKM_CONT void CastAndCall(FunctorOrStorageList&& functorOrStorageList, Args&&... args) const
|
||||
@ -423,35 +429,6 @@ struct VariantArrayHandleTry
|
||||
}
|
||||
};
|
||||
|
||||
struct VariantArrayHandleTryFallback
|
||||
{
|
||||
template <typename T, typename Functor, typename... Args>
|
||||
void operator()(T,
|
||||
Functor&& f,
|
||||
bool& called,
|
||||
const vtkm::cont::internal::VariantArrayHandleContainerBase& container,
|
||||
Args&&... args) const
|
||||
{
|
||||
if (!called && vtkm::cont::internal::variant::IsValueType<T>(&container))
|
||||
{
|
||||
called = true;
|
||||
const auto* derived =
|
||||
static_cast<const vtkm::cont::internal::VariantArrayHandleContainer<T>*>(&container);
|
||||
VTKM_LOG_CAST_SUCC(container, derived);
|
||||
|
||||
// If you get a compile error here, it means that you have called CastAndCall for a
|
||||
// vtkm::cont::VariantArrayHandle and the arguments of the functor do not match those
|
||||
// being passed. This is often because it is calling the functor with an ArrayHandle
|
||||
// type that was not expected. Either add overloads to the functor to accept all
|
||||
// possible array types or constrain the types tried for the CastAndCall. Note that
|
||||
// the functor will be called with an array of type vtkm::cont::ArrayHandle<T, S>.
|
||||
// Directly using a subclass of ArrayHandle (e.g. vtkm::cont::ArrayHandleConstant<T>)
|
||||
// might not work.
|
||||
f(derived->Array, std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IsUndefinedStorage
|
||||
{
|
||||
@ -484,16 +461,6 @@ VTKM_CONT void VariantArrayHandleCommon::CastAndCall(Functor&& f, Args&&... args
|
||||
ref,
|
||||
std::forward<Args>(args)...);
|
||||
if (!called)
|
||||
{
|
||||
// try to fall back to using ArrayHandleVirtual
|
||||
vtkm::ListForEach(detail::VariantArrayHandleTryFallback{},
|
||||
TypeList{},
|
||||
std::forward<Functor>(f),
|
||||
called,
|
||||
ref,
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
if (!called)
|
||||
{
|
||||
// throw an exception
|
||||
VTKM_LOG_CAST_FAIL(*this, TypeList);
|
||||
@ -660,14 +627,14 @@ struct VariantArrayHandleSerializeFunctor
|
||||
|
||||
struct VariantArrayHandleDeserializeFunctor
|
||||
{
|
||||
template <typename T, typename TypeList>
|
||||
void operator()(T,
|
||||
template <typename T, typename S, typename TypeList>
|
||||
void operator()(vtkm::List<T, S>,
|
||||
vtkm::cont::VariantArrayHandleBase<TypeList>& dh,
|
||||
const std::string& typeString,
|
||||
bool& success,
|
||||
BinaryBuffer& bb) const
|
||||
{
|
||||
using ArrayHandleType = vtkm::cont::ArrayHandleVirtual<T>;
|
||||
using ArrayHandleType = vtkm::cont::ArrayHandle<T, S>;
|
||||
|
||||
if (!success && (typeString == vtkm::cont::SerializableTypeString<ArrayHandleType>::Get()))
|
||||
{
|
||||
@ -690,7 +657,7 @@ private:
|
||||
public:
|
||||
static VTKM_CONT void save(BinaryBuffer& bb, const Type& obj)
|
||||
{
|
||||
obj.CastAndCall(vtkm::ListEmpty(), internal::VariantArrayHandleSerializeFunctor{}, bb);
|
||||
obj.CastAndCall(internal::VariantArrayHandleSerializeFunctor{}, bb);
|
||||
}
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& obj)
|
||||
@ -699,8 +666,12 @@ public:
|
||||
vtkmdiy::load(bb, typeString);
|
||||
|
||||
bool success = false;
|
||||
vtkm::ListForEach(
|
||||
internal::VariantArrayHandleDeserializeFunctor{}, TypeList{}, obj, typeString, success, bb);
|
||||
vtkm::ListForEach(internal::VariantArrayHandleDeserializeFunctor{},
|
||||
vtkm::cont::detail::ListDynamicTypes<TypeList, VTKM_DEFAULT_STORAGE_LIST>{},
|
||||
obj,
|
||||
typeString,
|
||||
success,
|
||||
bb);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ struct TryArrayInType
|
||||
}
|
||||
|
||||
using ArrayHandleType = vtkm::cont::ArrayHandle<T>;
|
||||
ArrayHandleType handle = vtkm::cont::make_ArrayHandle(array, ARRAY_SIZE);
|
||||
ArrayHandleType handle = vtkm::cont::make_ArrayHandle(array, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
|
||||
using PortalType = typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst;
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct TryArrayInOutType
|
||||
}
|
||||
|
||||
using ArrayHandleType = vtkm::cont::ArrayHandle<T>;
|
||||
ArrayHandleType handle = vtkm::cont::make_ArrayHandle(array, ARRAY_SIZE);
|
||||
ArrayHandleType handle = vtkm::cont::make_ArrayHandle(array, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
|
||||
using PortalType = typename ArrayHandleType::template ExecutionTypes<Device>::Portal;
|
||||
|
||||
|
@ -43,7 +43,7 @@ VTKM_CONT_EXPORT void ThrowCastAndCallException(
|
||||
const std::type_info& type)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Could not find appropriate cast for array in CastAndCall1.\n"
|
||||
out << "Could not find appropriate cast for array in CastAndCall.\n"
|
||||
"Array: ";
|
||||
ref.PrintSummary(out);
|
||||
out << "TypeList: " << type.name() << "\n";
|
||||
|
@ -211,6 +211,14 @@ struct VTKM_ALWAYS_EXPORT Caster<T, vtkm::cont::StorageTagVirtual>
|
||||
}
|
||||
};
|
||||
|
||||
// MSVC will issue deprecation warnings here if this template is instantiated with
|
||||
// a deprecated class even if the template is used from a section of code where
|
||||
// deprecation warnings are suppressed. This is annoying behavior since this template
|
||||
// has no control over what class it is used with. To get around it, we have to
|
||||
// suppress all deprecation warnings here.
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
#endif
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT ArrayHandleType Cast(const VariantArrayHandleContainerBase* container)
|
||||
{ //container could be nullptr
|
||||
@ -220,6 +228,9 @@ VTKM_CONT ArrayHandleType Cast(const VariantArrayHandleContainerBase* container)
|
||||
auto ret = Caster<Type, Storage>{}(container);
|
||||
return ArrayHandleType(std::move(ret));
|
||||
}
|
||||
#ifdef VTKM_MSVC
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
#endif
|
||||
|
||||
struct ForceCastToVirtual
|
||||
{
|
||||
|
@ -48,10 +48,10 @@ void VectorReallocator(void*& memory,
|
||||
{
|
||||
std::vector<T>* v = reinterpret_cast<std::vector<T>*>(container);
|
||||
VTKM_TEST_ASSERT(v->size() == static_cast<std::size_t>(oldSize));
|
||||
VTKM_TEST_ASSERT(memory == &v->front());
|
||||
VTKM_TEST_ASSERT(v->empty() || (memory == v->data()));
|
||||
|
||||
v->resize(static_cast<std::size_t>(newSize));
|
||||
memory = &v->front();
|
||||
memory = v->data();
|
||||
}
|
||||
struct VectorDeleter
|
||||
{
|
||||
@ -67,7 +67,7 @@ struct VectorDeleter
|
||||
{
|
||||
if (this->Data)
|
||||
{
|
||||
VTKM_TEST_ASSERT(reinterpret_cast<T*>(p) == &this->Data->front());
|
||||
VTKM_TEST_ASSERT(reinterpret_cast<T*>(p) == this->Data->data());
|
||||
this->Data.reset();
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ void DoTest()
|
||||
|
||||
std::cout << "Reset with device data" << std::endl;
|
||||
std::vector<T> v(ARRAY_SIZE);
|
||||
void* devicePointer = &v.front();
|
||||
void* devicePointer = v.data();
|
||||
SetPortal(MakePortal(devicePointer, ARRAY_SIZE));
|
||||
buffer.Reset(vtkm::cont::internal::BufferInfo(device,
|
||||
devicePointer,
|
||||
|
@ -90,6 +90,21 @@ static void ComputeChunkSize(const vtkm::Id numVals,
|
||||
valuesPerChunk = CeilDivide(pagesPerChunk * VTKM_PAGE_SIZE, bytesPerValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct CleanArrayRefImpl
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template <typename PortalType>
|
||||
struct CleanArrayRefImpl<vtkm::internal::ArrayPortalValueReference<PortalType>>
|
||||
{
|
||||
using type = typename PortalType::ValueType;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using CleanArrayRef = typename CleanArrayRefImpl<T>::type;
|
||||
|
||||
template <typename T, typename U>
|
||||
static void DoCopy(T src, U dst, vtkm::Id numVals, std::true_type)
|
||||
{
|
||||
@ -103,19 +118,24 @@ static void DoCopy(T src, U dst, vtkm::Id numVals, std::true_type)
|
||||
template <typename InIterT, typename OutIterT>
|
||||
static void DoCopy(InIterT inIter, OutIterT outIter, vtkm::Id numVals, std::false_type)
|
||||
{
|
||||
using ValueType = typename std::iterator_traits<OutIterT>::value_type;
|
||||
using InValueType = CleanArrayRef<typename std::iterator_traits<InIterT>::value_type>;
|
||||
using OutValueType = CleanArrayRef<typename std::iterator_traits<OutIterT>::value_type>;
|
||||
|
||||
for (vtkm::Id i = 0; i < numVals; ++i)
|
||||
{
|
||||
*(outIter++) = static_cast<ValueType>(*(inIter++));
|
||||
// The conversion to InputType and then OutputType looks weird, but it is necessary.
|
||||
// *inItr actually returns an ArrayPortalValueReference, which can automatically convert
|
||||
// itself to InputType but not necessarily OutputType. Thus, we first convert to
|
||||
// InputType, and then allow the conversion to OutputType.
|
||||
*(outIter++) = static_cast<OutValueType>(static_cast<InValueType>(*(inIter++)));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename InIterT, typename OutIterT>
|
||||
static void DoCopy(InIterT inIter, OutIterT outIter, vtkm::Id numVals)
|
||||
{
|
||||
using InValueType = typename std::iterator_traits<InIterT>::value_type;
|
||||
using OutValueType = typename std::iterator_traits<OutIterT>::value_type;
|
||||
using InValueType = CleanArrayRef<typename std::iterator_traits<InIterT>::value_type>;
|
||||
using OutValueType = CleanArrayRef<typename std::iterator_traits<OutIterT>::value_type>;
|
||||
|
||||
DoCopy(inIter, outIter, numVals, std::is_same<InValueType, OutValueType>());
|
||||
}
|
||||
|
@ -46,22 +46,32 @@ private:
|
||||
// template calls std::copy if and only if the types match, otherwise falls
|
||||
// back to a iterative casting approach. Since std::copy can only really
|
||||
// optimize same-type copies, this shouldn't affect performance.
|
||||
template <typename InIter, typename OutIter>
|
||||
static void DoCopy(InIter src, InIter srcEnd, OutIter dst, std::false_type)
|
||||
template <typename InPortal, typename OutPortal>
|
||||
static void DoCopy(InPortal src,
|
||||
OutPortal dst,
|
||||
std::false_type,
|
||||
vtkm::Id startIndex,
|
||||
vtkm::Id numToCopy,
|
||||
vtkm::Id outIndex)
|
||||
{
|
||||
using OutputType = typename std::iterator_traits<OutIter>::value_type;
|
||||
while (src != srcEnd)
|
||||
using OutputType = typename OutPortal::ValueType;
|
||||
for (vtkm::Id index = 0; index < numToCopy; ++index)
|
||||
{
|
||||
*dst = static_cast<OutputType>(*src);
|
||||
++src;
|
||||
++dst;
|
||||
dst.Set(index + startIndex, static_cast<OutputType>(src.Get(index + outIndex)));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename InIter, typename OutIter>
|
||||
static void DoCopy(InIter src, InIter srcEnd, OutIter dst, std::true_type)
|
||||
template <typename InPortal, typename OutPortal>
|
||||
static void DoCopy(InPortal src,
|
||||
OutPortal dst,
|
||||
std::true_type,
|
||||
vtkm::Id startIndex,
|
||||
vtkm::Id numToCopy,
|
||||
vtkm::Id outIndex)
|
||||
{
|
||||
std::copy(src, srcEnd, dst);
|
||||
std::copy(vtkm::cont::ArrayPortalToIteratorBegin(src) + startIndex,
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(src) + startIndex + numToCopy,
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(dst) + outIndex);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -85,10 +95,7 @@ public:
|
||||
using InputType = decltype(inputPortal.Get(0));
|
||||
using OutputType = decltype(outputPortal.Get(0));
|
||||
|
||||
DoCopy(vtkm::cont::ArrayPortalToIteratorBegin(inputPortal),
|
||||
vtkm::cont::ArrayPortalToIteratorEnd(inputPortal),
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(outputPortal),
|
||||
std::is_same<InputType, OutputType>());
|
||||
DoCopy(inputPortal, outputPortal, std::is_same<InputType, OutputType>{}, 0, inSize, 0);
|
||||
}
|
||||
|
||||
template <typename T, typename U, class CIn, class CStencil, class COut>
|
||||
@ -188,16 +195,16 @@ public:
|
||||
vtkm::cont::Token token;
|
||||
auto inputPortal = input.PrepareForInput(DeviceAdapterTagSerial(), token);
|
||||
auto outputPortal = output.PrepareForInPlace(DeviceAdapterTagSerial(), token);
|
||||
auto inIter = vtkm::cont::ArrayPortalToIteratorBegin(inputPortal);
|
||||
auto outIter = vtkm::cont::ArrayPortalToIteratorBegin(outputPortal);
|
||||
|
||||
using InputType = decltype(inputPortal.Get(0));
|
||||
using OutputType = decltype(outputPortal.Get(0));
|
||||
|
||||
DoCopy(inIter + inputStartIndex,
|
||||
inIter + inputStartIndex + numberOfElementsToCopy,
|
||||
outIter + outputIndex,
|
||||
std::is_same<InputType, OutputType>());
|
||||
DoCopy(inputPortal,
|
||||
outputPortal,
|
||||
std::is_same<InputType, OutputType>(),
|
||||
inputStartIndex,
|
||||
numberOfElementsToCopy,
|
||||
outputIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -107,10 +107,15 @@ struct CopyBody
|
||||
template <typename InIter, typename OutIter>
|
||||
void DoCopy(InIter src, InIter srcEnd, OutIter dst, std::false_type) const
|
||||
{
|
||||
using OutputType = typename std::iterator_traits<OutIter>::value_type;
|
||||
using InputType = typename InputPortalType::ValueType;
|
||||
using OutputType = typename OutputPortalType::ValueType;
|
||||
while (src != srcEnd)
|
||||
{
|
||||
*dst = static_cast<OutputType>(*src);
|
||||
// The conversion to InputType and then OutputType looks weird, but it is necessary.
|
||||
// *src actually returns an ArrayPortalValueReference, which can automatically convert
|
||||
// itself to InputType but not necessarily OutputType. Thus, we first convert to
|
||||
// InputType, and then allow the conversion to OutputType.
|
||||
*dst = static_cast<OutputType>(static_cast<InputType>(*src));
|
||||
++src;
|
||||
++dst;
|
||||
}
|
||||
|
@ -364,8 +364,10 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet3(const vtkm::Id
|
||||
dataSet.AddPointField("pointvar", pointvar);
|
||||
|
||||
vtkm::Id numCells = (dims[0] - 1) * (dims[1] - 1) * (dims[2] - 1);
|
||||
dataSet.AddCellField(
|
||||
"cellvar", vtkm::cont::make_ArrayHandleCounting(vtkm::Float64(0), vtkm::Float64(1), numCells));
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> cellvar;
|
||||
vtkm::cont::ArrayCopy(
|
||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Float64(0), vtkm::Float64(1), numCells), cellvar);
|
||||
dataSet.AddCellField("cellvar", cellvar);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
#ifndef vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
|
||||
#define vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
|
||||
|
||||
// This is testing deprecated functionality. It is left to make sure that old code
|
||||
// still works, but will be removed if ArrayHandleVirtualCoordinates is removed.
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
@ -17,6 +20,8 @@
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
@ -142,5 +147,6 @@ public:
|
||||
}
|
||||
} // vtkm::cont::testing
|
||||
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
#endif // vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
|
||||
|
@ -177,7 +177,7 @@ private:
|
||||
arrayHandle.ReleaseResourcesExecution();
|
||||
arrayHandle = vtkm::cont::ArrayHandle<T>();
|
||||
arrayHandle.ReleaseResources();
|
||||
arrayHandle = vtkm::cont::make_ArrayHandle(std::vector<T>());
|
||||
arrayHandle = vtkm::cont::make_ArrayHandleMove(std::vector<T>());
|
||||
arrayHandle.PrepareForInput(DeviceAdapterTag(), token);
|
||||
arrayHandle = vtkm::cont::ArrayHandle<T>();
|
||||
arrayHandle.PrepareForInPlace(DeviceAdapterTag(), token);
|
||||
@ -361,6 +361,144 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
struct VerifyVectorMovedMemory
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_CONT void operator()(T) const
|
||||
{
|
||||
std::cout << "Creating moved std::vector memory." << std::endl;
|
||||
std::vector<T> buffer(ARRAY_SIZE);
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||
{
|
||||
buffer[static_cast<std::size_t>(index)] = TestValue(index, T());
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<T> arrayHandle = vtkm::cont::make_ArrayHandleMove(std::move(buffer));
|
||||
// buffer is now invalid
|
||||
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"ArrayHandle has wrong number of entries.");
|
||||
|
||||
std::cout << "Check array with moved std::vector memory." << std::endl;
|
||||
array_handle_testing::CheckArray(arrayHandle);
|
||||
|
||||
std::cout << "Check out execution array behavior." << std::endl;
|
||||
{ //as input
|
||||
vtkm::cont::Token token;
|
||||
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapterTag>::PortalConst
|
||||
executionPortal;
|
||||
executionPortal = arrayHandle.PrepareForInput(DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//use a worklet to verify the input transfer worked properly
|
||||
vtkm::cont::ArrayHandle<T> result;
|
||||
DispatcherPassThrough().Invoke(arrayHandle, WrapPortal(executionPortal), result);
|
||||
array_handle_testing::CheckArray(result);
|
||||
}
|
||||
|
||||
std::cout << "Check out inplace." << std::endl;
|
||||
{ //as inplace
|
||||
vtkm::cont::Token token;
|
||||
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapterTag>::Portal
|
||||
executionPortal;
|
||||
executionPortal = arrayHandle.PrepareForInPlace(DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//use a worklet to verify the inplace transfer worked properly
|
||||
vtkm::cont::ArrayHandle<T> result;
|
||||
DispatcherPassThrough().Invoke(arrayHandle, WrapPortal(executionPortal), result);
|
||||
array_handle_testing::CheckArray(result);
|
||||
}
|
||||
|
||||
std::cout << "Check out output." << std::endl;
|
||||
{ //as output with same length as user provided. This should work
|
||||
//as no new memory needs to be allocated
|
||||
vtkm::cont::Token token;
|
||||
arrayHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//we can't verify output contents as those aren't fetched, we
|
||||
//can just make sure the allocation didn't throw an exception
|
||||
}
|
||||
|
||||
{ //as a vector moved to the ArrayHandle, reallocation should be possible
|
||||
vtkm::cont::Token token;
|
||||
arrayHandle.PrepareForOutput(ARRAY_SIZE * 2, DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//we can't verify output contents as those aren't fetched, we
|
||||
//can just make sure the allocation didn't throw an exception
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE * 2);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct VerifyInitializerList
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_CONT void operator()(T) const
|
||||
{
|
||||
std::cout << "Creating array with initializer list memory." << std::endl;
|
||||
vtkm::cont::ArrayHandle<T> arrayHandle =
|
||||
vtkm::cont::make_ArrayHandle({ TestValue(0, T()), TestValue(1, T()), TestValue(2, T()) });
|
||||
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == 3,
|
||||
"ArrayHandle has wrong number of entries.");
|
||||
|
||||
std::cout << "Check array with initializer list memory." << std::endl;
|
||||
array_handle_testing::CheckArray(arrayHandle);
|
||||
|
||||
std::cout << "Check out execution array behavior." << std::endl;
|
||||
{ //as input
|
||||
vtkm::cont::Token token;
|
||||
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapterTag>::PortalConst
|
||||
executionPortal;
|
||||
executionPortal = arrayHandle.PrepareForInput(DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//use a worklet to verify the input transfer worked properly
|
||||
vtkm::cont::ArrayHandle<T> result;
|
||||
DispatcherPassThrough().Invoke(arrayHandle, WrapPortal(executionPortal), result);
|
||||
array_handle_testing::CheckArray(result);
|
||||
}
|
||||
|
||||
std::cout << "Check out inplace." << std::endl;
|
||||
{ //as inplace
|
||||
vtkm::cont::Token token;
|
||||
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapterTag>::Portal
|
||||
executionPortal;
|
||||
executionPortal = arrayHandle.PrepareForInPlace(DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//use a worklet to verify the inplace transfer worked properly
|
||||
vtkm::cont::ArrayHandle<T> result;
|
||||
DispatcherPassThrough().Invoke(arrayHandle, WrapPortal(executionPortal), result);
|
||||
array_handle_testing::CheckArray(result);
|
||||
}
|
||||
|
||||
std::cout << "Check out output." << std::endl;
|
||||
{ //as output with same length as user provided. This should work
|
||||
//as no new memory needs to be allocated
|
||||
vtkm::cont::Token token;
|
||||
arrayHandle.PrepareForOutput(3, DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//we can't verify output contents as those aren't fetched, we
|
||||
//can just make sure the allocation didn't throw an exception
|
||||
}
|
||||
|
||||
{ //as a vector moved to the ArrayHandle, reallocation should be possible
|
||||
vtkm::cont::Token token;
|
||||
arrayHandle.PrepareForOutput(ARRAY_SIZE * 2, DeviceAdapterTag(), token);
|
||||
token.DetachFromAll();
|
||||
|
||||
//we can't verify output contents as those aren't fetched, we
|
||||
//can just make sure the allocation didn't throw an exception
|
||||
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == ARRAY_SIZE * 2);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct VerifyVTKMAllocatedHandle
|
||||
{
|
||||
template <typename T>
|
||||
@ -497,11 +635,13 @@ private:
|
||||
{
|
||||
void operator()() const
|
||||
{
|
||||
vtkm::testing::Testing::TryTypes(VerifyEmptyArrays());
|
||||
vtkm::testing::Testing::TryTypes(VerifyUserOwnedMemory());
|
||||
vtkm::testing::Testing::TryTypes(VerifyUserTransferredMemory());
|
||||
vtkm::testing::Testing::TryTypes(VerifyVTKMAllocatedHandle());
|
||||
vtkm::testing::Testing::TryTypes(VerifyEqualityOperators());
|
||||
vtkm::testing::Testing::TryTypes(VerifyEmptyArrays{});
|
||||
vtkm::testing::Testing::TryTypes(VerifyUserOwnedMemory{});
|
||||
vtkm::testing::Testing::TryTypes(VerifyUserTransferredMemory{});
|
||||
vtkm::testing::Testing::TryTypes(VerifyVectorMovedMemory{});
|
||||
vtkm::testing::Testing::TryTypes(VerifyInitializerList{});
|
||||
vtkm::testing::Testing::TryTypes(VerifyVTKMAllocatedHandle{});
|
||||
vtkm::testing::Testing::TryTypes(VerifyEqualityOperators{});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -170,7 +170,8 @@ public:
|
||||
pointsVec.push_back(point);
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> points = vtkm::cont::make_ArrayHandle(pointsVec);
|
||||
vtkm::cont::ArrayHandle<PointType> points =
|
||||
vtkm::cont::make_ArrayHandle(pointsVec, vtkm::CopyFlag::Off);
|
||||
|
||||
// Initialize locator
|
||||
vtkm::cont::CellLocatorRectilinearGrid locator;
|
||||
|
@ -76,10 +76,6 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
|
||||
vtkm::Vec<vtkm::FloatDefault, DIMENSIONS>(0.0f),
|
||||
vtkm::Vec<vtkm::FloatDefault, DIMENSIONS>(1.0f));
|
||||
|
||||
// copy points
|
||||
vtkm::cont::ArrayHandle<PointType> points;
|
||||
vtkm::cont::ArrayCopy(uniformDs.GetCoordinateSystem().GetData(), points);
|
||||
|
||||
auto uniformCs =
|
||||
uniformDs.GetCellSet().template Cast<vtkm::cont::CellSetStructured<DIMENSIONS>>();
|
||||
|
||||
@ -99,15 +95,21 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
|
||||
|
||||
// Warp the coordinates
|
||||
std::uniform_real_distribution<vtkm::FloatDefault> warpFactor(-0.10f, 0.10f);
|
||||
auto pointsPortal = points.WritePortal();
|
||||
for (vtkm::Id i = 0; i < pointsPortal.GetNumberOfValues(); ++i)
|
||||
auto inPointsPortal = uniformDs.GetCoordinateSystem()
|
||||
.GetData()
|
||||
.template Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>()
|
||||
.ReadPortal();
|
||||
vtkm::cont::ArrayHandle<PointType> points;
|
||||
points.Allocate(inPointsPortal.GetNumberOfValues());
|
||||
auto outPointsPortal = points.WritePortal();
|
||||
for (vtkm::Id i = 0; i < outPointsPortal.GetNumberOfValues(); ++i)
|
||||
{
|
||||
PointType warpVec(0);
|
||||
for (vtkm::IdComponent c = 0; c < DIMENSIONS; ++c)
|
||||
{
|
||||
warpVec[c] = warpFactor(RandomGenerator);
|
||||
}
|
||||
pointsPortal.Set(i, pointsPortal.Get(i) + warpVec);
|
||||
outPointsPortal.Set(i, inPointsPortal.Get(i) + warpVec);
|
||||
}
|
||||
|
||||
// build dataset
|
||||
@ -152,7 +154,8 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates> dispatcher(
|
||||
ParametricToWorldCoordinates::MakeScatter(cellIds));
|
||||
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
|
||||
dispatcher.Invoke(
|
||||
ds.GetCellSet(), ds.GetCoordinateSystem().GetDataAsMultiplexer(), pcoords, wcoords);
|
||||
}
|
||||
|
||||
class FindCellWorklet : public vtkm::worklet::WorkletMapField
|
||||
|
@ -145,7 +145,8 @@ public:
|
||||
pointsVec.push_back(vtkm::make_Vec(0, 4, 4));
|
||||
pointsVec.push_back(vtkm::make_Vec(4, 0, 4));
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> points = vtkm::cont::make_ArrayHandle(pointsVec);
|
||||
vtkm::cont::ArrayHandle<PointType> points =
|
||||
vtkm::cont::make_ArrayHandle(pointsVec, vtkm::CopyFlag::Off);
|
||||
// Query the points using the locators.
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellIds;
|
||||
vtkm::cont::ArrayHandle<PointType> parametric;
|
||||
|
@ -177,9 +177,7 @@ public:
|
||||
vtkm::cont::ColorTable table(range, rgb1, rgb2, rgbspace);
|
||||
VTKM_TEST_ASSERT(table.GetClamping() == true, "clamping not setup properly");
|
||||
|
||||
constexpr vtkm::Id nvals = 4;
|
||||
constexpr int data[nvals] = { -1, 0, 1, 2 };
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ -1, 0, 1, 2 });
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> colors;
|
||||
const bool ran = table.Map(field, colors);
|
||||
@ -202,9 +200,7 @@ public:
|
||||
table.SetClampingOff();
|
||||
VTKM_TEST_ASSERT(table.GetClamping() == false, "clamping not setup properly");
|
||||
|
||||
constexpr vtkm::Id nvals = 4;
|
||||
constexpr int data[nvals] = { -2, -1, 2, 3 };
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ -2, -1, 2, 3 });
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> colors;
|
||||
const bool ran = table.Map(field, colors);
|
||||
@ -249,9 +245,7 @@ public:
|
||||
"rescaled has incorrect number of control points");
|
||||
|
||||
//Verify that the rescaled color table generates correct colors
|
||||
constexpr vtkm::Id nvals = 6;
|
||||
constexpr int data[nvals] = { 0, 10, 20, 30, 40, 50 };
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ 0, 10, 20, 30, 40, 50 });
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> colors;
|
||||
const bool ran = newTable.Map(field, colors);
|
||||
@ -284,11 +278,8 @@ public:
|
||||
VTKM_TEST_ASSERT(table.GetNumberOfPoints() == 4,
|
||||
"adding points caused number of control points to be wrong");
|
||||
|
||||
constexpr vtkm::Id nvals = 3;
|
||||
constexpr float data[nvals] = { 10.0f, -5.0f, -15.0f };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> colors;
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ 10.0f, -5.0f, -15.0f });
|
||||
const bool ran = table.Map(field, colors);
|
||||
VTKM_TEST_ASSERT(ran, "color table failed to execute");
|
||||
|
||||
@ -322,11 +313,8 @@ public:
|
||||
VTKM_TEST_ASSERT(opacityData[3] == 0.0, "rescale modified mid/sharp of opacity");
|
||||
|
||||
|
||||
constexpr vtkm::Id nvals = 6;
|
||||
constexpr int data[nvals] = { 0, 10, 20, 30, 40, 50 };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> colors;
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ 0, 10, 20, 30, 40, 50 });
|
||||
const bool ran = table.Map(field, colors);
|
||||
VTKM_TEST_ASSERT(ran, "color table failed to execute");
|
||||
|
||||
@ -366,11 +354,8 @@ public:
|
||||
"removing points didn't update range");
|
||||
table.RescaleToRange(vtkm::Range{ 0.0, 50.0 });
|
||||
|
||||
constexpr vtkm::Id nvals = 6;
|
||||
constexpr float data[nvals] = { 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> colors;
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f });
|
||||
const bool ran = table.Map(field, colors);
|
||||
VTKM_TEST_ASSERT(ran, "color table failed to execute");
|
||||
|
||||
@ -424,11 +409,8 @@ public:
|
||||
"removing points didn't update range");
|
||||
table.RescaleToRange(vtkm::Range{ 0.0, 50.0 });
|
||||
|
||||
constexpr vtkm::Id nvals = 6;
|
||||
constexpr float data[nvals] = { 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> colors;
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f });
|
||||
const bool ran = table.Map(field, colors);
|
||||
VTKM_TEST_ASSERT(ran, "color table failed to execute");
|
||||
|
||||
@ -454,9 +436,7 @@ public:
|
||||
VTKM_TEST_ASSERT((table.GetNumberOfPoints() == 21),
|
||||
"loading linear green table failed with number of control points");
|
||||
|
||||
constexpr vtkm::Id nvals = 3;
|
||||
constexpr double data[3] = { 0.0, 0.5, 1.0 };
|
||||
auto samples = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto samples = vtkm::cont::make_ArrayHandle({ 0.0, 0.5, 1.0 });
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> colors;
|
||||
{
|
||||
@ -503,11 +483,8 @@ public:
|
||||
table.Sample(256, samples);
|
||||
VTKM_TEST_ASSERT((samples.Samples.GetNumberOfValues() == 260), "invalid sample length");
|
||||
|
||||
constexpr vtkm::Id nvals = 8;
|
||||
constexpr int data[nvals] = { -1, 0, 10, 20, 30, 40, 50, 60 };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> colors;
|
||||
auto field = vtkm::cont::make_ArrayHandle(data, nvals);
|
||||
auto field = vtkm::cont::make_ArrayHandle({ -1, 0, 10, 20, 30, 40, 50, 60 });
|
||||
const bool ran = table.Map(field, samples, colors);
|
||||
VTKM_TEST_ASSERT(ran, "color table failed to execute");
|
||||
|
||||
|
@ -51,8 +51,8 @@ private:
|
||||
std::random_device rng;
|
||||
std::mt19937 urng(rng());
|
||||
std::shuffle(data, data + nvals, urng);
|
||||
auto field =
|
||||
vtkm::cont::make_Field("TestField", vtkm::cont::Field::Association::POINTS, data, nvals);
|
||||
auto field = vtkm::cont::make_Field(
|
||||
"TestField", vtkm::cont::Field::Association::POINTS, data, nvals, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::Range result;
|
||||
field.GetRange(&result);
|
||||
@ -78,8 +78,8 @@ private:
|
||||
fieldData[j][i] = data[j];
|
||||
}
|
||||
}
|
||||
auto field =
|
||||
vtkm::cont::make_Field("TestField", vtkm::cont::Field::Association::POINTS, fieldData, nvals);
|
||||
auto field = vtkm::cont::make_Field(
|
||||
"TestField", vtkm::cont::Field::Association::POINTS, fieldData, nvals, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::Range result[NumberOfComponents];
|
||||
field.GetRange(result, CustomTypeList());
|
||||
|
@ -971,7 +971,7 @@ private:
|
||||
testData[i] = static_cast<vtkm::Id>(OFFSET + (i % 50));
|
||||
}
|
||||
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(&(*testData.begin()), ARRAY_SIZE);
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
|
||||
//make a deep copy of input and place it into temp
|
||||
IdArrayHandle temp;
|
||||
@ -1017,7 +1017,7 @@ private:
|
||||
randomData[5] = 955; // 3 (lower), 4 (upper)
|
||||
|
||||
//change the control structure under the handle
|
||||
input = vtkm::cont::make_ArrayHandle(randomData, RANDOMDATA_SIZE);
|
||||
input = vtkm::cont::make_ArrayHandle(randomData, RANDOMDATA_SIZE, vtkm::CopyFlag::Off);
|
||||
|
||||
FloatCastHandle tempCast(temp);
|
||||
Algorithm::Copy(input, tempCast);
|
||||
@ -1064,7 +1064,7 @@ private:
|
||||
testData[i] = static_cast<vtkm::Id>(OFFSET + ((ARRAY_SIZE - i) % 50));
|
||||
}
|
||||
|
||||
IdArrayHandle unsorted = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle unsorted = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
IdArrayHandle sorted;
|
||||
Algorithm::Copy(unsorted, sorted);
|
||||
|
||||
@ -1095,7 +1095,7 @@ private:
|
||||
}
|
||||
|
||||
//sort the users memory in-place
|
||||
IdArrayHandle sorted = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle sorted = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
Algorithm::Sort(sorted);
|
||||
|
||||
//copy the sorted array into our own memory, if use the same user ptr
|
||||
@ -1136,7 +1136,7 @@ private:
|
||||
testData[i] = static_cast<vtkm::Id>(OFFSET + ((ARRAY_SIZE - i) % 50));
|
||||
}
|
||||
|
||||
IdArrayHandle unsorted = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle unsorted = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
IdArrayHandle sorted;
|
||||
Algorithm::Copy(unsorted, sorted);
|
||||
|
||||
@ -1202,8 +1202,8 @@ private:
|
||||
testValues[index] = TestValue(i, Vec3());
|
||||
}
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(testKeys);
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues);
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(testKeys, vtkm::CopyFlag::Off);
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues, vtkm::CopyFlag::Off);
|
||||
|
||||
Algorithm::SortByKey(keys, values);
|
||||
|
||||
@ -1261,7 +1261,7 @@ private:
|
||||
{
|
||||
testData[i] = static_cast<vtkm::Id>(OFFSET + (i % 50));
|
||||
}
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
|
||||
//make a deep copy of input and place it into temp
|
||||
IdArrayHandle temp;
|
||||
@ -1297,7 +1297,7 @@ private:
|
||||
{
|
||||
testData[i] = static_cast<vtkm::Id>(OFFSET + (i % 50));
|
||||
}
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
|
||||
//make a deep copy of input and place it into temp
|
||||
IdArrayHandle temp;
|
||||
@ -1408,7 +1408,7 @@ private:
|
||||
}
|
||||
testData[ARRAY_SIZE / 2] = maxValue;
|
||||
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
vtkm::Id2 range = Algorithm::Reduce(input, vtkm::Id2(0, 0), vtkm::MinAndMax<vtkm::Id>());
|
||||
|
||||
VTKM_TEST_ASSERT(maxValue == range[1], "Got bad value from Reduce with comparison object");
|
||||
@ -1430,27 +1430,24 @@ private:
|
||||
std::cout << " Reduce bool array with vtkm::LogicalAnd to see if all values are true."
|
||||
<< std::endl;
|
||||
//construct an array of bools and verify that they aren't all true
|
||||
constexpr vtkm::Id inputLength = 60;
|
||||
constexpr bool inputValues[inputLength] = {
|
||||
true, true, true, true, true, true, false, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true
|
||||
};
|
||||
auto barray = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
auto barray =
|
||||
vtkm::cont::make_ArrayHandle({ true, true, true, true, true, true, false, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true });
|
||||
bool all_true = Algorithm::Reduce(barray, true, vtkm::LogicalAnd());
|
||||
VTKM_TEST_ASSERT(all_true == false, "reduction with vtkm::LogicalAnd should return false");
|
||||
|
||||
std::cout << " Reduce with custom value type and custom comparison operator." << std::endl;
|
||||
//test with a custom value type with the reduction value being a vtkm::Vec<float,2>
|
||||
constexpr CustomTForReduce inputFValues[inputLength] = {
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 413.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f,
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f,
|
||||
13.1f, -2.1f, -11.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f,
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -211.1f, -1.0f,
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 113.1f, -2.1f, -1.0f
|
||||
};
|
||||
auto farray = vtkm::cont::make_ArrayHandle(inputFValues, inputLength);
|
||||
auto farray = vtkm::cont::make_ArrayHandle<CustomTForReduce>(
|
||||
{ 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 413.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f,
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f,
|
||||
13.1f, -2.1f, -11.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f,
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -211.1f, -1.0f,
|
||||
13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 13.1f, -2.1f, -1.0f, 113.1f, -2.1f, -1.0f });
|
||||
vtkm::Vec2f_32 frange =
|
||||
Algorithm::Reduce(farray, vtkm::Vec2f_32(0.0f, 0.0f), CustomMinAndMax<CustomTForReduce>());
|
||||
VTKM_TEST_ASSERT(-211.1f == frange[0],
|
||||
@ -1494,20 +1491,15 @@ private:
|
||||
{
|
||||
//lastly test with heterogeneous zip values ( vec3, and constant array handle),
|
||||
//and a custom reduce binary functor
|
||||
const vtkm::Id indexLength = 30;
|
||||
const vtkm::Id valuesLength = 10;
|
||||
using ValueType = vtkm::Float32;
|
||||
|
||||
vtkm::Id indexs[indexLength] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4,
|
||||
5, 5, 5, 1, 4, 9, 7, 7, 7, 8, 8, 8, 0, 1, 2 };
|
||||
ValueType values[valuesLength] = {
|
||||
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, -2.0f
|
||||
};
|
||||
const ValueType expectedSum = 125;
|
||||
IdArrayHandle indexHandle =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4,
|
||||
5, 5, 5, 1, 4, 9, 7, 7, 7, 8, 8, 8, 0, 1, 2 });
|
||||
vtkm::cont::ArrayHandle<ValueType> valueHandle = vtkm::cont::make_ArrayHandle(
|
||||
{ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, -2.0f });
|
||||
|
||||
IdArrayHandle indexHandle = vtkm::cont::make_ArrayHandle(indexs, indexLength);
|
||||
vtkm::cont::ArrayHandle<ValueType> valueHandle =
|
||||
vtkm::cont::make_ArrayHandle(values, valuesLength);
|
||||
const ValueType expectedSum = 125;
|
||||
|
||||
vtkm::cont::ArrayHandlePermutation<IdArrayHandle, vtkm::cont::ArrayHandle<ValueType>> perm;
|
||||
perm = vtkm::cont::make_ArrayHandlePermutation(indexHandle, valueHandle);
|
||||
@ -1526,15 +1518,14 @@ private:
|
||||
|
||||
//first test with very basic integer key / values
|
||||
{
|
||||
const vtkm::Id inputLength = 12;
|
||||
const vtkm::Id expectedLength = 6;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 4, 0, 2, 2, 2, 2, -1 }; // in keys
|
||||
vtkm::Id inputValues[inputLength] = { 13, -2, -1, 1, 1, 0, 3, 1, 2, 3, 4, -42 }; // in values
|
||||
vtkm::IdComponent expectedKeys[expectedLength] = { 0, 1, 4, 0, 2, -1 };
|
||||
vtkm::Id expectedValues[expectedLength] = { 10, 2, 0, 3, 10, -42 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 4, 0, 2, 2, 2, 2, -1 });
|
||||
IdArrayHandle values =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 13, -2, -1, 1, 1, 0, 3, 1, 2, 3, 4, -42 });
|
||||
|
||||
IdComponentArrayHandle keysOut;
|
||||
IdArrayHandle valuesOut;
|
||||
@ -1560,22 +1551,19 @@ private:
|
||||
//next test with a single key across the entire set, using vec3 as the
|
||||
//value, using a custom reduce binary functor
|
||||
{
|
||||
const vtkm::Id inputLength = 3;
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 0, 0 });
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_64, StorageTag> values =
|
||||
vtkm::cont::make_ArrayHandle({ vtkm::Vec3f_64(13.1, 13.3, 13.5),
|
||||
vtkm::Vec3f_64(-2.1, -2.3, -2.5),
|
||||
vtkm::Vec3f_64(-1.0, -1.0, 1.0) });
|
||||
|
||||
const vtkm::Id expectedLength = 1;
|
||||
vtkm::Id inputKeys[inputLength] = { 0, 0, 0 }; // input keys
|
||||
vtkm::Vec3f_64 inputValues[inputLength];
|
||||
inputValues[0] = vtkm::make_Vec(13.1, 13.3, 13.5);
|
||||
inputValues[1] = vtkm::make_Vec(-2.1, -2.3, -2.5);
|
||||
inputValues[2] = vtkm::make_Vec(-1.0, -1.0, 1.0); // input keys
|
||||
|
||||
vtkm::Id expectedKeys[expectedLength] = { 0 };
|
||||
|
||||
vtkm::Vec3f_64 expectedValues[expectedLength];
|
||||
expectedValues[0] = vtkm::make_Vec(27.51, 30.59, -33.75);
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_64, StorageTag> values =
|
||||
vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
IdArrayHandle keysOut;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_64, StorageTag> valuesOut;
|
||||
Algorithm::ReduceByKey(keys, values, keysOut, valuesOut, vtkm::Multiply());
|
||||
@ -1603,17 +1591,16 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Reduce By Key with Fancy Arrays" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 12;
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 4, 0, 2, 2, 2, 2, -1 });
|
||||
IdArrayHandle values =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 13, -2, -1, 1, 1, 0, 3, 1, 2, 3, 4, -42 });
|
||||
FloatCastHandle castValues(values);
|
||||
|
||||
const vtkm::Id expectedLength = 6;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 4, 0, 2, 2, 2, 2, -1 }; // in keys
|
||||
vtkm::Id inputValues[inputLength] = { 13, -2, -1, 1, 1, 0, 3, 1, 2, 3, 4, -42 }; // in values
|
||||
vtkm::IdComponent expectedKeys[expectedLength] = { 0, 1, 4, 0, 2, -1 };
|
||||
vtkm::Id expectedValues[expectedLength] = { 10, 2, 0, 3, 10, -42 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
FloatCastHandle castValues(values);
|
||||
|
||||
IdComponentArrayHandle keysOut;
|
||||
IdArrayHandle valuesOut;
|
||||
FloatCastHandle castValuesOut(valuesOut);
|
||||
@ -1640,21 +1627,14 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Inclusive By Key with 1 elements" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 1;
|
||||
vtkm::Id inputKeys[inputLength] = { 0 };
|
||||
vtkm::Id inputValues[inputLength] = { 5 };
|
||||
|
||||
const vtkm::Id expectedLength = 1;
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 5 });
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanInclusiveByKey(keys, values, valuesOut, vtkm::Add());
|
||||
|
||||
VTKM_TEST_ASSERT(valuesOut.GetNumberOfValues() == expectedLength,
|
||||
"Got wrong number of output values");
|
||||
VTKM_TEST_ASSERT(valuesOut.GetNumberOfValues() == 1, "Got wrong number of output values");
|
||||
const vtkm::Id v = valuesOut.ReadPortal().Get(0);
|
||||
VTKM_TEST_ASSERT(5 == v, "Incorrect scanned value");
|
||||
}
|
||||
@ -1664,16 +1644,12 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Exclusive By Key with 2 elements" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 2;
|
||||
vtkm::Id inputKeys[inputLength] = { 0, 1 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1 };
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 1 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1 });
|
||||
|
||||
const vtkm::Id expectedLength = 2;
|
||||
vtkm::Id expectedValues[expectedLength] = { 1, 1 };
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanInclusiveByKey(keys, values, valuesOut, vtkm::Add());
|
||||
@ -1692,8 +1668,7 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Inclusive By Key with " << ARRAY_SIZE << " elements" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = ARRAY_SIZE;
|
||||
std::vector<vtkm::Id> inputKeys(inputLength);
|
||||
std::vector<vtkm::Id> inputKeys(ARRAY_SIZE);
|
||||
|
||||
for (vtkm::Id i = 0; i < ARRAY_SIZE; i++)
|
||||
{
|
||||
@ -1702,10 +1677,9 @@ private:
|
||||
else
|
||||
inputKeys[static_cast<std::size_t>(i)] = static_cast<vtkm::Id>(i);
|
||||
}
|
||||
std::vector<vtkm::Id> inputValues(inputLength, 1);
|
||||
std::vector<vtkm::Id> inputValues(ARRAY_SIZE, 1);
|
||||
|
||||
const vtkm::Id expectedLength = ARRAY_SIZE;
|
||||
std::vector<vtkm::Id> expectedValues(expectedLength);
|
||||
std::vector<vtkm::Id> expectedValues(ARRAY_SIZE);
|
||||
for (std::size_t i = 0; i < ARRAY_SIZE; i++)
|
||||
{
|
||||
if (i % 100 < 98)
|
||||
@ -1714,17 +1688,17 @@ private:
|
||||
expectedValues[i] = static_cast<vtkm::Id>(1);
|
||||
}
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues);
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, vtkm::CopyFlag::Off);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, vtkm::CopyFlag::Off);
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanInclusiveByKey(keys, values, valuesOut, vtkm::Add());
|
||||
|
||||
VTKM_TEST_ASSERT(valuesOut.GetNumberOfValues() == expectedLength,
|
||||
VTKM_TEST_ASSERT(valuesOut.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"Got wrong number of output values");
|
||||
auto values_portal = valuesOut.ReadPortal();
|
||||
for (auto i = 0; i < expectedLength; i++)
|
||||
for (auto i = 0; i < ARRAY_SIZE; i++)
|
||||
{
|
||||
const vtkm::Id v = values_portal.Get(i);
|
||||
VTKM_TEST_ASSERT(expectedValues[static_cast<std::size_t>(i)] == v, "Incorrect scanned value");
|
||||
@ -1735,16 +1709,13 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Inclusive By Key" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 10;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
|
||||
|
||||
const vtkm::Id expectedLength = 10;
|
||||
vtkm::Id expectedValues[expectedLength] = { 1, 2, 3, 1, 2, 1, 1, 2, 3, 4 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanInclusiveByKey(keys, values, valuesOut);
|
||||
@ -1763,16 +1734,13 @@ private:
|
||||
std::cout << "Testing Scan Inclusive By Key In Place" << std::endl;
|
||||
|
||||
|
||||
const vtkm::Id inputLength = 10;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
|
||||
|
||||
const vtkm::Id expectedLength = 10;
|
||||
vtkm::Id expectedValues[expectedLength] = { 1, 2, 3, 1, 2, 1, 1, 2, 3, 4 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
Algorithm::ScanInclusiveByKey(keys, values, values);
|
||||
VTKM_TEST_ASSERT(values.GetNumberOfValues() == expectedLength,
|
||||
"Got wrong number of output values");
|
||||
@ -1789,17 +1757,14 @@ private:
|
||||
std::cout << "Testing Scan Inclusive By Key In Place with a Fancy Array" << std::endl;
|
||||
|
||||
|
||||
const vtkm::Id inputLength = 10;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
|
||||
FloatCastHandle castValues(values);
|
||||
|
||||
const vtkm::Id expectedLength = 10;
|
||||
vtkm::Id expectedValues[expectedLength] = { 1, 2, 3, 1, 2, 1, 1, 2, 3, 4 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
FloatCastHandle castValues(values);
|
||||
|
||||
Algorithm::ScanInclusiveByKey(keys, castValues, castValues);
|
||||
VTKM_TEST_ASSERT(values.GetNumberOfValues() == expectedLength,
|
||||
"Got wrong number of output values");
|
||||
@ -1816,15 +1781,12 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Exclusive By Key with 1 elements" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 1;
|
||||
vtkm::Id inputKeys[inputLength] = { 0 };
|
||||
vtkm::Id inputValues[inputLength] = { 0 };
|
||||
vtkm::Id init = 5;
|
||||
|
||||
const vtkm::Id expectedLength = 1;
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0 });
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
@ -1841,17 +1803,14 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Exclusive By Key with 2 elements" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 2;
|
||||
vtkm::Id inputKeys[inputLength] = { 0, 1 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1 };
|
||||
vtkm::Id init = 5;
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 1 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1 });
|
||||
|
||||
const vtkm::Id expectedLength = 2;
|
||||
vtkm::Id expectedValues[expectedLength] = { 5, 5 };
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanExclusiveByKey(keys, values, valuesOut, init, vtkm::Add());
|
||||
@ -1871,8 +1830,7 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Exclusive By Key with " << ARRAY_SIZE << " elements" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = ARRAY_SIZE;
|
||||
std::vector<vtkm::Id> inputKeys(inputLength);
|
||||
std::vector<vtkm::Id> inputKeys(ARRAY_SIZE);
|
||||
for (std::size_t i = 0; i < ARRAY_SIZE; i++)
|
||||
{
|
||||
if (i % 100 < 98)
|
||||
@ -1880,11 +1838,10 @@ private:
|
||||
else
|
||||
inputKeys[i] = static_cast<vtkm::Id>(i);
|
||||
}
|
||||
std::vector<vtkm::Id> inputValues(inputLength, 1);
|
||||
std::vector<vtkm::Id> inputValues(ARRAY_SIZE, 1);
|
||||
vtkm::Id init = 5;
|
||||
|
||||
const vtkm::Id expectedLength = ARRAY_SIZE;
|
||||
std::vector<vtkm::Id> expectedValues(expectedLength);
|
||||
std::vector<vtkm::Id> expectedValues(ARRAY_SIZE);
|
||||
for (vtkm::Id i = 0; i < ARRAY_SIZE; i++)
|
||||
{
|
||||
if (i % 100 < 98)
|
||||
@ -1893,17 +1850,17 @@ private:
|
||||
expectedValues[static_cast<std::size_t>(i)] = init;
|
||||
}
|
||||
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues);
|
||||
IdArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, vtkm::CopyFlag::Off);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, vtkm::CopyFlag::Off);
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanExclusiveByKey(keys, values, valuesOut, init, vtkm::Add());
|
||||
|
||||
VTKM_TEST_ASSERT(valuesOut.GetNumberOfValues() == expectedLength,
|
||||
VTKM_TEST_ASSERT(valuesOut.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"Got wrong number of output values");
|
||||
auto valuesPortal = valuesOut.ReadPortal();
|
||||
for (vtkm::Id i = 0; i < expectedLength; i++)
|
||||
for (vtkm::Id i = 0; i < ARRAY_SIZE; i++)
|
||||
{
|
||||
const vtkm::Id v = valuesPortal.Get(i);
|
||||
VTKM_TEST_ASSERT(expectedValues[static_cast<std::size_t>(i)] == v, "Incorrect scanned value");
|
||||
@ -1915,17 +1872,15 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing Scan Exclusive By Key" << std::endl;
|
||||
|
||||
const vtkm::Id inputLength = 10;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
vtkm::Id init = 5;
|
||||
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
|
||||
|
||||
const vtkm::Id expectedLength = 10;
|
||||
vtkm::Id expectedValues[expectedLength] = { 5, 6, 7, 5, 6, 5, 5, 6, 7, 8 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
IdArrayHandle valuesOut;
|
||||
|
||||
Algorithm::ScanExclusiveByKey(keys, values, valuesOut, init, vtkm::Add());
|
||||
@ -1945,17 +1900,15 @@ private:
|
||||
std::cout << "Testing Scan Inclusive By Key In Place" << std::endl;
|
||||
|
||||
|
||||
const vtkm::Id inputLength = 10;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
vtkm::Id init = 5;
|
||||
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
|
||||
|
||||
const vtkm::Id expectedLength = 10;
|
||||
vtkm::Id expectedValues[expectedLength] = { 5, 6, 7, 5, 6, 5, 5, 6, 7, 8 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
|
||||
Algorithm::ScanExclusiveByKey(keys, values, values, init, vtkm::Add());
|
||||
VTKM_TEST_ASSERT(values.GetNumberOfValues() == expectedLength,
|
||||
"Got wrong number of output values");
|
||||
@ -1972,18 +1925,16 @@ private:
|
||||
std::cout << "Testing Scan Inclusive By Key In Place with a Fancy Array" << std::endl;
|
||||
|
||||
|
||||
const vtkm::Id inputLength = 10;
|
||||
vtkm::IdComponent inputKeys[inputLength] = { 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 };
|
||||
vtkm::Id inputValues[inputLength] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
vtkm::FloatDefault init = 5;
|
||||
|
||||
IdComponentArrayHandle keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::IdComponent>({ 0, 0, 0, 1, 1, 2, 3, 3, 3, 3 });
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
|
||||
FloatCastHandle castValues(values);
|
||||
|
||||
const vtkm::Id expectedLength = 10;
|
||||
vtkm::Id expectedValues[expectedLength] = { 5, 6, 7, 5, 6, 5, 5, 6, 7, 8 };
|
||||
|
||||
IdComponentArrayHandle keys = vtkm::cont::make_ArrayHandle(inputKeys, inputLength);
|
||||
IdArrayHandle values = vtkm::cont::make_ArrayHandle(inputValues, inputLength);
|
||||
FloatCastHandle castValues(values);
|
||||
|
||||
Algorithm::ScanExclusiveByKey(keys, castValues, castValues, init, vtkm::Add());
|
||||
VTKM_TEST_ASSERT(values.GetNumberOfValues() == expectedLength,
|
||||
"Got wrong number of output values");
|
||||
@ -2049,7 +2000,7 @@ private:
|
||||
inputValues[mid] = 0.0;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> array =
|
||||
vtkm::cont::make_ArrayHandle(&inputValues[0], ARRAY_SIZE);
|
||||
vtkm::cont::make_ArrayHandle(inputValues, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::Float64 product = Algorithm::ScanInclusive(array, array, vtkm::Multiply());
|
||||
|
||||
@ -2082,7 +2033,7 @@ private:
|
||||
{
|
||||
testValues[i] = TestValue(1, Vec3());
|
||||
}
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues);
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues, vtkm::CopyFlag::Off);
|
||||
|
||||
Vec3 sum = Algorithm::ScanInclusive(values, values);
|
||||
std::cout << "Sum that was returned " << sum << std::endl;
|
||||
@ -2194,7 +2145,8 @@ private:
|
||||
std::size_t mid = ARRAY_SIZE / 2;
|
||||
inputValues[mid] = 0.0;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> array = vtkm::cont::make_ArrayHandle(inputValues);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> array =
|
||||
vtkm::cont::make_ArrayHandle(inputValues, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::Float64 initialValue = 2.00;
|
||||
vtkm::Float64 product =
|
||||
@ -2231,7 +2183,7 @@ private:
|
||||
{
|
||||
testValues[i] = TestValue(1, Vec3());
|
||||
}
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues);
|
||||
Vec3ArrayHandle values = vtkm::cont::make_ArrayHandle(testValues, vtkm::CopyFlag::Off);
|
||||
|
||||
Vec3 sum = Algorithm::ScanExclusive(values, values);
|
||||
std::cout << "Sum that was returned " << sum << std::endl;
|
||||
@ -2470,7 +2422,7 @@ private:
|
||||
testData[i] = TestCopy<T>::get(index);
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<T> input = vtkm::cont::make_ArrayHandle(&testData[0], COPY_ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandle<T> input = vtkm::cont::make_ArrayHandle(testData, vtkm::CopyFlag::Off);
|
||||
|
||||
//make a deep copy of input and place it into temp
|
||||
{
|
||||
@ -2680,7 +2632,7 @@ private:
|
||||
testData[i] = static_cast<vtkm::Id>(OFFSET + (i % 50));
|
||||
}
|
||||
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle(testData);
|
||||
IdArrayHandle input = vtkm::cont::make_ArrayHandle<vtkm::Id>(testData, vtkm::CopyFlag::Off);
|
||||
|
||||
//make a deep copy of input and place it into temp
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> temp;
|
||||
@ -2710,10 +2662,8 @@ private:
|
||||
// a single atomic value.
|
||||
std::cout << "Testing Atomic Add with vtkm::Int32" << std::endl;
|
||||
{
|
||||
std::vector<vtkm::Int32> singleElement;
|
||||
singleElement.push_back(0);
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Int32>({ 0 });
|
||||
|
||||
vtkm::cont::AtomicArray<vtkm::Int32> atomic(atomicElement);
|
||||
{
|
||||
@ -2727,10 +2677,8 @@ private:
|
||||
|
||||
std::cout << "Testing Atomic Add with vtkm::Int64" << std::endl;
|
||||
{
|
||||
std::vector<vtkm::Int64> singleElement;
|
||||
singleElement.push_back(0);
|
||||
vtkm::cont::ArrayHandle<vtkm::Int64> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Int64>({ 0 });
|
||||
|
||||
vtkm::cont::AtomicArray<vtkm::Int64> atomic(atomicElement);
|
||||
{
|
||||
@ -2744,10 +2692,8 @@ private:
|
||||
|
||||
std::cout << "Testing Atomic CAS with vtkm::Int32" << std::endl;
|
||||
{
|
||||
std::vector<vtkm::Int32> singleElement;
|
||||
singleElement.push_back(0);
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Int32>({ 0 });
|
||||
|
||||
vtkm::cont::AtomicArray<vtkm::Int32> atomic(atomicElement);
|
||||
{
|
||||
@ -2761,10 +2707,8 @@ private:
|
||||
|
||||
std::cout << "Testing Atomic CAS with vtkm::Int64" << std::endl;
|
||||
{
|
||||
std::vector<vtkm::Int64> singleElement;
|
||||
singleElement.push_back(0);
|
||||
vtkm::cont::ArrayHandle<vtkm::Int64> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Int64>({ 0 });
|
||||
|
||||
vtkm::cont::AtomicArray<vtkm::Int64> atomic(atomicElement);
|
||||
{
|
||||
|
@ -359,12 +359,6 @@ private:
|
||||
vector2.push_back(value[2]);
|
||||
}
|
||||
|
||||
{
|
||||
vtkm::cont::ArrayHandleSOA<Vec3> soaArray = { vector0, vector1, vector2 };
|
||||
VTKM_TEST_ASSERT(soaArray.GetNumberOfValues() == ARRAY_SIZE);
|
||||
CheckPortal(soaArray.ReadPortal());
|
||||
}
|
||||
|
||||
{
|
||||
vtkm::cont::ArrayHandleSOA<Vec3> soaArray =
|
||||
vtkm::cont::make_ArrayHandleSOA<Vec3>({ vector0, vector1, vector2 });
|
||||
@ -374,21 +368,21 @@ private:
|
||||
|
||||
{
|
||||
vtkm::cont::ArrayHandleSOA<Vec3> soaArray =
|
||||
vtkm::cont::make_ArrayHandleSOA(vector0, vector1, vector2);
|
||||
vtkm::cont::make_ArrayHandleSOA(vtkm::CopyFlag::Off, vector0, vector1, vector2);
|
||||
VTKM_TEST_ASSERT(soaArray.GetNumberOfValues() == ARRAY_SIZE);
|
||||
CheckPortal(soaArray.ReadPortal());
|
||||
}
|
||||
|
||||
{
|
||||
vtkm::cont::ArrayHandleSOA<Vec3> soaArray = vtkm::cont::make_ArrayHandleSOA<Vec3>(
|
||||
{ &vector0.front(), &vector1.front(), &vector2.front() }, ARRAY_SIZE);
|
||||
{ vector0.data(), vector1.data(), vector2.data() }, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
VTKM_TEST_ASSERT(soaArray.GetNumberOfValues() == ARRAY_SIZE);
|
||||
CheckPortal(soaArray.ReadPortal());
|
||||
}
|
||||
|
||||
{
|
||||
vtkm::cont::ArrayHandleSOA<Vec3> soaArray = vtkm::cont::make_ArrayHandleSOA(
|
||||
ARRAY_SIZE, &vector0.front(), &vector1.front(), &vector2.front());
|
||||
ARRAY_SIZE, vtkm::CopyFlag::Off, vector0.data(), vector1.data(), vector2.data());
|
||||
VTKM_TEST_ASSERT(soaArray.GetNumberOfValues() == ARRAY_SIZE);
|
||||
CheckPortal(soaArray.ReadPortal());
|
||||
}
|
||||
@ -436,7 +430,7 @@ private:
|
||||
const ValueType value = TestValue(13, ValueType());
|
||||
std::vector<ValueType> compositeData(ARRAY_SIZE, value);
|
||||
vtkm::cont::ArrayHandle<ValueType> compositeInput =
|
||||
vtkm::cont::make_ArrayHandle(compositeData);
|
||||
vtkm::cont::make_ArrayHandle(compositeData, vtkm::CopyFlag::Off);
|
||||
|
||||
auto composite =
|
||||
vtkm::cont::make_ArrayHandleCompositeVector(compositeInput, compositeInput, compositeInput);
|
||||
@ -597,7 +591,7 @@ private:
|
||||
basicVec.push_back(ValueType(static_cast<ComponentType>(i)));
|
||||
basicVec.push_back(ValueType(ComponentType(i)));
|
||||
}
|
||||
BasicArrayType basic = vtkm::cont::make_ArrayHandle(basicVec);
|
||||
BasicArrayType basic = vtkm::cont::make_ArrayHandle(basicVec, vtkm::CopyFlag::Off);
|
||||
|
||||
// concatenate two arrays together
|
||||
ConcatenateType concatenate = vtkm::cont::make_ArrayHandleConcatenate(implicit, basic);
|
||||
@ -986,14 +980,9 @@ private:
|
||||
{
|
||||
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
||||
|
||||
ComponentType testValues[ARRAY_SIZE * NUM_COMPONENTS];
|
||||
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE * NUM_COMPONENTS; ++index)
|
||||
{
|
||||
testValues[index] = TestValue(index, ComponentType());
|
||||
}
|
||||
vtkm::cont::ArrayHandle<ComponentType> baseArray =
|
||||
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE * NUM_COMPONENTS);
|
||||
vtkm::cont::ArrayHandle<ComponentType> baseArray;
|
||||
baseArray.Allocate(ARRAY_SIZE * NUM_COMPONENTS);
|
||||
SetPortal(baseArray.WritePortal());
|
||||
|
||||
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS>
|
||||
groupArray(baseArray);
|
||||
@ -1210,9 +1199,10 @@ private:
|
||||
testKeys[i] = KeyType(static_cast<KeyComponentType>(ARRAY_SIZE - i));
|
||||
testValues[i] = ValueType(static_cast<ValueComponentType>(i));
|
||||
}
|
||||
vtkm::cont::ArrayHandle<KeyType> keys = vtkm::cont::make_ArrayHandle(testKeys, ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandle<KeyType> keys =
|
||||
vtkm::cont::make_ArrayHandle(testKeys, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
vtkm::cont::ArrayHandle<ValueType> values =
|
||||
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE);
|
||||
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::cont::ArrayHandleZip<vtkm::cont::ArrayHandle<KeyType>,
|
||||
vtkm::cont::ArrayHandle<ValueType>>
|
||||
@ -1425,7 +1415,7 @@ private:
|
||||
ValueType(static_cast<ValueComponentType>(i)));
|
||||
}
|
||||
vtkm::cont::ArrayHandle<PairType> input =
|
||||
vtkm::cont::make_ArrayHandle(testKeysAndValues, ARRAY_SIZE);
|
||||
vtkm::cont::make_ArrayHandle(testKeysAndValues, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::cont::ArrayHandle<KeyType> result_keys;
|
||||
vtkm::cont::ArrayHandle<ValueType> result_values;
|
||||
|
@ -69,7 +69,7 @@ void EvaluateOnCoordinates(vtkm::cont::CoordinateSystem points,
|
||||
EvaluateImplicitFunction eval(function.PrepareForExecution(device, token));
|
||||
EvalDispatcher dispatcher(eval);
|
||||
dispatcher.SetDevice(DeviceAdapter());
|
||||
dispatcher.Invoke(points, values, gradients);
|
||||
dispatcher.Invoke(points.GetDataAsMultiplexer(), values, gradients);
|
||||
}
|
||||
|
||||
template <typename ItemType, std::size_t N>
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
coordi.push_back(vtkm::make_Vec(00.0f, 10.0f, 10.0f));
|
||||
coordi.push_back(vtkm::make_Vec(10.0f, 00.0f, 10.0f));
|
||||
coordi.push_back(vtkm::make_Vec(10.0f, 10.0f, 10.0f));
|
||||
auto coordi_Handle = vtkm::cont::make_ArrayHandle(coordi);
|
||||
auto coordi_Handle = vtkm::cont::make_ArrayHandle(coordi, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::cont::CoordinateSystem coord("points", coordi_Handle);
|
||||
|
||||
@ -145,7 +145,7 @@ public:
|
||||
qcVec.push_back(vtkm::make_Vec(0.01f, 9.99f, 9.99f));
|
||||
qcVec.push_back(vtkm::make_Vec(9.99f, 0.01f, 9.99f));
|
||||
qcVec.push_back(vtkm::make_Vec(9.99f, 9.99f, 9.99f));
|
||||
auto qc_Handle = vtkm::cont::make_ArrayHandle(qcVec);
|
||||
auto qc_Handle = vtkm::cont::make_ArrayHandle(qcVec, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> nnId_Handle;
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> nnDis_Handle;
|
||||
@ -163,8 +163,7 @@ public:
|
||||
vtkm::worklet::DispatcherMapField<NearestNeighborSearchBruteForce3DWorklet> nnsbf3DDispatcher(
|
||||
nnsbf3dWorklet);
|
||||
nnsbf3DDispatcher.SetDevice(DeviceAdapter());
|
||||
nnsbf3DDispatcher.Invoke(
|
||||
qc_Handle, vtkm::cont::make_ArrayHandle(coordi), bfnnId_Handle, bfnnDis_Handle);
|
||||
nnsbf3DDispatcher.Invoke(qc_Handle, coordi_Handle, bfnnId_Handle, bfnnDis_Handle);
|
||||
|
||||
///// verify search result /////
|
||||
bool passTest = true;
|
||||
|
@ -53,8 +53,7 @@ void TryCopy()
|
||||
}
|
||||
|
||||
{ // ArrayHandle ids
|
||||
const std::vector<vtkm::Id> idsVec{ 3, 8, 7 };
|
||||
const auto ids = vtkm::cont::make_ArrayHandle(idsVec);
|
||||
const auto ids = vtkm::cont::make_ArrayHandle<vtkm::Id>({ 3, 8, 7 });
|
||||
{ // Return vector:
|
||||
const std::vector<ValueType> output = vtkm::cont::ArrayGetValues(ids, data);
|
||||
TestValues<ValueType>(output, { 3, 8, 7 });
|
||||
|
@ -83,9 +83,9 @@ void RunTest()
|
||||
createArr(Y, nY);
|
||||
createArr(Z, nZ);
|
||||
|
||||
ArrayHandleCPBasic(vtkm::cont::make_ArrayHandle(X),
|
||||
vtkm::cont::make_ArrayHandle(Y),
|
||||
vtkm::cont::make_ArrayHandle(Z));
|
||||
ArrayHandleCPBasic(vtkm::cont::make_ArrayHandle(X, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(Y, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(Z, vtkm::CopyFlag::Off));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,16 +52,7 @@ vtkm::cont::ArrayHandle<ValueType, StorageTag> MakeInputArray(int arrayId)
|
||||
}
|
||||
|
||||
// Make an array handle that points to this buffer.
|
||||
using ArrayHandleType = vtkm::cont::ArrayHandle<ValueType, StorageTag>;
|
||||
ArrayHandleType bufferHandle = vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE);
|
||||
|
||||
// When this function returns, the array is going to go out of scope, which
|
||||
// will invalidate the array handle we just created. So copy to a new buffer
|
||||
// that will stick around after we return.
|
||||
ArrayHandleType copyHandle;
|
||||
vtkm::cont::ArrayCopy(bufferHandle, copyHandle);
|
||||
|
||||
return copyHandle;
|
||||
return vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, vtkm::CopyFlag::On);
|
||||
}
|
||||
|
||||
template <typename ValueType, typename C>
|
||||
|
@ -54,7 +54,7 @@ void TestConcatenateEmptyArray()
|
||||
using ArrayConcat = vtkm::cont::ArrayHandleConcatenate<CoeffArrayTypeTmp, CoeffArrayTypeTmp>;
|
||||
using ArrayConcat2 = vtkm::cont::ArrayHandleConcatenate<ArrayConcat, CoeffArrayTypeTmp>;
|
||||
|
||||
CoeffArrayTypeTmp arr1 = vtkm::cont::make_ArrayHandle(vec);
|
||||
CoeffArrayTypeTmp arr1 = vtkm::cont::make_ArrayHandle(vec, vtkm::CopyFlag::Off);
|
||||
CoeffArrayTypeTmp arr2, arr3;
|
||||
|
||||
ArrayConcat arrConc(arr2, arr1);
|
||||
|
@ -60,8 +60,8 @@ struct Test
|
||||
}
|
||||
|
||||
// Prepare array handles:
|
||||
Handle keys = vtkm::cont::make_ArrayHandle(keyData, ARRAY_SIZE);
|
||||
Handle values = vtkm::cont::make_ArrayHandle(valueData, ARRAY_SIZE);
|
||||
Handle keys = vtkm::cont::make_ArrayHandle(keyData, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
Handle values = vtkm::cont::make_ArrayHandle(valueData, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
DiscardHandle output_keys;
|
||||
Handle output_values;
|
||||
|
||||
|
@ -96,7 +96,7 @@ int TestArrayHandleExtrude()
|
||||
const int numPlanes = 8;
|
||||
|
||||
auto coords = vtkm::cont::make_ArrayHandleExtrudeCoords(
|
||||
vtkm::cont::make_ArrayHandle(points_rz), numPlanes, false);
|
||||
vtkm::cont::make_ArrayHandle(points_rz, vtkm::CopyFlag::Off), numPlanes, false);
|
||||
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfValues() ==
|
||||
static_cast<vtkm::Id>(((points_rz.size() / 2) * numPlanes)),
|
||||
|
@ -196,14 +196,7 @@ struct PermutationTests
|
||||
}
|
||||
|
||||
// Create an ArrayHandle from the buffer
|
||||
ValueArrayType array = vtkm::cont::make_ArrayHandle(buffer);
|
||||
|
||||
// Copy the array so that the data is not destroyed when we return from
|
||||
// this method.
|
||||
ValueArrayType arrayCopy;
|
||||
Algorithm::Copy(array, arrayCopy);
|
||||
|
||||
return arrayCopy;
|
||||
return vtkm::cont::make_ArrayHandle(buffer, vtkm::CopyFlag::On);
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
|
@ -15,26 +15,35 @@ void TestArrayHandleRandomUniformBits()
|
||||
{
|
||||
auto actual0 = vtkm::cont::ArrayHandleRandomUniformBits(10, { 0 });
|
||||
// result from Random123 sample implementation of philox2x32x10
|
||||
std::vector<vtkm::UInt64> expected0{ 0x6cd10df2ff1dae59, 0x5f3adb6bdcdce855, 0x3fbb6394049f6998,
|
||||
0xbd592d1202a74512, 0x8a115b62c08084ef, 0x1411803b3bb7eefa,
|
||||
0x7d138a2280027d0e, 0x318a7703a1da82c5, 0xdcd79c6998975579,
|
||||
0x6cb1a07c91f81109 };
|
||||
auto expected0 = vtkm::cont::make_ArrayHandle<vtkm::UInt64>({ 0x6cd10df2ff1dae59,
|
||||
0x5f3adb6bdcdce855,
|
||||
0x3fbb6394049f6998,
|
||||
0xbd592d1202a74512,
|
||||
0x8a115b62c08084ef,
|
||||
0x1411803b3bb7eefa,
|
||||
0x7d138a2280027d0e,
|
||||
0x318a7703a1da82c5,
|
||||
0xdcd79c6998975579,
|
||||
0x6cb1a07c91f81109 });
|
||||
|
||||
|
||||
auto result =
|
||||
vtkm::cont::testing::test_equal_ArrayHandles(actual0, vtkm::cont::make_ArrayHandle(expected0));
|
||||
auto result = vtkm::cont::testing::test_equal_ArrayHandles(actual0, expected0);
|
||||
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
|
||||
|
||||
// initialize with seed = 100, could be "iteration number" in actual use case.
|
||||
auto actual100 = vtkm::cont::ArrayHandleRandomUniformBits(10, { 100 });
|
||||
// result from Random123 sample implementation of philox2x32x10
|
||||
std::vector<vtkm::UInt64> expected100{
|
||||
0xbd35360836122ea3, 0xe033b74acce7aa5f, 0xc0fbb65cba93ecd7, 0xe3fee2812b77e480,
|
||||
0x92e5c7d563767971, 0xd99e952fb054fc19, 0xb8f2adc12094ad29, 0xb7dcb35fea8c27ac,
|
||||
0x9c7b779e88270c45, 0x7325b123dc32e01d,
|
||||
};
|
||||
auto result100 = vtkm::cont::testing::test_equal_ArrayHandles(
|
||||
actual100, vtkm::cont::make_ArrayHandle(expected100));
|
||||
auto expected100 = vtkm::cont::make_ArrayHandle<vtkm::UInt64>({ 0xbd35360836122ea3,
|
||||
0xe033b74acce7aa5f,
|
||||
0xc0fbb65cba93ecd7,
|
||||
0xe3fee2812b77e480,
|
||||
0x92e5c7d563767971,
|
||||
0xd99e952fb054fc19,
|
||||
0xb8f2adc12094ad29,
|
||||
0xb7dcb35fea8c27ac,
|
||||
0x9c7b779e88270c45,
|
||||
0x7325b123dc32e01d });
|
||||
auto result100 = vtkm::cont::testing::test_equal_ArrayHandles(actual100, expected100);
|
||||
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ void TestArrayHandleReverseRead()
|
||||
void TestArrayHandleReverseWrite()
|
||||
{
|
||||
std::vector<vtkm::Id> ids(ARRAY_SIZE, 0);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> handle = vtkm::cont::make_ArrayHandle(ids);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> handle = vtkm::cont::make_ArrayHandle(ids, vtkm::CopyFlag::Off);
|
||||
|
||||
vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<vtkm::Id>> reverse =
|
||||
vtkm::cont::make_ArrayHandleReverse(handle);
|
||||
@ -63,10 +63,10 @@ void TestArrayHandleReverseWrite()
|
||||
|
||||
void TestArrayHandleReverseScanInclusiveByKey()
|
||||
{
|
||||
vtkm::Id ids[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
vtkm::Id seg[] = { 0, 0, 0, 0, 1, 1, 2, 3, 3, 4 };
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> values = vtkm::cont::make_ArrayHandle(ids, 10);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> keys = vtkm::cont::make_ArrayHandle(seg, 10);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> values =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> keys =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 0, 0, 0, 1, 1, 2, 3, 3, 4 });
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> output;
|
||||
vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<vtkm::Id>> reversed =
|
||||
@ -75,9 +75,9 @@ void TestArrayHandleReverseScanInclusiveByKey()
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>;
|
||||
Algorithm::ScanInclusiveByKey(keys, values, reversed);
|
||||
|
||||
vtkm::Id expected[] = { 0, 1, 3, 6, 4, 9, 6, 7, 15, 9 };
|
||||
vtkm::cont::ArrayHandleReverse<vtkm::cont::ArrayHandle<vtkm::Id>> expected_reversed =
|
||||
vtkm::cont::make_ArrayHandleReverse(vtkm::cont::make_ArrayHandle(expected, 10));
|
||||
vtkm::cont::make_ArrayHandleReverse(
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 0, 1, 3, 6, 4, 9, 6, 7, 15, 9 }));
|
||||
auto outputPortal = output.ReadPortal();
|
||||
auto reversePortal = expected_reversed.ReadPortal();
|
||||
for (int i = 0; i < 10; i++)
|
||||
|
@ -156,7 +156,8 @@ struct TemplatedTests
|
||||
T* end = begin + ARRAY_SIZE;
|
||||
const T* cbegin = begin;
|
||||
const T* cend = end;
|
||||
vtkm::cont::ArrayHandle<T> arrayHandle = vtkm::cont::make_ArrayHandle(begin, ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandle<T> arrayHandle =
|
||||
vtkm::cont::make_ArrayHandle(begin, ARRAY_SIZE, vtkm::CopyFlag::Off);
|
||||
|
||||
std::cout
|
||||
<< " Testing ArrayPortalToIterators(ArrayPortalFromIterators) gets back simple iterator."
|
||||
|
@ -61,7 +61,7 @@ vtkm::cont::DataSet MakeTestDataSetRectilinear()
|
||||
vtkm::cont::DataSet MakeTestDataSetCurvilinear()
|
||||
{
|
||||
auto recti = MakeTestDataSetRectilinear();
|
||||
auto coords = recti.GetCoordinateSystem().GetData();
|
||||
auto coords = recti.GetCoordinateSystem().GetDataAsMultiplexer();
|
||||
|
||||
vtkm::cont::ArrayHandle<PointType> sheared;
|
||||
sheared.Allocate(coords.GetNumberOfValues());
|
||||
@ -140,7 +140,8 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates> dispatcher(
|
||||
ParametricToWorldCoordinates::MakeScatter(cellIds));
|
||||
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
|
||||
dispatcher.Invoke(
|
||||
ds.GetCellSet(), ds.GetCoordinateSystem().GetDataAsMultiplexer(), pcoords, wcoords);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -45,10 +45,11 @@ vtkm::Id ArrayLength(const T (&)[Length])
|
||||
vtkm::cont::CellSetExplicit<> MakeTestCellSet1()
|
||||
{
|
||||
vtkm::cont::CellSetExplicit<> cs;
|
||||
cs.Fill(numberOfPoints,
|
||||
vtkm::cont::make_ArrayHandle(g_shapes, ArrayLength(g_shapes)),
|
||||
vtkm::cont::make_ArrayHandle(g_connectivity, ArrayLength(g_connectivity)),
|
||||
vtkm::cont::make_ArrayHandle(g_offsets, ArrayLength(g_offsets)));
|
||||
cs.Fill(
|
||||
numberOfPoints,
|
||||
vtkm::cont::make_ArrayHandle(g_shapes, ArrayLength(g_shapes), vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(g_connectivity, ArrayLength(g_connectivity), vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(g_offsets, ArrayLength(g_offsets), vtkm::CopyFlag::Off));
|
||||
return cs;
|
||||
}
|
||||
|
||||
@ -57,9 +58,10 @@ vtkm::cont::CellSetExplicit<> MakeTestCellSet2()
|
||||
{
|
||||
vtkm::cont::CellSetExplicit<> cs;
|
||||
cs.Fill(numberOfPoints,
|
||||
vtkm::cont::make_ArrayHandle(g_shapes2, ArrayLength(g_shapes2)),
|
||||
vtkm::cont::make_ArrayHandle(g_connectivity2, ArrayLength(g_connectivity2)),
|
||||
vtkm::cont::make_ArrayHandle(g_offsets2, ArrayLength(g_offsets2)));
|
||||
vtkm::cont::make_ArrayHandle(g_shapes2, ArrayLength(g_shapes2), vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(
|
||||
g_connectivity2, ArrayLength(g_connectivity2), vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(g_offsets2, ArrayLength(g_offsets2), vtkm::CopyFlag::Off));
|
||||
return cs;
|
||||
}
|
||||
|
||||
|
@ -129,14 +129,14 @@ int TestCellSetExtrude()
|
||||
|
||||
// verify that a constant value point field can be accessed
|
||||
std::vector<float> pvalues(static_cast<size_t>(coords.GetNumberOfValues()), 42.0f);
|
||||
vtkm::cont::Field pfield(
|
||||
"pfield", vtkm::cont::Field::Association::POINTS, vtkm::cont::make_ArrayHandle(pvalues));
|
||||
vtkm::cont::Field pfield = vtkm::cont::make_Field(
|
||||
"pfield", vtkm::cont::Field::Association::POINTS, pvalues, vtkm::CopyFlag::Off);
|
||||
dataset.AddField(pfield);
|
||||
|
||||
// verify that a constant cell value can be accessed
|
||||
std::vector<float> cvalues(static_cast<size_t>(cells.GetNumberOfCells()), 42.0f);
|
||||
vtkm::cont::Field cfield =
|
||||
vtkm::cont::make_FieldCell("cfield", vtkm::cont::make_ArrayHandle(cvalues));
|
||||
vtkm::cont::Field cfield = vtkm::cont::make_Field(
|
||||
"cfield", vtkm::cont::Field::Association::CELL_SET, cvalues, vtkm::CopyFlag::Off);
|
||||
dataset.AddField(cfield);
|
||||
|
||||
vtkm::filter::PointAverage avg;
|
||||
|
@ -83,9 +83,7 @@ std::vector<T> createVec(std::size_t n, const T* data)
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> createAH(std::size_t n, const T* data)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> arr;
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(data, static_cast<vtkm::Id>(n)), arr);
|
||||
return arr;
|
||||
return vtkm::cont::make_ArrayHandle(data, static_cast<vtkm::Id>(n), vtkm::CopyFlag::On);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -105,6 +103,9 @@ vtkm::cont::DataSet CreateDataSetArr(bool useSeparatedCoords,
|
||||
{
|
||||
std::vector<T> xvals(numPoints), yvals(numPoints), zvals(numPoints);
|
||||
std::vector<T> varP(numPoints), varC(numCells);
|
||||
std::vector<vtkm::UInt8> shapevals(numCells);
|
||||
std::vector<vtkm::IdComponent> indicesvals(numCells);
|
||||
std::vector<vtkm::Id> connvals(numConn);
|
||||
for (std::size_t i = 0; i < numPoints; i++, f++)
|
||||
{
|
||||
xvals[i] = coords[i * 3 + 0];
|
||||
@ -116,15 +117,17 @@ vtkm::cont::DataSet CreateDataSetArr(bool useSeparatedCoords,
|
||||
for (std::size_t i = 0; i < numCells; i++, f++)
|
||||
{
|
||||
varC[i] = static_cast<T>(f * 1.1f);
|
||||
shapevals[i] = shape[i];
|
||||
indicesvals[i] = indices[i];
|
||||
}
|
||||
vtkm::cont::ArrayHandle<T> X, Y, Z, P, C;
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), X);
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Y);
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Z);
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(varP), P);
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(varC), C);
|
||||
dataSet = dsb.Create(
|
||||
X, Y, Z, createAH(numCells, shape), createAH(numCells, indices), createAH(numConn, conn));
|
||||
for (std::size_t i = 0; i < numConn; i++)
|
||||
{
|
||||
connvals[i] = conn[i];
|
||||
}
|
||||
dataSet = dsb.Create(xvals, yvals, zvals, shapevals, indicesvals, connvals);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> P = vtkm::cont::make_ArrayHandle(varP, vtkm::CopyFlag::On);
|
||||
vtkm::cont::ArrayHandle<T> C = vtkm::cont::make_ArrayHandle(varC, vtkm::CopyFlag::On);
|
||||
dataSet.AddPointField("pointvar", P);
|
||||
dataSet.AddCellField("cellvar", C);
|
||||
return dataSet;
|
||||
@ -145,8 +148,8 @@ vtkm::cont::DataSet CreateDataSetArr(bool useSeparatedCoords,
|
||||
{
|
||||
varC[i][0] = static_cast<T>(f * 1.1f);
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> pts;
|
||||
DFA::Copy(vtkm::cont::make_ArrayHandle(tmp), pts);
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> pts =
|
||||
vtkm::cont::make_ArrayHandle(tmp, vtkm::CopyFlag::On);
|
||||
dataSet = dsb.Create(
|
||||
pts, createAH(numCells, shape), createAH(numCells, indices), createAH(numConn, conn));
|
||||
dataSet.AddPointField("pointvar", varP);
|
||||
@ -229,7 +232,6 @@ vtkm::cont::DataSet CreateDataSetVec(bool useSeparatedCoords,
|
||||
|
||||
void TestDataSetBuilderExplicit()
|
||||
{
|
||||
vtkm::cont::DataSetBuilderExplicit dsb;
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::Bounds bounds;
|
||||
|
||||
|
@ -121,7 +121,6 @@ void RectilinearTests()
|
||||
const vtkm::Id NUM_FILL_METHODS = 5;
|
||||
|
||||
vtkm::cont::DataSetBuilderRectilinear dataSetBuilder;
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
std::uniform_int_distribution<vtkm::Id> randomDim(1, MAX_DIM_SIZE);
|
||||
std::uniform_int_distribution<vtkm::IdComponent> randomFill(0, NUM_FILL_METHODS - 1);
|
||||
@ -130,6 +129,8 @@ void RectilinearTests()
|
||||
{
|
||||
std::cout << "Trial " << trial << std::endl;
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
vtkm::Id3 dimensions(
|
||||
randomDim(g_RandomGenerator), randomDim(g_RandomGenerator), randomDim(g_RandomGenerator));
|
||||
std::cout << "Dimensions: " << dimensions << std::endl;
|
||||
@ -210,16 +211,17 @@ void RectilinearTests()
|
||||
|
||||
std::cout << " Create with C array" << std::endl;
|
||||
dataSet = dataSetBuilder.Create(
|
||||
dimensions[0], dimensions[1], &xCoordinates.front(), &yCoordinates.front());
|
||||
dataSet.AddPointField("pointvar", &varP2D.front(), numPoints);
|
||||
dataSet.AddCellField("cellvar", &varC2D.front(), numCells);
|
||||
dimensions[0], dimensions[1], xCoordinates.data(), yCoordinates.data());
|
||||
dataSet.AddPointField("pointvar", varP2D.data(), numPoints);
|
||||
dataSet.AddCellField("cellvar", varC2D.data(), numCells);
|
||||
ValidateDataSet(dataSet, ndims, numPoints, numCells, bounds);
|
||||
|
||||
std::cout << " Create with ArrayHandle" << std::endl;
|
||||
dataSet = dataSetBuilder.Create(vtkm::cont::make_ArrayHandle(xCoordinates),
|
||||
vtkm::cont::make_ArrayHandle(yCoordinates));
|
||||
dataSet.AddPointField("pointvar", vtkm::cont::make_ArrayHandle(varP2D));
|
||||
dataSet.AddCellField("cellvar", vtkm::cont::make_ArrayHandle(varC2D));
|
||||
dataSet =
|
||||
dataSetBuilder.Create(vtkm::cont::make_ArrayHandle(xCoordinates, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(yCoordinates, vtkm::CopyFlag::Off));
|
||||
dataSet.AddPointField("pointvar", vtkm::cont::make_ArrayHandle(varP2D, vtkm::CopyFlag::Off));
|
||||
dataSet.AddCellField("cellvar", vtkm::cont::make_ArrayHandle(varC2D, vtkm::CopyFlag::Off));
|
||||
ValidateDataSet(dataSet, ndims, numPoints, numCells, bounds);
|
||||
}
|
||||
|
||||
@ -256,19 +258,20 @@ void RectilinearTests()
|
||||
dataSet = dataSetBuilder.Create(dimensions[0],
|
||||
dimensions[1],
|
||||
dimensions[2],
|
||||
&xCoordinates.front(),
|
||||
&yCoordinates.front(),
|
||||
&zCoordinates.front());
|
||||
dataSet.AddPointField("pointvar", vtkm::cont::make_ArrayHandle(varP3D));
|
||||
dataSet.AddCellField("cellvar", vtkm::cont::make_ArrayHandle(varC3D));
|
||||
xCoordinates.data(),
|
||||
yCoordinates.data(),
|
||||
zCoordinates.data());
|
||||
dataSet.AddPointField("pointvar", vtkm::cont::make_ArrayHandle(varP3D, vtkm::CopyFlag::Off));
|
||||
dataSet.AddCellField("cellvar", vtkm::cont::make_ArrayHandle(varC3D, vtkm::CopyFlag::Off));
|
||||
ValidateDataSet(dataSet, ndims, numPoints, numCells, bounds);
|
||||
|
||||
std::cout << " Create with ArrayHandle" << std::endl;
|
||||
dataSet = dataSetBuilder.Create(vtkm::cont::make_ArrayHandle(xCoordinates),
|
||||
vtkm::cont::make_ArrayHandle(yCoordinates),
|
||||
vtkm::cont::make_ArrayHandle(zCoordinates));
|
||||
dataSet.AddPointField("pointvar", vtkm::cont::make_ArrayHandle(varP3D));
|
||||
dataSet.AddCellField("cellvar", vtkm::cont::make_ArrayHandle(varC3D));
|
||||
dataSet =
|
||||
dataSetBuilder.Create(vtkm::cont::make_ArrayHandle(xCoordinates, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(yCoordinates, vtkm::CopyFlag::Off),
|
||||
vtkm::cont::make_ArrayHandle(zCoordinates, vtkm::CopyFlag::Off));
|
||||
dataSet.AddPointField("pointvar", vtkm::cont::make_ArrayHandle(varP3D, vtkm::CopyFlag::Off));
|
||||
dataSet.AddCellField("cellvar", vtkm::cont::make_ArrayHandle(varC3D, vtkm::CopyFlag::Off));
|
||||
ValidateDataSet(dataSet, ndims, numPoints, numCells, bounds);
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +86,9 @@ void TestDataSet_Explicit()
|
||||
|
||||
vtkm::cont::DataSet dataSet = make_SingleTypeDataSet();
|
||||
|
||||
std::vector<vtkm::Id> validIds;
|
||||
validIds.push_back(1); //iterate the 2nd cell 4 times
|
||||
validIds.push_back(1);
|
||||
validIds.push_back(1);
|
||||
validIds.push_back(1);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds = vtkm::cont::make_ArrayHandle(validIds);
|
||||
//iterate the 2nd cell 4 times
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1 });
|
||||
|
||||
//get the cellset single type from the dataset
|
||||
vtkm::cont::CellSetSingleType<> cellSet;
|
||||
@ -125,12 +122,9 @@ void TestDataSet_Structured2D()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make2DUniformDataSet0();
|
||||
|
||||
std::vector<vtkm::Id> validIds;
|
||||
validIds.push_back(1); //iterate the 2nd cell 4 times
|
||||
validIds.push_back(1);
|
||||
validIds.push_back(1);
|
||||
validIds.push_back(1);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds = vtkm::cont::make_ArrayHandle(validIds);
|
||||
//iterate the 2nd cell 4 times
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1 });
|
||||
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
@ -161,12 +155,9 @@ void TestDataSet_Structured3D()
|
||||
vtkm::cont::testing::MakeTestDataSet testDataSet;
|
||||
vtkm::cont::DataSet dataSet = testDataSet.Make3DUniformDataSet0();
|
||||
|
||||
std::vector<vtkm::Id> validIds;
|
||||
validIds.push_back(1); //iterate the 2nd cell 4 times
|
||||
validIds.push_back(1);
|
||||
validIds.push_back(1);
|
||||
validIds.push_back(1);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds = vtkm::cont::make_ArrayHandle(validIds);
|
||||
//iterate the 2nd cell 4 times
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> validCellIds =
|
||||
vtkm::cont::make_ArrayHandle<vtkm::Id>({ 1, 1, 1, 1 });
|
||||
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
@ -141,7 +141,9 @@ void TestContDataTypesHaveMoveSemantics()
|
||||
is_noexcept_movable<vtkm::cont::DataSet>();
|
||||
is_noexcept_movable<vtkm::cont::Field>();
|
||||
is_noexcept_movable<vtkm::cont::CoordinateSystem>();
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
is_noexcept_movable<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
VTKM_DEPRECATED_SUPPRESS_END
|
||||
|
||||
//verify the CellSetStructured, and CellSetExplicit
|
||||
//have efficient storage in containers such as std::vector
|
||||
|
@ -19,25 +19,25 @@ void TestParticleArrayCopy()
|
||||
vtkm::FloatDefault x0(-1), x1(1);
|
||||
std::uniform_real_distribution<vtkm::FloatDefault> dist(x0, x1);
|
||||
|
||||
std::vector<vtkm::Particle> particles;
|
||||
std::vector<vtkm::Massless> particles;
|
||||
vtkm::Id N = 17;
|
||||
for (vtkm::Id i = 0; i < N; i++)
|
||||
{
|
||||
auto x = dist(generator);
|
||||
auto y = dist(generator);
|
||||
auto z = dist(generator);
|
||||
particles.push_back(vtkm::Particle(vtkm::Vec3f(x, y, z), i));
|
||||
particles.push_back(vtkm::Massless(vtkm::Vec3f(x, y, z), i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
auto particleAH = vtkm::cont::make_ArrayHandle(particles);
|
||||
auto particleAH = vtkm::cont::make_ArrayHandle(particles, vtkm::CopyFlag::Off);
|
||||
|
||||
//Test copy position only
|
||||
if (i == 0)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> pos;
|
||||
vtkm::cont::ParticleArrayCopy(particleAH, pos);
|
||||
vtkm::cont::ParticleArrayCopy<vtkm::Massless>(particleAH, pos);
|
||||
|
||||
auto pPortal = particleAH.ReadPortal();
|
||||
for (vtkm::Id j = 0; j < N; j++)
|
||||
@ -54,7 +54,7 @@ void TestParticleArrayCopy()
|
||||
vtkm::cont::ArrayHandle<vtkm::ParticleStatus> status;
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> ptime;
|
||||
|
||||
vtkm::cont::ParticleArrayCopy(particleAH, pos, ids, steps, status, ptime);
|
||||
vtkm::cont::ParticleArrayCopy<vtkm::Massless>(particleAH, pos, ids, steps, status, ptime);
|
||||
|
||||
auto pPortal = particleAH.ReadPortal();
|
||||
for (vtkm::Id j = 0; j < N; j++)
|
||||
|
@ -132,30 +132,6 @@ struct TestArrayHandleCast
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleCompositeVector
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
auto array = vtkm::cont::make_ArrayHandleCompositeVector(RandomArrayHandle<T>::Make(ArraySize),
|
||||
RandomArrayHandle<T>::Make(ArraySize));
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleConcatenate
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
auto array = vtkm::cont::make_ArrayHandleConcatenate(RandomArrayHandle<T>::Make(ArraySize),
|
||||
RandomArrayHandle<T>::Make(ArraySize));
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleConstant
|
||||
{
|
||||
template <typename T>
|
||||
@ -181,19 +157,6 @@ struct TestArrayHandleCounting
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleExtractComponent
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
auto numComps = vtkm::VecTraits<T>::NUM_COMPONENTS;
|
||||
auto array = vtkm::cont::make_ArrayHandleExtractComponent(
|
||||
RandomArrayHandle<T>::Make(ArraySize), RandomValue<vtkm::IdComponent>::Make(0, numComps - 1));
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleGroupVec
|
||||
{
|
||||
template <typename T>
|
||||
@ -243,8 +206,8 @@ struct TestArrayHandleGroupVecVariable
|
||||
return offset;
|
||||
});
|
||||
|
||||
auto array = vtkm::cont::make_ArrayHandleGroupVecVariable(RandomArrayHandle<T>::Make(size),
|
||||
vtkm::cont::make_ArrayHandle(comps));
|
||||
auto array = vtkm::cont::make_ArrayHandleGroupVecVariable(
|
||||
RandomArrayHandle<T>::Make(size), vtkm::cont::make_ArrayHandle(comps, vtkm::CopyFlag::On));
|
||||
RunTest(array);
|
||||
|
||||
// cannot make a VariantArrayHandle containing ArrayHandleGroupVecVariable
|
||||
@ -253,37 +216,6 @@ struct TestArrayHandleGroupVecVariable
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleImplicit
|
||||
{
|
||||
template <typename T>
|
||||
struct ImplicitFunctor
|
||||
{
|
||||
ImplicitFunctor() = default;
|
||||
|
||||
explicit ImplicitFunctor(const T& factor)
|
||||
: Factor(factor)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT T operator()(vtkm::Id index) const
|
||||
{
|
||||
return static_cast<T>(this->Factor *
|
||||
static_cast<typename vtkm::VecTraits<T>::ComponentType>(index));
|
||||
}
|
||||
|
||||
T Factor;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
ImplicitFunctor<T> functor(RandomValue<T>::Make(2, 9));
|
||||
auto array = vtkm::cont::make_ArrayHandleImplicit(functor, ArraySize);
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
};
|
||||
|
||||
void TestArrayHandleIndex()
|
||||
{
|
||||
auto size = RandomValue<vtkm::Id>::Make(2, 10);
|
||||
@ -321,86 +253,6 @@ struct TestArrayHandleReverse
|
||||
}
|
||||
};
|
||||
|
||||
struct TestArrayHandleSwizzle
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
static const vtkm::IdComponent2 map2s[6] = { { 0, 1 }, { 0, 2 }, { 1, 0 },
|
||||
{ 1, 2 }, { 2, 0 }, { 2, 1 } };
|
||||
static const vtkm::IdComponent3 map3s[6] = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 },
|
||||
{ 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } };
|
||||
|
||||
auto numOutComps = RandomValue<vtkm::IdComponent>::Make(2, 3);
|
||||
switch (numOutComps)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
auto array = make_ArrayHandleSwizzle(RandomArrayHandle<vtkm::Vec<T, 3>>::Make(ArraySize),
|
||||
map2s[RandomValue<int>::Make(0, 5)]);
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
default:
|
||||
{
|
||||
auto array = make_ArrayHandleSwizzle(RandomArrayHandle<vtkm::Vec<T, 3>>::Make(ArraySize),
|
||||
map3s[RandomValue<int>::Make(0, 5)]);
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct TestArrayHandleTransform
|
||||
{
|
||||
struct TransformFunctor
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT T operator()(const T& in) const
|
||||
{
|
||||
return static_cast<T>(in * T{ 2 });
|
||||
}
|
||||
};
|
||||
|
||||
struct InverseTransformFunctor
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT T operator()(const T& in) const
|
||||
{
|
||||
return static_cast<T>(in / T{ 2 });
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void TestType1() const
|
||||
{
|
||||
auto array = vtkm::cont::make_ArrayHandleTransform(RandomArrayHandle<T>::Make(ArraySize),
|
||||
TransformFunctor{});
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TestType2() const
|
||||
{
|
||||
auto array = vtkm::cont::make_ArrayHandleTransform(
|
||||
RandomArrayHandle<T>::Make(ArraySize), TransformFunctor{}, InverseTransformFunctor{});
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
this->TestType1<T>();
|
||||
this->TestType2<T>();
|
||||
}
|
||||
};
|
||||
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates MakeRandomArrayHandleUniformPointCoordinates()
|
||||
{
|
||||
@ -417,46 +269,6 @@ void TestArrayHandleUniformPointCoordinates()
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
|
||||
void TestArrayHandleVirtualCoordinates()
|
||||
{
|
||||
int type = RandomValue<int>::Make(0, 2);
|
||||
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates array;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
array =
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(MakeRandomArrayHandleUniformPointCoordinates());
|
||||
break;
|
||||
case 1:
|
||||
array =
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(vtkm::cont::make_ArrayHandleCartesianProduct(
|
||||
RandomArrayHandle<vtkm::FloatDefault>::Make(ArraySize),
|
||||
RandomArrayHandle<vtkm::FloatDefault>::Make(ArraySize),
|
||||
RandomArrayHandle<vtkm::FloatDefault>::Make(ArraySize)));
|
||||
break;
|
||||
default:
|
||||
array =
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(RandomArrayHandle<vtkm::Vec3f>::Make(ArraySize));
|
||||
break;
|
||||
}
|
||||
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
|
||||
struct TestArrayHandleZip
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
auto array = vtkm::cont::make_ArrayHandleZip(RandomArrayHandle<T>::Make(ArraySize),
|
||||
vtkm::cont::ArrayHandleIndex(ArraySize));
|
||||
RunTest(array);
|
||||
RunTest(MakeTestVariantArrayHandle(array));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void TestArrayHandleSerialization()
|
||||
@ -464,62 +276,81 @@ void TestArrayHandleSerialization()
|
||||
std::cout << "Testing ArrayHandleBasic\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleBasic(), TestTypesList());
|
||||
|
||||
std::cout << "Testing ArrayHandleSOA\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleSOA(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagSOA>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleSOA\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleSOA(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleCartesianProduct\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCartesianProduct(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
|
||||
vtkm::cont::StorageTagCartesianProduct<vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic>>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleCartesianProduct\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCartesianProduct(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing TestArrayHandleCast\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCast(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
|
||||
vtkm::cont::StorageTagCast<vtkm::Int8, vtkm::cont::StorageTagBasic>>::value)
|
||||
{
|
||||
std::cout << "Testing TestArrayHandleCast\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCast(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleCompositeVector\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCompositeVector(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagConstant>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleConstant\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleConstant(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleConcatenate\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleConcatenate(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagCounting>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleCounting\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCounting(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleConstant\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleConstant(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
|
||||
vtkm::cont::StorageTagGroupVec<vtkm::cont::StorageTagBasic, 3>>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleGroupVec\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVec(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleCounting\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCounting(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
|
||||
vtkm::cont::StorageTagGroupVecVariable<vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic>>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleGroupVecVariable\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVecVariable(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleExtractComponent\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleExtractComponent(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagIndex>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleIndex\n";
|
||||
TestArrayHandleIndex();
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleGroupVec\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVec(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
|
||||
vtkm::cont::StorageTagPermutation<vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic>>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandlePermutation\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandlePermutation(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleGroupVecVariable\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVecVariable(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
|
||||
vtkm::cont::StorageTagReverse<vtkm::cont::StorageTagBasic>>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleReverse\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleReverse(), TestTypesList());
|
||||
}
|
||||
|
||||
std::cout << "Testing ArrayHandleImplicit\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleImplicit(), TestTypesList());
|
||||
|
||||
std::cout << "Testing ArrayHandleIndex\n";
|
||||
TestArrayHandleIndex();
|
||||
|
||||
std::cout << "Testing ArrayHandlePermutation\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandlePermutation(), TestTypesList());
|
||||
|
||||
std::cout << "Testing ArrayHandleReverse\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleReverse(), TestTypesList());
|
||||
|
||||
std::cout << "Testing ArrayHandleSwizzle\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleSwizzle(), TestTypesList());
|
||||
|
||||
std::cout << "Testing ArrayHandleTransform\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleTransform(), TestTypesList());
|
||||
|
||||
std::cout << "Testing ArrayHandleUniformPointCoordinates\n";
|
||||
TestArrayHandleUniformPointCoordinates();
|
||||
|
||||
std::cout << "Testing ArrayHandleVirtualCoordinates\n";
|
||||
TestArrayHandleVirtualCoordinates();
|
||||
|
||||
std::cout << "Testing ArrayHandleZip\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleZip(), TestTypesList());
|
||||
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagUniformPoints>::value)
|
||||
{
|
||||
std::cout << "Testing ArrayHandleUniformPointCoordinates\n";
|
||||
TestArrayHandleUniformPointCoordinates();
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@ -540,37 +371,3 @@ int UnitTestSerializationArrayHandle(int argc, char* argv[])
|
||||
|
||||
return vtkm::cont::testing::Testing::Run(TestArrayHandleSerialization, argc, argv);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct SerializableTypeString<TestArrayHandleImplicit::ImplicitFunctor<T>>
|
||||
{
|
||||
static VTKM_CONT const std::string& Get()
|
||||
{
|
||||
static std::string name =
|
||||
"TestArrayHandleImplicit::ImplicitFunctor<" + SerializableTypeString<T>::Get() + ">";
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SerializableTypeString<TestArrayHandleTransform::TransformFunctor>
|
||||
{
|
||||
static VTKM_CONT const std::string Get() { return "TestArrayHandleTransform::TransformFunctor"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SerializableTypeString<TestArrayHandleTransform::InverseTransformFunctor>
|
||||
{
|
||||
static VTKM_CONT const std::string Get()
|
||||
{
|
||||
return "TestArrayHandleTransform::InverseTransformFunctor";
|
||||
}
|
||||
};
|
||||
}
|
||||
} // vtkm::cont
|
||||
|
@ -34,20 +34,40 @@
|
||||
#include <type_traits>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Make an "unusual" type to use in the test. This is simply a type that
|
||||
// is sure not to be declared elsewhere.
|
||||
struct UnusualType
|
||||
{
|
||||
using T = vtkm::Id;
|
||||
T X;
|
||||
UnusualType() = default;
|
||||
UnusualType(T x)
|
||||
: X(x)
|
||||
{
|
||||
}
|
||||
UnusualType& operator=(T x)
|
||||
{
|
||||
this->X = x;
|
||||
return *this;
|
||||
}
|
||||
operator T() const { return this->X; }
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
// VariantArrayHandle requires its value type to have a defined VecTraits
|
||||
// class. One of the tests is to use an "unusual" array of std::string
|
||||
// (which is pretty pointless but might tease out some assumptions).
|
||||
// class. One of the tests is to use an "unusual" array.
|
||||
// Make an implementation here. Because I am lazy, this is only a partial
|
||||
// implementation.
|
||||
template <>
|
||||
struct VecTraits<std::string>
|
||||
struct VecTraits<UnusualType> : VecTraits<UnusualType::T>
|
||||
{
|
||||
using IsSizeStatic = vtkm::VecTraitsTagSizeStatic;
|
||||
static constexpr vtkm::IdComponent NUM_COMPONENTS = 1;
|
||||
using HasMultipleComponents = vtkm::VecTraitsTagSingleComponent;
|
||||
};
|
||||
|
||||
} // namespace vtkm
|
||||
@ -57,34 +77,6 @@ namespace
|
||||
|
||||
const vtkm::Id ARRAY_SIZE = 10;
|
||||
|
||||
using TypeListString = vtkm::List<std::string>;
|
||||
|
||||
template <typename T>
|
||||
struct UnusualPortal
|
||||
{
|
||||
using ValueType = T;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return ARRAY_SIZE; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const { return TestValue(index, ValueType()); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class ArrayHandleWithUnusualStorage
|
||||
: public vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagImplicit<UnusualPortal<T>>>
|
||||
{
|
||||
using Superclass = vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagImplicit<UnusualPortal<T>>>;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleWithUnusualStorage()
|
||||
: Superclass(typename Superclass::ReadPortalType())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct TestValueFunctor
|
||||
{
|
||||
@ -93,54 +85,48 @@ struct TestValueFunctor
|
||||
|
||||
struct CheckFunctor
|
||||
{
|
||||
template <typename T, typename S>
|
||||
static void CheckArray(const vtkm::cont::ArrayHandle<T, S>& array)
|
||||
{
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size.");
|
||||
CheckPortal(array.ReadPortal());
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void CheckArray(const vtkm::cont::ArrayHandle<UnusualType, S>& array)
|
||||
{
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size.");
|
||||
auto portal = array.ReadPortal();
|
||||
for (vtkm::Id index = 0; index < array.GetNumberOfValues(); ++index)
|
||||
{
|
||||
VTKM_TEST_ASSERT(portal.Get(index) == TestValue(index, UnusualType::T{}));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator()(const vtkm::cont::ArrayHandle<T>& array,
|
||||
bool& calledBasic,
|
||||
bool& vtkmNotUsed(calledUnusual),
|
||||
bool& vtkmNotUsed(calledVirtual)) const
|
||||
{
|
||||
calledBasic = true;
|
||||
std::cout << " Checking for basic array type: " << typeid(T).name() << std::endl;
|
||||
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size.");
|
||||
|
||||
auto portal = array.ReadPortal();
|
||||
CheckPortal(portal);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator()(
|
||||
const vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagImplicit<UnusualPortal<T>>>& array,
|
||||
bool& vtkmNotUsed(calledBasic),
|
||||
bool& calledUnusual,
|
||||
bool& vtkmNotUsed(calledVirtual)) const
|
||||
{
|
||||
calledUnusual = true;
|
||||
std::cout << " Checking for unusual array type: " << typeid(T).name() << std::endl;
|
||||
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size.");
|
||||
|
||||
auto portal = array.ReadPortal();
|
||||
CheckPortal(portal);
|
||||
CheckArray(array);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator()(const vtkm::cont::ArrayHandleVirtual<T>& array,
|
||||
bool& vtkmNotUsed(calledBasic),
|
||||
bool& vtkmNotUsed(calledUnusual),
|
||||
bool& calledVirtual) const
|
||||
{
|
||||
calledVirtual = true;
|
||||
std::cout << " Checking for virtual array type: " << typeid(T).name() << std::endl;
|
||||
|
||||
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Unexpected array size.");
|
||||
|
||||
auto portal = array.ReadPortal();
|
||||
CheckPortal(portal);
|
||||
CheckArray(array);
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
void operator()(const vtkm::cont::ArrayHandle<T, S>&, bool&, bool&, bool&) const
|
||||
void operator()(const vtkm::cont::ArrayHandle<T, S>&, bool&, bool&) const
|
||||
{
|
||||
VTKM_TEST_FAIL("Array resolved to unexpected type.");
|
||||
}
|
||||
@ -161,87 +147,76 @@ void BasicArrayVariantChecks(const vtkm::cont::VariantArrayHandleBase<TypeList>&
|
||||
template <typename TypeList>
|
||||
void CheckArrayVariant(const vtkm::cont::VariantArrayHandleBase<TypeList>& array,
|
||||
vtkm::IdComponent numComponents,
|
||||
bool isBasicArray,
|
||||
bool isUnusualArray)
|
||||
bool isBasicArray)
|
||||
{
|
||||
BasicArrayVariantChecks(array, numComponents);
|
||||
|
||||
std::cout << " CastAndCall with default storage" << std::endl;
|
||||
bool calledBasic = false;
|
||||
bool calledUnusual = false;
|
||||
bool calledVirtual = false;
|
||||
CastAndCall(array, CheckFunctor(), calledBasic, calledUnusual, calledVirtual);
|
||||
CastAndCall(array, CheckFunctor(), calledBasic, calledVirtual);
|
||||
|
||||
VTKM_TEST_ASSERT(
|
||||
calledBasic || calledUnusual || calledVirtual,
|
||||
calledBasic || calledVirtual,
|
||||
"The functor was never called (and apparently a bad value exception not thrown).");
|
||||
if (isBasicArray)
|
||||
{
|
||||
VTKM_TEST_ASSERT(calledBasic, "The functor was never called with the basic array fast path");
|
||||
VTKM_TEST_ASSERT(!calledUnusual, "The functor was somehow called with the unusual fast path");
|
||||
VTKM_TEST_ASSERT(!calledVirtual, "The functor was somehow called with the virtual path");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(!calledBasic, "The array somehow got cast to a basic storage.");
|
||||
VTKM_TEST_ASSERT(!calledUnusual, "The array somehow got cast to an unusual storage.");
|
||||
}
|
||||
|
||||
std::cout << " CastAndCall with no storage" << std::endl;
|
||||
calledBasic = false;
|
||||
calledUnusual = false;
|
||||
calledVirtual = false;
|
||||
array.CastAndCall(vtkm::ListEmpty(), CheckFunctor(), calledBasic, calledUnusual, calledVirtual);
|
||||
VTKM_TEST_ASSERT(
|
||||
calledBasic || calledUnusual || calledVirtual,
|
||||
"The functor was never called (and apparently a bad value exception not thrown).");
|
||||
VTKM_TEST_ASSERT(!calledBasic, "The array somehow got cast to a basic storage.");
|
||||
VTKM_TEST_ASSERT(!calledUnusual, "The array somehow got cast to an unusual storage.");
|
||||
|
||||
// Work around apparent bug in some versions of GCC that give a warning about
|
||||
// StorageVirtualImpl<>::GetNumberOfValues() being "declared 'static' but never defined"
|
||||
// (even though nothing about this method is declared static). See the following
|
||||
// stackoverflow discussion for more details:
|
||||
//
|
||||
// https://stackoverflow.com/questions/56615695/how-to-fix-declared-static-but-never-defined-on-member-function
|
||||
#if !defined(VTKM_GCC) || (__GNUC__ >= 9)
|
||||
std::cout << " CastAndCall with extra storage" << std::endl;
|
||||
calledBasic = false;
|
||||
calledUnusual = false;
|
||||
calledVirtual = false;
|
||||
array.CastAndCall(vtkm::List<vtkm::cont::StorageTagBasic,
|
||||
ArrayHandleWithUnusualStorage<vtkm::Id>::StorageTag,
|
||||
ArrayHandleWithUnusualStorage<std::string>::StorageTag>(),
|
||||
array.CastAndCall(vtkm::List<vtkm::cont::StorageTagBasic, vtkm::cont::StorageTagConstant>{},
|
||||
CheckFunctor(),
|
||||
calledBasic,
|
||||
calledUnusual,
|
||||
calledVirtual);
|
||||
VTKM_TEST_ASSERT(
|
||||
calledBasic || calledUnusual || calledVirtual,
|
||||
calledBasic || calledVirtual,
|
||||
"The functor was never called (and apparently a bad value exception not thrown).");
|
||||
if (isBasicArray)
|
||||
{
|
||||
VTKM_TEST_ASSERT(calledBasic, "The functor was never called with the basic array fast path");
|
||||
VTKM_TEST_ASSERT(!calledUnusual, "The functor was somehow called with the unusual fast path");
|
||||
VTKM_TEST_ASSERT(!calledVirtual, "The functor was somehow called with the virtual path");
|
||||
}
|
||||
else if (isUnusualArray)
|
||||
{
|
||||
VTKM_TEST_ASSERT(calledUnusual, "The functor was never called with the unusual fast path");
|
||||
VTKM_TEST_ASSERT(!calledBasic, "The functor was somehow called with the basic fast path");
|
||||
VTKM_TEST_ASSERT(!calledVirtual, "The functor was somehow called with the virtual path");
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(!calledBasic, "The array somehow got cast to a basic storage.");
|
||||
VTKM_TEST_ASSERT(!calledUnusual, "The array somehow got cast to an unusual storage.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
vtkm::cont::VariantArrayHandle CreateArrayVariant(T)
|
||||
{
|
||||
// Declared static to prevent going out of scope.
|
||||
static T buffer[ARRAY_SIZE];
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||
{
|
||||
buffer[index] = TestValue(index, T());
|
||||
}
|
||||
vtkm::cont::ArrayHandle<T> array;
|
||||
array.Allocate(ARRAY_SIZE);
|
||||
SetPortal(array.WritePortal());
|
||||
return vtkm::cont::VariantArrayHandle(array);
|
||||
}
|
||||
|
||||
return vtkm::cont::VariantArrayHandle(vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE));
|
||||
vtkm::cont::VariantArrayHandle CreateArrayVariant(UnusualType)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<UnusualType> array;
|
||||
array.Allocate(ARRAY_SIZE);
|
||||
auto portal = array.WritePortal();
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; ++index)
|
||||
{
|
||||
portal.Set(index, TestValue(index, UnusualType::T{}));
|
||||
}
|
||||
return vtkm::cont::VariantArrayHandle(array);
|
||||
}
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
@ -250,7 +225,7 @@ void CheckCastToArrayHandle(const ArrayHandleType& array)
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
|
||||
vtkm::cont::VariantArrayHandle arrayVariant = array;
|
||||
VTKM_TEST_ASSERT(!arrayVariant.IsType<vtkm::cont::ArrayHandle<std::string>>(),
|
||||
VTKM_TEST_ASSERT(!arrayVariant.IsType<vtkm::cont::ArrayHandle<UnusualType>>(),
|
||||
"Dynamic array reporting is wrong type.");
|
||||
|
||||
ArrayHandleType castArray1;
|
||||
@ -345,7 +320,7 @@ template <typename T, typename ArrayVariantType>
|
||||
void TryNewInstance(T, ArrayVariantType originalArray)
|
||||
{
|
||||
// This check should already have been performed by caller, but just in case.
|
||||
CheckArrayVariant(originalArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
|
||||
CheckArrayVariant(originalArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
|
||||
std::cout << "Create new instance of array." << std::endl;
|
||||
ArrayVariantType newArray = originalArray.NewInstance();
|
||||
@ -361,7 +336,7 @@ void TryNewInstance(T, ArrayVariantType originalArray)
|
||||
{
|
||||
staticArray.WritePortal().Set(index, TestValue(index + 100, T()));
|
||||
}
|
||||
CheckArrayVariant(originalArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
|
||||
CheckArrayVariant(originalArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
|
||||
std::cout << "Set the new static array to expected values and make sure the new" << std::endl
|
||||
<< "dynamic array points to the same new values." << std::endl;
|
||||
@ -369,7 +344,7 @@ void TryNewInstance(T, ArrayVariantType originalArray)
|
||||
{
|
||||
staticArray.WritePortal().Set(index, TestValue(index, T()));
|
||||
}
|
||||
CheckArrayVariant(newArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
|
||||
CheckArrayVariant(newArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
}
|
||||
|
||||
template <typename T, typename ArrayVariantType>
|
||||
@ -429,7 +404,7 @@ void TryDefaultType(T)
|
||||
{
|
||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T());
|
||||
|
||||
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
|
||||
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
|
||||
TryNewInstance(T(), array);
|
||||
|
||||
@ -444,7 +419,7 @@ struct TryBasicVTKmType
|
||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T());
|
||||
|
||||
CheckArrayVariant(
|
||||
array.ResetTypes(vtkm::TypeListAll()), vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
|
||||
array.ResetTypes(vtkm::TypeListAll()), vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
|
||||
TryNewInstance(T(), array.ResetTypes(vtkm::TypeListAll()));
|
||||
}
|
||||
@ -453,60 +428,20 @@ struct TryBasicVTKmType
|
||||
void TryUnusualType()
|
||||
{
|
||||
// A string is an unlikely type to be declared elsewhere in VTK-m.
|
||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(std::string());
|
||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(UnusualType{});
|
||||
|
||||
try
|
||||
{
|
||||
CheckArrayVariant(array, 1, true, false);
|
||||
CheckArrayVariant(array, 1, true);
|
||||
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type.");
|
||||
}
|
||||
catch (vtkm::cont::ErrorBadValue&)
|
||||
{
|
||||
std::cout << " Caught exception for unrecognized type." << std::endl;
|
||||
}
|
||||
|
||||
CheckArrayVariant(array.ResetTypes(TypeListString()), 1, true, false);
|
||||
CheckArrayVariant(array.ResetTypes(vtkm::List<UnusualType>()), 1, true);
|
||||
std::cout << " Found type when type list was reset." << std::endl;
|
||||
}
|
||||
|
||||
void TryUnusualStorage()
|
||||
{
|
||||
vtkm::cont::VariantArrayHandle array = ArrayHandleWithUnusualStorage<vtkm::Id>();
|
||||
|
||||
try
|
||||
{
|
||||
CheckArrayVariant(array, 1, false, true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
VTKM_TEST_FAIL("CastAndCall with Variant failed to handle unusual storage.");
|
||||
}
|
||||
}
|
||||
|
||||
void TryUnusualTypeAndStorage()
|
||||
{
|
||||
vtkm::cont::VariantArrayHandle array = ArrayHandleWithUnusualStorage<std::string>();
|
||||
|
||||
try
|
||||
{
|
||||
CheckArrayVariant(array, 1, false, true);
|
||||
VTKM_TEST_FAIL("CastAndCall failed to error for unrecognized type/storage.");
|
||||
}
|
||||
catch (vtkm::cont::ErrorBadValue&)
|
||||
{
|
||||
std::cout << " Caught exception for unrecognized type/storage." << std::endl;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CheckArrayVariant(array.ResetTypes(TypeListString()), 1, false, true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
VTKM_TEST_FAIL("CastAndCall with Variant failed to handle unusual storage.");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
void TryCastToArrayHandle(const ArrayHandleType& array)
|
||||
{
|
||||
@ -523,7 +458,8 @@ void TryCastToArrayHandle()
|
||||
buffer[index] = TestValue(index, vtkm::Id());
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> array = vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> array =
|
||||
vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, vtkm::CopyFlag::On);
|
||||
TryCastToArrayHandle(array);
|
||||
|
||||
std::cout << " Cast array handle." << std::endl;
|
||||
@ -586,12 +522,6 @@ void TestVariantArrayHandle()
|
||||
std::cout << "Try unusual type." << std::endl;
|
||||
TryUnusualType();
|
||||
|
||||
std::cout << "Try unusual storage." << std::endl;
|
||||
TryUnusualStorage();
|
||||
|
||||
std::cout << "Try unusual type in unusual storage." << std::endl;
|
||||
TryUnusualTypeAndStorage();
|
||||
|
||||
std::cout << "Try CastToArrayHandle" << std::endl;
|
||||
TryCastToArrayHandle();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <vtkm/TopologyElementTag.h>
|
||||
#include <vtkm/VecFromPortalPermute.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/exec/CellInside.h>
|
||||
#include <vtkm/exec/CellLocator.h>
|
||||
#include <vtkm/exec/ParametricCoordinates.h>
|
||||
@ -74,12 +74,13 @@ public:
|
||||
CellLocatorBoundingIntervalHierarchyExec() {}
|
||||
|
||||
VTKM_CONT
|
||||
CellLocatorBoundingIntervalHierarchyExec(const NodeArrayHandle& nodes,
|
||||
const CellIdArrayHandle& cellIds,
|
||||
const CellSetType& cellSet,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||
DeviceAdapter,
|
||||
vtkm::cont::Token& token)
|
||||
CellLocatorBoundingIntervalHierarchyExec(
|
||||
const NodeArrayHandle& nodes,
|
||||
const CellIdArrayHandle& cellIds,
|
||||
const CellSetType& cellSet,
|
||||
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coords,
|
||||
DeviceAdapter,
|
||||
vtkm::cont::Token& token)
|
||||
: Nodes(nodes.PrepareForInput(DeviceAdapter(), token))
|
||||
, CellIds(cellIds.PrepareForInput(DeviceAdapter(), token))
|
||||
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), VisitType(), IncidentType(), token))
|
||||
@ -277,8 +278,9 @@ private:
|
||||
using CellSetPortal = typename CellSetType::template ExecutionTypes<DeviceAdapter,
|
||||
VisitType,
|
||||
IncidentType>::ExecObjectType;
|
||||
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
using CoordsPortal =
|
||||
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
|
||||
NodePortal Nodes;
|
||||
CellIdPortal CellIds;
|
||||
|
@ -34,8 +34,6 @@ private:
|
||||
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;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
@ -44,15 +42,12 @@ public:
|
||||
const vtkm::Vec3f origin,
|
||||
const vtkm::Vec3f invSpacing,
|
||||
const vtkm::Vec3f maxPoint,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||
DeviceAdapter,
|
||||
vtkm::cont::Token& token)
|
||||
DeviceAdapter)
|
||||
: CellDims(cellDims)
|
||||
, PointDims(pointDims)
|
||||
, Origin(origin)
|
||||
, InvSpacing(invSpacing)
|
||||
, MaxPoint(maxPoint)
|
||||
, Coords(coords.PrepareForInput(DeviceAdapter(), token))
|
||||
{
|
||||
}
|
||||
|
||||
@ -120,7 +115,6 @@ private:
|
||||
vtkm::Vec3f Origin;
|
||||
vtkm::Vec3f InvSpacing;
|
||||
vtkm::Vec3f MaxPoint;
|
||||
CoordsPortal Coords;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,12 @@ public:
|
||||
return this->Internals.GetPointDimensions();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<vtkm::Id, Dimension> GetCellDimensions() const
|
||||
{
|
||||
return this->Internals.GetCellDimensions();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
SchedulingRangeType GetGlobalPointIndexStart() const
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ namespace exec
|
||||
/// be returned determined by the boundary behavior. A \c BoundaryState object can be used to
|
||||
/// determine if the neighborhood extends beyond the boundary of the mesh.
|
||||
///
|
||||
/// This class is typically constructued using the \c FieldInNeighborhood tag in an
|
||||
/// This class is typically constructed using the \c FieldInNeighborhood tag in an
|
||||
/// \c ExecutionSignature. There is little reason to construct this in user code.
|
||||
///
|
||||
/// \c FieldNeighborhood is templated on the array portal from which field values are retrieved.
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef vtk_m_exec_PointLocatorUniformGrid_h
|
||||
#define vtk_m_exec_PointLocatorUniformGrid_h
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
@ -29,7 +30,7 @@ class VTKM_ALWAYS_EXPORT PointLocatorUniformGrid final : public vtkm::exec::Poin
|
||||
{
|
||||
public:
|
||||
using CoordPortalType =
|
||||
typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
|
||||
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst;
|
||||
using IdPortalType =
|
||||
typename vtkm::cont::ArrayHandle<vtkm::Id>::template ExecutionTypes<DeviceAdapter>::PortalConst;
|
||||
|
@ -33,6 +33,8 @@ set(headers
|
||||
ThreadIndicesBasic.h
|
||||
ThreadIndicesBasic3D.h
|
||||
ThreadIndicesExtrude.h
|
||||
ThreadIndicesNeighborhood.h
|
||||
ThreadIndicesCellNeighborhood.h
|
||||
ThreadIndicesPointNeighborhood.h
|
||||
ThreadIndicesReduceByKey.h
|
||||
ThreadIndicesTopologyMap.h
|
||||
|
90
vtkm/exec/arg/ThreadIndicesCellNeighborhood.h
Normal file
90
vtkm/exec/arg/ThreadIndicesCellNeighborhood.h
Normal file
@ -0,0 +1,90 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_exec_arg_ThreadIndicesCellNeighborhood_h
|
||||
#define vtk_m_exec_arg_ThreadIndicesCellNeighborhood_h
|
||||
|
||||
#include <vtkm/exec/BoundaryState.h>
|
||||
#include <vtkm/exec/ConnectivityStructured.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesBasic.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesNeighborhood.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesTopologyMap.h> //for Deflate and Inflate
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace arg
|
||||
{
|
||||
/// \brief Container for thread information in a WorkletCellNeighborhood.
|
||||
///
|
||||
///
|
||||
class ThreadIndicesCellNeighborhood : public vtkm::exec::arg::ThreadIndicesNeighborhood
|
||||
{
|
||||
using Superclass = vtkm::exec::arg::ThreadIndicesNeighborhood;
|
||||
|
||||
public:
|
||||
template <vtkm::IdComponent Dimension>
|
||||
VTKM_EXEC ThreadIndicesCellNeighborhood(
|
||||
const vtkm::Id3& threadIndex3D,
|
||||
vtkm::Id threadIndex1D,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity)
|
||||
: Superclass(
|
||||
threadIndex1D,
|
||||
vtkm::exec::BoundaryState{ threadIndex3D, detail::To3D(connectivity.GetCellDimensions()) })
|
||||
{
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent Dimension>
|
||||
VTKM_EXEC ThreadIndicesCellNeighborhood(
|
||||
const vtkm::Id3& threadIndex3D,
|
||||
vtkm::Id threadIndex1D,
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity)
|
||||
: Superclass(
|
||||
threadIndex1D,
|
||||
inputIndex,
|
||||
visitIndex,
|
||||
outputIndex,
|
||||
vtkm::exec::BoundaryState{ threadIndex3D, detail::To3D(connectivity.GetCellDimensions()) })
|
||||
{
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent Dimension>
|
||||
VTKM_EXEC ThreadIndicesCellNeighborhood(
|
||||
vtkm::Id threadIndex,
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity)
|
||||
: Superclass(
|
||||
threadIndex,
|
||||
inputIndex,
|
||||
visitIndex,
|
||||
outputIndex,
|
||||
vtkm::exec::BoundaryState{ detail::To3D(connectivity.FlatToLogicalToIndex(inputIndex)),
|
||||
detail::To3D(connectivity.GetCellDimensions()) })
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::arg
|
||||
|
||||
#endif //vtk_m_exec_arg_ThreadIndicesCellNeighborhood_h
|
115
vtkm/exec/arg/ThreadIndicesNeighborhood.h
Normal file
115
vtkm/exec/arg/ThreadIndicesNeighborhood.h
Normal file
@ -0,0 +1,115 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_exec_arg_ThreadIndicesNeighborhood_h
|
||||
#define vtk_m_exec_arg_ThreadIndicesNeighborhood_h
|
||||
|
||||
|
||||
#include <vtkm/exec/BoundaryState.h>
|
||||
#include <vtkm/exec/ConnectivityStructured.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesBasic.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesTopologyMap.h> //for Deflate and Inflate
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace arg
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
///
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id3 index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id2 index)
|
||||
{
|
||||
return vtkm::Id3(index[0], index[1], 1);
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Vec<vtkm::Id, 1> index)
|
||||
{
|
||||
return vtkm::Id3(index[0], 1, 1);
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id index)
|
||||
{
|
||||
return vtkm::Id3(index, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
class ThreadIndicesNeighborhood
|
||||
{
|
||||
|
||||
public:
|
||||
VTKM_EXEC ThreadIndicesNeighborhood(vtkm::Id threadIndex1D,
|
||||
const vtkm::exec::BoundaryState& state)
|
||||
: State(state)
|
||||
, ThreadIndex(threadIndex1D)
|
||||
, InputIndex(threadIndex1D)
|
||||
, OutputIndex(threadIndex1D)
|
||||
, VisitIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC ThreadIndicesNeighborhood(vtkm::Id threadIndex1D,
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::Id outputIndex,
|
||||
const vtkm::exec::BoundaryState& state)
|
||||
: State(state)
|
||||
, ThreadIndex(threadIndex1D)
|
||||
, InputIndex(inputIndex)
|
||||
, OutputIndex(outputIndex)
|
||||
, VisitIndex(visitIndex)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
const vtkm::exec::BoundaryState& GetBoundaryState() const { return this->State; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetThreadIndex() const { return this->ThreadIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetInputIndex() const { return this->InputIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id3 GetInputIndex3D() const { return this->State.IJK; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetOutputIndex() const { return this->OutputIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
private:
|
||||
vtkm::exec::BoundaryState State;
|
||||
vtkm::Id ThreadIndex;
|
||||
vtkm::Id InputIndex;
|
||||
vtkm::Id OutputIndex;
|
||||
vtkm::IdComponent VisitIndex;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::arg
|
||||
|
||||
#endif //vtk_m_exec_arg_ThreadIndicesNeighborhood_h
|
@ -10,12 +10,7 @@
|
||||
#ifndef vtk_m_exec_arg_ThreadIndicesPointNeighborhood_h
|
||||
#define vtk_m_exec_arg_ThreadIndicesPointNeighborhood_h
|
||||
|
||||
#include <vtkm/exec/BoundaryState.h>
|
||||
#include <vtkm/exec/ConnectivityStructured.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesBasic.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesTopologyMap.h> //for Deflate and Inflate
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/exec/arg/ThreadIndicesNeighborhood.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -23,43 +18,12 @@ namespace exec
|
||||
{
|
||||
namespace arg
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
///
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id3 index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id2 index)
|
||||
{
|
||||
return vtkm::Id3(index[0], index[1], 1);
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Vec<vtkm::Id, 1> index)
|
||||
{
|
||||
return vtkm::Id3(index[0], 1, 1);
|
||||
}
|
||||
|
||||
/// Given a \c Vec of (semi) arbitrary size, inflate it to a vtkm::Id3 by padding with zeros.
|
||||
/// \overload
|
||||
inline VTKM_EXEC vtkm::Id3 To3D(vtkm::Id index)
|
||||
{
|
||||
return vtkm::Id3(index, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Container for thread information in a WorkletPointNeighborhood.
|
||||
///
|
||||
///
|
||||
class ThreadIndicesPointNeighborhood
|
||||
class ThreadIndicesPointNeighborhood : public vtkm::exec::arg::ThreadIndicesNeighborhood
|
||||
{
|
||||
using Superclass = vtkm::exec::arg::ThreadIndicesNeighborhood;
|
||||
|
||||
public:
|
||||
template <vtkm::IdComponent Dimension>
|
||||
@ -69,11 +33,9 @@ public:
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity)
|
||||
: State(threadIndex3D, detail::To3D(connectivity.GetPointDimensions()))
|
||||
, ThreadIndex(threadIndex1D)
|
||||
, InputIndex(threadIndex1D)
|
||||
, OutputIndex(threadIndex1D)
|
||||
, VisitIndex(0)
|
||||
: Superclass(
|
||||
threadIndex1D,
|
||||
vtkm::exec::BoundaryState{ threadIndex3D, detail::To3D(connectivity.GetPointDimensions()) })
|
||||
{
|
||||
}
|
||||
|
||||
@ -87,11 +49,12 @@ public:
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity)
|
||||
: State(threadIndex3D, detail::To3D(connectivity.GetPointDimensions()))
|
||||
, ThreadIndex(threadIndex1D)
|
||||
, InputIndex(inputIndex)
|
||||
, OutputIndex(outputIndex)
|
||||
, VisitIndex(visitIndex)
|
||||
: Superclass(
|
||||
threadIndex1D,
|
||||
inputIndex,
|
||||
visitIndex,
|
||||
outputIndex,
|
||||
vtkm::exec::BoundaryState{ threadIndex3D, detail::To3D(connectivity.GetPointDimensions()) })
|
||||
{
|
||||
}
|
||||
|
||||
@ -104,42 +67,17 @@ public:
|
||||
const vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
Dimension>& connectivity)
|
||||
: State(detail::To3D(connectivity.FlatToLogicalToIndex(inputIndex)),
|
||||
detail::To3D(connectivity.GetPointDimensions()))
|
||||
, ThreadIndex(threadIndex)
|
||||
, InputIndex(inputIndex)
|
||||
, OutputIndex(outputIndex)
|
||||
, VisitIndex(visitIndex)
|
||||
: Superclass(
|
||||
threadIndex,
|
||||
inputIndex,
|
||||
visitIndex,
|
||||
outputIndex,
|
||||
vtkm::exec::BoundaryState{ detail::To3D(connectivity.FlatToLogicalToIndex(inputIndex)),
|
||||
detail::To3D(connectivity.GetPointDimensions()) })
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
const vtkm::exec::BoundaryState& GetBoundaryState() const { return this->State; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetThreadIndex() const { return this->ThreadIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetInputIndex() const { return this->InputIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id3 GetInputIndex3D() const { return this->State.IJK; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Id GetOutputIndex() const { return this->OutputIndex; }
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::IdComponent GetVisitIndex() const { return this->VisitIndex; }
|
||||
|
||||
private:
|
||||
vtkm::exec::BoundaryState State;
|
||||
vtkm::Id ThreadIndex;
|
||||
vtkm::Id InputIndex;
|
||||
vtkm::Id OutputIndex;
|
||||
vtkm::IdComponent VisitIndex;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::arg
|
||||
|
||||
} // arg
|
||||
} // exec
|
||||
} // vtkm
|
||||
#endif //vtk_m_exec_arg_ThreadIndicesPointNeighborhood_h
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
VTKM_CONT
|
||||
CellMeasures();
|
||||
|
||||
/// Set/Get the name of the cell measure field. If empty, "measure" is used.
|
||||
/// Set/Get the name of the cell measure field. If not set, "measure" is used.
|
||||
void SetCellMeasureName(const std::string& name) { this->SetOutputFieldName(name); }
|
||||
const std::string& GetCellMeasureName() const { return this->GetOutputFieldName(); }
|
||||
|
||||
|
@ -25,6 +25,7 @@ inline VTKM_CONT CellMeasures<IntegrationType>::CellMeasures()
|
||||
: vtkm::filter::FilterCell<CellMeasures<IntegrationType>>()
|
||||
{
|
||||
this->SetUseCoordinateSystemAsField(true);
|
||||
this->SetCellMeasureName("measure");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -108,6 +108,8 @@ VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithField);
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithField_hxx
|
||||
#include <vtkm/filter/ClipWithField.hxx>
|
||||
#endif
|
||||
|
||||
#endif // vtk_m_filter_ClipWithField_h
|
||||
|
@ -11,6 +11,8 @@
|
||||
#ifndef vtk_m_filter_ClipWithField_hxx
|
||||
#define vtk_m_filter_ClipWithField_hxx
|
||||
|
||||
#include <vtkm/filter/ClipWithField.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
@ -21,6 +23,26 @@ namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ClipWithFieldProcessCoords
|
||||
{
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
||||
const std::string& coordsName,
|
||||
const vtkm::worklet::Clip& worklet,
|
||||
vtkm::cont::DataSet& output) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
||||
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
||||
output.AddCoordinateSystem(outCoords);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
@ -37,9 +59,6 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
//get the cells and coordinates of the dataset
|
||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||
|
||||
const vtkm::cont::CoordinateSystem& inputCoords =
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
||||
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, this->ClipValue, this->Invert);
|
||||
|
||||
@ -48,9 +67,14 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
||||
output.SetCellSet(outputCellSet);
|
||||
|
||||
// Compute the new boundary points and add them to the output:
|
||||
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
||||
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
|
||||
output.AddCoordinateSystem(outputCoords);
|
||||
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
||||
++coordSystemId)
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
|
||||
coords.GetData().CastAndCall(
|
||||
detail::ClipWithFieldProcessCoords{}, coords.GetName(), this->Worklet, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,8 @@ VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithImplicitFunction);
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_ClipWithImplicitFunction_hxx
|
||||
#include <vtkm/filter/ClipWithImplicitFunction.hxx>
|
||||
#endif
|
||||
|
||||
#endif // vtk_m_filter_ClipWithImplicitFunction_h
|
||||
|
@ -11,6 +11,8 @@
|
||||
#ifndef vtk_m_filter_ClipWithImplicitFunction_hxx
|
||||
#define vtk_m_filter_ClipWithImplicitFunction_hxx
|
||||
|
||||
#include <vtkm/filter/ClipWithImplicitFunction.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||
#include <vtkm/cont/CellSetPermutation.h>
|
||||
#include <vtkm/cont/DynamicCellSet.h>
|
||||
@ -19,6 +21,26 @@ namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct ClipWithImplicitFunctionProcessCoords
|
||||
{
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
|
||||
const std::string& coordsName,
|
||||
const vtkm::worklet::Clip& worklet,
|
||||
vtkm::cont::DataSet& output) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
|
||||
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
|
||||
output.AddCoordinateSystem(outCoords);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename DerivedPolicy>
|
||||
inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
||||
@ -37,14 +59,18 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
||||
inputCoords,
|
||||
this->Invert);
|
||||
|
||||
// compute output coordinates
|
||||
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
||||
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
|
||||
|
||||
//create the output data
|
||||
vtkm::cont::DataSet output;
|
||||
output.SetCellSet(outputCellSet);
|
||||
output.AddCoordinateSystem(outputCoords);
|
||||
|
||||
// compute output coordinates
|
||||
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
|
||||
++coordSystemId)
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
|
||||
coords.GetData().CastAndCall(
|
||||
detail::ClipWithImplicitFunctionProcessCoords{}, coords.GetName(), this->Worklet, output);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define vtk_m_filter_ImageMedian_hxx
|
||||
|
||||
#include <vtkm/Swap.h>
|
||||
#include <vtkm/worklet/WorkletPointNeighborhood.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/worklet/ParticleAdvection.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/particleadvection/Field.h>
|
||||
#include <vtkm/worklet/particleadvection/GridEvaluators.h>
|
||||
#include <vtkm/worklet/particleadvection/Integrators.h>
|
||||
#include <vtkm/worklet/particleadvection/Particles.h>
|
||||
@ -32,8 +33,8 @@
|
||||
#include <string.h>
|
||||
|
||||
static vtkm::Id cycle = 0;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Particle> BasisParticles;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Particle> BasisParticlesOriginal;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Massless> BasisParticles;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Massless> BasisParticlesOriginal;
|
||||
static vtkm::cont::ArrayHandle<vtkm::Id> BasisParticlesValidity;
|
||||
|
||||
namespace
|
||||
@ -51,7 +52,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename ValidityType>
|
||||
VTKM_EXEC void operator()(const vtkm::Particle& end_point, ValidityType& res) const
|
||||
VTKM_EXEC void operator()(const vtkm::Massless& end_point, ValidityType& res) const
|
||||
{
|
||||
vtkm::Id steps = end_point.NumSteps;
|
||||
if (steps > 0 && res == 1)
|
||||
@ -83,8 +84,8 @@ public:
|
||||
using InputDomain = _1;
|
||||
|
||||
template <typename DisplacementType>
|
||||
VTKM_EXEC void operator()(const vtkm::Particle& end_point,
|
||||
const vtkm::Particle& start_point,
|
||||
VTKM_EXEC void operator()(const vtkm::Massless& end_point,
|
||||
const vtkm::Massless& start_point,
|
||||
DisplacementType& res) const
|
||||
{
|
||||
res[0] = end_point.Pos[0] - start_point.Pos[0];
|
||||
@ -193,7 +194,7 @@ inline void Lagrangian::InitializeSeedPositions(const vtkm::cont::DataSet& input
|
||||
{
|
||||
vtkm::FloatDefault xi = static_cast<vtkm::FloatDefault>(x * x_spacing);
|
||||
portal1.Set(id,
|
||||
vtkm::Particle(Vec3f(static_cast<vtkm::FloatDefault>(bounds.X.Min) + xi,
|
||||
vtkm::Massless(Vec3f(static_cast<vtkm::FloatDefault>(bounds.X.Min) + xi,
|
||||
static_cast<vtkm::FloatDefault>(bounds.Y.Min) + yi,
|
||||
static_cast<vtkm::FloatDefault>(bounds.Z.Min) + zi),
|
||||
id));
|
||||
@ -264,7 +265,7 @@ inline VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(
|
||||
throw vtkm::cont::ErrorFilterExecution(
|
||||
"Write frequency can not be 0. Use SetWriteFrequency().");
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> basisParticleArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Massless> basisParticleArray;
|
||||
vtkm::cont::ArrayCopy(BasisParticles, basisParticleArray);
|
||||
|
||||
cycle += 1;
|
||||
@ -274,12 +275,14 @@ inline VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(
|
||||
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
|
||||
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>;
|
||||
using GridEvalType = vtkm::worklet::particleadvection::GridEvaluator<FieldHandle>;
|
||||
using FieldType = vtkm::worklet::particleadvection::VelocityField<FieldHandle>;
|
||||
using GridEvalType = vtkm::worklet::particleadvection::GridEvaluator<FieldType>;
|
||||
using RK4Type = vtkm::worklet::particleadvection::RK4Integrator<GridEvalType>;
|
||||
vtkm::worklet::ParticleAdvection particleadvection;
|
||||
vtkm::worklet::ParticleAdvectionResult res;
|
||||
vtkm::worklet::ParticleAdvectionResult<vtkm::Massless> res;
|
||||
|
||||
GridEvalType gridEval(coords, cells, field);
|
||||
FieldType velocities(field);
|
||||
GridEvalType gridEval(coords, cells, velocities);
|
||||
RK4Type rk4(gridEval, static_cast<vtkm::Float32>(this->stepSize));
|
||||
|
||||
res = particleadvection.Run(rk4, basisParticleArray, 1); // Taking a single step
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/ErrorFilterExecution.h>
|
||||
#include <vtkm/cont/Invoker.h>
|
||||
#include <vtkm/worklet/particleadvection/Field.h>
|
||||
#include <vtkm/worklet/particleadvection/GridEvaluators.h>
|
||||
#include <vtkm/worklet/particleadvection/Integrators.h>
|
||||
#include <vtkm/worklet/particleadvection/Particles.h>
|
||||
@ -34,12 +35,28 @@ public:
|
||||
using ExecutionSignature = void(_1, _2);
|
||||
using InputDomain = _1;
|
||||
|
||||
VTKM_EXEC void operator()(const vtkm::Particle& particle, vtkm::Vec3f& pt) const
|
||||
VTKM_EXEC void operator()(const vtkm::Massless& particle, vtkm::Vec3f& pt) const
|
||||
{
|
||||
pt = particle.Pos;
|
||||
}
|
||||
};
|
||||
|
||||
class MakeParticles : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
using ControlSignature = void(FieldIn seed, FieldOut particle);
|
||||
using ExecutionSignature = void(WorkIndex, _1, _2);
|
||||
using InputDomain = _1;
|
||||
|
||||
VTKM_EXEC void operator()(const vtkm::Id index,
|
||||
const vtkm::Vec3f& seed,
|
||||
vtkm::Massless& particle) const
|
||||
{
|
||||
particle.ID = index;
|
||||
particle.Pos = seed;
|
||||
}
|
||||
};
|
||||
|
||||
} //detail
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -66,7 +83,8 @@ inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
|
||||
using Structured3DType = vtkm::cont::CellSetStructured<3>;
|
||||
|
||||
using FieldHandle = vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>;
|
||||
using GridEvaluator = vtkm::worklet::particleadvection::GridEvaluator<FieldHandle>;
|
||||
using FieldType = vtkm::worklet::particleadvection::VelocityField<FieldHandle>;
|
||||
using GridEvaluator = vtkm::worklet::particleadvection::GridEvaluator<FieldType>;
|
||||
using Integrator = vtkm::worklet::particleadvection::RK4Integrator<GridEvaluator>;
|
||||
|
||||
vtkm::FloatDefault stepSize = this->GetStepSize();
|
||||
@ -115,15 +133,16 @@ inline VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(
|
||||
}
|
||||
else
|
||||
{
|
||||
GridEvaluator evaluator(input.GetCoordinateSystem(), input.GetCellSet(), field);
|
||||
vtkm::cont::Invoker invoke;
|
||||
|
||||
FieldType velocities(field);
|
||||
GridEvaluator evaluator(input.GetCoordinateSystem(), input.GetCellSet(), velocities);
|
||||
Integrator integrator(evaluator, stepSize);
|
||||
vtkm::worklet::ParticleAdvection particles;
|
||||
vtkm::worklet::ParticleAdvectionResult advectionResult;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> advectionPoints;
|
||||
vtkm::cont::ArrayCopy(lcsInputPoints, advectionPoints);
|
||||
vtkm::worklet::ParticleAdvectionResult<vtkm::Massless> advectionResult;
|
||||
vtkm::cont::ArrayHandle<vtkm::Massless> advectionPoints;
|
||||
invoke(detail::MakeParticles{}, lcsInputPoints, advectionPoints);
|
||||
advectionResult = particles.Run(integrator, advectionPoints, numberOfSteps);
|
||||
|
||||
vtkm::cont::Invoker invoke;
|
||||
invoke(detail::ExtractParticlePosition{}, advectionResult.Particles, lcsOutputPoints);
|
||||
}
|
||||
// FTLE output field
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
void SetNumberOfSteps(vtkm::Id n) { this->NumberOfSteps = n; }
|
||||
|
||||
VTKM_CONT
|
||||
void SetSeeds(vtkm::cont::ArrayHandle<vtkm::Particle>& seeds);
|
||||
void SetSeeds(vtkm::cont::ArrayHandle<vtkm::Massless>& seeds);
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(
|
||||
@ -56,7 +56,7 @@ public:
|
||||
private:
|
||||
vtkm::Id NumberOfSteps;
|
||||
vtkm::FloatDefault StepSize;
|
||||
vtkm::cont::ArrayHandle<vtkm::Particle> Seeds;
|
||||
vtkm::cont::ArrayHandle<vtkm::Massless> Seeds;
|
||||
vtkm::worklet::ParticleAdvection Worklet;
|
||||
};
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user