Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProbeMon.H
Go to the documentation of this file.
1 #ifndef _IR_PLOT_UTILS_H_
2 #define _IR_PLOT_UTILS_H_
3 #include <iostream>
4 #include <vector>
5 #include <string>
6 #include <sstream>
7 #include <fstream>
8 #include <cassert>
9 #include <cstdlib>
10 #include <cstdio>
11 
12 namespace IR {
13  class flowprobe : public std::vector<std::vector<double> >
14  {
15  public:
18  {
19  this->resize(NPROBEDATA);
20  };
21  flowprobe(const flowprobe &inFlowProbe)
22  {
23  this->resize(NPROBEDATA);
24  (*this)[TIME] = inFlowProbe[TIME];
25  (*this)[RHO] = inFlowProbe[RHO];
26  (*this)[U] = inFlowProbe[U];
27  (*this)[V] = inFlowProbe[V];
28  (*this)[W] = inFlowProbe[W];
29  (*this)[P] = inFlowProbe[P];
30  (*this)[T] = inFlowProbe[T];
31  };
32  void Clear()
33  {
34  this->resize(0);
35  this->resize(NPROBEDATA);
36  };
37  unsigned int ReadProbeData(std::istream &inStream)
38  {
39  Clear();
40  std::string probeLine;
41  while(std::getline(inStream,probeLine)){
42  if(probeLine[0] == '#')
43  continue;
44  std::istringstream Instr(probeLine);
45  double time = 0;
46  double rho = 0;
47  double rhou = 0;
48  double rhov = 0;
49  double rhow = 0;
50  double press = 0;
51  double temp = 0;
52  Instr >> time >> rho >> rhou >> rhov >> rhow >> press >> temp;
53  (*this)[TIME].push_back(time);
54  (*this)[RHO].push_back(rho);
55  (*this)[U].push_back(rhou/rho);
56  (*this)[V].push_back(rhov/rho);
57  (*this)[W].push_back(rhow/rho);
58  (*this)[P].push_back(press);
59  (*this)[T].push_back(temp);
60  }
61  return((*this)[TIME].size());
62  };
63  void WriteData(std::ostream &outStream,bool writeLoc = false)
64  {
65  unsigned int nTimes = (*this)[TIME].size();
66  for(unsigned int i = 0;i < nTimes;i++){
67  if(writeLoc){
68  outStream << locX << " " << locY << " " << locZ << " ";
69  }
70  for(unsigned int j = 0;j < NPROBEDATA;j++){
71  outStream << (*this)[j][i] << " ";
72  }
73  outStream << std::endl;
74  }
75  };
76  void SetLocation(double xLoc,double yLoc,double zLoc)
77  {
78  locX = xLoc;
79  locY = yLoc;
80  locZ = zLoc;
81  };
82  protected:
83  double locX;
84  double locY;
85  double locZ;
86  };
87  class derivedprobe : public std::vector<std::vector<double> >
88  {
89 
90  };
91  inline int GNUPlot(const std::string &commands)
92  {
93  FILE *fp = popen("gnuplot -persist","w");
94  fprintf(fp,commands.c_str());
95  pclose(fp);
96  return(0);
97  }
98 }
99 #endif
void WriteData(std::ostream &outStream, bool writeLoc=false)
Definition: ProbeMon.H:63
double locX
Definition: ProbeMon.H:81
double locY
Definition: ProbeMon.H:84
int GNUPlot(const std::string &commands)
Definition: ProbeMon.H:91
flowprobe(const flowprobe &inFlowProbe)
Definition: ProbeMon.H:21
void SetLocation(double xLoc, double yLoc, double zLoc)
Definition: ProbeMon.H:76
blockLoc i
Definition: read.cpp:79
unsigned int ReadProbeData(std::istream &inStream)
Definition: ProbeMon.H:37
void Clear()
Definition: ProbeMon.H:32
j indices j
Definition: Indexing.h:6
unsigned long time()
Get the value of a system timer with a millisecond precision.
Definition: CImg.h:4605
double locZ
Definition: ProbeMon.H:85