postprocessPhasicFlow

This commit is contained in:
hamidrezanorouzi
2022-09-26 11:08:03 +03:30
parent febe2ecc4c
commit f36a4d7782
36 changed files with 2678 additions and 110 deletions

View File

@ -38,12 +38,12 @@ public:
protected:
// - domain
box domain_;
box domain_{realx3(0.0), realx3(1.0)};
// - cell size
real cellSize_;
realx3 cellSize_{1,1,1};
CellType numCells_;
CellType numCells_{1,1,1};
// - protected methods
@ -69,12 +69,29 @@ public:
calculate();
}
INLINE_FUNCTION_H
cells(const box& domain, int32 nx, int32 ny, int32 nz)
:
domain_(domain),
cellSize_(
(domain_.maxPoint() - domain_.minPoint())/realx3(nx, ny, nz)
),
numCells_(nx, ny, nz)
{}
INLINE_FUNCTION_HD
cells(const cells&) = default;
INLINE_FUNCTION_HD
cells& operator = (const cells&) = default;
INLINE_FUNCTION_HD
cells(cells &&) = default;
INLINE_FUNCTION_HD
cells& operator=(cells&&) = default;
cells getCells()const
{
return *this;
@ -87,8 +104,15 @@ public:
calculate();
}
INLINE_FUNCTION_H
void setCellSize(realx3 cellSize)
{
cellSize_ = cellSize;
calculate();
}
INLINE_FUNCTION_HD
real cellSize()const
realx3 cellSize()const
{
return cellSize_;
}
@ -124,6 +148,11 @@ public:
static_cast<int64>(numCells_.y())*
static_cast<int64>(numCells_.z());
}
const auto& domain()const
{
return domain_;
}
INLINE_FUNCTION_HD
CellType pointIndex(const realx3& p)const
@ -221,9 +250,6 @@ public:
min( domain_.maxPoint().z(), max(domain_.minPoint().z(),p.z()))
);
}
};

View File

@ -24,6 +24,7 @@ Licence:
#include "cells.H"
#include "contactSearchFunctions.H"
#include "baseAlgorithms.H"
namespace pFlow
{
@ -76,7 +77,7 @@ protected:
ViewType1D<int32, memory_space> next_;
INLINE_FUNCTION_H
void nullify()
{
@ -85,13 +86,13 @@ protected:
range(0,this->nx()),
range(0,this->ny()),
range(0,this->nz()),
-1
static_cast<int32>(-1)
);
fill(
next_,
range(0,capacity_),
-1
static_cast<int32>(-1)
);
}
@ -102,13 +103,13 @@ protected:
range(0,this->nx()),
range(0,this->ny()),
range(0,this->nz()),
-1
static_cast<int32>(-1)
);
fill(
next_,
nextRng,
-1
static_cast<int32>(-1)
);
}
@ -179,6 +180,24 @@ public:
allocateHead();
}
NBS(
const box& domain,
int32 nx,
int32 ny,
int32 nz,
const ViewType1D<realx3, memory_space>& position,
const ViewType1D<real, memory_space>& diam,
int32 initialContainerSize = 1)
:
Cells(domain, nx, ny, nz),
pointPosition_(position),
diameter_(diam),
head_("NBS::head_",nx,ny,nz), //, this->nx(), this->ny(), this->nz()),
next_("NBS::next_",1) //,position.size()),
{
checkAllocateNext(pointPosition_.size());
}
NBS(
dictionary dict,
const box& domain,
@ -227,6 +246,16 @@ public:
return performedSearch_;
}
const auto& Head()const
{
return head_;
}
const auto& Next()const
{
return next_;
}
// - Perform the broad search to find pairs
// with force = true, perform broad search regardless of
// updateFrequency_ value
@ -332,6 +361,74 @@ public:
}
// - build based on all points in range [0, numPoints_)
INLINE_FUNCTION_H
void buildCheckInDomain(range activeRange)
{
checkAllocateNext(activeRange.second);
nullify(activeRange);
Cells cellIndex = static_cast<Cells>(*this);
auto points = pointPosition_;
auto next = next_;
auto head = head_;
Kokkos::RangePolicy<
Kokkos::IndexType<int32>,
Kokkos::Schedule<Kokkos::Static>,
ExecutionSpace> rPolicy(activeRange.first, activeRange.second);
Kokkos::parallel_for(
"NBS::buildCheckInDomain",
rPolicy,
LAMBDA_HD(int32 i){
CellType ind;
if( cellIndex.pointIndexInDomain(points[i], ind) )
{
int32 old = Kokkos::atomic_exchange(&head(ind.x(), ind.y(), ind.z()), i);
next[i] = old;
}
}
);
Kokkos::fence();
}
template<typename IncludeFunction>
INLINE_FUNCTION_H
void buildCheckInDomain(range activeRange, IncludeFunction incld)
{
checkAllocateNext(activeRange.second);
nullify(activeRange);
Cells cellIndex = static_cast<Cells>(*this);
auto points = pointPosition_;
auto next = next_;
auto head = head_;
Kokkos::RangePolicy<
Kokkos::IndexType<int32>,
Kokkos::Schedule<Kokkos::Dynamic>,
ExecutionSpace> rPolicy(activeRange.first, activeRange.second);
Kokkos::parallel_for(
"NBS::buildCheckInDomain",
rPolicy,
LAMBDA_HD(int32 i){
CellType ind;
if( incld(i) && cellIndex.pointIndexInDomain(points[i], ind) )
{
auto old = Kokkos::atomic_exchange(&head(ind.x(), ind.y(), ind.z()), i);
next[i] = old;
}
});
Kokkos::fence();
}
template<typename PairsContainer>
INLINE_FUNCTION_H
bool findPairs(PairsContainer& pairs)
@ -383,94 +480,6 @@ public:
return true;
}
/*INLINE_FUNCTION_HD
void operator()(
TagFindPairs,
int32 i,
int32 j,
int32 k,
int32& getFullUpdate)const
{
int32 m = head_(i,j,k);
CellType currentCell(i,j,k);
int32 n = -1;
while( m > -1 )
{
auto p_m = pointPosition_[m];
auto d_m = sizeRatio_* diameter_[m];
// the same cell
n = next_(m);
while(n >-1)
{
auto p_n = pointPosition_[n];
auto d_n = sizeRatio_*diameter_[n];
if( sphereSphereCheck(p_m, p_n, d_m, d_n) )
{
auto ln = n;
auto lm = m;
if(lm>ln) Swap(lm,ln);
if( auto res = pairs_.insert(lm,ln); res <0)
{
getFullUpdate++;
}
}
n = next_(n);
}
// neighbor cells
CellType neighborCell;
for(int32 ni=0; ni<13; ni++)
{
if(ni==0) neighborCell = currentCell + CellType( 0, 0,-1);
else if(ni==1) neighborCell = currentCell + CellType(-1, 0,-1);
else if(ni==2) neighborCell = currentCell + CellType(-1, 0, 0);
else if(ni==3) neighborCell = currentCell + CellType(-1, 0, 1);
else if(ni==4) neighborCell = currentCell + CellType( 0,-1,-1);
else if(ni==5) neighborCell = currentCell + CellType( 0,-1, 0);
else if(ni==6) neighborCell = currentCell + CellType( 0,-1, 1);
else if(ni==7) neighborCell = currentCell + CellType(-1,-1,-1);
else if(ni==8) neighborCell = currentCell + CellType(-1,-1, 0);
else if(ni==9) neighborCell = currentCell + CellType(-1,-1, 1);
else if(ni==10) neighborCell = currentCell + CellType( 1,-1,-1);
else if(ni==11) neighborCell = currentCell + CellType( 1,-1, 0);
else if(ni==12) neighborCell = currentCell + CellType( 1,-1, 1);
if( this->isInRange(neighborCell) )
{
n = head_(neighborCell.x(), neighborCell.y(), neighborCell.z());
while( n>-1)
{
auto p_n = pointPosition_[n];
auto d_n = sizeRatio_*diameter_[n];
if(sphereSphereCheck(p_m, p_n, d_m, d_n))
{
auto ln = n;
auto lm = m;
if(lm>ln) Swap(lm,ln);
if( auto res = pairs_.insert(lm,ln); res <0)
{
getFullUpdate++;
}
}
n = next_[n];
}
}
}
m = next_[m];
}
}*/
template <typename PairsContainer, typename teamMemberType>
INLINE_FUNCTION_HD

View File

@ -1,4 +1,3 @@
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and

View File

@ -29,6 +29,15 @@ Licence:
namespace pFlow
{
template<typename T>
using pointField_H = pointField<VectorSingle, T, HostSpace>;
template<typename T>
using pointField_D = pointField<VectorSingle, T>;
template<typename T>
using pointField_HD = pointField<VectorDual, T>;
using int8PointField_D = pointField<VectorSingle, int8>;

View File

@ -36,13 +36,26 @@ pFlow::twoPartEntry::twoPartEntry
iT >> firstPart_;
if(iT.eof()) return;
token t;
while(true)
{
iT.read(t);
if( !iT.read(t) )
{
fatalErrorInFunction<<"attemps to read from token stream failed \n";
fatalExit;
}
secondPart_.appendToken(t);
if(iT.eof())break;
}
}
}
bool pFlow::isTwoPartEntry(pFlow::dataEntry entry)
{
twoPartEntry tpEntry(entry);
if(tpEntry.secondPart().size() == 0) return false;
return true;
}

View File

@ -53,6 +53,11 @@ public:
return firstPart_;
}
iTstream& secondPart()
{
return secondPart_;
}
template<typename T>
T secondPartVal()const
{
@ -65,6 +70,10 @@ public:
};
bool isTwoPartEntry(dataEntry entry);
}
#endif

View File

@ -46,6 +46,7 @@ const inline char* motionModelFile__ = "motionModel";
const inline char* contactSearchFile__ = "contactSearch";
const inline char* propertyFile__ = "interaction";
const inline char* interactionFile__ = "interaction";
const inline char* postprocessFile__ = "postprocessDict";
const inline char* uniform__ = "uniform";

View File

@ -57,6 +57,17 @@ public:
return currentFolder_->second;
}
word timeName()const
{
auto tName = tailName(folder().wordPath(), '/');
return tName;
}
fileSystem localFolder()const
{
return fileSystem(timeName());
}
bool operator ++(int)
{
if(!finished()) currentFolder_++;

View File

@ -62,6 +62,7 @@ Licence:
{ return word(tName)+"<"+Type::TYPENAME()+">";} \
else \
return word(tName)+"<"+basicTypeName<Type>()+">"; \
return "noTYPE"; \
} \
virtual word typeName() const { return TYPENAME();}
@ -73,6 +74,7 @@ Licence:
{ return word(tName)+"<"+Type1::TYPENAME()+","+Type2::TYPENAME()+">";} \
else \
return word(tName)+"<"+basicTypeName<Type1>()+","+Type2::TYPENAME()+">";\
return "noTYPE"; \
} \
virtual word typeName() const { return TYPENAME();}
@ -101,7 +103,7 @@ Licence:
has_static_member(TYPENAME); \
inline static word TYPENAME() \
{ \
if constexpr( has_static_member_TYPENAME<Type,word(void)>::value) \
if constexpr ( has_static_member_TYPENAME<Type,word(void)>::value) \
{ return word(tName)+"<"+Type::TYPENAME()+","+word(tName2)+">";} \
else \
return word(tName)+"<"+basicTypeName<Type>()+","+word(tName2)+">"; \