Overture  Version 25
ShowFileReader.h
Go to the documentation of this file.
1 #ifndef SHOW_FILE_READER_H
2 #define SHOW_FILE_READER_H
3 
4 // -------------------------------------------------------------------
5 // This class can be used to access solutions from a show file.
6 //
7 // This class is used by plotStuff. It is also used by solvers to
8 // read in initial conditions from a show file.
9 // -------------------------------------------------------------------
10 
12 #include "CompositeGrid.h"
13 #include "HDF_DataBase.h"
15 #include "Ogshow.h"
16 #include "ShowFileParameter.h"
17 
18 #include OV_STD_INCLUDE(vector)
19 
21 {
22  public:
23 
25  {
30  };
31 
33  {
36  };
37 
38 
39  ShowFileReader(const aString & nameOfShowFile=nullString);
41 
42  int open(const aString & nameOfShowFile, const int displayInfo=1 );
43  int close();
44 
45  int getNumberOfFrameSeries() const;
46  aString getFrameSeriesName( const Ogshow::FrameSeriesID frame_series );
47  int getNumberOfFrames() const;
48  int getNumberOfSolutions() const;
49  int getNumberOfSequences() const;
50 
51  int setCurrentFrameSeries( const Ogshow::FrameSeriesID frame_series );
53 
55  int & solutionNumber,
56  int frameForGrid=useDefaultLocation);
57 
59  int & solutionNumber,
60  int frameForGrid=useDefaultLocation);
61 
62  ReturnType getASolution(int & solutionNumber,
63  MappedGrid & cg,
65 
66  ReturnType getASolution(int & solutionNumber,
67  GridCollection & cg,
69 
70  int getSequenceNames(aString *name, int maximumNumberOfNames);
71 
72  int getSequence(int sequenceNumber,
73  aString & name, RealArray & time, RealArray & value,
74  aString *componentName1, int maxcomponentName1,
75  aString *componentName2, int maxcomponentName2);
76 
77  // return a pointer to a frame (by default the current frame)
78  HDF_DataBase* getFrame(int solutionNumber=-1);
79 
80  bool isAMovingGrid();
81 
82  // get a parameter with a given name
83  bool getGeneralParameter(const aString & name, int & value,
85  bool getGeneralParameter(const aString & name, real & value,
87  bool getGeneralParameter(const aString & name, aString & value,
89 
90  // get a parameter with a given name and type
91  bool getGeneralParameter(const aString & name, ShowFileParameter::ParameterType type, int & value, real & rValue,
92  aString & stringValue,
94 
95  // Get parameters from a given directory in the current frame
96  bool getParameters(const aString & nameOfDirectory, ListOfShowFileParameters & params );
97 
98  // get header comments for the last grid or solution that was found
99  const aString* getHeaderComments(int & numberOfHeaderComments);
100 
101 
102 
103  // Get the list of parameters that go with this file.
104  int getGeneralParameters( const int displayInfo=1 );
105 
106  // Return the general parameters
109 
110  // For very large files we may have to reduce the number of files that we allow to be open at any time
111  void setMaximumNumberOfOpenShowFiles(const int maxNumber);
112 
113  private:
114  bool showFileIsOpen;
115  GenericDataBase **showFile;
116  std::vector<aString> frameSeriesNames;
117  enum SeriesItemEnum {
118  numFrames,
119  numSolutions,
120  numSequences,
121  isMovingGrid,
122  frameIDForGrid,
123  streamModeOption,
124  numItemsInSeries
125  };
126 
127  IntegerArray frameSeriesInfo;
128 
129  int numberOfFrames;
130  int numberOfSolutions;
131  int numberOfSequences;
132 
133  int numberOfShowFiles;
134  int numberOfOpenFiles;
135  int frameNumberForGrid;
136  int maximumNumberOfHeaderComments;
137  int numberOfHeaderComments; // for last solution/grid found
138 
139  int maxNumberOfShowFiles;
140  int maxNumberOfOpenFiles; // there is some limit like 30-40
141  aString *headerComment; // for last solution/grid found
142  aString nameOfShowFile;
143  bool movingGridProblem;
144 
145  int streamMode;
146 
147  Ogshow::FrameSeriesID currentFrameSeries;
148  HDF_DataBase currentFrameSeriesDB;
149  HDF_DataBase currentFrame;
150 
151 
152  std::vector<ListOfShowFileParameters> listOfGeneralParameters;
153 
154  int openShowFile(const int n);
155 
156  int getNumberOfValidFiles( const int displayInfo=1 );
157 
158  int countNumberOfFramesAndSolutions( const int displayInfo=1 );
159 
160  void checkSolutionNumber(const aString & routineName, int & solutionNumber );
161 
162 };
163 
164 
165 #endif
166 
167 
168 
169 
170 
171 
172 
173