Overture  Version 25
GridDistribution.h
Go to the documentation of this file.
1 #ifndef GRID_DISTRIBUTION_H
2 #define GRID_DISTRIBUTION_H
3 
4 // **********************************************************************
5 // This class defines a parallel distribution for Overture Grids
6 // **********************************************************************
7 
8 #include "GenericDataBase.h"
9 #include "OvertureTypes.h"
10 
11 #ifndef OV_USE_OLD_STL_HEADERS
12 #include <list>
13 #include <vector>
14 #else
15 #include <list.h>
16 #include <vector>
17 #endif
18 
20 // This class holds information about the parallel distribution and the work-loads on a grid
21 {
22  public:
23 
24  GridDistribution(int grid=0, real workLoad=0., int level=0 );
25 
29 
30 
31  int getGrid() const;
32  int getProcessorRange( int & pStart, int & pEnd) const;
33  int getRefinementLevel() const;
34  real getWorkLoad() const;
35  int getGridPoints( int gridPoints[3] ) const;
36 
37  int setGrid( int grid );
38  int setGridAndRefinementLevel( int grid, int level );
39  int setProcessors(int pStart, int pEnd);
40  int setRefinementLevel( int level );
41 
42  int setGridPoints( int gridPoints[3] );
43  int setWorkLoadAndGridPoints( real workLoad, int gridPoints[3] );
44 
45  // For sorting by work-load:
46  bool operator< ( const GridDistribution & x )const{ return workLoad<x.workLoad; }
47 
48  // --- The following functions are not normally called by the casual user: ---
49 
50  int determineAGoodNumberOfProcessors( int & numProc, const int minProc, const int maxProc );
51 
52  // determine the processor decomposition for a multidimensional distributed array
53  void computeParallelArrayDistribution(int *dimProc );
54 
55  // utility routine:
56  static void computeParallelArrayDistribution( const int nProcs, const int nDims, int *dimVec, int *dimProc );
57 
58  // return the desired minimum number of points per dimension on each processor
59  static int getMinimumNumberOfPointsPerDimensionPerProcessor(int numberOfDimensions);
60  static int setMinimumNumberOfPointsPerDimensionPerProcessor(int numberOfDimensions, int minNumber );
61 
62  virtual int get( const GenericDataBase & dir, const aString & name); // get from a database file
63  virtual int put( GenericDataBase & dir, const aString & name) const; // put to a database file
64 
65 
66  static int minNumberPerDimension[3]; // holds minimum number of points per dimension on each processor
67 
68  protected:
69 
70  int pStart, pEnd; // range of processors over which we distribute a grid
71  int grid; // grid number in the GridCollection
72  real workLoad; // estimated work load for this grid
73  int refinementLevel; // refinement level for this grid
74  int dims[3]; // grid dimensions in the 3 coordinate directions
75 };
76 
77 // typedef std::vector<GridDistribution> GridDistributionList;
78 
79 class GridDistributionList : public std::vector<GridDistribution>
80 {
81  public:
84 
86 
88 
89  // display the grid distribution info:
90  int display( const aString & label, FILE *file=stdout );
91 
92  virtual int get( const GenericDataBase & dir, const aString & name); // get from a database file
93  virtual int put( GenericDataBase & dir, const aString & name) const; // put to a database file
94 
95 };
96 
97 
98 #endif