Commit 93b8ee97 authored by Subhashis Hazarika's avatar Subhashis Hazarika
Browse files

Pasing range explicitly to NDHistogram worklet for ALPINE 2D sampling milestone

parent a3b8525e
...@@ -66,6 +66,29 @@ public: ...@@ -66,6 +66,29 @@ public:
} }
} }
// Add a field and the bin number for this field along with specific range of the data
// Return: binDelta is delta of a bin
template <typename HandleType>
void AddField(const HandleType& fieldArray,
vtkm::Id numberOfBins,
vtkm::Range& rangeOfValues,
vtkm::Float64& binDelta,
bool rangeProvided)
{
NumberOfBins.push_back(numberOfBins);
if (fieldArray.GetNumberOfValues() != NumDataPoints)
{
throw vtkm::cont::ErrorBadValue("Array lengths does not match");
}
else
{
CastAndCall(fieldArray.ResetTypes(vtkm::TypeListScalarAll()),
vtkm::worklet::histogram::ComputeBins(
Bin1DIndex, numberOfBins, rangeOfValues, binDelta, rangeProvided));
}
}
// Execute N-Dim histogram worklet to get N-Dims histogram from input fields // Execute N-Dim histogram worklet to get N-Dims histogram from input fields
// Input arguments: // Input arguments:
// binId: returned bin id of NDims-histogram, binId has n arrays, if length of fieldName is n // binId: returned bin id of NDims-histogram, binId has n arrays, if length of fieldName is n
......
...@@ -89,16 +89,35 @@ public: ...@@ -89,16 +89,35 @@ public:
, NumOfBins(_numOfBins) , NumOfBins(_numOfBins)
, MinMax(_minMax) , MinMax(_minMax)
, BinDelta(_binDelta) , BinDelta(_binDelta)
, RangeProvided(false)
{
}
VTKM_CONT
ComputeBins(vtkm::cont::ArrayHandle<vtkm::Id>& _bin1DIdx,
vtkm::Id& _numOfBins,
vtkm::Range& _minMax,
vtkm::Float64& _binDelta,
bool _rangeProvided)
: Bin1DIdx(_bin1DIdx)
, NumOfBins(_numOfBins)
, MinMax(_minMax)
, BinDelta(_binDelta)
, RangeProvided(_rangeProvided)
{ {
} }
template <typename T, typename Storage> template <typename T, typename Storage>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& field) const VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& field) const
{ {
const vtkm::Vec<T, 2> initValue(vtkm::cont::ArrayGetValue(0, field)); if (!RangeProvided)
vtkm::Vec<T, 2> minMax = vtkm::cont::Algorithm::Reduce(field, initValue, vtkm::MinAndMax<T>()); {
MinMax.Min = static_cast<vtkm::Float64>(minMax[0]); const vtkm::Vec<T, 2> initValue(vtkm::cont::ArrayGetValue(0, field));
MinMax.Max = static_cast<vtkm::Float64>(minMax[1]); vtkm::Vec<T, 2> minMax =
vtkm::cont::Algorithm::Reduce(field, initValue, vtkm::MinAndMax<T>());
MinMax.Min = static_cast<vtkm::Float64>(minMax[0]);
MinMax.Max = static_cast<vtkm::Float64>(minMax[1]);
}
BinDelta = compute_delta(MinMax.Min, MinMax.Max, NumOfBins); BinDelta = compute_delta(MinMax.Min, MinMax.Max, NumOfBins);
SetHistogramBin<T> binWorklet(NumOfBins, MinMax.Min, BinDelta); SetHistogramBin<T> binWorklet(NumOfBins, MinMax.Min, BinDelta);
...@@ -112,6 +131,7 @@ private: ...@@ -112,6 +131,7 @@ private:
vtkm::Id& NumOfBins; vtkm::Id& NumOfBins;
vtkm::Range& MinMax; vtkm::Range& MinMax;
vtkm::Float64& BinDelta; vtkm::Float64& BinDelta;
bool RangeProvided;
}; };
// Convert N-dims bin index into 1D index // Convert N-dims bin index into 1D index
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment