# PhasicFlow: src/phasicFlow/structuredData/peakableRegion/sphereRegion/sphereRegion.cpp Source File

sphereRegion.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#include "sphereRegion.hpp"
#include "dictionary.hpp"
pFlow::sphereRegion::sphereRegion
(
const dictionary& dict
)
:
sphere_(dict),
random_()
{
}
bool pFlow::sphereRegion::isInside
(
const realx3& p
) const
{
return sphere_.isInside(p);
}
pFlow::realx3 pFlow::sphereRegion::peek()const
{
for(int32 i=0; i<100; ++i)
{
auto p = random_.randomNumber(
sphere_.center() - realx3(sphere_.radius()),
sphere_.center() + realx3(sphere_.radius()));
if(sphere_.isInside(p)) return p;
}
fatalErrorInFunction<<
"cannot peek a random point from sphereRegion. \n";
fatalExit;
return 0;
}
bool pFlow::sphereRegion::read
(
const dictionary& dict
)
{
sphere_.read(dict);
return true;
}
bool pFlow::sphereRegion::write
(
dictionary& dict
)const
{
if(!sphere_.write(dict))
{
fatalErrorInFunction<<
" error in writing sphere data to dictionary "<<dict.globalName()<<endl;
return false;
}
return true;
}
pFlow::sphere::center
const INLINE_FUNCTION_HD realx3 & center() const
Definition: sphere.hpp:84
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::dictionary::globalName
virtual word globalName() const
Definition: dictionary.cpp:349
pFlow::sphereRegion::sphere_
sphere sphere_
Definition: sphereRegion.hpp:37
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
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
Definition: error.hpp:42
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
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
Definition: dictionary.hpp:38
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