# PhasicFlow: src/phasicFlow/containers/Vector/VectorI.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.

VectorI.hpp
Go to the documentation of this file.
#include "Vector.hpp"
/*------------------------------- 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, typename Allocator>
inline void pFlow::Vector<T, Allocator>::fill( const T& val)
{
std::fill(this->begin(), this->end(), val);
}
template <typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::fill(uint32 start, uint32 end, const T &val)
{
for(uint32 i=start; i<end; i++)
{
this->at(i) = val;
}
}
#pragma hd_warning_disable
template < typename T, typename Allocator> inline void pFlow::Vector < T, Allocator> ::operator+= (const T &val)
{
for( auto& v:(*this) )
{
v+= val;
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator -=( const T& val)
{
for( auto& v:(*this) )
{
v -= val;
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator *=( const T& val)
{
for( auto& v:(*this) )
{
v *= val;
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator /=( const T& val)
{
for( auto& v:(*this) )
{
v /= val;
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator +=( const Vector<T, Allocator>& v )
{
if(size() != v.size() )
{
fatalErrorInFunction <<
"the += operator is invalid, vector size of right side (" << v.size() <<
") is not equal to the left side (" << size() << ").\n";
fatalExit;
}
for(size_t i=0; i<v.size(); i++)
{
this->operator[](i) += v[i];
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator -=( const Vector<T, Allocator>& v )
{
if(size() != v.size() )
{
fatalErrorInFunction <<
"the -= operator is invalid, vector size of right side (" << v.size() <<
") is not equal to the left side (" << size() << ").\n";
fatalExit;
}
for(size_t i=0; i<v.size(); i++)
{
this->operator[](i) -= v[i];
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator *=( const Vector<T, Allocator>& v )
{
if(size() != v.size() )
{
fatalErrorInFunction <<
"the * operator is invalid, vector size of right side (" << v.size() <<
") is not equal to the left side (" << size() << ").\n";
fatalExit;
}
for(size_t i=0; i<v.size(); i++)
{
this->operator[](i) *= v[i];
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline void pFlow::Vector<T, Allocator>::operator /=( const Vector<T, Allocator>& v )
{
if(size() != v.size() )
{
fatalErrorInFunction <<
"the /= operator is invalid, vector size of right side (" << v.size() <<
") is not equal to the left side (" << size() << ").\n";
fatalExit;
}
for(size_t i=0; i<v.size(); i++)
{
this->operator[](i) /= v[i];
}
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::Vector<T, Allocator>::operator -
(
)const
{
Vector<T, Allocator> res(*this);
for( auto& vi:res)
{
vi = -vi;
}
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator+ (const Vector<T, Allocator>& op1, const T& op2 )
{
Vector<T, Allocator> res(op1);
res += op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator+ (const T& op1, const Vector<T, Allocator>& op2 )
{
Vector<T, Allocator> res(op2);
res += op1;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator+ (const Vector<T, Allocator>& op1, const Vector<T, Allocator>& op2 )
{
if( op1.size() != op2.size() )
{
fatalErrorInFunction <<
"the + operator is invalid, vector size of operand1 (" << op1.size() <<
") is not equal to vector size of operand2 (" << op1.size() << ").\n";
fatalExit;
}
Vector<T, Allocator> res(op1);
res += op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator - (const Vector<T, Allocator>& op1, const T& op2 )
{
Vector<T, Allocator> res(op1);
res -= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator - (const T& op1, const Vector<T, Allocator>& op2 )
{
Vector<T, Allocator> res(op2.size(), op1);
res -= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator - (const Vector<T, Allocator>& op1, const Vector<T, Allocator>& op2 )
{
if( op1.size() != op2.size() )
{
fatalErrorInFunction <<
"the - operator is invalid, vector size of operand1 (" << op1.size() <<
") is not equal to vector size of operand2 (" << op1.size() << ").\n";
fatalExit;
}
Vector<T, Allocator> res(op1);
res -= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator* (const Vector<T, Allocator>& op1, const T& op2 )
{
Vector<T, Allocator> res(op1);
res *= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator* (const T& op1, const Vector<T, Allocator>& op2 )
{
Vector<T, Allocator> res(op2);
res *= op1;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator* (const Vector<T, Allocator>& op1, const Vector<T, Allocator>& op2 )
{
if( op1.size() != op2.size() )
{
fatalErrorInFunction <<
"the * operator is invalid, vector size of operand1 (" << op1.size() <<
") is not equal to vector size of operand2 (" << op1.size() << ").\n";
fatalExit;
}
Vector<T, Allocator> res(op1);
res *= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator / (const Vector<T, Allocator>& op1, const T& op2 )
{
Vector<T, Allocator> res(op1);
res /= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator / (const T& op1, const Vector<T, Allocator>& op2 )
{
Vector<T, Allocator> res(op2.size(), op1);
res /= op2;
return res;
}
#pragma hd_warning_disable
template<typename T, typename Allocator>
inline pFlow::Vector<T, Allocator> pFlow::operator / (const Vector<T, Allocator>& op1, const Vector<T, Allocator>& op2 )
{
if( op1.size() != op2.size() )
{
fatalErrorInFunction <<
"the / operator is invalid, vector size of operand1 (" << op1.size() <<
") is not equal to vector size of operand2 (" << op1.size() << ").\n";
fatalExit;
}
Vector<T, Allocator> res(op1);
res /= op2;
return res;
}
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::Vector::operator*=
void operator*=(const T &val)
Definition: VectorI.hpp:58
pFlow::Vector::operator/=
void operator/=(const T &val)
Definition: VectorI.hpp:68
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::operator/
fileSystem operator/(const fileSystem &fs1, const fileSystem &fs2)
Definition: fileSystem.cpp:280
pFlow::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::operator-
array2D< T, nRow, nCol > operator-(const array2D< T, nRow, nCol > &arr1, const array2D< T, nRow, nCol > &arr2)
Definition: array2D.hpp:60
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::Vector::operator+=
void operator+=(const T &val)
Definition: VectorI.hpp:38
fill
void fill(Vector< T, Allocator > &vec, const T &val)
pFlow::Vector::operator-=
void operator-=(const T &val)
Definition: VectorI.hpp:48
pFlow::operator*
array2D< T, nRow, nCol > operator*(const array2D< T, nRow, nCol > &arr1, const array2D< T, nRow, nCol > &arr2)
Definition: array2D.hpp:73
pFlow::Vector::fill
void fill(const T &val)
Definition: VectorI.hpp:23
pFlow::Vector
Definition: Vector.hpp:48
Vector.hpp
pFlow::operator+
message operator+(message::EVENT evnt1, message::EVENT evnt2)
Definition: message.hpp:216