Block-Structured AMR Software Framework
AMReX_DataServices.H
Go to the documentation of this file.
1 // ---------------------------------------------------------------
2 // DataServices.H
3 // ---------------------------------------------------------------
4 #ifndef AMREX_DATASERVICES_H_
5 #define AMREX_DATASERVICES_H_
6 #include <AMReX_Config.H>
7 
8 #include <AMReX_Array.H>
9 #include <AMReX_Vector.H>
10 #include <AMReX_AmrData.H>
11 
12 #ifdef BL_USE_PROFPARSER
13 #include <AMReX_BLProfUtilities.H>
14 #include <AMReX_BLProfStats.H>
15 //#include <BLProfParser.tab.H>
16 #include <AMReX_CommProfStats.H>
17 #include <AMReX_RegionsProfStats.H>
18 #include <map>
19 #endif
20 
21 #include <cstdarg>
22 #include <string>
23 
24 namespace amrex {
25 
26 class XYPlotDataList;
27 
28 class DataServices {
29 
30  public:
31 
49 #ifdef BL_USE_PROFPARSER
50  InitTimeRanges,
51  WriteSummaryRequest,
52  CheckProfDataRequest,
53  RunStatsRequest,
54  RunSendsPFRequest,
55  RunTimelinePFRequest,
56  MakeRegionPltRequest,
57  MakeFilterFileRequest,
58 #endif
59  };
60 
61  DataServices(const std::string &filename, const Amrvis::FileType &filetype);
62  DataServices();
63  ~DataServices();
64 
65  void Init(const std::string &filename, const Amrvis::FileType &filetype);
66  void InitRegionTimeRanges();
67 
68  static void SetBatchMode();
69  static void Dispatch(DSRequestType requestType, DataServices *ds, ...);
70 
71  static void SetFabOutSize(int iSize);
72 
73  private:
74 
75  // Dispatchable functions
76 
78  bool FillVar(FArrayBox *destFab, const Box &destBox,
79  int finestFillLevel, const std::string &varname,
80  int procWithFab);
81 
82  // FillVarArrayOfFabs
83  //bool FillVar(Vector<FArrayBox *> &destFabs, const Vector<Box> &destBoxes,
84  //int finestFillLevel, const std::string &varname,
85  //int procWithFab);
86 
88  bool FillVar(MultiFab &destMultiFab, int finestFillLevel,
89  const std::string &varname);
90 
92  bool WriteFab(const std::string &fabfilename, const Box &region, int lev,
93  const std::string &varname);
94 
96  bool WriteFab(const std::string &fabfilename, const Box &region, int lev);
97 
99  bool DumpSlice(int slicedir, int slicenum, const std::string &varname);
100 
102  bool DumpSlice(int slicedir, int slicenum);
103 
105  bool DumpSlice(const Box &slicebox, const std::string &varname);
106 
108  bool DumpSlice(const Box &slicebox);
109 
111  bool MinMax(const Box &onBox, const std::string &derived, int level,
112  Real &dataMin, Real &dataMax, bool &minMaxValid);
113 
115  void PointValue(int pointBoxArraySize, Box *pointBoxArray,
116  const std::string &currentDerived,
117  int coarsestLevelToSearch, int finestLevelToSearch,
118  int &intersectedLevel, Box &intersectedGrid,
119  Real &dataPointValue, bool &bPointIsValid);
120 
122  void LineValues(int lineBoxArraySize, Box *lineBoxArray, int whichDir,
123  const std::string &currentDerived,
124  int coarsestLevelToSearch, int finestLevelToSearch,
125  XYPlotDataList *dataList, bool &lineIsValid);
126 
127  public:
128 
129  // information functions
130  const std::string &GetFileName() const { return fileName; }
132  bool CanDerive(const std::string &name) const;
133  bool CanDerive(const Vector<std::string> &names) const;
134  int NumDeriveFunc() const;
135  void ListDeriveFunc(std::ostream &os) const;
137  AmrData &AmrDataRef() { return amrData; }
138  bool AmrDataOk() { return bAmrDataOk; }
139  void SetWriteToLevel(const int iwtlev) { iWriteToLevel = iwtlev; }
140 
141  // other functions
142  int GetNumberOfUsers() const { return numberOfUsers; }
145 
146  // profiling functions
147 #ifdef BL_USE_PROFPARSER
148  bool ProfDataAvailable() const { return bProfDataAvailable; }
149  bool RegionDataAvailable() const { return bRegionDataAvailable; }
150  bool TraceDataAvailable() const { return bTraceDataAvailable; }
151  bool CommDataAvailable() const { return bCommDataAvailable; }
152 
153  BLProfStats &GetBLProfStats() { return blProfStats_H; }
154  RegionsProfStats &GetRegionsProfStats() { return regOutputStats_H; }
155  CommProfStats &GetCommOutputStats() { return commOutputStats_H; }
156  const amrex::BoxArray &ProcBoxArray() const { return procBoxArray; }
157 
158  void CheckProfData();
159 
160  void RunStats(std::map<int, std::string> &mpiFuncNames,
161  bool &statsCollected);
162 
163  void RunSendsPF(std::string &plotfileName,
164  int maxSmallImageLength,
165  bool proxMap,
166  int refRatioAll);
167 
168  void RunTimelinePF(std::map<int, std::string> &mpiFuncNames,
169  std::string &plotfileName,
170  BLProfStats::TimeRange& subTimeRange,
171  int maxSmallImageLength,
172  int refRatioAll,
173  int nTimeSlots,
174  bool &statsCollected);
175 
176  void RunACTPF(std::string &plotfileName,
177  int maxSmallImageLength,
178  int refRatioAll,
179  const amrex::Vector<std::string> &actFNames);
180 
181  void RunSyncPointData();
182  void RunSendRecvList();
183  void RunSendRecv();
184 
185  BLProfStats::TimeRange FindCalcTimeRange();
186  void MakeRegionPlt(std::string &plotfileName);
187  void MakeFilterFile(std::string &fFileName);
188 
189  void ProcessGridLog(const std::string &gridlogFileName);
190  void ParseFilterFile();
191 
192  void PrintCommStats(std::ostream &os, bool printHeaderNames);
193  void WriteSummary(std::ostream &os, bool bWriteAverage, int whichProc,
194  bool bUseTrace, bool graphTopPct);
195  void InitProxMap();
196  void TCEdison();
197  void WriteHTML(const std::string &fFileName, bool simpleCombine, int whichProc);
198  void WriteHTMLNC(const std::string &fFileName, int whichProc);
199  void WriteTextTrace(const std::string &fFileName, bool simpleCombine = true,
200  int whichProc = 0, std::string delimString = "\t");
201 #endif
202 
203  private:
204  std::string fileName;
211 
214  static int dsFabOutSize;
215  static bool dsBatchMode;
216  static bool profiler;
217 #ifdef BL_USE_PROFPARSER
218  bool bProfDataAvailable;
219  bool bRegionDataAvailable;
220  bool bTraceDataAvailable;
221  bool bCommDataAvailable;
222 
223  BLProfStats blProfStats_H;
224  RegionsProfStats regOutputStats_H;
225  CommProfStats commOutputStats_H;
226 
227  amrex::BoxArray procBoxArray;
228 #endif
229 };
230 
231 }
232 
233 #endif
Definition: AMReX_BLProfStats.H:30
Definition: AMReX_CommProfStats.H:38
Definition: AMReX_RegionsProfStats.H:38
Definition: AMReX_AmrData.H:19
const Vector< std::string > & PlotVarNames() const
Definition: AMReX_AmrData.H:60
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
Definition: AMReX_DataServices.H:28
static void SetBatchMode()
Definition: AMReX_DataServices.cpp:387
void Init(const std::string &filename, const Amrvis::FileType &filetype)
Definition: AMReX_DataServices.cpp:148
Amrvis::FileType GetFileType() const
Definition: AMReX_DataServices.H:131
const Vector< std::string > & PlotVarNames() const
Definition: AMReX_DataServices.H:136
bool AmrDataOk()
Definition: AMReX_DataServices.H:138
bool DumpSlice(int slicedir, int slicenum, const std::string &varname)
DumpSlicePlaneOneVar.
Definition: AMReX_DataServices.cpp:1181
AmrData & AmrDataRef()
Definition: AMReX_DataServices.H:137
const std::string & GetFileName() const
Definition: AMReX_DataServices.H:130
void IncrementNumberOfUsers()
Definition: AMReX_DataServices.H:143
std::string fileName
Definition: AMReX_DataServices.H:204
static int dsArrayIndexCounter
Definition: AMReX_DataServices.H:213
DSRequestType
Definition: AMReX_DataServices.H:32
@ NewRequest
Definition: AMReX_DataServices.H:35
@ FillVarOneFab
Definition: AMReX_DataServices.H:37
@ FillVarArrayOfFabs
Definition: AMReX_DataServices.H:38
@ DumpSlicePlaneAllVars
Definition: AMReX_DataServices.H:43
@ WriteFabOneVar
Definition: AMReX_DataServices.H:40
@ DumpSlicePlaneOneVar
Definition: AMReX_DataServices.H:42
@ FillVarMultiFab
Definition: AMReX_DataServices.H:39
@ WriteFabAllVars
Definition: AMReX_DataServices.H:41
@ MinMaxRequest
Definition: AMReX_DataServices.H:46
@ InvalidRequestType
Definition: AMReX_DataServices.H:33
@ LineValuesRequest
Definition: AMReX_DataServices.H:48
@ DeleteRequest
Definition: AMReX_DataServices.H:36
@ ExitRequest
Definition: AMReX_DataServices.H:34
@ DumpSliceBoxOneVar
Definition: AMReX_DataServices.H:44
@ PointValueRequest
Definition: AMReX_DataServices.H:47
@ DumpSliceBoxAllVars
Definition: AMReX_DataServices.H:45
int iWriteToLevel
Definition: AMReX_DataServices.H:210
static void Dispatch(DSRequestType requestType, DataServices *ds,...)
Definition: AMReX_DataServices.cpp:408
void InitRegionTimeRanges()
Definition: AMReX_DataServices.cpp:323
AmrData amrData
Definition: AMReX_DataServices.H:206
int GetNumberOfUsers() const
Definition: AMReX_DataServices.H:142
void PointValue(int pointBoxArraySize, Box *pointBoxArray, const std::string &currentDerived, int coarsestLevelToSearch, int finestLevelToSearch, int &intersectedLevel, Box &intersectedGrid, Real &dataPointValue, bool &bPointIsValid)
PointValueRequest.
Definition: AMReX_DataServices.cpp:1589
~DataServices()
Definition: AMReX_DataServices.cpp:378
int numberOfUsers
Definition: AMReX_DataServices.H:209
bool MinMax(const Box &onBox, const std::string &derived, int level, Real &dataMin, Real &dataMax, bool &minMaxValid)
MinMaxRequest.
Definition: AMReX_DataServices.cpp:1676
static Vector< DataServices * > dsArray
Definition: AMReX_DataServices.H:212
bool FillVar(FArrayBox *destFab, const Box &destBox, int finestFillLevel, const std::string &varname, int procWithFab)
FillVarOneFab.
Definition: AMReX_DataServices.cpp:1405
static bool profiler
Definition: AMReX_DataServices.H:216
int dsArrayIndex
Definition: AMReX_DataServices.H:208
void LineValues(int lineBoxArraySize, Box *lineBoxArray, int whichDir, const std::string &currentDerived, int coarsestLevelToSearch, int finestLevelToSearch, XYPlotDataList *dataList, bool &lineIsValid)
LineValuesRequest.
Definition: AMReX_DataServices.cpp:1642
void DecrementNumberOfUsers()
Definition: AMReX_DataServices.H:144
Amrvis::FileType fileType
Definition: AMReX_DataServices.H:205
bool bAmrDataOk
Definition: AMReX_DataServices.H:207
static bool dsBatchMode
Definition: AMReX_DataServices.H:215
void ListDeriveFunc(std::ostream &os) const
Definition: AMReX_DataServices.cpp:1574
static void SetFabOutSize(int iSize)
Definition: AMReX_DataServices.cpp:393
int NumDeriveFunc() const
Definition: AMReX_DataServices.cpp:1583
bool CanDerive(const std::string &name) const
Definition: AMReX_DataServices.cpp:1555
DataServices()
Definition: AMReX_DataServices.cpp:140
static int dsFabOutSize
Definition: AMReX_DataServices.H:214
void SetWriteToLevel(const int iwtlev)
Definition: AMReX_DataServices.H:139
bool WriteFab(const std::string &fabfilename, const Box &region, int lev, const std::string &varname)
WriteFabOneVar: write a single variable to one fab.
Definition: AMReX_DataServices.cpp:1439
A Fortran Array of REALs.
Definition: AMReX_FArrayBox.H:229
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Definition: AMReX_XYPlotDataList.H:71
FileType
Definition: AMReX_AmrvisConstants.H:86
Definition: AMReX_Amr.cpp:49
Definition: AMReX_BLProfStats.H:79