mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Make CoordinateSystem not fail on CUDA
This commit is contained in:
parent
66e356f7d9
commit
cbadd3e67e
@ -342,6 +342,11 @@ function(vtkm_unit_tests)
|
||||
${VTKm_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set_source_files_properties(${VTKm_UT_SOURCES}
|
||||
PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT "OBJ"
|
||||
)
|
||||
|
||||
|
||||
cuda_add_executable(${test_prog} ${TestSources})
|
||||
|
||||
set(CUDA_NVCC_FLAGS ${old_nvcc_flags})
|
||||
|
@ -94,6 +94,7 @@ set(header_impls
|
||||
ArrayHandle.hxx
|
||||
CellSetExplicit.hxx
|
||||
CellSetStructured.hxx
|
||||
CoordinateSystem.hxx
|
||||
StorageBasic.hxx
|
||||
)
|
||||
|
||||
|
@ -18,7 +18,9 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/CoordinateSystem.hxx>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -29,6 +31,44 @@ using CoordinatesTypeList = vtkm::ListTagBase<vtkm::cont::ArrayHandleVirtualCoor
|
||||
using CoordinatesStorageList =
|
||||
vtkm::ListTagBase<vtkm::cont::ArrayHandleVirtualCoordinates::StorageTag>;
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem()
|
||||
: Superclass()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates::Superclass& data)
|
||||
: Superclass(name, ASSOC_POINTS, data)
|
||||
{
|
||||
}
|
||||
|
||||
/// This constructor of coordinate system sets up a regular grid of points.
|
||||
///
|
||||
VTKM_CONT
|
||||
CoordinateSystem::CoordinateSystem(std::string name,
|
||||
vtkm::Id3 dimensions,
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> origin,
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> spacing)
|
||||
: Superclass(name,
|
||||
ASSOC_POINTS,
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates CoordinateSystem::GetData() const
|
||||
{
|
||||
return this->Superclass::GetData().Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void CoordinateSystem::SetData(const vtkm::cont::ArrayHandleVirtualCoordinates::Superclass& newdata)
|
||||
{
|
||||
this->Superclass::SetData(newdata);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void CoordinateSystem::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
@ -55,5 +95,42 @@ vtkm::Bounds CoordinateSystem::GetBounds() const
|
||||
this->GetRange(ranges);
|
||||
return vtkm::Bounds(ranges[0], ranges[1], ranges[2]);
|
||||
}
|
||||
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>>&);
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<double, 3>>&);
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::FloatDefault, 3>,
|
||||
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>&);
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::FloatDefault, 3>,
|
||||
vtkm::cont::internal::StorageTagCartesianProduct<
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>>>&);
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::FloatDefault, 3>,
|
||||
vtkm::cont::internal::StorageTagCompositeVector<vtkm::Vec<vtkm::FloatDefault, 3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, vtkm::cont::StorageTagBasic>)>>&);
|
||||
|
||||
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::DynamicArrayHandle&);
|
||||
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>>&);
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<double, 3>>&);
|
||||
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(const vtkm::cont::DynamicArrayHandle&);
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <vtkm/Bounds.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCast.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
@ -31,82 +30,23 @@ namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct MakeArrayHandleVirtualCoordinatesFunctor
|
||||
{
|
||||
VTKM_CONT explicit MakeArrayHandleVirtualCoordinatesFunctor(
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates& out)
|
||||
: Out(&out)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>, StorageTag>& array) const
|
||||
{
|
||||
*this->Out = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>, StorageTag>& array) const
|
||||
{
|
||||
*this->Out = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
|
||||
template <typename T, typename StorageTag>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, StorageTag>&) const
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("CoordinateSystem's value type should be a 3 component Vec "
|
||||
"of either vtkm::Float32 or vtkm::Float64");
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates* Out;
|
||||
};
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates MakeArrayHandleVirtualCoordinates(
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& array)
|
||||
{
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates out;
|
||||
array.CastAndCall(MakeArrayHandleVirtualCoordinatesFunctor(out));
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
|
||||
{
|
||||
using Superclass = vtkm::cont::Field;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
CoordinateSystem()
|
||||
: Superclass()
|
||||
{
|
||||
}
|
||||
CoordinateSystem();
|
||||
|
||||
VTKM_CONT CoordinateSystem(std::string name,
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates::Superclass& data)
|
||||
: Superclass(name, ASSOC_POINTS, data)
|
||||
{
|
||||
}
|
||||
const vtkm::cont::ArrayHandleVirtualCoordinates::Superclass& data);
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT CoordinateSystem(std::string name,
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& data)
|
||||
: Superclass(name, ASSOC_POINTS, detail::MakeArrayHandleVirtualCoordinates(data))
|
||||
{
|
||||
}
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& data);
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
|
||||
: Superclass(name, ASSOC_POINTS, vtkm::cont::ArrayHandleVirtualCoordinates(data))
|
||||
{
|
||||
}
|
||||
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data);
|
||||
|
||||
/// This constructor of coordinate system sets up a regular grid of points.
|
||||
///
|
||||
@ -115,40 +55,22 @@ public:
|
||||
std::string name,
|
||||
vtkm::Id3 dimensions,
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> origin = vtkm::Vec<vtkm::FloatDefault, 3>(0.0f, 0.0f, 0.0f),
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> spacing = vtkm::Vec<vtkm::FloatDefault, 3>(1.0f, 1.0f, 1.0f))
|
||||
: Superclass(name,
|
||||
ASSOC_POINTS,
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates(
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
|
||||
{
|
||||
}
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> spacing = vtkm::Vec<vtkm::FloatDefault, 3>(1.0f, 1.0f, 1.0f));
|
||||
|
||||
VTKM_CONT
|
||||
CoordinateSystem& operator=(const vtkm::cont::CoordinateSystem& src) = default;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates GetData() const
|
||||
{
|
||||
return this->Superclass::GetData().Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
|
||||
}
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates GetData() const;
|
||||
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandleVirtualCoordinates::Superclass& newdata)
|
||||
{
|
||||
this->Superclass::SetData(newdata);
|
||||
}
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandleVirtualCoordinates::Superclass& newdata);
|
||||
|
||||
template <typename T, typename StorageTag>
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandle<T, StorageTag>& newdata)
|
||||
{
|
||||
this->Superclass::SetData(vtkm::cont::ArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
VTKM_CONT void SetData(const vtkm::cont::ArrayHandle<T, StorageTag>& newdata);
|
||||
|
||||
VTKM_CONT
|
||||
template <typename TypeList, typename StorageList>
|
||||
void SetData(const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& newdata)
|
||||
{
|
||||
this->Superclass::SetData(detail::MakeArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
void SetData(const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& newdata);
|
||||
|
||||
VTKM_CONT
|
||||
void GetRange(vtkm::Range* range) const;
|
||||
|
92
vtkm/cont/CoordinateSystem.hxx
Normal file
92
vtkm/cont/CoordinateSystem.hxx
Normal file
@ -0,0 +1,92 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_CoordinateSystem_hxx
|
||||
#define vtk_m_cont_CoordinateSystem_hxx
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct MakeArrayHandleVirtualCoordinatesFunctor
|
||||
{
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>, StorageTag>& array,
|
||||
ArrayHandleVirtualCoordinates& output) const
|
||||
{
|
||||
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void operator()(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>, StorageTag>& array,
|
||||
ArrayHandleVirtualCoordinates& output) const
|
||||
{
|
||||
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates MakeArrayHandleVirtualCoordinates(
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& array)
|
||||
{
|
||||
vtkm::cont::ArrayHandleVirtualCoordinates output;
|
||||
vtkm::cont::CastAndCall(array.ResetTypeList(vtkm::TypeListTagFieldVec3{}),
|
||||
MakeArrayHandleVirtualCoordinatesFunctor{},
|
||||
output);
|
||||
return output;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(
|
||||
std::string name,
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& data)
|
||||
: Superclass(name, ASSOC_POINTS, detail::MakeArrayHandleVirtualCoordinates(data))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& data)
|
||||
: Superclass(name, ASSOC_POINTS, vtkm::cont::ArrayHandleVirtualCoordinates(data))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT void CoordinateSystem::SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata)
|
||||
{
|
||||
this->SetData(vtkm::cont::ArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT void CoordinateSystem::SetData(
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& newdata)
|
||||
{
|
||||
this->SetData(detail::MakeArrayHandleVirtualCoordinates(newdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <vtkm/Assert.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
#include <vtkm/exec/CellEdge.h>
|
||||
#include <vtkm/filter/ExternalFaces.h>
|
||||
|
@ -33,7 +33,11 @@ set(unit_tests
|
||||
UnitTestMapperVolume.cxx
|
||||
)
|
||||
|
||||
VTKm_unit_tests(SOURCES ${unit_tests})
|
||||
if (VTKm_ENABLE_CUDA)
|
||||
vtkm_unit_tests(SOURCES ${unit_tests} CUDA)
|
||||
else()
|
||||
vtkm_unit_tests(SOURCES ${unit_tests})
|
||||
endif()
|
||||
|
||||
#add_subdirectory(osmesa)
|
||||
#add_subdirectory(egl)
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/rendering/Actor.h>
|
||||
#include <vtkm/rendering/Canvas.h>
|
||||
|
Loading…
Reference in New Issue
Block a user