# PhasicFlow: utilities/pFlowToVTK/pFlowToVTK.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

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 "vocabs.hpp"
#include "systemControl.hpp"
#include "timeFolder.hpp"
#include "commandLine.hpp"
#include "ranges.hpp"
#include "Vectors.hpp"
#include "phasicFlowKokkos.hpp"
#include "pointFieldToVTK.hpp"
#include "triSurfaceFieldToVTK.hpp"
#include "fileSeries.hpp"
//#include "readControlDict.hpp"
bool bindaryOutput__;
int main(int argc, char** argv )
{
pFlow::word outFolder = (pFlow::CWD()/pFlow::word("VTK")).wordPath();
pFlow::commandLine cmds(
"pFlowToVTK",
"Convrtes the saved pointField and geometry"
" date in time folders into vtk file format.");
pFlow::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");
bindaryOutput__ = false;
cmds.add_flag("-b, --binary",
bindaryOutput__,
"Wrtie vtk file (for particles only) in binary format. Default is ASCII");
cmds.addOption("-o,--out-folder",
outFolder,
"path to output folder of VTK",
"path");
bool separateSurfaces = false;
cmds.add_flag(
"-s,--separate-surfaces",
separateSurfaces,
"use this when you want to have sub-surfaces in separate files");
pFlow::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"
if(!bindaryOutput__)
{
INFORMATION<<"Writing vtk file in binray format will accelerate the conversion (5~10x)"<<
" and visualization in paraview."<<
" Consider addig flag -b or --binary in the command line."<<END_INFO;
}
pFlow::word formatName = bindaryOutput__?"binary":"ascii";
pFlow::timeFolder folders(Control);
auto destFolderGeometry = pFlow::fileSystem(outFolder)/pFlow::word(pFlow::geometryFolder__);
auto destFolderField = pFlow::fileSystem(outFolder)/pFlow::word("particles");
pFlow::wordList geomfiles{"triSurface"};
if(cmds.count("--fields"))
{
allFields = false;
}
pFlow::realCombinedRange validRange;
if( cmds.count("--time") )
{
if(!validRange.addRanges(times))
{
fatalExit;
}
}
else
{
validRange.addIntervalRange(folders.startTime(), folders.endTime());
}
{
pFlow::PFtoVTK::fileSeries timeSeries{pFlow::fileSystem(outFolder)};
pFlow::word fileName;
pFlow::wordList geomFileNames;
pFlow::wordList surfNames;
do
{
Control.time().setTime(folders.time());
if( !validRange.isMember( folders.time() ) )continue;
pFlow::output<< "time: " << Cyan_Text( folders.time() )<<" s" <<pFlow::endl;
if(!noGoem)
{
if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(
Control, destFolderGeometry, "surface", separateSurfaces, surfNames, geomFileNames))
{
fatalExit;
return 1;
}
timeSeries.addTimeFile(surfNames, folders.time(), geomFileNames);
}
if(!noParticle)
{
REPORT(1)<< "Converting pointFields to vtk file in "<< formatName<< " format ..."<<END_REPORT;
if(allFields)
{
if( !pFlow::PFtoVTK::convertTimeFolderPointFields(
Control,
destFolderField,
"particles",
fileName
)
)
{
fatalExit;
}
}else
{
if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
Control,
destFolderField,
"particles",
fields,
!pFlow::equal(folders.time(),static_cast< pFlow::real >(0.0)),
fileName
)
)
{
fatalExit;
}
}
timeSeries.addTimeFile("particles", folders.time(), fileName);
}
pFlow::output<<pFlow::endl;
}
while( folders++ );
}
pFlow::output<< "\nFinished successfully.\n";
// this should be palced in each main
#include "finalize.hpp"
return 0;
}
initialize_Control.hpp
pFlow::timeFolder::time
real time() const
Definition: timeFolder.hpp:57
pFlow::List< word >
pFlow::Vector::vectorField
const vectorType & vectorField() const
Definition: Vector.hpp:227
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
Cyan_Text
#define Cyan_Text(text)
Definition: iOstream.hpp:44
REPORT
#define REPORT(n)
Definition: streams.hpp:39
pFlow::PFtoVTK::convertTimeFolderPointFields
bool convertTimeFolderPointFields(systemControl &control, const fileSystem &destPath, const word &bName, word &filename)
Definition: pointFieldToVTK.cpp:8
systemControl.hpp
pFlow::commandLine::addOption
Option * addOption(word optionName, word description, word opText="")
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::PFtoVTK::fileSeries
Definition: fileSeries.hpp:14
pFlow::commandLine
Definition: commandLine.hpp:36
Vectors.hpp
pointFieldToVTK.hpp
fileSeries.hpp
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
main
int main(int argc, char **argv)
Definition: pFlowToVTK.cpp:35
pFlow::timeFolder::startTime
real startTime() const
Definition: timeFolder.hpp:105
pFlow::combinedRange
Definition: combinedRange.hpp:36
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
triSurfaceFieldToVTK.hpp
phasicFlowKokkos.hpp
pFlow::combinedRange::addIntervalRange
bool addIntervalRange(const word &strRange)
Definition: combinedRange.hpp:97
pFlow::geometryFolder__
const char *const geometryFolder__
Definition: vocabs.hpp:32
pFlow::commandLine::parse
bool parse(int argc, char **argv)
Definition: commandLine.cpp:50
pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields
bool convertTimeFolderTriSurfaceFields(systemControl &control, const fileSystem &destPath, const word &bName, bool separate, wordList &surfNames, wordList &fileNames)
Definition: triSurfaceFieldToVTK.cpp:5
pFlow::output
Ostream output
pFlow::combinedRange::addRanges
bool addRanges(const std::vector< word > &strRanges)
Definition: combinedRange.hpp:64
bindaryOutput__
bool bindaryOutput__
Definition: pFlowToVTK.cpp:33
ranges.hpp
pFlow::combinedRange::isMember
bool isMember(T val) const
Definition: combinedRange.hpp:131
END_REPORT
#define END_REPORT
Definition: streams.hpp:40
pFlow::CWD
fileSystem CWD()
Free function to reture current working directory.
Definition: fileSystem.hpp:221
pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected
bool convertTimeFolderPointFieldsSelected(systemControl &control, const fileSystem &destPath, const word &bName, const wordVector &fieldsName, bool mustExist, word &filename)
Definition: pointFieldToVTK.cpp:95
pFlow::timeFolder::endTime
real endTime() const
Definition: timeFolder.hpp:111
vocabs.hpp
pFlow::Vector< word >
END_INFO
#define END_INFO
Definition: streams.hpp:37
commandLine.hpp
Control
auto & Control
Definition: initialize_Control.hpp:47
INFORMATION
#define INFORMATION
Definition: streams.hpp:36
timeFolder.hpp
pFlow::timeFolder
Definition: timeFolder.hpp:32
finalize.hpp