utilities added

This commit is contained in:
hamidrezanorouzi
2022-09-05 11:14:41 +04:30
parent fb3fcf5945
commit 7f3b4e0e2c
34 changed files with 3361 additions and 1 deletions

View File

@ -0,0 +1,110 @@
/*------------------------------- 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 "positionParticles.H"
#include "cells.H"
#include "contactSearchFunctions.H"
#include "streams.H"
pFlow::realx3Vector pFlow::positionParticles::sortByMortonCode(realx3Vector& position)const
{
struct indexMorton
{
size_t morton;
size_t index;
};
realx3 minP = min(position);
realx3 maxP = max(position);
real cellsize = maxDiameter();
cells<size_t> allCells( box(minP, maxP), cellsize);
Vector<indexMorton> indMor(position.size(),RESERVE());
indMor.clear();
size_t ind=0;
for(const auto& p:position)
{
auto cellInd = allCells.pointIndex(p);
indMor.push_back(
{ xyzToMortonCode64(cellInd.x(), cellInd.y(), cellInd.z()),
ind++});
}
Info<<"Performing morton sorting."<<endInfo;
std::sort(
indMor.begin(),
indMor.end(),
[]( const indexMorton &lhs, const indexMorton &rhs){
return lhs.morton < rhs.morton; } );
realx3Vector sortedPos(position.capacity(), RESERVE());
sortedPos.clear();
for(auto& ind:indMor)
{
sortedPos.push_back( position[ind.index] );
}
return sortedPos;
}
pFlow::positionParticles::positionParticles
(
const dictionary& dict
)
{
maxNumberOfParticles_ = dict.getValOrSet("maxNumberOfParticles", static_cast<size_t>(10000));
mortonSorting_ = dict.getValOrSet("mortonSorting", Logical("Yes"));
}
pFlow::uniquePtr<pFlow::positionParticles> pFlow::positionParticles::create(const dictionary & dict)
{
word method = dict.getVal<word>("method");
if( dictionaryvCtorSelector_.search(method) )
{
return dictionaryvCtorSelector_[method] (dict);
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< method << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
dictionaryvCtorSelector_
);
fatalExit;
}
return nullptr;
}

View File

@ -0,0 +1,98 @@
/*------------------------------- 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 __positionParticles_H__
#define __positionParticles_H__
#include "virtualConstructor.H"
#include "Vectors.H"
#include "dictionary.H"
namespace pFlow
{
class positionParticles
{
protected:
size_t maxNumberOfParticles_ = 10000;
Logical mortonSorting_;
static const size_t numReports_ = 40;
realx3Vector sortByMortonCode(realx3Vector& position)const;
public:
// - type Info
TypeName("positionParticles");
positionParticles(const dictionary& dict);
create_vCtor
(
positionParticles,
dictionary,
(const dictionary& dict),
(dict)
);
virtual ~positionParticles() = default;
//// - Methods
virtual label numPoints()const = 0;
virtual label size()const = 0;
virtual real maxDiameter() const = 0;
// - const access to position
virtual const realx3Vector& position()const = 0;
// - access to position
virtual realx3Vector& position() = 0;
virtual realx3Vector getFinalPosition()
{
if(mortonSorting_)
{
return sortByMortonCode(position());
}
else
{
return position();
}
}
static
uniquePtr<positionParticles> create(const dictionary & dict);
};
}
#endif // __positionParticles_H__