mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
positionParticles-ordered modified to accept cylinder&sphere region
This commit is contained in:
@ -44,6 +44,8 @@ repository/IOobject/IOobject.C
|
||||
repository/IOobject/IOfileHeader.C
|
||||
|
||||
structuredData/box/box.C
|
||||
structuredData/cylinder/cylinder.C
|
||||
structuredData/sphere/sphere.C
|
||||
structuredData/iBox/iBoxs.C
|
||||
structuredData/line/line.C
|
||||
structuredData/pointStructure/pointStructure.C
|
||||
@ -54,6 +56,7 @@ structuredData/trisurfaceStructure/triSurface.C
|
||||
structuredData/trisurfaceStructure/multiTriSurface.C
|
||||
structuredData/trisurfaceStructure/stlFile.C
|
||||
structuredData/peakableRegion/sphereRegion/sphereRegion.C
|
||||
structuredData/peakableRegion/cylinderRegion/cylinderRegion.C
|
||||
structuredData/peakableRegion/boxRegion/boxRegion.C
|
||||
structuredData/peakableRegion/peakableRegion/peakableRegion.C
|
||||
structuredData/peakableRegion/peakableRegions.C
|
||||
|
@ -114,7 +114,7 @@ bool pFlow::box::write
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::iIstream& pFlow::operator << (iIstream& is, box& b)
|
||||
pFlow::iIstream& pFlow::operator >>(iIstream& is, box& b)
|
||||
{
|
||||
if(! b.read(is))
|
||||
{
|
||||
@ -126,7 +126,7 @@ pFlow::iIstream& pFlow::operator << (iIstream& is, box& b)
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::iOstream& pFlow::operator >> (iOstream& os, const box& b)
|
||||
pFlow::iOstream& pFlow::operator <<(iOstream& os, const box& b)
|
||||
{
|
||||
|
||||
if(! b.write(os))
|
||||
|
@ -77,13 +77,13 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
const realx3& minPoint()const
|
||||
realx3 minPoint()const
|
||||
{
|
||||
return min_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
const realx3& maxPoint()const
|
||||
realx3 maxPoint()const
|
||||
{
|
||||
return max_;
|
||||
}
|
||||
@ -103,10 +103,10 @@ public:
|
||||
};
|
||||
|
||||
FUNCTION_H
|
||||
iIstream& operator << (iIstream& is, box& b);
|
||||
iIstream& operator >>(iIstream& is, box& b);
|
||||
|
||||
FUNCTION_H
|
||||
iOstream& operator >> (iOstream& os, const box& b);
|
||||
iOstream& operator << (iOstream& os, const box& b);
|
||||
|
||||
|
||||
}
|
||||
|
187
src/phasicFlow/structuredData/cylinder/cylinder.C
Normal file
187
src/phasicFlow/structuredData/cylinder/cylinder.C
Normal file
@ -0,0 +1,187 @@
|
||||
/*------------------------------- 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 "cylinder.H"
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::cylinder::calculateParams()
|
||||
{
|
||||
|
||||
auto p1p2 = p2_ - p1_;
|
||||
|
||||
if( p1p2.length() > smallValue )
|
||||
{
|
||||
axisVector2_ = dot(p1p2,p1p2);
|
||||
axisVector_ = p1p2;
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::cylinder::cylinder(
|
||||
const realx3& p1,
|
||||
const realx3& p2,
|
||||
const real radius)
|
||||
:
|
||||
p1_(p1),
|
||||
p2_(p2),
|
||||
radius2_(radius*radius)
|
||||
{
|
||||
if(!calculateParams())
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"error in the input parameters for cylinder"<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::cylinder::cylinder
|
||||
(
|
||||
const dictionary & dict
|
||||
)
|
||||
:
|
||||
p1_
|
||||
(
|
||||
dict.getVal<realx3>("p1")
|
||||
),
|
||||
p2_
|
||||
(
|
||||
dict.getVal<realx3>("p2")
|
||||
)
|
||||
{
|
||||
auto rad = dict.getVal<real>("radius");
|
||||
radius2_= rad*rad;
|
||||
|
||||
if(!calculateParams())
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"error in the input parameters for cylinder in dictionary "<< dict.globalName()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::cylinder::cylinder
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
if( !read(is))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
"error in reading cylinder from file. \n";
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::cylinder::read(iIstream & is)
|
||||
{
|
||||
if(!is.nextData<realx3>("p1", p1_)) return false;
|
||||
if(!is.nextData<realx3>("p2", p2_)) return false;
|
||||
real rad;
|
||||
if(!is.nextData<real>("radius", rad)) return false;
|
||||
radius2_ =rad*rad;
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::cylinder::write(iOstream& os)const
|
||||
{
|
||||
os.writeWordEntry("p1", p1_);
|
||||
os.writeWordEntry("p2", p2_);
|
||||
os.writeWordEntry("radius", sqrt(radius2_));
|
||||
return os.check(FUNCTION_NAME);
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::cylinder::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
p1_ = dict.getVal<realx3>("p1");
|
||||
p2_ = dict.getVal<realx3>("p2");
|
||||
auto rad = dict.getVal<real>("radius");
|
||||
radius2_ = rad*rad;
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::cylinder::write
|
||||
(
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
if(!dict.add("p1", p1_))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing p1 to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!dict.add("p2", p2_))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing p2 to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!dict.add("radius", sqrt(radius2_)) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing radius to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::iIstream& pFlow::operator >>(iIstream& is, cylinder& b)
|
||||
{
|
||||
if(! b.read(is))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
"error in reading cylinder. \n";
|
||||
fatalExit;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::iOstream& pFlow::operator << (iOstream& os, const cylinder& b)
|
||||
{
|
||||
|
||||
if(! b.write(os))
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
"error in writing cylinder. \n";
|
||||
fatalExit;
|
||||
}
|
||||
return os;
|
||||
}
|
158
src/phasicFlow/structuredData/cylinder/cylinder.H
Normal file
158
src/phasicFlow/structuredData/cylinder/cylinder.H
Normal file
@ -0,0 +1,158 @@
|
||||
/*------------------------------- 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_H__
|
||||
#define __cylinder_H__
|
||||
|
||||
#include "types.H"
|
||||
#include "dictionary.H"
|
||||
#include "iIstream.H"
|
||||
#include "iOstream.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class cylinder
|
||||
{
|
||||
protected:
|
||||
|
||||
// - begin point
|
||||
realx3 p1_;
|
||||
|
||||
// - end point
|
||||
realx3 p2_;
|
||||
|
||||
// - radius^2
|
||||
real radius2_;
|
||||
|
||||
realx3 axisVector_;
|
||||
|
||||
real axisVector2_;
|
||||
|
||||
FUNCTION_H
|
||||
bool calculateParams();
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeNameNV("cylinder");
|
||||
|
||||
//// - Constructors
|
||||
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;
|
||||
|
||||
//// - Methods
|
||||
|
||||
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 min( p1_ - realx3(radius()), p2_ - realx3(radius())); // should be improved
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 maxPoint()const
|
||||
{
|
||||
return max( p1_ + realx3(radius()), p2_ + realx3(radius())); // should be improved
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
real radius()const
|
||||
{
|
||||
return sqrt(radius2_);
|
||||
}
|
||||
|
||||
//// - IO operation
|
||||
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_H__
|
@ -0,0 +1,73 @@
|
||||
/*------------------------------- 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 "cylinderRegion.H"
|
||||
|
||||
|
||||
pFlow::cylinderRegion::cylinderRegion
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
cylinder_(dict),
|
||||
random_()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::cylinderRegion::isInside
|
||||
(
|
||||
const realx3& p
|
||||
) const
|
||||
{
|
||||
return cylinder_.isInside(p);
|
||||
}
|
||||
|
||||
pFlow::realx3 pFlow::cylinderRegion::peek()const
|
||||
{
|
||||
for(int32 i=0; i<100;i++)
|
||||
{
|
||||
auto p =
|
||||
random_.randomNumber(cylinder_.minPoint(), cylinder_.maxPoint());
|
||||
if( cylinder_.isInside(p)) return p;
|
||||
}
|
||||
|
||||
fatalErrorInFunction<<
|
||||
"cannot peek a random point from cylinderRegion. \n";
|
||||
fatalExit;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::cylinderRegion::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
return cylinder_.read(dict);
|
||||
}
|
||||
|
||||
bool pFlow::cylinderRegion::write
|
||||
(
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
return cylinder_.write(dict);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*------------------------------- 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 __cylinderRegion_H__
|
||||
#define __cylinderRegion_H__
|
||||
|
||||
#include "cylinder.H"
|
||||
#include "uniformRandomReal.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class cylinderRegion
|
||||
{
|
||||
protected:
|
||||
cylinder cylinder_;
|
||||
|
||||
mutable uniformRandomReal random_;
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeNameNV("cylinderRegion");
|
||||
|
||||
cylinderRegion(const dictionary& dict);
|
||||
|
||||
~cylinderRegion() = default;
|
||||
|
||||
//// - methods
|
||||
bool isInside(const realx3& p) const;
|
||||
|
||||
realx3 peek()const;
|
||||
|
||||
|
||||
//// IO operation
|
||||
bool read(const dictionary& dict);
|
||||
|
||||
bool write(dictionary& dict)const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -26,8 +26,7 @@ pFlow::sphereRegion::sphereRegion
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
center_(dict.getVal<realx3>("center")),
|
||||
radius_(dict.getVal<real>("radius")),
|
||||
sphere_(dict),
|
||||
random_()
|
||||
{
|
||||
|
||||
@ -38,15 +37,17 @@ bool pFlow::sphereRegion::isInside
|
||||
const realx3& p
|
||||
) const
|
||||
{
|
||||
return length(center_-p) <= radius_;
|
||||
return sphere_.isInside(p);
|
||||
}
|
||||
|
||||
pFlow::realx3 pFlow::sphereRegion::peek()const
|
||||
{
|
||||
for(int32 i=0; i<100; ++i)
|
||||
{
|
||||
auto p = random_.randomNumber(center_ - realx3(radius_), center_ + realx3(radius_));
|
||||
if(isInside(p)) return p;
|
||||
auto p = random_.randomNumber(
|
||||
sphere_.center() - realx3(sphere_.radius()),
|
||||
sphere_.center() + realx3(sphere_.radius()));
|
||||
if(sphere_.isInside(p)) return p;
|
||||
}
|
||||
|
||||
fatalErrorInFunction<<
|
||||
@ -62,8 +63,8 @@ bool pFlow::sphereRegion::read
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
center_ = dict.getVal<realx3>("center");
|
||||
radius_ = dict.getVal<real>("radius");
|
||||
sphere_.read(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -72,17 +73,10 @@ bool pFlow::sphereRegion::write
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
if(!dict.add("center", center_))
|
||||
if(!sphere_.write(dict))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing center to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!dict.add("radius", radius_))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing radius to dictionary "<<dict.globalName()<<endl;
|
||||
" error in writing sphere data to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ Licence:
|
||||
#define __sphereRegion_H__
|
||||
|
||||
#include "types.H"
|
||||
#include "sphere.H"
|
||||
#include "uniformRandomReal.H"
|
||||
|
||||
namespace pFlow
|
||||
@ -33,9 +34,7 @@ class sphereRegion
|
||||
{
|
||||
protected:
|
||||
|
||||
realx3 center_;
|
||||
|
||||
real radius_;
|
||||
sphere sphere_;
|
||||
|
||||
mutable uniformRandomReal random_;
|
||||
public:
|
||||
|
143
src/phasicFlow/structuredData/sphere/sphere.C
Normal file
143
src/phasicFlow/structuredData/sphere/sphere.C
Normal file
@ -0,0 +1,143 @@
|
||||
/*------------------------------- 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 "sphere.H"
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::sphere::sphere(
|
||||
const realx3& center,
|
||||
const real radius)
|
||||
:
|
||||
center_(center),
|
||||
radius2_(radius*radius)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::sphere::sphere
|
||||
(
|
||||
const dictionary & dict
|
||||
)
|
||||
:
|
||||
center_
|
||||
(
|
||||
dict.getVal<realx3>("center")
|
||||
)
|
||||
{
|
||||
auto rad = dict.getVal<real>("radius");
|
||||
radius2_= rad*rad;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::sphere::sphere
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
if( !read(is))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
"error in reading sphere from file. \n";
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::sphere::read(iIstream & is)
|
||||
{
|
||||
if(!is.nextData<realx3>("center", center_)) return false;
|
||||
real rad;
|
||||
if(!is.nextData<real>("radius", rad)) return false;
|
||||
radius2_ =rad*rad;
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::sphere::write(iOstream& os)const
|
||||
{
|
||||
os.writeWordEntry("center", center_);
|
||||
os.writeWordEntry("radius", sqrt(radius2_));
|
||||
return os.check(FUNCTION_NAME);
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::sphere::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
center_ = dict.getVal<realx3>("center");
|
||||
auto rad = dict.getVal<real>("radius");
|
||||
radius2_ = rad*rad;
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::sphere::write
|
||||
(
|
||||
dictionary& dict
|
||||
)const
|
||||
{
|
||||
if(!dict.add("center", center_))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing center to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!dict.add("radius", sqrt(radius2_)) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" error in writing radius to dictionary "<<dict.globalName()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::iIstream& pFlow::operator >>(iIstream& is, sphere& b)
|
||||
{
|
||||
if(! b.read(is))
|
||||
{
|
||||
ioErrorInFile(is.name(), is.lineNumber())<<
|
||||
"error in reading sphere. \n";
|
||||
fatalExit;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::iOstream& pFlow::operator << (iOstream& os, const sphere& b)
|
||||
{
|
||||
|
||||
if(! b.write(os))
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber())<<
|
||||
"error in writing sphere. \n";
|
||||
fatalExit;
|
||||
}
|
||||
return os;
|
||||
}
|
132
src/phasicFlow/structuredData/sphere/sphere.H
Normal file
132
src/phasicFlow/structuredData/sphere/sphere.H
Normal file
@ -0,0 +1,132 @@
|
||||
/*------------------------------- 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 __sphere_H__
|
||||
#define __sphere_H__
|
||||
|
||||
#include "types.H"
|
||||
#include "dictionary.H"
|
||||
#include "iIstream.H"
|
||||
#include "iOstream.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class sphere
|
||||
{
|
||||
protected:
|
||||
|
||||
// - center
|
||||
realx3 center_;
|
||||
|
||||
// - radius^2
|
||||
real radius2_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeNameNV("sphere");
|
||||
|
||||
//// - Constructors
|
||||
FUNCTION_H
|
||||
sphere(const realx3& center, const real radius);
|
||||
|
||||
FUNCTION_H
|
||||
sphere(const dictionary& dict);
|
||||
|
||||
FUNCTION_H
|
||||
sphere(iIstream& is);
|
||||
|
||||
FUNCTION_HD
|
||||
sphere(const sphere&) = default;
|
||||
|
||||
FUNCTION_HD
|
||||
sphere(sphere&&) = default;
|
||||
|
||||
FUNCTION_HD
|
||||
sphere& operator=(const sphere&) = default;
|
||||
|
||||
FUNCTION_HD
|
||||
sphere& operator=(sphere&&) = default;
|
||||
|
||||
~sphere()=default;
|
||||
|
||||
//// - Methods
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool isInside(const realx3& point)const
|
||||
{
|
||||
auto cPoint = point-center_;
|
||||
auto dist2 = dot(cPoint,cPoint);
|
||||
return dist2 < radius2_;
|
||||
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
const realx3& center()const
|
||||
{
|
||||
return center_;
|
||||
}
|
||||
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 minPoint()const
|
||||
{
|
||||
return center_ - realx3(radius());
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
realx3 maxPoint()const
|
||||
{
|
||||
return center_ + realx3(radius());
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
real radius()const
|
||||
{
|
||||
return sqrt(radius2_);
|
||||
}
|
||||
|
||||
//// - IO operation
|
||||
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, sphere& b);
|
||||
|
||||
FUNCTION_H
|
||||
iOstream& operator << (iOstream& os, const sphere& b);
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
#endif // __sphere_H__
|
Reference in New Issue
Block a user