# PhasicFlow: src/Particles/Insertion/insertionRegion/timeFlowControl.hpp Source File

timeFlowControl.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 __timeFlowControl_hpp__
#define __timeFlowControl_hpp__
#include "types.hpp"
#include "streams.hpp"
namespace pFlow
{
class dictionary;
class timeFlowControl
{
protected:
real startTime_;
real endTime_;
real interval_;
real rate_;
size_t numInserted_ = 0;
bool readTimeFlowControl(const dictionary& dict);
bool writeTimeFlowControl(dictionary& dict) const;
size_t numberToBeInserted(real currentTime)
{
if(currentTime<startTime_)return 0;
if(currentTime>endTime_) return 0;
return static_cast<size_t>( (currentTime - startTime_ + interval_)*rate_ - numInserted_ );
}
size_t addToNumInserted(size_t newInserted)
{
return numInserted_ += newInserted;
}
public:
timeFlowControl(const dictionary& dict);
bool insertionTime( real currentTime, real dt)
{
if(currentTime < startTime_) return false;
if(currentTime > endTime_) return false;
if( mod(abs(currentTime-startTime_),interval_)/dt < 1 ) return true;
return false;
}
size_t totalInserted()const
{
return numInserted_;
}
bool read(const dictionary& dict)
{
return readTimeFlowControl(dict);
}
bool write(dictionary& dict)const
{
return writeTimeFlowControl(dict);
}
};
}
#endif //__timeFlowControl_hpp__
pFlow::timeFlowControl::timeFlowControl
timeFlowControl(const dictionary &dict)
Definition: timeFlowControl.cpp:52
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::timeFlowControl::endTime_
real endTime_
Definition: timeFlowControl.hpp:38
pFlow::timeFlowControl::rate_
real rate_
Definition: timeFlowControl.hpp:42
pFlow::timeFlowControl::read
bool read(const dictionary &dict)
Definition: timeFlowControl.hpp:84
types.hpp
pFlow::timeFlowControl::numberToBeInserted
size_t numberToBeInserted(real currentTime)
Definition: timeFlowControl.hpp:50
pFlow::timeFlowControl::numInserted_
size_t numInserted_
Definition: timeFlowControl.hpp:44
pFlow::timeFlowControl
Definition: timeFlowControl.hpp:32
pFlow
Definition: demComponent.hpp:28
pFlow::timeFlowControl::startTime_
real startTime_
Definition: timeFlowControl.hpp:36
pFlow::timeFlowControl::totalInserted
size_t totalInserted() const
Definition: timeFlowControl.hpp:79
pFlow::timeFlowControl::writeTimeFlowControl
bool writeTimeFlowControl(dictionary &dict) const
Definition: timeFlowControl.cpp:38
pFlow::abs
INLINE_FUNCTION_HD real abs(real x)
Definition: math.hpp:43
pFlow::timeFlowControl::write
bool write(dictionary &dict) const
Definition: timeFlowControl.hpp:89
pFlow::mod
INLINE_FUNCTION_HD real mod(real x, real y)
Definition: math.hpp:72
streams.hpp
pFlow::timeFlowControl::addToNumInserted
size_t addToNumInserted(size_t newInserted)
Definition: timeFlowControl.hpp:58
pFlow::timeFlowControl::readTimeFlowControl
bool readTimeFlowControl(const dictionary &dict)
Definition: timeFlowControl.cpp:25
pFlow::timeFlowControl::insertionTime
bool insertionTime(real currentTime, real dt)
Definition: timeFlowControl.hpp:69
pFlow::timeFlowControl::interval_
real interval_
Definition: timeFlowControl.hpp:40
pFlow::dictionary
Definition: dictionary.hpp:38