www.cemf.ir
zAxis.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #include "zAxis.hpp"
23 
24 
25 pFlow::zAxis::zAxis(const realx3 &p1, const realx3 &p2)
26 :
27  p1_(p1),
28  p2_(p2)
29 {
30  if( equal(p1,p2))
31  {
33  "points are equal "<< p1 <<" "<<p2<<endl;
34  fatalExit;
35  }
36  makeTransMatrix(p2-p1);
37 }
38 
40 {
41  const auto p0 = p1_-p;
42  array2D<real,3,1> po {p0.x(), p0.y(), p0.z()};
43 
44  auto tp = MatMul(rotMat_, po);
45 
46  return realx3(tp(0,0), tp(1,0), tp(2,0));
47 
48 }
49 
51 {
52 
53  auto rp = MatMul(invRotMat_,array2D<real,3,1>{p.x(), p.y(), p.z()});
54 
55  return realx3(rp(0,0)+p1_.x(),rp(1,0)+p1_.y(), rp(2,0)+p1_.z());
56 }
57 
58 
59 
60 
62 {
63  const realx3 Unit = {0,0,1};
64  const auto v_unit = normalize(vec);
65  auto uvw = cross(v_unit,Unit);
66 
67  const auto rcos = dot(v_unit, Unit);
68  const auto rsin = uvw.length();
69 
70  if (abs(rsin) > smallValue)
71  uvw /= rsin;
72  const auto& [u, v, w] = uvw;
73 
74  rotMat_ =
75  ArrayType({rcos, 0, 0, 0, rcos, 0, 0, 0, rcos})+
76  ArrayType({0, -w, v, w, 0, -u, -v, u, 0})+
77  (1-rcos)*ArrayType({u*u, u*v, u*w, u*v, v*v, w*v, u*w, v*w, w*w});
78 
79  invRotMat_ = transpose(rotMat_);
80 
81 }
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