Merge pull request #94 from PhasicFlow/develop

pFlowToVTK and enhanced wall-particle search
This commit is contained in:
Hamidreza Norouzi 2024-03-30 00:24:04 +03:30 committed by GitHub
commit cab49ef036
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 185 additions and 148 deletions

View File

@ -56,12 +56,12 @@ public:
ContactSearch( ContactSearch(
const dictionary& csDict, const dictionary& csDict,
const box& domain, const box& extDomain,
const particles& prtcl, const particles& prtcl,
const geometry& geom, const geometry& geom,
Timers& timers) Timers& timers)
: :
contactSearch(csDict, domain, prtcl, geom, timers) contactSearch(csDict, extDomain, prtcl, geom, timers)
{ {
auto method = dict().getVal<word>("method"); auto method = dict().getVal<word>("method");
@ -79,12 +79,13 @@ public:
uint32 wnTri = this->Geometry().size(); uint32 wnTri = this->Geometry().size();
const auto& wPoints = this->Geometry().points().deviceViewAll(); const auto& wPoints = this->Geometry().points().deviceViewAll();
const auto& wVertices = this->Geometry().vertices().deviceViewAll(); const auto& wVertices = this->Geometry().vertices().deviceViewAll();
const auto& wNormals = this->Geometry().normals().deviceViewAll();
ppwContactSearch_ = ppwContactSearch_ =
makeUnique<SearchMethodType> makeUnique<SearchMethodType>
( (
nbDict, nbDict,
this->domainBox(), this->extendedDomainBox(),
minD, minD,
maxD, maxD,
position, position,
@ -93,7 +94,8 @@ public:
wnPoints, wnPoints,
wnTri, wnTri,
wPoints, wPoints,
wVertices wVertices,
wNormals
); );
REPORT(2)<<"Contact search algorithm for particle-particle is "<< REPORT(2)<<"Contact search algorithm for particle-particle is "<<
Green_Text(ppwContactSearch_().typeName())<<END_REPORT; Green_Text(ppwContactSearch_().typeName())<<END_REPORT;

View File

@ -25,12 +25,12 @@ Licence:
pFlow::contactSearch::contactSearch( pFlow::contactSearch::contactSearch(
const dictionary& dict, const dictionary& dict,
const box& domain, const box& extDomain,
const particles& prtcl, const particles& prtcl,
const geometry& geom, const geometry& geom,
Timers& timers) Timers& timers)
: :
domainBox_(domain), extendedDomainBox_(extDomain),
particles_(prtcl), particles_(prtcl),
geometry_(geom), geometry_(geom),
ppTimer_("particle-particle contact search", &timers), ppTimer_("particle-particle contact search", &timers),
@ -47,7 +47,7 @@ const pFlow::pointStructure &pFlow::contactSearch::pStruct() const
pFlow::uniquePtr<pFlow::contactSearch> pFlow::contactSearch::create( pFlow::uniquePtr<pFlow::contactSearch> pFlow::contactSearch::create(
const dictionary &dict, const dictionary &dict,
const box &domain, const box &extDomain,
const particles &prtcl, const particles &prtcl,
const geometry &geom, const geometry &geom,
Timers &timers) Timers &timers)
@ -60,7 +60,7 @@ pFlow::uniquePtr<pFlow::contactSearch> pFlow::contactSearch::create(
if( dictionaryvCtorSelector_.search(model)) if( dictionaryvCtorSelector_.search(model))
{ {
auto objPtr = dictionaryvCtorSelector_[model] (dict, domain, prtcl, geom, timers); auto objPtr = dictionaryvCtorSelector_[model] (dict, extDomain, prtcl, geom, timers);
REPORT(2)<<"Model "<< Green_Text(model)<<" is created."<< END_REPORT; REPORT(2)<<"Model "<< Green_Text(model)<<" is created."<< END_REPORT;
return objPtr; return objPtr;
} }

View File

@ -42,7 +42,7 @@ class contactSearch
{ {
private: private:
const box& domainBox_; const box& extendedDomainBox_;
const particles& particles_; const particles& particles_;
@ -60,7 +60,7 @@ public:
contactSearch( contactSearch(
const dictionary& dict, const dictionary& dict,
const box& domain, const box& extDomain,
const particles& prtcl, const particles& prtcl,
const geometry& geom, const geometry& geom,
Timers& timers); Timers& timers);
@ -88,9 +88,9 @@ public:
return dict_; return dict_;
} }
const auto& domainBox()const const auto& extendedDomainBox()const
{ {
return domainBox_; return extendedDomainBox_;
} }
const auto& Particles()const const auto& Particles()const
@ -133,7 +133,7 @@ public:
static static
uniquePtr<contactSearch> create( uniquePtr<contactSearch> create(
const dictionary& dict, const dictionary& dict,
const box& domain, const box& extDomain,
const particles& prtcl, const particles& prtcl,
const geometry& geom, const geometry& geom,
Timers& timers); Timers& timers);

View File

@ -32,7 +32,8 @@ pFlow::NBS::NBS
uint32 nWallPoints, uint32 nWallPoints,
uint32 nWallElements, uint32 nWallElements,
const ViewType1D<realx3,memory_space>& wallPoints, const ViewType1D<realx3,memory_space>& wallPoints,
const ViewType1D<uint32x3,memory_space>& wallVertices const ViewType1D<uint32x3,memory_space>& wallVertices,
const ViewType1D<realx3,memory_space>& wallNormals
) )
: :
particleWallContactSearchs<NBS>( particleWallContactSearchs<NBS>(
@ -61,7 +62,8 @@ pFlow::NBS::NBS
nWallPoints, nWallPoints,
nWallElements, nWallElements,
wallPoints, wallPoints,
wallVertices wallVertices,
wallNormals
) )
{ {
} }

View File

@ -80,7 +80,10 @@ protected:
if(!cellsWallLevel0_.broadSearch( if(!cellsWallLevel0_.broadSearch(
pwPairs, pwPairs,
NBSLevel0_.getSearchCells(), NBSLevel0_.getSearchCells(),
NBSLevel0_.getCellIterator())) NBSLevel0_.getCellIterator(),
pointPos,
diameter,
sizeRatio_))
{ {
fatalErrorInFunction<< fatalErrorInFunction<<
"Error in broadSearch for NBS (particle-wall)"<<endl; "Error in broadSearch for NBS (particle-wall)"<<endl;
@ -105,7 +108,8 @@ public:
uint32 nWallPoints, uint32 nWallPoints,
uint32 nWallElements, uint32 nWallElements,
const ViewType1D<realx3,memory_space>& wallPoints, const ViewType1D<realx3,memory_space>& wallPoints,
const ViewType1D<uint32x3,memory_space>& wallVertices); const ViewType1D<uint32x3,memory_space>& wallVertices,
const ViewType1D<realx3,memory_space>& wallNormals );
INLINE_FUNCTION_HD INLINE_FUNCTION_HD

View File

@ -60,7 +60,6 @@ bool pFlow::NBSLevel0::findPairs
} }
Kokkos::fence();
} }
return true; return true;

View File

@ -26,18 +26,18 @@ pFlow::cellsWallLevel0::cellsWallLevel0
real cellExtent, real cellExtent,
uint32 numPoints, uint32 numPoints,
uint32 numElements, uint32 numElements,
const ViewType1D<realx3, const ViewType1D<realx3, memory_space> &points,
memory_space> &points, const ViewType1D<uint32x3, memory_space> &vertices,
const ViewType1D<uint32x3, memory_space> &vertices const ViewType1D<realx3, memory_space>& normals
) )
: :
cellExtent_( max(cellExtent, 0.5 ) ), cellExtent_( max(cellExtent, 0.5 ) ),
numElements_(numElements), numElements_(numElements),
numPoints_(numPoints), numPoints_(numPoints),
vertices_(vertices), vertices_(vertices),
points_(points) points_(points),
normals_(normals)
{ {
allocateArrays(); allocateArrays();
} }
@ -45,8 +45,9 @@ bool pFlow::cellsWallLevel0::resetElements
( (
uint32 numElements, uint32 numElements,
uint32 numPoints, uint32 numPoints,
ViewType1D<realx3, memory_space> &points, const ViewType1D<realx3, memory_space>& points,
ViewType1D<uint32x3, memory_space> &vertices const ViewType1D<uint32x3, memory_space>& vertices,
const ViewType1D<realx3, memory_space>& normals
) )
{ {
@ -54,6 +55,7 @@ bool pFlow::cellsWallLevel0::resetElements
numPoints_ = numPoints; numPoints_ = numPoints;
points_ = points; points_ = points;
vertices_ = vertices; vertices_ = vertices;
normals_ = normals;
allocateArrays(); allocateArrays();
@ -64,7 +66,10 @@ bool pFlow::cellsWallLevel0::broadSearch
( (
csPairContainerType &pairs, csPairContainerType &pairs,
const cells& searchBox, const cells& searchBox,
const mapperNBS::CellIterator &particleMap const mapperNBS::CellIterator &particleMap,
const deviceViewType1D<realx3>& pPoints,
const deviceViewType1D<real>& pDiams,
real sizeRatio
) )
{ {
@ -72,7 +77,7 @@ bool pFlow::cellsWallLevel0::broadSearch
this->build(searchBox); this->build(searchBox);
this->particleWallFindPairs(pairs, particleMap); this->particleWallFindPairs(pairs, particleMap, pPoints, pDiams, sizeRatio);
return true; return true;
} }
@ -104,7 +109,10 @@ bool pFlow::cellsWallLevel0::build(const cells & searchBox)
bool pFlow::cellsWallLevel0::particleWallFindPairs bool pFlow::cellsWallLevel0::particleWallFindPairs
( (
csPairContainerType &pairs, csPairContainerType &pairs,
const mapperNBS::CellIterator &particleMap const mapperNBS::CellIterator &particleMap,
const deviceViewType1D<realx3>& pPoints,
const deviceViewType1D<real>& pDiams,
real sizeRatio
) )
{ {
@ -113,7 +121,7 @@ bool pFlow::cellsWallLevel0::particleWallFindPairs
while (getFull) while (getFull)
{ {
getFull = findPairsElementRangeCount(pairs, particleMap); getFull = findPairsElementRangeCount(pairs, particleMap, pPoints, pDiams, sizeRatio);
if(getFull) if(getFull)
{ {
@ -137,14 +145,14 @@ bool pFlow::cellsWallLevel0::particleWallFindPairs
pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount
( (
csPairContainerType &pairs, csPairContainerType &pairs,
const mapperNBS::CellIterator &particleMap const mapperNBS::CellIterator &particleMap,
const deviceViewType1D<realx3>& pPoints,
const deviceViewType1D<real>& pDiams,
real sizeRatio
) )
{ {
uint32 getFull =0; uint32 getFull =0;
//const auto pwPairs = pairs;
const auto elementBox = elementBox_;
Kokkos::parallel_reduce( Kokkos::parallel_reduce(
"pFlow::cellsWallLevel0::findPairsElementRangeCount", "pFlow::cellsWallLevel0::findPairsElementRangeCount",
@ -155,7 +163,10 @@ pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount
const uint32 iTri = teamMember.league_rank(); const uint32 iTri = teamMember.league_rank();
const auto triBox = elementBox[iTri]; const auto triBox = elementBox_[iTri];
const auto triPlane = infinitePlane(
normals_[iTri],
points_[vertices_[iTri].x()]);
uint32 getFull2 = 0; uint32 getFull2 = 0;
@ -175,10 +186,13 @@ pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount
while( n != particleMap.NoPos) while( n != particleMap.NoPos)
{ {
// id is wall id the pair is (particle id, wall id) // id is wall id the pair is (particle id, wall id)
if( pairs.insert( if( abs(triPlane.pointFromPlane(pPoints[n]))< pDiams[n]*sizeRatio*cellExtent_)
static_cast<csIdType>(n), {
static_cast<csIdType>(iTri) ) == -1 ) if( pairs.insert(
innerUpdate++; static_cast<csIdType>(n),
static_cast<csIdType>(iTri) ) == -1 )
innerUpdate++;
}
n = particleMap.next(n); n = particleMap.next(n);
} }

View File

@ -60,6 +60,9 @@ private:
// - ref to points in the trisurface (borrowed) // - ref to points in the trisurface (borrowed)
ViewType1D<realx3, memory_space> points_; ViewType1D<realx3, memory_space> points_;
// - ref to normal vectors of triangles (borrowed)
ViewType1D<realx3, memory_space> normals_;
// cell range of element/triangle bounding box // cell range of element/triangle bounding box
ViewType1D<iBoxType, memory_space> elementBox_; ViewType1D<iBoxType, memory_space> elementBox_;
@ -88,7 +91,8 @@ public:
uint32 numPoints, uint32 numPoints,
uint32 numElements, uint32 numElements,
const ViewType1D<realx3,memory_space>& points, const ViewType1D<realx3,memory_space>& points,
const ViewType1D<uint32x3,memory_space>& vertices); const ViewType1D<uint32x3,memory_space>& vertices,
const ViewType1D<realx3, memory_space>& normals);
@ -97,8 +101,9 @@ public:
bool resetElements( bool resetElements(
uint32 numElements, uint32 numElements,
uint32 numPoints, uint32 numPoints,
ViewType1D<realx3, memory_space>& points, const ViewType1D<realx3, memory_space>& points,
ViewType1D<uint32x3, memory_space>& vertices); const ViewType1D<uint32x3, memory_space>& vertices,
const ViewType1D<realx3, memory_space>& normals);
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
@ -116,18 +121,27 @@ public:
bool broadSearch( bool broadSearch(
csPairContainerType& pairs, csPairContainerType& pairs,
const cells& searchBox, const cells& searchBox,
const mapperNBS::CellIterator& particleMap); const mapperNBS::CellIterator& particleMap,
const deviceViewType1D<realx3>& pPoints,
const deviceViewType1D<real>& pDiams,
real sizeRatio);
bool build(const cells& searchBox); bool build(const cells& searchBox);
bool particleWallFindPairs( bool particleWallFindPairs(
csPairContainerType& pairs, csPairContainerType& pairs,
const mapperNBS::CellIterator& particleMap); const mapperNBS::CellIterator& particleMap,
const deviceViewType1D<realx3>& pPoints,
const deviceViewType1D<real>& pDiams,
real sizeRatio);
int32 findPairsElementRangeCount( int32 findPairsElementRangeCount(
csPairContainerType& pairs, csPairContainerType& pairs,
const mapperNBS::CellIterator& particleMap); const mapperNBS::CellIterator& particleMap,
const deviceViewType1D<realx3>& pPoints,
const deviceViewType1D<real>& pDiams,
real sizeRatio);

View File

@ -134,7 +134,7 @@ pFlow::sphereInteraction<cFM,gMM, cLT>::sphereInteraction
{ {
contactSearch_ = contactSearch::create( contactSearch_ = contactSearch::create(
subDict("contactSearch"), subDict("contactSearch"),
prtcl.thisDomain().domainBox(), prtcl.extendedDomain().domainBox(),
prtcl, prtcl,
geom, geom,
timers()); timers());

View File

@ -281,6 +281,15 @@ pFlow::fileSystem pFlow::operator /
} }
pFlow::fileSystem pFlow::operator /
(
const fileSystem& fs1,
const word& dir2
)
{
return fs1/fileSystem(dir2, "");
}
pFlow::fileSystem pFlow::operator + pFlow::fileSystem pFlow::operator +
( (
const fileSystem& fs1, const fileSystem& fs1,

View File

@ -50,7 +50,13 @@ fileSystem operator /
( (
const fileSystem& fs1, const fileSystem& fs1,
const fileSystem& fs2 const fileSystem& fs2
); );
fileSystem operator /
(
const fileSystem& fs1,
const word& dir2
);
fileSystem operator + fileSystem operator +
( (

View File

@ -117,6 +117,15 @@ pFlow::timeControl::timeControl(
checkForOutputToFile(); checkForOutputToFile();
} }
pFlow::real pFlow::timeControl::setTime(real t)
{
real tmp = currentTime_;
currentTime_ = t;
lastSaved_ = t;
checkForOutputToFile();
return tmp;
}
pFlow::word pFlow::timeControl::timeName()const pFlow::word pFlow::timeControl::timeName()const
{ {
if(managedExternaly_) if(managedExternaly_)
@ -167,8 +176,6 @@ void pFlow::timeControl::checkForOutputToFile()
} }
outputToFile_ = save; outputToFile_ = save;
} }
bool pFlow::timeControl::timersReportTime()const bool pFlow::timeControl::timersReportTime()const

View File

@ -108,14 +108,8 @@ public:
return dt_; return dt_;
} }
real setTime(real t) real setTime(real t);
{
real tmp = currentTime_;
currentTime_ = t;
lastSaved_ = t;
checkForOutputToFile();
return tmp;
}
void setStopAt(real sT) void setStopAt(real sT)
{ {

View File

@ -31,7 +31,6 @@ Licence:
#include "types.hpp" #include "types.hpp"
#include "Time.hpp" #include "Time.hpp"
#include "fileDictionary.hpp" #include "fileDictionary.hpp"
#include "box.hpp"
#include "Timers.hpp" #include "Timers.hpp"
#include "dynamicLinkLibs.hpp" #include "dynamicLinkLibs.hpp"
#include "Set.hpp" #include "Set.hpp"
@ -176,11 +175,6 @@ public:
return settingsDict_().getVal<realx3>("g"); return settingsDict_().getVal<realx3>("g");
} }
/*inline box domain()
{
return box(domainDict().subDict("globalBox"));
}*/
bool operator ++(int); bool operator ++(int);
void setSaveTimeFolder( void setSaveTimeFolder(

View File

@ -148,6 +148,12 @@ public:
return simulationDomain_().thisDomain(); return simulationDomain_().thisDomain();
} }
inline
const auto& extendedDomain()const
{
return boundaries_.extendedDomain();
}
// - IO methods // - IO methods
/// @brief read the point structure from the input stream. /// @brief read the point structure from the input stream.

View File

@ -5,7 +5,7 @@ add_subdirectory(particlesPhasicFlow)
add_subdirectory(geometryPhasicFlow) add_subdirectory(geometryPhasicFlow)
#add_subdirectory(pFlowToVTK) add_subdirectory(pFlowToVTK)
add_subdirectory(Utilities) add_subdirectory(Utilities)

View File

@ -1,8 +1,8 @@
set(SourceFiles set(SourceFiles
readFromTimeFolder.cpp readFromTimeFolder.cpp
readControlDict.cpp #readControlDict.cpp
#vtkFile/vtkFile.cpp vtkFile/vtkFile.cpp
geometryPhasicFlow/Wall/Wall.cpp geometryPhasicFlow/Wall/Wall.cpp
geometryPhasicFlow/planeWall/planeWall.cpp geometryPhasicFlow/planeWall/planeWall.cpp
#geometryPhasicFlow/stlWall/stlWall.cpp #geometryPhasicFlow/stlWall/stlWall.cpp

View File

@ -1,7 +1,7 @@
set(source_files set(source_files
pFlowToVTK.cpp pFlowToVTK.cpp
geometric.cpp #geometric.cpp
) )
set(link_lib phasicFlow Kokkos::kokkos Utilities) set(link_lib phasicFlow Kokkos::kokkos Utilities)

View File

@ -18,29 +18,19 @@ Licence:
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#include "vocabs.hpp"
#include "systemControl.hpp" #include "systemControl.hpp"
#include "pointFieldToVTK.hpp"
#include "triSurfaceFieldToVTK.hpp"
#include "timeFolder.hpp" #include "timeFolder.hpp"
#include "commandLine.hpp" #include "commandLine.hpp"
#include "ranges.hpp" #include "ranges.hpp"
#include "readControlDict.hpp" #include "Vectors.hpp"
#include "phasicFlowKokkos.hpp"
#include "pointFieldToVTK.hpp"
//#include "triSurfaceFieldToVTK.hpp"
//#include "readControlDict.hpp"
using pFlow::word; using namespace pFlow;
using pFlow::wordVector;
using pFlow::geometryFolder__;
using pFlow::timeFolder;
using pFlow::fileSystem;
using pFlow::wordList;
using pFlow::IOfileHeader;
using pFlow::objectFile;
using pFlow::output;
using pFlow::endl;
using pFlow::multiTriSurface;
using pFlow::commandLine;
using pFlow::realCombinedRange;
int main(int argc, char** argv ) int main(int argc, char** argv )
{ {
@ -69,6 +59,12 @@ int main(int argc, char** argv )
"path to output folder of VTK", "path to output folder of VTK",
"path"); "path");
bool separateSurfaces = false;
cmds.addOption(
"-s,--separate-surfaces",
separateSurfaces,
"surfaces in the geometry are converted separatedly");
wordVector fields; wordVector fields;
bool allFields = true; bool allFields = true;
cmds.addOption("-f,--fields", cmds.addOption("-f,--fields",
@ -92,7 +88,7 @@ int main(int argc, char** argv )
timeFolder folders(Control); timeFolder folders(Control);
fileSystem destFolder = fileSystem(outFolder)/geometryFolder__; fileSystem destFolder = fileSystem(outFolder)/word(geometryFolder__);
fileSystem destFolderField = fileSystem(outFolder); fileSystem destFolderField = fileSystem(outFolder);
wordList geomfiles{"triSurface"}; wordList geomfiles{"triSurface"};
@ -117,11 +113,11 @@ int main(int argc, char** argv )
do do
{ {
Control.time().setTime(folders.time());
if( !validRange.isMember( folders.time() ) )continue; if( !validRange.isMember( folders.time() ) )continue;
output<< "time: " << cyanText( folders.time() )<<" s" <<endl; output<< "time: " << Cyan_Text( folders.time() )<<" s" <<endl;
if(!noGoem) /*if(!noGoem)
{ {
fileSystem geomFolder = folders.folder()/geometryFolder__; fileSystem geomFolder = folders.folder()/geometryFolder__;
if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(geomFolder, folders.time(), destFolder, "surface")) if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(geomFolder, folders.time(), destFolder, "surface"))
@ -129,7 +125,7 @@ int main(int argc, char** argv )
fatalExit; fatalExit;
return 1; return 1;
} }
} }*/
if(!noParticle) if(!noParticle)
{ {
@ -137,17 +133,15 @@ int main(int argc, char** argv )
if(allFields) if(allFields)
{ {
if( !pFlow::PFtoVTK::convertTimeFolderPointFields( if( !pFlow::PFtoVTK::convertTimeFolderPointFields(
folders.folder(), Control,
folders.time(),
destFolderField, destFolderField,
"sphereFields" ) "sphereFields" ))
)
{ {
fatalExit; fatalExit;
} }
}else }else
{ {
if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected( /*if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
folders.folder(), folders.folder(),
folders.time(), folders.time(),
destFolderField, destFolderField,
@ -157,7 +151,7 @@ int main(int argc, char** argv )
) )
{ {
fatalExit; fatalExit;
} }*/
} }
} }

View File

@ -25,13 +25,15 @@ Licence:
#include <regex> #include <regex>
#include "vtkFile.hpp" #include "vtkFile.hpp"
#include "systemControl.hpp"
#include "pointStructure.hpp"
#include "pointFields.hpp" #include "pointFields.hpp"
#include "IOobject.hpp"
namespace pFlow::PFtoVTK namespace pFlow::PFtoVTK
{ {
template<typename IntType, typename IncludeMaskType> /*template<typename IntType, typename IncludeMaskType>
bool addIntPointField( bool addIntPointField(
iOstream& os, iOstream& os,
word fieldName, word fieldName,
@ -53,7 +55,7 @@ bool addRealx3PointField(
word fieldName, word fieldName,
int32 numActivePoints, int32 numActivePoints,
realx3* field, realx3* field,
IncludeMaskType includeMask ); IncludeMaskType includeMask );*/
bool regexCheck(word TYPENAME, word fieldType) bool regexCheck(word TYPENAME, word fieldType)
{ {
@ -69,14 +71,10 @@ bool regexCheck(word TYPENAME, word fieldType)
template<typename Type> template<typename Type>
bool checkFieldType(word objectType) bool checkFieldType(word objectType)
{ {
//if( pointField<VectorSingle,Type>::TYPENAME() == objectType )return true; return regexCheck(pointField<Type>::TYPENAME(), objectType);
//if( pointField<VectorSingle,Type, HostSpace>::TYPENAME() == objectType ) return true;
//if( pointField<VectorDual, Type>::TYPENAME() == objectType )return true;
return regexCheck(pointField<VectorSingle,Type>::TYPENAME(), objectType);
} }
template<typename T> /*template<typename T>
bool convertIntPointField bool convertIntPointField
( (
iOstream& os, iOstream& os,
@ -113,10 +111,10 @@ bool convertIntPointField
pStruct.numActive(), pStruct.numActive(),
data, data,
pStruct.activePointsMaskH() ); pStruct.activePointsMaskH() );
} }*/
bool convertRealTypePointField( /*bool convertRealTypePointField(
iOstream& os, iOstream& os,
const IOfileHeader& header, const IOfileHeader& header,
const pointStructure& pStruct) const pointStructure& pStruct)
@ -144,9 +142,9 @@ bool convertRealTypePointField(
pStruct.numActive(), pStruct.numActive(),
data, data,
pStruct.activePointsMaskH() ); pStruct.activePointsMaskH() );
} }*/
bool convertRealx3TypePointField( /*bool convertRealx3TypePointField(
iOstream& os, iOstream& os,
const IOfileHeader& header, const IOfileHeader& header,
const pointStructure& pStruct) const pointStructure& pStruct)
@ -174,50 +172,45 @@ bool convertRealx3TypePointField(
pStruct.numActive(), pStruct.numActive(),
data, data,
pStruct.activePointsMaskH() ); pStruct.activePointsMaskH() );
} }*/
template<typename IncludeMaskType>
bool addUndstrcuturedGridField( bool addUndstrcuturedGridField(
iOstream& os, iOstream& os,
int32 numActivePoints,
realx3* position, realx3* position,
IncludeMaskType includeMask) uint32 numPoints)
{ {
auto [iFirst, iLast] = includeMask.activeRange();
os<< "DATASET UNSTRUCTURED_GRID\n"; os<< "DATASET UNSTRUCTURED_GRID\n";
os<< "POINTS "<< numActivePoints << " float\n"; os<< "POINTS "<< numPoints << " float\n";
if(numActivePoints==0) return true; if(numPoints==0) return true;
for(int32 i=iFirst; i<iLast; ++i) for(uint32 i=0; i<numPoints; i++)
{ {
if(includeMask(i)) os<< position[i].x()<<' '<< position[i].y()<<' '<<position[i].z()<<'\n';
os<< position[i].x()<<' '<< position[i].y()<<' '<<position[i].z()<<'\n';
} }
os<<"CELLS "<< numActivePoints<<' '<< 2*numActivePoints<<'\n'; os<<"CELLS "<< numPoints<<' '<< 2*numPoints<<'\n';
for(int32 i=0; i<numActivePoints; i++) for(uint32 i=0; i<numPoints; i++)
{ {
os<< 1 <<' '<< i<<'\n'; os<< 1 <<' '<< i<<'\n';
} }
os<<"CELL_TYPES "<< numActivePoints<<'\n'; os<<"CELL_TYPES "<< numPoints<<'\n';
for(int32 i=0; i<numActivePoints; i++) for(int32 i=0; i<numPoints; i++)
{ {
os<< 1 <<'\n'; os<< 1 <<'\n';
} }
os << "POINT_DATA " << numActivePoints << endl; os << "POINT_DATA " << numPoints << endl;
return true; return true;
} }
template<typename IntType, typename IncludeMaskType> /*template<typename IntType, typename IncludeMaskType>
bool addIntPointField( bool addIntPointField(
iOstream& os, iOstream& os,
word fieldName, word fieldName,
@ -238,9 +231,9 @@ bool addIntPointField(
} }
return true; return true;
} }*/
template<typename IncludeMaskType> /*template<typename IncludeMaskType>
bool addRealPointField( bool addRealPointField(
iOstream& os, iOstream& os,
word fieldName, word fieldName,
@ -260,9 +253,9 @@ bool addRealPointField(
os<< field[i] <<'\n'; os<< field[i] <<'\n';
} }
return true; return true;
} }*/
template<typename IncludeMaskType> /*template<typename IncludeMaskType>
bool addRealx3PointField( bool addRealx3PointField(
iOstream& os, iOstream& os,
word fieldName, word fieldName,
@ -283,16 +276,16 @@ bool addRealx3PointField(
} }
return true; return true;
} }*/
bool convertTimeFolderPointFields( bool convertTimeFolderPointFields(
fileSystem timeFolder, systemControl& control,
real time,
fileSystem destPath, fileSystem destPath,
word bName) word bName)
{ {
fileSystem timeFolder = control.time().path();
// check if pointStructure exist in this folder // check if pointStructure exist in this folder
IOfileHeader pStructHeader( IOfileHeader pStructHeader(
objectFile( objectFile(
@ -304,36 +297,35 @@ bool convertTimeFolderPointFields(
if( !pStructHeader.headerOk(true) ) if( !pStructHeader.headerOk(true) )
{ {
output<<yellowColor<<"Time folder "<< timeFolder << output<<yellowColor<<"Time folder "<< control.time().path() <<
" does not contain any pStructure data file. Skipping this folder . . ." " does not contain any pStructure data file. Skipping this folder . . ."
<<defaultColor<<nl; <<defaultColor<<nl;
return true; return true;
} }
vtkFile vtk(destPath, bName, time); vtkFile vtk(destPath, bName, control.time().currentTime());
if(!vtk) return false; if(!vtk) return false;
auto pStructObjPtr = IOobject::make<pointStructure>(pStructHeader);
auto& pStruct = pStructObjPtr().getObject<pointStructure>(); auto pStruct = pointStructure(control);
// get a list of files in this timeFolder; // get a list of files in this timeFolder;
auto posVec = std::as_const(pStruct).pointPosition().hostVectorAll(); auto posVec = pStruct.pointPositionHost();
auto* pos = posVec.data(); auto* pos = posVec.data();
REPORT(1)<<"Writing pointStructure to vtk file with "<< yellowText(pStruct.numActive()) REPORT(1)<<"Writing pointStructure to vtk file with "<< Yellow_Text(pStruct.numActive())
<<" active particles"<<endREPORT; <<" active particles"<<END_REPORT;
addUndstrcuturedGridField( addUndstrcuturedGridField(
vtk(), vtk(),
pStruct.numActive(),
pos, pos,
pStruct.activePointsMaskH()); pStruct.numActive());
auto fileList = containingFiles(timeFolder); //auto fileList = containingFiles(timeFolder);
for(auto& file:fileList) /*for(auto& file:fileList)
{ {
IOfileHeader fieldHeader( IOfileHeader fieldHeader(
objectFile( objectFile(
@ -350,7 +342,7 @@ bool convertTimeFolderPointFields(
convertRealTypePointField(vtk(), fieldHeader, pStruct); convertRealTypePointField(vtk(), fieldHeader, pStruct);
convertRealx3TypePointField(vtk(), fieldHeader, pStruct); convertRealx3TypePointField(vtk(), fieldHeader, pStruct);
} }
} }*/
return true; return true;
} }
@ -367,7 +359,7 @@ bool convertTimeFolderPointFieldsSelected(
{ {
// check if pointStructure exist in this folder // check if pointStructure exist in this folder
IOfileHeader pStructHeader( /*IOfileHeader pStructHeader(
objectFile( objectFile(
pointStructureFile__, pointStructureFile__,
timeFolder, timeFolder,
@ -438,7 +430,7 @@ bool convertTimeFolderPointFieldsSelected(
REPORT(1)<<"Could not find "<<yellowText(fieldAddress) <<" skipping . . ."<<endREPORT; REPORT(1)<<"Could not find "<<yellowText(fieldAddress) <<" skipping . . ."<<endREPORT;
} }
} }
} }*/
return true; return true;
} }