# PhasicFlow: src/phasicFlow/structuredData/sphere/sphere.hpp Source File

sphere.hpp
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.
-----------------------------------------------------------------------------*/
#ifndef __sphere_hpp__
#define __sphere_hpp__
#include "types.hpp"
#include "dictionary.hpp"
#include "iIstream.hpp"
#include "iOstream.hpp"
namespace pFlow
{
class sphere
{
protected:
// - center
realx3 center_;
// - radius^2
real radius2_;
public:
// - type info
TypeInfoNV("sphere");
FUNCTION_H
sphere(const realx3& center, const real radius);
FUNCTION_H
sphere(const dictionary& dict);
FUNCTION_H
sphere(iIstream& is);
FUNCTION_HD
sphere(const sphere&) = default;
FUNCTION_HD
sphere(sphere&&) = default;
FUNCTION_HD
sphere& operator=(const sphere&) = default;
FUNCTION_HD
sphere& operator=(sphere&&) = default;
~sphere()=default;
INLINE_FUNCTION_HD
bool isInside(const realx3& point)const
{
auto cPoint = point-center_;
auto dist2 = dot(cPoint,cPoint);
return dist2 < radius2_;
}
INLINE_FUNCTION_HD
const realx3& center()const
{
return center_;
}
INLINE_FUNCTION_HD
realx3 minPoint()const
{
return center_ - realx3(radius());
}
INLINE_FUNCTION_HD
realx3 maxPoint()const
{
return center_ + realx3(radius());
}
INLINE_FUNCTION_HD
real radius()const
{
return sqrt(radius2_);
}
FUNCTION_H
bool read(iIstream & is);
FUNCTION_H
bool write(iOstream& os)const;
FUNCTION_H
bool read(const dictionary& dict);
FUNCTION_H
bool write(dictionary& dict)const;
};
FUNCTION_H
iIstream& operator >>(iIstream& is, sphere& b);
FUNCTION_H
iOstream& operator << (iOstream& os, const sphere& b);
} // pFlow
#endif // __sphere_hpp__
pFlow::sphere::center
const INLINE_FUNCTION_HD realx3 & center() const
Definition: sphere.hpp:84
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::sphere::write
FUNCTION_H bool write(iOstream &os) const
Definition: sphere.cpp:77
iIstream.hpp
types.hpp
pFlow::sphere::maxPoint
INLINE_FUNCTION_HD realx3 maxPoint() const
Definition: sphere.hpp:97
pFlow::realx3
triple< real > realx3
Definition: types.hpp:48
pFlow
Definition: demComponent.hpp:28
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::sphere::center_
realx3 center_
Definition: sphere.hpp:37
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::sphere::read
FUNCTION_H bool read(iIstream &is)
Definition: sphere.cpp:67
dictionary.hpp
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
pFlow::sphere::~sphere
~sphere()=default
pFlow::sphere::minPoint
INLINE_FUNCTION_HD realx3 minPoint() const
Definition: sphere.hpp:91
pFlow::sphere::sphere
FUNCTION_H sphere(const realx3 &center, const real radius)
Definition: sphere.cpp:26
pFlow::sphere::radius2_
real radius2_
Definition: sphere.hpp:40
pFlow::sphere
Definition: sphere.hpp:32
iOstream.hpp
pFlow::sphere::TypeInfoNV
TypeInfoNV("sphere")
pFlow::sqrt
INLINE_FUNCTION_HD real sqrt(real x)
Definition: math.hpp:148
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::sphere::radius
INLINE_FUNCTION_HD real radius() const
Definition: sphere.hpp:103
pFlow::sphere::operator=
FUNCTION_HD sphere & operator=(const sphere &)=default
pFlow::sphere::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: sphere.hpp:75