# PhasicFlow: utilities/Utilities/vtkFile/vtkFile.cpp Source File

vtkFile.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 "vtkFile.hpp"
bool pFlow::vtkFile::openStream()
{
oStream_ = makeUnique<oFstream>( fileName() );
if( !oStream_ )return false;
return writeHeader();
}
bool pFlow::vtkFile::vtkFile::writeHeader()
{
if(!oStream_) return false;
oStream_() << "# vtk DataFile Version 2.0" << endl;
oStream_() << "vtk file for time : " << time_ << endl;
oStream_() << "ASCII" << endl;
if( oStream_().fail() ) return false;
return true;
}
pFlow::vtkFile::vtkFile
(
const fileSystem dir,
const word& bName,
real time
)
:
dirPath_(dir),
baseName_(bName),
time_(time)
{
if(!openStream())
{
fatalErrorInFunction <<
" error in creating vtkFile "<<fileName()<<endl;
fatalExit;
}
}
pFlow::fileSystem pFlow::vtkFile::fileName()const
{
word fName = baseName_ +"-" + int322Word(10000*time_) + ".vtk";
return dirPath_ +fName;
}
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::vtkFile::fileName
virtual fileSystem fileName() const
Definition: vtkFile.cpp:70
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::vtkFile::openStream
bool openStream()
Definition: vtkFile.cpp:24
pFlow::vtkFile::writeHeader
virtual bool writeHeader()
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::fileSystem
Definition: fileSystem.hpp:63
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::vtkFile::vtkFile
vtkFile(const fileSystem dir, const word &bName, real time)
Definition: vtkFile.cpp:49
pFlow::int322Word
word int322Word(const int32 &v)
Definition: bTypesFunctions.cpp:67
pFlow::vtkFile::oStream_
uniquePtr< oFstream > oStream_
Definition: vtkFile.hpp:43
vtkFile.hpp