# PhasicFlow: src/Interaction/sphereInteraction/triWall.hpp Source File

triWall.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 __triWall_hpp__
#define __triWall_hpp__
#include "types.hpp"
namespace pFlow::sphTriInteraction
{
struct triWall
{
realx3 n_;
real offset_;
INLINE_FUNCTION_H
triWall(const realx3& p1, const realx3& p2, const realx3& p3)
{
if(!makeWall(p1,p2,p3, n_, offset_))
{
fatalErrorInFunction<<
"bad input for the wall.\n";
fatalExit;
}
}
INLINE_FUNCTION_HD
triWall(bool, const realx3& p1, const realx3& p2, const realx3& p3)
{
makeWall(p1,p2,p3,n_,offset_);
}
INLINE_FUNCTION_HD
triWall(const realx3x3& tri)
{
makeWall(tri.x_, tri.y_, tri.z_, n_, offset_);
}
INLINE_FUNCTION_HD
triWall(const triWall&) = default;
INLINE_FUNCTION_HD
triWall& operator=(const triWall&) = default;
INLINE_FUNCTION_HD
triWall(triWall&&) = default;
INLINE_FUNCTION_HD
triWall& operator=(triWall&&) = default;
INLINE_FUNCTION_HD
~triWall()=default;
INLINE_FUNCTION_HD
real normalDistFromWall(const realx3 &p) const
{
return dot(n_, p) + offset_;
}
INLINE_FUNCTION_HD
realx3 nearestPointOnWall(const realx3 &p) const
{
real t = -(dot(n_, p) + offset_);
return realx3(n_.x_*t + p.x_, n_.y_*t + p.y_, n_.z_*t + p.z_);
}
INLINE_FUNCTION_HD static
bool makeWall(
const realx3& p1,
const realx3& p2,
const realx3& p3,
realx3& n, real& offset)
{
n = cross(p2 - p1, p3 - p1);
real len = length(n);
if (len < 0.00000000001) return false;
n /= len;
offset = -dot(n, p1);
return true;
}
};
}
#endif
pFlow::sphTriInteraction::triWall::~triWall
INLINE_FUNCTION_HD ~triWall()=default
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
types.hpp
pFlow::sphTriInteraction::triWall
Definition: triWall.hpp:29
pFlow::sphTriInteraction::triWall::n_
realx3 n_
Definition: triWall.hpp:32
pFlow::realx3
triple< real > realx3
Definition: types.hpp:48
pFlow::sphTriInteraction::triWall::offset_
real offset_
Definition: triWall.hpp:33
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
cross
INLINE_FUNCTION_HD triple< T > cross(const triple< T > &v1, const triple< T > &v2)
n
int32 n
Definition: NBSCrossLoop.hpp:24
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
pFlow::sphTriInteraction::triWall::triWall
INLINE_FUNCTION_HD triWall(const realx3x3 &tri)
Definition: triWall.hpp:53
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::triple::x_
T x_
Definition: triple.hpp:49
pFlow::sphTriInteraction::triWall::normalDistFromWall
INLINE_FUNCTION_HD real normalDistFromWall(const realx3 &p) const
Definition: triWall.hpp:75
pFlow::sphTriInteraction::triWall::triWall
INLINE_FUNCTION_HD triWall(bool, const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triWall.hpp:47
pFlow::triple::y_
T y_
Definition: triple.hpp:50
pFlow::triple::z_
T z_
Definition: triple.hpp:51
pFlow::sphTriInteraction::triWall::nearestPointOnWall
INLINE_FUNCTION_HD realx3 nearestPointOnWall(const realx3 &p) const
Definition: triWall.hpp:81
pFlow::sphTriInteraction::triWall::triWall
INLINE_FUNCTION_H triWall(const realx3 &p1, const realx3 &p2, const realx3 &p3)
Definition: triWall.hpp:36
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::sphTriInteraction::triWall::operator=
INLINE_FUNCTION_HD triWall & operator=(const triWall &)=default
pFlow::sphTriInteraction::triWall::makeWall
static INLINE_FUNCTION_HD bool makeWall(const realx3 &p1, const realx3 &p2, const realx3 &p3, realx3 &n, real &offset)
Definition: triWall.hpp:88
pFlow::sphTriInteraction
Definition: pLine.hpp:26