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

tripleI.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 triple<T>& oprnd1, const triple<T>& oprnd2)
{
return oprnd1.x_ * oprnd2.x_ + oprnd1.y_ * oprnd2.y_ +
oprnd1.z_ * oprnd2.z_;
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::cross(const triple<T>& v1, const triple<T>& v2)
{
return triple<T>(
v1.y_ * v2.z_ - v1.z_ * v2.y_,
v1.z_ * v2.x_ - v1.x_ * v2.z_,
v1.x_ * v2.y_ - v1.y_ * v2.x_
);
}
template<typename T>
INLINE_FUNCTION_HD T
pFlow::length(const triple<T>& v1)
{
return v1.length();
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::normalize(const triple<T>& v1)
{
return v1 / max(length(v1), verySmallValue);
}
template<typename T>
INLINE_FUNCTION_HD T
pFlow::triple<T>::length() const
{
return sqrt(dot(*this, *this));
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::triple<T>::normalize()
{
*this = *this / max(length(), verySmallValue);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator+(const triple<T>& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1.x_ + oprnd2.x_, oprnd1.y_ + oprnd2.y_, oprnd1.z_ + oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator+(const triple<T>& oprnd1, const T& oprnd2)
{
return triple<T>(
oprnd1.x_ + oprnd2, oprnd1.y_ + oprnd2, oprnd1.z_ + oprnd2
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator+(const T& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1 + oprnd2.x_, oprnd1 + oprnd2.y_, oprnd1 + oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator-(const triple<T>& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1.x_ - oprnd2.x_, oprnd1.y_ - oprnd2.y_, oprnd1.z_ - oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator-(const triple<T>& oprnd1, const T& oprnd2)
{
return triple<T>(
oprnd1.x_ - oprnd2, oprnd1.y_ - oprnd2, oprnd1.z_ - oprnd2
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator-(const T& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1 - oprnd2.x_, oprnd1 - oprnd2.y_, oprnd1 - oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator*(const triple<T>& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1.x_ * oprnd2.x_, oprnd1.y_ * oprnd2.y_, oprnd1.z_ * oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator*(const triple<T>& oprnd1, const T& oprnd2)
{
return triple<T>(
oprnd1.x_ * oprnd2, oprnd1.y_ * oprnd2, oprnd1.z_ * oprnd2
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator*(const T& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1 * oprnd2.x_, oprnd1 * oprnd2.y_, oprnd1 * oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator/(const triple<T>& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1.x_ / oprnd2.x_, oprnd1.y_ / oprnd2.y_, oprnd1.z_ / oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator/(const triple<T>& oprnd1, const T& oprnd2)
{
return triple<T>(
oprnd1.x_ / oprnd2, oprnd1.y_ / oprnd2, oprnd1.z_ / oprnd2
);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::operator/(const T& oprnd1, const triple<T>& oprnd2)
{
return triple<T>(
oprnd1 / oprnd2.x_, oprnd1 / oprnd2.y_, oprnd1 / oprnd2.z_
);
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::triple<T>::operator+=(const triple<T>& oprnd2)
{
this->x_ = this->x_ + oprnd2.x_;
this->y_ = this->y_ + oprnd2.y_;
this->z_ = this->z_ + oprnd2.z_;
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::triple<T>::operator-=(const triple<T>& oprnd2)
{
this->x_ = this->x_ - oprnd2.x_;
this->y_ = this->y_ - oprnd2.y_;
this->z_ = this->z_ - oprnd2.z_;
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::triple<T>::operator*=(const triple<T>& oprnd2)
{
this->x_ = this->x_ * oprnd2.x_;
this->y_ = this->y_ * oprnd2.y_;
this->z_ = this->z_ * oprnd2.z_;
}
template<typename T>
INLINE_FUNCTION_HD void
pFlow::triple<T>::operator/=(const triple<T>& oprnd2)
{
this->x_ = this->x_ / oprnd2.x_;
this->y_ = this->y_ / oprnd2.y_;
this->z_ = this->z_ / oprnd2.z_;
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::triple<T>::operator-() const
{
return triple<T>(-this->x_, -this->y_, -this->z_);
}
template<typename T>
INLINE_FUNCTION_HD pFlow::triple<T>
pFlow::triple<T>::operator+() const
{
return *this;
}
template<typename T>
INLINE_FUNCTION_HD bool
pFlow::operator==(const triple<T>& opr1, const triple<T>& opr2)
{
return equal(opr1, opr2);
};
template<typename T>
INLINE_FUNCTION_HD bool
pFlow::operator<(const triple<T>& opr1, const triple<T>& opr2)
{
if (opr1.x_ < opr2.x_ && opr1.y_ < opr2.y_ && opr1.z_ < opr2.z_)
{
return true;
}
else
{
return false;
}
};
template<typename T>
INLINE_FUNCTION_HD bool
pFlow::operator>(const triple<T>& opr1, const triple<T>& opr2)
{
if (opr1.x_ > opr2.x_ && opr1.y_ > opr2.y_ && opr1.z_ > opr2.z_)
{
return true;
}
else
{
return false;
}
};
template<typename T>
INLINE_FUNCTION_HD bool
pFlow::operator<=(const triple<T>& opr1, const triple<T>& opr2)
{
if (opr1.x_ <= opr2.x_ && opr1.y_ <= opr2.y_ && opr1.z_ <= opr2.z_)
{
return true;
}
else
{
return false;
}
}
template<typename T>
INLINE_FUNCTION_HD bool
pFlow::operator>=(const triple<T>& opr1, const triple<T>& opr2)
{
if (opr1.x_ >= opr2.x_ && opr1.y_ >= opr2.y_ && opr1.z_ >= opr2.z_)
{
return true;
}
else
{
return false;
}
}
template<typename T>
INLINE_FUNCTION pFlow::iOstream&
pFlow::operator<<(iOstream& str, const triple<T>& ov)
{
str << token::BEGIN_LIST << ov.x_ << token::SPACE << ov.y_ << token::SPACE
<< ov.z_ << token::END_LIST;
str.check(FUNCTION_NAME);
return str;
}
template<typename T>
INLINE_FUNCTION pFlow::iIstream&
pFlow::operator>>(iIstream& str, triple<T>& iv)
{
str.readBegin("triple<T>");
str >> iv.x_;
str >> iv.y_;
str >> iv.z_;
str.readEnd("triple<T>");
str.check(FUNCTION_NAME);
return str;
}
template<typename T>
INLINE_FUNCTION void
pFlow::readIstream(iIstream& str, triple<T>& iv)
{
str.readBegin("triple<T>");
T val;
readIstream(str, val);
iv.x_ = val;
readIstream(str, val);
iv.y_ = val;
readIstream(str, val);
iv.z_ = val;
str.readEnd("triple<T>");
str.check(FUNCTION_NAME);
}
template<typename T>
bool INLINE_FUNCTION_HD
pFlow::equal(const triple<T>& opr1, const triple<T>& opr2)
{
return equal(opr1.x(), opr2.x()) && equal(opr1.y(), opr2.y()) &&
equal(opr1.z(), opr2.z());
}
normalize
INLINE_FUNCTION_HD triple< T > normalize(const triple< T > &v1)
pFlow::iIstream::readBegin
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: iIstream.cpp:238
pFlow::triple::operator+=
INLINE_FUNCTION_HD void operator+=(const triple &oprnd2)
Definition: tripleI.hpp:178
pFlow::verySmallValue
const real verySmallValue
Definition: numericConstants.hpp:32
INLINE_FUNCTION
#define INLINE_FUNCTION
Definition: pFlowMacros.hpp:66
pFlow::triple::operator*=
INLINE_FUNCTION_HD void operator*=(const triple &oprnd2)
Definition: tripleI.hpp:196
pFlow::sqrt
Vector< T, Allocator > sqrt(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:90
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
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
operator<
INLINE_FUNCTION_HD bool operator<(const triple< T > &opr1, const triple< T > &opr2)
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
operator<=
INLINE_FUNCTION_HD bool operator<=(const triple< T > &opr1, const triple< T > &opr2)
pFlow::triple::y
INLINE_FUNCTION_HD T & y()
access component
Definition: triple.hpp:144
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
cross
INLINE_FUNCTION_HD triple< T > cross(const triple< T > &v1, const triple< T > &v2)
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
pFlow::triple::operator-
INLINE_FUNCTION_HD triple operator-() const
unary negate operator
Definition: tripleI.hpp:214
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::triple::operator-=
INLINE_FUNCTION_HD void operator-=(const triple &oprnd2)
Definition: tripleI.hpp:187
pFlow::triple::normalize
INLINE_FUNCTION_HD void normalize()
Normalize the vector.
Definition: tripleI.hpp:63
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::triple::x_
T x_
data members
Definition: triple.hpp:49
readIstream
INLINE_FUNCTION_H void readIstream(iIstream &str, quadruple< T > &iv)
pFlow::triple::z
INLINE_FUNCTION_HD T & z()
access component
Definition: triple.hpp:156
operator>
INLINE_FUNCTION_HD bool operator>(const triple< T > &opr1, const triple< T > &opr2)
pFlow::triple::y_
T y_
Definition: triple.hpp:50
pFlow::operator*
array2D< T, nRow, nCol > operator*(const array2D< T, nRow, nCol > &arr1, const array2D< T, nRow, nCol > &arr2)
Definition: array2D.hpp:73
pFlow::triple::z_
T z_
Definition: triple.hpp:51
operator>=
INLINE_FUNCTION_HD bool operator>=(const triple< T > &opr1, const triple< T > &opr2)
pFlow::triple::x
INLINE_FUNCTION_HD T & x()
access component
Definition: triple.hpp:132
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple
A set of 3 variables that can be used for vector variables.
Definition: triple.hpp:36
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::triple::operator+
INLINE_FUNCTION_HD triple operator+() const
unary plus operator
Definition: tripleI.hpp:221
pFlow::triple::operator/=
INLINE_FUNCTION_HD void operator/=(const triple &oprnd2)
Definition: tripleI.hpp:205
pFlow::operator+
message operator+(message::EVENT evnt1, message::EVENT evnt2)
Definition: message.hpp:216
pFlow::triple::length
INLINE_FUNCTION_HD T length() const
Length of the vector.
Definition: tripleI.hpp:56