www.cemf.ir
sphereRegion.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 "sphereRegion.hpp"
22 #include "dictionary.hpp"
23 
25 (
26  const dictionary& dict
27 )
28 :
29  sphere_(dict),
30  random_()
31 {
32 
33 }
34 
36 (
37  const realx3& p
38 ) const
39 {
40  return sphere_.isInside(p);
41 }
42 
44 {
45  for(int32 i=0; i<100; ++i)
46  {
47  auto p = random_.randomNumber(
50  if(sphere_.isInside(p)) return p;
51  }
52 
54  "cannot peek a random point from sphereRegion. \n";
55  fatalExit;
56  return 0;
57 
58 }
59 
60 
62 (
63  const dictionary& dict
64 )
65 {
66  sphere_.read(dict);
67 
68  return true;
69 }
70 
72 (
73  dictionary& dict
74 )const
75 {
76  if(!sphere_.write(dict))
77  {
79  " error in writing sphere data to dictionary "<<dict.globalName()<<endl;
80  return false;
81  }
82 
83  return true;
84 }
pFlow::sphere::center
const INLINE_FUNCTION_HD realx3 & center() const
Definition: sphere.hpp:84
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::sphereRegion::sphere_
sphere sphere_
Definition: sphereRegion.hpp:37
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::sphereRegion::isInside
bool isInside(const realx3 &p) const
Definition: sphereRegion.cpp:36
pFlow::sphereRegion::write
bool write(dictionary &dict) const
Definition: sphereRegion.cpp:72
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
dictionary.hpp
pFlow::sphereRegion::random_
uniformRandomReal random_
Definition: sphereRegion.hpp:39
sphereRegion.hpp
pFlow::sphereRegion::peek
realx3 peek() const
Definition: sphereRegion.cpp:43
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
pFlow::sphereRegion::read
bool read(const dictionary &dict)
Definition: sphereRegion.cpp:62
pFlow::sphere::radius
INLINE_FUNCTION_HD real radius() const
Definition: sphere.hpp:103
pFlow::sphereRegion::sphereRegion
sphereRegion(const dictionary &dict)
Definition: sphereRegion.cpp:25
pFlow::uniformRandomReal::randomNumber
real randomNumber(real a, real b)
Definition: uniformRandomReal.hpp:53
pFlow::sphere::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: sphere.hpp:75