pFlowToVTK.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #include "systemControl.hpp"
23 #include "pointFieldToVTK.hpp"
24 #include "triSurfaceFieldToVTK.hpp"
25 #include "timeFolder.hpp"
26 #include "commandLine.hpp"
27 #include "ranges.hpp"
28 #include "readControlDict.hpp"
29 
30 
31 using pFlow::word;
32 using pFlow::wordVector;
34 using pFlow::timeFolder;
35 using pFlow::fileSystem;
36 using pFlow::wordList;
38 using pFlow::objectFile;
39 using pFlow::output;
40 using pFlow::endl;
42 using pFlow::commandLine;
44 
45 int main(int argc, char** argv )
46 {
47  word outFolder = (pFlow::CWD()/word("VTK")).wordPath();
48 
49  commandLine cmds(
50  "pFlowToVTK",
51  "Convrtes the saved pointField and geometry"
52  " date in time folders into vtk file format.");
53 
54  wordVector times;
55 
56  bool noGoem = false;
57  cmds.add_flag(
58  "--no-geometry",
59  noGoem,
60  "Do not convert geometry to VTK file");
61 
62  bool noParticle = false;
63  cmds.add_flag("--no-particles",
64  noParticle,
65  "Do not convert particle fields to VTK file");
66 
67  cmds.addOption("-o,--out-folder",
68  outFolder,
69  "path to output folder of VTK",
70  "path");
71 
72  wordVector fields;
73  bool allFields = true;
74  cmds.addOption("-f,--fields",
75  fields.vectorField(),
76  "a space-separated list of fields names to be converted to VTK",
77  "word");
78 
79  cmds.addOption(
80  "-t,--time",
81  times.vectorField(),
82  "a space separated lists of time folders, or a strided range begin:stride:end, or an interval begin:end",
83  " ");
84 
85  bool isCoupling = false;
86 
87  if(!cmds.parse(argc, argv)) return 0;
88 
89 
90 // this should be palced in each main
91 #include "initialize_Control.hpp"
92 
93 
94  timeFolder folders(Control);
95  fileSystem destFolder = fileSystem(outFolder)/geometryFolder__;
96  fileSystem destFolderField = fileSystem(outFolder);
97  wordList geomfiles{"triSurface"};
98 
99 
100  if(cmds.count("--fields"))
101  {
102  allFields = false;
103  }
104 
105  realCombinedRange validRange;
106  if( cmds.count("--time") )
107  {
108  if(!validRange.addRanges(times))
109  {
110  fatalExit;
111  }
112  }
113  else
114  {
115  validRange.addIntervalRange(folders.startTime(), folders.endTime());
116  }
117 
118  do
119  {
120 
121  if( !validRange.isMember( folders.time() ) )continue;
122 
123  output<< "time: " << cyanText( folders.time() )<<" s" <<endl;
124  if(!noGoem)
125  {
126  fileSystem geomFolder = folders.folder()/geometryFolder__;
127  if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(geomFolder, folders.time(), destFolder, "surface"))
128  {
129  fatalExit;
130  return 1;
131  }
132  }
133 
134  if(!noParticle)
135  {
136 
137  if(allFields)
138  {
140  folders.folder(),
141  folders.time(),
142  destFolderField,
143  "sphereFields" )
144  )
145  {
146  fatalExit;
147  }
148  }else
149  {
151  folders.folder(),
152  folders.time(),
153  destFolderField,
154  "sphereFields",
155  fields,
156  !pFlow::equal(folders.time(),static_cast<pFlow::real>(0.0)) )
157  )
158  {
159  fatalExit;
160  }
161  }
162  }
163 
164  output<<endl;
165 
166  }
167  while( folders++ );
168 
169 
170  output<< "\nFinished successfully.\n";
171 
172 
173 // this should be palced in each main
174 #include "finalize.hpp"
175  return 0;
176 }
initialize_Control.hpp
pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected
bool convertTimeFolderPointFieldsSelected(fileSystem timeFolder, real time, fileSystem destPath, word bName, wordVector fieldsName, bool mustExist)
Definition: pointFieldToVTK.hpp:360
pFlow::timeFolder::time
real time() const
Definition: timeFolder.hpp:57
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
cyanText
#define cyanText(text)
Definition: streams.hpp:34
systemControl.hpp
pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields
bool convertTimeFolderTriSurfaceFields(fileSystem timeFolder, real time, fileSystem destPath, word bName)
Definition: triSurfaceFieldToVTK.hpp:180
pFlow::realCombinedRange
combinedRange< real > realCombinedRange
Definition: ranges.hpp:41
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pointFieldToVTK.hpp
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
main
int main(int argc, char **argv)
Definition: pFlowToVTK.cpp:45
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:33
pFlow::timeFolder::startTime
real startTime() const
Definition: timeFolder.hpp:105
pFlow::fileSystem
Definition: fileSystem.hpp:63
triSurfaceFieldToVTK.hpp
pFlow::geometryFolder__
const char * geometryFolder__
Definition: vocabs.hpp:33
pFlow::output
Ostream output
ranges.hpp
pFlow::objectFile
Definition: objectFile.hpp:33
pFlow::wordVector
Vector< word > wordVector
Definition: Vectors.hpp:64
pFlow::IOfileHeader
Definition: IOfileHeader.hpp:35
pFlow::CWD
fileSystem CWD()
Definition: fileSystem.hpp:186
pFlow::PFtoVTK::convertTimeFolderPointFields
bool convertTimeFolderPointFields(fileSystem timeFolder, real time, fileSystem destPath, word bName)
Definition: pointFieldToVTK.hpp:291
pFlow::timeFolder::endTime
real endTime() const
Definition: timeFolder.hpp:111
readControlDict.hpp
pFlow::equal
INLINE_FUNCTION_HD bool equal(const real &s1, const real &s2)
Definition: bTypesFunctions.hpp:188
Control
auto & Control
Definition: initialize_Control.hpp:47
pFlow::wordList
List< word > wordList
Definition: List.hpp:241
pFlow::timeFolder::folder
fileSystem folder() const
Definition: timeFolder.hpp:62
timeFolder.hpp
pFlow::timeFolder
Definition: timeFolder.hpp:32
finalize.hpp