# PhasicFlow: src/phasicFlow/structuredData/zAxis/zAxis.cpp 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.

zAxis.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 "zAxis.hpp"
pFlow::zAxis::zAxis(const realx3 &p1, const realx3 &p2)
:
p1_(p1),
p2_(p2)
{
if( equal(p1,p2))
{
fatalErrorInFunction<<
"points are equal "<< p1 <<" "<<p2<<endl;
fatalExit;
}
makeTransMatrix(p2-p1);
}
pFlow::realx3 pFlow::zAxis::transferToZ(const realx3 & p)const
{
const auto p0 = p1_-p;
array2D<real,3,1> po {p0.x(), p0.y(), p0.z()};
auto tp = MatMul(rotMat_, po);
return realx3(tp(0,0), tp(1,0), tp(2,0));
}
pFlow::realx3 pFlow::zAxis::transferBackZ(const realx3 & p)const
{
auto rp = MatMul(invRotMat_,array2D<real,3,1>{p.x(), p.y(), p.z()});
return realx3(rp(0,0)+p1_.x(),rp(1,0)+p1_.y(), rp(2,0)+p1_.z());
}
void pFlow::zAxis::makeTransMatrix(const realx3& vec)
{
const realx3 Unit = {0,0,1};
const auto v_unit = normalize(vec);
auto uvw = cross(v_unit,Unit);
const auto rcos = dot(v_unit, Unit);
const auto rsin = uvw.length();
if (abs(rsin) > smallValue)
uvw /= rsin;
const auto& [u, v, w] = uvw;
rotMat_ =
ArrayType({rcos, 0, 0, 0, rcos, 0, 0, 0, rcos})+
ArrayType({0, -w, v, w, 0, -u, -v, u, 0})+
(1-rcos)*ArrayType({u*u, u*v, u*w, u*v, v*v, w*v, u*w, v*w, w*w});
invRotMat_ = transpose(rotMat_);
}
normalize
INLINE_FUNCTION_HD triple< T > normalize(const triple< T > &v1)
pFlow::zAxis::makeTransMatrix
void makeTransMatrix(const realx3 &v)
Definition: zAxis.cpp:61
pFlow::smallValue
const real smallValue
Definition: numericConstants.hpp:31
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::transpose
array2D< T, nCol, nRow > transpose(const array2D< T, nRow, nCol > &arr)
Definition: array2D.hpp:150
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::array2D
Definition: array2D.hpp:11
pFlow::zAxis::zAxis
zAxis(const realx3 &lp1, const realx3 &lp2)
Definition: zAxis.cpp:25
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::realx3
triple< real > realx3
Definition: types.hpp:43
pFlow::triple::y
INLINE_FUNCTION_HD T & y()
access component
Definition: triple.hpp:144
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)
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::MatMul
array2D< T, nRow, nCol > MatMul(const array2D< T, nRow, nInner > &A, const array2D< T, nInner, nCol > &B)
Definition: array2D.hpp:126
pFlow::abs
Vector< T, Allocator > abs(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:84
pFlow::triple::z
INLINE_FUNCTION_HD T & z()
access component
Definition: triple.hpp:156
pFlow::zAxis::transferBackZ
realx3 transferBackZ(const realx3 &p) const
Definition: zAxis.cpp:50
pFlow::zAxis::transferToZ
realx3 transferToZ(const realx3 &p) const
Definition: zAxis.cpp:39
pFlow::triple::x
INLINE_FUNCTION_HD T & x()
access component
Definition: triple.hpp:132
pFlow::triple< real >
zAxis.hpp