# PhasicFlow: src/MotionModel/entities/rotatingAxis/rotatingAxis.cpp Source File

rotatingAxis.cpp
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.
-----------------------------------------------------------------------------*/
#include "rotatingAxis.hpp"
#include "dictionary.hpp"
FUNCTION_H
pFlow::rotatingAxis::rotatingAxis
(
const dictionary& dict
)
{
if(!read(dict))
{
fatalErrorInFunction<<
" error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
fatalExit;
}
}
FUNCTION_HD
pFlow::rotatingAxis::rotatingAxis
(
const realx3& p1,
const realx3& p2,
real omega
)
:
timeInterval(),
line(p1, p2),
omega_(omega),
rotating_(!equal(omega,0.0))
{
}
FUNCTION_HD
pFlow::real pFlow::rotatingAxis::setOmega(real omega)
{
auto tmp = omega_;
omega_ = omega;
rotating_ = !equal(omega, 0.0);
return tmp;
}
FUNCTION_H
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));
setOmega(omega);
return true;
}
FUNCTION_H
bool pFlow::rotatingAxis::write
(
dictionary& dict
) const
{
if( !timeInterval::write(dict) ) return false;
if( !line::write(dict) ) return false;
if( !dict.add("omega", omega_) )
{
fatalErrorInFunction<<
" error in writing omega to dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
FUNCTION_H
bool pFlow::rotatingAxis::read
(
iIstream& is
)
{
if( !rotatingAxis::timeInterval::read(is)) return false;
if( !rotatingAxis::line::read(is)) return false;
word omegaw;
real omega;
is >> omegaw >> omega;
if( !is.check(FUNCTION_NAME))
{
ioErrorInFile(is.name(), is.lineNumber());
return false;
}
if(omegaw != "omega")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected omega but found "<< omegaw <<endl;
return false;
}
is.readEndStatement(FUNCTION_NAME);
setOmega(omega);
return true;
}
FUNCTION_H
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());
return os.check(FUNCTION_NAME);
}
pFlow::rotatingAxis::setOmega
FUNCTION_HD real setOmega(real omega)
Set omega.
Definition: rotatingAxis.cpp:58
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
Definition: dictionary.hpp:325
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::line
Definition: line.hpp:36
pFlow::timeInterval::write
FUNCTION_H bool write(dictionary &dict) const
Definition: timeInterval.cpp:26
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::line::write
FUNCTION_H bool write(dictionary &ditc) const
Definition: line.cpp:61
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
Definition: iIstream.cpp:324
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::dictionary::globalName
virtual word globalName() const
Definition: dictionary.cpp:349
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
Definition: dictionary.cpp:422
rotatingAxis.hpp
pFlow::timeInterval::read
FUNCTION_H bool read(const dictionary &dict)
Definition: timeInterval.cpp:17
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::rotatingAxis::write
FUNCTION_H bool write(dictionary &dict) const
Write to dictionary.
Definition: rotatingAxis.cpp:84
pFlow::rotatingAxis::rotating_
bool rotating_
is rotating
Definition: rotatingAxis.hpp:73
pFlow::IOstream::check
virtual bool check(const char *operation) const
Definition: IOstream.cpp:42
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::line::read
FUNCTION_H bool read(const dictionary &dict)
Definition: line.cpp:50
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::rotatingAxis::omega_
real omega_
rotation speed
Definition: rotatingAxis.hpp:70
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
dictionary.hpp
pFlow::rotatingAxis::omega
INLINE_FUNCTION_HD real omega() const
Return omega.
Definition: rotatingAxis.hpp:104
pFlow::timeInterval
Definition: timeInterval.hpp:16
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::rotatingAxis::read
FUNCTION_H bool read(const dictionary &dict)
Read from dictionary.
Definition: rotatingAxis.cpp:68
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::triple< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::equal
INLINE_FUNCTION_HD bool equal(const real &s1, const real &s2)
Definition: bTypesFunctions.hpp:188
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Definition: iOstream.hpp:217
pFlow::rotatingAxis::rotatingAxis
FUNCTION_HD rotatingAxis()
Empty constructor.
Definition: rotatingAxis.hpp:81
pFlow::dictionary
Definition: dictionary.hpp:38