SENSEI
A frame work for generic in situ analytics
Histogram.h
1 #ifndef Histogram_h
2 #define Histogram_h
3 
4 #include "senseiConfig.h"
5 #include "AnalysisAdaptor.h"
6 #include <mpi.h>
7 #include <vector>
8 
9 class svtkDataObject;
10 class svtkDataArray;
11 
12 namespace sensei
13 {
14 
15 /// Computes a histogram in parallel.
16 class SENSEI_EXPORT Histogram : public AnalysisAdaptor
17 {
18 public:
19  /// allocates a new instance
20  static Histogram* New();
21 
22  senseiTypeMacro(Histogram, AnalysisAdaptor);
23 
24  /// initialize for the run
25  void Initialize(int bins, const std::string &meshName,
26  int association, const std::string& arrayName,
27  const std::string &fileName);
28 
29  /// compute the histogram for this time step
30  bool Execute(DataAdaptor* data, DataAdaptor**) override;
31 
32  /// finalize the run
33  int Finalize() override;
34 
35  /// the computed histogram may be accessed through the following data structure.
36  struct Data
37  {
38  Data() : NumberOfBins(1), BinMin(1.0), BinMax(0.0), BinWidth(1.0), Histogram() {}
39 
40  int NumberOfBins; ///< The number of bins in the histogram
41  double BinMin; ///< The left most bin edge
42  double BinMax; ///< The right most bin edge
43  double BinWidth; ///< The width of the equally spaced bins
44  std::vector<unsigned int> Histogram; ///< The counts of each bin
45  };
46 
47  /// return the histogram computed by the most recent call to Execute
48  int GetHistogram(Histogram::Data &data);
49 
50 protected:
51  Histogram();
52  ~Histogram();
53 
54  Histogram(const Histogram&) = delete;
55  void operator=(const Histogram&) = delete;
56 
57  static const char *GetGhostArrayName();
58  svtkDataArray* GetArray(svtkDataObject* dobj, const std::string& arrayname);
59 
60  int NumberOfBins;
61  std::string MeshName;
62  std::string ArrayName;
63  int Association;
64  std::string FileName;
65  Histogram::Data LastResult;
66 };
67 
68 }
69 
70 #endif
int Initialize(MPI_Comm comm, const std::string &fileName, InTransitDataAdaptor *&dataAdaptor)
Creates a sensei::ConfigurableAnalysis adaptor and sensei::InTransitDataAdaptor based on a SENSEI XML...
double BinMin
The left most bin edge.
Definition: Histogram.h:41
The base class for data consumers.
Definition: AnalysisAdaptor.h:24
double BinWidth
The width of the equally spaced bins.
Definition: Histogram.h:43
int NumberOfBins
The number of bins in the histogram.
Definition: Histogram.h:40
the computed histogram may be accessed through the following data structure.
Definition: Histogram.h:36
Definition: Histogram.py:1
double BinMax
The right most bin edge.
Definition: Histogram.h:42
SENSEI.
Definition: ADIOS2AnalysisAdaptor.h:27
Base class that defines the interface for fetching data from a simulation.
Definition: DataAdaptor.h:25
std::vector< unsigned int > Histogram
The counts of each bin.
Definition: Histogram.h:44