www.cemf.ir
planeWall.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 "planeWall.hpp"
23 #include "line.hpp"
24 
26 (
27  const dictionary& dict
28 )
29 {
30  auto p1 = dict.getVal<realx3>("p1");
31  auto p2 = dict.getVal<realx3>("p2");
32  auto p3 = dict.getVal<realx3>("p3");
33  auto p4 = dict.getVal<realx3>("p4");
34 
35  auto numDiv12 = max(dict.getValOrSet<int32>("numDiv12",1),1);
36  auto numDiv23 = max(dict.getValOrSet<int32>("numDiv23",1),1);
37 
38 
39  if(!checkFlatness(p1,p2,p3,p4))
40  {
42  "points p1, p2, p3 and p4 do not form a plane wall in dictionary " << dict.globalName()<<endl;
43  return false;
44  }
45 
46  if(!addPlaneWall(p1,p2,p3,p4,numDiv12,numDiv23))
47  {
49  "could not create plane wall from dictionary "<< dict.globalName()<<endl;
50  return false;
51  }
52 
53  return true;
54 
55 }
56 
57 
59  const realx3& p1,
60  const realx3& p2,
61  const realx3& p3,
62  const realx3& p4)
63 {
64 
65  if(!checkFlatness(p1,p2,p3,p4))return false;
66 
67  triangles_.push_back(realx3x3(p1,p2,p3));
68  triangles_.push_back(realx3x3(p3,p4,p1));
69 
70  return true;
71 }
72 
74  const realx3& p1,
75  const realx3& p2,
76  const realx3& p3,
77  const realx3& p4)
78 {
79  if( !Wall::checkTrianlge(p1,p2,p3) ) return false;
80  if( !Wall::checkTrianlge(p3,p4,p1) ) return false;
81  return true;
82 }
83 
85  const realx3& p1,
86  const realx3& p2,
87  const realx3& p3,
88  const realx3& p4,
89  int32 numDiv12,
90  int32 numDiv23 )
91 {
92  real dt12 = 1.0/numDiv12;
93  real dt23 = 1.0/numDiv23;
94 
95  real t12 = 0;
96 
97 
98  line line12(p1,p2);
99  line line43(p4,p3);
100 
101  for(int32 i=0; i<numDiv12; i++)
102  {
103 
104  auto lp1 = line12.point(t12);
105  auto lp4 = line43.point(t12);
106  auto lp2 = line12.point(t12+dt12);
107  auto lp3 = line43.point(t12+dt12);
108 
109  line line14(lp1,lp4);
110  line line23(lp2,lp3);
111  real t23 = 0;
112  for(int32 j=0; j<numDiv23; j++)
113  {
114  if(
115  !addWall4(
116  line14.point(t23),
117  line23.point(t23),
118  line23.point(t23+dt23),
119  line14.point(t23+dt23) )
120  )
121  {
122  return false;
123  }
124  t23+=dt23;
125  }
126  t12+=dt12;
127  }
128 
129 
130  return true;
131 }
132 
134 {}
135 
137 (
138  const dictionary& dict
139 )
140 :
141  Wall(dict)
142 {
143  if(!readPlaneWall(dict))
144  {
145  fatalExit;
146  }
147 }
148 
150  const realx3& p1,
151  const realx3& p2,
152  const realx3& p3,
153  const realx3& p4,
154  int32 numDiv12,
155  int32 numDiv23 )
156 {
157 
158  if(!checkFlatness(p1,p2,p3,p4))
159  {
161  "the input points p1, p2, p3, and p4 are not in the same plane "<<endl;
162  fatalExit;
163  }
164 
165  if(!addPlaneWall(p1,p2,p3,p4, numDiv12, numDiv23))
166  {
168  "could not create plane wall from input points "<<endl;
169  fatalExit;
170  }
171 
172 }
173 
pFlow::Wall::triangles_
std::vector< realx3x3 > triangles_
Definition: Wall.hpp:45
pFlow::planeWall::readPlaneWall
bool readPlaneWall(const dictionary &dict)
Definition: planeWall.cpp:26
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
get the value of data entry or if not found, set the value to setVal
Definition: dictionary.hpp:415
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::line
Definition: line.hpp:36
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
planeWall.hpp
pFlow::planeWall::addWall4
bool addWall4(const realx3 &p1, const realx3 &p2, const realx3 &p3, const realx3 &p4)
Definition: planeWall.cpp:58
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::line::point
INLINE_FUNCTION_HD realx3 point(real t) const
Definition: line.hpp:102
pFlow::planeWall::addPlaneWall
bool addPlaneWall(const realx3 &p1, const realx3 &p2, const realx3 &p3, const realx3 &p4, int32 numDiv12=1, int32 numDiv23=1)
Definition: planeWall.cpp:84
pFlow::planeWall::planeWall
planeWall()
Definition: planeWall.cpp:133
pFlow::realx3x3
triple< realx3 > realx3x3
Definition: types.hpp:47
pFlow::planeWall::checkFlatness
bool checkFlatness(const realx3 &p1, const realx3 &p2, const realx3 &p3, const realx3 &p4)
Definition: planeWall.cpp:73
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::Wall::checkTrianlge
static bool checkTrianlge(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: Wall.cpp:46
pFlow::triple< real >
pFlow::Wall
Definition: Wall.hpp:41
line.hpp
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67