Merge pull request #149 from PhasicFlow/develop
Binary conversion from pointFiled files to vtk format
This commit is contained in:
commit
bab1984b8e
|
@ -167,6 +167,11 @@ pFlow::fileSystem pFlow::fileSystem::canonical
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::fileSystem pFlow::fileSystem::relative(const fileSystem &base)const
|
||||||
|
{
|
||||||
|
return fileSystem( std::filesystem::relative(path_, base.path_));
|
||||||
|
}
|
||||||
|
|
||||||
bool pFlow::fileSystem::dirExist
|
bool pFlow::fileSystem::dirExist
|
||||||
(
|
(
|
||||||
) const
|
) const
|
||||||
|
|
|
@ -175,6 +175,9 @@ public:
|
||||||
/// Canonical path of this (it should exist)
|
/// Canonical path of this (it should exist)
|
||||||
fileSystem canonical()const;
|
fileSystem canonical()const;
|
||||||
|
|
||||||
|
/// relative path of this this with respect to base
|
||||||
|
fileSystem relative(const fileSystem& base)const;
|
||||||
|
|
||||||
/// Only operate on dir path
|
/// Only operate on dir path
|
||||||
/// Check if the dir path exists
|
/// Check if the dir path exists
|
||||||
bool dirExist()const;
|
bool dirExist()const;
|
||||||
|
|
|
@ -36,9 +36,9 @@ pFlow::pointSorting::pointSorting(const dictionary & dict)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if( performSorting_() )
|
if( performSorting_() )
|
||||||
REPORT(1)<<"Point sorting is "<<Yellow_Text("active")<<" in simulation"<<END_REPORT;
|
REPORT(2)<<"Point sorting is "<<Yellow_Text("active")<<" in simulation"<<END_REPORT;
|
||||||
else
|
else
|
||||||
REPORT(1)<<"Point sorting is "<<Yellow_Text("inactive")<<" in simulation"<<END_REPORT;
|
REPORT(2)<<"Point sorting is "<<Yellow_Text("inactive")<<" in simulation"<<END_REPORT;
|
||||||
|
|
||||||
}
|
}
|
||||||
pFlow::uint32IndexContainer
|
pFlow::uint32IndexContainer
|
||||||
|
|
|
@ -113,7 +113,7 @@ pFlow::pointStructure::pointStructure
|
||||||
(
|
(
|
||||||
simulationDomain::create(control)
|
simulationDomain::create(control)
|
||||||
),
|
),
|
||||||
pointSorting_(simulationDomain_->subDictOrCreate("pointSorting")),
|
//pointSorting_(simulationDomain_->subDictOrCreate("pointSorting")),
|
||||||
boundaries_
|
boundaries_
|
||||||
(
|
(
|
||||||
*this
|
*this
|
||||||
|
@ -130,6 +130,8 @@ pFlow::pointStructure::pointStructure
|
||||||
"Error in reading from file "<<IOobject::path()<<endl;
|
"Error in reading from file "<<IOobject::path()<<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pointSorting_ = makeUnique<pointSorting>(simulationDomain_->subDictOrCreate("pointSorting"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +157,7 @@ pFlow::pointStructure::pointStructure(
|
||||||
(
|
(
|
||||||
simulationDomain::create(control)
|
simulationDomain::create(control)
|
||||||
),
|
),
|
||||||
pointSorting_(simulationDomain_->subDictOrCreate("pointSorting")),
|
//pointSorting_(simulationDomain_->subDictOrCreate("pointSorting")),
|
||||||
boundaries_
|
boundaries_
|
||||||
(
|
(
|
||||||
*this
|
*this
|
||||||
|
@ -167,15 +169,16 @@ pFlow::pointStructure::pointStructure(
|
||||||
"Error in seting up pointStructure"<<endl;
|
"Error in seting up pointStructure"<<endl;
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
pointSorting_ = makeUnique<pointSorting>(simulationDomain_->subDictOrCreate("pointSorting"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::pointStructure::beforeIteration()
|
bool pFlow::pointStructure::beforeIteration()
|
||||||
{
|
{
|
||||||
const timeInfo ti = TimeInfo();
|
const timeInfo ti = TimeInfo();
|
||||||
|
|
||||||
if(pointSorting_.sortTime(ti.iter(), ti.t(), ti.dt()))
|
if(pointSorting_().sortTime(ti.iter(), ti.t(), ti.dt()))
|
||||||
{
|
{
|
||||||
auto sortedIndices = pointSorting_.getSortedIndices(
|
auto sortedIndices = pointSorting_().getSortedIndices(
|
||||||
simulationDomain_().globalBox(),
|
simulationDomain_().globalBox(),
|
||||||
pointPositionDevice(),
|
pointPositionDevice(),
|
||||||
activePointsMaskDevice()
|
activePointsMaskDevice()
|
||||||
|
|
|
@ -54,7 +54,7 @@ private:
|
||||||
//// - data members
|
//// - data members
|
||||||
uniquePtr<simulationDomain> simulationDomain_ = nullptr;
|
uniquePtr<simulationDomain> simulationDomain_ = nullptr;
|
||||||
|
|
||||||
pointSorting pointSorting_;
|
uniquePtr<pointSorting> pointSorting_ = nullptr;
|
||||||
|
|
||||||
boundaryList boundaries_;
|
boundaryList boundaries_;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*------------------------------- 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 __vtkByteSwapper_h__
|
||||||
|
#define __vtkByteSwapper_h__
|
||||||
|
|
||||||
|
namespace pFlow
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
This utility is used to re-order bytes when writing data in binary format to vtk file
|
||||||
|
These lines of code are exactly copied from the source code of https://github.com/Kitware/VTK/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
template <size_t s>
|
||||||
|
struct vtkByteSwapper;
|
||||||
|
|
||||||
|
/// @brief with char, no re-ordering is required
|
||||||
|
template <>
|
||||||
|
struct vtkByteSwapper<1>
|
||||||
|
{
|
||||||
|
static inline void Swap(char*) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief re-order 2-byte data
|
||||||
|
template <>
|
||||||
|
struct vtkByteSwapper<2>
|
||||||
|
{
|
||||||
|
static inline void Swap(char* data)
|
||||||
|
{
|
||||||
|
const uint16_t& ref16 = *reinterpret_cast<uint16_t*>(data);
|
||||||
|
*reinterpret_cast<uint16_t*>(data) = (ref16 >> 8) | (ref16 << 8);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief re-order 4-byte data
|
||||||
|
template <>
|
||||||
|
struct vtkByteSwapper<4>
|
||||||
|
{
|
||||||
|
static inline void Swap(char* data)
|
||||||
|
{
|
||||||
|
const uint32_t& ref32 = *reinterpret_cast<uint32_t*>(data);
|
||||||
|
*reinterpret_cast<uint32_t*>(data) =
|
||||||
|
(ref32 >> 24) | (ref32 << 24) | ((ref32 & 0x00ff0000) >> 8) | ((ref32 & 0x0000ff00) << 8);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief re-order of 8-byte data
|
||||||
|
template <>
|
||||||
|
struct vtkByteSwapper<8>
|
||||||
|
{
|
||||||
|
static inline void Swap(char* data)
|
||||||
|
{
|
||||||
|
const uint64_t& ref64 = *reinterpret_cast<uint64_t*>(data);
|
||||||
|
*reinterpret_cast<uint64_t*>(data) = (ref64 >> 56) | (ref64 << 56) |
|
||||||
|
((ref64 & 0x00ff000000000000) >> 40) | ((ref64 & 0x000000000000ff00) << 40) |
|
||||||
|
((ref64 & 0x0000ff0000000000) >> 24) | ((ref64 & 0x0000000000ff0000) << 24) |
|
||||||
|
((ref64 & 0x000000ff00000000) >> 8) | ((ref64 & 0x00000000ff000000) << 8);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T byteSwaper(const T& p)
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
T value;
|
||||||
|
char data[sizeof(T)];
|
||||||
|
} temp = { p };
|
||||||
|
vtkByteSwapper<sizeof(T)>::Swap(temp.data);
|
||||||
|
return temp.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // pFlow
|
||||||
|
|
||||||
|
#endif //__vtkByteSwapper_h__
|
|
@ -23,7 +23,7 @@ Licence:
|
||||||
|
|
||||||
bool pFlow::vtkFile::openStream(bool wHeader)
|
bool pFlow::vtkFile::openStream(bool wHeader)
|
||||||
{
|
{
|
||||||
oStream_ = makeUnique<oFstream>( fileName(), false, append_ );
|
oStream_ = makeUnique<oFstream>( fileName(), binary_, append_ );
|
||||||
if( !oStream_ )return false;
|
if( !oStream_ )return false;
|
||||||
if(wHeader)
|
if(wHeader)
|
||||||
return writeHeader();
|
return writeHeader();
|
||||||
|
@ -36,11 +36,13 @@ bool pFlow::vtkFile::vtkFile::writeHeader()
|
||||||
|
|
||||||
if(!oStream_) return false;
|
if(!oStream_) return false;
|
||||||
|
|
||||||
oStream_() << "# vtk DataFile Version 2.0" << endl;
|
oStream_() << "# vtk DataFile Version 3.0" << endl;
|
||||||
|
|
||||||
oStream_() << "vtk file for time : " << time_ << endl;
|
oStream_() << "vtk file for time : " << time_ << endl;
|
||||||
|
if(binary_)
|
||||||
oStream_() << "ASCII" << endl;
|
oStream_() << "BINARY" << endl;
|
||||||
|
else
|
||||||
|
oStream_() << "ASCII" << endl;
|
||||||
|
|
||||||
if( oStream_().fail() ) return false;
|
if( oStream_().fail() ) return false;
|
||||||
|
|
||||||
|
@ -53,13 +55,15 @@ pFlow::vtkFile::vtkFile
|
||||||
const fileSystem dir,
|
const fileSystem dir,
|
||||||
const word& bName,
|
const word& bName,
|
||||||
real time,
|
real time,
|
||||||
|
bool bnry,
|
||||||
bool append
|
bool append
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
dirPath_(dir),
|
binary_(bnry),
|
||||||
baseName_(bName),
|
append_(append),
|
||||||
time_(time),
|
time_(time),
|
||||||
append_(append)
|
dirPath_(dir),
|
||||||
|
baseName_(bName)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!openStream(!append))
|
if(!openStream(!append))
|
||||||
|
|
|
@ -34,15 +34,17 @@ class vtkFile
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
fileSystem dirPath_;
|
uniquePtr<oFstream> oStream_= nullptr;
|
||||||
|
|
||||||
word baseName_;
|
bool binary_ = false;
|
||||||
|
|
||||||
real time_ = 0.0;
|
|
||||||
|
|
||||||
bool append_=false;
|
bool append_=false;
|
||||||
|
|
||||||
uniquePtr<oFstream> oStream_= nullptr;
|
real time_ = 0.0;
|
||||||
|
|
||||||
|
fileSystem dirPath_;
|
||||||
|
|
||||||
|
word baseName_;
|
||||||
|
|
||||||
bool openStream(bool wHeader);
|
bool openStream(bool wHeader);
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ public:
|
||||||
const fileSystem dir,
|
const fileSystem dir,
|
||||||
const word& bName,
|
const word& bName,
|
||||||
real time,
|
real time,
|
||||||
|
bool bnry,
|
||||||
bool append = false);
|
bool append = false);
|
||||||
|
|
||||||
virtual ~vtkFile() = default;
|
virtual ~vtkFile() = default;
|
||||||
|
@ -87,6 +90,12 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool binary()const
|
||||||
|
{
|
||||||
|
return binary_;
|
||||||
|
}
|
||||||
|
|
||||||
virtual fileSystem fileName()const;
|
virtual fileSystem fileName()const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
|
||||||
set(source_files
|
set(source_files
|
||||||
|
fileSeries.cpp
|
||||||
pointFieldToVTK.cpp
|
pointFieldToVTK.cpp
|
||||||
triSurfaceFieldToVTK.cpp
|
triSurfaceFieldToVTK.cpp
|
||||||
pFlowToVTK.cpp
|
pFlowToVTK.cpp
|
||||||
|
|
||||||
#geometric.cpp
|
#geometric.cpp
|
||||||
)
|
)
|
||||||
set(link_lib phasicFlow Kokkos::kokkos Utilities)
|
set(link_lib phasicFlow Kokkos::kokkos Utilities)
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
#include "fileSeries.hpp"
|
||||||
|
#include "oFstream.hpp"
|
||||||
|
#include "streams.hpp"
|
||||||
|
|
||||||
|
void pFlow::PFtoVTK::fileSeries::writeOneBaseName(const word &baseName)
|
||||||
|
{
|
||||||
|
auto& fList = timeFiles_[baseName];
|
||||||
|
word fileName = baseName + ".vtk.series";
|
||||||
|
oFstream os(destDir_+fileName);
|
||||||
|
|
||||||
|
REPORT(1)<<"Writing to "<<os.name()<<END_REPORT;
|
||||||
|
|
||||||
|
os<<"{\n";
|
||||||
|
os<<" \"file-series-version\" : \"1.0\",\n";
|
||||||
|
os<<" \"files\" : [\n";
|
||||||
|
const auto lastItem = std::prev(fList.end());
|
||||||
|
for(auto iter = fList.begin(); iter != fList.end(); ++iter)
|
||||||
|
{
|
||||||
|
os<<" {\"name\" : \"";
|
||||||
|
os<< iter->second;
|
||||||
|
os<<"\", \"time\" :";
|
||||||
|
os<<iter->first;
|
||||||
|
if(iter == lastItem)
|
||||||
|
os<<"}\n";
|
||||||
|
else
|
||||||
|
os<<"},\n";
|
||||||
|
}
|
||||||
|
os<<" ]\n";
|
||||||
|
os<<"}\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::PFtoVTK::fileSeries::fileSeries(const fileSystem dest)
|
||||||
|
: destDir_(dest)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::PFtoVTK::fileSeries::~fileSeries()
|
||||||
|
{
|
||||||
|
REPORT(0)<<"Writing time series files..."<<END_REPORT;
|
||||||
|
for(const auto& fSeries:timeFiles_)
|
||||||
|
{
|
||||||
|
writeOneBaseName(fSeries.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::PFtoVTK::fileSeries::addTimeFile(const word& baseName, real time, const word &fileName)
|
||||||
|
{
|
||||||
|
fileSystem fs(fileName);
|
||||||
|
word relFileName = fs.relative(destDir_).wordPath();
|
||||||
|
|
||||||
|
if( auto [iter, found]=timeFiles_.findIf(baseName); found )
|
||||||
|
{
|
||||||
|
return iter->second.insertIf(time, relFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TimeFileType newList;
|
||||||
|
newList.insertIf(time, relFileName);
|
||||||
|
return timeFiles_.insertIf(baseName, newList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::PFtoVTK::fileSeries::addTimeFile(const wordList &baseNames, real time, const wordList &fileNames)
|
||||||
|
{
|
||||||
|
if(baseNames.size()!= fileNames.size() )
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<<"sizes of base names and file names are not equal\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(size_t i=0; i<baseNames.size(); i++)
|
||||||
|
{
|
||||||
|
if(!addTimeFile(baseNames[i], time, fileNames[i]))
|
||||||
|
{
|
||||||
|
fatalErrorInFunction<<"Error in adding multiple time files\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __fileSeries_hpp__
|
||||||
|
#define __fileSeries_hpp__
|
||||||
|
|
||||||
|
#include "fileStream.hpp"
|
||||||
|
#include "Map.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace pFlow::PFtoVTK
|
||||||
|
{
|
||||||
|
|
||||||
|
class fileSeries
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
using TimeFileType = Map<real, word>;
|
||||||
|
|
||||||
|
Map<word, TimeFileType> timeFiles_;
|
||||||
|
|
||||||
|
fileSystem destDir_;
|
||||||
|
|
||||||
|
void writeOneBaseName(const word& baseName);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
fileSeries(const fileSystem dest);
|
||||||
|
|
||||||
|
~fileSeries();
|
||||||
|
|
||||||
|
|
||||||
|
bool addTimeFile(const word& baseName, real time, const word& fileName);
|
||||||
|
|
||||||
|
bool addTimeFile(const wordList& baseNames, real time, const wordList& fileNames);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__fileSeries_hpp__
|
|
@ -27,8 +27,10 @@ Licence:
|
||||||
#include "phasicFlowKokkos.hpp"
|
#include "phasicFlowKokkos.hpp"
|
||||||
#include "pointFieldToVTK.hpp"
|
#include "pointFieldToVTK.hpp"
|
||||||
#include "triSurfaceFieldToVTK.hpp"
|
#include "triSurfaceFieldToVTK.hpp"
|
||||||
|
#include "fileSeries.hpp"
|
||||||
//#include "readControlDict.hpp"
|
//#include "readControlDict.hpp"
|
||||||
|
|
||||||
|
bool bindaryOutput__;
|
||||||
|
|
||||||
int main(int argc, char** argv )
|
int main(int argc, char** argv )
|
||||||
{
|
{
|
||||||
|
@ -52,6 +54,11 @@ int main(int argc, char** argv )
|
||||||
noParticle,
|
noParticle,
|
||||||
"Do not convert particle fields to VTK file");
|
"Do not convert particle fields to VTK file");
|
||||||
|
|
||||||
|
bindaryOutput__ = false;
|
||||||
|
cmds.add_flag("-b, --binary",
|
||||||
|
bindaryOutput__,
|
||||||
|
"Wrtie vtk file (for particles only) in binary format. Default is ASCII");
|
||||||
|
|
||||||
cmds.addOption("-o,--out-folder",
|
cmds.addOption("-o,--out-folder",
|
||||||
outFolder,
|
outFolder,
|
||||||
"path to output folder of VTK",
|
"path to output folder of VTK",
|
||||||
|
@ -85,9 +92,18 @@ int main(int argc, char** argv )
|
||||||
#include "initialize_Control.hpp"
|
#include "initialize_Control.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
if(!bindaryOutput__)
|
||||||
|
{
|
||||||
|
INFORMATION<<"Writing vtk file in binray format will accelerate the conversion (5~10x)"<<
|
||||||
|
" and visualization in paraview."<<
|
||||||
|
" Consider addig flag -b or --binary in the command line."<<END_INFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::word formatName = bindaryOutput__?"binary":"ascii";
|
||||||
|
|
||||||
pFlow::timeFolder folders(Control);
|
pFlow::timeFolder folders(Control);
|
||||||
auto destFolder = pFlow::fileSystem(outFolder)/pFlow::word(pFlow::geometryFolder__);
|
auto destFolderGeometry = pFlow::fileSystem(outFolder)/pFlow::word(pFlow::geometryFolder__);
|
||||||
auto destFolderField = pFlow::fileSystem(outFolder);
|
auto destFolderField = pFlow::fileSystem(outFolder)/pFlow::word("particles");
|
||||||
pFlow::wordList geomfiles{"triSurface"};
|
pFlow::wordList geomfiles{"triSurface"};
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,6 +125,12 @@ int main(int argc, char** argv )
|
||||||
validRange.addIntervalRange(folders.startTime(), folders.endTime());
|
validRange.addIntervalRange(folders.startTime(), folders.endTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
pFlow::PFtoVTK::fileSeries timeSeries{pFlow::fileSystem(outFolder)};
|
||||||
|
pFlow::word fileName;
|
||||||
|
pFlow::wordList geomFileNames;
|
||||||
|
pFlow::wordList surfNames;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Control.time().setTime(folders.time());
|
Control.time().setTime(folders.time());
|
||||||
|
@ -119,22 +141,27 @@ int main(int argc, char** argv )
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(
|
if(!pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(
|
||||||
Control, destFolder, "surface", separateSurfaces))
|
Control, destFolderGeometry, "surface", separateSurfaces, surfNames, geomFileNames))
|
||||||
{
|
{
|
||||||
fatalExit;
|
fatalExit;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeSeries.addTimeFile(surfNames, folders.time(), geomFileNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!noParticle)
|
if(!noParticle)
|
||||||
{
|
{
|
||||||
|
REPORT(1)<< "Converting pointFields to vtk file in "<< formatName<< " format ..."<<END_REPORT;
|
||||||
if(allFields)
|
if(allFields)
|
||||||
{
|
{
|
||||||
if( !pFlow::PFtoVTK::convertTimeFolderPointFields(
|
if( !pFlow::PFtoVTK::convertTimeFolderPointFields(
|
||||||
Control,
|
Control,
|
||||||
destFolderField,
|
destFolderField,
|
||||||
"sphereFields" ))
|
"particles",
|
||||||
|
fileName
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
@ -143,14 +170,19 @@ int main(int argc, char** argv )
|
||||||
if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
Control,
|
Control,
|
||||||
destFolderField,
|
destFolderField,
|
||||||
"sphereFields",
|
"particles",
|
||||||
fields,
|
fields,
|
||||||
!pFlow::equal(folders.time(),static_cast<pFlow::real>(0.0)) )
|
!pFlow::equal(folders.time(),static_cast<pFlow::real>(0.0)),
|
||||||
|
fileName
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeSeries.addTimeFile("particles", folders.time(), fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::output<<pFlow::endl;
|
pFlow::output<<pFlow::endl;
|
||||||
|
@ -158,6 +190,8 @@ int main(int argc, char** argv )
|
||||||
}
|
}
|
||||||
while( folders++ );
|
while( folders++ );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pFlow::output<< "\nFinished successfully.\n";
|
pFlow::output<< "\nFinished successfully.\n";
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include "vocabs.hpp"
|
#include "vocabs.hpp"
|
||||||
#include "pointFieldToVTK.hpp"
|
#include "pointFieldToVTK.hpp"
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::PFtoVTK::convertTimeFolderPointFields(
|
bool pFlow::PFtoVTK::convertTimeFolderPointFields(
|
||||||
systemControl &control,
|
systemControl &control,
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
const word &bName)
|
const word &bName,
|
||||||
|
word& filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
fileSystem timeFolder = control.time().path();
|
fileSystem timeFolder = control.time().path();
|
||||||
|
@ -27,11 +29,14 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFields(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkFile vtk(destPath, bName, control.time().currentTime());
|
vtkFile vtk(destPath, bName, control.time().currentTime(), bindaryOutput__);
|
||||||
|
|
||||||
if (!vtk)
|
if (!vtk)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
filename = vtk.fileName().wordPath();
|
||||||
|
|
||||||
|
REPORT(1);
|
||||||
auto pStruct = pointStructure(control);
|
auto pStruct = pointStructure(control);
|
||||||
|
|
||||||
// get a list of files in this timeFolder;
|
// get a list of files in this timeFolder;
|
||||||
|
@ -39,7 +44,7 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFields(
|
||||||
auto posVec = pStruct.pointPositionHost();
|
auto posVec = pStruct.pointPositionHost();
|
||||||
auto *pos = posVec.data();
|
auto *pos = posVec.data();
|
||||||
|
|
||||||
REPORT(1) << "Writing pointStructure to vtk file with " <<
|
REPORT(2) << ">>> Writing pointStructure to vtk file with " <<
|
||||||
Yellow_Text(pStruct.numActive())<<
|
Yellow_Text(pStruct.numActive())<<
|
||||||
" active particles" << END_REPORT;
|
" active particles" << END_REPORT;
|
||||||
|
|
||||||
|
@ -62,13 +67,14 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFields(
|
||||||
|
|
||||||
if (fieldHeader.headerOk(true))
|
if (fieldHeader.headerOk(true))
|
||||||
{
|
{
|
||||||
|
// 64-bit intergers are not supported for convertion
|
||||||
if(
|
if(
|
||||||
convertRealx3TypePointField(vtk(), fieldHeader, pStruct) ||
|
convertRealx3TypePointField(vtk(), fieldHeader, pStruct) ||
|
||||||
convertRealTypePointField(vtk(), fieldHeader, pStruct) ||
|
convertRealTypePointField(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<uint32>(vtk(), fieldHeader, pStruct) ||
|
convertIntPointField<uint32>(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<uint64>(vtk(), fieldHeader, pStruct) ||
|
//convertIntPointField<uint64>(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<int32>(vtk(), fieldHeader, pStruct) ||
|
convertIntPointField<int32>(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<int64>(vtk(), fieldHeader, pStruct)||
|
//convertIntPointField<int64>(vtk(), fieldHeader, pStruct)||
|
||||||
fieldHeader.objectName() == pointStructureFile__ )
|
fieldHeader.objectName() == pointStructureFile__ )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -91,7 +97,8 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
const word &bName,
|
const word &bName,
|
||||||
const wordVector &fieldsName,
|
const wordVector &fieldsName,
|
||||||
bool mustExist)
|
bool mustExist,
|
||||||
|
word& filename)
|
||||||
{
|
{
|
||||||
fileSystem timeFolder = control.time().path();
|
fileSystem timeFolder = control.time().path();
|
||||||
// check if pointStructure exist in this folder
|
// check if pointStructure exist in this folder
|
||||||
|
@ -111,11 +118,14 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkFile vtk(destPath, bName, control.time().currentTime());
|
vtkFile vtk(destPath, bName, control.time().currentTime(), bindaryOutput__);
|
||||||
|
|
||||||
if (!vtk)
|
if (!vtk)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
filename = vtk.fileName().wordPath();
|
||||||
|
|
||||||
|
REPORT(1);
|
||||||
auto pStruct = pointStructure(control);
|
auto pStruct = pointStructure(control);
|
||||||
|
|
||||||
// get a list of files in this timeFolder;
|
// get a list of files in this timeFolder;
|
||||||
|
@ -123,7 +133,7 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
auto posVec = pStruct.pointPositionHost();
|
auto posVec = pStruct.pointPositionHost();
|
||||||
auto *pos = posVec.data();
|
auto *pos = posVec.data();
|
||||||
|
|
||||||
REPORT(1) << "Writing pointStructure to vtk file with " <<
|
REPORT(2) << ">>> Writing pointStructure to vtk file with " <<
|
||||||
Yellow_Text(pStruct.numActive())
|
Yellow_Text(pStruct.numActive())
|
||||||
<< " active particles" << END_REPORT;
|
<< " active particles" << END_REPORT;
|
||||||
|
|
||||||
|
@ -148,12 +158,13 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
if (fieldHeader.headerOk(true))
|
if (fieldHeader.headerOk(true))
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
|
// 64-bit intergers are not supported for convertion
|
||||||
convertRealx3TypePointField(vtk(), fieldHeader, pStruct) ||
|
convertRealx3TypePointField(vtk(), fieldHeader, pStruct) ||
|
||||||
convertRealTypePointField(vtk(), fieldHeader, pStruct) ||
|
convertRealTypePointField(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<uint32>(vtk(), fieldHeader, pStruct) ||
|
convertIntPointField<uint32>(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<uint64>(vtk(), fieldHeader, pStruct) ||
|
// convertIntPointField<uint64>(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<int32>(vtk(), fieldHeader, pStruct) ||
|
convertIntPointField<int32>(vtk(), fieldHeader, pStruct) ||
|
||||||
convertIntPointField<int64>(vtk(), fieldHeader, pStruct) ||
|
//convertIntPointField<int64>(vtk(), fieldHeader, pStruct) ||
|
||||||
fieldHeader.objectName() == pointStructureFile__ )
|
fieldHeader.objectName() == pointStructureFile__ )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -176,7 +187,7 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
REPORT(1) << "Could not find " << Yellow_Text(fieldAddress) <<
|
REPORT(2) << "Could not find " << Yellow_Text(fieldAddress) <<
|
||||||
". Skipping this field . . ." << END_REPORT;
|
". Skipping this field . . ." << END_REPORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,45 +196,79 @@ bool pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::PFtoVTK::addUndstrcuturedGridField(
|
bool pFlow::PFtoVTK::addUndstrcuturedGridField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
realx3 *position,
|
realx3 *position,
|
||||||
uint32 numPoints)
|
uint32 numPoints)
|
||||||
{
|
{
|
||||||
|
|
||||||
os << "DATASET UNSTRUCTURED_GRID\n";
|
os << "DATASET UNSTRUCTURED_GRID\n";
|
||||||
os << "POINTS " << numPoints << " float\n";
|
|
||||||
|
|
||||||
if (numPoints == 0)
|
if (numPoints == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (uint32 i = 0; i < numPoints; i++)
|
os << "POINTS " << numPoints << " float"<<'\n';
|
||||||
{
|
if(bindaryOutput__)
|
||||||
os << position[i].x() <<
|
{
|
||||||
' ' << position[i].y() <<
|
for(uint32 i=0; i<numPoints; i++)
|
||||||
' ' << position[i].z() << '\n';
|
{
|
||||||
|
float x = byteSwaper(static_cast<float>(position[i].x()));
|
||||||
|
float y = byteSwaper(static_cast<float>(position[i].y()));
|
||||||
|
float z = byteSwaper(static_cast<float>(position[i].z()));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&x), sizeof(x));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&y), sizeof(y));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&z), sizeof(z));
|
||||||
|
}
|
||||||
|
os<<'\n';
|
||||||
|
os << "CELLS " << numPoints << ' ' << 2 * numPoints<<'\n';
|
||||||
|
|
||||||
|
const int32 one_ro = byteSwaper(1);
|
||||||
|
for (int i = 0; i < numPoints; i++)
|
||||||
|
{
|
||||||
|
int pN = byteSwaper(i);
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&one_ro), sizeof(one_ro));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&pN), sizeof(pN));
|
||||||
|
}
|
||||||
|
os<<'\n';
|
||||||
|
os << "CELL_TYPES " << numPoints<<'\n';
|
||||||
|
for (int32 i = 0; i < numPoints; i++)
|
||||||
|
{
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&one_ro), sizeof(one_ro));
|
||||||
|
}
|
||||||
|
os<<'\n';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
os << "CELLS " << numPoints << ' ' << 2 * numPoints << '\n';
|
|
||||||
for (uint32 i = 0; i < numPoints; i++)
|
|
||||||
{
|
{
|
||||||
os << 1 << ' ' << i << '\n';
|
for (uint32 i = 0; i < numPoints; i++)
|
||||||
|
{
|
||||||
|
os << position[i].x() <<
|
||||||
|
' ' << position[i].y() <<
|
||||||
|
' ' << position[i].z() << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "CELLS " << numPoints << ' ' << 2 * numPoints << '\n';
|
||||||
|
for (uint32 i = 0; i < numPoints; i++)
|
||||||
|
{
|
||||||
|
os << 1 << ' ' << i << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "CELL_TYPES " << numPoints << '\n';
|
||||||
|
|
||||||
|
for (int32 i = 0; i < numPoints; i++)
|
||||||
|
{
|
||||||
|
os << 1 << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "CELL_TYPES " << numPoints << '\n';
|
|
||||||
|
|
||||||
for (int32 i = 0; i < numPoints; i++)
|
|
||||||
{
|
|
||||||
os << 1 << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
os << "POINT_DATA " << numPoints << endl;
|
os << "POINT_DATA " << numPoints << endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::PFtoVTK::convertRealTypePointField(
|
bool pFlow::PFtoVTK::convertRealTypePointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const IOfileHeader &header,
|
const IOfileHeader &header,
|
||||||
pointStructure &pStruct)
|
pointStructure &pStruct)
|
||||||
{
|
{
|
||||||
|
@ -232,6 +277,7 @@ bool pFlow::PFtoVTK::convertRealTypePointField(
|
||||||
if (!checkFieldType<real>(objectType))
|
if (!checkFieldType<real>(objectType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
REPORT(1);
|
||||||
auto field = realPointField_H(
|
auto field = realPointField_H(
|
||||||
header,
|
header,
|
||||||
pStruct,
|
pStruct,
|
||||||
|
@ -239,7 +285,7 @@ bool pFlow::PFtoVTK::convertRealTypePointField(
|
||||||
|
|
||||||
real const *data = field.deviceViewAll().data();
|
real const *data = field.deviceViewAll().data();
|
||||||
|
|
||||||
REPORT(1) << "writing " << Green_Text(header.objectName()) <<
|
REPORT(2) << ">>> Writing " << Green_Text(header.objectName()) <<
|
||||||
" field to vtk." << END_REPORT;
|
" field to vtk." << END_REPORT;
|
||||||
|
|
||||||
return addRealPointField(
|
return addRealPointField(
|
||||||
|
@ -250,7 +296,7 @@ bool pFlow::PFtoVTK::convertRealTypePointField(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::PFtoVTK::convertRealx3TypePointField(
|
bool pFlow::PFtoVTK::convertRealx3TypePointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const IOfileHeader &header,
|
const IOfileHeader &header,
|
||||||
pointStructure &pStruct)
|
pointStructure &pStruct)
|
||||||
{
|
{
|
||||||
|
@ -259,6 +305,7 @@ bool pFlow::PFtoVTK::convertRealx3TypePointField(
|
||||||
if (!checkFieldType<realx3>(objectType))
|
if (!checkFieldType<realx3>(objectType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
REPORT(1);
|
||||||
auto field = realx3PointField_H(
|
auto field = realx3PointField_H(
|
||||||
header,
|
header,
|
||||||
pStruct,
|
pStruct,
|
||||||
|
@ -266,7 +313,7 @@ bool pFlow::PFtoVTK::convertRealx3TypePointField(
|
||||||
|
|
||||||
realx3 const *data = field.deviceViewAll().data();
|
realx3 const *data = field.deviceViewAll().data();
|
||||||
|
|
||||||
REPORT(1) << "writing " << Green_Text(header.objectName()) <<
|
REPORT(2) << ">>> Writing " << Green_Text(header.objectName()) <<
|
||||||
" field to vtk." << END_REPORT;
|
" field to vtk." << END_REPORT;
|
||||||
|
|
||||||
return addRealx3PointField(
|
return addRealx3PointField(
|
||||||
|
@ -277,7 +324,7 @@ bool pFlow::PFtoVTK::convertRealx3TypePointField(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::PFtoVTK::addRealPointField(
|
bool pFlow::PFtoVTK::addRealPointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const word &fieldName,
|
const word &fieldName,
|
||||||
const real *field,
|
const real *field,
|
||||||
uint32 numData)
|
uint32 numData)
|
||||||
|
@ -287,15 +334,28 @@ bool pFlow::PFtoVTK::addRealPointField(
|
||||||
|
|
||||||
os << "FIELD FieldData 1\n"
|
os << "FIELD FieldData 1\n"
|
||||||
<< fieldName << " 1 " << numData << " float\n";
|
<< fieldName << " 1 " << numData << " float\n";
|
||||||
for (uint32 i = 0; i < numData; ++i)
|
if(bindaryOutput__)
|
||||||
{
|
{
|
||||||
os << field[i] << '\n';
|
for (uint32 i = 0; i < numData; ++i)
|
||||||
|
{
|
||||||
|
float x = byteSwaper(static_cast<float>(field[i]));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&x), sizeof(x));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < numData; ++i)
|
||||||
|
{
|
||||||
|
os << field[i] << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::PFtoVTK::addRealx3PointField(
|
bool pFlow::PFtoVTK::addRealx3PointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const word &fieldName,
|
const word &fieldName,
|
||||||
const realx3 *field,
|
const realx3 *field,
|
||||||
uint32 numData)
|
uint32 numData)
|
||||||
|
@ -305,12 +365,30 @@ bool pFlow::PFtoVTK::addRealx3PointField(
|
||||||
|
|
||||||
os << "FIELD FieldData 1\n"
|
os << "FIELD FieldData 1\n"
|
||||||
<< fieldName << " 3 " << numData << " float\n";
|
<< fieldName << " 3 " << numData << " float\n";
|
||||||
for (uint32 i = 0; i < numData; ++i)
|
|
||||||
|
if(bindaryOutput__)
|
||||||
{
|
{
|
||||||
os << field[i].x() <<
|
for(uint32 i=0; i<numData; i++)
|
||||||
' ' << field[i].y() <<
|
{
|
||||||
' ' << field[i].z() << '\n';
|
float x = byteSwaper(static_cast<float>(field[i].x()));
|
||||||
|
float y = byteSwaper(static_cast<float>(field[i].y()));
|
||||||
|
float z = byteSwaper(static_cast<float>(field[i].z()));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&x), sizeof(x));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&y), sizeof(y));
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&z), sizeof(z));
|
||||||
|
}
|
||||||
|
os<<'\n';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < numData; ++i)
|
||||||
|
{
|
||||||
|
os << field[i].x() <<
|
||||||
|
' ' << field[i].y() <<
|
||||||
|
' ' << field[i].z() << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ Licence:
|
||||||
#include "systemControl.hpp"
|
#include "systemControl.hpp"
|
||||||
#include "pointStructure.hpp"
|
#include "pointStructure.hpp"
|
||||||
#include "pointFields.hpp"
|
#include "pointFields.hpp"
|
||||||
|
#include "vtkByteSwapper.hpp"
|
||||||
|
|
||||||
|
extern bool bindaryOutput__;
|
||||||
|
|
||||||
namespace pFlow::PFtoVTK
|
namespace pFlow::PFtoVTK
|
||||||
{
|
{
|
||||||
|
@ -31,45 +34,47 @@ namespace pFlow::PFtoVTK
|
||||||
bool convertTimeFolderPointFields(
|
bool convertTimeFolderPointFields(
|
||||||
systemControl &control,
|
systemControl &control,
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
const word &bName);
|
const word &bName,
|
||||||
|
word& filename);
|
||||||
|
|
||||||
bool convertTimeFolderPointFieldsSelected(
|
bool convertTimeFolderPointFieldsSelected(
|
||||||
systemControl &control,
|
systemControl &control,
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
const word &bName,
|
const word &bName,
|
||||||
const wordVector &fieldsName,
|
const wordVector &fieldsName,
|
||||||
bool mustExist);
|
bool mustExist,
|
||||||
|
word& filename);
|
||||||
|
|
||||||
bool addUndstrcuturedGridField(
|
bool addUndstrcuturedGridField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
realx3 *position,
|
realx3 *position,
|
||||||
uint32 numPoints);
|
uint32 numPoints);
|
||||||
|
|
||||||
bool convertRealTypePointField(
|
bool convertRealTypePointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const IOfileHeader &header,
|
const IOfileHeader &header,
|
||||||
pointStructure &pStruct);
|
pointStructure &pStruct);
|
||||||
|
|
||||||
bool convertRealx3TypePointField(
|
bool convertRealx3TypePointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const IOfileHeader &header,
|
const IOfileHeader &header,
|
||||||
pointStructure &pStruct);
|
pointStructure &pStruct);
|
||||||
|
|
||||||
template <typename IntType>
|
template <typename IntType>
|
||||||
bool addIntPointField(
|
bool addIntPointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const word &fieldName,
|
const word &fieldName,
|
||||||
IntType *field,
|
IntType *field,
|
||||||
uint32 numData);
|
uint32 numData);
|
||||||
|
|
||||||
bool addRealPointField(
|
bool addRealPointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const word &fieldName,
|
const word &fieldName,
|
||||||
const real *field,
|
const real *field,
|
||||||
uint32 numData);
|
uint32 numData);
|
||||||
|
|
||||||
bool addRealx3PointField(
|
bool addRealx3PointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const word &fieldName,
|
const word &fieldName,
|
||||||
const realx3 *field,
|
const realx3 *field,
|
||||||
uint32 numData);
|
uint32 numData);
|
||||||
|
@ -87,7 +92,7 @@ namespace pFlow::PFtoVTK
|
||||||
|
|
||||||
template <typename IntType>
|
template <typename IntType>
|
||||||
inline bool convertIntPointField(
|
inline bool convertIntPointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const IOfileHeader &header,
|
const IOfileHeader &header,
|
||||||
pointStructure &pStruct)
|
pointStructure &pStruct)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +106,7 @@ namespace pFlow::PFtoVTK
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REPORT(1);
|
||||||
auto field = PointFieldType(
|
auto field = PointFieldType(
|
||||||
header,
|
header,
|
||||||
pStruct,
|
pStruct,
|
||||||
|
@ -108,7 +114,7 @@ namespace pFlow::PFtoVTK
|
||||||
|
|
||||||
const IntType *data = field.deviceViewAll().data();
|
const IntType *data = field.deviceViewAll().data();
|
||||||
|
|
||||||
REPORT(1) << "writing " << Green_Text(header.objectName()) << " field to vtk.\n";
|
REPORT(2) << ">>> Writing " << Green_Text(header.objectName()) << " field to vtk.\n";
|
||||||
|
|
||||||
return addIntPointField(
|
return addIntPointField(
|
||||||
os,
|
os,
|
||||||
|
@ -119,21 +125,49 @@ namespace pFlow::PFtoVTK
|
||||||
|
|
||||||
template <typename IntType>
|
template <typename IntType>
|
||||||
inline bool addIntPointField(
|
inline bool addIntPointField(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const word &fieldName,
|
const word &fieldName,
|
||||||
IntType *field,
|
IntType *field,
|
||||||
uint32 numData)
|
uint32 numData)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (numData == 0)
|
if (numData == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
os << "FIELD FieldData 1\n"
|
if(std::is_same_v<IntType, int> || std::is_same_v<IntType, const int> )
|
||||||
<< fieldName << " 1 " << numData << " int\n";
|
|
||||||
for (uint32 i = 0; i < numData; ++i)
|
|
||||||
{
|
{
|
||||||
os << field[i] << '\n';
|
os << "FIELD FieldData 1\n"
|
||||||
|
<< fieldName << " 1 " << numData << " int\n";
|
||||||
|
}
|
||||||
|
else if( std::is_same_v<IntType, unsigned int>|| std::is_same_v<IntType, const unsigned int>)
|
||||||
|
{
|
||||||
|
os << "FIELD FieldData 1\n"
|
||||||
|
<< fieldName << " 1 " << numData << " unsigned_int\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WARNING<<"Field "<< fieldName<< " has invalid data type for conversion. Type is "
|
||||||
|
<<getTypeName<IntType>()<<END_WARNING;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bindaryOutput__)
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < numData; ++i)
|
||||||
|
{
|
||||||
|
IntType val = byteSwaper(field[i]);
|
||||||
|
os.stdStream().write(reinterpret_cast<const char*>(&val), sizeof(IntType));
|
||||||
|
}
|
||||||
|
os<<'\n';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < numData; ++i)
|
||||||
|
{
|
||||||
|
os << field[i] << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,15 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(
|
||||||
systemControl &control,
|
systemControl &control,
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
const word &bName,
|
const word &bName,
|
||||||
bool separate)
|
bool separate,
|
||||||
|
wordList& surfNames,
|
||||||
|
wordList& fileNames)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto timeFolder = control.geometry().path();
|
auto timeFolder = control.geometry().path();
|
||||||
|
|
||||||
|
surfNames.clear();
|
||||||
|
fileNames.clear();
|
||||||
|
|
||||||
// check if pointStructure exist in this folder
|
// check if pointStructure exist in this folder
|
||||||
IOfileHeader triSurfaeHeader(
|
IOfileHeader triSurfaeHeader(
|
||||||
|
@ -40,7 +45,9 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(
|
||||||
triSurfaceObj,
|
triSurfaceObj,
|
||||||
destPath,
|
destPath,
|
||||||
control.time().currentTime(),
|
control.time().currentTime(),
|
||||||
bName);
|
bName,
|
||||||
|
surfNames,
|
||||||
|
fileNames);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -48,12 +55,14 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFields(
|
||||||
triSurfaceObj,
|
triSurfaceObj,
|
||||||
destPath,
|
destPath,
|
||||||
control.time().currentTime(),
|
control.time().currentTime(),
|
||||||
bName );
|
bName,
|
||||||
|
surfNames,
|
||||||
|
fileNames );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::TSFtoVTK::triSurfaceToVTK(
|
bool pFlow::TSFtoVTK::triSurfaceToVTK(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const realx3 *points,
|
const realx3 *points,
|
||||||
const uint32x3 *vertices,
|
const uint32x3 *vertices,
|
||||||
const subSurface &subSurf)
|
const subSurface &subSurf)
|
||||||
|
@ -97,7 +106,7 @@ bool pFlow::TSFtoVTK::triSurfaceToVTK(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::TSFtoVTK::triSurfaceToVTK(
|
bool pFlow::TSFtoVTK::triSurfaceToVTK(
|
||||||
iOstream &os,
|
Ostream &os,
|
||||||
const realx3 *points,
|
const realx3 *points,
|
||||||
const uint32x3 *vertices,
|
const uint32x3 *vertices,
|
||||||
uint32 numPoints,
|
uint32 numPoints,
|
||||||
|
@ -143,10 +152,12 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFieldsSingle
|
||||||
multiTriSurface &surface,
|
multiTriSurface &surface,
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
real time,
|
real time,
|
||||||
const word &bName
|
const word &bName,
|
||||||
|
wordList& surfNames,
|
||||||
|
wordList& fileNames
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
vtkFile vtk(destPath, bName, time);
|
vtkFile vtk(destPath, bName, time, false);
|
||||||
|
|
||||||
if (!vtk)
|
if (!vtk)
|
||||||
return false;
|
return false;
|
||||||
|
@ -157,7 +168,7 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFieldsSingle
|
||||||
realx3 const* pData = hPoints.data();
|
realx3 const* pData = hPoints.data();
|
||||||
uint32x3 const* vData = hVertices.data();
|
uint32x3 const* vData = hVertices.data();
|
||||||
|
|
||||||
REPORT(1) << "Wrting triSurface geometry to vtk file "<<
|
REPORT(2) << "Wrting surface to "<<
|
||||||
Green_Text(vtk.fileName()) << END_REPORT;
|
Green_Text(vtk.fileName()) << END_REPORT;
|
||||||
|
|
||||||
if (! triSurfaceToVTK(
|
if (! triSurfaceToVTK(
|
||||||
|
@ -189,6 +200,9 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFieldsSingle
|
||||||
convertRealx3TypetriSurfaceField(vtk(), fieldHeader, surface);
|
convertRealx3TypetriSurfaceField(vtk(), fieldHeader, surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surfNames.push_back(bName);
|
||||||
|
fileNames.push_back(vtk.fileName().wordPath());
|
||||||
|
|
||||||
output<<endl;
|
output<<endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -198,7 +212,9 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFieldsSeparate(
|
||||||
multiTriSurface &surface,
|
multiTriSurface &surface,
|
||||||
const fileSystem &destPath,
|
const fileSystem &destPath,
|
||||||
real time,
|
real time,
|
||||||
const word &bName)
|
const word &bName,
|
||||||
|
wordList& surfNames,
|
||||||
|
wordList& fileNames)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto hPoints = surface.points().hostView();
|
auto hPoints = surface.points().hostView();
|
||||||
|
@ -210,17 +226,23 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFieldsSeparate(
|
||||||
REPORT(1) << "Wrting triSurface geometry to vtk file . . ."<<
|
REPORT(1) << "Wrting triSurface geometry to vtk file . . ."<<
|
||||||
END_REPORT;
|
END_REPORT;
|
||||||
|
|
||||||
|
wordList sNames, fNames;
|
||||||
|
|
||||||
auto nSurf = surface.numSurfaces();
|
auto nSurf = surface.numSurfaces();
|
||||||
for(auto nS=0; nS<nSurf; nS++)
|
for(auto nS=0; nS<nSurf; nS++)
|
||||||
{
|
{
|
||||||
auto sName = surface.subSurfaceName(nS);
|
auto sName = surface.subSurfaceName(nS);
|
||||||
vtkFile vtk(destPath, groupNames(bName,sName), time);
|
word fName = groupNames(bName,sName,'_');
|
||||||
|
vtkFile vtk(destPath, fName, time, false);
|
||||||
REPORT(2) << "Wrting sub-surface to "<<
|
REPORT(2) << "Wrting sub-surface to "<<
|
||||||
Green_Text(vtk.fileName())<<END_REPORT;
|
Green_Text(vtk.fileName())<<END_REPORT;
|
||||||
|
|
||||||
if (!vtk)
|
if (!vtk)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
fNames.push_back(vtk.fileName().wordPath());
|
||||||
|
sNames.push_back(fName);
|
||||||
|
|
||||||
if (! triSurfaceToVTK(
|
if (! triSurfaceToVTK(
|
||||||
vtk(),
|
vtk(),
|
||||||
pData,
|
pData,
|
||||||
|
@ -257,13 +279,15 @@ bool pFlow::TSFtoVTK::convertTimeFolderTriSurfaceFieldsSeparate(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileNames = fNames;
|
||||||
|
surfNames = sNames;
|
||||||
output<<endl;
|
output<<endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::TSFtoVTK::convertRealx3TypetriSurfaceField(
|
bool pFlow::TSFtoVTK::convertRealx3TypetriSurfaceField(
|
||||||
iOstream& os,
|
Ostream& os,
|
||||||
const IOfileHeader& header,
|
const IOfileHeader& header,
|
||||||
multiTriSurface& tSurface)
|
multiTriSurface& tSurface)
|
||||||
{
|
{
|
||||||
|
@ -325,7 +349,7 @@ bool pFlow::TSFtoVTK::convertRealx3TypetriSurfaceFieldSeparate
|
||||||
auto& subSurf = tSurface.subSurfaces()[nS];
|
auto& subSurf = tSurface.subSurfaces()[nS];
|
||||||
|
|
||||||
auto sName = subSurf.name();
|
auto sName = subSurf.name();
|
||||||
vtkFile vtk(destPath, groupNames(bName,sName), time, true);
|
vtkFile vtk(destPath, groupNames(bName,sName,'_'), time, false, true);
|
||||||
REPORT(2) << "Wrting sub-surface to "<<
|
REPORT(2) << "Wrting sub-surface to "<<
|
||||||
Green_Text(vtk.fileName())<<END_REPORT;
|
Green_Text(vtk.fileName())<<END_REPORT;
|
||||||
|
|
||||||
|
|
|
@ -37,15 +37,17 @@ bool convertTimeFolderTriSurfaceFields(
|
||||||
systemControl& control,
|
systemControl& control,
|
||||||
const fileSystem& destPath,
|
const fileSystem& destPath,
|
||||||
const word& bName,
|
const word& bName,
|
||||||
bool separate);
|
bool separate,
|
||||||
|
wordList& surfNames,
|
||||||
|
wordList& fileNames);
|
||||||
|
|
||||||
|
|
||||||
bool triSurfaceToVTK(iOstream &os,
|
bool triSurfaceToVTK(Ostream &os,
|
||||||
const realx3 *points,
|
const realx3 *points,
|
||||||
const uint32x3 *vertices,
|
const uint32x3 *vertices,
|
||||||
const subSurface &subSurf);
|
const subSurface &subSurf);
|
||||||
|
|
||||||
bool triSurfaceToVTK(iOstream &os,
|
bool triSurfaceToVTK(Ostream &os,
|
||||||
const realx3* points,
|
const realx3* points,
|
||||||
const uint32x3* vertices,
|
const uint32x3* vertices,
|
||||||
uint32 numPoints,
|
uint32 numPoints,
|
||||||
|
@ -55,13 +57,17 @@ bool convertTimeFolderTriSurfaceFieldsSingle(
|
||||||
multiTriSurface& surface,
|
multiTriSurface& surface,
|
||||||
const fileSystem& destPath,
|
const fileSystem& destPath,
|
||||||
real time,
|
real time,
|
||||||
const word& bName);
|
const word& bName,
|
||||||
|
wordList& surfNames,
|
||||||
|
wordList& fileNames);
|
||||||
|
|
||||||
bool convertTimeFolderTriSurfaceFieldsSeparate(
|
bool convertTimeFolderTriSurfaceFieldsSeparate(
|
||||||
multiTriSurface& surface,
|
multiTriSurface& surface,
|
||||||
const fileSystem& destPath,
|
const fileSystem& destPath,
|
||||||
real time,
|
real time,
|
||||||
const word& bName);
|
const word& bName,
|
||||||
|
wordList& surfNames,
|
||||||
|
wordList& fileNames);
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool regexCheck(const word& TYPENAME, const word& fieldType)
|
bool regexCheck(const word& TYPENAME, const word& fieldType)
|
||||||
|
@ -84,7 +90,7 @@ bool checkTriFieldType(word objectType)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool convertRealx3TypetriSurfaceField(
|
bool convertRealx3TypetriSurfaceField(
|
||||||
iOstream& os,
|
Ostream& os,
|
||||||
const IOfileHeader& header,
|
const IOfileHeader& header,
|
||||||
multiTriSurface& tSurface);
|
multiTriSurface& tSurface);
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ bool pFlow::postprocess::processTimeFolder(const timeFolder& tFolder)
|
||||||
|
|
||||||
bool pFlow::postprocess::writeToVTK(fileSystem destPath, word bName)const
|
bool pFlow::postprocess::writeToVTK(fileSystem destPath, word bName)const
|
||||||
{
|
{
|
||||||
vtkFile vtk(destPath, bName, time_);
|
vtkFile vtk(destPath, bName, time_, false);
|
||||||
|
|
||||||
if(!vtk) return false;
|
if(!vtk) return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue