# PhasicFlow: utilities/pFlowToVTK/pFlowToVTK.cpp Source File

pFlowToVTK.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#include "systemControl.hpp"
#include "pointFieldToVTK.hpp"
#include "triSurfaceFieldToVTK.hpp"
#include "timeFolder.hpp"
#include "commandLine.hpp"
#include "ranges.hpp"
#include "readControlDict.hpp"
using pFlow::word;
using pFlow::wordVector;
using pFlow::geometryFolder__;
using pFlow::timeFolder;
using pFlow::fileSystem;
using pFlow::wordList;
using pFlow::IOfileHeader;
using pFlow::objectFile;
using pFlow::output;
using pFlow::endl;
using pFlow::multiTriSurface;
using pFlow::commandLine;
using pFlow::realCombinedRange;
int main(int argc, char** argv )
{
word outFolder = (pFlow::CWD()/word("VTK")).wordPath();
commandLine cmds(
"pFlowToVTK",
"Convrtes the saved pointField and geometry"
" date in time folders into vtk file format.");
wordVector times;
bool noGoem = false;
cmds.add_flag(
"--no-geometry",
noGoem,
"Do not convert geometry to VTK file");
bool noParticle = false;
cmds.add_flag("--no-particles",
noParticle,
"Do not convert particle fields to VTK file");
cmds.addOption("-o,--out-folder",
outFolder,
"path to output folder of VTK",
"path");
wordVector fields;
bool allFields = true;
cmds.addOption("-f,--fields",
fields.vectorField(),
"a space-separated list of fields names to be converted to VTK",
"word");
cmds.addOption(
"-t,--time",
times.vectorField(),
"a space separated lists of time folders, or a strided range begin:stride:end, or an interval begin:end",
" ");
bool isCoupling = false;
if(!cmds.parse(argc, argv)) return 0;
// this should be palced in each main
#include "initialize_Control.hpp"
timeFolder folders(Control);
fileSystem destFolder = fileSystem(outFolder)/geometryFolder__;
fileSystem destFolderField = fileSystem(outFolder);
wordList geomfiles{"triSurface"};
if(cmds.count("--fields"))
{
allFields = false;
}
realCombinedRange validRange;
if( cmds.count("--time") )
{
if(!validRange.addRanges(times))
{
fatalExit;
}
}
else
{
validRange.addIntervalRange(folders.startTime(), folders.endTime());
}
do
{
if( !validRange.isMember( folders.time() ) )continue;
output<< "time: " << cyanText( folders.time() )<<" s" <<endl;
if(!noGoem)
{
fileSystem geomFolder = folders.folder()/geometryFolder__;
if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(geomFolder, folders.time(), destFolder, "surface"))
{
fatalExit;
return 1;
}
}
if(!noParticle)
{
if(allFields)
{
if( !pFlow::PFtoVTK::convertTimeFolderPointFields(
folders.folder(),
folders.time(),
destFolderField,
"sphereFields" )
)
{
fatalExit;
}
}else
{
if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
folders.folder(),
folders.time(),
destFolderField,
"sphereFields",
fields,
!pFlow::equal(folders.time(),static_cast< pFlow::real >(0.0)) )
)
{
fatalExit;
}
}
}
output<<endl;
}
while( folders++ );
output<< "\nFinished successfully.\n";
// this should be palced in each main
#include "finalize.hpp"
return 0;
}
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::commandLine::addOption
Option * addOption(word optionName, word description, word opText="")
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
pFlow::commandLine
Definition: commandLine.hpp:36
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::commandLine::parse
bool parse(int argc, char **argv)
Definition: commandLine.cpp:50
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
commandLine.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