www.cemf.ir
triWall.hpp
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 #ifndef __triWall_hpp__
22 #define __triWall_hpp__
23 
24 #include "types.hpp"
25 
27 {
28 
29 struct triWall
30 {
31 
34 
36  triWall(const realx3& p1, const realx3& p2, const realx3& p3)
37  {
38  if(!makeWall(p1,p2,p3, n_, offset_))
39  {
41  "bad input for the wall.\n";
42  fatalExit;
43  }
44  }
45 
47  triWall(bool, const realx3& p1, const realx3& p2, const realx3& p3)
48  {
49  makeWall(p1,p2,p3,n_,offset_);
50  }
51 
53  triWall(const realx3x3& tri)
54  {
55  makeWall(tri.x_, tri.y_, tri.z_, n_, offset_);
56  }
57 
59  triWall(const triWall&) = default;
60 
62  triWall& operator=(const triWall&) = default;
63 
65  triWall(triWall&&) = default;
66 
68  triWall& operator=(triWall&&) = default;
69 
71  ~triWall()=default;
72 
73 
75  real normalDistFromWall(const realx3 &p) const
76  {
77  return dot(n_, p) + offset_;
78  }
79 
82  {
83  real t = -(dot(n_, p) + offset_);
84  return realx3(n_.x_*t + p.x_, n_.y_*t + p.y_, n_.z_*t + p.z_);
85  }
86 
87  INLINE_FUNCTION_HD static
88  bool makeWall(
89  const realx3& p1,
90  const realx3& p2,
91  const realx3& p3,
92  realx3& n, real& offset)
93  {
94  n = cross(p2 - p1, p3 - p1);
95  real len = length(n);
96 
97  if (len < 0.00000000001) return false;
98  n /= len;
99  offset = -dot(n, p1);
100  return true;
101  }
102 
103 
104 };
105 
106 }
107 
108 #endif
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::grnTriInteraction::triWall::triWall
INLINE_FUNCTION_H triWall(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triWall.hpp:36
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::grnTriInteraction::triWall::offset_
real offset_
Definition: triWall.hpp:33
pFlow::grnTriInteraction::triWall::n_
realx3 n_
Definition: triWall.hpp:32
pFlow::grnTriInteraction::triWall::~triWall
INLINE_FUNCTION_HD ~triWall()=default
types.hpp
pFlow::grnTriInteraction::triWall::operator=
INLINE_FUNCTION_HD triWall & operator=(const triWall &)=default
pFlow::grnTriInteraction::triWall::nearestPointOnWall
INLINE_FUNCTION_HD realx3 nearestPointOnWall(const realx3 &p) const
Definition: triWall.hpp:81
pFlow::grnTriInteraction
Definition: grainTriSurfaceContact.hpp:28
pFlow::realx3
triple< real > realx3
Definition: types.hpp:43
pFlow::grnTriInteraction::triWall::triWall
INLINE_FUNCTION_HD triWall(bool, const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triWall.hpp:47
pFlow::grnTriInteraction::triWall::normalDistFromWall
INLINE_FUNCTION_HD real normalDistFromWall(const realx3 &p) const
Definition: triWall.hpp:75
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
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::triple::x_
T x_
data members
Definition: triple.hpp:49
pFlow::triple::y_
T y_
Definition: triple.hpp:50
pFlow::triple::z_
T z_
Definition: triple.hpp:51
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::grnTriInteraction::triWall::makeWall
static INLINE_FUNCTION_HD bool makeWall(const realx3 &p1, const realx3 &p2, const realx3 &p3, realx3 &n, real &offset)
Definition: triWall.hpp:88
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::grnTriInteraction::triWall::triWall
INLINE_FUNCTION_HD triWall(const realx3x3 &tri)
Definition: triWall.hpp:53
pFlow::grnTriInteraction::triWall
Definition: triWall.hpp:29