Commit 7ef956a9 authored by Li-Ta Lo's avatar Li-Ta Lo
Browse files

Merge branch 'master' into connected_component

parents a9ed1ecf 3de1717b
...@@ -14,4 +14,4 @@ data/* filter=lfs diff=lfs merge=lfs -text ...@@ -14,4 +14,4 @@ data/* filter=lfs diff=lfs merge=lfs -text
*.rst whitespace=tab-in-indent conflict-marker-size=79 *.rst whitespace=tab-in-indent conflict-marker-size=79
*.txt whitespace=tab-in-indent *.txt whitespace=tab-in-indent
diy/** -format.clang-format -whitespace vtkm/thirdparty/diy/vtkmdiy/** -format.clang-format -whitespace
...@@ -39,9 +39,7 @@ set(FILES_TO_CHECK ...@@ -39,9 +39,7 @@ set(FILES_TO_CHECK
set(EXCEPTIONS set(EXCEPTIONS
LICENSE.txt LICENSE.txt
README.txt README.txt
diy/include/diy vtkm/thirdparty/diy/vtkmdiy
diy/LEGAL.txt
diy/LICENSE.txt
) )
if (NOT VTKm_SOURCE_DIR) if (NOT VTKm_SOURCE_DIR)
......
...@@ -39,11 +39,21 @@ set(FILES_TO_CHECK ...@@ -39,11 +39,21 @@ set(FILES_TO_CHECK
set(EXCEPTIONS set(EXCEPTIONS
) )
set(DIRECTORY_EXCEPTIONS
${VTKm_SOURCE_DIR}/vtkm/thirdparty/diy/vtkmdiy
)
if (NOT VTKm_SOURCE_DIR) if (NOT VTKm_SOURCE_DIR)
message(SEND_ERROR "VTKm_SOURCE_DIR not defined.") message(SEND_ERROR "VTKm_SOURCE_DIR not defined.")
endif (NOT VTKm_SOURCE_DIR) endif (NOT VTKm_SOURCE_DIR)
function(check_directory directory parent_CMakeLists_contents) function(check_directory directory parent_CMakeLists_contents)
foreach(exception IN LISTS DIRECTORY_EXCEPTIONS)
if(directory MATCHES "^${exception}$")
return()
endif()
endforeach(exception)
message("Checking directory ${directory}...") message("Checking directory ${directory}...")
get_filename_component(directory_name "${directory}" NAME) get_filename_component(directory_name "${directory}" NAME)
......
...@@ -221,11 +221,6 @@ find_package(Pyexpander) ...@@ -221,11 +221,6 @@ find_package(Pyexpander)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Add subdirectories # Add subdirectories
if(VTKm_ENABLE_MPI)
# This `if` is temporary and will be removed once `diy` supports building
# without MPI.
add_subdirectory(diy)
endif()
add_subdirectory(vtkm) add_subdirectory(vtkm)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
......
...@@ -104,14 +104,11 @@ int main(int argc, char* argv[]) ...@@ -104,14 +104,11 @@ int main(int argc, char* argv[])
output.AddCellSet(outputCellSet); output.AddCellSet(outputCellSet);
auto inCoords = input.GetCoordinateSystem(0).GetData();
timer.Reset(); timer.Reset();
vtkm::cont::DynamicArrayHandle coords; auto outCoords = clip.ProcessCellField(inCoords, DeviceAdapter());
{
FieldMapper<DeviceAdapter> coordMapper(coords, clip, false);
input.GetCoordinateSystem(0).GetData().CastAndCall(coordMapper);
}
vtkm::Float64 processCoordinatesTime = timer.GetElapsedTime(); vtkm::Float64 processCoordinatesTime = timer.GetElapsedTime();
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coords)); output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", outCoords));
timer.Reset(); timer.Reset();
for (vtkm::Id i = 0; i < input.GetNumberOfFields(); ++i) for (vtkm::Id i = 0; i < input.GetNumberOfFields(); ++i)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#endif #endif
#include <vtkm/Math.h> #include <vtkm/Math.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h> #include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DataSet.h> #include <vtkm/cont/DataSet.h>
#include <vtkm/worklet/DispatcherMapField.h> #include <vtkm/worklet/DispatcherMapField.h>
...@@ -68,30 +69,6 @@ Quaternion qrot; ...@@ -68,30 +69,6 @@ Quaternion qrot;
int lastx, lasty; int lastx, lasty;
int mouse_state = 1; int mouse_state = 1;
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
// //
// Initialize the OpenGL state // Initialize the OpenGL state
// //
...@@ -145,16 +122,10 @@ void displayCall() ...@@ -145,16 +122,10 @@ void displayCall()
// Get the cell set, coordinate system and coordinate data // Get the cell set, coordinate system and coordinate data
vtkm::cont::CellSetExplicit<> cellSet; vtkm::cont::CellSetExplicit<> cellSet;
outDataSet.GetCellSet(0).CopyTo(cellSet); outDataSet.GetCellSet(0).CopyTo(cellSet);
const vtkm::cont::DynamicArrayHandleCoordinateSystem& coordArray = auto coordArray = outDataSet.GetCoordinateSystem().GetData();
outDataSet.GetCoordinateSystem().GetData();
vtkm::Id numberOfCells = cellSet.GetNumberOfCells(); vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
vtkm::Id numberOfPoints = coordArray.GetNumberOfValues(); vtkm::cont::ArrayCopy(coordArray, vertexArray);
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfPoints);
vtkm::cont::CastAndCall(coordArray, GetVertexArray());
// Each cell is a polyline // Each cell is a polyline
glColor3f(1.0f, 0.0f, 0.0f); glColor3f(1.0f, 0.0f, 0.0f);
......
...@@ -52,9 +52,6 @@ namespace ...@@ -52,9 +52,6 @@ namespace
// Takes input uniform grid and outputs unstructured grid of tets // Takes input uniform grid and outputs unstructured grid of tets
static vtkm::cont::DataSet outDataSet; static vtkm::cont::DataSet outDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
// OpenGL display variables // OpenGL display variables
Quaternion qrot; Quaternion qrot;
int lastx, lasty; int lastx, lasty;
...@@ -123,30 +120,6 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet() ...@@ -123,30 +120,6 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
return builder.Create(); return builder.Create();
} }
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
// //
// Initialize the OpenGL state // Initialize the OpenGL state
// //
...@@ -201,10 +174,7 @@ void displayCall() ...@@ -201,10 +174,7 @@ void displayCall()
outDataSet.GetCellSet(0).CopyTo(cellSet); outDataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::Id numberOfCells = cellSet.GetNumberOfCells(); vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
// Need the actual vertex points from a static cast of the dynamic array but can't get it right auto vertexArray = outDataSet.GetCoordinateSystem().GetData();
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the five tetrahedra belonging to each hexadron // Draw the five tetrahedra belonging to each hexadron
vtkm::Float32 color[5][3] = { { 1.0f, 0.0f, 0.0f }, vtkm::Float32 color[5][3] = { { 1.0f, 0.0f, 0.0f },
...@@ -223,10 +193,10 @@ void displayCall() ...@@ -223,10 +193,10 @@ void displayCall()
cellSet.GetIndices(tetra, tetIndices); cellSet.GetIndices(tetra, tetIndices);
// Get the vertex points for this tetrahedron // Get the vertex points for this tetrahedron
vtkm::Vec<vtkm::Float64, 3> pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]); auto pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
vtkm::Vec<vtkm::Float64, 3> pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]); auto pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
vtkm::Vec<vtkm::Float64, 3> pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]); auto pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
vtkm::Vec<vtkm::Float64, 3> pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]); auto pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
// Draw the tetrahedron filled with alternating colors // Draw the tetrahedron filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
...@@ -323,7 +293,6 @@ int main(int argc, char* argv[]) ...@@ -323,7 +293,6 @@ int main(int argc, char* argv[])
glutMainLoop(); glutMainLoop();
outDataSet.Clear(); outDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }
......
...@@ -52,9 +52,6 @@ static vtkm::Id cellsToDisplay = 64; ...@@ -52,9 +52,6 @@ static vtkm::Id cellsToDisplay = 64;
// Takes input uniform grid and outputs unstructured grid of tets // Takes input uniform grid and outputs unstructured grid of tets
static vtkm::cont::DataSet tetDataSet; static vtkm::cont::DataSet tetDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
// OpenGL display variables // OpenGL display variables
static Quaternion qrot; static Quaternion qrot;
static int lastx, lasty; static int lastx, lasty;
...@@ -87,30 +84,6 @@ vtkm::cont::DataSet MakeTetrahedralizeTestDataSet(vtkm::Id3 dim) ...@@ -87,30 +84,6 @@ vtkm::cont::DataSet MakeTetrahedralizeTestDataSet(vtkm::Id3 dim)
return dataSet; return dataSet;
} }
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
// //
// Initialize the OpenGL state // Initialize the OpenGL state
// //
...@@ -165,10 +138,7 @@ void displayCall() ...@@ -165,10 +138,7 @@ void displayCall()
vtkm::cont::CellSetSingleType<> cellSet; vtkm::cont::CellSetSingleType<> cellSet;
tetDataSet.GetCellSet(0).CopyTo(cellSet); tetDataSet.GetCellSet(0).CopyTo(cellSet);
// Need the actual vertex points from a static cast of the dynamic array but can't get it right auto vertexArray = tetDataSet.GetCoordinateSystem().GetData();
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(tetDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the five tetrahedra belonging to each hexadron // Draw the five tetrahedra belonging to each hexadron
vtkm::Id tetra = 0; vtkm::Id tetra = 0;
...@@ -190,10 +160,10 @@ void displayCall() ...@@ -190,10 +160,10 @@ void displayCall()
cellSet.GetIndices(tetra, tetIndices); cellSet.GetIndices(tetra, tetIndices);
// Get the vertex points for this tetrahedron // Get the vertex points for this tetrahedron
vtkm::Vec<vtkm::Float64, 3> pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]); auto pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
vtkm::Vec<vtkm::Float64, 3> pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]); auto pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
vtkm::Vec<vtkm::Float64, 3> pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]); auto pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
vtkm::Vec<vtkm::Float64, 3> pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]); auto pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
// Draw the tetrahedron filled with alternating colors // Draw the tetrahedron filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
...@@ -305,7 +275,6 @@ int main(int argc, char* argv[]) ...@@ -305,7 +275,6 @@ int main(int argc, char* argv[])
glutMainLoop(); glutMainLoop();
tetDataSet.Clear(); tetDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }
......
...@@ -50,9 +50,6 @@ namespace ...@@ -50,9 +50,6 @@ namespace
static vtkm::cont::DataSet outDataSet; static vtkm::cont::DataSet outDataSet;
static vtkm::Id numberOfInPoints; static vtkm::Id numberOfInPoints;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
} // anonymous namespace } // anonymous namespace
// //
...@@ -125,30 +122,6 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet() ...@@ -125,30 +122,6 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
return builder.Create(); return builder.Create();
} }
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
// //
// Initialize the OpenGL state // Initialize the OpenGL state
// //
...@@ -173,10 +146,7 @@ void displayCall() ...@@ -173,10 +146,7 @@ void displayCall()
outDataSet.GetCellSet(0).CopyTo(cellSet); outDataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::Id numberOfCells = cellSet.GetNumberOfCells(); vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
// Need the actual vertex points from a static cast of the dynamic array but can't get it right auto vertexArray = outDataSet.GetCoordinateSystem().GetData();
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfInPoints);
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the two triangles belonging to each quad // Draw the two triangles belonging to each quad
vtkm::Float32 color[4][3] = { vtkm::Float32 color[4][3] = {
...@@ -239,7 +209,6 @@ int main(int argc, char* argv[]) ...@@ -239,7 +209,6 @@ int main(int argc, char* argv[])
glutMainLoop(); glutMainLoop();
outDataSet.Clear(); outDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }
......
...@@ -50,9 +50,6 @@ static vtkm::Id cellsToDisplay = 16; ...@@ -50,9 +50,6 @@ static vtkm::Id cellsToDisplay = 16;
// Takes input uniform grid and outputs unstructured grid of triangles // Takes input uniform grid and outputs unstructured grid of triangles
static vtkm::cont::DataSet triDataSet; static vtkm::cont::DataSet triDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
// //
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing // Construct an input data set with uniform grid of indicated dimensions, origin and spacing
// //
...@@ -78,30 +75,6 @@ vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim) ...@@ -78,30 +75,6 @@ vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim)
return dataSet; return dataSet;
} }
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
// //
// Initialize the OpenGL state // Initialize the OpenGL state
// //
...@@ -125,10 +98,7 @@ void displayCall() ...@@ -125,10 +98,7 @@ void displayCall()
vtkm::cont::CellSetSingleType<> cellSet; vtkm::cont::CellSetSingleType<> cellSet;
triDataSet.GetCellSet(0).CopyTo(cellSet); triDataSet.GetCellSet(0).CopyTo(cellSet);
// Need the actual vertex points from a static cast of the dynamic array but can't get it right auto vertexArray = triDataSet.GetCoordinateSystem().GetData();
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(triDataSet.GetCoordinateSystem(), GetVertexArray());
// Draw the two triangles belonging to each quad // Draw the two triangles belonging to each quad
vtkm::Id triangle = 0; vtkm::Id triangle = 0;
...@@ -207,7 +177,6 @@ int main(int argc, char* argv[]) ...@@ -207,7 +177,6 @@ int main(int argc, char* argv[])
glutMainLoop(); glutMainLoop();
triDataSet.Clear(); triDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }
......
...@@ -67,6 +67,11 @@ vtkm_declare_headers(${headers}) ...@@ -67,6 +67,11 @@ vtkm_declare_headers(${headers})
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
#first add all the components vtkm that are shared between control and exec #first add all the components vtkm that are shared between control and exec
if(VTKm_ENABLE_MPI)
# This `if` is temporary and will be removed once `diy` supports building
# without MPI.
add_subdirectory(thirdparty/diy)
endif()
add_subdirectory(testing) add_subdirectory(testing)
add_subdirectory(internal) add_subdirectory(internal)
......
This diff is collapsed.
...@@ -108,28 +108,30 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType< ...@@ -108,28 +108,30 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
}} }}
'''.format(vtkmname) '''.format(vtkmname)
def unary_math_function_no_vec(vtkmname, sysname, returntype = None): def unary_math_function_no_vec(vtkmname, sysname):
return unary_function(vtkmname, general_type = '''template <typename T>
'T', static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type {0}(const T& x)
'typename detail::FloatingPointReturnType<T>::Type' if returntype == None else returntype, {{
'VTKM_CUDA_MATH_FUNCTION_64(' + sysname + ')(static_cast<vtkm::Float64>(x))', using RT = typename detail::FloatingPointReturnType<T>::Type;
'std::' + sysname + '(static_cast<vtkm::Float64>(x))', return vtkm::{0}(static_cast<RT>(x));
'template <typename T>', }}
'static inline') + \ '''.format(vtkmname)
unary_function(vtkmname, specialization_types = unary_function(vtkmname,
'vtkm::Float32', 'vtkm::Float32',
'detail::FloatingPointReturnType<vtkm::Float32>::Type' if returntype == None else returntype, 'vtkm::Float32',
'VTKM_CUDA_MATH_FUNCTION_32(' + sysname + ')(x)', 'VTKM_CUDA_MATH_FUNCTION_32(' + sysname + ')(x)',
'std::' + sysname + '(x)', 'std::' + sysname + '(x)',
'template <>', '',
'inline') + \ 'inline')
unary_function(vtkmname,