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

line.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 __line_hpp__
#define __line_hpp__
#include "types.hpp"
#include "typeInfo.hpp"
namespace pFlow
{
class dictionary;
// pLine
class line
{
protected:
// point 1
realx3 p1_;
// vector pointing from 1 to 2
realx3 v21_;
public:
TypeInfoNV("line");
FUNCTION_HD
line()
{}
FUNCTION_HD
line(const realx3 &lp1, const realx3 &lp2);
FUNCTION_H
line(const dictionary& dict);
FUNCTION_HD
line(const line& src) = default;
FUNCTION_HD
line(line&& src) = default;
FUNCTION_HD
line& operator = (const line&) = default;
FUNCTION_HD
line& operator = (line&&) = default;
// set two points of line
INLINE_FUNCTION_HD
void set(const realx3 &lp1, const realx3 &lp2)
{
v21_ = lp2 - lp1;
p1_ = lp1;
}
// return point 1
INLINE_FUNCTION_HD
realx3 point1()const { return p1_; }
// return point 2
INLINE_FUNCTION_HD
realx3 point2()const { return point(1.0); }
// get a point on the line based on input 0<= t <= 1
INLINE_FUNCTION_HD
realx3 point(real t)const { return v21_ * t + p1_; }
// length of line
INLINE_FUNCTION_HD
real length()const { return pFlow::length(v21_); }
// get unit vector of the line direction vector
INLINE_FUNCTION_HD
realx3 unitVector() const{ return normalize(v21_); }
// return the projected point of point p on line
INLINE_FUNCTION_HD
realx3 projectPoint(const realx3 &p) const
{
return point(projectNormalizedLength(p));
}
// calculates the normalized distance between projected p and p1
INLINE_FUNCTION_HD
real projectNormalizedLength(realx3 p) const
{
realx3 w = p - p1_;
return dot(w,v21_) / dot(v21_,v21_);
}
FUNCTION_H
bool read(const dictionary& dict);
FUNCTION_H
bool write(dictionary& ditc) const;
FUNCTION_H
bool read(iIstream& is);
FUNCTION_H
bool write(iOstream& os)const;
};
}
#endif //
normalize
INLINE_FUNCTION_HD triple< T > normalize(const triple< T > &v1)
pFlow::line::TypeInfoNV
TypeInfoNV("line")
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::line
Definition: line.hpp:36
types.hpp
pFlow::line::write
FUNCTION_H bool write(dictionary &ditc) const
Definition: line.cpp:61
pFlow::line::set
INLINE_FUNCTION_HD void set(const realx3 &lp1, const realx3 &lp2)
Definition: line.hpp:78
pFlow::line::line
FUNCTION_HD line()
Definition: line.hpp:52
pFlow
Definition: demComponent.hpp:28
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::line::read
FUNCTION_H bool read(const dictionary &dict)
Definition: line.cpp:50
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::line::projectPoint
INLINE_FUNCTION_HD realx3 projectPoint(const realx3 &p) const
Definition: line.hpp:106
pFlow::iIstream
Definition: iIstream.hpp:33
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
pFlow::line::point2
INLINE_FUNCTION_HD realx3 point2() const
Definition: line.hpp:90
pFlow::line::projectNormalizedLength
INLINE_FUNCTION_HD real projectNormalizedLength(realx3 p) const
Definition: line.hpp:113
pFlow::line::point
INLINE_FUNCTION_HD realx3 point(real t) const
Definition: line.hpp:94
pFlow::line::length
INLINE_FUNCTION_HD real length() const
Definition: line.hpp:98
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
pFlow::line::operator=
FUNCTION_HD line & operator=(const line &)=default
pFlow::line::point1
INLINE_FUNCTION_HD realx3 point1() const
Definition: line.hpp:86
pFlow::line::p1_
realx3 p1_
Definition: line.hpp:41
typeInfo.hpp
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::line::unitVector
INLINE_FUNCTION_HD realx3 unitVector() const
Definition: line.hpp:102
pFlow::triple< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::line::v21_
realx3 v21_
Definition: line.hpp:44