# PhasicFlow: src/MotionModel/entities/vibrating/vibrating.hpp Source File

vibrating.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 __vibrating_hpp__
#define __vibrating_hpp__
#include "timeInterval.hpp"
#include "streams.hpp"
namespace pFlow
{
// forward
class dictionary;
class vibrating
:
public timeInterval
{
protected:
// rotation speed
realx3 angularFreq_{0,0,0};
realx3 phaseAngle_{0,0,0};
realx3 amplitude_{0,0,0};
realx3 velocity_{0,0,0};
realx3 velocity0_{0,0,0};
INLINE_FUNCTION_HD
void calculateVelocity()
{
if(inTimeRange())
{
velocity_ = amplitude_ * sin( angularFreq_*(time()-startTime() ) + phaseAngle_ );
}else
{
velocity_ = {0,0,0};
}
}
public:
FUNCTION_HD
vibrating(){}
FUNCTION_H
vibrating(const dictionary& dict);
FUNCTION_HD
vibrating(const vibrating&) = default;
vibrating& operator=(const vibrating&) = default;
INLINE_FUNCTION_HD
void setTime(real t)
{
if( !equal(t, time()) ) velocity0_ = velocity_;
timeInterval::setTime(t);
calculateVelocity();
}
INLINE_FUNCTION_HD
realx3 linTangentialVelocityPoint(const realx3 &p)const
{
return velocity_;
}
INLINE_FUNCTION_HD
realx3 transferPoint(const realx3& p, real dt)
{
if(!inTimeRange()) return p;
return p + static_cast< real >(0.5)*dt*(velocity0_+velocity_);
}
// - IO operation
FUNCTION_H
bool read(const dictionary& dict);
FUNCTION_H
bool write(dictionary& dict) const;
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
inline iOstream& operator <<(iOstream& os, const vibrating& obj)
{
if(!obj.write(os))
{
fatalExit;
}
return os;
}
inline iIstream& operator >>(iIstream& is, vibrating& obj)
{
if( !obj.read(is) )
{
fatalExit;
}
return is;
}
}
#endif
timeInterval.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::vibrating::angularFreq_
realx3 angularFreq_
Definition: vibrating.hpp:73
pFlow::vibrating
Vibrating model for a wall.
Definition: vibrating.hpp:65
pFlow::vibrating::velocity0_
realx3 velocity0_
Definition: vibrating.hpp:81
pFlow::timeInterval::startTime
INLINE_FUNCTION_HD auto startTime() const
Definition: timeInterval.hpp:45
pFlow::sin
INLINE_FUNCTION_HD real sin(real x)
Definition: math.hpp:168
pFlow::vibrating::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(const realx3 &p, real dt)
Definition: vibrating.hpp:124
pFlow::vibrating::calculateVelocity
INLINE_FUNCTION_HD void calculateVelocity()
Definition: vibrating.hpp:84
pFlow::vibrating::operator=
vibrating & operator=(const vibrating &)=default
pFlow
Definition: demComponent.hpp:28
pFlow::vibrating::velocity_
realx3 velocity_
Definition: vibrating.hpp:79
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::timeInterval::time
INLINE_FUNCTION_HD auto time() const
Definition: timeInterval.hpp:57
pFlow::vibrating::phaseAngle_
realx3 phaseAngle_
Definition: vibrating.hpp:75
pFlow::vibrating::linTangentialVelocityPoint
INLINE_FUNCTION_HD realx3 linTangentialVelocityPoint(const realx3 &p) const
Definition: vibrating.hpp:118
pFlow::vibrating::read
FUNCTION_H bool read(const dictionary &dict)
Definition: vibrating.cpp:40
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::timeInterval::inTimeRange
INLINE_FUNCTION_HD bool inTimeRange() const
Definition: timeInterval.hpp:76
pFlow::timeInterval
Definition: timeInterval.hpp:16
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
streams.hpp
pFlow::vibrating::write
FUNCTION_H bool write(dictionary &dict) const
Definition: vibrating.cpp:55
pFlow::vibrating::setTime
INLINE_FUNCTION_HD void setTime(real t)
Definition: vibrating.hpp:110
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::timeInterval::setTime
INLINE_FUNCTION_HD void setTime(real t)
Definition: timeInterval.hpp:63
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::equal
INLINE_FUNCTION_HD bool equal(const real &s1, const real &s2)
Definition: bTypesFunctions.hpp:188
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::vibrating::vibrating
FUNCTION_HD vibrating()
Definition: vibrating.hpp:98
pFlow::vibrating::amplitude_
realx3 amplitude_
Definition: vibrating.hpp:77