commit
359560cd13
|
@ -1,9 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||
|
||||
# set the project name and version
|
||||
project(phasicFlow VERSION 0.1 )
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_INSTALL_PREFIX ${phasicFlow_SOURCE_DIR} CACHE PATH "Install path of phasicFlow" FORCE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "build type" FORCE)
|
||||
|
@ -75,7 +75,7 @@ add_subdirectory(solvers)
|
|||
|
||||
add_subdirectory(utilities)
|
||||
|
||||
add_subdirectory(test_newFeatures)
|
||||
#add_subdirectory(test_newFeatures)
|
||||
|
||||
|
||||
install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H"
|
||||
|
|
|
@ -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_;
|
||||
}
|
||||
|
@ -125,6 +149,11 @@ public:
|
|||
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()))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ Licence:
|
|||
|
||||
#include "cells.H"
|
||||
#include "contactSearchFunctions.H"
|
||||
#include "baseAlgorithms.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
@ -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
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*------------------------------- phasicFlow ---------------------------------
|
||||
O C enter of
|
||||
O O E ngineering and
|
||||
|
|
|
@ -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>;
|
||||
|
||||
|
|
|
@ -36,13 +36,26 @@ pFlow::twoPartEntry::twoPartEntry
|
|||
|
||||
iT >> firstPart_;
|
||||
|
||||
token t;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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_++;
|
||||
|
|
|
@ -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)+">"; \
|
||||
|
|
|
@ -7,4 +7,7 @@ add_subdirectory(geometryPhasicFlow)
|
|||
|
||||
add_subdirectory(pFlowToVTK)
|
||||
|
||||
add_subdirectory(Utilities)
|
||||
|
||||
add_subdirectory(postprocessPhasicFlow)
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
set(SourceFiles
|
||||
vtkFile.C
|
||||
readFromTimeFolder.C
|
||||
)
|
||||
|
||||
set(link_libs Kokkos::kokkos phasicFlow Particles Geometry)
|
||||
|
||||
pFlow_add_library_install(Utilities SourceFiles link_libs)
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*------------------------------- 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 "readFromTimeFolder.H"
|
||||
|
||||
pFlow::readFromTimeFolder::readFromTimeFolder(repository& rep)
|
||||
:
|
||||
repository_(rep)
|
||||
{}
|
||||
|
||||
|
||||
std::pair<bool, pFlow::IOfileHeader>
|
||||
pFlow::readFromTimeFolder::fieldExists(word fieldName)const
|
||||
{
|
||||
IOfileHeader fieldHeader(
|
||||
objectFile(
|
||||
fieldName,
|
||||
repository_.path(),
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER)
|
||||
);
|
||||
|
||||
return std::make_pair( fieldHeader.headerOk(true), fieldHeader);
|
||||
}
|
||||
|
||||
bool pFlow::readFromTimeFolder::pointFieldFileGetType(
|
||||
word fieldName,
|
||||
word& typeName) const
|
||||
{
|
||||
|
||||
word fileTypeName, space;
|
||||
if( auto [exist, fieldHeader]= fieldExists(fieldName); !exist )
|
||||
{
|
||||
fatalErrorInFunction<< "Folder "<< repository_.path() <<
|
||||
" does not contain " << fieldName << " field."<<endl;
|
||||
fatalExit;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileTypeName = fieldHeader.objectType();
|
||||
}
|
||||
|
||||
typeName.clear();
|
||||
word flType{};
|
||||
|
||||
if( !pFlow::utilities::pointFieldGetType(
|
||||
fileTypeName, flType, space) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"error in extracting type from "<<fileTypeName<<endl;
|
||||
fatalExit;
|
||||
return false;
|
||||
}
|
||||
|
||||
typeName = flType;
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
/*------------------------------- 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 __readFromTimeFolder_H__
|
||||
#define __readFromTimeFolder_H__
|
||||
|
||||
|
||||
#include "repository.H"
|
||||
#include "pointFields.H"
|
||||
#include "utilityFunctions.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class readFromTimeFolder
|
||||
{
|
||||
protected:
|
||||
|
||||
repository& repository_;
|
||||
|
||||
bool checkForPointStructure()const
|
||||
{
|
||||
return repository_.lookupObjectName(pointStructureFile__);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
readFromTimeFolder(repository& rep);
|
||||
|
||||
auto path()const
|
||||
{
|
||||
return repository_.path();
|
||||
}
|
||||
|
||||
auto& db()
|
||||
{
|
||||
return repository_;
|
||||
}
|
||||
|
||||
std::pair<bool, IOfileHeader>
|
||||
fieldExists(word fieldName)const;
|
||||
|
||||
|
||||
|
||||
bool pointFieldFileGetType(word fieldName, word& typeName) const;
|
||||
|
||||
template<typename T>
|
||||
bool pointFieldGetType(word& typeName)const
|
||||
{
|
||||
word fieldTYPENAME = pointField_H<T>::TYPENAME();
|
||||
word fldType{}, space{};
|
||||
|
||||
if( !pFlow::utilities::pointFieldGetType(
|
||||
fieldTYPENAME, fldType, space) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"error in extracting type from "<<fieldTYPENAME<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
typeName = fldType;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool pointFieldGetCheckType(word fieldName, word& typeName) const
|
||||
{
|
||||
|
||||
word fieldTYPENAME = pointField_H<T>::TYPENAME();
|
||||
word flType{},fldType{};
|
||||
|
||||
if(!pointFieldFileGetType( fieldName, flType))
|
||||
{
|
||||
fatalExit;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pointFieldGetType<T>(fldType) )
|
||||
{
|
||||
fatalExit;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( flType == fldType )
|
||||
{
|
||||
typeName = flType;
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
typeName.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
pointField_H<T>& createUniformPointField_H(word name, T value)
|
||||
{
|
||||
if( !checkForPointStructure() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"cannot find " << pointStructureFile__ << " in repository "<< repository_.name()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
|
||||
|
||||
word fType;
|
||||
pointFieldGetType<T>(fType);
|
||||
word newName = name + fType;
|
||||
|
||||
auto& field = repository_.emplaceReplaceObject<pointField_H<T>>(
|
||||
objectFile(
|
||||
name,
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
pStruct,
|
||||
value
|
||||
);
|
||||
|
||||
return field;
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
pointField_H<T>& readPointField_H(word name)
|
||||
{
|
||||
if( !checkForPointStructure() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"cannot find " << pointStructureFile__ << " in repository "<< repository_.name()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
|
||||
|
||||
auto& field = repository_.emplaceObjectOrGet<pointField_H<T>>(
|
||||
objectFile(
|
||||
name,
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct,
|
||||
T{}
|
||||
);
|
||||
|
||||
return field;
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
pointField_D<T>& readPointField_D(word name)
|
||||
{
|
||||
if( !checkForPointStructure() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"cannot find " << pointStructureFile__ << " in repository "<< repository_.name()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
|
||||
|
||||
auto& field = repository_.emplaceObjectOrGet<pointField_H<T>>(
|
||||
objectFile(
|
||||
name,
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
pStruct,
|
||||
T{}
|
||||
);
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} //pFlow
|
||||
|
||||
|
||||
|
||||
#endif //__readFromTimeFolder_H__
|
|
@ -0,0 +1,45 @@
|
|||
/*------------------------------- 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 __utilityFunctions_H__
|
||||
#define __utilityFunctions_H__
|
||||
|
||||
#include <regex>
|
||||
|
||||
|
||||
namespace pFlow::utilities
|
||||
{
|
||||
|
||||
bool inline pointFieldGetType(std::string TYPENAME, std::string& fieldType, std::string& fieldSpace)
|
||||
{
|
||||
std::regex match("pointField\\<([A-Za-z1-9_]*)\\,([A-Za-z1-9_]*)\\>");
|
||||
std::smatch search;
|
||||
if(!std::regex_match(TYPENAME, search, match)) return false;
|
||||
if(search.size()!= 3) return false;
|
||||
fieldType = search[1];
|
||||
fieldSpace = search[2];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //__utilityFunctions_H__
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
set(source_files
|
||||
pFlowToVTK.C
|
||||
vtkFile.C
|
||||
geometric.C
|
||||
)
|
||||
set(link_lib phasicFlow Kokkos::kokkos)
|
||||
set(link_lib phasicFlow Kokkos::kokkos Utilities)
|
||||
|
||||
pFlow_make_executable_install(pFlowToVTK source_files link_lib)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
set(source_files
|
||||
postprocessPhasicFlow.C
|
||||
postprocess.C
|
||||
processField.C
|
||||
ProcessFields.C
|
||||
includeMask.C
|
||||
IncludeMasks.C
|
||||
|
||||
)
|
||||
set(link_lib phasicFlow Interaction Kokkos::kokkos Utilities)
|
||||
|
||||
pFlow_make_executable_install(postprocessPhasicFlow source_files link_lib)
|
|
@ -0,0 +1,250 @@
|
|||
/*------------------------------- 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 __IncludeMask_H__
|
||||
#define __IncludeMask_H__
|
||||
|
||||
|
||||
#include "includeMask.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct greaterThanOp
|
||||
{
|
||||
TypeNameNV("greaterThan");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val > compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct greaterThanEqOp
|
||||
{
|
||||
TypeNameNV("greaterThanEq");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val >= compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct lessThanOp
|
||||
{
|
||||
TypeNameNV("lessThan");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val < compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct lessThanEqOp
|
||||
{
|
||||
TypeNameNV("lessThanEq");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return val <= compVal; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct equalOp
|
||||
{
|
||||
TypeNameNV("equal");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal, const T &val) const {
|
||||
return equal(val , compVal); }
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct betweenOp
|
||||
{
|
||||
TypeNameNV("between");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const {
|
||||
return val>compVal1 && val<compVal2; }
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct betweenEqOp
|
||||
{
|
||||
TypeNameNV("betweenEq");
|
||||
|
||||
inline
|
||||
bool operator()(const T &compVal1, const T &compVal2 ,const T &val) const {
|
||||
return val>=compVal1 && val<=compVal2; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct allOp
|
||||
{
|
||||
TypeNameNV("all");
|
||||
|
||||
inline
|
||||
bool operator()() const {return true; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename T, template<class> class Operator>
|
||||
class compareOne
|
||||
{
|
||||
public:
|
||||
|
||||
using opertorType = Operator<T>;
|
||||
|
||||
protected:
|
||||
T compValue_{};
|
||||
opertorType operator_{};
|
||||
public:
|
||||
|
||||
TypeNameNV(Operator<T>::TYPENAME());
|
||||
|
||||
compareOne(const dictionary& dict)
|
||||
:
|
||||
compValue_(dict.getVal<T>("value"))
|
||||
{}
|
||||
|
||||
bool operator()(const T& value)const
|
||||
{
|
||||
return operator_(compValue_, value);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, template<class> class Operator>
|
||||
class compareTwo
|
||||
{
|
||||
public:
|
||||
using opertorType = Operator<T>;
|
||||
protected:
|
||||
T compValue1_;
|
||||
T compValue2_;
|
||||
opertorType operator_{};
|
||||
public:
|
||||
|
||||
TypeNameNV(opertorType::TYPENAME());
|
||||
|
||||
compareTwo(const dictionary& dict)
|
||||
:
|
||||
compValue1_(dict.getVal<T>("value1")),
|
||||
compValue2_(dict.getVal<T>("value2"))
|
||||
{}
|
||||
|
||||
bool operator()(const T& value)const
|
||||
{
|
||||
return operator_(compValue1_, compValue2_, value);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename Operator>
|
||||
class compareZero
|
||||
{
|
||||
protected:
|
||||
Operator operator_{};
|
||||
public:
|
||||
|
||||
TypeNameNV(Operator::TYPENAME());
|
||||
compareZero(const dictionary& dict);
|
||||
|
||||
bool operator()(const T& value) const
|
||||
{
|
||||
return operator_();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename Operator>
|
||||
class IncludeMask
|
||||
:
|
||||
public includeMask
|
||||
{
|
||||
protected:
|
||||
|
||||
Operator operator_;
|
||||
|
||||
pointField_H<T> field_;
|
||||
|
||||
public:
|
||||
|
||||
TypeNameTemplate2("IncludeMask", T, Operator);
|
||||
|
||||
IncludeMask(
|
||||
const dictionary& dict,
|
||||
const word& opType,
|
||||
readFromTimeFolder& timeFolder)
|
||||
:
|
||||
includeMask(dict, opType, timeFolder),
|
||||
operator_(dict),
|
||||
field_(timeFolder.readPointField_H<T>(this->fieldName()))
|
||||
{}
|
||||
|
||||
add_vCtor(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary);
|
||||
|
||||
bool isIncluded(int32 n)const override
|
||||
{
|
||||
return operator_(field_[n]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class IncludeMask<T,allOp<T>>
|
||||
:
|
||||
public includeMask
|
||||
{
|
||||
public:
|
||||
TypeNameTemplate2("IncludeMask", T, allOp<int8>);
|
||||
|
||||
IncludeMask(
|
||||
const dictionary& dict,
|
||||
const word& opType,
|
||||
readFromTimeFolder& timeFolder)
|
||||
:
|
||||
includeMask(dict, opType, timeFolder)
|
||||
{}
|
||||
|
||||
add_vCtor(
|
||||
includeMask,
|
||||
IncludeMask,
|
||||
dictionary);
|
||||
|
||||
bool isIncluded(int32 n)const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__IncludeMask_H__
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*------------------------------- 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 "IncludeMask.H"
|
||||
|
||||
// real
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::lessThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::lessThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::greaterThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::greaterThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareOne<pFlow::real, pFlow::equalOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareTwo<pFlow::real, pFlow::betweenOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::compareTwo<pFlow::real, pFlow::betweenEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::real, pFlow::allOp<pFlow::real>>;
|
||||
|
||||
// realx3
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::lessThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::lessThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::greaterThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::greaterThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareOne<pFlow::realx3, pFlow::equalOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareTwo<pFlow::realx3, pFlow::betweenOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::compareTwo<pFlow::realx3, pFlow::betweenEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::realx3, pFlow::allOp<pFlow::realx3>>;
|
||||
|
||||
// int32
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareOne<pFlow::int32, pFlow::lessThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareOne<pFlow::int32, pFlow::lessThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareOne<pFlow::int32, pFlow::greaterThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareOne<pFlow::int32, pFlow::greaterThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareOne<pFlow::int32, pFlow::equalOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareTwo<pFlow::int32, pFlow::betweenOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::compareTwo<pFlow::int32, pFlow::betweenEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int32, pFlow::allOp<pFlow::int32>>;
|
||||
|
||||
// in64
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareOne<pFlow::int64, pFlow::lessThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareOne<pFlow::int64, pFlow::lessThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareOne<pFlow::int64, pFlow::greaterThanOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareOne<pFlow::int64, pFlow::greaterThanEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareOne<pFlow::int64, pFlow::equalOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareTwo<pFlow::int64, pFlow::betweenOp> >;
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::compareTwo<pFlow::int64, pFlow::betweenEqOp> >;
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int64, pFlow::allOp<pFlow::int64>>;
|
||||
|
||||
|
||||
template class pFlow::IncludeMask<pFlow::int8, pFlow::allOp<pFlow::int8>>;
|
|
@ -0,0 +1,164 @@
|
|||
/*------------------------------- 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 __ProcessField_H__
|
||||
#define __ProcessField_H__
|
||||
|
||||
|
||||
#include "processField.H"
|
||||
#include "rectMeshFields.H"
|
||||
#include "twoPartEntry.H"
|
||||
#include "fieldOperations.H"
|
||||
#include "rectMeshFieldToVTK.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
template<typename T>
|
||||
class ProcessField
|
||||
:
|
||||
public processField
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
pointField_H<T>& field_;
|
||||
|
||||
|
||||
rectMeshField_H<T>& processedField_;
|
||||
|
||||
public:
|
||||
|
||||
TypeNameTemplate("ProcessField", T);
|
||||
|
||||
|
||||
ProcessField(
|
||||
const dictionary& dict,
|
||||
pointRectCell& pToCell,
|
||||
repository& rep)
|
||||
:
|
||||
processField(dict, pToCell, rep),
|
||||
field_(
|
||||
this->isUniform()?
|
||||
timeFolder().createUniformPointField_H(this->fieldName(), getUniformValue() ):
|
||||
timeFolder().readPointField_H<T>(this->fieldName())
|
||||
),
|
||||
processedField_
|
||||
(
|
||||
processedRepository().emplaceObject<rectMeshField_H<T>>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
processedFieldName(),
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
mesh(),
|
||||
processedFieldName(),
|
||||
T{}
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
add_vCtor(
|
||||
processField,
|
||||
ProcessField,
|
||||
dictionary);
|
||||
|
||||
|
||||
T getUniformValue()const
|
||||
{
|
||||
const dataEntry& entry = dict().dataEntryRef("field");
|
||||
twoPartEntry tpEntry(entry);
|
||||
return tpEntry.secondPartVal<T>();
|
||||
}
|
||||
|
||||
virtual bool process() override
|
||||
{
|
||||
|
||||
const includeMask& incMask = includeMask_();
|
||||
|
||||
auto numerator = sumMaksOp( field_ , this->pointToCell(), incMask);
|
||||
|
||||
rectMeshField_H<real> denomerator( this->mesh(), real{} );
|
||||
|
||||
if(action() == "sum")
|
||||
{
|
||||
denomerator = rectMeshField_H<real>(this->mesh(), static_cast<real>(1.0));
|
||||
|
||||
}else if(action() == "average")
|
||||
{
|
||||
|
||||
pointField_H<real> oneFld(field_.pStruct(), 1.0, 1.0);
|
||||
|
||||
denomerator = sumOp(oneFld, this->pointToCell());
|
||||
|
||||
}else if(action() == "averageMask")
|
||||
{
|
||||
pointField_H<real> oneFld(field_.pStruct(), 1.0, 1.0);
|
||||
|
||||
denomerator = sumMaksOp(oneFld, this->pointToCell(), incMask);
|
||||
}else
|
||||
{
|
||||
fatalErrorInFunction<<"action is not known: "<< action()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
|
||||
for(int32 i=0; i<this->mesh().nx(); i++ )
|
||||
{
|
||||
for(int32 j=0; j<this->mesh().ny(); j++ )
|
||||
{
|
||||
for(int32 k=0; k<this->mesh().nz(); k++ )
|
||||
{
|
||||
if( pointToCell().nPointInCell(i,j,k)>= threshold() )
|
||||
{
|
||||
processedField_(i,j,k) = numerator(i,j,k)/denomerator(i,j,k);
|
||||
}
|
||||
else
|
||||
{
|
||||
processedField_(i,j,k) = T{};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool writeToVTK(iOstream& os)const override
|
||||
{
|
||||
return convertRectMeshField(os, processedField_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
||||
|
||||
#endif //__ProcessField_H__
|
|
@ -0,0 +1,33 @@
|
|||
/*------------------------------- 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 "ProcessField.H"
|
||||
|
||||
|
||||
template class pFlow::ProcessField<pFlow::int8>;
|
||||
|
||||
template class pFlow::ProcessField<pFlow::int32>;
|
||||
|
||||
template class pFlow::ProcessField<pFlow::int64>;
|
||||
|
||||
template class pFlow::ProcessField<pFlow::real>;
|
||||
|
||||
template class pFlow::ProcessField<pFlow::realx3>;
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*------------------------------- 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 __fieldOperations_H__
|
||||
#define __fieldOperations_H__
|
||||
|
||||
#include "rectMeshFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "pointRectCell.H"
|
||||
#include "includeMask.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
template<typename T>
|
||||
rectMeshField_H<T> sumOp( const pointField_H<T> field, const pointRectCell& pointToCell)
|
||||
{
|
||||
// create field
|
||||
const auto& mesh = pointToCell.mesh();
|
||||
|
||||
rectMeshField_H<T> results(mesh, T(0));
|
||||
|
||||
for(int32 i=0; i<mesh.nx(); i++)
|
||||
{
|
||||
for(int32 j=0; j<mesh.ny(); j++)
|
||||
{
|
||||
for(int32 k=0; k<mesh.nz(); k++)
|
||||
{
|
||||
auto n = pointToCell.Head(i,j,k);
|
||||
T res (0);
|
||||
while(n>-1)
|
||||
{
|
||||
res += field[n];
|
||||
n = pointToCell.Next(n);
|
||||
}
|
||||
|
||||
results(i,j,k) = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
template<typename T, typename incMask>
|
||||
rectMeshField_H<T> sumMaksOp( const pointField_H<T> field, const pointRectCell& pointToCell, const incMask& mask)
|
||||
{
|
||||
// create field
|
||||
const auto& mesh = pointToCell.mesh();
|
||||
|
||||
rectMeshField_H<T> results(mesh, T(0));
|
||||
|
||||
for(int32 i=0; i<mesh.nx(); i++)
|
||||
{
|
||||
for(int32 j=0; j<mesh.ny(); j++)
|
||||
{
|
||||
for(int32 k=0; k<mesh.nz(); k++)
|
||||
{
|
||||
//auto [loop, n] = pointToCell.startLoop(i,j,k);
|
||||
auto n = pointToCell.Head(i,j,k);
|
||||
T res (0);
|
||||
|
||||
while(n>-1)
|
||||
{
|
||||
|
||||
if(mask(n))
|
||||
{
|
||||
res += field[n];
|
||||
}
|
||||
|
||||
n = pointToCell.Next(n);
|
||||
}
|
||||
|
||||
results(i,j,k) = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //__fieldOperations_H__
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/*------------------------------- 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 "includeMask.H"
|
||||
|
||||
pFlow::includeMask::includeMask(
|
||||
const dictionary& dict,
|
||||
const word& opType,
|
||||
readFromTimeFolder& timeFolder)
|
||||
:
|
||||
operatorType_(opType),
|
||||
timeFolder_(timeFolder)
|
||||
{
|
||||
if(!getFieldType(dict, timeFolder, fieldName_, fieldType_))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool pFlow::includeMask::getFieldType(
|
||||
const dictionary& dict,
|
||||
readFromTimeFolder& timeFolder,
|
||||
word& fName,
|
||||
word& fType)
|
||||
{
|
||||
|
||||
fName = dict.getValOrSet<word>("field", "none");
|
||||
|
||||
if(fName == "none")
|
||||
{
|
||||
fType = "int8";
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !timeFolder.pointFieldFileGetType(fName, fType) )
|
||||
{
|
||||
fatalErrorInFunction<<"error in reading field type from file "<< fName<<
|
||||
"in folder "<< timeFolder.path()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
pFlow::uniquePtr<pFlow::includeMask> pFlow::includeMask::create(
|
||||
const dictionary& dict,
|
||||
const word& opType,
|
||||
readFromTimeFolder& timeFolder)
|
||||
{
|
||||
|
||||
word fType, fName;
|
||||
if(!getFieldType(dict, timeFolder, fName, fType))
|
||||
{
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
word method = angleBracketsNames2("IncludeMask", fType, opType);
|
||||
|
||||
if( dictionaryvCtorSelector_.search(method) )
|
||||
{
|
||||
auto objPtr =
|
||||
dictionaryvCtorSelector_[method]
|
||||
(dict, opType, timeFolder);
|
||||
Report(2)<< dict.name()<< " with model "<<greenText(method)<<" is processed."<<endReport;
|
||||
return objPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
printKeys
|
||||
(
|
||||
fatalError << "Ctor Selector "<<
|
||||
method << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*------------------------------- 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 __includeMask_H__
|
||||
#define __includeMask_H__
|
||||
|
||||
#include "virtualConstructor.H"
|
||||
#include "readFromTimeFolder.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class includeMask
|
||||
{
|
||||
protected:
|
||||
word fieldName_;
|
||||
|
||||
word fieldType_;
|
||||
|
||||
word operatorType_;
|
||||
|
||||
readFromTimeFolder& timeFolder_;
|
||||
|
||||
static
|
||||
bool getFieldType(const dictionary& dict, readFromTimeFolder& timeFolder, word& fName, word& fType);
|
||||
|
||||
public:
|
||||
|
||||
TypeName("includeMask");
|
||||
|
||||
includeMask(const dictionary& dict, const word& opType, readFromTimeFolder& timeFolder);
|
||||
|
||||
virtual ~includeMask() = default;
|
||||
|
||||
create_vCtor(
|
||||
includeMask,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict,
|
||||
const word& opType,
|
||||
readFromTimeFolder& timeFolder
|
||||
),
|
||||
(dict, opType, timeFolder)
|
||||
);
|
||||
|
||||
word fieldName()const
|
||||
{
|
||||
return fieldName_;
|
||||
}
|
||||
|
||||
word fieldType()const
|
||||
{
|
||||
return fieldType_;
|
||||
}
|
||||
|
||||
word operatorType()const
|
||||
{
|
||||
return operatorType_;
|
||||
}
|
||||
|
||||
auto& timeFolder()
|
||||
{
|
||||
return timeFolder_;
|
||||
}
|
||||
|
||||
virtual bool isIncluded(int32 n) const = 0;
|
||||
|
||||
bool operator()(int32 n) const
|
||||
{
|
||||
return isIncluded(n);
|
||||
}
|
||||
|
||||
static
|
||||
uniquePtr<includeMask> create(
|
||||
const dictionary& dict,
|
||||
const word& opType,
|
||||
readFromTimeFolder& timeFolder);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__IncludeMask_H__
|
||||
|
||||
|
|
@ -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 __pointRectCell_H__
|
||||
#define __pointRectCell_H__
|
||||
|
||||
#include "NBS.H"
|
||||
#include "rectMeshFields.H"
|
||||
#include "pointStructure.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class pointRectCell
|
||||
{
|
||||
public:
|
||||
|
||||
using mapType = NBS<DefaultHostExecutionSpace, int32>;
|
||||
|
||||
using memory_space = typename mapType::memory_space;
|
||||
|
||||
protected:
|
||||
|
||||
repository& processedRepository_;
|
||||
|
||||
rectangleMesh& mesh_;
|
||||
|
||||
|
||||
const pointStructure& pStruct_;
|
||||
|
||||
ViewType1D<realx3, memory_space> pointPosition_;
|
||||
|
||||
ViewType1D<real, memory_space> diameter_;
|
||||
|
||||
|
||||
mapType map_;
|
||||
|
||||
int32RectMeshField_H nPointInCell_;
|
||||
|
||||
public:
|
||||
|
||||
pointRectCell(
|
||||
const dictionary& dictMesh,
|
||||
const pointStructure& pStruct,
|
||||
repository& rep)
|
||||
:
|
||||
processedRepository_(rep),
|
||||
mesh_
|
||||
(
|
||||
processedRepository_.emplaceObject<rectangleMesh>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"rectMesh",
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
dictMesh
|
||||
)
|
||||
),
|
||||
pStruct_(pStruct),
|
||||
pointPosition_(pStruct_.pointPosition().hostVectorAll()),
|
||||
diameter_("diameter", pStruct_.capacity()),
|
||||
map_(
|
||||
mesh_.domain(),
|
||||
mesh_.nx(),
|
||||
mesh_.ny(),
|
||||
mesh_.nz(),
|
||||
pointPosition_,
|
||||
diameter_),
|
||||
nPointInCell_(mesh_, 0)
|
||||
{
|
||||
|
||||
mapPOints();
|
||||
}
|
||||
|
||||
const auto& mesh()const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
auto& processedRepository()
|
||||
{
|
||||
return processedRepository_;
|
||||
}
|
||||
|
||||
void mapPOints()
|
||||
{
|
||||
range activeRange = pStruct_.activeRange();
|
||||
auto activeMask = pStruct_.activePointsMaskH();
|
||||
|
||||
|
||||
map_.buildCheckInDomain(activeRange, activeMask);
|
||||
|
||||
|
||||
const auto& Next = map_.Next();
|
||||
const auto& Head = map_.Head();
|
||||
for(int32 i=0; i<map_.nx(); i++)
|
||||
{
|
||||
for(int32 j=0; j<map_.ny(); j++)
|
||||
{
|
||||
for(int32 k=0; k<map_.nz(); k++)
|
||||
{
|
||||
|
||||
int32 res = 0;
|
||||
int32 n = Head(i,j,k);
|
||||
while( n>-1)
|
||||
{
|
||||
res+=1;
|
||||
n = Next[n];
|
||||
}
|
||||
nPointInCell_(i,j,k) = res;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int32 nPointInCell(int32 i, int32 j, int32 k)const
|
||||
{
|
||||
return nPointInCell_(i,j,k);
|
||||
}
|
||||
|
||||
auto inline Head(int32 i, int32 j, int32 k)const
|
||||
{
|
||||
return map_.Head()(i,j,k);
|
||||
}
|
||||
|
||||
auto inline Next(int32 n)const
|
||||
{
|
||||
return map_.Next()(n);
|
||||
}
|
||||
//auto
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __pointRectCell_H__
|
|
@ -0,0 +1,145 @@
|
|||
/*------------------------------- 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 "postprocess.H"
|
||||
#include "timeFolder.H"
|
||||
#include "pointStructure.H"
|
||||
#include "vocabs.H"
|
||||
#include "vtkFile.H"
|
||||
|
||||
pFlow::postprocess::postprocess(systemControl& control)
|
||||
:
|
||||
control_(control),
|
||||
dict_(postprocessFile__, control_.settings().path()+postprocessFile__)
|
||||
{
|
||||
Report(1)<<"Reading numberBased dictionary ..."<<endReport;
|
||||
auto nbDict = dict_.subDictOrCreate("numberBased");
|
||||
|
||||
numberBasedDictNames_ = dict_.subDictOrCreate("numberBased").dictionaryKeywords();
|
||||
if(!numberBasedDictNames_.empty())
|
||||
{
|
||||
Report(1)<< "numberBased dictionary contains " << yellowText(numberBasedDictNames_)<<endReport<<endl;
|
||||
}
|
||||
|
||||
|
||||
weightBasedDictNames_ = dict_.subDictOrCreate("weightBased").dictionaryKeywords();
|
||||
if(!weightBasedDictNames_.empty())
|
||||
{
|
||||
Report(1)<< "numberBased dictionary contains " << yellowText(weightBasedDictNames_)<<endReport<<endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool pFlow::postprocess::processTimeFolder(real time, const word& tName, const fileSystem& localFolder)
|
||||
{
|
||||
|
||||
time_ = time;
|
||||
|
||||
Report(0)<<"Working on time folder "<< cyanText(time)<<endReport;
|
||||
timeFolderReposiory_ =
|
||||
makeUnique<repository>
|
||||
(
|
||||
"timeFolder-"+tName,
|
||||
localFolder,
|
||||
&control_
|
||||
);
|
||||
|
||||
Report(1)<<"Reading pointStructure"<<endReport;
|
||||
timeFolderReposiory().emplaceObject<pointStructure>(
|
||||
objectFile
|
||||
(
|
||||
pFlow::pointStructureFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
));
|
||||
|
||||
|
||||
Report(1)<<"Creating mesh and point to cell mapper"<<endReport;
|
||||
pointToCell_ = makeUnique<pointRectCell>(
|
||||
dict_.subDict("rectMesh"),
|
||||
timeFolderReposiory().lookupObject<pointStructure>(pointStructureFile__),
|
||||
timeFolderReposiory());
|
||||
|
||||
// first numberbased dict
|
||||
processedFields_.clear();
|
||||
for(word& dictName:numberBasedDictNames_)
|
||||
{
|
||||
|
||||
|
||||
auto fieldDict = dict_.subDict("numberBased").subDict(dictName);
|
||||
auto ppFieldPtr = processField::create(
|
||||
fieldDict,
|
||||
pointToCell_(),
|
||||
timeFolderReposiory());
|
||||
|
||||
if(!ppFieldPtr->process())
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
processedFields_.push_back( ppFieldPtr.release() );
|
||||
|
||||
output<<endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::postprocess::processTimeFolder(const timeFolder& tFolder)
|
||||
{
|
||||
return processTimeFolder(
|
||||
tFolder.time(),
|
||||
tFolder.timeName(),
|
||||
tFolder.localFolder() );
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::postprocess::writeToVTK(fileSystem destPath, word bName)const
|
||||
{
|
||||
vtkFile vtk(destPath, bName, time_);
|
||||
|
||||
if(!vtk) return false;
|
||||
|
||||
Report(1)<<"Writing processed fields to vtk file..."<<endReport;
|
||||
// mesh
|
||||
pointToCell_->mesh().writeToVtk(vtk());
|
||||
|
||||
forAll( i, processedFields_)
|
||||
{
|
||||
|
||||
if( !processedFields_[i].writeToVTK(vtk()))
|
||||
{
|
||||
|
||||
fatalErrorInFunction<<"error in writing "<< processedFields_[i].processedFieldName()<<
|
||||
"to vtk file\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*------------------------------- 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 __postprocess_H__
|
||||
#define __postprocess_H__
|
||||
|
||||
|
||||
#include "MapPtr.H"
|
||||
#include "systemControl.H"
|
||||
#include "pointRectCell.H"
|
||||
#include "processField.H"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class timeFolder;
|
||||
|
||||
|
||||
class postprocess
|
||||
{
|
||||
protected:
|
||||
|
||||
systemControl& control_;
|
||||
|
||||
dictionary dict_;
|
||||
|
||||
wordList numberBasedDictNames_;
|
||||
|
||||
wordList weightBasedDictNames_;
|
||||
|
||||
uniquePtr<repository> timeFolderReposiory_ {nullptr};
|
||||
|
||||
uniquePtr<pointRectCell> pointToCell_ {nullptr};
|
||||
|
||||
//uniquePtr<repository> processedRepository_ {nullptr};
|
||||
|
||||
ListPtr<processField> processedFields_;
|
||||
|
||||
real time_=0.0;
|
||||
|
||||
//orderedMapPtr<real, repository> timeFolderRepositories_;
|
||||
|
||||
|
||||
Logical saveTimes{"No"};
|
||||
|
||||
Logical saveTimeFolders{"No"};
|
||||
|
||||
|
||||
auto& timeFolderReposiory()
|
||||
{
|
||||
return timeFolderReposiory_();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
postprocess(systemControl& control);
|
||||
|
||||
|
||||
|
||||
bool processTimeFolder(real time, const word& tName, const fileSystem& localFolder);
|
||||
|
||||
bool processTimeFolder(const timeFolder& tFolder);
|
||||
|
||||
|
||||
bool writeToVTK(fileSystem path, word bName)const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //__postprocess_H__
|
|
@ -0,0 +1,113 @@
|
|||
/*------------------------------- 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 "systemControl.H"
|
||||
#include "timeFolder.H"
|
||||
#include "commandLine.H"
|
||||
#include "ranges.H"
|
||||
|
||||
#include "postprocess.H"
|
||||
|
||||
using pFlow::word;
|
||||
using pFlow::wordVector;
|
||||
using pFlow::wordList;
|
||||
using pFlow::commandLine;
|
||||
using pFlow::timeFolder;
|
||||
using pFlow::output;
|
||||
using pFlow::endl;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char** argv )
|
||||
{
|
||||
|
||||
word outFolder = (pFlow::CWD()/word("VTK/postprocess")).wordPath();
|
||||
|
||||
commandLine cmds(
|
||||
"postprocessPhasicFlow",
|
||||
"post-process fields in time folders based on the input file "
|
||||
"settings/postprocessDict and convetes the results into vtk file format.");
|
||||
|
||||
wordVector times;
|
||||
|
||||
cmds.addOption("-o,--out-folder",
|
||||
outFolder,
|
||||
"path to output folder of VTK/postprocess",
|
||||
"path");
|
||||
|
||||
cmds.addOption(
|
||||
"-t,--time",
|
||||
times.vectorField(),
|
||||
"a space separated lits of time folders, or a strided range begin:stride:end, or an interval begin:end",
|
||||
" ");
|
||||
|
||||
bool withZeroFolder = false;
|
||||
cmds.addOption(
|
||||
"-z, --zeroFolder",
|
||||
withZeroFolder,
|
||||
"Do NOT exclude zero folder from processing time folders");
|
||||
|
||||
if(!cmds.parse(argc, argv)) return 0;
|
||||
|
||||
#include "initialize_Control.H"
|
||||
|
||||
|
||||
pFlow::postprocess post(Control);
|
||||
|
||||
// time folders in case
|
||||
timeFolder folders(Control);
|
||||
|
||||
// time in command line
|
||||
pFlow::realCombinedRange validRange;
|
||||
if( cmds.count("--time") )
|
||||
{
|
||||
if(!validRange.addRanges(times)){
|
||||
fatalExit; }
|
||||
}
|
||||
else
|
||||
{
|
||||
validRange.addIntervalRange(folders.startTime(), folders.endTime());
|
||||
}
|
||||
|
||||
pFlow::fileSystem destFolder = pFlow::fileSystem(outFolder);
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
|
||||
if( !validRange.isMember( folders.time() ) )continue;
|
||||
|
||||
if( !withZeroFolder && pFlow::equal(folders.time() , 0.0))continue;
|
||||
|
||||
post.processTimeFolder(folders);
|
||||
|
||||
if(!post.writeToVTK(destFolder, "processed"))
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
|
||||
}while (folders++);
|
||||
|
||||
#include "finalize.H"
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
/*------------------------------- 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 "processField.H"
|
||||
#include "pointRectCell.H"
|
||||
#include "repository.H"
|
||||
#include "twoPartEntry.H"
|
||||
|
||||
|
||||
pFlow::processField::processField(
|
||||
const dictionary& dict,
|
||||
pointRectCell& pToCell,
|
||||
repository& rep)
|
||||
:
|
||||
dict_(dict),
|
||||
pointToCell_(pToCell),
|
||||
timeFolder_(rep),
|
||||
processedFieldName_(dict.name()),
|
||||
action_(dict.getVal<word>("action")),
|
||||
includeMaskType_(dict.getVal<word>("includeMask")),
|
||||
threshold_(dict.getValOrSet<int32>("threshold", 1))
|
||||
{
|
||||
|
||||
if(!processField::getFieldType(
|
||||
dict_,
|
||||
timeFolder_,
|
||||
fieldName_,
|
||||
fieldType_) )
|
||||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
auto& incDict = dict_.subDictOrCreate(includeMaskType_+"Info");
|
||||
|
||||
includeMask_ = includeMask::create(incDict, includeMaskType_, timeFolder_);
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::processField::getFieldType(
|
||||
const dictionary& dict,
|
||||
readFromTimeFolder& timeFolder,
|
||||
word& fieldName,
|
||||
word& fieldType)
|
||||
{
|
||||
if(dict.containsDataEntry("field"))
|
||||
{
|
||||
const dataEntry& entry = dict.dataEntryRef("field");
|
||||
|
||||
if( isTwoPartEntry(entry))
|
||||
{
|
||||
twoPartEntry tpEntry(entry);
|
||||
fieldName = "uniformField";
|
||||
fieldType = tpEntry.firstPart();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = dict.getVal<word>("field");
|
||||
if( !timeFolder.pointFieldFileGetType(fieldName, fieldType) )
|
||||
{
|
||||
fatalErrorInFunction<<"error in reading field type from file "<< fieldName<<
|
||||
"in folder "<< timeFolder.path()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<< "dictionary "<< dict.globalName()<<
|
||||
"does not contain field keyword"<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
pFlow::uniquePtr<pFlow::processField>
|
||||
pFlow::processField::create(
|
||||
const dictionary& dict,
|
||||
pointRectCell& pToCell,
|
||||
repository& rep)
|
||||
{
|
||||
|
||||
word fName, fType;
|
||||
readFromTimeFolder timeFolder(rep);
|
||||
if(!getFieldType(dict, timeFolder, fName, fType))
|
||||
{
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
auto method = angleBracketsNames("ProcessField", fType);
|
||||
|
||||
if( dictionaryvCtorSelector_.search(method) )
|
||||
{
|
||||
auto objPtr =
|
||||
dictionaryvCtorSelector_[method]
|
||||
(dict, pToCell, rep);
|
||||
Report(2)<<"Processing/creating " << yellowText(dict.name())<< " with model "<<greenText(method)<<"."<<endReport;
|
||||
return objPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
printKeys
|
||||
(
|
||||
fatalError << "Ctor Selector "<<
|
||||
method << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/*------------------------------- 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 __processField_H__
|
||||
#define __processField_H__
|
||||
|
||||
|
||||
#include "virtualConstructor.H"
|
||||
#include "dictionary.H"
|
||||
#include "readFromTimeFolder.H"
|
||||
#include "includeMask.H"
|
||||
#include "pointRectCell.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
class repository;
|
||||
|
||||
class processField
|
||||
{
|
||||
protected:
|
||||
|
||||
dictionary dict_;
|
||||
|
||||
pointRectCell& pointToCell_;
|
||||
|
||||
mutable readFromTimeFolder timeFolder_;
|
||||
|
||||
word processedFieldName_;
|
||||
|
||||
word fieldName_;
|
||||
|
||||
word fieldType_;
|
||||
|
||||
word action_;
|
||||
|
||||
word includeMaskType_;
|
||||
|
||||
int32 threshold_ = 1;
|
||||
|
||||
uniquePtr<includeMask> includeMask_ = nullptr;
|
||||
|
||||
bool static getFieldType(
|
||||
const dictionary& dict,
|
||||
readFromTimeFolder& timeFolder,
|
||||
word& fieldName,
|
||||
word& fieldType);
|
||||
|
||||
public:
|
||||
|
||||
TypeName("processField");
|
||||
|
||||
processField(const dictionary& dict, pointRectCell& pToCell, repository& rep);
|
||||
|
||||
|
||||
create_vCtor(
|
||||
processField,
|
||||
dictionary,
|
||||
(const dictionary& dict,
|
||||
pointRectCell& pToCell,
|
||||
repository& rep),
|
||||
(dict, pToCell, rep) );
|
||||
|
||||
|
||||
const auto& mesh()const
|
||||
{
|
||||
return pointToCell_.mesh();
|
||||
}
|
||||
|
||||
const auto& pointToCell()const
|
||||
{
|
||||
return pointToCell_;
|
||||
}
|
||||
|
||||
auto& dict()
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
const auto& dict()const
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
auto& timeFolderRepository()
|
||||
{
|
||||
return timeFolder_.db();
|
||||
}
|
||||
|
||||
auto& processedRepository()
|
||||
{
|
||||
return pointToCell_.processedRepository();
|
||||
}
|
||||
|
||||
const word& fieldType()const
|
||||
{
|
||||
return fieldType_;
|
||||
}
|
||||
|
||||
const word& fieldName()const
|
||||
{
|
||||
return fieldName_;
|
||||
}
|
||||
|
||||
bool isUniform()const
|
||||
{
|
||||
return fieldName_ == "uniformField";
|
||||
}
|
||||
|
||||
const word& action()const
|
||||
{
|
||||
return action_;
|
||||
}
|
||||
|
||||
auto& timeFolder()
|
||||
{
|
||||
return timeFolder_;
|
||||
}
|
||||
|
||||
const word& includeMaskType()const
|
||||
{
|
||||
return includeMaskType_;
|
||||
}
|
||||
|
||||
auto threshold()const
|
||||
{
|
||||
return threshold_;
|
||||
}
|
||||
|
||||
const word& processedFieldName()const
|
||||
{
|
||||
return processedFieldName_;
|
||||
}
|
||||
|
||||
// requires a class to read pointField from timefolder
|
||||
virtual bool process() = 0;
|
||||
|
||||
virtual bool writeToVTK(iOstream& is) const = 0;
|
||||
|
||||
static
|
||||
uniquePtr<processField> create(
|
||||
const dictionary& dict,
|
||||
pointRectCell& pToCell,
|
||||
repository& rep);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //__processField_H__
|
|
@ -0,0 +1,173 @@
|
|||
/*------------------------------- 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 __rectMeshField_H__
|
||||
#define __rectMeshField_H__
|
||||
|
||||
#include "rectangleMesh.H"
|
||||
#include "baseAlgorithms.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename T, typename MemorySpace=void>
|
||||
class rectMeshField
|
||||
{
|
||||
public:
|
||||
|
||||
using viewType = ViewType3D<T,MemorySpace>;
|
||||
|
||||
using memory_space = typename viewType::memory_space;
|
||||
|
||||
protected:
|
||||
|
||||
const rectangleMesh* mesh_;
|
||||
|
||||
word name_="noName";
|
||||
|
||||
viewType field_;
|
||||
|
||||
T defaultValue_{};
|
||||
|
||||
constexpr static inline const char* memoerySpaceName()
|
||||
{
|
||||
return memory_space::name();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
TypeNameTemplateNV2("rectMeshField", T, memoerySpaceName());
|
||||
|
||||
rectMeshField(const rectangleMesh& mesh, const word& name ,const T& defVal)
|
||||
:
|
||||
mesh_(&mesh),
|
||||
name_(name),
|
||||
field_("pFlow::reactMeshField", mesh_->nx(), mesh_->ny(), mesh_->nz()),
|
||||
defaultValue_(defVal)
|
||||
{
|
||||
this->fill(defaultValue_);
|
||||
}
|
||||
|
||||
rectMeshField(const rectangleMesh& mesh, const T& defVal)
|
||||
:
|
||||
rectMeshField(mesh, "noName", defVal)
|
||||
{}
|
||||
|
||||
rectMeshField(const rectMeshField&) = default;
|
||||
|
||||
rectMeshField& operator = (const rectMeshField&) = default;
|
||||
|
||||
rectMeshField(rectMeshField&&) = default;
|
||||
|
||||
rectMeshField& operator =(rectMeshField&&) = default;
|
||||
|
||||
|
||||
inline uniquePtr<rectMeshField> clone() const
|
||||
{
|
||||
return makeUnique<rectMeshField>(*this);
|
||||
}
|
||||
|
||||
inline rectMeshField* clonePtr()const
|
||||
{
|
||||
return new rectMeshField(*this);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
const word& name()const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int64 size()const
|
||||
{
|
||||
return mesh_->size();
|
||||
}
|
||||
|
||||
auto nx()const
|
||||
{
|
||||
return mesh_->nx();
|
||||
}
|
||||
|
||||
auto ny()const
|
||||
{
|
||||
return mesh_->ny();
|
||||
}
|
||||
|
||||
auto nz()const
|
||||
{
|
||||
return mesh_->nz();
|
||||
}
|
||||
|
||||
const auto& mesh()
|
||||
{
|
||||
return *mesh_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
real cellVol()const
|
||||
{
|
||||
return mesh_->cellVol();
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
T& operator()(int32 i, int32 j, int32 k)
|
||||
{
|
||||
return field_(i,j,k);
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
const T& operator()(int32 i, int32 j, int32 k)const
|
||||
{
|
||||
return field_(i,j,k);
|
||||
}
|
||||
|
||||
void fill(T val)
|
||||
{
|
||||
pFlow::fill(
|
||||
field_,
|
||||
range(0,mesh_->nx()),
|
||||
range(0,mesh_->ny()),
|
||||
range(0,mesh_->nz()),
|
||||
val
|
||||
);
|
||||
}
|
||||
|
||||
bool read(iIstream& is)
|
||||
{
|
||||
notImplementedFunction;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const
|
||||
{
|
||||
notImplementedFunction;
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // __rectMeshField_H__
|
|
@ -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 __rectMeshFieldToVTK_H__
|
||||
#define __rectMeshFieldToVTK_H__
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
bool convertRectMeshField(iOstream& os, rectMeshField_H<T>& field)
|
||||
{
|
||||
fatalErrorInFunction<< "this type is not supported "<<
|
||||
field.typeName()<<endl;
|
||||
fatalExit;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
bool convertRectMeshField(iOstream& os, rectMeshField_H<real>& field)
|
||||
{
|
||||
|
||||
os<<"FIELD FieldData 1 " << field.name() << " 1 "<< field.size() << " float\n";
|
||||
for(int32 k=0; k<field.nz(); k++)
|
||||
{
|
||||
for(int32 j=0; j<field.ny(); j++)
|
||||
{
|
||||
for(int32 i=0; i<field.nx(); i++)
|
||||
{
|
||||
os<< field(i,j,k)<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
os<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool convertRectMeshField(iOstream& os, rectMeshField_H<realx3>& field)
|
||||
{
|
||||
|
||||
os<<"FIELD FieldData 1 " << field.name() << " 3 "<< field.size() << " float\n";
|
||||
for(int32 k=0; k<field.nz(); k++)
|
||||
{
|
||||
for(int32 j=0; j<field.ny(); j++)
|
||||
{
|
||||
for(int32 i=0; i<field.nx(); i++)
|
||||
{
|
||||
os<< field(i,j,k).x()<<" "<<field(i,j,k).y()<<" "<<field(i,j,k).z()<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
os<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool convertRectMeshField(iOstream& os, rectMeshField_H<int32>& field)
|
||||
{
|
||||
|
||||
os<<"FIELD FieldData 1 " << field.name() << " 1 "<< field.size() << " int\n";
|
||||
for(int32 k=0; k<field.nz(); k++)
|
||||
{
|
||||
for(int32 j=0; j<field.ny(); j++)
|
||||
{
|
||||
for(int32 i=0; i<field.nx(); i++)
|
||||
{
|
||||
os<< field(i,j,k)<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
os<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
/*------------------------------- 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 __rectMeshFields_H__
|
||||
#define __rectMeshFields_H__
|
||||
|
||||
#include "rectMeshField.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
using rectMeshField_H = rectMeshField<T,HostSpace>;
|
||||
|
||||
using int8RectMeshField_H = rectMeshField<int8, HostSpace>;
|
||||
|
||||
using int32RectMeshField_H = rectMeshField<int32, HostSpace>;
|
||||
|
||||
using int64RectMeshField_H = rectMeshField<int64, HostSpace>;
|
||||
|
||||
using realRectMeshField_H = rectMeshField<real, HostSpace>;
|
||||
|
||||
using realx3RectMeshField_H = rectMeshField<realx3, HostSpace>;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // __rectMeshFields_H__
|
|
@ -0,0 +1,162 @@
|
|||
/*------------------------------- 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 __rectangleMesh_H__
|
||||
#define __rectangleMesh_H__
|
||||
|
||||
#include "cells.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
|
||||
class rectangleMesh
|
||||
:
|
||||
public cells<int32>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
TypeNameNV("rectangleMesh");
|
||||
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
rectangleMesh(){};
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
rectangleMesh(
|
||||
const realx3& minP,
|
||||
const realx3& maxP,
|
||||
int32 nx,
|
||||
int32 ny,
|
||||
int32 nz)
|
||||
:
|
||||
cells(
|
||||
box(minP, maxP),
|
||||
nx, ny, nz)
|
||||
{}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
rectangleMesh(const dictionary & dict)
|
||||
:
|
||||
cells(
|
||||
box(
|
||||
dict.getVal<realx3>("min"),
|
||||
dict.getVal<realx3>("max")),
|
||||
dict.getVal<int32>("nx"),
|
||||
dict.getVal<int32>("ny"),
|
||||
dict.getVal<int32>("nz")
|
||||
)
|
||||
{}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
rectangleMesh(const rectangleMesh&) = default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
rectangleMesh& operator = (const rectangleMesh&) = default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
rectangleMesh(rectangleMesh&&) = default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
rectangleMesh& operator = (rectangleMesh&&) = default;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
~rectangleMesh() = default;
|
||||
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int64 size()const
|
||||
{
|
||||
return this->totalCells();
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
real cellVol()const
|
||||
{
|
||||
auto [dx,dy,dz] = this->cellSize();
|
||||
return dx*dy*dz;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
auto minPoint()const
|
||||
{
|
||||
return domain().minPoint();
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
auto maxPoint()const
|
||||
{
|
||||
return domain().maxPoint();
|
||||
}
|
||||
|
||||
bool read(iIstream& is)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool writeToVtk(iOstream& os)const
|
||||
{
|
||||
os<<"DATASET RECTILINEAR_GRID"<<endl;
|
||||
os<<"DIMENSIONS "<<nx()+1<<" "<< ny()+1 << " "<< nz()+1 <<endl;
|
||||
|
||||
auto [x, y , z] = this->minPoint();
|
||||
auto [dx, dy, dz] = this->cellSize();
|
||||
|
||||
os<<"X_COORDINATES "<< nx()+1 <<" float\n";
|
||||
for(int32 i=0; i<nx()+1; i++)
|
||||
{
|
||||
os<< x<<"\n";
|
||||
x+= dx;
|
||||
}
|
||||
|
||||
os<<"Y_COORDINATES "<< ny()+1 <<" float\n";
|
||||
for(int32 j=0; j<ny()+1; j++)
|
||||
{
|
||||
os<< y <<"\n";
|
||||
y+= dy;
|
||||
}
|
||||
|
||||
os<<"Z_COORDINATES "<< nz()+1 <<" float\n";
|
||||
for(int32 j=0; j<nz()+1; j++)
|
||||
{
|
||||
os<< z <<"\n";
|
||||
z+= dz;
|
||||
}
|
||||
|
||||
os<<"CELL_DATA "<< nx()*ny()*nz()<<endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // __rectangleMesh_H__
|
Loading…
Reference in New Issue