# PhasicFlow: src/phasicFlow/types/quadruple/quadrupleI.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.

quadrupleI.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.
-----------------------------------------------------------------------------*/
template<typename T>
INLINE_FUNCTION_HD T
pFlow::dot(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
{
return oprnd1.s_ * oprnd2.s_ + dot(oprnd1.v(), oprnd2.v());
}
template<typename T>
INLINE_FUNCTION_HD T
pFlow::quadruple<T>::length() const
{
return sqrt(dot(*this, *this));
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::quadruple<T>::normalize()
{
T l = length();
if (static_cast< real >(l) > smallValue)
{
*this /= l;
}
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator+(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1.s_ + oprnd2.s_, oprnd1.v_ + oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator+(const quadruple<T>& oprnd1, const T& oprnd2)
{
return quadruple<T>(oprnd1.s_ + oprnd2, oprnd1.v_ + oprnd2);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator+(const T& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1 + oprnd2.s_, oprnd1 + oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator-(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1.s_ - oprnd2.s_, oprnd1.v_ - oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator-(const quadruple<T>& oprnd1, const T& oprnd2)
{
return quadruple<T>(oprnd1.s_ - oprnd2, oprnd1.v_ - oprnd2);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator-(const T& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1 - oprnd2.s_, oprnd1 - oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator*(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1.s_ * oprnd2.s_, oprnd1.v_ * oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator*(const quadruple<T>& oprnd1, const T& oprnd2)
{
return quadruple<T>(oprnd1.s_ * oprnd2, oprnd1.v_ * oprnd2);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator*(const T& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1 * oprnd2.s_, oprnd1 * oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator/(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1.s_ / oprnd2.s_, oprnd1.v_ / oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator/(const quadruple<T>& oprnd1, const T& oprnd2)
{
return quadruple<T>(oprnd1.s_ / oprnd2, oprnd1.v_ / oprnd2);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::operator/(const T& oprnd1, const quadruple<T>& oprnd2)
{
return quadruple<T>(oprnd1 / oprnd2.s_, oprnd1 / oprnd2.v_);
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::quadruple<T>::operator+=(const quadruple<T>& oprnd2)
{
this->s_ += oprnd2.s_;
this->v_ += oprnd2.v_;
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::quadruple<T>::operator-=(const quadruple<T>& oprnd2)
{
this->s_ -= oprnd2.s_;
this->v_ -= oprnd2.v_;
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::quadruple<T>::operator*=(const quadruple<T>& oprnd2)
{
this->s_ *= oprnd2.s_;
this->v_ *= oprnd2.v_;
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::quadruple<T>::operator/=(const quadruple<T>& oprnd2)
{
this->s_ /= oprnd2.s_;
this->v_ /= oprnd2.v_;
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::quadruple<T>::operator-() const
{
return quadruple<T>(-this->s_, -this->v_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::quadruple<T>
pFlow::quadruple<T>::operator+() const
{
return *this;
}
template<typename T>
INLINE_FUNCTION_HD bool
pFlow::operator==(const quadruple<T>& opr1, const quadruple<T>& opr2)
{
return equal(opr1.s_, opr2.s_) && equal(opr1.v_, opr2.v_);
};
template<typename T>
INLINE_FUNCTION_H pFlow::iOstream&
pFlow::operator<<(iOstream& str, const quadruple<T>& ov)
{
str << token::BEGIN_LIST << ov.w() << token::SPACE << ov.x() << token::SPACE
<< ov.y() << token::SPACE << ov.z() << token::END_LIST;
str.check(FUNCTION_NAME);
return str;
}
template<typename T>
INLINE_FUNCTION_H pFlow::iIstream&
pFlow::operator>>(iIstream& str, quadruple<T>& iv)
{
str.readBegin("quadruple<T>");
str >> iv.w();
str >> iv.x();
str >> iv.y();
str >> iv.z();
str.readEnd("quadruple<T>");
str.check(FUNCTION_NAME);
return str;
}
template<typename T>
INLINE_FUNCTION_H void
pFlow::readIstream(iIstream& str, quadruple<T>& iv)
{
str.readBegin("quadruple<T>");
T val;
readIstream(str, val);
iv.w() = val;
readIstream(str, val);
iv.x() = val;
readIstream(str, val);
iv.y() = val;
readIstream(str, val);
iv.z() = val;
str.readEnd("quadruple<T>");
str.check(FUNCTION_NAME);
}
pFlow::iIstream::readBegin
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: iIstream.cpp:238
pFlow::quadruple::operator-
INLINE_FUNCTION_HD quadruple operator-() const
Definition: quadrupleI.hpp:164
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::smallValue
const real smallValue
Definition: numericConstants.hpp:31
pFlow::quadruple::length
INLINE_FUNCTION_HD T length() const
Definition: quadrupleI.hpp:30
pFlow::quadruple::v_
triple< T > v_
Definition: quadruple.hpp:47
pFlow::sqrt
Vector< T, Allocator > sqrt(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:90
pFlow::quadruple::normalize
INLINE_FUNCTION_HD void normalize()
Definition: quadrupleI.hpp:37
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::operator==
INLINE_FUNCTION_HD bool operator==(const box &b1, const box &b2)
Definition: box.hpp:142
pFlow::operator/
fileSystem operator/(const fileSystem &fs1, const fileSystem &fs2)
Definition: fileSystem.cpp:280
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::operator-
array2D< T, nRow, nCol > operator-(const array2D< T, nRow, nCol > &arr1, const array2D< T, nRow, nCol > &arr2)
Definition: array2D.hpp:60
pFlow::quadruple::operator*=
INLINE_FUNCTION_HD void operator*=(const quadruple &oprnd2)
Definition: quadrupleI.hpp:148
pFlow::quadruple::s_
T s_
Definition: quadruple.hpp:46
pFlow::quadruple::operator+=
INLINE_FUNCTION_HD void operator+=(const quadruple &oprnd2)
Definition: quadrupleI.hpp:132
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
pFlow::quadruple::operator+
INLINE_FUNCTION_HD quadruple operator+() const
Definition: quadrupleI.hpp:171
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
pFlow::quadruple::operator-=
INLINE_FUNCTION_HD void operator-=(const quadruple &oprnd2)
Definition: quadrupleI.hpp:140
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
readIstream
INLINE_FUNCTION_H void readIstream(iIstream &str, quadruple< T > &iv)
pFlow::quadruple::operator/=
INLINE_FUNCTION_HD void operator/=(const quadruple &oprnd2)
Definition: quadrupleI.hpp:156
pFlow::operator*
array2D< T, nRow, nCol > operator*(const array2D< T, nRow, nCol > &arr1, const array2D< T, nRow, nCol > &arr2)
Definition: array2D.hpp:73
pFlow::quadruple
Definition: quadruple.hpp:36
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::operator+
message operator+(message::EVENT evnt1, message::EVENT evnt2)
Definition: message.hpp:216