# PhasicFlow: src/phasicFlow/containers/Vector/VectorI.hpp Source File

VectorI.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, typename Allocator>
inline void pFlow::Vector<T, Allocator>::fill( const T& val)
{
std::fill(this->begin(), this->end(), 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(label 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(label 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(label 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(label 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
Definition: error.hpp:57
pFlow::Vector::operator*=
void operator*=(const T &val)
Definition: VectorI.hpp:49
pFlow::Vector::operator/=
void operator/=(const T &val)
Definition: VectorI.hpp:59
pFlow::operator/
fileSystem operator/(const fileSystem &fs1, const fileSystem &fs2)
Definition: fileSystem.cpp:265
pFlow::Vector::size
auto size() const
Definition: Vector.hpp:299
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
operator*
Vector< T, Allocator > operator*(const Vector< T, Allocator > &op1, const T &op2)
pFlow::Vector::operator+=
void operator+=(const T &val)
Definition: VectorI.hpp:29
fill
void fill(Vector< T, Allocator > &vec, const T &val)
pFlow::Vector::operator-=
void operator-=(const T &val)
Definition: VectorI.hpp:39
pFlow::operator+
fileSystem operator+(const fileSystem &fs1, const word fName)
Definition: fileSystem.cpp:277
pFlow::Vector::fill
void fill(const T &val)
Definition: VectorI.hpp:22
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::Vector
Definition: Vector.hpp:46
operator-
Vector< T, Allocator > operator-(const Vector< T, Allocator > &op1, const T &op2)