# PhasicFlow: src/phasicFlow/streams/Fstream/fileStream.hpp 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.

fileStream.hpp
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.
-----------------------------------------------------------------------------*/
// based on OpenFOAM stream, with some modifications/simplifications
// to be tailored to our needs
#ifndef __fileStream_hpp__
#define __fileStream_hpp__
#include <fstream>
#include "fileSystem.hpp"
#include "uniquePtr.hpp"
namespace pFlow
{
class fileStream
{
protected:
uniquePtr<std::ifstream> inStream_;
uniquePtr<std::ofstream> outStream_;
bool binary_ = false;
bool append_ = false;
void openInFile(const fileSystem& path);
void openOutFile(const fileSystem& path);
void close();
public:
fileStream( const fileSystem& path, bool outStream = false, bool binary = false, bool append = false);
fileStream(const fileStream&)= delete;
fileStream& operator=(const fileStream&)=delete;
virtual ~fileStream()
{
close();
}
std::ifstream& inStream();
std::ofstream& outStream();
};
}
#endif
pFlow::fileStream::outStream_
uniquePtr< std::ofstream > outStream_
out file stream
Definition: fileStream.hpp:51
pFlow::fileStream::append_
bool append_
Definition: fileStream.hpp:55
pFlow::fileStream::openInFile
void openInFile(const fileSystem &path)
open input file
Definition: fileStream.cpp:27
pFlow::fileStream::close
void close()
close streams
Definition: fileStream.cpp:106
pFlow::fileStream::operator=
fileStream & operator=(const fileStream &)=delete
No assignment.
pFlow::fileStream::~fileStream
virtual ~fileStream()
Destructor.
Definition: fileStream.hpp:80
fileSystem.hpp
pFlow
Definition: demGeometry.hpp:27
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
pFlow::fileStream::outStream
std::ofstream & outStream()
Access output file stream.
Definition: fileStream.cpp:148
uniquePtr.hpp
pFlow::fileStream::binary_
bool binary_
Definition: fileStream.hpp:53
pFlow::fileStream::inStream_
uniquePtr< std::ifstream > inStream_
in file stream
Definition: fileStream.hpp:48
pFlow::fileStream
Creates and manages an input/output file stream with specified format.
Definition: fileStream.hpp:43
pFlow::uniquePtr< std::ifstream >
pFlow::fileStream::fileStream
fileStream(const fileSystem &path, bool outStream=false, bool binary=false, bool append=false)
From file path and input type and format.
Definition: fileStream.cpp:120
pFlow::fileStream::openOutFile
void openOutFile(const fileSystem &path)
open output file
Definition: fileStream.cpp:58
pFlow::fileStream::inStream
std::ifstream & inStream()
Access input file stream.
Definition: fileStream.cpp:143