# PhasicFlow: src/phasicFlow/eventManagement/message.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.

message.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 __message_hpp__
#define __message_hpp__
#include <bitset>
#include <array>
#include "types.hpp"
#include "iOstream.hpp"
namespace pFlow
{
class message
{
public:
enum EVENT : size_t
{
DEFAULT = 0,
CAP_CHANGED = 1, // internal points capacity changed
SIZE_CHANGED = 2, // internal points size changed
ITEM_DELETE = 3, // internal points item deleted
ITEM_INSERT = 4, // internal points item inserted
RANGE_CHANGED = 5, // internal points range changed
ITEM_REARRANGE = 6, // internal points item rearrange
ITEM_FLAGCHANGED= 7, // internal points item flag changed, this occurs when transfer occurs
BNDR_REARRANGE = 8, // boundary indices rearrange
BNDR_TRANSFER = 9, // boundary indices transfered
BNDR_RESET = 10, // boundary indices reset entirely
BNDR_DELETE = 11, // boundary indices deleted
BNDR_APPEND = 12, //
BNDR_PROCTRANSFER_SEND = 13, // transfer of data between processors step 1
BNDR_PROCTRANSFER_RECIEVE = 14, // transfer of data between processors step 2
BNDR_PROCTRANSFER_WAITFILL = 15, // wait for data and fill the field
BNDR_PROC_SIZE_CHANGED = 16
};
private:
static constexpr size_t numberOfEvents_ = 17;
std::bitset<numberOfEvents_> events_{0x0000};
static
inline const std::array<word,numberOfEvents_> eventNames_
{
"",
"capacity",
"size",
"deletedIndices",
"insertedIndices",
"range",
"rearrangedIndices",
"transferredIndices",
"rearrangedIndices",
"transferredIndices",
"",
"deletedIndices",
"appendedIndices",
"transferredIndices",
"numToRecieve",
"insertedIndices",
"size"
};
public:
message()=default;
message(EVENT evnt)
{
add(evnt);
}
message(size_t i )
{
if(i<numberOfEvents_)
{
events_.set(i);
}
}
message(const message&) = default;
message(message&&) = default;
message& operator=(const message&) = default;
message& operator=(message&&) = default;
~message()=default;
inline message& add( EVENT evnt)
{
events_.set(static_cast<size_t>(evnt));
return *this;
}
inline const word& addAndName(EVENT evnt)
{
add(evnt);
return eventName(static_cast<size_t>(evnt));
}
inline message& remove(EVENT evnt)
{
events_.set(static_cast<size_t>(evnt), false);
return *this;
}
inline bool equivalentTo( EVENT evnt )const
{
return equivalentTo(static_cast<size_t>(evnt));
}
inline bool equivalentTo(size_t i)const
{
return events_.test(i);
}
inline bool isNull()const
{
return events_.none();
}
inline auto size()const
{
return events_.size();
}
inline
message& operator+(EVENT evnt)
{
return add(evnt);
}
inline
message& operator-(EVENT evnt)
{
return remove(evnt);
}
inline
message& operator+(const message& msg)
{
for(size_t i=0uL; i< events_.size(); i++)
{
if(msg.equivalentTo(i))
{
events_.set(i);
}
}
return *this;
}
static
auto constexpr numEvents()
{
return numberOfEvents_;
}
static
message Default()
{
message msg;
return msg+DEFAULT;
}
static
message Empty()
{
message msg;
return msg;
}
static
const word& eventName(size_t event)
{
return eventNames_[event];
}
};
inline
iOstream& operator<<(iOstream& os, const message& msg)
{
for(size_t i=msg.size(); i>0; i--)
{
os<< msg.equivalentTo(i-1)? '1':0;
}
os<<endl;
return os;
}
inline
message operator + (message::EVENT evnt1, message::EVENT evnt2)
{
message msg = message::Empty().add(evnt1).add(evnt2);
return msg;
}
}
#endif // __eventMessage_hpp__
pFlow::message::equivalentTo
bool equivalentTo(EVENT evnt) const
Definition: message.hpp:131
pFlow::message
Definition: message.hpp:33
pFlow::message::Default
static message Default()
Definition: message.hpp:182
pFlow::message::events_
std::bitset< numberOfEvents_ > events_
Definition: message.hpp:62
pFlow::message::operator-
message & operator-(EVENT evnt)
Definition: message.hpp:158
types.hpp
pFlow::message::BNDR_PROCTRANSFER_RECIEVE
@ BNDR_PROCTRANSFER_RECIEVE
Definition: message.hpp:52
pFlow::message::operator=
message & operator=(const message &)=default
pFlow::message::operator+
message & operator+(EVENT evnt)
Definition: message.hpp:152
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::message::numEvents
static constexpr auto numEvents()
Definition: message.hpp:177
pFlow::message::size
auto size() const
Definition: message.hpp:146
pFlow::message::eventNames_
static const std::array< word, numberOfEvents_ > eventNames_
Definition: message.hpp:66
pFlow::message::message
message(size_t i)
Definition: message.hpp:95
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::message::SIZE_CHANGED
@ SIZE_CHANGED
Definition: message.hpp:40
pFlow::message::BNDR_REARRANGE
@ BNDR_REARRANGE
Definition: message.hpp:46
pFlow::message::BNDR_PROC_SIZE_CHANGED
@ BNDR_PROC_SIZE_CHANGED
Definition: message.hpp:54
pFlow::message::ITEM_REARRANGE
@ ITEM_REARRANGE
Definition: message.hpp:44
pFlow::message::BNDR_APPEND
@ BNDR_APPEND
Definition: message.hpp:50
pFlow::message::~message
~message()=default
pFlow::message::EVENT
EVENT
Definition: message.hpp:36
pFlow
Definition: demGeometry.hpp:27
pFlow::message::BNDR_RESET
@ BNDR_RESET
Definition: message.hpp:48
pFlow::message::equivalentTo
bool equivalentTo(size_t i) const
Definition: message.hpp:136
pFlow::message::numberOfEvents_
static constexpr size_t numberOfEvents_
Definition: message.hpp:60
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::message::message
message(EVENT evnt)
Definition: message.hpp:90
pFlow::message::ITEM_INSERT
@ ITEM_INSERT
Definition: message.hpp:42
pFlow::message::RANGE_CHANGED
@ RANGE_CHANGED
Definition: message.hpp:43
pFlow::message::operator+
message & operator+(const message &msg)
Definition: message.hpp:164
pFlow::message::ITEM_DELETE
@ ITEM_DELETE
Definition: message.hpp:41
pFlow::message::addAndName
const word & addAndName(EVENT evnt)
Definition: message.hpp:119
pFlow::message::message
message()=default
pFlow::message::BNDR_PROCTRANSFER_SEND
@ BNDR_PROCTRANSFER_SEND
Definition: message.hpp:51
pFlow::message::CAP_CHANGED
@ CAP_CHANGED
Definition: message.hpp:39
pFlow::message::remove
message & remove(EVENT evnt)
Definition: message.hpp:125
pFlow::message::Empty
static message Empty()
Definition: message.hpp:189
pFlow::message::BNDR_DELETE
@ BNDR_DELETE
Definition: message.hpp:49
iOstream.hpp
pFlow::message::isNull
bool isNull() const
Definition: message.hpp:141
pFlow::message::BNDR_TRANSFER
@ BNDR_TRANSFER
Definition: message.hpp:47
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::message::BNDR_PROCTRANSFER_WAITFILL
@ BNDR_PROCTRANSFER_WAITFILL
Definition: message.hpp:53
pFlow::message::DEFAULT
@ DEFAULT
Definition: message.hpp:38
pFlow::operator+
message operator+(message::EVENT evnt1, message::EVENT evnt2)
Definition: message.hpp:216
pFlow::message::ITEM_FLAGCHANGED
@ ITEM_FLAGCHANGED
Definition: message.hpp:45
pFlow::message::add
message & add(EVENT evnt)
Definition: message.hpp:113
pFlow::message::eventName
static const word & eventName(size_t event)
Definition: message.hpp:196