www.cemf.ir
infinitePlane.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 #include "infinitePlane.hpp"
22 
24 (
25  const realx3& p1,
26  const realx3& p2,
27  const realx3& p3
28 )
29 {
30  auto ln = cross(p2-p1, p3-p1);
31 
32  if( equal(ln.length(),0.0) )
33  {
35  "invalid input to form a infinte wall "<< realx3x3(p1,p2,p3)<<endl;
36  fatalExit;
37  }
38  normal_ = normalize(ln);
39  d_ = -dot(normal_, p1);
40 }
41 
43 {
44  os.writeWordEntry("normal", normal_);
45  os.writeWordEntry("d", d_);
46  return os.check(FUNCTION_NAME);
47 }
48 
50 {
51  if(!is.nextData<realx3>("normal", normal_)) return false;
52  if(!is.nextData<real>("d", d_)) return false;
53  return true;
54 }
55 
57 (
58  const realx3& p1,
59  const realx3& p2,
60  const realx3& p3
61 )
62 {
63  return !equal(cross(p2-p1, p3-p1).length(), 0.0);
64 }
normalize
INLINE_FUNCTION_HD triple< T > normalize(const triple< T > &v1)
pFlow::infinitePlane::normal_
realx3 normal_
normal vector
Definition: infinitePlane.hpp:37
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::infinitePlane::read
bool read(iIstream &is)
Definition: infinitePlane.cpp:49
pFlow::infinitePlane::write
FUNCTION_H bool write(iOstream &os) const
Definition: infinitePlane.cpp:42
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::infinitePlane::infinitePlane
INLINE_FUNCTION_HD infinitePlane()
Default.
Definition: infinitePlane.hpp:51
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
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)
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
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)
pFlow::iIstream::nextData
bool nextData(const word &keyword, T &data)
read the data next to keword keyword data; check the keyword is correct or not
Definition: iIstreamI.hpp:81
infinitePlane.hpp
pFlow::realx3x3
triple< realx3 > realx3x3
Definition: types.hpp:47
pFlow::infinitePlane::validPlane3
static bool validPlane3(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: infinitePlane.cpp:57
pFlow::infinitePlane::d_
real d_
distance value
Definition: infinitePlane.hpp:40
pFlow::triple< real >
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Write a keyword/value entry.
Definition: iOstream.hpp:239