vibrating wall added, tested; time interval for wall motion added, tested

This commit is contained in:
hamidrezanorouzi
2023-01-03 19:31:12 +03:30
parent c8134eb3cf
commit 0d45a2b8a5
19 changed files with 941 additions and 22 deletions

View File

@ -21,13 +21,6 @@ Licence:
#include "rotatingAxis.hpp"
#include "dictionary.hpp"
/*FUNCTION_HD
pFlow::rotatingAxis::rotatingAxis()
:
line(),
omega_(0.0),
rotating_(false)
{}*/
FUNCTION_H
pFlow::rotatingAxis::rotatingAxis
@ -52,6 +45,7 @@ pFlow::rotatingAxis::rotatingAxis
real omega
)
:
timeInterval(),
line(p1, p2),
omega_(omega),
rotating_(!equal(omega,0.0))
@ -60,7 +54,6 @@ pFlow::rotatingAxis::rotatingAxis
}
//rotatingAxis(const dictionary& dict);
FUNCTION_HD
pFlow::real pFlow::rotatingAxis::setOmega(real omega)
{
@ -76,6 +69,8 @@ bool pFlow::rotatingAxis::read
const dictionary& dict
)
{
if(!timeInterval::read(dict))return false;
if(!line::read(dict)) return false;
real omega = dict.getValOrSet("omega", static_cast<real>(0.0));
@ -90,6 +85,7 @@ bool pFlow::rotatingAxis::write
dictionary& dict
) const
{
if( !timeInterval::write(dict) ) return false;
if( !line::write(dict) ) return false;
if( !dict.add("omega", omega_) )
@ -107,6 +103,7 @@ bool pFlow::rotatingAxis::read
iIstream& is
)
{
if( !rotatingAxis::timeInterval::read(is)) return false;
if( !rotatingAxis::line::read(is)) return false;
word omegaw;
@ -137,6 +134,7 @@ bool pFlow::rotatingAxis::write
iOstream& os
)const
{
if( !rotatingAxis::timeInterval::write(os)) return false;
if( !rotatingAxis::line::write(os) ) return false;
os.writeWordEntry("omega", omega());

View File

@ -21,6 +21,7 @@ Licence:
#ifndef __rotatingAxis_hpp__
#define __rotatingAxis_hpp__
#include "timeInterval.hpp"
#include "line.hpp"
namespace pFlow
@ -33,6 +34,7 @@ class rotatingAxis;
class rotatingAxis
:
public timeInterval,
public line
{
protected:

View File

@ -21,6 +21,9 @@ Licence:
INLINE_FUNCTION_HD
pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)const
{
if(!inTimeRange()) return {0,0,0};
realx3 L = p - projectPoint(p);
return cross(omega_*unitVector(),L);
}
@ -28,6 +31,9 @@ pFlow::realx3 pFlow::rotatingAxis::linTangentialVelocityPoint(const realx3 &p)co
INLINE_FUNCTION_HD
pFlow::realx3 pFlow::rotate(const realx3& p, const rotatingAxis& ax, real dt)
{
if(!ax.inTimeRange()) return p;
realx3 nv = ax.unitVector();
real cos_tet = cos(ax.omega()*dt);
real sin_tet = sin(ax.omega()*dt);
@ -61,7 +67,6 @@ INLINE_FUNCTION_HD
pFlow::realx3 pFlow::rotate(const realx3 &p, const line& ln, real theta)
{
realx3 nv = ln.unitVector();
real cos_tet = cos(theta);
real sin_tet = sin(theta);
@ -130,6 +135,8 @@ void pFlow::rotate(realx3* p, size_t n, const line& ln, real theta)
INLINE_FUNCTION_HD
void pFlow::rotate(realx3* p, size_t n, const rotatingAxis& ax, real dt)
{
if(!ax.inTimeRange()) return;
realx3 nv = ax.unitVector();
real cos_tet = cos(ax.omega()*dt);
real sin_tet = sin(ax.omega()*dt);

View File

@ -0,0 +1,84 @@
#include "timeInterval.hpp"
#include "dictionary.hpp"
FUNCTION_H
pFlow::timeInterval::timeInterval(const dictionary& dict)
{
if(!read(dict))
{
fatalExit;
}
}
FUNCTION_H
bool pFlow::timeInterval::read(const dictionary& dict)
{
startTime_ = dict.getValOrSet<real>("startTime", 0);
endTime_ = dict.getValOrSet<real>("endTime", largeValue);
return true;
}
FUNCTION_H
bool pFlow::timeInterval::write(dictionary& dict) const
{
if( !dict.add("startTime", startTime_) )
{
fatalErrorInFunction<<
" error in writing startTime to dictionary "<< dict.globalName()<<endl;
return false;
}
if( !dict.add("endTime", endTime_) )
{
fatalErrorInFunction<<
" error in writing endTime to dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
FUNCTION_H
bool pFlow::timeInterval::read(iIstream& is)
{
word key;
real val;
is >> key >> val;
if(key != "startTime")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected startTime but found "<< key <<endl;
return false;
}
else
startTime_ = val;
is.readEndStatement(FUNCTION_NAME);
is >> key >> val;
if(key != "endTime")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected endTime but found "<< key <<endl;
return false;
}
else
endTime_ = val;
is.readEndStatement(FUNCTION_NAME);
return true;
}
FUNCTION_H
bool pFlow::timeInterval::write(iOstream& os)const
{
os.writeWordEntry("startTime", startTime_);
os.writeWordEntry("endTime", endTime_);
return os.check(FUNCTION_NAME);
}

View File

@ -0,0 +1,116 @@
#ifndef __timeInterval_hpp__
#define __timeInterval_hpp__
#include "types.hpp"
#include "pFlowMacros.hpp"
namespace pFlow
{
// forward
class dictionary;
class timeInterval
{
protected:
real startTime_ = 0;
real endTime_ = largeValue;
real time_=0;
bool isInInterval_ = true;
public:
INLINE_FUNCTION_HD
timeInterval(){}
INLINE_FUNCTION_HD
timeInterval(const timeInterval&) = default;
INLINE_FUNCTION_HD
timeInterval& operator=(const timeInterval&) = default;
FUNCTION_H
timeInterval(const dictionary& dict);
INLINE_FUNCTION_HD
~timeInterval() = default;
INLINE_FUNCTION_HD
auto startTime()const
{
return startTime_;
}
INLINE_FUNCTION_HD
auto endTime()const
{
return endTime_;
}
INLINE_FUNCTION_HD
auto time()const
{
return time_;
}
INLINE_FUNCTION_HD
void setTime(real t)
{
isInInterval_ = inTimeRange(t);
time_ = t;
}
INLINE_FUNCTION_HD
bool inTimeRange(real t)const
{
return t>= startTime_ && t<= endTime_;
}
INLINE_FUNCTION_HD
bool inTimeRange()const
{
return isInInterval_;
}
// - 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 timeInterval& obj)
{
if(!obj.write(os))
{
fatalExit;
}
return os;
}
inline iIstream& operator >>(iIstream& is, timeInterval& obj)
{
if( !obj.read(is) )
{
fatalExit;
}
return is;
}
}
#endif

View File

@ -0,0 +1,102 @@
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
#include "vibrating.hpp"
#include "dictionary.hpp"
FUNCTION_H
pFlow::vibrating::vibrating(const dictionary& dict)
{
if(!read(dict))
{
fatalErrorInFunction<<
" error in reading vibrating from dictionary "<< dict.globalName()<<endl;
fatalExit;
}
}
FUNCTION_H
bool pFlow::vibrating::read(const dictionary& dict)
{
if(!timeInterval::read(dict))return false;
angularFreq_ = dict.getVal<realx3>("angularFreq");
phaseAngle_ = dict.getValOrSet<realx3>("phaseAngle", realx3(0));
amplitude_ = dict.getVal<realx3>("amplitude");
return true;
}
FUNCTION_H
bool pFlow::vibrating::write(dictionary& dict) const
{
if(!timeInterval::write(dict)) return false;
if( !dict.add("angularFreq", angularFreq_) )
{
fatalErrorInFunction<<
" error in writing angularFreq to dictionary "<< dict.globalName()<<endl;
return false;
}
if( !dict.add("phaseAngle", phaseAngle_) )
{
fatalErrorInFunction<<
" error in writing phaseAngle to dictionary "<< dict.globalName()<<endl;
return false;
}
if( !dict.add("amplitude", amplitude_) )
{
fatalErrorInFunction<<
" error in writing amplitude to dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
FUNCTION_H
bool pFlow::vibrating::read(iIstream& is)
{
notImplementedFunction;
return true;
}
FUNCTION_H
bool pFlow::vibrating::write(iOstream& os)const
{
if(!timeInterval::write(os)) return false;
os.writeWordEntry("angularFreq", angularFreq_);
os.writeWordEntry("phaseAngle", phaseAngle_);
os.writeWordEntry("amplitude", amplitude_);
return os.check(FUNCTION_NAME);
}

View File

@ -0,0 +1,137 @@
/*------------------------------- 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
{
class dictionary;
class vibrating;
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 + 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