mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Experiment with speeding up the GetHexahedronClassification.
This commit is contained in:
parent
57f5881538
commit
69f9125663
@ -23,16 +23,17 @@
|
||||
#path so that our examples can find VTK-m
|
||||
set(CMAKE_PREFIX_PATH ${VTKm_BINARY_DIR}/${VTKm_INSTALL_CONFIG_DIR})
|
||||
|
||||
add_subdirectory(clipping)
|
||||
add_subdirectory(contour_tree)
|
||||
add_subdirectory(demo)
|
||||
add_subdirectory(dynamic_dispatcher)
|
||||
add_subdirectory(hello_world)
|
||||
add_subdirectory(isosurface)
|
||||
add_subdirectory(multi_backend)
|
||||
#add_subdirectory(clipping)
|
||||
#add_subdirectory(contour_tree)
|
||||
#add_subdirectory(demo)
|
||||
#add_subdirectory(dynamic_dispatcher)
|
||||
#add_subdirectory(hello_world)
|
||||
#add_subdirectory(isosurface)
|
||||
#add_subdirectory(multi_backend)
|
||||
add_subdirectory(streamline)
|
||||
add_subdirectory(tetrahedra)
|
||||
if(VTKm_ENABLE_RENDERING)
|
||||
add_subdirectory(rendering)
|
||||
endif()
|
||||
#add_subdirectory(tetrahedra)
|
||||
add_subdirectory(tau_timing)
|
||||
#if(VTKm_ENABLE_RENDERING)
|
||||
# add_subdirectory(rendering)
|
||||
#endif()
|
||||
|
||||
|
@ -262,7 +262,6 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//We are done with the file now, so release the file descriptor
|
||||
fclose(pFile);
|
||||
|
||||
@ -282,7 +281,7 @@ int main(int argc, char* argv[])
|
||||
vtkm::cont::DataSet inDataSet;
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims);
|
||||
inDataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
inDataSet.AddField(vtkm::cont::Field("vecData", vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
inDataSet.AddField(vtkm::cont::Field("vec", vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
|
||||
vtkm::cont::CellSetStructured<3> inCellSet("cells");
|
||||
inCellSet.SetPointDimensions(vtkm::make_Vec(vdims[0], vdims[1], vdims[2]));
|
||||
@ -291,12 +290,12 @@ int main(int argc, char* argv[])
|
||||
// Create and run the filter
|
||||
streamLineFilter = new vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter>();
|
||||
outDataSet = streamLineFilter->Run(inDataSet,
|
||||
//vtkm::worklet::internal::FORWARD,
|
||||
direction,
|
||||
nSeeds,
|
||||
nSteps,
|
||||
tStep);
|
||||
|
||||
|
||||
// Render the output dataset of polylines
|
||||
lastx = lasty = 0;
|
||||
glutInit(&argc, argv);
|
||||
|
49
examples/tau_timing/CMakeLists.txt
Normal file
49
examples/tau_timing/CMakeLists.txt
Normal file
@ -0,0 +1,49 @@
|
||||
##=============================================================================
|
||||
##
|
||||
## 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 Sandia Corporation.
|
||||
## Copyright 2015 UT-Battelle, LLC.
|
||||
## Copyright 2015 Los Alamos National Security.
|
||||
##
|
||||
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
## 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.
|
||||
##
|
||||
##=============================================================================
|
||||
|
||||
#Find the VTK-m package
|
||||
find_package(VTKm REQUIRED QUIET
|
||||
OPTIONAL_COMPONENTS Serial CUDA TBB Rendering
|
||||
)
|
||||
|
||||
add_executable(Tau_timing_SERIAL TauTiming.cxx)
|
||||
target_include_directories(Tau_timing_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(Tau_timing_SERIAL ${VTKm_LIBRARIES})
|
||||
target_compile_options(Tau_timing_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
|
||||
if(VTKm_TBB_FOUND)
|
||||
add_executable(Tau_timing_TBB TauTimingTBB.cxx)
|
||||
target_include_directories(Tau_timing_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(Tau_timing_TBB ${VTKm_LIBRARIES})
|
||||
target_compile_options(Tau_timing_TBB PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
endif()
|
||||
|
||||
if(VTKm_OpenGL_FOUND)
|
||||
if(VTKm_CUDA_FOUND)
|
||||
# Cuda compiles do not respect target_include_directories
|
||||
cuda_include_directories(${VTKm_INCLUDE_DIRS})
|
||||
cuda_add_executable(Tau_timing_CUDA TauTiming.cu)
|
||||
target_include_directories(Tau_timing_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(Tau_timing_CUDA PRIVATE ${VTKm_LIBRARIES})
|
||||
target_compile_options(Tau_timing_CUDA PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
endif()
|
||||
endif()
|
23
examples/tau_timing/TauTiming.cu
Normal file
23
examples/tau_timing/TauTiming.cu
Normal file
@ -0,0 +1,23 @@
|
||||
//============================================================================
|
||||
// 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 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_CUDA
|
||||
|
||||
#include "TauTiming.cxx"
|
494
examples/tau_timing/TauTiming.cxx
Normal file
494
examples/tau_timing/TauTiming.cxx
Normal file
@ -0,0 +1,494 @@
|
||||
//============================================================================
|
||||
// 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 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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 VTKM_DEVICE_ADAPTER
|
||||
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
|
||||
#endif
|
||||
|
||||
#include <vtkm/io/writer/VTKDataSetWriter.h>
|
||||
#include <vtkm/io/reader/VTKDataSetReader.h>
|
||||
#include <vtkm/filter/MarchingCubes.h>
|
||||
#include <vtkm/worklet/StreamLineUniformGrid.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/ExternalFaces.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
|
||||
#include <vtkm/rendering/Actor.h>
|
||||
#include <vtkm/rendering/CanvasRayTracer.h>
|
||||
#include <vtkm/rendering/MapperRayTracer.h>
|
||||
#include <vtkm/rendering/MapperVolume.h>
|
||||
#include <vtkm/rendering/Scene.h>
|
||||
#include <vtkm/rendering/View3D.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/rendering/testing/RenderTest.h>
|
||||
|
||||
#include <vtkm/worklet/StreamLineUniformGrid.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
|
||||
#include <vtkm/io/writer/VTKDataSetWriter.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
|
||||
static bool printProgress = true;
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,3> Normalize(vtkm::Vec<T,3> v)
|
||||
{
|
||||
T magnitude = static_cast<T>(sqrt(vtkm::dot(v, v)));
|
||||
T zero = static_cast<T>(0.0);
|
||||
T one = static_cast<T>(1.0);
|
||||
if (magnitude == zero)
|
||||
return vtkm::make_Vec(zero, zero, zero);
|
||||
else
|
||||
return one / magnitude * v;
|
||||
}
|
||||
|
||||
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
|
||||
|
||||
class TangleField : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldIn<IdType> vertexId, FieldOut<Scalar> v);
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
typedef _1 InputDomain;
|
||||
|
||||
const vtkm::Id xdim, ydim, zdim;
|
||||
const vtkm::FloatDefault xmin, ymin, zmin, xmax, ymax, zmax;
|
||||
const vtkm::Id cellsPerLayer;
|
||||
|
||||
VTKM_CONT
|
||||
TangleField(const vtkm::Id3 dims, const vtkm::FloatDefault mins[3], const vtkm::FloatDefault maxs[3]) : xdim(dims[0]), ydim(dims[1]), zdim(dims[2]),
|
||||
xmin(mins[0]), ymin(mins[1]), zmin(mins[2]), xmax(maxs[0]), ymax(maxs[1]), zmax(maxs[2]), cellsPerLayer((xdim) * (ydim))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Id &vertexId, vtkm::Float32 &v) const
|
||||
{
|
||||
const vtkm::Id x = vertexId % (xdim);
|
||||
const vtkm::Id y = (vertexId / (xdim)) % (ydim);
|
||||
const vtkm::Id z = vertexId / cellsPerLayer;
|
||||
|
||||
const vtkm::FloatDefault fx = static_cast<vtkm::FloatDefault>(x) / static_cast<vtkm::FloatDefault>(xdim-1);
|
||||
const vtkm::FloatDefault fy = static_cast<vtkm::FloatDefault>(y) / static_cast<vtkm::FloatDefault>(xdim-1);
|
||||
const vtkm::FloatDefault fz = static_cast<vtkm::FloatDefault>(z) / static_cast<vtkm::FloatDefault>(xdim-1);
|
||||
|
||||
const vtkm::Float32 xx = 3.0f*vtkm::Float32(xmin+(xmax-xmin)*(fx));
|
||||
const vtkm::Float32 yy = 3.0f*vtkm::Float32(ymin+(ymax-ymin)*(fy));
|
||||
const vtkm::Float32 zz = 3.0f*vtkm::Float32(zmin+(zmax-zmin)*(fz));
|
||||
|
||||
v = (xx*xx*xx*xx - 5.0f*xx*xx + yy*yy*yy*yy - 5.0f*yy*yy + zz*zz*zz*zz - 5.0f*zz*zz + 11.8f) * 0.2f + 0.5f;
|
||||
}
|
||||
};
|
||||
|
||||
vtkm::cont::DataSet
|
||||
CreateTestDataSet(vtkm::Id3 dims)
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
const vtkm::Id3 vdims(dims[0] + 1, dims[1] + 1, dims[2] + 1);
|
||||
|
||||
vtkm::FloatDefault mins[3] = {-1.0f, -1.0f, -1.0f};
|
||||
vtkm::FloatDefault maxs[3] = {1.0f, 1.0f, 1.0f};
|
||||
|
||||
|
||||
static const vtkm::IdComponent ndim = 3;
|
||||
vtkm::cont::CellSetStructured<ndim> cellSet("cells");
|
||||
cellSet.SetPointDimensions(vdims);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
vtkm::Vec<vtkm::FloatDefault,3> origin(0.0f, 0.0f, 0.0f);
|
||||
vtkm::Vec<vtkm::FloatDefault,3> spacing(
|
||||
1.0f/static_cast<vtkm::FloatDefault>(dims[0]),
|
||||
1.0f/static_cast<vtkm::FloatDefault>(dims[2]),
|
||||
1.0f/static_cast<vtkm::FloatDefault>(dims[1]));
|
||||
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates
|
||||
coordinates(vdims, origin, spacing);
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarVar;
|
||||
vtkm::cont::ArrayHandleIndex vertexCountImplicitArray(vdims[0]*vdims[1]*vdims[2]);
|
||||
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(TangleField(vdims, mins, maxs));
|
||||
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, scalarVar);
|
||||
|
||||
dataSet.AddField(vtkm::cont::Field(std::string("scalar"), vtkm::cont::Field::ASSOC_POINTS, scalarVar));
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
void TestMarchingCubesUniformGrid(int d)
|
||||
{
|
||||
vtkm::Id3 dims(d,d,d);
|
||||
std::cout<<"Marching cubes with gridsize = "<<dims<<std::endl;
|
||||
|
||||
vtkm::cont::DataSet dataSet = CreateTestDataSet(dims);
|
||||
|
||||
//vtkm::io::writer::VTKDataSetWriter wrt("ds.vtk");
|
||||
//wrt.WriteDataSet(dataSet);
|
||||
|
||||
int N = 100;
|
||||
vtkm::Float32 v0 = -.8f, v1 = 24.0f;
|
||||
vtkm::Float32 dv = (v1-v0)/(vtkm::Float32)(N-1);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
vtkm::filter::ResultDataSet result;
|
||||
vtkm::filter::MarchingCubes mc;
|
||||
mc.SetGenerateNormals(true);
|
||||
|
||||
vtkm::Float32 val = v0 + i*dv;
|
||||
//std::cout<<i<<": "<<val<<std::endl;
|
||||
if (N == 1)
|
||||
val = 0.5f;
|
||||
mc.SetIsoValue(val);
|
||||
//mc.SetMergeDuplicatePoints(false);
|
||||
result = mc.Execute( dataSet,
|
||||
dataSet.GetField("nodevar") );
|
||||
const vtkm::cont::DataSet &out = result.GetDataSet();
|
||||
}
|
||||
//std::cout<<"Number of points in isosurface: "<<out.GetCoordinateSystem().GetData().GetNumberOfValues()<<std::endl;
|
||||
}
|
||||
|
||||
void TestStreamlineUniformGrid(int d)
|
||||
{
|
||||
/*
|
||||
vtkm::Id3 dims(d,d,d);
|
||||
std::cout<<"Streamline with gridsize = "<<dims<<std::endl;
|
||||
vtkm::cont::DataSet dataSet = MakeIsosurfaceTestDataSet(dims);
|
||||
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > result;
|
||||
|
||||
PointGrad<vtkm::Float32> func(dataSet, "nodevar", result);
|
||||
vtkm::cont::CastAndCall(dataSet.GetCellSet(), func);
|
||||
|
||||
printSummary_ArrayHandle(result, std::cout);
|
||||
*/
|
||||
}
|
||||
|
||||
void CreateData(int d)
|
||||
{
|
||||
|
||||
vtkm::Id3 dims(d,d,d);
|
||||
vtkm::cont::DataSet dataSet = CreateTestDataSet(dims);
|
||||
|
||||
char tmp[64];
|
||||
sprintf(tmp, "regular_%d.vtk", d);
|
||||
std::string fname = tmp;
|
||||
|
||||
std::cout<<fname<<std::endl;
|
||||
vtkm::io::writer::VTKDataSetWriter wrt(fname);
|
||||
wrt.WriteDataSet(dataSet);
|
||||
}
|
||||
|
||||
void MarchingCubesTest(const vtkm::cont::DataSet &ds, int N)
|
||||
{
|
||||
std::cout<<"Marching Cubes test: "<<N<<std::endl;
|
||||
vtkm::Range range;
|
||||
ds.GetField(0).GetRange(&range, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
|
||||
int nv = 10;
|
||||
vtkm::Float32 v0 = range.Min, v1 = range.Max;
|
||||
vtkm::Float32 dv = (v1-v0)/(vtkm::Float32)(nv-1);
|
||||
std::cout<<"Field range: ("<<v0<<","<<v1<<") dv= "<<dv<<std::endl;
|
||||
|
||||
vtkm::filter::MarchingCubes mc;
|
||||
mc.SetGenerateNormals(true);
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
|
||||
for (int j = 0; j < nv; j++)
|
||||
{
|
||||
vtkm::filter::ResultDataSet result;
|
||||
//vtkm::Float32 val = v0 + i*dv;
|
||||
//std::cout<<i<<": "<<val<<std::endl;
|
||||
mc.SetIsoValue(v0 + j*dv);
|
||||
//mc.SetMergeDuplicatePoints(false);
|
||||
result = mc.Execute(ds, ds.GetField(0));
|
||||
const vtkm::cont::DataSet &out = result.GetDataSet();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
vtkm::Float32 v0 = range.Min, v1 = range.Max;
|
||||
vtkm::Float32 dv = (v1-v0)/(vtkm::Float32)(N-1);
|
||||
std::cout<<"Field range: ("<<v0<<","<<v1<<") dv= "<<dv<<std::endl;
|
||||
|
||||
|
||||
#if 0
|
||||
vtkm::filter::MarchingCubes mc;
|
||||
mc.SetGenerateNormals(true);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
vtkm::filter::ResultDataSet result;
|
||||
//vtkm::Float32 val = v0 + i*dv;
|
||||
//std::cout<<i<<": "<<val<<std::endl;
|
||||
mc.SetIsoValue(v0 + i*dv);
|
||||
//mc.SetMergeDuplicatePoints(false);
|
||||
result = mc.Execute(ds, ds.GetField(0));
|
||||
const vtkm::cont::DataSet &out = result.GetDataSet();
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
vtkm::filter::ResultDataSet result;
|
||||
vtkm::filter::MarchingCubes mc;
|
||||
mc.SetGenerateNormals(true);
|
||||
//vtkm::Float32 val = v0 + i*dv;
|
||||
//std::cout<<i<<": "<<val<<std::endl;
|
||||
mc.SetIsoValue(v0 + i*dv);
|
||||
//mc.SetMergeDuplicatePoints(false);
|
||||
result = mc.Execute(ds, ds.GetField(0));
|
||||
const vtkm::cont::DataSet &out = result.GetDataSet();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
vtkm::filter::ResultDataSet result;
|
||||
vtkm::filter::MarchingCubes mc;
|
||||
mc.SetGenerateNormals(true);
|
||||
//vtkm::Float32 val = v0 + i*dv;
|
||||
//std::cout<<i<<": "<<val<<std::endl;
|
||||
mc.SetIsoValue(0.5f);
|
||||
result = mc.Execute(ds, ds.GetField(0));
|
||||
const vtkm::cont::DataSet &out = result.GetDataSet();
|
||||
vtkm::io::writer::VTKDataSetWriter wrt("iso.vtk");
|
||||
wrt.WriteDataSet(out);
|
||||
*/
|
||||
}
|
||||
|
||||
static vtkm::cont::DataSet
|
||||
createUniform(const vtkm::cont::DataSet &ds)
|
||||
{
|
||||
vtkm::cont::DataSetBuilderUniform builder;
|
||||
vtkm::cont::DataSetFieldAdd fieldAdd;
|
||||
|
||||
vtkm::cont::DataSet out = builder.Create(vtkm::Id3(50,50,50));
|
||||
fieldAdd.AddPointField(out, ds.GetField(0).GetName(),
|
||||
ds.GetField(0).GetData());
|
||||
out.PrintSummary(std::cout);
|
||||
return out;
|
||||
}
|
||||
|
||||
void StreamlineTest(vtkm::cont::DataSet &ds, int N)
|
||||
{
|
||||
const vtkm::Id nSeeds = 25000;
|
||||
const vtkm::Id nSteps = 20000;
|
||||
const vtkm::Float32 tStep = 0.05f;
|
||||
const vtkm::Id direction = vtkm::worklet::internal::FORWARD; //vtkm::worklet::internal::BOTH;
|
||||
|
||||
vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter> *streamLineFilter;
|
||||
streamLineFilter = new vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter>();
|
||||
|
||||
std::cout<<"Streamline test: "<<N<<std::endl;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
vtkm::cont::DataSet out;
|
||||
out = streamLineFilter->Run(ds,
|
||||
direction,
|
||||
nSeeds,
|
||||
nSteps,
|
||||
tStep);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderRTTest(const vtkm::cont::DataSet &ds, int N)
|
||||
{
|
||||
std::cout<<"Ray Tracing test: "<<N<<std::endl;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
|
||||
typedef vtkm::rendering::MapperRayTracer M;
|
||||
typedef vtkm::rendering::CanvasRayTracer C;
|
||||
typedef vtkm::rendering::View3D V3;
|
||||
|
||||
//std::cout<<"Render: "<<i<<std::endl;
|
||||
vtkm::rendering::ColorTable colorTable("thermal");
|
||||
vtkm::rendering::testing::Render<M,C,V3>(ds, "scalar", colorTable);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderVolTest(const vtkm::cont::DataSet &ds, int N)
|
||||
{
|
||||
std::cout<<"Volume Rendering test :"<<N<<std::endl;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
|
||||
typedef vtkm::rendering::MapperVolume M;
|
||||
typedef vtkm::rendering::CanvasRayTracer C;
|
||||
typedef vtkm::rendering::View3D V3;
|
||||
|
||||
//std::cout<<"Render: "<<i<<std::endl;
|
||||
vtkm::rendering::ColorTable colorTable("thermal");
|
||||
vtkm::rendering::testing::Render<M,C,V3>(ds, "scalar", colorTable);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalFacesTest(const vtkm::cont::DataSet &ds, int N)
|
||||
{
|
||||
std::cout<<"External Face test: "<<N<<std::endl;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (printProgress && i % 10 == 0)
|
||||
std::cout<<" "<<i<<" of "<<N<<std::endl;
|
||||
|
||||
vtkm::cont::CellSetExplicit<> inCellSet;
|
||||
//vtkm::cont::CellSetSingleType<> inCellSet;
|
||||
ds.GetCellSet(0).CopyTo(inCellSet);
|
||||
vtkm::cont::CellSetExplicit<> outCellSet("cells");
|
||||
//vtkm::cont::CellSetSingleType<> outCellSet("cells");
|
||||
//Run the External Faces worklet
|
||||
vtkm::worklet::ExternalFaces().Run(inCellSet,
|
||||
outCellSet,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::DataSet outDataSet;
|
||||
for(vtkm::IdComponent i=0; i < ds.GetNumberOfCoordinateSystems(); ++i)
|
||||
outDataSet.AddCoordinateSystem(ds.GetCoordinateSystem(i));
|
||||
outDataSet.AddCellSet(outCellSet);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Notes:
|
||||
render: 256 reg and rect. 100 iterations.
|
||||
|
||||
expl: external faces requires non-SingleType explicit. Forced reader to use this.
|
||||
|
||||
streamlines: vector field must be named "vecData"
|
||||
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (0)
|
||||
{
|
||||
int d = 16;
|
||||
if (argc > 1)
|
||||
d = atoi(argv[1]);
|
||||
CreateData(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc != 5)
|
||||
{
|
||||
std::cout<<"Error: "<<argv[0]<<" <algo:iso/sl/ext/rt/vol> N SZ <ftype:reg/rect/expl>"<<std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
std::string alg = argv[1];
|
||||
int N = atoi(argv[2]);
|
||||
|
||||
if (alg == "sl")
|
||||
{
|
||||
char fname[64];
|
||||
sprintf(fname,"../data/tornado.vec");
|
||||
std::cout<<"Reading file: "<<fname<<std::endl;
|
||||
|
||||
FILE * pFile = fopen(fname, "rb");
|
||||
int dims[3];
|
||||
size_t ret_code = fread(dims, sizeof(int), 3, pFile);
|
||||
const vtkm::Id3 vdims(dims[0], dims[1], dims[2]);
|
||||
vtkm::Id nElements = vdims[0] * vdims[1] * vdims[2] * 3;
|
||||
float* data = new float[static_cast<std::size_t>(nElements)];
|
||||
ret_code = fread(data, sizeof(float), static_cast<std::size_t>(nElements), pFile);
|
||||
fclose(pFile);
|
||||
|
||||
std::vector<vtkm::Vec<vtkm::Float32, 3> > field;
|
||||
for (vtkm::Id i = 0; i < nElements; i++)
|
||||
{
|
||||
vtkm::Float32 x = data[i];
|
||||
vtkm::Float32 y = data[++i];
|
||||
vtkm::Float32 z = data[++i];
|
||||
vtkm::Vec<vtkm::Float32, 3> vecData(x, y, z);
|
||||
field.push_back(Normalize(vecData));
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3> > fieldArray;
|
||||
fieldArray = vtkm::cont::make_ArrayHandle(field);
|
||||
|
||||
// Construct the input dataset (uniform) to hold the input and set vector data
|
||||
vtkm::cont::DataSet ds;
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims);
|
||||
ds.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
ds.AddField(vtkm::cont::Field("vec", vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
|
||||
vtkm::cont::CellSetStructured<3> inCellSet("cells");
|
||||
inCellSet.SetPointDimensions(vtkm::make_Vec(vdims[0], vdims[1], vdims[2]));
|
||||
ds.AddCellSet(inCellSet);
|
||||
|
||||
StreamlineTest(ds, N);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int sz = atoi(argv[3]);
|
||||
std::string ftype = argv[4];
|
||||
|
||||
char fname[64];
|
||||
sprintf(fname, "../data/s%s_%d.vtk", ftype.c_str(), sz);
|
||||
std::cout<<"FNAME= "<<fname<<std::endl;
|
||||
|
||||
vtkm::cont::DataSet ds;
|
||||
if (sz < 0)
|
||||
{
|
||||
vtkm::cont::testing::MakeTestDataSet dataSetMaker;
|
||||
ds = dataSetMaker.Make3DExplicitDataSet5();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Reading file: "<<fname<<std::endl;
|
||||
vtkm::io::reader::VTKDataSetReader rdr(fname);
|
||||
ds = rdr.ReadDataSet();
|
||||
}
|
||||
|
||||
if (alg == "iso")
|
||||
MarchingCubesTest(ds, N);
|
||||
else if (alg == "ext")
|
||||
ExternalFacesTest(ds, N);
|
||||
else if (alg == "rt")
|
||||
RenderRTTest(ds, N);
|
||||
else if (alg == "vol")
|
||||
RenderVolTest(ds, N);
|
||||
return 0;
|
||||
}
|
||||
}
|
23
examples/tau_timing/TauTimingTBB.cxx
Normal file
23
examples/tau_timing/TauTimingTBB.cxx
Normal file
@ -0,0 +1,23 @@
|
||||
//============================================================================
|
||||
// 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 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// 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.
|
||||
//============================================================================
|
||||
|
||||
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_TBB
|
||||
|
||||
#include "TauTiming.cxx"
|
@ -692,14 +692,16 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const ComponentType& operator[](vtkm::IdComponent idx) const
|
||||
//DRP
|
||||
/* inline */ const ComponentType& operator[](vtkm::IdComponent idx) const
|
||||
{
|
||||
VTKM_ASSERT(idx >= 0);
|
||||
VTKM_ASSERT(idx < NUM_COMPONENTS);
|
||||
return this->Components[idx];
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
ComponentType& operator[](vtkm::IdComponent idx)
|
||||
//DRP
|
||||
/*inline*/ ComponentType& operator[](vtkm::IdComponent idx)
|
||||
{
|
||||
VTKM_ASSERT(idx >= 0);
|
||||
VTKM_ASSERT(idx < NUM_COMPONENTS);
|
||||
|
@ -59,7 +59,8 @@ public:
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template<vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT
|
||||
void CopyInto(vtkm::Vec<ComponentType,DestSize> &dest) const
|
||||
//DRP
|
||||
/*inline*/ void CopyInto(vtkm::Vec<ComponentType,DestSize> &dest) const
|
||||
{
|
||||
vtkm::IdComponent numComponents =
|
||||
vtkm::Min(DestSize, this->GetNumberOfComponents());
|
||||
@ -69,9 +70,40 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//DRP
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template<vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT
|
||||
inline void CopyRangeInto(vtkm::Vec<ComponentType,DestSize> &dest) const
|
||||
{
|
||||
this->Portal.CopyRangeInto((*this->Indices), dest);
|
||||
}
|
||||
|
||||
//DRP
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ComponentType operator[](vtkm::IdComponent index) const
|
||||
inline void Copy8(vtkm::Vec<ComponentType,8> &dest) const
|
||||
{
|
||||
this->Portal.Get8((*this->Indices), dest);
|
||||
|
||||
//dest[0] = this->Portal.Get_1((*this->Indices)); //(*this->Indices));
|
||||
/*
|
||||
dest[0] = this->Portal.Get((*this->Indices)[0]);
|
||||
dest[1] = this->Portal.Get((*this->Indices)[1]);
|
||||
dest[2] = this->Portal.Get((*this->Indices)[2]);
|
||||
dest[3] = this->Portal.Get((*this->Indices)[3]);
|
||||
dest[4] = this->Portal.Get((*this->Indices)[4]);
|
||||
dest[5] = this->Portal.Get((*this->Indices)[5]);
|
||||
dest[6] = this->Portal.Get((*this->Indices)[6]);
|
||||
dest[7] = this->Portal.Get((*this->Indices)[7]);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
//DRP
|
||||
/* inline*/ ComponentType operator[](vtkm::IdComponent index) const
|
||||
{
|
||||
return this->Portal.Get((*this->Indices)[index]);
|
||||
}
|
||||
|
@ -174,13 +174,121 @@ public:
|
||||
return this->NumberOfValues;
|
||||
}
|
||||
|
||||
//DRP
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template<typename T1, typename T2>
|
||||
VTKM_EXEC_CONT
|
||||
inline void CopyRangeInto(const T1 &indices, T2 &vals) const
|
||||
{
|
||||
std::cout<<" WRONG CopyRangeInto()"<<std::endl;
|
||||
}
|
||||
|
||||
//DRP
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const
|
||||
inline void CopyRangeInto(const vtkm::Vec<vtkm::Id,8> &indices, vtkm::Vec<ValueType,8> &vals) const
|
||||
{
|
||||
//std::cout<<"Inside RIGHT CopyRangeInto()"<<std::endl;
|
||||
vals[0] = *(this->BeginIterator + indices[0]);
|
||||
vals[1] = *(this->BeginIterator + indices[1]);
|
||||
vals[2] = *(this->BeginIterator + indices[2]);
|
||||
vals[3] = *(this->BeginIterator + indices[3]);
|
||||
vals[4] = *(this->BeginIterator + indices[4]);
|
||||
vals[5] = *(this->BeginIterator + indices[5]);
|
||||
vals[6] = *(this->BeginIterator + indices[6]);
|
||||
vals[7] = *(this->BeginIterator + indices[7]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
// template<vtkm::IdComponent N, vtkm::IdComponent M>
|
||||
VTKM_EXEC_CONT
|
||||
// inline void CopyRangeInto(const vtkm::Vec<vtkm::Id, N> &indices, vtkm::Vec<ValueType, M> &vals) const
|
||||
inline void CopyRangeInto(const vtkm::Vec<vtkm::Id,8> &indices, vtkm::Vec<ValueType,8> &vals) const
|
||||
{
|
||||
std::cout<<"Inside CopyRangeInto()"<<std::endl;
|
||||
/*
|
||||
for (int i = 0; i < N; i++)
|
||||
vals[i] = *(this->BeginIterator + indices[i]);
|
||||
*/
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
inline void CopyRangeInto(const vtkm::Vec<vtkm::Id,4> &indices, vtkm::Vec<ValueType,8> &vals) const
|
||||
{
|
||||
std::cout<<"Inside CopyRangeInto()"<<std::endl;
|
||||
/*
|
||||
for (int i = 0; i < N; i++)
|
||||
vals[i] = *(this->BeginIterator + indices[i]);
|
||||
*/
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
inline void CopyRangeInto(const vtkm::Vec<vtkm::Id,4> &indices, vtkm::Vec<double,8> &vals) const
|
||||
{
|
||||
std::cout<<"Inside CopyRangeInto()"<<std::endl;
|
||||
/*
|
||||
for (int i = 0; i < N; i++)
|
||||
vals[i] = *(this->BeginIterator + indices[i]);
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
//DRP
|
||||
/* inline*/ ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
return *this->IteratorAt(index);
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
inline ValueType Get_1(const vtkm::Vec<vtkm::Id,8> &indices) const
|
||||
{
|
||||
std::cout<<"In Get_1()"<<std::endl;
|
||||
//return this->BeginIterator + 0; //indices[0];
|
||||
return *this->IteratorAt(indices[0]);
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
inline void Get8(const vtkm::Vec<vtkm::Id,8> &indices, vtkm::Vec<ValueType,8> &vals) const
|
||||
{
|
||||
}
|
||||
|
||||
//DRP
|
||||
#if 0
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <>
|
||||
VTKM_EXEC_CONT
|
||||
inline void Get8(const vtkm::Vec<vtkm::Id,8> &indices, vtkm::Vec<ValueType,8> &vals) const
|
||||
{
|
||||
//std::cout<<"HI THERE"<<std::endl;
|
||||
vals[0] = *(this->BeginIterator + indices[0]);
|
||||
vals[1] = *(this->BeginIterator + indices[1]);
|
||||
vals[2] = *(this->BeginIterator + indices[2]);
|
||||
vals[3] = *(this->BeginIterator + indices[3]);
|
||||
vals[4] = *(this->BeginIterator + indices[4]);
|
||||
vals[5] = *(this->BeginIterator + indices[5]);
|
||||
vals[6] = *(this->BeginIterator + indices[6]);
|
||||
vals[7] = *(this->BeginIterator + indices[7]);
|
||||
|
||||
/*
|
||||
vals[0] = this->BeginIterator + index;
|
||||
vals[1] = this->BeginIterator + index + 1;
|
||||
vals[2] = this->BeginIterator + index + 2;
|
||||
vals[3] = this->BeginIterator + index + 3;
|
||||
vals[4] = this->BeginIterator + index + 4;
|
||||
vals[5] = this->BeginIterator + index + 5;
|
||||
vals[6] = this->BeginIterator + index + 6;
|
||||
vals[7] = this->BeginIterator + index + 7;
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
|
||||
@ -202,7 +310,8 @@ private:
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
IteratorT IteratorAt(vtkm::Id index) const
|
||||
//DRP
|
||||
/* inline*/ IteratorT IteratorAt(vtkm::Id index) const
|
||||
{
|
||||
VTKM_ASSERT(index >= 0);
|
||||
VTKM_ASSERT(index < this->GetNumberOfValues());
|
||||
|
@ -383,7 +383,8 @@ public:
|
||||
typedef vtkm::CellShapeTagHexahedron CellShapeTag;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL>
|
||||
//DRP
|
||||
/* inline */ vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL>
|
||||
GetPointsOfCell(const SchedulingRangeType &ijk) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,NUM_POINTS_IN_CELL> pointIds;
|
||||
|
@ -76,7 +76,8 @@ private:
|
||||
vtkm::io::internal::FixupCellSet(connectivity, numIndices, shapes, permutation);
|
||||
this->SetCellsPermutation(permutation);
|
||||
|
||||
if (vtkm::io::internal::IsSingleShape(shapes))
|
||||
//DRP
|
||||
if (false) //vtkm::io::internal::IsSingleShape(shapes))
|
||||
{
|
||||
vtkm::cont::CellSetSingleType<> cellSet("cells");
|
||||
cellSet.Fill(numPoints,
|
||||
|
@ -129,11 +129,11 @@ if(VTKm_OpenGL_FOUND)
|
||||
list(APPEND sources ${osmesa_sources})
|
||||
endif()
|
||||
|
||||
vtkm_configure_component_EGL()
|
||||
if(VTKm_EGL_FOUND)
|
||||
list(APPEND headers ${egl_headers})
|
||||
list(APPEND sources ${egl_sources})
|
||||
endif()
|
||||
# vtkm_configure_component_EGL()
|
||||
# if(VTKm_EGL_FOUND)
|
||||
# list(APPEND headers ${egl_headers})
|
||||
# list(APPEND sources ${egl_sources})
|
||||
# endif()
|
||||
endif()
|
||||
|
||||
if(VTKm_ENABLE_OSMESA AND NOT VTKm_OSMesa_FOUND)
|
||||
|
@ -31,7 +31,7 @@ set(unit_tests
|
||||
|
||||
VTKm_unit_tests(SOURCES ${unit_tests})
|
||||
|
||||
add_subdirectory(osmesa)
|
||||
add_subdirectory(egl)
|
||||
add_subdirectory(glfw)
|
||||
#add_subdirectory(osmesa)
|
||||
#add_subdirectory(egl)
|
||||
#add_subdirectory(glfw)
|
||||
|
||||
|
@ -87,11 +87,12 @@ SetCamera<vtkm::rendering::View1D>(vtkm::rendering::Camera &camera,
|
||||
template <typename MapperType,typename CanvasType, typename ViewType>
|
||||
void
|
||||
Render(ViewType &view,
|
||||
const std::string &outputFile)
|
||||
const std::string &outputFile="")
|
||||
{
|
||||
view.Initialize();
|
||||
view.Paint();
|
||||
view.SaveAs(outputFile);
|
||||
if (outputFile.size() > 0)
|
||||
view.SaveAs(outputFile);
|
||||
}
|
||||
|
||||
template <typename MapperType,typename CanvasType, typename ViewType>
|
||||
@ -99,7 +100,7 @@ void
|
||||
Render(const vtkm::cont::DataSet &ds,
|
||||
const std::string &fieldNm,
|
||||
const vtkm::rendering::ColorTable &colorTable,
|
||||
const std::string &outputFile)
|
||||
const std::string &outputFile="")
|
||||
{
|
||||
MapperType mapper;
|
||||
CanvasType canvas(512,512);
|
||||
@ -122,7 +123,7 @@ template <typename MapperType,typename CanvasType, typename ViewType>
|
||||
void
|
||||
Render(const vtkm::cont::DataSet &ds,
|
||||
const std::string &fieldNm,
|
||||
const std::string &outputFile)
|
||||
const std::string &outputFile="")
|
||||
{
|
||||
MapperType mapper;
|
||||
CanvasType canvas(512,512);
|
||||
|
@ -43,6 +43,10 @@
|
||||
|
||||
#include <vtkm/worklet/MarchingCubesDataTables.h>
|
||||
|
||||
//#define WHICH0
|
||||
//#define WHICH1
|
||||
#define WHICH2
|
||||
|
||||
namespace vtkm {
|
||||
namespace worklet {
|
||||
|
||||
@ -70,7 +74,8 @@ make_ScalarField(const vtkm::cont::ArrayHandle<vtkm::Int8,S>& ah)
|
||||
// -----------------------------------------------------------------------------
|
||||
template<typename T, typename U>
|
||||
VTKM_EXEC
|
||||
int GetHexahedronClassification(const T& values, const U isoValue)
|
||||
//DRP
|
||||
inline int GetHexahedronClassification(const T& values, const U isoValue)
|
||||
{
|
||||
return ((values[0] > isoValue) |
|
||||
(values[1] > isoValue) << 1 |
|
||||
@ -81,6 +86,48 @@ int GetHexahedronClassification(const T& values, const U isoValue)
|
||||
(values[6] > isoValue) << 6 |
|
||||
(values[7] > isoValue) << 7);
|
||||
}
|
||||
|
||||
#if 1
|
||||
template<>
|
||||
VTKM_EXEC
|
||||
inline int
|
||||
GetHexahedronClassification<vtkm::VecFromPortalPermute<vtkm::Vec<long long, 8>,
|
||||
vtkm::cont::internal::ArrayPortalFromIterators<float const*, void> >,
|
||||
float>
|
||||
(
|
||||
vtkm::VecFromPortalPermute<vtkm::Vec<long long, 8>,
|
||||
vtkm::cont::internal::ArrayPortalFromIterators<float const*, void> > const& values,
|
||||
float isoValue
|
||||
)
|
||||
{
|
||||
//Original
|
||||
#if 1
|
||||
return ((values[0] > isoValue) |
|
||||
(values[1] > isoValue) << 1 |
|
||||
(values[2] > isoValue) << 2 |
|
||||
(values[3] > isoValue) << 3 |
|
||||
(values[4] > isoValue) << 4 |
|
||||
(values[5] > isoValue) << 5 |
|
||||
(values[6] > isoValue) << 6 |
|
||||
(values[7] > isoValue) << 7);
|
||||
#else
|
||||
vtkm::Vec<vtkm::Float32, 8> vals;
|
||||
values.Copy8(vals);
|
||||
|
||||
return ((vals[0] > isoValue) |
|
||||
(vals[1] > isoValue) << 1 |
|
||||
(vals[2] > isoValue) << 2 |
|
||||
(vals[3] > isoValue) << 3 |
|
||||
(vals[4] > isoValue) << 4 |
|
||||
(vals[5] > isoValue) << 5 |
|
||||
(vals[6] > isoValue) << 6 |
|
||||
(vals[7] > isoValue) << 7);
|
||||
#endif
|
||||
|
||||
// std::cout<<"GetHexClassification: val= "<<isoValue<<" ["<<vals[0]<<" "<<vals[1]<<" "<<vals[2]<<" "<<vals[3]<<" "<<vals[4]<<" "<<vals[5]<<" "<<vals[6]<<" "<<vals[7]<<"]"<<std::endl;
|
||||
// return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
@ -114,9 +161,34 @@ public:
|
||||
{
|
||||
typedef typename vtkm::VecTraits<FieldInType>::ComponentType FieldType;
|
||||
const FieldType iso = static_cast<FieldType>(this->Isovalue);
|
||||
|
||||
const vtkm::IdComponent caseNumber =
|
||||
GetHexahedronClassification(fieldIn, iso);
|
||||
#ifdef WHICH0
|
||||
const vtkm::IdComponent caseNumber = GetHexahedronClassification(fieldIn, iso);
|
||||
#endif
|
||||
#ifdef WHICH1
|
||||
const vtkm::IdComponent caseNumber = ((fieldIn[0] > iso) |
|
||||
(fieldIn[1] > iso) << 1 |
|
||||
(fieldIn[2] > iso) << 2 |
|
||||
(fieldIn[3] > iso) << 3 |
|
||||
(fieldIn[4] > iso) << 4 |
|
||||
(fieldIn[5] > iso) << 5 |
|
||||
(fieldIn[6] > iso) << 6 |
|
||||
(fieldIn[7] > iso) << 7);
|
||||
#endif
|
||||
#ifdef WHICH2
|
||||
vtkm::Vec<FieldType, 8> vals;
|
||||
fieldIn.CopyRangeInto(vals);
|
||||
//fieldIn.CopyInto(vals);
|
||||
//fieldIn.Copy8(vals);
|
||||
const vtkm::IdComponent caseNumber = ((vals[0] > iso) |
|
||||
(vals[1] > iso) << 1 |
|
||||
(vals[2] > iso) << 2 |
|
||||
(vals[3] > iso) << 3 |
|
||||
(vals[4] > iso) << 4 |
|
||||
(vals[5] > iso) << 5 |
|
||||
(vals[6] > iso) << 6 |
|
||||
(vals[7] > iso) << 7);
|
||||
#endif
|
||||
|
||||
numTriangles = numTrianglesTable.Get(caseNumber);
|
||||
}
|
||||
};
|
||||
@ -267,8 +339,32 @@ public:
|
||||
const FieldType iso = static_cast<FieldType>(this->Isovalue);
|
||||
|
||||
// Compute the Marching Cubes case number for this cell
|
||||
const vtkm::IdComponent caseNumber =
|
||||
GetHexahedronClassification(fieldIn, iso);
|
||||
#ifdef WHICH0
|
||||
const vtkm::IdComponent caseNumber = GetHexahedronClassification(fieldIn, iso);
|
||||
#endif
|
||||
#ifdef WHICH1
|
||||
const vtkm::IdComponent caseNumber = ((fieldIn[0] > iso) |
|
||||
(fieldIn[1] > iso) << 1 |
|
||||
(fieldIn[2] > iso) << 2 |
|
||||
(fieldIn[3] > iso) << 3 |
|
||||
(fieldIn[4] > iso) << 4 |
|
||||
(fieldIn[5] > iso) << 5 |
|
||||
(fieldIn[6] > iso) << 6 |
|
||||
(fieldIn[7] > iso) << 7);
|
||||
#endif
|
||||
#ifdef WHICH2
|
||||
vtkm::Vec<FieldType, 8> vals;
|
||||
fieldIn.CopyRangeInto(vals);
|
||||
//fieldIn.Copy8(vals);
|
||||
const vtkm::IdComponent caseNumber = ((vals[0] > iso) |
|
||||
(vals[1] > iso) << 1 |
|
||||
(vals[2] > iso) << 2 |
|
||||
(vals[3] > iso) << 3 |
|
||||
(vals[4] > iso) << 4 |
|
||||
(vals[5] > iso) << 5 |
|
||||
(vals[6] > iso) << 6 |
|
||||
(vals[7] > iso) << 7);
|
||||
#endif
|
||||
|
||||
// Interpolate for vertex positions and associated scalar values
|
||||
const vtkm::Id triTableOffset =
|
||||
|
Loading…
Reference in New Issue
Block a user