rsvs3D  0.0.0
Codes for the c++ implementation of the 3D RSVS
postprocessing.hpp
Go to the documentation of this file.
1 
7 //===============================================
8 // Include Guards
9 #ifndef POSTPROCESSING_H_INCLUDED
10 #define POSTPROCESSING_H_INCLUDED
11 
12 //===============================================
13 // Levels of debuging Guards
14 #ifdef DEBUGLVL2 // All Debugging calls
15 #define DEBUGLVL1
16 
17 #endif
18 
19 #ifdef DEBUGLVL1 // Debugging of new features.
20 #define TEST_POSTPROCESSING
21 #endif
22 
23 //=================================
24 // forward declared dependencies
25 // class foo; //when you only need a pointer not the actual object
26 // and to avoid circular dependencies
27 
28 class mesh;
29 class snake;
30 class RSVScalc;
31 class triangulation;
32 class trisurfarray;
33 class triarray;
34 
35 //=================================
36 // included dependencies
37 #include <stdarg.h>
38 
39 #include <iostream>
40 
41 #include "arraystructures.hpp"
42 
43 //==================================
44 // Code
45 // NOTE: function in a class definition are IMPLICITELY INLINED
46 // ie replaced by their code at compile time
47 
48 namespace rsvs3d
49 {
50 namespace constants
51 {
52 namespace tecplot
53 {
54 static const int autoselect = 0;
55 static const int polyhedron = 1;
56 static const int polygon = 2;
57 static const int line = 3;
58 static const int point = 4;
59 
60 static const int nosharedzone = -1;
61 static const auto __issharedzone = [](int z) -> bool { return z > 0; };
62 namespace snakedata
63 {
64 static const std::string snaxel = "snaxel";
65 static const std::string normal = "normal";
66 static const std::string laplacian = "laplacian";
67 static const std::string direction = "direction";
68 static const std::string __default = snaxel;
69 } // namespace snakedata
70 } // namespace tecplot
71 } // namespace constants
72 } // namespace rsvs3d
73 
74 // Base classes
75 
77 {
78  private:
79  HashedVector<int, int> strands;
80  FILE *fid = nullptr;
81  int lengthLine;
82  int nZones = 0;
83  bool isloud;
84 
85  public:
86  bool isStrand(int strandID)
87  {
88  return rsvs3d::logicals::__isfound(this->strands.find(strandID));
89  }
90  int OpenFile(const char *str, const char *mode = "w");
91  bool isOpen()
92  {
93  return this->fid != nullptr;
94  }
95  void CloseFile();
96  int ZoneNum() const
97  {
98  return (nZones);
99  }
100  // Mesh out
101  int PrintMesh(const mesh &meshout, int strandID = 0, double timeStep = 0,
102  int forceOutType = rsvs3d::constants::tecplot::autoselect, const std::vector<int> &vertList = {});
103  int PrintSnakeInternalPts(const snake &snakein, int strandID = 0, double timeStep = 0);
104  int VolDataBlock(const mesh &meshout, int nVert, int nVolu, int nVertDat, const std::vector<int> &voluList = {},
105  const std::vector<int> &vertList = {});
106  int SurfDataBlock(const mesh &meshout, int nVert, int nSurf, int nVertDat);
107  int LineDataBlock(const mesh &meshout, int nVert, int nEdge, int nVertDat, int nCellDat);
108  int VertDataBlock(const mesh &meshout, int nVert, int nVertDat, int nCellDat,
109  const std::vector<int> &vertList = {});
110  int VolFaceMap(const mesh &meshout, int nSurf);
111  int VolFaceMap(const mesh &meshout, const std::vector<int> &surfList, const std::vector<int> &voluList,
112  const std::vector<int> &vertList);
113  int SurfFaceMap(const mesh &meshout, int nEdge);
114  int LineFaceMap(const mesh &meshout, int nEdge);
115  // Partial Mesh Out with variable sharing
116  int PrintVolumeDat(const mesh &meshout, int shareZone, int strandID, double timeStep);
117  int DefShareZoneVolume(int shareZone, int nVertDat);
118 
119  // Triangulation out
120  int VolDataBlock(const triangulation &triout, triarray triangulation::*mp, int nVert, int nVolu, int nVertDat);
121  int SurfDataBlock(const triangulation &triout, triarray triangulation::*mp, int nVert, int nSurf, int nVertDat);
122  int LineDataBlock(const triangulation &triout, triarray triangulation::*mp, int nVert, int nEdge, int nVertDat,
123  int nCellDat);
124  int LineDataBlock(const triangulation &triout, triarray triangulation::*mp, int nVert, int nEdge, int nVertDat,
125  int nCellDat, const std::vector<int> &triList);
126  int SurfFaceMap(const triangulation &triout, triarray triangulation::*mp);
127  int LineFaceMap(const triangulation &triout, triarray triangulation::*mp);
128  int LineFaceMap(const std::vector<int> &triList);
129  int VolFaceMap(const triangulation &triout, triarray triangulation::*mp, int nSurf);
130  int PrintTriangulation(const triangulation &triout, triarray triangulation::*mp, int strandID = 0,
131  double timeStep = 0, int forceOutType = rsvs3d::constants::tecplot::autoselect,
132  const std::vector<int> &triList = {});
133 
134  // Triangulation surface array out
135  int VolDataBlock(const triangulation &triout, trisurfarray triangulation::*mp, int nVert, int nVolu, int nVertDat);
136  int SurfDataBlock(const triangulation &triout, trisurfarray triangulation::*mp, int nVert, int nSurf, int nVertDat);
137  int LineDataBlock(const triangulation &triout, trisurfarray triangulation::*mp, int nVert, int nEdge, int nVertDat,
138  int nCellDat);
139  int SurfFaceMap(const triangulation &triout, trisurfarray triangulation::*mp);
140  int LineFaceMap(const triangulation &triout, trisurfarray triangulation::*mp);
141  int VolFaceMap(const triangulation &triout, trisurfarray triangulation::*mp, int nSurf);
142  int PrintTriangulation(const triangulation &triout, trisurfarray triangulation::*mp, int strandID = 0,
143  double timeStep = 0, int forceOutType = rsvs3d::constants::tecplot::autoselect);
144 
145  // Snake specific functions
146  int SnakeDataBlock(const snake &snakeout, int nVert, int nVertDat,
147  std::string = rsvs3d::constants::tecplot::snakedata::__default, bool printCoord = true);
148  int PrintSnake(const snake &snakeout, int strandID = 0, double timeStep = 0,
149  int forceOutType = rsvs3d::constants::tecplot::autoselect, const std::vector<int> &vertList = {});
150  int PrintSnake(std::string snakeData, const snake &snakeout, int strandID = 0, double timeStep = 0,
151  int forceOutType = rsvs3d::constants::tecplot::autoselect,
152  int coordConnShareZone = rsvs3d::constants::tecplot::nosharedzone,
153  const std::vector<int> &vertList = {});
154  // Zone Headers
155  void ZoneHeaderPolyhedron(int nVert, int nVolu, int nSurf, int totNumFaceNode, int nVertDat, int nCellDat);
156  void ZoneHeaderPolygon(int nVert, int nEdge, int nSurf, int nVertDat, int nCellDat);
157  void ZoneHeaderFelineseg(int nVert, int nEdge, int nVertDat, int nCellDat);
158  void ZoneHeaderOrdered(int nVert, int nVertDat, int nCellDat, int nSensDat = 0);
159 
160  void ZoneHeaderPolyhedronSnake(int nVert, int nVolu, int nSurf, int totNumFaceNode, int nVertDat, int nCellDat,
161  int nSensDat = 0);
162  void ZoneHeaderPolygonSnake(int nVert, int nEdge, int nSurf, int nVertDat, int nCellDat, int nSensDat = 0);
163  void ZoneHeaderFelinesegSnake(int nVert, int nEdge, int nVertDat, int nCellDat, int nSensDat = 0);
164 
165  // Snake sensitivity
166  int PrintSnakeSensitivity(const triangulation &triRSVS, const RSVScalc &calcObj, int strandID = 0,
167  double timeStep = 0, int forceOutType = rsvs3d::constants::tecplot::autoselect,
168  const std::vector<int> &vertList = {});
169  int RSVScalcDataBlock(const triangulation &triRSVS, const RSVScalc &calcObj, int nVert, int nSensDat,
170  int sensStart = 0, int methodProcess = 1);
171  int RSVScalcVectorDataBlock(const triangulation &triRSVS, const RSVScalc &calcObj, int nVert, int numConstrPlot = 0,
172  int methodProcess = 1);
173  int PrintSnakeSensitivityTime(const triangulation &triRSVS, const RSVScalc &calcObj, int strandID = 0,
174  double timeStep = 0, int forceOutType = rsvs3d::constants::tecplot::autoselect,
175  const std::vector<int> &vertList = {});
176  int PrintSnakeSensitivityVector(const triangulation &triRSVS, const RSVScalc &calcObj, int strandID = 0,
177  double timeStep = 0, int forceOutType = rsvs3d::constants::tecplot::autoselect,
178  const std::vector<int> &vertList = {});
179  int PrintSnakeGradients(const triangulation &triRSVS, const RSVScalc &calcObj, int strandID = 0,
180  double timeStep = 0, int forceOutType = rsvs3d::constants::tecplot::autoselect,
181  const std::vector<int> &vertList = {});
182 
183  tecplotfile()
184  {
185  this->fid = NULL;
186  this->lengthLine = 0;
187  this->isloud = false;
188  }
189  tecplotfile(bool isloudIn)
190  {
191  fid = NULL;
192  lengthLine = 0;
193  this->isloud = isloudIn;
194  if (this->isloud)
195  {
196  std::cout << "tecplot file object created" << std::endl;
197  }
198  }
199  ~tecplotfile()
200  {
201  if (fid != NULL)
202  {
203  this->CloseFile();
204  if (this->isloud)
205  {
206  std::cout << "Object deleted - File Closed" << std::endl;
207  }
208  }
209  else
210  {
211  if (this->isloud)
212  {
213  std::cout << "Object deleted - No File Closed" << std::endl;
214  }
215  }
216  }
217 
218  void NewZone()
219  {
220  this->Print("ZONE\n");
221  nZones++;
222  }
223  void StrandTime(int strandID, double timeStep)
224  {
225  this->Print("STRANDID = %i \nSOLUTIONTIME = %.10lf \n", strandID, timeStep);
226  if (!rsvs3d::logicals::__isfound(this->strands.find(strandID)))
227  {
228  this->strands.push_back(strandID);
229  }
230  }
231 
232  int Print(const char *format, ...)
233  { // Mimics the printf function hides fid
234  if (!this->isOpen())
235  {
236  return 0;
237  }
238  va_list arg;
239  int i;
240 
241  va_start(arg, format);
242  i = vfprintf(fid, format, arg);
243  va_end(arg);
244  lengthLine += i;
245  if (lengthLine > 25000)
246  {
247  fprintf(fid, " \n");
248  lengthLine = 0;
249  }
250  return (lengthLine);
251  }
252  void ResetLine()
253  {
254  lengthLine = 0;
255  }
256  void NewLine()
257  {
258  this->Print("\n");
259  this->ResetLine();
260  };
261 };
262 
263 // Derived Classes
264 
265 // functions
266 
267 namespace dataoutput
268 {
269 void Coord(tecplotfile &tecout, const mesh &meshout, int nVert, int nVertDat);
270 void Snaxel(tecplotfile &tecout, const snake &snakeout, int nVert);
271 void VertexNormal(tecplotfile &tecout, const mesh &meshin, int nVert);
272 void VertexLaplacian(tecplotfile &tecout, const mesh &meshin, int nVert);
273 } // namespace dataoutput
274 
275 int Test_tecplotfile();
276 int TestCompareReadWrite(const char *fileToOpen, mesh &blockGrid, tecplotfile &outmesh1);
277 // member function definition template <class T>
278 
279 #endif // POSTPROCESSING_H_INCLUDED
Provide std::vector container with hashed index mapping.
Class to handle the RSVS calculation.
Definition: RSVScalc.hpp:130
Class for mesh handling.
Definition: mesh.hpp:592
Definition: snake.hpp:83
std::tuple< coordvec, double > VertexNormal(const std::vector< double > &centre, const grid::coordlist &vecPts)
Calculates the vertex normal weighted by surface angle partitions.
Definition: mesh.cpp:747
Namespace for general purpose tools of the RSVS project.
Definition: snake.cpp:1464