# PhasicFlow: utilities/Utilities/geometryPhasicFlow/cylinderWall/cylinderWall.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

cylinderWall.cpp
Go to the documentation of this file.
#include "cylinderWall.hpp"
#include "Vectors.hpp"
#include "line.hpp"
bool pFlow::cylinderWall::readCylinderWall(const dictionary& dict)
{
auto p1 = dict.getVal<realx3>("p1");
auto p2 = dict.getVal<realx3>("p2");
auto radius1 = dict.getVal<real>("radius1");
auto radius2 = dict.getVal<real>("radius2") ;
int32 resolution = dict.getValOrSet("resolution", 24 );
int32 zResolution = dict.getValOrSet("zResolution", 1);
triangles_.clear();
triangles_.reserve(2*resolution*zResolution);
line cylAxis(p1, p2);
auto lp1 = p1;
auto dt = static_cast< real >(1.0/zResolution);
real t = 0;
for(int32 i=0; i<zResolution; i++)
{
t += dt;
auto lp2 = cylAxis.point(t);
if(!createCylinder(lp1, lp2, radius1, radius2, resolution))
return false;
lp1 = lp2;
}
return true;
}
bool pFlow::cylinderWall::createCylinder(
const realx3& p1,
const realx3& p2,
real rad1,
real rad2,
int32 numDiv)
{
zAxis zAx(p1, p2);
real L = zAx.length();
realx3Vector r1P("r1P",numDiv + 1), r2P("r1P",numDiv + 1);
real dTheta = 2 * Pi / numDiv;
real theta = 0;
for (int32 i = 0; i < numDiv + 1; i++)
{
r1P[i] = realx3(rad1*cos(theta), rad1*sin(theta), 0);
r2P[i] = realx3(rad2*cos(theta), rad2*sin(theta), L);
theta += dTheta;
}
// transferring back all points to the original axis of cylinder
for (int32 i = 0; i < numDiv + 1; i++)
{
r1P[i] = zAx.transferBackZ(r1P[i]);
r2P[i] = zAx.transferBackZ(r2P[i]);
}
realx3 norm;
for (int32 i = 0; i < numDiv; i++)
{
realx3 p1 = r1P[i];
realx3 p2 = r2P[i];
realx3 p3 = r2P[i + 1];
realx3 p4 = r1P[i + 1];
if(checkNormalVec(p1, p2, p3, norm))
{
triangles_.push_back(realx3x3(p1, p2, p3));
}
else
{
fatalErrorInFunction<<
"planner input triangle: "<<realx3x3(p1, p2, p3)<<endl;
return false;
}
if (checkNormalVec(p3, p4, p1, norm))
{
triangles_.push_back(realx3x3(p3, p4, p1));
}
else
{
fatalErrorInFunction<<
"planner input triangle: "<<realx3x3(p3, p4, p1)<<endl;
return false;
}
}
return true;
}
pFlow::cylinderWall::cylinderWall()
{}
pFlow::cylinderWall::cylinderWall(
const dictionary& dict
)
:
Wall(dict)
{
if( !readCylinderWall(dict) )
{
fatalExit;
}
}
pFlow::Wall::triangles_
std::vector< realx3x3 > triangles_
Definition: Wall.hpp:45
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
get the value of data entry or if not found, set the value to setVal
Definition: dictionary.hpp:415
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::line
Definition: line.hpp:36
pFlow::zAxis
Definition: zAxis.hpp:38
pFlow::cos
Vector< T, Allocator > cos(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:93
Vectors.hpp
pFlow::checkNormalVec
bool checkNormalVec(const realx3 &p1, const realx3 &p2, const realx3 &p3, realx3 &norm)
Definition: Wall.cpp:88
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::realx3
triple< real > realx3
Definition: types.hpp:43
pFlow::cylinderWall::cylinderWall
cylinderWall()
Definition: cylinderWall.cpp:106
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
pFlow::line::point
INLINE_FUNCTION_HD realx3 point(real t) const
Definition: line.hpp:102
pFlow::cylinderWall::readCylinderWall
bool readCylinderWall(const dictionary &dict)
Definition: cylinderWall.cpp:6
pFlow::realx3x3
triple< realx3 > realx3x3
Definition: types.hpp:47
pFlow::zAxis::transferBackZ
realx3 transferBackZ(const realx3 &p) const
Definition: zAxis.cpp:50
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
cylinderWall.hpp
pFlow::sin
Vector< T, Allocator > sin(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:92
pFlow::cylinderWall::createCylinder
bool createCylinder(const realx3 &p1, const realx3 &p2, real rad1, real rad2, int32 numDiv)
Definition: cylinderWall.cpp:39
pFlow::zAxis::length
real length() const
Definition: zAxis.hpp:66
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:30
pFlow::triple< real >
pFlow::Vector< realx3 >
pFlow::Wall
Definition: Wall.hpp:41
line.hpp
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