# PhasicFlow: src/phasicFlow/repository/IOobject/IOPattern.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.

IOPattern.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 __IOPattern_hpp__
#define __IOPattern_hpp__
#include "types.hpp"
namespace pFlow
{
class IOPattern
{
public:
enum IOType : int
{
MasterProcessorOnly = 0,
AllProcessorsSimilar = 1,
MasterProcessorDistribute = 4,
AllProcessorsDifferent = 8 // this is used for << and >> operators for
// standard input and output streams
};
private:
IOType ioType_;
int globalSize_ = 1;
int globalRank_ = 0;
bool isMaster_ = true;
bool isParallel_ = false;
public:
IOPattern( IOPattern::IOType iotype);
IOPattern(const IOPattern&)=default;
IOPattern(IOPattern&&) = default;
IOPattern& operator=(const IOPattern&)=default;
IOPattern& operator=(IOPattern&&)=default;
~IOPattern() = default;
inline
bool isMasterProcessorOnly()const
{
return ioType_ == MasterProcessorOnly;
}
inline
bool isAllProcessorSimilar()const
{
return ioType_ == AllProcessorsSimilar;
}
inline
bool isMasterProcessorDistribute()const
{
return ioType_ == MasterProcessorDistribute;
}
inline
bool isAllProcessorsDifferent()const
{
return ioType_ == AllProcessorsDifferent;
}
inline
bool isMaster()const
{
return isMaster_;
}
inline
bool isParallel()const
{
return isParallel_;
}
inline
bool thisCallRead()const
{
if(isMasterProcessorOnly() && !isMaster())return false;
return true;
}
inline
bool thisCallWrite()const
{
if(isMasterProcessorOnly()&& !isMaster())return false;
return true;
}
inline
bool thisProcReadData()const
{
if(isMasterProcessorOnly() && !isMaster())return false;
if(isMasterProcessorDistribute()&& !isMaster())return false;
return true;
}
inline
bool thisProcWriteData()const
{
if(isAllProcessorsDifferent()) return true;
return isMaster();
}
inline
bool thisProcReadHeader()const
{
return thisProcReadData();
}
inline
bool thisProcWriteHeader()const
{
return isMaster();
}
inline
auto globalSize()const
{
return globalSize_;
}
inline
auto globalRank()const
{
return globalRank_;
}
static
word exeMode();
};
}
#endif //__IOPattern_hpp__
pFlow::IOPattern::thisProcReadHeader
bool thisProcReadHeader() const
Definition: IOPattern.hpp:153
pFlow::IOPattern::isAllProcessorSimilar
bool isAllProcessorSimilar() const
Definition: IOPattern.hpp:94
pFlow::IOPattern::IOPattern
IOPattern(IOPattern::IOType iotype)
Definition: IOPattern.cpp:23
pFlow::IOPattern::thisCallRead
bool thisCallRead() const
Definition: IOPattern.hpp:124
pFlow::IOPattern::globalSize_
int globalSize_
Definition: IOPattern.hpp:65
types.hpp
pFlow::IOPattern::globalSize
auto globalSize() const
Definition: IOPattern.hpp:165
pFlow::IOPattern::~IOPattern
~IOPattern()=default
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::IOPattern::ioType_
IOType ioType_
Definition: IOPattern.hpp:63
pFlow::IOPattern::globalRank
auto globalRank() const
Definition: IOPattern.hpp:171
pFlow::IOPattern::isMasterProcessorOnly
bool isMasterProcessorOnly() const
Definition: IOPattern.hpp:88
pFlow::IOPattern::isParallel
bool isParallel() const
Definition: IOPattern.hpp:118
pFlow::IOPattern::IOType
IOType
Type of input/output.
Definition: IOPattern.hpp:52
pFlow
Definition: demGeometry.hpp:27
pFlow::IOPattern::globalRank_
int globalRank_
Definition: IOPattern.hpp:67
pFlow::IOPattern::thisProcWriteHeader
bool thisProcWriteHeader() const
Definition: IOPattern.hpp:159
pFlow::IOPattern::isAllProcessorsDifferent
bool isAllProcessorsDifferent() const
Definition: IOPattern.hpp:106
pFlow::IOPattern::isMasterProcessorDistribute
bool isMasterProcessorDistribute() const
Definition: IOPattern.hpp:100
pFlow::IOPattern::AllProcessorsDifferent
@ AllProcessorsDifferent
Definition: IOPattern.hpp:57
pFlow::IOPattern::thisCallWrite
bool thisCallWrite() const
Definition: IOPattern.hpp:131
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::IOPattern::isMaster_
bool isMaster_
Definition: IOPattern.hpp:69
pFlow::IOPattern::exeMode
static word exeMode()
Definition: IOPattern.cpp:32
pFlow::IOPattern::thisProcReadData
bool thisProcReadData() const
Definition: IOPattern.hpp:138
pFlow::IOPattern::thisProcWriteData
bool thisProcWriteData() const
Definition: IOPattern.hpp:146
pFlow::IOPattern::isParallel_
bool isParallel_
Definition: IOPattern.hpp:71
pFlow::IOPattern::operator=
IOPattern & operator=(const IOPattern &)=default
pFlow::IOPattern::AllProcessorsSimilar
@ AllProcessorsSimilar
Definition: IOPattern.hpp:55
pFlow::IOPattern::isMaster
bool isMaster() const
Definition: IOPattern.hpp:112
pFlow::IOPattern::MasterProcessorDistribute
@ MasterProcessorDistribute
Definition: IOPattern.hpp:56
pFlow::IOPattern::MasterProcessorOnly
@ MasterProcessorOnly
Definition: IOPattern.hpp:54