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

cylinder.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 __cylinder_hpp__
#define __cylinder_hpp__
#include "types.hpp"
#include "dictionary.hpp"
#include "iIstream.hpp"
#include "iOstream.hpp"
namespace pFlow
{
class cylinder
{
protected:
// - begin point
realx3 p1_;
// - end point
realx3 p2_;
// - radius^2
real radius2_;
realx3 axisVector_;
real axisVector2_;
realx3 minPoint_;
realx3 maxPoint_;
FUNCTION_H
bool calculateParams();
public:
// - type info
TypeInfoNV("cylinder");
FUNCTION_H
cylinder(const realx3& p1, const realx3& p2, const real radius);
FUNCTION_H
cylinder(const dictionary& dict);
FUNCTION_H
cylinder(iIstream& is);
FUNCTION_HD
cylinder(const cylinder&) = default;
FUNCTION_HD
cylinder(cylinder&&) = default;
FUNCTION_HD
cylinder& operator=(const cylinder&) = default;
FUNCTION_HD
cylinder& operator=(cylinder&&) = default;
~cylinder()=default;
INLINE_FUNCTION_HD
bool isInside(const realx3& point)const
{
auto p1Point = point-p1_;
auto H = cross(p1Point , axisVector_);
auto H2 = dot(H,H);
if( H2 < radius2_*axisVector2_)
{
real t = dot(p1Point, axisVector_)/axisVector2_;
if(t >= 0.0 && t <= 1.0)
return true;
else
return false;
}
else
{
return false;
}
}
INLINE_FUNCTION_HD
const realx3& p1()const
{
return p1_;
}
INLINE_FUNCTION_HD
const realx3& p2()const
{
return p2_;
}
INLINE_FUNCTION_HD
realx3 minPoint()const
{
return minPoint_;
}
INLINE_FUNCTION_HD
realx3 maxPoint()const
{
return maxPoint_;
}
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, cylinder& b);
FUNCTION_H
iOstream& operator << (iOstream& os, const cylinder& b);
} // pFlow
#endif // __cylinder_hpp__
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::cylinder::write
FUNCTION_H bool write(iOstream &os) const
Definition: cylinder.cpp:124
iIstream.hpp
pFlow::cylinder::~cylinder
~cylinder()=default
pFlow::cylinder::maxPoint_
realx3 maxPoint_
Definition: cylinder.hpp:51
types.hpp
pFlow::cylinder::operator=
FUNCTION_HD cylinder & operator=(const cylinder &)=default
pFlow::cylinder::TypeInfoNV
TypeInfoNV("cylinder")
pFlow::cylinder::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: cylinder.hpp:88
pFlow::cylinder::radius
INLINE_FUNCTION_HD real radius() const
Definition: cylinder.hpp:133
pFlow
Definition: demComponent.hpp:28
pFlow::cylinder::minPoint
INLINE_FUNCTION_HD realx3 minPoint() const
Definition: cylinder.hpp:121
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::cylinder
Definition: cylinder.hpp:32
cross
INLINE_FUNCTION_HD triple< T > cross(const triple< T > &v1, const triple< T > &v2)
pFlow::cylinder::axisVector2_
real axisVector2_
Definition: cylinder.hpp:47
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::cylinder::p2_
realx3 p2_
Definition: cylinder.hpp:40
pFlow::cylinder::p2
const INLINE_FUNCTION_HD realx3 & p2() const
Definition: cylinder.hpp:115
dictionary.hpp
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::cylinder::cylinder
FUNCTION_H cylinder(const realx3 &p1, const realx3 &p2, const real radius)
Definition: cylinder.cpp:53
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::cylinder::radius2_
real radius2_
Definition: cylinder.hpp:43
pFlow::cylinder::p1_
realx3 p1_
Definition: cylinder.hpp:37
pFlow::cylinder::maxPoint
INLINE_FUNCTION_HD realx3 maxPoint() const
Definition: cylinder.hpp:127
pFlow::cylinder::p1
const INLINE_FUNCTION_HD realx3 & p1() const
Definition: cylinder.hpp:109
pFlow::cylinder::read
FUNCTION_H bool read(iIstream &is)
Definition: cylinder.cpp:113
pFlow::cylinder::calculateParams
FUNCTION_H bool calculateParams()
Definition: cylinder.cpp:26
pFlow::cylinder::axisVector_
realx3 axisVector_
Definition: cylinder.hpp:45
pFlow::cylinder::minPoint_
realx3 minPoint_
Definition: cylinder.hpp:49
iOstream.hpp
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