# PhasicFlow: utilities/Utilities/geometryPhasicFlow/planeWall/planeWall.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.

planeWall.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 "planeWall.hpp"
#include "line.hpp"
bool pFlow::planeWall::readPlaneWall
(
const dictionary& dict
)
{
auto p1 = dict.getVal<realx3>("p1");
auto p2 = dict.getVal<realx3>("p2");
auto p3 = dict.getVal<realx3>("p3");
auto p4 = dict.getVal<realx3>("p4");
auto numDiv12 = max(dict.getValOrSet<int32>("numDiv12",1),1);
auto numDiv23 = max(dict.getValOrSet<int32>("numDiv23",1),1);
if(!checkFlatness(p1,p2,p3,p4))
{
fatalErrorInFunction <<
"points p1, p2, p3 and p4 do not form a plane wall in dictionary " << dict.globalName()<<endl;
return false;
}
if(!addPlaneWall(p1,p2,p3,p4,numDiv12,numDiv23))
{
fatalErrorInFunction<<
"could not create plane wall from dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
bool pFlow::planeWall::addWall4(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4)
{
if(!checkFlatness(p1,p2,p3,p4))return false;
triangles_.push_back(realx3x3(p1,p2,p3));
triangles_.push_back(realx3x3(p3,p4,p1));
return true;
}
bool pFlow::planeWall::checkFlatness(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4)
{
if( !Wall::checkTrianlge(p1,p2,p3) ) return false;
if( !Wall::checkTrianlge(p3,p4,p1) ) return false;
return true;
}
bool pFlow::planeWall::addPlaneWall(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4,
int32 numDiv12,
int32 numDiv23 )
{
real dt12 = 1.0/numDiv12;
real dt23 = 1.0/numDiv23;
real t12 = 0;
line line12(p1,p2);
line line43(p4,p3);
for(int32 i=0; i<numDiv12; i++)
{
auto lp1 = line12.point(t12);
auto lp4 = line43.point(t12);
auto lp2 = line12.point(t12+dt12);
auto lp3 = line43.point(t12+dt12);
line line14(lp1,lp4);
line line23(lp2,lp3);
real t23 = 0;
for(int32 j=0; j<numDiv23; j++)
{
if(
!addWall4(
line14.point(t23),
line23.point(t23),
line23.point(t23+dt23),
line14.point(t23+dt23) )
)
{
return false;
}
t23+=dt23;
}
t12+=dt12;
}
return true;
}
pFlow::planeWall::planeWall()
{}
pFlow::planeWall::planeWall
(
const dictionary& dict
)
:
Wall(dict)
{
if(!readPlaneWall(dict))
{
fatalExit;
}
}
pFlow::planeWall::planeWall(
const realx3& p1,
const realx3& p2,
const realx3& p3,
const realx3& p4,
int32 numDiv12,
int32 numDiv23 )
{
if(!checkFlatness(p1,p2,p3,p4))
{
fatalErrorInFunction<<
"the input points p1, p2, p3, and p4 are not in the same plane "<<endl;
fatalExit;
}
if(!addPlaneWall(p1,p2,p3,p4, numDiv12, numDiv23))
{
fatalErrorInFunction<<
"could not create plane wall from input points "<<endl;
fatalExit;
}
}
pFlow::Wall::triangles_
std::vector< realx3x3 > triangles_
Definition: Wall.hpp:45
pFlow::planeWall::readPlaneWall
bool readPlaneWall(const dictionary &dict)
Definition: planeWall.cpp:26
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::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
planeWall.hpp
pFlow::planeWall::addWall4
bool addWall4(const realx3 &p1, const realx3 &p2, const realx3 &p3, const realx3 &p4)
Definition: planeWall.cpp:58
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::planeWall::addPlaneWall
bool addPlaneWall(const realx3 &p1, const realx3 &p2, const realx3 &p3, const realx3 &p4, int32 numDiv12=1, int32 numDiv23=1)
Definition: planeWall.cpp:84
pFlow::planeWall::planeWall
planeWall()
Definition: planeWall.cpp:133
pFlow::realx3x3
triple< realx3 > realx3x3
Definition: types.hpp:47
pFlow::planeWall::checkFlatness
bool checkFlatness(const realx3 &p1, const realx3 &p2, const realx3 &p3, const realx3 &p4)
Definition: planeWall.cpp:73
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::Wall::checkTrianlge
static bool checkTrianlge(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: Wall.cpp:46
pFlow::triple< real >
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