2018-04-11 00:11:32 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-04-11 00:11:32 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_examples_histogram_HistogramMPI_h
|
|
|
|
#define vtk_m_examples_histogram_HistogramMPI_h
|
|
|
|
|
2022-12-01 20:07:56 +00:00
|
|
|
#include <vtkm/filter/FilterField.h>
|
2018-04-11 00:11:32 +00:00
|
|
|
|
|
|
|
namespace example
|
|
|
|
{
|
|
|
|
|
|
|
|
/// \brief Construct the HistogramMPI of a given Field
|
|
|
|
///
|
|
|
|
/// Construct a HistogramMPI with a default of 10 bins.
|
|
|
|
///
|
2022-12-01 20:07:56 +00:00
|
|
|
class HistogramMPI : public vtkm::filter::FilterField
|
2018-04-11 00:11:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-08-02 02:03:04 +00:00
|
|
|
//currently the HistogramMPI filter only works on scalar data.
|
|
|
|
//this mainly has to do with getting the ranges for each bin
|
|
|
|
//would require returning a more complex value type
|
2019-12-05 17:55:57 +00:00
|
|
|
using SupportedTypes = vtkm::TypeListScalarAll;
|
2019-08-02 02:03:04 +00:00
|
|
|
|
2018-04-11 00:11:32 +00:00
|
|
|
//Construct a HistogramMPI with a default of 10 bins
|
|
|
|
VTKM_CONT
|
2022-09-26 16:23:26 +00:00
|
|
|
HistogramMPI() { this->SetOutputFieldName("histogram"); }
|
2018-04-11 00:11:32 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void SetNumberOfBins(vtkm::Id count) { this->NumberOfBins = count; }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Id GetNumberOfBins() const { return this->NumberOfBins; }
|
|
|
|
|
2022-09-09 02:29:48 +00:00
|
|
|
///@{
|
2018-04-11 00:11:32 +00:00
|
|
|
/// Get/Set the range to use to generate the HistogramMPI. If range is set to
|
|
|
|
/// empty, the field's global range (computed using `vtkm::cont::FieldRangeGlobalCompute`)
|
|
|
|
/// will be used.
|
|
|
|
VTKM_CONT
|
|
|
|
void SetRange(const vtkm::Range& range) { this->Range = range; }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
const vtkm::Range& GetRange() const { return this->Range; }
|
2022-09-09 02:29:48 +00:00
|
|
|
///@}
|
2018-04-11 00:11:32 +00:00
|
|
|
|
|
|
|
/// Returns the bin delta of the last computed field.
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Float64 GetBinDelta() const { return this->BinDelta; }
|
|
|
|
|
|
|
|
/// Returns the range used for most recent execute. If `SetRange` is used to
|
|
|
|
/// specify and non-empty range, then this will be same as the range after
|
|
|
|
/// the `Execute` call.
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Range GetComputedRange() const { return this->ComputedRange; }
|
|
|
|
|
2022-09-26 16:23:26 +00:00
|
|
|
protected:
|
|
|
|
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
|
|
|
|
VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions(
|
|
|
|
const vtkm::cont::PartitionedDataSet& input) override;
|
2018-04-11 00:11:32 +00:00
|
|
|
|
2022-09-09 02:29:48 +00:00
|
|
|
///@{
|
2019-09-02 14:38:47 +00:00
|
|
|
/// when operating on vtkm::cont::PartitionedDataSet, we
|
2018-04-11 00:11:32 +00:00
|
|
|
/// want to do processing across ranks as well. Just adding pre/post handles
|
|
|
|
/// for the same does the trick.
|
2022-09-26 16:23:26 +00:00
|
|
|
VTKM_CONT void PreExecute(const vtkm::cont::PartitionedDataSet& input);
|
2019-09-02 14:38:47 +00:00
|
|
|
VTKM_CONT void PostExecute(const vtkm::cont::PartitionedDataSet& input,
|
2022-09-26 16:23:26 +00:00
|
|
|
vtkm::cont::PartitionedDataSet& output);
|
2022-09-09 02:29:48 +00:00
|
|
|
///@}
|
2018-04-11 00:11:32 +00:00
|
|
|
|
|
|
|
private:
|
2022-09-26 16:23:26 +00:00
|
|
|
vtkm::Id NumberOfBins = 10;
|
|
|
|
vtkm::Float64 BinDelta = 0;
|
2018-04-11 00:11:32 +00:00
|
|
|
vtkm::Range ComputedRange;
|
|
|
|
vtkm::Range Range;
|
2022-09-26 16:23:26 +00:00
|
|
|
bool InExecutePartitions = false;
|
2018-04-11 00:11:32 +00:00
|
|
|
};
|
|
|
|
} // namespace example
|
|
|
|
|
|
|
|
#endif // vtk_m_filter_Histogram_h
|