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

processorOstream.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.
-----------------------------------------------------------------------------*/
#ifndef __processorOstream_hpp__
#define __processorOstream_hpp__
#include "Ostream.hpp"
namespace pFlow
{
class processorOstream
:
public Ostream
{
protected:
bool printPrefix_ = false;
word prefix_ = "";
inline
void checkForPrefix()
{
if(printPrefix_ && prefix_.size())
{
Ostream::write(prefix_.c_str());
printPrefix_ = false;
}
}
public:
processorOstream(std::ostream& os, const word& streamName);
processorOstream(const processorOstream&) = delete;
void operator=(const processorOstream&) = delete;
word setPrefixNum(int procNum)
{
prefix_ = word("[")+int322Word(procNum)+word("] ");
return prefix_;
}
void activatePrefix()
{
printPrefix_ = true;
}
bool write(const token& tok)
// to prevent compiler warning, this method is overriden agian
{
return Ostream::write(tok);
}
iOstream& write(const char c)override;
iOstream& write(const char* str)override;
iOstream& write(const word& str)override;
// Optional write without quotes.
iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
iOstream& write(const int64 val) override;
iOstream& write(const int32 val) override;
iOstream& write(const int8 val) override;
iOstream& write(const uint64 val) override;
iOstream& write(const uint32 val) override;
iOstream& write(const uint8 val) override;
iOstream& write(const float val) override;
iOstream& write(const double val) override;
iOstream& write(const size_t val) override;
iOstream& write(const char* binaryData, std::streamsize count) override;
void indent() override;
processorOstream& setColor(const char* colorCode);
}; // processorOstream
} // pFlow
#endif // __processorOstream_hpp__
Ostream.hpp
pFlow::processorOstream::activatePrefix
void activatePrefix()
Activate prefix for this stream.
Definition: processorOstream.hpp:83
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::processorOstream::write
bool write(const token &tok)
Write token to stream or otherwise handle it.
Definition: processorOstream.hpp:90
pFlow::processorOstream::setColor
processorOstream & setColor(const char *colorCode)
Definition: processorOstream.cpp:160
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::processorOstream
Output stream for MPI parallel run, when we need to know which the processor number in the output lin...
Definition: processorOstream.hpp:36
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::processorOstream::operator=
void operator=(const processorOstream &)=delete
No copy assignment.
pFlow
Definition: demGeometry.hpp:27
pFlow::processorOstream::prefix_
word prefix_
Prefix word
Definition: processorOstream.hpp:46
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::processorOstream::checkForPrefix
void checkForPrefix()
Output the prefix if required.
Definition: processorOstream.hpp:50
pFlow::processorOstream::processorOstream
processorOstream(std::ostream &os, const word &streamName)
From components.
Definition: processorOstream.cpp:28
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::processorOstream::indent
void indent() override
Add indentation characters.
Definition: processorOstream.cpp:154
pFlow::processorOstream::writeQuoted
iOstream & writeQuoted(const word &str, const bool quoted=true) override
Write std::string surrounded by quotes.
Definition: processorOstream.cpp:75
pFlow::processorOstream::setPrefixNum
word setPrefixNum(int procNum)
Set processor number to be used in the prefix.
Definition: processorOstream.hpp:76
pFlow::processorOstream::printPrefix_
bool printPrefix_
Print prefix?
Definition: processorOstream.hpp:43
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::int322Word
word int322Word(const int32 &v)
Convert int32 to word.
Definition: bTypesFunctions.cpp:110
pFlow::Ostream::write
bool write(const token &tok) override
Write token to stream or otherwise handle it.
Definition: Ostream.cpp:51
pFlow::Ostream
Standard output stream for BINARY and ASCII formats.
Definition: Ostream.hpp:39
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59