mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-12 16:26:23 +00:00
Merge pull request #21 from hamidrezanorouzi/solvers
positionParticles-ordered modified to accept cylinder&sphere region
This commit is contained in:
@ -324,7 +324,8 @@ bool convertTimeFolderPointFields(
|
||||
auto posVec = std::as_const(pStruct).pointPosition().hostVectorAll();
|
||||
auto* pos = posVec.data();
|
||||
|
||||
Report(1)<<"Writing pointStructure to vtk file."<<endReport;
|
||||
Report(1)<<"Writing pointStructure to vtk file with "<< yellowText(pStruct.numActive())
|
||||
<<" active particles"<<endReport;
|
||||
addUndstrcuturedGridField(
|
||||
vtk(),
|
||||
pStruct.numActive(),
|
||||
|
@ -82,15 +82,19 @@ bool pFlow::positionOrdered::positionPointsOrdered()
|
||||
position_.clear();
|
||||
|
||||
realx3 dl(diameter_);
|
||||
auto minP = static_cast<real>(0.5)*dl + box_.minPoint();
|
||||
auto maxP = static_cast<real>(0.5)*dl + box_.maxPoint();
|
||||
auto minP = region_->minPoint();
|
||||
auto maxP = region_->maxPoint();
|
||||
|
||||
auto cntr = minP;
|
||||
|
||||
size_t n = 0;
|
||||
while( n < numPoints_ )
|
||||
{
|
||||
position_.push_back(cntr);
|
||||
if(region_->isInside(cntr))
|
||||
{
|
||||
position_.push_back(cntr);
|
||||
n++;
|
||||
}
|
||||
|
||||
cntr += dl*uVector1_;
|
||||
|
||||
@ -111,7 +115,7 @@ bool pFlow::positionOrdered::positionPointsOrdered()
|
||||
}
|
||||
}
|
||||
}
|
||||
n++;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -139,10 +143,6 @@ pFlow::positionOrdered::positionOrdered
|
||||
(
|
||||
poDict_.getValOrSet("axisOrder", wordList{"x", "y", "z"})
|
||||
),
|
||||
box_
|
||||
(
|
||||
poDict_.subDict("box")
|
||||
),
|
||||
position_
|
||||
(
|
||||
maxNumberOfParticles_, RESERVE()
|
||||
@ -154,6 +154,13 @@ pFlow::positionOrdered::positionOrdered
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(!region_)
|
||||
{
|
||||
fatalErrorInFunction<<"You must provided a region (box, cylinder, ...) for positioning particles in dictionary "<<
|
||||
dict.globalName()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(!positionPointsOrdered())
|
||||
{
|
||||
fatalExit;
|
||||
|
@ -22,7 +22,6 @@ Licence:
|
||||
#define __positionOrdered_H__
|
||||
|
||||
#include "positionParticles.H"
|
||||
#include "box.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
@ -42,8 +41,6 @@ protected:
|
||||
|
||||
wordList axisOrder_;
|
||||
|
||||
box box_;
|
||||
|
||||
// - unit vector of the first axis
|
||||
realx3 uVector1_;
|
||||
|
||||
|
@ -19,6 +19,9 @@ Licence:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "positionParticles.H"
|
||||
#include "box.H"
|
||||
#include "cylinder.H"
|
||||
#include "sphere.H"
|
||||
#include "cells.H"
|
||||
#include "contactSearchFunctions.H"
|
||||
|
||||
@ -78,7 +81,20 @@ pFlow::positionParticles::positionParticles
|
||||
{
|
||||
maxNumberOfParticles_ = dict.getValOrSet("maxNumberOfParticles", static_cast<size_t>(10000));
|
||||
|
||||
mortonSorting_ = dict.getValOrSet("mortonSorting", Logical("Yes"));
|
||||
mortonSorting_ = dict.getValOrSet("mortonSorting", Logical("Yes"));
|
||||
|
||||
if( dict.containsDictionay("box") )
|
||||
{
|
||||
region_ = makeUnique<region<box>>(dict.subDict("box"));
|
||||
}
|
||||
else if(dict.containsDictionay("cylinder"))
|
||||
{
|
||||
region_ = makeUnique<region<cylinder>>(dict.subDict("cylinder"));
|
||||
}
|
||||
else if(dict.containsDictionay("sphere"))
|
||||
{
|
||||
region_ = makeUnique<region<sphere>>(dict.subDict("sphere"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,11 +28,77 @@ Licence:
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class regionBase
|
||||
{
|
||||
public:
|
||||
|
||||
regionBase() = default;
|
||||
|
||||
regionBase(const regionBase&) = default;
|
||||
|
||||
regionBase& operator =(const regionBase&) = default;
|
||||
|
||||
virtual ~regionBase() = default;
|
||||
|
||||
virtual bool isInside(const realx3 point)const = 0;
|
||||
|
||||
virtual realx3 minPoint()const =0;
|
||||
|
||||
virtual realx3 maxPoint()const =0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class region
|
||||
:
|
||||
public regionBase
|
||||
{
|
||||
protected:
|
||||
|
||||
T region_;
|
||||
|
||||
public:
|
||||
|
||||
region(const T& rgn)
|
||||
:
|
||||
region_(rgn)
|
||||
{}
|
||||
|
||||
region(const dictionary& dict)
|
||||
:
|
||||
region_(dict)
|
||||
{}
|
||||
|
||||
region(const region&) = default;
|
||||
|
||||
region& operator =(const region&) = default;
|
||||
|
||||
virtual ~region()=default;
|
||||
|
||||
bool isInside(const realx3 point) const override
|
||||
{
|
||||
return region_.isInside(point);
|
||||
}
|
||||
|
||||
realx3 minPoint()const override
|
||||
{
|
||||
return region_.minPoint();
|
||||
}
|
||||
|
||||
realx3 maxPoint()const override
|
||||
{
|
||||
return region_.maxPoint();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class positionParticles
|
||||
{
|
||||
protected:
|
||||
|
||||
uniquePtr<regionBase> region_ = nullptr;
|
||||
|
||||
size_t maxNumberOfParticles_ = 10000;
|
||||
|
||||
Logical mortonSorting_;
|
||||
|
Reference in New Issue
Block a user