www.cemf.ir
geometricRegion.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 template<typename GeomType>
23  : geom_(dict)
24  , random_()
25 {
26  minPoint_ = geom_.minPoint();
27  maxPoint_ = geom_.maxPoint();
28 }
29 
30 template<typename GeomType>
31 inline bool
33 {
34  return geom_.isInside(p);
35 }
36 
37 template<typename GeomType>
38 inline pFlow::realx3
40 {
41  for (uint32 i = 0u; i < maxTries_; i++)
42  {
43  realx3 p = random_.randomNumber(minPoint_, maxPoint_);
44 
45  if (isInside(p))
46  return p;
47  }
48 
49  fatalErrorInFunction << "cannot peek a random point from geometricRegion "
50  << typeName() << endl;
51  fatalExit;
52  return 0;
53 }
54 
55 template<typename GeomType>
56 bool
58 {
59  return geom_.read(dict);
60 }
61 
62 template<typename GeomType>
63 bool
65 {
66  return geom_.write(dict);
67 }
pFlow::geometricRegion::geom_
GeomType geom_
Definition: geometricRegion.hpp:41
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::geometricRegion::minPoint_
realx3 minPoint_
Definition: geometricRegion.hpp:43
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::geometricRegion::geometricRegion
geometricRegion(const dictionary &dict)
Definition: geometricRegion.cpp:22
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::geometricRegion::isInside
bool isInside(const realx3 &p) const
Definition: geometricRegion.cpp:32
pFlow::geometricRegion::read
bool read(const dictionary &dict)
Definition: geometricRegion.cpp:57
pFlow::geometricRegion::write
bool write(dictionary &dict) const
Definition: geometricRegion.cpp:64
pFlow::geometricRegion::maxPoint_
realx3 maxPoint_
Definition: geometricRegion.hpp:45
pFlow::geometricRegion::peek
realx3 peek() const
Definition: geometricRegion.cpp:39
pFlow::triple< real >
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