Merge branch 'master' of https://gitlab.kitware.com/vtk/vtk-m
This commit is contained in:
commit
b2cab86da8
@ -1,4 +1,4 @@
|
||||
VTKm License Version 1.7
|
||||
VTKm License Version 1.8
|
||||
========================================================================
|
||||
|
||||
Copyright (c) 2014-2022
|
||||
|
@ -48,14 +48,6 @@ set(benchmarks
|
||||
BenchmarkTopologyAlgorithms
|
||||
)
|
||||
|
||||
#Taking too long to compile with HIPCC
|
||||
if(HIP IN_LIST Kokkos_DEVICES)
|
||||
list(REMOVE_ITEM benchmarks
|
||||
BenchmarkDeviceAdapter
|
||||
BenchmarkODEIntegrators
|
||||
)
|
||||
endif()
|
||||
|
||||
set(VTKm_BENCHS_RANGE_LOWER_BOUNDARY 4096 CACHE STRING "Smallest sample for input size bench for BenchmarkDeviceAdapter")
|
||||
set(VTKm_BENCHS_RANGE_UPPER_BOUNDARY 134217728 CACHE STRING "Biggest sample for input size bench for BenchmarkDeviceAdapter")
|
||||
mark_as_advanced(VTKm_BENCHS_RANGE_LOWER_BOUNDARY VTKm_BENCHS_RANGE_UPPER_BOUNDARY)
|
||||
@ -64,10 +56,8 @@ foreach (benchmark ${benchmarks})
|
||||
add_benchmark(NAME ${benchmark} FILE ${benchmark}.cxx LIBS vtkm_source vtkm_filter vtkm_io)
|
||||
endforeach ()
|
||||
|
||||
if(NOT HIP IN_LIST Kokkos_DEVICES)
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY})
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY})
|
||||
endif()
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER_BOUNDARY=${VTKm_BENCHS_RANGE_LOWER_BOUNDARY})
|
||||
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY})
|
||||
|
||||
if(TARGET vtkm_rendering)
|
||||
add_benchmark(NAME BenchmarkRayTracing FILE BenchmarkRayTracing.cxx LIBS vtkm_rendering vtkm_source)
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:17b032ff1f2cf019b8cc39e5db2f823a8f5c1ceac5bf05ee7c2dd82d2097d19c
|
||||
size 19720
|
||||
oid sha256:fa95a5a698a8ec1b80884a31f7a1f339a302e4a32adfb1c33b3e8e713fb4f243
|
||||
size 67902
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1252a96282b1713a57769d2b7d8bdf3d16f38ad2e02dfeb454e770d42679dedf
|
||||
size 19398
|
||||
oid sha256:29aef56293f9909f1f0abd1e3fa598dd4853d04d2a66277959398743337eebd8
|
||||
size 81058
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:da36149e1a86d54d2f051a48f06b1091306f3a5e972727287e18511371b125a7
|
||||
size 19659
|
||||
oid sha256:2b4b6ba29eb3b2a66d9084d6c82523636eaf01472e397ae9d3222f6e4309795d
|
||||
size 81353
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c27cead7392df7591bb03418e0a6e97e2966577f630a43aad08e38dd93006543
|
||||
size 26903
|
||||
oid sha256:471bca272393b52d6000b3446c4d96c7ad4cd6f57affab8023c4ff67a2b720be
|
||||
size 72052
|
||||
|
466
docs/changelog/1.8/release-notes.md
Normal file
466
docs/changelog/1.8/release-notes.md
Normal file
@ -0,0 +1,466 @@
|
||||
VTK-m 1.8 Release Notes
|
||||
=======================
|
||||
|
||||
# Table of Contents
|
||||
|
||||
1. [Core](#Core)
|
||||
|
||||
- New `vtkm::List` features
|
||||
- No longer use brigand.hpp
|
||||
- Rename field associations
|
||||
- Favor scoped `enum`s
|
||||
- UnknownCellSet
|
||||
- Add implementation of `VecTraits` for `Range` and `Bounds`
|
||||
|
||||
2. [ArrayHandle](#ArrayHandle)
|
||||
|
||||
- ArrayHandle::Fill
|
||||
- Make ArrayCopy not depend on a device compiler
|
||||
- Better fallback for ArrayGetValue
|
||||
|
||||
3. [Worklets and Filters](#Worklets-and-Filters)
|
||||
|
||||
- Add `CreateResult` to `NewFilter` and absorb field mapping
|
||||
- NewFilterField
|
||||
- New Filter Interface Design
|
||||
- Perlin Noise source
|
||||
|
||||
4. [Build](#Build)
|
||||
|
||||
- Enable CMAKE_CUDA_ARCHITECTURES
|
||||
- Enable Unity build -
|
||||
- Generalized instantiation
|
||||
- Fix compile when testing is turned off
|
||||
|
||||
5. [Other](#Other)
|
||||
|
||||
- Redesign of Render Regression Tests
|
||||
|
||||
|
||||
# Core
|
||||
|
||||
## Remove brigand from List.h
|
||||
|
||||
Early in the development of VTK-m, a third party header library named
|
||||
brigand was incorporated into the source code. This header file contained
|
||||
the implementation of several complex meta-template programming constructs
|
||||
that are useful. Furthermore, it is implemented in such a way as to compile
|
||||
(relatively) quickly.
|
||||
|
||||
However, lately we have run into problems with brigand. First, it is not a
|
||||
very active project so that it is hard to submit fixes back to the project.
|
||||
Of the activity that is there, the most recent version of brigand now
|
||||
requires C++17, which is not directly supported by VTK-m. Second, brigand
|
||||
was added before the thridparty directory was established. This means as we
|
||||
have added corrections to the brigand source code, they have not been
|
||||
properly marked up in git to allow us to easily bring in changes from the
|
||||
main repo. On top of all that, because of the complexity of brigand, we
|
||||
often run into problems with compilers that fail in corner cases, which
|
||||
makes it difficult to support.
|
||||
|
||||
We have already moved away from brigand quite a bit. This takes another big
|
||||
step closer to removing our independence on brigand by no longer requiring
|
||||
it for any of the implementation of `vtkm::List`.
|
||||
|
||||
Because brigand.hpp is no longer included in List.h, some uses of the
|
||||
brigand header have been replaced with the implementation in List.h.
|
||||
|
||||
|
||||
## New `vtkm::List` features
|
||||
|
||||
New features were added to those available in `vtkm/List.h`. These new
|
||||
features provide new operations on lists.
|
||||
|
||||
### Reductions
|
||||
|
||||
The new `vtkm::ListReduce` allows a reduction on a list. This template
|
||||
takes three arguments: a `vtkm::List`, an operation, and an initial value.
|
||||
The operation is itself a template that has two type arguments.
|
||||
|
||||
`vtkm::ListReduce` applies the initial value and the first item of the list
|
||||
to the operator. The result of that template is then iteratively applied to
|
||||
the operator with the next item in the list and so on.
|
||||
|
||||
``` cpp
|
||||
// Operation to use
|
||||
template <typename T1, typename T2>
|
||||
using Add = std::integral_constant<typename T1::type, T1::value + T2::value>;
|
||||
|
||||
using MyList = vtkm::List<std::integral_constant<int, 25>,
|
||||
std::integral_constant<int, 60>,
|
||||
std::integral_constant<int, 87>,
|
||||
std::integral_constant<int, 62>>;
|
||||
|
||||
using MySum = vtkm::ListReduce<MyList, Add, std::integral_constant<int, 0>>;
|
||||
// MySum becomes std::integral_constant<int, 234> (25+60+87+62 = 234)
|
||||
```
|
||||
|
||||
### All and Any
|
||||
|
||||
Because they are very common, two reductions that are automatically
|
||||
supported are `vtkm::ListAll` and `vtkm::ListAny`. These both take a
|
||||
`vtkm::List` containing either `std::true_type` or `std::false_type` (or
|
||||
some other "compatible" type that has a constant static `bool` named
|
||||
`value`). `vtkm::ListAll` will become `std::false_type` if any of the
|
||||
entries in the list are `std::false_type`. `vtkm::ListAny` becomes
|
||||
`std::true_type` if any of the entires in the list are `std::true_type`.
|
||||
|
||||
``` cpp
|
||||
using MyList = vtkm::List<std::integral_constant<int, 25>,
|
||||
std::integral_constant<int, 60>,
|
||||
std::integral_constant<int, 87>,
|
||||
std::integral_constant<int, 62>>;
|
||||
|
||||
template <typename T>
|
||||
using IsEven = std::integral_constant<bool, ((T % 2) == 0)>;
|
||||
|
||||
// Note that vtkm::ListTransform<MyList, IsEven> becomes
|
||||
// vtkm::List<std::false_type, std::true_type, std::false_type, std::true_type>
|
||||
|
||||
using AllEven = vtkm::ListAll<vtkm::ListTransform<MyList, IsEven>>;
|
||||
// AllEven becomes std::false_type
|
||||
|
||||
using AnyEven = vtkm::ListAny<vtkm::ListTransform<MyList, IsEven>>;
|
||||
// AnyEven becomes std::true_type
|
||||
```
|
||||
|
||||
|
||||
## No longer use brigand.hpp
|
||||
|
||||
Remove brigand.hpp from VTK-m's source and all references to it. This was
|
||||
declared in an internal directory, so making this backward-incompatible
|
||||
changes should be OK.
|
||||
|
||||
Brigand is a third-party library to support template meta-programming. Over
|
||||
the years, we have had to make a few modifications to make sure it compiles
|
||||
with all compilers supported by VTK-m. Unfortunately, because brigand was
|
||||
added before our standard third-party library management was set up, these
|
||||
changes are not managed well. Thus, we cannot easily update with any
|
||||
changes from the project. Thus, our version is slowly diverging from the
|
||||
original, and maintaining it is a hassle.
|
||||
|
||||
Also, we have been using brigand less and less throughout the years. Now
|
||||
that we have moved on to C++11 (and now C++14) with variadic templates and
|
||||
other useful `std` features, the features of brigand have become less
|
||||
critical. Thus, we have implemented all the features we need from brigand
|
||||
internally and have moved our code away from using it.
|
||||
|
||||
|
||||
## Rename field associations
|
||||
|
||||
The symbols in `vtkm::cont::Field::Association` have been changed from
|
||||
`ANY`, `WHOLE_MESH`, `POINTS`, and `CELL_SET` to `Any`, `WholeMesh`,
|
||||
`Points`, and `Cells`, respectively. The reason for this change is twofold:
|
||||
|
||||
* The general standard that VTK-m follows for `enum struct` enumerators
|
||||
is to use camel case (with the first character capitalized), not all
|
||||
upper case.
|
||||
* The use of `CELL_SET` for fields associated with cells is obsolete. A
|
||||
`DataSet` used to support having more than one `CellSet`, and so a
|
||||
field association on cells was actually bound to a particular
|
||||
`CellSet`. However, that is no longer the case. A `DataSet` has exactly
|
||||
one `CellSet`, so a cell field no longer has to point to a `CellSet`.
|
||||
Thus the enumeration symbol for `Cells` should match the one for
|
||||
`Points`.
|
||||
|
||||
For backward compatibility, the old enumerations still exist. They are
|
||||
aliases for the new names, and they are marked as deprecated, so using them
|
||||
will result in a compiler warning (on some systems).
|
||||
|
||||
|
||||
## Favor scoped `enum`s
|
||||
|
||||
Several `enum` declarations were changed from a standard `enum` to a
|
||||
"scoped" `enum` (i.e. `enum struct`). The advantage of a scoped enum is
|
||||
that they provide better type safety because they won't be converted
|
||||
willy-nilly to other types. They also prevent the names they define from
|
||||
being accessible on the inner scope.
|
||||
|
||||
There are some cases where you do want the `enum` to convert to other types
|
||||
(but still want the scope of the symbols to be contained in the `enum`
|
||||
type). In this case, we worked around the problem by placing an unscoped
|
||||
`enum` inside of a standard `struct`.
|
||||
|
||||
|
||||
## UnknownCellSet
|
||||
|
||||
The `DynamicCellSet` class has been replaced with `UnknownCellSet`.
|
||||
Likewise, the `DynamicCellSetBase` class (a templated version of
|
||||
`DynamicCellSet`) has been replaced with `UncertainCellSet`.
|
||||
|
||||
These changes principally follow the changes to the `UnknownArrayHandle`
|
||||
management class. The `ArrayHandle` version of a polymorphic manager has
|
||||
gone through several refinements from `DynamicArrayHandle` to
|
||||
`VariantArrayHandle` to its current form as `UnknownArrayHandle`.
|
||||
Throughout these improvements for `ArrayHandle`, the equivalent classes for
|
||||
`CellSet` have lagged behind. The `CellSet` version is decidedly simpler
|
||||
because `CellSet` itself is polymorphic, but there were definitely
|
||||
improvements to be had.
|
||||
|
||||
The biggest improvement was to remove the templating from the basic unknown
|
||||
cell set. The old `DynamicArrayHandle` was actually a type alias for
|
||||
`DynamicArrayHandleBase<VTKM_DEFAULT_CELL_SET_LIST>`. As
|
||||
`VTKM_DEFAULT_CELL_SET_LIST` tends to be pretty long, `DynamicArrayHandle`
|
||||
was actually a really long type. In contrast, `UnknownArrayHandle` is its
|
||||
own untemplated class and will show up in linker symbols as such.
|
||||
|
||||
|
||||
## Add implementation of `VecTraits` for `Range` and `Bounds`
|
||||
|
||||
Added specializations of `vtkm::VecTraits` for the simple structures of
|
||||
`vtkm::Range` and `vtkm::Bounds`. This expands the support for using these
|
||||
structures in things like `ArrayHandle` and `UnknownArrayHandle`.
|
||||
|
||||
|
||||
# ArrayHandle
|
||||
|
||||
## ArrayHandle::Fill
|
||||
|
||||
`ArrayHandle` has a new method named `Fill`. As the name would suggest, the
|
||||
`Fill` method initializes all elements in the array to a specified value.
|
||||
In addition to being more convenient than calling `Algorithm::Fill` or
|
||||
`ArrayCopy` with a constant array, the `ArrayHandle::Fill` can be used
|
||||
without using a device adapter.
|
||||
|
||||
Calling `Fill` directly requires the `ArrayHandle` to first be allocated to
|
||||
the appropriate size. The `ArrayHandle` now also has a new member named
|
||||
`AllocateAndFill`. As the name would suggest, this method resizes the array
|
||||
and then fills it with the specified value. Another feature this method has
|
||||
over calling `Allocate` and `Fill` separately is if you call
|
||||
`AllocateAndFill` with `vtkm::CopyFlag::On`, it will fill only the extended
|
||||
portion of the array.
|
||||
|
||||
Also added a similar `Fill` and `AllocateAndFill` methods to `BitField` for
|
||||
similar reasons.
|
||||
|
||||
|
||||
## Make ArrayCopy not depend on a device compiler
|
||||
|
||||
Rather than require `ArrayCopy` to create special versions of copy for
|
||||
all arrays, use a precompiled versions. This should speed up compiles,
|
||||
reduce the amount of code being generated, and require the device
|
||||
compiler on fewer source files.
|
||||
|
||||
There are some cases where you still need to copy arrays that are not
|
||||
well supported by the precompiled versions in `ArrayCopy`. (It will
|
||||
always work, but the fallback is very slow.) In this case, you will want
|
||||
to switch over to `ArrayCopyDevice`, which has the old behavior.
|
||||
|
||||
|
||||
## Better fallback for ArrayGetValue
|
||||
|
||||
To avoid having to use a device compiler every time you wish to use
|
||||
`ArrayGetValue`, the actual implementation is compiled into the `vtkm_cont`
|
||||
library. To allow this to work for all the templated versions of
|
||||
`ArrayHandle`, the implementation uses the extract component features of
|
||||
`UnknownArrayHandle`. This works for most common arrays, but not all
|
||||
arrays.
|
||||
|
||||
For arrays that cannot be directly represented by an `ArrayHandleStride`,
|
||||
the fallback is bad. The entire array has to be pulled to the host and then
|
||||
copied serially to a basic array.
|
||||
|
||||
For `ArrayGetValue`, this is just silly. So, for arrays that cannot be
|
||||
simply represented by `ArrayHandleStride`, make a fallback that just uses
|
||||
`ReadPortal` to get the data. Often this is not the most efficient method,
|
||||
but it is better than the current alternative.
|
||||
|
||||
# Worklets and Filters
|
||||
|
||||
## Add `CreateResult` to `NewFilter` and absorb field mapping
|
||||
|
||||
The original version of `Filter` classes had a helper header file named
|
||||
`CreateResult.h` that had several forms of a `CreateResult` function that
|
||||
helped correctly create the `DataSet` to be returned from a filter's
|
||||
`DoExecute`. With the move to the `NewFilter` structure, these functions
|
||||
did not line up very well with how `DataSet`s should actually be created.
|
||||
|
||||
A replacement for these functions have been added as protected helper
|
||||
methods to `NewFilter` and `NewFilterField`. In addition to moving them
|
||||
into the filter themselves, the behavior of `CreateResult` has been merged
|
||||
with the map field to output functionality. The original implementation of
|
||||
`Filter` did this mapping internally in a different step. The first design
|
||||
of `NewFilter` required the filter implementer to call a
|
||||
`MapFieldsOntoOutput` themselves. This new implementation wraps the
|
||||
functionality of `CreateResult` and `MapFieldsOntoOutput` together so that
|
||||
the `DataSet` will be created correctly with a single call to
|
||||
`CreateResult`. This makes it easier to correctly create the output.
|
||||
|
||||
|
||||
## NewFilterField
|
||||
|
||||
As part of the New Filter Interface Design, `FilterField`, `FilterDataSet`
|
||||
and `FilterDataSetWithField` are now refactored into a single
|
||||
`NewFilterField`. A `NewFilterField` takes an input `DataSet` with some
|
||||
`Fields`, operates on the input `CellSet` and/or `Field` and generates an
|
||||
output DataSet, possibly with a new `CellSet` and/or `Field`.
|
||||
|
||||
Unlike the old `FilterField`, `NewFilterField` can support arbitrary number
|
||||
of *active* `Field`s. They are set by the extended `SetActiveField` method
|
||||
which now also takes an integer index.
|
||||
|
||||
`SupportedType` and `Policy` are no longer supported or needed by
|
||||
`NewFilterField`. Implementations are given full responsibility of extracting
|
||||
an `ArrayHandle` with proper value and storage type list from an input `Field`
|
||||
(through a variant of `CastAndCall`). Automatic type conversion from unsupported
|
||||
value types to `FloatDefault` is also added to UnknownArrayHandle. See
|
||||
`DotProduct::DoExecute` for an example on how to use the new facility.
|
||||
|
||||
|
||||
## New Filter Interface Design ##
|
||||
|
||||
An overhaul of the Filter interface is undergoing. This refactoring effort will
|
||||
address many problems we faced in the old design. The most important one is to
|
||||
remove the requirement to compile every single Filter users with a Device Compiler.
|
||||
This is addressed by removing C++ template (and CRTP) from Filter and is subclasses.
|
||||
A new non-templated NewFilter class is added with many old templated public interface
|
||||
removed.
|
||||
|
||||
This new design also made Filter implementations thread-safe by default. Filter
|
||||
implementations are encouraged to take advantage of the new design and removing
|
||||
shared metatable states from their `DoExecute`, see Doxygen documentation in
|
||||
NewFilter.h
|
||||
|
||||
Filter implementations are also re-organized into submodules, with each submodule
|
||||
in its own `vtkm/filter` subdirectory. User should update their code to include
|
||||
the new header files, for example, `vtkm/filter/field_transform/GenerateIds.h`and
|
||||
link to submodule library file, for example, `libvtkm_filter_field_transform.so`.
|
||||
To maintain backward compatability, old `vtkm/filter/FooFilter.h` header files
|
||||
can still be used but will be deprecated in release 2.0.
|
||||
|
||||
|
||||
## Perlin Noise source
|
||||
|
||||
A new source, `vtkm::source::PerlinNoise`, has been added. As the name
|
||||
would imply, this source generates a pseudo-random [Perlin
|
||||
noise](https://en.wikipedia.org/wiki/Perlin_noise) field.
|
||||
|
||||
The field is defined on a 3D grid of specified dimensions. A seed value can
|
||||
also be specified to enforce consistent results in, for example, test code.
|
||||
If a seed is not specified, one will be created based on the current system
|
||||
time.
|
||||
|
||||
Perlin noise is useful for testing purposes as it can create non-trivial
|
||||
geometry at pretty much any scale.
|
||||
|
||||
# Build
|
||||
|
||||
## Enable CMAKE_CUDA_ARCHITECTURES
|
||||
|
||||
When using _CMake_ > 3.18, `CMAKE_CUDA_ARCHITECTURES` can now be used instead of
|
||||
`VTKm_CUDA_Architecture` to specify the list of architectures desired for the
|
||||
compilation of _CUDA_ sources.
|
||||
|
||||
Since `CMAKE_CUDA_ARCHITECTURES` is the canonical method of specifying _CUDA_
|
||||
architectures in _CMake_ and it is more flexible, for instance we can also
|
||||
specify _CUDA_ virtual architectures, from _CMake_ 3.18 explicitly setting
|
||||
`VTKm_CUDA_Architecture` will be deprecated whilst still supported.
|
||||
|
||||
|
||||
## Enable Unity build ##
|
||||
|
||||
VTK-m now partially supports unity builds in a subset its sources files which
|
||||
are known to take the longer time/memory to build. Particularly, this enables
|
||||
you to speedup compilation in VTK-m not memory intensive builds (HIP, CUDA) in a
|
||||
system with sufficient resources.
|
||||
|
||||
We use `BATCH` unity builds type and the number of source files per batch can be
|
||||
controlled by the canonical _CMake_ variable: `CMAKE_UNITY_BUILD_BATCH_SIZE`.
|
||||
|
||||
Unity builds requires _CMake_ >= 3.16, if using a older version, unity build
|
||||
will be disabled a regular build will be performed.
|
||||
|
||||
|
||||
## Generalized instantiation
|
||||
|
||||
Recently, an instantiation method was added to the VTK-m configuration
|
||||
files to set up a set of source files that compile instances of a template.
|
||||
This allows the template instances to be compiled exactly once in separate
|
||||
build files.
|
||||
|
||||
However, the implementation made the assumption that the instantiations
|
||||
were happening for VTK-m filters. Now that the VTK-m filters are being
|
||||
redesigned, this assumption is broken.
|
||||
|
||||
Thus, the instantiation code has been redesigned to be more general. It can
|
||||
now be applied to code within the new filter structure. It can also be
|
||||
applied anywhere else in the VTK-m source code.
|
||||
|
||||
|
||||
## Fix compile when testing is turned off
|
||||
|
||||
There were some places in VTK-m's code that included test header files even
|
||||
though they were not tests. As more code goes into libraries, this can
|
||||
break the build.
|
||||
|
||||
Remove VTK-m library dependence on testing code where found. Also added a
|
||||
CI build that turns off all testing to check for this condition in the
|
||||
future.
|
||||
|
||||
# Other
|
||||
|
||||
## Redesign of Render Regression Tests
|
||||
|
||||
The helper functions for creating the render regression tests have been
|
||||
reformulated. The main changes are outlined here.
|
||||
|
||||
### Helper functions are no longer templated
|
||||
|
||||
The principle change made is that the `RenderAndRegressionTest` has been
|
||||
changed to no longer require template arguments (which were used to specify
|
||||
which rendering components to use). However, using templated arguments
|
||||
requires each rendering test to entirely recompile the rendering code that
|
||||
it uses. Since the rendering code currently is itself templated, this leads
|
||||
to a significant amount of re-compilation.
|
||||
|
||||
As a side effect of this, the render helper function is now compiled into a
|
||||
new library, `vtkm_rendering_testing`. Once again, this allows multiple
|
||||
tests to use rendering without having to recompile the rendering code.
|
||||
|
||||
As part of the change, the name of the `RenderAndRegressionTest` function
|
||||
has been simplified to `RenderTest`.
|
||||
|
||||
### Use a more efficient device
|
||||
|
||||
It is common for the testing infrastructure to run the same test multiple
|
||||
times with different devices. Thus, a filter might be run once with the
|
||||
Kokkos backend and once with the Serial backend. However, even if the
|
||||
filter is being tested with the serial backend, there is no real reason to
|
||||
restrict the rendering to a serial process.
|
||||
|
||||
Thus, unless otherwise specified, the rendering will use whatever device is
|
||||
available regardless of what was requested for the test.
|
||||
|
||||
### Consolidate options into a struct
|
||||
|
||||
Before these changes, there were several options that could be provided to
|
||||
the render function, and these changes have added several more. The
|
||||
previous version of the render function specified each of these options as
|
||||
arguments to the function. However, that quickly became unwieldy as the
|
||||
number of options grows. Also, it was impossible to send options to the
|
||||
image comparison (which is called as a subprocess) such as threshold
|
||||
values.
|
||||
|
||||
### Move general testing methods to library
|
||||
|
||||
A side effect of these changes is that some more general testing methods
|
||||
have been moved to the `vtkm_cont_testing` library. Previously, all methods
|
||||
in the `vtkm::cont::testing::Testing` class were inlined in the header
|
||||
file. This makes sense for the methods that are templated, but not so much
|
||||
for methods that are not templated.
|
||||
|
||||
Although this change provides minimal improvements with compile times and
|
||||
object sizes (maybe). But the real benefit is that some of these methods
|
||||
declare static objects. When declared in inlined functions, a different
|
||||
object will be created for each translation unit. This can lead to
|
||||
unexpected behavior when multiple versions of a supposed singleton static
|
||||
object exist. In particular, this was causing a failure when the static
|
||||
objects holding testing directories was created by the test translation
|
||||
unit but was then unavailable to `vtkm_rendering_testing`.
|
||||
|
||||
### Expand test_equal_images
|
||||
|
||||
The `test_equal_images` function has been expanded to supply the generated
|
||||
image in a `Canvas` or a `DataSet` in addition to a `View`. Much of the
|
||||
templating code has been removed from `test_equal_images` and most of the
|
||||
code has moved into the `vtkm_rendering_testing` library.
|
@ -1,12 +0,0 @@
|
||||
## Enable Unity build ##
|
||||
|
||||
VTK-m now partially supports unity builds in a subset its sources files which
|
||||
are known to take the longer time/memory to build. Particularly, this enables
|
||||
you to speedup compilation in VTK-m not memory intensive builds (HIP, CUDA) in a
|
||||
system with sufficient resources.
|
||||
|
||||
We use `BATCH` unity builds type and the number of source files per batch can be
|
||||
controlled by the canonical _CMake_ variable: `CMAKE_UNITY_BUILD_BATCH_SIZE`.
|
||||
|
||||
Unity builds requires _CMake_ >= 3.16, if using a older version, unity build
|
||||
will be disabled a regular build will be performed.
|
@ -1,18 +0,0 @@
|
||||
## NewFilterField
|
||||
|
||||
As part of the New Filter Interface Design, `FilterField`, `FilterDataSet`
|
||||
and `FilterDataSetWithField` are now refactored into a single
|
||||
`NewFilterField`. A `NewFilterField` takes an input `DataSet` with some
|
||||
`Fields`, operates on the input `CellSet` and/or `Field` and generates an
|
||||
output DataSet, possibly with a new `CellSet` and/or `Field`.
|
||||
|
||||
Unlike the old `FilterField`, `NewFilterField` can support arbitrary number
|
||||
of *active* `Field`s. They are set by the extended `SetActiveField` method
|
||||
which now also takes an integer index.
|
||||
|
||||
`SupportedType` and `Policy` are no longer supported or needed by
|
||||
`NewFilterField`. Implementations are given full responsibility of extracting
|
||||
an `ArrayHandle` with proper value and storage type list from an input `Field`
|
||||
(through a variant of `CastAndCall`). Automatic type conversion from unsupported
|
||||
value types to `FloatDefault` is also added to UnknownArrayHandle. See
|
||||
`DotProduct::DoExecute` for an example on how to use the new facility.
|
@ -1,20 +0,0 @@
|
||||
## New Filter Interface Design ##
|
||||
|
||||
An overhaul of the Filter interface is undergoing. This refactoring effort will
|
||||
address many problems we faced in the old design. The most important one is to
|
||||
remove the requirement to compile every single Filter users with a Device Compiler.
|
||||
This is addressed by removing C++ template (and CRTP) from Filter and is subclasses.
|
||||
A new non-templated NewFilter class is added with many old templated public interface
|
||||
removed.
|
||||
|
||||
This new design also made Filter implementations thread-safe by default. Filter
|
||||
implementations are encouraged to take advantage of the new design and removing
|
||||
shared metatable states from their `DoExecute`, see Doxygen documentation in
|
||||
NewFilter.h
|
||||
|
||||
Filter implementations are also re-organized into submodules, with each submodule
|
||||
in its own `vtkm/filter` subdirectory. User should update their code to include
|
||||
the new header files, for example, `vtkm/filter/field_transform/GenerateIds.h`and
|
||||
link to submodule library file, for example, `libvtkm_filter_field_transform.so`.
|
||||
To maintain backward compatability, old `vtkm/filter/FooFilter.h` header files
|
||||
can still be used but will be deprecated in release 2.0.
|
@ -1,18 +0,0 @@
|
||||
# ArrayHandle::Fill
|
||||
|
||||
`ArrayHandle` has a new method named `Fill`. As the name would suggest, the
|
||||
`Fill` method initializes all elements in the array to a specified value.
|
||||
In addition to being more convenient than calling `Algorithm::Fill` or
|
||||
`ArrayCopy` with a constant array, the `ArrayHandle::Fill` can be used
|
||||
without using a device adapter.
|
||||
|
||||
Calling `Fill` directly requires the `ArrayHandle` to first be allocated to
|
||||
the appropriate size. The `ArrayHandle` now also has a new member named
|
||||
`AllocateAndFill`. As the name would suggest, this method resizes the array
|
||||
and then fills it with the specified value. Another feature this method has
|
||||
over calling `Allocate` and `Fill` separately is if you call
|
||||
`AllocateAndFill` with `vtkm::CopyFlag::On`, it will fill only the extended
|
||||
portion of the array.
|
||||
|
||||
Also added a similar `Fill` and `AllocateAndFill` methods to `BitField` for
|
||||
similar reasons.
|
@ -1,11 +0,0 @@
|
||||
# Make ArrayCopy not depend on a device compiler
|
||||
|
||||
Rather than require `ArrayCopy` to create special versions of copy for
|
||||
all arrays, use a precompiled versions. This should speed up compiles,
|
||||
reduce the amount of code being generated, and require the device
|
||||
compiler on fewer source files.
|
||||
|
||||
There are some cases where you still need to copy arrays that are not
|
||||
well supported by the precompiled versions in `ArrayCopy`. (It will
|
||||
always work, but the fallback is very slow.) In this case, you will want
|
||||
to switch over to `ArrayCopyDevice`, which has the old behavior.
|
@ -1,18 +0,0 @@
|
||||
# Add `CreateResult` to `NewFilter` and absorb field mapping
|
||||
|
||||
The original version of `Filter` classes had a helper header file named
|
||||
`CreateResult.h` that had several forms of a `CreateResult` function that
|
||||
helped correctly create the `DataSet` to be returned from a filter's
|
||||
`DoExecute`. With the move to the `NewFilter` structure, these functions
|
||||
did not line up very well with how `DataSet`s should actually be created.
|
||||
|
||||
A replacement for these functions have been added as protected helper
|
||||
methods to `NewFilter` and `NewFilterField`. In addition to moving them
|
||||
into the filter themselves, the behavior of `CreateResult` has been merged
|
||||
with the map field to output functionality. The original implementation of
|
||||
`Filter` did this mapping internally in a different step. The first design
|
||||
of `NewFilter` required the filter implementer to call a
|
||||
`MapFieldsOntoOutput` themselves. This new implementation wraps the
|
||||
functionality of `CreateResult` and `MapFieldsOntoOutput` together so that
|
||||
the `DataSet` will be created correctly with a single call to
|
||||
`CreateResult`. This makes it easier to correctly create the output.
|
@ -1,10 +0,0 @@
|
||||
## Enable CMAKE_CUDA_ARCHITECTURES
|
||||
|
||||
When using _CMake_ > 3.18, `CMAKE_CUDA_ARCHITECTURES` can now be used instead of
|
||||
`VTKm_CUDA_Architecture` to specify the list of architectures desired for the
|
||||
compilation of _CUDA_ sources.
|
||||
|
||||
Since `CMAKE_CUDA_ARCHITECTURES` is the canonical method of specifying _CUDA_
|
||||
architectures in _CMake_ and it is more flexible, for instance we can also
|
||||
specify _CUDA_ virtual architectures, from _CMake_ 3.18 explicitly setting
|
||||
`VTKm_CUDA_Architecture` will be deprecated whilst still supported.
|
@ -1,14 +0,0 @@
|
||||
# Generalized instantiation
|
||||
|
||||
Recently, an instantiation method was added to the VTK-m configuration
|
||||
files to set up a set of source files that compile instances of a template.
|
||||
This allows the template instances to be compiled exactly once in separate
|
||||
build files.
|
||||
|
||||
However, the implementation made the assumption that the instantiations
|
||||
were happening for VTK-m filters. Now that the VTK-m filters are being
|
||||
redesigned, this assumption is broken.
|
||||
|
||||
Thus, the instantiation code has been redesigned to be more general. It can
|
||||
now be applied to code within the new filter structure. It can also be
|
||||
applied anywhere else in the VTK-m source code.
|
@ -1,17 +0,0 @@
|
||||
# Better fallback for ArrayGetValue
|
||||
|
||||
To avoid having to use a device compiler every time you wish to use
|
||||
`ArrayGetValue`, the actual implementation is compiled into the `vtkm_cont`
|
||||
library. To allow this to work for all the templated versions of
|
||||
`ArrayHandle`, the implementation uses the extract component features of
|
||||
`UnknownArrayHandle`. This works for most common arrays, but not all
|
||||
arrays.
|
||||
|
||||
For arrays that cannot be directly represented by an `ArrayHandleStride`,
|
||||
the fallback is bad. The entire array has to be pulled to the host and then
|
||||
copied serially to a basic array.
|
||||
|
||||
For `ArrayGetValue`, this is just silly. So, for arrays that cannot be
|
||||
simply represented by `ArrayHandleStride`, make a fallback that just uses
|
||||
`ReadPortal` to get the data. Often this is not the most efficient method,
|
||||
but it is better than the current alternative.
|
@ -1,25 +0,0 @@
|
||||
# Remove brigand from List.h
|
||||
|
||||
Early in the development of VTK-m, a third party header library named
|
||||
brigand was incorporated into the source code. This header file contained
|
||||
the implementation of several complex meta-template programming constructs
|
||||
that are useful. Furthermore, it is implemented in such a way as to compile
|
||||
(relatively) quickly.
|
||||
|
||||
However, lately we have run into problems with brigand. First, it is not a
|
||||
very active project so that it is hard to submit fixes back to the project.
|
||||
Of the activity that is there, the most recent version of brigand now
|
||||
requires C++17, which is not directly supported by VTK-m. Second, brigand
|
||||
was added before the thridparty directory was established. This means as we
|
||||
have added corrections to the brigand source code, they have not been
|
||||
properly marked up in git to allow us to easily bring in changes from the
|
||||
main repo. On top of all that, because of the complexity of brigand, we
|
||||
often run into problems with compilers that fail in corner cases, which
|
||||
makes it difficult to support.
|
||||
|
||||
We have already moved away from brigand quite a bit. This takes another big
|
||||
step closer to removing our independence on brigand by no longer requiring
|
||||
it for any of the implementation of `vtkm::List`.
|
||||
|
||||
Because brigand.hpp is no longer included in List.h, some uses of the
|
||||
brigand header have been replaced with the implementation in List.h.
|
@ -1,57 +0,0 @@
|
||||
# New `vtkm::List` features
|
||||
|
||||
New features were added to those available in `vtkm/List.h`. These new
|
||||
features provide new operations on lists.
|
||||
|
||||
## Reductions
|
||||
|
||||
The new `vtkm::ListReduce` allows a reduction on a list. This template
|
||||
takes three arguments: a `vtkm::List`, an operation, and an initial value.
|
||||
The operation is itself a template that has two type arguments.
|
||||
|
||||
`vtkm::ListReduce` applies the initial value and the first item of the list
|
||||
to the operator. The result of that template is then iteratively applied to
|
||||
the operator with the next item in the list and so on.
|
||||
|
||||
``` cpp
|
||||
// Operation to use
|
||||
template <typename T1, typename T2>
|
||||
using Add = std::integral_constant<typename T1::type, T1::value + T2::value>;
|
||||
|
||||
using MyList = vtkm::List<std::integral_constant<int, 25>,
|
||||
std::integral_constant<int, 60>,
|
||||
std::integral_constant<int, 87>,
|
||||
std::integral_constant<int, 62>>;
|
||||
|
||||
using MySum = vtkm::ListReduce<MyList, Add, std::integral_constant<int, 0>>;
|
||||
// MySum becomes std::integral_constant<int, 234> (25+60+87+62 = 234)
|
||||
```
|
||||
|
||||
## All and Any
|
||||
|
||||
Because they are very common, two reductions that are automatically
|
||||
supported are `vtkm::ListAll` and `vtkm::ListAny`. These both take a
|
||||
`vtkm::List` containing either `std::true_type` or `std::false_type` (or
|
||||
some other "compatible" type that has a constant static `bool` named
|
||||
`value`). `vtkm::ListAll` will become `std::false_type` if any of the
|
||||
entries in the list are `std::false_type`. `vtkm::ListAny` becomes
|
||||
`std::true_type` if any of the entires in the list are `std::true_type`.
|
||||
|
||||
``` cpp
|
||||
using MyList = vtkm::List<std::integral_constant<int, 25>,
|
||||
std::integral_constant<int, 60>,
|
||||
std::integral_constant<int, 87>,
|
||||
std::integral_constant<int, 62>>;
|
||||
|
||||
template <typename T>
|
||||
using IsEven = std::integral_constant<bool, ((T % 2) == 0)>;
|
||||
|
||||
// Note that vtkm::ListTransform<MyList, IsEven> becomes
|
||||
// vtkm::List<std::false_type, std::true_type, std::false_type, std::true_type>
|
||||
|
||||
using AllEven = vtkm::ListAll<vtkm::ListTransform<MyList, IsEven>>;
|
||||
// AllEven becomes std::false_type
|
||||
|
||||
using AnyEven = vtkm::ListAny<vtkm::ListTransform<MyList, IsEven>>;
|
||||
// AnyEven becomes std::true_type
|
||||
```
|
@ -1,19 +0,0 @@
|
||||
# No longer use brigand.hpp
|
||||
|
||||
Remove brigand.hpp from VTK-m's source and all references to it. This was
|
||||
declared in an internal directory, so making this backward-incompatible
|
||||
changes should be OK.
|
||||
|
||||
Brigand is a third-party library to support template meta-programming. Over
|
||||
the years, we have had to make a few modifications to make sure it compiles
|
||||
with all compilers supported by VTK-m. Unfortunately, because brigand was
|
||||
added before our standard third-party library management was set up, these
|
||||
changes are not managed well. Thus, we cannot easily update with any
|
||||
changes from the project. Thus, our version is slowly diverging from the
|
||||
original, and maintaining it is a hassle.
|
||||
|
||||
Also, we have been using brigand less and less throughout the years. Now
|
||||
that we have moved on to C++11 (and now C++14) with variadic templates and
|
||||
other useful `std` features, the features of brigand have become less
|
||||
critical. Thus, we have implemented all the features we need from brigand
|
||||
internally and have moved our code away from using it.
|
@ -1,9 +0,0 @@
|
||||
# Fix compile when testing is turned off
|
||||
|
||||
There were some places in VTK-m's code that included test header files even
|
||||
though they were not tests. As more code goes into libraries, this can
|
||||
break the build.
|
||||
|
||||
Remove VTK-m library dependence on testing code where found. Also added a
|
||||
CI build that turns off all testing to check for this condition in the
|
||||
future.
|
@ -1,13 +0,0 @@
|
||||
# Perlin Noise source
|
||||
|
||||
A new source, `vtkm::source::PerlinNoise`, has been added. As the name
|
||||
would imply, this source generates a pseudo-random [Perlin
|
||||
noise](https://en.wikipedia.org/wiki/Perlin_noise) field.
|
||||
|
||||
The field is defined on a 3D grid of specified dimensions. A seed value can
|
||||
also be specified to enforce consistent results in, for example, test code.
|
||||
If a seed is not specified, one will be created based on the current system
|
||||
time.
|
||||
|
||||
Perlin noise is useful for testing purposes as it can create non-trivial
|
||||
geometry at pretty much any scale.
|
@ -1,20 +0,0 @@
|
||||
# Rename field associations
|
||||
|
||||
The symbols in `vtkm::cont::Field::Association` have been changed from
|
||||
`ANY`, `WHOLE_MESH`, `POINTS`, and `CELL_SET` to `Any`, `WholeMesh`,
|
||||
`Points`, and `Cells`, respectively. The reason for this change is twofold:
|
||||
|
||||
* The general standard that VTK-m follows for `enum struct` enumerators
|
||||
is to use camel case (with the first character capitalized), not all
|
||||
upper case.
|
||||
* The use of `CELL_SET` for fields associated with cells is obsolete. A
|
||||
`DataSet` used to support having more than one `CellSet`, and so a
|
||||
field association on cells was actually bound to a particular
|
||||
`CellSet`. However, that is no longer the case. A `DataSet` has exactly
|
||||
one `CellSet`, so a cell field no longer has to point to a `CellSet`.
|
||||
Thus the enumeration symbol for `Cells` should match the one for
|
||||
`Points`.
|
||||
|
||||
For backward compatibility, the old enumerations still exist. They are
|
||||
aliases for the new names, and they are marked as deprecated, so using them
|
||||
will result in a compiler warning (on some systems).
|
@ -1,65 +0,0 @@
|
||||
# Redesign of Render Regression Tests
|
||||
|
||||
The helper functions for creating the render regression tests have been
|
||||
reformulated. The main changes are outlined here.
|
||||
|
||||
## Helper functions are no longer templated
|
||||
|
||||
The principle change made is that the `RenderAndRegressionTest` has been
|
||||
changed to no longer require template arguments (which were used to specify
|
||||
which rendering components to use). However, using templated arguments
|
||||
requires each rendering test to entirely recompile the rendering code that
|
||||
it uses. Since the rendering code currently is itself templated, this leads
|
||||
to a significant amount of re-compilation.
|
||||
|
||||
As a side effect of this, the render helper function is now compiled into a
|
||||
new library, `vtkm_rendering_testing`. Once again, this allows multiple
|
||||
tests to use rendering without having to recompile the rendering code.
|
||||
|
||||
As part of the change, the name of the `RenderAndRegressionTest` function
|
||||
has been simplified to `RenderTest`.
|
||||
|
||||
## Use a more efficient device
|
||||
|
||||
It is common for the testing infrastructure to run the same test multiple
|
||||
times with different devices. Thus, a filter might be run once with the
|
||||
Kokkos backend and once with the Serial backend. However, even if the
|
||||
filter is being tested with the serial backend, there is no real reason to
|
||||
restrict the rendering to a serial process.
|
||||
|
||||
Thus, unless otherwise specified, the rendering will use whatever device is
|
||||
available regardless of what was requested for the test.
|
||||
|
||||
## Consolidate options into a struct
|
||||
|
||||
Before these changes, there were several options that could be provided to
|
||||
the render function, and these changes have added several more. The
|
||||
previous version of the render function specified each of these options as
|
||||
arguments to the function. However, that quickly became unwieldy as the
|
||||
number of options grows. Also, it was impossible to send options to the
|
||||
image comparison (which is called as a subprocess) such as threshold
|
||||
values.
|
||||
|
||||
## Move general testing methods to library
|
||||
|
||||
A side effect of these changes is that some more general testing methods
|
||||
have been moved to the `vtkm_cont_testing` library. Previously, all methods
|
||||
in the `vtkm::cont::testing::Testing` class were inlined in the header
|
||||
file. This makes sense for the methods that are templated, but not so much
|
||||
for methods that are not templated.
|
||||
|
||||
Although this change provides minimal improvements with compile times and
|
||||
object sizes (maybe). But the real benefit is that some of these methods
|
||||
declare static objects. When declared in inlined functions, a different
|
||||
object will be created for each translation unit. This can lead to
|
||||
unexpected behavior when multiple versions of a supposed singleton static
|
||||
object exist. In particular, this was causing a failure when the static
|
||||
objects holding testing directories was created by the test translation
|
||||
unit but was then unavailable to `vtkm_rendering_testing`.
|
||||
|
||||
## Expand test_equal_images
|
||||
|
||||
The `test_equal_images` function has been expanded to supply the generated
|
||||
image in a `Canvas` or a `DataSet` in addition to a `View`. Much of the
|
||||
templating code has been removed from `test_equal_images` and most of the
|
||||
code has moved into the `vtkm_rendering_testing` library.
|
@ -1,12 +0,0 @@
|
||||
# Favor scoped `enum`s
|
||||
|
||||
Several `enum` declarations were changed from a standard `enum` to a
|
||||
"scoped" `enum` (i.e. `enum struct`). The advantage of a scoped enum is
|
||||
that they provide better type safety because they won't be converted
|
||||
willy-nilly to other types. They also prevent the names they define from
|
||||
being accessible on the inner scope.
|
||||
|
||||
There are some cases where you do want the `enum` to convert to other types
|
||||
(but still want the scope of the symbols to be contained in the `enum`
|
||||
type). In this case, we worked around the problem by placing an unscoped
|
||||
`enum` inside of a standard `struct`.
|
@ -1,21 +0,0 @@
|
||||
# UnknownCellSet
|
||||
|
||||
The `DynamicCellSet` class has been replaced with `UnknownCellSet`.
|
||||
Likewise, the `DynamicCellSetBase` class (a templated version of
|
||||
`DynamicCellSet`) has been replaced with `UncertainCellSet`.
|
||||
|
||||
These changes principally follow the changes to the `UnknownArrayHandle`
|
||||
management class. The `ArrayHandle` version of a polymorphic manager has
|
||||
gone through several refinements from `DynamicArrayHandle` to
|
||||
`VariantArrayHandle` to its current form as `UnknownArrayHandle`.
|
||||
Throughout these improvements for `ArrayHandle`, the equivalent classes for
|
||||
`CellSet` have lagged behind. The `CellSet` version is decidedly simpler
|
||||
because `CellSet` itself is polymorphic, but there were definitely
|
||||
improvements to be had.
|
||||
|
||||
The biggest improvement was to remove the templating from the basic unknown
|
||||
cell set. The old `DynamicArrayHandle` was actually a type alias for
|
||||
`DynamicArrayHandleBase<VTKM_DEFAULT_CELL_SET_LIST>`. As
|
||||
`VTKM_DEFAULT_CELL_SET_LIST` tends to be pretty long, `DynamicArrayHandle`
|
||||
was actually a really long type. In contrast, `UnknownArrayHandle` is its
|
||||
own untemplated class and will show up in linker symbols as such.
|
@ -1,6 +0,0 @@
|
||||
# Add implementation of `VecTraits` for `Range` and `Bounds`
|
||||
|
||||
Added specializations of `vtkm::VecTraits` for the simple structures of
|
||||
`vtkm::Range` and `vtkm::Bounds`. This expands the support for using these
|
||||
structures in things like `ArrayHandle` and `UnknownArrayHandle`.
|
||||
|
@ -16,7 +16,4 @@ find_package(VTKm REQUIRED QUIET)
|
||||
if(TARGET vtkm_rendering)
|
||||
add_executable(Demo Demo.cxx)
|
||||
target_link_libraries(Demo PRIVATE vtkm_filter vtkm_rendering vtkm_source)
|
||||
vtkm_add_target_information(Demo
|
||||
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
|
||||
DEVICE_SOURCES Demo.cxx)
|
||||
endif()
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include <vtkm/filter/vector_analysis/Gradient.h>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -14,10 +14,6 @@ include(CTest)
|
||||
|
||||
find_package(VTKm REQUIRED)
|
||||
|
||||
if (VTKm_VERSION VERSION_LESS 1.7)
|
||||
message(FATAL_ERROR "Requires VTK-m 1.7 or newer")
|
||||
endif()
|
||||
|
||||
add_executable(smoke_test smoke_test.cxx)
|
||||
target_link_libraries(smoke_test PRIVATE vtkm_source)
|
||||
|
||||
|
@ -1 +1 @@
|
||||
1.7.1
|
||||
1.8.0-rc1
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#include <vtkm/internal/Meta.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
|
@ -45,6 +45,7 @@ set(deprecated_headers
|
||||
PointAverage.h
|
||||
PointElevation.h
|
||||
PointTransform.h
|
||||
Probe.h
|
||||
Slice.h
|
||||
SplitSharpEdges.h
|
||||
SurfaceNormals.h
|
||||
@ -106,7 +107,6 @@ set(extra_headers
|
||||
ParticleAdvection.h
|
||||
Pathline.h
|
||||
PathParticle.h
|
||||
Probe.h
|
||||
Streamline.h
|
||||
StreamSurface.h
|
||||
)
|
||||
@ -122,7 +122,6 @@ set(extra_header_template_sources
|
||||
ParticleAdvection.hxx
|
||||
Pathline.hxx
|
||||
PathParticle.hxx
|
||||
Probe.hxx
|
||||
Streamline.hxx
|
||||
StreamSurface.hxx
|
||||
)
|
||||
@ -200,6 +199,7 @@ add_subdirectory(field_conversion)
|
||||
add_subdirectory(field_transform)
|
||||
add_subdirectory(geometry_refinement)
|
||||
add_subdirectory(mesh_info)
|
||||
add_subdirectory(resampling)
|
||||
add_subdirectory(vector_analysis)
|
||||
add_subdirectory(zfp)
|
||||
|
||||
|
@ -420,9 +420,6 @@ protected:
|
||||
const vtkm::cont::PartitionedDataSet& inData);
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
|
||||
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
||||
vtkm::cont::DataSet& output,
|
||||
@ -438,6 +435,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
virtual vtkm::Id DetermineNumberOfThreads(const vtkm::cont::PartitionedDataSet& input);
|
||||
|
||||
|
||||
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
||||
bool RunFilterWithMultipleThreads = false;
|
||||
};
|
||||
|
@ -10,53 +10,23 @@
|
||||
#ifndef vtk_m_filter_Probe_h
|
||||
#define vtk_m_filter_Probe_h
|
||||
|
||||
#include <vtkm/filter/FilterDataSet.h>
|
||||
#include <vtkm/worklet/Probe.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/resampling //Probe.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
class Probe : public vtkm::filter::FilterDataSet<Probe>
|
||||
VTKM_DEPRECATED(1.8, "Use vtkm/filter/resampling/Probe.h instead of vtkm/filter/Probe.h.")
|
||||
inline void Probe_deprecated() {}
|
||||
|
||||
inline void Probe_deprecated_warning()
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
void SetGeometry(const vtkm::cont::DataSet& geometry);
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& GetGeometry() const;
|
||||
|
||||
VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; }
|
||||
VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; }
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
//Map a new field onto the resulting dataset after running the filter
|
||||
//this call is only valid after calling DoExecute.
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>);
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||
|
||||
private:
|
||||
vtkm::cont::DataSet Geometry;
|
||||
vtkm::worklet::Probe Worklet;
|
||||
vtkm::Float64 InvalidValue = vtkm::Nan64();
|
||||
};
|
||||
Probe_deprecated();
|
||||
}
|
||||
} // vtkm::filter
|
||||
|
||||
#ifndef vtk_m_filter_Probe_hxx
|
||||
#include <vtkm/filter/Probe.hxx>
|
||||
#endif
|
||||
}
|
||||
} // namespace vtkm::filter
|
||||
|
||||
#endif // vtk_m_filter_Probe_h
|
||||
#endif //vtk_m_filter_Probe_h
|
||||
|
@ -1,111 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_Probe_hxx
|
||||
#define vtk_m_filter_Probe_hxx
|
||||
|
||||
#include <vtkm/filter/Probe.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
|
||||
#include <vtkm/cont/internal/CastInvalidValue.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
inline void Probe::SetGeometry(const vtkm::cont::DataSet& geometry)
|
||||
{
|
||||
this->Geometry = vtkm::cont::DataSet();
|
||||
this->Geometry.SetCellSet(geometry.GetCellSet());
|
||||
this->Geometry.AddCoordinateSystem(geometry.GetCoordinateSystem());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
inline const vtkm::cont::DataSet& Probe::GetGeometry() const
|
||||
{
|
||||
return this->Geometry;
|
||||
}
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
|
||||
const vtkm::cont::DataSet& input,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this),
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
||||
this->Geometry.GetCoordinateSystem().GetData());
|
||||
|
||||
auto output = this->Geometry;
|
||||
auto hpf = this->Worklet.GetHiddenPointsField();
|
||||
auto hcf = this->Worklet.GetHiddenCellsField(
|
||||
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy, *this));
|
||||
|
||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
|
||||
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
VTKM_CONT inline bool Probe::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
// If the field is a point field, then we need to do a custom interpolation of the points.
|
||||
// In this case, we need to call the superclass's MapFieldOntoOutput, which will in turn
|
||||
// call our DoMapField.
|
||||
return this->FilterDataSet<Probe>::MapFieldOntoOutput(result, field, policy);
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
vtkm::cont::Field outField;
|
||||
if (vtkm::filter::MapFieldPermutation(
|
||||
field, this->Worklet.GetCellIds(), outField, this->InvalidValue))
|
||||
{
|
||||
// output field should be associated with points
|
||||
outField = vtkm::cont::Field(
|
||||
field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData());
|
||||
result.AddField(outField);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename StorageType, typename DerivedPolicy>
|
||||
VTKM_CONT inline bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::ArrayHandle<T, StorageType>& input,
|
||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||
{
|
||||
VTKM_ASSERT(fieldMeta.IsPointField());
|
||||
auto fieldArray =
|
||||
this->Worklet.ProcessPointField(input,
|
||||
vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue),
|
||||
typename DerivedPolicy::AllCellSetList());
|
||||
result.AddField(fieldMeta.AsField(fieldArray));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // vtkm::filter
|
||||
#endif
|
@ -23,30 +23,7 @@ namespace density_estimate
|
||||
class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityBase : public vtkm::filter::NewFilterField
|
||||
{
|
||||
protected:
|
||||
ParticleDensityBase(const vtkm::Id3& dimension,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing)
|
||||
: Dimension(dimension)
|
||||
, Origin(origin)
|
||||
, Spacing(spacing)
|
||||
, ComputeNumberDensity(false)
|
||||
, DivideByVolume(true)
|
||||
{
|
||||
}
|
||||
|
||||
ParticleDensityBase(const vtkm::Id3& dimension, const vtkm::Bounds& bounds)
|
||||
: Dimension(dimension)
|
||||
, Origin({ static_cast<vtkm::FloatDefault>(bounds.X.Min),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Y.Min),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Z.Min) })
|
||||
, Spacing(vtkm::Vec3f{ static_cast<vtkm::FloatDefault>(bounds.X.Length()),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Y.Length()),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Z.Length()) } /
|
||||
Dimension)
|
||||
, ComputeNumberDensity(false)
|
||||
, DivideByVolume(true)
|
||||
{
|
||||
}
|
||||
ParticleDensityBase() = default;
|
||||
|
||||
public:
|
||||
VTKM_CONT void SetComputeNumberDensity(bool yes) { this->ComputeNumberDensity = yes; }
|
||||
@ -57,16 +34,64 @@ public:
|
||||
|
||||
VTKM_CONT bool GetDivideByVolume() const { return this->DivideByVolume; }
|
||||
|
||||
///@{
|
||||
/// @brief The number of bins in the grid used as regions to estimate density.
|
||||
///
|
||||
/// To estimate particle density, this filter defines a uniform grid in space. The
|
||||
/// `Dimension` is the number of grid particles in each direction.
|
||||
///
|
||||
VTKM_CONT void SetDimension(const vtkm::Id3& dimension) { this->Dimension = dimension; }
|
||||
VTKM_CONT vtkm::Id3 GetDimension() const { return this->Dimension; }
|
||||
///@}
|
||||
|
||||
///@{
|
||||
/// @brief The lower-left (minimum) corner of the domain of density estimation.
|
||||
///
|
||||
VTKM_CONT void SetOrigin(const vtkm::Vec3f& origin) { this->Origin = origin; }
|
||||
VTKM_CONT vtkm::Vec3f GetOrigin() const { return this->Origin; }
|
||||
///@}
|
||||
|
||||
///@{
|
||||
/// @brief The spacing of the grid points used to form the grid for density estimation.
|
||||
///
|
||||
VTKM_CONT void SetSpacing(const vtkm::Vec3f& spacing) { this->Spacing = spacing; }
|
||||
VTKM_CONT vtkm::Vec3f GetSpacing() const { return this->Spacing; }
|
||||
///@}
|
||||
|
||||
///@{
|
||||
/// @brief The bounds of the region where density estimation occurs.
|
||||
///
|
||||
/// The dimensions must be set before the bounds are set. Calling `SetDimension`
|
||||
/// will change the ranges of the bounds.
|
||||
///
|
||||
VTKM_CONT void SetBounds(const vtkm::Bounds& bounds)
|
||||
{
|
||||
this->Origin = { static_cast<vtkm::FloatDefault>(bounds.X.Min),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Y.Min),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Z.Min) };
|
||||
this->Spacing = (vtkm::Vec3f{ static_cast<vtkm::FloatDefault>(bounds.X.Length()),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Y.Length()),
|
||||
static_cast<vtkm::FloatDefault>(bounds.Z.Length()) } /
|
||||
Dimension);
|
||||
}
|
||||
VTKM_CONT vtkm::Bounds GetBounds() const
|
||||
{
|
||||
return { { this->Origin[0], this->Origin[0] + (this->Spacing[0] * this->Dimension[0]) },
|
||||
{ this->Origin[1], this->Origin[1] + (this->Spacing[1] * this->Dimension[1]) },
|
||||
{ this->Origin[2], this->Origin[2] + (this->Spacing[2] * this->Dimension[2]) } };
|
||||
}
|
||||
///@}
|
||||
|
||||
protected:
|
||||
// Note: we are using the paradoxical "const ArrayHandle&" parameter whose content can actually
|
||||
// be change by the function.
|
||||
VTKM_CONT void DoDivideByVolume(const vtkm::cont::UnknownArrayHandle& array) const;
|
||||
|
||||
vtkm::Id3 Dimension; // Cell dimension
|
||||
vtkm::Vec3f Origin;
|
||||
vtkm::Vec3f Spacing;
|
||||
bool ComputeNumberDensity;
|
||||
bool DivideByVolume;
|
||||
vtkm::Id3 Dimension = { 100, 100, 100 }; // Cell dimension
|
||||
vtkm::Vec3f Origin = { 0.0f, 0.0f, 0.0f };
|
||||
vtkm::Vec3f Spacing = { 1.0f, 1.0f, 1.0f };
|
||||
bool ComputeNumberDensity = false;
|
||||
bool DivideByVolume = true;
|
||||
};
|
||||
} // namespace density_estimate
|
||||
} // namespace filter
|
||||
|
@ -75,14 +75,17 @@ namespace density_estimate
|
||||
VTKM_CONT ParticleDensityCloudInCell::ParticleDensityCloudInCell(const vtkm::Id3& dimension,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing)
|
||||
: Superclass(dimension, origin, spacing)
|
||||
{
|
||||
this->SetDimension(dimension);
|
||||
this->SetOrigin(origin);
|
||||
this->SetSpacing(spacing);
|
||||
}
|
||||
|
||||
VTKM_CONT ParticleDensityCloudInCell::ParticleDensityCloudInCell(const Id3& dimension,
|
||||
const vtkm::Bounds& bounds)
|
||||
: Superclass(dimension, bounds)
|
||||
{
|
||||
this->SetDimension(dimension);
|
||||
this->SetBounds(bounds);
|
||||
}
|
||||
|
||||
VTKM_CONT vtkm::cont::DataSet ParticleDensityCloudInCell::DoExecute(const cont::DataSet& input)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#ifndef vtk_m_filter_density_estimate_ParticleDensityCIC_h
|
||||
#define vtk_m_filter_density_estimate_ParticleDensityCIC_h
|
||||
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/filter/density_estimate/ParticleDensityBase.h>
|
||||
|
||||
namespace vtkm
|
||||
@ -40,10 +41,14 @@ class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityCloudInCell : public Pa
|
||||
public:
|
||||
using Superclass = ParticleDensityBase;
|
||||
|
||||
ParticleDensityCloudInCell() = default;
|
||||
|
||||
VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.")
|
||||
ParticleDensityCloudInCell(const vtkm::Id3& dimension,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing);
|
||||
|
||||
VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.")
|
||||
ParticleDensityCloudInCell(const Id3& dimension, const vtkm::Bounds& bounds);
|
||||
|
||||
private:
|
||||
|
@ -58,15 +58,18 @@ VTKM_CONT ParticleDensityNearestGridPoint::ParticleDensityNearestGridPoint(
|
||||
const vtkm::Id3& dimension,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing)
|
||||
: Superclass(dimension, origin, spacing)
|
||||
{
|
||||
this->SetDimension(dimension);
|
||||
this->SetOrigin(origin);
|
||||
this->SetSpacing(spacing);
|
||||
}
|
||||
|
||||
VTKM_CONT ParticleDensityNearestGridPoint::ParticleDensityNearestGridPoint(
|
||||
const Id3& dimension,
|
||||
const vtkm::Bounds& bounds)
|
||||
: Superclass(dimension, bounds)
|
||||
{
|
||||
this->SetDimension(dimension);
|
||||
this->SetBounds(bounds);
|
||||
}
|
||||
|
||||
VTKM_CONT vtkm::cont::DataSet ParticleDensityNearestGridPoint::DoExecute(
|
||||
|
@ -40,10 +40,14 @@ class VTKM_FILTER_DENSITY_ESTIMATE_EXPORT ParticleDensityNearestGridPoint
|
||||
public:
|
||||
using Superclass = ParticleDensityBase;
|
||||
|
||||
ParticleDensityNearestGridPoint() = default;
|
||||
|
||||
VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.")
|
||||
ParticleDensityNearestGridPoint(const vtkm::Id3& dimension,
|
||||
const vtkm::Vec3f& origin,
|
||||
const vtkm::Vec3f& spacing);
|
||||
|
||||
VTKM_DEPRECATED(1.9, "Use default constructor and `Set*` accessors.")
|
||||
ParticleDensityNearestGridPoint(const vtkm::Id3& dimension, const vtkm::Bounds& bounds);
|
||||
|
||||
private:
|
||||
|
@ -42,11 +42,15 @@ void TestNGP()
|
||||
vtkm::cont::ArrayHandleRandomUniformReal<vtkm::FloatDefault>(N, 0xd1ce), mass);
|
||||
dataSet.AddCellField("mass", mass);
|
||||
|
||||
auto cellDims = vtkm::Id3{ 3, 3, 3 };
|
||||
vtkm::filter::density_estimate::ParticleDensityNearestGridPoint filter{
|
||||
cellDims, { 0.f, 0.f, 0.f }, vtkm::Vec3f{ 1.f / 3.f, 1.f / 3.f, 1.f / 3.f }
|
||||
};
|
||||
vtkm::Id3 cellDims = { 3, 3, 3 };
|
||||
vtkm::Bounds bounds = { { 0, 1 }, { 0, 1 }, { 0, 1 } };
|
||||
vtkm::filter::density_estimate::ParticleDensityNearestGridPoint filter;
|
||||
filter.SetDimension(cellDims);
|
||||
filter.SetBounds(bounds);
|
||||
filter.SetActiveField("mass");
|
||||
VTKM_TEST_ASSERT(test_equal(filter.GetBounds(), bounds));
|
||||
VTKM_TEST_ASSERT(test_equal(filter.GetOrigin(), vtkm::make_Vec(0, 0, 0)));
|
||||
VTKM_TEST_ASSERT(test_equal(filter.GetSpacing(), vtkm::make_Vec(0.33333, 0.33333, 0.33333)));
|
||||
auto density = filter.Execute(dataSet);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> field;
|
||||
@ -93,10 +97,17 @@ void TestCIC()
|
||||
mass);
|
||||
dataSet.AddCellField("mass", mass);
|
||||
|
||||
auto cellDims = vtkm::Id3{ 3, 3, 3 };
|
||||
vtkm::filter::density_estimate::ParticleDensityCloudInCell filter{
|
||||
cellDims, { 0.f, 0.f, 0.f }, vtkm::Vec3f{ 1.f / 3.f, 1.f / 3.f, 1.f / 3.f }
|
||||
};
|
||||
vtkm::Id3 cellDims = { 3, 3, 3 };
|
||||
vtkm::Vec3f origin = { 0.f, 0.f, 0.f };
|
||||
vtkm::Vec3f spacing = { 1.f / 3.f, 1.f / 3.f, 1.f / 3.f };
|
||||
vtkm::Bounds bounds = { { 0, 1 }, { 0, 1 }, { 0, 1 } };
|
||||
vtkm::filter::density_estimate::ParticleDensityCloudInCell filter;
|
||||
filter.SetDimension(cellDims);
|
||||
filter.SetOrigin(origin);
|
||||
filter.SetSpacing(spacing);
|
||||
VTKM_TEST_ASSERT(test_equal(filter.GetOrigin(), origin));
|
||||
VTKM_TEST_ASSERT(test_equal(filter.GetSpacing(), spacing));
|
||||
VTKM_TEST_ASSERT(test_equal(filter.GetBounds(), bounds));
|
||||
filter.SetActiveField("mass");
|
||||
auto density = filter.Execute(dataSet);
|
||||
|
||||
|
@ -105,7 +105,7 @@ VTKM_CONT FieldToColors::FieldToColors(const vtkm::cont::ColorTable& table)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT void FieldToColors::SetNumberOfSamplingPoints(vtkm::Int32 count)
|
||||
VTKM_CONT void FieldToColors::SetNumberOfSamplingPoints(vtkm::Int32 count)
|
||||
{
|
||||
if (this->SampleCount != count && count > 0)
|
||||
{
|
||||
|
@ -25,13 +25,13 @@ VTKM_CONT PointTransform::PointTransform()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT void PointTransform::SetChangeCoordinateSystem(bool flag)
|
||||
VTKM_CONT void PointTransform::SetChangeCoordinateSystem(bool flag)
|
||||
{
|
||||
this->ChangeCoordinateSystem = flag;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VTKM_CONT bool PointTransform::GetChangeCoordinateSystem() const
|
||||
VTKM_CONT bool PointTransform::GetChangeCoordinateSystem() const
|
||||
{
|
||||
return this->ChangeCoordinateSystem;
|
||||
}
|
||||
|
@ -102,10 +102,11 @@ void TestPointTransformTranslation(const vtkm::cont::DataSet& ds, const vtkm::Ve
|
||||
|
||||
filter.SetOutputFieldName("translation");
|
||||
filter.SetTranslation(trans);
|
||||
VTKM_TEST_ASSERT(filter.GetChangeCoordinateSystem() == true);
|
||||
vtkm::cont::DataSet result = filter.Execute(ds);
|
||||
|
||||
ValidatePointTransform(
|
||||
ds.GetCoordinateSystem(), "translation", result, Transform3DTranslate(trans));
|
||||
ds.GetCoordinateSystem(), "translation", result, vtkm::Transform3DTranslate(trans));
|
||||
}
|
||||
|
||||
void TestPointTransformScale(const vtkm::cont::DataSet& ds, const vtkm::Vec3f& scale)
|
||||
@ -114,9 +115,10 @@ void TestPointTransformScale(const vtkm::cont::DataSet& ds, const vtkm::Vec3f& s
|
||||
|
||||
filter.SetOutputFieldName("scale");
|
||||
filter.SetScale(scale);
|
||||
filter.SetChangeCoordinateSystem(true);
|
||||
vtkm::cont::DataSet result = filter.Execute(ds);
|
||||
|
||||
ValidatePointTransform(ds.GetCoordinateSystem(), "scale", result, Transform3DScale(scale));
|
||||
ValidatePointTransform(ds.GetCoordinateSystem(), "scale", result, vtkm::Transform3DScale(scale));
|
||||
}
|
||||
|
||||
void TestPointTransformRotation(const vtkm::cont::DataSet& ds,
|
||||
@ -130,7 +132,19 @@ void TestPointTransformRotation(const vtkm::cont::DataSet& ds,
|
||||
vtkm::cont::DataSet result = filter.Execute(ds);
|
||||
|
||||
ValidatePointTransform(
|
||||
ds.GetCoordinateSystem(), "rotation", result, Transform3DRotate(angle, axis));
|
||||
ds.GetCoordinateSystem(), "rotation", result, vtkm::Transform3DRotate(angle, axis));
|
||||
}
|
||||
|
||||
void TestPointTransformGeneral(const vtkm::cont::DataSet& ds,
|
||||
const vtkm::Matrix<vtkm::FloatDefault, 4, 4>& transform)
|
||||
{
|
||||
vtkm::filter::field_transform::PointTransform filter;
|
||||
|
||||
auto fieldName = filter.GetOutputFieldName();
|
||||
filter.SetTransform(transform);
|
||||
vtkm::cont::DataSet result = filter.Execute(ds);
|
||||
|
||||
ValidatePointTransform(ds.GetCoordinateSystem(), fieldName, result, transform);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,6 +204,14 @@ void TestPointTransform()
|
||||
for (auto& angle : angles)
|
||||
for (auto& axe : axes)
|
||||
TestPointTransformRotation(ds, angle, axe);
|
||||
|
||||
//Test general
|
||||
auto transform = vtkm::Transform3DTranslate(vtkm::Vec3f{ 1, 1, 1 });
|
||||
transform =
|
||||
vtkm::MatrixMultiply(transform, vtkm::Transform3DScale(static_cast<vtkm::FloatDefault>(1.5f)));
|
||||
transform = vtkm::MatrixMultiply(transform,
|
||||
vtkm::Transform3DRotateX(static_cast<vtkm::FloatDefault>(90.f)));
|
||||
TestPointTransformGeneral(ds, transform);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace
|
||||
//the output dataset fields
|
||||
const std::map<CellMetric, std::string> MetricNames = {
|
||||
{ CellMetric::Area, "area" },
|
||||
{ CellMetric::AspectGama, "aspectGamma" },
|
||||
{ CellMetric::AspectGamma, "aspectGamma" },
|
||||
{ CellMetric::AspectRatio, "aspectRatio" },
|
||||
{ CellMetric::Condition, "condition" },
|
||||
{ CellMetric::DiagonalRatio, "diagonalRatio" },
|
||||
@ -144,7 +144,7 @@ vtkm::filter::mesh_info::CellMetric MeshQuality::ConvertCellMetric(
|
||||
case vtkm::filter::CellMetric::AREA:
|
||||
return vtkm::filter::mesh_info::CellMetric::Area;
|
||||
case vtkm::filter::CellMetric::ASPECT_GAMMA:
|
||||
return vtkm::filter::mesh_info::CellMetric::AspectGama;
|
||||
return vtkm::filter::mesh_info::CellMetric::AspectGamma;
|
||||
case vtkm::filter::CellMetric::ASPECT_RATIO:
|
||||
return vtkm::filter::mesh_info::CellMetric::AspectRatio;
|
||||
case vtkm::filter::CellMetric::CONDITION:
|
||||
|
@ -34,7 +34,7 @@ namespace mesh_info
|
||||
enum struct CellMetric
|
||||
{
|
||||
Area,
|
||||
AspectGama,
|
||||
AspectGamma,
|
||||
AspectRatio,
|
||||
Condition,
|
||||
DiagonalRatio,
|
||||
@ -132,8 +132,8 @@ enum struct VTKM_DEPRECATED(1.8 "Use vtkm::filter::mesh_info::CellMetric.") Cell
|
||||
EMPTY
|
||||
};
|
||||
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::MeshQuality.") MeshQuality
|
||||
: public vtkm::filter::mesh_info::MeshQuality
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::MeshQuality.")
|
||||
VTKM_FILTER_MESH_INFO_EXPORT MeshQuality : public vtkm::filter::mesh_info::MeshQuality
|
||||
{
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
static vtkm::filter::mesh_info::CellMetric ConvertCellMetric(
|
||||
|
@ -221,7 +221,7 @@ int TestMeshQuality()
|
||||
inputs.push_back(singleTypeInput);
|
||||
|
||||
expectedValues.push_back(FloatVec{ 0, 0, 1.52012f, 0, 0, 0 });
|
||||
metrics.push_back(vtkm::filter::mesh_info::CellMetric::AspectGama);
|
||||
metrics.push_back(vtkm::filter::mesh_info::CellMetric::AspectGamma);
|
||||
metricName.emplace_back("aspectGamma");
|
||||
inputs.push_back(explicitInput);
|
||||
|
||||
|
@ -121,7 +121,7 @@ private:
|
||||
if (dims != 2)
|
||||
metricValue = 0.;
|
||||
break;
|
||||
case vtkm::filter::mesh_info::CellMetric::AspectGama:
|
||||
case vtkm::filter::mesh_info::CellMetric::AspectGamma:
|
||||
metricValue =
|
||||
vtkm::worklet::cellmetrics::CellAspectGammaMetric<OutType>(numPts, pts, tag, ec);
|
||||
break;
|
||||
|
32
vtkm/filter/resampling/CMakeLists.txt
Normal file
32
vtkm/filter/resampling/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
##============================================================================
|
||||
## Copyright (c) Kitware, Inc.
|
||||
## All rights reserved.
|
||||
## See LICENSE.txt for details.
|
||||
##
|
||||
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
set(resampling_headers
|
||||
Probe.h
|
||||
)
|
||||
|
||||
set(resampling_sources
|
||||
Probe.cxx)
|
||||
|
||||
vtkm_library(
|
||||
NAME vtkm_filter_resampling
|
||||
HEADERS ${resampling_headers}
|
||||
DEVICE_SOURCES ${resampling_sources}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_filter_resampling PUBLIC vtkm_worklet vtkm_filter_core)
|
||||
target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_resampling)
|
||||
|
||||
add_subdirectory(worklet)
|
||||
|
||||
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
||||
if (VTKm_ENABLE_TESTING)
|
||||
add_subdirectory(testing)
|
||||
endif ()
|
83
vtkm/filter/resampling/Probe.cxx
Normal file
83
vtkm/filter/resampling/Probe.cxx
Normal file
@ -0,0 +1,83 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/cont/internal/CastInvalidValue.h>
|
||||
|
||||
#include <vtkm/filter/MapFieldPermutation.h>
|
||||
#include <vtkm/filter/resampling/Probe.h>
|
||||
#include <vtkm/filter/resampling/worklet/Probe.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace filter
|
||||
{
|
||||
namespace resampling
|
||||
{
|
||||
vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
vtkm::worklet::Probe worklet;
|
||||
worklet.Run(input.GetCellSet(),
|
||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
||||
this->Geometry.GetCoordinateSystem().GetData());
|
||||
|
||||
auto mapper = [&](auto& outDataSet, const auto& f) { this->DoMapField(outDataSet, f, worklet); };
|
||||
auto output = this->CreateResult(
|
||||
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper);
|
||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField()));
|
||||
output.AddField(
|
||||
vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet())));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
bool Probe::DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::worklet::Probe& worklet)
|
||||
{
|
||||
if (field.IsFieldPoint())
|
||||
{
|
||||
auto resolve = [&](const auto& concrete) {
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
vtkm::cont::ArrayHandle<T> outputArray = worklet.ProcessPointField(
|
||||
concrete, vtkm::cont::internal::CastInvalidValue<T>(this->InvalidValue));
|
||||
result.AddPointField(field.GetName(), outputArray);
|
||||
};
|
||||
field.GetData()
|
||||
.CastAndCallForTypesWithFloatFallback<vtkm::TypeListField, VTKM_DEFAULT_STORAGE_LIST>(
|
||||
resolve);
|
||||
return true;
|
||||
}
|
||||
else if (field.IsFieldCell())
|
||||
{
|
||||
vtkm::cont::Field outField;
|
||||
if (vtkm::filter::MapFieldPermutation(
|
||||
field, worklet.GetCellIds(), outField, this->InvalidValue))
|
||||
{
|
||||
// output field should be associated with points
|
||||
outField = vtkm::cont::Field(
|
||||
field.GetName(), vtkm::cont::Field::Association::Points, outField.GetData());
|
||||
result.AddField(outField);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (field.IsFieldGlobal())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace resampling
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
65
vtkm/filter/resampling/Probe.h
Normal file
65
vtkm/filter/resampling/Probe.h
Normal file
@ -0,0 +1,65 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_filter_Probe_h
|
||||
#define vtk_m_filter_Probe_h
|
||||
|
||||
#include <vtkm/filter/NewFilterField.h>
|
||||
#include <vtkm/filter/resampling/vtkm_filter_resampling_export.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
{
|
||||
class Probe;
|
||||
}
|
||||
|
||||
namespace filter
|
||||
{
|
||||
namespace resampling
|
||||
{
|
||||
class VTKM_FILTER_RESAMPLING_EXPORT Probe : public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
void SetGeometry(const vtkm::cont::DataSet& geometry)
|
||||
{
|
||||
this->Geometry = vtkm::cont::DataSet();
|
||||
this->Geometry.CopyStructure(geometry);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::DataSet& GetGeometry() const { return this->Geometry; }
|
||||
|
||||
VTKM_CONT void SetInvalidValue(vtkm::Float64 invalidValue) { this->InvalidValue = invalidValue; }
|
||||
VTKM_CONT vtkm::Float64 GetInvalidValue() const { return this->InvalidValue; }
|
||||
|
||||
private:
|
||||
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
||||
|
||||
bool DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::worklet::Probe& worklet);
|
||||
|
||||
vtkm::cont::DataSet Geometry;
|
||||
|
||||
vtkm::Float64 InvalidValue = vtkm::Nan64();
|
||||
};
|
||||
} // namespace resampling
|
||||
|
||||
class VTKM_DEPRECATED(1.8, "Use vtkm::filter::resampling::Probe.") Probe
|
||||
: public vtkm::filter::resampling::Probe
|
||||
{
|
||||
using resampling::Probe::Probe;
|
||||
};
|
||||
|
||||
} // namespace filter
|
||||
} // namespace vtkm
|
||||
|
||||
#endif // vtk_m_filter_Probe_h
|
24
vtkm/filter/resampling/testing/CMakeLists.txt
Normal file
24
vtkm/filter/resampling/testing/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
##============================================================================
|
||||
## Copyright (c) Kitware, Inc.
|
||||
## All rights reserved.
|
||||
## See LICENSE.txt for details.
|
||||
##
|
||||
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
|
||||
set(unit_tests
|
||||
UnitTestProbe.cxx
|
||||
)
|
||||
|
||||
set(libraries
|
||||
vtkm_filter_clean_grid
|
||||
vtkm_filter_resampling
|
||||
)
|
||||
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES ${libraries}
|
||||
USE_VTKM_JOB_POOL
|
||||
)
|
@ -7,13 +7,12 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/filter/Probe.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/worklet/CellDeepCopy.h>
|
||||
#include <vtkm/filter/clean_grid/CleanGrid.h>
|
||||
#include <vtkm/filter/resampling/Probe.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -46,22 +45,9 @@ vtkm::cont::DataSet MakeGeometryDataSet()
|
||||
|
||||
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
||||
{
|
||||
vtkm::cont::DataSet eds;
|
||||
vtkm::cont::CellSetExplicit<> cs;
|
||||
vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs);
|
||||
eds.SetCellSet(cs);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> points;
|
||||
vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points);
|
||||
eds.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points));
|
||||
|
||||
for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i)
|
||||
{
|
||||
eds.AddField(uds.GetField(i));
|
||||
}
|
||||
|
||||
return eds;
|
||||
vtkm::filter::clean_grid::CleanGrid toUnstructured;
|
||||
toUnstructured.SetMergePoints(true);
|
||||
return toUnstructured.Execute(uds);
|
||||
}
|
||||
|
||||
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
||||
@ -153,7 +139,7 @@ private:
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = MakeGeometryDataSet();
|
||||
|
||||
vtkm::filter::Probe probe;
|
||||
vtkm::filter::resampling::Probe probe;
|
||||
probe.SetGeometry(geometry);
|
||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||
auto output = probe.Execute(input);
|
||||
@ -175,7 +161,7 @@ private:
|
||||
auto input = MakeInputDataSet();
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::filter::Probe probe;
|
||||
vtkm::filter::resampling::Probe probe;
|
||||
probe.SetGeometry(geometry);
|
||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||
auto output = probe.Execute(input);
|
||||
@ -197,7 +183,7 @@ private:
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::filter::Probe probe;
|
||||
vtkm::filter::resampling::Probe probe;
|
||||
probe.SetGeometry(geometry);
|
||||
probe.SetFieldsToPass({ "pointdata", "celldata" });
|
||||
auto output = probe.Execute(input);
|
15
vtkm/filter/resampling/worklet/CMakeLists.txt
Normal file
15
vtkm/filter/resampling/worklet/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
##============================================================================
|
||||
## Copyright (c) Kitware, Inc.
|
||||
## All rights reserved.
|
||||
## See LICENSE.txt for details.
|
||||
##
|
||||
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
Probe.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
@ -25,21 +25,10 @@ set(unit_tests
|
||||
UnitTestMIRFilter.cxx
|
||||
UnitTestMultiBlockFilter.cxx
|
||||
UnitTestPartitionedDataSetFilters.cxx
|
||||
UnitTestProbe.cxx
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
)
|
||||
|
||||
#Taking too long to compile with HIPCC
|
||||
if(HIP IN_LIST Kokkos_DEVICES)
|
||||
list(REMOVE_ITEM unit_tests
|
||||
UnitTestLagrangianFilter.cxx
|
||||
UnitTestLagrangianStructuresFilter.cxx
|
||||
UnitTestStreamlineFilter.cxx
|
||||
UnitTestStreamSurfaceFilter.cxx
|
||||
)
|
||||
endif()
|
||||
|
||||
set(libraries
|
||||
vtkm_filter
|
||||
vtkm_io
|
||||
|
@ -89,34 +89,34 @@ struct StructuredPointGradient : public vtkm::worklet::WorkletPointNeighborhood
|
||||
if (boundary.IsRadiusInXBoundary(1))
|
||||
{
|
||||
auto dx = inputField.GetUnchecked(1, 0, 0) - inputField.GetUnchecked(-1, 0, 0);
|
||||
outputGradient[0] = static_cast<OT>(dx * (r[0] * 0.5f));
|
||||
outputGradient[0] = static_cast<OT>((dx * 0.5f) / r[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dx = inputField.Get(1, 0, 0) - inputField.Get(-1, 0, 0);
|
||||
outputGradient[0] = static_cast<OT>(dx * r[0]);
|
||||
outputGradient[0] = static_cast<OT>(dx / r[0]);
|
||||
}
|
||||
|
||||
if (boundary.IsRadiusInYBoundary(1))
|
||||
{
|
||||
auto dy = inputField.GetUnchecked(0, 1, 0) - inputField.GetUnchecked(0, -1, 0);
|
||||
outputGradient[1] = static_cast<OT>(dy * r[1] * 0.5f);
|
||||
outputGradient[1] = static_cast<OT>((dy * 0.5f) / r[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dy = inputField.Get(0, 1, 0) - inputField.Get(0, -1, 0);
|
||||
outputGradient[1] = static_cast<OT>(dy * (r[1]));
|
||||
outputGradient[1] = static_cast<OT>(dy / (r[1]));
|
||||
}
|
||||
|
||||
if (boundary.IsRadiusInZBoundary(1))
|
||||
{
|
||||
auto dz = inputField.GetUnchecked(0, 0, 1) - inputField.GetUnchecked(0, 0, -1);
|
||||
outputGradient[2] = static_cast<OT>(dz * r[2] * 0.5f);
|
||||
outputGradient[2] = static_cast<OT>((dz * 0.5f) / r[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dz = inputField.Get(0, 0, 1) - inputField.Get(0, 0, -1);
|
||||
outputGradient[2] = static_cast<OT>(dz * (r[2]));
|
||||
outputGradient[2] = static_cast<OT>(dz / (r[2]));
|
||||
}
|
||||
#if (defined(VTKM_CUDA) && defined(VTKM_GCC))
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -353,7 +353,7 @@ public:
|
||||
}; //class CalculateNormals
|
||||
|
||||
template <typename Precision>
|
||||
class GetScalar : public vtkm::worklet::WorkletMapField
|
||||
class GetLerpedScalar : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
Precision MinScalar;
|
||||
@ -361,8 +361,11 @@ private:
|
||||
bool Normalize;
|
||||
|
||||
public:
|
||||
using ControlSignature = void(FieldIn, FieldIn, FieldIn, FieldOut, WholeArrayIn, WholeArrayIn);
|
||||
using ExecutionSignature = void(_1, _2, _3, _4, _5, _6);
|
||||
|
||||
VTKM_CONT
|
||||
GetScalar(const vtkm::Float32& minScalar, const vtkm::Float32& maxScalar)
|
||||
GetLerpedScalar(const vtkm::Float32& minScalar, const vtkm::Float32& maxScalar)
|
||||
: MinScalar(minScalar)
|
||||
{
|
||||
Normalize = true;
|
||||
@ -379,8 +382,66 @@ public:
|
||||
this->InvDeltaScalar = 1.f / (maxScalar - MinScalar);
|
||||
}
|
||||
}
|
||||
typedef void ControlSignature(FieldIn, FieldOut, WholeArrayIn, WholeArrayIn);
|
||||
typedef void ExecutionSignature(_1, _2, _3, _4);
|
||||
template <typename ScalarPortalType, typename IndicesPortalType>
|
||||
VTKM_EXEC void operator()(const vtkm::Id& hitIndex,
|
||||
const Precision& u,
|
||||
const Precision& v,
|
||||
Precision& scalar,
|
||||
const ScalarPortalType& scalars,
|
||||
const IndicesPortalType& indicesPortal) const
|
||||
{
|
||||
if (hitIndex < 0)
|
||||
return;
|
||||
|
||||
vtkm::Vec<vtkm::Id, 5> pointId = indicesPortal.Get(hitIndex);
|
||||
|
||||
Precision aScalar = Precision(scalars.Get(pointId[1]));
|
||||
Precision bScalar = Precision(scalars.Get(pointId[2]));
|
||||
Precision cScalar = Precision(scalars.Get(pointId[3]));
|
||||
Precision dScalar = Precision(scalars.Get(pointId[4]));
|
||||
|
||||
Precision uP = 1.0f - u;
|
||||
Precision vP = 1.0f - v;
|
||||
scalar = uP * vP * aScalar + u * vP * bScalar + u * v * cScalar + uP * v * dScalar;
|
||||
|
||||
if (Normalize)
|
||||
{
|
||||
scalar = (scalar - MinScalar) * this->InvDeltaScalar;
|
||||
}
|
||||
}
|
||||
}; //class GetLerpedScalar
|
||||
|
||||
template <typename Precision>
|
||||
class GetNodalScalar : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
Precision MinScalar;
|
||||
Precision InvDeltaScalar;
|
||||
bool Normalize;
|
||||
|
||||
public:
|
||||
using ControlSignature = void(FieldIn, FieldOut, WholeArrayIn, WholeArrayIn);
|
||||
using ExecutionSignature = void(_1, _2, _3, _4);
|
||||
|
||||
VTKM_CONT
|
||||
GetNodalScalar(const vtkm::Float32& minScalar, const vtkm::Float32& maxScalar)
|
||||
: MinScalar(minScalar)
|
||||
{
|
||||
Normalize = true;
|
||||
if (minScalar >= maxScalar)
|
||||
{
|
||||
// support the scalar renderer
|
||||
Normalize = false;
|
||||
this->InvDeltaScalar = Precision(0.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Make sure the we don't divide by zero on
|
||||
//something like an iso-surface
|
||||
this->InvDeltaScalar = 1.f / (maxScalar - MinScalar);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ScalarPortalType, typename IndicesPortalType>
|
||||
VTKM_EXEC void operator()(const vtkm::Id& hitIndex,
|
||||
Precision& scalar,
|
||||
@ -390,7 +451,6 @@ public:
|
||||
if (hitIndex < 0)
|
||||
return;
|
||||
|
||||
//TODO: this should be interpolated?
|
||||
vtkm::Vec<vtkm::Id, 5> pointId = indicesPortal.Get(hitIndex);
|
||||
|
||||
scalar = Precision(scalars.Get(pointId[0]));
|
||||
@ -399,7 +459,7 @@ public:
|
||||
scalar = (scalar - MinScalar) * this->InvDeltaScalar;
|
||||
}
|
||||
}
|
||||
}; //class GetScalar
|
||||
}; //class GetNodalScalar
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@ -450,12 +510,28 @@ void QuadIntersector::IntersectionDataImp(Ray<Precision>& rays,
|
||||
vtkm::worklet::DispatcherMapField<detail::CalculateNormals>(detail::CalculateNormals())
|
||||
.Invoke(rays.HitIdx, rays.Dir, rays.NormalX, rays.NormalY, rays.NormalZ, CoordsHandle, QuadIds);
|
||||
|
||||
vtkm::worklet::DispatcherMapField<detail::GetScalar<Precision>>(
|
||||
detail::GetScalar<Precision>(vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)))
|
||||
.Invoke(rays.HitIdx,
|
||||
rays.Scalar,
|
||||
vtkm::rendering::raytracing::GetScalarFieldArray(scalarField),
|
||||
QuadIds);
|
||||
if (scalarField.IsFieldPoint())
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<detail::GetLerpedScalar<Precision>>(
|
||||
detail::GetLerpedScalar<Precision>(vtkm::Float32(scalarRange.Min),
|
||||
vtkm::Float32(scalarRange.Max)))
|
||||
.Invoke(rays.HitIdx,
|
||||
rays.U,
|
||||
rays.V,
|
||||
rays.Scalar,
|
||||
vtkm::rendering::raytracing::GetScalarFieldArray(scalarField),
|
||||
QuadIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<detail::GetNodalScalar<Precision>>(
|
||||
detail::GetNodalScalar<Precision>(vtkm::Float32(scalarRange.Min),
|
||||
vtkm::Float32(scalarRange.Max)))
|
||||
.Invoke(rays.HitIdx,
|
||||
rays.Scalar,
|
||||
vtkm::rendering::raytracing::GetScalarFieldArray(scalarField),
|
||||
QuadIds);
|
||||
}
|
||||
}
|
||||
|
||||
void QuadIntersector::IntersectionData(Ray<vtkm::Float32>& rays,
|
||||
|
@ -33,7 +33,6 @@ set(headers
|
||||
NDimsHistMarginalization.h
|
||||
Normalize.h
|
||||
ParticleAdvection.h
|
||||
Probe.h
|
||||
ScalarsToColors.h
|
||||
ScatterCounting.h
|
||||
ScatterIdentity.h
|
||||
|
@ -8,11 +8,8 @@
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##============================================================================
|
||||
|
||||
#Failing on HIP backend(crash)
|
||||
if(NOT HIP IN_LIST Kokkos_DEVICES)
|
||||
set(unit_tests
|
||||
UnitTestDispatcherBase.cxx
|
||||
set(unit_tests
|
||||
UnitTestDispatcherBase.cxx
|
||||
)
|
||||
|
||||
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)
|
||||
endif()
|
||||
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <vtkm/worklet/internal/WorkletBase.h>
|
||||
|
||||
#include <vtkm/cont/internal/Buffer.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
@ -111,45 +113,44 @@ namespace arg
|
||||
{
|
||||
|
||||
template <>
|
||||
struct TypeCheck<TestTypeCheckTag, std::vector<vtkm::Id>>
|
||||
struct TypeCheck<TestTypeCheckTag, vtkm::cont::internal::Buffer>
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template <typename Device>
|
||||
struct Transport<TestTransportTagIn, std::vector<vtkm::Id>, Device>
|
||||
struct Transport<TestTransportTagIn, vtkm::cont::internal::Buffer, Device>
|
||||
{
|
||||
using ExecObjectType = TestExecObjectIn;
|
||||
|
||||
VTKM_CONT
|
||||
ExecObjectType operator()(const std::vector<vtkm::Id>& contData,
|
||||
const std::vector<vtkm::Id>&,
|
||||
ExecObjectType operator()(const vtkm::cont::internal::Buffer& contData,
|
||||
const vtkm::cont::internal::Buffer&,
|
||||
vtkm::Id inputRange,
|
||||
vtkm::Id outputRange,
|
||||
vtkm::cont::Token&) const
|
||||
vtkm::cont::Token& token) const
|
||||
{
|
||||
VTKM_TEST_ASSERT(inputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
VTKM_TEST_ASSERT(outputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
return ExecObjectType(contData.data());
|
||||
return reinterpret_cast<const vtkm::Id*>(contData.ReadPointerDevice(Device{}, token));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Device>
|
||||
struct Transport<TestTransportTagOut, std::vector<vtkm::Id>, Device>
|
||||
struct Transport<TestTransportTagOut, vtkm::cont::internal::Buffer, Device>
|
||||
{
|
||||
using ExecObjectType = TestExecObjectOut;
|
||||
|
||||
VTKM_CONT
|
||||
ExecObjectType operator()(const std::vector<vtkm::Id>& contData,
|
||||
const std::vector<vtkm::Id>&,
|
||||
ExecObjectType operator()(const vtkm::cont::internal::Buffer& contData,
|
||||
const vtkm::cont::internal::Buffer&,
|
||||
vtkm::Id inputRange,
|
||||
vtkm::Id outputRange,
|
||||
vtkm::cont::Token&) const
|
||||
vtkm::cont::Token& token) const
|
||||
{
|
||||
VTKM_TEST_ASSERT(inputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
VTKM_TEST_ASSERT(outputRange == ARRAY_SIZE, "Got unexpected size in test transport.");
|
||||
auto ptr = const_cast<vtkm::Id*>(contData.data());
|
||||
return ExecObjectType(ptr);
|
||||
return reinterpret_cast<vtkm::Id*>(contData.WritePointerDevice(Device{}, token));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -283,15 +284,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline vtkm::Id SchedulingRange(const std::vector<T>& inputDomain)
|
||||
inline vtkm::Id SchedulingRange(const vtkm::cont::internal::Buffer& inputDomain)
|
||||
{
|
||||
return static_cast<vtkm::Id>(inputDomain.size());
|
||||
return static_cast<vtkm::Id>(inputDomain.GetNumberOfBytes() / sizeof(vtkm::Id));
|
||||
}
|
||||
template <typename T>
|
||||
inline vtkm::Id SchedulingRange(const std::vector<T>* const inputDomain)
|
||||
inline vtkm::Id SchedulingRange(const vtkm::cont::internal::Buffer* inputDomain)
|
||||
{
|
||||
return static_cast<vtkm::Id>(inputDomain->size());
|
||||
return static_cast<vtkm::Id>(inputDomain->GetNumberOfBytes() / sizeof(vtkm::Id));
|
||||
}
|
||||
|
||||
template <typename WorkletType>
|
||||
@ -345,28 +344,41 @@ void TestBasicInvoke()
|
||||
{
|
||||
std::cout << "Test basic invoke" << std::endl;
|
||||
std::cout << " Set up data." << std::endl;
|
||||
std::vector<vtkm::Id> inputArray(ARRAY_SIZE);
|
||||
std::vector<vtkm::Id> outputArray(ARRAY_SIZE);
|
||||
vtkm::cont::internal::Buffer inputBuffer;
|
||||
vtkm::cont::internal::Buffer outputBuffer;
|
||||
TestExecObjectType execObject;
|
||||
execObject.Value = EXPECTED_EXEC_OBJECT_VALUE;
|
||||
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
vtkm::cont::Token token;
|
||||
inputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
outputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
auto inputArray = reinterpret_cast<vtkm::Id*>(inputBuffer.WritePointerHost(token));
|
||||
auto outputArray = reinterpret_cast<vtkm::Id*>(outputBuffer.WritePointerHost(token));
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " Create and run dispatcher." << std::endl;
|
||||
TestDispatcher<TestWorklet> dispatcher;
|
||||
dispatcher.Invoke(inputArray, execObject, &outputArray);
|
||||
dispatcher.Invoke(inputBuffer, execObject, &outputBuffer);
|
||||
|
||||
std::cout << " Check output of invoke." << std::endl;
|
||||
i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(outputArray[i] == TestValue(index, vtkm::Id()) + 1000,
|
||||
"Got bad value from testing.");
|
||||
vtkm::cont::Token token;
|
||||
auto outputArray = reinterpret_cast<const vtkm::Id*>(outputBuffer.ReadPointerHost(token));
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
VTKM_TEST_ASSERT(outputArray[i] == TestValue(index, vtkm::Id()) + 1000,
|
||||
"Got bad value from testing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,23 +386,32 @@ void TestInvokeWithError()
|
||||
{
|
||||
std::cout << "Test invoke with error raised" << std::endl;
|
||||
std::cout << " Set up data." << std::endl;
|
||||
std::vector<vtkm::Id> inputArray(ARRAY_SIZE);
|
||||
std::vector<vtkm::Id> outputArray(ARRAY_SIZE);
|
||||
vtkm::cont::internal::Buffer inputBuffer;
|
||||
vtkm::cont::internal::Buffer outputBuffer;
|
||||
TestExecObjectType execObject;
|
||||
execObject.Value = EXPECTED_EXEC_OBJECT_VALUE;
|
||||
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, ++i)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
vtkm::cont::Token token;
|
||||
inputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
outputBuffer.SetNumberOfBytes(
|
||||
static_cast<vtkm::BufferSizeType>(ARRAY_SIZE * sizeof(vtkm::Id)), vtkm::CopyFlag::Off, token);
|
||||
auto inputArray = reinterpret_cast<vtkm::Id*>(inputBuffer.WritePointerHost(token));
|
||||
auto outputArray = reinterpret_cast<vtkm::Id*>(outputBuffer.WritePointerHost(token));
|
||||
std::size_t i = 0;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++, i++)
|
||||
{
|
||||
inputArray[i] = TestValue(index, vtkm::Id());
|
||||
outputArray[i] = static_cast<vtkm::Id>(0xDEADDEAD);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
std::cout << " Create and run dispatcher that raises error." << std::endl;
|
||||
TestDispatcher<TestErrorWorklet> dispatcher;
|
||||
dispatcher.Invoke(&inputArray, execObject, outputArray);
|
||||
dispatcher.Invoke(&inputBuffer, execObject, outputBuffer);
|
||||
VTKM_TEST_FAIL("Exception not thrown.");
|
||||
}
|
||||
catch (vtkm::cont::ErrorExecution& error)
|
||||
|
@ -29,7 +29,6 @@ set(unit_tests
|
||||
UnitTestNormalize.cxx
|
||||
UnitTestNDimsHistMarginalization.cxx
|
||||
UnitTestParticleAdvection.cxx
|
||||
UnitTestProbe.cxx
|
||||
UnitTestScalarsToColors.cxx
|
||||
UnitTestScatterAndMask.cxx
|
||||
UnitTestScatterCounting.cxx
|
||||
@ -53,13 +52,6 @@ set(unit_tests
|
||||
UnitTestWaveletCompressor.cxx
|
||||
)
|
||||
|
||||
if(HIP IN_LIST Kokkos_DEVICES)
|
||||
list(REMOVE_ITEM unit_tests
|
||||
UnitTestParticleAdvection.cxx # Taking too long to compile with HIPCC
|
||||
UnitTestScalarsToColors.cxx # Failing: incorrect results
|
||||
)
|
||||
endif()
|
||||
|
||||
vtkm_unit_tests(
|
||||
SOURCES ${unit_tests}
|
||||
LIBRARIES vtkm_source vtkm_worklet vtkm_filter vtkm_io
|
||||
|
@ -1,211 +0,0 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <vtkm/worklet/Probe.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/worklet/CellDeepCopy.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
vtkm::cont::DataSet MakeInputDataSet()
|
||||
{
|
||||
auto input = vtkm::cont::DataSetBuilderUniform::Create(
|
||||
vtkm::Id2(4, 4), vtkm::make_Vec(0.0f, 0.0f), vtkm::make_Vec(1.0f, 1.0f));
|
||||
input.AddPointField("pointdata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.3f, 16));
|
||||
input.AddCellField("celldata", vtkm::cont::make_ArrayHandleCounting(0.0f, 0.7f, 9));
|
||||
return input;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet MakeGeometryDataSet()
|
||||
{
|
||||
auto geometry = vtkm::cont::DataSetBuilderUniform::Create(
|
||||
vtkm::Id2(9, 9), vtkm::make_Vec(0.7f, 0.7f), vtkm::make_Vec(0.35f, 0.35f));
|
||||
return geometry;
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet ConvertDataSetUniformToExplicit(const vtkm::cont::DataSet& uds)
|
||||
{
|
||||
vtkm::cont::DataSet eds;
|
||||
|
||||
vtkm::cont::CellSetExplicit<> cs;
|
||||
vtkm::worklet::CellDeepCopy::Run(uds.GetCellSet(), cs);
|
||||
eds.SetCellSet(cs);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> points;
|
||||
vtkm::cont::ArrayCopy(uds.GetCoordinateSystem().GetData(), points);
|
||||
eds.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(uds.GetCoordinateSystem().GetName(), points));
|
||||
|
||||
for (vtkm::IdComponent i = 0; i < uds.GetNumberOfFields(); ++i)
|
||||
{
|
||||
eds.AddField(uds.GetField(i));
|
||||
}
|
||||
|
||||
return eds;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::Float32>& GetExpectedPointData()
|
||||
{
|
||||
static std::vector<vtkm::Float32> expected = {
|
||||
1.05f, 1.155f, 1.26f, 1.365f, 1.47f, 1.575f, 1.68f, 0.0f, 0.0f, 1.47f, 1.575f, 1.68f,
|
||||
1.785f, 1.89f, 1.995f, 2.1f, 0.0f, 0.0f, 1.89f, 1.995f, 2.1f, 2.205f, 2.31f, 2.415f,
|
||||
2.52f, 0.0f, 0.0f, 2.31f, 2.415f, 2.52f, 2.625f, 2.73f, 2.835f, 2.94f, 0.0f, 0.0f,
|
||||
2.73f, 2.835f, 2.94f, 3.045f, 3.15f, 3.255f, 3.36f, 0.0f, 0.0f, 3.15f, 3.255f, 3.36f,
|
||||
3.465f, 3.57f, 3.675f, 3.78f, 0.0f, 0.0f, 3.57f, 3.675f, 3.78f, 3.885f, 3.99f, 4.095f,
|
||||
4.2f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
||||
};
|
||||
return expected;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::Float32>& GetExpectedCellData()
|
||||
{
|
||||
static std::vector<vtkm::Float32> expected = {
|
||||
0.0f, 0.7f, 0.7f, 0.7f, 1.4f, 1.4f, 1.4f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f,
|
||||
3.5f, 3.5f, 0.0f, 0.0f, 2.1f, 2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 2.1f,
|
||||
2.8f, 2.8f, 2.8f, 3.5f, 3.5f, 3.5f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f,
|
||||
5.6f, 0.0f, 0.0f, 4.2f, 4.9f, 4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 4.2f, 4.9f,
|
||||
4.9f, 4.9f, 5.6f, 5.6f, 5.6f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
||||
};
|
||||
return expected;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::UInt8>& GetExpectedHiddenPoints()
|
||||
{
|
||||
static std::vector<vtkm::UInt8> expected = { 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2,
|
||||
2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
||||
return expected;
|
||||
}
|
||||
|
||||
const std::vector<vtkm::UInt8>& GetExpectedHiddenCells()
|
||||
{
|
||||
static std::vector<vtkm::UInt8> expected = { 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
||||
return expected;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TestResultArray(const vtkm::cont::ArrayHandle<T>& result, const std::vector<T>& expected)
|
||||
{
|
||||
vtkm::cont::printSummary_ArrayHandle(result, std::cout);
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
|
||||
"Incorrect field size");
|
||||
|
||||
auto portal = result.ReadPortal();
|
||||
vtkm::Id size = portal.GetNumberOfValues();
|
||||
for (vtkm::Id i = 0; i < size; ++i)
|
||||
{
|
||||
VTKM_TEST_ASSERT(test_equal(portal.Get(i), expected[static_cast<std::size_t>(i)]),
|
||||
"Incorrect field value");
|
||||
}
|
||||
}
|
||||
|
||||
class TestProbe
|
||||
{
|
||||
private:
|
||||
using FieldArrayType = vtkm::cont::ArrayHandleCounting<vtkm::Float32>;
|
||||
|
||||
static void ExplicitToUnifrom()
|
||||
{
|
||||
std::cout << "Testing Probe Explicit to Uniform:\n";
|
||||
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = MakeGeometryDataSet();
|
||||
|
||||
vtkm::worklet::Probe probe;
|
||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
||||
|
||||
auto pf = probe.ProcessPointField(
|
||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto cf = probe.ProcessCellField(
|
||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto hp = probe.GetHiddenPointsField();
|
||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
||||
|
||||
TestResultArray(pf, GetExpectedPointData());
|
||||
TestResultArray(cf, GetExpectedCellData());
|
||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
||||
TestResultArray(hc, GetExpectedHiddenCells());
|
||||
}
|
||||
|
||||
static void UniformToExplict()
|
||||
{
|
||||
std::cout << "Testing Probe Uniform to Explicit:\n";
|
||||
|
||||
auto input = MakeInputDataSet();
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::worklet::Probe probe;
|
||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
||||
|
||||
auto pf = probe.ProcessPointField(
|
||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto cf = probe.ProcessCellField(
|
||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
|
||||
auto hp = probe.GetHiddenPointsField();
|
||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
||||
|
||||
TestResultArray(pf, GetExpectedPointData());
|
||||
TestResultArray(cf, GetExpectedCellData());
|
||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
||||
TestResultArray(hc, GetExpectedHiddenCells());
|
||||
}
|
||||
|
||||
static void ExplicitToExplict()
|
||||
{
|
||||
std::cout << "Testing Probe Explicit to Explicit:\n";
|
||||
|
||||
auto input = ConvertDataSetUniformToExplicit(MakeInputDataSet());
|
||||
auto geometry = ConvertDataSetUniformToExplicit(MakeGeometryDataSet());
|
||||
|
||||
vtkm::worklet::Probe probe;
|
||||
probe.Run(input.GetCellSet(), input.GetCoordinateSystem(), geometry.GetCoordinateSystem());
|
||||
|
||||
auto pf = probe.ProcessPointField(
|
||||
input.GetField("pointdata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
auto cf = probe.ProcessCellField(
|
||||
input.GetField("celldata").GetData().AsArrayHandle<FieldArrayType>(), 0.0f);
|
||||
|
||||
auto hp = probe.GetHiddenPointsField();
|
||||
auto hc = probe.GetHiddenCellsField(geometry.GetCellSet());
|
||||
|
||||
TestResultArray(pf, GetExpectedPointData());
|
||||
TestResultArray(cf, GetExpectedCellData());
|
||||
TestResultArray(hp, GetExpectedHiddenPoints());
|
||||
TestResultArray(hc, GetExpectedHiddenCells());
|
||||
}
|
||||
|
||||
public:
|
||||
static void Run()
|
||||
{
|
||||
ExplicitToUnifrom();
|
||||
UniformToExplict();
|
||||
ExplicitToExplict();
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestProbe(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestProbe::Run, argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user