Commit 77acc39f authored by Mark Kim's avatar Mark Kim Committed by Kitware Robot

Merge topic 'zfp'

865942f1 Home stretch of warnings...(?)
f5569fb9 More warnings.
6beefb4a Technically need default initialization.
6f86d21e clang is my nemesis.
ce00cc6e straggling function variables.
3dae0b08 CUDA can still be finicky.
e7c1151c So many warnings.
f5ca28f5 More compiler warnings.
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland's avatarKenneth Moreland <kmorel@sandia.gov>
Merge-request: !1482
parents f3536e44 865942f1
......@@ -2553,6 +2553,45 @@ static inline VTKM_EXEC_CONT vtkm::Vec<T, N> CopySign(const vtkm::Vec<T, N>& x,
return result;
}
/// Decompose floating poing value
///
inline VTKM_EXEC_CONT vtkm::Float32 Frexp(vtkm::Float32 x, vtkm::Int32 *exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(frexp)(x, exponent);
#else
return std::frexp(x, exponent);
#endif
}
inline VTKM_EXEC_CONT vtkm::Float64 Frexp(vtkm::Float64 x, vtkm::Int32 *exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(frexp)(x, exponent);
#else
return std::frexp(x, exponent);
#endif
}
inline VTKM_EXEC_CONT vtkm::Float32 Ldexp(vtkm::Float32 x, vtkm::Int32 exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(ldexp)(x, exponent);
#else
return std::ldexp(x, exponent);
#endif
}
inline VTKM_EXEC_CONT vtkm::Float64 Ldexp(vtkm::Float64 x, vtkm::Int32 exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(ldexp)(x, exponent);
#else
return std::ldexp(x, exponent);
#endif
}
} // namespace vtkm
// clang-format on
......
......@@ -1155,6 +1155,45 @@ static inline VTKM_EXEC_CONT vtkm::Vec<T, N> CopySign(const vtkm::Vec<T, N>& x,
return result;
}
/// Decompose floating poing value
///
inline VTKM_EXEC_CONT vtkm::Float32 Frexp(vtkm::Float32 x, vtkm::Int32 *exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(frexp)(x, exponent);
#else
return std::frexp(x, exponent);
#endif
}
inline VTKM_EXEC_CONT vtkm::Float64 Frexp(vtkm::Float64 x, vtkm::Int32 *exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(frexp)(x, exponent);
#else
return std::frexp(x, exponent);
#endif
}
inline VTKM_EXEC_CONT vtkm::Float32 Ldexp(vtkm::Float32 x, vtkm::Int32 exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(ldexp)(x, exponent);
#else
return std::ldexp(x, exponent);
#endif
}
inline VTKM_EXEC_CONT vtkm::Float64 Ldexp(vtkm::Float64 x, vtkm::Int32 exponent)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(ldexp)(x, exponent);
#else
return std::ldexp(x, exponent);
#endif
}
} // namespace vtkm
// clang-format on
......
......@@ -43,17 +43,21 @@ public:
// 1D uniform datasets.
vtkm::cont::DataSet Make1DUniformDataSet0();
vtkm::cont::DataSet Make1DUniformDataSet1();
vtkm::cont::DataSet Make1DUniformDataSet2();
// 1D explicit datasets.
vtkm::cont::DataSet Make1DExplicitDataSet0();
// 2D uniform datasets.
vtkm::cont::DataSet Make2DUniformDataSet0();
vtkm::cont::DataSet Make2DUniformDataSet1();
vtkm::cont::DataSet Make2DUniformDataSet2();
// 3D uniform datasets.
vtkm::cont::DataSet Make3DUniformDataSet0();
vtkm::cont::DataSet Make3DUniformDataSet1();
vtkm::cont::DataSet Make3DUniformDataSet2();
vtkm::cont::DataSet Make3DUniformDataSet3(const vtkm::Id3 dims);
vtkm::cont::DataSet Make3DRegularDataSet0();
vtkm::cont::DataSet Make3DRegularDataSet1();
......@@ -111,6 +115,33 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet1()
return dataSet;
}
//Make a simple 1D, 16 cell uniform dataset.
inline vtkm::cont::DataSet MakeTestDataSet::Make1DUniformDataSet2()
{
vtkm::cont::DataSetBuilderUniform dsb;
constexpr vtkm::Id dims = 256;
vtkm::cont::DataSet dataSet = dsb.Create(dims);
vtkm::cont::DataSetFieldAdd dsf;
vtkm::Float64 pointvar[dims];
vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims - 1);
vtkm::Id idx = 0;
for (vtkm::Id x = 0; x < dims; ++x)
{
vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi();
vtkm::Float64 cv = vtkm::Sin(cx);
pointvar[idx] = cv;
idx++;
}
dsf.AddPointField(dataSet, "pointvar", pointvar, dims);
return dataSet;
}
inline vtkm::cont::DataSet MakeTestDataSet::Make1DExplicitDataSet0()
{
const int nVerts = 5;
......@@ -183,6 +214,39 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet1()
return dataSet;
}
//Make a simple 2D, 16 cell uniform dataset.
inline vtkm::cont::DataSet MakeTestDataSet::Make2DUniformDataSet2()
{
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::Id2 dims(16, 16);
vtkm::cont::DataSet dataSet = dsb.Create(dims);
vtkm::cont::DataSetFieldAdd dsf;
constexpr vtkm::Id nVerts = 256;
vtkm::Float64 pointvar[nVerts];
vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims[0] - 1);
vtkm::Float64 dy = vtkm::Float64(2.0 * vtkm::Pi()) / vtkm::Float64(dims[1] - 1);
vtkm::Id idx = 0;
for (vtkm::Id y = 0; y < dims[1]; ++y)
{
vtkm::Float64 cy = vtkm::Float64(y) * dy - vtkm::Pi();
for (vtkm::Id x = 0; x < dims[0]; ++x)
{
vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi();
vtkm::Float64 cv = vtkm::Sin(cx) + vtkm::Sin(cy) +
2.0 * vtkm::Cos(vtkm::Sqrt((cx * cx) / 2.0 + cy * cy) / 0.75) +
4.0 * vtkm::Cos(cx * cy / 4.0);
pointvar[idx] = cv;
idx++;
}
} // y
dsf.AddPointField(dataSet, "pointvar", pointvar, nVerts);
return dataSet;
}
//Make a simple 3D, 4 cell uniform dataset.
inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet0()
{
......@@ -275,6 +339,48 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet2()
return dataSet;
}
inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet3(const vtkm::Id3 dims)
{
vtkm::cont::DataSetBuilderUniform dsb;
vtkm::cont::DataSet dataSet = dsb.Create(dims);
// add point scalar field
vtkm::Id numPoints = dims[0] * dims[1] * dims[2];
std::vector<vtkm::Float64> pointvar(static_cast<size_t>(numPoints));
vtkm::Float64 dx = vtkm::Float64(4.0 * vtkm::Pi()) / vtkm::Float64(dims[0] - 1);
vtkm::Float64 dy = vtkm::Float64(2.0 * vtkm::Pi()) / vtkm::Float64(dims[1] - 1);
vtkm::Float64 dz = vtkm::Float64(3.0 * vtkm::Pi()) / vtkm::Float64(dims[2] - 1);
vtkm::Id idx = 0;
for (vtkm::Id z = 0; z < dims[2]; ++z)
{
vtkm::Float64 cz = vtkm::Float64(z) * dz - 1.5 * vtkm::Pi();
for (vtkm::Id y = 0; y < dims[1]; ++y)
{
vtkm::Float64 cy = vtkm::Float64(y) * dy - vtkm::Pi();
for (vtkm::Id x = 0; x < dims[0]; ++x)
{
vtkm::Float64 cx = vtkm::Float64(x) * dx - 2.0 * vtkm::Pi();
vtkm::Float64 cv = vtkm::Sin(cx) + vtkm::Sin(cy) +
2.0 * vtkm::Cos(vtkm::Sqrt((cx * cx) / 2.0 + cy * cy) / 0.75) +
4.0 * vtkm::Cos(cx * cy / 4.0);
if (dims[2] > 1)
{
cv += vtkm::Sin(cz) + 1.5 * vtkm::Cos(vtkm::Sqrt(cx * cx + cy * cy + cz * cz) / 0.75);
}
pointvar[static_cast<size_t>(idx)] = cv;
idx++;
}
} // y
} // z
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddPointField(dataSet, "pointvar", pointvar);
return dataSet;
}
inline vtkm::cont::DataSet MakeTestDataSet::Make2DRectilinearDataSet0()
{
vtkm::cont::DataSetBuilderRectilinear dsb;
......
......@@ -70,6 +70,12 @@ set(headers
VertexClustering.h
WarpScalar.h
WarpVector.h
ZFPCompressor1D.h
ZFPDecompressor1D.h
ZFPCompressor2D.h
ZFPDecompressor2D.h
ZFPCompressor3D.h
ZFPDecompressor3D.h
)
set(header_template_sources
......@@ -119,6 +125,12 @@ set(header_template_sources
VertexClustering.hxx
WarpScalar.hxx
WarpVector.hxx
ZFPCompressor1D.hxx
ZFPDecompressor1D.hxx
ZFPCompressor2D.hxx
ZFPDecompressor2D.hxx
ZFPCompressor3D.hxx
ZFPDecompressor3D.hxx
)
vtkm_declare_headers(${headers}
......
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_filter_ZFPCompressor1D_h
#define vtk_m_filter_ZFPCompressor1D_h
#include <vtkm/filter/FilterField.h>
#include <vtkm/worklet/ZFP1DCompressor.h>
namespace vtkm
{
namespace filter
{
/// \brief Compress a scalar field using ZFP
/// Takes as input a 1D array and generates on
/// output of compressed data.
/// @warning
/// This filter is currently only supports 1D volumes.
class ZFPCompressor1D : public vtkm::filter::FilterField<ZFPCompressor1D>
{
public:
VTKM_CONT
ZFPCompressor1D();
void SetRate(vtkm::Float64 _rate) { rate = _rate; }
vtkm::Float64 GetRate() { return rate; }
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
//Map a new field onto the resulting dataset after running the filter
//this call is only valid
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
private:
vtkm::Float64 rate;
vtkm::worklet::ZFP1DCompressor compressor;
};
template <>
class FilterTraits<ZFPCompressor1D>
{
public:
struct TypeListTagMCScalars
: vtkm::ListTagBase<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>
{
};
using InputFieldTypeList = TypeListTagMCScalars;
};
}
} // namespace vtkm::filter
#include <vtkm/filter/ZFPCompressor1D.hxx>
#endif // vtk_m_filter_ZFPCompressor1D_h
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
namespace vtkm
{
namespace filter
{
namespace
{
template <typename CellSetList>
bool IsCellSetStructured(const vtkm::cont::DynamicCellSetBase<CellSetList>& cellset)
{
if (cellset.template IsType<vtkm::cont::CellSetStructured<1>>())
{
return true;
}
return false;
}
} // anonymous namespace
//-----------------------------------------------------------------------------
inline VTKM_CONT ZFPCompressor1D::ZFPCompressor1D()
: vtkm::filter::FilterField<ZFPCompressor1D>()
, rate(0)
{
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ZFPCompressor1D::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// if (fieldMeta.IsPointField() == false)
// {
// throw vtkm::cont::ErrorFilterExecution("Point field expected.");
// }
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
auto compressed = compressor.Compress(field, rate, field.GetNumberOfValues());
vtkm::cont::DataSet dataset;
vtkm::cont::Field compressedField(
"compressed", vtkm::cont::Field::Association::POINTS, compressed);
dataset.AddField(compressedField);
return dataset;
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT bool ZFPCompressor1D::DoMapField(vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<T, StorageType>&,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
return false;
}
}
} // namespace vtkm::filter
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_filter_ZFPCompressor2D_h
#define vtk_m_filter_ZFPCompressor2D_h
#include <vtkm/filter/FilterField.h>
#include <vtkm/worklet/ZFP2DCompressor.h>
namespace vtkm
{
namespace filter
{
/// \brief Compress a scalar field using ZFP
/// Takes as input a 1D array and generates on
/// output of compressed data.
/// @warning
/// This filter is currently only supports 1D volumes.
class ZFPCompressor2D : public vtkm::filter::FilterField<ZFPCompressor2D>
{
public:
VTKM_CONT
ZFPCompressor2D();
void SetRate(vtkm::Float64 _rate) { rate = _rate; }
vtkm::Float64 GetRate() { return rate; }
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
//Map a new field onto the resulting dataset after running the filter
//this call is only valid
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
private:
vtkm::Float64 rate;
vtkm::worklet::ZFP2DCompressor compressor;
};
template <>
class FilterTraits<ZFPCompressor2D>
{
public:
struct TypeListTagMCScalars
: vtkm::ListTagBase<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>
{
};
using InputFieldTypeList = TypeListTagMCScalars;
};
}
} // namespace vtkm::filter
#include <vtkm/filter/ZFPCompressor2D.hxx>
#endif // vtk_m_filter_ZFPCompressor2D_h
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
namespace vtkm
{
namespace filter
{
namespace
{
template <typename CellSetList>
bool IsCellSet2DStructured(const vtkm::cont::DynamicCellSetBase<CellSetList>& cellset)
{
if (cellset.template IsType<vtkm::cont::CellSetStructured<2>>())
{
return true;
}
return false;
}
} // anonymous namespace
//-----------------------------------------------------------------------------
inline VTKM_CONT ZFPCompressor2D::ZFPCompressor2D()
: vtkm::filter::FilterField<ZFPCompressor2D>()
, rate(0)
{
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ZFPCompressor2D::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
// if (fieldMeta.IsPointField() == false)
// {
// throw vtkm::cont::ErrorFilterExecution("Point field expected.");
// }
// Check the fields of the dataset to see what kinds of fields are present so
// we can free the mapping arrays that won't be needed. A point field must
// exist for this algorithm, so just check cells.
const vtkm::Id numFields = input.GetNumberOfFields();
bool hasCellFields = false;
for (vtkm::Id fieldIdx = 0; fieldIdx < numFields && !hasCellFields; ++fieldIdx)
{
auto f = input.GetField(fieldIdx);
if (f.GetAssociation() == vtkm::cont::Field::Association::CELL_SET)
{
hasCellFields = true;
}
}
vtkm::cont::CellSetStructured<2> cellSet;
input.GetCellSet(0).CopyTo(cellSet);
vtkm::Id2 pointDimensions = cellSet.GetPointDimensions();
auto compressed = compressor.Compress(field, rate, pointDimensions);
vtkm::cont::DataSet dataset;
vtkm::cont::Field compressedField(
"compressed", vtkm::cont::Field::Association::POINTS, compressed);
dataset.AddCellSet(cellSet);
dataset.AddField(compressedField);
return dataset;
}
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT bool ZFPCompressor2D::DoMapField(vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<T, StorageType>&,
const vtkm::filter::FieldMetadata&,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
return false;
}
}
} // namespace vtkm::filter
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_filter_ZFPCompressor3D_h
#define vtk_m_filter_ZFPCompressor3D_h
#include <vtkm/filter/FilterField.h>
#include <vtkm/worklet/ZFPCompressor.h>
namespace vtkm
{
namespace filter
{
/// \brief Compress a scalar field using ZFP
/// Takes as input a 1D array and generates on
/// output of compressed data.
/// @warning
/// This filter is currently only supports 1D volumes.
class ZFPCompressor3D : public vtkm::filter::FilterField<ZFPCompressor3D>
{
public:
VTKM_CONT
ZFPCompressor3D();
void SetRate(vtkm::Float64 _rate) { rate = _rate; }
vtkm::Float64 GetRate() { return rate; }
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
//Map a new field onto the resulting dataset after running the filter
//this call is only valid
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
private:
vtkm::Float64 rate;
vtkm::worklet::ZFPCompressor compressor;
};
template <>
class FilterTraits<ZFPCompressor3D>
{
public:
struct TypeListTagMCScalars
: vtkm::ListTagBase<vtkm::UInt8, vtkm::Int8, vtkm::Float32, vtkm::Float64>