Commit c63bf12f authored by Li-Ta Lo's avatar Li-Ta Lo Committed by Bolea Sanchez, Vicente Adolfo
Browse files

Merge topic 'alpine_sampling_2d'

ed8d2fb3 Merge branch 'master' into alpine_sampling_2d
93b8ee97

 Pasing range explicitly to NDHistogram worklet for ALPINE 2D sampling milestone
Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarLi-Ta Lo <ollie@lanl.gov>
Merge-request: !2257
parent 19c1b99f
......@@ -64,6 +64,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
// Input arguments:
// binId: returned bin id of NDims-histogram, binId has n arrays, if length of fieldName is n
......
......@@ -89,16 +89,35 @@ public:
, NumOfBins(_numOfBins)
, MinMax(_minMax)
, 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>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& field) const
{
const vtkm::Vec<T, 2> initValue(vtkm::cont::ArrayGetValue(0, field));
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]);
if (!RangeProvided)
{
const vtkm::Vec<T, 2> initValue(vtkm::cont::ArrayGetValue(0, field));
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);
SetHistogramBin<T> binWorklet(NumOfBins, MinMax.Min, BinDelta);
......@@ -112,6 +131,7 @@ private:
vtkm::Id& NumOfBins;
vtkm::Range& MinMax;
vtkm::Float64& BinDelta;
bool RangeProvided;
};
// Convert N-dims bin index into 1D index
......
Markdown is supported
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