clang-format: apply to the entire tree
This commit is contained in:
parent
9e56a5d881
commit
4ade5f5770
@ -25,8 +25,10 @@
|
||||
int main()
|
||||
{
|
||||
int count = 0;
|
||||
if (cudaSuccess != cudaGetDeviceCount(&count)) return 1;
|
||||
if (count == 0) return 1;
|
||||
if (cudaSuccess != cudaGetDeviceCount(&count))
|
||||
return 1;
|
||||
if (count == 0)
|
||||
return 1;
|
||||
|
||||
int prev_arch = 0;
|
||||
for (int device = 0; device < count; ++device)
|
||||
@ -37,10 +39,16 @@ int main()
|
||||
int arch = (prop.major * 10) + prop.minor;
|
||||
int compute_level = arch;
|
||||
//arch 21 has no equivalent compute level.
|
||||
if(compute_level == 21) { compute_level = 20; }
|
||||
if (compute_level == 21)
|
||||
{
|
||||
compute_level = 20;
|
||||
}
|
||||
|
||||
//handle multiple cards of the same architecture
|
||||
if(arch == prev_arch) { continue; }
|
||||
if (arch == prev_arch)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
prev_arch = arch;
|
||||
printf(" --generate-code=arch=compute_%d,code=sm_%d", compute_level, arch);
|
||||
}
|
||||
|
@ -34,29 +34,24 @@
|
||||
|
||||
typedef vtkm::Vec<vtkm::Float32, 3> FloatVec3;
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 4)
|
||||
{
|
||||
std::cout << "Usage: " << std::endl
|
||||
<< "$ " << argv[0]
|
||||
<< " <input_vtk_file> [fieldName] <isoval> <output_vtk_file>"
|
||||
<< "$ " << argv[0] << " <input_vtk_file> [fieldName] <isoval> <output_vtk_file>"
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
|
||||
std::cout << "Device Adapter Name: "
|
||||
<< vtkm::cont::DeviceAdapterTraits<DeviceAdapter>::GetName()
|
||||
std::cout << "Device Adapter Name: " << vtkm::cont::DeviceAdapterTraits<DeviceAdapter>::GetName()
|
||||
<< std::endl;
|
||||
|
||||
vtkm::io::reader::VTKDataSetReader reader(argv[1]);
|
||||
vtkm::cont::DataSet input = reader.ReadDataSet();
|
||||
|
||||
vtkm::cont::Field scalarField = (argc == 5) ?
|
||||
input.GetField(argv[2]) :
|
||||
input.GetField(0);
|
||||
vtkm::cont::Field scalarField = (argc == 5) ? input.GetField(argv[2]) : input.GetField(0);
|
||||
|
||||
vtkm::Float32 clipValue = std::stof(argv[argc - 2]);
|
||||
vtkm::worklet::Clip clip;
|
||||
@ -64,10 +59,8 @@ int main(int argc, char *argv[])
|
||||
vtkm::cont::Timer<DeviceAdapter> total;
|
||||
vtkm::cont::Timer<DeviceAdapter> timer;
|
||||
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||
clip.Run(input.GetCellSet(0),
|
||||
scalarField.GetData().ResetTypeList(vtkm::TypeListTagScalarAll()),
|
||||
clipValue,
|
||||
DeviceAdapter());
|
||||
clip.Run(input.GetCellSet(0), scalarField.GetData().ResetTypeList(vtkm::TypeListTagScalarAll()),
|
||||
clipValue, DeviceAdapter());
|
||||
vtkm::Float64 clipTime = timer.GetElapsedTime();
|
||||
|
||||
vtkm::cont::DataSet output;
|
||||
@ -88,10 +81,8 @@ int main(int argc, char *argv[])
|
||||
continue; // clip only supports point fields for now.
|
||||
}
|
||||
vtkm::cont::DynamicArrayHandle data =
|
||||
clip.ProcessField(inField.GetData().ResetTypeList(vtkm::TypeListTagAll()),
|
||||
DeviceAdapter());
|
||||
output.AddField(vtkm::cont::Field(inField.GetName(),
|
||||
vtkm::cont::Field::ASSOC_POINTS, data));
|
||||
clip.ProcessField(inField.GetData().ResetTypeList(vtkm::TypeListTagAll()), DeviceAdapter());
|
||||
output.AddField(vtkm::cont::Field(inField.GetName(), vtkm::cont::Field::ASSOC_POINTS, data));
|
||||
}
|
||||
vtkm::Float64 processScalarsTime = timer.GetElapsedTime();
|
||||
|
||||
|
@ -81,7 +81,8 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
std::cout << "ContourTreeMesh2D Example" << std::endl;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 2)
|
||||
{
|
||||
std::cout << "Parameter is fileName" << std::endl;
|
||||
std::cout << "File is expected to be ASCII with xdim ydim integers " << std::endl;
|
||||
std::cout << "followed by vector data last dimension varying fastest" << std::endl;
|
||||
@ -90,7 +91,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
// open input file
|
||||
std::ifstream inFile(argv[1]);
|
||||
if (inFile.bad()) return 0;
|
||||
if (inFile.bad())
|
||||
return 0;
|
||||
|
||||
// read size of mesh
|
||||
vtkm::Id2 vdims;
|
||||
|
@ -81,7 +81,8 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
std::cout << "ContourTreeMesh3D Example" << std::endl;
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 2)
|
||||
{
|
||||
std::cout << "Parameter is fileName" << std::endl;
|
||||
std::cout << "File is expected to be ASCII with xdim ydim zdim integers " << std::endl;
|
||||
std::cout << "followed by vector data last dimension varying fastest" << std::endl;
|
||||
@ -90,15 +91,15 @@ int main(int argc, char* argv[])
|
||||
|
||||
// open input file
|
||||
std::ifstream inFile(argv[1]);
|
||||
if (inFile.bad()) return 0;
|
||||
if (inFile.bad())
|
||||
return 0;
|
||||
|
||||
// read size of mesh
|
||||
vtkm::Id3 vdims;
|
||||
inFile >> vdims[0];
|
||||
inFile >> vdims[1];
|
||||
inFile >> vdims[2];
|
||||
std::size_t nVertices =
|
||||
static_cast<std::size_t>(vdims[0] * vdims[1] * vdims[2]);
|
||||
std::size_t nVertices = static_cast<std::size_t>(vdims[0] * vdims[1] * vdims[2]);
|
||||
|
||||
// read data
|
||||
std::vector<vtkm::Float32> values(nVertices);
|
||||
|
@ -34,17 +34,11 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void makeScene(const vtkm::cont::DataSet &inputData,
|
||||
const vtkm::rendering::ColorTable &colorTable,
|
||||
const std::string &fieldName,
|
||||
vtkm::rendering::Scene &scene)
|
||||
void makeScene(const vtkm::cont::DataSet& inputData, const vtkm::rendering::ColorTable& colorTable,
|
||||
const std::string& fieldName, vtkm::rendering::Scene& scene)
|
||||
{
|
||||
scene.AddActor(vtkm::rendering::Actor(inputData.GetCellSet(),
|
||||
inputData.GetCoordinateSystem(),
|
||||
inputData.GetField(fieldName),
|
||||
colorTable));
|
||||
|
||||
|
||||
scene.AddActor(vtkm::rendering::Actor(inputData.GetCellSet(), inputData.GetCoordinateSystem(),
|
||||
inputData.GetField(fieldName), colorTable));
|
||||
}
|
||||
|
||||
// This example reads an input vtk file specified on the command-line (or generates a default
|
||||
@ -111,11 +105,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
makeScene(inputData, colorTable, fieldName, scene);
|
||||
// Create a view and use it to render the input data using OS Mesa
|
||||
vtkm::rendering::View3D view(scene,
|
||||
mapper,
|
||||
canvas,
|
||||
camera,
|
||||
bg);
|
||||
vtkm::rendering::View3D view(scene, mapper, canvas, camera, bg);
|
||||
view.Initialize();
|
||||
view.Paint();
|
||||
view.SaveAs("demo_input.pnm");
|
||||
@ -125,8 +115,7 @@ int main(int argc, char* argv[])
|
||||
filter.SetGenerateNormals(false);
|
||||
filter.SetMergeDuplicatePoints(false);
|
||||
filter.SetIsoValue(0, isovalue);
|
||||
vtkm::filter::ResultDataSet result = filter.Execute( inputData,
|
||||
inputData.GetField(fieldName) );
|
||||
vtkm::filter::ResultDataSet result = filter.Execute(inputData, inputData.GetField(fieldName));
|
||||
filter.MapFieldOntoOutput(result, inputData.GetField(fieldName));
|
||||
vtkm::cont::DataSet& outputData = result.GetDataSet();
|
||||
// Render a separate image with the output isosurface
|
||||
@ -134,12 +123,7 @@ int main(int argc, char* argv[])
|
||||
vtkm::rendering::Scene scene2;
|
||||
makeScene(outputData, colorTable, fieldName, scene2);
|
||||
|
||||
|
||||
vtkm::rendering::View3D view2(scene2,
|
||||
mapper,
|
||||
canvas,
|
||||
camera,
|
||||
bg);
|
||||
vtkm::rendering::View3D view2(scene2, mapper, canvas, camera, bg);
|
||||
view2.Initialize();
|
||||
view2.Paint();
|
||||
view2.SaveAs("demo_output.pnm");
|
||||
|
@ -31,18 +31,13 @@
|
||||
|
||||
struct ExampleFieldWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
typedef void ControlSignature( FieldIn<>, FieldIn<>, FieldIn<>,
|
||||
FieldOut<>, FieldOut<>, FieldOut<> );
|
||||
typedef void ControlSignature(FieldIn<>, FieldIn<>, FieldIn<>, FieldOut<>, FieldOut<>,
|
||||
FieldOut<>);
|
||||
typedef void ExecutionSignature(_1, _2, _3, _4, _5, _6);
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
VTKM_EXEC
|
||||
void operator()( const vtkm::Vec< T, 3 > & vec,
|
||||
const U & scalar1,
|
||||
const V& scalar2,
|
||||
vtkm::Vec<T, 3>& out_vec,
|
||||
U& out_scalar1,
|
||||
V& out_scalar2 ) const
|
||||
VTKM_EXEC void operator()(const vtkm::Vec<T, 3>& vec, const U& scalar1, const V& scalar2,
|
||||
vtkm::Vec<T, 3>& out_vec, U& out_scalar1, V& out_scalar2) const
|
||||
{
|
||||
out_vec = vec * scalar1;
|
||||
out_scalar1 = static_cast<U>(scalar1 + scalar2);
|
||||
@ -51,19 +46,12 @@ struct ExampleFieldWorklet : public vtkm::worklet::WorkletMapField
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V, typename W, typename X, typename Y>
|
||||
VTKM_EXEC
|
||||
void operator()( const T &,
|
||||
const U &,
|
||||
const V&,
|
||||
W&,
|
||||
X&,
|
||||
Y& ) const
|
||||
VTKM_EXEC void operator()(const T&, const U&, const V&, W&, X&, Y&) const
|
||||
{
|
||||
//no-op
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void)argc;
|
||||
@ -76,11 +64,9 @@ int main(int argc, char** argv)
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>> handleV =
|
||||
vtkm::cont::make_ArrayHandle(inputVec);
|
||||
|
||||
vtkm::cont::ArrayHandle< vtkm::Int32 > handleS1 =
|
||||
vtkm::cont::make_ArrayHandle(inputScalar1);
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> handleS1 = vtkm::cont::make_ArrayHandle(inputScalar1);
|
||||
|
||||
vtkm::cont::ArrayHandle< vtkm::Float64 > handleS2 =
|
||||
vtkm::cont::make_ArrayHandle(inputScalar2);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> handleS2 = vtkm::cont::make_ArrayHandle(inputScalar2);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>> handleOV;
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> handleOS1;
|
||||
@ -90,6 +76,4 @@ int main(int argc, char** argv)
|
||||
|
||||
vtkm::worklet::DispatcherMapField<ExampleFieldWorklet> dispatcher;
|
||||
dispatcher.Invoke(handleV, handleS1, handleS2, out1, out2, out3);
|
||||
|
||||
}
|
||||
|
||||
|
@ -68,17 +68,17 @@ struct HelloVTKMInterop
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> OutCoords;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> OutColors;
|
||||
|
||||
HelloVTKMInterop(vtkm::Int32 width, vtkm::Int32 height):
|
||||
Dims(256,256),
|
||||
ProgramId(),
|
||||
VAOId(),
|
||||
VBOState(),
|
||||
ColorState(),
|
||||
Timer(),
|
||||
InputData(),
|
||||
InHandle(),
|
||||
OutCoords(),
|
||||
OutColors()
|
||||
HelloVTKMInterop(vtkm::Int32 width, vtkm::Int32 height)
|
||||
: Dims(256, 256)
|
||||
, ProgramId()
|
||||
, VAOId()
|
||||
, VBOState()
|
||||
, ColorState()
|
||||
, Timer()
|
||||
, InputData()
|
||||
, InHandle()
|
||||
, OutCoords()
|
||||
, OutColors()
|
||||
{
|
||||
int dim = 256;
|
||||
this->InputData.reserve(static_cast<std::size_t>(dim * dim));
|
||||
@ -86,8 +86,7 @@ struct HelloVTKMInterop
|
||||
{
|
||||
for (int j = 0; j < dim; ++j)
|
||||
{
|
||||
this->InputData.push_back(vtkm::Vec<T,3>(2.f*static_cast<T>(i/dim)-1.f,
|
||||
0.f,
|
||||
this->InputData.push_back(vtkm::Vec<T, 3>(2.f * static_cast<T>(i / dim) - 1.f, 0.f,
|
||||
2.f * static_cast<T>(j / dim) - 1.f));
|
||||
}
|
||||
}
|
||||
@ -111,9 +110,8 @@ struct HelloVTKMInterop
|
||||
vtkm::Int32 arraySize = this->Dims[0] * this->Dims[1];
|
||||
|
||||
//precomputed based on 1027x768 render window size
|
||||
vtkm::Float32 mvp[16] = {-1.79259f, 0.f, 0.f, 0.f,
|
||||
0.f, 1.26755f, -0.721392f, -0.707107f,
|
||||
0.f, 1.26755f, 0.721392f, 0.707107f,
|
||||
vtkm::Float32 mvp[16] = { -1.79259f, 0.f, 0.f, 0.f, 0.f, 1.26755f,
|
||||
-0.721392f, -0.707107f, 0.f, 1.26755f, 0.721392f, 0.707107f,
|
||||
0.f, 0.f, 1.24076f, 1.41421f };
|
||||
|
||||
GLint unifLoc = glGetUniformLocation(this->ProgramId, "MVP");
|
||||
@ -136,14 +134,16 @@ struct HelloVTKMInterop
|
||||
struct GenerateSurfaceWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
vtkm::Float32 t;
|
||||
GenerateSurfaceWorklet(vtkm::Float32 st) : t(st) {}
|
||||
GenerateSurfaceWorklet(vtkm::Float32 st)
|
||||
: t(st)
|
||||
{
|
||||
}
|
||||
|
||||
typedef void ControlSignature(FieldIn<>, FieldOut<>, FieldOut<>);
|
||||
typedef void ExecutionSignature(_1, _2, _3);
|
||||
|
||||
VTKM_EXEC
|
||||
void operator()( const vtkm::Vec< T, 3 > & input,
|
||||
vtkm::Vec<T, 3> & output,
|
||||
void operator()(const vtkm::Vec<T, 3>& input, vtkm::Vec<T, 3>& output,
|
||||
vtkm::Vec<vtkm::UInt8, 4>& color) const
|
||||
{
|
||||
output[0] = input[0];
|
||||
@ -197,8 +197,8 @@ void idle()
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
typedef vtkm::cont::DeviceAdapterTraits<DeviceAdapter> DeviceAdapterTraits;
|
||||
std::cout << "Running Hello World example on device adapter: "
|
||||
<< DeviceAdapterTraits::GetName() << std::endl;
|
||||
std::cout << "Running Hello World example on device adapter: " << DeviceAdapterTraits::GetName()
|
||||
<< std::endl;
|
||||
|
||||
glewExperimental = GL_TRUE;
|
||||
glutInit(&argc, argv);
|
||||
|
@ -31,8 +31,7 @@ namespace shaders
|
||||
{
|
||||
static std::string const& make_fragment_shader_code()
|
||||
{
|
||||
static std::string const data =
|
||||
"#version 120\n"
|
||||
static std::string const data = "#version 120\n"
|
||||
"void main(void)"
|
||||
"{"
|
||||
" gl_FragColor = gl_Color;"
|
||||
@ -43,8 +42,7 @@ static std::string const& make_fragment_shader_code()
|
||||
|
||||
static std::string const& make_vertex_shader_code()
|
||||
{
|
||||
static std::string const data =
|
||||
"#version 120\n"
|
||||
static std::string const data = "#version 120\n"
|
||||
"attribute vec3 posAttr;"
|
||||
"uniform mat4 MVP;"
|
||||
"void main()"
|
||||
@ -56,7 +54,6 @@ static std::string const& make_vertex_shader_code()
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline GLuint LoadShaders()
|
||||
@ -123,7 +120,6 @@ inline GLuint LoadShaders()
|
||||
std::cout << &ProgramErrorMessage[0] << std::endl;
|
||||
}
|
||||
|
||||
|
||||
glDeleteShader(VertexShaderID);
|
||||
glDeleteShader(FragmentShaderID);
|
||||
|
||||
|
@ -55,7 +55,8 @@ static Quaternion qrot;
|
||||
static int lastx, lasty;
|
||||
static int mouse_state = 1;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
// Define the tangle field for the input data
|
||||
class TangleField : public vtkm::worklet::WorkletMapField
|
||||
@ -70,8 +71,17 @@ public:
|
||||
const vtkm::Id cellsPerLayer;
|
||||
|
||||
VTKM_CONT
|
||||
TangleField(const vtkm::Id3 dims, const vtkm::Float32 mins[3], const vtkm::Float32 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)) { };
|
||||
TangleField(const vtkm::Id3 dims, const vtkm::Float32 mins[3], const vtkm::Float32 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
|
||||
@ -88,11 +98,13 @@ public:
|
||||
const vtkm::Float32 yy = 3.0f * (ymin + (ymax - ymin) * (fy));
|
||||
const vtkm::Float32 zz = 3.0f * (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;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Construct an input data set using the tangle field worklet
|
||||
vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
{
|
||||
@ -104,20 +116,19 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
vtkm::Float32 maxs[3] = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> vertexCountImplicitArray(0, 1, vdims[0]*vdims[1]*vdims[2]);
|
||||
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(TangleField(vdims, mins, maxs));
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> vertexCountImplicitArray(0, 1, vdims[0] * vdims[1] *
|
||||
vdims[2]);
|
||||
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(
|
||||
TangleField(vdims, mins, maxs));
|
||||
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, fieldArray);
|
||||
|
||||
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]),
|
||||
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::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
dataSet.AddField(vtkm::cont::Field("nodevar", vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
|
||||
@ -128,10 +139,8 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Initialize the OpenGL state
|
||||
void initializeGL()
|
||||
{
|
||||
@ -157,7 +166,6 @@ void initializeGL()
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
|
||||
// Render the output using simple OpenGL
|
||||
void displayCall()
|
||||
{
|
||||
@ -194,7 +202,6 @@ void displayCall()
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
// Allow rotations of the view
|
||||
void mouseMove(int x, int y)
|
||||
{
|
||||
@ -218,14 +225,17 @@ void mouseMove(int x, int y)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
// Respond to mouse button
|
||||
void mouseCall(int button, int state, int x, int y)
|
||||
{
|
||||
if (button == 0) mouse_state = state;
|
||||
if ((button == 0) && (state == 0)) { lastx = x; lasty = y; }
|
||||
if (button == 0)
|
||||
mouse_state = state;
|
||||
if ((button == 0) && (state == 0))
|
||||
{
|
||||
lastx = x;
|
||||
lasty = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Compute and render an isosurface for a uniform grid example
|
||||
int main(int argc, char* argv[])
|
||||
@ -236,21 +246,20 @@ int main(int argc, char* argv[])
|
||||
filter.SetGenerateNormals(true);
|
||||
filter.SetMergeDuplicatePoints(false);
|
||||
filter.SetIsoValue(0, 0.5);
|
||||
vtkm::filter::ResultDataSet result =
|
||||
filter.Execute( dataSet, dataSet.GetField("nodevar") );
|
||||
vtkm::filter::ResultDataSet result = filter.Execute(dataSet, dataSet.GetField("nodevar"));
|
||||
|
||||
filter.MapFieldOntoOutput(result, dataSet.GetField("nodevar"));
|
||||
|
||||
//need to extract vertices, normals, and scalars
|
||||
vtkm::cont::DataSet& outputData = result.GetDataSet();
|
||||
|
||||
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>> VertType;
|
||||
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
|
||||
|
||||
verticesArray = coords.GetData().Cast<VertType>();
|
||||
normalsArray = outputData.GetField("normals").GetData().Cast<VertType>();
|
||||
scalarsArray = outputData.GetField("nodevar").GetData().Cast< vtkm::cont::ArrayHandle<vtkm::Float32> >();
|
||||
scalarsArray =
|
||||
outputData.GetField("nodevar").GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32>>();
|
||||
|
||||
std::cout << "Number of output vertices: " << verticesArray.GetNumberOfValues() << std::endl;
|
||||
|
||||
|
@ -36,13 +36,33 @@
|
||||
class Quaternion
|
||||
{
|
||||
public:
|
||||
Quaternion() { x = y = z = 0.0; w = 1.0; }
|
||||
Quaternion(double ax, double ay, double az, double aw) : x(ax), y(ay), z(az), w(aw) {};
|
||||
void set(double ax, double ay, double az, double aw) { x = ax; y = ay; z = az; w = aw; }
|
||||
Quaternion()
|
||||
{
|
||||
x = y = z = 0.0;
|
||||
w = 1.0;
|
||||
}
|
||||
Quaternion(double ax, double ay, double az, double aw)
|
||||
: x(ax)
|
||||
, y(ay)
|
||||
, z(az)
|
||||
, w(aw){};
|
||||
void set(double ax, double ay, double az, double aw)
|
||||
{
|
||||
x = ax;
|
||||
y = ay;
|
||||
z = az;
|
||||
w = aw;
|
||||
}
|
||||
void normalize()
|
||||
{
|
||||
float norm = static_cast<float>(sqrt(x * x + y * y + z * z + w * w));
|
||||
if (norm > 0.00001) { x /= norm; y /= norm; z /= norm; w /= norm; }
|
||||
if (norm > 0.00001)
|
||||
{
|
||||
x /= norm;
|
||||
y /= norm;
|
||||
z /= norm;
|
||||
w /= norm;
|
||||
}
|
||||
}
|
||||
void mul(Quaternion q)
|
||||
{
|
||||
@ -52,21 +72,31 @@ public:
|
||||
tz = w * q.z + z * q.w + x * q.y - y * q.x;
|
||||
tw = w * q.w - x * q.x - y * q.y - z * q.z;
|
||||
|
||||
x = tx; y = ty; z = tz; w = tw;
|
||||
x = tx;
|
||||
y = ty;
|
||||
z = tz;
|
||||
w = tw;
|
||||
}
|
||||
void setEulerAngles(float pitch, float yaw, float roll)
|
||||
{
|
||||
w = cos(pitch/2.0)*cos(yaw/2.0)*cos(roll/2.0) - sin(pitch/2.0)*sin(yaw/2.0)*sin(roll/2.0);
|
||||
x = sin(pitch/2.0)*sin(yaw/2.0)*cos(roll/2.0) + cos(pitch/2.0)*cos(yaw/2.0)*sin(roll/2.0);
|
||||
y = sin(pitch/2.0)*cos(yaw/2.0)*cos(roll/2.0) + cos(pitch/2.0)*sin(yaw/2.0)*sin(roll/2.0);
|
||||
z = cos(pitch/2.0)*sin(yaw/2.0)*cos(roll/2.0) - sin(pitch/2.0)*cos(yaw/2.0)*sin(roll/2.0);
|
||||
w = cos(pitch / 2.0) * cos(yaw / 2.0) * cos(roll / 2.0) -
|
||||
sin(pitch / 2.0) * sin(yaw / 2.0) * sin(roll / 2.0);
|
||||
x = sin(pitch / 2.0) * sin(yaw / 2.0) * cos(roll / 2.0) +
|
||||
cos(pitch / 2.0) * cos(yaw / 2.0) * sin(roll / 2.0);
|
||||
y = sin(pitch / 2.0) * cos(yaw / 2.0) * cos(roll / 2.0) +
|
||||
cos(pitch / 2.0) * sin(yaw / 2.0) * sin(roll / 2.0);
|
||||
z = cos(pitch / 2.0) * sin(yaw / 2.0) * cos(roll / 2.0) -
|
||||
sin(pitch / 2.0) * cos(yaw / 2.0) * sin(roll / 2.0);
|
||||
|
||||
normalize();
|
||||
}
|
||||
|
||||
void getRotMat(float* m) const
|
||||
{
|
||||
for (int i=0; i<16; i++) {m[i] = 0.0;}
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
m[i] = 0.0;
|
||||
}
|
||||
|
||||
m[0] = static_cast<float>(1.0 - 2.0 * y * y - 2.0 * z * z);
|
||||
m[1] = static_cast<float>(2.0 * x * y - 2.0 * z * w);
|
||||
@ -86,5 +116,4 @@ public:
|
||||
double x, y, z, w;
|
||||
};
|
||||
|
||||
|
||||
#endif /* QUATERNION_H_ */
|
||||
|
@ -37,15 +37,16 @@ typedef vtkm::Vec< vtkm::UInt8, 4 > Uint8Vec4;
|
||||
struct GenerateSurfaceWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
vtkm::Float32 t;
|
||||
GenerateSurfaceWorklet(vtkm::Float32 st) : t(st) {}
|
||||
GenerateSurfaceWorklet(vtkm::Float32 st)
|
||||
: t(st)
|
||||
{
|
||||
}
|
||||
|
||||
typedef void ControlSignature(FieldIn<>, FieldOut<>, FieldOut<>);
|
||||
typedef void ExecutionSignature(_1, _2, _3);
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC
|
||||
void operator()( const vtkm::Vec< T, 3 > & input,
|
||||
vtkm::Vec<T, 3> & output,
|
||||
VTKM_EXEC void operator()(const vtkm::Vec<T, 3>& input, vtkm::Vec<T, 3>& output,
|
||||
vtkm::Vec<vtkm::UInt8, 4>& color) const
|
||||
{
|
||||
output[0] = input[0];
|
||||
@ -67,16 +68,13 @@ struct RunGenerateSurfaceWorklet
|
||||
//At this point we know we have runtime support
|
||||
typedef vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag> DeviceTraits;
|
||||
|
||||
typedef vtkm::worklet::DispatcherMapField<GenerateSurfaceWorklet,
|
||||
DeviceAdapterTag> DispatcherType;
|
||||
typedef vtkm::worklet::DispatcherMapField<GenerateSurfaceWorklet, DeviceAdapterTag>
|
||||
DispatcherType;
|
||||
|
||||
std::cout << "Running a worklet on device adapter: "
|
||||
<< DeviceTraits::GetName() << std::endl;
|
||||
std::cout << "Running a worklet on device adapter: " << DeviceTraits::GetName() << std::endl;
|
||||
|
||||
GenerateSurfaceWorklet worklet(0.05f);
|
||||
DispatcherType(worklet).Invoke( this->In,
|
||||
this->Out,
|
||||
this->Color);
|
||||
DispatcherType(worklet).Invoke(this->In, this->Out, this->Color);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -86,7 +84,6 @@ struct RunGenerateSurfaceWorklet
|
||||
vtkm::cont::ArrayHandle<Uint8Vec4> Color;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::vector<vtkm::Vec<T, 3>> make_testData(int size)
|
||||
{
|
||||
@ -96,8 +93,7 @@ std::vector< vtkm::Vec<T, 3> > make_testData(int size)
|
||||
{
|
||||
for (int j = 0; j < size; ++j)
|
||||
{
|
||||
data.push_back( vtkm::Vec<T,3>(2.f*static_cast<T>(i/size)-1.f,
|
||||
0.f,
|
||||
data.push_back(vtkm::Vec<T, 3>(2.f * static_cast<T>(i / size) - 1.f, 0.f,
|
||||
2.f * static_cast<T>(j / size) - 1.f));
|
||||
}
|
||||
}
|
||||
@ -107,11 +103,10 @@ std::vector< vtkm::Vec<T, 3> > make_testData(int size)
|
||||
//This is the list of devices to compile in support for. The order of the
|
||||
//devices determines the runtime preference.
|
||||
struct DevicesToTry
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::DeviceAdapterTagCuda,
|
||||
vtkm::cont::DeviceAdapterTagTBB,
|
||||
vtkm::cont::DeviceAdapterTagSerial> { };
|
||||
|
||||
: vtkm::ListTagBase<vtkm::cont::DeviceAdapterTagCuda, vtkm::cont::DeviceAdapterTagTBB,
|
||||
vtkm::cont::DeviceAdapterTagSerial>
|
||||
{
|
||||
};
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
@ -119,7 +114,6 @@ int main(int, char**)
|
||||
|
||||
//make array handles for the data
|
||||
|
||||
|
||||
// TryExecutes takes a functor and a list of devices. It then tries to run
|
||||
// the functor for each device (in the order given in the list) until the
|
||||
// execution succeeds. This allows you to compile in support for multiple
|
||||
@ -136,7 +130,4 @@ int main(int, char**)
|
||||
RunGenerateSurfaceWorklet task;
|
||||
task.In = vtkm::cont::make_ArrayHandle(data);
|
||||
vtkm::cont::TryExecute(task, DevicesToTry());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,8 +54,7 @@ int buttonStates[3] = {GLUT_UP, GLUT_UP, GLUT_UP};
|
||||
bool shiftKey = false;
|
||||
int lastx = -1, lasty = -1;
|
||||
|
||||
void
|
||||
reshape(int, int)
|
||||
void reshape(int, int)
|
||||
{
|
||||
//Don't allow resizing window.
|
||||
glutReshapeWindow(W, H);
|
||||
@ -100,7 +99,6 @@ void mouseMove(int x, int y)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
// Respond to mouse button
|
||||
void mouseCall(int button, int state, int vtkmNotUsed(x), int vtkmNotUsed(y))
|
||||
{
|
||||
@ -119,8 +117,7 @@ void mouseCall(int button, int state, int vtkmNotUsed(x), int vtkmNotUsed(y))
|
||||
}
|
||||
|
||||
// Compute and render an isosurface for a uniform grid example
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::testing::MakeTestDataSet maker;
|
||||
vtkm::cont::DataSet ds = maker.Make3DUniformDataSet0();
|
||||
@ -141,8 +138,7 @@ main(int argc, char* argv[])
|
||||
vtkm::rendering::MapperGL mapper;
|
||||
|
||||
vtkm::rendering::Scene scene;
|
||||
scene.AddActor(vtkm::rendering::Actor(ds.GetCellSet(),
|
||||
ds.GetCoordinateSystem(),
|
||||
scene.AddActor(vtkm::rendering::Actor(ds.GetCellSet(), ds.GetCoordinateSystem(),
|
||||
ds.GetField("pointvar"),
|
||||
vtkm::rendering::ColorTable("thermal")));
|
||||
|
||||
|
37
examples/streamline/StreamLineUniformGrid.cxx
Executable file → Normal file
37
examples/streamline/StreamLineUniformGrid.cxx
Executable file → Normal file
@ -76,16 +76,14 @@ int mouse_state = 1;
|
||||
struct GetVertexArray
|
||||
{
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
void operator()(ArrayHandleType array) const
|
||||
VTKM_CONT void operator()(ArrayHandleType array) const
|
||||
{
|
||||
this->GetVertexPortal(array.GetPortalConstControl());
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename PortalType>
|
||||
VTKM_CONT
|
||||
void GetVertexPortal(const PortalType &portal) const
|
||||
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
|
||||
{
|
||||
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
|
||||
{
|
||||
@ -201,19 +199,23 @@ void mouseMove(int x, int y)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
// Respond to mouse button
|
||||
void mouseCall(int button, int state, int x, int y)
|
||||
{
|
||||
if (button == 0) mouse_state = state;
|
||||
if ((button == 0) && (state == 0)) { lastx = x; lasty = y; }
|
||||
if (button == 0)
|
||||
mouse_state = state;
|
||||
if ((button == 0) && (state == 0))
|
||||
{
|
||||
lastx = x;
|
||||
lasty = y;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,3> Normalize(vtkm::Vec<T,3> v)
|
||||
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);
|
||||
@ -223,21 +225,22 @@ vtkm::Vec<T,3> Normalize(vtkm::Vec<T,3> v)
|
||||
else
|
||||
return one / magnitude * v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Run streamlines on a uniform grid of vector data
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::cout << "StreamLineUniformGrid Example" << std::endl;
|
||||
std::cout << "Parameters are fileName [numSeeds maxSteps timeStep direction]" << std::endl << std::endl;
|
||||
std::cout << "Parameters are fileName [numSeeds maxSteps timeStep direction]" << std::endl
|
||||
<< std::endl;
|
||||
std::cout << "Direction is FORWARD=0 BACKWARD=1 BOTH=2" << std::endl << std::endl;
|
||||
std::cout << "File is expected to be binary with xdim ydim zdim as 32 bit integers " << std::endl;
|
||||
std::cout << "followed by vector data per dimension point as 32 bit float" << std::endl;
|
||||
|
||||
// Read in the vector data for testing
|
||||
FILE* pFile = fopen(argv[1], "rb");
|
||||
if (pFile == nullptr) perror ("Error opening file");
|
||||
if (pFile == nullptr)
|
||||
perror("Error opening file");
|
||||
|
||||
size_t ret_code = 0;
|
||||
// Size of the dataset
|
||||
@ -262,7 +265,6 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//We are done with the file now, so release the file descriptor
|
||||
fclose(pFile);
|
||||
|
||||
@ -290,12 +292,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// Create and run the filter
|
||||
streamLineFilter = new vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter>();
|
||||
outDataSet = streamLineFilter->Run(inDataSet,
|
||||
direction,
|
||||
nSeeds,
|
||||
nSteps,
|
||||
tStep);
|
||||
|
||||
outDataSet = streamLineFilter->Run(inDataSet, direction, nSeeds, nSteps, tStep);
|
||||
|
||||
// Render the output dataset of polylines
|
||||
lastx = lasty = 0;
|
||||
|
@ -46,7 +46,8 @@
|
||||
|
||||
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
// Takes input uniform grid and outputs unstructured grid of tets
|
||||
static vtkm::cont::DataSet outDataSet;
|
||||
@ -130,16 +131,14 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
|
||||
struct GetVertexArray
|
||||
{
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
void operator()(ArrayHandleType array) const
|
||||
VTKM_CONT void operator()(ArrayHandleType array) const
|
||||
{
|
||||
this->GetVertexPortal(array.GetPortalConstControl());
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename PortalType>
|
||||
VTKM_CONT
|
||||
void GetVertexPortal(const PortalType &portal) const
|
||||
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
|
||||
{
|
||||
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
|
||||
{
|
||||
@ -175,7 +174,6 @@ void initializeGL()
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Render the output using simple OpenGL
|
||||
//
|
||||
@ -209,15 +207,14 @@ void displayCall()
|
||||
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
|
||||
|
||||
// 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 },
|
||||
{ 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f },
|
||||
{ 1.0f, 0.0f, 1.0f },
|
||||
{1.0f, 1.0f, 0.0f}
|
||||
};
|
||||
{ 1.0f, 1.0f, 0.0f } };
|
||||
|
||||
for (vtkm::Id tetra = 0; tetra < numberOfCells; tetra++) {
|
||||
for (vtkm::Id tetra = 0; tetra < numberOfCells; tetra++)
|
||||
{
|
||||
vtkm::Id indx = tetra % 5;
|
||||
glColor3f(color[indx][0], color[indx][1], color[indx][2]);
|
||||
|
||||
@ -258,7 +255,6 @@ void displayCall()
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
// Allow rotations of the view
|
||||
void mouseMove(int x, int y)
|
||||
{
|
||||
@ -282,14 +278,17 @@ void mouseMove(int x, int y)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
// Respond to mouse button
|
||||
void mouseCall(int button, int state, int x, int y)
|
||||
{
|
||||
if (button == 0) mouse_state = state;
|
||||
if ((button == 0) && (state == 0)) { lastx = x; lasty = y; }
|
||||
if (button == 0)
|
||||
mouse_state = state;
|
||||
if ((button == 0) && (state == 0))
|
||||
{
|
||||
lastx = x;
|
||||
lasty = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Tetrahedralize and render uniform grid example
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -71,14 +71,12 @@ vtkm::cont::DataSet MakeTetrahedralizeTestDataSet(vtkm::Id3 dim)
|
||||
const vtkm::Id3 vdims(dim[0] + 1, dim[1] + 1, dim[2] + 1);
|
||||
const vtkm::Vec<vtkm::Float32, 3> origin = vtkm::make_Vec(0.0f, 0.0f, 0.0f);
|
||||
const vtkm::Vec<vtkm::Float32, 3> spacing = vtkm::make_Vec(
|
||||
1.0f/static_cast<vtkm::Float32>(dim[0]),
|
||||
1.0f/static_cast<vtkm::Float32>(dim[1]),
|
||||
1.0f / static_cast<vtkm::Float32>(dim[0]), 1.0f / static_cast<vtkm::Float32>(dim[1]),
|
||||
1.0f / static_cast<vtkm::Float32>(dim[2]));
|
||||
|
||||
// Generate coordinate system
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
// Generate cell set
|
||||
vtkm::cont::CellSetStructured<3> cellSet("cells");
|
||||
@ -96,16 +94,14 @@ vtkm::cont::DataSet MakeTetrahedralizeTestDataSet(vtkm::Id3 dim)
|
||||
struct GetVertexArray
|
||||
{
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
void operator()(ArrayHandleType array) const
|
||||
VTKM_CONT void operator()(ArrayHandleType array) const
|
||||
{
|
||||
this->GetVertexPortal(array.GetPortalConstControl());
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename PortalType>
|
||||
VTKM_CONT
|
||||
void GetVertexPortal(const PortalType &portal) const
|
||||
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
|
||||
{
|
||||
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
|
||||
{
|
||||
@ -141,7 +137,6 @@ void initializeGL()
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Render the output using simple OpenGL
|
||||
//
|
||||
@ -176,14 +171,11 @@ void displayCall()
|
||||
|
||||
// Draw the five tetrahedra belonging to each hexadron
|
||||
vtkm::Id tetra = 0;
|
||||
vtkm::Float32 color[5][3] =
|
||||
{
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
vtkm::Float32 color[5][3] = { { 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f },
|
||||
{ 1.0f, 0.0f, 1.0f },
|
||||
{1.0f, 1.0f, 0.0f}
|
||||
};
|
||||
{ 1.0f, 1.0f, 0.0f } };
|
||||
|
||||
for (vtkm::Id hex = 0; hex < cellsToDisplay; hex++)
|
||||
{
|
||||
@ -233,7 +225,6 @@ void displayCall()
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
// Allow rotations of the view
|
||||
void mouseMove(int x, int y)
|
||||
{
|
||||
@ -257,14 +248,17 @@ void mouseMove(int x, int y)
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
// Respond to mouse button
|
||||
void mouseCall(int button, int state, int x, int y)
|
||||
{
|
||||
if (button == 0) mouse_state = state;
|
||||
if ((button == 0) && (state == 0)) { lastx = x; lasty = y; }
|
||||
if (button == 0)
|
||||
mouse_state = state;
|
||||
if ((button == 0) && (state == 0))
|
||||
{
|
||||
lastx = x;
|
||||
lasty = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Tetrahedralize and render uniform grid example
|
||||
int main(int argc, char* argv[])
|
||||
@ -280,7 +274,8 @@ int main(int argc, char* argv[])
|
||||
dims[2] = atoi(argv[3]);
|
||||
cellsToDisplay = dims[0] * dims[1] * dims[2];
|
||||
}
|
||||
if (argc == 5) {
|
||||
if (argc == 5)
|
||||
{
|
||||
cellsToDisplay = atoi(argv[4]);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,8 @@
|
||||
|
||||
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
// Takes input uniform grid and outputs unstructured grid of triangles
|
||||
static vtkm::cont::DataSet outDataSet;
|
||||
@ -132,16 +133,14 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
|
||||
struct GetVertexArray
|
||||
{
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
void operator()(ArrayHandleType array) const
|
||||
VTKM_CONT void operator()(ArrayHandleType array) const
|
||||
{
|
||||
this->GetVertexPortal(array.GetPortalConstControl());
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename PortalType>
|
||||
VTKM_CONT
|
||||
void GetVertexPortal(const PortalType &portal) const
|
||||
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
|
||||
{
|
||||
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
|
||||
{
|
||||
@ -161,7 +160,6 @@ void initializeGL()
|
||||
glOrtho(-0.5f, 3.5f, -0.5f, 4.5f, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Render the output using simple OpenGL
|
||||
//
|
||||
@ -182,13 +180,11 @@ void displayCall()
|
||||
|
||||
// Draw the two triangles belonging to each quad
|
||||
vtkm::Float32 color[4][3] = {
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{0.0f, 1.0f, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{1.0f, 1.0f, 0.0f}
|
||||
{ 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 0.0f }
|
||||
};
|
||||
|
||||
for (vtkm::Id triangle = 0; triangle < numberOfCells; triangle++) {
|
||||
for (vtkm::Id triangle = 0; triangle < numberOfCells; triangle++)
|
||||
{
|
||||
vtkm::Id indx = triangle % 4;
|
||||
glColor3f(color[indx][0], color[indx][1], color[indx][2]);
|
||||
|
||||
|
@ -64,14 +64,11 @@ vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim)
|
||||
const vtkm::Id3 vdims(dim[0] + 1, dim[1] + 1, 1);
|
||||
const vtkm::Vec<vtkm::Float32, 3> origin = vtkm::make_Vec(0.0f, 0.0f, 0.0f);
|
||||
const vtkm::Vec<vtkm::Float32, 3> spacing = vtkm::make_Vec(
|
||||
1.0f/static_cast<vtkm::Float32>(dim[0]),
|
||||
1.0f/static_cast<vtkm::Float32>(dim[1]),
|
||||
0.0f);
|
||||
1.0f / static_cast<vtkm::Float32>(dim[0]), 1.0f / static_cast<vtkm::Float32>(dim[1]), 0.0f);
|
||||
|
||||
// Generate coordinate system
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
// Generate cell set
|
||||
vtkm::cont::CellSetStructured<2> cellSet("cells");
|
||||
@ -89,16 +86,14 @@ vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim)
|
||||
struct GetVertexArray
|
||||
{
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
void operator()(ArrayHandleType array) const
|
||||
VTKM_CONT void operator()(ArrayHandleType array) const
|
||||
{
|
||||
this->GetVertexPortal(array.GetPortalConstControl());
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename PortalType>
|
||||
VTKM_CONT
|
||||
void GetVertexPortal(const PortalType &portal) const
|
||||
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
|
||||
{
|
||||
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
|
||||
{
|
||||
@ -118,7 +113,6 @@ void initializeGL()
|
||||
glOrtho(-0.5f, 1.5f, -0.5f, 1.5f, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Render the output using simple OpenGL
|
||||
//
|
||||
@ -138,12 +132,8 @@ void displayCall()
|
||||
|
||||
// Draw the two triangles belonging to each quad
|
||||
vtkm::Id triangle = 0;
|
||||
vtkm::Float32 color[4][3] =
|
||||
{
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{0.0f, 1.0f, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{1.0f, 1.0f, 0.0f}
|
||||
vtkm::Float32 color[4][3] = {
|
||||
{ 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 0.0f }
|
||||
};
|
||||
|
||||
for (vtkm::Id quad = 0; quad < cellsToDisplay; quad++)
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
// Define the tangle field for the input data
|
||||
class TangleField : public vtkm::worklet::WorkletMapField
|
||||
@ -47,8 +47,17 @@ public:
|
||||
const vtkm::Id cellsPerLayer;
|
||||
|
||||
VTKM_CONT
|
||||
TangleField(const vtkm::Id3 dims, const vtkm::Float32 mins[3], const vtkm::Float32 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)) { };
|
||||
TangleField(const vtkm::Id3 dims, const vtkm::Float32 mins[3], const vtkm::Float32 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
|
||||
@ -65,11 +74,13 @@ public:
|
||||
const vtkm::Float32 yy = 3.0f * (ymin + (ymax - ymin) * (fy));
|
||||
const vtkm::Float32 zz = 3.0f * (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;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Construct an input data set using the tangle field worklet
|
||||
vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
{
|
||||
@ -81,20 +92,19 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
vtkm::Float32 maxs[3] = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> vertexCountImplicitArray(0, 1, vdims[0]*vdims[1]*vdims[2]);
|
||||
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(TangleField(vdims, mins, maxs));
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> vertexCountImplicitArray(0, 1, vdims[0] * vdims[1] *
|
||||
vdims[2]);
|
||||
vtkm::worklet::DispatcherMapField<TangleField> tangleFieldDispatcher(
|
||||
TangleField(vdims, mins, maxs));
|
||||
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, fieldArray);
|
||||
|
||||
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]),
|
||||
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::ArrayHandleUniformPointCoordinates coordinates(vdims, origin, spacing);
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
||||
|
||||
dataSet.AddField(vtkm::cont::Field("nodevar", vtkm::cont::Field::ASSOC_POINTS, fieldArray));
|
||||
|
||||
@ -105,10 +115,8 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace worklet
|
||||
@ -120,26 +128,26 @@ public:
|
||||
typedef _2 ExecutionSignature(_1, WorkIndex);
|
||||
|
||||
VTKM_EXEC
|
||||
vtkm::Float32 operator()(vtkm::Int64 x, vtkm::Id& index) const {
|
||||
return (vtkm::Sin(1.0*x));
|
||||
}
|
||||
vtkm::Float32 operator()(vtkm::Int64 x, vtkm::Id& index) const { return (vtkm::Sin(1.0 * x)); }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Run a simple worklet, and compute an isosurface
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
vtkm::Int64 N = 1024 * 1024 * 1024;
|
||||
if (argc > 1) N = N*atoi(argv[1]);
|
||||
else N = N*4;
|
||||
if (argc > 1)
|
||||
N = N * atoi(argv[1]);
|
||||
else
|
||||
N = N * 4;
|
||||
std::cout << "Testing streaming worklet with size " << N << std::endl;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Int64> input;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> output;
|
||||
std::vector<vtkm::Int64> data(N);
|
||||
for (vtkm::Int64 i=0; i<N; i++) data[i] = i;
|
||||
for (vtkm::Int64 i = 0; i < N; i++)
|
||||
data[i] = i;
|
||||
input = vtkm::cont::make_ArrayHandle(data);
|
||||
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> DeviceAlgorithms;
|
||||
@ -148,8 +156,7 @@ int main(int argc, char* argv[])
|
||||
#ifdef VTKM_USE_UNIFIED_MEMORY
|
||||
std::cout << "Testing with unified memory" << std::endl;
|
||||
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::SineWorklet>
|
||||
dispatcher(sineWorklet);
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::SineWorklet> dispatcher(sineWorklet);
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
|
||||
@ -161,12 +168,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
#else
|
||||
|
||||
vtkm::worklet::DispatcherStreamingMapField<vtkm::worklet::SineWorklet>
|
||||
dispatcher(sineWorklet);
|
||||
vtkm::worklet::DispatcherStreamingMapField<vtkm::worklet::SineWorklet> dispatcher(sineWorklet);
|
||||
vtkm::Id NBlocks = N / (1024 * 1024 * 1024);
|
||||
NBlocks *= 2;
|
||||
dispatcher.SetNumberOfBlocks(NBlocks);
|
||||
std::cout << "Testing with streaming (without unified memory) with " << NBlocks << " blocks" << std::endl;
|
||||
std::cout << "Testing with streaming (without unified memory) with " << NBlocks << " blocks"
|
||||
<< std::endl;
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
|
||||
@ -179,7 +186,8 @@ int main(int argc, char* argv[])
|
||||
#endif
|
||||
|
||||
int dim = 128;
|
||||
if (argc > 2) dim = atoi(argv[2]);
|
||||
if (argc > 2)
|
||||
dim = atoi(argv[2]);
|
||||
std::cout << "Testing Marching Cubes with size " << dim << "x" << dim << "x" << dim << std::endl;
|
||||
|
||||
vtkm::Id3 dims(dim, dim, dim);
|
||||
@ -191,8 +199,7 @@ int main(int argc, char* argv[])
|
||||
filter.SetGenerateNormals(true);
|
||||
filter.SetMergeDuplicatePoints(false);
|
||||
filter.SetIsoValue(0.5);
|
||||
vtkm::filter::ResultDataSet result =
|
||||
filter.Execute( dataSet, dataSet.GetField("nodevar") );
|
||||
vtkm::filter::ResultDataSet result = filter.Execute(dataSet, dataSet.GetField("nodevar"));
|
||||
|
||||
filter.MapFieldOntoOutput(result, dataSet.GetField("nodevar"));
|
||||
|
||||
@ -204,7 +211,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
verticesArray = coords.GetData().Cast<VertType>();
|
||||
normalsArray = outputData.GetField("normals").GetData().Cast<VertType>();
|
||||
scalarsArray = outputData.GetField("nodevar").GetData().Cast< vtkm::cont::ArrayHandle<vtkm::Float32> >();
|
||||
scalarsArray =
|
||||
outputData.GetField("nodevar").GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Float32>>();
|
||||
|
||||
std::cout << "Number of output vertices: " << verticesArray.GetNumberOfValues() << std::endl;
|
||||
|
||||
@ -220,4 +228,3 @@ int main(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
2
vtkm/.gitattributes
vendored
Normal file
2
vtkm/.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Generated.
|
||||
TypeListTag.h -format.clang-format
|
@ -37,11 +37,9 @@
|
||||
/// for the possibility that the condition is never evaluated.
|
||||
///
|
||||
#if !defined(NDEBUG)
|
||||
#define VTKM_ASSERT(condition) \
|
||||
assert(condition)
|
||||
#define VTKM_ASSERT(condition) assert(condition)
|
||||
#else
|
||||
#define VTKM_ASSERT(condition)
|
||||
#endif
|
||||
|
||||
|
||||
#endif //vtk_m_Assert_h
|
||||
|
@ -20,14 +20,15 @@
|
||||
#ifndef vtk_m_BaseComponent_h
|
||||
#define vtk_m_BaseComponent_h
|
||||
|
||||
|
||||
#include <vtkm/Matrix.h>
|
||||
#include <vtkm/TypeTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename VecType, typename DimensionalityTag>
|
||||
struct BaseComponentImpl;
|
||||
@ -37,18 +38,18 @@ struct BaseComponentImpl<VecType, vtkm::TypeTraitsVectorTag>
|
||||
{
|
||||
private:
|
||||
using ComponentType = typename vtkm::VecTraits<VecType>::ComponentType;
|
||||
|
||||
public:
|
||||
using Type =
|
||||
typename BaseComponentImpl<
|
||||
ComponentType,
|
||||
typename vtkm::TypeTraits<ComponentType>::DimensionalityTag
|
||||
>::Type;
|
||||
typename BaseComponentImpl<ComponentType,
|
||||
typename vtkm::TypeTraits<ComponentType>::DimensionalityTag>::Type;
|
||||
};
|
||||
|
||||
template <typename VecType>
|
||||
struct BaseComponentImpl<VecType, vtkm::TypeTraitsMatrixTag>
|
||||
: BaseComponentImpl<VecType, vtkm::TypeTraitsVectorTag>
|
||||
{ };
|
||||
{
|
||||
};
|
||||
|
||||
template <typename ScalarType>
|
||||
struct BaseComponentImpl<ScalarType, vtkm::TypeTraitsScalarTag>
|
||||
@ -64,8 +65,7 @@ template<typename VecType>
|
||||
struct BaseComponent
|
||||
{
|
||||
using Type =
|
||||
typename detail::BaseComponentImpl<
|
||||
VecType,
|
||||
typename detail::BaseComponentImpl<VecType,
|
||||
typename vtkm::TypeTraits<VecType>::DimensionalityTag>::Type;
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
// Disable conversion warnings for Sum and Product on GCC only.
|
||||
// GCC creates false positive warnings for signed/unsigned char* operations.
|
||||
@ -64,7 +65,6 @@ struct Product
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // gcc || clang
|
||||
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns the \c x if x > y otherwise returns \c y.
|
||||
/// Note: Requires Type \p T implement the < operator.
|
||||
@ -91,7 +91,6 @@ struct Minimum
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns a vtkm::Vec<T,2> that represents the minimum and maximum values
|
||||
/// Note: Requires Type \p T implement the vtkm::Min and vtkm::Max functions.
|
||||
@ -105,11 +104,9 @@ struct MinAndMax
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,2> operator()(
|
||||
const vtkm::Vec<T,2>& a, const vtkm::Vec<T,2>& b) const
|
||||
vtkm::Vec<T, 2> operator()(const vtkm::Vec<T, 2>& a, const vtkm::Vec<T, 2>& b) const
|
||||
{
|
||||
return vtkm::make_Vec(
|
||||
vtkm::Min(a[0], b[0]), vtkm::Max(a[1], b[1]));
|
||||
return vtkm::make_Vec(vtkm::Min(a[0], b[0]), vtkm::Max(a[1], b[1]));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
@ -161,7 +158,6 @@ struct BitwiseXor
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_BinaryOperators_h
|
||||
|
@ -22,7 +22,8 @@
|
||||
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns True if and only if \c x is equal to \c y.
|
||||
|
@ -23,7 +23,8 @@
|
||||
|
||||
#include <vtkm/Range.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief Represent an axis-aligned 3D bounds in space.
|
||||
///
|
||||
@ -45,47 +46,43 @@ struct Bounds
|
||||
Bounds() {}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Bounds(const vtkm::Range &xRange,
|
||||
const vtkm::Range &yRange,
|
||||
const vtkm::Range &zRange)
|
||||
: X(xRange), Y(yRange), Z(zRange) { }
|
||||
Bounds(const vtkm::Range& xRange, const vtkm::Range& yRange, const vtkm::Range& zRange)
|
||||
: X(xRange)
|
||||
, Y(yRange)
|
||||
, Z(zRange)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6>
|
||||
VTKM_EXEC_CONT
|
||||
Bounds(const T1 &minX, const T2 &maxX,
|
||||
const T3 &minY, const T4 &maxY,
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
VTKM_EXEC_CONT Bounds(const T1& minX, const T2& maxX, const T3& minY, const T4& maxY,
|
||||
const T5& minZ, const T6& maxZ)
|
||||
: X(vtkm::Range(minX, maxX)),
|
||||
Y(vtkm::Range(minY, maxY)),
|
||||
Z(vtkm::Range(minZ, maxZ))
|
||||
{ }
|
||||
: X(vtkm::Range(minX, maxX))
|
||||
, Y(vtkm::Range(minY, maxY))
|
||||
, Z(vtkm::Range(minZ, maxZ))
|
||||
{
|
||||
}
|
||||
|
||||
/// Initialize bounds with an array of 6 values in the order xmin, xmax,
|
||||
/// ymin, ymax, zmin, zmax.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
explicit Bounds(const T bounds[6])
|
||||
: X(vtkm::Range(bounds[0], bounds[1])),
|
||||
Y(vtkm::Range(bounds[2], bounds[3])),
|
||||
Z(vtkm::Range(bounds[4], bounds[5]))
|
||||
{ }
|
||||
VTKM_EXEC_CONT explicit Bounds(const T bounds[6])
|
||||
: X(vtkm::Range(bounds[0], bounds[1]))
|
||||
, Y(vtkm::Range(bounds[2], bounds[3]))
|
||||
, Z(vtkm::Range(bounds[4], bounds[5]))
|
||||
{
|
||||
}
|
||||
|
||||
/// Initialize bounds with the minimum corner point and the maximum corner
|
||||
/// point.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
Bounds(const vtkm::Vec<T,3> &minPoint, const vtkm::Vec<T,3> &maxPoint)
|
||||
: X(vtkm::Range(minPoint[0], maxPoint[0])),
|
||||
Y(vtkm::Range(minPoint[1], maxPoint[1])),
|
||||
Z(vtkm::Range(minPoint[2], maxPoint[2]))
|
||||
{ }
|
||||
VTKM_EXEC_CONT Bounds(const vtkm::Vec<T, 3>& minPoint, const vtkm::Vec<T, 3>& maxPoint)
|
||||
: X(vtkm::Range(minPoint[0], maxPoint[0]))
|
||||
, Y(vtkm::Range(minPoint[1], maxPoint[1]))
|
||||
, Z(vtkm::Range(minPoint[2], maxPoint[2]))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const vtkm::Bounds& operator=(const vtkm::Bounds& src)
|
||||
@ -105,20 +102,15 @@ struct Bounds
|
||||
VTKM_EXEC_CONT
|
||||
bool IsNonEmpty() const
|
||||
{
|
||||
return (this->X.IsNonEmpty() &&
|
||||
this->Y.IsNonEmpty() &&
|
||||
this->Z.IsNonEmpty());
|
||||
return (this->X.IsNonEmpty() && this->Y.IsNonEmpty() && this->Z.IsNonEmpty());
|
||||
}
|
||||
|
||||
/// \b Determines if a point coordinate is within the bounds.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
bool Contains(const vtkm::Vec<T,3> &point) const
|
||||
VTKM_EXEC_CONT bool Contains(const vtkm::Vec<T, 3>& point) const
|
||||
{
|
||||
return (this->X.Contains(point[0]) &&
|
||||
this->Y.Contains(point[1]) &&
|
||||
this->Z.Contains(point[2]));
|
||||
return (this->X.Contains(point[0]) && this->Y.Contains(point[1]) && this->Z.Contains(point[2]));
|
||||
}
|
||||
|
||||
/// \b Returns the center of the range.
|
||||
@ -129,9 +121,7 @@ struct Bounds
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<vtkm::Float64, 3> Center() const
|
||||
{
|
||||
return vtkm::Vec<vtkm::Float64,3>(this->X.Center(),
|
||||
this->Y.Center(),
|
||||
this->Z.Center());
|
||||
return vtkm::Vec<vtkm::Float64, 3>(this->X.Center(), this->Y.Center(), this->Z.Center());
|
||||
}
|
||||
|
||||
/// \b Expand bounds to include a point.
|
||||
@ -141,8 +131,7 @@ struct Bounds
|
||||
/// nothing is done.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
void Include(const vtkm::Vec<T,3> &point)
|
||||
VTKM_EXEC_CONT void Include(const vtkm::Vec<T, 3>& point)
|
||||
{
|
||||
this->X.Include(point[0]);
|
||||
this->Y.Include(point[1]);
|
||||
@ -177,25 +166,18 @@ struct Bounds
|
||||
/// \b Operator for union
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Bounds operator+(const vtkm::Bounds &otherBounds) const
|
||||
{
|
||||
return this->Union(otherBounds);
|
||||
}
|
||||
vtkm::Bounds operator+(const vtkm::Bounds& otherBounds) const { return this->Union(otherBounds); }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
bool operator==(const vtkm::Bounds& bounds) const
|
||||
{
|
||||
return ((this->X == bounds.X) &&
|
||||
(this->Y == bounds.Y) &&
|
||||
(this->Z == bounds.Z));
|
||||
return ((this->X == bounds.X) && (this->Y == bounds.Y) && (this->Z == bounds.Z));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
bool operator!=(const vtkm::Bounds& bounds) const
|
||||
{
|
||||
return ((this->X != bounds.X) ||
|
||||
(this->Y != bounds.Y) ||
|
||||
(this->Z != bounds.Z));
|
||||
return ((this->X != bounds.X) || (this->Y != bounds.Y) || (this->Z != bounds.Z));
|
||||
}
|
||||
};
|
||||
|
||||
@ -203,12 +185,9 @@ struct Bounds
|
||||
|
||||
/// Helper function for printing bounds during testing
|
||||
///
|
||||
static inline VTKM_CONT
|
||||
std::ostream &operator<<(std::ostream &stream, const vtkm::Bounds &bounds)
|
||||
static inline VTKM_CONT std::ostream& operator<<(std::ostream& stream, const vtkm::Bounds& bounds)
|
||||
{
|
||||
return stream << "{ X:" << bounds.X
|
||||
<< ", Y:" << bounds.Y
|
||||
<< ", Z:" << bounds.Z << " }";
|
||||
return stream << "{ X:" << bounds.X << ", Y:" << bounds.Y << ", Z:" << bounds.Z << " }";
|
||||
}
|
||||
|
||||
#endif //vtk_m_Bounds_h
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <vtkm/StaticAssert.h>
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// CellShapeId identifies the type of each cell. Currently these are designed
|
||||
/// to match up with VTK cell types.
|
||||
@ -56,13 +57,16 @@ enum CellShapeIdEnum
|
||||
// There are also many other cell-specific features that code might expect such
|
||||
// as \c CellTraits and interpolations.
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// A class that can be used to determine if a class is a CellShapeTag or not.
|
||||
/// The class will be either std::true_type or std::false_type.
|
||||
///
|
||||
template <typename T>
|
||||
struct CellShapeTagCheck : std::false_type { };
|
||||
struct CellShapeTagCheck : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@ -71,14 +75,14 @@ struct CellShapeTagCheck : std::false_type { };
|
||||
/// tag.
|
||||
///
|
||||
#define VTKM_IS_CELL_SHAPE_TAG(tag) \
|
||||
VTKM_STATIC_ASSERT_MSG( \
|
||||
::vtkm::internal::CellShapeTagCheck<tag>::value, \
|
||||
VTKM_STATIC_ASSERT_MSG(::vtkm::internal::CellShapeTagCheck<tag>::value, \
|
||||
"Provided type is not a valid VTK-m cell shape tag.")
|
||||
|
||||
/// A traits-like class to get an CellShapeId known at compile time to a tag.
|
||||
///
|
||||
template <vtkm::IdComponent Id>
|
||||
struct CellShapeIdToTag {
|
||||
struct CellShapeIdToTag
|
||||
{
|
||||
// If you get a compile error for this class about Id not being defined, that
|
||||
// probably means you are using an ID that does not have a defined cell
|
||||
// shape.
|
||||
@ -86,29 +90,32 @@ struct CellShapeIdToTag {
|
||||
typedef std::false_type valid;
|
||||
};
|
||||
|
||||
|
||||
// Define a tag for each cell shape as well as the support structs to go
|
||||
// between tags and ids. The following macro is only valid here.
|
||||
|
||||
#define VTKM_DEFINE_CELL_TAG(name, idname) \
|
||||
struct CellShapeTag ## name { \
|
||||
struct CellShapeTag##name \
|
||||
{ \
|
||||
static const vtkm::UInt8 Id = vtkm::idname; \
|
||||
}; \
|
||||
namespace internal { \
|
||||
namespace internal \
|
||||
{ \
|
||||
template <> \
|
||||
struct CellShapeTagCheck<vtkm::CellShapeTag ## name> : std::true_type { }; \
|
||||
struct CellShapeTagCheck<vtkm::CellShapeTag##name> : std::true_type \
|
||||
{ \
|
||||
}; \
|
||||
} \
|
||||
static inline VTKM_EXEC_CONT \
|
||||
const char *GetCellShapeName(vtkm::CellShapeTag ## name) { \
|
||||
static inline VTKM_EXEC_CONT const char* GetCellShapeName(vtkm::CellShapeTag##name) \
|
||||
{ \
|
||||
return #name; \
|
||||
} \
|
||||
template <> \
|
||||
struct CellShapeIdToTag<vtkm::idname> { \
|
||||
struct CellShapeIdToTag<vtkm::idname> \
|
||||
{ \
|
||||
typedef std::true_type valid; \
|
||||
typedef vtkm::CellShapeTag##name Tag; \
|
||||
}
|
||||
|
||||
|
||||
VTKM_DEFINE_CELL_TAG(Empty, CELL_SHAPE_EMPTY);
|
||||
VTKM_DEFINE_CELL_TAG(Vertex, CELL_SHAPE_VERTEX);
|
||||
//VTKM_DEFINE_CELL_TAG(PolyVertex, CELL_SHAPE_POLY_VERTEX);
|
||||
@ -127,25 +134,26 @@ VTKM_DEFINE_CELL_TAG(Pyramid, CELL_SHAPE_PYRAMID);
|
||||
|
||||
#undef VTKM_DEFINE_CELL_TAG
|
||||
|
||||
|
||||
/// A special cell shape tag that holds a cell shape that is not known at
|
||||
/// compile time. Unlike other cell set tags, the Id field is set at runtime
|
||||
/// so its value cannot be used in template parameters. You need to use
|
||||
/// \c vtkmGenericCellShapeMacro to specialize on the cell type.
|
||||
///
|
||||
struct CellShapeTagGeneric {
|
||||
struct CellShapeTagGeneric
|
||||
{
|
||||
VTKM_EXEC_CONT
|
||||
CellShapeTagGeneric(vtkm::UInt8 shape) : Id(shape) { }
|
||||
CellShapeTagGeneric(vtkm::UInt8 shape)
|
||||
: Id(shape)
|
||||
{
|
||||
}
|
||||
|
||||
vtkm::UInt8 Id;
|
||||
};
|
||||
|
||||
|
||||
#define vtkmGenericCellShapeMacroCase(cellShapeId, call) \
|
||||
case vtkm::cellShapeId: \
|
||||
{ \
|
||||
typedef \
|
||||
vtkm::CellShapeIdToTag<vtkm::cellShapeId>::Tag CellShapeTag; \
|
||||
typedef vtkm::CellShapeIdToTag<vtkm::cellShapeId>::Tag CellShapeTag; \
|
||||
call; \
|
||||
} \
|
||||
break
|
||||
|
@ -22,22 +22,29 @@
|
||||
|
||||
#include <vtkm/CellShape.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \c vtkm::CellTraits::TopologyDimensionType is typedef to this with the
|
||||
/// template parameter set to \c TOPOLOGICAL_DIMENSIONS. See \c
|
||||
/// vtkm::CellTraits for more information.
|
||||
///
|
||||
template <vtkm::IdComponent dimension>
|
||||
struct CellTopologicalDimensionsTag { };
|
||||
struct CellTopologicalDimensionsTag
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief Tag for cell shapes with a fixed number of points.
|
||||
///
|
||||
struct CellTraitsTagSizeFixed { };
|
||||
struct CellTraitsTagSizeFixed
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief Tag for cell shapes that can have a variable number of points.
|
||||
///
|
||||
struct CellTraitsTagSizeVariable { };
|
||||
struct CellTraitsTagSizeVariable
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief Information about a cell based on its tag.
|
||||
///
|
||||
@ -59,8 +66,7 @@ struct CellTraits
|
||||
/// a convenient way to overload a function based on topological dimensions
|
||||
/// (which is usually more efficient than conditionals).
|
||||
///
|
||||
typedef vtkm::CellTopologicalDimensionsTag<TOPOLOGICAL_DIMENSIONS>
|
||||
TopologicalDimensionsTag;
|
||||
typedef vtkm::CellTopologicalDimensionsTag<TOPOLOGICAL_DIMENSIONS> TopologicalDimensionsTag;
|
||||
|
||||
/// \brief A tag specifying whether the number of points is fixed.
|
||||
///
|
||||
@ -87,20 +93,20 @@ struct CellTraits
|
||||
|
||||
#define VTKM_DEFINE_CELL_TRAITS(name, dimensions, numPoints) \
|
||||
template <> \
|
||||
struct CellTraits<vtkm::CellShapeTag ## name> { \
|
||||
struct CellTraits<vtkm::CellShapeTag##name> \
|
||||
{ \
|
||||
const static vtkm::IdComponent TOPOLOGICAL_DIMENSIONS = dimensions; \
|
||||
typedef vtkm::CellTopologicalDimensionsTag<TOPOLOGICAL_DIMENSIONS> \
|
||||
TopologicalDimensionsTag; \
|
||||
typedef vtkm::CellTopologicalDimensionsTag<TOPOLOGICAL_DIMENSIONS> TopologicalDimensionsTag; \
|
||||
typedef vtkm::CellTraitsTagSizeFixed IsSizeFixed; \
|
||||
static const vtkm::IdComponent NUM_POINTS = numPoints; \
|
||||
}
|
||||
|
||||
#define VTKM_DEFINE_CELL_TRAITS_VARIABLE(name, dimensions) \
|
||||
template <> \
|
||||
struct CellTraits<vtkm::CellShapeTag ## name> { \
|
||||
struct CellTraits<vtkm::CellShapeTag##name> \
|
||||
{ \
|
||||
const static vtkm::IdComponent TOPOLOGICAL_DIMENSIONS = dimensions; \
|
||||
typedef vtkm::CellTopologicalDimensionsTag<TOPOLOGICAL_DIMENSIONS> \
|
||||
TopologicalDimensionsTag; \
|
||||
typedef vtkm::CellTopologicalDimensionsTag<TOPOLOGICAL_DIMENSIONS> TopologicalDimensionsTag; \
|
||||
typedef vtkm::CellTraitsTagSizeVariable IsSizeFixed; \
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,16 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename ListTag>
|
||||
struct ListTagCheck : std::is_base_of<vtkm::detail::ListRoot, ListTag>
|
||||
{
|
||||
static VTKM_CONSTEXPR bool Valid = std::is_base_of<vtkm::detail::ListRoot,
|
||||
ListTag>::value;
|
||||
static VTKM_CONSTEXPR bool Valid = std::is_base_of<vtkm::detail::ListRoot, ListTag>::value;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@ -46,48 +47,46 @@ struct ListTagCheck : std::is_base_of<vtkm::detail::ListRoot,ListTag>
|
||||
/// code when a mistake is made.)
|
||||
///
|
||||
#define VTKM_IS_LIST_TAG(tag) \
|
||||
VTKM_STATIC_ASSERT_MSG( \
|
||||
(::vtkm::internal::ListTagCheck<tag>::value), \
|
||||
VTKM_STATIC_ASSERT_MSG((::vtkm::internal::ListTagCheck<tag>::value), \
|
||||
"Provided type is not a valid VTK-m list tag.")
|
||||
|
||||
|
||||
/// A special tag for a list that represents holding all potential values
|
||||
///
|
||||
/// Note: Can not be used with ForEach for obvious reasons.
|
||||
struct ListTagUniversal : detail::ListRoot {
|
||||
struct ListTagUniversal : detail::ListRoot
|
||||
{
|
||||
using list = vtkm::detail::ListBase<vtkm::detail::UniversalTag>;
|
||||
};
|
||||
|
||||
/// A special tag for an empty list.
|
||||
///
|
||||
struct ListTagEmpty : detail::ListRoot {
|
||||
struct ListTagEmpty : detail::ListRoot
|
||||
{
|
||||
using list = vtkm::detail::ListBase<>;
|
||||
};
|
||||
|
||||
/// A tag that is a construction of two other tags joined together. This struct
|
||||
/// can be subclassed and still behave like a list tag.
|
||||
template <typename ListTag1, typename ListTag2>
|
||||
struct ListTagJoin : detail::ListRoot {
|
||||
using list = typename detail::ListJoin<
|
||||
typename ListTag1::list,
|
||||
typename ListTag2::list>::type;
|
||||
struct ListTagJoin : detail::ListRoot
|
||||
{
|
||||
using list = typename detail::ListJoin<typename ListTag1::list, typename ListTag2::list>::type;
|
||||
};
|
||||
|
||||
/// A tag that consits of elements that are found in both tags. This struct
|
||||
/// can be subclassed and still behave like a list tag.
|
||||
template <typename ListTag1, typename ListTag2>
|
||||
struct ListTagIntersect : detail::ListRoot {
|
||||
using list = typename detail::ListIntersect<
|
||||
typename ListTag1::list,
|
||||
typename ListTag2::list>::type;
|
||||
struct ListTagIntersect : detail::ListRoot
|
||||
{
|
||||
using list =
|
||||
typename detail::ListIntersect<typename ListTag1::list, typename ListTag2::list>::type;
|
||||
};
|
||||
|
||||
/// For each typename represented by the list tag, call the functor with a
|
||||
/// default instance of that type.
|
||||
///
|
||||
template <typename Functor, typename ListTag>
|
||||
VTKM_CONT
|
||||
void ListForEach(Functor &f, ListTag)
|
||||
VTKM_CONT void ListForEach(Functor& f, ListTag)
|
||||
{
|
||||
VTKM_IS_LIST_TAG(ListTag);
|
||||
detail::ListForEachImpl(f, typename ListTag::list());
|
||||
@ -97,8 +96,7 @@ void ListForEach(Functor &f, ListTag)
|
||||
/// default instance of that type.
|
||||
///
|
||||
template <typename Functor, typename ListTag>
|
||||
VTKM_CONT
|
||||
void ListForEach(const Functor &f, ListTag)
|
||||
VTKM_CONT void ListForEach(const Functor& f, ListTag)
|
||||
{
|
||||
VTKM_IS_LIST_TAG(ListTag);
|
||||
detail::ListForEachImpl(f, typename ListTag::list());
|
||||
@ -112,8 +110,7 @@ template<typename ListTag, typename Type>
|
||||
struct ListContains
|
||||
{
|
||||
VTKM_IS_LIST_TAG(ListTag);
|
||||
static VTKM_CONSTEXPR bool value =
|
||||
detail::ListContainsImpl<Type,typename ListTag::list>::value;
|
||||
static VTKM_CONSTEXPR bool value = detail::ListContainsImpl<Type, typename ListTag::list>::value;
|
||||
};
|
||||
|
||||
} // namespace vtkm
|
||||
|
1724
vtkm/Math.h
1724
vtkm/Math.h
File diff suppressed because it is too large
Load Diff
204
vtkm/Matrix.h
204
vtkm/Matrix.h
@ -28,7 +28,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief Basic Matrix type.
|
||||
///
|
||||
@ -41,7 +42,8 @@ namespace vtkm {
|
||||
/// tensors.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
class Matrix {
|
||||
class Matrix
|
||||
{
|
||||
public:
|
||||
typedef T ComponentType;
|
||||
static const vtkm::IdComponent NUM_ROWS = NumRow;
|
||||
@ -52,14 +54,16 @@ public:
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
explicit Matrix(const ComponentType& value)
|
||||
: Components(vtkm::Vec<ComponentType, NUM_COLUMNS>(value)) { }
|
||||
: Components(vtkm::Vec<ComponentType, NUM_COLUMNS>(value))
|
||||
{
|
||||
}
|
||||
|
||||
/// Brackets are used to reference a matrix like a 2D array (i.e.
|
||||
/// matrix[row][column]).
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
const vtkm::Vec<ComponentType, NUM_COLUMNS> &
|
||||
operator[](vtkm::IdComponent rowIndex) const {
|
||||
const vtkm::Vec<ComponentType, NUM_COLUMNS>& operator[](vtkm::IdComponent rowIndex) const
|
||||
{
|
||||
VTKM_ASSERT(rowIndex >= 0);
|
||||
VTKM_ASSERT(rowIndex < NUM_ROWS);
|
||||
return this->Components[rowIndex];
|
||||
@ -69,8 +73,8 @@ public:
|
||||
/// matrix[row][column].
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<ComponentType, NUM_COLUMNS> &
|
||||
operator[](vtkm::IdComponent rowIndex) {
|
||||
vtkm::Vec<ComponentType, NUM_COLUMNS>& operator[](vtkm::IdComponent rowIndex)
|
||||
{
|
||||
VTKM_ASSERT(rowIndex >= 0);
|
||||
VTKM_ASSERT(rowIndex < NUM_ROWS);
|
||||
return this->Components[rowIndex];
|
||||
@ -80,8 +84,8 @@ public:
|
||||
/// notation i.e. matrix(row,column).
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
const ComponentType &
|
||||
operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex) const {
|
||||
const ComponentType& operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex) const
|
||||
{
|
||||
VTKM_ASSERT(rowIndex >= 0);
|
||||
VTKM_ASSERT(rowIndex < NUM_ROWS);
|
||||
VTKM_ASSERT(colIndex >= 0);
|
||||
@ -93,8 +97,8 @@ public:
|
||||
/// notation i.e. matrix(row,column).
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
ComponentType &
|
||||
operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex) {
|
||||
ComponentType& operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex)
|
||||
{
|
||||
VTKM_ASSERT(rowIndex >= 0);
|
||||
VTKM_ASSERT(rowIndex < NUM_ROWS);
|
||||
VTKM_ASSERT(colIndex >= 0);
|
||||
@ -110,8 +114,7 @@ private:
|
||||
/// matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
const vtkm::Vec<T, NumCol> &MatrixGetRow(
|
||||
VTKM_EXEC_CONT const vtkm::Vec<T, NumCol>& MatrixGetRow(
|
||||
const vtkm::Matrix<T, NumRow, NumCol>& matrix, vtkm::IdComponent rowIndex)
|
||||
{
|
||||
return matrix[rowIndex];
|
||||
@ -121,9 +124,8 @@ const vtkm::Vec<T, NumCol> &MatrixGetRow(
|
||||
/// matrix. Might not be as efficient as the \c MatrixGetRow function.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T, NumRow> MatrixGetColumn(
|
||||
const vtkm::Matrix<T,NumRow,NumCol> &matrix, vtkm::IdComponent columnIndex)
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, NumRow> MatrixGetColumn(const vtkm::Matrix<T, NumRow, NumCol>& matrix,
|
||||
vtkm::IdComponent columnIndex)
|
||||
{
|
||||
vtkm::Vec<T, NumRow> columnValues;
|
||||
for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
|
||||
@ -136,10 +138,8 @@ vtkm::Vec<T, NumRow> MatrixGetColumn(
|
||||
/// Convenience function for setting a row of a matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
void MatrixSetRow(vtkm::Matrix<T,NumRow,NumCol> &matrix,
|
||||
vtkm::IdComponent rowIndex,
|
||||
const vtkm::Vec<T,NumCol> &rowValues)
|
||||
VTKM_EXEC_CONT void MatrixSetRow(vtkm::Matrix<T, NumRow, NumCol>& matrix,
|
||||
vtkm::IdComponent rowIndex, const vtkm::Vec<T, NumCol>& rowValues)
|
||||
{
|
||||
matrix[rowIndex] = rowValues;
|
||||
}
|
||||
@ -147,8 +147,7 @@ void MatrixSetRow(vtkm::Matrix<T,NumRow,NumCol> &matrix,
|
||||
/// Convenience function for setting a column of a matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
void MatrixSetColumn(vtkm::Matrix<T,NumRow,NumCol> &matrix,
|
||||
VTKM_EXEC_CONT void MatrixSetColumn(vtkm::Matrix<T, NumRow, NumCol>& matrix,
|
||||
vtkm::IdComponent columnIndex,
|
||||
const vtkm::Vec<T, NumRow>& columnValues)
|
||||
{
|
||||
@ -160,12 +159,9 @@ void MatrixSetColumn(vtkm::Matrix<T,NumRow,NumCol> &matrix,
|
||||
|
||||
/// Standard matrix multiplication.
|
||||
///
|
||||
template<typename T,
|
||||
vtkm::IdComponent NumRow,
|
||||
vtkm::IdComponent NumCol,
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol,
|
||||
vtkm::IdComponent NumInternal>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,NumRow,NumCol> MatrixMultiply(
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, NumRow, NumCol> MatrixMultiply(
|
||||
const vtkm::Matrix<T, NumRow, NumInternal>& leftFactor,
|
||||
const vtkm::Matrix<T, NumInternal, NumCol>& rightFactor)
|
||||
{
|
||||
@ -175,12 +171,9 @@ vtkm::Matrix<T,NumRow,NumCol> MatrixMultiply(
|
||||
for (vtkm::IdComponent colIndex = 0; colIndex < NumCol; colIndex++)
|
||||
{
|
||||
T sum = T(leftFactor(rowIndex, 0) * rightFactor(0, colIndex));
|
||||
for (vtkm::IdComponent internalIndex = 1;
|
||||
internalIndex < NumInternal;
|
||||
internalIndex++)
|
||||
for (vtkm::IdComponent internalIndex = 1; internalIndex < NumInternal; internalIndex++)
|
||||
{
|
||||
sum = T(sum + (leftFactor(rowIndex, internalIndex)
|
||||
* rightFactor(internalIndex, colIndex)));
|
||||
sum = T(sum + (leftFactor(rowIndex, internalIndex) * rightFactor(internalIndex, colIndex)));
|
||||
}
|
||||
result(rowIndex, colIndex) = sum;
|
||||
}
|
||||
@ -191,16 +184,13 @@ vtkm::Matrix<T,NumRow,NumCol> MatrixMultiply(
|
||||
/// Standard matrix-vector multiplication.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,NumRow> MatrixMultiply(
|
||||
const vtkm::Matrix<T,NumRow,NumCol> &leftFactor,
|
||||
const vtkm::Vec<T,NumCol> &rightFactor)
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, NumRow> MatrixMultiply(
|
||||
const vtkm::Matrix<T, NumRow, NumCol>& leftFactor, const vtkm::Vec<T, NumCol>& rightFactor)
|
||||
{
|
||||
vtkm::Vec<T, NumRow> product;
|
||||
for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
|
||||
{
|
||||
product[rowIndex] =
|
||||
vtkm::dot(vtkm::MatrixGetRow(leftFactor,rowIndex), rightFactor);
|
||||
product[rowIndex] = vtkm::dot(vtkm::MatrixGetRow(leftFactor, rowIndex), rightFactor);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
@ -208,17 +198,13 @@ vtkm::Vec<T,NumRow> MatrixMultiply(
|
||||
/// Standard vector-matrix multiplication
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,NumCol> MatrixMultiply(
|
||||
const vtkm::Vec<T,NumRow> &leftFactor,
|
||||
const vtkm::Matrix<T,NumRow,NumCol> &rightFactor)
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, NumCol> MatrixMultiply(
|
||||
const vtkm::Vec<T, NumRow>& leftFactor, const vtkm::Matrix<T, NumRow, NumCol>& rightFactor)
|
||||
{
|
||||
vtkm::Vec<T, NumCol> product;
|
||||
for (vtkm::IdComponent colIndex = 0; colIndex < NumCol; colIndex++)
|
||||
{
|
||||
product[colIndex] =
|
||||
vtkm::dot(leftFactor,
|
||||
vtkm::MatrixGetColumn(rightFactor, colIndex));
|
||||
product[colIndex] = vtkm::dot(leftFactor, vtkm::MatrixGetColumn(rightFactor, colIndex));
|
||||
}
|
||||
return product;
|
||||
}
|
||||
@ -226,8 +212,7 @@ vtkm::Vec<T,NumCol> MatrixMultiply(
|
||||
/// Returns the identity matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,Size,Size> MatrixIdentity()
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, Size, Size> MatrixIdentity()
|
||||
{
|
||||
vtkm::Matrix<T, Size, Size> result(T(0));
|
||||
for (vtkm::IdComponent index = 0; index < Size; index++)
|
||||
@ -240,8 +225,7 @@ vtkm::Matrix<T,Size,Size> MatrixIdentity()
|
||||
/// Fills the given matrix with the identity matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
void MatrixIdentity(vtkm::Matrix<T,Size,Size> &matrix)
|
||||
VTKM_EXEC_CONT void MatrixIdentity(vtkm::Matrix<T, Size, Size>& matrix)
|
||||
{
|
||||
matrix = vtkm::MatrixIdentity<T, Size>();
|
||||
}
|
||||
@ -249,8 +233,7 @@ void MatrixIdentity(vtkm::Matrix<T,Size,Size> &matrix)
|
||||
/// Returns the transpose of the given matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRows, vtkm::IdComponent NumCols>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,NumCols,NumRows> MatrixTranspose(
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, NumCols, NumRows> MatrixTranspose(
|
||||
const vtkm::Matrix<T, NumRows, NumCols>& matrix)
|
||||
{
|
||||
vtkm::Matrix<T, NumCols, NumRows> result;
|
||||
@ -270,22 +253,19 @@ vtkm::Matrix<T,NumCols,NumRows> MatrixTranspose(
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Used with MatrixLUPFactor.
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
void MatrixLUPFactorFindPivot(vtkm::Matrix<T,Size,Size> &A,
|
||||
VTKM_EXEC_CONT void MatrixLUPFactorFindPivot(vtkm::Matrix<T, Size, Size>& A,
|
||||
vtkm::Vec<vtkm::IdComponent, Size>& permutation,
|
||||
vtkm::IdComponent topCornerIndex,
|
||||
T &inversionParity,
|
||||
vtkm::IdComponent topCornerIndex, T& inversionParity,
|
||||
bool& valid)
|
||||
{
|
||||
vtkm::IdComponent maxRowIndex = topCornerIndex;
|
||||
T maxValue = vtkm::Abs(A(maxRowIndex, topCornerIndex));
|
||||
for (vtkm::IdComponent rowIndex = topCornerIndex + 1;
|
||||
rowIndex < Size;
|
||||
rowIndex++)
|
||||
for (vtkm::IdComponent rowIndex = topCornerIndex + 1; rowIndex < Size; rowIndex++)
|
||||
{
|
||||
T compareValue = vtkm::Abs(A(rowIndex, topCornerIndex));
|
||||
if (maxValue < compareValue)
|
||||
@ -295,15 +275,16 @@ void MatrixLUPFactorFindPivot(vtkm::Matrix<T,Size,Size> &A,
|
||||
}
|
||||
}
|
||||
|
||||
if (maxValue < vtkm::Epsilon<T>()) { valid = false; }
|
||||
if (maxValue < vtkm::Epsilon<T>())
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (maxRowIndex != topCornerIndex)
|
||||
{
|
||||
// Swap rows in matrix.
|
||||
vtkm::Vec<T, Size> maxRow = vtkm::MatrixGetRow(A, maxRowIndex);
|
||||
vtkm::MatrixSetRow(A,
|
||||
maxRowIndex,
|
||||
vtkm::MatrixGetRow(A,topCornerIndex));
|
||||
vtkm::MatrixSetRow(A, maxRowIndex, vtkm::MatrixGetRow(A, topCornerIndex));
|
||||
vtkm::MatrixSetRow(A, topCornerIndex, maxRow);
|
||||
|
||||
// Record change in permutation matrix.
|
||||
@ -318,29 +299,21 @@ void MatrixLUPFactorFindPivot(vtkm::Matrix<T,Size,Size> &A,
|
||||
|
||||
// Used with MatrixLUPFactor
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
void MatrixLUPFactorFindUpperTriangleElements(vtkm::Matrix<T,Size,Size> &A,
|
||||
VTKM_EXEC_CONT void MatrixLUPFactorFindUpperTriangleElements(vtkm::Matrix<T, Size, Size>& A,
|
||||
vtkm::IdComponent topCornerIndex)
|
||||
{
|
||||
// Compute values for upper triangle on row topCornerIndex
|
||||
for (vtkm::IdComponent colIndex = topCornerIndex+1;
|
||||
colIndex < Size;
|
||||
colIndex++)
|
||||
for (vtkm::IdComponent colIndex = topCornerIndex + 1; colIndex < Size; colIndex++)
|
||||
{
|
||||
A(topCornerIndex, colIndex) /= A(topCornerIndex, topCornerIndex);
|
||||
}
|
||||
|
||||
// Update the rest of the matrix for calculations on subsequent rows
|
||||
for (vtkm::IdComponent rowIndex = topCornerIndex+1;
|
||||
rowIndex < Size;
|
||||
rowIndex++)
|
||||
for (vtkm::IdComponent rowIndex = topCornerIndex + 1; rowIndex < Size; rowIndex++)
|
||||
{
|
||||
for (vtkm::IdComponent colIndex = topCornerIndex+1;
|
||||
colIndex < Size;
|
||||
colIndex++)
|
||||
for (vtkm::IdComponent colIndex = topCornerIndex + 1; colIndex < Size; colIndex++)
|
||||
{
|
||||
A(rowIndex,colIndex) -=
|
||||
A(rowIndex,topCornerIndex)*A(topCornerIndex,colIndex);
|
||||
A(rowIndex, colIndex) -= A(rowIndex, topCornerIndex) * A(topCornerIndex, colIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,11 +349,9 @@ void MatrixLUPFactorFindUpperTriangleElements(vtkm::Matrix<T,Size,Size> &A,
|
||||
/// Otherwise, valid is set to false and the result is indeterminant.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
void MatrixLUPFactor(vtkm::Matrix<T,Size,Size> &A,
|
||||
VTKM_EXEC_CONT void MatrixLUPFactor(vtkm::Matrix<T, Size, Size>& A,
|
||||
vtkm::Vec<vtkm::IdComponent, Size>& permutation,
|
||||
T &inversionParity,
|
||||
bool &valid)
|
||||
T& inversionParity, bool& valid)
|
||||
{
|
||||
// Initialize permutation.
|
||||
for (vtkm::IdComponent index = 0; index < Size; index++)
|
||||
@ -402,10 +373,8 @@ void MatrixLUPFactor(vtkm::Matrix<T,Size,Size> &A,
|
||||
/// matrices calculated by MatrixLUPFactor from A. The x matrix is returned.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,Size>
|
||||
MatrixLUPSolve(const vtkm::Matrix<T,Size,Size> &LU,
|
||||
const vtkm::Vec<vtkm::IdComponent,Size> &permutation,
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, Size> MatrixLUPSolve(
|
||||
const vtkm::Matrix<T, Size, Size>& LU, const vtkm::Vec<vtkm::IdComponent, Size>& permutation,
|
||||
const vtkm::Vec<T, Size>& b)
|
||||
{
|
||||
// The LUP-factorization gives us PA = LU or equivalently A = inv(P)LU.
|
||||
@ -448,10 +417,8 @@ MatrixLUPSolve(const vtkm::Matrix<T,Size,Size> &LU,
|
||||
/// is set to true, false otherwise.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,Size> SolveLinearSystem(const vtkm::Matrix<T,Size,Size> &A,
|
||||
const vtkm::Vec<T,Size> &b,
|
||||
bool &valid)
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, Size> SolveLinearSystem(const vtkm::Matrix<T, Size, Size>& A,
|
||||
const vtkm::Vec<T, Size>& b, bool& valid)
|
||||
{
|
||||
// First, we will make an LUP-factorization to help us.
|
||||
vtkm::Matrix<T, Size, Size> LU = A;
|
||||
@ -467,8 +434,7 @@ vtkm::Vec<T,Size> SolveLinearSystem(const vtkm::Matrix<T,Size,Size> &A,
|
||||
/// the inverse will not be correct and valid will be set to false.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,Size,Size> MatrixInverse(const vtkm::Matrix<T,Size,Size> &A,
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, Size, Size> MatrixInverse(const vtkm::Matrix<T, Size, Size>& A,
|
||||
bool& valid)
|
||||
{
|
||||
// First, we will make an LUP-factorization to help us.
|
||||
@ -495,8 +461,7 @@ vtkm::Matrix<T,Size,Size> MatrixInverse(const vtkm::Matrix<T,Size,Size> &A,
|
||||
/// Compute the determinant of a matrix.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
VTKM_EXEC_CONT
|
||||
T MatrixDeterminant(const vtkm::Matrix<T,Size,Size> &A)
|
||||
VTKM_EXEC_CONT T MatrixDeterminant(const vtkm::Matrix<T, Size, Size>& A)
|
||||
{
|
||||
// First, we will make an LUP-factorization to help us.
|
||||
vtkm::Matrix<T, Size, Size> LU = A;
|
||||
@ -507,7 +472,10 @@ T MatrixDeterminant(const vtkm::Matrix<T,Size,Size> &A)
|
||||
|
||||
// If the matrix is singular, the factorization is invalid, but in that
|
||||
// case we know that the determinant is 0.
|
||||
if (!valid) { return 0; }
|
||||
if (!valid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The determinant is equal to the product of the diagonal of the L matrix,
|
||||
// possibly negated depending on the parity of the inversion. The
|
||||
@ -524,26 +492,22 @@ T MatrixDeterminant(const vtkm::Matrix<T,Size,Size> &A)
|
||||
// Specializations for common small determinants.
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
T MatrixDeterminant(const vtkm::Matrix<T,1,1> &A)
|
||||
VTKM_EXEC_CONT T MatrixDeterminant(const vtkm::Matrix<T, 1, 1>& A)
|
||||
{
|
||||
return A(0, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
T MatrixDeterminant(const vtkm::Matrix<T,2,2> &A)
|
||||
VTKM_EXEC_CONT T MatrixDeterminant(const vtkm::Matrix<T, 2, 2>& A)
|
||||
{
|
||||
return A(0, 0) * A(1, 1) - A(1, 0) * A(0, 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
T MatrixDeterminant(const vtkm::Matrix<T,3,3> &A)
|
||||
VTKM_EXEC_CONT T MatrixDeterminant(const vtkm::Matrix<T, 3, 3>& A)
|
||||
{
|
||||
return A(0,0) * A(1,1) * A(2,2) + A(1,0) * A(2,1) * A(0,2) +
|
||||
A(2,0) * A(0,1) * A(1,2) - A(0,0) * A(2,1) * A(1,2) -
|
||||
A(1,0) * A(0,1) * A(2,2) - A(2,0) * A(1,1) * A(0,2);
|
||||
return A(0, 0) * A(1, 1) * A(2, 2) + A(1, 0) * A(2, 1) * A(0, 2) + A(2, 0) * A(0, 1) * A(1, 2) -
|
||||
A(0, 0) * A(2, 1) * A(1, 2) - A(1, 0) * A(0, 1) * A(2, 2) - A(2, 0) * A(1, 1) * A(0, 2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@ -552,10 +516,13 @@ T MatrixDeterminant(const vtkm::Matrix<T,3,3> &A)
|
||||
/// Tag used to identify 2 dimensional types (matrices). A TypeTraits class
|
||||
/// will typedef this class to DimensionalityTag.
|
||||
///
|
||||
struct TypeTraitsMatrixTag {};
|
||||
struct TypeTraitsMatrixTag
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
struct TypeTraits<vtkm::Matrix<T, NumRow, NumCol> > {
|
||||
struct TypeTraits<vtkm::Matrix<T, NumRow, NumCol>>
|
||||
{
|
||||
typedef typename TypeTraits<T>::NumericTag NumericTag;
|
||||
typedef TypeTraitsMatrixTag DimensionalityTag;
|
||||
};
|
||||
@ -563,9 +530,11 @@ struct TypeTraits<vtkm::Matrix<T, NumRow, NumCol> > {
|
||||
/// A matrix has vector traits to implement component-wise operations.
|
||||
///
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
struct VecTraits<vtkm::Matrix<T, NumRow, NumCol> > {
|
||||
struct VecTraits<vtkm::Matrix<T, NumRow, NumCol>>
|
||||
{
|
||||
private:
|
||||
typedef vtkm::Matrix<T, NumRow, NumCol> MatrixType;
|
||||
|
||||
public:
|
||||
typedef T ComponentType;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = NumRow * NumCol;
|
||||
@ -573,28 +542,24 @@ public:
|
||||
typedef vtkm::VecTraitsTagSizeStatic IsSizeStatic;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const MatrixType &) {
|
||||
return NUM_COMPONENTS;
|
||||
}
|
||||
static vtkm::IdComponent GetNumberOfComponents(const MatrixType&) { return NUM_COMPONENTS; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static const ComponentType &GetComponent(const MatrixType &matrix,
|
||||
vtkm::IdComponent component) {
|
||||
static const ComponentType& GetComponent(const MatrixType& matrix, vtkm::IdComponent component)
|
||||
{
|
||||
vtkm::IdComponent colIndex = component % NumCol;
|
||||
vtkm::IdComponent rowIndex = component / NumCol;
|
||||
return matrix(rowIndex, colIndex);
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType &GetComponent(MatrixType &matrix,
|
||||
vtkm::IdComponent component) {
|
||||
static ComponentType& GetComponent(MatrixType& matrix, vtkm::IdComponent component)
|
||||
{
|
||||
vtkm::IdComponent colIndex = component % NumCol;
|
||||
vtkm::IdComponent rowIndex = component / NumCol;
|
||||
return matrix(rowIndex, colIndex);
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
static void SetComponent(MatrixType &matrix,
|
||||
vtkm::IdComponent component,
|
||||
T value)
|
||||
static void SetComponent(MatrixType& matrix, vtkm::IdComponent component, T value)
|
||||
{
|
||||
GetComponent(matrix, component) = value;
|
||||
}
|
||||
@ -606,22 +571,21 @@ public:
|
||||
// Basic comparison operators.
|
||||
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
bool operator==(const vtkm::Matrix<T,NumRow,NumCol> &a,
|
||||
VTKM_EXEC_CONT bool operator==(const vtkm::Matrix<T, NumRow, NumCol>& a,
|
||||
const vtkm::Matrix<T, NumRow, NumCol>& b)
|
||||
{
|
||||
for (vtkm::IdComponent colIndex = 0; colIndex < NumCol; colIndex++)
|
||||
{
|
||||
for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
|
||||
{
|
||||
if (a(rowIndex, colIndex) != b(rowIndex, colIndex)) return false;
|
||||
if (a(rowIndex, colIndex) != b(rowIndex, colIndex))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
|
||||
VTKM_EXEC_CONT
|
||||
bool operator!=(const vtkm::Matrix<T,NumRow,NumCol> &a,
|
||||
VTKM_EXEC_CONT bool operator!=(const vtkm::Matrix<T, NumRow, NumCol>& a,
|
||||
const vtkm::Matrix<T, NumRow, NumCol>& b)
|
||||
{
|
||||
return !(a == b);
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/Matrix.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// Uses Newton's method (a.k.a. Newton-Raphson method) to solve a nonlinear
|
||||
/// system of equations. This function assumes that the number of variables
|
||||
@ -36,19 +37,13 @@ namespace vtkm {
|
||||
/// returned.
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template<typename ScalarType,
|
||||
vtkm::IdComponent Size,
|
||||
typename JacobianFunctor,
|
||||
template <typename ScalarType, vtkm::IdComponent Size, typename JacobianFunctor,
|
||||
typename FunctionFunctor>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<ScalarType,Size>
|
||||
NewtonsMethod(JacobianFunctor jacobianEvaluator,
|
||||
FunctionFunctor functionEvaluator,
|
||||
VTKM_EXEC_CONT vtkm::Vec<ScalarType, Size> NewtonsMethod(
|
||||
JacobianFunctor jacobianEvaluator, FunctionFunctor functionEvaluator,
|
||||
vtkm::Vec<ScalarType, Size> desiredFunctionOutput,
|
||||
vtkm::Vec<ScalarType,Size> initialGuess
|
||||
= vtkm::Vec<ScalarType,Size>(ScalarType(0)),
|
||||
ScalarType convergeDifference = ScalarType(1e-3),
|
||||
vtkm::IdComponent maxIterations = 10)
|
||||
vtkm::Vec<ScalarType, Size> initialGuess = vtkm::Vec<ScalarType, Size>(ScalarType(0)),
|
||||
ScalarType convergeDifference = ScalarType(1e-3), vtkm::IdComponent maxIterations = 10)
|
||||
{
|
||||
typedef vtkm::Vec<ScalarType, Size> VectorType;
|
||||
typedef vtkm::Matrix<ScalarType, Size, Size> MatrixType;
|
||||
@ -56,9 +51,7 @@ NewtonsMethod(JacobianFunctor jacobianEvaluator,
|
||||
VectorType x = initialGuess;
|
||||
|
||||
bool converged = false;
|
||||
for (vtkm::IdComponent iteration = 0;
|
||||
!converged && (iteration < maxIterations);
|
||||
iteration++)
|
||||
for (vtkm::IdComponent iteration = 0; !converged && (iteration < maxIterations); iteration++)
|
||||
{
|
||||
// For Newton's method, we solve the linear system
|
||||
//
|
||||
@ -74,10 +67,7 @@ NewtonsMethod(JacobianFunctor jacobianEvaluator,
|
||||
|
||||
bool valid; // Ignored.
|
||||
VectorType deltaX =
|
||||
vtkm::SolveLinearSystem(
|
||||
jacobian,
|
||||
currentFunctionOutput - desiredFunctionOutput,
|
||||
valid);
|
||||
vtkm::SolveLinearSystem(jacobian, currentFunctionOutput - desiredFunctionOutput, valid);
|
||||
|
||||
x = x - deltaX;
|
||||
|
||||
|
66
vtkm/Pair.h
66
vtkm/Pair.h
@ -27,7 +27,8 @@
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// A \c vtkm::Pair is essentially the same as an STL pair object except that
|
||||
/// the methods (constructors and operators) are defined to work in both the
|
||||
@ -64,37 +65,50 @@ struct Pair
|
||||
SecondType second;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Pair() : first(), second() { }
|
||||
Pair()
|
||||
: first()
|
||||
, second()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Pair(const FirstType& firstSrc, const SecondType& secondSrc)
|
||||
: first(firstSrc), second(secondSrc) { }
|
||||
: first(firstSrc)
|
||||
, second(secondSrc)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U1, typename U2>
|
||||
VTKM_EXEC_CONT
|
||||
Pair(const vtkm::Pair<U1,U2> &src)
|
||||
: first(src.first), second(src.second) { }
|
||||
VTKM_EXEC_CONT Pair(const vtkm::Pair<U1, U2>& src)
|
||||
: first(src.first)
|
||||
, second(src.second)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U1, typename U2>
|
||||
VTKM_EXEC_CONT
|
||||
Pair(const std::pair<U1,U2> &src)
|
||||
: first(src.first), second(src.second) { }
|
||||
VTKM_EXEC_CONT Pair(const std::pair<U1, U2>& src)
|
||||
: first(src.first)
|
||||
, second(src.second)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Pair<FirstType,SecondType> &
|
||||
operator=(const vtkm::Pair<FirstType,SecondType> &src) {
|
||||
vtkm::Pair<FirstType, SecondType>& operator=(const vtkm::Pair<FirstType, SecondType>& src)
|
||||
{
|
||||
this->first = src.first;
|
||||
this->second = src.second;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
bool operator==(const vtkm::Pair<FirstType,SecondType> &other) const {
|
||||
bool operator==(const vtkm::Pair<FirstType, SecondType>& other) const
|
||||
{
|
||||
return ((this->first == other.first) && (this->second == other.second));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
bool operator!=(const vtkm::Pair<FirstType,SecondType> &other) const {
|
||||
bool operator!=(const vtkm::Pair<FirstType, SecondType>& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
@ -102,54 +116,46 @@ struct Pair
|
||||
/// first are equal.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
bool operator<(const vtkm::Pair<FirstType,SecondType> &other) const {
|
||||
return ((this->first < other.first)
|
||||
|| (!(other.first < this->first) && (this->second < other.second)));
|
||||
bool operator<(const vtkm::Pair<FirstType, SecondType>& other) const
|
||||
{
|
||||
return ((this->first < other.first) ||
|
||||
(!(other.first < this->first) && (this->second < other.second)));
|
||||
}
|
||||
|
||||
/// Tests ordering on the first object, and then on the second object if the
|
||||
/// first are equal.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
bool operator>(const vtkm::Pair<FirstType,SecondType> &other) const {
|
||||
return (other < *this);
|
||||
}
|
||||
bool operator>(const vtkm::Pair<FirstType, SecondType>& other) const { return (other < *this); }
|
||||
|
||||
/// Tests ordering on the first object, and then on the second object if the
|
||||
/// first are equal.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
bool operator<=(const vtkm::Pair<FirstType,SecondType> &other) const {
|
||||
return !(other < *this);
|
||||
}
|
||||
bool operator<=(const vtkm::Pair<FirstType, SecondType>& other) const { return !(other < *this); }
|
||||
|
||||
/// Tests ordering on the first object, and then on the second object if the
|
||||
/// first are equal.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
bool operator>=(const vtkm::Pair<FirstType,SecondType> &other) const {
|
||||
return !(*this < other);
|
||||
}
|
||||
bool operator>=(const vtkm::Pair<FirstType, SecondType>& other) const { return !(*this < other); }
|
||||
};
|
||||
|
||||
/// Pairwise Add.
|
||||
/// This is done by adding the two objects separately.
|
||||
/// Useful for Reduce operation on a zipped array
|
||||
template <typename T, typename U>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Pair<T, U> operator+(const vtkm::Pair<T, U>& a, const vtkm::Pair<T, U> &b)
|
||||
VTKM_EXEC_CONT vtkm::Pair<T, U> operator+(const vtkm::Pair<T, U>& a, const vtkm::Pair<T, U>& b)
|
||||
{
|
||||
return vtkm::Pair<T, U>(a.first + b.first, a.second + b.second);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Pair<T1,T2> make_Pair(const T1 &firstSrc, const T2 &secondSrc)
|
||||
VTKM_EXEC_CONT vtkm::Pair<T1, T2> make_Pair(const T1& firstSrc, const T2& secondSrc)
|
||||
{
|
||||
return vtkm::Pair<T1, T2>(firstSrc, secondSrc);
|
||||
}
|
||||
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_Pair_h
|
||||
|
37
vtkm/Range.h
37
vtkm/Range.h
@ -25,7 +25,8 @@
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief Represent a continuous scalar range of values.
|
||||
///
|
||||
@ -42,13 +43,18 @@ struct Range
|
||||
vtkm::Float64 Max;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
Range() : Min(vtkm::Infinity64()), Max(vtkm::NegativeInfinity64()) { }
|
||||
Range()
|
||||
: Min(vtkm::Infinity64())
|
||||
, Max(vtkm::NegativeInfinity64())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
VTKM_EXEC_CONT
|
||||
Range(const T1 &min, const T2 &max)
|
||||
: Min(static_cast<vtkm::Float64>(min)), Max(static_cast<vtkm::Float64>(max))
|
||||
{ }
|
||||
VTKM_EXEC_CONT Range(const T1& min, const T2& max)
|
||||
: Min(static_cast<vtkm::Float64>(min))
|
||||
, Max(static_cast<vtkm::Float64>(max))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const vtkm::Range& operator=(const vtkm::Range& src)
|
||||
@ -68,10 +74,7 @@ struct Range
|
||||
/// are equal then true is returned.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
bool IsNonEmpty() const
|
||||
{
|
||||
return (this->Min <= this->Max);
|
||||
}
|
||||
bool IsNonEmpty() const { return (this->Min <= this->Max); }
|
||||
|
||||
/// \b Determines if a value is within the range.
|
||||
///
|
||||
@ -80,8 +83,7 @@ struct Range
|
||||
/// the value is exactly the min or max, true is returned.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
bool Contains(const T &value) const
|
||||
VTKM_EXEC_CONT bool Contains(const T& value) const
|
||||
{
|
||||
return ((this->Min <= static_cast<vtkm::Float64>(value)) &&
|
||||
(this->Max >= static_cast<vtkm::Float64>(value)));
|
||||
@ -130,8 +132,7 @@ struct Range
|
||||
/// done.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
void Include(const T &value)
|
||||
VTKM_EXEC_CONT void Include(const T& value)
|
||||
{
|
||||
this->Min = vtkm::Min(this->Min, static_cast<vtkm::Float64>(value));
|
||||
this->Max = vtkm::Max(this->Max, static_cast<vtkm::Float64>(value));
|
||||
@ -164,10 +165,7 @@ struct Range
|
||||
/// \b Operator for union
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Range operator+(const vtkm::Range &otherRange) const
|
||||
{
|
||||
return this->Union(otherRange);
|
||||
}
|
||||
vtkm::Range operator+(const vtkm::Range& otherRange) const { return this->Union(otherRange); }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
bool operator==(const vtkm::Range& otherRange) const
|
||||
@ -186,8 +184,7 @@ struct Range
|
||||
|
||||
/// Helper function for printing ranges during testing
|
||||
///
|
||||
static inline VTKM_CONT
|
||||
std::ostream &operator<<(std::ostream &stream, const vtkm::Range &range)
|
||||
static inline VTKM_CONT std::ostream& operator<<(std::ostream& stream, const vtkm::Range& range)
|
||||
{
|
||||
return stream << "[" << range.Min << ".." << range.Max << "]";
|
||||
}
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
#define VTKM_STATIC_ASSERT(condition) \
|
||||
static_assert((condition), "Failed static assert: " #condition)
|
||||
#define VTKM_STATIC_ASSERT_MSG(condition, message) \
|
||||
static_assert( (condition), message)
|
||||
|
||||
#define VTKM_STATIC_ASSERT_MSG(condition, message) static_assert((condition), message)
|
||||
|
||||
#endif //vtk_m_StaticAssert_h
|
||||
|
@ -22,7 +22,8 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief A tag used to identify the cell elements in a topology.
|
||||
///
|
||||
@ -30,7 +31,9 @@ namespace vtkm {
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagCell { };
|
||||
struct TopologyElementTagCell
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief A tag used to identify the point elements in a topology.
|
||||
///
|
||||
@ -38,7 +41,9 @@ struct TopologyElementTagCell { };
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagPoint { };
|
||||
struct TopologyElementTagPoint
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief A tag used to identify the edge elements in a topology.
|
||||
///
|
||||
@ -46,7 +51,9 @@ struct TopologyElementTagPoint { };
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagEdge { };
|
||||
struct TopologyElementTagEdge
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief A tag used to identify the face elements in a topology.
|
||||
///
|
||||
@ -54,10 +61,12 @@ struct TopologyElementTagEdge { };
|
||||
/// example, a 3D mesh has points, edges, faces, and cells. Each of these is an
|
||||
/// example of a topology element and has its own tag.
|
||||
///
|
||||
struct TopologyElementTagFace { };
|
||||
struct TopologyElementTagFace
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// Checks to see if the given object is a topology element tag.This check is
|
||||
/// compatible with C++11 type_traits.
|
||||
@ -90,7 +99,6 @@ struct TopologyElementTagCheck<vtkm::TopologyElementTagFace> : std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
#define VTKM_IS_TOPOLOGY_ELEMENT_TAG(type) \
|
||||
static_assert(::vtkm::internal::TopologyElementTagCheck<type>::value, \
|
||||
"Invalid Topology Element Tag being used")
|
||||
|
@ -28,7 +28,8 @@
|
||||
#include <vtkm/Matrix.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief Transform a 3D point by a transformation matrix.
|
||||
///
|
||||
@ -42,13 +43,11 @@ namespace vtkm {
|
||||
/// transformations.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,3> Transform3DPoint(const vtkm::Matrix<T,4,4> &matrix,
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, 3> Transform3DPoint(const vtkm::Matrix<T, 4, 4>& matrix,
|
||||
const vtkm::Vec<T, 3>& point)
|
||||
{
|
||||
vtkm::Vec<T, 4> homogeneousPoint(point[0], point[1], point[2], T(1));
|
||||
return vtkm::Vec<T,3>(
|
||||
vtkm::dot(vtkm::MatrixGetRow(matrix,0), homogeneousPoint),
|
||||
return vtkm::Vec<T, 3>(vtkm::dot(vtkm::MatrixGetRow(matrix, 0), homogeneousPoint),
|
||||
vtkm::dot(vtkm::MatrixGetRow(matrix, 1), homogeneousPoint),
|
||||
vtkm::dot(vtkm::MatrixGetRow(matrix, 2), homogeneousPoint));
|
||||
}
|
||||
@ -63,14 +62,12 @@ vtkm::Vec<T,3> Transform3DPoint(const vtkm::Matrix<T,4,4> &matrix,
|
||||
/// transformations, but requires some more computations.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,3> Transform3DPointPerspective(const vtkm::Matrix<T,4,4> &matrix,
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, 3> Transform3DPointPerspective(const vtkm::Matrix<T, 4, 4>& matrix,
|
||||
const vtkm::Vec<T, 3>& point)
|
||||
{
|
||||
vtkm::Vec<T, 4> homogeneousPoint(point[0], point[1], point[2], T(1));
|
||||
T inverseW = 1 / vtkm::dot(vtkm::MatrixGetRow(matrix, 3), homogeneousPoint);
|
||||
return vtkm::Vec<T,3>(
|
||||
vtkm::dot(vtkm::MatrixGetRow(matrix,0), homogeneousPoint)*inverseW,
|
||||
return vtkm::Vec<T, 3>(vtkm::dot(vtkm::MatrixGetRow(matrix, 0), homogeneousPoint) * inverseW,
|
||||
vtkm::dot(vtkm::MatrixGetRow(matrix, 1), homogeneousPoint) * inverseW,
|
||||
vtkm::dot(vtkm::MatrixGetRow(matrix, 2), homogeneousPoint) * inverseW);
|
||||
}
|
||||
@ -82,16 +79,12 @@ vtkm::Vec<T,3> Transform3DPointPerspective(const vtkm::Matrix<T,4,4> &matrix,
|
||||
/// vectors do not get translated.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<T,3> Transform3DVector(const vtkm::Matrix<T,4,4> &matrix,
|
||||
VTKM_EXEC_CONT vtkm::Vec<T, 3> Transform3DVector(const vtkm::Matrix<T, 4, 4>& matrix,
|
||||
const vtkm::Vec<T, 3>& vector)
|
||||
{
|
||||
vtkm::Vec<T, 4> homogeneousVector(vector[0], vector[1], vector[2], T(0));
|
||||
homogeneousVector = vtkm::MatrixMultiply(matrix, homogeneousVector);
|
||||
return vtkm::Vec<T,3>(
|
||||
homogeneousVector[0],
|
||||
homogeneousVector[1],
|
||||
homogeneousVector[2]);
|
||||
return vtkm::Vec<T, 3>(homogeneousVector[0], homogeneousVector[1], homogeneousVector[2]);
|
||||
}
|
||||
|
||||
/// \brief Returns a scale matrix.
|
||||
@ -100,9 +93,8 @@ vtkm::Vec<T,3> Transform3DVector(const vtkm::Matrix<T,4,4> &matrix,
|
||||
/// transformation matrix for those scales.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4>
|
||||
Transform3DScale(const T &scaleX, const T &scaleY, const T &scaleZ)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DScale(const T& scaleX, const T& scaleY,
|
||||
const T& scaleZ)
|
||||
{
|
||||
vtkm::Matrix<T, 4, 4> scaleMatrix(T(0));
|
||||
scaleMatrix(0, 0) = scaleX;
|
||||
@ -118,8 +110,7 @@ Transform3DScale(const T &scaleX, const T &scaleY, const T &scaleZ)
|
||||
/// returns a transformation matrix for those scales.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DScale(const vtkm::Vec<T,3> &scaleVec)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DScale(const vtkm::Vec<T, 3>& scaleVec)
|
||||
{
|
||||
return vtkm::Transform3DScale(scaleVec[0], scaleVec[1], scaleVec[2]);
|
||||
}
|
||||
@ -130,8 +121,7 @@ vtkm::Matrix<T,4,4> Transform3DScale(const vtkm::Vec<T,3> &scaleVec)
|
||||
/// scales.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DScale(const T &scale)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DScale(const T& scale)
|
||||
{
|
||||
return vtkm::Transform3DScale(scale, scale, scale);
|
||||
}
|
||||
@ -139,8 +129,7 @@ vtkm::Matrix<T,4,4> Transform3DScale(const T &scale)
|
||||
/// \brief Returns a translation matrix.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DTranslate(const T &x, const T &y, const T &z)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DTranslate(const T& x, const T& y, const T& z)
|
||||
{
|
||||
vtkm::Matrix<T, 4, 4> translateMatrix;
|
||||
vtkm::MatrixIdentity(translateMatrix);
|
||||
@ -150,8 +139,7 @@ vtkm::Matrix<T,4,4> Transform3DTranslate(const T &x, const T &y, const T &z)
|
||||
return translateMatrix;
|
||||
}
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DTranslate(const vtkm::Vec<T,3> &v)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DTranslate(const vtkm::Vec<T, 3>& v)
|
||||
{
|
||||
return vtkm::Transform3DTranslate(v[0], v[1], v[2]);
|
||||
}
|
||||
@ -164,8 +152,7 @@ vtkm::Matrix<T,4,4> Transform3DTranslate(const vtkm::Vec<T,3> &v)
|
||||
/// rotation will be counterclockwise.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DRotate(T angleDegrees,
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DRotate(T angleDegrees,
|
||||
const vtkm::Vec<T, 3>& axisOfRotation)
|
||||
{
|
||||
T angleRadians = static_cast<T>(vtkm::Pi() / 180) * angleDegrees;
|
||||
@ -198,8 +185,7 @@ vtkm::Matrix<T,4,4> Transform3DRotate(T angleDegrees,
|
||||
return matrix;
|
||||
}
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DRotate(T angleDegrees, T x, T y, T z)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DRotate(T angleDegrees, T x, T y, T z)
|
||||
{
|
||||
return vtkm::Transform3DRotate(angleDegrees, vtkm::Vec<T, 3>(x, y, z));
|
||||
}
|
||||
@ -209,8 +195,7 @@ vtkm::Matrix<T,4,4> Transform3DRotate(T angleDegrees, T x, T y, T z)
|
||||
/// Returns a transformation matrix that rotates around the x axis.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DRotateX(T angleDegrees)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DRotateX(T angleDegrees)
|
||||
{
|
||||
return vtkm::Transform3DRotate(angleDegrees, T(1), T(0), T(0));
|
||||
}
|
||||
@ -220,8 +205,7 @@ vtkm::Matrix<T,4,4> Transform3DRotateX(T angleDegrees)
|
||||
/// Returns a transformation matrix that rotates around the y axis.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DRotateY(T angleDegrees)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DRotateY(T angleDegrees)
|
||||
{
|
||||
return vtkm::Transform3DRotate(angleDegrees, T(0), T(1), T(0));
|
||||
}
|
||||
@ -231,8 +215,7 @@ vtkm::Matrix<T,4,4> Transform3DRotateY(T angleDegrees)
|
||||
/// Returns a transformation matrix that rotates around the z axis.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Matrix<T,4,4> Transform3DRotateZ(T angleDegrees)
|
||||
VTKM_EXEC_CONT vtkm::Matrix<T, 4, 4> Transform3DRotateZ(T angleDegrees)
|
||||
{
|
||||
return vtkm::Transform3DRotate(angleDegrees, T(0), T(0), T(1));
|
||||
}
|
||||
|
@ -22,35 +22,45 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// Tag used to identify types that aren't Real, Integer, Scalar or Vector.
|
||||
///
|
||||
struct TypeTraitsUnknownTag {};
|
||||
struct TypeTraitsUnknownTag
|
||||
{
|
||||
};
|
||||
|
||||
/// Tag used to identify types that store real (floating-point) numbers. A
|
||||
/// TypeTraits class will typedef this class to NumericTag if it stores real
|
||||
/// numbers (or vectors of real numbers).
|
||||
///
|
||||
struct TypeTraitsRealTag {};
|
||||
struct TypeTraitsRealTag
|
||||
{
|
||||
};
|
||||
|
||||
/// Tag used to identify types that store integer numbers. A TypeTraits class
|
||||
/// will typedef this class to NumericTag if it stores integer numbers (or
|
||||
/// vectors of integers).
|
||||
///
|
||||
struct TypeTraitsIntegerTag {};
|
||||
struct TypeTraitsIntegerTag
|
||||
{
|
||||
};
|
||||
|
||||
/// Tag used to identify 0 dimensional types (scalars). Scalars can also be
|
||||
/// treated like vectors when used with VecTraits. A TypeTraits class will
|
||||
/// typedef this class to DimensionalityTag.
|
||||
///
|
||||
struct TypeTraitsScalarTag {};
|
||||
struct TypeTraitsScalarTag
|
||||
{
|
||||
};
|
||||
|
||||
/// Tag used to identify 1 dimensional types (vectors). A TypeTraits class will
|
||||
/// typedef this class to DimensionalityTag.
|
||||
///
|
||||
struct TypeTraitsVectorTag {};
|
||||
|
||||
struct TypeTraitsVectorTag
|
||||
{
|
||||
};
|
||||
|
||||
/// The TypeTraits class provides helpful compile-time information about the
|
||||
/// basic types used in VTKm (and a few others for convienience). The majority
|
||||
@ -79,17 +89,22 @@ public:
|
||||
//
|
||||
template <typename T>
|
||||
struct TypeTraits<const T> : TypeTraits<T>
|
||||
{ };
|
||||
{
|
||||
};
|
||||
|
||||
#define VTKM_BASIC_REAL_TYPE(T) \
|
||||
template<> struct TypeTraits<T> { \
|
||||
template <> \
|
||||
struct TypeTraits<T> \
|
||||
{ \
|
||||
typedef TypeTraitsRealTag NumericTag; \
|
||||
typedef TypeTraitsScalarTag DimensionalityTag; \
|
||||
VTKM_EXEC_CONT static T ZeroInitialization() { return T(); } \
|
||||
};
|
||||
|
||||
#define VTKM_BASIC_INTEGER_TYPE(T) \
|
||||
template<> struct TypeTraits< T > { \
|
||||
template <> \
|
||||
struct TypeTraits<T> \
|
||||
{ \
|
||||
typedef TypeTraitsIntegerTag NumericTag; \
|
||||
typedef TypeTraitsScalarTag DimensionalityTag; \
|
||||
VTKM_EXEC_CONT static T ZeroInitialization() \
|
||||
@ -97,7 +112,7 @@ struct TypeTraits<const T> : TypeTraits<T>
|
||||
typedef T ReturnType; \
|
||||
return ReturnType(); \
|
||||
} \
|
||||
}; \
|
||||
};
|
||||
|
||||
/// Traits for basic C++ types.
|
||||
///
|
||||
@ -117,7 +132,6 @@ VTKM_BASIC_INTEGER_TYPE(unsigned long)
|
||||
VTKM_BASIC_INTEGER_TYPE(long long)
|
||||
VTKM_BASIC_INTEGER_TYPE(unsigned long long)
|
||||
|
||||
|
||||
#undef VTKM_BASIC_REAL_TYPE
|
||||
#undef VTKM_BASIC_INTEGER_TYPE
|
||||
|
||||
@ -145,8 +159,7 @@ struct TypeTraits<vtkm::VecCConst<T> >
|
||||
using DimensionalityTag = TypeTraitsVectorTag;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::VecCConst<T> ZeroInitialization()
|
||||
{ return vtkm::VecCConst<T>(); }
|
||||
static vtkm::VecCConst<T> ZeroInitialization() { return vtkm::VecCConst<T>(); }
|
||||
};
|
||||
|
||||
/// Traits for VecC types.
|
||||
@ -158,8 +171,7 @@ struct TypeTraits<vtkm::VecC<T> >
|
||||
using DimensionalityTag = TypeTraitsVectorTag;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::VecC<T> ZeroInitialization()
|
||||
{ return vtkm::VecC<T>(); }
|
||||
static vtkm::VecC<T> ZeroInitialization() { return vtkm::VecC<T>(); }
|
||||
};
|
||||
|
||||
/// \brief Traits for Pair types.
|
||||
|
544
vtkm/Types.h
544
vtkm/Types.h
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,8 @@
|
||||
#include <vtkm/TypeTraits.h>
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// Predicate that takes a single argument \c x, and returns
|
||||
/// True if it is the identity of the Type \p T.
|
||||
|
@ -27,7 +27,8 @@
|
||||
|
||||
#include <vtkm/internal/ArrayPortalValueReference.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief A short variable-length array from a window in an ArrayPortal.
|
||||
///
|
||||
@ -38,28 +39,30 @@ template<typename PortalType>
|
||||
class VecFromPortal
|
||||
{
|
||||
public:
|
||||
using ComponentType =
|
||||
typename std::remove_const<typename PortalType::ValueType>::type;
|
||||
using ComponentType = typename std::remove_const<typename PortalType::ValueType>::type;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
VecFromPortal() : NumComponents(0), Offset(0) { }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
VecFromPortal(const PortalType &portal,
|
||||
vtkm::IdComponent numComponents = 0,
|
||||
vtkm::Id offset = 0)
|
||||
: Portal(portal), NumComponents(numComponents), Offset(offset) { }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::IdComponent GetNumberOfComponents() const {
|
||||
return this->NumComponents;
|
||||
VecFromPortal()
|
||||
: NumComponents(0)
|
||||
, Offset(0)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T, vtkm::IdComponent DestSize>
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void CopyInto(vtkm::Vec<T,DestSize> &dest) const
|
||||
VecFromPortal(const PortalType& portal, vtkm::IdComponent numComponents = 0, vtkm::Id offset = 0)
|
||||
: Portal(portal)
|
||||
, NumComponents(numComponents)
|
||||
, Offset(offset)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::IdComponent GetNumberOfComponents() const { return this->NumComponents; }
|
||||
|
||||
template <typename T, vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT void CopyInto(vtkm::Vec<T, DestSize>& dest) const
|
||||
{
|
||||
vtkm::IdComponent numComponents = vtkm::Min(DestSize, this->NumComponents);
|
||||
for (vtkm::IdComponent index = 0; index < numComponents; index++)
|
||||
@ -70,11 +73,10 @@ public:
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::internal::ArrayPortalValueReference<PortalType>
|
||||
operator[](vtkm::IdComponent index) const
|
||||
vtkm::internal::ArrayPortalValueReference<PortalType> operator[](vtkm::IdComponent index) const
|
||||
{
|
||||
return vtkm::internal::ArrayPortalValueReference<PortalType>(
|
||||
this->Portal, index + this->Offset);
|
||||
return vtkm::internal::ArrayPortalValueReference<PortalType>(this->Portal,
|
||||
index + this->Offset);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -112,23 +114,21 @@ struct VecTraits<vtkm::VecFromPortal<PortalType> >
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType &vector) {
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType& vector)
|
||||
{
|
||||
return vector.GetNumberOfComponents();
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent componentIndex)
|
||||
static ComponentType GetComponent(const VecType& vector, vtkm::IdComponent componentIndex)
|
||||
{
|
||||
return vector[componentIndex];
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void CopyInto(const VecType &src,
|
||||
vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
|
@ -25,7 +25,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief A short vector from an ArrayPortal and a vector of indices.
|
||||
///
|
||||
@ -37,9 +38,7 @@ template<typename IndexVecType, typename PortalType>
|
||||
class VecFromPortalPermute
|
||||
{
|
||||
public:
|
||||
using ComponentType =
|
||||
typename std::remove_const<typename PortalType::ValueType>::type;
|
||||
|
||||
using ComponentType = typename std::remove_const<typename PortalType::ValueType>::type;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
@ -48,21 +47,20 @@ public:
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
VecFromPortalPermute(const IndexVecType* indices, const PortalType& portal)
|
||||
: Indices(indices), Portal(portal) { }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::IdComponent GetNumberOfComponents() const {
|
||||
return this->Indices->GetNumberOfComponents();
|
||||
: Indices(indices)
|
||||
, Portal(portal)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template<vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT
|
||||
void CopyInto(vtkm::Vec<ComponentType,DestSize> &dest) const
|
||||
vtkm::IdComponent GetNumberOfComponents() const { return this->Indices->GetNumberOfComponents(); }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT void CopyInto(vtkm::Vec<ComponentType, DestSize>& dest) const
|
||||
{
|
||||
vtkm::IdComponent numComponents =
|
||||
vtkm::Min(DestSize, this->GetNumberOfComponents());
|
||||
vtkm::IdComponent numComponents = vtkm::Min(DestSize, this->GetNumberOfComponents());
|
||||
for (vtkm::IdComponent index = 0; index < numComponents; index++)
|
||||
{
|
||||
dest[index] = (*this)[index];
|
||||
@ -82,12 +80,10 @@ private:
|
||||
};
|
||||
|
||||
template <typename IndexVecType, typename PortalType>
|
||||
struct TypeTraits<
|
||||
vtkm::VecFromPortalPermute<IndexVecType,PortalType> >
|
||||
struct TypeTraits<vtkm::VecFromPortalPermute<IndexVecType, PortalType>>
|
||||
{
|
||||
private:
|
||||
typedef vtkm::VecFromPortalPermute<IndexVecType,PortalType>
|
||||
VecType;
|
||||
typedef vtkm::VecFromPortalPermute<IndexVecType, PortalType> VecType;
|
||||
typedef typename PortalType::ValueType ComponentType;
|
||||
|
||||
public:
|
||||
@ -96,18 +92,13 @@ public:
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
static VecType ZeroInitialization()
|
||||
{
|
||||
return VecType();
|
||||
}
|
||||
static VecType ZeroInitialization() { return VecType(); }
|
||||
};
|
||||
|
||||
template <typename IndexVecType, typename PortalType>
|
||||
struct VecTraits<
|
||||
vtkm::VecFromPortalPermute<IndexVecType,PortalType> >
|
||||
struct VecTraits<vtkm::VecFromPortalPermute<IndexVecType, PortalType>>
|
||||
{
|
||||
typedef vtkm::VecFromPortalPermute<IndexVecType,PortalType>
|
||||
VecType;
|
||||
typedef vtkm::VecFromPortalPermute<IndexVecType, PortalType> VecType;
|
||||
|
||||
typedef typename VecType::ComponentType ComponentType;
|
||||
typedef vtkm::VecTraitsTagMultipleComponents HasMultipleComponents;
|
||||
@ -115,23 +106,21 @@ struct VecTraits<
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType &vector) {
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType& vector)
|
||||
{
|
||||
return vector.GetNumberOfComponents();
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent componentIndex)
|
||||
static ComponentType GetComponent(const VecType& vector, vtkm::IdComponent componentIndex)
|
||||
{
|
||||
return vector[componentIndex];
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void CopyInto(const VecType &src,
|
||||
vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
|
@ -25,9 +25,11 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/// Specifies the size of VecRectilinearPointCoordinates for the given
|
||||
/// dimension.
|
||||
@ -55,14 +57,8 @@ struct VecRectilinearPointCoordinatesNumComponents<3>
|
||||
|
||||
VTKM_EXEC_CONSTANT
|
||||
const vtkm::FloatDefault VecRectilinearPointCoordinatesOffsetTable[8][3] = {
|
||||
{ 0.0f, 0.0f, 0.0f },
|
||||
{ 1.0f, 0.0f, 0.0f },
|
||||
{ 1.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f },
|
||||
{ 1.0f, 0.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 1.0f },
|
||||
{ 0.0f, 1.0f, 1.0f }
|
||||
{ 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@ -86,17 +82,18 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
VecRectilinearPointCoordinates(ComponentType origin = ComponentType(0, 0, 0),
|
||||
ComponentType spacing = ComponentType(1, 1, 1))
|
||||
: Origin(origin), Spacing(spacing) { }
|
||||
: Origin(origin)
|
||||
, Spacing(spacing)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::IdComponent GetNumberOfComponents() const { return NUM_COMPONENTS; }
|
||||
|
||||
template <vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT
|
||||
void CopyInto(vtkm::Vec<ComponentType,DestSize> &dest) const
|
||||
VTKM_EXEC_CONT void CopyInto(vtkm::Vec<ComponentType, DestSize>& dest) const
|
||||
{
|
||||
vtkm::IdComponent numComponents =
|
||||
vtkm::Min(DestSize, this->GetNumberOfComponents());
|
||||
vtkm::IdComponent numComponents = vtkm::Min(DestSize, this->GetNumberOfComponents());
|
||||
for (vtkm::IdComponent index = 0; index < numComponents; index++)
|
||||
{
|
||||
dest[index] = (*this)[index];
|
||||
@ -106,8 +103,7 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
ComponentType operator[](vtkm::IdComponent index) const
|
||||
{
|
||||
const vtkm::FloatDefault *offset =
|
||||
detail::VecRectilinearPointCoordinatesOffsetTable[index];
|
||||
const vtkm::FloatDefault* offset = detail::VecRectilinearPointCoordinatesOffsetTable[index];
|
||||
return ComponentType(this->Origin[0] + offset[0] * this->Spacing[0],
|
||||
this->Origin[1] + offset[1] * this->Spacing[1],
|
||||
this->Origin[2] + offset[2] * this->Spacing[2]);
|
||||
@ -134,12 +130,10 @@ struct TypeTraits<vtkm::VecRectilinearPointCoordinates<NumDimensions> >
|
||||
typedef TypeTraitsVectorTag DimensionalityTag;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::VecRectilinearPointCoordinates<NumDimensions>
|
||||
ZeroInitialization()
|
||||
static vtkm::VecRectilinearPointCoordinates<NumDimensions> ZeroInitialization()
|
||||
{
|
||||
return vtkm::VecRectilinearPointCoordinates<NumDimensions>(
|
||||
vtkm::Vec<vtkm::FloatDefault,3>(0,0,0),
|
||||
vtkm::Vec<vtkm::FloatDefault,3>(0,0,0));
|
||||
vtkm::Vec<vtkm::FloatDefault, 3>(0, 0, 0), vtkm::Vec<vtkm::FloatDefault, 3>(0, 0, 0));
|
||||
}
|
||||
};
|
||||
|
||||
@ -155,21 +149,16 @@ struct VecTraits<vtkm::VecRectilinearPointCoordinates<NumDimensions> >
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = VecType::NUM_COMPONENTS;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType &) {
|
||||
return NUM_COMPONENTS;
|
||||
}
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType&) { return NUM_COMPONENTS; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent componentIndex)
|
||||
static ComponentType GetComponent(const VecType& vector, vtkm::IdComponent componentIndex)
|
||||
{
|
||||
return vector[componentIndex];
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void CopyInto(const VecType &src,
|
||||
vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
|
134
vtkm/VecTraits.h
134
vtkm/VecTraits.h
@ -22,28 +22,38 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// A tag for vectors that are "true" vectors (i.e. have more than one
|
||||
/// component).
|
||||
///
|
||||
struct VecTraitsTagMultipleComponents { };
|
||||
struct VecTraitsTagMultipleComponents
|
||||
{
|
||||
};
|
||||
|
||||
/// A tag for vectors that are really just scalars (i.e. have only one
|
||||
/// component)
|
||||
///
|
||||
struct VecTraitsTagSingleComponent { };
|
||||
struct VecTraitsTagSingleComponent
|
||||
{
|
||||
};
|
||||
|
||||
/// A tag for vectors where the number of components are known at compile time.
|
||||
///
|
||||
struct VecTraitsTagSizeStatic { };
|
||||
struct VecTraitsTagSizeStatic
|
||||
{
|
||||
};
|
||||
|
||||
/// A tag for vectors where the number of components are not determined until
|
||||
/// run time.
|
||||
///
|
||||
struct VecTraitsTagSizeVariable { };
|
||||
struct VecTraitsTagSizeVariable
|
||||
{
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <vtkm::IdComponent numComponents>
|
||||
struct VecTraitsMultipleComponentChooser
|
||||
@ -85,8 +95,8 @@ struct VecTraits
|
||||
/// This tag can be useful for creating specialized functions when a vector
|
||||
/// is really just a scalar.
|
||||
///
|
||||
typedef typename internal::VecTraitsMultipleComponentChooser<
|
||||
NUM_COMPONENTS>::Type HasMultipleComponents;
|
||||
typedef typename internal::VecTraitsMultipleComponentChooser<NUM_COMPONENTS>::Type
|
||||
HasMultipleComponents;
|
||||
|
||||
/// \brief A tag specifying whether the size of this vector is known at compile time.
|
||||
///
|
||||
@ -99,24 +109,19 @@ struct VecTraits
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT static const ComponentType& GetComponent(
|
||||
const typename std::remove_const<VecType>::type &vector,
|
||||
vtkm::IdComponent component);
|
||||
const typename std::remove_const<VecType>::type& vector, vtkm::IdComponent component);
|
||||
VTKM_EXEC_CONT static ComponentType& GetComponent(
|
||||
typename std::remove_const<VecType>::type &vector,
|
||||
vtkm::IdComponent component);
|
||||
typename std::remove_const<VecType>::type& vector, vtkm::IdComponent component);
|
||||
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent component,
|
||||
VTKM_EXEC_CONT static void SetComponent(VecType& vector, vtkm::IdComponent component,
|
||||
ComponentType value);
|
||||
|
||||
/// Copies the components in the given vector into a given Vec object.
|
||||
///
|
||||
template <vktm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void
|
||||
CopyInto(const VecType &src, vtkm::Vec<ComponentType,destSize> &dest);
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest);
|
||||
};
|
||||
#else // VTKM_DOXYGEN_ONLY
|
||||
;
|
||||
@ -127,7 +132,8 @@ struct VecTraits
|
||||
//
|
||||
template <typename T>
|
||||
struct VecTraits<const T> : VecTraits<T>
|
||||
{ };
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, vtkm::IdComponent Size>
|
||||
struct VecTraits<vtkm::Vec<T, Size>>
|
||||
@ -145,16 +151,14 @@ struct VecTraits<vtkm::Vec<T,Size> >
|
||||
/// Number of components in the given vector.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType &) {
|
||||
return NUM_COMPONENTS;
|
||||
}
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType&) { return NUM_COMPONENTS; }
|
||||
|
||||
/// A tag specifying whether this vector has multiple components (i.e. is a
|
||||
/// "real" vector). This tag can be useful for creating specialized functions
|
||||
/// when a vector is really just a scalar.
|
||||
///
|
||||
typedef typename internal::VecTraitsMultipleComponentChooser<
|
||||
NUM_COMPONENTS>::Type HasMultipleComponents;
|
||||
typedef typename internal::VecTraitsMultipleComponentChooser<NUM_COMPONENTS>::Type
|
||||
HasMultipleComponents;
|
||||
|
||||
/// A tag specifying whether the size of this vector is known at compile
|
||||
/// time. If set to \c VecTraitsTagSizeStatic, then \c NUM_COMPONENTS is set.
|
||||
@ -167,30 +171,28 @@ struct VecTraits<vtkm::Vec<T,Size> >
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
static const ComponentType &GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent component)
|
||||
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType &GetComponent(VecType &vector, vtkm::IdComponent component) {
|
||||
static ComponentType& GetComponent(VecType& vector, vtkm::IdComponent component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent component,
|
||||
ComponentType value) {
|
||||
VTKM_EXEC_CONT static void SetComponent(VecType& vector, vtkm::IdComponent component,
|
||||
ComponentType value)
|
||||
{
|
||||
vector[component] = value;
|
||||
}
|
||||
|
||||
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
||||
///
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void
|
||||
CopyInto(const VecType &src, vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
@ -234,31 +236,28 @@ struct VecTraits<vtkm::VecC<T> >
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
static const ComponentType &GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent component)
|
||||
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType &GetComponent(VecType &vector, vtkm::IdComponent component) {
|
||||
static ComponentType& GetComponent(VecType& vector, vtkm::IdComponent component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent component,
|
||||
ComponentType value) {
|
||||
static void SetComponent(VecType& vector, vtkm::IdComponent component, ComponentType value)
|
||||
{
|
||||
vector[component] = value;
|
||||
}
|
||||
|
||||
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
||||
///
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void
|
||||
CopyInto(const VecType &src, vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
@ -302,8 +301,7 @@ struct VecTraits<vtkm::VecCConst<T> >
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
static const ComponentType &GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent component)
|
||||
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
@ -311,59 +309,51 @@ struct VecTraits<vtkm::VecCConst<T> >
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT
|
||||
static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent component,
|
||||
ComponentType value) {
|
||||
static void SetComponent(VecType& vector, vtkm::IdComponent component, ComponentType value)
|
||||
{
|
||||
vector[component] = value;
|
||||
}
|
||||
|
||||
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
||||
///
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void
|
||||
CopyInto(const VecType &src, vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
/// Used for overriding VecTraits for basic scalar types.
|
||||
///
|
||||
template <typename ScalarType>
|
||||
struct VecTraitsBasic {
|
||||
struct VecTraitsBasic
|
||||
{
|
||||
typedef ScalarType ComponentType;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = 1;
|
||||
typedef VecTraitsTagSingleComponent HasMultipleComponents;
|
||||
typedef vtkm::VecTraitsTagSizeStatic IsSizeStatic;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const ScalarType &) {
|
||||
return 1;
|
||||
}
|
||||
static vtkm::IdComponent GetNumberOfComponents(const ScalarType&) { return 1; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static const ComponentType &GetComponent(
|
||||
const ScalarType &vector,
|
||||
vtkm::IdComponent) {
|
||||
static const ComponentType& GetComponent(const ScalarType& vector, vtkm::IdComponent)
|
||||
{
|
||||
return vector;
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType &GetComponent(ScalarType &vector, vtkm::IdComponent) {
|
||||
return vector;
|
||||
}
|
||||
static ComponentType& GetComponent(ScalarType& vector, vtkm::IdComponent) { return vector; }
|
||||
|
||||
VTKM_EXEC_CONT static void SetComponent(ScalarType &vector,
|
||||
vtkm::IdComponent,
|
||||
ComponentType value) {
|
||||
VTKM_EXEC_CONT static void SetComponent(ScalarType& vector, vtkm::IdComponent,
|
||||
ComponentType value)
|
||||
{
|
||||
vector = value;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void CopyInto(const ScalarType &src,
|
||||
vtkm::Vec<ScalarType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const ScalarType& src, vtkm::Vec<ScalarType, destSize>& dest)
|
||||
{
|
||||
dest[0] = src;
|
||||
}
|
||||
@ -378,18 +368,19 @@ struct VecTraitsBasic {
|
||||
/// component. Thus we treat a pair as a "scalar" unit.
|
||||
///
|
||||
template <typename T, typename U>
|
||||
struct VecTraits<vtkm::Pair<T,U> >
|
||||
: public vtkm::internal::VecTraitsBasic<vtkm::Pair<T, U> >
|
||||
struct VecTraits<vtkm::Pair<T, U>> : public vtkm::internal::VecTraitsBasic<vtkm::Pair<T, U>>
|
||||
{
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
#define VTKM_BASIC_TYPE_VECTOR(type) \
|
||||
namespace vtkm { \
|
||||
namespace vtkm \
|
||||
{ \
|
||||
template <> \
|
||||
struct VecTraits<type> \
|
||||
: public vtkm::internal::VecTraitsBasic<type> { }; \
|
||||
struct VecTraits<type> : public vtkm::internal::VecTraitsBasic<type> \
|
||||
{ \
|
||||
}; \
|
||||
}
|
||||
|
||||
/// Allows you to treat basic types as if they were vectors.
|
||||
@ -409,7 +400,6 @@ VTKM_BASIC_TYPE_VECTOR(unsigned long)
|
||||
VTKM_BASIC_TYPE_VECTOR(long long)
|
||||
VTKM_BASIC_TYPE_VECTOR(unsigned long long)
|
||||
|
||||
|
||||
//#undef VTKM_BASIC_TYPE_VECTOR
|
||||
|
||||
#endif //vtk_m_VecTraits_h
|
||||
|
@ -26,7 +26,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
/// \brief A short variable-length array with maximum length.
|
||||
///
|
||||
@ -42,11 +43,13 @@ public:
|
||||
typedef T ComponentType;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
VecVariable() : NumComponents(0) { }
|
||||
VecVariable()
|
||||
: NumComponents(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent SrcSize>
|
||||
VTKM_EXEC_CONT
|
||||
VecVariable(const vtkm::VecVariable<ComponentType,SrcSize> &src)
|
||||
VTKM_EXEC_CONT VecVariable(const vtkm::VecVariable<ComponentType, SrcSize>& src)
|
||||
: NumComponents(src.GetNumberOfComponents())
|
||||
{
|
||||
VTKM_ASSERT(this->NumComponents <= MaxSize);
|
||||
@ -57,8 +60,7 @@ public:
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent SrcSize>
|
||||
VTKM_EXEC_CONT
|
||||
VecVariable(const vtkm::Vec<ComponentType,SrcSize> &src)
|
||||
VTKM_EXEC_CONT VecVariable(const vtkm::Vec<ComponentType, SrcSize>& src)
|
||||
: NumComponents(SrcSize)
|
||||
{
|
||||
VTKM_ASSERT(this->NumComponents <= MaxSize);
|
||||
@ -69,13 +71,10 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::IdComponent GetNumberOfComponents() const {
|
||||
return this->NumComponents;
|
||||
}
|
||||
vtkm::IdComponent GetNumberOfComponents() const { return this->NumComponents; }
|
||||
|
||||
template <vtkm::IdComponent DestSize>
|
||||
VTKM_EXEC_CONT
|
||||
void CopyInto(vtkm::Vec<ComponentType,DestSize> &dest) const
|
||||
VTKM_EXEC_CONT void CopyInto(vtkm::Vec<ComponentType, DestSize>& dest) const
|
||||
{
|
||||
vtkm::IdComponent numComponents = vtkm::Min(DestSize, this->NumComponents);
|
||||
for (vtkm::IdComponent index = 0; index < numComponents; index++)
|
||||
@ -85,16 +84,10 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const ComponentType &operator[](vtkm::IdComponent index) const
|
||||
{
|
||||
return this->Data[index];
|
||||
}
|
||||
const ComponentType& operator[](vtkm::IdComponent index) const { return this->Data[index]; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ComponentType &operator[](vtkm::IdComponent index)
|
||||
{
|
||||
return this->Data[index];
|
||||
}
|
||||
ComponentType& operator[](vtkm::IdComponent index) { return this->Data[index]; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void Append(ComponentType value)
|
||||
@ -132,35 +125,31 @@ struct VecTraits<vtkm::VecVariable<T,MaxSize> >
|
||||
typedef vtkm::VecTraitsTagSizeVariable IsSizeStatic;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType &vector) {
|
||||
static vtkm::IdComponent GetNumberOfComponents(const VecType& vector)
|
||||
{
|
||||
return vector.GetNumberOfComponents();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static const ComponentType &GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent componentIndex)
|
||||
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent componentIndex)
|
||||
{
|
||||
return vector[componentIndex];
|
||||
}
|
||||
VTKM_EXEC_CONT
|
||||
static ComponentType &GetComponent(VecType &vector,
|
||||
vtkm::IdComponent componentIndex)
|
||||
static ComponentType& GetComponent(VecType& vector, vtkm::IdComponent componentIndex)
|
||||
{
|
||||
return vector[componentIndex];
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent componentIndex,
|
||||
static void SetComponent(VecType& vector, vtkm::IdComponent componentIndex,
|
||||
const ComponentType& value)
|
||||
{
|
||||
vector[componentIndex] = value;
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent destSize>
|
||||
VTKM_EXEC_CONT
|
||||
static void CopyInto(const VecType &src,
|
||||
vtkm::Vec<ComponentType,destSize> &dest)
|
||||
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
||||
{
|
||||
src.CopyInto(dest);
|
||||
}
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/// \brief Returns the linear interpolation of two values based on weight
|
||||
@ -41,24 +41,20 @@ namespace vtkm {
|
||||
/// extrapolates. If w=0 => v0 is returned if w=1 => v1 is returned.
|
||||
///
|
||||
template <typename ValueType, typename WeightType>
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Lerp(const ValueType &value0,
|
||||
const ValueType &value1,
|
||||
VTKM_EXEC_CONT ValueType Lerp(const ValueType& value0, const ValueType& value1,
|
||||
const WeightType& weight)
|
||||
{
|
||||
return static_cast<ValueType>((WeightType(1) - weight) * value0 + weight * value1);
|
||||
}
|
||||
template <typename ValueType, vtkm::IdComponent N, typename WeightType>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<ValueType,N> Lerp(const vtkm::Vec<ValueType,N> &value0,
|
||||
VTKM_EXEC_CONT vtkm::Vec<ValueType, N> Lerp(const vtkm::Vec<ValueType, N>& value0,
|
||||
const vtkm::Vec<ValueType, N>& value1,
|
||||
const WeightType& weight)
|
||||
{
|
||||
return (WeightType(1) - weight) * value0 + weight * value1;
|
||||
}
|
||||
template <typename ValueType, vtkm::IdComponent N>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<ValueType,N> Lerp(const vtkm::Vec<ValueType,N> &value0,
|
||||
VTKM_EXEC_CONT vtkm::Vec<ValueType, N> Lerp(const vtkm::Vec<ValueType, N>& value0,
|
||||
const vtkm::Vec<ValueType, N>& value1,
|
||||
const vtkm::Vec<ValueType, N>& weight)
|
||||
{
|
||||
@ -74,27 +70,24 @@ vtkm::Vec<ValueType,N> Lerp(const vtkm::Vec<ValueType,N> &value0,
|
||||
/// when possible.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename vtkm::VecTraits<T>::ComponentType
|
||||
MagnitudeSquared(const T &x)
|
||||
VTKM_EXEC_CONT typename vtkm::VecTraits<T>::ComponentType MagnitudeSquared(const T& x)
|
||||
{
|
||||
return vtkm::dot(x, x);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename detail::FloatingPointReturnType<T>::Type
|
||||
MagnitudeTemplate(T x, vtkm::TypeTraitsScalarTag)
|
||||
VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
|
||||
T x, vtkm::TypeTraitsScalarTag)
|
||||
{
|
||||
return static_cast<typename detail::FloatingPointReturnType<T>::Type>(vtkm::Abs(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename detail::FloatingPointReturnType<T>::Type
|
||||
MagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
|
||||
VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
|
||||
const T& x, vtkm::TypeTraitsVectorTag)
|
||||
{
|
||||
return vtkm::Sqrt(vtkm::MagnitudeSquared(x));
|
||||
}
|
||||
@ -110,28 +103,24 @@ MagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
|
||||
/// actually plan to divide by the magnitude.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename detail::FloatingPointReturnType<T>::Type
|
||||
Magnitude(const T &x)
|
||||
VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Magnitude(const T& x)
|
||||
{
|
||||
return detail::MagnitudeTemplate(
|
||||
x, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||
return detail::MagnitudeTemplate(x, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename detail::FloatingPointReturnType<T>::Type
|
||||
RMagnitudeTemplate(T x, vtkm::TypeTraitsScalarTag)
|
||||
VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
|
||||
T x, vtkm::TypeTraitsScalarTag)
|
||||
{
|
||||
return T(1) / vtkm::Abs(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename detail::FloatingPointReturnType<T>::Type
|
||||
RMagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
|
||||
VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
|
||||
const T& x, vtkm::TypeTraitsVectorTag)
|
||||
{
|
||||
return vtkm::RSqrt(vtkm::MagnitudeSquared(x));
|
||||
}
|
||||
@ -143,26 +132,22 @@ RMagnitudeTemplate(const T &x, vtkm::TypeTraitsVectorTag)
|
||||
/// as fast as MagnitudeSquared.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
typename detail::FloatingPointReturnType<T>::Type
|
||||
RMagnitude(const T &x)
|
||||
VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitude(const T& x)
|
||||
{
|
||||
return detail::RMagnitudeTemplate(
|
||||
x, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||
return detail::RMagnitudeTemplate(x, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
T NormalTemplate(T x, vtkm::TypeTraitsScalarTag)
|
||||
VTKM_EXEC_CONT T NormalTemplate(T x, vtkm::TypeTraitsScalarTag)
|
||||
{
|
||||
return vtkm::CopySign(T(1), x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
T NormalTemplate(const T &x, vtkm::TypeTraitsVectorTag)
|
||||
VTKM_EXEC_CONT T NormalTemplate(const T& x, vtkm::TypeTraitsVectorTag)
|
||||
{
|
||||
return vtkm::RMagnitude(x) * x;
|
||||
}
|
||||
@ -173,11 +158,9 @@ T NormalTemplate(const T &x, vtkm::TypeTraitsVectorTag)
|
||||
/// The resulting vector points in the same direction but has unit length.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
T Normal(const T &x)
|
||||
VTKM_EXEC_CONT T Normal(const T& x)
|
||||
{
|
||||
return detail::NormalTemplate(
|
||||
x, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||
return detail::NormalTemplate(x, typename vtkm::TypeTraits<T>::DimensionalityTag());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -186,8 +169,7 @@ T Normal(const T &x)
|
||||
/// The given vector is scaled to be unit length.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
void Normalize(T &x)
|
||||
VTKM_EXEC_CONT void Normalize(T& x)
|
||||
{
|
||||
x = vtkm::Normal(x);
|
||||
}
|
||||
@ -196,13 +178,11 @@ void Normalize(T &x)
|
||||
/// \brief Find the cross product of two vectors.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>
|
||||
Cross(const vtkm::Vec<T,3> &x, const vtkm::Vec<T,3> &y)
|
||||
VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, 3> Cross(
|
||||
const vtkm::Vec<T, 3>& x, const vtkm::Vec<T, 3>& y)
|
||||
{
|
||||
return vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>(x[1]*y[2] - x[2]*y[1],
|
||||
x[2]*y[0] - x[0]*y[2],
|
||||
x[0]*y[1] - x[1]*y[0]);
|
||||
return vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, 3>(
|
||||
x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0]);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -213,16 +193,12 @@ Cross(const vtkm::Vec<T,3> &x, const vtkm::Vec<T,3> &y)
|
||||
/// to that triangle/plane.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type,3>
|
||||
TriangleNormal(const vtkm::Vec<T,3> &a,
|
||||
const vtkm::Vec<T,3> &b,
|
||||
const vtkm::Vec<T,3> &c)
|
||||
VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, 3> TriangleNormal(
|
||||
const vtkm::Vec<T, 3>& a, const vtkm::Vec<T, 3>& b, const vtkm::Vec<T, 3>& c)
|
||||
{
|
||||
return vtkm::Cross(b - a, c - a);
|
||||
}
|
||||
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_VectorAnalysis_h
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <vtkm/cont/internal/DeviceAdapterError.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
@ -42,13 +41,16 @@
|
||||
|
||||
#include <vtkm/internal/Windows.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace benchmarking {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace benchmarking
|
||||
{
|
||||
|
||||
#define ARRAY_SIZE (1 << 21)
|
||||
const static std::string DIVIDER(40, '-');
|
||||
|
||||
enum BenchmarkName {
|
||||
enum BenchmarkName
|
||||
{
|
||||
COPY = 1,
|
||||
COPY_IF = 1 << 1,
|
||||
LOWER_BOUNDS = 1 << 2,
|
||||
@ -60,21 +62,24 @@ enum BenchmarkName {
|
||||
SORT_BY_KEY = 1 << 8,
|
||||
UNIQUE = 1 << 9,
|
||||
UPPER_BOUNDS = 1 << 10,
|
||||
ALL = COPY | COPY_IF | LOWER_BOUNDS | REDUCE | REDUCE_BY_KEY | SCAN_INCLUSIVE
|
||||
| SCAN_EXCLUSIVE | SORT | SORT_BY_KEY | UNIQUE | UPPER_BOUNDS
|
||||
ALL = COPY | COPY_IF | LOWER_BOUNDS | REDUCE | REDUCE_BY_KEY | SCAN_INCLUSIVE | SCAN_EXCLUSIVE |
|
||||
SORT |
|
||||
SORT_BY_KEY |
|
||||
UNIQUE |
|
||||
UPPER_BOUNDS
|
||||
};
|
||||
|
||||
/// This class runs a series of micro-benchmarks to measure
|
||||
/// performance of the parallel primitives provided by each
|
||||
/// device adapter
|
||||
template <class DeviceAdapterTag>
|
||||
class BenchmarkDeviceAdapter {
|
||||
class BenchmarkDeviceAdapter
|
||||
{
|
||||
typedef vtkm::cont::StorageTagBasic StorageTag;
|
||||
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Id, StorageTag> IdArrayHandle;
|
||||
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>
|
||||
Algorithm;
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag> Algorithm;
|
||||
|
||||
typedef vtkm::cont::Timer<DeviceAdapterTag> Timer;
|
||||
|
||||
@ -82,75 +87,86 @@ public:
|
||||
// Various kernels used by the different benchmarks to accelerate
|
||||
// initialization of data
|
||||
template <typename Value>
|
||||
struct FillTestValueKernel : vtkm::exec::FunctorBase {
|
||||
struct FillTestValueKernel : vtkm::exec::FunctorBase
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>
|
||||
::Portal PortalType;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>::Portal PortalType;
|
||||
|
||||
PortalType Output;
|
||||
|
||||
VTKM_CONT
|
||||
FillTestValueKernel(PortalType out) : Output(out){}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const {
|
||||
Output.Set(i, TestValue(i, Value()));
|
||||
FillTestValueKernel(PortalType out)
|
||||
: Output(out)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const { Output.Set(i, TestValue(i, Value())); }
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct FillScaledTestValueKernel : vtkm::exec::FunctorBase {
|
||||
struct FillScaledTestValueKernel : vtkm::exec::FunctorBase
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>
|
||||
::Portal PortalType;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>::Portal PortalType;
|
||||
|
||||
PortalType Output;
|
||||
const vtkm::Id IdScale;
|
||||
|
||||
VTKM_CONT
|
||||
FillScaledTestValueKernel(vtkm::Id id_scale, PortalType out) : Output(out), IdScale(id_scale) {}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const {
|
||||
Output.Set(i, TestValue(i * IdScale, Value()));
|
||||
FillScaledTestValueKernel(vtkm::Id id_scale, PortalType out)
|
||||
: Output(out)
|
||||
, IdScale(id_scale)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const { Output.Set(i, TestValue(i * IdScale, Value())); }
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct FillModuloTestValueKernel : vtkm::exec::FunctorBase {
|
||||
struct FillModuloTestValueKernel : vtkm::exec::FunctorBase
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>
|
||||
::Portal PortalType;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>::Portal PortalType;
|
||||
|
||||
PortalType Output;
|
||||
const vtkm::Id Modulus;
|
||||
|
||||
VTKM_CONT
|
||||
FillModuloTestValueKernel(vtkm::Id modulus, PortalType out) : Output(out), Modulus(modulus) {}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const {
|
||||
Output.Set(i, TestValue(i % Modulus, Value()));
|
||||
FillModuloTestValueKernel(vtkm::Id modulus, PortalType out)
|
||||
: Output(out)
|
||||
, Modulus(modulus)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const { Output.Set(i, TestValue(i % Modulus, Value())); }
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct FillBinaryTestValueKernel : vtkm::exec::FunctorBase {
|
||||
struct FillBinaryTestValueKernel : vtkm::exec::FunctorBase
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>
|
||||
::Portal PortalType;
|
||||
typedef typename ValueArrayHandle::template ExecutionTypes<DeviceAdapterTag>::Portal PortalType;
|
||||
|
||||
PortalType Output;
|
||||
const vtkm::Id Modulus;
|
||||
|
||||
VTKM_CONT
|
||||
FillBinaryTestValueKernel(vtkm::Id modulus, PortalType out) : Output(out), Modulus(modulus) {}
|
||||
FillBinaryTestValueKernel(vtkm::Id modulus, PortalType out)
|
||||
: Output(out)
|
||||
, Modulus(modulus)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const {
|
||||
VTKM_EXEC void operator()(vtkm::Id i) const
|
||||
{
|
||||
Output.Set(i, i % Modulus == 0 ? TestValue(vtkm::Id(1), Value()) : Value());
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
template <typename Value>
|
||||
struct BenchCopy {
|
||||
struct BenchCopy
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
ValueArrayHandle ValueHandle_src;
|
||||
@ -158,14 +174,17 @@ private:
|
||||
std::mt19937 Rng;
|
||||
|
||||
VTKM_CONT
|
||||
BenchCopy(){
|
||||
BenchCopy()
|
||||
{
|
||||
ValueHandle_src.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag());
|
||||
ValueHandle_dst.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
for (vtkm::Id i = 0; i < ValueHandle_src.GetNumberOfValues(); ++i){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
for (vtkm::Id i = 0; i < ValueHandle_src.GetNumberOfValues(); ++i)
|
||||
{
|
||||
ValueHandle_src.GetPortalControl().Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
|
||||
}
|
||||
Timer timer;
|
||||
@ -174,7 +193,8 @@ private:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Copy " << ARRAY_SIZE << " values";
|
||||
return description.str();
|
||||
@ -183,7 +203,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(Copy, BenchCopy);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchCopyIf {
|
||||
struct BenchCopyIf
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
const vtkm::Id N_VALID;
|
||||
@ -191,28 +212,32 @@ private:
|
||||
IdArrayHandle StencilHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchCopyIf(vtkm::Id percent_valid) : N_VALID((ARRAY_SIZE * percent_valid) / 100)
|
||||
BenchCopyIf(vtkm::Id percent_valid)
|
||||
: N_VALID((ARRAY_SIZE * percent_valid) / 100)
|
||||
{
|
||||
vtkm::Id modulo = ARRAY_SIZE / N_VALID;
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillBinaryTestValueKernel<vtkm::Id>(modulo,
|
||||
StencilHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillBinaryTestValueKernel<vtkm::Id>(
|
||||
modulo, StencilHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()() {
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::CopyIf(ValueHandle, StencilHandle, OutHandle);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "CopyIf on " << ARRAY_SIZE << " "
|
||||
<< " values with " << OutHandle.GetNumberOfValues()
|
||||
<< " valid values";
|
||||
<< " values with " << OutHandle.GetNumberOfValues() << " valid values";
|
||||
return description.str();
|
||||
}
|
||||
};
|
||||
@ -224,7 +249,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(CopyIf30, BenchCopyIf, 30);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchLowerBounds {
|
||||
struct BenchLowerBounds
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
const vtkm::Id N_VALS;
|
||||
@ -232,26 +258,30 @@ private:
|
||||
IdArrayHandle OutHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchLowerBounds(vtkm::Id value_percent) : N_VALS((ARRAY_SIZE * value_percent) / 100)
|
||||
BenchLowerBounds(vtkm::Id value_percent)
|
||||
: N_VALS((ARRAY_SIZE * value_percent) / 100)
|
||||
{
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
InputHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillScaledTestValueKernel<Value>(2,
|
||||
ValueHandle.PrepareForOutput(N_VALS, DeviceAdapterTag())), N_VALS);
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(InputHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillScaledTestValueKernel<Value>(
|
||||
2, ValueHandle.PrepareForOutput(N_VALS, DeviceAdapterTag())),
|
||||
N_VALS);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::LowerBounds(InputHandle, ValueHandle, OutHandle);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "LowerBounds on " << ARRAY_SIZE << " input and "
|
||||
<< N_VALS << " values";
|
||||
description << "LowerBounds on " << ARRAY_SIZE << " input and " << N_VALS << " values";
|
||||
return description.str();
|
||||
}
|
||||
};
|
||||
@ -263,26 +293,31 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(LowerBounds30, BenchLowerBounds, 30);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchReduce {
|
||||
struct BenchReduce
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
ValueArrayHandle InputHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchReduce(){
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
InputHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
BenchReduce()
|
||||
{
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(InputHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::Reduce(InputHandle, Value());
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Reduce on " << ARRAY_SIZE << " values";
|
||||
return description.str();
|
||||
@ -291,7 +326,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(Reduce, BenchReduce);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchReduceByKey {
|
||||
struct BenchReduceByKey
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
const vtkm::Id N_KEYS;
|
||||
@ -299,28 +335,32 @@ private:
|
||||
IdArrayHandle KeyHandle, KeysOut;
|
||||
|
||||
VTKM_CONT
|
||||
BenchReduceByKey(vtkm::Id key_percent) : N_KEYS((ARRAY_SIZE * key_percent) / 100)
|
||||
BenchReduceByKey(vtkm::Id key_percent)
|
||||
: N_KEYS((ARRAY_SIZE * key_percent) / 100)
|
||||
{
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillModuloTestValueKernel<vtkm::Id>(N_KEYS,
|
||||
KeyHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillModuloTestValueKernel<vtkm::Id>(
|
||||
N_KEYS, KeyHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Algorithm::SortByKey(KeyHandle, ValueHandle);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::ReduceByKey(KeyHandle, ValueHandle, KeysOut, ValuesOut,
|
||||
vtkm::Add());
|
||||
Algorithm::ReduceByKey(KeyHandle, ValueHandle, KeysOut, ValuesOut, vtkm::Add());
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "ReduceByKey on " << ARRAY_SIZE
|
||||
<< " values with " << N_KEYS << " distinct vtkm::Id keys";
|
||||
description << "ReduceByKey on " << ARRAY_SIZE << " values with " << N_KEYS
|
||||
<< " distinct vtkm::Id keys";
|
||||
return description.str();
|
||||
}
|
||||
};
|
||||
@ -332,25 +372,30 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(ReduceByKey30, BenchReduceByKey, 30);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchScanInclusive {
|
||||
struct BenchScanInclusive
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
ValueArrayHandle ValueHandle, OutHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchScanInclusive(){
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
BenchScanInclusive()
|
||||
{
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::ScanInclusive(ValueHandle, OutHandle);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "ScanInclusive on " << ARRAY_SIZE << " values";
|
||||
return description.str();
|
||||
@ -359,26 +404,31 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(ScanInclusive, BenchScanInclusive);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchScanExclusive {
|
||||
struct BenchScanExclusive
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
ValueArrayHandle ValueHandle, OutHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchScanExclusive(){
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
BenchScanExclusive()
|
||||
{
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::ScanExclusive(ValueHandle, OutHandle);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "ScanExclusive on " << ARRAY_SIZE << " values";
|
||||
return description.str();
|
||||
@ -387,20 +437,21 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(ScanExclusive, BenchScanExclusive);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchSort {
|
||||
struct BenchSort
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
ValueArrayHandle ValueHandle;
|
||||
std::mt19937 Rng;
|
||||
|
||||
VTKM_CONT
|
||||
BenchSort(){
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag());
|
||||
}
|
||||
BenchSort() { ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag()); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
for (vtkm::Id i = 0; i < ValueHandle.GetNumberOfValues(); ++i){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
for (vtkm::Id i = 0; i < ValueHandle.GetNumberOfValues(); ++i)
|
||||
{
|
||||
ValueHandle.GetPortalControl().Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
|
||||
}
|
||||
Timer timer;
|
||||
@ -409,7 +460,8 @@ private:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Sort on " << ARRAY_SIZE << " random values";
|
||||
return description.str();
|
||||
@ -418,7 +470,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(Sort, BenchSort);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchSortByKey {
|
||||
struct BenchSortByKey
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
std::mt19937 Rng;
|
||||
@ -427,27 +480,33 @@ private:
|
||||
IdArrayHandle KeyHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchSortByKey(vtkm::Id percent_key) : N_KEYS((ARRAY_SIZE * percent_key) / 100){
|
||||
BenchSortByKey(vtkm::Id percent_key)
|
||||
: N_KEYS((ARRAY_SIZE * percent_key) / 100)
|
||||
{
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
for (vtkm::Id i = 0; i < ValueHandle.GetNumberOfValues(); ++i){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
for (vtkm::Id i = 0; i < ValueHandle.GetNumberOfValues(); ++i)
|
||||
{
|
||||
ValueHandle.GetPortalControl().Set(vtkm::Id(i), TestValue(vtkm::Id(Rng()), Value()));
|
||||
}
|
||||
Algorithm::Schedule(FillModuloTestValueKernel<vtkm::Id>(N_KEYS,
|
||||
KeyHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillModuloTestValueKernel<vtkm::Id>(
|
||||
N_KEYS, KeyHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Timer timer;
|
||||
Algorithm::SortByKey(ValueHandle, KeyHandle);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "SortByKey on " << ARRAY_SIZE
|
||||
<< " random values with " << N_KEYS << " different vtkm::Id keys";
|
||||
description << "SortByKey on " << ARRAY_SIZE << " random values with " << N_KEYS
|
||||
<< " different vtkm::Id keys";
|
||||
return description.str();
|
||||
}
|
||||
};
|
||||
@ -459,20 +518,25 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(SortByKey30, BenchSortByKey, 30);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchUnique {
|
||||
struct BenchUnique
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
const vtkm::Id N_VALID;
|
||||
ValueArrayHandle ValueHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchUnique(vtkm::Id percent_valid) : N_VALID((ARRAY_SIZE * percent_valid) / 100)
|
||||
{}
|
||||
BenchUnique(vtkm::Id percent_valid)
|
||||
: N_VALID((ARRAY_SIZE * percent_valid) / 100)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
Algorithm::Schedule(FillModuloTestValueKernel<Value>(N_VALID,
|
||||
ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Algorithm::Schedule(FillModuloTestValueKernel<Value>(
|
||||
N_VALID, ValueHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Algorithm::Sort(ValueHandle);
|
||||
Timer timer;
|
||||
Algorithm::Unique(ValueHandle);
|
||||
@ -480,7 +544,8 @@ private:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Unique on " << ARRAY_SIZE << " values with "
|
||||
<< ValueHandle.GetNumberOfValues() << " valid values";
|
||||
@ -495,7 +560,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(Unique30, BenchUnique, 30);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchUpperBounds {
|
||||
struct BenchUpperBounds
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<Value, StorageTag> ValueArrayHandle;
|
||||
|
||||
const vtkm::Id N_VALS;
|
||||
@ -503,26 +569,30 @@ private:
|
||||
IdArrayHandle OutHandle;
|
||||
|
||||
VTKM_CONT
|
||||
BenchUpperBounds(vtkm::Id percent_vals) : N_VALS((ARRAY_SIZE * percent_vals) / 100)
|
||||
BenchUpperBounds(vtkm::Id percent_vals)
|
||||
: N_VALS((ARRAY_SIZE * percent_vals) / 100)
|
||||
{
|
||||
Algorithm::Schedule(FillTestValueKernel<Value>(
|
||||
InputHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())), ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillScaledTestValueKernel<Value>(2,
|
||||
ValueHandle.PrepareForOutput(N_VALS, DeviceAdapterTag())), N_VALS);
|
||||
Algorithm::Schedule(
|
||||
FillTestValueKernel<Value>(InputHandle.PrepareForOutput(ARRAY_SIZE, DeviceAdapterTag())),
|
||||
ARRAY_SIZE);
|
||||
Algorithm::Schedule(FillScaledTestValueKernel<Value>(
|
||||
2, ValueHandle.PrepareForOutput(N_VALS, DeviceAdapterTag())),
|
||||
N_VALS);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()(){
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
Timer timer;
|
||||
Algorithm::UpperBounds(InputHandle, ValueHandle, OutHandle);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "UpperBounds on " << ARRAY_SIZE << " input and "
|
||||
<< N_VALS << " values";
|
||||
description << "UpperBounds on " << ARRAY_SIZE << " input and " << N_VALS << " values";
|
||||
return description.str();
|
||||
}
|
||||
};
|
||||
@ -534,22 +604,25 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(UpperBounds30, BenchUpperBounds, 30);
|
||||
|
||||
public:
|
||||
struct ValueTypes
|
||||
: vtkm::ListTagBase<vtkm::UInt8, vtkm::UInt32, vtkm::Int32, vtkm::Int64,
|
||||
vtkm::Vec<vtkm::Int32, 2>, vtkm::Vec<vtkm::UInt8, 4>, vtkm::Float32,
|
||||
vtkm::Float64, vtkm::Vec<vtkm::Float64, 3>, vtkm::Vec<vtkm::Float32, 4>>
|
||||
{
|
||||
};
|
||||
|
||||
struct ValueTypes : vtkm::ListTagBase<vtkm::UInt8, vtkm::UInt32, vtkm::Int32,
|
||||
vtkm::Int64, vtkm::Vec<vtkm::Int32, 2>,
|
||||
vtkm::Vec<vtkm::UInt8, 4>, vtkm::Float32,
|
||||
vtkm::Float64, vtkm::Vec<vtkm::Float64, 3>,
|
||||
vtkm::Vec<vtkm::Float32, 4> >{};
|
||||
|
||||
static VTKM_CONT int Run(int benchmarks){
|
||||
static VTKM_CONT int Run(int benchmarks)
|
||||
{
|
||||
std::cout << DIVIDER << "\nRunning DeviceAdapter benchmarks\n";
|
||||
|
||||
if (benchmarks & COPY) {
|
||||
if (benchmarks & COPY)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Copy\n";
|
||||
VTKM_RUN_BENCHMARK(Copy, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & COPY_IF){
|
||||
if (benchmarks & COPY_IF)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking CopyIf\n";
|
||||
VTKM_RUN_BENCHMARK(CopyIf5, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(CopyIf10, ValueTypes());
|
||||
@ -559,7 +632,8 @@ public:
|
||||
VTKM_RUN_BENCHMARK(CopyIf30, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & LOWER_BOUNDS){
|
||||
if (benchmarks & LOWER_BOUNDS)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking LowerBounds\n";
|
||||
VTKM_RUN_BENCHMARK(LowerBounds5, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(LowerBounds10, ValueTypes());
|
||||
@ -569,12 +643,14 @@ public:
|
||||
VTKM_RUN_BENCHMARK(LowerBounds30, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & REDUCE){
|
||||
if (benchmarks & REDUCE)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking Reduce\n";
|
||||
VTKM_RUN_BENCHMARK(Reduce, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & REDUCE_BY_KEY){
|
||||
if (benchmarks & REDUCE_BY_KEY)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking ReduceByKey\n";
|
||||
VTKM_RUN_BENCHMARK(ReduceByKey5, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(ReduceByKey10, ValueTypes());
|
||||
@ -584,22 +660,26 @@ public:
|
||||
VTKM_RUN_BENCHMARK(ReduceByKey30, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & SCAN_INCLUSIVE){
|
||||
if (benchmarks & SCAN_INCLUSIVE)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking ScanInclusive\n";
|
||||
VTKM_RUN_BENCHMARK(ScanInclusive, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & SCAN_EXCLUSIVE){
|
||||
if (benchmarks & SCAN_EXCLUSIVE)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking ScanExclusive\n";
|
||||
VTKM_RUN_BENCHMARK(ScanExclusive, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & SORT){
|
||||
if (benchmarks & SORT)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking Sort\n";
|
||||
VTKM_RUN_BENCHMARK(Sort, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & SORT_BY_KEY){
|
||||
if (benchmarks & SORT_BY_KEY)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking SortByKey\n";
|
||||
VTKM_RUN_BENCHMARK(SortByKey5, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(SortByKey10, ValueTypes());
|
||||
@ -609,7 +689,8 @@ public:
|
||||
VTKM_RUN_BENCHMARK(SortByKey30, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & UNIQUE){
|
||||
if (benchmarks & UNIQUE)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking Unique\n";
|
||||
VTKM_RUN_BENCHMARK(Unique5, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(Unique10, ValueTypes());
|
||||
@ -619,7 +700,8 @@ public:
|
||||
VTKM_RUN_BENCHMARK(Unique30, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & UPPER_BOUNDS){
|
||||
if (benchmarks & UPPER_BOUNDS)
|
||||
{
|
||||
std::cout << "\n" << DIVIDER << "\nBenchmarking UpperBounds\n";
|
||||
VTKM_RUN_BENCHMARK(UpperBounds5, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(UpperBounds10, ValueTypes());
|
||||
@ -633,54 +715,68 @@ public:
|
||||
};
|
||||
|
||||
#undef ARRAY_SIZE
|
||||
|
||||
}
|
||||
} // namespace vtkm::benchmarking
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int benchmarks = 0;
|
||||
if (argc < 2){
|
||||
if (argc < 2)
|
||||
{
|
||||
benchmarks = vtkm::benchmarking::ALL;
|
||||
}
|
||||
else {
|
||||
for (int i = 1; i < argc; ++i){
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::string arg = argv[i];
|
||||
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower);
|
||||
if (arg == "copy"){
|
||||
if (arg == "copy")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::COPY;
|
||||
}
|
||||
else if (arg == "copyif"){
|
||||
else if (arg == "copyif")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::COPY_IF;
|
||||
}
|
||||
else if (arg == "lowerbounds"){
|
||||
else if (arg == "lowerbounds")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::LOWER_BOUNDS;
|
||||
}
|
||||
else if (arg == "reduce"){
|
||||
else if (arg == "reduce")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::REDUCE;
|
||||
}
|
||||
else if (arg == "reducebykey"){
|
||||
else if (arg == "reducebykey")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::REDUCE_BY_KEY;
|
||||
}
|
||||
else if (arg == "scaninclusive"){
|
||||
else if (arg == "scaninclusive")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::SCAN_INCLUSIVE;
|
||||
}
|
||||
else if (arg == "scanexclusive"){
|
||||
else if (arg == "scanexclusive")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::SCAN_EXCLUSIVE;
|
||||
}
|
||||
else if (arg == "sort"){
|
||||
else if (arg == "sort")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::SORT;
|
||||
}
|
||||
else if (arg == "sortbykey"){
|
||||
else if (arg == "sortbykey")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::SORT_BY_KEY;
|
||||
}
|
||||
else if (arg == "unique"){
|
||||
else if (arg == "unique")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::UNIQUE;
|
||||
}
|
||||
else if (arg == "upperbounds"){
|
||||
else if (arg == "upperbounds")
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::UPPER_BOUNDS;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
std::cout << "Unrecognized benchmark: " << argv[i] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@ -688,7 +784,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
//now actually execute the benchmarks
|
||||
return vtkm::benchmarking::BenchmarkDeviceAdapter
|
||||
<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Run(benchmarks);
|
||||
return vtkm::benchmarking::BenchmarkDeviceAdapter<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Run(
|
||||
benchmarks);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
|
||||
@ -39,24 +38,23 @@
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
namespace vtkm {
|
||||
namespace benchmarking {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace benchmarking
|
||||
{
|
||||
|
||||
#define ARRAY_SIZE (1 << 22)
|
||||
#define CUBE_SIZE 256
|
||||
const static std::string DIVIDER(40, '-');
|
||||
|
||||
enum BenchmarkName {
|
||||
enum BenchmarkName
|
||||
{
|
||||
BLACK_SCHOLES = 1,
|
||||
MATH = 1 << 1,
|
||||
FUSED_MATH = 1 << 2,
|
||||
INTERPOLATE_FIELD = 1 << 3,
|
||||
IMPLICIT_FUNCTION = 1 << 4,
|
||||
ALL = BLACK_SCHOLES |
|
||||
MATH |
|
||||
FUSED_MATH |
|
||||
INTERPOLATE_FIELD |
|
||||
IMPLICIT_FUNCTION
|
||||
ALL = BLACK_SCHOLES | MATH | FUSED_MATH | INTERPOLATE_FIELD | IMPLICIT_FUNCTION
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -64,15 +62,15 @@ class BlackScholes : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
T Riskfree;
|
||||
T Volatility;
|
||||
|
||||
public:
|
||||
typedef void ControlSignature(FieldIn<Scalar>, FieldIn<Scalar>,
|
||||
FieldIn<Scalar>, FieldOut<Scalar>,
|
||||
typedef void ControlSignature(FieldIn<Scalar>, FieldIn<Scalar>, FieldIn<Scalar>, FieldOut<Scalar>,
|
||||
FieldOut<Scalar>);
|
||||
typedef void ExecutionSignature(_1, _2, _3, _4, _5);
|
||||
|
||||
BlackScholes(T risk, T volatility):
|
||||
Riskfree(risk),
|
||||
Volatility(volatility)
|
||||
BlackScholes(T risk, T volatility)
|
||||
: Riskfree(risk)
|
||||
, Volatility(volatility)
|
||||
{
|
||||
}
|
||||
|
||||
@ -89,8 +87,8 @@ public:
|
||||
const vtkm::Float32 df = static_cast<vtkm::Float32>(d);
|
||||
const vtkm::Float32 K = 1.0f / (1.0f + 0.2316419f * vtkm::Abs(df));
|
||||
|
||||
vtkm::Float32 cnd = RSQRT2PI * vtkm::Exp(-0.5f * df * df) *
|
||||
(K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
|
||||
vtkm::Float32 cnd =
|
||||
RSQRT2PI * vtkm::Exp(-0.5f * df * df) * (K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
|
||||
|
||||
if (df > 0.0f)
|
||||
{
|
||||
@ -101,8 +99,8 @@ public:
|
||||
}
|
||||
|
||||
template <typename U, typename V, typename W>
|
||||
VTKM_EXEC void operator()(const U& sp, const V& os, const W& oy,
|
||||
T& callResult, T& putResult) const
|
||||
VTKM_EXEC void operator()(const U& sp, const V& os, const W& oy, T& callResult,
|
||||
T& putResult) const
|
||||
{
|
||||
const T stockPrice = static_cast<T>(sp);
|
||||
const T optionStrike = static_cast<T>(os);
|
||||
@ -112,7 +110,9 @@ public:
|
||||
const T sqrtYears = vtkm::Sqrt(optionYears);
|
||||
const T volMultSqY = this->Volatility * sqrtYears;
|
||||
|
||||
const T d1 = ( vtkm::Log(stockPrice / optionStrike) + (this->Riskfree + 0.5f * Volatility * Volatility) * optionYears) / (volMultSqY);
|
||||
const T d1 = (vtkm::Log(stockPrice / optionStrike) +
|
||||
(this->Riskfree + 0.5f * Volatility * Volatility) * optionYears) /
|
||||
(volMultSqY);
|
||||
const T d2 = d1 - volMultSqY;
|
||||
const T CNDD1 = CumulativeNormalDistribution(d1);
|
||||
const T CNDD2 = CumulativeNormalDistribution(d2);
|
||||
@ -122,7 +122,6 @@ public:
|
||||
callResult = stockPrice * CNDD1 - optionStrike * expRT * CNDD2;
|
||||
putResult = optionStrike * expRT * (1.0f - CNDD2) - stockPrice * (1.0f - CNDD1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class Mag : public vtkm::worklet::WorkletMapField
|
||||
@ -132,8 +131,7 @@ public:
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Vec<T,3>& vec, U& result) const
|
||||
VTKM_EXEC void operator()(const vtkm::Vec<T, 3>& vec, U& result) const
|
||||
{
|
||||
result = static_cast<U>(vtkm::Magnitude(vec));
|
||||
}
|
||||
@ -146,8 +144,7 @@ public:
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_EXEC
|
||||
void operator()(T input, U& output) const
|
||||
VTKM_EXEC void operator()(T input, U& output) const
|
||||
{
|
||||
output = static_cast<U>(input * input);
|
||||
}
|
||||
@ -160,8 +157,7 @@ public:
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_EXEC
|
||||
void operator()(T input, U& output) const
|
||||
VTKM_EXEC void operator()(T input, U& output) const
|
||||
{
|
||||
output = static_cast<U>(vtkm::Sin(input));
|
||||
}
|
||||
@ -174,8 +170,7 @@ public:
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_EXEC
|
||||
void operator()(T input, U& output) const
|
||||
VTKM_EXEC void operator()(T input, U& output) const
|
||||
{
|
||||
output = static_cast<U>(vtkm::Cos(input));
|
||||
}
|
||||
@ -188,16 +183,14 @@ public:
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
|
||||
template <typename T>
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Vec<T,3>& vec, T& result) const
|
||||
VTKM_EXEC void operator()(const vtkm::Vec<T, 3>& vec, T& result) const
|
||||
{
|
||||
const T m = vtkm::Magnitude(vec);
|
||||
result = vtkm::Cos(vtkm::Sin(m) * vtkm::Sin(m));
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Vec<T,3>& , U& ) const
|
||||
VTKM_EXEC void operator()(const vtkm::Vec<T, 3>&, U&) const
|
||||
{
|
||||
this->RaiseError("Mixed types unsupported.");
|
||||
}
|
||||
@ -210,25 +203,20 @@ public:
|
||||
typedef void ExecutionSignature(PointIndices, ThreadIndices, _2);
|
||||
typedef _1 InputDomain;
|
||||
|
||||
template<typename ConnectivityInVec,
|
||||
typename ThreadIndicesType,
|
||||
typename IdPairTableType>
|
||||
VTKM_EXEC
|
||||
void operator()(const ConnectivityInVec &connectivity,
|
||||
template <typename ConnectivityInVec, typename ThreadIndicesType, typename IdPairTableType>
|
||||
VTKM_EXEC void operator()(const ConnectivityInVec& connectivity,
|
||||
const ThreadIndicesType threadIndices,
|
||||
const IdPairTableType& edgeIds) const
|
||||
{
|
||||
const vtkm::Id writeOffset = (threadIndices.GetInputIndex() * 12);
|
||||
|
||||
const vtkm::IdComponent edgeTable[24] = { 0, 1, 1, 2, 3, 2, 0, 3,
|
||||
4, 5, 5, 6, 7, 6, 4, 7,
|
||||
0, 4, 1, 5, 2, 6, 3, 7 };
|
||||
const vtkm::IdComponent edgeTable[24] = { 0, 1, 1, 2, 3, 2, 0, 3, 4, 5, 5, 6,
|
||||
7, 6, 4, 7, 0, 4, 1, 5, 2, 6, 3, 7 };
|
||||
|
||||
for (vtkm::Id i = 0; i < 12; ++i)
|
||||
{
|
||||
const vtkm::Id offset = (i * 2);
|
||||
const vtkm::Id2 edge( connectivity[ edgeTable[offset] ],
|
||||
connectivity[ edgeTable[offset+1] ] );
|
||||
const vtkm::Id2 edge(connectivity[edgeTable[offset]], connectivity[edgeTable[offset + 1]]);
|
||||
edgeIds.Set(writeOffset + i, edge);
|
||||
}
|
||||
}
|
||||
@ -238,32 +226,23 @@ class InterpolateField : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldIn<Id2Type> interpolation_ids,
|
||||
FieldIn< Scalar > interpolation_weights,
|
||||
WholeArrayIn<> inputField,
|
||||
FieldOut<> output
|
||||
);
|
||||
FieldIn<Scalar> interpolation_weights, WholeArrayIn<> inputField,
|
||||
FieldOut<> output);
|
||||
typedef void ExecutionSignature(_1, _2, _3, _4);
|
||||
typedef _1 InputDomain;
|
||||
|
||||
template <typename WeightType, typename T, typename S, typename D>
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Id2& low_high,
|
||||
const WeightType &weight,
|
||||
VTKM_EXEC void operator()(const vtkm::Id2& low_high, const WeightType& weight,
|
||||
const vtkm::exec::ExecutionWholeArrayConst<T, S, D>& inPortal,
|
||||
T& result) const
|
||||
{
|
||||
//fetch the low / high values from inPortal
|
||||
result = vtkm::Lerp(inPortal.Get(low_high[0]),
|
||||
inPortal.Get(low_high[1]),
|
||||
weight);
|
||||
result = vtkm::Lerp(inPortal.Get(low_high[0]), inPortal.Get(low_high[1]), weight);
|
||||
}
|
||||
|
||||
template <typename WeightType, typename T, typename S, typename D, typename U>
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Id2& ,
|
||||
const WeightType &,
|
||||
const vtkm::exec::ExecutionWholeArrayConst<T,S,D>& ,
|
||||
U &) const
|
||||
VTKM_EXEC void operator()(const vtkm::Id2&, const WeightType&,
|
||||
const vtkm::exec::ExecutionWholeArrayConst<T, S, D>&, U&) const
|
||||
{
|
||||
//the inPortal and result need to be the same type so this version only
|
||||
//exists to generate code when using dynamic arrays
|
||||
@ -280,11 +259,11 @@ public:
|
||||
|
||||
EvaluateImplicitFunction(const ImplicitFunction& function)
|
||||
: Function(function)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
template <typename VecType, typename ScalarType>
|
||||
VTKM_EXEC
|
||||
void operator()(const VecType &point, ScalarType &val) const
|
||||
VTKM_EXEC void operator()(const VecType& point, ScalarType& val) const
|
||||
{
|
||||
val = this->Function.Value(point);
|
||||
}
|
||||
@ -301,12 +280,13 @@ public:
|
||||
typedef void ExecutionSignature(_1, _2);
|
||||
|
||||
Evaluate2ImplicitFunctions(const T1& f1, const T2& f2)
|
||||
: Function1(f1), Function2(f2)
|
||||
{ }
|
||||
: Function1(f1)
|
||||
, Function2(f2)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename VecType, typename ScalarType>
|
||||
VTKM_EXEC
|
||||
void operator()(const VecType &point, ScalarType &val) const
|
||||
VTKM_EXEC void operator()(const VecType& point, ScalarType& val) const
|
||||
{
|
||||
val = this->Function1.Value(point) + this->Function2.Value(point);
|
||||
}
|
||||
@ -316,35 +296,37 @@ private:
|
||||
T2 Function2;
|
||||
};
|
||||
|
||||
struct ValueTypes : vtkm::ListTagBase<vtkm::Float32, vtkm::Float64>{};
|
||||
struct ValueTypes : vtkm::ListTagBase<vtkm::Float32, vtkm::Float64>
|
||||
{
|
||||
};
|
||||
|
||||
struct InterpValueTypes : vtkm::ListTagBase<vtkm::Float32,
|
||||
vtkm::Float64,
|
||||
vtkm::Vec< vtkm::Float32, 3>,
|
||||
vtkm::Vec< vtkm::Float64, 3>
|
||||
>{};
|
||||
struct InterpValueTypes
|
||||
: vtkm::ListTagBase<vtkm::Float32, vtkm::Float64, vtkm::Vec<vtkm::Float32, 3>,
|
||||
vtkm::Vec<vtkm::Float64, 3>>
|
||||
{
|
||||
};
|
||||
using StorageListTag = ::vtkm::cont::StorageListTagBasic;
|
||||
|
||||
/// This class runs a series of micro-benchmarks to measure
|
||||
/// performance of different field operations
|
||||
template <class DeviceAdapterTag>
|
||||
class BenchmarkFieldAlgorithms {
|
||||
class BenchmarkFieldAlgorithms
|
||||
{
|
||||
typedef vtkm::cont::StorageTagBasic StorageTag;
|
||||
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag> Algorithm;
|
||||
|
||||
typedef vtkm::cont::Timer<DeviceAdapterTag> Timer;
|
||||
|
||||
using ValueDynamicHandle =
|
||||
vtkm::cont::DynamicArrayHandleBase<ValueTypes, StorageListTag>;
|
||||
using InterpDynamicHandle =
|
||||
vtkm::cont::DynamicArrayHandleBase<InterpValueTypes, StorageListTag>;
|
||||
using ValueDynamicHandle = vtkm::cont::DynamicArrayHandleBase<ValueTypes, StorageListTag>;
|
||||
using InterpDynamicHandle = vtkm::cont::DynamicArrayHandleBase<InterpValueTypes, StorageListTag>;
|
||||
using IdDynamicHandle =
|
||||
vtkm::cont::DynamicArrayHandleBase<vtkm::TypeListTagIndex, StorageListTag>;
|
||||
|
||||
private:
|
||||
template <typename Value>
|
||||
struct BenchBlackScholes {
|
||||
struct BenchBlackScholes
|
||||
{
|
||||
using ValueArrayHandle = vtkm::cont::ArrayHandle<Value, StorageTag>;
|
||||
|
||||
ValueArrayHandle StockPrice;
|
||||
@ -389,12 +371,8 @@ private:
|
||||
BlackScholes<Value> worklet(RISKFREE, VOLATILITY);
|
||||
vtkm::worklet::DispatcherMapField<BlackScholes<Value>> dispatcher(worklet);
|
||||
|
||||
dispatcher.Invoke( this->StockPrice,
|
||||
this->OptionStrike,
|
||||
this->OptionYears,
|
||||
callResultHandle,
|
||||
putResultHandle
|
||||
);
|
||||
dispatcher.Invoke(this->StockPrice, this->OptionStrike, this->OptionYears, callResultHandle,
|
||||
putResultHandle);
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
@ -402,7 +380,8 @@ private:
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "BlackScholes "
|
||||
<< "[" << this->Type() << "] "
|
||||
@ -412,7 +391,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchBlackScholesDynamic : public BenchBlackScholes<Value> {
|
||||
struct BenchBlackScholesDynamic : public BenchBlackScholes<Value>
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -429,26 +409,20 @@ private:
|
||||
BlackScholes<Value> worklet(RISKFREE, VOLATILITY);
|
||||
vtkm::worklet::DispatcherMapField<BlackScholes<Value>> dispatcher(worklet);
|
||||
|
||||
dispatcher.Invoke( dstocks,
|
||||
dstrikes,
|
||||
doptions,
|
||||
callResultHandle,
|
||||
putResultHandle
|
||||
);
|
||||
dispatcher.Invoke(dstocks, dstrikes, doptions, callResultHandle, putResultHandle);
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
virtual std::string Type() const { return std::string("Dynamic"); }
|
||||
|
||||
};
|
||||
|
||||
VTKM_MAKE_BENCHMARK(BlackScholes, BenchBlackScholes);
|
||||
VTKM_MAKE_BENCHMARK(BlackScholesDynamic, BenchBlackScholesDynamic);
|
||||
|
||||
|
||||
template <typename Value>
|
||||
struct BenchMath {
|
||||
struct BenchMath
|
||||
{
|
||||
std::vector<vtkm::Vec<Value, 3>> input;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Value, 3>, StorageTag> InputHandle;
|
||||
|
||||
@ -461,9 +435,7 @@ private:
|
||||
this->input.resize(ARRAY_SIZE);
|
||||
for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
|
||||
{
|
||||
this->input[i] = vtkm::Vec<Value, 3>(range(rng),
|
||||
range(rng),
|
||||
range(rng));
|
||||
this->input[i] = vtkm::Vec<Value, 3>(range(rng), range(rng), range(rng));
|
||||
}
|
||||
|
||||
this->InputHandle = vtkm::cont::make_ArrayHandle(this->input);
|
||||
@ -488,7 +460,8 @@ private:
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Magnitude -> Sine -> Square -> Cosine "
|
||||
<< "[" << this->Type() << "] "
|
||||
@ -498,14 +471,13 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchMathDynamic : public BenchMath<Value> {
|
||||
struct BenchMathDynamic : public BenchMath<Value>
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
using MathTypes = vtkm::ListTagBase<vtkm::Vec< vtkm::Float32, 3>,
|
||||
vtkm::Vec< vtkm::Float64, 3>
|
||||
>;
|
||||
using MathTypes = vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 3>, vtkm::Vec<vtkm::Float64, 3>>;
|
||||
|
||||
vtkm::cont::ArrayHandle<Value> temp1;
|
||||
vtkm::cont::ArrayHandle<Value> temp2;
|
||||
@ -524,14 +496,14 @@ private:
|
||||
}
|
||||
|
||||
virtual std::string Type() const { return std::string("Dynamic"); }
|
||||
|
||||
};
|
||||
|
||||
VTKM_MAKE_BENCHMARK(Math, BenchMath);
|
||||
VTKM_MAKE_BENCHMARK(MathDynamic, BenchMathDynamic);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchFusedMath {
|
||||
struct BenchFusedMath
|
||||
{
|
||||
std::vector<vtkm::Vec<Value, 3>> input;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Value, 3>, StorageTag> InputHandle;
|
||||
|
||||
@ -544,9 +516,7 @@ private:
|
||||
this->input.resize(ARRAY_SIZE);
|
||||
for (std::size_t i = 0; i < ARRAY_SIZE; ++i)
|
||||
{
|
||||
this->input[i] = vtkm::Vec<Value, 3>(range(rng),
|
||||
range(rng),
|
||||
range(rng));
|
||||
this->input[i] = vtkm::Vec<Value, 3>(range(rng), range(rng), range(rng));
|
||||
}
|
||||
|
||||
this->InputHandle = vtkm::cont::make_ArrayHandle(this->input);
|
||||
@ -565,7 +535,8 @@ private:
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Fused Magnitude -> Sine -> Square -> Cosine "
|
||||
<< "[" << this->Type() << "] "
|
||||
@ -575,14 +546,13 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchFusedMathDynamic : public BenchFusedMath<Value> {
|
||||
struct BenchFusedMathDynamic : public BenchFusedMath<Value>
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
using MathTypes = vtkm::ListTagBase<vtkm::Vec< vtkm::Float32, 3>,
|
||||
vtkm::Vec< vtkm::Float64, 3>
|
||||
>;
|
||||
using MathTypes = vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 3>, vtkm::Vec<vtkm::Float64, 3>>;
|
||||
|
||||
vtkm::cont::DynamicArrayHandleBase<MathTypes, StorageListTag> dinput(this->InputHandle);
|
||||
|
||||
@ -600,7 +570,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(FusedMathDynamic, BenchFusedMathDynamic);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchEdgeInterp {
|
||||
struct BenchEdgeInterp
|
||||
{
|
||||
std::vector<vtkm::Float32> weight;
|
||||
std::vector<Value> field;
|
||||
|
||||
@ -630,8 +601,7 @@ private:
|
||||
const std::size_t psize = static_cast<std::size_t>(cellSet.GetNumberOfPoints());
|
||||
|
||||
this->EdgePairHandle.Allocate(numberOfEdges);
|
||||
vtkm::worklet::DispatcherMapTopology< GenerateEdges >().Invoke( cellSet,
|
||||
this->EdgePairHandle );
|
||||
vtkm::worklet::DispatcherMapTopology<GenerateEdges>().Invoke(cellSet, this->EdgePairHandle);
|
||||
|
||||
this->weight.resize(esize);
|
||||
for (std::size_t i = 0; i < esize; ++i)
|
||||
@ -655,19 +625,16 @@ private:
|
||||
vtkm::cont::ArrayHandle<Value> result;
|
||||
|
||||
Timer timer;
|
||||
vtkm::worklet::DispatcherMapField<
|
||||
InterpolateField,
|
||||
DeviceAdapterTag>().Invoke(this->EdgePairHandle,
|
||||
this->WeightHandle,
|
||||
this->FieldHandle,
|
||||
result);
|
||||
vtkm::worklet::DispatcherMapField<InterpolateField, DeviceAdapterTag>().Invoke(
|
||||
this->EdgePairHandle, this->WeightHandle, this->FieldHandle, result);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
std::stringstream description;
|
||||
const std::size_t size = (CUBE_SIZE - 1) * (CUBE_SIZE - 1) * (CUBE_SIZE - 1) * 12;
|
||||
description << "Edge Interpolation "
|
||||
@ -678,7 +645,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchEdgeInterpDynamic : public BenchEdgeInterp<Value> {
|
||||
struct BenchEdgeInterpDynamic : public BenchEdgeInterp<Value>
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -689,12 +657,8 @@ private:
|
||||
vtkm::cont::ArrayHandle<Value> result;
|
||||
|
||||
Timer timer;
|
||||
vtkm::worklet::DispatcherMapField<
|
||||
InterpolateField,
|
||||
DeviceAdapterTag>().Invoke(dedges,
|
||||
dweight,
|
||||
dfield,
|
||||
result);
|
||||
vtkm::worklet::DispatcherMapField<InterpolateField, DeviceAdapterTag>().Invoke(
|
||||
dedges, dweight, dfield, result);
|
||||
return timer.GetElapsedTime();
|
||||
}
|
||||
|
||||
@ -704,7 +668,6 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(EdgeInterp, BenchEdgeInterp);
|
||||
VTKM_MAKE_BENCHMARK(EdgeInterpDynamic, BenchEdgeInterpDynamic);
|
||||
|
||||
|
||||
struct ImplicitFunctionBenchData
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> Points;
|
||||
@ -743,7 +706,8 @@ private:
|
||||
{
|
||||
BenchImplicitFunction()
|
||||
: Internal(MakeImplicitFunctionBenchData())
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -763,8 +727,7 @@ private:
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Implicit Function (vtkm::cont::Sphere) on "
|
||||
<< Internal.Points.GetNumberOfValues()
|
||||
<< " points";
|
||||
<< Internal.Points.GetNumberOfValues() << " points";
|
||||
return description.str();
|
||||
}
|
||||
|
||||
@ -776,7 +739,8 @@ private:
|
||||
{
|
||||
BenchDynamicImplicitFunction()
|
||||
: Internal(MakeImplicitFunctionBenchData())
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -796,8 +760,7 @@ private:
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Implicit Function (DynamicImplicitFunction) on "
|
||||
<< Internal.Points.GetNumberOfValues()
|
||||
<< " points";
|
||||
<< Internal.Points.GetNumberOfValues() << " points";
|
||||
return description.str();
|
||||
}
|
||||
|
||||
@ -809,7 +772,8 @@ private:
|
||||
{
|
||||
Bench2ImplicitFunctions()
|
||||
: Internal(MakeImplicitFunctionBenchData())
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -829,8 +793,7 @@ private:
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Implicit Function 2x(vtkm::cont::Sphere) on "
|
||||
<< Internal.Points.GetNumberOfValues()
|
||||
<< " points";
|
||||
<< Internal.Points.GetNumberOfValues() << " points";
|
||||
return description.str();
|
||||
}
|
||||
|
||||
@ -842,13 +805,14 @@ private:
|
||||
{
|
||||
Bench2DynamicImplicitFunctions()
|
||||
: Internal(MakeImplicitFunctionBenchData())
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
using EvalWorklet = Evaluate2ImplicitFunctions<vtkm::exec::ImplicitFunction,
|
||||
vtkm::exec::ImplicitFunction>;
|
||||
using EvalWorklet =
|
||||
Evaluate2ImplicitFunctions<vtkm::exec::ImplicitFunction, vtkm::exec::ImplicitFunction>;
|
||||
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
|
||||
|
||||
EvalWorklet eval(Internal.Sphere1.PrepareForExecution(DeviceAdapterTag()),
|
||||
@ -864,8 +828,7 @@ private:
|
||||
{
|
||||
std::stringstream description;
|
||||
description << "Implicit Function 2x(DynamicImplicitFunction) on "
|
||||
<< Internal.Points.GetNumberOfValues()
|
||||
<< " points";
|
||||
<< Internal.Points.GetNumberOfValues() << " points";
|
||||
return description.str();
|
||||
}
|
||||
|
||||
@ -878,35 +841,40 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(ImplicitFunctionDynamic2, Bench2DynamicImplicitFunctions);
|
||||
|
||||
public:
|
||||
|
||||
static VTKM_CONT int Run(int benchmarks){
|
||||
static VTKM_CONT int Run(int benchmarks)
|
||||
{
|
||||
std::cout << DIVIDER << "\nRunning Field Algorithm benchmarks\n";
|
||||
|
||||
if (benchmarks & BLACK_SCHOLES) {
|
||||
if (benchmarks & BLACK_SCHOLES)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking BlackScholes\n";
|
||||
VTKM_RUN_BENCHMARK(BlackScholes, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(BlackScholesDynamic, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & MATH){
|
||||
if (benchmarks & MATH)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Multiple Math Worklets\n";
|
||||
VTKM_RUN_BENCHMARK(Math, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(MathDynamic, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & FUSED_MATH){
|
||||
if (benchmarks & FUSED_MATH)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Single Fused Math Worklet\n";
|
||||
VTKM_RUN_BENCHMARK(FusedMath, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(FusedMathDynamic, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & INTERPOLATE_FIELD){
|
||||
if (benchmarks & INTERPOLATE_FIELD)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Edge Based Field InterpolationWorklet\n";
|
||||
VTKM_RUN_BENCHMARK(EdgeInterp, InterpValueTypes());
|
||||
VTKM_RUN_BENCHMARK(EdgeInterpDynamic, InterpValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & IMPLICIT_FUNCTION) {
|
||||
if (benchmarks & IMPLICIT_FUNCTION)
|
||||
{
|
||||
using FloatDefaultType = vtkm::ListTagBase<vtkm::FloatDefault>;
|
||||
|
||||
std::cout << "\nBenchmarking Implicit Function\n";
|
||||
@ -920,20 +888,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#undef ARRAY_SIZE
|
||||
|
||||
}
|
||||
} // namespace vtkm::benchmarking
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int benchmarks = 0;
|
||||
if (argc < 2){
|
||||
if (argc < 2)
|
||||
{
|
||||
benchmarks = vtkm::benchmarking::ALL;
|
||||
}
|
||||
else {
|
||||
for (int i = 1; i < argc; ++i){
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::string arg = argv[i];
|
||||
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower);
|
||||
if (arg == "blackscholes")
|
||||
@ -965,6 +934,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
//now actually execute the benchmarks
|
||||
return vtkm::benchmarking::BenchmarkFieldAlgorithms
|
||||
<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Run(benchmarks);
|
||||
return vtkm::benchmarking::BenchmarkFieldAlgorithms<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Run(
|
||||
benchmarks);
|
||||
}
|
||||
|
@ -35,35 +35,33 @@
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
namespace vtkm {
|
||||
namespace benchmarking {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace benchmarking
|
||||
{
|
||||
|
||||
#define CUBE_SIZE 256
|
||||
const static std::string DIVIDER(40, '-');
|
||||
|
||||
enum BenchmarkName {
|
||||
enum BenchmarkName
|
||||
{
|
||||
CELL_TO_POINT = 1 << 1,
|
||||
POINT_TO_CELL = 1 << 2,
|
||||
MC_CLASSIFY = 1 << 3,
|
||||
ALL = CELL_TO_POINT |
|
||||
POINT_TO_CELL |
|
||||
MC_CLASSIFY
|
||||
ALL = CELL_TO_POINT | POINT_TO_CELL | MC_CLASSIFY
|
||||
};
|
||||
|
||||
class AveragePointToCell : public vtkm::worklet::WorkletMapPointToCell
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldInPoint<> inPoints,
|
||||
CellSetIn cellset,
|
||||
typedef void ControlSignature(FieldInPoint<> inPoints, CellSetIn cellset,
|
||||
FieldOutCell<> outCells);
|
||||
typedef void ExecutionSignature(_1, PointCount, _3);
|
||||
typedef _2 InputDomain;
|
||||
|
||||
template <typename PointValueVecType, typename OutType>
|
||||
VTKM_EXEC
|
||||
void operator()(const PointValueVecType &pointValues,
|
||||
const vtkm::IdComponent &numPoints,
|
||||
OutType &average) const
|
||||
VTKM_EXEC void operator()(const PointValueVecType& pointValues,
|
||||
const vtkm::IdComponent& numPoints, OutType& average) const
|
||||
{
|
||||
OutType sum = static_cast<OutType>(pointValues[0]);
|
||||
for (vtkm::IdComponent pointIndex = 1; pointIndex < numPoints; ++pointIndex)
|
||||
@ -78,16 +76,12 @@ public:
|
||||
class AverageCellToPoint : public vtkm::worklet::WorkletMapCellToPoint
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldInCell<> inCells,
|
||||
CellSetIn topology,
|
||||
FieldOut<> outPoints);
|
||||
typedef void ControlSignature(FieldInCell<> inCells, CellSetIn topology, FieldOut<> outPoints);
|
||||
typedef void ExecutionSignature(_1, _3, CellCount);
|
||||
typedef _2 InputDomain;
|
||||
|
||||
template <typename CellVecType, typename OutType>
|
||||
VTKM_EXEC
|
||||
void operator()(const CellVecType &cellValues,
|
||||
OutType &avgVal,
|
||||
VTKM_EXEC void operator()(const CellVecType& cellValues, OutType& avgVal,
|
||||
const vtkm::IdComponent& numCellIDs) const
|
||||
{
|
||||
//simple functor that returns the average cell Value.
|
||||
@ -105,9 +99,7 @@ template<typename T>
|
||||
class Classification : public vtkm::worklet::WorkletMapPointToCell
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(
|
||||
FieldInPoint<> inNodes,
|
||||
CellSetIn cellset,
|
||||
typedef void ControlSignature(FieldInPoint<> inNodes, CellSetIn cellset,
|
||||
FieldOutCell<IdComponentType> outCaseId);
|
||||
typedef void ExecutionSignature(_1, _3);
|
||||
typedef _2 InputDomain;
|
||||
@ -115,80 +107,78 @@ public:
|
||||
T IsoValue;
|
||||
|
||||
VTKM_CONT
|
||||
Classification(T isovalue) :
|
||||
IsoValue(isovalue)
|
||||
Classification(T isovalue)
|
||||
: IsoValue(isovalue)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename FieldInType>
|
||||
VTKM_EXEC
|
||||
void operator()(const FieldInType &fieldIn,
|
||||
vtkm::IdComponent &caseNumber) const
|
||||
VTKM_EXEC void operator()(const FieldInType& fieldIn, vtkm::IdComponent& caseNumber) const
|
||||
{
|
||||
typedef typename vtkm::VecTraits<FieldInType>::ComponentType FieldType;
|
||||
const FieldType iso = static_cast<FieldType>(this->IsoValue);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
struct ValueTypes : vtkm::ListTagBase<vtkm::UInt32, vtkm::Int32, vtkm::Int64,
|
||||
vtkm::Float32, vtkm::Float64 >{};
|
||||
struct ValueTypes
|
||||
: vtkm::ListTagBase<vtkm::UInt32, vtkm::Int32, vtkm::Int64, vtkm::Float32, vtkm::Float64>
|
||||
{
|
||||
};
|
||||
using StorageListTag = ::vtkm::cont::StorageListTagBasic;
|
||||
|
||||
/// This class runs a series of micro-benchmarks to measure
|
||||
/// performance of different field operations
|
||||
template <class DeviceAdapterTag>
|
||||
class BenchmarkTopologyAlgorithms {
|
||||
class BenchmarkTopologyAlgorithms
|
||||
{
|
||||
typedef vtkm::cont::StorageTagBasic StorageTag;
|
||||
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag> Algorithm;
|
||||
|
||||
typedef vtkm::cont::Timer<DeviceAdapterTag> Timer;
|
||||
|
||||
using ValueDynamicHandle =
|
||||
vtkm::cont::DynamicArrayHandleBase<ValueTypes, StorageListTag>;
|
||||
using ValueDynamicHandle = vtkm::cont::DynamicArrayHandleBase<ValueTypes, StorageListTag>;
|
||||
|
||||
private:
|
||||
|
||||
template<typename T, typename Enable= void> struct NumberGenerator {};
|
||||
template <typename T, typename Enable = void>
|
||||
struct NumberGenerator
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct NumberGenerator<T,
|
||||
typename std::enable_if<
|
||||
std::is_floating_point<T>::value
|
||||
>::type
|
||||
>
|
||||
struct NumberGenerator<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
|
||||
{
|
||||
std::mt19937 rng;
|
||||
std::uniform_real_distribution<T> distribution;
|
||||
NumberGenerator(T low, T high): rng(), distribution(low,high) {}
|
||||
NumberGenerator(T low, T high)
|
||||
: rng()
|
||||
, distribution(low, high)
|
||||
{
|
||||
}
|
||||
T next() { return distribution(rng); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct NumberGenerator<T,
|
||||
typename std::enable_if<
|
||||
!std::is_floating_point<T>::value
|
||||
>::type
|
||||
>
|
||||
struct NumberGenerator<T, typename std::enable_if<!std::is_floating_point<T>::value>::type>
|
||||
{
|
||||
std::mt19937 rng;
|
||||
std::uniform_int_distribution<T> distribution;
|
||||
|
||||
NumberGenerator(T low, T high): rng(), distribution(low,high) {}
|
||||
NumberGenerator(T low, T high)
|
||||
: rng()
|
||||
, distribution(low, high)
|
||||
{
|
||||
}
|
||||
T next() { return distribution(rng); }
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchCellToPointAvg {
|
||||
struct BenchCellToPointAvg
|
||||
{
|
||||
std::vector<Value> input;
|
||||
vtkm::cont::ArrayHandle<Value, StorageTag> InputHandle;
|
||||
std::size_t DomainSize;
|
||||
@ -196,8 +186,7 @@ private:
|
||||
VTKM_CONT
|
||||
BenchCellToPointAvg()
|
||||
{
|
||||
NumberGenerator<Value> generator(static_cast<Value>(1.0),
|
||||
static_cast<Value>(100.0));
|
||||
NumberGenerator<Value> generator(static_cast<Value>(1.0), static_cast<Value>(100.0));
|
||||
//cube size is points in each dim
|
||||
this->DomainSize = (CUBE_SIZE - 1) * (CUBE_SIZE - 1) * (CUBE_SIZE - 1);
|
||||
this->input.resize(DomainSize);
|
||||
@ -218,9 +207,7 @@ private:
|
||||
Timer timer;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<AverageCellToPoint> dispatcher;
|
||||
dispatcher.Invoke( this->InputHandle,
|
||||
cellSet,
|
||||
result);
|
||||
dispatcher.Invoke(this->InputHandle, cellSet, result);
|
||||
//result.SyncControlArray();
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
@ -229,7 +216,8 @@ private:
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
|
||||
std::stringstream description;
|
||||
description << "Computing Cell To Point Average "
|
||||
@ -240,7 +228,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchCellToPointAvgDynamic : public BenchCellToPointAvg<Value> {
|
||||
struct BenchCellToPointAvgDynamic : public BenchCellToPointAvg<Value>
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -255,9 +244,7 @@ private:
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<AverageCellToPoint> dispatcher;
|
||||
|
||||
dispatcher.Invoke( dinput,
|
||||
cellSet,
|
||||
result);
|
||||
dispatcher.Invoke(dinput, cellSet, result);
|
||||
//result.SyncControlArray();
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
@ -270,7 +257,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(CellToPointAvgDynamic, BenchCellToPointAvgDynamic);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchPointToCellAvg {
|
||||
struct BenchPointToCellAvg
|
||||
{
|
||||
std::vector<Value> input;
|
||||
vtkm::cont::ArrayHandle<Value, StorageTag> InputHandle;
|
||||
std::size_t DomainSize;
|
||||
@ -278,8 +266,7 @@ private:
|
||||
VTKM_CONT
|
||||
BenchPointToCellAvg()
|
||||
{
|
||||
NumberGenerator<Value> generator(static_cast<Value>(1.0),
|
||||
static_cast<Value>(100.0));
|
||||
NumberGenerator<Value> generator(static_cast<Value>(1.0), static_cast<Value>(100.0));
|
||||
|
||||
this->DomainSize = (CUBE_SIZE) * (CUBE_SIZE) * (CUBE_SIZE);
|
||||
this->input.resize(DomainSize);
|
||||
@ -300,9 +287,7 @@ private:
|
||||
Timer timer;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<AveragePointToCell> dispatcher;
|
||||
dispatcher.Invoke( this->InputHandle,
|
||||
cellSet,
|
||||
result);
|
||||
dispatcher.Invoke(this->InputHandle, cellSet, result);
|
||||
//result.SyncControlArray();
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
@ -311,7 +296,8 @@ private:
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
|
||||
std::stringstream description;
|
||||
description << "Computing Point To Cell Average "
|
||||
@ -322,7 +308,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchPointToCellAvgDynamic : public BenchPointToCellAvg<Value> {
|
||||
struct BenchPointToCellAvgDynamic : public BenchPointToCellAvg<Value>
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
@ -336,9 +323,7 @@ private:
|
||||
Timer timer;
|
||||
|
||||
vtkm::worklet::DispatcherMapTopology<AveragePointToCell> dispatcher;
|
||||
dispatcher.Invoke( dinput,
|
||||
cellSet,
|
||||
result);
|
||||
dispatcher.Invoke(dinput, cellSet, result);
|
||||
//result.SyncControlArray();
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
@ -351,7 +336,8 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(PointToCellAvgDynamic, BenchPointToCellAvgDynamic);
|
||||
|
||||
template <typename Value>
|
||||
struct BenchClassification {
|
||||
struct BenchClassification
|
||||
{
|
||||
std::vector<Value> input;
|
||||
vtkm::cont::ArrayHandle<Value, StorageTag> InputHandle;
|
||||
Value IsoValue;
|
||||
@ -360,8 +346,7 @@ private:
|
||||
VTKM_CONT
|
||||
BenchClassification()
|
||||
{
|
||||
NumberGenerator<Value> generator(static_cast<Value>(1.0),
|
||||
static_cast<Value>(100.0));
|
||||
NumberGenerator<Value> generator(static_cast<Value>(1.0), static_cast<Value>(100.0));
|
||||
|
||||
this->DomainSize = (CUBE_SIZE) * (CUBE_SIZE) * (CUBE_SIZE);
|
||||
this->input.resize(DomainSize);
|
||||
@ -386,9 +371,7 @@ private:
|
||||
|
||||
Classification<Value> worklet(this->IsoValue);
|
||||
vtkm::worklet::DispatcherMapTopology<Classification<Value>> dispatcher(worklet);
|
||||
dispatcher.Invoke( dinput,
|
||||
cellSet,
|
||||
result);
|
||||
dispatcher.Invoke(dinput, cellSet, result);
|
||||
//result.SyncControlArray();
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
@ -397,7 +380,8 @@ private:
|
||||
virtual std::string Type() const { return std::string("Static"); }
|
||||
|
||||
VTKM_CONT
|
||||
std::string Description() const {
|
||||
std::string Description() const
|
||||
{
|
||||
|
||||
std::stringstream description;
|
||||
description << "Computing Marching Cubes Classification "
|
||||
@ -408,7 +392,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct BenchClassificationDynamic : public BenchClassification<Value> {
|
||||
struct BenchClassificationDynamic : public BenchClassification<Value>
|
||||
{
|
||||
VTKM_CONT
|
||||
vtkm::Float64 operator()()
|
||||
{
|
||||
@ -420,9 +405,7 @@ private:
|
||||
|
||||
Classification<Value> worklet(this->IsoValue);
|
||||
vtkm::worklet::DispatcherMapTopology<Classification<Value>> dispatcher(worklet);
|
||||
dispatcher.Invoke( this->InputHandle,
|
||||
cellSet,
|
||||
result);
|
||||
dispatcher.Invoke(this->InputHandle, cellSet, result);
|
||||
//result.SyncControlArray();
|
||||
|
||||
return timer.GetElapsedTime();
|
||||
@ -435,23 +418,26 @@ private:
|
||||
VTKM_MAKE_BENCHMARK(ClassificationDynamic, BenchClassificationDynamic);
|
||||
|
||||
public:
|
||||
|
||||
static VTKM_CONT int Run(int benchmarks){
|
||||
static VTKM_CONT int Run(int benchmarks)
|
||||
{
|
||||
std::cout << DIVIDER << "\nRunning Topology Algorithm benchmarks\n";
|
||||
|
||||
if (benchmarks & CELL_TO_POINT) {
|
||||
if (benchmarks & CELL_TO_POINT)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Cell To Point Average\n";
|
||||
VTKM_RUN_BENCHMARK(CellToPointAvg, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(CellToPointAvgDynamic, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & POINT_TO_CELL){
|
||||
if (benchmarks & POINT_TO_CELL)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Point to Cell Average\n";
|
||||
VTKM_RUN_BENCHMARK(PointToCellAvg, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(PointToCellAvgDynamic, ValueTypes());
|
||||
}
|
||||
|
||||
if (benchmarks & MC_CLASSIFY){
|
||||
if (benchmarks & MC_CLASSIFY)
|
||||
{
|
||||
std::cout << DIVIDER << "\nBenchmarking Hex/Voxel MC Classification\n";
|
||||
VTKM_RUN_BENCHMARK(Classification, ValueTypes());
|
||||
VTKM_RUN_BENCHMARK(ClassificationDynamic, ValueTypes());
|
||||
@ -461,20 +447,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#undef ARRAY_SIZE
|
||||
|
||||
}
|
||||
} // namespace vtkm::benchmarking
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int benchmarks = 0;
|
||||
if (argc < 2){
|
||||
if (argc < 2)
|
||||
{
|
||||
benchmarks = vtkm::benchmarking::ALL;
|
||||
}
|
||||
else {
|
||||
for (int i = 1; i < argc; ++i){
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::string arg = argv[i];
|
||||
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower);
|
||||
if (arg == "celltopoint")
|
||||
@ -489,7 +476,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
benchmarks |= vtkm::benchmarking::MC_CLASSIFY;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
std::cout << "Unrecognized benchmark: " << argv[i] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@ -497,6 +485,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
//now actually execute the benchmarks
|
||||
return vtkm::benchmarking::BenchmarkTopologyAlgorithms
|
||||
<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Run(benchmarks);
|
||||
return vtkm::benchmarking::BenchmarkTopologyAlgorithms<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::Run(
|
||||
benchmarks);
|
||||
}
|
||||
|
@ -88,10 +88,11 @@
|
||||
* pass any extra arguments needed by your benchmark
|
||||
*/
|
||||
#define VTKM_MAKE_BENCHMARK(Name, Bench, ...) \
|
||||
struct MakeBench##Name { \
|
||||
struct MakeBench##Name \
|
||||
{ \
|
||||
template <typename Value> \
|
||||
VTKM_CONT \
|
||||
Bench<Value> operator()(const Value vtkmNotUsed(v)) const { \
|
||||
VTKM_CONT Bench<Value> operator()(const Value vtkmNotUsed(v)) const \
|
||||
{ \
|
||||
return Bench<Value>(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
@ -104,17 +105,23 @@
|
||||
#define VTKM_RUN_BENCHMARK(Name, Types) \
|
||||
vtkm::benchmarking::BenchmarkTypes(MakeBench##Name(), (Types))
|
||||
|
||||
namespace vtkm {
|
||||
namespace benchmarking {
|
||||
namespace stats {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace benchmarking
|
||||
{
|
||||
namespace stats
|
||||
{
|
||||
// Checks that the sequence is sorted, returns true if it's sorted, false
|
||||
// otherwise
|
||||
template <typename ForwardIt>
|
||||
bool is_sorted(ForwardIt first, ForwardIt last){
|
||||
bool is_sorted(ForwardIt first, ForwardIt last)
|
||||
{
|
||||
ForwardIt next = first;
|
||||
++next;
|
||||
for (; next != last; ++next, ++first){
|
||||
if (*first > *next){
|
||||
for (; next != last; ++next, ++first)
|
||||
{
|
||||
if (*first > *next)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -123,16 +130,19 @@ bool is_sorted(ForwardIt first, ForwardIt last){
|
||||
|
||||
// Get the value representing the `percent` percentile of the
|
||||
// sorted samples using linear interpolation
|
||||
vtkm::Float64 PercentileValue(const std::vector<vtkm::Float64> &samples, const vtkm::Float64 percent){
|
||||
vtkm::Float64 PercentileValue(const std::vector<vtkm::Float64>& samples,
|
||||
const vtkm::Float64 percent)
|
||||
{
|
||||
VTKM_ASSERT(!samples.empty());
|
||||
if (samples.size() == 1){
|
||||
if (samples.size() == 1)
|
||||
{
|
||||
return samples.front();
|
||||
}
|
||||
VTKM_ASSERT(percent >= 0.0);
|
||||
VTKM_ASSERT(percent <= 100.0);
|
||||
VTKM_ASSERT(
|
||||
vtkm::benchmarking::stats::is_sorted(samples.begin(), samples.end()));
|
||||
if (percent == 100.0){
|
||||
VTKM_ASSERT(vtkm::benchmarking::stats::is_sorted(samples.begin(), samples.end()));
|
||||
if (percent == 100.0)
|
||||
{
|
||||
return samples.back();
|
||||
}
|
||||
// Find the two nearest percentile values and linearly
|
||||
@ -149,45 +159,56 @@ vtkm::Float64 PercentileValue(const std::vector<vtkm::Float64> &samples, const v
|
||||
// Will replace all samples below `percent` and above 100 - `percent` percentiles
|
||||
// with the value at the percentile
|
||||
// NOTE: Assumes the samples have been sorted, as we make use of PercentileValue
|
||||
void Winsorize(std::vector<vtkm::Float64> &samples, const vtkm::Float64 percent){
|
||||
void Winsorize(std::vector<vtkm::Float64>& samples, const vtkm::Float64 percent)
|
||||
{
|
||||
const vtkm::Float64 low_percentile = PercentileValue(samples, percent);
|
||||
const vtkm::Float64 high_percentile = PercentileValue(samples, 100.0 - percent);
|
||||
for (std::vector<vtkm::Float64>::iterator it = samples.begin(); it != samples.end(); ++it){
|
||||
if (*it < low_percentile){
|
||||
for (std::vector<vtkm::Float64>::iterator it = samples.begin(); it != samples.end(); ++it)
|
||||
{
|
||||
if (*it < low_percentile)
|
||||
{
|
||||
*it = low_percentile;
|
||||
}
|
||||
else if (*it > high_percentile){
|
||||
else if (*it > high_percentile)
|
||||
{
|
||||
*it = high_percentile;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Compute the mean value of the dataset
|
||||
vtkm::Float64 Mean(const std::vector<vtkm::Float64> &samples){
|
||||
vtkm::Float64 Mean(const std::vector<vtkm::Float64>& samples)
|
||||
{
|
||||
vtkm::Float64 mean = 0;
|
||||
for (std::vector<vtkm::Float64>::const_iterator it = samples.begin(); it != samples.end(); ++it){
|
||||
for (std::vector<vtkm::Float64>::const_iterator it = samples.begin(); it != samples.end(); ++it)
|
||||
{
|
||||
mean += *it;
|
||||
}
|
||||
return mean / static_cast<vtkm::Float64>(samples.size());
|
||||
}
|
||||
// Compute the sample variance of the samples
|
||||
vtkm::Float64 Variance(const std::vector<vtkm::Float64> &samples){
|
||||
vtkm::Float64 Variance(const std::vector<vtkm::Float64>& samples)
|
||||
{
|
||||
vtkm::Float64 mean = Mean(samples);
|
||||
vtkm::Float64 square_deviations = 0;
|
||||
for (std::vector<vtkm::Float64>::const_iterator it = samples.begin(); it != samples.end(); ++it){
|
||||
for (std::vector<vtkm::Float64>::const_iterator it = samples.begin(); it != samples.end(); ++it)
|
||||
{
|
||||
square_deviations += vtkm::Pow(*it - mean, 2.0);
|
||||
}
|
||||
return square_deviations / (static_cast<vtkm::Float64>(samples.size()) - 1.0);
|
||||
}
|
||||
// Compute the standard deviation of the samples
|
||||
vtkm::Float64 StandardDeviation(const std::vector<vtkm::Float64> &samples){
|
||||
vtkm::Float64 StandardDeviation(const std::vector<vtkm::Float64>& samples)
|
||||
{
|
||||
return vtkm::Sqrt(Variance(samples));
|
||||
}
|
||||
// Compute the median absolute deviation of the dataset
|
||||
vtkm::Float64 MedianAbsDeviation(const std::vector<vtkm::Float64> &samples){
|
||||
vtkm::Float64 MedianAbsDeviation(const std::vector<vtkm::Float64>& samples)
|
||||
{
|
||||
std::vector<vtkm::Float64> abs_deviations;
|
||||
abs_deviations.reserve(samples.size());
|
||||
const vtkm::Float64 median = PercentileValue(samples, 50.0);
|
||||
for (std::vector<vtkm::Float64>::const_iterator it = samples.begin(); it != samples.end(); ++it){
|
||||
for (std::vector<vtkm::Float64>::const_iterator it = samples.begin(); it != samples.end(); ++it)
|
||||
{
|
||||
abs_deviations.push_back(vtkm::Abs(*it - median));
|
||||
}
|
||||
std::sort(abs_deviations.begin(), abs_deviations.end());
|
||||
@ -202,15 +223,20 @@ vtkm::Float64 MedianAbsDeviation(const std::vector<vtkm::Float64> &samples){
|
||||
* in seconds, this lets us avoid including any per-run setup time in the benchmark.
|
||||
* However any one-time setup should be done in the functor's constructor
|
||||
*/
|
||||
struct Benchmarker {
|
||||
struct Benchmarker
|
||||
{
|
||||
const vtkm::Float64 MAX_RUNTIME;
|
||||
const size_t MAX_ITERATIONS;
|
||||
|
||||
Benchmarker() : MAX_RUNTIME(30), MAX_ITERATIONS(500){}
|
||||
Benchmarker()
|
||||
: MAX_RUNTIME(30)
|
||||
, MAX_ITERATIONS(500)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Functor>
|
||||
VTKM_CONT
|
||||
void operator()(Functor func) const {
|
||||
VTKM_CONT void operator()(Functor func) const
|
||||
{
|
||||
std::vector<vtkm::Float64> samples;
|
||||
// Do a warm-up run. If the benchmark allocates any additional memory
|
||||
// eg. storage for output results, this will let it do that and
|
||||
@ -230,8 +256,7 @@ struct Benchmarker {
|
||||
}
|
||||
std::sort(samples.begin(), samples.end());
|
||||
stats::Winsorize(samples, 5.0);
|
||||
std::cout << "Benchmark \'"
|
||||
<< func.Description() << "\' results:\n"
|
||||
std::cout << "Benchmark \'" << func.Description() << "\' results:\n"
|
||||
<< "\tmedian = " << stats::PercentileValue(samples, 50.0) << "s\n"
|
||||
<< "\tmedian abs dev = " << stats::MedianAbsDeviation(samples) << "s\n"
|
||||
<< "\tmean = " << stats::Mean(samples) << "s\n"
|
||||
@ -242,32 +267,32 @@ struct Benchmarker {
|
||||
};
|
||||
|
||||
template <typename MakerFunctor>
|
||||
class InternalPrintTypeAndBench {
|
||||
class InternalPrintTypeAndBench
|
||||
{
|
||||
MakerFunctor Maker;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
InternalPrintTypeAndBench(MakerFunctor maker) : Maker(maker) {}
|
||||
InternalPrintTypeAndBench(MakerFunctor maker)
|
||||
: Maker(maker)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
void operator()(T t) const {
|
||||
std::cout << "*** "
|
||||
<< vtkm::testing::TypeName<T>::Name()
|
||||
<< " ***************" << std::endl;
|
||||
VTKM_CONT void operator()(T t) const
|
||||
{
|
||||
std::cout << "*** " << vtkm::testing::TypeName<T>::Name() << " ***************" << std::endl;
|
||||
Benchmarker bench;
|
||||
bench(Maker(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <class MakerFunctor, class TypeList>
|
||||
VTKM_CONT
|
||||
void BenchmarkTypes(const MakerFunctor &maker, TypeList){
|
||||
VTKM_CONT void BenchmarkTypes(const MakerFunctor& maker, TypeList)
|
||||
{
|
||||
vtkm::ListForEach(InternalPrintTypeAndBench<MakerFunctor>(maker), TypeList());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -23,10 +23,14 @@
|
||||
|
||||
#ifdef VTKM_MSVC
|
||||
#define _VTKM_SHARED_PTR_INSTANTIATE(Type) \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<Type, vtkm::cont::StorageTagBasic>::InternalStruct >; \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Vec<Type, 2>, vtkm::cont::StorageTagBasic>::InternalStruct >; \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Vec<Type, 3>, vtkm::cont::StorageTagBasic>::InternalStruct >; \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Vec<Type, 4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
|
||||
template class VTKM_CONT_EXPORT \
|
||||
std::shared_ptr<vtkm::cont::ArrayHandle<Type, vtkm::cont::StorageTagBasic>::InternalStruct>; \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< \
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Type, 2>, vtkm::cont::StorageTagBasic>::InternalStruct>; \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< \
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Type, 3>, vtkm::cont::StorageTagBasic>::InternalStruct>; \
|
||||
template class VTKM_CONT_EXPORT std::shared_ptr< \
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Type, 4>, vtkm::cont::StorageTagBasic>::InternalStruct>;
|
||||
|
||||
_VTKM_SHARED_PTR_INSTANTIATE(char)
|
||||
_VTKM_SHARED_PTR_INSTANTIATE(vtkm::Int8)
|
||||
@ -43,19 +47,25 @@ _VTKM_SHARED_PTR_INSTANTIATE(vtkm::Float64)
|
||||
#undef _VTKM_SHARED_PTR_INSTANTIATE
|
||||
#endif // VTKM_MSVC
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
#define _VTKM_ARRAYHANDLE_INSTANTIATE(Type) \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<Type, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
namespace internal { \
|
||||
namespace internal \
|
||||
{ \
|
||||
template class VTKM_CONT_EXPORT ArrayHandleExecutionManagerBase<Type, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
template class VTKM_CONT_EXPORT ArrayPortalFromIterators<Type*>; \
|
||||
template class VTKM_CONT_EXPORT ArrayPortalFromIterators<vtkm::Vec<Type, 2>*>; \
|
||||
template class VTKM_CONT_EXPORT ArrayPortalFromIterators<vtkm::Vec<Type, 3>*>; \
|
||||
@ -75,6 +85,5 @@ _VTKM_ARRAYHANDLE_INSTANTIATE(vtkm::Float32)
|
||||
_VTKM_ARRAYHANDLE_INSTANTIATE(vtkm::Float64)
|
||||
|
||||
#undef _VTKM_ARRAYHANDLE_INSTANTIATE
|
||||
|
||||
}
|
||||
} // end vtkm::cont
|
||||
|
@ -38,11 +38,13 @@
|
||||
#include <vtkm/cont/internal/ArrayHandleExecutionManager.h>
|
||||
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// \brief Base class of all ArrayHandle classes.
|
||||
///
|
||||
@ -50,7 +52,9 @@ namespace internal {
|
||||
/// ArrayHandle class (or at least something that behaves exactly like one).
|
||||
/// The \c ArrayHandle template class inherits from this.
|
||||
///
|
||||
class VTKM_CONT_EXPORT ArrayHandleBase { };
|
||||
class VTKM_CONT_EXPORT ArrayHandleBase
|
||||
{
|
||||
};
|
||||
|
||||
/// Checks to see if the given type and storage can form a valid array handle
|
||||
/// (some storage objects cannot support all types). This check is compatible
|
||||
@ -59,13 +63,13 @@ class VTKM_CONT_EXPORT ArrayHandleBase { };
|
||||
/// Both of these have a typedef named value with the respective boolean value.
|
||||
///
|
||||
template <typename T, typename StorageTag>
|
||||
struct IsValidArrayHandle {
|
||||
struct IsValidArrayHandle
|
||||
{
|
||||
//need to add the not
|
||||
using type = std::integral_constant<bool,
|
||||
!( std::is_base_of<
|
||||
vtkm::cont::internal::UndefinedStorage,
|
||||
vtkm::cont::internal::Storage<T,StorageTag>
|
||||
>::value)>;
|
||||
using type =
|
||||
std::integral_constant<bool,
|
||||
!(std::is_base_of<vtkm::cont::internal::UndefinedStorage,
|
||||
vtkm::cont::internal::Storage<T, StorageTag>>::value)>;
|
||||
};
|
||||
|
||||
/// Checks to see if the ArrayHandle for the given DeviceAdatper allows
|
||||
@ -76,7 +80,8 @@ struct IsValidArrayHandle {
|
||||
/// Both of these have a typedef named value with the respective boolean value.
|
||||
///
|
||||
template <typename ArrayHandle, typename DeviceAdapterTag>
|
||||
struct IsWriteableArrayHandle {
|
||||
struct IsWriteableArrayHandle
|
||||
{
|
||||
private:
|
||||
template <typename T>
|
||||
using ExecutionTypes = typename ArrayHandle::template ExecutionTypes<T>;
|
||||
@ -87,6 +92,7 @@ private:
|
||||
//will have a value type of void*, which is what we are trying to detect
|
||||
using RawValueType = typename std::remove_pointer<ValueType>::type;
|
||||
using IsVoidType = std::is_void<RawValueType>;
|
||||
|
||||
public:
|
||||
using type = std::integral_constant<bool, !IsVoidType::value>;
|
||||
};
|
||||
@ -106,8 +112,7 @@ public:
|
||||
template <typename T>
|
||||
struct ArrayHandleCheck
|
||||
{
|
||||
using type = typename std::is_base_of<
|
||||
::vtkm::cont::internal::ArrayHandleBase, T>::type;
|
||||
using type = typename std::is_base_of<::vtkm::cont::internal::ArrayHandleBase, T>::type;
|
||||
};
|
||||
|
||||
#define VTKM_IS_ARRAY_HANDLE(T) \
|
||||
@ -115,9 +120,11 @@ struct ArrayHandleCheck
|
||||
|
||||
} // namespace internal
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename T> struct GetTypeInParentheses;
|
||||
template <typename T>
|
||||
struct GetTypeInParentheses;
|
||||
template <typename T>
|
||||
struct GetTypeInParentheses<void(T)>
|
||||
{
|
||||
@ -134,13 +141,23 @@ struct GetTypeInParentheses<void(T)>
|
||||
VTKM_IS_ARRAY_HANDLE(Superclass); \
|
||||
\
|
||||
VTKM_CONT \
|
||||
classname() : Superclass() { } \
|
||||
classname() \
|
||||
: Superclass() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
VTKM_CONT \
|
||||
classname(const Thisclass &src) : Superclass(src) { } \
|
||||
classname(const Thisclass& src) \
|
||||
: Superclass(src) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
VTKM_CONT \
|
||||
classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, typename__ Superclass::StorageTag> &src) : Superclass(src) { } \
|
||||
classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
|
||||
typename__ Superclass::StorageTag>& src) \
|
||||
: Superclass(src) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
VTKM_CONT \
|
||||
Thisclass& operator=(const Thisclass& src) \
|
||||
@ -220,14 +237,13 @@ struct GetTypeInParentheses<void(T)>
|
||||
/// allocated memory is released.
|
||||
///
|
||||
///
|
||||
template<
|
||||
typename T,
|
||||
typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
|
||||
template <typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
|
||||
class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase<T, StorageTag_>
|
||||
ExecutionManagerType;
|
||||
|
||||
public:
|
||||
typedef vtkm::cont::internal::Storage<T, StorageTag_> StorageType;
|
||||
typedef T ValueType;
|
||||
@ -237,10 +253,9 @@ public:
|
||||
template <typename DeviceAdapterTag>
|
||||
struct ExecutionTypes
|
||||
{
|
||||
typedef typename ExecutionManagerType
|
||||
::template ExecutionTypes<DeviceAdapterTag>::Portal Portal;
|
||||
typedef typename ExecutionManagerType
|
||||
::template ExecutionTypes<DeviceAdapterTag>::PortalConst PortalConst;
|
||||
typedef typename ExecutionManagerType::template ExecutionTypes<DeviceAdapterTag>::Portal Portal;
|
||||
typedef typename ExecutionManagerType::template ExecutionTypes<DeviceAdapterTag>::PortalConst
|
||||
PortalConst;
|
||||
};
|
||||
|
||||
/// Constructs an empty ArrayHandle. Typically used for output or
|
||||
@ -266,7 +281,6 @@ public:
|
||||
///
|
||||
ArrayHandle(vtkm::cont::ArrayHandle<ValueType, StorageTag>&& src);
|
||||
|
||||
|
||||
/// Special constructor for subclass specializations that need to set the
|
||||
/// initial state of the control array. When this constructor is used, it
|
||||
/// is assumed that the control array is valid.
|
||||
@ -285,14 +299,14 @@ public:
|
||||
/// \brief Copies an ArrayHandle
|
||||
///
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<ValueType,StorageTag> &
|
||||
operator=(const vtkm::cont::ArrayHandle<ValueType,StorageTag> &src);
|
||||
vtkm::cont::ArrayHandle<ValueType, StorageTag>& operator=(
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTag>& src);
|
||||
|
||||
/// \brief Move and Assignment of an ArrayHandle
|
||||
///
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<ValueType,StorageTag> &
|
||||
operator=(vtkm::cont::ArrayHandle<ValueType,StorageTag> &&src);
|
||||
vtkm::cont::ArrayHandle<ValueType, StorageTag>& operator=(
|
||||
vtkm::cont::ArrayHandle<ValueType, StorageTag>&& src);
|
||||
|
||||
/// Like a pointer, two \c ArrayHandles are considered equal if they point
|
||||
/// to the same location in memory.
|
||||
@ -385,6 +399,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/// Prepares this array to be used as an input to an operation in the
|
||||
/// execution environment. If necessary, copies data to the execution
|
||||
/// environment. Can throw an exception if this array does not yet contain
|
||||
@ -393,8 +408,8 @@ public:
|
||||
///
|
||||
template <typename DeviceAdapterTag>
|
||||
VTKM_CONT
|
||||
typename ExecutionTypes<DeviceAdapterTag>::PortalConst
|
||||
PrepareForInput(DeviceAdapterTag) const;
|
||||
typename ExecutionTypes<DeviceAdapterTag>::PortalConst PrepareForInput(DeviceAdapterTag) const;
|
||||
// clang-format on
|
||||
|
||||
/// Prepares (allocates) this array to be used as an output from an operation
|
||||
/// in the execution environment. The internal state of this class is set to
|
||||
@ -404,9 +419,8 @@ public:
|
||||
/// execution environment.
|
||||
///
|
||||
template <typename DeviceAdapterTag>
|
||||
VTKM_CONT
|
||||
typename ExecutionTypes<DeviceAdapterTag>::Portal
|
||||
PrepareForOutput(vtkm::Id numberOfValues, DeviceAdapterTag);
|
||||
VTKM_CONT typename ExecutionTypes<DeviceAdapterTag>::Portal PrepareForOutput(
|
||||
vtkm::Id numberOfValues, DeviceAdapterTag);
|
||||
|
||||
/// Prepares this array to be used in an in-place operation (both as input
|
||||
/// and output) in the execution environment. If necessary, copies data to
|
||||
@ -415,9 +429,7 @@ public:
|
||||
/// in the execution environment.
|
||||
///
|
||||
template <typename DeviceAdapterTag>
|
||||
VTKM_CONT
|
||||
typename ExecutionTypes<DeviceAdapterTag>::Portal
|
||||
PrepareForInPlace(DeviceAdapterTag);
|
||||
VTKM_CONT typename ExecutionTypes<DeviceAdapterTag>::Portal PrepareForInPlace(DeviceAdapterTag);
|
||||
|
||||
/// Gets this array handle ready to interact with the given device. If the
|
||||
/// array handle has already interacted with this device, then this method
|
||||
@ -425,8 +437,7 @@ public:
|
||||
/// method is declared const because logically the data does not.
|
||||
///
|
||||
template <typename DeviceAdapterTag>
|
||||
VTKM_CONT
|
||||
void PrepareForDevice(DeviceAdapterTag) const;
|
||||
VTKM_CONT void PrepareForDevice(DeviceAdapterTag) const;
|
||||
|
||||
/// Synchronizes the control array with the execution array. If either the
|
||||
/// user array or control array is already valid, this method does nothing
|
||||
@ -451,16 +462,16 @@ public:
|
||||
StorageType ControlArray;
|
||||
bool ControlArrayValid;
|
||||
|
||||
std::unique_ptr<
|
||||
vtkm::cont::internal::ArrayHandleExecutionManagerBase<
|
||||
ValueType,StorageTag> > ExecutionArray;
|
||||
std::unique_ptr<vtkm::cont::internal::ArrayHandleExecutionManagerBase<ValueType, StorageTag>>
|
||||
ExecutionArray;
|
||||
bool ExecutionArrayValid;
|
||||
};
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandle(const std::shared_ptr<InternalStruct>& i)
|
||||
: Internals(i)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<InternalStruct> Internals;
|
||||
};
|
||||
@ -468,30 +479,23 @@ public:
|
||||
/// A convenience function for creating an ArrayHandle from a standard C array.
|
||||
///
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
make_ArrayHandle(const T *array,
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic> make_ArrayHandle(const T* array,
|
||||
vtkm::Id length)
|
||||
{
|
||||
typedef vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
ArrayHandleType;
|
||||
typedef vtkm::cont::internal::Storage<T, vtkm::cont::StorageTagBasic>
|
||||
StorageType;
|
||||
typedef vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic> ArrayHandleType;
|
||||
typedef vtkm::cont::internal::Storage<T, vtkm::cont::StorageTagBasic> StorageType;
|
||||
return ArrayHandleType(StorageType(array, length));
|
||||
}
|
||||
|
||||
/// A convenience function for creating an ArrayHandle from an std::vector.
|
||||
///
|
||||
template<typename T,
|
||||
typename Allocator>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>
|
||||
make_ArrayHandle(const std::vector<T,Allocator> &array)
|
||||
template <typename T, typename Allocator>
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic> make_ArrayHandle(
|
||||
const std::vector<T, Allocator>& array)
|
||||
{
|
||||
if (!array.empty())
|
||||
{
|
||||
return make_ArrayHandle(&array.front(),
|
||||
static_cast<vtkm::Id>(array.size()));
|
||||
return make_ArrayHandle(&array.front(), static_cast<vtkm::Id>(array.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -500,24 +504,19 @@ make_ArrayHandle(const std::vector<T,Allocator> &array)
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
VTKM_NEVER_EXPORT
|
||||
VTKM_CONT
|
||||
inline void printSummary_ArrayHandle_Value(const T &value,
|
||||
std::ostream &out,
|
||||
vtkm::VecTraitsTagSingleComponent)
|
||||
VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
|
||||
const T& value, std::ostream& out, vtkm::VecTraitsTagSingleComponent)
|
||||
{
|
||||
out << value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_NEVER_EXPORT
|
||||
VTKM_CONT
|
||||
inline void printSummary_ArrayHandle_Value(const T &value,
|
||||
std::ostream &out,
|
||||
vtkm::VecTraitsTagMultipleComponents)
|
||||
VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
|
||||
const T& value, std::ostream& out, vtkm::VecTraitsTagMultipleComponents)
|
||||
{
|
||||
using Traits = vtkm::VecTraits<T>;
|
||||
using ComponentType = typename Traits::ComponentType;
|
||||
@ -535,8 +534,7 @@ inline void printSummary_ArrayHandle_Value(const T &value,
|
||||
|
||||
VTKM_NEVER_EXPORT
|
||||
VTKM_CONT
|
||||
inline void printSummary_ArrayHandle_Value(UInt8 value,
|
||||
std::ostream &out,
|
||||
inline void printSummary_ArrayHandle_Value(UInt8 value, std::ostream& out,
|
||||
vtkm::VecTraitsTagSingleComponent)
|
||||
{
|
||||
out << static_cast<int>(value);
|
||||
@ -544,29 +542,21 @@ inline void printSummary_ArrayHandle_Value(UInt8 value,
|
||||
|
||||
VTKM_NEVER_EXPORT
|
||||
VTKM_CONT
|
||||
inline void printSummary_ArrayHandle_Value(Int8 value,
|
||||
std::ostream &out,
|
||||
inline void printSummary_ArrayHandle_Value(Int8 value, std::ostream& out,
|
||||
vtkm::VecTraitsTagSingleComponent)
|
||||
{
|
||||
out << static_cast<int>(value);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
VTKM_NEVER_EXPORT
|
||||
VTKM_CONT
|
||||
inline void printSummary_ArrayHandle_Value(const vtkm::Pair<T1,T2> &value,
|
||||
std::ostream &out,
|
||||
vtkm::VecTraitsTagSingleComponent)
|
||||
VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
|
||||
const vtkm::Pair<T1, T2>& value, std::ostream& out, vtkm::VecTraitsTagSingleComponent)
|
||||
{
|
||||
out << "{";
|
||||
printSummary_ArrayHandle_Value(
|
||||
value.first,
|
||||
out,
|
||||
printSummary_ArrayHandle_Value(value.first, out,
|
||||
typename vtkm::VecTraits<T1>::HasMultipleComponents());
|
||||
out << ",";
|
||||
printSummary_ArrayHandle_Value(
|
||||
value.second,
|
||||
out,
|
||||
printSummary_ArrayHandle_Value(value.second, out,
|
||||
typename vtkm::VecTraits<T2>::HasMultipleComponents());
|
||||
out << "}";
|
||||
}
|
||||
@ -574,11 +564,8 @@ inline void printSummary_ArrayHandle_Value(const vtkm::Pair<T1,T2> &value,
|
||||
} // namespace detail
|
||||
|
||||
template <typename T, typename StorageT>
|
||||
VTKM_NEVER_EXPORT
|
||||
VTKM_CONT
|
||||
inline void
|
||||
printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<T,StorageT> &array,
|
||||
std::ostream &out)
|
||||
VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle(
|
||||
const vtkm::cont::ArrayHandle<T, StorageT>& array, std::ostream& out)
|
||||
{
|
||||
using ArrayType = vtkm::cont::ArrayHandle<T, StorageT>;
|
||||
using PortalType = typename ArrayType::PortalConstControl;
|
||||
@ -586,10 +573,8 @@ printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<T,StorageT> &array,
|
||||
|
||||
vtkm::Id sz = array.GetNumberOfValues();
|
||||
|
||||
out << "valueType=" << typeid(T).name()
|
||||
<< " storageType=" << typeid(StorageT).name()
|
||||
<< " numValues=" << sz
|
||||
<< " [";
|
||||
out << "valueType=" << typeid(T).name() << " storageType=" << typeid(StorageT).name()
|
||||
<< " numValues=" << sz << " [";
|
||||
|
||||
PortalType portal = array.GetPortalConstControl();
|
||||
if (sz <= 7)
|
||||
@ -619,7 +604,6 @@ printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<T,StorageT> &array,
|
||||
}
|
||||
out << "]\n";
|
||||
}
|
||||
|
||||
}
|
||||
} //namespace vtkm::cont
|
||||
|
||||
@ -630,10 +614,14 @@ printSummary_ArrayHandle(const vtkm::cont::ArrayHandle<T,StorageT> &array,
|
||||
|
||||
#ifdef VTKM_MSVC
|
||||
#define _VTKM_SHARED_PTR_EXPORT(Type) \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<Type, vtkm::cont::StorageTagBasic>::InternalStruct >; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Vec<Type, 2>, vtkm::cont::StorageTagBasic>::InternalStruct >; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Vec<Type, 3>, vtkm::cont::StorageTagBasic>::InternalStruct >; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< vtkm::cont::ArrayHandle<vtkm::Vec<Type, 4>, vtkm::cont::StorageTagBasic>::InternalStruct >;
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
std::shared_ptr<vtkm::cont::ArrayHandle<Type, vtkm::cont::StorageTagBasic>::InternalStruct>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< \
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Type, 2>, vtkm::cont::StorageTagBasic>::InternalStruct>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< \
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Type, 3>, vtkm::cont::StorageTagBasic>::InternalStruct>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT std::shared_ptr< \
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<Type, 4>, vtkm::cont::StorageTagBasic>::InternalStruct>;
|
||||
|
||||
_VTKM_SHARED_PTR_EXPORT(char)
|
||||
_VTKM_SHARED_PTR_EXPORT(vtkm::Int8)
|
||||
@ -650,19 +638,29 @@ _VTKM_SHARED_PTR_EXPORT(vtkm::Float64)
|
||||
#undef _VTKM_SHARED_PTR_EXPORT
|
||||
#endif // VTKM_MSVC
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
#define _VTKM_ARRAYHANDLE_EXPORT(Type) \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<Type, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
namespace internal { \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleExecutionManagerBase<Type, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandle<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandle<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandle<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
namespace internal \
|
||||
{ \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<Type, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 2>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 3>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT \
|
||||
ArrayHandleExecutionManagerBase<vtkm::Vec<Type, 4>, StorageTagBasic>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayPortalFromIterators<Type*>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayPortalFromIterators<vtkm::Vec<Type, 2>*>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayPortalFromIterators<vtkm::Vec<Type, 3>*>; \
|
||||
@ -682,7 +680,6 @@ _VTKM_ARRAYHANDLE_EXPORT(vtkm::Float32)
|
||||
_VTKM_ARRAYHANDLE_EXPORT(vtkm::Float64)
|
||||
|
||||
#undef _VTKM_ARRAYHANDLE_EXPORT
|
||||
|
||||
}
|
||||
} // end vtkm::cont
|
||||
|
||||
|
@ -18,8 +18,10 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename T, typename S>
|
||||
ArrayHandle<T, S>::ArrayHandle()
|
||||
@ -32,12 +34,14 @@ ArrayHandle<T,S>::ArrayHandle()
|
||||
template <typename T, typename S>
|
||||
ArrayHandle<T, S>::ArrayHandle(const ArrayHandle<T, S>& src)
|
||||
: Internals(src.Internals)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
ArrayHandle<T, S>::ArrayHandle(ArrayHandle<T, S>&& src)
|
||||
: Internals(std::move(src.Internals))
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
ArrayHandle<T, S>::ArrayHandle(const typename ArrayHandle<T, S>::StorageType& storage)
|
||||
@ -54,24 +58,21 @@ ArrayHandle<T,S>::~ArrayHandle()
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
ArrayHandle<T,S>&
|
||||
ArrayHandle<T,S>::operator=(const ArrayHandle<T,S> &src)
|
||||
ArrayHandle<T, S>& ArrayHandle<T, S>::operator=(const ArrayHandle<T, S>& src)
|
||||
{
|
||||
this->Internals = src.Internals;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
ArrayHandle<T,S>&
|
||||
ArrayHandle<T,S>::operator=(ArrayHandle<T,S> &&src)
|
||||
ArrayHandle<T, S>& ArrayHandle<T, S>::operator=(ArrayHandle<T, S>&& src)
|
||||
{
|
||||
this->Internals = std::move(src.Internals);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
typename ArrayHandle<T,S>::StorageType&
|
||||
ArrayHandle<T,S>::GetStorage()
|
||||
typename ArrayHandle<T, S>::StorageType& ArrayHandle<T, S>::GetStorage()
|
||||
{
|
||||
this->SyncControlArray();
|
||||
if (this->Internals->ControlArrayValid)
|
||||
@ -86,8 +87,7 @@ ArrayHandle<T,S>::GetStorage()
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
const typename ArrayHandle<T,S>::StorageType&
|
||||
ArrayHandle<T,S>::GetStorage() const
|
||||
const typename ArrayHandle<T, S>::StorageType& ArrayHandle<T, S>::GetStorage() const
|
||||
{
|
||||
this->SyncControlArray();
|
||||
if (this->Internals->ControlArrayValid)
|
||||
@ -102,8 +102,7 @@ ArrayHandle<T,S>::GetStorage() const
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
typename ArrayHandle<T,S>::PortalControl
|
||||
ArrayHandle<T,S>::GetPortalControl()
|
||||
typename ArrayHandle<T, S>::PortalControl ArrayHandle<T, S>::GetPortalControl()
|
||||
{
|
||||
this->SyncControlArray();
|
||||
if (this->Internals->ControlArrayValid)
|
||||
@ -122,8 +121,7 @@ ArrayHandle<T,S>::GetPortalControl()
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
typename ArrayHandle<T,S>::PortalConstControl
|
||||
ArrayHandle<T,S>::GetPortalConstControl() const
|
||||
typename ArrayHandle<T, S>::PortalConstControl ArrayHandle<T, S>::GetPortalConstControl() const
|
||||
{
|
||||
this->SyncControlArray();
|
||||
if (this->Internals->ControlArrayValid)
|
||||
@ -161,16 +159,13 @@ void ArrayHandle<T,S>::CopyInto(IteratorType dest, DeviceAdapterTag) const
|
||||
using pointer_type = typename std::iterator_traits<IteratorType>::pointer;
|
||||
using value_type = typename std::remove_pointer<pointer_type>::type;
|
||||
|
||||
static_assert( !std::is_const<value_type>::value,
|
||||
"CopyInto requires a non const iterator." );
|
||||
static_assert(!std::is_const<value_type>::value, "CopyInto requires a non const iterator.");
|
||||
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||
|
||||
if (!this->Internals->ControlArrayValid &&
|
||||
!this->Internals->ExecutionArrayValid)
|
||||
if (!this->Internals->ControlArrayValid && !this->Internals->ExecutionArrayValid)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"ArrayHandle has no data to copy into Iterator.");
|
||||
throw vtkm::cont::ErrorBadValue("ArrayHandle has no data to copy into Iterator.");
|
||||
}
|
||||
|
||||
if (!this->Internals->ControlArrayValid &&
|
||||
@ -180,8 +175,8 @@ void ArrayHandle<T,S>::CopyInto(IteratorType dest, DeviceAdapterTag) const
|
||||
/// class and call CopyInto. The dynamic conversion will be sucessful
|
||||
/// becuase the check to ensure the ExecutionArray is of the type
|
||||
/// DeviceAdapterTag has already passed
|
||||
typedef vtkm::cont::internal::ArrayHandleExecutionManager<
|
||||
T, StorageTag, DeviceAdapterTag> ConcreteType;
|
||||
typedef vtkm::cont::internal::ArrayHandleExecutionManager<T, StorageTag, DeviceAdapterTag>
|
||||
ConcreteType;
|
||||
ConcreteType* ConcreteExecutionArray =
|
||||
dynamic_cast<ConcreteType*>(this->Internals->ExecutionArray.get());
|
||||
|
||||
@ -191,8 +186,7 @@ void ArrayHandle<T,S>::CopyInto(IteratorType dest, DeviceAdapterTag) const
|
||||
{
|
||||
PortalConstControl portal = this->GetPortalConstControl();
|
||||
std::copy(vtkm::cont::ArrayPortalToIteratorBegin(portal),
|
||||
vtkm::cont::ArrayPortalToIteratorEnd(portal),
|
||||
dest);
|
||||
vtkm::cont::ArrayPortalToIteratorEnd(portal), dest);
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,8 +216,7 @@ void ArrayHandle<T,S>::Shrink(vtkm::Id numberOfValues)
|
||||
}
|
||||
else // numberOfValues > originalNumberOfValues
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"ArrayHandle::Shrink cannot be used to grow array.");
|
||||
throw vtkm::cont::ErrorBadValue("ArrayHandle::Shrink cannot be used to grow array.");
|
||||
}
|
||||
|
||||
VTKM_ASSERT(this->GetNumberOfValues() == numberOfValues);
|
||||
@ -244,8 +237,7 @@ ArrayHandle<T,S>::PrepareForInput(DeviceAdapterTag) const
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||
|
||||
if (!this->Internals->ControlArrayValid
|
||||
&& !this->Internals->ExecutionArrayValid)
|
||||
if (!this->Internals->ControlArrayValid && !this->Internals->ExecutionArrayValid)
|
||||
{
|
||||
// Want to use an empty array.
|
||||
// Set up ArrayHandle state so this actually works.
|
||||
@ -255,8 +247,8 @@ ArrayHandle<T,S>::PrepareForInput(DeviceAdapterTag) const
|
||||
|
||||
this->PrepareForDevice(DeviceAdapterTag());
|
||||
typename ExecutionTypes<DeviceAdapterTag>::PortalConst portal =
|
||||
this->Internals->ExecutionArray->PrepareForInput(
|
||||
!this->Internals->ExecutionArrayValid, DeviceAdapterTag());
|
||||
this->Internals->ExecutionArray->PrepareForInput(!this->Internals->ExecutionArrayValid,
|
||||
DeviceAdapterTag());
|
||||
|
||||
this->Internals->ExecutionArrayValid = true;
|
||||
|
||||
@ -277,8 +269,7 @@ ArrayHandle<T,S>::PrepareForOutput(vtkm::Id numberOfValues, DeviceAdapterTag)
|
||||
|
||||
this->PrepareForDevice(DeviceAdapterTag());
|
||||
typename ExecutionTypes<DeviceAdapterTag>::Portal portal =
|
||||
this->Internals->ExecutionArray->PrepareForOutput(numberOfValues,
|
||||
DeviceAdapterTag());
|
||||
this->Internals->ExecutionArray->PrepareForOutput(numberOfValues, DeviceAdapterTag());
|
||||
|
||||
// We are assuming that the calling code will fill the array using the
|
||||
// iterators we are returning, so go ahead and mark the execution array as
|
||||
@ -301,8 +292,7 @@ ArrayHandle<T,S>::PrepareForInPlace(DeviceAdapterTag)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||
|
||||
if (!this->Internals->ControlArrayValid
|
||||
&& !this->Internals->ExecutionArrayValid)
|
||||
if (!this->Internals->ControlArrayValid && !this->Internals->ExecutionArrayValid)
|
||||
{
|
||||
// Want to use an empty array.
|
||||
// Set up ArrayHandle state so this actually works.
|
||||
@ -312,8 +302,8 @@ ArrayHandle<T,S>::PrepareForInPlace(DeviceAdapterTag)
|
||||
|
||||
this->PrepareForDevice(DeviceAdapterTag());
|
||||
typename ExecutionTypes<DeviceAdapterTag>::Portal portal =
|
||||
this->Internals->ExecutionArray->PrepareForInPlace(
|
||||
!this->Internals->ExecutionArrayValid, DeviceAdapterTag());
|
||||
this->Internals->ExecutionArray->PrepareForInPlace(!this->Internals->ExecutionArrayValid,
|
||||
DeviceAdapterTag());
|
||||
|
||||
this->Internals->ExecutionArrayValid = true;
|
||||
|
||||
@ -347,8 +337,7 @@ void ArrayHandle<T,S>::PrepareForDevice(DeviceAdapterTag) const
|
||||
this->SyncControlArray();
|
||||
// Need to change some state that does not change the logical state from
|
||||
// an external point of view.
|
||||
InternalStruct *internals
|
||||
= const_cast<InternalStruct*>(this->Internals.get());
|
||||
InternalStruct* internals = const_cast<InternalStruct*>(this->Internals.get());
|
||||
internals->ExecutionArray.reset();
|
||||
internals->ExecutionArrayValid = false;
|
||||
}
|
||||
@ -358,14 +347,12 @@ void ArrayHandle<T,S>::PrepareForDevice(DeviceAdapterTag) const
|
||||
VTKM_ASSERT(!this->Internals->ExecutionArrayValid);
|
||||
// Need to change some state that does not change the logical state from
|
||||
// an external point of view.
|
||||
InternalStruct *internals
|
||||
= const_cast<InternalStruct*>(this->Internals.get());
|
||||
InternalStruct* internals = const_cast<InternalStruct*>(this->Internals.get());
|
||||
internals->ExecutionArray.reset(
|
||||
new vtkm::cont::internal::ArrayHandleExecutionManager<
|
||||
T, StorageTag, DeviceAdapterTag>(&internals->ControlArray));
|
||||
new vtkm::cont::internal::ArrayHandleExecutionManager<T, StorageTag, DeviceAdapterTag>(
|
||||
&internals->ControlArray));
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename S>
|
||||
void ArrayHandle<T, S>::SyncControlArray() const
|
||||
{
|
||||
@ -373,8 +360,7 @@ void ArrayHandle<T,S>::SyncControlArray() const
|
||||
{
|
||||
// Need to change some state that does not change the logical state from
|
||||
// an external point of view.
|
||||
InternalStruct *internals
|
||||
= const_cast<InternalStruct*>(this->Internals.get());
|
||||
InternalStruct* internals = const_cast<InternalStruct*>(this->Internals.get());
|
||||
if (this->Internals->ExecutionArrayValid)
|
||||
{
|
||||
internals->ExecutionArray->RetrieveOutputData(&internals->ControlArray);
|
||||
@ -390,7 +376,5 @@ void ArrayHandle<T,S>::SyncControlArray() const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,15 +25,16 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ErrorBadAllocation.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// \brief An array portal that acts as a 3D cartesian product of 3 arrays.
|
||||
///
|
||||
template<typename ValueType_,
|
||||
typename PortalTypeFirst_,
|
||||
typename PortalTypeSecond_,
|
||||
template <typename ValueType_, typename PortalTypeFirst_, typename PortalTypeSecond_,
|
||||
typename PortalTypeThird_>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalCartesianProduct
|
||||
{
|
||||
@ -47,15 +48,21 @@ public:
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalCartesianProduct()
|
||||
: PortalFirst(), PortalSecond(), PortalThird()
|
||||
{ } //needs to be host and device so that cuda can create lvalue of these
|
||||
: PortalFirst()
|
||||
, PortalSecond()
|
||||
, PortalThird()
|
||||
{
|
||||
} //needs to be host and device so that cuda can create lvalue of these
|
||||
|
||||
VTKM_CONT
|
||||
ArrayPortalCartesianProduct(const PortalTypeFirst& portalfirst,
|
||||
const PortalTypeSecond& portalsecond,
|
||||
const PortalTypeThird& portalthird)
|
||||
: PortalFirst(portalfirst), PortalSecond(portalsecond), PortalThird(portalthird)
|
||||
{ }
|
||||
: PortalFirst(portalfirst)
|
||||
, PortalSecond(portalsecond)
|
||||
, PortalThird(portalthird)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalCartesianProduct with an iterator
|
||||
/// type that can be copied to this iterator type. This allows us to do any
|
||||
@ -63,20 +70,19 @@ public:
|
||||
///
|
||||
|
||||
template <class OtherV, class OtherP1, class OtherP2, class OtherP3>
|
||||
VTKM_CONT
|
||||
ArrayPortalCartesianProduct(const ArrayPortalCartesianProduct<OtherV,OtherP1,OtherP2,OtherP3> &src)
|
||||
: PortalFirst(src.GetPortalFirst()),
|
||||
PortalSecond(src.GetPortalSecond()),
|
||||
PortalThird(src.GetPortalThird())
|
||||
{ }
|
||||
|
||||
VTKM_CONT ArrayPortalCartesianProduct(
|
||||
const ArrayPortalCartesianProduct<OtherV, OtherP1, OtherP2, OtherP3>& src)
|
||||
: PortalFirst(src.GetPortalFirst())
|
||||
, PortalSecond(src.GetPortalSecond())
|
||||
, PortalThird(src.GetPortalThird())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->PortalFirst.GetNumberOfValues() *
|
||||
this->PortalSecond.GetNumberOfValues() *
|
||||
return this->PortalFirst.GetNumberOfValues() * this->PortalSecond.GetNumberOfValues() *
|
||||
this->PortalThird.GetNumberOfValues();
|
||||
}
|
||||
|
||||
@ -95,8 +101,7 @@ public:
|
||||
vtkm::Id i2 = idx12 / dim1;
|
||||
vtkm::Id i3 = index / dim12;
|
||||
|
||||
return vtkm::make_Vec(this->PortalFirst.Get(i1),
|
||||
this->PortalSecond.Get(i2),
|
||||
return vtkm::make_Vec(this->PortalFirst.Get(i1), this->PortalSecond.Get(i2),
|
||||
this->PortalThird.Get(i3));
|
||||
}
|
||||
|
||||
@ -133,31 +138,34 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
const PortalTypeThird& GetThirdPortal() const { return this->PortalThird; }
|
||||
|
||||
|
||||
private:
|
||||
PortalTypeFirst PortalFirst;
|
||||
PortalTypeSecond PortalSecond;
|
||||
PortalTypeThird PortalThird;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::internal
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagCartesianProduct { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagCartesianProduct
|
||||
{
|
||||
};
|
||||
|
||||
/// This helper struct defines the value type for a zip container containing
|
||||
/// the given two array handles.
|
||||
///
|
||||
template <typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType>
|
||||
struct ArrayHandleCartesianProductTraits {
|
||||
struct ArrayHandleCartesianProductTraits
|
||||
{
|
||||
/// The ValueType (a pair containing the value types of the two arrays).
|
||||
///
|
||||
typedef vtkm::Vec<typename FirstHandleType::ValueType, 3> ValueType;
|
||||
@ -171,7 +179,6 @@ struct ArrayHandleCartesianProductTraits {
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, Tag> Superclass;
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType>
|
||||
class Storage<T, StorageTagCartesianProduct<FirstHandleType, SecondHandleType, ThirdHandleType>>
|
||||
{
|
||||
@ -182,31 +189,36 @@ class Storage<T, StorageTagCartesianProduct<FirstHandleType, SecondHandleType, T
|
||||
public:
|
||||
typedef T ValueType;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalCartesianProduct< ValueType,
|
||||
typename FirstHandleType::PortalControl,
|
||||
typename SecondHandleType::PortalControl,
|
||||
typename ThirdHandleType::PortalControl> PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalCartesianProduct< ValueType,
|
||||
typename FirstHandleType::PortalConstControl,
|
||||
typename SecondHandleType::PortalConstControl,
|
||||
typename ThirdHandleType::PortalConstControl>
|
||||
typedef vtkm::exec::internal::ArrayPortalCartesianProduct<
|
||||
ValueType, typename FirstHandleType::PortalControl, typename SecondHandleType::PortalControl,
|
||||
typename ThirdHandleType::PortalControl>
|
||||
PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalCartesianProduct<
|
||||
ValueType, typename FirstHandleType::PortalConstControl,
|
||||
typename SecondHandleType::PortalConstControl, typename ThirdHandleType::PortalConstControl>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : FirstArray(), SecondArray(), ThirdArray() { }
|
||||
Storage()
|
||||
: FirstArray()
|
||||
, SecondArray()
|
||||
, ThirdArray()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const FirstHandleType &array1, const SecondHandleType &array2, const ThirdHandleType &array3)
|
||||
: FirstArray(array1), SecondArray(array2), ThirdArray(array3)
|
||||
Storage(const FirstHandleType& array1, const SecondHandleType& array2,
|
||||
const ThirdHandleType& array3)
|
||||
: FirstArray(array1)
|
||||
, SecondArray(array2)
|
||||
, ThirdArray(array3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal()
|
||||
{
|
||||
return PortalType(this->FirstArray.GetPortalControl(),
|
||||
this->SecondArray.GetPortalControl(),
|
||||
return PortalType(this->FirstArray.GetPortalControl(), this->SecondArray.GetPortalControl(),
|
||||
this->ThirdArray.GetPortalControl());
|
||||
}
|
||||
|
||||
@ -221,8 +233,7 @@ public:
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->FirstArray.GetNumberOfValues() *
|
||||
this->SecondArray.GetNumberOfValues() *
|
||||
return this->FirstArray.GetNumberOfValues() * this->SecondArray.GetNumberOfValues() *
|
||||
this->ThirdArray.GetNumberOfValues();
|
||||
}
|
||||
|
||||
@ -246,22 +257,13 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const FirstHandleType &GetFirstArray() const
|
||||
{
|
||||
return this->FirstArray;
|
||||
}
|
||||
const FirstHandleType& GetFirstArray() const { return this->FirstArray; }
|
||||
|
||||
VTKM_CONT
|
||||
const SecondHandleType &GetSecondArray() const
|
||||
{
|
||||
return this->SecondArray;
|
||||
}
|
||||
const SecondHandleType& GetSecondArray() const { return this->SecondArray; }
|
||||
|
||||
VTKM_CONT
|
||||
const ThirdHandleType &GetThirdArray() const
|
||||
{
|
||||
return this->ThirdArray;
|
||||
}
|
||||
const ThirdHandleType& GetThirdArray() const { return this->ThirdArray; }
|
||||
|
||||
private:
|
||||
FirstHandleType FirstArray;
|
||||
@ -269,10 +271,7 @@ private:
|
||||
ThirdHandleType ThirdArray;
|
||||
};
|
||||
|
||||
template<typename T,
|
||||
typename FirstHandleType,
|
||||
typename SecondHandleType,
|
||||
typename ThirdHandleType,
|
||||
template <typename T, typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType,
|
||||
typename Device>
|
||||
class ArrayTransfer<
|
||||
T, StorageTagCartesianProduct<FirstHandleType, SecondHandleType, ThirdHandleType>, Device>
|
||||
@ -287,38 +286,35 @@ public:
|
||||
typedef typename StorageType::PortalConstType PortalConstControl;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalCartesianProduct<
|
||||
ValueType,
|
||||
typename FirstHandleType::template ExecutionTypes<Device>::Portal,
|
||||
ValueType, typename FirstHandleType::template ExecutionTypes<Device>::Portal,
|
||||
typename SecondHandleType::template ExecutionTypes<Device>::Portal,
|
||||
typename ThirdHandleType::template ExecutionTypes<Device>::Portal
|
||||
> PortalExecution;
|
||||
typename ThirdHandleType::template ExecutionTypes<Device>::Portal>
|
||||
PortalExecution;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalCartesianProduct<
|
||||
ValueType,
|
||||
typename FirstHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
ValueType, typename FirstHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
typename SecondHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
typename ThirdHandleType::template ExecutionTypes<Device>::PortalConst
|
||||
> PortalConstExecution;
|
||||
typename ThirdHandleType::template ExecutionTypes<Device>::PortalConst>
|
||||
PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: FirstArray(storage->GetFirstArray()),
|
||||
SecondArray(storage->GetSecondArray()),
|
||||
ThirdArray(storage->GetThirdArray())
|
||||
{ }
|
||||
|
||||
: FirstArray(storage->GetFirstArray())
|
||||
, SecondArray(storage->GetSecondArray())
|
||||
, ThirdArray(storage->GetThirdArray())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->FirstArray.GetNumberOfValues() *
|
||||
this->SecondArray.GetNumberOfValues() *
|
||||
return this->FirstArray.GetNumberOfValues() * this->SecondArray.GetNumberOfValues() *
|
||||
this->ThirdArray.GetNumberOfValues();
|
||||
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) {
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalConstExecution(this->FirstArray.PrepareForInput(Device()),
|
||||
this->SecondArray.PrepareForInput(Device()),
|
||||
this->ThirdArray.PrepareForInput(Device()));
|
||||
@ -362,7 +358,6 @@ public:
|
||||
this->ThirdArray.ReleaseResourcesExecution();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
FirstHandleType FirstArray;
|
||||
SecondHandleType SecondArray;
|
||||
@ -374,11 +369,10 @@ private:
|
||||
/// array handle and makes a new handle that access the corresponding entries
|
||||
/// in these arrays as a pair.
|
||||
///
|
||||
template<typename FirstHandleType,
|
||||
typename SecondHandleType,
|
||||
typename ThirdHandleType>
|
||||
template <typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType>
|
||||
class ArrayHandleCartesianProduct
|
||||
: public internal::ArrayHandleCartesianProductTraits<FirstHandleType,SecondHandleType,ThirdHandleType>::Superclass
|
||||
: public internal::ArrayHandleCartesianProductTraits<FirstHandleType, SecondHandleType,
|
||||
ThirdHandleType>::Superclass
|
||||
{
|
||||
// If the following line gives a compile error, then the FirstHandleType
|
||||
// template argument is not a valid ArrayHandle type.
|
||||
@ -390,8 +384,8 @@ public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleCartesianProduct,
|
||||
(ArrayHandleCartesianProduct<FirstHandleType, SecondHandleType, ThirdHandleType>),
|
||||
(typename internal::ArrayHandleCartesianProductTraits<
|
||||
FirstHandleType,SecondHandleType,ThirdHandleType>::Superclass));
|
||||
(typename internal::ArrayHandleCartesianProductTraits<FirstHandleType, SecondHandleType,
|
||||
ThirdHandleType>::Superclass));
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
@ -401,7 +395,9 @@ public:
|
||||
ArrayHandleCartesianProduct(const FirstHandleType& firstArray,
|
||||
const SecondHandleType& secondArray,
|
||||
const ThirdHandleType& thirdArray)
|
||||
: Superclass(StorageType(firstArray, secondArray, thirdArray)) { }
|
||||
: Superclass(StorageType(firstArray, secondArray, thirdArray))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// A convenience function for creating an ArrayHandleCartesianProduct. It takes the two
|
||||
@ -410,15 +406,12 @@ public:
|
||||
template <typename FirstHandleType, typename SecondHandleType, typename ThirdHandleType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleCartesianProduct<FirstHandleType, SecondHandleType, ThirdHandleType>
|
||||
make_ArrayHandleCartesianProduct(const FirstHandleType &first,
|
||||
const SecondHandleType &second,
|
||||
make_ArrayHandleCartesianProduct(const FirstHandleType& first, const SecondHandleType& second,
|
||||
const ThirdHandleType& third)
|
||||
{
|
||||
return ArrayHandleCartesianProduct<FirstHandleType,
|
||||
SecondHandleType,
|
||||
ThirdHandleType>(first, second,third);
|
||||
return ArrayHandleCartesianProduct<FirstHandleType, SecondHandleType, ThirdHandleType>(
|
||||
first, second, third);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -24,24 +24,23 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename FromType, typename ToType>
|
||||
struct VTKM_ALWAYS_EXPORT Cast
|
||||
{
|
||||
VTKM_EXEC_CONT
|
||||
ToType operator()(const FromType &val) const
|
||||
{
|
||||
return static_cast<ToType>(val);
|
||||
}
|
||||
ToType operator()(const FromType& val) const { return static_cast<ToType>(val); }
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
/// \brief Cast the values of an array to the specified type, on demand.
|
||||
///
|
||||
/// ArrayHandleCast is a specialization of ArrayHandleTransform. Given an ArrayHandle
|
||||
@ -49,39 +48,33 @@ struct VTKM_ALWAYS_EXPORT Cast
|
||||
/// to the specified type.
|
||||
///
|
||||
template <typename T, typename ArrayHandleType>
|
||||
class ArrayHandleCast :
|
||||
public vtkm::cont::ArrayHandleTransform<
|
||||
T,
|
||||
ArrayHandleType,
|
||||
class ArrayHandleCast
|
||||
: public vtkm::cont::ArrayHandleTransform<T, ArrayHandleType,
|
||||
internal::Cast<typename ArrayHandleType::ValueType, T>,
|
||||
internal::Cast<T, typename ArrayHandleType::ValueType>>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleCast,
|
||||
(ArrayHandleCast<T, ArrayHandleType>),
|
||||
(vtkm::cont::ArrayHandleTransform<
|
||||
T,
|
||||
ArrayHandleType,
|
||||
ArrayHandleCast, (ArrayHandleCast<T, ArrayHandleType>),
|
||||
(vtkm::cont::ArrayHandleTransform<T, ArrayHandleType,
|
||||
internal::Cast<typename ArrayHandleType::ValueType, T>,
|
||||
internal::Cast<T, typename ArrayHandleType::ValueType>>));
|
||||
|
||||
ArrayHandleCast(const ArrayHandleType& handle)
|
||||
: Superclass(handle)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// make_ArrayHandleCast is convenience function to generate an
|
||||
/// ArrayHandleCast.
|
||||
///
|
||||
template <typename T, typename HandleType>
|
||||
VTKM_CONT
|
||||
ArrayHandleCast<T, HandleType> make_ArrayHandleCast(const HandleType &handle,
|
||||
VTKM_CONT ArrayHandleCast<T, HandleType> make_ArrayHandleCast(const HandleType& handle,
|
||||
const T& = T())
|
||||
{
|
||||
return ArrayHandleCast<T, HandleType>(handle);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -31,18 +31,21 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename ValueType>
|
||||
struct VTKM_ALWAYS_EXPORT CompositeVectorSwizzleFunctor
|
||||
{
|
||||
static const vtkm::IdComponent NUM_COMPONENTS =
|
||||
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
typedef vtkm::Vec<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
|
||||
|
||||
// Caution! This is a reference.
|
||||
@ -50,41 +53,36 @@ struct VTKM_ALWAYS_EXPORT CompositeVectorSwizzleFunctor
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
CompositeVectorSwizzleFunctor(const ComponentMapType& sourceComponents)
|
||||
: SourceComponents(sourceComponents) { }
|
||||
: SourceComponents(sourceComponents)
|
||||
{
|
||||
}
|
||||
|
||||
// Currently only supporting 1-4 components.
|
||||
template <typename T1>
|
||||
VTKM_EXEC_CONT
|
||||
ValueType operator()(const T1 &p1) const {
|
||||
return ValueType(
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]));
|
||||
VTKM_EXEC_CONT ValueType operator()(const T1& p1) const
|
||||
{
|
||||
return ValueType(vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]));
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
VTKM_EXEC_CONT
|
||||
ValueType operator()(const T1 &p1, const T2 &p2) const {
|
||||
return ValueType(
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
VTKM_EXEC_CONT ValueType operator()(const T1& p1, const T2& p2) const
|
||||
{
|
||||
return ValueType(vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VecTraits<T2>::GetComponent(p2, this->SourceComponents[1]));
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
VTKM_EXEC_CONT
|
||||
ValueType operator()(const T1 &p1, const T2 &p2, const T3 &p3) const {
|
||||
return ValueType(
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
VTKM_EXEC_CONT ValueType operator()(const T1& p1, const T2& p2, const T3& p3) const
|
||||
{
|
||||
return ValueType(vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VecTraits<T2>::GetComponent(p2, this->SourceComponents[1]),
|
||||
vtkm::VecTraits<T3>::GetComponent(p3, this->SourceComponents[2]));
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
VTKM_EXEC_CONT
|
||||
ValueType operator()(const T1 &p1,
|
||||
const T2 &p2,
|
||||
const T3 &p3,
|
||||
const T4 &p4) const {
|
||||
return ValueType(
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
VTKM_EXEC_CONT ValueType operator()(const T1& p1, const T2& p2, const T3& p3, const T4& p4) const
|
||||
{
|
||||
return ValueType(vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VecTraits<T2>::GetComponent(p2, this->SourceComponents[1]),
|
||||
vtkm::VecTraits<T3>::GetComponent(p3, this->SourceComponents[2]),
|
||||
vtkm::VecTraits<T4>::GetComponent(p4, this->SourceComponents[3]));
|
||||
@ -97,67 +95,74 @@ struct VTKM_ALWAYS_EXPORT CompositeVectorPullValueFunctor
|
||||
vtkm::Id Index;
|
||||
|
||||
VTKM_EXEC
|
||||
CompositeVectorPullValueFunctor(vtkm::Id index) : Index(index) { }
|
||||
CompositeVectorPullValueFunctor(vtkm::Id index)
|
||||
: Index(index)
|
||||
{
|
||||
}
|
||||
|
||||
// This form is to pull values out of array arguments.
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename PortalType>
|
||||
VTKM_EXEC_CONT
|
||||
typename PortalType::ValueType operator()(const PortalType &portal) const {
|
||||
VTKM_EXEC_CONT typename PortalType::ValueType operator()(const PortalType& portal) const
|
||||
{
|
||||
return portal.Get(this->Index);
|
||||
}
|
||||
|
||||
// This form is an identity to pass the return value back.
|
||||
VTKM_EXEC_CONT
|
||||
const ReturnValueType &operator()(const ReturnValueType &value) const {
|
||||
return value;
|
||||
}
|
||||
const ReturnValueType& operator()(const ReturnValueType& value) const { return value; }
|
||||
};
|
||||
|
||||
struct CompositeVectorArrayToPortalCont {
|
||||
struct CompositeVectorArrayToPortalCont
|
||||
{
|
||||
template <typename ArrayHandleType, vtkm::IdComponent Index>
|
||||
struct ReturnType {
|
||||
struct ReturnType
|
||||
{
|
||||
typedef typename ArrayHandleType::PortalConstControl type;
|
||||
};
|
||||
|
||||
template <typename ArrayHandleType, vtkm::IdComponent Index>
|
||||
VTKM_CONT
|
||||
typename ReturnType<ArrayHandleType, Index>::type
|
||||
operator()(const ArrayHandleType &array,
|
||||
vtkm::internal::IndexTag<Index>) const {
|
||||
VTKM_CONT typename ReturnType<ArrayHandleType, Index>::type operator()(
|
||||
const ArrayHandleType& array, vtkm::internal::IndexTag<Index>) const
|
||||
{
|
||||
return array.GetPortalConstControl();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename DeviceAdapterTag>
|
||||
struct CompositeVectorArrayToPortalExec {
|
||||
struct CompositeVectorArrayToPortalExec
|
||||
{
|
||||
template <typename ArrayHandleType, vtkm::IdComponent Index>
|
||||
struct ReturnType {
|
||||
typedef typename ArrayHandleType::template ExecutionTypes<
|
||||
DeviceAdapterTag>::PortalConst type;
|
||||
struct ReturnType
|
||||
{
|
||||
typedef typename ArrayHandleType::template ExecutionTypes<DeviceAdapterTag>::PortalConst type;
|
||||
};
|
||||
|
||||
template <typename ArrayHandleType, vtkm::IdComponent Index>
|
||||
VTKM_CONT
|
||||
typename ReturnType<ArrayHandleType, Index>::type
|
||||
operator()(const ArrayHandleType &array,
|
||||
vtkm::internal::IndexTag<Index>) const {
|
||||
VTKM_CONT typename ReturnType<ArrayHandleType, Index>::type operator()(
|
||||
const ArrayHandleType& array, vtkm::internal::IndexTag<Index>) const
|
||||
{
|
||||
return array.PrepareForInput(DeviceAdapterTag());
|
||||
}
|
||||
};
|
||||
|
||||
struct CheckArraySizeFunctor {
|
||||
struct CheckArraySizeFunctor
|
||||
{
|
||||
vtkm::Id ExpectedSize;
|
||||
CheckArraySizeFunctor(vtkm::Id expectedSize) : ExpectedSize(expectedSize) { }
|
||||
CheckArraySizeFunctor(vtkm::Id expectedSize)
|
||||
: ExpectedSize(expectedSize)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, vtkm::IdComponent Index>
|
||||
void operator()(const T &a, vtkm::internal::IndexTag<Index>) const {
|
||||
void operator()(const T& a, vtkm::internal::IndexTag<Index>) const
|
||||
{
|
||||
if (a.GetNumberOfValues() != this->ExpectedSize)
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "All input arrays to ArrayHandleCompositeVector must be the same size.\n"
|
||||
<< "Array " << Index-1 << " has " << a.GetNumberOfValues()
|
||||
<< ". Expected " << this->ExpectedSize << ".";
|
||||
<< "Array " << Index - 1 << " has " << a.GetNumberOfValues() << ". Expected "
|
||||
<< this->ExpectedSize << ".";
|
||||
throw vtkm::cont::ErrorBadValue(message.str().c_str());
|
||||
}
|
||||
}
|
||||
@ -176,8 +181,7 @@ class VTKM_ALWAYS_EXPORT ArrayPortalCompositeVector
|
||||
|
||||
public:
|
||||
typedef typename PortalTypes::ResultType ValueType;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS =
|
||||
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
|
||||
// Used internally.
|
||||
typedef vtkm::Vec<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
|
||||
@ -190,20 +194,24 @@ public:
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_CONT
|
||||
ArrayPortalCompositeVector(
|
||||
const PortalTypes portals,
|
||||
ArrayPortalCompositeVector(const PortalTypes portals,
|
||||
vtkm::Vec<vtkm::IdComponent, NUM_COMPONENTS> sourceComponents)
|
||||
: Portals(portals), SourceComponents(sourceComponents) { }
|
||||
: Portals(portals)
|
||||
, SourceComponents(sourceComponents)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->Portals.template GetParameter<1>().GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
// This might be inefficient because we are copying all the portals only
|
||||
// because they are coupled with the return value.
|
||||
PortalTypes localPortals = this->Portals;
|
||||
@ -215,32 +223,31 @@ public:
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index),
|
||||
const ValueType &vtkmNotUsed(value)) const
|
||||
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
|
||||
{
|
||||
// There is no technical reason why this cannot be implemented. As of this
|
||||
// writing no one has needed to write to a composite vector yet.
|
||||
VTKM_ASSERT(false && "Set not yet implemented for composite vector. Do you volunteer to implement it?");
|
||||
VTKM_ASSERT(false &&
|
||||
"Set not yet implemented for composite vector. Do you volunteer to implement it?");
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
PortalTypes Portals;
|
||||
ComponentMapType SourceComponents;
|
||||
};
|
||||
|
||||
template <typename SignatureWithArrays>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagCompositeVector { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagCompositeVector
|
||||
{
|
||||
};
|
||||
|
||||
/// A convenience class that provides a typedef to the appropriate tag for
|
||||
/// a composite storage.
|
||||
template <typename SignatureWithArrays>
|
||||
struct ArrayHandleCompositeVectorTraits
|
||||
{
|
||||
typedef vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays>
|
||||
Tag;
|
||||
typedef typename vtkm::internal::FunctionInterface<SignatureWithArrays>::ResultType
|
||||
ValueType;
|
||||
typedef vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays> Tag;
|
||||
typedef typename vtkm::internal::FunctionInterface<SignatureWithArrays>::ResultType ValueType;
|
||||
typedef vtkm::cont::internal::Storage<ValueType, Tag> StorageType;
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, Tag> Superclass;
|
||||
};
|
||||
@ -249,18 +256,15 @@ struct ArrayHandleCompositeVectorTraits
|
||||
// everything, but that is because all the functionality is handled in the
|
||||
// ArrayTransfer class.
|
||||
template <typename SignatureWithArrays>
|
||||
class Storage<
|
||||
typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType,
|
||||
class Storage<typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType,
|
||||
vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays>>
|
||||
{
|
||||
typedef vtkm::internal::FunctionInterface<SignatureWithArrays>
|
||||
FunctionInterfaceWithArrays;
|
||||
typedef vtkm::internal::FunctionInterface<SignatureWithArrays> FunctionInterfaceWithArrays;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = FunctionInterfaceWithArrays::ARITY;
|
||||
typedef vtkm::Vec<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
|
||||
|
||||
typedef typename FunctionInterfaceWithArrays::template StaticTransformType<
|
||||
detail::CompositeVectorArrayToPortalCont>::type
|
||||
FunctionInterfaceWithPortals;
|
||||
detail::CompositeVectorArrayToPortalCont>::type FunctionInterfaceWithPortals;
|
||||
typedef typename FunctionInterfaceWithPortals::Signature SignatureWithPortals;
|
||||
|
||||
public:
|
||||
@ -269,37 +273,42 @@ public:
|
||||
typedef typename PortalType::ValueType ValueType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const FunctionInterfaceWithArrays &arrays,
|
||||
const ComponentMapType &sourceComponents)
|
||||
: Arrays(arrays), SourceComponents(sourceComponents), Valid(true)
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
arrays.ForEachCont(
|
||||
detail::CheckArraySizeFunctor(this->GetNumberOfValues()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() {
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Composite vector arrays are read only.");
|
||||
Storage(const FunctionInterfaceWithArrays& arrays, const ComponentMapType& sourceComponents)
|
||||
: Arrays(arrays)
|
||||
, SourceComponents(sourceComponents)
|
||||
, Valid(true)
|
||||
{
|
||||
arrays.ForEachCont(detail::CheckArraySizeFunctor(this->GetNumberOfValues()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const {
|
||||
PortalType GetPortal()
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Composite vector arrays are read only.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
if (!this->Valid)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Tried to use an ArrayHandleCompositeHandle without dependent arrays.");
|
||||
}
|
||||
return PortalConstType(this->Arrays.StaticTransformCont(
|
||||
detail::CompositeVectorArrayToPortalCont()),
|
||||
return PortalConstType(
|
||||
this->Arrays.StaticTransformCont(detail::CompositeVectorArrayToPortalCont()),
|
||||
this->SourceComponents);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
if (!this->Valid)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
@ -309,7 +318,8 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorInternal(
|
||||
|
||||
"The allocate method for the composite vector storage should never "
|
||||
@ -320,13 +330,14 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Composite vector arrays are read-only.");
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Composite vector arrays are read-only.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
if (this->Valid)
|
||||
{
|
||||
// TODO: Implement this.
|
||||
@ -334,13 +345,15 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const FunctionInterfaceWithArrays &GetArrays() const {
|
||||
const FunctionInterfaceWithArrays& GetArrays() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->Arrays;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const ComponentMapType &GetSourceComponents() const {
|
||||
const ComponentMapType& GetSourceComponents() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->SourceComponents;
|
||||
}
|
||||
@ -352,26 +365,21 @@ private:
|
||||
};
|
||||
|
||||
template <typename SignatureWithArrays, typename DeviceAdapterTag>
|
||||
class ArrayTransfer<
|
||||
typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType,
|
||||
class ArrayTransfer<typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType,
|
||||
vtkm::cont::internal::StorageTagCompositeVector<SignatureWithArrays>,
|
||||
DeviceAdapterTag>
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
|
||||
|
||||
typedef typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::StorageType
|
||||
StorageType;
|
||||
typedef typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::StorageType StorageType;
|
||||
|
||||
typedef vtkm::internal::FunctionInterface<SignatureWithArrays>
|
||||
FunctionWithArrays;
|
||||
typedef vtkm::internal::FunctionInterface<SignatureWithArrays> FunctionWithArrays;
|
||||
typedef typename FunctionWithArrays::template StaticTransformType<
|
||||
detail::CompositeVectorArrayToPortalExec<DeviceAdapterTag> >::type
|
||||
FunctionWithPortals;
|
||||
detail::CompositeVectorArrayToPortalExec<DeviceAdapterTag>>::type FunctionWithPortals;
|
||||
typedef typename FunctionWithPortals::Signature SignatureWithPortals;
|
||||
|
||||
public:
|
||||
typedef typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType
|
||||
ValueType;
|
||||
typedef typename ArrayHandleCompositeVectorTraits<SignatureWithArrays>::ValueType ValueType;
|
||||
|
||||
// These are not currently fully implemented.
|
||||
typedef typename StorageType::PortalType PortalControl;
|
||||
@ -381,19 +389,18 @@ public:
|
||||
typedef ArrayPortalCompositeVector<SignatureWithPortals> PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType *storage) : Storage(storage) { }
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: Storage(storage)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->Storage->GetNumberOfValues();
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->Storage->GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) const
|
||||
{
|
||||
return
|
||||
PortalConstExecution(
|
||||
this->Storage->GetArrays().StaticTransformCont(
|
||||
return PortalConstExecution(this->Storage->GetArrays().StaticTransformCont(
|
||||
detail::CompositeVectorArrayToPortalExec<DeviceAdapterTag>()),
|
||||
this->Storage->GetSourceComponents());
|
||||
}
|
||||
@ -413,28 +420,23 @@ public:
|
||||
// It may be the case a composite vector could be used for output if you
|
||||
// want the delegate arrays to be resized, but this is not implemented
|
||||
// currently.
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Composite vector arrays cannot be used for output.");
|
||||
throw vtkm::cont::ErrorBadValue("Composite vector arrays cannot be used for output.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Composite vector arrays cannot be used for output.");
|
||||
throw vtkm::cont::ErrorBadValue("Composite vector arrays cannot be used for output.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Composite vector arrays cannot be resized.");
|
||||
throw vtkm::cont::ErrorBadValue("Composite vector arrays cannot be resized.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
this->Storage->ReleaseResources();
|
||||
}
|
||||
void ReleaseResources() { this->Storage->ReleaseResources(); }
|
||||
|
||||
private:
|
||||
StorageType* Storage;
|
||||
@ -456,87 +458,66 @@ template<typename Signature>
|
||||
class ArrayHandleCompositeVector
|
||||
: public internal::ArrayHandleCompositeVectorTraits<Signature>::Superclass
|
||||
{
|
||||
typedef typename internal::ArrayHandleCompositeVectorTraits<Signature>::StorageType
|
||||
StorageType;
|
||||
typedef typename internal::ArrayPortalCompositeVector<Signature>::ComponentMapType
|
||||
ComponentMapType;
|
||||
typedef typename internal::ArrayHandleCompositeVectorTraits<Signature>::StorageType StorageType;
|
||||
typedef
|
||||
typename internal::ArrayPortalCompositeVector<Signature>::ComponentMapType ComponentMapType;
|
||||
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleCompositeVector,
|
||||
(ArrayHandleCompositeVector<Signature>),
|
||||
ArrayHandleCompositeVector, (ArrayHandleCompositeVector<Signature>),
|
||||
(typename internal::ArrayHandleCompositeVectorTraits<Signature>::Superclass));
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandleCompositeVector(
|
||||
const vtkm::internal::FunctionInterface<Signature> &arrays,
|
||||
ArrayHandleCompositeVector(const vtkm::internal::FunctionInterface<Signature>& arrays,
|
||||
const ComponentMapType& sourceComponents)
|
||||
: Superclass(StorageType(arrays, sourceComponents))
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
/// Template constructors for passing in types. You'll get weird compile
|
||||
/// errors if the argument types do not actually match the types in the
|
||||
/// signature.
|
||||
///
|
||||
template <typename ArrayHandleType1>
|
||||
VTKM_CONT
|
||||
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
VTKM_CONT ArrayHandleCompositeVector(const ArrayHandleType1& array1,
|
||||
vtkm::IdComponent sourceComponent1)
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(array1),
|
||||
: Superclass(StorageType(vtkm::internal::make_FunctionInterface<ValueType>(array1),
|
||||
ComponentMapType(sourceComponent1)))
|
||||
{ }
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2>
|
||||
VTKM_CONT
|
||||
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
{
|
||||
}
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
VTKM_CONT ArrayHandleCompositeVector(const ArrayHandleType1& array1,
|
||||
vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2& array2,
|
||||
vtkm::IdComponent sourceComponent2)
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(
|
||||
array1, array2),
|
||||
ComponentMapType(sourceComponent1,
|
||||
sourceComponent2)))
|
||||
{ }
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2,
|
||||
typename ArrayHandleType3>
|
||||
VTKM_CONT
|
||||
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
: Superclass(StorageType(vtkm::internal::make_FunctionInterface<ValueType>(array1, array2),
|
||||
ComponentMapType(sourceComponent1, sourceComponent2)))
|
||||
{
|
||||
}
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2, typename ArrayHandleType3>
|
||||
VTKM_CONT ArrayHandleCompositeVector(const ArrayHandleType1& array1,
|
||||
vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2& array2,
|
||||
vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3& array3,
|
||||
vtkm::IdComponent sourceComponent3)
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(
|
||||
array1, array2, array3),
|
||||
ComponentMapType(sourceComponent1,
|
||||
sourceComponent2,
|
||||
sourceComponent3)))
|
||||
{ }
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2,
|
||||
typename ArrayHandleType3,
|
||||
: Superclass(
|
||||
StorageType(vtkm::internal::make_FunctionInterface<ValueType>(array1, array2, array3),
|
||||
ComponentMapType(sourceComponent1, sourceComponent2, sourceComponent3)))
|
||||
{
|
||||
}
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2, typename ArrayHandleType3,
|
||||
typename ArrayHandleType4>
|
||||
VTKM_CONT
|
||||
ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2 &array2,
|
||||
vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3 &array3,
|
||||
vtkm::IdComponent sourceComponent3,
|
||||
const ArrayHandleType4 &array4,
|
||||
vtkm::IdComponent sourceComponent4)
|
||||
VTKM_CONT ArrayHandleCompositeVector(
|
||||
const ArrayHandleType1& array1, vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2& array2, vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3& array3, vtkm::IdComponent sourceComponent3,
|
||||
const ArrayHandleType4& array4, vtkm::IdComponent sourceComponent4)
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(
|
||||
array1, array2, array3, array4),
|
||||
ComponentMapType(sourceComponent1,
|
||||
sourceComponent2,
|
||||
sourceComponent3,
|
||||
sourceComponent4)))
|
||||
{ }
|
||||
vtkm::internal::make_FunctionInterface<ValueType>(array1, array2, array3, array4),
|
||||
ComponentMapType(sourceComponent1, sourceComponent2, sourceComponent3, sourceComponent4)))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Get the type for an ArrayHandleCompositeVector
|
||||
@ -552,54 +533,53 @@ public:
|
||||
/// OutArrayType outArray = vtkm::cont::make_ArrayHandleCompositeVector(a1,a2);
|
||||
/// \endcode
|
||||
///
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2 = void,
|
||||
typename ArrayHandleType3 = void,
|
||||
typename ArrayHandleType4 = void>
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2 = void,
|
||||
typename ArrayHandleType3 = void, typename ArrayHandleType4 = void>
|
||||
struct ArrayHandleCompositeVectorType
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType2);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType3);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType4);
|
||||
|
||||
private:
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef vtkm::Vec<ComponentType,4> Signature(
|
||||
ArrayHandleType1,ArrayHandleType2,ArrayHandleType3,ArrayHandleType4);
|
||||
typedef
|
||||
typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType ComponentType;
|
||||
typedef vtkm::Vec<ComponentType, 4> Signature(ArrayHandleType1, ArrayHandleType2,
|
||||
ArrayHandleType3, ArrayHandleType4);
|
||||
|
||||
public:
|
||||
typedef vtkm::cont::ArrayHandleCompositeVector<Signature> type;
|
||||
};
|
||||
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2,
|
||||
typename ArrayHandleType3>
|
||||
struct ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1,ArrayHandleType2,ArrayHandleType3>
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2, typename ArrayHandleType3>
|
||||
struct ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2, ArrayHandleType3>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType2);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType3);
|
||||
|
||||
private:
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef vtkm::Vec<ComponentType,3> Signature(
|
||||
ArrayHandleType1,ArrayHandleType2,ArrayHandleType3);
|
||||
typedef
|
||||
typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType ComponentType;
|
||||
typedef vtkm::Vec<ComponentType, 3> Signature(ArrayHandleType1, ArrayHandleType2,
|
||||
ArrayHandleType3);
|
||||
|
||||
public:
|
||||
typedef vtkm::cont::ArrayHandleCompositeVector<Signature> type;
|
||||
};
|
||||
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2>
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
struct ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType2);
|
||||
|
||||
private:
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef vtkm::Vec<ComponentType,2> Signature(
|
||||
ArrayHandleType1,ArrayHandleType2);
|
||||
typedef
|
||||
typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType ComponentType;
|
||||
typedef vtkm::Vec<ComponentType, 2> Signature(ArrayHandleType1, ArrayHandleType2);
|
||||
|
||||
public:
|
||||
typedef vtkm::cont::ArrayHandleCompositeVector<Signature> type;
|
||||
};
|
||||
@ -608,108 +588,83 @@ template<typename ArrayHandleType1>
|
||||
struct ArrayHandleCompositeVectorType<ArrayHandleType1>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
|
||||
private:
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef
|
||||
typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType ComponentType;
|
||||
typedef ComponentType Signature(ArrayHandleType1);
|
||||
|
||||
public:
|
||||
typedef vtkm::cont::ArrayHandleCompositeVector<Signature> type;
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
/// Create a composite vector array from other arrays.
|
||||
///
|
||||
template <typename ValueType1, typename Storage1>
|
||||
VTKM_CONT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1> >::type
|
||||
make_ArrayHandleCompositeVector(
|
||||
const vtkm::cont::ArrayHandle<ValueType1,Storage1> &array1,
|
||||
typename ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<ValueType1, Storage1>>::type
|
||||
make_ArrayHandleCompositeVector(const vtkm::cont::ArrayHandle<ValueType1, Storage1>& array1,
|
||||
vtkm::IdComponent sourceComponent1)
|
||||
{
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<ValueType1,Storage1> >::type(array1,
|
||||
sourceComponent1);
|
||||
return
|
||||
typename ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<ValueType1, Storage1>>::type(
|
||||
array1, sourceComponent1);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
template <typename ArrayHandleType1>
|
||||
VTKM_CONT
|
||||
typename ArrayHandleCompositeVectorType<ArrayHandleType1>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
vtkm::IdComponent sourceComponent1)
|
||||
VTKM_CONT typename ArrayHandleCompositeVectorType<ArrayHandleType1>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1& array1, vtkm::IdComponent sourceComponent1)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1>::type(array1, sourceComponent1);
|
||||
return typename ArrayHandleCompositeVectorType<ArrayHandleType1>::type(array1, sourceComponent1);
|
||||
}
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2>
|
||||
VTKM_CONT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1, ArrayHandleType2>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2 &array2,
|
||||
vtkm::IdComponent sourceComponent2)
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
VTKM_CONT typename ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1& array1, vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2& array2, vtkm::IdComponent sourceComponent2)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType2);
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1,
|
||||
ArrayHandleType2>::type(array1, sourceComponent1,
|
||||
array2, sourceComponent2);
|
||||
return typename ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2>::type(
|
||||
array1, sourceComponent1, array2, sourceComponent2);
|
||||
}
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2,
|
||||
typename ArrayHandleType3>
|
||||
VTKM_CONT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1, ArrayHandleType2, ArrayHandleType3>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2 &array2,
|
||||
vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3 &array3,
|
||||
vtkm::IdComponent sourceComponent3)
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2, typename ArrayHandleType3>
|
||||
VTKM_CONT typename ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2,
|
||||
ArrayHandleType3>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1& array1, vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2& array2, vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3& array3, vtkm::IdComponent sourceComponent3)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType2);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType3);
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1,
|
||||
ArrayHandleType2,
|
||||
return typename ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2,
|
||||
ArrayHandleType3>::type(array1, sourceComponent1,
|
||||
array2, sourceComponent2,
|
||||
array3, sourceComponent3);
|
||||
}
|
||||
template<typename ArrayHandleType1,
|
||||
typename ArrayHandleType2,
|
||||
typename ArrayHandleType3,
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2, typename ArrayHandleType3,
|
||||
typename ArrayHandleType4>
|
||||
VTKM_CONT
|
||||
typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1, ArrayHandleType2, ArrayHandleType3, ArrayHandleType4>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1 &array1,
|
||||
vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2 &array2,
|
||||
vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3 &array3,
|
||||
vtkm::IdComponent sourceComponent3,
|
||||
const ArrayHandleType4 &array4,
|
||||
vtkm::IdComponent sourceComponent4)
|
||||
VTKM_CONT typename ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2,
|
||||
ArrayHandleType3, ArrayHandleType4>::type
|
||||
make_ArrayHandleCompositeVector(const ArrayHandleType1& array1, vtkm::IdComponent sourceComponent1,
|
||||
const ArrayHandleType2& array2, vtkm::IdComponent sourceComponent2,
|
||||
const ArrayHandleType3& array3, vtkm::IdComponent sourceComponent3,
|
||||
const ArrayHandleType4& array4, vtkm::IdComponent sourceComponent4)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType1);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType2);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType3);
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType4);
|
||||
return typename ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1,
|
||||
ArrayHandleType2,
|
||||
ArrayHandleType3,
|
||||
return
|
||||
typename ArrayHandleCompositeVectorType<ArrayHandleType1, ArrayHandleType2, ArrayHandleType3,
|
||||
ArrayHandleType4>::type(array1, sourceComponent1,
|
||||
array2, sourceComponent2,
|
||||
array3, sourceComponent3,
|
||||
array4, sourceComponent4);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -24,9 +24,12 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename PortalType1, typename PortalType2>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalConcatenate
|
||||
@ -35,23 +38,31 @@ public:
|
||||
typedef typename PortalType1::ValueType ValueType;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalConcatenate() : portal1(), portal2() {}
|
||||
ArrayPortalConcatenate()
|
||||
: portal1()
|
||||
, portal2()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalConcatenate(const PortalType1& p1, const PortalType2& p2)
|
||||
: portal1( p1 ), portal2( p2 ) {}
|
||||
: portal1(p1)
|
||||
, portal2(p2)
|
||||
{
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
template <typename OtherP1, typename OtherP2>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalConcatenate( const ArrayPortalConcatenate< OtherP1, OtherP2 > &src )
|
||||
: portal1( src.GetPortal1() ), portal2( src.GetPortal2() ) {}
|
||||
VTKM_EXEC_CONT ArrayPortalConcatenate(const ArrayPortalConcatenate<OtherP1, OtherP2>& src)
|
||||
: portal1(src.GetPortal1())
|
||||
, portal2(src.GetPortal2())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->portal1.GetNumberOfValues() +
|
||||
this->portal2.GetNumberOfValues() ;
|
||||
return this->portal1.GetNumberOfValues() + this->portal2.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
@ -73,16 +84,10 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const PortalType1 &GetPortal1() const
|
||||
{
|
||||
return this->portal1;
|
||||
}
|
||||
const PortalType1& GetPortal1() const { return this->portal1; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
const PortalType2 &GetPortal2() const
|
||||
{
|
||||
return this->portal2;
|
||||
}
|
||||
const PortalType2& GetPortal2() const { return this->portal2; }
|
||||
|
||||
private:
|
||||
PortalType1 portal1;
|
||||
@ -91,12 +96,13 @@ private:
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
class StorageTagConcatenate {};
|
||||
class StorageTagConcatenate
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
class Storage<typename ArrayHandleType1::ValueType,
|
||||
@ -105,17 +111,23 @@ class Storage< typename ArrayHandleType1::ValueType,
|
||||
public:
|
||||
typedef typename ArrayHandleType1::ValueType ValueType;
|
||||
typedef ArrayPortalConcatenate<typename ArrayHandleType1::PortalControl,
|
||||
typename ArrayHandleType2::PortalControl > PortalType;
|
||||
typedef ArrayPortalConcatenate<
|
||||
typename ArrayHandleType1::PortalConstControl,
|
||||
typename ArrayHandleType2::PortalConstControl > PortalConstType;
|
||||
typename ArrayHandleType2::PortalControl>
|
||||
PortalType;
|
||||
typedef ArrayPortalConcatenate<typename ArrayHandleType1::PortalConstControl,
|
||||
typename ArrayHandleType2::PortalConstControl>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : valid( false ) { }
|
||||
Storage()
|
||||
: valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const ArrayHandleType1& a1, const ArrayHandleType2& a2)
|
||||
: array1( a1 ), array2( a2 ), valid( true ) {};
|
||||
: array1(a1)
|
||||
, array2(a2)
|
||||
, valid(true){};
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
@ -129,8 +141,7 @@ public:
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->valid);
|
||||
return PortalType( this->array1.GetPortalControl(),
|
||||
this->array2.GetPortalControl() );
|
||||
return PortalType(this->array1.GetPortalControl(), this->array2.GetPortalControl());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -143,8 +154,7 @@ public:
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorInternal(
|
||||
"ArrayHandleConcatenate should not be allocated explicitly. " );
|
||||
throw vtkm::cont::ErrorInternal("ArrayHandleConcatenate should not be allocated explicitly. ");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -188,11 +198,9 @@ private:
|
||||
bool valid;
|
||||
}; // class Storage
|
||||
|
||||
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2, typename Device>
|
||||
class ArrayTransfer<typename ArrayHandleType1::ValueType,
|
||||
StorageTagConcatenate< ArrayHandleType1, ArrayHandleType2>,
|
||||
Device >
|
||||
StorageTagConcatenate<ArrayHandleType1, ArrayHandleType2>, Device>
|
||||
{
|
||||
public:
|
||||
typedef typename ArrayHandleType1::ValueType ValueType;
|
||||
@ -205,8 +213,7 @@ public:
|
||||
typedef typename StorageType::PortalType PortalControl;
|
||||
typedef typename StorageType::PortalConstType PortalConstControl;
|
||||
|
||||
typedef ArrayPortalConcatenate<
|
||||
typename ArrayHandleType1::template ExecutionTypes< Device >::Portal,
|
||||
typedef ArrayPortalConcatenate<typename ArrayHandleType1::template ExecutionTypes<Device>::Portal,
|
||||
typename ArrayHandleType2::template ExecutionTypes<Device>::Portal>
|
||||
PortalExecution;
|
||||
typedef ArrayPortalConcatenate<
|
||||
@ -216,7 +223,10 @@ public:
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: array1( storage->GetArray1() ), array2( storage->GetArray2() ) {}
|
||||
: array1(storage->GetArray1())
|
||||
, array2(storage->GetArray2())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
@ -241,8 +251,7 @@ public:
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorInternal(
|
||||
"ArrayHandleConcatenate is derived and read-only. " );
|
||||
throw vtkm::cont::ErrorInternal("ArrayHandleConcatenate is derived and read-only. ");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -273,17 +282,15 @@ public:
|
||||
private:
|
||||
ArrayHandleType1 array1;
|
||||
ArrayHandleType2 array2;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont::internal
|
||||
|
||||
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
class ArrayHandleConcatenate
|
||||
@ -291,8 +298,8 @@ class ArrayHandleConcatenate
|
||||
StorageTagConcatenate<ArrayHandleType1, ArrayHandleType2>>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS( ArrayHandleConcatenate,
|
||||
( ArrayHandleConcatenate< ArrayHandleType1, ArrayHandleType2> ),
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleConcatenate, (ArrayHandleConcatenate<ArrayHandleType1, ArrayHandleType2>),
|
||||
(vtkm::cont::ArrayHandle<typename ArrayHandleType1::ValueType,
|
||||
StorageTagConcatenate<ArrayHandleType1, ArrayHandleType2>>));
|
||||
|
||||
@ -300,25 +307,19 @@ protected:
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandleConcatenate( const ArrayHandleType1 &array1,
|
||||
const ArrayHandleType2 &array2 )
|
||||
ArrayHandleConcatenate(const ArrayHandleType1& array1, const ArrayHandleType2& array2)
|
||||
: Superclass(StorageType(array1, array2))
|
||||
{}
|
||||
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename ArrayHandleType1, typename ArrayHandleType2>
|
||||
VTKM_CONT
|
||||
ArrayHandleConcatenate< ArrayHandleType1, ArrayHandleType2 >
|
||||
make_ArrayHandleConcatenate( const ArrayHandleType1 &array1,
|
||||
const ArrayHandleType2 &array2 )
|
||||
VTKM_CONT ArrayHandleConcatenate<ArrayHandleType1, ArrayHandleType2> make_ArrayHandleConcatenate(
|
||||
const ArrayHandleType1& array1, const ArrayHandleType2& array2)
|
||||
{
|
||||
return ArrayHandleConcatenate<ArrayHandleType1, ArrayHandleType2>(array1, array2);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -24,22 +24,25 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleImplicit.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename ValueType>
|
||||
struct VTKM_ALWAYS_EXPORT ConstantFunctor
|
||||
{
|
||||
VTKM_EXEC_CONT
|
||||
ConstantFunctor(const ValueType &value = ValueType()) : Value(value) { }
|
||||
ConstantFunctor(const ValueType& value = ValueType())
|
||||
: Value(value)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ValueType operator()(vtkm::Id vtkmNotUsed(index)) const
|
||||
{
|
||||
return this->Value;
|
||||
}
|
||||
ValueType operator()(vtkm::Id vtkmNotUsed(index)) const { return this->Value; }
|
||||
|
||||
private:
|
||||
ValueType Value;
|
||||
@ -56,18 +59,17 @@ private:
|
||||
/// takes (almost) no memory.
|
||||
///
|
||||
template <typename T>
|
||||
class ArrayHandleConstant
|
||||
: public vtkm::cont::ArrayHandleImplicit<T, detail::ConstantFunctor<T> >
|
||||
class ArrayHandleConstant : public vtkm::cont::ArrayHandleImplicit<T, detail::ConstantFunctor<T>>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleConstant,
|
||||
(ArrayHandleConstant<T>),
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleConstant, (ArrayHandleConstant<T>),
|
||||
(vtkm::cont::ArrayHandleImplicit<T, detail::ConstantFunctor<T>>));
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandleConstant(T value, vtkm::Id numberOfValues = 0)
|
||||
: Superclass(detail::ConstantFunctor<T>(value), numberOfValues) { }
|
||||
: Superclass(detail::ConstantFunctor<T>(value), numberOfValues)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// make_ArrayHandleConstant is convenience function to generate an
|
||||
@ -75,12 +77,10 @@ public:
|
||||
/// array.
|
||||
///
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandleConstant<T>
|
||||
make_ArrayHandleConstant(T value, vtkm::Id numberOfValues)
|
||||
vtkm::cont::ArrayHandleConstant<T> make_ArrayHandleConstant(T value, vtkm::Id numberOfValues)
|
||||
{
|
||||
return vtkm::cont::ArrayHandleConstant<T>(value, numberOfValues);
|
||||
}
|
||||
|
||||
}
|
||||
} // vtkm::cont
|
||||
|
||||
|
@ -25,46 +25,49 @@
|
||||
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// \brief An implicit array portal that returns an counting value.
|
||||
template <class CountingValueType>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalCounting
|
||||
{
|
||||
typedef typename vtkm::VecTraits<CountingValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef typename vtkm::VecTraits<CountingValueType>::ComponentType ComponentType;
|
||||
|
||||
public:
|
||||
typedef CountingValueType ValueType;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalCounting() :
|
||||
Start(0),
|
||||
Step(1),
|
||||
NumberOfValues(0)
|
||||
{ }
|
||||
ArrayPortalCounting()
|
||||
: Start(0)
|
||||
, Step(1)
|
||||
, NumberOfValues(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalCounting(ValueType start, ValueType step, vtkm::Id numValues) :
|
||||
Start(start),
|
||||
Step(step),
|
||||
NumberOfValues(numValues)
|
||||
{ }
|
||||
ArrayPortalCounting(ValueType start, ValueType step, vtkm::Id numValues)
|
||||
: Start(start)
|
||||
, Step(step)
|
||||
, NumberOfValues(numValues)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OtherValueType>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalCounting(const ArrayPortalCounting<OtherValueType> &src)
|
||||
: Start(src.Start),
|
||||
Step(src.Step),
|
||||
NumberOfValues(src.NumberOfValues)
|
||||
{ }
|
||||
VTKM_EXEC_CONT ArrayPortalCounting(const ArrayPortalCounting<OtherValueType>& src)
|
||||
: Start(src.Start)
|
||||
, Step(src.Step)
|
||||
, NumberOfValues(src.NumberOfValues)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OtherValueType>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalCounting<ValueType> &operator=(
|
||||
VTKM_EXEC_CONT ArrayPortalCounting<ValueType>& operator=(
|
||||
const ArrayPortalCounting<OtherValueType>& src)
|
||||
{
|
||||
this->Start = src.Start;
|
||||
@ -77,14 +80,13 @@ public:
|
||||
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
return ValueType(this->Start +
|
||||
this->Step*ValueType(static_cast<ComponentType>(index)));
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
return ValueType(this->Start + this->Step * ValueType(static_cast<ComponentType>(index)));
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index),
|
||||
const ValueType &vtkmNotUsed(value)) const
|
||||
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
|
||||
{
|
||||
VTKM_ASSERT(false && "Cannot write to read-only counting array.");
|
||||
}
|
||||
@ -101,7 +103,8 @@ template<typename ConstantValueType>
|
||||
struct ArrayHandleCountingTraits
|
||||
{
|
||||
typedef vtkm::cont::StorageTagImplicit<
|
||||
vtkm::cont::internal::ArrayPortalCounting<ConstantValueType> > Tag;
|
||||
vtkm::cont::internal::ArrayPortalCounting<ConstantValueType>>
|
||||
Tag;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@ -112,23 +115,16 @@ struct ArrayHandleCountingTraits
|
||||
template <typename CountingValueType>
|
||||
class ArrayHandleCounting
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
CountingValueType,
|
||||
typename internal::ArrayHandleCountingTraits<CountingValueType>::Tag
|
||||
>
|
||||
CountingValueType, typename internal::ArrayHandleCountingTraits<CountingValueType>::Tag>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleCounting,
|
||||
(ArrayHandleCounting<CountingValueType>),
|
||||
ArrayHandleCounting, (ArrayHandleCounting<CountingValueType>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
CountingValueType,
|
||||
typename internal::ArrayHandleCountingTraits<CountingValueType>::Tag
|
||||
>));
|
||||
CountingValueType, typename internal::ArrayHandleCountingTraits<CountingValueType>::Tag>));
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandleCounting(CountingValueType start,
|
||||
CountingValueType step,
|
||||
vtkm::Id length)
|
||||
ArrayHandleCounting(CountingValueType start, CountingValueType step, vtkm::Id length)
|
||||
: Superclass(typename Superclass::PortalConstControl(start, step, length))
|
||||
{
|
||||
}
|
||||
@ -137,17 +133,11 @@ public:
|
||||
/// A convenience function for creating an ArrayHandleCounting. It takes the
|
||||
/// value to start counting from and and the number of times to increment.
|
||||
template <typename CountingValueType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleCounting<CountingValueType>
|
||||
make_ArrayHandleCounting(CountingValueType start,
|
||||
CountingValueType step,
|
||||
vtkm::Id length)
|
||||
VTKM_CONT vtkm::cont::ArrayHandleCounting<CountingValueType> make_ArrayHandleCounting(
|
||||
CountingValueType start, CountingValueType step, vtkm::Id length)
|
||||
{
|
||||
return vtkm::cont::ArrayHandleCounting<CountingValueType>(start,
|
||||
step,
|
||||
length);
|
||||
return vtkm::cont::ArrayHandleCounting<CountingValueType>(start, step, length);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -23,9 +23,12 @@
|
||||
#include <vtkm/TypeTraits.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// \brief An output-only array portal with no storage. All written values are
|
||||
/// discarded.
|
||||
@ -39,30 +42,30 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalDiscard()
|
||||
: NumberOfValues(0)
|
||||
{ } // needs to be host and device so that cuda can create lvalue of these
|
||||
{
|
||||
} // needs to be host and device so that cuda can create lvalue of these
|
||||
|
||||
VTKM_CONT
|
||||
explicit ArrayPortalDiscard(vtkm::Id numValues)
|
||||
: NumberOfValues(numValues)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalDiscard with an iterator
|
||||
/// type that can be copied to this iterator type. This allows us to do any
|
||||
/// type casting that the iterators do (like the non-const to const cast).
|
||||
///
|
||||
template <class OtherV>
|
||||
VTKM_CONT
|
||||
ArrayPortalDiscard(const ArrayPortalDiscard<OtherV> &src)
|
||||
VTKM_CONT ArrayPortalDiscard(const ArrayPortalDiscard<OtherV>& src)
|
||||
: NumberOfValues(src.NumberOfValues)
|
||||
{ }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->NumberOfValues;
|
||||
}
|
||||
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
||||
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
VTKM_ASSERT(index < this->GetNumberOfValues());
|
||||
VTKM_ASSERT("Method not supported for ArrayPortalDiscard." && false);
|
||||
(void)index;
|
||||
@ -84,11 +87,15 @@ private:
|
||||
} // end namespace internal
|
||||
} // end namespace exec
|
||||
|
||||
namespace cont {
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagDiscard { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagDiscard
|
||||
{
|
||||
};
|
||||
|
||||
template <typename ValueType_>
|
||||
class Storage<ValueType_, StorageTagDiscard>
|
||||
@ -102,40 +109,22 @@ public:
|
||||
Storage() {}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal()
|
||||
{
|
||||
return PortalType(this->NumberOfValues);
|
||||
}
|
||||
PortalType GetPortal() { return PortalType(this->NumberOfValues); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst()
|
||||
{
|
||||
return PortalConstType(this->NumberOfValues);
|
||||
}
|
||||
PortalConstType GetPortalConst() { return PortalConstType(this->NumberOfValues); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->NumberOfValues;
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id numValues)
|
||||
{
|
||||
this->NumberOfValues = numValues;
|
||||
}
|
||||
void Allocate(vtkm::Id numValues) { this->NumberOfValues = numValues; }
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numValues)
|
||||
{
|
||||
this->NumberOfValues = numValues;
|
||||
}
|
||||
void Shrink(vtkm::Id numValues) { this->NumberOfValues = numValues; }
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources()
|
||||
{
|
||||
this->NumberOfValues = 0;
|
||||
}
|
||||
void ReleaseResources() { this->NumberOfValues = 0; }
|
||||
|
||||
private:
|
||||
vtkm::Id NumberOfValues;
|
||||
@ -157,7 +146,8 @@ public:
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: Internal(storage)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
@ -169,16 +159,14 @@ public:
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Input access not supported: "
|
||||
throw vtkm::cont::ErrorBadValue("Input access not supported: "
|
||||
"Cannot read from an ArrayHandleDiscard.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"InPlace access not supported: "
|
||||
throw vtkm::cont::ErrorBadValue("InPlace access not supported: "
|
||||
"Cannot read from an ArrayHandleDiscard.");
|
||||
}
|
||||
|
||||
@ -230,13 +218,10 @@ struct ArrayHandleDiscardTraits
|
||||
/// it. This can be used to save memory when a filter provides optional outputs
|
||||
/// that are not needed.
|
||||
template <typename ValueType_>
|
||||
class ArrayHandleDiscard
|
||||
: public internal::ArrayHandleDiscardTraits<ValueType_>::Superclass
|
||||
class ArrayHandleDiscard : public internal::ArrayHandleDiscardTraits<ValueType_>::Superclass
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleDiscard,
|
||||
(ArrayHandleDiscard<ValueType_>),
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleDiscard, (ArrayHandleDiscard<ValueType_>),
|
||||
(typename internal::ArrayHandleDiscardTraits<ValueType_>::Superclass));
|
||||
};
|
||||
|
||||
|
@ -24,10 +24,13 @@
|
||||
#include <vtkm/cont/ArrayPortal.h>
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename _SourcePortalType, vtkm::IdComponent _NUM_COMPONENTS>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalGroupVec
|
||||
@ -36,29 +39,33 @@ public:
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = _NUM_COMPONENTS;
|
||||
typedef _SourcePortalType SourcePortalType;
|
||||
|
||||
typedef typename
|
||||
std::remove_const<typename SourcePortalType::ValueType>::type
|
||||
ComponentType;
|
||||
typedef typename std::remove_const<typename SourcePortalType::ValueType>::type ComponentType;
|
||||
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalGroupVec() : SourcePortal() { }
|
||||
ArrayPortalGroupVec()
|
||||
: SourcePortal()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalGroupVec(const SourcePortalType& sourcePortal)
|
||||
: SourcePortal(sourcePortal) { }
|
||||
: SourcePortal(sourcePortal)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalConcatenate with a portal type
|
||||
/// that can be copied to this portal type. This allows us to do any type
|
||||
/// casting that the portals do (like the non-const to const cast).
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename OtherSourcePortalType>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalGroupVec(
|
||||
VTKM_EXEC_CONT ArrayPortalGroupVec(
|
||||
const ArrayPortalGroupVec<OtherSourcePortalType, NUM_COMPONENTS>& src)
|
||||
: SourcePortal(src.GetPortal()) { }
|
||||
: SourcePortal(src.GetPortal())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
@ -73,9 +80,7 @@ public:
|
||||
{
|
||||
ValueType result;
|
||||
vtkm::Id sourceIndex = index * NUM_COMPONENTS;
|
||||
for (vtkm::IdComponent componentIndex = 0;
|
||||
componentIndex < NUM_COMPONENTS;
|
||||
componentIndex++)
|
||||
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
|
||||
{
|
||||
result[componentIndex] = this->SourcePortal.Get(sourceIndex);
|
||||
sourceIndex++;
|
||||
@ -88,9 +93,7 @@ public:
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
vtkm::Id sourceIndex = index * NUM_COMPONENTS;
|
||||
for (vtkm::IdComponent componentIndex = 0;
|
||||
componentIndex < NUM_COMPONENTS;
|
||||
componentIndex++)
|
||||
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
|
||||
{
|
||||
this->SourcePortal.Set(sourceIndex, value[componentIndex]);
|
||||
sourceIndex++;
|
||||
@ -104,44 +107,51 @@ public:
|
||||
private:
|
||||
SourcePortalType SourcePortal;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::internal
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagGroupVec { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagGroupVec
|
||||
{
|
||||
};
|
||||
|
||||
template<typename SourceArrayHandleType,
|
||||
vtkm::IdComponent NUM_COMPONENTS>
|
||||
class Storage<
|
||||
vtkm::Vec<typename SourceArrayHandleType::ValueType,NUM_COMPONENTS>,
|
||||
vtkm::cont::internal::StorageTagGroupVec<
|
||||
SourceArrayHandleType, NUM_COMPONENTS> >
|
||||
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
|
||||
class Storage<vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
||||
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>>
|
||||
{
|
||||
typedef typename SourceArrayHandleType::ValueType ComponentType;
|
||||
|
||||
public:
|
||||
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalGroupVec<typename SourceArrayHandleType::PortalControl,
|
||||
NUM_COMPONENTS>
|
||||
PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalGroupVec<
|
||||
typename SourceArrayHandleType::PortalControl,
|
||||
NUM_COMPONENTS> PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalGroupVec<
|
||||
typename SourceArrayHandleType::PortalConstControl,
|
||||
NUM_COMPONENTS> PortalConstType;
|
||||
typename SourceArrayHandleType::PortalConstControl, NUM_COMPONENTS>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const SourceArrayHandleType& sourceArray)
|
||||
: SourceArray(sourceArray), Valid(true) { }
|
||||
: SourceArray(sourceArray)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal()
|
||||
@ -206,13 +216,9 @@ private:
|
||||
bool Valid;
|
||||
};
|
||||
|
||||
template<typename SourceArrayHandleType,
|
||||
vtkm::IdComponent NUM_COMPONENTS,
|
||||
typename Device>
|
||||
class ArrayTransfer<
|
||||
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
||||
vtkm::cont::internal::StorageTagGroupVec<
|
||||
SourceArrayHandleType, NUM_COMPONENTS>,
|
||||
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS, typename Device>
|
||||
class ArrayTransfer<vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
||||
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>,
|
||||
Device>
|
||||
{
|
||||
public:
|
||||
@ -220,8 +226,8 @@ public:
|
||||
typedef vtkm::Vec<ComponentType, NUM_COMPONENTS> ValueType;
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::StorageTagGroupVec<
|
||||
SourceArrayHandleType, NUM_COMPONENTS> StorageTag;
|
||||
typedef vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>
|
||||
StorageTag;
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
@ -229,17 +235,17 @@ public:
|
||||
typedef typename StorageType::PortalConstType PortalConstControl;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalGroupVec<
|
||||
typename SourceArrayHandleType::template ExecutionTypes<Device>::Portal,
|
||||
NUM_COMPONENTS>
|
||||
typename SourceArrayHandleType::template ExecutionTypes<Device>::Portal, NUM_COMPONENTS>
|
||||
PortalExecution;
|
||||
typedef vtkm::exec::internal::ArrayPortalGroupVec<
|
||||
typename SourceArrayHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
NUM_COMPONENTS>
|
||||
typename SourceArrayHandleType::template ExecutionTypes<Device>::PortalConst, NUM_COMPONENTS>
|
||||
PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: SourceArray(storage->GetSourceArray()) { }
|
||||
: SourceArray(storage->GetSourceArray())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
@ -278,8 +284,8 @@ public:
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
|
||||
{
|
||||
return PortalExecution(this->SourceArray.PrepareForOutput(
|
||||
numberOfValues*NUM_COMPONENTS, Device()));
|
||||
return PortalExecution(
|
||||
this->SourceArray.PrepareForOutput(numberOfValues * NUM_COMPONENTS, Device()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -297,10 +303,7 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources()
|
||||
{
|
||||
this->SourceArray.ReleaseResourcesExecution();
|
||||
}
|
||||
void ReleaseResources() { this->SourceArray.ReleaseResourcesExecution(); }
|
||||
|
||||
private:
|
||||
SourceArrayHandleType SourceArray;
|
||||
@ -324,19 +327,16 @@ template<typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
|
||||
class ArrayHandleGroupVec
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
||||
vtkm::cont::internal::StorageTagGroupVec<
|
||||
SourceArrayHandleType, NUM_COMPONENTS> >
|
||||
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(SourceArrayHandleType);
|
||||
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleGroupVec,
|
||||
(ArrayHandleGroupVec<SourceArrayHandleType, NUM_COMPONENTS>),
|
||||
ArrayHandleGroupVec, (ArrayHandleGroupVec<SourceArrayHandleType, NUM_COMPONENTS>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
||||
vtkm::cont::internal::StorageTagGroupVec<
|
||||
SourceArrayHandleType, NUM_COMPONENTS> >));
|
||||
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>>));
|
||||
|
||||
typedef typename SourceArrayHandleType::ValueType ComponentType;
|
||||
|
||||
@ -346,7 +346,9 @@ private:
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleGroupVec(const SourceArrayHandleType& sourceArray)
|
||||
: Superclass(StorageType(sourceArray)) { }
|
||||
: Superclass(StorageType(sourceArray))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// \c make_ArrayHandleGroupVec is convenience function to generate an
|
||||
@ -354,15 +356,12 @@ public:
|
||||
/// (as a specified template parameter), and returns an array handle with
|
||||
/// consecutive entries grouped in a Vec.
|
||||
///
|
||||
template<vtkm::IdComponent NUM_COMPONENTS,
|
||||
typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleGroupVec<ArrayHandleType, NUM_COMPONENTS>
|
||||
make_ArrayHandleGroupVec(const ArrayHandleType &array)
|
||||
template <vtkm::IdComponent NUM_COMPONENTS, typename ArrayHandleType>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleGroupVec<ArrayHandleType, NUM_COMPONENTS> make_ArrayHandleGroupVec(
|
||||
const ArrayHandleType& array)
|
||||
{
|
||||
return vtkm::cont::ArrayHandleGroupVec<ArrayHandleType, NUM_COMPONENTS>(array);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -32,47 +32,53 @@
|
||||
|
||||
#include <vtkm/exec/arg/FetchTagArrayDirectOut.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename SourcePortalType, typename OffsetsPortalType>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalGroupVecVariable
|
||||
{
|
||||
public:
|
||||
using ComponentType =
|
||||
typename std::remove_const<typename SourcePortalType::ValueType>::type;
|
||||
using ComponentType = typename std::remove_const<typename SourcePortalType::ValueType>::type;
|
||||
using ValueType = vtkm::VecFromPortal<SourcePortalType>;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalGroupVecVariable() : SourcePortal(), OffsetsPortal() { }
|
||||
ArrayPortalGroupVecVariable()
|
||||
: SourcePortal()
|
||||
, OffsetsPortal()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalGroupVecVariable(const SourcePortalType& sourcePortal,
|
||||
const OffsetsPortalType& offsetsPortal)
|
||||
: SourcePortal(sourcePortal), OffsetsPortal(offsetsPortal) { }
|
||||
: SourcePortal(sourcePortal)
|
||||
, OffsetsPortal(offsetsPortal)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalConcatenate with a portal type
|
||||
/// that can be copied to this portal type. This allows us to do any type
|
||||
/// casting that the portals do (like the non-const to const cast).
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename OtherSourcePortalType, typename OtherOffsetsPortalType>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalGroupVecVariable(
|
||||
VTKM_EXEC_CONT ArrayPortalGroupVecVariable(
|
||||
const ArrayPortalGroupVecVariable<OtherSourcePortalType, OtherOffsetsPortalType>& src)
|
||||
: SourcePortal(src.GetSourcePortal()),
|
||||
OffsetsPortal(src.GetOffsetsPortal())
|
||||
{ }
|
||||
: SourcePortal(src.GetSourcePortal())
|
||||
, OffsetsPortal(src.GetOffsetsPortal())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->OffsetsPortal.GetNumberOfValues();
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->OffsetsPortal.GetNumberOfValues(); }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
@ -89,16 +95,13 @@ public:
|
||||
nextOffsetIndex = this->SourcePortal.GetNumberOfValues();
|
||||
}
|
||||
|
||||
return
|
||||
ValueType(this->SourcePortal,
|
||||
static_cast<vtkm::IdComponent>(nextOffsetIndex-offsetIndex),
|
||||
offsetIndex);
|
||||
return ValueType(this->SourcePortal,
|
||||
static_cast<vtkm::IdComponent>(nextOffsetIndex - offsetIndex), offsetIndex);
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index),
|
||||
const ValueType &vtkmNotUsed(value)) const
|
||||
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
|
||||
{
|
||||
// The ValueType (VecFromPortal) operates on demand. Thus, if you set
|
||||
// something in the value, it has already been passed to the array. Perhaps
|
||||
@ -108,17 +111,11 @@ public:
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
const SourcePortalType &GetSourcePortal() const
|
||||
{
|
||||
return this->SourcePortal;
|
||||
}
|
||||
const SourcePortalType& GetSourcePortal() const { return this->SourcePortal; }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
const OffsetsPortalType &GetOffsetsPortal() const
|
||||
{
|
||||
return this->OffsetsPortal;
|
||||
}
|
||||
const OffsetsPortalType& GetOffsetsPortal() const { return this->OffsetsPortal; }
|
||||
|
||||
private:
|
||||
SourcePortalType SourcePortal;
|
||||
@ -127,7 +124,8 @@ private:
|
||||
|
||||
} // namespace internal (in vtkm::exec)
|
||||
|
||||
namespace arg {
|
||||
namespace arg
|
||||
{
|
||||
|
||||
// We need to override the fetch for output fields using
|
||||
// ArrayPortalGroupVecVariable because this portal does not behave like most
|
||||
@ -136,33 +134,25 @@ namespace arg {
|
||||
// Instead, you need to implement the Load to point to the array portal. You
|
||||
// can also ignore the Store because the data is already set in the array at
|
||||
// that point.
|
||||
template<typename ThreadIndicesType,
|
||||
typename SourcePortalType,
|
||||
typename OffsetsPortalType>
|
||||
struct Fetch<
|
||||
vtkm::exec::arg::FetchTagArrayDirectOut,
|
||||
vtkm::exec::arg::AspectTagDefault,
|
||||
template <typename ThreadIndicesType, typename SourcePortalType, typename OffsetsPortalType>
|
||||
struct Fetch<vtkm::exec::arg::FetchTagArrayDirectOut, vtkm::exec::arg::AspectTagDefault,
|
||||
ThreadIndicesType,
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<SourcePortalType, OffsetsPortalType>>
|
||||
{
|
||||
using ExecObjectType =
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
SourcePortalType,OffsetsPortalType>;
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<SourcePortalType, OffsetsPortalType>;
|
||||
using ValueType = typename ExecObjectType::ValueType;
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
ValueType Load(const ThreadIndicesType &indices,
|
||||
const ExecObjectType &arrayPortal) const
|
||||
ValueType Load(const ThreadIndicesType& indices, const ExecObjectType& arrayPortal) const
|
||||
{
|
||||
return arrayPortal.Get(indices.GetOutputIndex());
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
void Store(const ThreadIndicesType &,
|
||||
const ExecObjectType &,
|
||||
const ValueType &) const
|
||||
void Store(const ThreadIndicesType&, const ExecObjectType&, const ValueType&) const
|
||||
{
|
||||
// We can actually ignore this because the VecFromPortal will already have
|
||||
// set new values in the array.
|
||||
@ -170,52 +160,56 @@ struct Fetch<
|
||||
};
|
||||
|
||||
} // namespace arg (in vtkm::exec)
|
||||
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename SourceArrayHandleType, typename OffsetsArrayHandleType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagGroupVecVariable { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagGroupVecVariable
|
||||
{
|
||||
};
|
||||
|
||||
template <typename SourceArrayHandleType, typename OffsetsArrayHandleType>
|
||||
class Storage<
|
||||
vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>,
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType> >
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<SourceArrayHandleType, OffsetsArrayHandleType>>
|
||||
{
|
||||
using ComponentType = typename SourceArrayHandleType::ValueType;
|
||||
|
||||
public:
|
||||
using ValueType =
|
||||
vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>;
|
||||
using ValueType = vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>;
|
||||
|
||||
using PortalType =
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
typename SourceArrayHandleType::PortalControl,
|
||||
typename OffsetsArrayHandleType::PortalControl>;
|
||||
using PortalConstType =
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
using PortalType = vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
typename SourceArrayHandleType::PortalControl, typename OffsetsArrayHandleType::PortalControl>;
|
||||
using PortalConstType = vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
typename SourceArrayHandleType::PortalConstControl,
|
||||
typename OffsetsArrayHandleType::PortalConstControl>;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const SourceArrayHandleType &sourceArray,
|
||||
const OffsetsArrayHandleType &offsetsArray)
|
||||
: SourceArray(sourceArray), OffsetsArray(offsetsArray), Valid(true) { }
|
||||
Storage(const SourceArrayHandleType& sourceArray, const OffsetsArrayHandleType& offsetsArray)
|
||||
: SourceArray(sourceArray)
|
||||
, OffsetsArray(offsetsArray)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal()
|
||||
{
|
||||
return PortalType(this->SourceArray.GetPortalControl(),
|
||||
this->OffsetsArray.GetPortalControl());
|
||||
return PortalType(this->SourceArray.GetPortalControl(), this->OffsetsArray.GetPortalControl());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -235,8 +229,7 @@ public:
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
VTKM_ASSERT(
|
||||
"Allocate not supported for ArrayhandleGroupVecVariable" && false);
|
||||
VTKM_ASSERT("Allocate not supported for ArrayhandleGroupVecVariable" && false);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -278,50 +271,41 @@ private:
|
||||
bool Valid;
|
||||
};
|
||||
|
||||
template<typename SourceArrayHandleType,
|
||||
typename OffsetsArrayHandleType,
|
||||
typename Device>
|
||||
template <typename SourceArrayHandleType, typename OffsetsArrayHandleType, typename Device>
|
||||
class ArrayTransfer<
|
||||
vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>,
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType>,
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<SourceArrayHandleType, OffsetsArrayHandleType>,
|
||||
Device>
|
||||
{
|
||||
public:
|
||||
using ComponentType = typename SourceArrayHandleType::ValueType;
|
||||
using ValueType =
|
||||
vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>;
|
||||
using ValueType = vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>;
|
||||
|
||||
private:
|
||||
using StorageTag =
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType>;
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<SourceArrayHandleType, OffsetsArrayHandleType>;
|
||||
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
|
||||
|
||||
public:
|
||||
using PortalControl = typename StorageType::PortalType;
|
||||
using PortalConstControl = typename StorageType::PortalConstType;
|
||||
|
||||
using PortalExecution =
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
using PortalExecution = vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
typename SourceArrayHandleType::template ExecutionTypes<Device>::Portal,
|
||||
typename OffsetsArrayHandleType::template ExecutionTypes<Device>::PortalConst>;
|
||||
using PortalConstExecution =
|
||||
vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
using PortalConstExecution = vtkm::exec::internal::ArrayPortalGroupVecVariable<
|
||||
typename SourceArrayHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
typename OffsetsArrayHandleType::template ExecutionTypes<Device>::PortalConst>;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: SourceArray(storage->GetSourceArray()),
|
||||
OffsetsArray(storage->GetOffsetsArray())
|
||||
{ }
|
||||
: SourceArray(storage->GetSourceArray())
|
||||
, OffsetsArray(storage->GetOffsetsArray())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->OffsetsArray.GetNumberOfValues();
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->OffsetsArray.GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
@ -342,8 +326,8 @@ public:
|
||||
{
|
||||
// Cannot reallocate an ArrayHandleGroupVecVariable
|
||||
VTKM_ASSERT(numberOfValues == this->OffsetsArray.GetNumberOfValues());
|
||||
return PortalExecution(this->SourceArray.PrepareForOutput(
|
||||
this->SourceArray.GetNumberOfValues(), Device()),
|
||||
return PortalExecution(
|
||||
this->SourceArray.PrepareForOutput(this->SourceArray.GetNumberOfValues(), Device()),
|
||||
this->OffsetsArray.PrepareForInput(Device()));
|
||||
}
|
||||
|
||||
@ -356,10 +340,7 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues)
|
||||
{
|
||||
this->OffsetsArray.Shrink(numberOfValues);
|
||||
}
|
||||
void Shrink(vtkm::Id numberOfValues) { this->OffsetsArray.Shrink(numberOfValues); }
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources()
|
||||
@ -411,8 +392,8 @@ template<typename SourceArrayHandleType, typename OffsetsArrayHandleType>
|
||||
class ArrayHandleGroupVecVariable
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>,
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType> >
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<SourceArrayHandleType,
|
||||
OffsetsArrayHandleType>>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(SourceArrayHandleType);
|
||||
VTKM_IS_ARRAY_HANDLE(OffsetsArrayHandleType);
|
||||
@ -421,8 +402,7 @@ public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleGroupVecVariable,
|
||||
(ArrayHandleGroupVecVariable<SourceArrayHandleType, OffsetsArrayHandleType>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>,
|
||||
(vtkm::cont::ArrayHandle<vtkm::VecFromPortal<typename SourceArrayHandleType::PortalControl>,
|
||||
vtkm::cont::internal::StorageTagGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType>>));
|
||||
|
||||
@ -435,7 +415,9 @@ public:
|
||||
VTKM_CONT
|
||||
ArrayHandleGroupVecVariable(const SourceArrayHandleType& sourceArray,
|
||||
const OffsetsArrayHandleType& offsetsArray)
|
||||
: Superclass(StorageType(sourceArray, offsetsArray)) { }
|
||||
: Superclass(StorageType(sourceArray, offsetsArray))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// \c make_ArrayHandleGroupVecVariable is convenience function to generate an
|
||||
@ -444,20 +426,18 @@ public:
|
||||
/// entries grouped in a Vec.
|
||||
///
|
||||
template <typename SourceArrayHandleType, typename OffsetsArrayHandleType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleGroupVecVariable<SourceArrayHandleType, OffsetsArrayHandleType>
|
||||
make_ArrayHandleGroupVecVariable(const SourceArrayHandleType& sourceArray,
|
||||
const OffsetsArrayHandleType& offsetsArray)
|
||||
{
|
||||
return vtkm::cont::ArrayHandleGroupVecVariable<
|
||||
SourceArrayHandleType, OffsetsArrayHandleType>(sourceArray, offsetsArray);
|
||||
return vtkm::cont::ArrayHandleGroupVecVariable<SourceArrayHandleType, OffsetsArrayHandleType>(
|
||||
sourceArray, offsetsArray);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename NumComponentsArrayType,
|
||||
typename OffsetsArrayType>
|
||||
template <typename NumComponentsArrayType, typename OffsetsArrayType>
|
||||
struct ConvertNumComponentsToOffsetsFunctor
|
||||
{
|
||||
const NumComponentsArrayType NumComponentsArray;
|
||||
@ -465,43 +445,38 @@ struct ConvertNumComponentsToOffsetsFunctor
|
||||
vtkm::Id SourceArraySize;
|
||||
|
||||
VTKM_CONT
|
||||
ConvertNumComponentsToOffsetsFunctor(
|
||||
const NumComponentsArrayType &numCompArray)
|
||||
: NumComponentsArray(numCompArray), SourceArraySize(0)
|
||||
{ }
|
||||
ConvertNumComponentsToOffsetsFunctor(const NumComponentsArrayType& numCompArray)
|
||||
: NumComponentsArray(numCompArray)
|
||||
, SourceArraySize(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT
|
||||
bool operator()(Device)
|
||||
VTKM_CONT bool operator()(Device)
|
||||
{
|
||||
this->SourceArraySize =
|
||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::
|
||||
ScanExclusive(this->NumComponentsArray, this->OffsetsArray);
|
||||
this->SourceArraySize = vtkm::cont::DeviceAdapterAlgorithm<Device>::ScanExclusive(
|
||||
this->NumComponentsArray, this->OffsetsArray);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename NumComponentsArrayType,
|
||||
typename OffsetsArrayType>
|
||||
VTKM_CONT
|
||||
void DoConvertNumComponentsToOffsets(
|
||||
const NumComponentsArrayType &numComponentsArray,
|
||||
template <typename NumComponentsArrayType, typename OffsetsArrayType>
|
||||
VTKM_CONT void DoConvertNumComponentsToOffsets(const NumComponentsArrayType& numComponentsArray,
|
||||
OffsetsArrayType& offsetsArray,
|
||||
vtkm::Id& sourceArraySize)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
|
||||
VTKM_IS_ARRAY_HANDLE(OffsetsArrayType);
|
||||
|
||||
detail::ConvertNumComponentsToOffsetsFunctor<
|
||||
NumComponentsArrayType,OffsetsArrayType> functor(numComponentsArray);
|
||||
detail::ConvertNumComponentsToOffsetsFunctor<NumComponentsArrayType, OffsetsArrayType> functor(
|
||||
numComponentsArray);
|
||||
bool success = vtkm::cont::TryExecute(functor);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
// Internal error? Maybe need to make a failed to execute error.
|
||||
throw vtkm::cont::ErrorInternal(
|
||||
"Failed to run ExclusiveScan on any device.");
|
||||
throw vtkm::cont::ErrorInternal("Failed to run ExclusiveScan on any device.");
|
||||
}
|
||||
|
||||
sourceArraySize = functor.SourceArraySize;
|
||||
@ -518,54 +493,41 @@ void DoConvertNumComponentsToOffsets(
|
||||
/// If an optional second parameter is given, the expected size of the source
|
||||
/// values array is returned in it.
|
||||
///
|
||||
template<typename NumComponentsArrayType,
|
||||
typename OffsetsStorage>
|
||||
VTKM_CONT
|
||||
void ConvertNumComponentsToOffsets(
|
||||
template <typename NumComponentsArrayType, typename OffsetsStorage>
|
||||
VTKM_CONT void ConvertNumComponentsToOffsets(
|
||||
const NumComponentsArrayType& numComponentsArray,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id,OffsetsStorage> &offsetsArray,
|
||||
vtkm::Id &sourceArraySize)
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage>& offsetsArray, vtkm::Id& sourceArraySize)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
|
||||
|
||||
detail::DoConvertNumComponentsToOffsets(
|
||||
vtkm::cont::make_ArrayHandleCast<vtkm::Id>(numComponentsArray),
|
||||
offsetsArray,
|
||||
sourceArraySize);
|
||||
vtkm::cont::make_ArrayHandleCast<vtkm::Id>(numComponentsArray), offsetsArray, sourceArraySize);
|
||||
}
|
||||
template<typename NumComponentsArrayType,
|
||||
typename OffsetsStorage>
|
||||
VTKM_CONT
|
||||
void ConvertNumComponentsToOffsets(
|
||||
template <typename NumComponentsArrayType, typename OffsetsStorage>
|
||||
VTKM_CONT void ConvertNumComponentsToOffsets(
|
||||
const NumComponentsArrayType& numComponentsArray,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorage>& offsetsArray)
|
||||
{
|
||||
vtkm::Id dummy;
|
||||
vtkm::cont::ConvertNumComponentsToOffsets(
|
||||
numComponentsArray, offsetsArray, dummy);
|
||||
vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, offsetsArray, dummy);
|
||||
}
|
||||
template <typename NumComponentsArrayType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>
|
||||
ConvertNumComponentsToOffsets(const NumComponentsArrayType &numComponentsArray,
|
||||
vtkm::Id &sourceArraySize)
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
|
||||
const NumComponentsArrayType& numComponentsArray, vtkm::Id& sourceArraySize)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(NumComponentsArrayType);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray;
|
||||
vtkm::cont::ConvertNumComponentsToOffsets(
|
||||
numComponentsArray, offsetsArray, sourceArraySize);
|
||||
vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, offsetsArray, sourceArraySize);
|
||||
return offsetsArray;
|
||||
}
|
||||
template <typename NumComponentsArrayType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>
|
||||
ConvertNumComponentsToOffsets(const NumComponentsArrayType &numComponentsArray)
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Id> ConvertNumComponentsToOffsets(
|
||||
const NumComponentsArrayType& numComponentsArray)
|
||||
{
|
||||
vtkm::Id dummy;
|
||||
return vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, dummy);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -25,11 +25,13 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
/// \brief An array portal that returns the result of a functor
|
||||
///
|
||||
/// This array portal is similar to an implicit array i.e an array that is
|
||||
@ -47,15 +49,18 @@ public:
|
||||
typedef FunctorType_ FunctorType;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalImplicit() :
|
||||
Functor(),
|
||||
NumberOfValues(0) { }
|
||||
ArrayPortalImplicit()
|
||||
: Functor()
|
||||
, NumberOfValues(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalImplicit(FunctorType f, vtkm::Id numValues) :
|
||||
Functor(f),
|
||||
NumberOfValues(numValues)
|
||||
{ }
|
||||
ArrayPortalImplicit(FunctorType f, vtkm::Id numValues)
|
||||
: Functor(f)
|
||||
, NumberOfValues(numValues)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
|
||||
@ -65,22 +70,18 @@ public:
|
||||
ValueType Get(vtkm::Id index) const { return this->Functor(index); }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index),
|
||||
const ValueType &vtkmNotUsed(value)) const
|
||||
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
|
||||
{
|
||||
#if !(defined(VTKM_MSVC) && defined(VTKM_CUDA))
|
||||
VTKM_ASSERT(false && "Cannot write to read-only implicit array.");
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef vtkm::cont::internal::IteratorFromArrayPortal<
|
||||
ArrayPortalImplicit<ValueType,FunctorType> > IteratorType;
|
||||
typedef vtkm::cont::internal::IteratorFromArrayPortal<ArrayPortalImplicit<ValueType, FunctorType>>
|
||||
IteratorType;
|
||||
|
||||
VTKM_CONT
|
||||
IteratorType GetIteratorBegin() const
|
||||
{
|
||||
return IteratorType(*this);
|
||||
}
|
||||
IteratorType GetIteratorBegin() const { return IteratorType(*this); }
|
||||
|
||||
private:
|
||||
FunctorType Functor;
|
||||
@ -93,14 +94,13 @@ template<typename ValueType, typename FunctorType>
|
||||
struct ArrayHandleImplicitTraits
|
||||
{
|
||||
typedef vtkm::cont::StorageTagImplicit<
|
||||
vtkm::cont::detail::ArrayPortalImplicit<ValueType,
|
||||
FunctorType> > StorageTag;
|
||||
vtkm::cont::detail::ArrayPortalImplicit<ValueType, FunctorType>>
|
||||
StorageTag;
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, StorageTag> Superclass;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
/// \brief An \c ArrayHandle that computes values on the fly.
|
||||
///
|
||||
/// \c ArrayHandleImplicit is a specialization of ArrayHandle.
|
||||
@ -108,24 +108,21 @@ struct ArrayHandleImplicitTraits
|
||||
/// The functor returns the result of the functor as the value of this
|
||||
/// array at that position.
|
||||
///
|
||||
template <typename T,
|
||||
class FunctorType>
|
||||
class ArrayHandleImplicit
|
||||
: public detail::ArrayHandleImplicitTraits<T,FunctorType>::Superclass
|
||||
template <typename T, class FunctorType>
|
||||
class ArrayHandleImplicit : public detail::ArrayHandleImplicitTraits<T, FunctorType>::Superclass
|
||||
{
|
||||
private:
|
||||
typedef typename detail::ArrayHandleImplicitTraits<T, FunctorType> ArrayTraits;
|
||||
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleImplicit,
|
||||
(ArrayHandleImplicit<T,FunctorType>),
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleImplicit, (ArrayHandleImplicit<T, FunctorType>),
|
||||
(typename ArrayTraits::Superclass));
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandleImplicit(FunctorType functor, vtkm::Id length)
|
||||
: Superclass(typename Superclass::PortalConstControl(functor, length))
|
||||
{ }
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// make_ArrayHandleImplicit is convenience function to generate an
|
||||
@ -133,14 +130,11 @@ public:
|
||||
/// arry.
|
||||
|
||||
template <typename T, typename FunctorType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleImplicit<T, FunctorType>
|
||||
make_ArrayHandleImplicit(FunctorType functor, vtkm::Id length)
|
||||
VTKM_CONT vtkm::cont::ArrayHandleImplicit<T, FunctorType> make_ArrayHandleImplicit(
|
||||
FunctorType functor, vtkm::Id length)
|
||||
{
|
||||
return ArrayHandleImplicit<T, FunctorType>(functor, length);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -24,12 +24,16 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleImplicit.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT IndexFunctor {
|
||||
struct VTKM_ALWAYS_EXPORT IndexFunctor
|
||||
{
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id operator()(vtkm::Id index) const { return index; }
|
||||
};
|
||||
@ -42,19 +46,18 @@ struct VTKM_ALWAYS_EXPORT IndexFunctor {
|
||||
/// 0, 1, 2, 3,... to a specified size. Every value in the array is the same
|
||||
/// as the index to that value.
|
||||
///
|
||||
class ArrayHandleIndex
|
||||
: public vtkm::cont::ArrayHandleImplicit<vtkm::Id, detail::IndexFunctor>
|
||||
class ArrayHandleIndex : public vtkm::cont::ArrayHandleImplicit<vtkm::Id, detail::IndexFunctor>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS_NT(
|
||||
ArrayHandleIndex,
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandleIndex,
|
||||
(vtkm::cont::ArrayHandleImplicit<vtkm::Id, detail::IndexFunctor>));
|
||||
|
||||
VTKM_CONT
|
||||
ArrayHandleIndex(vtkm::Id length)
|
||||
: Superclass(detail::IndexFunctor(), length) { }
|
||||
: Superclass(detail::IndexFunctor(), length)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -26,9 +26,12 @@
|
||||
#include <vtkm/cont/ErrorBadType.h>
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename IndexPortalType, typename ValuePortalType>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalPermutation
|
||||
@ -39,14 +42,18 @@ public:
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalPermutation()
|
||||
: IndexPortal(), ValuePortal() { }
|
||||
: IndexPortal()
|
||||
, ValuePortal()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalPermutation(
|
||||
const IndexPortalType &indexPortal,
|
||||
const ValuePortalType &valuePortal)
|
||||
: IndexPortal(indexPortal), ValuePortal(valuePortal) { }
|
||||
ArrayPortalPermutation(const IndexPortalType& indexPortal, const ValuePortalType& valuePortal)
|
||||
: IndexPortal(indexPortal)
|
||||
, ValuePortal(valuePortal)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalPermutation with delegate
|
||||
/// portal types that can be copied to these portal types. This allows us to
|
||||
@ -55,28 +62,28 @@ public:
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename OtherIP, typename OtherVP>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalPermutation(
|
||||
const ArrayPortalPermutation<OtherIP,OtherVP> &src)
|
||||
: IndexPortal(src.GetIndexPortal()), ValuePortal(src.GetValuePortal())
|
||||
{ }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->IndexPortal.GetNumberOfValues();
|
||||
VTKM_EXEC_CONT ArrayPortalPermutation(const ArrayPortalPermutation<OtherIP, OtherVP>& src)
|
||||
: IndexPortal(src.GetIndexPortal())
|
||||
, ValuePortal(src.GetValuePortal())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->IndexPortal.GetNumberOfValues(); }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
vtkm::Id permutedIndex = this->IndexPortal.Get(index);
|
||||
return this->ValuePortal.Get(permutedIndex);
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
void Set(vtkm::Id index, const ValueType &value) const {
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
vtkm::Id permutedIndex = this->IndexPortal.Get(index);
|
||||
this->ValuePortal.Set(permutedIndex, value);
|
||||
}
|
||||
@ -93,22 +100,25 @@ private:
|
||||
IndexPortalType IndexPortal;
|
||||
ValuePortalType ValuePortal;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::internal
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename IndexArrayType, typename ValueArrayType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagPermutation { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagPermutation
|
||||
{
|
||||
};
|
||||
|
||||
template <typename IndexArrayType, typename ValueArrayType>
|
||||
class Storage<
|
||||
typename ValueArrayType::ValueType,
|
||||
class Storage<typename ValueArrayType::ValueType,
|
||||
StorageTagPermutation<IndexArrayType, ValueArrayType>>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(IndexArrayType);
|
||||
@ -117,54 +127,65 @@ class Storage<
|
||||
public:
|
||||
typedef typename ValueArrayType::ValueType ValueType;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalPermutation<
|
||||
typename IndexArrayType::PortalConstControl,
|
||||
typename ValueArrayType::PortalControl> PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalPermutation<
|
||||
typename IndexArrayType::PortalConstControl,
|
||||
typename ValueArrayType::PortalConstControl> PortalConstType;
|
||||
typedef vtkm::exec::internal::ArrayPortalPermutation<typename IndexArrayType::PortalConstControl,
|
||||
typename ValueArrayType::PortalControl>
|
||||
PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalPermutation<typename IndexArrayType::PortalConstControl,
|
||||
typename ValueArrayType::PortalConstControl>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const IndexArrayType& indexArray, const ValueArrayType& valueArray)
|
||||
: IndexArray(indexArray), ValueArray(valueArray), Valid(true) { }
|
||||
: IndexArray(indexArray)
|
||||
, ValueArray(valueArray)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() {
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->IndexArray.GetPortalConstControl(),
|
||||
this->ValueArray.GetPortalControl());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const {
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->IndexArray.GetPortalConstControl(),
|
||||
this->ValueArray.GetPortalConstControl());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->IndexArray.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandlePermutation cannot be allocated.");
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandlePermutation cannot be allocated.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandlePermutation cannot shrink.");
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandlePermutation cannot shrink.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
// This request is ignored since it is asking to release the resources
|
||||
// of the delegate array, which may be used elsewhere. Should the behavior
|
||||
// be different?
|
||||
@ -183,10 +204,8 @@ private:
|
||||
};
|
||||
|
||||
template <typename IndexArrayType, typename ValueArrayType, typename Device>
|
||||
class ArrayTransfer<
|
||||
typename ValueArrayType::ValueType,
|
||||
StorageTagPermutation<IndexArrayType, ValueArrayType>,
|
||||
Device>
|
||||
class ArrayTransfer<typename ValueArrayType::ValueType,
|
||||
StorageTagPermutation<IndexArrayType, ValueArrayType>, Device>
|
||||
{
|
||||
public:
|
||||
typedef typename ValueArrayType::ValueType ValueType;
|
||||
@ -210,22 +229,24 @@ public:
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: IndexArray(storage->GetIndexArray()),
|
||||
ValueArray(storage->GetValueArray()) { }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->IndexArray.GetNumberOfValues();
|
||||
: IndexArray(storage->GetIndexArray())
|
||||
, ValueArray(storage->GetValueArray())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) {
|
||||
vtkm::Id GetNumberOfValues() const { return this->IndexArray.GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalConstExecution(this->IndexArray.PrepareForInput(Device()),
|
||||
this->ValueArray.PrepareForInput(Device()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData)) {
|
||||
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalExecution(this->IndexArray.PrepareForInput(Device()),
|
||||
this->ValueArray.PrepareForInPlace(Device()));
|
||||
}
|
||||
@ -233,7 +254,8 @@ public:
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
|
||||
{
|
||||
if (numberOfValues != this->GetNumberOfValues()) {
|
||||
if (numberOfValues != this->GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"An ArrayHandlePermutation can be used as an output array, "
|
||||
"but it cannot be resized. Make sure the index array is sized "
|
||||
@ -251,26 +273,28 @@ public:
|
||||
"output of ArrayHandlePermutation.");
|
||||
}
|
||||
|
||||
return PortalExecution(this->IndexArray.PrepareForInput(Device()),
|
||||
this->ValueArray.PrepareForOutput(
|
||||
this->ValueArray.GetNumberOfValues(), Device()));
|
||||
return PortalExecution(
|
||||
this->IndexArray.PrepareForInput(Device()),
|
||||
this->ValueArray.PrepareForOutput(this->ValueArray.GetNumberOfValues(), Device()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const {
|
||||
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
||||
{
|
||||
// Implementation of this method should be unnecessary. The internal
|
||||
// array handles should automatically retrieve the output data as
|
||||
// necessary.
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandlePermutation cannot shrink.");
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandlePermutation cannot shrink.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
this->IndexArray.ReleaseResourcesExecution();
|
||||
this->ValueArray.ReleaseResourcesExecution();
|
||||
}
|
||||
@ -318,22 +342,21 @@ class ArrayHandlePermutation
|
||||
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandlePermutation,
|
||||
(ArrayHandlePermutation<IndexArrayHandleType,ValueArrayHandleType>),
|
||||
ArrayHandlePermutation, (ArrayHandlePermutation<IndexArrayHandleType, ValueArrayHandleType>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
typename ValueArrayHandleType::ValueType,
|
||||
internal::StorageTagPermutation<
|
||||
IndexArrayHandleType,ValueArrayHandleType> >));
|
||||
internal::StorageTagPermutation<IndexArrayHandleType, ValueArrayHandleType>>));
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag>
|
||||
StorageType;
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandlePermutation(const IndexArrayHandleType& indexArray,
|
||||
const ValueArrayHandleType& valueArray)
|
||||
: Superclass(StorageType(indexArray, valueArray)) { }
|
||||
: Superclass(StorageType(indexArray, valueArray))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// make_ArrayHandleTransform is convenience function to generate an
|
||||
@ -341,15 +364,11 @@ private:
|
||||
/// to apply to each element of the Handle.
|
||||
|
||||
template <typename IndexArrayHandleType, typename ValueArrayHandleType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandlePermutation<IndexArrayHandleType, ValueArrayHandleType>
|
||||
make_ArrayHandlePermutation(IndexArrayHandleType indexArray,
|
||||
ValueArrayHandleType valueArray)
|
||||
VTKM_CONT vtkm::cont::ArrayHandlePermutation<IndexArrayHandleType, ValueArrayHandleType>
|
||||
make_ArrayHandlePermutation(IndexArrayHandleType indexArray, ValueArrayHandleType valueArray)
|
||||
{
|
||||
return ArrayHandlePermutation<IndexArrayHandleType,ValueArrayHandleType>(
|
||||
indexArray, valueArray);
|
||||
return ArrayHandlePermutation<IndexArrayHandleType, ValueArrayHandleType>(indexArray, valueArray);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -20,16 +20,18 @@
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifndef vtk_m_cont_ArrayHandleReverse_h
|
||||
#define vtk_m_cont_ArrayHandleReverse_h
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename PortalType>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalReverse
|
||||
@ -38,33 +40,40 @@ public:
|
||||
typedef typename PortalType::ValueType ValueType;
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalReverse() : portal() {}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalReverse(const PortalType &p) : portal(p) {}
|
||||
|
||||
template< typename OtherPortal >
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalReverse(const ArrayPortalReverse<OtherPortal> &src) : portal(src.GetPortal()) {}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->portal.GetNumberOfValues();
|
||||
ArrayPortalReverse()
|
||||
: portal()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
ArrayPortalReverse(const PortalType& p)
|
||||
: portal(p)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OtherPortal>
|
||||
VTKM_EXEC_CONT ArrayPortalReverse(const ArrayPortalReverse<OtherPortal>& src)
|
||||
: portal(src.GetPortal())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->portal.GetNumberOfValues(); }
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
return this->portal.Get(portal.GetNumberOfValues() - index - 1);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id index, const ValueType &value) const {
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
this->portal1.Set(portal.GetNumberOfValues() - index - 1, value);
|
||||
}
|
||||
|
||||
private:
|
||||
PortalType portal;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@ -73,7 +82,8 @@ class StorageTagReverse
|
||||
{
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
class Storage<typename ArrayHandleType::ValueType, StorageTagReverse<ArrayHandleType>>
|
||||
@ -84,11 +94,15 @@ public:
|
||||
typedef ArrayPortalReverse<typename ArrayHandleType::PortalConstControl> PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : valid( false ) { }
|
||||
Storage()
|
||||
: valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const ArrayHandleType& a1)
|
||||
: array( a1 ), valid( true ) {};
|
||||
: array(a1)
|
||||
, valid(true){};
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
@ -114,8 +128,7 @@ public:
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorInternal(
|
||||
"ArrayHandleReverse should not be allocated explicitly. " );
|
||||
throw vtkm::cont::ErrorInternal("ArrayHandleReverse should not be allocated explicitly. ");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -159,18 +172,19 @@ public:
|
||||
typedef typename StorageType::PortalType PortalControl;
|
||||
typedef typename StorageType::PortalConstType PortalConstControl;
|
||||
|
||||
typedef ArrayPortalReverse<typename ArrayHandleType::template ExecutionTypes< Device >::Portal> PortalExecution;
|
||||
typedef ArrayPortalReverse<typename ArrayHandleType::template ExecutionTypes< Device >::PortalConst> PortalConstExecution;
|
||||
typedef ArrayPortalReverse<typename ArrayHandleType::template ExecutionTypes<Device>::Portal>
|
||||
PortalExecution;
|
||||
typedef ArrayPortalReverse<typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst>
|
||||
PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: array( storage->GetArray() ) {}
|
||||
: array(storage->GetArray())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->array.GetNumberOfValues();
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->array.GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
@ -204,10 +218,7 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources()
|
||||
{
|
||||
this->array.ReleaseResourcesExecution();
|
||||
}
|
||||
void ReleaseResources() { this->array.ReleaseResourcesExecution(); }
|
||||
|
||||
private:
|
||||
ArrayHandleType array;
|
||||
@ -227,27 +238,28 @@ class ArrayHandleReverse : public vtkm::cont::ArrayHandle<typename ArrayHandleTy
|
||||
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleReverse,
|
||||
(ArrayHandleReverse<ArrayHandleType>),
|
||||
(vtkm::cont::ArrayHandle<typename ArrayHandleType::ValueType, StorageTagReverse<ArrayHandleType> >));
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleReverse, (ArrayHandleReverse<ArrayHandleType>),
|
||||
(vtkm::cont::ArrayHandle<typename ArrayHandleType::ValueType,
|
||||
StorageTagReverse<ArrayHandleType>>));
|
||||
|
||||
protected:
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
ArrayHandleReverse(const ArrayHandleType& handle)
|
||||
: Superclass(handle) {}
|
||||
: Superclass(handle)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// make_ArrayHandleReverse is convenience function to generate an
|
||||
/// ArrayHandleReverse.
|
||||
///
|
||||
template <typename HandleType>
|
||||
VTKM_CONT
|
||||
ArrayHandleReverse<HandleType> make_ArrayHandleReverse(const HandleType &handle) {
|
||||
VTKM_CONT ArrayHandleReverse<HandleType> make_ArrayHandleReverse(const HandleType& handle)
|
||||
{
|
||||
return ArrayHandleReverse<HandleType>(handle);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -23,9 +23,12 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayPortal.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename P>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalStreaming
|
||||
@ -35,34 +38,45 @@ public:
|
||||
typedef typename PortalType::ValueType ValueType;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayPortalStreaming() : InputPortal(), BlockIndex(0), BlockSize(0), CurBlockSize(0) { }
|
||||
|
||||
VTKM_CONT
|
||||
ArrayPortalStreaming(const PortalType &inputPortal, vtkm::Id blockIndex,
|
||||
vtkm::Id blockSize, vtkm::Id curBlockSize) :
|
||||
InputPortal(inputPortal), BlockIndex(blockIndex),
|
||||
BlockSize(blockSize), CurBlockSize(curBlockSize) { }
|
||||
|
||||
template<typename OtherP>
|
||||
VTKM_CONT
|
||||
ArrayPortalStreaming(const ArrayPortalStreaming<OtherP> &src) :
|
||||
InputPortal(src.GetPortal()),
|
||||
BlockIndex(src.GetBlockIndex()),
|
||||
BlockSize(src.GetBlockSize()),
|
||||
CurBlockSize(src.GetCurBlockSize()) { }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->CurBlockSize;
|
||||
ArrayPortalStreaming()
|
||||
: InputPortal()
|
||||
, BlockIndex(0)
|
||||
, BlockSize(0)
|
||||
, CurBlockSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
ArrayPortalStreaming(const PortalType& inputPortal, vtkm::Id blockIndex, vtkm::Id blockSize,
|
||||
vtkm::Id curBlockSize)
|
||||
: InputPortal(inputPortal)
|
||||
, BlockIndex(blockIndex)
|
||||
, BlockSize(blockSize)
|
||||
, CurBlockSize(curBlockSize)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OtherP>
|
||||
VTKM_CONT ArrayPortalStreaming(const ArrayPortalStreaming<OtherP>& src)
|
||||
: InputPortal(src.GetPortal())
|
||||
, BlockIndex(src.GetBlockIndex())
|
||||
, BlockSize(src.GetBlockSize())
|
||||
, CurBlockSize(src.GetCurBlockSize())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->CurBlockSize; }
|
||||
|
||||
VTKM_CONT
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
return this->InputPortal.Get(this->BlockIndex * this->BlockSize + index);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Set(vtkm::Id index, const ValueType &value) const {
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
this->InputPortal.Set(this->BlockIndex * this->BlockSize + index, value);
|
||||
}
|
||||
|
||||
@ -97,78 +111,95 @@ private:
|
||||
} // internal
|
||||
|
||||
template <typename ArrayHandleInputType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagStreaming { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagStreaming
|
||||
{
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename ArrayHandleInputType>
|
||||
class Storage<
|
||||
typename ArrayHandleInputType::ValueType,
|
||||
StorageTagStreaming<ArrayHandleInputType> >
|
||||
class Storage<typename ArrayHandleInputType::ValueType, StorageTagStreaming<ArrayHandleInputType>>
|
||||
{
|
||||
public:
|
||||
typedef typename ArrayHandleInputType::ValueType ValueType;
|
||||
|
||||
typedef vtkm::cont::internal::ArrayPortalStreaming<typename ArrayHandleInputType::PortalControl>
|
||||
PortalType;
|
||||
typedef vtkm::cont::internal::ArrayPortalStreaming<
|
||||
typename ArrayHandleInputType::PortalControl> PortalType;
|
||||
typedef vtkm::cont::internal::ArrayPortalStreaming<
|
||||
typename ArrayHandleInputType::PortalConstControl> PortalConstType;
|
||||
typename ArrayHandleInputType::PortalConstControl>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const ArrayHandleInputType inputArray, vtkm::Id blockSize,
|
||||
vtkm::Id blockIndex, vtkm::Id curBlockSize) :
|
||||
InputArray(inputArray), BlockSize(blockSize),
|
||||
BlockIndex(blockIndex), CurBlockSize(curBlockSize), Valid(true) { }
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() {
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->InputArray.GetPortalControl(),
|
||||
BlockSize, BlockIndex, CurBlockSize);
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const {
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->InputArray.GetPortalConstControl(),
|
||||
BlockSize, BlockIndex, CurBlockSize);
|
||||
Storage(const ArrayHandleInputType inputArray, vtkm::Id blockSize, vtkm::Id blockIndex,
|
||||
vtkm::Id curBlockSize)
|
||||
: InputArray(inputArray)
|
||||
, BlockSize(blockSize)
|
||||
, BlockIndex(blockIndex)
|
||||
, CurBlockSize(curBlockSize)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->InputArray.GetPortalControl(), BlockSize, BlockIndex, CurBlockSize);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->InputArray.GetPortalConstControl(), BlockSize, BlockIndex,
|
||||
CurBlockSize);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return CurBlockSize;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id numberOfValues) const {
|
||||
void Allocate(vtkm::Id numberOfValues) const
|
||||
{
|
||||
(void)numberOfValues;
|
||||
// Do nothing, since we only allocate a streaming array once at the beginning
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AllocateFullArray(vtkm::Id numberOfValues) {
|
||||
void AllocateFullArray(vtkm::Id numberOfValues)
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
this->InputArray.Allocate(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues) {
|
||||
void Shrink(vtkm::Id numberOfValues)
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
this->InputArray.Shrink(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
this->InputArray.ReleaseResources();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const ArrayHandleInputType &GetArray() const {
|
||||
const ArrayHandleInputType& GetArray() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->InputArray;
|
||||
}
|
||||
@ -180,26 +211,23 @@ private:
|
||||
vtkm::Id CurBlockSize;
|
||||
bool Valid;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <typename ArrayHandleInputType>
|
||||
class ArrayHandleStreaming
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
typename ArrayHandleInputType::ValueType,
|
||||
: public vtkm::cont::ArrayHandle<typename ArrayHandleInputType::ValueType,
|
||||
StorageTagStreaming<ArrayHandleInputType>>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleStreaming,
|
||||
(ArrayHandleStreaming<ArrayHandleInputType>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
typename ArrayHandleInputType::ValueType,
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleStreaming, (ArrayHandleStreaming<ArrayHandleInputType>),
|
||||
(vtkm::cont::ArrayHandle<typename ArrayHandleInputType::ValueType,
|
||||
StorageTagStreaming<ArrayHandleInputType>>));
|
||||
|
||||
private:
|
||||
@ -207,9 +235,8 @@ private:
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleStreaming(const ArrayHandleInputType &inputArray,
|
||||
const vtkm::Id blockIndex, const vtkm::Id blockSize,
|
||||
const vtkm::Id curBlockSize)
|
||||
ArrayHandleStreaming(const ArrayHandleInputType& inputArray, const vtkm::Id blockIndex,
|
||||
const vtkm::Id blockSize, const vtkm::Id curBlockSize)
|
||||
: Superclass(StorageType(inputArray, blockIndex, blockSize, curBlockSize))
|
||||
{
|
||||
this->GetPortalConstControl().SetBlockIndex(blockIndex);
|
||||
@ -218,14 +245,13 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AllocateFullArray(vtkm::Id numberOfValues) {
|
||||
void AllocateFullArray(vtkm::Id numberOfValues)
|
||||
{
|
||||
this->ReleaseResourcesExecutionInternal();
|
||||
this->Internals->ControlArray.AllocateFullArray(numberOfValues);
|
||||
this->Internals->ControlArrayValid = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,20 +26,27 @@
|
||||
#include <vtkm/cont/ErrorBadType.h>
|
||||
#include <vtkm/cont/ErrorInternal.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// Tag used in place of an inverse functor.
|
||||
struct NullFunctorType {};
|
||||
|
||||
struct NullFunctorType
|
||||
{
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont::internal
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
typedef vtkm::cont::internal::NullFunctorType NullFunctorType;
|
||||
|
||||
@ -50,7 +57,8 @@ template<typename ValueType_, typename PortalType_, typename FunctorType_,
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalTransform;
|
||||
|
||||
template <typename ValueType_, typename PortalType_, typename FunctorType_>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType>
|
||||
class VTKM_ALWAYS_EXPORT
|
||||
ArrayPortalTransform<ValueType_, PortalType_, FunctorType_, NullFunctorType>
|
||||
{
|
||||
public:
|
||||
typedef PortalType_ PortalType;
|
||||
@ -61,8 +69,10 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalTransform(const PortalType& portal = PortalType(),
|
||||
const FunctorType& functor = FunctorType())
|
||||
: Portal(portal), Functor(functor)
|
||||
{ }
|
||||
: Portal(portal)
|
||||
, Functor(functor)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalTransform with an iterator
|
||||
/// type that can be copied to this iterator type. This allows us to do any
|
||||
@ -70,31 +80,27 @@ public:
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <class OtherV, class OtherP, class OtherF>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalTransform(const ArrayPortalTransform<OtherV,OtherP,OtherF> &src)
|
||||
: Portal(src.GetPortal()),
|
||||
Functor(src.GetFunctor())
|
||||
{ }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->Portal.GetNumberOfValues();
|
||||
VTKM_EXEC_CONT ArrayPortalTransform(const ArrayPortalTransform<OtherV, OtherP, OtherF>& src)
|
||||
: Portal(src.GetPortal())
|
||||
, Functor(src.GetFunctor())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
return this->Functor(this->Portal.Get(index));
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->Portal.GetNumberOfValues(); }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index),
|
||||
const ValueType &vtkmNotUsed(value)) const
|
||||
ValueType Get(vtkm::Id index) const { return this->Functor(this->Portal.Get(index)); }
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id vtkmNotUsed(index), const ValueType& vtkmNotUsed(value)) const
|
||||
{
|
||||
#if !(defined(VTKM_MSVC) && defined(VTKM_CUDA))
|
||||
VTKM_ASSERT(false && "Cannot write to read-only transform array. (No inverse transform given.)");
|
||||
VTKM_ASSERT(false &&
|
||||
"Cannot write to read-only transform array. (No inverse transform given.)");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -111,9 +117,10 @@ protected:
|
||||
FunctorType Functor;
|
||||
};
|
||||
|
||||
template<typename ValueType_, typename PortalType_,
|
||||
typename FunctorType_, typename InverseFunctorType_>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalTransform : public ArrayPortalTransform<ValueType_,PortalType_,FunctorType_,NullFunctorType>
|
||||
template <typename ValueType_, typename PortalType_, typename FunctorType_,
|
||||
typename InverseFunctorType_>
|
||||
class VTKM_ALWAYS_EXPORT ArrayPortalTransform
|
||||
: public ArrayPortalTransform<ValueType_, PortalType_, FunctorType_, NullFunctorType>
|
||||
{
|
||||
public:
|
||||
typedef ArrayPortalTransform<ValueType_, PortalType_, FunctorType_, NullFunctorType> Superclass;
|
||||
@ -127,45 +134,51 @@ public:
|
||||
ArrayPortalTransform(const PortalType& portal = PortalType(),
|
||||
const FunctorType& functor = FunctorType(),
|
||||
const InverseFunctorType& inverseFunctor = InverseFunctorType())
|
||||
: Superclass(portal,functor), InverseFunctor(inverseFunctor)
|
||||
{ }
|
||||
: Superclass(portal, functor)
|
||||
, InverseFunctor(inverseFunctor)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <class OtherV, class OtherP, class OtherF, class OtherInvF>
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalTransform(const ArrayPortalTransform<OtherV,OtherP,OtherF,OtherInvF> &src)
|
||||
: Superclass(src), InverseFunctor(src.GetInverseFunctor())
|
||||
{ }
|
||||
VTKM_EXEC_CONT ArrayPortalTransform(
|
||||
const ArrayPortalTransform<OtherV, OtherP, OtherF, OtherInvF>& src)
|
||||
: Superclass(src)
|
||||
, InverseFunctor(src.GetInverseFunctor())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
void Set(vtkm::Id index, const ValueType& value) const {
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
return this->Portal.Set(index, this->InverseFunctor(value));
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
const InverseFunctorType &GetInverseFunctor() const {
|
||||
return this->InverseFunctor; }
|
||||
const InverseFunctorType& GetInverseFunctor() const { return this->InverseFunctor; }
|
||||
|
||||
private:
|
||||
InverseFunctorType InverseFunctor;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::internal
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename ValueType, typename ArrayHandleType, typename FunctorType,
|
||||
typename InverseFunctorType = NullFunctorType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagTransform {};
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagTransform
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType>
|
||||
class Storage<T, StorageTagTransform<T, ArrayHandleType, FunctorType, NullFunctorType>>
|
||||
@ -186,62 +199,69 @@ public:
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const ArrayHandleType &array,
|
||||
const FunctorType &functor = FunctorType())
|
||||
: Array(array), Functor(functor), Valid(true) { }
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() {
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->Array.GetPortalControl(),
|
||||
this->Functor);
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const {
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->Array.GetPortalConstControl(),
|
||||
this->Functor);
|
||||
Storage(const ArrayHandleType& array, const FunctorType& functor = FunctorType())
|
||||
: Array(array)
|
||||
, Functor(functor)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->Array.GetPortalControl(), this->Functor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->Array.GetPortalConstControl(), this->Functor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->Array.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandleTransform is read only. It cannot be allocated.");
|
||||
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandleTransform is read only. It cannot be allocated.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandleTransform is read only. It cannot shrink.");
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandleTransform is read only. It cannot shrink.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
// This request is ignored since it is asking to release the resources
|
||||
// of the delegate array, which may be used elsewhere. Should the behavior
|
||||
// be different?
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const ArrayHandleType &GetArray() const {
|
||||
const ArrayHandleType& GetArray() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->Array;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const FunctorType &GetFunctor() const {
|
||||
return this->Functor;
|
||||
}
|
||||
const FunctorType& GetFunctor() const { return this->Functor; }
|
||||
|
||||
private:
|
||||
ArrayHandleType Array;
|
||||
@ -249,84 +269,86 @@ private:
|
||||
bool Valid;
|
||||
};
|
||||
|
||||
template<typename T, typename ArrayHandleType, typename FunctorType,
|
||||
typename InverseFunctorType>
|
||||
class Storage<T,
|
||||
StorageTagTransform<T, ArrayHandleType, FunctorType, InverseFunctorType> >
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType, typename InverseFunctorType>
|
||||
class Storage<T, StorageTagTransform<T, ArrayHandleType, FunctorType, InverseFunctorType>>
|
||||
{
|
||||
public:
|
||||
typedef T ValueType;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<ValueType,
|
||||
typename ArrayHandleType::PortalControl, FunctorType, InverseFunctorType>
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<
|
||||
ValueType, typename ArrayHandleType::PortalControl, FunctorType, InverseFunctorType>
|
||||
PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<ValueType,
|
||||
typename ArrayHandleType::PortalConstControl,FunctorType,InverseFunctorType>
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<
|
||||
ValueType, typename ArrayHandleType::PortalConstControl, FunctorType, InverseFunctorType>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : Valid(false) { }
|
||||
Storage()
|
||||
: Valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const ArrayHandleType &array,
|
||||
const FunctorType &functor,
|
||||
Storage(const ArrayHandleType& array, const FunctorType& functor,
|
||||
const InverseFunctorType& inverseFunctor)
|
||||
: Array(array), Functor(functor), InverseFunctor(inverseFunctor), Valid(true) { }
|
||||
: Array(array)
|
||||
, Functor(functor)
|
||||
, InverseFunctor(inverseFunctor)
|
||||
, Valid(true)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() {
|
||||
PortalType GetPortal()
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalType(this->Array.GetPortalControl(),
|
||||
this->Functor,
|
||||
return PortalType(this->Array.GetPortalControl(), this->Functor, this->InverseFunctor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->Array.GetPortalConstControl(), this->Functor,
|
||||
this->InverseFunctor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const {
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return PortalConstType(this->Array.GetPortalConstControl(),
|
||||
this->Functor,
|
||||
this->InverseFunctor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->Array.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id numberOfValues) {
|
||||
void Allocate(vtkm::Id numberOfValues)
|
||||
{
|
||||
this->Array.Allocate(numberOfValues);
|
||||
this->Valid = true;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues) {
|
||||
this->Array.Shrink(numberOfValues);
|
||||
}
|
||||
void Shrink(vtkm::Id numberOfValues) { this->Array.Shrink(numberOfValues); }
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
this->Array.ReleaseResources();
|
||||
this->Valid = false;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const ArrayHandleType &GetArray() const {
|
||||
const ArrayHandleType& GetArray() const
|
||||
{
|
||||
VTKM_ASSERT(this->Valid);
|
||||
return this->Array;
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const FunctorType &GetFunctor() const {
|
||||
return this->Functor;
|
||||
}
|
||||
const FunctorType& GetFunctor() const { return this->Functor; }
|
||||
|
||||
VTKM_CONT
|
||||
const InverseFunctorType &GetInverseFunctor() const {
|
||||
return this->InverseFunctor;
|
||||
}
|
||||
const InverseFunctorType& GetInverseFunctor() const { return this->InverseFunctor; }
|
||||
|
||||
private:
|
||||
ArrayHandleType Array;
|
||||
@ -335,12 +357,8 @@ private:
|
||||
bool Valid;
|
||||
};
|
||||
|
||||
template<typename T,
|
||||
typename ArrayHandleType,
|
||||
typename FunctorType,
|
||||
typename Device>
|
||||
class ArrayTransfer<
|
||||
T, StorageTagTransform<T,ArrayHandleType,FunctorType>, Device>
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType, typename Device>
|
||||
class ArrayTransfer<T, StorageTagTransform<T, ArrayHandleType, FunctorType>, Device>
|
||||
{
|
||||
typedef StorageTagTransform<T, ArrayHandleType, FunctorType> StorageTag;
|
||||
typedef vtkm::cont::internal::Storage<T, StorageTag> StorageType;
|
||||
@ -354,39 +372,41 @@ public:
|
||||
//meant to be an invalid writeable execution portal
|
||||
typedef typename StorageType::PortalType PortalExecution;
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<
|
||||
ValueType,
|
||||
typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
FunctorType> PortalConstExecution;
|
||||
ValueType, typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst, FunctorType>
|
||||
PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: Array(storage->GetArray()), Functor(storage->GetFunctor()) { }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->Array.GetNumberOfValues();
|
||||
: Array(storage->GetArray())
|
||||
, Functor(storage->GetFunctor())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) {
|
||||
vtkm::Id GetNumberOfValues() const { return this->Array.GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalConstExecution(this->Array.PrepareForInput(Device()), this->Functor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForInPlace(bool &vtkmNotUsed(updateData)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandleTransform read only. "
|
||||
PortalExecution PrepareForInPlace(bool& vtkmNotUsed(updateData))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandleTransform read only. "
|
||||
"Cannot be used for in-place operations.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandleTransform read only. Cannot be used as output.");
|
||||
PortalExecution PrepareForOutput(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandleTransform read only. Cannot be used as output.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const {
|
||||
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
||||
{
|
||||
throw vtkm::cont::ErrorInternal(
|
||||
"ArrayHandleTransform read only. "
|
||||
"There should be no occurance of the ArrayHandle trying to pull "
|
||||
@ -394,32 +414,25 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues)) {
|
||||
throw vtkm::cont::ErrorBadType(
|
||||
"ArrayHandleTransform read only. Cannot shrink.");
|
||||
void Shrink(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadType("ArrayHandleTransform read only. Cannot shrink.");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
this->Array.ReleaseResourcesExecution();
|
||||
}
|
||||
void ReleaseResources() { this->Array.ReleaseResourcesExecution(); }
|
||||
|
||||
private:
|
||||
ArrayHandleType Array;
|
||||
FunctorType Functor;
|
||||
};
|
||||
|
||||
template<typename T,
|
||||
typename ArrayHandleType,
|
||||
typename FunctorType,
|
||||
typename InverseFunctorType,
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType, typename InverseFunctorType,
|
||||
typename Device>
|
||||
class ArrayTransfer<
|
||||
T, StorageTagTransform<T,ArrayHandleType,FunctorType,InverseFunctorType>,
|
||||
class ArrayTransfer<T, StorageTagTransform<T, ArrayHandleType, FunctorType, InverseFunctorType>,
|
||||
Device>
|
||||
{
|
||||
typedef StorageTagTransform<T,ArrayHandleType,
|
||||
FunctorType,InverseFunctorType> StorageTag;
|
||||
typedef StorageTagTransform<T, ArrayHandleType, FunctorType, InverseFunctorType> StorageTag;
|
||||
typedef vtkm::cont::internal::Storage<T, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
@ -429,56 +442,58 @@ public:
|
||||
typedef typename StorageType::PortalConstType PortalConstControl;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<
|
||||
ValueType,
|
||||
typename ArrayHandleType::template ExecutionTypes<Device>::Portal,
|
||||
FunctorType, InverseFunctorType> PortalExecution;
|
||||
ValueType, typename ArrayHandleType::template ExecutionTypes<Device>::Portal, FunctorType,
|
||||
InverseFunctorType>
|
||||
PortalExecution;
|
||||
typedef vtkm::exec::internal::ArrayPortalTransform<
|
||||
ValueType,
|
||||
typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
FunctorType, InverseFunctorType> PortalConstExecution;
|
||||
ValueType, typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst, FunctorType,
|
||||
InverseFunctorType>
|
||||
PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: Array(storage->GetArray()),
|
||||
Functor(storage->GetFunctor()),
|
||||
InverseFunctor(storage->GetInverseFunctor()) { }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
return this->Array.GetNumberOfValues();
|
||||
: Array(storage->GetArray())
|
||||
, Functor(storage->GetFunctor())
|
||||
, InverseFunctor(storage->GetInverseFunctor())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) {
|
||||
return PortalConstExecution(this->Array.PrepareForInput(Device()),this->Functor,this->InverseFunctor);
|
||||
vtkm::Id GetNumberOfValues() const { return this->Array.GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalConstExecution(this->Array.PrepareForInput(Device()), this->Functor,
|
||||
this->InverseFunctor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForInPlace(bool &vtkmNotUsed(updateData)) {
|
||||
return PortalExecution(this->Array.PrepareForInPlace(Device()),this->Functor,this->InverseFunctor);
|
||||
PortalExecution PrepareForInPlace(bool& vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalExecution(this->Array.PrepareForInPlace(Device()), this->Functor,
|
||||
this->InverseFunctor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForOutput(vtkm::Id numberOfValues) {
|
||||
return PortalExecution(this->Array.PrepareForOutput(numberOfValues,
|
||||
Device()),this->Functor,this->InverseFunctor);
|
||||
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
|
||||
{
|
||||
return PortalExecution(this->Array.PrepareForOutput(numberOfValues, Device()), this->Functor,
|
||||
this->InverseFunctor);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const {
|
||||
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
||||
{
|
||||
// Implementation of this method should be unnecessary. The internal
|
||||
// array handle should automatically retrieve the output data as necessary.
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues) {
|
||||
this->Array.Shrink(numberOfValues);
|
||||
}
|
||||
void Shrink(vtkm::Id numberOfValues) { this->Array.Shrink(numberOfValues); }
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
this->Array.ReleaseResourcesExecution();
|
||||
}
|
||||
void ReleaseResources() { this->Array.ReleaseResourcesExecution(); }
|
||||
|
||||
private:
|
||||
ArrayHandleType Array;
|
||||
@ -499,18 +514,14 @@ private:
|
||||
/// the functor operator should work in both the control and execution
|
||||
/// environments.
|
||||
///
|
||||
template <typename T,
|
||||
typename ArrayHandleType,
|
||||
typename FunctorType,
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType,
|
||||
typename InverseFunctorType = internal::NullFunctorType>
|
||||
class ArrayHandleTransform;
|
||||
|
||||
template <typename T,
|
||||
typename ArrayHandleType,
|
||||
typename FunctorType>
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType>
|
||||
class ArrayHandleTransform<T, ArrayHandleType, FunctorType, internal::NullFunctorType>
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
T, internal::StorageTagTransform<T, ArrayHandleType, FunctorType> >
|
||||
: public vtkm::cont::ArrayHandle<T,
|
||||
internal::StorageTagTransform<T, ArrayHandleType, FunctorType>>
|
||||
{
|
||||
// If the following line gives a compile error, then the ArrayHandleType
|
||||
// template argument is not a valid ArrayHandle type.
|
||||
@ -518,19 +529,18 @@ class ArrayHandleTransform<T,ArrayHandleType,FunctorType,internal::NullFunctorTy
|
||||
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleTransform,
|
||||
(ArrayHandleTransform<T,ArrayHandleType,FunctorType>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
T, internal::StorageTagTransform<T, ArrayHandleType, FunctorType> >));
|
||||
ArrayHandleTransform, (ArrayHandleTransform<T, ArrayHandleType, FunctorType>),
|
||||
(vtkm::cont::ArrayHandle<T, internal::StorageTagTransform<T, ArrayHandleType, FunctorType>>));
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::Storage<T, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleTransform(const ArrayHandleType &handle,
|
||||
const FunctorType &functor = FunctorType())
|
||||
: Superclass(StorageType(handle, functor)) { }
|
||||
ArrayHandleTransform(const ArrayHandleType& handle, const FunctorType& functor = FunctorType())
|
||||
: Superclass(StorageType(handle, functor))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// make_ArrayHandleTransform is convenience function to generate an
|
||||
@ -538,24 +548,18 @@ public:
|
||||
/// to apply to each element of the Handle.
|
||||
|
||||
template <typename T, typename HandleType, typename FunctorType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleTransform<T, HandleType, FunctorType>
|
||||
make_ArrayHandleTransform(HandleType handle, FunctorType functor)
|
||||
VTKM_CONT vtkm::cont::ArrayHandleTransform<T, HandleType, FunctorType> make_ArrayHandleTransform(
|
||||
HandleType handle, FunctorType functor)
|
||||
{
|
||||
return ArrayHandleTransform<T, HandleType, FunctorType>(handle, functor);
|
||||
}
|
||||
|
||||
// ArrayHandleTransform with inverse functors enabled (no need to subclass from
|
||||
// ArrayHandleTransform without inverse functors: nothing to inherit).
|
||||
template <typename T,
|
||||
typename ArrayHandleType,
|
||||
typename FunctorType,
|
||||
typename InverseFunctorType>
|
||||
template <typename T, typename ArrayHandleType, typename FunctorType, typename InverseFunctorType>
|
||||
class ArrayHandleTransform
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
T,
|
||||
internal::StorageTagTransform<T, ArrayHandleType, FunctorType,
|
||||
InverseFunctorType> >
|
||||
T, internal::StorageTagTransform<T, ArrayHandleType, FunctorType, InverseFunctorType>>
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
|
||||
@ -564,27 +568,26 @@ public:
|
||||
ArrayHandleTransform,
|
||||
(ArrayHandleTransform<T, ArrayHandleType, FunctorType, InverseFunctorType>),
|
||||
(vtkm::cont::ArrayHandle<
|
||||
T, internal::StorageTagTransform<T, ArrayHandleType, FunctorType,
|
||||
InverseFunctorType> >));
|
||||
T, internal::StorageTagTransform<T, ArrayHandleType, FunctorType, InverseFunctorType>>));
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::Storage<T, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
ArrayHandleTransform(const ArrayHandleType &handle,
|
||||
const FunctorType &functor = FunctorType(),
|
||||
ArrayHandleTransform(const ArrayHandleType& handle, const FunctorType& functor = FunctorType(),
|
||||
const InverseFunctorType& inverseFunctor = InverseFunctorType())
|
||||
: Superclass(StorageType(handle, functor, inverseFunctor)) { }
|
||||
: Superclass(StorageType(handle, functor, inverseFunctor))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename HandleType, typename FunctorType, typename InverseFunctorType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleTransform<T, HandleType, FunctorType, InverseFunctorType>
|
||||
VTKM_CONT vtkm::cont::ArrayHandleTransform<T, HandleType, FunctorType, InverseFunctorType>
|
||||
make_ArrayHandleTransform(HandleType handle, FunctorType functor, InverseFunctorType inverseFunctor)
|
||||
{
|
||||
return ArrayHandleTransform<T,HandleType,FunctorType,InverseFunctorType>(handle,functor,inverseFunctor);
|
||||
return ArrayHandleTransform<T, HandleType, FunctorType, InverseFunctorType>(handle, functor,
|
||||
inverseFunctor);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -24,8 +24,10 @@
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
#include <vtkm/internal/ArrayPortalUniformPointCoordinates.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
/// ArrayHandleUniformPointCoordinates is a specialization of ArrayHandle. It
|
||||
/// contains the information necessary to compute the point coordinates in a
|
||||
@ -35,32 +37,28 @@ namespace cont {
|
||||
class ArrayHandleUniformPointCoordinates
|
||||
: public vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::FloatDefault, 3>,
|
||||
vtkm::cont::StorageTagImplicit<
|
||||
vtkm::internal::ArrayPortalUniformPointCoordinates> >
|
||||
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>
|
||||
{
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS_NT(
|
||||
ArrayHandleUniformPointCoordinates,
|
||||
(vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::FloatDefault, 3>,
|
||||
vtkm::cont::StorageTagImplicit<
|
||||
vtkm::internal::ArrayPortalUniformPointCoordinates> >));
|
||||
vtkm::cont::StorageTagImplicit<vtkm::internal::ArrayPortalUniformPointCoordinates>>));
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleUniformPointCoordinates(
|
||||
vtkm::Id3 dimensions,
|
||||
ArrayHandleUniformPointCoordinates(vtkm::Id3 dimensions,
|
||||
ValueType origin = ValueType(0.0f, 0.0f, 0.0f),
|
||||
ValueType spacing = ValueType(1.0f, 1.0f, 1.0f))
|
||||
: Superclass(
|
||||
StorageType(vtkm::internal::ArrayPortalUniformPointCoordinates(
|
||||
dimensions, origin, spacing)))
|
||||
{ }
|
||||
: Superclass(StorageType(
|
||||
vtkm::internal::ArrayPortalUniformPointCoordinates(dimensions, origin, spacing)))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -23,15 +23,16 @@
|
||||
#include <vtkm/Pair.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace exec {
|
||||
namespace internal {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// \brief An array portal that zips two portals together into a single value
|
||||
/// for the execution environment
|
||||
template<typename ValueType_,
|
||||
typename PortalTypeFirst_,
|
||||
typename PortalTypeSecond_>
|
||||
template <typename ValueType_, typename PortalTypeFirst_, typename PortalTypeSecond_>
|
||||
class ArrayPortalZip
|
||||
{
|
||||
public:
|
||||
@ -43,37 +44,41 @@ public:
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalZip()
|
||||
: PortalFirst(), PortalSecond()
|
||||
{ } //needs to be host and device so that cuda can create lvalue of these
|
||||
: PortalFirst()
|
||||
, PortalSecond()
|
||||
{
|
||||
} //needs to be host and device so that cuda can create lvalue of these
|
||||
|
||||
VTKM_CONT
|
||||
ArrayPortalZip(const PortalTypeFirst &portalfirst,
|
||||
const PortalTypeSecond &portalsecond)
|
||||
: PortalFirst(portalfirst), PortalSecond(portalsecond)
|
||||
{ }
|
||||
ArrayPortalZip(const PortalTypeFirst& portalfirst, const PortalTypeSecond& portalsecond)
|
||||
: PortalFirst(portalfirst)
|
||||
, PortalSecond(portalsecond)
|
||||
{
|
||||
}
|
||||
|
||||
/// Copy constructor for any other ArrayPortalZip with an iterator
|
||||
/// type that can be copied to this iterator type. This allows us to do any
|
||||
/// type casting that the iterators do (like the non-const to const cast).
|
||||
///
|
||||
template <class OtherV, class OtherF, class OtherS>
|
||||
VTKM_CONT
|
||||
ArrayPortalZip(const ArrayPortalZip<OtherV,OtherF,OtherS> &src)
|
||||
: PortalFirst(src.GetFirstPortal()),
|
||||
PortalSecond(src.GetSecondPortal())
|
||||
{ }
|
||||
VTKM_CONT ArrayPortalZip(const ArrayPortalZip<OtherV, OtherF, OtherS>& src)
|
||||
: PortalFirst(src.GetFirstPortal())
|
||||
, PortalSecond(src.GetSecondPortal())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
vtkm::Id GetNumberOfValues() const { return this->PortalFirst.GetNumberOfValues(); }
|
||||
|
||||
VTKM_EXEC
|
||||
ValueType Get(vtkm::Id index) const {
|
||||
return vtkm::make_Pair(this->PortalFirst.Get(index),
|
||||
this->PortalSecond.Get(index));
|
||||
ValueType Get(vtkm::Id index) const
|
||||
{
|
||||
return vtkm::make_Pair(this->PortalFirst.Get(index), this->PortalSecond.Get(index));
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void Set(vtkm::Id index, const ValueType &value) const {
|
||||
void Set(vtkm::Id index, const ValueType& value) const
|
||||
{
|
||||
this->PortalFirst.Set(index, value.first);
|
||||
this->PortalSecond.Set(index, value.second);
|
||||
}
|
||||
@ -84,34 +89,37 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
const PortalTypeSecond& GetSecondPortal() const { return this->PortalSecond; }
|
||||
|
||||
|
||||
private:
|
||||
PortalTypeFirst PortalFirst;
|
||||
PortalTypeSecond PortalSecond;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec::internal
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename FirstHandleType, typename SecondHandleType>
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagZip { };
|
||||
struct VTKM_ALWAYS_EXPORT StorageTagZip
|
||||
{
|
||||
};
|
||||
|
||||
/// This helper struct defines the value type for a zip container containing
|
||||
/// the given two array handles.
|
||||
///
|
||||
template <typename FirstHandleType, typename SecondHandleType>
|
||||
struct ArrayHandleZipTraits {
|
||||
struct ArrayHandleZipTraits
|
||||
{
|
||||
/// The ValueType (a pair containing the value types of the two arrays).
|
||||
///
|
||||
typedef vtkm::Pair<typename FirstHandleType::ValueType,
|
||||
typename SecondHandleType::ValueType> ValueType;
|
||||
typedef vtkm::Pair<typename FirstHandleType::ValueType, typename SecondHandleType::ValueType>
|
||||
ValueType;
|
||||
|
||||
/// The appropriately templated tag.
|
||||
///
|
||||
@ -122,7 +130,6 @@ struct ArrayHandleZipTraits {
|
||||
typedef vtkm::cont::ArrayHandle<ValueType, Tag> Superclass;
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename FirstHandleType, typename SecondHandleType>
|
||||
class Storage<T, StorageTagZip<FirstHandleType, SecondHandleType>>
|
||||
{
|
||||
@ -132,82 +139,82 @@ class Storage<T, StorageTagZip<FirstHandleType, SecondHandleType > >
|
||||
public:
|
||||
typedef T ValueType;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalZip< ValueType,
|
||||
typename FirstHandleType::PortalControl,
|
||||
typename SecondHandleType::PortalControl> PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalZip<ValueType, typename FirstHandleType::PortalControl,
|
||||
typename SecondHandleType::PortalControl>
|
||||
PortalType;
|
||||
typedef vtkm::exec::internal::ArrayPortalZip<ValueType,
|
||||
typename FirstHandleType::PortalConstControl,
|
||||
typename SecondHandleType::PortalConstControl>
|
||||
PortalConstType;
|
||||
|
||||
VTKM_CONT
|
||||
Storage() : FirstArray(), SecondArray() { }
|
||||
Storage()
|
||||
: FirstArray()
|
||||
, SecondArray()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Storage(const FirstHandleType& farray, const SecondHandleType& sarray)
|
||||
: FirstArray(farray), SecondArray(sarray)
|
||||
: FirstArray(farray)
|
||||
, SecondArray(sarray)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalType GetPortal() {
|
||||
return PortalType(this->FirstArray.GetPortalControl(),
|
||||
this->SecondArray.GetPortalControl());
|
||||
PortalType GetPortal()
|
||||
{
|
||||
return PortalType(this->FirstArray.GetPortalControl(), this->SecondArray.GetPortalControl());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstType GetPortalConst() const {
|
||||
PortalConstType GetPortalConst() const
|
||||
{
|
||||
return PortalConstType(this->FirstArray.GetPortalConstControl(),
|
||||
this->SecondArray.GetPortalConstControl());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const {
|
||||
VTKM_ASSERT(this->FirstArray.GetNumberOfValues()
|
||||
== this->SecondArray.GetNumberOfValues());
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT(this->FirstArray.GetNumberOfValues() == this->SecondArray.GetNumberOfValues());
|
||||
return this->FirstArray.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Allocate(vtkm::Id numberOfValues) {
|
||||
void Allocate(vtkm::Id numberOfValues)
|
||||
{
|
||||
this->FirstArray.Allocate(numberOfValues);
|
||||
this->SecondArray.Allocate(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues) {
|
||||
void Shrink(vtkm::Id numberOfValues)
|
||||
{
|
||||
this->FirstArray.Shrink(numberOfValues);
|
||||
this->SecondArray.Shrink(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
// This request is ignored since it is asking to release the resources
|
||||
// of the two zipped array, which may be used elsewhere.
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const FirstHandleType &GetFirstArray() const {
|
||||
return this->FirstArray;
|
||||
}
|
||||
const FirstHandleType& GetFirstArray() const { return this->FirstArray; }
|
||||
|
||||
VTKM_CONT
|
||||
const SecondHandleType &GetSecondArray() const {
|
||||
return this->SecondArray;
|
||||
}
|
||||
const SecondHandleType& GetSecondArray() const { return this->SecondArray; }
|
||||
|
||||
private:
|
||||
FirstHandleType FirstArray;
|
||||
SecondHandleType SecondArray;
|
||||
};
|
||||
|
||||
template<typename T,
|
||||
typename FirstHandleType,
|
||||
typename SecondHandleType,
|
||||
typename Device>
|
||||
class ArrayTransfer<
|
||||
T, StorageTagZip<FirstHandleType,SecondHandleType>, Device>
|
||||
template <typename T, typename FirstHandleType, typename SecondHandleType, typename Device>
|
||||
class ArrayTransfer<T, StorageTagZip<FirstHandleType, SecondHandleType>, Device>
|
||||
{
|
||||
typedef StorageTagZip<FirstHandleType, SecondHandleType> StorageTag;
|
||||
typedef vtkm::cont::internal::Storage<T, StorageTag> StorageType;
|
||||
@ -219,40 +226,39 @@ public:
|
||||
typedef typename StorageType::PortalConstType PortalConstControl;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalZip<
|
||||
ValueType,
|
||||
typename FirstHandleType::template ExecutionTypes<Device>::Portal,
|
||||
typename SecondHandleType::template ExecutionTypes<Device>::Portal
|
||||
> PortalExecution;
|
||||
ValueType, typename FirstHandleType::template ExecutionTypes<Device>::Portal,
|
||||
typename SecondHandleType::template ExecutionTypes<Device>::Portal>
|
||||
PortalExecution;
|
||||
|
||||
typedef vtkm::exec::internal::ArrayPortalZip<
|
||||
ValueType,
|
||||
typename FirstHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
typename SecondHandleType::template ExecutionTypes<Device>::PortalConst
|
||||
> PortalConstExecution;
|
||||
ValueType, typename FirstHandleType::template ExecutionTypes<Device>::PortalConst,
|
||||
typename SecondHandleType::template ExecutionTypes<Device>::PortalConst>
|
||||
PortalConstExecution;
|
||||
|
||||
VTKM_CONT
|
||||
ArrayTransfer(StorageType* storage)
|
||||
: FirstArray(storage->GetFirstArray()),
|
||||
SecondArray(storage->GetSecondArray())
|
||||
{ }
|
||||
|
||||
: FirstArray(storage->GetFirstArray())
|
||||
, SecondArray(storage->GetSecondArray())
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
VTKM_ASSERT( this->FirstArray.GetNumberOfValues()
|
||||
== this->SecondArray.GetNumberOfValues() );
|
||||
VTKM_ASSERT(this->FirstArray.GetNumberOfValues() == this->SecondArray.GetNumberOfValues());
|
||||
return this->FirstArray.GetNumberOfValues();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData)) {
|
||||
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalConstExecution(this->FirstArray.PrepareForInput(Device()),
|
||||
this->SecondArray.PrepareForInput(Device()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData)) {
|
||||
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
|
||||
{
|
||||
return PortalExecution(this->FirstArray.PrepareForInPlace(Device()),
|
||||
this->SecondArray.PrepareForInPlace(Device()));
|
||||
}
|
||||
@ -265,25 +271,27 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RetrieveOutputData(StorageType *vtkmNotUsed(storage)) const {
|
||||
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
||||
{
|
||||
// Implementation of this method should be unnecessary. The internal
|
||||
// first and second array handles should automatically retrieve the
|
||||
// output data as necessary.
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void Shrink(vtkm::Id numberOfValues) {
|
||||
void Shrink(vtkm::Id numberOfValues)
|
||||
{
|
||||
this->FirstArray.Shrink(numberOfValues);
|
||||
this->SecondArray.Shrink(numberOfValues);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ReleaseResources() {
|
||||
void ReleaseResources()
|
||||
{
|
||||
this->FirstArray.ReleaseResourcesExecution();
|
||||
this->SecondArray.ReleaseResourcesExecution();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
FirstHandleType FirstArray;
|
||||
SecondHandleType SecondArray;
|
||||
@ -294,8 +302,7 @@ private:
|
||||
/// array handle and makes a new handle that access the corresponding entries
|
||||
/// in these arrays as a pair.
|
||||
///
|
||||
template<typename FirstHandleType,
|
||||
typename SecondHandleType>
|
||||
template <typename FirstHandleType, typename SecondHandleType>
|
||||
class ArrayHandleZip
|
||||
: public internal::ArrayHandleZipTraits<FirstHandleType, SecondHandleType>::Superclass
|
||||
{
|
||||
@ -309,33 +316,29 @@ class ArrayHandleZip
|
||||
|
||||
public:
|
||||
VTKM_ARRAY_HANDLE_SUBCLASS(
|
||||
ArrayHandleZip,
|
||||
(ArrayHandleZip<FirstHandleType,SecondHandleType>),
|
||||
(typename internal::ArrayHandleZipTraits<
|
||||
FirstHandleType,SecondHandleType>::Superclass));
|
||||
ArrayHandleZip, (ArrayHandleZip<FirstHandleType, SecondHandleType>),
|
||||
(typename internal::ArrayHandleZipTraits<FirstHandleType, SecondHandleType>::Superclass));
|
||||
|
||||
private:
|
||||
typedef vtkm::cont::internal::Storage<ValueType, StorageTag> StorageType;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
ArrayHandleZip(const FirstHandleType &firstArray,
|
||||
const SecondHandleType &secondArray)
|
||||
: Superclass( StorageType( firstArray, secondArray ) ) { }
|
||||
ArrayHandleZip(const FirstHandleType& firstArray, const SecondHandleType& secondArray)
|
||||
: Superclass(StorageType(firstArray, secondArray))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// A convenience function for creating an ArrayHandleZip. It takes the two
|
||||
/// arrays to be zipped together.
|
||||
///
|
||||
template <typename FirstHandleType, typename SecondHandleType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandleZip<FirstHandleType,SecondHandleType>
|
||||
make_ArrayHandleZip(const FirstHandleType &first,
|
||||
const SecondHandleType &second)
|
||||
VTKM_CONT vtkm::cont::ArrayHandleZip<FirstHandleType, SecondHandleType> make_ArrayHandleZip(
|
||||
const FirstHandleType& first, const SecondHandleType& second)
|
||||
{
|
||||
return ArrayHandleZip<FirstHandleType, SecondHandleType>(first, second);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
#ifdef VTKM_DOXYGEN_ONLY
|
||||
|
||||
@ -81,7 +83,6 @@ public:
|
||||
};
|
||||
|
||||
#endif // VTKM_DOXYGEN_ONLY
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -23,8 +23,10 @@
|
||||
#include <vtkm/cont/ArrayPortal.h>
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
/// \brief Convert an \c ArrayPortal to STL iterators.
|
||||
///
|
||||
@ -48,28 +50,26 @@ public:
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
ArrayPortalToIterators(const PortalType &portal) : Portal(portal) { }
|
||||
ArrayPortalToIterators(const PortalType& portal)
|
||||
: Portal(portal)
|
||||
{
|
||||
}
|
||||
|
||||
/// The type of the iterator.
|
||||
///
|
||||
typedef vtkm::cont::internal::IteratorFromArrayPortal<PortalType>
|
||||
IteratorType;
|
||||
typedef vtkm::cont::internal::IteratorFromArrayPortal<PortalType> IteratorType;
|
||||
|
||||
/// Returns an iterator pointing to the beginning of the ArrayPortal.
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
IteratorType GetBegin() const {
|
||||
return vtkm::cont::internal::make_IteratorBegin(this->Portal);
|
||||
}
|
||||
IteratorType GetBegin() const { return vtkm::cont::internal::make_IteratorBegin(this->Portal); }
|
||||
|
||||
/// Returns an iterator pointing to one past the end of the ArrayPortal.
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC_CONT
|
||||
IteratorType GetEnd() const {
|
||||
return vtkm::cont::internal::make_IteratorEnd(this->Portal);
|
||||
}
|
||||
IteratorType GetEnd() const { return vtkm::cont::internal::make_IteratorEnd(this->Portal); }
|
||||
|
||||
private:
|
||||
PortalType Portal;
|
||||
@ -79,8 +79,7 @@ private:
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename PortalType>
|
||||
VTKM_EXEC_CONT
|
||||
typename vtkm::cont::ArrayPortalToIterators<PortalType>::IteratorType
|
||||
VTKM_EXEC_CONT typename vtkm::cont::ArrayPortalToIterators<PortalType>::IteratorType
|
||||
ArrayPortalToIteratorBegin(const PortalType& portal)
|
||||
{
|
||||
vtkm::cont::ArrayPortalToIterators<PortalType> iterators(portal);
|
||||
@ -91,14 +90,12 @@ ArrayPortalToIteratorBegin(const PortalType &portal)
|
||||
///
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
template <typename PortalType>
|
||||
VTKM_EXEC_CONT
|
||||
typename vtkm::cont::ArrayPortalToIterators<PortalType>::IteratorType
|
||||
VTKM_EXEC_CONT typename vtkm::cont::ArrayPortalToIterators<PortalType>::IteratorType
|
||||
ArrayPortalToIteratorEnd(const PortalType& portal)
|
||||
{
|
||||
vtkm::cont::ArrayPortalToIterators<PortalType> iterators(portal);
|
||||
return iterators.GetEnd();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -20,22 +20,23 @@
|
||||
|
||||
#include <vtkm/cont/ArrayRangeCompute.hxx>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
#define VTKM_ARRAY_RANGE_COMPUTE_IMPL_T(T, Storage) \
|
||||
VTKM_CONT \
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> \
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<T, Storage> &input, \
|
||||
vtkm::cont::RuntimeDeviceTracker tracker) \
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute( \
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& input, vtkm::cont::RuntimeDeviceTracker tracker) \
|
||||
{ \
|
||||
return detail::ArrayRangeComputeImpl(input, tracker); \
|
||||
} \
|
||||
struct SwallowSemicolon
|
||||
#define VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(T, N, Storage) \
|
||||
VTKM_CONT \
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> \
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<vtkm::Vec<T,N>, Storage> &input, \
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, Storage>& input, \
|
||||
vtkm::cont::RuntimeDeviceTracker tracker) \
|
||||
{ \
|
||||
return detail::ArrayRangeComputeImpl(input, tracker); \
|
||||
@ -73,30 +74,24 @@ VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC(vtkm::Float64, 4, vtkm::cont::StorageTagBasic)
|
||||
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_T
|
||||
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC
|
||||
|
||||
|
||||
// Special implementation for regular point coordinates, which are easy
|
||||
// to determine.
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::FloatDefault,3>,
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag>
|
||||
&array,
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>,
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag>& array,
|
||||
vtkm::cont::RuntimeDeviceTracker)
|
||||
{
|
||||
vtkm::internal::ArrayPortalUniformPointCoordinates portal =
|
||||
array.GetPortalConstControl();
|
||||
vtkm::internal::ArrayPortalUniformPointCoordinates portal = array.GetPortalConstControl();
|
||||
|
||||
// In this portal we know that the min value is the first entry and the
|
||||
// max value is the last entry.
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> minimum = portal.Get(0);
|
||||
vtkm::Vec<vtkm::FloatDefault,3> maximum =
|
||||
portal.Get(portal.GetNumberOfValues()-1);
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> maximum = portal.Get(portal.GetNumberOfValues() - 1);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> rangeArray;
|
||||
rangeArray.Allocate(3);
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>::PortalControl outPortal =
|
||||
rangeArray.GetPortalControl();
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>::PortalControl outPortal = rangeArray.GetPortalControl();
|
||||
outPortal.Set(0, vtkm::Range(minimum[0], maximum[0]));
|
||||
outPortal.Set(1, vtkm::Range(minimum[1], maximum[1]));
|
||||
outPortal.Set(2, vtkm::Range(minimum[2], maximum[2]));
|
||||
@ -106,36 +101,27 @@ ArrayRangeCompute(const vtkm::cont::ArrayHandle<
|
||||
|
||||
// Special implementation for composite vectors.
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::Float32, 3>,
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<
|
||||
vtkm::Vec<vtkm::Float32,3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>)
|
||||
>::StorageTag
|
||||
> &input,
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<vtkm::Vec<vtkm::Float32, 3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>, vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>)>::StorageTag>& input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
{
|
||||
return detail::ArrayRangeComputeImpl(input, tracker);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::Float64, 3>,
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<
|
||||
vtkm::Vec<vtkm::Float64,3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>)
|
||||
>::StorageTag
|
||||
> &input,
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<vtkm::Vec<vtkm::Float64, 3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>, vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>)>::StorageTag>& input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
{
|
||||
return detail::ArrayRangeComputeImpl(input, tracker);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -28,8 +28,10 @@
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
/// \brief Compute the range of the data in an array handle.
|
||||
///
|
||||
@ -45,27 +47,23 @@ namespace cont {
|
||||
/// type.
|
||||
///
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const ArrayHandleType &input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker =
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker());
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const ArrayHandleType& input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker());
|
||||
|
||||
// Precompiled versions of ArrayRangeCompute
|
||||
#define VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(T, Storage) \
|
||||
VTKM_CONT_EXPORT \
|
||||
VTKM_CONT \
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> \
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<T, Storage> &input, \
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = \
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker())
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute( \
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& input, \
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker())
|
||||
#define VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(T, N, Storage) \
|
||||
VTKM_CONT_EXPORT \
|
||||
VTKM_CONT \
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> \
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<vtkm::Vec<T,N>, Storage> &input, \
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = \
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker())
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, Storage>& input, \
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker())
|
||||
|
||||
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(char, vtkm::cont::StorageTagBasic);
|
||||
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T(vtkm::Int8, vtkm::cont::StorageTagBasic);
|
||||
@ -95,8 +93,7 @@ VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::UInt8, 4, vtkm::cont::StorageTagBasic)
|
||||
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float32, 4, vtkm::cont::StorageTagBasic);
|
||||
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::Float64, 4, vtkm::cont::StorageTagBasic);
|
||||
|
||||
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(
|
||||
vtkm::FloatDefault, 3,
|
||||
VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(vtkm::FloatDefault, 3,
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag);
|
||||
|
||||
#undef VTKM_ARRAY_RANGE_COMPUTE_EXPORT_T
|
||||
@ -105,48 +102,30 @@ VTKM_ARRAY_RANGE_COMPUTE_EXPORT_VEC(
|
||||
// Implementation of composite vectors
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::Float32, 3>,
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<
|
||||
vtkm::Vec<vtkm::Float32,3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>)
|
||||
>::StorageTag
|
||||
> &input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker =
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker());
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<vtkm::Vec<vtkm::Float32, 3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>, vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>)>::StorageTag>& input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker());
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const vtkm::cont::ArrayHandle<
|
||||
vtkm::Vec<vtkm::Float64, 3>,
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<
|
||||
vtkm::Vec<vtkm::Float64,3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>)
|
||||
>::StorageTag
|
||||
> &input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker =
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker());
|
||||
typename vtkm::cont::ArrayHandleCompositeVector<vtkm::Vec<vtkm::Float64, 3>(
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>, vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>)>::StorageTag>& input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker());
|
||||
|
||||
// Implementation of cartesian products
|
||||
template<typename T,
|
||||
typename ArrayType1,
|
||||
typename ArrayType2,
|
||||
typename ArrayType3>
|
||||
VTKM_CONT
|
||||
inline
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const vtkm::cont::ArrayHandle<T,
|
||||
vtkm::cont::internal::StorageTagCartesianProduct<
|
||||
ArrayType1,ArrayType2,ArrayType3
|
||||
> > &input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker =
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker())
|
||||
template <typename T, typename ArrayType1, typename ArrayType2, typename ArrayType3>
|
||||
VTKM_CONT inline vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const vtkm::cont::ArrayHandle<
|
||||
T, vtkm::cont::internal::StorageTagCartesianProduct<ArrayType1, ArrayType2, ArrayType3>>& input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker())
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> result;
|
||||
result.Allocate(3);
|
||||
@ -171,7 +150,6 @@ ArrayRangeCompute(const vtkm::cont::ArrayHandle<T,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -28,10 +28,13 @@
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
struct ArrayRangeComputeFunctor
|
||||
@ -44,11 +47,11 @@ struct ArrayRangeComputeFunctor
|
||||
VTKM_CONT
|
||||
ArrayRangeComputeFunctor(const ArrayHandleType& input)
|
||||
: InputArray(input)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT
|
||||
bool operator()(Device)
|
||||
VTKM_CONT bool operator()(Device)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
|
||||
@ -69,31 +72,25 @@ struct ArrayRangeComputeFunctor
|
||||
return true;
|
||||
}
|
||||
|
||||
vtkm::Vec<ValueType,2> initial(
|
||||
this->InputArray.GetPortalConstControl().Get(0));
|
||||
vtkm::Vec<ValueType, 2> initial(this->InputArray.GetPortalConstControl().Get(0));
|
||||
|
||||
vtkm::Vec<ValueType, 2> result =
|
||||
Algorithm::Reduce(this->InputArray,
|
||||
initial,
|
||||
vtkm::MinAndMax<ValueType>());
|
||||
Algorithm::Reduce(this->InputArray, initial, vtkm::MinAndMax<ValueType>());
|
||||
|
||||
for (vtkm::IdComponent i = 0; i < NumberOfComponents; ++i)
|
||||
{
|
||||
this->RangeArray.GetPortalControl().Set(
|
||||
i, vtkm::Range(VecTraits::GetComponent(result[0], i),
|
||||
VecTraits::GetComponent(result[1], i)));
|
||||
i,
|
||||
vtkm::Range(VecTraits::GetComponent(result[0], i), VecTraits::GetComponent(result[1], i)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
inline
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeComputeImpl(const ArrayHandleType &input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
inline vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeComputeImpl(
|
||||
const ArrayHandleType& input, vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
|
||||
@ -101,8 +98,7 @@ ArrayRangeComputeImpl(const ArrayHandleType &input,
|
||||
|
||||
if (!vtkm::cont::TryExecute(functor, tracker))
|
||||
{
|
||||
throw vtkm::cont::ErrorExecution(
|
||||
"Failed to run ArrayRangeComputation on any device.");
|
||||
throw vtkm::cont::ErrorExecution("Failed to run ArrayRangeComputation on any device.");
|
||||
}
|
||||
|
||||
return functor.RangeArray;
|
||||
@ -111,17 +107,13 @@ ArrayRangeComputeImpl(const ArrayHandleType &input,
|
||||
} // namespace detail
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
inline
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>
|
||||
ArrayRangeCompute(const ArrayHandleType &input,
|
||||
vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
inline vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
const ArrayHandleType& input, vtkm::cont::RuntimeDeviceTracker tracker)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
|
||||
return detail::ArrayRangeComputeImpl(input, tracker);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -20,14 +20,13 @@
|
||||
|
||||
#include <vtkm/cont/CellSet.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
CellSet::~CellSet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -29,8 +29,10 @@
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class VTKM_CONT_EXPORT CellSet
|
||||
{
|
||||
@ -44,7 +46,8 @@ public:
|
||||
VTKM_CONT
|
||||
CellSet(const vtkm::cont::CellSet& src)
|
||||
: Name(src.Name)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSet& operator=(const vtkm::cont::CellSet& src)
|
||||
@ -55,10 +58,7 @@ public:
|
||||
|
||||
virtual ~CellSet();
|
||||
|
||||
std::string GetName() const
|
||||
{
|
||||
return this->Name;
|
||||
}
|
||||
std::string GetName() const { return this->Name; }
|
||||
|
||||
virtual vtkm::Id GetNumberOfCells() const = 0;
|
||||
|
||||
@ -74,7 +74,8 @@ protected:
|
||||
std::string Name;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// Checks to see if the given object is a cell set. It contains a
|
||||
/// typedef named \c type that is either std::true_type or
|
||||
@ -87,11 +88,9 @@ struct CellSetCheck
|
||||
using type = typename std::is_base_of<vtkm::cont::CellSet, T>;
|
||||
};
|
||||
|
||||
#define VTKM_IS_CELL_SET(T) \
|
||||
VTKM_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck<T>::type::value)
|
||||
#define VTKM_IS_CELL_SET(T) VTKM_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck<T>::type::value)
|
||||
|
||||
} // namespace internal
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -35,21 +35,22 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename CellSetType, typename FromTopology, typename ToTopology>
|
||||
struct CellSetExplicitConnectivityChooser
|
||||
{
|
||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<>
|
||||
ConnectivityType;
|
||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<> ConnectivityType;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
#ifndef VTKM_DEFAULT_SHAPE_STORAGE_TAG
|
||||
#define VTKM_DEFAULT_SHAPE_STORAGE_TAG VTKM_DEFAULT_STORAGE_TAG
|
||||
#endif
|
||||
@ -72,33 +73,28 @@ template<typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
|
||||
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG>
|
||||
class VTKM_ALWAYS_EXPORT CellSetExplicit : public CellSet
|
||||
{
|
||||
typedef CellSetExplicit< ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag > Thisclass;
|
||||
typedef CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag,
|
||||
OffsetsStorageTag>
|
||||
Thisclass;
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
struct ConnectivityChooser
|
||||
{
|
||||
typedef typename detail::CellSetExplicitConnectivityChooser<
|
||||
Thisclass,
|
||||
FromTopology,
|
||||
ToTopology>::ConnectivityType ConnectivityType;
|
||||
Thisclass, FromTopology, ToTopology>::ConnectivityType ConnectivityType;
|
||||
|
||||
typedef typename ConnectivityType::ShapeArrayType ShapeArrayType;
|
||||
typedef typename ConnectivityType::NumIndicesArrayType NumIndicesArrayType;
|
||||
typedef typename ConnectivityType::ConnectivityArrayType ConnectivityArrayType;
|
||||
typedef typename ConnectivityType::IndexOffsetArrayType IndexOffsetArrayType;
|
||||
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
typedef vtkm::Id SchedulingRangeType;
|
||||
|
||||
//point to cell is used when iterating cells and asking for point properties
|
||||
typedef ConnectivityChooser< vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell > PointToCellConnectivityType;
|
||||
typedef ConnectivityChooser<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
|
||||
PointToCellConnectivityType;
|
||||
|
||||
typedef typename PointToCellConnectivityType::ShapeArrayType ShapeArrayType;
|
||||
typedef typename PointToCellConnectivityType::NumIndicesArrayType NumIndicesArrayType;
|
||||
@ -107,22 +103,23 @@ public:
|
||||
|
||||
VTKM_CONT
|
||||
CellSetExplicit(const std::string& name = std::string())
|
||||
: CellSet(name),
|
||||
ConnectivityAdded(-1),
|
||||
NumberOfCellsAdded(-1),
|
||||
NumberOfPoints(0)
|
||||
: CellSet(name)
|
||||
, ConnectivityAdded(-1)
|
||||
, NumberOfCellsAdded(-1)
|
||||
, NumberOfPoints(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetExplicit(const Thisclass& src)
|
||||
: CellSet(src),
|
||||
PointToCell(src.PointToCell),
|
||||
CellToPoint(src.CellToPoint),
|
||||
ConnectivityAdded(src.ConnectivityAdded),
|
||||
NumberOfCellsAdded(src.NumberOfCellsAdded),
|
||||
NumberOfPoints(src.NumberOfPoints)
|
||||
{ }
|
||||
: CellSet(src)
|
||||
, PointToCell(src.PointToCell)
|
||||
, CellToPoint(src.CellToPoint)
|
||||
, ConnectivityAdded(src.ConnectivityAdded)
|
||||
, NumberOfCellsAdded(src.NumberOfCellsAdded)
|
||||
, NumberOfPoints(src.NumberOfPoints)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Thisclass& operator=(const Thisclass& src)
|
||||
@ -143,10 +140,7 @@ public:
|
||||
return this->PointToCell.GetNumberOfElements();
|
||||
}
|
||||
|
||||
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE
|
||||
{
|
||||
return this->NumberOfPoints;
|
||||
}
|
||||
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE { return this->NumberOfPoints; }
|
||||
|
||||
vtkm::Id GetNumberOfFaces() const VTKM_OVERRIDE { return -1; }
|
||||
|
||||
@ -177,14 +171,11 @@ public:
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent ItemTupleLength>
|
||||
VTKM_CONT
|
||||
void GetIndices(vtkm::Id index,
|
||||
vtkm::Vec<vtkm::Id,ItemTupleLength> &ids) const
|
||||
VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, ItemTupleLength>& ids) const
|
||||
{
|
||||
this->PointToCell.BuildIndexOffsets(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::IdComponent numIndices = this->GetNumberOfPointsInCell(index);
|
||||
vtkm::Id start =
|
||||
this->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
|
||||
vtkm::Id start = this->PointToCell.IndexOffsets.GetPortalConstControl().Get(index);
|
||||
for (vtkm::IdComponent i = 0; i < numIndices && i < ItemTupleLength; i++)
|
||||
ids[i] = this->PointToCell.Connectivity.GetPortalConstControl().Get(start + i);
|
||||
}
|
||||
@ -202,29 +193,22 @@ public:
|
||||
}
|
||||
|
||||
template <typename IdVecType>
|
||||
VTKM_CONT
|
||||
void AddCell(vtkm::UInt8 cellType,
|
||||
vtkm::IdComponent numVertices,
|
||||
const IdVecType &ids)
|
||||
VTKM_CONT void AddCell(vtkm::UInt8 cellType, vtkm::IdComponent numVertices, const IdVecType& ids)
|
||||
{
|
||||
using Traits = vtkm::VecTraits<IdVecType>;
|
||||
VTKM_STATIC_ASSERT_MSG(
|
||||
(std::is_same<typename Traits::ComponentType,vtkm::Id>::value),
|
||||
VTKM_STATIC_ASSERT_MSG((std::is_same<typename Traits::ComponentType, vtkm::Id>::value),
|
||||
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
|
||||
|
||||
if (Traits::GetNumberOfComponents(ids) < numVertices)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Not enough indices given to CellSetSingleType::AddCell.");
|
||||
throw vtkm::cont::ErrorBadValue("Not enough indices given to CellSetSingleType::AddCell.");
|
||||
}
|
||||
|
||||
if (this->NumberOfCellsAdded >= this->PointToCell.Shapes.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Added more cells then expected.");
|
||||
throw vtkm::cont::ErrorBadValue("Added more cells then expected.");
|
||||
}
|
||||
if (this->ConnectivityAdded+numVertices >
|
||||
this->PointToCell.Connectivity.GetNumberOfValues())
|
||||
if (this->ConnectivityAdded + numVertices > this->PointToCell.Connectivity.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Connectivity increased passed estimated maximum connectivity.");
|
||||
@ -234,11 +218,11 @@ public:
|
||||
this->PointToCell.NumIndices.GetPortalControl().Set(this->NumberOfCellsAdded, numVertices);
|
||||
for (vtkm::IdComponent iVec = 0; iVec < numVertices; ++iVec)
|
||||
{
|
||||
this->PointToCell.Connectivity.GetPortalControl().Set(
|
||||
this->ConnectivityAdded+iVec, Traits::GetComponent(ids,iVec));
|
||||
this->PointToCell.Connectivity.GetPortalControl().Set(this->ConnectivityAdded + iVec,
|
||||
Traits::GetComponent(ids, iVec));
|
||||
}
|
||||
this->PointToCell.IndexOffsets.GetPortalControl().Set(
|
||||
this->NumberOfCellsAdded, this->ConnectivityAdded);
|
||||
this->PointToCell.IndexOffsets.GetPortalControl().Set(this->NumberOfCellsAdded,
|
||||
this->ConnectivityAdded);
|
||||
this->NumberOfCellsAdded++;
|
||||
this->ConnectivityAdded += numVertices;
|
||||
}
|
||||
@ -253,8 +237,7 @@ public:
|
||||
|
||||
if (this->NumberOfCellsAdded != this->GetNumberOfCells())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Did not add as many cells as expected.");
|
||||
throw vtkm::cont::ErrorBadValue("Did not add as many cells as expected.");
|
||||
}
|
||||
|
||||
this->NumberOfCellsAdded = -1;
|
||||
@ -269,8 +252,8 @@ public:
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorageTag>& cellTypes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorageTag>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag>& connectivity,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag> &offsets
|
||||
= vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>() )
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>& offsets =
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, OffsetsStorageTag>())
|
||||
{
|
||||
this->NumberOfPoints = numPoints;
|
||||
this->PointToCell.Shapes = cellTypes;
|
||||
@ -289,8 +272,7 @@ public:
|
||||
this->PointToCell.IndexOffsetsValid = false;
|
||||
if (offsets.GetNumberOfValues() != 0)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Explicit cell offsets array unexpected size. "
|
||||
throw vtkm::cont::ErrorBadValue("Explicit cell offsets array unexpected size. "
|
||||
"Use an empty array to automatically generate.");
|
||||
}
|
||||
}
|
||||
@ -305,33 +287,32 @@ public:
|
||||
|
||||
typedef ConnectivityChooser<FromTopology, ToTopology> ConnectivityTypes;
|
||||
|
||||
typedef typename ConnectivityTypes::ShapeArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst ShapePortalType;
|
||||
typedef typename ConnectivityTypes::NumIndicesArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst IndicePortalType;
|
||||
typedef typename ConnectivityTypes::ConnectivityArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst ConnectivityPortalType;
|
||||
typedef typename ConnectivityTypes::IndexOffsetArrayType::template ExecutionTypes<DeviceAdapter>::PortalConst IndexOffsetPortalType;
|
||||
typedef typename ConnectivityTypes::ShapeArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst ShapePortalType;
|
||||
typedef typename ConnectivityTypes::NumIndicesArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst IndicePortalType;
|
||||
typedef typename ConnectivityTypes::ConnectivityArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst ConnectivityPortalType;
|
||||
typedef typename ConnectivityTypes::IndexOffsetArrayType::template ExecutionTypes<
|
||||
DeviceAdapter>::PortalConst IndexOffsetPortalType;
|
||||
|
||||
typedef vtkm::exec::ConnectivityExplicit<ShapePortalType,
|
||||
IndicePortalType,
|
||||
ConnectivityPortalType,
|
||||
IndexOffsetPortalType
|
||||
> ExecObjectType;
|
||||
typedef vtkm::exec::ConnectivityExplicit<ShapePortalType, IndicePortalType,
|
||||
ConnectivityPortalType, IndexOffsetPortalType>
|
||||
ExecObjectType;
|
||||
};
|
||||
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
typename ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
|
||||
PrepareForInput(Device, FromTopology, ToTopology) const
|
||||
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType PrepareForInput(
|
||||
Device, FromTopology, ToTopology) const
|
||||
{
|
||||
this->BuildConnectivity(Device(), FromTopology(), ToTopology());
|
||||
|
||||
const typename
|
||||
ConnectivityChooser<FromTopology,ToTopology>::ConnectivityType
|
||||
&connectivity = this->GetConnectivity(FromTopology(), ToTopology());
|
||||
const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityType& connectivity =
|
||||
this->GetConnectivity(FromTopology(), ToTopology());
|
||||
|
||||
VTKM_ASSERT(connectivity.ElementsValid);
|
||||
|
||||
typedef typename
|
||||
ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
|
||||
ExecObjType;
|
||||
typedef typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType ExecObjType;
|
||||
return ExecObjType(connectivity.Shapes.PrepareForInput(Device()),
|
||||
connectivity.NumIndices.PrepareForInput(Device()),
|
||||
connectivity.Connectivity.PrepareForInput(Device()),
|
||||
@ -339,26 +320,21 @@ public:
|
||||
}
|
||||
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT
|
||||
void BuildConnectivity(Device, FromTopology, ToTopology) const
|
||||
VTKM_CONT void BuildConnectivity(Device, FromTopology, ToTopology) const
|
||||
{
|
||||
typedef CellSetExplicit<ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag> CSE;
|
||||
typedef CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag, ConnectivityStorageTag,
|
||||
OffsetsStorageTag>
|
||||
CSE;
|
||||
|
||||
CSE* self = const_cast<CSE*>(this);
|
||||
|
||||
self->CreateConnectivity(Device(), FromTopology(), ToTopology());
|
||||
|
||||
self->GetConnectivity(FromTopology(), ToTopology()).
|
||||
BuildIndexOffsets(Device());
|
||||
self->GetConnectivity(FromTopology(), ToTopology()).BuildIndexOffsets(Device());
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT
|
||||
void CreateConnectivity(Device,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
VTKM_CONT void CreateConnectivity(Device, vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell)
|
||||
{
|
||||
// nothing to do
|
||||
@ -368,9 +344,7 @@ public:
|
||||
class ExpandIndices : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
typedef void ControlSignature(FieldIn<> cellIndex,
|
||||
FieldIn<> offset,
|
||||
FieldIn<> numIndices,
|
||||
typedef void ControlSignature(FieldIn<> cellIndex, FieldIn<> offset, FieldIn<> numIndices,
|
||||
WholeArrayOut<> cellIndices);
|
||||
typedef void ExecutionSignature(_1, _2, _3, _4);
|
||||
typedef _1 InputDomain;
|
||||
@ -379,11 +353,8 @@ public:
|
||||
ExpandIndices() {}
|
||||
|
||||
template <typename PortalType>
|
||||
VTKM_EXEC
|
||||
void operator()(const vtkm::Id &cellIndex,
|
||||
const vtkm::Id &offset,
|
||||
const vtkm::Id &numIndices,
|
||||
const PortalType &cellIndices) const
|
||||
VTKM_EXEC void operator()(const vtkm::Id& cellIndex, const vtkm::Id& offset,
|
||||
const vtkm::Id& numIndices, const PortalType& cellIndices) const
|
||||
{
|
||||
VTKM_ASSERT(cellIndices.GetNumberOfValues() >= offset + numIndices);
|
||||
vtkm::Id startIndex = offset;
|
||||
@ -395,9 +366,7 @@ public:
|
||||
};
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT
|
||||
void CreateConnectivity(Device,
|
||||
vtkm::TopologyElementTagCell,
|
||||
VTKM_CONT void CreateConnectivity(Device, vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint)
|
||||
{
|
||||
// PointToCell connectivity array (point indices) will be
|
||||
@ -428,9 +397,7 @@ public:
|
||||
|
||||
this->PointToCell.BuildIndexOffsets(Device());
|
||||
vtkm::worklet::DispatcherMapField<ExpandIndices, Device> expandDispatcher;
|
||||
expandDispatcher.Invoke(index,
|
||||
this->PointToCell.IndexOffsets,
|
||||
this->PointToCell.NumIndices,
|
||||
expandDispatcher.Invoke(index, this->PointToCell.IndexOffsets, this->PointToCell.NumIndices,
|
||||
this->CellToPoint.Connectivity);
|
||||
|
||||
// SortByKey where key is PointToCell connectivity and value is the expanded cellIndex
|
||||
@ -449,9 +416,7 @@ public:
|
||||
uniquePoints.Allocate(numberOfPoints);
|
||||
numIndices.Allocate(numberOfPoints);
|
||||
|
||||
Algorithm::ReduceByKey(pointIndices, numArray,
|
||||
uniquePoints, numIndices,
|
||||
vtkm::Add());
|
||||
Algorithm::ReduceByKey(pointIndices, numArray, uniquePoints, numIndices, vtkm::Add());
|
||||
|
||||
// Set the CellToPoint information
|
||||
this->CellToPoint.Shapes = vtkm::cont::make_ArrayHandleConstant(
|
||||
@ -472,72 +437,62 @@ public:
|
||||
}
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT
|
||||
const typename ConnectivityChooser<FromTopology,ToTopology>::ShapeArrayType &
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
|
||||
GetShapesArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).Shapes;
|
||||
}
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT
|
||||
const typename ConnectivityChooser<FromTopology,ToTopology>::NumIndicesArrayType &
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
|
||||
GetNumIndicesArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).NumIndices;
|
||||
}
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT
|
||||
const typename ConnectivityChooser<FromTopology,ToTopology>::ConnectivityArrayType &
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
|
||||
GetConnectivityArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).Connectivity;
|
||||
}
|
||||
|
||||
template <typename FromTopology, typename ToTopology>
|
||||
VTKM_CONT
|
||||
const typename ConnectivityChooser<FromTopology,ToTopology>::IndexOffsetArrayType &
|
||||
VTKM_CONT const typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
|
||||
GetIndexOffsetArray(FromTopology, ToTopology) const
|
||||
{
|
||||
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
||||
}
|
||||
|
||||
protected:
|
||||
typename ConnectivityChooser<
|
||||
vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell>::
|
||||
ConnectivityType PointToCell;
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell>::ConnectivityType PointToCell;
|
||||
|
||||
// TODO: Actually implement CellToPoint and other connectivity. (That is,
|
||||
// derive the connectivity from PointToCell.
|
||||
typename ConnectivityChooser<
|
||||
vtkm::TopologyElementTagCell,vtkm::TopologyElementTagPoint>::
|
||||
ConnectivityType CellToPoint;
|
||||
private:
|
||||
typename ConnectivityChooser<vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint>::ConnectivityType CellToPoint;
|
||||
|
||||
private:
|
||||
// A set of overloaded methods to get the connectivity from a pair of
|
||||
// topology element types.
|
||||
#define VTKM_GET_CONNECTIVITY_METHOD(FromTopology, ToTopology, Ivar) \
|
||||
VTKM_CONT \
|
||||
const typename ConnectivityChooser< \
|
||||
FromTopology,ToTopology>::ConnectivityType & \
|
||||
GetConnectivity(FromTopology, ToTopology) const \
|
||||
const typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityType& GetConnectivity( \
|
||||
FromTopology, ToTopology) const \
|
||||
{ \
|
||||
return this->Ivar; \
|
||||
} \
|
||||
VTKM_CONT \
|
||||
typename ConnectivityChooser< \
|
||||
FromTopology,ToTopology>::ConnectivityType & \
|
||||
GetConnectivity(FromTopology, ToTopology) \
|
||||
typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityType& GetConnectivity( \
|
||||
FromTopology, ToTopology) \
|
||||
{ \
|
||||
return this->Ivar; \
|
||||
}
|
||||
|
||||
VTKM_GET_CONNECTIVITY_METHOD(vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell,
|
||||
VTKM_GET_CONNECTIVITY_METHOD(vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell,
|
||||
PointToCell)
|
||||
VTKM_GET_CONNECTIVITY_METHOD(vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
VTKM_GET_CONNECTIVITY_METHOD(vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint,
|
||||
CellToPoint)
|
||||
|
||||
#undef VTKM_GET_CONNECTIVITY_METHOD
|
||||
@ -551,33 +506,31 @@ protected:
|
||||
vtkm::Id NumberOfPoints;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Storage1, typename Storage2, typename Storage3, typename Storage4>
|
||||
struct CellSetExplicitConnectivityChooser<
|
||||
vtkm::cont::CellSetExplicit<Storage1, Storage2, Storage3, Storage4>,
|
||||
vtkm::TopologyElementTagPoint,
|
||||
vtkm::TopologyElementTagCell>
|
||||
vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell>
|
||||
{
|
||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<
|
||||
Storage1,Storage2,Storage3,Storage4> ConnectivityType;
|
||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<Storage1, Storage2, Storage3,
|
||||
Storage4>
|
||||
ConnectivityType;
|
||||
};
|
||||
|
||||
|
||||
template <typename CellSetType>
|
||||
struct CellSetExplicitConnectivityChooser<
|
||||
CellSetType,
|
||||
vtkm::TopologyElementTagCell,
|
||||
struct CellSetExplicitConnectivityChooser<CellSetType, vtkm::TopologyElementTagCell,
|
||||
vtkm::TopologyElementTagPoint>
|
||||
{
|
||||
//only specify the shape type as it will be constant as everything
|
||||
//is a vertex. otherwise use the defaults.
|
||||
typedef vtkm::cont::internal::ConnectivityExplicitInternals<
|
||||
typename ArrayHandleConstant<vtkm::UInt8>::StorageTag > ConnectivityType;
|
||||
typename ArrayHandleConstant<vtkm::UInt8>::StorageTag>
|
||||
ConnectivityType;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -30,54 +30,55 @@
|
||||
#include <vtkm/cont/CellSetSingleType.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured1D
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<1> > { };
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<1>>
|
||||
{
|
||||
};
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured2D
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<2> > { };
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<2>>
|
||||
{
|
||||
};
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured3D
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<3> > { };
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<3>>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename ShapeStorageTag = VTKM_DEFAULT_SHAPE_STORAGE_TAG,
|
||||
typename NumIndicesStorageTag = VTKM_DEFAULT_NUM_INDICES_STORAGE_TAG,
|
||||
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG,
|
||||
typename OffsetsStorageTag = VTKM_DEFAULT_OFFSETS_STORAGE_TAG>
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagExplicit
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::CellSetExplicit<
|
||||
ShapeStorageTag,
|
||||
NumIndicesStorageTag,
|
||||
ConnectivityStorageTag,
|
||||
OffsetsStorageTag> > { };
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagExplicitDefault
|
||||
: CellSetListTagExplicit<> { };
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetExplicit<ShapeStorageTag, NumIndicesStorageTag,
|
||||
ConnectivityStorageTag, OffsetsStorageTag>>
|
||||
{
|
||||
};
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagExplicitDefault : CellSetListTagExplicit<>
|
||||
{
|
||||
};
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagCommon
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::CellSetStructured<2>,
|
||||
vtkm::cont::CellSetStructured<3>,
|
||||
vtkm::cont::CellSetExplicit<>,
|
||||
vtkm::cont::CellSetSingleType<>
|
||||
> { };
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<2>, vtkm::cont::CellSetStructured<3>,
|
||||
vtkm::cont::CellSetExplicit<>, vtkm::cont::CellSetSingleType<>>
|
||||
{
|
||||
};
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagStructured
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::CellSetStructured<2>,
|
||||
vtkm::cont::CellSetStructured<3>
|
||||
> { };
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetStructured<2>, vtkm::cont::CellSetStructured<3>>
|
||||
{
|
||||
};
|
||||
|
||||
struct VTKM_ALWAYS_EXPORT CellSetListTagUnstructured
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::CellSetExplicit<>,
|
||||
vtkm::cont::CellSetSingleType<>
|
||||
> { };
|
||||
|
||||
: vtkm::ListTagBase<vtkm::cont::CellSetExplicit<>, vtkm::cont::CellSetSingleType<>>
|
||||
{
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -27,12 +27,16 @@
|
||||
|
||||
#include <vtkm/exec/ConnectivityPermuted.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template< typename OriginalCellSet, typename ValidCellArrayHandleType> class CellSetPermutation;
|
||||
template <typename OriginalCellSet, typename ValidCellArrayHandleType>
|
||||
class CellSetPermutation;
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename OriginalCellSet, typename PermutationArrayHandleType>
|
||||
class CellSetGeneralPermutation : public CellSet
|
||||
@ -40,33 +44,26 @@ class CellSetGeneralPermutation : public CellSet
|
||||
public:
|
||||
VTKM_CONT
|
||||
CellSetGeneralPermutation(const PermutationArrayHandleType& validCellIds,
|
||||
const OriginalCellSet& cellset,
|
||||
const std::string &name)
|
||||
: CellSet(name),
|
||||
ValidCellIds(validCellIds),
|
||||
FullCellSet(cellset)
|
||||
const OriginalCellSet& cellset, const std::string& name)
|
||||
: CellSet(name)
|
||||
, ValidCellIds(validCellIds)
|
||||
, FullCellSet(cellset)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetGeneralPermutation(const std::string& name)
|
||||
: CellSet(name),
|
||||
ValidCellIds(),
|
||||
FullCellSet()
|
||||
: CellSet(name)
|
||||
, ValidCellIds()
|
||||
, FullCellSet()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfCells() const VTKM_OVERRIDE
|
||||
{
|
||||
return this->ValidCellIds.GetNumberOfValues();
|
||||
}
|
||||
vtkm::Id GetNumberOfCells() const VTKM_OVERRIDE { return this->ValidCellIds.GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE
|
||||
{
|
||||
return this->FullCellSet.GetNumberOfPoints();
|
||||
}
|
||||
vtkm::Id GetNumberOfPoints() const VTKM_OVERRIDE { return this->FullCellSet.GetNumberOfPoints(); }
|
||||
|
||||
vtkm::Id GetNumberOfFaces() const VTKM_OVERRIDE { return -1; }
|
||||
|
||||
@ -74,43 +71,41 @@ public:
|
||||
|
||||
//This is the way you can fill the memory from another system without copying
|
||||
VTKM_CONT
|
||||
void Fill(const PermutationArrayHandleType &validCellIds,
|
||||
const OriginalCellSet& cellset)
|
||||
void Fill(const PermutationArrayHandleType& validCellIds, const OriginalCellSet& cellset)
|
||||
{
|
||||
ValidCellIds = validCellIds;
|
||||
FullCellSet = cellset;
|
||||
}
|
||||
|
||||
template <typename TopologyElement>
|
||||
VTKM_CONT
|
||||
vtkm::Id GetSchedulingRange(TopologyElement) const {
|
||||
VTKM_CONT vtkm::Id GetSchedulingRange(TopologyElement) const
|
||||
{
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(TopologyElement);
|
||||
return this->ValidCellIds.GetNumberOfValues();
|
||||
}
|
||||
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
struct ExecutionTypes {
|
||||
struct ExecutionTypes
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||
|
||||
typedef typename PermutationArrayHandleType::template ExecutionTypes<Device>::PortalConst ExecPortalType;
|
||||
typedef typename PermutationArrayHandleType::template ExecutionTypes<Device>::PortalConst
|
||||
ExecPortalType;
|
||||
|
||||
typedef typename OriginalCellSet::template ExecutionTypes<
|
||||
Device,
|
||||
FromTopology,
|
||||
ToTopology>::ExecObjectType OrigExecObjectType;
|
||||
Device, FromTopology, ToTopology>::ExecObjectType OrigExecObjectType;
|
||||
|
||||
typedef vtkm::exec::ConnectivityPermuted<ExecPortalType, OrigExecObjectType> ExecObjectType;
|
||||
};
|
||||
|
||||
template <typename Device, typename FromTopology, typename ToTopology>
|
||||
typename ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
|
||||
PrepareForInput(Device d, FromTopology f, ToTopology t) const
|
||||
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType PrepareForInput(
|
||||
Device d, FromTopology f, ToTopology t) const
|
||||
{
|
||||
typedef typename
|
||||
ExecutionTypes<Device,FromTopology,ToTopology>::ExecObjectType
|
||||
ConnectivityType;
|
||||
typedef
|
||||
typename ExecutionTypes<Device, FromTopology, ToTopology>::ExecObjectType ConnectivityType;
|
||||
return ConnectivityType(this->ValidCellIds.PrepareForInput(d),
|
||||
this->FullCellSet.PrepareForInput(d, f, t));
|
||||
}
|
||||
@ -133,19 +128,22 @@ private:
|
||||
#endif
|
||||
|
||||
template <typename OriginalCellSet,
|
||||
typename PermutationArrayHandleType = vtkm::cont::ArrayHandle< vtkm::Id, VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG > >
|
||||
class CellSetPermutation : public vtkm::cont::internal::CellSetGeneralPermutation<OriginalCellSet, PermutationArrayHandleType>
|
||||
typename PermutationArrayHandleType =
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, VTKM_DEFAULT_CELLSET_PERMUTATION_STORAGE_TAG>>
|
||||
class CellSetPermutation
|
||||
: public vtkm::cont::internal::CellSetGeneralPermutation<OriginalCellSet,
|
||||
PermutationArrayHandleType>
|
||||
{
|
||||
VTKM_IS_CELL_SET(OriginalCellSet);
|
||||
VTKM_IS_ARRAY_HANDLE(PermutationArrayHandleType);
|
||||
|
||||
typedef typename vtkm::cont::internal::CellSetGeneralPermutation<
|
||||
OriginalCellSet, PermutationArrayHandleType> ParentType;
|
||||
public:
|
||||
typedef typename vtkm::cont::internal::CellSetGeneralPermutation<OriginalCellSet,
|
||||
PermutationArrayHandleType>
|
||||
ParentType;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
CellSetPermutation(const PermutationArrayHandleType& validCellIds,
|
||||
const OriginalCellSet& cellset,
|
||||
CellSetPermutation(const PermutationArrayHandleType& validCellIds, const OriginalCellSet& cellset,
|
||||
const std::string& name = std::string())
|
||||
: ParentType(validCellIds, cellset, name)
|
||||
{
|
||||
@ -158,41 +156,35 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetPermutation<OriginalCellSet,PermutationArrayHandleType>&
|
||||
operator=(const CellSetPermutation<OriginalCellSet,PermutationArrayHandleType> &src)
|
||||
CellSetPermutation<OriginalCellSet, PermutationArrayHandleType>& operator=(
|
||||
const CellSetPermutation<OriginalCellSet, PermutationArrayHandleType>& src)
|
||||
{
|
||||
ParentType::operator=(src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename OriginalCellSet, typename PermutationArrayHandleType>
|
||||
vtkm::cont::CellSetPermutation<OriginalCellSet,PermutationArrayHandleType>
|
||||
make_CellSetPermutation(const PermutationArrayHandleType &cellIndexMap,
|
||||
const OriginalCellSet &cellSet,
|
||||
vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType> make_CellSetPermutation(
|
||||
const PermutationArrayHandleType& cellIndexMap, const OriginalCellSet& cellSet,
|
||||
const std::string& name)
|
||||
{
|
||||
VTKM_IS_CELL_SET(OriginalCellSet);
|
||||
VTKM_IS_ARRAY_HANDLE(PermutationArrayHandleType);
|
||||
|
||||
return vtkm::cont::CellSetPermutation<
|
||||
OriginalCellSet,PermutationArrayHandleType>(
|
||||
cellIndexMap, cellSet, name);
|
||||
return vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType>(cellIndexMap,
|
||||
cellSet, name);
|
||||
}
|
||||
|
||||
template <typename OriginalCellSet, typename PermutationArrayHandleType>
|
||||
vtkm::cont::CellSetPermutation<OriginalCellSet,PermutationArrayHandleType>
|
||||
make_CellSetPermutation(const PermutationArrayHandleType &cellIndexMap,
|
||||
const OriginalCellSet &cellSet)
|
||||
vtkm::cont::CellSetPermutation<OriginalCellSet, PermutationArrayHandleType> make_CellSetPermutation(
|
||||
const PermutationArrayHandleType& cellIndexMap, const OriginalCellSet& cellSet)
|
||||
{
|
||||
VTKM_IS_CELL_SET(OriginalCellSet);
|
||||
VTKM_IS_ARRAY_HANDLE(PermutationArrayHandleType);
|
||||
|
||||
return vtkm::cont::make_CellSetPermutation(
|
||||
cellIndexMap, cellSet, cellSet.GetName());
|
||||
return vtkm::cont::make_CellSetPermutation(cellIndexMap, cellSet, cellSet.GetName());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -30,17 +30,19 @@
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
//Only works with fixed sized cell sets
|
||||
|
||||
template <typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG>
|
||||
class VTKM_ALWAYS_EXPORT CellSetSingleType :
|
||||
public vtkm::cont::CellSetExplicit<
|
||||
class VTKM_ALWAYS_EXPORT CellSetSingleType
|
||||
: public vtkm::cont::CellSetExplicit<
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag, //ShapeStorageTag
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag, //NumIndicesStorageTag
|
||||
typename vtkm::cont::ArrayHandleConstant<
|
||||
vtkm::IdComponent>::StorageTag, //NumIndicesStorageTag
|
||||
ConnectivityStorageTag,
|
||||
typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag //IndexOffsetStorageTag
|
||||
>
|
||||
@ -48,28 +50,28 @@ class VTKM_ALWAYS_EXPORT CellSetSingleType :
|
||||
typedef vtkm::cont::CellSetSingleType<ConnectivityStorageTag> Thisclass;
|
||||
typedef vtkm::cont::CellSetExplicit<
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag,
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag,
|
||||
ConnectivityStorageTag,
|
||||
typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag > Superclass;
|
||||
typename vtkm::cont::ArrayHandleConstant<vtkm::IdComponent>::StorageTag, ConnectivityStorageTag,
|
||||
typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag>
|
||||
Superclass;
|
||||
|
||||
public:
|
||||
|
||||
VTKM_CONT
|
||||
CellSetSingleType(const std::string& name = std::string())
|
||||
: Superclass(name),
|
||||
ExpectedNumberOfCellsAdded(-1),
|
||||
CellShapeAsId(CellShapeTagEmpty::Id),
|
||||
NumberOfPointsPerCell(0)
|
||||
: Superclass(name)
|
||||
, ExpectedNumberOfCellsAdded(-1)
|
||||
, CellShapeAsId(CellShapeTagEmpty::Id)
|
||||
, NumberOfPointsPerCell(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CellSetSingleType(const Thisclass& src)
|
||||
: Superclass(src),
|
||||
ExpectedNumberOfCellsAdded(-1),
|
||||
CellShapeAsId(src.CellShapeAsId),
|
||||
NumberOfPointsPerCell(src.NumberOfPointsPerCell)
|
||||
{ }
|
||||
: Superclass(src)
|
||||
, ExpectedNumberOfCellsAdded(-1)
|
||||
, CellShapeAsId(src.CellShapeAsId)
|
||||
, NumberOfPointsPerCell(src.NumberOfPointsPerCell)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Thisclass& operator=(const Thisclass& src)
|
||||
@ -84,8 +86,7 @@ public:
|
||||
|
||||
/// First method to add cells -- one at a time.
|
||||
VTKM_CONT
|
||||
void PrepareToAddCells(vtkm::Id numCells,
|
||||
vtkm::Id connectivityMaxLen)
|
||||
void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen)
|
||||
{
|
||||
this->CellShapeAsId = vtkm::CELL_SHAPE_EMPTY;
|
||||
|
||||
@ -98,24 +99,18 @@ public:
|
||||
|
||||
/// Second method to add cells -- one at a time.
|
||||
template <typename IdVecType>
|
||||
VTKM_CONT
|
||||
void AddCell(vtkm::UInt8 shapeId,
|
||||
vtkm::IdComponent numVertices,
|
||||
const IdVecType &ids)
|
||||
VTKM_CONT void AddCell(vtkm::UInt8 shapeId, vtkm::IdComponent numVertices, const IdVecType& ids)
|
||||
{
|
||||
using Traits = vtkm::VecTraits<IdVecType>;
|
||||
VTKM_STATIC_ASSERT_MSG(
|
||||
(std::is_same<typename Traits::ComponentType,vtkm::Id>::value),
|
||||
VTKM_STATIC_ASSERT_MSG((std::is_same<typename Traits::ComponentType, vtkm::Id>::value),
|
||||
"CellSetSingleType::AddCell requires vtkm::Id for indices.");
|
||||
|
||||
if (Traits::GetNumberOfComponents(ids) < numVertices)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Not enough indices given to CellSetSingleType::AddCell.");
|
||||
throw vtkm::cont::ErrorBadValue("Not enough indices given to CellSetSingleType::AddCell.");
|
||||
}
|
||||
|
||||
if (this->ConnectivityAdded+numVertices >
|
||||
this->PointToCell.Connectivity.GetNumberOfValues())
|
||||
if (this->ConnectivityAdded + numVertices > this->PointToCell.Connectivity.GetNumberOfValues())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Connectivity increased passed estimated maximum connectivity.");
|
||||
@ -125,8 +120,7 @@ public:
|
||||
{
|
||||
if (shapeId == vtkm::CELL_SHAPE_EMPTY)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Cannot create cells of type empty.");
|
||||
throw vtkm::cont::ErrorBadValue("Cannot create cells of type empty.");
|
||||
}
|
||||
this->CellShapeAsId = shapeId;
|
||||
this->CheckNumberOfPointsPerCell(numVertices);
|
||||
@ -136,8 +130,7 @@ public:
|
||||
{
|
||||
if (shapeId != this->GetCellShape(0))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Cannot have differing shapes in CellSetSingleType.");
|
||||
throw vtkm::cont::ErrorBadValue("Cannot have differing shapes in CellSetSingleType.");
|
||||
}
|
||||
if (numVertices != this->NumberOfPointsPerCell)
|
||||
{
|
||||
@ -147,8 +140,8 @@ public:
|
||||
}
|
||||
for (vtkm::IdComponent iVert = 0; iVert < numVertices; ++iVert)
|
||||
{
|
||||
this->PointToCell.Connectivity.GetPortalControl().Set(
|
||||
this->ConnectivityAdded+iVert, Traits::GetComponent(ids,iVert));
|
||||
this->PointToCell.Connectivity.GetPortalControl().Set(this->ConnectivityAdded + iVert,
|
||||
Traits::GetComponent(ids, iVert));
|
||||
}
|
||||
this->NumberOfCellsAdded++;
|
||||
this->ConnectivityAdded += numVertices;
|
||||
@ -166,21 +159,16 @@ public:
|
||||
this->PointToCell.Shapes =
|
||||
vtkm::cont::make_ArrayHandleConstant(this->GetCellShape(0), numCells);
|
||||
this->PointToCell.NumIndices =
|
||||
vtkm::cont::make_ArrayHandleConstant(this->NumberOfPointsPerCell,
|
||||
numCells);
|
||||
this->PointToCell.IndexOffsets =
|
||||
vtkm::cont::make_ArrayHandleCounting(
|
||||
vtkm::Id(0),
|
||||
static_cast<vtkm::Id>(this->NumberOfPointsPerCell),
|
||||
numCells);
|
||||
vtkm::cont::make_ArrayHandleConstant(this->NumberOfPointsPerCell, numCells);
|
||||
this->PointToCell.IndexOffsets = vtkm::cont::make_ArrayHandleCounting(
|
||||
vtkm::Id(0), static_cast<vtkm::Id>(this->NumberOfPointsPerCell), numCells);
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
this->PointToCell.IndexOffsetsValid = true;
|
||||
|
||||
if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Did not add the expected number of cells.");
|
||||
throw vtkm::cont::ErrorBadValue("Did not add the expected number of cells.");
|
||||
}
|
||||
|
||||
this->NumberOfCellsAdded = -1;
|
||||
@ -190,27 +178,19 @@ public:
|
||||
|
||||
//This is the way you can fill the memory from another system without copying
|
||||
VTKM_CONT
|
||||
void Fill(vtkm::Id numPoints,
|
||||
vtkm::UInt8 shapeId,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id,ConnectivityStorageTag>
|
||||
&connectivity)
|
||||
void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityStorageTag>& connectivity)
|
||||
{
|
||||
this->NumberOfPoints = numPoints;
|
||||
this->CellShapeAsId = shapeId;
|
||||
this->CheckNumberOfPointsPerCell(numberOfPointsPerCell);
|
||||
const vtkm::Id numCells =
|
||||
connectivity.GetNumberOfValues() / numberOfPointsPerCell;
|
||||
const vtkm::Id numCells = connectivity.GetNumberOfValues() / numberOfPointsPerCell;
|
||||
VTKM_ASSERT((connectivity.GetNumberOfValues() % numberOfPointsPerCell) == 0);
|
||||
this->PointToCell.Shapes =
|
||||
vtkm::cont::make_ArrayHandleConstant(shapeId, numCells);
|
||||
this->PointToCell.Shapes = vtkm::cont::make_ArrayHandleConstant(shapeId, numCells);
|
||||
this->PointToCell.NumIndices =
|
||||
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell,
|
||||
numCells);
|
||||
this->PointToCell.IndexOffsets =
|
||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0),
|
||||
static_cast<vtkm::Id>(numberOfPointsPerCell),
|
||||
numCells );
|
||||
vtkm::cont::make_ArrayHandleConstant(numberOfPointsPerCell, numCells);
|
||||
this->PointToCell.IndexOffsets = vtkm::cont::make_ArrayHandleCounting(
|
||||
vtkm::Id(0), static_cast<vtkm::Id>(numberOfPointsPerCell), numCells);
|
||||
this->PointToCell.Connectivity = connectivity;
|
||||
|
||||
this->PointToCell.ElementsValid = true;
|
||||
@ -218,10 +198,7 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetCellShapeAsId() const
|
||||
{
|
||||
return this->CellShapeAsId;
|
||||
}
|
||||
vtkm::Id GetCellShapeAsId() const { return this->CellShapeAsId; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::UInt8 GetCellShape(vtkm::Id vtkmNotUsed(cellIndex)) const
|
||||
@ -231,7 +208,8 @@ public:
|
||||
|
||||
virtual void PrintSummary(std::ostream& out) const
|
||||
{
|
||||
out << " ExplicitSingleCellSet: " << this->Name << " Type "<<this->CellShapeAsId<<std::endl;
|
||||
out << " ExplicitSingleCellSet: " << this->Name << " Type " << this->CellShapeAsId
|
||||
<< std::endl;
|
||||
out << " PointToCell: " << std::endl;
|
||||
this->PointToCell.PrintSummary(out);
|
||||
out << " CellToPoint: " << std::endl;
|
||||
@ -240,20 +218,17 @@ public:
|
||||
|
||||
private:
|
||||
template <typename CellShapeTag>
|
||||
void CheckNumberOfPointsPerCell(CellShapeTag,
|
||||
vtkm::CellTraitsTagSizeFixed,
|
||||
void CheckNumberOfPointsPerCell(CellShapeTag, vtkm::CellTraitsTagSizeFixed,
|
||||
vtkm::IdComponent numVertices) const
|
||||
{
|
||||
if (numVertices != vtkm::CellTraits<CellShapeTag>::NUM_POINTS)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Passed invalid number of points for cell shape.");
|
||||
throw vtkm::cont::ErrorBadValue("Passed invalid number of points for cell shape.");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
void CheckNumberOfPointsPerCell(CellShapeTag,
|
||||
vtkm::CellTraitsTagSizeVariable,
|
||||
void CheckNumberOfPointsPerCell(CellShapeTag, vtkm::CellTraitsTagSizeVariable,
|
||||
vtkm::IdComponent vtkmNotUsed(numVertices)) const
|
||||
{
|
||||
// Technically, a shape with a variable number of points probably has a
|
||||
@ -261,18 +236,14 @@ private:
|
||||
// check that. Instead, just pass the check by returning without error.
|
||||
}
|
||||
|
||||
|
||||
void CheckNumberOfPointsPerCell(vtkm::IdComponent numVertices) const
|
||||
{
|
||||
switch (this->CellShapeAsId)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(
|
||||
this->CheckNumberOfPointsPerCell(CellShapeTag(),
|
||||
vtkm::CellTraits<CellShapeTag>::IsSizeFixed(),
|
||||
numVertices) );
|
||||
vtkmGenericCellShapeMacro(this->CheckNumberOfPointsPerCell(
|
||||
CellShapeTag(), vtkm::CellTraits<CellShapeTag>::IsSizeFixed(), numVertices));
|
||||
default:
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"CellSetSingleType unable to determine the cell type");
|
||||
throw vtkm::cont::ErrorBadValue("CellSetSingleType unable to determine the cell type");
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +251,6 @@ private:
|
||||
vtkm::Id CellShapeAsId;
|
||||
vtkm::IdComponent NumberOfPointsPerCell;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -21,12 +21,13 @@
|
||||
#define vtkm_cont_CellSetStructured_cxx
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template class VTKM_CONT_EXPORT CellSetStructured<1>;
|
||||
template class VTKM_CONT_EXPORT CellSetStructured<2>;
|
||||
template class VTKM_CONT_EXPORT CellSetStructured<3>;
|
||||
|
||||
}
|
||||
}
|
@ -28,16 +28,17 @@
|
||||
#include <vtkm/exec/ConnectivityStructured.h>
|
||||
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
class VTKM_ALWAYS_EXPORT CellSetStructured : public CellSet
|
||||
{
|
||||
private:
|
||||
typedef vtkm::cont::CellSetStructured<DIMENSION> Thisclass;
|
||||
typedef vtkm::internal::ConnectivityStructuredInternals<DIMENSION>
|
||||
InternalsType;
|
||||
typedef vtkm::internal::ConnectivityStructuredInternals<DIMENSION> InternalsType;
|
||||
|
||||
public:
|
||||
static const vtkm::IdComponent Dimension = DIMENSION;
|
||||
@ -45,7 +46,8 @@ public:
|
||||
typedef typename InternalsType::SchedulingRangeType SchedulingRangeType;
|
||||
|
||||
CellSetStructured(const std::string& name = std::string())
|
||||
: CellSet(name), Structure()
|
||||
: CellSet(name)
|
||||
, Structure()
|
||||
{
|
||||
}
|
||||
|
||||
@ -53,15 +55,9 @@ public:
|
||||
|
||||
Thisclass& operator=(const Thisclass& src);
|
||||
|
||||
virtual vtkm::Id GetNumberOfCells() const
|
||||
{
|
||||
return this->Structure.GetNumberOfCells();
|
||||
}
|
||||
virtual vtkm::Id GetNumberOfCells() const { return this->Structure.GetNumberOfCells(); }
|
||||
|
||||
virtual vtkm::Id GetNumberOfPoints() const
|
||||
{
|
||||
return this->Structure.GetNumberOfPoints();
|
||||
}
|
||||
virtual vtkm::Id GetNumberOfPoints() const { return this->Structure.GetNumberOfPoints(); }
|
||||
|
||||
virtual vtkm::Id GetNumberOfFaces() const { return -1; }
|
||||
|
||||
@ -72,32 +68,23 @@ public:
|
||||
this->Structure.SetPointDimensions(dimensions);
|
||||
}
|
||||
|
||||
SchedulingRangeType GetPointDimensions()
|
||||
{
|
||||
return this->Structure.GetPointDimensions();
|
||||
}
|
||||
SchedulingRangeType GetPointDimensions() { return this->Structure.GetPointDimensions(); }
|
||||
|
||||
SchedulingRangeType GetCellDimensions()
|
||||
{
|
||||
return this->Structure.GetCellDimensions();
|
||||
}
|
||||
SchedulingRangeType GetCellDimensions() { return this->Structure.GetCellDimensions(); }
|
||||
|
||||
vtkm::IdComponent
|
||||
GetNumberOfPointsInCell(vtkm::Id vtkmNotUsed(cellIndex)=0) const
|
||||
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id vtkmNotUsed(cellIndex) = 0) const
|
||||
{
|
||||
return this->Structure.GetNumberOfPointsInCell();
|
||||
}
|
||||
|
||||
vtkm::IdComponent GetCellShape() const
|
||||
{
|
||||
return this->Structure.GetCellShape();
|
||||
}
|
||||
vtkm::IdComponent GetCellShape() const { return this->Structure.GetCellShape(); }
|
||||
|
||||
template <typename TopologyElement>
|
||||
SchedulingRangeType GetSchedulingRange(TopologyElement) const;
|
||||
|
||||
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||
struct ExecutionTypes {
|
||||
struct ExecutionTypes
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(FromTopology);
|
||||
VTKM_IS_TOPOLOGY_ELEMENT_TAG(ToTopology);
|
||||
@ -105,8 +92,8 @@ public:
|
||||
};
|
||||
|
||||
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||
typename ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
|
||||
PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const;
|
||||
typename ExecutionTypes<DeviceAdapter, FromTopology, ToTopology>::ExecObjectType PrepareForInput(
|
||||
DeviceAdapter, FromTopology, ToTopology) const;
|
||||
|
||||
virtual void PrintSummary(std::ostream& out) const;
|
||||
|
||||
@ -119,7 +106,6 @@ extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<1>;
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<2>;
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<3>;
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -18,19 +18,21 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
CellSetStructured<DIMENSION>::CellSetStructured(const CellSetStructured<DIMENSION>& src)
|
||||
: CellSet(src), Structure(src.Structure)
|
||||
: CellSet(src)
|
||||
, Structure(src.Structure)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
CellSetStructured<DIMENSION>&
|
||||
CellSetStructured<DIMENSION>::operator=(const CellSetStructured<DIMENSION> &src)
|
||||
CellSetStructured<DIMENSION>& CellSetStructured<DIMENSION>::operator=(
|
||||
const CellSetStructured<DIMENSION>& src)
|
||||
{
|
||||
this->CellSet::operator=(src);
|
||||
this->Structure = src.Structure;
|
||||
@ -48,11 +50,11 @@ CellSetStructured<DIMENSION>::GetSchedulingRange(TopologyElement) const
|
||||
|
||||
template <vtkm::IdComponent DIMENSION>
|
||||
template <typename DeviceAdapter, typename FromTopology, typename ToTopology>
|
||||
typename CellSetStructured<DIMENSION>::template ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
|
||||
typename CellSetStructured<DIMENSION>::template ExecutionTypes<DeviceAdapter, FromTopology,
|
||||
ToTopology>::ExecObjectType
|
||||
CellSetStructured<DIMENSION>::PrepareForInput(DeviceAdapter, FromTopology, ToTopology) const
|
||||
{
|
||||
typedef typename
|
||||
ExecutionTypes<DeviceAdapter,FromTopology,ToTopology>::ExecObjectType
|
||||
typedef typename ExecutionTypes<DeviceAdapter, FromTopology, ToTopology>::ExecObjectType
|
||||
ConnectivityType;
|
||||
return ConnectivityType(this->Structure);
|
||||
}
|
||||
@ -63,7 +65,5 @@ void CellSetStructured<DIMENSION>::PrintSummary(std::ostream &out) const
|
||||
out << " StructuredCellSet: " << this->GetName() << std::endl;
|
||||
this->Structure.PrintSummary(out);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,10 @@
|
||||
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_CONT
|
||||
void CoordinateSystem::PrintSummary(std::ostream& out) const
|
||||
@ -33,18 +35,14 @@ void CoordinateSystem::PrintSummary(std::ostream &out) const
|
||||
VTKM_CONT
|
||||
void CoordinateSystem::GetRange(vtkm::Range* range) const
|
||||
{
|
||||
this->Superclass::GetRange(
|
||||
range,
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
|
||||
this->Superclass::GetRange(range, VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::ArrayHandle<vtkm::Range>&
|
||||
CoordinateSystem::GetRange() const
|
||||
const vtkm::cont::ArrayHandle<vtkm::Range>& CoordinateSystem::GetRange() const
|
||||
{
|
||||
return this->Superclass::GetRange(
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
|
||||
return this->Superclass::GetRange(VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
}
|
||||
|
||||
@ -54,6 +52,5 @@ vtkm::Bounds CoordinateSystem::GetBounds() const
|
||||
return this->GetBounds(VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG(),
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
@ -28,8 +28,7 @@
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
#ifndef VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG
|
||||
#define VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG \
|
||||
::vtkm::TypeListTagFieldVec3
|
||||
#define VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG ::vtkm::TypeListTagFieldVec3
|
||||
#endif
|
||||
|
||||
#ifndef VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG
|
||||
@ -37,22 +36,21 @@
|
||||
::vtkm::cont::StorageListTagCoordinateSystemDefault
|
||||
#endif
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
typedef vtkm::cont::ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> >::type
|
||||
ArrayHandleCompositeVectorFloat32_3Default;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>, vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>>::type ArrayHandleCompositeVectorFloat32_3Default;
|
||||
|
||||
typedef vtkm::cont::ArrayHandleCompositeVectorType<
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> >::type
|
||||
ArrayHandleCompositeVectorFloat64_3Default;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>, vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>>::type ArrayHandleCompositeVectorFloat64_3Default;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@ -63,18 +61,16 @@ typedef vtkm::cont::ArrayHandleCompositeVectorType<
|
||||
///
|
||||
struct StorageListTagCoordinateSystemDefault
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
|
||||
vtkm::cont::StorageTagBasic, vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
|
||||
detail::ArrayHandleCompositeVectorFloat32_3Default::StorageTag,
|
||||
detail::ArrayHandleCompositeVectorFloat64_3Default::StorageTag,
|
||||
vtkm::cont::ArrayHandleCartesianProduct<
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>, vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>::StorageTag>
|
||||
{ };
|
||||
{
|
||||
};
|
||||
|
||||
typedef vtkm::cont::DynamicArrayHandleBase<
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG,
|
||||
typedef vtkm::cont::DynamicArrayHandleBase<VTKM_DEFAULT_COORDINATE_SYSTEM_TYPE_LIST_TAG,
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG>
|
||||
DynamicArrayHandleCoordinateSystem;
|
||||
|
||||
@ -84,46 +80,47 @@ class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
CoordinateSystem() : Superclass() { }
|
||||
CoordinateSystem()
|
||||
: Superclass()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CoordinateSystem(std::string name,
|
||||
const vtkm::cont::DynamicArrayHandle &data)
|
||||
: Superclass(name, ASSOC_POINTS, data) { }
|
||||
CoordinateSystem(std::string name, const vtkm::cont::DynamicArrayHandle& data)
|
||||
: Superclass(name, ASSOC_POINTS, data)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT
|
||||
CoordinateSystem(std::string name,
|
||||
const ArrayHandle<T, Storage> &data)
|
||||
: Superclass(name, ASSOC_POINTS, data) { }
|
||||
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
|
||||
: Superclass(name, ASSOC_POINTS, data)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
CoordinateSystem(std::string name,
|
||||
const std::vector<T> &data)
|
||||
: Superclass(name, ASSOC_POINTS, data) { }
|
||||
VTKM_CONT CoordinateSystem(std::string name, const std::vector<T>& data)
|
||||
: Superclass(name, ASSOC_POINTS, data)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
CoordinateSystem(std::string name,
|
||||
const T *data,
|
||||
vtkm::Id numberOfValues)
|
||||
: Superclass(name, ASSOC_POINTS, data, numberOfValues) { }
|
||||
VTKM_CONT CoordinateSystem(std::string name, const T* data, vtkm::Id numberOfValues)
|
||||
: Superclass(name, ASSOC_POINTS, data, numberOfValues)
|
||||
{
|
||||
}
|
||||
|
||||
/// This constructor of coordinate system sets up a regular grid of points.
|
||||
///
|
||||
VTKM_CONT
|
||||
CoordinateSystem(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,
|
||||
CoordinateSystem(
|
||||
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::DynamicArrayHandle(
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
CoordinateSystem& operator=(const vtkm::cont::CoordinateSystem& src) = default;
|
||||
@ -131,103 +128,82 @@ public:
|
||||
VTKM_CONT
|
||||
vtkm::cont::DynamicArrayHandleCoordinateSystem GetData() const
|
||||
{
|
||||
return vtkm::cont::DynamicArrayHandleCoordinateSystem(
|
||||
this->Superclass::GetData());
|
||||
return vtkm::cont::DynamicArrayHandleCoordinateSystem(this->Superclass::GetData());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DynamicArrayHandleCoordinateSystem GetData()
|
||||
{
|
||||
return vtkm::cont::DynamicArrayHandleCoordinateSystem(
|
||||
this->Superclass::GetData());
|
||||
return vtkm::cont::DynamicArrayHandleCoordinateSystem(this->Superclass::GetData());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void GetRange(vtkm::Range* range) const;
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT
|
||||
void GetRange(vtkm::Range *range, TypeList) const
|
||||
VTKM_CONT void GetRange(vtkm::Range* range, TypeList) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
|
||||
this->Superclass::GetRange(
|
||||
range,
|
||||
TypeList(),
|
||||
this->Superclass::GetRange(range, TypeList(),
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
}
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT
|
||||
void GetRange(vtkm::Range *range, TypeList, StorageList) const
|
||||
VTKM_CONT void GetRange(vtkm::Range* range, TypeList, StorageList) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
VTKM_IS_LIST_TAG(StorageList);
|
||||
|
||||
this->Superclass::GetRange(
|
||||
range,
|
||||
TypeList(),
|
||||
StorageList());
|
||||
this->Superclass::GetRange(range, TypeList(), StorageList());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange() const;
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT
|
||||
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList) const
|
||||
VTKM_CONT const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
|
||||
return this->Superclass::GetRange(
|
||||
TypeList(),
|
||||
return this->Superclass::GetRange(TypeList(),
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
}
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT
|
||||
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList,
|
||||
StorageList) const
|
||||
VTKM_CONT const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList, StorageList) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
VTKM_IS_LIST_TAG(StorageList);
|
||||
|
||||
return this->Superclass::GetRange(
|
||||
TypeList(),
|
||||
StorageList());
|
||||
return this->Superclass::GetRange(TypeList(), StorageList());
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Bounds GetBounds() const;
|
||||
|
||||
template <typename TypeList>
|
||||
VTKM_CONT
|
||||
vtkm::Bounds GetBounds(TypeList) const
|
||||
VTKM_CONT vtkm::Bounds GetBounds(TypeList) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
|
||||
return this->GetBounds(TypeList(),
|
||||
VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
return this->GetBounds(TypeList(), VTKM_DEFAULT_COORDINATE_SYSTEM_STORAGE_LIST_TAG());
|
||||
}
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT
|
||||
vtkm::Bounds GetBounds(TypeList, StorageList) const
|
||||
VTKM_CONT vtkm::Bounds GetBounds(TypeList, StorageList) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
VTKM_IS_LIST_TAG(StorageList);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ranges =
|
||||
this->GetRange(TypeList(), StorageList());
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ranges = this->GetRange(TypeList(), StorageList());
|
||||
|
||||
VTKM_ASSERT(ranges.GetNumberOfValues() == 3);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Range>::PortalConstControl rangePortal =
|
||||
ranges.GetPortalConstControl();
|
||||
|
||||
return vtkm::Bounds(rangePortal.Get(0),
|
||||
rangePortal.Get(1),
|
||||
rangePortal.Get(2));
|
||||
return vtkm::Bounds(rangePortal.Get(0), rangePortal.Get(1), rangePortal.Get(2));
|
||||
}
|
||||
|
||||
virtual void PrintSummary(std::ostream& out) const;
|
||||
@ -239,7 +215,8 @@ void CastAndCall(const vtkm::cont::CoordinateSystem& coords, const Functor &f)
|
||||
coords.GetData().CastAndCall(f);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <>
|
||||
struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
@ -251,5 +228,4 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
|
||||
#endif //vtk_m_cont_CoordinateSystem_h
|
||||
|
@ -28,16 +28,16 @@
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class DataSet
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
DataSet()
|
||||
{
|
||||
}
|
||||
DataSet() {}
|
||||
|
||||
VTKM_CONT
|
||||
void Clear()
|
||||
@ -48,24 +48,18 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AddField(Field field)
|
||||
{
|
||||
this->Fields.push_back(field);
|
||||
}
|
||||
void AddField(Field field) { this->Fields.push_back(field); }
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field& GetField(vtkm::Id index) const
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) &&
|
||||
(index < this->GetNumberOfFields()));
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfFields()));
|
||||
return this->Fields[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
bool HasField(
|
||||
const std::string &name,
|
||||
vtkm::cont::Field::AssociationEnum assoc = vtkm::cont::Field::ASSOC_ANY)
|
||||
const
|
||||
bool HasField(const std::string& name,
|
||||
vtkm::cont::Field::AssociationEnum assoc = vtkm::cont::Field::ASSOC_ANY) const
|
||||
{
|
||||
bool found;
|
||||
this->FindFieldIndex(name, assoc, found);
|
||||
@ -73,10 +67,8 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetFieldIndex(
|
||||
const std::string &name,
|
||||
vtkm::cont::Field::AssociationEnum assoc = vtkm::cont::Field::ASSOC_ANY)
|
||||
const
|
||||
vtkm::Id GetFieldIndex(const std::string& name, vtkm::cont::Field::AssociationEnum assoc =
|
||||
vtkm::cont::Field::ASSOC_ANY) const
|
||||
{
|
||||
bool found;
|
||||
vtkm::Id index = this->FindFieldIndex(name, assoc, found);
|
||||
@ -86,15 +78,14 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"No field with requested name: " + name);
|
||||
throw vtkm::cont::ErrorBadValue("No field with requested name: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::Field &GetField(const std::string &name,
|
||||
vtkm::cont::Field::AssociationEnum assoc = vtkm::cont::Field::ASSOC_ANY)
|
||||
const
|
||||
const vtkm::cont::Field& GetField(
|
||||
const std::string& name,
|
||||
vtkm::cont::Field::AssociationEnum assoc = vtkm::cont::Field::ASSOC_ANY) const
|
||||
{
|
||||
return this->GetField(this->GetFieldIndex(name, assoc));
|
||||
}
|
||||
@ -112,17 +103,12 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AddCoordinateSystem(vtkm::cont::CoordinateSystem cs)
|
||||
{
|
||||
this->CoordSystems.push_back(cs);
|
||||
}
|
||||
void AddCoordinateSystem(vtkm::cont::CoordinateSystem cs) { this->CoordSystems.push_back(cs); }
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CoordinateSystem &
|
||||
GetCoordinateSystem(vtkm::Id index=0) const
|
||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) &&
|
||||
(index < this->GetNumberOfCoordinateSystems()));
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems()));
|
||||
return this->CoordSystems[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
@ -145,27 +131,21 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"No coordinate system with requested name");
|
||||
throw vtkm::cont::ErrorBadValue("No coordinate system with requested name");
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CoordinateSystem &
|
||||
GetCoordinateSystem(const std::string &name) const
|
||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) const
|
||||
{
|
||||
return this->GetCoordinateSystem(this->GetCoordinateSystemIndex(name));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void AddCellSet(vtkm::cont::DynamicCellSet cellSet)
|
||||
{
|
||||
this->CellSets.push_back(cellSet);
|
||||
}
|
||||
void AddCellSet(vtkm::cont::DynamicCellSet cellSet) { this->CellSets.push_back(cellSet); }
|
||||
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
void AddCellSet(const CellSetType &cellSet)
|
||||
VTKM_CONT void AddCellSet(const CellSetType& cellSet)
|
||||
{
|
||||
VTKM_IS_CELL_SET(CellSetType);
|
||||
this->CellSets.push_back(vtkm::cont::DynamicCellSet(cellSet));
|
||||
@ -174,8 +154,7 @@ public:
|
||||
VTKM_CONT
|
||||
vtkm::cont::DynamicCellSet GetCellSet(vtkm::Id index = 0) const
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) &&
|
||||
(index < this->GetNumberOfCellSets()));
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCellSets()));
|
||||
return this->CellSets[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
@ -255,8 +234,7 @@ private:
|
||||
std::vector<vtkm::cont::DynamicCellSet> CellSets;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id FindFieldIndex(const std::string &name,
|
||||
vtkm::cont::Field::AssociationEnum association,
|
||||
vtkm::Id FindFieldIndex(const std::string& name, vtkm::cont::Field::AssociationEnum association,
|
||||
bool& found) const
|
||||
{
|
||||
for (std::size_t index = 0; index < this->Fields.size(); ++index)
|
||||
@ -307,5 +285,4 @@ private:
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
|
||||
#endif //vtk_m_cont_DataSet_h
|
||||
|
@ -25,8 +25,10 @@
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
//Coordinates builder??
|
||||
//Need a singlecellset handler.
|
||||
@ -34,15 +36,12 @@ namespace cont {
|
||||
class DataSetBuilderExplicit
|
||||
{
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void CopyInto(const std::vector<T>& input,
|
||||
vtkm::cont::ArrayHandle<T>& output )
|
||||
VTKM_CONT static void CopyInto(const std::vector<T>& input, vtkm::cont::ArrayHandle<T>& output)
|
||||
{
|
||||
output.Allocate(static_cast<vtkm::Id>(input.size()));
|
||||
std::copy( input.begin(), input.end(),
|
||||
ArrayPortalToIteratorBegin(output.GetPortalControl()) );
|
||||
std::copy(input.begin(), input.end(), ArrayPortalToIteratorBegin(output.GetPortalControl()));
|
||||
}
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
DataSetBuilderExplicit() {}
|
||||
@ -52,10 +51,7 @@ public:
|
||||
|
||||
//Zoo explicit cell
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<T> &xVals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xVals,
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
@ -63,16 +59,12 @@ public:
|
||||
const std::string& cellNm = "cells")
|
||||
{
|
||||
std::vector<T> yVals(xVals.size(), 0), zVals(xVals.size(), 0);
|
||||
return DataSetBuilderExplicit::Create(xVals,yVals,zVals,
|
||||
shapes,numIndices,connectivity,
|
||||
return DataSetBuilderExplicit::Create(xVals, yVals, zVals, shapes, numIndices, connectivity,
|
||||
coordsNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<T> &xVals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xVals,
|
||||
const std::vector<T>& yVals,
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
@ -81,18 +73,31 @@ public:
|
||||
const std::string& cellNm = "cells")
|
||||
{
|
||||
std::vector<T> zVals(xVals.size(), 0);
|
||||
return DataSetBuilderExplicit::Create(xVals,yVals,zVals,
|
||||
shapes,numIndices,connectivity,
|
||||
return DataSetBuilderExplicit::Create(xVals, yVals, zVals, shapes, numIndices, connectivity,
|
||||
coordsNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<T> &xVals,
|
||||
const std::vector<T> &yVals,
|
||||
const std::vector<T> &zVals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
const std::vector<T>& xVals, const std::vector<T>& yVals, const std::vector<T>& zVals,
|
||||
const std::vector<vtkm::UInt8>& shapes, const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity, const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells");
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
const vtkm::cont::ArrayHandle<T>& xVals, const vtkm::cont::ArrayHandle<T>& yVals,
|
||||
const vtkm::cont::ArrayHandle<T>& zVals, const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(xVals, yVals, zVals, shapes, numIndices,
|
||||
connectivity, coordsNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<vtkm::Vec<T, 3>>& coords,
|
||||
const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
@ -100,136 +105,66 @@ public:
|
||||
const std::string& cellNm = "cells");
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<T> &xVals,
|
||||
const vtkm::cont::ArrayHandle<T> &yVals,
|
||||
const vtkm::cont::ArrayHandle<T> &zVals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm="coords",
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
xVals,yVals,zVals,
|
||||
shapes,numIndices,connectivity,
|
||||
return DataSetBuilderExplicit::BuildDataSet(coords, shapes, numIndices, connectivity, coordsNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<vtkm::Vec<T, 3>>& coords,
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords",
|
||||
const std::string& cellNm = "cells");
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords, CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm = "coords", const std::string& cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(coords, tag, numberOfPointsPerCell, connectivity,
|
||||
coordsNm, cellNm);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<vtkm::Vec<T,3> > &coords,
|
||||
const std::vector<vtkm::UInt8> &shapes,
|
||||
const std::vector<vtkm::IdComponent> &numIndices,
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm="coords",
|
||||
const std::string &cellNm="cells");
|
||||
|
||||
template<typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent> &numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm="coords",
|
||||
const std::string &cellNm="cells")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(coords,
|
||||
shapes,
|
||||
numIndices,
|
||||
connectivity,
|
||||
coordsNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
template<typename T, typename CellShapeTag>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<vtkm::Vec<T,3> > &coords,
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm="coords",
|
||||
const std::string &cellNm="cells");
|
||||
|
||||
template<typename T, typename CellShapeTag>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm="coords",
|
||||
const std::string &cellNm="cells")
|
||||
{
|
||||
return DataSetBuilderExplicit::BuildDataSet(coords,
|
||||
tag,
|
||||
numberOfPointsPerCell,
|
||||
connectivity,
|
||||
coordsNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
BuildDataSet(const vtkm::cont::ArrayHandle<T> &X,
|
||||
const vtkm::cont::ArrayHandle<T> &Y,
|
||||
const vtkm::cont::ArrayHandle<T> &Z,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
|
||||
static vtkm::cont::DataSet BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<T>& X, const vtkm::cont::ArrayHandle<T>& Y,
|
||||
const vtkm::cont::ArrayHandle<T>& Z, const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, const std::string& coordsNm,
|
||||
const std::string& cellNm);
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, const std::string& coordsNm,
|
||||
const std::string& cellNm);
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const std::string &cellNm);
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords, CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm, const std::string& cellNm);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
|
||||
const std::vector<T> &yVals,
|
||||
const std::vector<T> &zVals,
|
||||
const std::vector<vtkm::UInt8> &shapes,
|
||||
const std::vector<vtkm::IdComponent> &numIndices,
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const std::string &cellNm)
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
const std::vector<T>& xVals, const std::vector<T>& yVals, const std::vector<T>& zVals,
|
||||
const std::vector<vtkm::UInt8>& shapes, const std::vector<vtkm::IdComponent>& numIndices,
|
||||
const std::vector<vtkm::Id>& connectivity, const std::string& coordsNm, const std::string& cellNm)
|
||||
{
|
||||
VTKM_ASSERT(xVals.size() == yVals.size() &&
|
||||
yVals.size() == zVals.size() &&
|
||||
xVals.size() > 0);
|
||||
VTKM_ASSERT(xVals.size() == yVals.size() && yVals.size() == zVals.size() && xVals.size() > 0);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> Xc, Yc, Zc;
|
||||
DataSetBuilderExplicit::CopyInto(xVals, Xc);
|
||||
@ -243,32 +178,24 @@ DataSetBuilderExplicit::Create(const std::vector<T> &xVals,
|
||||
DataSetBuilderExplicit::CopyInto(numIndices, Nc);
|
||||
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
||||
|
||||
return DataSetBuilderExplicit::BuildDataSet(
|
||||
Xc,Yc,Zc, Sc,Nc,Cc, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::BuildDataSet(Xc, Yc, Zc, Sc, Nc, Cc, coordsNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<T> &X,
|
||||
const vtkm::cont::ArrayHandle<T> &Y,
|
||||
const vtkm::cont::ArrayHandle<T> &Z,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8> &shapes,
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<T>& X, const vtkm::cont::ArrayHandle<T>& Y,
|
||||
const vtkm::cont::ArrayHandle<T>& Z, const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
{
|
||||
VTKM_ASSERT(X.GetNumberOfValues() == Y.GetNumberOfValues() &&
|
||||
Y.GetNumberOfValues() == Z.GetNumberOfValues() &&
|
||||
X.GetNumberOfValues() > 0 &&
|
||||
Y.GetNumberOfValues() == Z.GetNumberOfValues() && X.GetNumberOfValues() > 0 &&
|
||||
shapes.GetNumberOfValues() == numIndices.GetNumberOfValues());
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
dataSet.AddCoordinateSystem(
|
||||
vtkm::cont::CoordinateSystem(coordsNm,
|
||||
make_ArrayHandleCompositeVector(X,0, Y,0, Z,0)));
|
||||
vtkm::cont::CoordinateSystem(coordsNm, make_ArrayHandleCompositeVector(X, 0, Y, 0, Z, 0)));
|
||||
vtkm::Id nPts = X.GetNumberOfValues();
|
||||
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
|
||||
|
||||
@ -279,14 +206,10 @@ DataSetBuilderExplicit::BuildDataSet(
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
|
||||
const std::vector<vtkm::UInt8> &shapes,
|
||||
const std::vector<vtkm::IdComponent> &numIndices,
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const std::string &cellNm)
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
const std::vector<vtkm::Vec<T, 3>>& coords, const std::vector<vtkm::UInt8>& shapes,
|
||||
const std::vector<vtkm::IdComponent>& numIndices, const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm, const std::string& cellNm)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<Vec<T, 3>> coordsArray;
|
||||
DataSetBuilderExplicit::CopyInto(coords, coordsArray);
|
||||
@ -298,24 +221,20 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
|
||||
DataSetBuilderExplicit::CopyInto(numIndices, Nc);
|
||||
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
||||
|
||||
return DataSetBuilderExplicit::Create(
|
||||
coordsArray, Sc, Nc, Cc, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::Create(coordsArray, Sc, Nc, Cc, coordsNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
|
||||
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity, const std::string& coordsNm,
|
||||
const std::string& cellNm)
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm,
|
||||
coords));
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
||||
vtkm::Id nPts = static_cast<vtkm::Id>(coords.GetNumberOfValues());
|
||||
vtkm::cont::CellSetExplicit<> cellSet(cellNm);
|
||||
|
||||
@ -326,14 +245,10 @@ DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3
|
||||
}
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const std::vector<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const std::string &cellNm)
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
|
||||
const std::vector<vtkm::Vec<T, 3>>& coords, CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell, const std::vector<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm, const std::string& cellNm)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<Vec<T, 3>> coordsArray;
|
||||
DataSetBuilderExplicit::CopyInto(coords, coordsArray);
|
||||
@ -341,35 +256,27 @@ DataSetBuilderExplicit::Create(const std::vector<vtkm::Vec<T,3> > &coords,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> Cc;
|
||||
DataSetBuilderExplicit::CopyInto(connectivity, Cc);
|
||||
|
||||
return DataSetBuilderExplicit::Create(
|
||||
coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm, cellNm);
|
||||
return DataSetBuilderExplicit::Create(coordsArray, tag, numberOfPointsPerCell, Cc, coordsNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
template <typename T, typename CellShapeTag>
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicit::BuildDataSet(const vtkm::cont::ArrayHandle<vtkm::Vec<T,3> > &coords,
|
||||
CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &connectivity,
|
||||
const std::string &coordsNm,
|
||||
const std::string &cellNm)
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords, CellShapeTag tag,
|
||||
vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
|
||||
const std::string& coordsNm, const std::string& cellNm)
|
||||
{
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem(coordsNm, coords));
|
||||
vtkm::cont::CellSetSingleType<> cellSet(cellNm);
|
||||
|
||||
cellSet.Fill(coords.GetNumberOfValues(),
|
||||
tag.Id,
|
||||
numberOfPointsPerCell,
|
||||
connectivity);
|
||||
cellSet.Fill(coords.GetNumberOfValues(), tag.Id, numberOfPointsPerCell, connectivity);
|
||||
dataSet.AddCellSet(cellSet);
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
|
||||
class DataSetBuilderExplicitIterative
|
||||
{
|
||||
public:
|
||||
@ -377,8 +284,7 @@ public:
|
||||
DataSetBuilderExplicitIterative() {}
|
||||
|
||||
VTKM_CONT
|
||||
void Begin(const std::string &coordName="coords",
|
||||
const std::string &cellName="cells")
|
||||
void Begin(const std::string& coordName = "coords", const std::string& cellName = "cells")
|
||||
{
|
||||
this->coordNm = coordName;
|
||||
this->cellNm = cellName;
|
||||
@ -401,9 +307,7 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id AddPoint(const vtkm::Float32 &x,
|
||||
const vtkm::Float32 &y,
|
||||
const vtkm::Float32 &z=0)
|
||||
vtkm::Id AddPoint(const vtkm::Float32& x, const vtkm::Float32& y, const vtkm::Float32& z = 0)
|
||||
{
|
||||
points.push_back(vtkm::make_Vec(x, y, z));
|
||||
vtkm::Id id = static_cast<vtkm::Id>(points.size());
|
||||
@ -411,17 +315,14 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
vtkm::Id AddPoint(const T &x, const T &y, const T &z=0)
|
||||
VTKM_CONT vtkm::Id AddPoint(const T& x, const T& y, const T& z = 0)
|
||||
{
|
||||
return AddPoint(static_cast<vtkm::Float32>(x),
|
||||
static_cast<vtkm::Float32>(y),
|
||||
return AddPoint(static_cast<vtkm::Float32>(x), static_cast<vtkm::Float32>(y),
|
||||
static_cast<vtkm::Float32>(z));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
vtkm::Id AddPoint(const vtkm::Vec<T,3> &pt)
|
||||
VTKM_CONT vtkm::Id AddPoint(const vtkm::Vec<T, 3>& pt)
|
||||
{
|
||||
return AddPoint(static_cast<vtkm::Vec<vtkm::Float32, 3>>(pt));
|
||||
}
|
||||
@ -470,15 +371,11 @@ private:
|
||||
std::vector<vtkm::Id> connectivity;
|
||||
};
|
||||
|
||||
inline VTKM_CONT
|
||||
vtkm::cont::DataSet
|
||||
DataSetBuilderExplicitIterative::Create()
|
||||
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicitIterative::Create()
|
||||
{
|
||||
DataSetBuilderExplicit dsb;
|
||||
return dsb.Create(points, shapes, numIdx, connectivity, coordNm, cellNm);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,173 +26,135 @@
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class DataSetBuilderRectilinear
|
||||
{
|
||||
template <typename T, typename U>
|
||||
VTKM_CONT
|
||||
static
|
||||
void CopyInto(const std::vector<T>& input,
|
||||
vtkm::cont::ArrayHandle<U>& output )
|
||||
VTKM_CONT static void CopyInto(const std::vector<T>& input, vtkm::cont::ArrayHandle<U>& output)
|
||||
{
|
||||
DataSetBuilderRectilinear::CopyInto(
|
||||
vtkm::cont::make_ArrayHandle(input), output);
|
||||
DataSetBuilderRectilinear::CopyInto(vtkm::cont::make_ArrayHandle(input), output);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_CONT
|
||||
static
|
||||
void CopyInto(const vtkm::cont::ArrayHandle<T>& input,
|
||||
VTKM_CONT static void CopyInto(const vtkm::cont::ArrayHandle<T>& input,
|
||||
vtkm::cont::ArrayHandle<U>& output)
|
||||
{
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<
|
||||
vtkm::cont::DeviceAdapterTagSerial> Algorithm;
|
||||
typedef vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial> Algorithm;
|
||||
Algorithm::Copy(input, output);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
VTKM_CONT
|
||||
static
|
||||
void CopyInto(const T* input, vtkm::Id len,
|
||||
vtkm::cont::ArrayHandle<U>& output )
|
||||
VTKM_CONT static void CopyInto(const T* input, vtkm::Id len, vtkm::cont::ArrayHandle<U>& output)
|
||||
{
|
||||
DataSetBuilderRectilinear::CopyInto(
|
||||
vtkm::cont::make_ArrayHandle(input, len), output);
|
||||
DataSetBuilderRectilinear::CopyInto(vtkm::cont::make_ArrayHandle(input, len), output);
|
||||
}
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
DataSetBuilderRectilinear() {}
|
||||
|
||||
//1D grids.
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<T> &xvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
std::vector<T> yvals(1, 0), zvals(1, 0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
1, xvals,yvals,zvals, coordNm,cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(1, xvals, yvals, zvals, coordNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(vtkm::Id nx, T *xvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(vtkm::Id nx, T* xvals, std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
T yvals = 0, zvals = 0;
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
1, nx,1, 1, xvals, &yvals, &zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(1, nx, 1, 1, xvals, &yvals, &zvals, coordNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<T> &xvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::cont::ArrayHandle<T>& xvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> yvals, zvals;
|
||||
yvals.Allocate(1);
|
||||
yvals.GetPortalControl().Set(0, 0.0);
|
||||
zvals.Allocate(1);
|
||||
zvals.GetPortalControl().Set(0, 0.0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
1, xvals,yvals,zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(1, xvals, yvals, zvals, coordNm, cellNm);
|
||||
}
|
||||
|
||||
//2D grids.
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<T> &xvals, const std::vector<T> &yvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xvals,
|
||||
const std::vector<T>& yvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
std::vector<T> zvals(1, 0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
2, xvals,yvals,zvals, coordNm,cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(2, xvals, yvals, zvals, coordNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(vtkm::Id nx, vtkm::Id ny,
|
||||
T *xvals, T *yvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(vtkm::Id nx, vtkm::Id ny, T* xvals, T* yvals,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
T zvals = 0;
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
2, nx,ny, 1, xvals, yvals, &zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(2, nx, ny, 1, xvals, yvals, &zvals, coordNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<T> &xvals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::cont::ArrayHandle<T>& xvals,
|
||||
const vtkm::cont::ArrayHandle<T>& yvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> zvals;
|
||||
zvals.Allocate(1);
|
||||
zvals.GetPortalControl().Set(0, 0.0);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
2, xvals,yvals,zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(2, xvals, yvals, zvals, coordNm, cellNm);
|
||||
}
|
||||
|
||||
//3D grids.
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
|
||||
T *xvals, T *yvals, T *zvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(vtkm::Id nx, vtkm::Id ny, vtkm::Id nz, T* xvals,
|
||||
T* yvals, T* zvals, std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
3, nx,ny,nz, xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(3, nx, ny, nz, xvals, yvals, zvals, coordNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const std::vector<T> &xvals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const std::vector<T>& xvals,
|
||||
const std::vector<T>& yvals,
|
||||
const std::vector<T>& zvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
3, xvals, yvals, zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(3, xvals, yvals, zvals, coordNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::cont::ArrayHandle<T> &xvals,
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::cont::ArrayHandle<T>& xvals,
|
||||
const vtkm::cont::ArrayHandle<T>& yvals,
|
||||
const vtkm::cont::ArrayHandle<T>& zvals,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
3, xvals,yvals,zvals, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(3, xvals, yvals, zvals, coordNm, cellNm);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
BuildDataSet(int dim,
|
||||
const std::vector<T> &xvals,
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(int dim, const std::vector<T>& xvals,
|
||||
const std::vector<T>& yvals,
|
||||
const std::vector<T>& zvals,
|
||||
std::string coordNm, std::string cellNm)
|
||||
@ -206,15 +168,11 @@ private:
|
||||
DataSetBuilderRectilinear::CopyInto(yvals, Yc);
|
||||
DataSetBuilderRectilinear::CopyInto(zvals, Zc);
|
||||
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
dim, Xc,Yc,Zc, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(dim, Xc, Yc, Zc, coordNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
BuildDataSet(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
|
||||
const T* xvals, const T* yvals, const T* zvals,
|
||||
std::string coordNm, std::string cellNm)
|
||||
{
|
||||
@ -227,16 +185,11 @@ private:
|
||||
DataSetBuilderRectilinear::CopyInto(yvals, ny, Yc);
|
||||
DataSetBuilderRectilinear::CopyInto(zvals, nz, Zc);
|
||||
|
||||
return DataSetBuilderRectilinear::BuildDataSet(
|
||||
dim, Xc,Yc,Zc, coordNm, cellNm);
|
||||
return DataSetBuilderRectilinear::BuildDataSet(dim, Xc, Yc, Zc, coordNm, cellNm);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
BuildDataSet(int dim,
|
||||
const vtkm::cont::ArrayHandle<T> &X,
|
||||
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(int dim, const vtkm::cont::ArrayHandle<T>& X,
|
||||
const vtkm::cont::ArrayHandle<T>& Y,
|
||||
const vtkm::cont::ArrayHandle<T>& Z,
|
||||
std::string coordNm, std::string cellNm)
|
||||
@ -244,10 +197,10 @@ private:
|
||||
vtkm::cont::DataSet dataSet;
|
||||
|
||||
//Convert all coordinates to floatDefault.
|
||||
vtkm::cont::ArrayHandleCartesianProduct<
|
||||
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> > coords;
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>
|
||||
coords;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> Xc, Yc, Zc;
|
||||
DataSetBuilderRectilinear::CopyInto(X, Xc);
|
||||
@ -267,16 +220,14 @@ private:
|
||||
else if (dim == 2)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<2> cellSet(cellNm);
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(Xc.GetNumberOfValues(),
|
||||
Yc.GetNumberOfValues()));
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(Xc.GetNumberOfValues(), Yc.GetNumberOfValues()));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSet(cellNm);
|
||||
cellSet.SetPointDimensions(vtkm::make_Vec(Xc.GetNumberOfValues(),
|
||||
Yc.GetNumberOfValues(),
|
||||
Zc.GetNumberOfValues()));
|
||||
cellSet.SetPointDimensions(
|
||||
vtkm::make_Vec(Xc.GetNumberOfValues(), Yc.GetNumberOfValues(), Zc.GetNumberOfValues()));
|
||||
dataSet.AddCellSet(cellSet);
|
||||
}
|
||||
else
|
||||
|
@ -23,85 +23,71 @@
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class DataSetBuilderUniform
|
||||
{
|
||||
typedef vtkm::Vec<vtkm::FloatDefault, 3> VecType;
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
DataSetBuilderUniform() {}
|
||||
|
||||
//1D uniform grid
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::Id &dimension,
|
||||
const T &origin, const T &spacing,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id& dimension, const T& origin,
|
||||
const T& spacing, std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderUniform::CreateDataSet(1,
|
||||
dimension,1,1,
|
||||
VecType(static_cast<vtkm::FloatDefault>(origin),
|
||||
0,0),
|
||||
VecType(static_cast<vtkm::FloatDefault>(spacing),
|
||||
1,1),
|
||||
coordNm, cellNm);
|
||||
return DataSetBuilderUniform::CreateDataSet(
|
||||
1, dimension, 1, 1, VecType(static_cast<vtkm::FloatDefault>(origin), 0, 0),
|
||||
VecType(static_cast<vtkm::FloatDefault>(spacing), 1, 1), coordNm, cellNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::Id &dimension,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
static vtkm::cont::DataSet Create(const vtkm::Id& dimension, std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return CreateDataSet(1, dimension, 1, 1,
|
||||
VecType(0), VecType(1), coordNm, cellNm);
|
||||
return CreateDataSet(1, dimension, 1, 1, VecType(0), VecType(1), coordNm, cellNm);
|
||||
}
|
||||
|
||||
//2D uniform grids.
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::Id2 &dimensions,
|
||||
const vtkm::Vec<T,2> &origin, const vtkm::Vec<T,2> &spacing,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id2& dimensions,
|
||||
const vtkm::Vec<T, 2>& origin,
|
||||
const vtkm::Vec<T, 2>& spacing,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderUniform::CreateDataSet(2,
|
||||
dimensions[0],dimensions[1],1,
|
||||
VecType(static_cast<vtkm::FloatDefault>(origin[0]),
|
||||
static_cast<vtkm::FloatDefault>(origin[1]),
|
||||
0),
|
||||
return DataSetBuilderUniform::CreateDataSet(
|
||||
2, dimensions[0], dimensions[1], 1, VecType(static_cast<vtkm::FloatDefault>(origin[0]),
|
||||
static_cast<vtkm::FloatDefault>(origin[1]), 0),
|
||||
VecType(static_cast<vtkm::FloatDefault>(spacing[0]),
|
||||
static_cast<vtkm::FloatDefault>(spacing[1]),
|
||||
1),
|
||||
static_cast<vtkm::FloatDefault>(spacing[1]), 1),
|
||||
coordNm, cellNm);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::Id2 &dimensions,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
static vtkm::cont::DataSet Create(const vtkm::Id2& dimensions, std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return CreateDataSet(2, dimensions[0], dimensions[1], 1,
|
||||
VecType(0), VecType(1), coordNm, cellNm);
|
||||
return CreateDataSet(2, dimensions[0], dimensions[1], 1, VecType(0), VecType(1), coordNm,
|
||||
cellNm);
|
||||
}
|
||||
|
||||
//3D uniform grids.
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::Id3 &dimensions,
|
||||
const vtkm::Vec<T,3> &origin, const vtkm::Vec<T,3> &spacing,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
VTKM_CONT static vtkm::cont::DataSet Create(const vtkm::Id3& dimensions,
|
||||
const vtkm::Vec<T, 3>& origin,
|
||||
const vtkm::Vec<T, 3>& spacing,
|
||||
std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return DataSetBuilderUniform::CreateDataSet(3,
|
||||
dimensions[0],dimensions[1],dimensions[2],
|
||||
return DataSetBuilderUniform::CreateDataSet(
|
||||
3, dimensions[0], dimensions[1], dimensions[2],
|
||||
VecType(static_cast<vtkm::FloatDefault>(origin[0]),
|
||||
static_cast<vtkm::FloatDefault>(origin[1]),
|
||||
static_cast<vtkm::FloatDefault>(origin[2])),
|
||||
@ -112,20 +98,16 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
Create(const vtkm::Id3 &dimensions,
|
||||
std::string coordNm="coords", std::string cellNm="cells")
|
||||
static vtkm::cont::DataSet Create(const vtkm::Id3& dimensions, std::string coordNm = "coords",
|
||||
std::string cellNm = "cells")
|
||||
{
|
||||
return CreateDataSet(3, dimensions[0], dimensions[1], dimensions[2],
|
||||
VecType(0), VecType(1), coordNm, cellNm);
|
||||
return CreateDataSet(3, dimensions[0], dimensions[1], dimensions[2], VecType(0), VecType(1),
|
||||
coordNm, cellNm);
|
||||
}
|
||||
|
||||
private:
|
||||
VTKM_CONT
|
||||
static
|
||||
vtkm::cont::DataSet
|
||||
CreateDataSet(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
|
||||
static vtkm::cont::DataSet CreateDataSet(int dim, vtkm::Id nx, vtkm::Id ny, vtkm::Id nz,
|
||||
const vtkm::Vec<vtkm::FloatDefault, 3>& origin,
|
||||
const vtkm::Vec<vtkm::FloatDefault, 3>& spacing,
|
||||
std::string coordNm, std::string cellNm)
|
||||
@ -136,9 +118,7 @@ private:
|
||||
VTKM_ASSERT(spacing[0] > 0 && spacing[1] > 0 && spacing[2] > 0);
|
||||
|
||||
vtkm::cont::DataSet dataSet;
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates
|
||||
coords(vtkm::Id3(nx, ny, nz),
|
||||
origin, spacing);
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates coords(vtkm::Id3(nx, ny, nz), origin, spacing);
|
||||
vtkm::cont::CoordinateSystem cs(coordNm, coords);
|
||||
dataSet.AddCoordinateSystem(cs);
|
||||
|
||||
@ -165,11 +145,9 @@ private:
|
||||
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace cont
|
||||
} // namespace vtkm
|
||||
|
||||
|
||||
#endif //vtk_m_cont_DataSetBuilderUniform_h
|
||||
|
@ -24,8 +24,10 @@
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/Field.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class DataSetFieldAdd
|
||||
{
|
||||
@ -35,150 +37,97 @@ public:
|
||||
|
||||
//Point centered fields.
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddPointField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
static void AddPointField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const vtkm::cont::DynamicArrayHandle& field)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS,
|
||||
field));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS, field));
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddPointField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS,
|
||||
field));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS, field));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddPointField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const std::vector<T>& field)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS,
|
||||
field));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS, field));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddPointField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const T* field, const vtkm::Id& n)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS,
|
||||
field, n));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_POINTS, field, n));
|
||||
}
|
||||
|
||||
//Cell centered field
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const vtkm::cont::DynamicArrayHandle& field,
|
||||
const std::string& cellSetName)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET,
|
||||
cellSetName, field));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET, cellSetName, field));
|
||||
}
|
||||
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field,
|
||||
const std::string& cellSetName)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET,
|
||||
cellSetName, field));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET, cellSetName, field));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
const std::vector<T> &field,
|
||||
const std::string &cellSetName)
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const std::vector<T>& field, const std::string& cellSetName)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET,
|
||||
cellSetName, field));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET, cellSetName, field));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const T* field, const vtkm::Id& n,
|
||||
const std::string& cellSetName)
|
||||
{
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET,
|
||||
cellSetName, field, n));
|
||||
dataSet.AddField(Field(fieldName, vtkm::cont::Field::ASSOC_CELL_SET, cellSetName, field, n));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
const vtkm::cont::DynamicArrayHandle &field,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const vtkm::cont::DynamicArrayHandle& field, vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName =
|
||||
dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
|
||||
}
|
||||
template <typename T, typename Storage>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const vtkm::cont::ArrayHandle<T, Storage>& field,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName =
|
||||
dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
|
||||
}
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
const std::vector<T> &field,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const std::vector<T>& field, vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName =
|
||||
dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VTKM_CONT
|
||||
static
|
||||
void AddCellField(vtkm::cont::DataSet &dataSet,
|
||||
const std::string &fieldName,
|
||||
const T *field, const vtkm::Id &n,
|
||||
vtkm::Id cellSetIndex = 0)
|
||||
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet, const std::string& fieldName,
|
||||
const T* field, const vtkm::Id& n, vtkm::Id cellSetIndex = 0)
|
||||
{
|
||||
std::string cellSetName =
|
||||
dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
|
||||
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, n, cellSetName);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} //namespace vtkm::cont
|
||||
|
||||
|
||||
#endif //vtk_m_cont_DataSetFieldAdd_h
|
||||
|
@ -31,8 +31,10 @@
|
||||
#include <vtkm/cont/internal/ArrayManagerExecution.h>
|
||||
// clang-format on
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
#ifdef VTKM_DOXYGEN_ONLY
|
||||
/// \brief A tag specifying the interface between the control and execution environments.
|
||||
@ -62,15 +64,16 @@ namespace cont {
|
||||
/// documentation on all the functions and classes that must be
|
||||
/// overloaded/specialized to create a new device adapter.
|
||||
///
|
||||
struct DeviceAdapterTag___ { };
|
||||
struct DeviceAdapterTag___
|
||||
{
|
||||
};
|
||||
#endif //VTKM_DOXYGEN_ONLY
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
} // namespace internal
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
||||
#endif //vtk_m_cont_DeviceAdapter_h
|
||||
|
@ -34,8 +34,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
/// \brief Struct containing device adapter algorithms.
|
||||
///
|
||||
@ -70,8 +72,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// algorithm.
|
||||
///
|
||||
template <typename T, typename U, class CIn, class CStencil, class COut>
|
||||
VTKM_CONT static void CopyIf(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
VTKM_CONT static void CopyIf(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output);
|
||||
|
||||
@ -86,10 +87,8 @@ struct DeviceAdapterAlgorithm
|
||||
/// the number of elements that will be removed by the stream compaction
|
||||
/// algorithm.
|
||||
///
|
||||
template<typename T, typename U, class CIn, class CStencil,
|
||||
class COut, class UnaryPredicate>
|
||||
VTKM_CONT static void CopyIf(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
|
||||
VTKM_CONT static void CopyIf(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
UnaryPredicate unary_predicate);
|
||||
@ -113,8 +112,7 @@ struct DeviceAdapterAlgorithm
|
||||
///
|
||||
template <typename T, typename U, class CIn, class COut>
|
||||
VTKM_CONT static bool CopySubRange(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::Id inputStartIndex,
|
||||
vtkm::Id numberOfElementsToCopy,
|
||||
vtkm::Id inputStartIndex, vtkm::Id numberOfElementsToCopy,
|
||||
vtkm::cont::ArrayHandle<U, COut>& output,
|
||||
vtkm::Id outputIndex = 0);
|
||||
|
||||
@ -128,8 +126,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \arg \c input must already be sorted
|
||||
///
|
||||
template <typename T, class CIn, class CVal, class COut>
|
||||
VTKM_CONT static void LowerBounds(
|
||||
const vtkm::cont::ArrayHandle<T,CIn>& input,
|
||||
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output);
|
||||
|
||||
@ -144,8 +141,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \arg \c input must already be sorted
|
||||
///
|
||||
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
||||
VTKM_CONT static void LowerBounds(
|
||||
const vtkm::cont::ArrayHandle<T,CIn>& input,
|
||||
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
||||
BinaryCompare binary_compare);
|
||||
@ -158,8 +154,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// arrays is limited to vtkm::Id.
|
||||
///
|
||||
template <class CIn, class COut>
|
||||
VTKM_CONT static void LowerBounds(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id,CIn>& input,
|
||||
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output);
|
||||
|
||||
/// \brief Compute a accumulated sum operation on the input ArrayHandle
|
||||
@ -172,9 +167,7 @@ struct DeviceAdapterAlgorithm
|
||||
///
|
||||
/// \return The total sum.
|
||||
template <typename T, typename U, class CIn>
|
||||
VTKM_CONT static U Reduce(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
U initialValue);
|
||||
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue);
|
||||
|
||||
/// \brief Compute a accumulated sum operation on the input ArrayHandle
|
||||
///
|
||||
@ -187,9 +180,7 @@ struct DeviceAdapterAlgorithm
|
||||
///
|
||||
/// \return The total sum.
|
||||
template <typename T, typename U, class CIn, class BinaryFunctor>
|
||||
VTKM_CONT static U Reduce(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
U initialValue,
|
||||
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue,
|
||||
BinaryFunctor binary_functor);
|
||||
|
||||
/// \brief Compute a accumulated sum operation on the input key value pairs
|
||||
@ -200,12 +191,9 @@ struct DeviceAdapterAlgorithm
|
||||
/// values inside that range. Once finished a single key and value is created
|
||||
/// for each segment.
|
||||
///
|
||||
template<typename T, typename U,
|
||||
class CKeyIn, class CValIn,
|
||||
class CKeyOut, class CValOut,
|
||||
template <typename T, typename U, class CKeyIn, class CValIn, class CKeyOut, class CValOut,
|
||||
class BinaryFunctor>
|
||||
VTKM_CONT static void ReduceByKey(
|
||||
const vtkm::cont::ArrayHandle<T,CKeyIn> &keys,
|
||||
VTKM_CONT static void ReduceByKey(const vtkm::cont::ArrayHandle<T, CKeyIn>& keys,
|
||||
const vtkm::cont::ArrayHandle<U, CValIn>& values,
|
||||
vtkm::cont::ArrayHandle<T, CKeyOut>& keys_output,
|
||||
vtkm::cont::ArrayHandle<T, CValOut>& values_output,
|
||||
@ -224,8 +212,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \return The total sum.
|
||||
///
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T ScanInclusive(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output);
|
||||
|
||||
/// \brief Streaming version of scan inclusive
|
||||
@ -235,8 +222,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \return The total sum.
|
||||
///
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T StreamingScanInclusive(
|
||||
const vtkm::Id numBlocks,
|
||||
VTKM_CONT static T StreamingScanInclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output);
|
||||
|
||||
@ -253,8 +239,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \return The total sum.
|
||||
///
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T ScanInclusive(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor);
|
||||
|
||||
@ -266,11 +251,9 @@ struct DeviceAdapterAlgorithm
|
||||
/// applied to all values inside that range. Once finished the result is
|
||||
/// stored in \c values_output ArrayHandle.
|
||||
///
|
||||
template<typename T, typename U,
|
||||
typename KIn, typename VIn,
|
||||
typename VOut, typename BinaryFunctor>
|
||||
VTKM_CONT static void ScanInclusiveByKey(
|
||||
const vtkm::cont::ArrayHandle<T, KIn> &keys,
|
||||
template <typename T, typename U, typename KIn, typename VIn, typename VOut,
|
||||
typename BinaryFunctor>
|
||||
VTKM_CONT static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||
vtkm::cont::ArrayHandle<U, VOut>& values_output,
|
||||
BinaryFunctor binary_functor);
|
||||
@ -282,11 +265,8 @@ struct DeviceAdapterAlgorithm
|
||||
/// equal keys with the binary operation vtkm::Add applied to all values inside
|
||||
/// that range. Once finished the result is stored in \c values_output ArrayHandle.
|
||||
///
|
||||
template<typename T, typename U,
|
||||
typename KIn, typename VIn,
|
||||
typename VOut>
|
||||
VTKM_CONT static void ScanInclusiveByKey(
|
||||
const vtkm::cont::ArrayHandle<T, KIn> &keys,
|
||||
template <typename T, typename U, typename KIn, typename VIn, typename VOut>
|
||||
VTKM_CONT static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||
vtkm::cont::ArrayHandle<U, VOut>& values_output);
|
||||
|
||||
@ -297,8 +277,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \return The total sum.
|
||||
///
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T StreamingScanInclusive(
|
||||
const vtkm::Id numBlocks,
|
||||
VTKM_CONT static T StreamingScanInclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor);
|
||||
@ -316,8 +295,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \return The total sum.
|
||||
///
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T ScanExclusive(
|
||||
const vtkm::cont::ArrayHandle<T,CIn> &input,
|
||||
VTKM_CONT static T ScanExclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output);
|
||||
|
||||
/// \brief Compute a segmented exclusive prefix sum operation on the input key value pairs.
|
||||
@ -328,15 +306,11 @@ struct DeviceAdapterAlgorithm
|
||||
/// applied to all values inside that range. Once finished the result is
|
||||
/// stored in \c values_output ArrayHandle.
|
||||
///
|
||||
template<typename T, typename U,
|
||||
typename KIn, typename VIn,
|
||||
typename VOut, class BinaryFunctor>
|
||||
VTKM_CONT static void ScanExclusiveByKey(
|
||||
const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||
template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
|
||||
VTKM_CONT static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||
vtkm::cont::ArrayHandle<U, VOut>& output,
|
||||
const U& initialValue,
|
||||
BinaryFunctor binaryFunctor);
|
||||
const U& initialValue, BinaryFunctor binaryFunctor);
|
||||
|
||||
/// \brief Compute a segmented exclusive prefix sum operation on the input key value pairs.
|
||||
///
|
||||
@ -346,8 +320,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// that range. Once finished the result is stored in \c values_output ArrayHandle.
|
||||
///
|
||||
template <typename T, typename U, class KIn, typename VIn, typename VOut>
|
||||
VTKM_CONT static void ScanExclusiveByKey(
|
||||
const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||
VTKM_CONT static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||
vtkm::cont::ArrayHandle<U, VOut>& output);
|
||||
|
||||
@ -369,8 +342,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// in the range [0, \c numInstances].
|
||||
///
|
||||
template <class Functor>
|
||||
VTKM_CONT static void Schedule(Functor functor,
|
||||
vtkm::Id numInstances);
|
||||
VTKM_CONT static void Schedule(Functor functor, vtkm::Id numInstances);
|
||||
|
||||
/// \brief Schedule many instances of a function to run on concurrent threads.
|
||||
///
|
||||
@ -395,8 +367,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// rangeMax[0]*rangeMax[1]*rangeMax[2])</tt> were called.
|
||||
///
|
||||
template <class Functor, class IndiceType>
|
||||
VTKM_CONT static void Schedule(Functor functor,
|
||||
vtkm::Id3 rangeMax);
|
||||
VTKM_CONT static void Schedule(Functor functor, vtkm::Id3 rangeMax);
|
||||
|
||||
/// \brief Unstable ascending sort of input array.
|
||||
///
|
||||
@ -423,8 +394,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// on the values of keys.
|
||||
///
|
||||
template <typename T, typename U, class StorageT, class StorageU>
|
||||
VTKM_CONT static void SortByKey(
|
||||
vtkm::cont::ArrayHandle<T,StorageT> &keys,
|
||||
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||
vtkm::cont::ArrayHandle<U, StorageU>& values);
|
||||
|
||||
/// \brief Unstable ascending sort of keys and values.
|
||||
@ -435,8 +405,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// BinaryCompare should be a strict weak ordering comparison operator
|
||||
///
|
||||
template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
|
||||
VTKM_CONT static void SortByKey(
|
||||
vtkm::cont::ArrayHandle<T,StorageT> &keys,
|
||||
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||
vtkm::cont::ArrayHandle<U, StorageU>& values,
|
||||
BinaryCompare binary_compare)
|
||||
|
||||
@ -454,8 +423,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// be modified by this operation.
|
||||
///
|
||||
template <typename T, class Storage>
|
||||
VTKM_CONT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Storage>& values);
|
||||
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values);
|
||||
|
||||
/// \brief Reduce an array to only the unique values it contains
|
||||
///
|
||||
@ -468,8 +436,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// is unique. The predicate must return true if the two items are the same.
|
||||
///
|
||||
template <typename T, class Storage, class BinaryCompare>
|
||||
VTKM_CONT static void Unique(
|
||||
vtkm::cont::ArrayHandle<T,Storage>& values,
|
||||
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||
BinaryCompare binary_compare);
|
||||
|
||||
/// \brief Output is the last index in input for each item in values that wouldn't alter the ordering of input
|
||||
@ -482,8 +449,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \arg \c input must already be sorted
|
||||
///
|
||||
template <typename T, class CIn, class CVal, class COut>
|
||||
VTKM_CONT static void UpperBounds(
|
||||
const vtkm::cont::ArrayHandle<T,CIn>& input,
|
||||
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output);
|
||||
|
||||
@ -498,8 +464,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// \arg \c input must already be sorted
|
||||
///
|
||||
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
||||
VTKM_CONT static void UpperBounds(
|
||||
const vtkm::cont::ArrayHandle<T,CIn>& input,
|
||||
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
||||
BinaryCompare binary_compare);
|
||||
@ -512,8 +477,7 @@ struct DeviceAdapterAlgorithm
|
||||
/// of the arrays is limited to vtkm::Id.
|
||||
///
|
||||
template <class CIn, class COut>
|
||||
VTKM_CONT static void UpperBounds(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id,CIn>& input,
|
||||
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output);
|
||||
};
|
||||
#else // VTKM_DOXYGEN_ONLY
|
||||
@ -534,19 +498,13 @@ public:
|
||||
/// When a timer is constructed, all threads are synchronized and the
|
||||
/// current time is marked so that GetElapsedTime returns the number of
|
||||
/// seconds elapsed since the construction.
|
||||
VTKM_CONT DeviceAdapterTimerImplementation()
|
||||
{
|
||||
this->Reset();
|
||||
}
|
||||
VTKM_CONT DeviceAdapterTimerImplementation() { this->Reset(); }
|
||||
|
||||
/// Resets the timer. All further calls to GetElapsedTime will report the
|
||||
/// number of seconds elapsed since the call to this. This method
|
||||
/// synchronizes all asynchronous operations.
|
||||
///
|
||||
VTKM_CONT void Reset()
|
||||
{
|
||||
this->StartTime = this->GetCurrentTime();
|
||||
}
|
||||
VTKM_CONT void Reset() { this->StartTime = this->GetCurrentTime(); }
|
||||
|
||||
/// Returns the elapsed time in seconds between the construction of this
|
||||
/// class or the last call to Reset and the time this function is called. The
|
||||
@ -560,9 +518,8 @@ public:
|
||||
|
||||
vtkm::Float64 elapsedTime;
|
||||
elapsedTime = vtkm::Float64(currentTime.Seconds - this->StartTime.Seconds);
|
||||
elapsedTime +=
|
||||
(vtkm::Float64(currentTime.Microseconds - this->StartTime.Microseconds)
|
||||
/vtkm::Float64(1000000));
|
||||
elapsedTime += (vtkm::Float64(currentTime.Microseconds - this->StartTime.Microseconds) /
|
||||
vtkm::Float64(1000000));
|
||||
|
||||
return elapsedTime;
|
||||
}
|
||||
@ -575,8 +532,7 @@ public:
|
||||
|
||||
VTKM_CONT TimeStamp GetCurrentTime()
|
||||
{
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>
|
||||
::Synchronize();
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>::Synchronize();
|
||||
|
||||
TimeStamp retval;
|
||||
#ifdef _WIN32
|
||||
@ -607,7 +563,6 @@ template<class DeviceAdapterTag>
|
||||
class DeviceAdapterRuntimeDetector
|
||||
{
|
||||
public:
|
||||
|
||||
/// Returns true if the given device adapter is supported on the current
|
||||
/// machine.
|
||||
///
|
||||
@ -628,7 +583,6 @@ public:
|
||||
///
|
||||
template <typename T, typename DeviceTag>
|
||||
class DeviceAdapterAtomicArrayImplementation;
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -21,8 +21,7 @@
|
||||
#define vtk_m_cont_DeviceAdapterListTag_h
|
||||
|
||||
#ifndef VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG
|
||||
#define VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG \
|
||||
::vtkm::cont::DeviceAdapterListTagCommon
|
||||
#define VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG ::vtkm::cont::DeviceAdapterListTagCommon
|
||||
#endif
|
||||
|
||||
#include <vtkm/ListTag.h>
|
||||
@ -31,15 +30,16 @@
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
struct DeviceAdapterListTagCommon
|
||||
: vtkm::ListTagBase<
|
||||
vtkm::cont::DeviceAdapterTagCuda,
|
||||
vtkm::cont::DeviceAdapterTagTBB,
|
||||
vtkm::cont::DeviceAdapterTagSerial> { };
|
||||
|
||||
: vtkm::ListTagBase<vtkm::cont::DeviceAdapterTagCuda, vtkm::cont::DeviceAdapterTagTBB,
|
||||
vtkm::cont::DeviceAdapterTagSerial>
|
||||
{
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -20,20 +20,20 @@
|
||||
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace detail {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
PolymorphicArrayHandleContainerBase::PolymorphicArrayHandleContainerBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PolymorphicArrayHandleContainerBase::~PolymorphicArrayHandleContainerBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont::detail
|
||||
|
@ -33,14 +33,17 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
// Forward declaration
|
||||
template <typename TypeList, typename StorageList>
|
||||
class DynamicArrayHandleBase;
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/// \brief Base class for PolymorphicArrayHandleContainer
|
||||
///
|
||||
@ -56,8 +59,7 @@ struct VTKM_CONT_EXPORT PolymorphicArrayHandleContainerBase
|
||||
|
||||
virtual void PrintSummary(std::ostream& out) const = 0;
|
||||
|
||||
virtual std::shared_ptr<PolymorphicArrayHandleContainerBase>
|
||||
NewInstance() const = 0;
|
||||
virtual std::shared_ptr<PolymorphicArrayHandleContainerBase> NewInstance() const = 0;
|
||||
};
|
||||
|
||||
/// \brief ArrayHandle container that can use C++ run-time type information.
|
||||
@ -77,29 +79,30 @@ struct VTKM_ALWAYS_EXPORT PolymorphicArrayHandleContainer
|
||||
ArrayHandleType Array;
|
||||
|
||||
VTKM_CONT
|
||||
PolymorphicArrayHandleContainer() : Array() { }
|
||||
PolymorphicArrayHandleContainer()
|
||||
: Array()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
PolymorphicArrayHandleContainer(const ArrayHandleType& array)
|
||||
: Array(array) { }
|
||||
: Array(array)
|
||||
{
|
||||
}
|
||||
|
||||
virtual vtkm::IdComponent GetNumberOfComponents() const
|
||||
{
|
||||
return vtkm::VecTraits<T>::NUM_COMPONENTS;
|
||||
}
|
||||
|
||||
virtual vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->Array.GetNumberOfValues();
|
||||
}
|
||||
virtual vtkm::Id GetNumberOfValues() const { return this->Array.GetNumberOfValues(); }
|
||||
|
||||
virtual void PrintSummary(std::ostream& out) const
|
||||
{
|
||||
vtkm::cont::printSummary_ArrayHandle(this->Array, out);
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<PolymorphicArrayHandleContainerBase>
|
||||
NewInstance() const
|
||||
virtual std::shared_ptr<PolymorphicArrayHandleContainerBase> NewInstance() const
|
||||
{
|
||||
return std::shared_ptr<PolymorphicArrayHandleContainerBase>(
|
||||
new PolymorphicArrayHandleContainer<T, Storage>());
|
||||
@ -111,11 +114,10 @@ struct VTKM_ALWAYS_EXPORT PolymorphicArrayHandleContainer
|
||||
// construct a DynamicArrayHandle from another DynamicArrayHandle of any other
|
||||
// type. Since you cannot partially specialize friendship, use this accessor
|
||||
// class to get at the internals for the copy constructor.
|
||||
struct DynamicArrayHandleCopyHelper {
|
||||
struct DynamicArrayHandleCopyHelper
|
||||
{
|
||||
template <typename TypeList, typename StorageList>
|
||||
VTKM_CONT
|
||||
static
|
||||
const std::shared_ptr<vtkm::cont::detail::PolymorphicArrayHandleContainerBase>&
|
||||
VTKM_CONT static const std::shared_ptr<vtkm::cont::detail::PolymorphicArrayHandleContainerBase>&
|
||||
GetArrayHandleContainer(const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& src)
|
||||
{
|
||||
return src.ArrayContainer;
|
||||
@ -126,14 +128,11 @@ struct DynamicArrayHandleCopyHelper {
|
||||
// PolymorphicArrayHandleContainerBase to the given type of ArrayHandle. If the
|
||||
// conversion cannot be done, nullptr is returned.
|
||||
template <typename Type, typename Storage>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<Type,Storage> *
|
||||
DynamicArrayHandleTryCast(
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<Type, Storage>* DynamicArrayHandleTryCast(
|
||||
vtkm::cont::detail::PolymorphicArrayHandleContainerBase* arrayContainer)
|
||||
{
|
||||
vtkm::cont::detail::PolymorphicArrayHandleContainer<Type,Storage> *
|
||||
downcastContainer = dynamic_cast<
|
||||
vtkm::cont::detail::PolymorphicArrayHandleContainer<Type,Storage> *>(
|
||||
vtkm::cont::detail::PolymorphicArrayHandleContainer<Type, Storage>* downcastContainer =
|
||||
dynamic_cast<vtkm::cont::detail::PolymorphicArrayHandleContainer<Type, Storage>*>(
|
||||
arrayContainer);
|
||||
if (downcastContainer != nullptr)
|
||||
{
|
||||
@ -146,9 +145,7 @@ DynamicArrayHandleTryCast(
|
||||
}
|
||||
|
||||
template <typename Type, typename Storage>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<Type,Storage> *
|
||||
DynamicArrayHandleTryCast(
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<Type, Storage>* DynamicArrayHandleTryCast(
|
||||
const std::shared_ptr<vtkm::cont::detail::PolymorphicArrayHandleContainerBase>& arrayContainer)
|
||||
{
|
||||
return detail::DynamicArrayHandleTryCast<Type, Storage>(arrayContainer.get());
|
||||
@ -197,31 +194,30 @@ public:
|
||||
DynamicArrayHandleBase() {}
|
||||
|
||||
template <typename Type, typename Storage>
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleBase(const vtkm::cont::ArrayHandle<Type,Storage> &array)
|
||||
: ArrayContainer(new vtkm::cont::detail::PolymorphicArrayHandleContainer<
|
||||
Type,Storage>(array))
|
||||
{ }
|
||||
VTKM_CONT DynamicArrayHandleBase(const vtkm::cont::ArrayHandle<Type, Storage>& array)
|
||||
: ArrayContainer(new vtkm::cont::detail::PolymorphicArrayHandleContainer<Type, Storage>(array))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleBase(
|
||||
const DynamicArrayHandleBase<TypeList,StorageList> &src)
|
||||
: ArrayContainer(src.ArrayContainer) { }
|
||||
DynamicArrayHandleBase(const DynamicArrayHandleBase<TypeList, StorageList>& src)
|
||||
: ArrayContainer(src.ArrayContainer)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OtherTypeList, typename OtherStorageList>
|
||||
VTKM_CONT
|
||||
explicit DynamicArrayHandleBase(
|
||||
VTKM_CONT explicit DynamicArrayHandleBase(
|
||||
const DynamicArrayHandleBase<OtherTypeList, OtherStorageList>& src)
|
||||
: ArrayContainer(
|
||||
detail::DynamicArrayHandleCopyHelper::GetArrayHandleContainer(src))
|
||||
{ }
|
||||
: ArrayContainer(detail::DynamicArrayHandleCopyHelper::GetArrayHandleContainer(src))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
~DynamicArrayHandleBase() {}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DynamicArrayHandleBase<TypeList,StorageList> &
|
||||
operator=(const vtkm::cont::DynamicArrayHandleBase<TypeList,StorageList> &src)
|
||||
vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& operator=(
|
||||
const vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>& src)
|
||||
{
|
||||
this->ArrayContainer = src.ArrayContainer;
|
||||
return *this;
|
||||
@ -231,18 +227,15 @@ public:
|
||||
/// storage.
|
||||
///
|
||||
template <typename Type, typename Storage>
|
||||
VTKM_CONT
|
||||
bool IsTypeAndStorage() const {
|
||||
return (
|
||||
detail::DynamicArrayHandleTryCast<Type,Storage>(this->ArrayContainer)
|
||||
!= nullptr);
|
||||
VTKM_CONT bool IsTypeAndStorage() const
|
||||
{
|
||||
return (detail::DynamicArrayHandleTryCast<Type, Storage>(this->ArrayContainer) != nullptr);
|
||||
}
|
||||
|
||||
/// Returns true if this array matches the array handle type passed in.
|
||||
///
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
bool IsType()
|
||||
VTKM_CONT bool IsType()
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
typedef typename ArrayHandleType::ValueType ValueType;
|
||||
@ -254,8 +247,7 @@ public:
|
||||
/// type as the object given.
|
||||
///
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
bool IsSameType(const ArrayHandleType &)
|
||||
VTKM_CONT bool IsSameType(const ArrayHandleType&)
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
return this->IsType<ArrayHandleType>();
|
||||
@ -267,9 +259,8 @@ public:
|
||||
///
|
||||
///
|
||||
template <typename Type, typename Storage>
|
||||
VTKM_CONT
|
||||
vtkm::cont::ArrayHandle<Type, Storage>
|
||||
CastToTypeStorage() const {
|
||||
VTKM_CONT vtkm::cont::ArrayHandle<Type, Storage> CastToTypeStorage() const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<Type, Storage>* downcastArray =
|
||||
detail::DynamicArrayHandleTryCast<Type, Storage>(this->ArrayContainer);
|
||||
if (downcastArray == nullptr)
|
||||
@ -287,8 +278,8 @@ public:
|
||||
/// to check if the cast can happen.
|
||||
///
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
ArrayHandleType Cast() const {
|
||||
VTKM_CONT ArrayHandleType Cast() const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
typedef typename ArrayHandleType::ValueType ValueType;
|
||||
typedef typename ArrayHandleType::StorageTag StorageTag;
|
||||
@ -307,8 +298,8 @@ public:
|
||||
/// in the data in one array will be reflected in the other.
|
||||
///
|
||||
template <typename ArrayHandleType>
|
||||
VTKM_CONT
|
||||
void CopyTo(ArrayHandleType &array) const {
|
||||
VTKM_CONT void CopyTo(ArrayHandleType& array) const
|
||||
{
|
||||
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||
array = this->Cast<ArrayHandleType>();
|
||||
}
|
||||
@ -321,9 +312,9 @@ public:
|
||||
/// constraints.
|
||||
///
|
||||
template <typename NewTypeList>
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleBase<NewTypeList,StorageList>
|
||||
ResetTypeList(NewTypeList = NewTypeList()) const {
|
||||
VTKM_CONT DynamicArrayHandleBase<NewTypeList, StorageList> ResetTypeList(
|
||||
NewTypeList = NewTypeList()) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(NewTypeList);
|
||||
return DynamicArrayHandleBase<NewTypeList, StorageList>(*this);
|
||||
}
|
||||
@ -336,9 +327,9 @@ public:
|
||||
/// using an array of particular constraints.
|
||||
///
|
||||
template <typename NewStorageList>
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleBase<TypeList,NewStorageList>
|
||||
ResetStorageList(NewStorageList = NewStorageList()) const {
|
||||
VTKM_CONT DynamicArrayHandleBase<TypeList, NewStorageList> ResetStorageList(
|
||||
NewStorageList = NewStorageList()) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(NewStorageList);
|
||||
return DynamicArrayHandleBase<TypeList, NewStorageList>(*this);
|
||||
}
|
||||
@ -350,10 +341,9 @@ public:
|
||||
/// types and traits.
|
||||
///
|
||||
template <typename NewTypeList, typename NewStorageList>
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleBase<NewTypeList,NewStorageList>
|
||||
ResetTypeAndStorageLists(NewTypeList = NewTypeList(),
|
||||
NewStorageList = NewStorageList()) const {
|
||||
VTKM_CONT DynamicArrayHandleBase<NewTypeList, NewStorageList> ResetTypeAndStorageLists(
|
||||
NewTypeList = NewTypeList(), NewStorageList = NewStorageList()) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(NewTypeList);
|
||||
VTKM_IS_LIST_TAG(NewStorageList);
|
||||
return DynamicArrayHandleBase<NewTypeList, NewStorageList>(*this);
|
||||
@ -367,8 +357,7 @@ public:
|
||||
/// respectively.
|
||||
///
|
||||
template <typename Functor>
|
||||
VTKM_CONT
|
||||
void CastAndCall(const Functor &f) const;
|
||||
VTKM_CONT void CastAndCall(const Functor& f) const;
|
||||
|
||||
/// \brief Create a new array of the same type as this array.
|
||||
///
|
||||
@ -399,44 +388,42 @@ public:
|
||||
/// \brief Get the number of values in the array.
|
||||
///
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfValues() const
|
||||
{
|
||||
return this->ArrayContainer->GetNumberOfValues();
|
||||
}
|
||||
vtkm::Id GetNumberOfValues() const { return this->ArrayContainer->GetNumberOfValues(); }
|
||||
|
||||
VTKM_CONT
|
||||
void PrintSummary(std::ostream &out) const
|
||||
{
|
||||
this->ArrayContainer->PrintSummary(out);
|
||||
}
|
||||
void PrintSummary(std::ostream& out) const { this->ArrayContainer->PrintSummary(out); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<vtkm::cont::detail::PolymorphicArrayHandleContainerBase>
|
||||
ArrayContainer;
|
||||
std::shared_ptr<vtkm::cont::detail::PolymorphicArrayHandleContainerBase> ArrayContainer;
|
||||
|
||||
friend struct detail::DynamicArrayHandleCopyHelper;
|
||||
};
|
||||
|
||||
typedef vtkm::cont::DynamicArrayHandleBase<
|
||||
VTKM_DEFAULT_TYPE_LIST_TAG, VTKM_DEFAULT_STORAGE_LIST_TAG>
|
||||
typedef vtkm::cont::DynamicArrayHandleBase<VTKM_DEFAULT_TYPE_LIST_TAG,
|
||||
VTKM_DEFAULT_STORAGE_LIST_TAG>
|
||||
DynamicArrayHandle;
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Functor, typename Type>
|
||||
struct DynamicArrayHandleTryStorage {
|
||||
struct DynamicArrayHandleTryStorage
|
||||
{
|
||||
const DynamicArrayHandle* const Array;
|
||||
const Functor& Function;
|
||||
bool FoundCast;
|
||||
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleTryStorage(const DynamicArrayHandle &array,
|
||||
const Functor &f)
|
||||
: Array(&array), Function(f), FoundCast(false) { }
|
||||
DynamicArrayHandleTryStorage(const DynamicArrayHandle& array, const Functor& f)
|
||||
: Array(&array)
|
||||
, Function(f)
|
||||
, FoundCast(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Storage>
|
||||
VTKM_CONT
|
||||
void operator()(Storage) {
|
||||
VTKM_CONT void operator()(Storage)
|
||||
{
|
||||
this->DoCast(Storage(),
|
||||
typename vtkm::cont::internal::IsValidArrayHandle<Type, Storage>::type());
|
||||
}
|
||||
@ -445,8 +432,7 @@ private:
|
||||
template <typename Storage>
|
||||
void DoCast(Storage, std::true_type)
|
||||
{
|
||||
if (!this->FoundCast &&
|
||||
this->Array->template IsTypeAndStorage<Type,Storage>())
|
||||
if (!this->FoundCast && this->Array->template IsTypeAndStorage<Type, Storage>())
|
||||
{
|
||||
this->Function(this->Array->template CastToTypeStorage<Type, Storage>());
|
||||
this->FoundCast = true;
|
||||
@ -463,22 +449,29 @@ private:
|
||||
};
|
||||
|
||||
template <typename Functor, typename StorageList>
|
||||
struct DynamicArrayHandleTryType {
|
||||
struct DynamicArrayHandleTryType
|
||||
{
|
||||
const DynamicArrayHandle* const Array;
|
||||
const Functor& Function;
|
||||
bool FoundCast;
|
||||
|
||||
VTKM_CONT
|
||||
DynamicArrayHandleTryType(const DynamicArrayHandle& array, const Functor& f)
|
||||
: Array(&array), Function(f), FoundCast(false) { }
|
||||
: Array(&array)
|
||||
, Function(f)
|
||||
, FoundCast(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
VTKM_CONT
|
||||
void operator()(Type) {
|
||||
if (this->FoundCast) { return; }
|
||||
VTKM_CONT void operator()(Type)
|
||||
{
|
||||
if (this->FoundCast)
|
||||
{
|
||||
return;
|
||||
}
|
||||
typedef DynamicArrayHandleTryStorage<Functor, Type> TryStorageType;
|
||||
TryStorageType tryStorage =
|
||||
TryStorageType(*this->Array, this->Function);
|
||||
TryStorageType tryStorage = TryStorageType(*this->Array, this->Function);
|
||||
|
||||
vtkm::ListForEach(tryStorage, StorageList());
|
||||
if (tryStorage.FoundCast)
|
||||
@ -495,9 +488,7 @@ private:
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
template <typename Functor>
|
||||
VTKM_CONT
|
||||
void DynamicArrayHandleBase<TypeList,StorageList>::
|
||||
CastAndCall(const Functor &f) const
|
||||
VTKM_CONT void DynamicArrayHandleBase<TypeList, StorageList>::CastAndCall(const Functor& f) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
VTKM_IS_LIST_TAG(StorageList);
|
||||
@ -528,14 +519,11 @@ void DynamicArrayHandleBase<TypeList,StorageList>::
|
||||
|
||||
template <>
|
||||
template <typename Functor>
|
||||
VTKM_CONT
|
||||
void DynamicArrayHandleBase<VTKM_DEFAULT_TYPE_LIST_TAG,
|
||||
VTKM_DEFAULT_STORAGE_LIST_TAG>::
|
||||
CastAndCall(const Functor &f) const
|
||||
VTKM_CONT void DynamicArrayHandleBase<
|
||||
VTKM_DEFAULT_TYPE_LIST_TAG, VTKM_DEFAULT_STORAGE_LIST_TAG>::CastAndCall(const Functor& f) const
|
||||
{
|
||||
|
||||
typedef detail::DynamicArrayHandleTryType<Functor,
|
||||
VTKM_DEFAULT_STORAGE_LIST_TAG> TryTypeType;
|
||||
typedef detail::DynamicArrayHandleTryType<Functor, VTKM_DEFAULT_STORAGE_LIST_TAG> TryTypeType;
|
||||
|
||||
// We can remove the copy, as the current DynamicArrayHandle is already
|
||||
// the default one, and no reason to do an atomic increment and increase
|
||||
@ -545,22 +533,20 @@ void DynamicArrayHandleBase<VTKM_DEFAULT_TYPE_LIST_TAG,
|
||||
vtkm::ListForEach(tryType, VTKM_DEFAULT_TYPE_LIST_TAG());
|
||||
if (!tryType.FoundCast)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Could not find appropriate cast for array in CastAndCall2.");
|
||||
throw vtkm::cont::ErrorBadValue("Could not find appropriate cast for array in CastAndCall2.");
|
||||
}
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename TypeList, typename StorageList>
|
||||
struct DynamicTransformTraits<
|
||||
vtkm::cont::DynamicArrayHandleBase<TypeList,StorageList> >
|
||||
struct DynamicTransformTraits<vtkm::cont::DynamicArrayHandleBase<TypeList, StorageList>>
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -27,25 +27,27 @@
|
||||
#include <vtkm/cont/internal/DynamicTransform.h>
|
||||
#include <vtkm/cont/internal/SimplePolymorphicContainer.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
// Forward declaration.
|
||||
template <typename CellSetList>
|
||||
class DynamicCellSetBase;
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// One instance of a template class cannot access the private members of
|
||||
// another instance of a template class. However, I want to be able to copy
|
||||
// construct a DynamicCellSet from another DynamicCellSet of any other type.
|
||||
// Since you cannot partially specialize friendship, use this accessor class to
|
||||
// get at the internals for the copy constructor.
|
||||
struct DynamicCellSetCopyHelper {
|
||||
struct DynamicCellSetCopyHelper
|
||||
{
|
||||
template <typename CellSetList>
|
||||
VTKM_CONT
|
||||
static
|
||||
const std::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase>&
|
||||
VTKM_CONT static const std::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase>&
|
||||
GetCellSetContainer(const vtkm::cont::DynamicCellSetBase<CellSetList>& src)
|
||||
{
|
||||
return src.CellSetContainer;
|
||||
@ -56,15 +58,11 @@ struct DynamicCellSetCopyHelper {
|
||||
// SimplePolymorphicContainerBase to the given subclass of CellSet. If the
|
||||
// conversion cannot be done, nullptr is returned.
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
CellSetType *
|
||||
DynamicCellSetTryCast(
|
||||
VTKM_CONT CellSetType* DynamicCellSetTryCast(
|
||||
vtkm::cont::internal::SimplePolymorphicContainerBase* cellSetContainer)
|
||||
{
|
||||
vtkm::cont::internal::SimplePolymorphicContainer<CellSetType> *
|
||||
downcastContainer = dynamic_cast<
|
||||
vtkm::cont::internal::SimplePolymorphicContainer<CellSetType> *>(
|
||||
cellSetContainer);
|
||||
vtkm::cont::internal::SimplePolymorphicContainer<CellSetType>* downcastContainer =
|
||||
dynamic_cast<vtkm::cont::internal::SimplePolymorphicContainer<CellSetType>*>(cellSetContainer);
|
||||
if (downcastContainer != nullptr)
|
||||
{
|
||||
return &downcastContainer->Item;
|
||||
@ -76,9 +74,7 @@ DynamicCellSetTryCast(
|
||||
}
|
||||
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
CellSetType *
|
||||
DynamicCellSetTryCast(
|
||||
VTKM_CONT CellSetType* DynamicCellSetTryCast(
|
||||
const std::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase>& cellSetContainer)
|
||||
{
|
||||
return detail::DynamicCellSetTryCast<CellSetType>(cellSetContainer.get());
|
||||
@ -119,38 +115,36 @@ template<typename CellSetList>
|
||||
class VTKM_ALWAYS_EXPORT DynamicCellSetBase
|
||||
{
|
||||
VTKM_IS_LIST_TAG(CellSetList);
|
||||
|
||||
public:
|
||||
VTKM_CONT
|
||||
DynamicCellSetBase() {}
|
||||
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
DynamicCellSetBase(const CellSetType &cellSet)
|
||||
: CellSetContainer(
|
||||
new vtkm::cont::internal::SimplePolymorphicContainer<CellSetType>(
|
||||
cellSet))
|
||||
VTKM_CONT DynamicCellSetBase(const CellSetType& cellSet)
|
||||
: CellSetContainer(new vtkm::cont::internal::SimplePolymorphicContainer<CellSetType>(cellSet))
|
||||
{
|
||||
VTKM_IS_CELL_SET(CellSetType);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
DynamicCellSetBase(const DynamicCellSetBase<CellSetList>& src)
|
||||
: CellSetContainer(src.CellSetContainer) { }
|
||||
: CellSetContainer(src.CellSetContainer)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OtherCellSetList>
|
||||
VTKM_CONT
|
||||
explicit
|
||||
DynamicCellSetBase(const DynamicCellSetBase<OtherCellSetList> &src)
|
||||
: CellSetContainer(
|
||||
detail::DynamicCellSetCopyHelper::GetCellSetContainer(src))
|
||||
{ }
|
||||
VTKM_CONT explicit DynamicCellSetBase(const DynamicCellSetBase<OtherCellSetList>& src)
|
||||
: CellSetContainer(detail::DynamicCellSetCopyHelper::GetCellSetContainer(src))
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
~DynamicCellSetBase() {}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::DynamicCellSetBase<CellSetList> &
|
||||
operator=(const vtkm::cont::DynamicCellSetBase<CellSetList> &src)
|
||||
vtkm::cont::DynamicCellSetBase<CellSetList>& operator=(
|
||||
const vtkm::cont::DynamicCellSetBase<CellSetList>& src)
|
||||
{
|
||||
this->CellSetContainer = src.CellSetContainer;
|
||||
return *this;
|
||||
@ -159,27 +153,26 @@ public:
|
||||
/// Returns true if this cell set is of the provided type.
|
||||
///
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
bool IsType() const {
|
||||
return (detail::DynamicCellSetTryCast<CellSetType>(this->CellSetContainer)
|
||||
!= nullptr);
|
||||
VTKM_CONT bool IsType() const
|
||||
{
|
||||
return (detail::DynamicCellSetTryCast<CellSetType>(this->CellSetContainer) != nullptr);
|
||||
}
|
||||
|
||||
/// Returns true if this cell set is the same (or equivalent) type as the
|
||||
/// object provided.
|
||||
///
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
bool IsSameType(const CellSetType &) const {
|
||||
VTKM_CONT bool IsSameType(const CellSetType&) const
|
||||
{
|
||||
return this->IsType<CellSetType>();
|
||||
}
|
||||
|
||||
/// Returns the contained cell set as the abstract \c CellSet type.
|
||||
///
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CellSet &CastToBase() const {
|
||||
return *reinterpret_cast<const vtkm::cont::CellSet *>(
|
||||
this->CellSetContainer->GetVoidPointer());
|
||||
const vtkm::cont::CellSet& CastToBase() const
|
||||
{
|
||||
return *reinterpret_cast<const vtkm::cont::CellSet*>(this->CellSetContainer->GetVoidPointer());
|
||||
}
|
||||
|
||||
/// Returns this cell set cast to the given \c CellSet type. Throws \c
|
||||
@ -187,8 +180,8 @@ public:
|
||||
/// the cast can happen.
|
||||
///
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
CellSetType &Cast() const {
|
||||
VTKM_CONT CellSetType& Cast() const
|
||||
{
|
||||
CellSetType* cellSetPointer =
|
||||
detail::DynamicCellSetTryCast<CellSetType>(this->CellSetContainer);
|
||||
if (cellSetPointer == nullptr)
|
||||
@ -207,8 +200,8 @@ public:
|
||||
/// copied.
|
||||
///
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
void CopyTo(CellSetType &cellSet) const {
|
||||
VTKM_CONT void CopyTo(CellSetType& cellSet) const
|
||||
{
|
||||
cellSet = this->Cast<CellSetType>();
|
||||
}
|
||||
|
||||
@ -220,9 +213,9 @@ public:
|
||||
/// when using a cell set of particular constraints.
|
||||
///
|
||||
template <typename NewCellSetList>
|
||||
VTKM_CONT
|
||||
DynamicCellSetBase<NewCellSetList>
|
||||
ResetCellSetList(NewCellSetList = NewCellSetList()) const {
|
||||
VTKM_CONT DynamicCellSetBase<NewCellSetList> ResetCellSetList(
|
||||
NewCellSetList = NewCellSetList()) const
|
||||
{
|
||||
VTKM_IS_LIST_TAG(NewCellSetList);
|
||||
return DynamicCellSetBase<NewCellSetList>(*this);
|
||||
}
|
||||
@ -235,8 +228,7 @@ public:
|
||||
/// behavior from \c CastAndCall.
|
||||
///
|
||||
template <typename Functor>
|
||||
VTKM_CONT
|
||||
void CastAndCall(const Functor &f) const;
|
||||
VTKM_CONT void CastAndCall(const Functor& f) const;
|
||||
|
||||
/// \brief Create a new cell set of the same type as this cell set.
|
||||
///
|
||||
@ -254,50 +246,31 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
std::string GetName() const
|
||||
{
|
||||
return this->CastToBase().GetName();
|
||||
}
|
||||
std::string GetName() const { return this->CastToBase().GetName(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfCells() const
|
||||
{
|
||||
return this->CastToBase().GetNumberOfCells();
|
||||
}
|
||||
vtkm::Id GetNumberOfCells() const { return this->CastToBase().GetNumberOfCells(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfFaces() const
|
||||
{
|
||||
return this->CastToBase().GetNumberOfFaces();
|
||||
}
|
||||
vtkm::Id GetNumberOfFaces() const { return this->CastToBase().GetNumberOfFaces(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfEdges() const
|
||||
{
|
||||
return this->CastToBase().GetNumberOfEdges();
|
||||
}
|
||||
vtkm::Id GetNumberOfEdges() const { return this->CastToBase().GetNumberOfEdges(); }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Id GetNumberOfPoints() const
|
||||
{
|
||||
return this->CastToBase().GetNumberOfPoints();
|
||||
}
|
||||
vtkm::Id GetNumberOfPoints() const { return this->CastToBase().GetNumberOfPoints(); }
|
||||
|
||||
VTKM_CONT
|
||||
void PrintSummary(std::ostream& stream) const
|
||||
{
|
||||
return this->CastToBase().PrintSummary(stream);
|
||||
}
|
||||
|
||||
void PrintSummary(std::ostream& stream) const { return this->CastToBase().PrintSummary(stream); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase>
|
||||
CellSetContainer;
|
||||
std::shared_ptr<vtkm::cont::internal::SimplePolymorphicContainerBase> CellSetContainer;
|
||||
|
||||
friend struct detail::DynamicCellSetCopyHelper;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Functor>
|
||||
struct DynamicCellSetTryCellSet
|
||||
@ -307,18 +280,20 @@ struct DynamicCellSetTryCellSet
|
||||
bool FoundCast;
|
||||
|
||||
VTKM_CONT
|
||||
DynamicCellSetTryCellSet(
|
||||
vtkm::cont::internal::SimplePolymorphicContainerBase *cellSetContainer,
|
||||
DynamicCellSetTryCellSet(vtkm::cont::internal::SimplePolymorphicContainerBase* cellSetContainer,
|
||||
const Functor& f)
|
||||
: CellSetContainer(cellSetContainer), Function(f), FoundCast(false) { }
|
||||
: CellSetContainer(cellSetContainer)
|
||||
, Function(f)
|
||||
, FoundCast(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT
|
||||
void operator()(CellSetType) {
|
||||
VTKM_CONT void operator()(CellSetType)
|
||||
{
|
||||
if (!this->FoundCast)
|
||||
{
|
||||
CellSetType *cellSet =
|
||||
detail::DynamicCellSetTryCast<CellSetType>(this->CellSetContainer);
|
||||
CellSetType* cellSet = detail::DynamicCellSetTryCast<CellSetType>(this->CellSetContainer);
|
||||
if (cellSet != nullptr)
|
||||
{
|
||||
this->Function(*cellSet);
|
||||
@ -335,8 +310,7 @@ private:
|
||||
|
||||
template <typename CellSetList>
|
||||
template <typename Functor>
|
||||
VTKM_CONT
|
||||
void DynamicCellSetBase<CellSetList>::CastAndCall(const Functor &f) const
|
||||
VTKM_CONT void DynamicCellSetBase<CellSetList>::CastAndCall(const Functor& f) const
|
||||
{
|
||||
typedef detail::DynamicCellSetTryCellSet<Functor> TryCellSetType;
|
||||
TryCellSetType tryCellSet = TryCellSetType(this->CellSetContainer.get(), f);
|
||||
@ -344,25 +318,25 @@ void DynamicCellSetBase<CellSetList>::CastAndCall(const Functor &f) const
|
||||
vtkm::ListForEach(tryCellSet, CellSetList());
|
||||
if (!tryCellSet.FoundCast)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Could not find appropriate cast for cell set.");
|
||||
throw vtkm::cont::ErrorBadValue("Could not find appropriate cast for cell set.");
|
||||
}
|
||||
}
|
||||
|
||||
typedef DynamicCellSetBase<VTKM_DEFAULT_CELL_SET_LIST_TAG> DynamicCellSet;
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename CellSetList>
|
||||
struct DynamicTransformTraits<
|
||||
vtkm::cont::DynamicCellSetBase<CellSetList> >
|
||||
struct DynamicTransformTraits<vtkm::cont::DynamicCellSetBase<CellSetList>>
|
||||
{
|
||||
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
/// Checks to see if the given object is a dynamic cell set. It contains a
|
||||
/// typedef named \c type that is either std::true_type or std::false_type.
|
||||
@ -384,12 +358,10 @@ struct DynamicCellSetCheck<vtkm::cont::DynamicCellSetBase<CellSetList> >
|
||||
VTKM_STATIC_ASSERT(::vtkm::cont::internal::DynamicCellSetCheck<T>::type::value)
|
||||
|
||||
#define VTKM_IS_DYNAMIC_OR_STATIC_CELL_SET(T) \
|
||||
VTKM_STATIC_ASSERT( \
|
||||
::vtkm::cont::internal::CellSetCheck<T>::type::value || \
|
||||
VTKM_STATIC_ASSERT(::vtkm::cont::internal::CellSetCheck<T>::type::value || \
|
||||
::vtkm::cont::internal::DynamicCellSetCheck<T>::type::value)
|
||||
|
||||
} // namespace internal
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -29,8 +29,10 @@
|
||||
|
||||
#include <vtkm/internal/ExportMacros.h> // For VTKM_OVERRIDE
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
|
||||
|
||||
@ -53,26 +55,22 @@ public:
|
||||
#endif
|
||||
|
||||
// For std::exception compatibility:
|
||||
const char* what() const VTKM_NOEXCEPT VTKM_OVERRIDE
|
||||
{
|
||||
return this->Message.c_str();
|
||||
}
|
||||
const char* what() const VTKM_NOEXCEPT VTKM_OVERRIDE { return this->Message.c_str(); }
|
||||
|
||||
protected:
|
||||
Error() {}
|
||||
Error(const std::string message) : Message(message) { }
|
||||
|
||||
void SetMessage(const std::string &message)
|
||||
Error(const std::string message)
|
||||
: Message(message)
|
||||
{
|
||||
this->Message = message;
|
||||
}
|
||||
|
||||
void SetMessage(const std::string& message) { this->Message = message; }
|
||||
|
||||
private:
|
||||
std::string Message;
|
||||
};
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
#include <vtkm/cont/Error.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
|
||||
|
||||
@ -34,11 +36,12 @@ class VTKM_ALWAYS_EXPORT ErrorBadAllocation : public Error
|
||||
{
|
||||
public:
|
||||
ErrorBadAllocation(const std::string& message)
|
||||
: Error(message) { }
|
||||
: Error(message)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
#include <vtkm/cont/Error.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
|
||||
|
||||
@ -34,11 +36,12 @@ class VTKM_ALWAYS_EXPORT ErrorBadType : public Error
|
||||
{
|
||||
public:
|
||||
ErrorBadType(const std::string& message)
|
||||
: Error(message) { }
|
||||
: Error(message)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
#include <vtkm/cont/Error.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
|
||||
|
||||
@ -34,11 +36,12 @@ class VTKM_ALWAYS_EXPORT ErrorBadValue : public Error
|
||||
{
|
||||
public:
|
||||
ErrorBadValue(const std::string& message)
|
||||
: Error(message) { }
|
||||
: Error(message)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
#include <vtkm/cont/Error.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace cont {
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
|
||||
|
||||
@ -34,11 +36,12 @@ class VTKM_ALWAYS_EXPORT ErrorExecution : public vtkm::cont::Error
|
||||
{
|
||||
public:
|
||||
ErrorExecution(const std::string& message)
|
||||
: Error(message) { }
|
||||
: Error(message)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
|
||||
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user