From 1a46bcc4457269102a17afe032200614d7385e35 Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Thu, 11 Jan 2018 14:06:13 +0100 Subject: [PATCH] - remove basics vf code from gpu library --- .../basics/utilities/UbFileInputASCII.cpp | 7 + .../basics/utilities/UbFileInputASCII.h | 7 +- .../basics/utilities/UbFileOutputASCII.h | 4 +- .../basics/utilities/UbTuple.h | 1 + .../basics/writer/WbWriter.h | 6 +- .../basics/writer/WbWriterVtkXmlASCII.cpp | 2 +- .../basics/writer/WbWriterVtkXmlASCII.h | 6 +- .../basics/writer/WbWriterVtkXmlBinary.cpp | 3 +- .../basics/writer/WbWriterVtkXmlBinary.h | 6 +- src/VirtualFluids_GPU/GPU/devCheck.cpp | 2 +- .../Output/UnstructuredGridWriter.hpp | 9 +- .../basics/memory/MbChessMemPool2D.h | 519 ----- .../basics/memory/MbChessMemPool3D.h | 537 ------ .../basics/memory/MbMemPool.h | 87 - .../basics/memory/MbSharedPointerDefines.h | 39 - .../basics/memory/MbSmartPtr.h | 147 -- .../basics/memory/MbSmartPtrBase.cpp | 44 - .../basics/memory/MbSmartPtrBase.h | 50 - .../basics/memory/package.include | 0 .../basics/objects/ObCreator.h | 112 -- .../basics/objects/ObFactory.h | 174 -- .../basics/objects/ObObject.cpp | 10 - .../basics/objects/ObObject.h | 60 - .../basics/objects/ObObjectCreator.h | 58 - .../basics/objects/ObObjectFactory.cpp | 54 - .../basics/objects/ObObjectFactory.h | 42 - .../basics/objects/ObObjectManager.cpp | 216 --- .../basics/objects/ObObjectManager.h | 79 - .../basics/objects/package.include | 0 .../basics/utilities/UbAutoRun.hpp | 58 - .../basics/utilities/UbComparators.h | 208 -- .../basics/utilities/UbConverter.cpp | 96 - .../basics/utilities/UbConverter.h | 49 - .../basics/utilities/UbEqual.h | 120 -- .../basics/utilities/UbException.h | 156 -- .../basics/utilities/UbFileInput.h | 101 - .../basics/utilities/UbFileInputASCII.cpp | 274 --- .../basics/utilities/UbFileInputASCII.h | 79 - .../basics/utilities/UbFileInputBinary.cpp | 176 -- .../basics/utilities/UbFileInputBinary.h | 75 - .../basics/utilities/UbFileOutput.h | 98 - .../basics/utilities/UbFileOutputASCII.cpp | 189 -- .../basics/utilities/UbFileOutputASCII.h | 74 - .../basics/utilities/UbFileOutputBinary.cpp | 190 -- .../basics/utilities/UbFileOutputBinary.h | 72 - .../basics/utilities/UbInfinity.h | 180 -- .../basics/utilities/UbKeys.h | 294 --- .../basics/utilities/UbLimits.h | 141 -- .../basics/utilities/UbLogger.cpp | 8 - .../basics/utilities/UbLogger.h | 360 ---- .../basics/utilities/UbMath.cpp | 614 ------ .../basics/utilities/UbMath.h | 543 ------ .../basics/utilities/UbNupsTimer.h | 93 - .../basics/utilities/UbObservable.h | 259 --- .../basics/utilities/UbObserver.h | 55 - .../basics/utilities/UbPointerWrapper.h | 36 - .../basics/utilities/UbRandom.h | 60 - .../basics/utilities/UbScheduler.h | 411 ---- .../basics/utilities/UbStaticPathMap.cpp | 4 - .../basics/utilities/UbStaticPathMap.h | 80 - .../basics/utilities/UbStringInputASCII.cpp | 218 --- .../basics/utilities/UbStringInputASCII.h | 56 - .../basics/utilities/UbSystem.h | 510 ----- .../basics/utilities/UbTableModel.cpp | 20 - .../basics/utilities/UbTableModel.h | 37 - .../basics/utilities/UbTiming.h | 429 ----- .../basics/utilities/UbTuple.h | 1144 ----------- .../basics/utilities/email/composer.cpp | 90 - .../basics/utilities/email/composer.h | 38 - .../basics/utilities/email/main.cpp | 35 - .../basics/utilities/email/moc_composer.cpp | 113 -- .../basics/utilities/email/moc_smtp.cpp | 125 -- .../basics/utilities/email/smtp.cpp | 148 -- .../basics/utilities/email/smtp.h | 52 - .../basics/utilities/package.include | 0 .../basics/writer/WbWriter.h | 180 -- .../basics/writer/WbWriterAvsASCII.cpp | 642 ------- .../basics/writer/WbWriterAvsASCII.h | 80 - .../basics/writer/WbWriterAvsBinary.cpp | 975 ---------- .../basics/writer/WbWriterAvsBinary.h | 78 - .../basics/writer/WbWriterBOBJ.cpp | 79 - .../basics/writer/WbWriterBOBJ.h | 42 - .../basics/writer/WbWriterSunflow.cpp | 112 -- .../basics/writer/WbWriterSunflow.h | 38 - .../basics/writer/WbWriterTecPlotASCII.cpp | 68 - .../basics/writer/WbWriterTecPlotASCII.h | 95 - .../basics/writer/WbWriterVtkASCII.cpp | 602 ------ .../basics/writer/WbWriterVtkASCII.h | 86 - .../basics/writer/WbWriterVtkBinary.cpp | 747 -------- .../basics/writer/WbWriterVtkBinary.h | 86 - .../basics/writer/WbWriterVtkXmlASCII.cpp | 1105 ----------- .../basics/writer/WbWriterVtkXmlASCII.h | 100 - .../basics/writer/WbWriterVtkXmlBinary.cpp | 1686 ----------------- .../basics/writer/WbWriterVtkXmlBinary.h | 101 - .../basics/writer/WbWriterX3D.cpp | 152 -- .../basics/writer/WbWriterX3D.h | 43 - .../basics/writer/package.include | 0 .../libs/GridGenerator/3rdPartyLinking.cmake | 10 +- .../libs/VirtualFluids_GPU/CMakePackage.cmake | 4 +- 99 files changed, 44 insertions(+), 17516 deletions(-) delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbChessMemPool2D.h delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbChessMemPool3D.h delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbMemPool.h delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbSharedPointerDefines.h delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbSmartPtr.h delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.cpp delete mode 100644 src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.h delete mode 100644 src/VirtualFluids_GPU/basics/memory/package.include delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObCreator.h delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObFactory.h delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObject.cpp delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObject.h delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObjectCreator.h delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObjectFactory.cpp delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObjectFactory.h delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObjectManager.cpp delete mode 100644 src/VirtualFluids_GPU/basics/objects/ObObjectManager.h delete mode 100644 src/VirtualFluids_GPU/basics/objects/package.include delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbAutoRun.hpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbComparators.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbConverter.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbConverter.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbEqual.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbException.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileInput.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileOutput.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbInfinity.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbKeys.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbLimits.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbLogger.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbLogger.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbMath.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbMath.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbNupsTimer.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbObservable.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbObserver.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbPointerWrapper.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbRandom.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbScheduler.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbSystem.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbTableModel.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbTableModel.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbTiming.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/UbTuple.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/composer.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/composer.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/main.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/moc_composer.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/moc_smtp.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/smtp.cpp delete mode 100644 src/VirtualFluids_GPU/basics/utilities/email/smtp.h delete mode 100644 src/VirtualFluids_GPU/basics/utilities/package.include delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriter.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterX3D.cpp delete mode 100644 src/VirtualFluids_GPU/basics/writer/WbWriterX3D.h delete mode 100644 src/VirtualFluids_GPU/basics/writer/package.include diff --git a/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.cpp b/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.cpp index 9feeefbf7..84a6ff490 100644 --- a/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.cpp +++ b/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.cpp @@ -31,6 +31,13 @@ int UbFileInputASCII::readInteger() return dummy; } /*==========================================================*/ +long long UbFileInputASCII::readLongLong() +{ + long long dummy; + infile >> dummy; + return dummy; +} +/*==========================================================*/ string UbFileInputASCII::getFileName() { return this->filename; diff --git a/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.h b/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.h index 019418f80..075708e78 100644 --- a/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.h +++ b/src/VirtualFluidsBasics/basics/utilities/UbFileInputASCII.h @@ -11,6 +11,8 @@ #include <iostream> #include <string> +#include <VirtualFluidsDefinitions.h> + #include <basics/utilities/UbException.h> #include <basics/utilities/UbFileInput.h> @@ -28,7 +30,7 @@ usage: ... */ -class UbFileInputASCII : public UbFileInput +class VF_PUBLIC UbFileInputASCII : public UbFileInput { public: UbFileInputASCII() : UbFileInput() { } @@ -42,6 +44,8 @@ public: void readLine(); std::string readStringLine(); int readInteger(); // Liest einen Int-Wert ein + long long readLongLong(); // Liest einen long-Wert ein + std::size_t readSize_t(); double readDouble(); // Liest einen double-Wert ein float readFloat(); // Liest einen float-Wert ein @@ -51,6 +55,7 @@ public: std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen std::string parseString(); + bool containsString(const std::string& var); void setPosAfterLineWithString(const std::string& var); int readIntegerAfterString(const std::string& var); diff --git a/src/VirtualFluidsBasics/basics/utilities/UbFileOutputASCII.h b/src/VirtualFluidsBasics/basics/utilities/UbFileOutputASCII.h index 065abe922..707874192 100644 --- a/src/VirtualFluidsBasics/basics/utilities/UbFileOutputASCII.h +++ b/src/VirtualFluidsBasics/basics/utilities/UbFileOutputASCII.h @@ -11,6 +11,8 @@ #include <fstream> #include <iostream> +#include <VirtualFluidsDefinitions.h> + #include <basics/utilities/UbException.h> #include <basics/utilities/UbFileOutput.h> @@ -28,7 +30,7 @@ usage: ... */ -class UbFileOutputASCII : public UbFileOutput +class VF_PUBLIC UbFileOutputASCII : public UbFileOutput { public: UbFileOutputASCII() : UbFileOutput() {} diff --git a/src/VirtualFluidsBasics/basics/utilities/UbTuple.h b/src/VirtualFluidsBasics/basics/utilities/UbTuple.h index 311331747..710aed4df 100644 --- a/src/VirtualFluidsBasics/basics/utilities/UbTuple.h +++ b/src/VirtualFluidsBasics/basics/utilities/UbTuple.h @@ -591,6 +591,7 @@ typedef UbTuple<int,int,int,int> UbTupleInt4; typedef UbTuple<int,int,int,int,int> UbTupleInt5; typedef UbTuple<int,int,int,int,int,int> UbTupleInt6; typedef UbTuple<int,int,int,int,int,int,int,int> UbTupleInt8; +typedef UbTuple<unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned> UbTupleUInt8; typedef UbTuple<double,double> UbTupleDouble2; typedef UbTuple<double,double,double> UbTupleDouble3; typedef UbTuple<double,double,double,double> UbTupleDouble4; diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriter.h b/src/VirtualFluidsBasics/basics/writer/WbWriter.h index 844bffcac..0f3478155 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriter.h +++ b/src/VirtualFluidsBasics/basics/writer/WbWriter.h @@ -11,6 +11,8 @@ #include <3rdParty/rcf/RcfSerializationIncludes.h> #endif +#include <VirtualFluidsDefinitions.h> + #include <vector> #include <string> @@ -29,7 +31,7 @@ #include <boost/serialization/serialization.hpp> -class WbWriter +class VF_PUBLIC WbWriter { public: OBCREATOR_EXT(WbWriter) @@ -92,7 +94,7 @@ public: // 0 ---- 1 virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } virtual std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } + virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleUInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } private: friend class boost::serialization::access; diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.cpp b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.cpp index b861c473c..0dcc7db61 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.cpp +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.cpp @@ -806,7 +806,7 @@ std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,ve return vtkfilename; } /*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) +std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleUInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) { string vtkfilename=filename+getFileExtension(); UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start"); diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.h b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.h index 0ea2a82d6..0339011b4 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.h +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.h @@ -3,11 +3,13 @@ #include <string> +#include <VirtualFluidsDefinitions.h> + #include <basics/writer/WbWriter.h> #include <boost/serialization/base_object.hpp> -class WbWriterVtkXmlASCII : public WbWriter +class VF_PUBLIC WbWriterVtkXmlASCII : public WbWriter { public: OBCREATOR_EXT( WbWriterVtkXmlASCII ) @@ -85,7 +87,7 @@ public: // 0 ---- 1 std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); + std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleUInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); private: friend class boost::serialization::access; diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp index 80e1388d9..7db53a8f9 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp @@ -1193,7 +1193,8 @@ string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector return vtkfilename; } /*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) + +string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleUInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) { string vtkfilename = filename+getFileExtension(); UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.h b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.h index 79bec97b4..82db1c330 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.h +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.h @@ -3,11 +3,13 @@ #include <string> +#include <VirtualFluidsDefinitions.h> + #include <basics/writer/WbWriter.h> #include <boost/serialization/base_object.hpp> -class WbWriterVtkXmlBinary : public WbWriter +class VF_PUBLIC WbWriterVtkXmlBinary : public WbWriter { public: #ifndef SWIG @@ -88,7 +90,7 @@ public: // 0 ---- 1 std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); + std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleUInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); private: friend class boost::serialization::access; diff --git a/src/VirtualFluids_GPU/GPU/devCheck.cpp b/src/VirtualFluids_GPU/GPU/devCheck.cpp index 9b4853fef..bd3f510c4 100644 --- a/src/VirtualFluids_GPU/GPU/devCheck.cpp +++ b/src/VirtualFluids_GPU/GPU/devCheck.cpp @@ -23,7 +23,7 @@ int devCheck(int gpudevice) // cudaGetDeviceProperties() is also demonstrated in the deviceQuery/ example // of the sdk projects directory - cudaGetDeviceProperties(&deviceProp, gpudevice); + cudaGetDeviceProperties(&deviceProp, gpudevice); printf("[deviceProp.major.deviceProp.minor] = [%d.%d]\n", deviceProp.major, deviceProp.minor); diff --git a/src/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp b/src/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp index 967331b98..0b9434327 100644 --- a/src/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp +++ b/src/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp @@ -9,11 +9,10 @@ #include "LBM/LB.h" #include "LBM/D3Q27.h" #include "Parameter/Parameter.h" -#include "basics/utilities/UbSystem.h" -#include "Utilities/StringUtil.hpp" -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - +#include "VirtualFluidsBasics/basics/utilities/UbSystem.h" +#include <VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.h> +#include <VirtualFluidsBasics/basics/writer/WbWriterVtkXmlASCII.h> +#include <VirtualFluidsBasics/basics/utilities/UbTuple.h> using namespace std; diff --git a/src/VirtualFluids_GPU/basics/memory/MbChessMemPool2D.h b/src/VirtualFluids_GPU/basics/memory/MbChessMemPool2D.h deleted file mode 100644 index f05ec07ff..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbChessMemPool2D.h +++ /dev/null @@ -1,519 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBCHESSMEMPOOL2D_H -#define MBCHESSMEMPOOL2D_H - -#include <map> -#include <vector> -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <fstream> -#include <cmath> -#include <typeinfo> - -#include <basics/utilities/UbException.h> - - -template <class TData, std::size_t cachSize> -class MbChessMemPool2D; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMap2DKey -//key zum Auffinden der ChessMem2DBlocks -class MbChessMap2DKey -{ -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMap2DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0) - { - - } - /*==========================================================*/ - MbChessMap2DKey(std::size_t vectorPos, std::size_t firstCriteria, std::size_t secondCriteria) - : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria) - { - } - /*==========================================================*/ - MbChessMap2DKey& operator=(const MbChessMap2DKey& srcKey) - { - if(this == &srcKey ) return *this; - - mVectorPos = srcKey.mVectorPos; - mFirstCriteria = srcKey.mFirstCriteria; - mSecondCriteria = srcKey.mSecondCriteria; - - return *this; - } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey) - { - if(lhsKey.mFirstCriteria < rhsKey.mFirstCriteria ) return true; - if(lhsKey.mFirstCriteria > rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey) - { - if(lhsKey.mVectorPos != rhsKey.mVectorPos ) return false; - if(lhsKey.mFirstCriteria != rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false; - - return true; - } - //ueberladene Operatoren - friend inline bool operator!=(const MbChessMap2DKey& lhsKey,const MbChessMap2DKey& rhsKey) - { - return !(lhsKey==rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const MbChessMap2DKey& key) - { - os<<"VectorPos,first-,second-,third Criteria) ("; - os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<")"; - return os; - } - - ////////////////////////////////////////////////////////////////////////// - //public Methoden - std::size_t getVectorPos() {return mVectorPos;} -private: - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mVectorPos; - std::size_t mFirstCriteria; - std::size_t mSecondCriteria; -}; - - - -template<class T,std::size_t cachSize> -class MbChessMem2DBlock -{ - friend class MbChessMemPool2D<T,cachSize>; -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMem2DBlock() - { - mUsedElements = 0; - std::size_t arrayLength = mBlockWidth*mBlockWidth; - //mDataElements = new T[arrayLength]; - mDataElements = operator new(arrayLength*sizeof(T)); - mFlagVector = new bool[arrayLength]; - for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false; - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMem2DBlock() - { - //if(mDataElements) delete[] mDataElements; - if(mDataElements) operator delete(mDataElements); - if(mFlagVector) delete[] mFlagVector; - } - -private: - ////////////////////////////////////////////////////////////////////////// - //private Methoden - void* getReference(std::size_t chessX1, std::size_t chessX2) - { - std::size_t arrayIndex = chessX2*mBlockWidth + chessX1; - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth) throw UbException(UB_EXARGS,"index out of range"); - #endif - - if(mFlagVector[arrayIndex]==true) throw UbException(UB_EXARGS,"memory already allocated!"); - - mUsedElements++; - mFlagVector[arrayIndex]=true; - - return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]); - } - /*==========================================================*/ - std::size_t freeReference(void* p) - { - //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0] - std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements)); - - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth) throw UbException(UB_EXARGS,"index out of range"); - #endif - - if(mFlagVector[arrayIndex]==false) throw UbException(UB_EXARGS,"memory not allocated!"); - - mFlagVector[arrayIndex]=false; - - return --mUsedElements; - } - /*==========================================================*/ - std::size_t getNofUsedElements() { return mUsedElements; } - /*==========================================================*/ - void addPointerToTElementsToVector(std::vector<T*>& tdataVector) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth; - for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++) - { - //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]); - if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex); - } - } - /*==========================================================*/ - template<typename Pred> - void addPointerToTElementsToVector(std::vector<T*>& tdataVector, Pred& pred) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth; - T* tmp; - for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++) - { - if(mFlagVector[arrayIndex]) - { - //tmp = &mDataElements[arrayIndex]; - tmp = (static_cast<T*>(mDataElements))+arrayIndex; - if( pred(*tmp) ) tdataVector.push_back(tmp); - } - } - } -private: - ////////////////////////////////////////////////////////////////////////// - //static Member - static const std::size_t mBlockWidth; - - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mUsedElements; - //T* mDataElements; - void* mDataElements; - bool* mFlagVector; - -}; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMemPool2D -//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur -//die ChessMemBloecke haben hier eine Groesse von ~cachSize -template <class TData, std::size_t cachSize> -class MbChessMemPool2D -{ -private: - ////////////////////////////////////////////////////////////////////////// - //protected static const Member - static const std::size_t mCacheSize; - - ////////////////////////////////////////////////////////////////////////// - //protected Member - static std::vector< std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* > > mMapVector; - static std::map< void*, MbChessMap2DKey > mPointerKeyMap; - - ////////////////////////////////////////////////////////////////////////// - //protected Konstrukoren - MbChessMemPool2D() //protected, um max einmal vererbt werden zu koennen!!! - { //zudem kann man so keine elmente von TreeBasedMemPool erstellen - - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMemPool2D() - { - } - -public: - - ////////////////////////////////////////////////////////////////////////// - //static public Methoden - static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2) - { - if(!MbChessMem2DBlock< TData,cachSize >::mBlockWidth) - { - std::stringstream ss; - ss<<"TreeBasedMemPool() - InitialisationError\n"; - ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n"; - ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n"; - ss<<"\t cache-size has to be larger than data-size"; - throw UbException(ss.str()); - } - - if( mMapVector.size()<=level ) mMapVector.resize(level+1); - - std::size_t chessX1 = ix1/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - std::size_t chessX2 = ix2/(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - - MbChessMap2DKey mapKey(level,chessX1,chessX2); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey); - - MbChessMem2DBlock<TData,cachSize>* memBlock = NULL; - - if(pos==mMapVector[level].end()) - { - memBlock = new MbChessMem2DBlock<TData,cachSize>; - (mMapVector[level])[mapKey] = memBlock; - } - else memBlock = pos->second; - - std::size_t internalChessX1 = ix1%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - std::size_t internalChessX2 = ix2%(MbChessMem2DBlock<TData,cachSize>::mBlockWidth); - - void* p = memBlock->getReference(internalChessX1,internalChessX2); - - mPointerKeyMap[p]=mapKey; - - return p; - } - /*==========================================================*/ - static void freeReference(void *p) - { - typename std::map<void*,MbChessMap2DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p); - - if(posPointerKeyMap==mPointerKeyMap.end()) throw UbException(UB_EXARGS,"pointer not in map"); - - MbChessMap2DKey mapKey = posPointerKeyMap->second; - mPointerKeyMap.erase(posPointerKeyMap); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator posMemBlockMap; - posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey); - - if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end()) - throw UbException(UB_EXARGS,"mapKey not in ChessMem2DBlockMap"); - - std::size_t leftElements = posMemBlockMap->second->freeReference(p); - if(!leftElements) - { - MbChessMem2DBlock<TData,cachSize>* tmp = posMemBlockMap->second; - mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap); - delete tmp; - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - } - /*==========================================================*/ - template<typename Pred> - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - /*==========================================================*/ - template<typename Pred> - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks() - { - std::size_t nofElements = 0; - for(std::size_t i=0; i<mMapVector.size(); i++) - { - nofElements+=mMapVector[i].size(); - } - return nofElements; - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks(std::size_t level) - { - if(level<mMapVector.size() )return mMapVector[level].size(); - return 0; - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements() - { - return mPointerKeyMap.size(); - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements(std::size_t level) - { - if(level<mMapVector.size() ) - { - std::size_t nofElements = 0; - typename std::map< MbChessMap2DKey , MbChessMem2DBlock< TData,cachSize >* >::iterator pos; - - for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos) - { - nofElements += pos->second->getNofUsedElements(); - } - return nofElements; - } - return 0; - - } - /*==========================================================*/ - static std::string toString() - { - long double capaticityPerBlock = (std::size_t)pow((double)MbChessMem2DBlock<TData,cachSize>::mBlockWidth,2.0); - std::size_t storedElements = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements(); - std::size_t initialisedMemBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - - std::stringstream ss; - ss<<std::endl; - ss<<"****************** MbChessMemPool2D-Info (BEGIN) ******************"<<std::endl; - ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl; - ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl; - ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl; - ss<<"#elements per MbChessMem2DBlock [bytes]: "<<capaticityPerBlock<<std::endl; - ss<<"mem per MbChessMem2DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl; - ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl; - ss<<"\n"; - ss<<"#stored Elements = "<<storedElements<<std::endl; - ss<<"#ChessMem2DBlocks = "<<initialisedMemBlocks<<std::endl; - ss<<std::endl; - ss<<"level | #ChessMem2DBlocks | #stored Elements | used capaticity [%] \n"; - ss<<"----------------------------------------------------------------\n"; - for(std::size_t level=0;level<mMapVector.size();level++) - { - std::size_t nofStoredElements = MbChessMemPool2D<TData,cachSize>::getNumberOfStoredDataElements(level); - std::size_t nofChessMem2DBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(level); - - ss<<std::left<<" "<<std::setw(5)<<level<<"| " - <<std::setw(16)<<nofChessMem2DBlocks<<"| " - <<std::setw(17)<<nofStoredElements<<"| "; - if(nofStoredElements) - ss<<setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem2DBlocks)*100<<std::endl; - else ss<<"-"<<std::endl; - } - ss<<std::endl; - ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl; - ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl; - double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData)); - if(fabs(denominator)>1.E-13) ss<<"used.............. [%] : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl; - else ss<<"used.............. [%] : 0.0"<<std::endl; - ss<<"****************** MbChessMemPool2D-Info (END) *******************"<<std::endl; - return ss.str(); - } - /*==========================================================*/ - static void writeStatisticFiles(const std::string& filename) - { - //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level) - //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock - //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten - std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str()); - if(!spreadingFile) throw UbException(UB_EXARGS,"couldn't open file"); - - std::size_t initialisedMemBlocks = MbChessMemPool2D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - std::size_t maxNofDataElementsPerBlock = MbChessMem2DBlock<TData,cachSize>::mBlockWidth - * MbChessMem2DBlock<TData,cachSize>::mBlockWidth - * MbChessMem2DBlock<TData,cachSize>::mBlockWidth; - std::vector<std::size_t> spreading; - spreading.resize(maxNofDataElementsPerBlock+1,0); - std::vector< std::vector<std::size_t> > spreadingPerLevel; - spreadingPerLevel.resize(mMapVector.size()); - - typename std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t level=0; level<mMapVector.size(); level++ ) - { - spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0); - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - std::size_t number = pos->second->getNofUsedElements(); - spreading[number]++; - spreadingPerLevel[level][number]++; - } - } - spreadingFile<<"#BlockUsage nofBlocks(all Level) "; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<"nofBlockLevel"<<level<<" "; - spreadingFile<<std::endl; - - for(std::size_t i=0; i<spreading.size(); i++) - { - spreadingFile<<i<<" "<<spreading[i]; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<" "<<spreadingPerLevel[level][i]; - spreadingFile<<std::endl; - } - spreadingFile.flush(); - spreadingFile.close(); - } - ////////////////////////////////////////////////////////////////////////// - //ueberladene operatoren - void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2) - { - if(level<0) throw UbException(UB_EXARGS,"level ist negativ!"); - void *p = getReference(level,ix1,ix2); - return p; - } - /*==========================================================*/ - void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2) - { - //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!! - //throw UbException(UB_EXARGS,"Scheisse noch nicht gerafft, wie das geht!"); - std::cerr<<"MbChessMemPool2D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2) - Scheisse noch nicht gerafft, wie das geht!\n"; - } - - /*==========================================================*/ - void operator delete(void* p) - { - freeReference(p); - } - -private: - ////////////////////////////////////////////////////////////////////////// - //private statische Methoden -}; - -//statische Variablen initialisieren -template <class TData, std::size_t cachSize> -std::vector< std::map<MbChessMap2DKey,MbChessMem2DBlock<TData,cachSize>* > > MbChessMemPool2D<TData,cachSize>::mMapVector; - -template <class TData, std::size_t cachSize> -std::map<void*,MbChessMap2DKey > MbChessMemPool2D< TData, cachSize>::mPointerKeyMap; - -template <class TData, std::size_t cachSize> -const std::size_t MbChessMemPool2D<TData,cachSize>::mCacheSize=cachSize; - -template <class TData,std::size_t cachSize> -const std::size_t MbChessMem2DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.)); - -#endif diff --git a/src/VirtualFluids_GPU/basics/memory/MbChessMemPool3D.h b/src/VirtualFluids_GPU/basics/memory/MbChessMemPool3D.h deleted file mode 100644 index d7c693aec..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbChessMemPool3D.h +++ /dev/null @@ -1,537 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBCHESSMEMPOOL3D_H -#define MBCHESSMEMPOOL3D_H - -#include <map> -#include <vector> -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <fstream> -#include <cmath> - -#include <basics/utilities/UbException.h> - -template <class TData, std::size_t cachSize> -class MbChessMemPool3D; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMap3DKey -//key zum Auffinden der ChessMem3DBlocks -class MbChessMap3DKey -{ -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMap3DKey(): mVectorPos(0),mFirstCriteria(0),mSecondCriteria(0),mThirdCriteria(0) - { - } - /*==========================================================*/ - MbChessMap3DKey(std::size_t vectorPos,std::size_t firstCriteria,std::size_t secondCriteria,std::size_t thirdCriteria) - : mVectorPos(vectorPos), mFirstCriteria(firstCriteria), mSecondCriteria(secondCriteria), mThirdCriteria(thirdCriteria) - { - } - /*==========================================================*/ - MbChessMap3DKey& operator=(const MbChessMap3DKey& srcKey) - { - if(this == &srcKey ) return *this; - - mVectorPos = srcKey.mVectorPos; - mFirstCriteria = srcKey.mFirstCriteria; - mSecondCriteria = srcKey.mSecondCriteria; - mThirdCriteria = srcKey.mThirdCriteria; - - return *this; - } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey) - { - if(lhsKey.mFirstCriteria < rhsKey.mFirstCriteria ) return true; - if(lhsKey.mFirstCriteria > rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria < rhsKey.mSecondCriteria) return true; - if(lhsKey.mSecondCriteria > rhsKey.mSecondCriteria) return false; - if(lhsKey.mThirdCriteria < rhsKey.mThirdCriteria ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey) - { - if(lhsKey.mVectorPos != rhsKey.mVectorPos ) return false; - if(lhsKey.mFirstCriteria != rhsKey.mFirstCriteria ) return false; - if(lhsKey.mSecondCriteria != rhsKey.mSecondCriteria ) return false; - if(lhsKey.mThirdCriteria != rhsKey.mThirdCriteria ) return false; - - return true; - } - //ueberladene Operatoren - friend inline bool operator!=(const MbChessMap3DKey& lhsKey,const MbChessMap3DKey& rhsKey) - { - return !(lhsKey==rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const MbChessMap3DKey& key) - { - os<<"VectorPos,first-,second-,third Criteria) ("; - os<<key.mVectorPos<<","<<key.mFirstCriteria<<","<<key.mSecondCriteria<<","<<key.mThirdCriteria<<")"; - return os; - } - - ////////////////////////////////////////////////////////////////////////// - //public Methoden - std::size_t getVectorPos() {return mVectorPos;} -private: - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mVectorPos; - std::size_t mFirstCriteria; - std::size_t mSecondCriteria; - std::size_t mThirdCriteria; -}; - - - -template<class T,std::size_t cachSize> -class MbChessMem3DBlock -{ - friend class MbChessMemPool3D<T,cachSize>; -public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - MbChessMem3DBlock() - { - mUsedElements = 0; - std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth; - //mDataElements = new T[arrayLength]; - mDataElements = operator new(arrayLength*sizeof(T)); - if(!mDataElements) throw UbException(UB_EXARGS,"out of memeory!"); - mFlagVector = new bool[arrayLength]; - if(!mFlagVector) throw UbException(UB_EXARGS,"out of memeory!"); - for(std::size_t i=0;i<arrayLength;i++) mFlagVector[i] = false; - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMem3DBlock() - { - //if(mDataElements) delete[] mDataElements; - if(mDataElements) operator delete(mDataElements); - if(mFlagVector) delete[] mFlagVector; - } - -private: - ////////////////////////////////////////////////////////////////////////// - //private Methoden - void* getReference(std::size_t chessX1, std::size_t chessX2, std::size_t chessX3) - { - //std::size_t arrayIndex = (chessX1*mBlockWidth+chessX2)*mBlockWidth + chessX3; - std::size_t arrayIndex = (chessX3*mBlockWidth+chessX2)*mBlockWidth + chessX1; - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) throw UbException(UB_EXARGS,"index out of range"); - #endif - - if(mFlagVector[arrayIndex]==true) throw UbException(UB_EXARGS,"memory already allocated!"); - - mUsedElements++; - mFlagVector[arrayIndex]=true; - - return (void*)((T*)(mDataElements)+arrayIndex);//&(mDataElements[arrayIndex]); - } - /*==========================================================*/ - std::size_t freeReference(void* p) - { - //std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - mDataElements); //mDataElements = &mDataElements[0] - std::size_t arrayIndex = static_cast<std::size_t>(static_cast<T*>(p) - static_cast<T*>(mDataElements)); - - #ifdef _DEBUG - if(arrayIndex>=mBlockWidth*mBlockWidth*mBlockWidth) throw UbException(UB_EXARGS,"index out of range"); - #endif - - if(mFlagVector[arrayIndex]==false) throw UbException(UB_EXARGS,"memory not allocated!"); - - mFlagVector[arrayIndex]=false; - - return --mUsedElements; - } - /*==========================================================*/ - std::size_t getNofUsedElements() { return mUsedElements; } - /*==========================================================*/ - void addPointerToTElementsToVector(std::vector<T*>& tdataVector) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth; - for(std::size_t arrayIndex=0; arrayIndex<arrayLength; arrayIndex++) - { - //if(mFlagVector[arrayIndex]) tdataVector.push_back(&mDataElements[arrayIndex]); - if(mFlagVector[arrayIndex]) tdataVector.push_back(static_cast<T*>(mDataElements)+arrayIndex); - } - } - /*==========================================================*/ - template<typename Pred> - void addPointerToTElementsToVector(std::vector<T*>& tdataVector,Pred& pred ) - { - std::size_t arrayLength = mBlockWidth*mBlockWidth*mBlockWidth; - T* tmp; - for(std::size_t arrayIndex=0;arrayIndex<arrayLength;arrayIndex++) - { - if(mFlagVector[arrayIndex]) - { - //tmp = &mDataElements[arrayIndex]; - tmp = static_cast<T*>(mDataElements)+arrayIndex; - if( pred(*tmp) ) tdataVector.push_back(tmp); - } - } - } -private: - ////////////////////////////////////////////////////////////////////////// - //static Member - static const std::size_t mBlockWidth; - - ////////////////////////////////////////////////////////////////////////// - //private Member - std::size_t mUsedElements; - //T* mDataElements; - void* mDataElements; - bool* mFlagVector; - -}; - -////////////////////////////////////////////////////////////////////////// -//class MbChessMemPool3D -//zum Verwalten von TData Elementen in einer Schabrett-artigen Struktur -//die ChessMemBloecke haben hier eine Groesse von ~cachSize -template <class TData, std::size_t cachSize> -class MbChessMemPool3D -{ -private: - ////////////////////////////////////////////////////////////////////////// - //protected static const Member - static const std::size_t mCacheSize; - - ////////////////////////////////////////////////////////////////////////// - //protected Member - static std::vector< std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* > > mMapVector; - static std::map< void*, MbChessMap3DKey > mPointerKeyMap; - - ////////////////////////////////////////////////////////////////////////// - //protected Konstrukoren - MbChessMemPool3D() //private, da NUR static erlaubt!!! - { - - } - ////////////////////////////////////////////////////////////////////////// - //Destruktor - ~MbChessMemPool3D() - { - } - -public: - ////////////////////////////////////////////////////////////////////////// - //static public Methoden - static void* getReference(std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - { - if(!MbChessMem3DBlock< TData,cachSize >::mBlockWidth) - { - std::stringstream ss; - ss<<"TreeBasedMemPool() - InitialisationError\n"; - ss<<"\t size of StorageData ("<<typeid(TData).name()<<", "<<sizeof(TData)<<" byte)\n"; - ss<<"\t exceeds user-specifyed cache-zize ("<<mCacheSize<<" byte)\n"; - ss<<"\t cache-size has to be larger than data-size"; - throw UbException(UB_EXARGS,ss.str()); - } - - if( mMapVector.size()<=level ) mMapVector.resize(level+1); - - std::size_t chessX1 = ix1/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t chessX2 = ix2/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t chessX3 = ix3/(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - - MbChessMap3DKey mapKey(level,chessX1,chessX2,chessX3); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos = mMapVector[level].find(mapKey); - - MbChessMem3DBlock<TData,cachSize>* memBlock = NULL; - - if(pos==mMapVector[level].end()) - { - memBlock = new MbChessMem3DBlock<TData,cachSize>; - (mMapVector[level])[mapKey] = memBlock; - } - else memBlock = pos->second; - - std::size_t internalChessX1 = ix1%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t internalChessX2 = ix2%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - std::size_t internalChessX3 = ix3%(MbChessMem3DBlock<TData,cachSize>::mBlockWidth); - - void* p = memBlock->getReference(internalChessX1,internalChessX2,internalChessX3); - - mPointerKeyMap[p]=mapKey; - - return p; - } - static void freeReference(void *p) - { - typename std::map<void*,MbChessMap3DKey>::iterator posPointerKeyMap = mPointerKeyMap.find(p); - - if(posPointerKeyMap==mPointerKeyMap.end()) throw UbException(UB_EXARGS,"pointer not in map"); - - MbChessMap3DKey mapKey = posPointerKeyMap->second; - mPointerKeyMap.erase(posPointerKeyMap); - - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator posMemBlockMap; - posMemBlockMap = mMapVector[mapKey.getVectorPos()].find(mapKey); - - - if(posMemBlockMap == mMapVector[mapKey.getVectorPos()].end()) - throw UbException(UB_EXARGS,"mapKey not in ChessMem3DBlockMap"); - - std::size_t leftElements = posMemBlockMap->second->freeReference(p); - if(!leftElements) - { - MbChessMem3DBlock<TData,cachSize>* tmp = posMemBlockMap->second; - mMapVector[mapKey.getVectorPos()].erase(posMemBlockMap); - try{ delete tmp; } - catch(...){throw UbException(UB_EXARGS,"could not delete MbChessMem3DBlock");} - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - /*==========================================================*/ - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector) - { - tdataVector.clear(); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector); - } - } - } - /*==========================================================*/ - template<class Pred> - static void fillVectorWithPointerToTDataElements(std::size_t level,std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - if(level>=mMapVector.size()) return; - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - /*==========================================================*/ - template<typename Pred> - static void fillVectorWithPointerToTDataElements(std::vector<TData*>& tdataVector, Pred pred) - { - tdataVector.clear(); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t vecIndex=0; vecIndex<mMapVector.size(); vecIndex++ ) - { - for(pos=mMapVector[vecIndex].begin();pos!=mMapVector[vecIndex].end();++pos) - { - pos->second->addPointerToTElementsToVector(tdataVector,pred); - } - } - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks() - { - std::size_t nofElements = 0; - for(std::size_t i=0;i<mMapVector.size();i++) - { - nofElements+=mMapVector[i].size(); - } - return nofElements; - } - /*==========================================================*/ - static std::size_t getNumberOfChessMemoryBlocks(std::size_t level) - { - if(level<mMapVector.size() ) return mMapVector[level].size(); - return 0; - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements() - { - return mPointerKeyMap.size(); - } - /*==========================================================*/ - static std::size_t getNumberOfStoredDataElements(std::size_t level) - { - if(level<mMapVector.size() ) - { - std::size_t nofElements = 0; - typename std::map< MbChessMap3DKey , MbChessMem3DBlock< TData,cachSize >* >::iterator pos; - - for(pos=mMapVector[level].begin(); pos!=mMapVector[level].end(); ++pos) - { - nofElements+= pos->second->getNofUsedElements(); - } - return nofElements; - } - return 0; - } - /*==========================================================*/ - static std::string toString() - { - long double capaticityPerBlock = pow((double)MbChessMem3DBlock<TData,cachSize>::mBlockWidth,3.0); - std::size_t storedElements = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements(); - std::size_t initialisedMemBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - - std::stringstream ss; - ss<<std::endl; - ss<<"****************** MbChessMemPool3D-Info (BEGIN) ******************"<<std::endl; - ss<<"type of Storage-Data.................. : "<<typeid(TData).name()<<std::endl; - ss<<"size of Storage-Data........... [bytes]: "<<sizeof(TData)<<std::endl; - ss<<"specified cache-size........... [bytes]: "<<mCacheSize<<std::endl; - ss<<"#elements per MbChessMem3DBlock [bytes]: "<<capaticityPerBlock<<std::endl; - ss<<"mem per MbChessMem3DBlock...... [bytes]: "<<capaticityPerBlock*sizeof(TData)<<std::endl; - ss<<"used cache-size[%]............. [bytes]: "<<capaticityPerBlock*sizeof(TData)/(double)mCacheSize*100<<std::endl; - ss<<"\n"; - ss<<"#stored Elements = "<<storedElements<<std::endl; - ss<<"#ChessMem3DBlocks = "<<initialisedMemBlocks<<std::endl; - ss<<std::endl; - ss<<"level | #ChessMem3DBlocks | #stored Elements | used capaticity [%] \n"; - ss<<"----------------------------------------------------------------\n"; - for(std::size_t level=0;level<mMapVector.size();level++) - { - std::size_t nofStoredElements = MbChessMemPool3D<TData,cachSize>::getNumberOfStoredDataElements(level); - std::size_t nofChessMem3DBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(level); - - ss<<std::left<<" "<<std::setw(5)<<level<<"| " - <<std::setw(16)<<nofChessMem3DBlocks<<"| " - <<std::setw(17)<<nofStoredElements<<"| "; - if(nofStoredElements) - ss<<std::setw(15)<<nofStoredElements/(double)(capaticityPerBlock*nofChessMem3DBlocks)*100<<std::endl; - else ss<<"-"<<std::endl; - } - ss<<std::endl; - ss<<"called memory..... [bytes]: "<<storedElements*sizeof(TData)<<std::endl; - ss<<"initialised memory [bytes]: "<<initialisedMemBlocks*capaticityPerBlock*sizeof(TData)<<std::endl; - double denominator = (double)(initialisedMemBlocks*capaticityPerBlock*sizeof(TData)); - if(fabs(denominator)>1.E-13) ss<<"used.............. [%] : "<<100.*storedElements*sizeof(TData)/denominator<<std::endl; - else ss<<"used.............. [%] : 0.0"<<std::endl; - ss<<"****************** MbChessMemPool3D-Info (END) *******************"<<std::endl; - return ss.str(); - } - /*==========================================================*/ - static void writeStatisticFiles(const std::string& filename) - { - //liefert Statistik ueber aufuellung der einzelnen bloecke (gesamt und pro level) - //x-Achse: 0... max moegliche Anzahl von moeglichen Elementen pro MemBlock - //y-Achse: Anzahl an Bloecken, die die Anzahl an Elementen beinhalten - std::ofstream spreadingFile(((std::string)(filename+"_spreading.txt")).c_str()); - if(!spreadingFile) throw UbException(UB_EXARGS,"couldn't open file"); - - //std::size_t initialisedMemBlocks = MbChessMemPool3D<TData,cachSize>::getNumberOfChessMemoryBlocks(); - std::size_t maxNofDataElementsPerBlock = MbChessMem3DBlock<TData,cachSize>::mBlockWidth - *MbChessMem3DBlock<TData,cachSize>::mBlockWidth - *MbChessMem3DBlock<TData,cachSize>::mBlockWidth; - std::vector<std::size_t> spreading; - spreading.resize(maxNofDataElementsPerBlock+1,0); - std::vector< std::vector<std::size_t> > spreadingPerLevel; - spreadingPerLevel.resize(mMapVector.size()); - - typename std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* >::iterator pos; - - for(std::size_t level=0; level<mMapVector.size(); level++ ) - { - spreadingPerLevel[level].resize(maxNofDataElementsPerBlock+1,0); - for(pos=mMapVector[level].begin();pos!=mMapVector[level].end();++pos) - { - std::size_t number = pos->second->getNofUsedElements(); - spreading[number]++; - spreadingPerLevel[level][number]++; - } - } - spreadingFile<<"#BlockUsage nofBlocks(all Level) "; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<"nofBlockLevel"<<level<<" "; - spreadingFile<<std::endl; - - for(std::size_t i=0;i<spreading.size();i++) - { - spreadingFile<<i<<" "<<spreading[i]; - for(std::size_t level=0; level<mMapVector.size(); level++ ) - spreadingFile<<" "<<spreadingPerLevel[level][i]; - spreadingFile<<std::endl; - } - spreadingFile.flush(); - spreadingFile.close(); - } - - //////////////////////////////////////////////////////////////////////////// - ////ueberladene operatoren - //void* operator new(size_t size, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - //{ - // if(level<0) throw UbException(UB_EXARGS,"level ist negativ!"); - // void *p = getReference(level,ix1,ix2,ix3); - // return p; - //} - ///*==========================================================*/ - //void operator delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - //{ - // //ACHTUNG: wenn man hier ne Exception schmeisst, dann gibts einen BoeSEN compilerFehler!!! - // //throw UbException(__FILE__, __LINE__, "MbChessMemPool3D::delete - Scheisse noch nicht gerafft, wie das geht!"); - // cout<<"MbChessMemPool3D::delete(void* p, std::size_t level, std::size_t ix1, std::size_t ix2, std::size_t ix3) - Scheisse noch nicht gerafft, wie das geht!\n"; - //} - - ///*==========================================================*/ - //void operator delete(void* p) - //{ - // freeReference(p); - //} - -private: - ////////////////////////////////////////////////////////////////////////// - //private statische Methoden -}; - - -//statische Variablen initialisieren -template <class TData, std::size_t cachSize> -std::vector< std::map<MbChessMap3DKey,MbChessMem3DBlock<TData,cachSize>* > > MbChessMemPool3D<TData,cachSize>::mMapVector; - -template <class TData, std::size_t cachSize> -std::map<void*,MbChessMap3DKey > MbChessMemPool3D< TData, cachSize>::mPointerKeyMap; - -template <class TData, std::size_t cachSize> -const std::size_t MbChessMemPool3D<TData,cachSize>::mCacheSize=cachSize; - -//template <class TData, std::size_t cachSize> -//const std::size_t MbChessMemPool3D<TData,cachSize>::mNofElementsWidthMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.)); - -//template <class TData, std::size_t cachSize> -//const std::size_t MbChessMemPool3D<TData,cachSize>::mNofElementsInMemBlock=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.))),3.0)); - -template <class TData,std::size_t cachSize> -const std::size_t MbChessMem3DBlock<TData,cachSize>::mBlockWidth=static_cast<std::size_t>(std::pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1./3.)); - -//template <class TData,std::size_t cachSize> -//const std::size_t MbChessMem3DBlock<TData,cachSize>::mMaxElements=static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(pow(static_cast<double>(static_cast<std::size_t>(cachSize/sizeof(TData))),1.0/3.0))),3.0))),3.0)); - -#endif diff --git a/src/VirtualFluids_GPU/basics/memory/MbMemPool.h b/src/VirtualFluids_GPU/basics/memory/MbMemPool.h deleted file mode 100644 index e2482caa7..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbMemPool.h +++ /dev/null @@ -1,87 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBMEMPOOL_H -#define MBMEMPOOL_H - -#include <queue> -#include <list> - - -template <typename TData, int asize> -class MbMemPool -{ - -protected: - MbMemPool(){} - // Alle 3 Attribute sind Singleton-Objekte ! - // Allokiere Blocke der Groesse m_asize - static int m_asize; - // Halte alle freien Pointer (jedes einzelne Element) in eine FIFO Liste - static std::queue<void*> m_queue; - // Pointer auf Bloecke zum Loeschen ! - static std::list<TData*> m_list; - -public: - - - ~MbMemPool(){} - - // Daten-Bloecke Loeschen, damit wird der gesamte Speicher freigegeben, - // erst aufrufen, wenn die objekte nicht mehr gebraucht werden! - static void deallocatePool(); - - void* operator new(std::size_t size) - { - void* pNew; - TData* feld; - int i; - - //i=m_queue.size(); - //pNew = m_queue.front(); - if(m_queue.size()==0) - { - //Wenn kein freier Speicher mehr vorhanden, Block anlegen - feld = new TData[m_asize]; - m_list.push_back(feld); - for(i=0 ; i<m_asize ; i++) - { - pNew = (void*) &(feld[i]); - m_queue.push( pNew ); - } - } - pNew = m_queue.front(); - m_queue.pop(); - return pNew; - - } - - void operator delete(void* p) - { - m_queue.push(p); - } -}; - - -template <typename TData, int asize> -std::queue<void*> MbMemPool<TData,asize>::m_queue; - -template <typename TData, int asize> -std::list<TData*> MbMemPool<TData,asize>::m_list; - -template <typename TData, int asize> -int MbMemPool<TData,asize>::m_asize=asize; - -template <typename TData, int asize> -void MbMemPool<TData,asize>::deallocatePool() -{ - for(typename std::list<TData*>::iterator pos=m_list.begin() ; pos!=m_list.end(); ++pos) - { - delete[] pos; - } -} - -#endif //MBMEMPOOL_H diff --git a/src/VirtualFluids_GPU/basics/memory/MbSharedPointerDefines.h b/src/VirtualFluids_GPU/basics/memory/MbSharedPointerDefines.h deleted file mode 100644 index aa8e3767d..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbSharedPointerDefines.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef MBSHAREDPOINTERDEFINES_H -#define MBSHAREDPOINTERDEFINES_H - - -// Boost includes -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> - -#define VFSharedFromThis boost::enable_shared_from_this -#define VFSharedPtr boost::shared_ptr -#define VFWeakPtr boost::weak_ptr -#define VFDynamicPtrCast boost::dynamic_pointer_cast - -template<typename T> -class VFPtrDeleter -{ -public: - void operator()(T* p) { delete p; } -}; - - - -// std includes -#include <vector> - -//#ifdef WIN32 -//# include <memory> -//#else -//# include<tr1/memory> -//#endif - -//# define DCSharedFromThis std::tr1::enable_shared_from_this -//# define DCSharedPtr std::tr1::shared_ptr -//# define DCWeakPtr std::tr1::weak_ptr -//# define DCDynamicPtrCast std::tr1::dynamic_pointer_cast - -#endif diff --git a/src/VirtualFluids_GPU/basics/memory/MbSmartPtr.h b/src/VirtualFluids_GPU/basics/memory/MbSmartPtr.h deleted file mode 100644 index 8b751b20d..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbSmartPtr.h +++ /dev/null @@ -1,147 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBSMARTPTR_H -#define MBSMARTPTR_H - -#include <basics/memory/MbSmartPtrBase.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - -//===================================================== -// Globale Funktion, um das Loeschen des referenzierten -// Objektes flexibler zu gestalten. -// -template<class ObjType> -void deleteRefPtr(ObjType* ptr) -{ - delete ptr; -} - -//====================================================== -// Die Reference-Pointer Klasse: -// -// Beim Referenzieren eines Objektes ueber einen SmartPointer wird ein Zaehler fuer die referezierte Objekt- -// adresse inkrementiert. Wird der Pointer wieder einem anderen Objekt zugewiesen, so wird der Zaehler fuer das -// urspruenglich referenzierte Objekt wieder dekremtiert, ebenfalls beim Destruktor des Reference-Pointers. -// Tatsaechlich geloescht wird das referenzierte Objekt erst, wenn der zugehoerige Zaehler auf 0 ist. Dies geschieht -// ueber die globale Template-Funktion deleteRefPtr(), die bei Bedarf ueberschrieben werden kann. -// Der Reference-Pointer verfuegt also sozusagen ueber eine automatische Garbage Collection - -template<class ObjType> -class MbSmartPtr : public MbSmartPtrBase -{ -public: - // Konstruktoren //bei explicit geht der implizite cast nicht mehr, aber um keinen stress zu verursachen - /*explicit*/ MbSmartPtr<ObjType>(const ObjType* pPtr=NULL) - : MbSmartPtrBase(), mpPtr(NULL) - { - init(pPtr); - } - template<class ParamType> - MbSmartPtr<ObjType>(const MbSmartPtr<ParamType>& ptr) - : MbSmartPtrBase(), mpPtr(NULL) - { - init(ptr.get()); - } - // Destruktor - ~MbSmartPtr<ObjType>() - { - init(NULL); - } - //--------------------------------------------------- - // Kopierkonstruktor - MbSmartPtr<ObjType>(const MbSmartPtr<ObjType>& ptr) - : MbSmartPtrBase(), mpPtr(NULL) - { - init(ptr.get()); - } - //--------------------------------------------------- - // Zuweisungsoperatoren - template<class ParamType> - const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ParamType>& ptr) - { - init(ptr.get()); - return *this; - } - const MbSmartPtr<ObjType>& operator =(const MbSmartPtr<ObjType>& ptr) - { - init(ptr.get()); - return *this; - } - - const MbSmartPtr<ObjType>& operator =(const ObjType *pPtr) - { - init(pPtr); - return *this; - } - //--------------------------------------------------- - // Dereferenzierung-Operatoren - ObjType& operator *() const { return *mpPtr; } - ObjType* operator ->() const { return mpPtr; } - bool operator !() const { return !mpPtr; } - operator ObjType *() const { return mpPtr; } - //--------------------------------------------------- - // Methoden - ObjType* get() const - { - return mpPtr; - } - //--------------------------------------------------- - int ref_count() const - { - return MbSmartPtrBase::ref_count(mpPtr); - } - //--------------------------------------------------- - bool release() const - { - return MbSmartPtrBase::removeFromGC(mpPtr); - } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - if(ArchiveTools::isWriting(ar)) - { - ar & mpPtr; - } - else - { - ObjType* ptr; - ar & ptr; - - mpPtr=NULL; - init(ptr); - } - } -#endif //CAB_RCF - -private: - void init(const ObjType* pPtr) - { - // Nur was tun, wenn wirklich noetig - if(pPtr==mpPtr) return; - - // Aktuell referenziertes Objekt freigeben, dabei ueberpruefen, ob letztes Release - if(mpPtr && releaseRef(mpPtr)) - { - // referenziertes Objekt loeschen - deleteRefPtr(mpPtr); - } - - // Wenn pPtr ein neues Objekt ist, Zugriffszaehler auf neues Objekt erhoehen - mpPtr=const_cast<ObjType*>(pPtr); - if(mpPtr) addRef(mpPtr); - } - -private: - ObjType* mpPtr; -}; - -#endif //MBSMARTPTR_H diff --git a/src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.cpp b/src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.cpp deleted file mode 100644 index d0e07fa95..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include <basics/memory/MbSmartPtrBase.h> - -using namespace std; - -bool MbSmartPtrBase::addRef(void* ptr) -{ - MbSmartPtrBaseMap::getInstance()->getMap()[ptr]++; - return true; -} -//------------------------------------------------- -bool MbSmartPtrBase::releaseRef(void* ptr) -{ - map<void*,int>& ptrMap = MbSmartPtrBaseMap::getInstance()->getMap(); - map<void*,int>::iterator pos=ptrMap.find(ptr); - - if( pos!=ptrMap.end() ) - { - pos->second--; - - if(pos->second==0) - { - ptrMap.erase(pos); - return true; - } - } - return false; -} -//------------------------------------------------- -bool MbSmartPtrBase::removeFromGC(void* ptr) const -{ - if( MbSmartPtrBaseMap::getInstance()->getMap().erase(ptr) ) return true; - return false; -} -//------------------------------------------------- -int MbSmartPtrBase::ref_count(void* ptr) const -{ - map<void*,int>& ptrMap = MbSmartPtrBaseMap::getInstance()->getMap(); - map<void*,int>::iterator pos=ptrMap.find(ptr); - - if( pos!=ptrMap.end() ) return pos->second; - else return 0; -} - - diff --git a/src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.h b/src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.h deleted file mode 100644 index bd8af5909..000000000 --- a/src/VirtualFluids_GPU/basics/memory/MbSmartPtrBase.h +++ /dev/null @@ -1,50 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef MBSMARTPTRBASE_H -#define MBSMARTPTRBASE_H - -#include <iostream> -#include <map> - -//============================================================ -// Klasse MbSmartPtrBase -// -// Basisklasse, speziell fuer MbSmartPtr, die das eigentliche -// Reference-Counting uebernimmt. -// -class MbSmartPtrBase -{ - //Ursprung: - // mpCntrMap ist ein Pointer, weil sichergestellt sein muss, dass die - // Map existiert, wenn das erste mal darauf zugegriffen wird. - // Ein Zugriff zwischen zwei statischen Objekten kann zum Fehler fuehren, da - // die Reihenfolge der Konstruktorenaufrufe dann vom Linker bestimmt wird. - - //Anpassung a la UbWriter mit SingletonMap - class MbSmartPtrBaseMap - { - private: - MbSmartPtrBaseMap() { } - MbSmartPtrBaseMap( const MbSmartPtrBaseMap& ); //no copy allowed - const MbSmartPtrBaseMap& operator=( const MbSmartPtrBaseMap& ); //no copy allowed - - std::map<void*,int> mpCntrMap; - public: - static MbSmartPtrBaseMap* getInstance() { static MbSmartPtrBaseMap instance; return &instance; } - std::map<void*,int>& getMap() { return mpCntrMap; } - }; - -protected: - MbSmartPtrBase() {} - virtual ~MbSmartPtrBase() {} - bool addRef(void* p); - bool releaseRef(void* p); - bool removeFromGC(void* ptr) const; - int ref_count(void* ptr) const; -}; - -#endif //MBSMARTPTRBASE_H diff --git a/src/VirtualFluids_GPU/basics/memory/package.include b/src/VirtualFluids_GPU/basics/memory/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/VirtualFluids_GPU/basics/objects/ObCreator.h b/src/VirtualFluids_GPU/basics/objects/ObCreator.h deleted file mode 100644 index 8b9ef047c..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObCreator.h +++ /dev/null @@ -1,112 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBCREATOR_H -#define OBCREATOR_H - -#include <string> - -/*=========================================================================*/ -/* ObCreator / ObCreatorImpl */ -/* */ -/** -generic factory -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 14.06.07 -@version 1.1 - 12.04.08 -*/ - -/* -usage: see bottom of file "./ObFactory.h" -*/ - -////////////////////////////////////////////////////////////////////////// -// ObCreator -// Um in der Factory verschiedene Typen von Creaors in einer -// std::map<std::string,ObCreator<BaseT>*> halten zu koennen -// muss eine gemeinsame Basisklasse existieren -////////////////////////////////////////////////////////////////////////// -template< class BaseT > -class ObCreator -{ -public: - virtual std::string getObjectTypeID()=0; - virtual BaseT* createObject() = 0; - - virtual ~ObCreator() { } - -protected: - ObCreator() {} -private: - ObCreator( const ObCreator< BaseT >& ); //no copy allowed - const ObCreator& operator=( const ObCreator& ); //no copy allowed -}; - -////////////////////////////////////////////////////////////////////////// -// ObCreatorImpl -// Implementierung des speziellen Creators -////////////////////////////////////////////////////////////////////////// -template< class T, class BaseT=T > -class ObCreatorImpl : public ObCreator< BaseT > -{ -public: - static ObCreator<BaseT >* getInstance() - { - static ObCreatorImpl< T, BaseT > instance; - return &instance; - } - -public: - ~ObCreatorImpl() {} - - //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist - std::string getObjectTypeID() { return T::getStaticClassObjectTypeID(); } - - virtual T* createObject() { return new T(); } - -protected: - ObCreatorImpl() {} -private: - ObCreatorImpl( const ObCreatorImpl< T, BaseT >& ); //no copy allowed - const ObCreatorImpl& operator=( const ObCreatorImpl& ); //no copy allowed -}; - -////////////////////////////////////////////////////////////////////////// -// ObCreatorImpl -// Implementierung des speziellen Creators fuer Singletons -////////////////////////////////////////////////////////////////////////// -template< class T, class BaseT=T > -class ObSingletonCreatorImpl : public ObCreator< BaseT > -{ -public: - static ObCreator<BaseT >* getInstance() - { - static ObSingletonCreatorImpl< T, BaseT > instance; - return &instance; - } -public: - ~ObSingletonCreatorImpl() {} - - //aus portabilitaetsgruenden kann man nicht typeinfo nehmen, da diese compilerabhaengig ist - std::string getObjectTypeID() { return T::getStaticClassObjectTypeID(); } - - virtual T* createObject() { return T::getInstance(); } - -protected: - ObSingletonCreatorImpl() {} -private: - ObSingletonCreatorImpl( const ObSingletonCreatorImpl< T, BaseT >& ); //no copy allowed - const ObSingletonCreatorImpl& operator=( const ObSingletonCreatorImpl& ); //no copy allowed -}; - -//workaround for the not perfect C++ world. typeinfo::name is not usable for this purpose! -//see Andrei Alexandrescu, "Modern C++ Design: Generic Programming and Design Patterns Applied", Chapter 8.5 -#define OBCREATOR_EXT( ClassObject ) \ - static std::string getStaticClassObjectTypeID() { return #ClassObject; } \ - virtual std::string getClassObjectTypeID() { return getStaticClassObjectTypeID(); } - -#endif //OBCREATOR_H diff --git a/src/VirtualFluids_GPU/basics/objects/ObFactory.h b/src/VirtualFluids_GPU/basics/objects/ObFactory.h deleted file mode 100644 index a5868a245..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObFactory.h +++ /dev/null @@ -1,174 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBFACTORY_H -#define OBFACTORY_H - - -#include <string> -#include <map> -#include <sstream> -#include <iomanip> -#include <typeinfo> - -#include <basics/objects/ObCreator.h> - -/*=========================================================================*/ -/* ObFactory */ -/* */ -/** -generic factory -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 14.06.07 -@version 1.1 - 12.04.08 -*/ - -/* -usage: T = zu erzeugende Klasse - Creator = Erzeugerklasse -////////////////////////////////////////////////////////////////////////// -//example -////////////////////////////////////////////////////////////////////////// -// class Base{ -// public: -// OBCREATOR_EXT(Base) -// }; -// //automatisches registrieren: -// UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base,Base>::getInstance()), CAB_Base); -// class Derived : public Base -// { -// public: -// OBCREATOR_EXT(Derived) -//}; -// //automatisches registrieren: -// UB_AUTO_RUN_NAMED(ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Derived,Base>::getInstance()), CAB_Derived); -//////////////////////////////////////////////////////////////////////////// -// int main() -// { -// //Alternativ zu UB_AUTO_RUN_NAMED: haendisches registrieren -// ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Base>::getInstance()); -// ObFactory<Base>::getInstance()->addObCreator(ObCreatorImpl<Derived,Base>::getInstance()); -// -// //create objects - method1 -// Base* test1 = ObFactory<Base>::getInstance()->createObject<Base>(); -// Base* test2 = ObFactory<Base>::getInstance()->createObject<Derived>(); -// -// //create objects - method2 -// Base* test1 = ObFactory<Base>::getInstance()->createObject(Base::getStaticClassObjectTypeID() ); -// Base* test2 = ObFactory<Base>::getInstance()->createObject(Derived::getStaticClassObjectTypeID() ); -// //... -// } -*/ - - -template<class T, typename Creator = ObCreator< T > > -class ObFactory -{ - typedef std::map< std::string, Creator* > CreatorMap; - typedef typename CreatorMap::iterator CreatorMapIt; - typedef std::pair< std::string, Creator* > CreatorMapElement; - -protected: - ObFactory() {} //so ist vererbung gewahrleistet - -private: - ObFactory( const ObFactory< T, Creator >& ); //no copy allowed - const ObFactory& operator=( const ObFactory& ); //no copy allowed - - -public: - virtual ~ObFactory() {} - - static ObFactory< T, Creator >* getInstance() - { - static ObFactory< T, Creator > instance; - return &instance; - } - - bool addObCreator(Creator* creator); - bool removeObCreator(Creator* creator); - - T* createObject(const std::string& objectTypeID); - - template< typename T2 > - T* createObject() { return this->createObject( T2::getStaticClassObjectTypeID() ); } - - Creator* getCreator(const std::string& objectTypeID); - - virtual std::string toString(); - -private: - CreatorMap creatorMap; -}; - -////////////////////////////////////////////////////////////////////////// -//Implementation -template<class T, typename Creator > -bool ObFactory< T, Creator >::addObCreator(Creator* creator) -{ - if(creatorMap.insert( CreatorMapElement(creator->getObjectTypeID(), creator) ).second ) - { - //insert succeeded - return true; - } - //insert fails - return false; -} -/*======================================================================*/ -template<class T, typename Creator > -bool ObFactory< T, Creator >::removeObCreator(Creator* creator) -{ - if(creator && creatorMap->erase( creator->getClassObjectTypeID() ) ) - return true; - - return false; -} -/*======================================================================*/ -template<class T, typename Creator > -Creator* ObFactory< T, Creator >::getCreator(const std::string& obtypeID) -{ - CreatorMapIt it = creatorMap.find(obtypeID); - if(it == creatorMap.end()) return NULL; - - Creator* creator = it->second; - if(!creator) return NULL; - - return creator; -} -/*======================================================================*/ - template<class T, typename Creator > - T* ObFactory< T, Creator >::createObject(const std::string& objectTypeID) - { - Creator* creator = this->getCreator(objectTypeID); - - if(!creator) - { - throw UbException(UB_EXARGS,"no creator avaivlable for ID="+objectTypeID ); - } - - return creator->createObject(); - } -/*======================================================================*/ -template<class T, typename Creator > -std::string ObFactory< T, Creator >::toString() -{ - std::size_t maxL = 6; - for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it) - if( it->first.size() > maxL ) - maxL = it->first.size(); - - std::stringstream os; - os<<(std::string)typeid(*this).name()<<" - info:"<<std::endl; - os<<" "<<std::left<<std::setw(maxL)<<"object"<<" <-> "<<"creator "<<std::endl; - for(CreatorMapIt it=creatorMap.begin(); it!=creatorMap.end(); ++it) - os<< " - " << std::setw(maxL) << it->first << " <-> " << (std::string)typeid(*it->second).name() << std::endl; - - return os.str(); -} -/*======================================================================*/ - -#endif //OBFACTORY_H diff --git a/src/VirtualFluids_GPU/basics/objects/ObObject.cpp b/src/VirtualFluids_GPU/basics/objects/ObObject.cpp deleted file mode 100644 index e7774e916..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObject.cpp +++ /dev/null @@ -1,10 +0,0 @@ -//#include <basics/objects/ObObject.h> - -// ObObject::ObObject() -// { -// } -// /*=======================================*/ -// std::string ObObject::getName() -// { -// return name; -// } diff --git a/src/VirtualFluids_GPU/basics/objects/ObObject.h b/src/VirtualFluids_GPU/basics/objects/ObObject.h deleted file mode 100644 index fb2f3fce5..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObject.h +++ /dev/null @@ -1,60 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECT_H -#define OBOBJECT_H - -#include <string> - -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbObservable.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - - -class ObObjectCreator; - -class ObObject : public UbObservable -{ -public: - ObObject() : name("") { } - ObObject(const std::string& name) : name(name) { } - - virtual ~ObObject() { } - - virtual ObObject* clone()=0; - virtual std::string getTypeID()=0; - - virtual std::string getName() { return name; } - void setName(std::string name) { this->name=name; } - - virtual std::string toString()=0; - - virtual ObObjectCreator* getCreator()=0; - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - //SF::SF_SERIALIZE_PARENT<UbObservable>(ar, *this); - SF_SERIALIZE_PARENT<UbObservable>(ar, *this); - ar & name; - } -#endif //CAB_RCF - -private: - std::string name; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - SF_NO_CTOR(ObObject); - UB_AUTO_RUN_NAMED( ( SF::registerType<ObObject>("ObObject") ), SF_ObObject ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<UbObservable, ObObject >() ), SF_ObObject_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/src/VirtualFluids_GPU/basics/objects/ObObjectCreator.h b/src/VirtualFluids_GPU/basics/objects/ObObjectCreator.h deleted file mode 100644 index 3224466dc..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObjectCreator.h +++ /dev/null @@ -1,58 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECTCREATOR_H -#define OBOBJECTCREATOR_H - -#include <string> - -class ObObject; -class ObObjectManager; - -class Presentator; -class QViewer; - -#ifdef CAB_QT -class QObObjectSpecificInstrument; -class QWidget; -class QActionGroup; -#endif - -class ObObjectCreator -{ -public: - virtual ~ObObjectCreator() {} - - virtual ObObject* createObObject()=0; - - virtual std::string getTypeID() { return "ObObject"; } - virtual std::string toString() { return "ObObjectCreator"; } - -#ifdef CAB_QT - //virtual Presentator* createObjectPresentator(ObObject *object)=0; - virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; } - virtual QActionGroup* getSpecificPresentatorGroup(ObObject* object, QViewer *viewer, QWidget* parent) { return NULL; } - virtual QActionGroup* getSpecificActionGroup(ObObjectManager* manager, ObObject* object, QWidget* parent) - { - return NULL; - } - - virtual ObObject* createObObjectWithQt() { return NULL; } - virtual void showSpecificInstrument(ObObject* object, QWidget* parent=0) {} - virtual QObObjectSpecificInstrument* getSpecificInstrument() { return NULL; } - - //virtual QActionGroup *getSpecificContextMenuActionGroup() { return NULL; } -#endif - -protected: - ObObjectCreator() {} - -private: - ObObjectCreator( const ObObjectCreator& ); //no copy allowed - const ObObjectCreator& operator=( const ObObjectCreator& ); //no copy allowed - -}; -#endif diff --git a/src/VirtualFluids_GPU/basics/objects/ObObjectFactory.cpp b/src/VirtualFluids_GPU/basics/objects/ObObjectFactory.cpp deleted file mode 100644 index b208db20e..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObjectFactory.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include <basics/objects/ObObjectFactory.h> - -/**** Eigene ****/ -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbException.h> - -using namespace std; - -//ObObjectFactory::ObObjectFactory() -//{ -//} -// -//ObObjectFactory::~ObObjectFactory() -//{ -//} -/*======================================================================*/ -//ObObjectFactory* ObObjectFactory::getInstance() -//{ -// static ObObjectFactory instance; -// return &instance; -//} -/*======================================================================*/ -void ObObjectFactory::addObObjectCreator(ObObjectCreator *creator) -{ - //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getTypeID()<<endl; - creatorSet.insert(std::pair<string, ObObjectCreator*>(creator->getTypeID(), creator)); -} -/*======================================================================*/ -void ObObjectFactory::removeObObjectCreator(ObObjectCreator *creator) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -ObObjectCreator* ObObjectFactory::getCreator(string objectType) -{ - std::map<string, ObObjectCreator*>::iterator creatorIterator = creatorSet.find(objectType); - if(creatorIterator == creatorSet.end()) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - ObObjectCreator *creator = creatorIterator->second; - if(!creator) throw UbException(UB_EXARGS,"no time series creator for type available"); - return creator; -} -/*======================================================================*/ -string ObObjectFactory::toString() -{ - stringstream text; - - std::map<string, ObObjectCreator*>::iterator creatorIterator; - std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet(); - - for(creatorIterator = creatorSet->begin(); creatorIterator!=creatorSet->end(); ++creatorIterator) - text<<" - "<<(creatorIterator->second)->toString()<<" for "<<(creatorIterator->first)<<endl; - - return text.str(); -} diff --git a/src/VirtualFluids_GPU/basics/objects/ObObjectFactory.h b/src/VirtualFluids_GPU/basics/objects/ObObjectFactory.h deleted file mode 100644 index 2af7458cd..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObjectFactory.h +++ /dev/null @@ -1,42 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECTFACTORY_H -#define OBOBJECTFACTORY_H - -#include <string> -#include <map> - -class ObObjectCreator; - -class ObObjectFactory -{ -public: - ObObjectFactory() {} - virtual ~ObObjectFactory() {} - - //static geht nicht, da abgeleitete Factories existieren ... - //static ObObjectFactory* getInstance(); - //virtual ObObjectFactory* getInstance()=0; - - ObObjectCreator* getCreator(std::string objectType); - - void addObObjectCreator(ObObjectCreator* creator); - void removeObObjectCreator(ObObjectCreator* creator); - - std::map<std::string, ObObjectCreator*>* getCreatorSet() { return &creatorSet; } - - virtual std::string toString(); - -private: - ObObjectFactory( const ObObjectFactory& ); //no copy allowed - const ObObjectFactory& operator=( const ObObjectFactory& ); //no copy allowed - - std::map<std::string, ObObjectCreator*> creatorSet; -}; - - -#endif //OBOBJECTFACTORY_H diff --git a/src/VirtualFluids_GPU/basics/objects/ObObjectManager.cpp b/src/VirtualFluids_GPU/basics/objects/ObObjectManager.cpp deleted file mode 100644 index e156e6f6c..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObjectManager.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include <basics/objects/ObObjectManager.h> -#include <basics/objects/ObObject.h> -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbTableModel.h> -#include <basics/utilities/UbException.h> - -using namespace std; - -ObObjectEntry::ObObjectEntry(ObObjectManager *parent, ObObject *object) -{ - this->parent = parent; - this->object = object; -} -/*======================================================*/ -ObObjectManager::ObObjectManager() -{ - this->selectedObject = NULL; - this->tableModel = NULL; -} - -/*======================================================*/ -ObObjectManager::~ObObjectManager() -{ - //cerr<<"NEIN, notifyObserversObjectWillBeDeleted wird AUSSCHLIESSLICH von BasisKlasse aufgerufen!!!"<<endl; - // cerr<<"das muss so sein, denn ansonsten duerfte diese funktion nur in der speziellen klasse stehen, da\n"; - // cerr<<"virtuelle destruktoren sich rekursiv vom speziellen ins allg. aufrufen --> notify.. wuerde\n"; - // cerr<<"oefters aufgerufen werden...\n"; - - this->objectList.clear(); - if(this->tableModel) delete this->tableModel; -} -/*======================================================*/ -UbTableModel* ObObjectManager::getTableModel() -{ - return tableModel; -} -/*======================================================*/ -//bool ObObjectManager::addObObject(ObObject *object) -//{ -// cout<<"ObObjectManager::addObObject "<<object->toString()<<endl; -// for(int pos=0; pos<(int)this->objectList.size(); pos++) -// if(this->objectList[pos]->object==object) -// return false; -// -// this->objectList.push_back(new ObObjectEntry(this,object)); -// //object->addObserver(this); -// this->selectObObject(object); -// return true; -//} -/*======================================================*/ -bool ObObjectManager::addObObjectEntry(ObObjectEntry* objectEntry) -{ - for(int pos=0; pos<(int)this->objectList.size(); pos++) - if(this->objectList[pos]->object==objectEntry->object) - return false; - - this->objectList.push_back(objectEntry); -// objectEntry->getObject()->addObserver(this); - this->selectObObject(objectEntry->object); - return true; -} -/*======================================================*/ -bool ObObjectManager::removeObObject(ObObject* object) -{ - if (this->selectedObject == object) this->selectedObject=NULL; - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - - if(this->objectList[pos]->object==object) - { - return this->removeObObject(pos); -// this->objectList.erase(objectList.begin()+pos); -// //this->removeObserver(this); -// return true; - } - } - return false; -} -/*======================================================*/ -bool ObObjectManager::removeObObject(int index) -{ - try - { - if ( objectList[index]->object == this->selectedObject ) this->selectedObject=NULL; - //den entry loeschen ... das object im Entry ??? erstmal ausserhalb ... - delete objectList[index]; - objectList.erase(objectList.begin()+index); - this->notifyObserversObjectChanged(); - return true; - } - catch(const std::exception& e) { cerr<<e.what()<<endl; } - catch(...) { cerr<<"Fehler in ObObjectManager::removeObObject"<<endl; } - return false; -} -/*======================================================*/ -void ObObjectManager::removeAllObObjects() -{ - //TODO: implementieren!! - //foreach grid: - //grid->removeObserver(this); - //vector<ObObject*>::iterator it; - //for(it=objectList.begin(); it!=objectList.end(); it++) - //{ - // it->removeObserver(this); - //} -// for(int i=0; i<(int)objectList.size(); i++) -// { -// delete objectList[i]->object->removeObserver(this); -// } - this->objectList.clear(); - this->selectedObject = NULL; - this->notifyObserversObjectChanged(); -} -/*======================================================*/ -int ObObjectManager::getNumberOfObObjects() -{ - return (int)this->objectList.size(); -} -/*======================================================*/ -vector<ObObject*>* ObObjectManager::getAllObObjects() -{ - throw UbException(UB_EXARGS,"hier muss noch was getan werden"); -// return this->objectList; -} -vector<ObObjectEntry*>* ObObjectManager::getAllObObjectEntries() -{ - return &this->objectList; -} -/*======================================================*/ -ObObject* ObObjectManager::getObObject(int index) -{ - if(index < 0) return NULL; - if(index >= (int)this->objectList.size()) return NULL; - - return(this->objectList[index]->object); -} -/*======================================================*/ -ObObjectEntry* ObObjectManager::getObObjectEntry(int index) -{ - if(index < 0) return NULL; - if(index >= (int)this->objectList.size()) return NULL; - - return(this->objectList[index]); -} -/*====================================================*/ -string ObObjectManager::toString() -{ - stringstream ss; ss<<endl; - - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - ObObject* object = this->objectList[pos]->object; - ss<<(pos+1)<<". "<<object->toString()<<endl; - } - return ss.str(); -} -/*======================================================*/ -void ObObjectManager::objectChanged(UbObservable* observable) -{ - //cout<<"ObObjectManager::objectChanged ??"; - this->notifyObserversObjectChanged(); -} -/*======================================================*/ -void ObObjectManager::objectWillBeDeleted(UbObservable* observable) -{ - cout<<"ObObjectManager::objectWillBeDeleted ??"; - //observable->removeObserver(this); -} -/*======================================================*/ -bool ObObjectManager::selectObObject(int index) -{ - if((int)this->objectList.size()==0) - { - this->selectedObject = NULL; return false; - } - if (index > (int)this->objectList.size()-1 || index < 0) return false; - if ( this->selectedObject == this->getObObject(index) ) return true; - - this->selectedObject = this->getObObject(index); - //cout<<this->getObserverList()->size()<<endl; - - this->notifyObserversObjectChanged(); - return true; -} -/*======================================================*/ -bool ObObjectManager::selectObObject(ObObject* object) -{ - if((int)this->objectList.size()==0) { this->selectedObject = NULL; return false; } - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - if(this->objectList[pos]->object==object) - { - return this->selectObObject(pos); - } - } - return false; -} -/*======================================================*/ -ObObject* ObObjectManager::getSelectedObObject() -{ - return this->selectedObject; -} -/*======================================================*/ -int ObObjectManager::getSelectedIndex() -{ - for(int pos=0; pos<(int)this->objectList.size(); pos++) - { - if(this->objectList[pos]->object==this->selectedObject) - { - return pos; - } - } - return -1; -} -/*======================================================*/ - diff --git a/src/VirtualFluids_GPU/basics/objects/ObObjectManager.h b/src/VirtualFluids_GPU/basics/objects/ObObjectManager.h deleted file mode 100644 index 9d5b42df9..000000000 --- a/src/VirtualFluids_GPU/basics/objects/ObObjectManager.h +++ /dev/null @@ -1,79 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef OBOBJECTMANAGER_H -#define OBOBJECTMANAGER_H - -#include <string> -#include <sstream> -#include <vector> - -#include <basics/utilities/UbObservable.h> -#include <basics/utilities/UbObserver.h> - -class UbException; -class UbTableModel; -class ObObjectManager; -class ObObjectFactory; -class ObObject; - - -class ObObjectEntry -{ - friend class ObObjectManager; -public: - ObObjectManager* getParent() { return parent; } - ObObject* getObject() { return object; } - - ObObjectEntry(ObObjectManager* parent, ObObject* object); - virtual ~ObObjectEntry() { } - -protected: - ObObjectManager* parent; - ObObject* object; -}; - - -class ObObjectManager : public UbObservable, public UbObserver -{ -public: - ObObjectManager(); - ~ObObjectManager(); - - //virtual bool addObObject(ObObject* object); - virtual bool addObObjectEntry(ObObjectEntry* objectEntry); - - virtual ObObjectEntry* createNewObObjectEntry(ObObject* obj) { return new ObObjectEntry(this, obj); } - - bool removeObObject(ObObject* object); - bool removeObObject(int index); - void removeAllObObjects(); - bool selectObObject(int index); - bool selectObObject(ObObject* object); - ObObject* getSelectedObObject(); - int getSelectedIndex(); - - int getNumberOfObObjects(); - std::vector<ObObject*>* getAllObObjects(); - std::vector<ObObjectEntry*>* getAllObObjectEntries(); - ObObject* getObObject(int index); - ObObjectEntry* getObObjectEntry(int index); - - std::string toString(); - - virtual void objectChanged(UbObservable* observable); - virtual void objectWillBeDeleted(UbObservable* observable); - - UbTableModel* getTableModel(); - virtual ObObjectFactory* getObObjectFactory()=0; - -protected: - std::vector<ObObjectEntry*> objectList; - ObObject* selectedObject; - UbTableModel* tableModel; -}; - -#endif //OBOBJECTMANAGER_H diff --git a/src/VirtualFluids_GPU/basics/objects/package.include b/src/VirtualFluids_GPU/basics/objects/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/VirtualFluids_GPU/basics/utilities/UbAutoRun.hpp b/src/VirtualFluids_GPU/basics/utilities/UbAutoRun.hpp deleted file mode 100644 index 50fcf37b6..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbAutoRun.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef UB_AUTORUN_HPP -#define UB_AUTORUN_HPP - -#define UB_AUTO_RUN(func) UB_AUTO_RUN_(func, __LINE__) -#define UB_AUTO_RUN_(func, nID) UB_AUTO_RUN__(func, nID) -#define UB_AUTO_RUN__(func, nID) UB_AUTO_RUN___(func, nID) -#define UB_AUTO_RUN___(func, ID) \ - namespace { \ - struct UbAutoRun##ID { \ - UbAutoRun##ID() { \ - func; \ - } \ - } UbAutoRunInst##ID; \ - } - - // More concise to implement UB_AUTO_RUN using the following, but BCB emits an ICE on it. - //static bool UB_AutoRun##ID = ( func , false); - - -#define UB_AUTO_RUN_1(func) UB_AUTO_RUN_NAMED(func, 1) -#define UB_AUTO_RUN_2(func) UB_AUTO_RUN_NAMED(func, 2) -#define UB_AUTO_RUN_3(func) UB_AUTO_RUN_NAMED(func, 3) -#define UB_AUTO_RUN_4(func) UB_AUTO_RUN_NAMED(func, 4) -#define UB_AUTO_RUN_5(func) UB_AUTO_RUN_NAMED(func, 5) - -#define UB_AUTO_RUN_NAMED(func, name) UB_AUTO_RUN_NAMED_(func, name, __LINE__) -#define UB_AUTO_RUN_NAMED_(func, name, nID) UB_AUTO_RUN_NAMED__(func, name, nID) -#define UB_AUTO_RUN_NAMED__(func, name, nID) UB_AUTO_RUN___(func, _##name##_##nID) - -#define UB_AUTO_RUN_ONCE(func) UB_AUTO_RUN_ONCE_(func, __LINE__) -#define UB_AUTO_RUN_ONCE_(func, nID) UB_AUTO_RUN_ONCE__(func, nID) -#define UB_AUTO_RUN_ONCE__(func, nID) UB_AUTO_RUN_ONCE___(func, nID) -#define UB_AUTO_RUN_ONCE___(func, ID) \ - struct UbAutoRunOnce##ID { \ - UbAutoRunOnce##ID() { \ - if (!init()) { \ - init() = true; \ - func; \ - } \ - } \ - static bool &init() { \ - static bool bInit = false; \ - return bInit; \ - } \ - }; \ - static UbAutoRunOnce##ID AutoRunOnceInst##ID; - -#define UB_AUTO_RUN_ONCE_1(func) UB_AUTO_RUN_ONCE_NAMED(func, 1) -#define UB_AUTO_RUN_ONCE_2(func) UB_AUTO_RUN_ONCE_NAMED(func, 2) -#define UB_AUTO_RUN_ONCE_3(func) UB_AUTO_RUN_ONCE_NAMED(func, 3) -#define UB_AUTO_RUN_ONCE_4(func) UB_AUTO_RUN_ONCE_NAMED(func, 4) -#define UB_AUTO_RUN_ONCE_5(func) UB_AUTO_RUN_ONCE_NAMED(func, 5) - -#define UB_AUTO_RUN_ONCE_NAMED(func, name) UB_AUTO_RUN_ONCE_NAMED_(func, name, __LINE__) -#define UB_AUTO_RUN_ONCE_NAMED_(func, name, nID) UB_AUTO_RUN_ONCE_NAMED__(func, name, nID) -#define UB_AUTO_RUN_ONCE_NAMED__(func, name, nID) UB_AUTO_RUN_ONCE___(func, _##name##_##nID) - -#endif // ! UB_AUTORUN_HPP diff --git a/src/VirtualFluids_GPU/basics/utilities/UbComparators.h b/src/VirtualFluids_GPU/basics/utilities/UbComparators.h deleted file mode 100644 index ee809cf1c..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbComparators.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef UBCOMPARATORS_H -#define UBCOMPARATORS_H - -#include <functional> - -/*=========================================================================*/ -/* UbComparators */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 16.08.2007 -*/ - -namespace UbComparators -{ - //type_traits - template <typename T> struct MemberInfo; //not defined for correct compiler errors! - - // specialization for MemberFunctionsPtr - // C - class with return T method - template <typename T, typename C> - struct MemberInfo<T C::*> - { - typedef T type; - typedef C class_type; - - static T& apply( C& c, T C::* ptr ) { return c.*ptr; } - static const T& apply( const C& c, T C::* ptr ) { return c.*ptr; } - }; - //specialization for MemberFunctionsPtr - //C - class with return T method - template <typename T, typename C> - struct MemberInfo<T (C::*)()> - { - typedef T type; - typedef C class_type; - - static T apply( C& c, T (C::*ptr)() ) { return (c.*ptr)(); } - }; - //specialization for const MemberFunctionsPtr - //C - class with return T method - template <typename T, typename C> - struct MemberInfo<T (C::*)() const> - { - typedef T type; - typedef C class_type; - - static T apply( const C& c, T (C::*ptr)() const ) { return (c.*ptr)(); } - }; - - //MemberComparative-Class - template <typename Ptr, typename Comp = std::less<typename MemberInfo<Ptr>::type> > - class MemComp - : private Comp // -> usage of Empty Base Class Optimization (EBCO) - { - typedef typename MemberInfo<Ptr>::class_type C; - - public: - MemComp( Ptr ptr, Comp c = Comp() ) - : Comp(c), mp_(ptr) - {} - - bool operator()(C& lhs, C& rhs) - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - bool operator()(C& lhs, C& rhs) const - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - bool operator()(const C& lhs, const C& rhs) - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - bool operator()(const C& lhs, const C& rhs) const - { - return Comp::operator()( MemberInfo<Ptr>::apply(lhs, mp_), MemberInfo<Ptr>::apply(rhs, mp_) ); - } - - private: - Ptr mp_; - }; - - // Factoryfunktionen - template <typename Ptr> - MemComp<Ptr> membercomp(Ptr p) - { - return MemComp<Ptr>(p); - } - - template<typename Comp, typename Ptr> - MemComp<Ptr, Comp> membercomp(Ptr p, Comp c = Comp()) - { - return MemComp<Ptr, Comp>(p, c); - } - - template<template<typename> class Comp, typename Ptr> - MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> > - membercomp(Ptr p, Comp<typename MemberInfo<Ptr>::type> c = Comp<typename MemberInfo<Ptr>::type>()) - { - return MemComp<Ptr, Comp<typename MemberInfo<Ptr>::type> >(p, c); - } - - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - //andere Variante (alerdings ist hier keine Deduction moeglich!!!) - ////////////////////////////////////////////////////////////////////////// - //Vergleichs-Templates: - //Funktor zum "non-const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1 ); - template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() /*MethodenPointer*/> // Allgemeiner Fall - struct compareMethods - { - bool operator()(K& r, K& l) const // da fct nicht const ist, kann auch K nicht const sein. das const hinter der deklaration besagt dass compareMethods const sein kann - { return (r.*fct)() < (l.*fct)(); } - }; - ////////////////////////////////////////////////////////////////////////// - //Funktor zum "const" Methodenvergleich: liste.sort( compareMethods<Klasse, int, &Klasse::getVal1 ); - template<typename K/*Klasse*/, typename M /*MethodenRueckgabeTyp*/, M (K::*fct)() const /*MethodenPointer*/> // <- hier const - struct compareConstMethods - { - bool operator()(const K& r, const K& l) const //hier koennen die K's auch const sein, muessen sie aber nicht (const hinzufuegen geht ja problemlos) - { return (r.*fct)() < (l.*fct)(); } - }; - ////////////////////////////////////////////////////////////////////////// - //Funktor zum Membervergleich: lise.sort( compareMember<Klasse, int, &Klasse::member>() ); - template<typename K/*Klasse*/, typename M /*MemberTyp*/, M (K::*Member) /*MemberPointer*/> // <- hier const - struct compareMember - { - bool operator()(const K& r,const K& l) const - { return r.*Member < l.*Member; } - }; - //Bsp: - //class Klasse{ - //public: - // Klasse(double val1, double val2 ) : val1(val1),val2(val2) {} - // double getVal1() { return val1; } - // double getVal2() const { return val2; } // <- hier const - // double val1, val2; - //}; - //int main(int argc, char** argv){ - // std::list<Klasse> l; - // l.push_back( Klasse(10,10) ); - // l.push_back( Klasse(1,5) ); - // l.sort( compareMember<Klasse, double, &Klasse::val1 >() ); - // l.sort( compareMethods<Klasse, double, &Klasse::getVal1 >() ); - // l.sort( compareConstMethods<Klasse, double, &Klasse::getVal1 >() ); - //} - -}; - -#endif //UBCOMPARATOR_H - -//example -// #include <basics/utilities/UbComparators.h" -// #include <list> -// using namespace std; -// using namespace UbComparators; -// -// struct S { -// S(int i) :x(i) {} -// int x; -// float f() {return x;}; -// double g() const {return x;} -// }; -// -// struct intComp { -// bool operator()(int l, int r) const -// { return l > r; } -// }; -// -// struct dblComp { -// bool operator()(double l, double r) const -// { return l > r; } -// }; -// -// template <typename T> -// struct genComp { -// bool operator()(const T& l, const T& r) const -// { return l > r; } -// }; -// -// -// int main() -// { -// S a(1); -// S b(2); -// list<S> sList; -// sList.push_back(a); -// sList.push_back(b); -// sList.sort(UbComparators::membercomp(&S::x,intComp())); //calls overload (1) -// sList.sort(UbComparators::membercomp<intComp>(&S::x)); //same -// sList.sort(UbComparators::membercomp(&S::x)); //calls overload (5) -// sList.sort(UbComparators::membercomp<genComp>(&S::x)); //calls overload(3) -// sList.sort(UbComparators::membercomp(&S::x, genComp<int>())); //calls overload(1) -// //same for nonconst function -// sList.sort(UbComparators::membercomp(&S::f, dblComp())); //overload(2) -// sList.sort(UbComparators::membercomp<dblComp>(&S::f)); //same -// sList.sort(UbComparators::membercomp(&S::f)); //overload(6) -// sList.sort(UbComparators::membercomp<genComp>(&S::f)); //overload(4) -// //same for const function -// sList.sort(UbComparators::membercomp(&S::g, dblComp())); //overload(2) -// sList.sort(UbComparators::membercomp<dblComp>(&S::g)); //same -// sList.sort(UbComparators::membercomp(&S::g)); //overload(6) -// sList.sort(UbComparators::membercomp<genComp>(&S::g)); //overload(4) -// } diff --git a/src/VirtualFluids_GPU/basics/utilities/UbConverter.cpp b/src/VirtualFluids_GPU/basics/utilities/UbConverter.cpp deleted file mode 100644 index dcdf17f5d..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbConverter.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include <basics/utilities/UbConverter.h> - -const std::string UbConverter::base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - -std::string UbConverter::base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) -{ - std::string ret; - int i = 0; - int j = 0; - unsigned char char_array_3[3]; - unsigned char char_array_4[4]; - - while (in_len--) - { - char_array_3[i++] = *(bytes_to_encode++); - if( i==3) - { - char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for( i=0; i<4 ; i++) - ret += base64_chars[char_array_4[i]]; - i=0; - } - } - - if( i ) - { - for( j=i; j<3; j++) - char_array_3[j] = '\0'; - - char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for ( j=0; j<i+1; j++) - ret += base64_chars[char_array_4[j]]; - - while( i++<3 ) - ret += '='; - } - - return ret; -} -/*=======================================================*/ -std::string UbConverter::base64_decode(std::string const& encoded_string) -{ - int in_len = (int)encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - unsigned char char_array_4[4], char_array_3[3]; - std::string ret; - - while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) - { - char_array_4[i++] = encoded_string[in_]; in_++; - if(i ==4) - { - for (i = 0; i <4; i++) - char_array_4[i] = (unsigned char)base64_chars.find(char_array_4[i]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret += char_array_3[i]; - i = 0; - } - } - - if( i ) - { - for(j = i; j <4; j++) - char_array_4[j] = 0; - - for(j = 0; j <4; j++) - char_array_4[j] = (unsigned char)base64_chars.find(char_array_4[j]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for(j = 0; (j < i - 1); j++) - ret += char_array_3[j]; - } - - return ret; -} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbConverter.h b/src/VirtualFluids_GPU/basics/utilities/UbConverter.h deleted file mode 100644 index 7fd99c689..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbConverter.h +++ /dev/null @@ -1,49 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBCONVERTER_H -#define UBCONVERTER_H - -#include <cstdlib> -#include <ctime> -#include <cassert> -#include <string> - -/*=========================================================================*/ -/* UBConverter */ -/* */ -// -// encodes vals to e.g. base64 -// dencodes vals from e.g. base64 -// author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -// version 1.0 - 22.10.2007 - - -class UbConverter -{ -public: - static std::string base64_encode(unsigned char const* , unsigned int len); - static std::string base64_decode(std::string const& s); - - static inline bool is_base64(const unsigned char& c) - { - return (isalnum(c) || (c == '+') || (c == '/')); - } - -protected: - UbConverter() {} - ~UbConverter() {} - -private: - UbConverter(const UbConverter&); // not implemented. - void operator=(const UbConverter&); //not implemented. - - static const std::string base64_chars; -}; - - - -#endif //UBCONVERTER_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbEqual.h b/src/VirtualFluids_GPU/basics/utilities/UbEqual.h deleted file mode 100644 index 8c01318af..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbEqual.h +++ /dev/null @@ -1,120 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBEQUAL_H -#define UBEQUAL_H - -#include<cmath> - -////////////////////////////////////////////////////////////////////////// -//isUbEqual<T1,T2>(a,b) -//vergleicht die gleichtheit der beiden werte a und b -// -//std-maessig wird hierfür der operator== verwendet -// -//Ausnahme: floating-points -//hier wird jeweils der "genauere typ zum ungenaueren gecastet und dann verglichen" -//e.g.: double d=1.2; int i=1; bool check = isUbEqual(d,i); -> true -// -//bei klassen muss hier operator== fuer const objecte implementiert sein!!! -//e.g.: bool operator==(const Test&) const { if(blabla) return true; else return false; } -// -// -//author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//version 1.0 - 25.03.2008 -////////////////////////////////////////////////////////////////////////// - -//std-trait, fuer alle nicht spezifischen typen: -template < typename T1, typename T2 > -struct UbEqualTrait -{ - typedef T1 High; - typedef T1 Low; -}; - -//std-trait, fuer gleiche T -template < typename T > -struct UbEqualTrait< T, T > -{ - typedef T High; - typedef T Low; -}; - -//spezialisierung für diverse Typen-Tuples -template<> struct UbEqualTrait< short, int > { typedef int High; typedef short Low; }; -template<> struct UbEqualTrait< short, long > { typedef long High; typedef short Low; }; -template<> struct UbEqualTrait< short, float > { typedef float High; typedef short Low; }; -template<> struct UbEqualTrait< short, double > { typedef double High; typedef short Low; }; -template<> struct UbEqualTrait< short, long double > { typedef long double High; typedef short Low; }; - -template<> struct UbEqualTrait< int, short > { typedef int High; typedef short Low; }; -template<> struct UbEqualTrait< int, long > { typedef long High; typedef int Low; }; -template<> struct UbEqualTrait< int, float > { typedef float High; typedef int Low; }; -template<> struct UbEqualTrait< int, double > { typedef double High; typedef int Low; }; -template<> struct UbEqualTrait< int, long double > { typedef long double High; typedef int Low; }; - -template<> struct UbEqualTrait< long, short > { typedef long High; typedef short Low; }; -template<> struct UbEqualTrait< long, int > { typedef long High; typedef int Low; }; -template<> struct UbEqualTrait< long, float > { typedef float High; typedef long Low; }; -template<> struct UbEqualTrait< long, double > { typedef double High; typedef long Low; }; -template<> struct UbEqualTrait< long, long double > { typedef long double High; typedef long Low; }; - -template<> struct UbEqualTrait< float, short > { typedef float High; typedef short Low; }; -template<> struct UbEqualTrait< float, int > { typedef float High; typedef int Low; }; -template<> struct UbEqualTrait< float, long > { typedef float High; typedef long Low; }; -template<> struct UbEqualTrait< float, double > { typedef double High; typedef float Low; }; -template<> struct UbEqualTrait< float, long double > { typedef long double High; typedef float Low; }; - -template<> struct UbEqualTrait< double, short > { typedef double High; typedef short Low; }; -template<> struct UbEqualTrait< double, int > { typedef double High; typedef int Low; }; -template<> struct UbEqualTrait< double, long > { typedef double High; typedef long Low; }; -template<> struct UbEqualTrait< double, float > { typedef double High; typedef float Low; }; -template<> struct UbEqualTrait< double, long double > { typedef long double High; typedef double Low; }; - -template<> struct UbEqualTrait< long double, short > { typedef long double High; typedef short Low; }; -template<> struct UbEqualTrait< long double, int > { typedef long double High; typedef int Low; }; -template<> struct UbEqualTrait< long double, long > { typedef long double High; typedef long Low; }; -template<> struct UbEqualTrait< long double, float > { typedef long double High; typedef float Low; }; -template<> struct UbEqualTrait< long double, double > { typedef long double High; typedef double Low; }; - -////////////////////////////////////////////////////////////////////////// -//fuer Allgmeine-Typen ( operator== ): -template< typename T1, typename T2 > -inline bool specific_equal(const T1& a, const T2& b) { return a==b; } - -////////////////////////////////////////////////////////////////////////// -//fuer floating point build-in-type -//float.float -template< /*float,float*/> -inline bool specific_equal< float, float >(const float& a, const float& b) { return std::fabs( a - b ) < 1E-8; } - -template</*double,double*/> -inline bool specific_equal< double, double >(const double& a, const double& b) { return std::fabs( a - b ) < 1E-13; } - -template</*long double,long double*/> -inline bool specific_equal< long double, long double >(const long double& a, const long double& b) { return std::fabs( a - b ) < 1E-16; } - -////////////////////////////////////////////////////////////////////////// -//globale isUbEqual - Funktion -template< typename T1, typename T2 > -inline bool isUbEqual(const T1& a, const T2& b) -{ - typedef typename UbEqualTrait<T1,T2>::Low Low; - return specific_equal< Low, Low >(static_cast< Low >( a ),static_cast< Low >( b )); -}; - -////////////////////////////////////////////////////////////////////////// -//UbEqual-Functor -template< typename T1, typename T2 > -struct UbEqual -{ - bool operator()(const T1& a, const T2& b) - { - return isUbEqual(a,b); - } -}; - -#endif //UBEQUAL_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbException.h b/src/VirtualFluids_GPU/basics/utilities/UbException.h deleted file mode 100644 index 06943900b..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbException.h +++ /dev/null @@ -1,156 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBEXCEPTION_H -#define UBEXCEPTION_H - -#include <vector> -#include <iostream> -#include <string> -#include <sstream> -#include <stdexcept> - -#include "./UbTuple.h" - -/*=========================================================================*/ -/* UbException */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -@version 1.5 - 14.03.08 -@version 1.6 - 31.03.08 derivation from std::run_time_error -@version 1.6a - helper marco UB_EXARGS -*/ - -/* -usage: throw UbException("error message"); - throw UbException(__FILE__, __LINE__,"error message"); - throw UbException(__FILE__, __LINE__,UB_FUNCTION,"error message"); - throw UbException(UB_EXARGS,"error"); //same as above -*/ - -//Macro UB_FUNCTION: figures out the method/function name (platform dependant) -#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) - # define UB_FUNCTION __PRETTY_FUNCTION__ -#elif defined(__DMC__) && (__DMC__ >= 0x810) - # define UB_FUNCTION __PRETTY_FUNCTION__ -#elif defined(__FUNCSIG__) - # define UB_FUNCTION __FUNCSIG__ -#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) - # define UB_FUNCTION __FUNCTION__ -#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) - # define UB_FUNCTION __FUNC__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) - # define UB_FUNCTION __func__ -#else - # define UB_FUNCTION "(unknown)" -#endif - -//Helper Marco -#ifndef SWIG -#define UB_EXARGS __FILE__,__LINE__,UB_FUNCTION -#endif -class UbException : public std::runtime_error -{ -public: - typedef UbTuple< std::string, int, std::string, std::string > ExceptionData; -public: - ////////////////////////////////////////////////////////////////////////// - //constructors - UbException() - : std::runtime_error("") - { - } - /*==========================================================*/ - UbException(const std::string& str) - : std::runtime_error("") - { - this->addInfo(str); - } - /*==========================================================*/ - UbException(const std::string& file, const int& line, const std::string& err_str) - : std::runtime_error("") - { - this->addInfo(file,line,"unknown",err_str); - } - /*==========================================================*/ - //UbException(const char* file, const int& line, const char* function, const std::string& err_str) - UbException(const std::string& file, const int& line, const std::string& function, const std::string& err_str) - : std::runtime_error("") - { - this->addInfo(file,line,function,err_str); - } - ////////////////////////////////////////////////////////////////////////// - //destructor - virtual ~UbException() throw() { } - ////////////////////////////////////////////////////////////////////////// - //virtual public methods - //returns exception-string - virtual const char* what() const throw() - { - exceptionString = this->toString(); - return exceptionString.c_str(); //ansonsten ist das Verhalten anschließend undefiniert! - } - /*==========================================================*/ - virtual void addInfo(const std::string& err_str) - { - exceptionData.push_back( makeUbTuple( (std::string)"-", 0, (std::string)"unknown", err_str) ); - } - /*==========================================================*/ - //add exception - virtual void addInfo(const std::string& file, const int& line, const std::string& function, const std::string& err_str) - { - exceptionData.push_back( makeUbTuple( file, line, function, err_str ) ); - } - /*==========================================================*/ - //returns exception-string with all calles exceptions - virtual const std::vector<std::string> getInfo() const - { - std::vector<std::string> tmp; - for(std::size_t i=0; i<exceptionData.size(); i++) - { - std::stringstream str; - str << val<1>( exceptionData[i] ) << ", " - << val<2>( exceptionData[i] ) << ", " - << val<3>( exceptionData[i] ) << ", " - << val<4>( exceptionData[i] ); - tmp.push_back( str.str()); - } - return tmp; - } - /*==========================================================*/ - //returns exception-string with all calles exceptions and detailes informations - virtual std::string toString() const - { - std::stringstream str("UbExeption"); - - for(std::size_t i=0; i<exceptionData.size(); i++) - str<<(std::string)"caller[" << i << "]\n" - <<" - file: "<< val<1>( exceptionData[i] )<<"\n" - <<" - line: "<< val<2>( exceptionData[i] )<<"\n" - <<" - function: "<< val<3>( exceptionData[i] )<<"\n" - <<" - what: "<< val<4>( exceptionData[i] )<< std::endl; - - return str.str(); - } - -protected: - ////////////////////////////////////////////////////////////////////////// - //protected member - std::vector< ExceptionData > exceptionData; - mutable std::string exceptionString; -}; - -//overlading operator << -inline std::ostream& operator<<(std::ostream& os, const UbException& e) -{ - return os<<e.toString(); -} - -#endif //UBEXCEPTION_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileInput.h b/src/VirtualFluids_GPU/basics/utilities/UbFileInput.h deleted file mode 100644 index 088b718a1..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileInput.h +++ /dev/null @@ -1,101 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUT_H -#define UBFILEINPUT_H - -#include <fstream> -#include <iostream> -#include <string> - -#include <cstdlib> //atoi -#include <cstring> //strstr - -#include <basics/utilities/UbException.h> - -/*=========================================================================*/ -/* UbFileInput */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileInput -{ -public: - enum FILETYPE {ASCII, BINARY}; - -public: - UbFileInput() : filename(""), commentindicator('C') { } - virtual ~UbFileInput() { infile.close(); } - - virtual bool operator!() { return !(infile); } - virtual bool isOpen() { return !(!(infile)); } - - virtual bool open(std::string filename)=0; - virtual void close() { infile.close(); } - virtual int eof() { return infile.eof(); } - std::fstream::pos_type tellg() { return infile.tellg(); } - void seekg(std::fstream::off_type offset, std::ios::seekdir origin=std::ios::beg) { infile.seekg(offset, origin); } - - virtual void skipLine()=0; // Springt zur naechsten Zeile - virtual void readLine()=0; - virtual std::string readStringLine()=0; - virtual int readInteger()=0; // Liest einen int-Wert ein - virtual long readLong()=0; // Liest einen long-Wert ein - virtual long long readLongLong()=0; // Liest einen long-Wert ein - virtual std::size_t readSize_t()=0; - virtual double readDouble()=0; // Liest einen double-Wert ein - virtual float readFloat()=0; // Liest einen float-Wert ein - virtual bool readBool()=0; // Liest einen bool-Wert ein - virtual char readChar()=0; // Liest einen char-Wert ein - virtual std::string readString()=0; // Liest ein Wort ein - virtual std::string readLineTill(char stop)=0; // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - virtual std::string parseString()=0; // Liest - - virtual void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} - - virtual bool containsString( const std::string& var)=0; - virtual void setPosAfterLineWithString( const std::string& var)=0; - virtual int readIntegerAfterString( const std::string& var)=0; - virtual double readDoubleAfterString( const std::string& var)=0; - virtual bool readBoolAfterString( const std::string& var)=0; - virtual std::string readStringAfterString( const std::string& var)=0; - - virtual std::string getFileName() {return this->filename;} - - //returns file extension: - //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> "" - virtual std::string getFileExtension() - { - std::size_t pos1 = filename.rfind("/"); - if(pos1==std::string::npos) pos1 = 0; - std::size_t pos2 = filename.rfind("."); - if(pos2!=std::string::npos && pos2>pos1) - return filename.substr(pos2+1); - - return ""; - } - - //returns "ASCII", "BINARY" - virtual FILETYPE getFileType()=0; - -protected: - std::ifstream infile; - std::string filename; - char commentindicator; -}; - -#endif //UBFILEINPUT_H - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.cpp b/src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.cpp deleted file mode 100644 index c4f65a712..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.cpp +++ /dev/null @@ -1,274 +0,0 @@ -#include <basics/utilities/UbFileInputASCII.h> -#include <cstring> -//#include <Windows.h> - -using namespace std; - -UbFileInputASCII::UbFileInputASCII(string filename) -{ - this->filename = filename; - this->commentindicator = 'C'; - - infile.open(filename.c_str()); - - //if(!infile) throw UbException((string)("UbFileInputASCII::UbFileInputASCII(string filename, int how) couldn't open file:\n "+filename)); -} -/*==========================================================*/ -bool UbFileInputASCII::open(string filename) -{ - infile.close(); - infile.clear(); //setzt flags zurueck - - this->filename = filename; - infile.open(this->filename.c_str()); - - return infile.is_open(); -} -/*==========================================================*/ -int UbFileInputASCII::readInteger() -{ - int dummy; - infile>>dummy; - return dummy; -} - -unsigned short UbFileInputASCII::readUnsignedInteger() -{ - unsigned short dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -long UbFileInputASCII::readLong() -{ - long dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -long long UbFileInputASCII::readLongLong() -{ - long long dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::getFileName() -{ - return this->filename; -} - -/*==========================================================*/ -void UbFileInputASCII::skipLine() -{ - string dummy; - getline(infile, dummy); -} -/*==========================================================*/ -void UbFileInputASCII::readLine() -{ - string dummy; - getline(infile, dummy); -} -/*==========================================================*/ -string UbFileInputASCII::readStringLine() -{ - string dummy; - getline(infile, dummy); - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::readLineTill(char stop) -{ - string dummy; - getline(infile, dummy, stop); - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::parseString() -{ - string dummy; - getline(infile, dummy, ' '); - return dummy; -} -/*==========================================================*/ -double UbFileInputASCII::readDouble() -{ - double dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -float UbFileInputASCII::readFloat() -{ - float dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -string UbFileInputASCII::readString() -{ - string dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -char UbFileInputASCII::readChar() -{ - int dummy; - infile>>dummy; - return (char)dummy; -} -/*==========================================================*/ -std::size_t UbFileInputASCII::readSize_t() -{ - std::size_t dummy; - infile>>dummy; - return dummy; -} -/*==========================================================*/ -void UbFileInputASCII::setPosAfterLineWithString(const string& var) -{ - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - infile.getline(line,512); - if(infile.eof()) throw UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> string "+var+" wasn't found in "+this->filename); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt -} -/*==========================================================*/ -bool UbFileInputASCII::containsString(const string& var) -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - infile.getline(line,512); - if(infile.eof()) return false; - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - return true; -} -/*==========================================================*/ -int UbFileInputASCII::readIntegerAfterString(const string& var) -// last change [10.3.2004] at [9:46] -//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. timesteps 9 -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - infile.getline(line,512); - if(infile.eof()) throw UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return atoi(line); // Umwandlung in int -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -double UbFileInputASCII::readDoubleAfterString(const string& var) -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - infile.getline(line,512); - if(infile.eof()) throw UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename); - }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return (atof(line)); // Umwandlung in double -} -/*==========================================================*/ -// [9.9.2002] -// liefert string-Wert der hinter dem uebergebenen char feld in der datei infile steht -// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig) -string UbFileInputASCII::readStringAfterString(const string& var)//,char *value) -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - //string line_copy[512]; - - do{ - infile.getline(line,512); - if(infile.eof()) throw UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> "+var+" wasn't found in "+this->filename); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - char *p; - p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab - p=strtok(line,"\t");//schneidet alles "ab und inklusive tab " nach namen ab - - return static_cast<string>(p); // Umwandlung in string -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbFileInputASCII::readBoolAfterString(const string& var) -{ - if(this->readStringAfterString(var) == "true" ) return true; - else if(this->readStringAfterString(var) == "false") return false; - else throw UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression after "+var+" is not equal to 'true' or 'false' in "+this->filename); -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbFileInputASCII::readBool() -{ - string tmp = this->readString(); - if( tmp == "true" ) return true; - else if(tmp == "false") return false; - else throw UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression=\""+tmp+"\" is not equal to 'true' or 'false' in "+this->filename); -} -/*==========================================================*/ -int UbFileInputASCII::getNumberOfLines() -{ - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - int counter=0; - - do - { - infile.getline(line,512); - counter++; - }while ( !infile.eof() ); - - counter -= 1; - - - infile.clear(); // setzt den EOF-Status zurueck (wird durch infile.seekg() NICHT getan!!!) - - infile.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - return counter; -} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.h b/src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.h deleted file mode 100644 index 2ca037c94..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileInputASCII.h +++ /dev/null @@ -1,79 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUTASCII_H -#define UBFILEINPUTASCII_H - -#include <fstream> -#include <iostream> -#include <string> -//#include <Windows.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -/*=========================================================================*/ -/* UbFileInputASCII */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileInputASCII : public UbFileInput -{ -public: - UbFileInputASCII() : UbFileInput() { } - UbFileInputASCII(std::string filename); - - bool open(std::string filename); - - std::string getFileName(); - void skipLine(); // Springt zur naechsten Zeile - - void readLine(); - std::string readStringLine(); - int readInteger(); // Liest einen int-Wert ein - unsigned short readUnsignedInteger(); - long readLong(); // Liest einen long-Wert ein - long long readLongLong(); // Liest einen long-Wert ein - std::size_t readSize_t(); - double readDouble(); // Liest einen double-Wert ein - float readFloat(); // Liest einen float-Wert ein - bool readBool(); // Liest einen bool-Wert ein - char readChar(); // Liest einen char-Wert ein - std::string readString(); // Liest ein Wort ein - std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - std::string parseString(); - - bool containsString(const std::string& var); - void setPosAfterLineWithString(const std::string& var); - int readIntegerAfterString(const std::string& var); - double readDoubleAfterString(const std::string& var); - bool readBoolAfterString(const std::string& var); - std::string readStringAfterString(const std::string& var); - - FILETYPE getFileType() { return ASCII; } - - int getNumberOfLines(); - - template< typename T > - friend inline UbFileInputASCII& operator>>(UbFileInputASCII& file, T& data) - { - file.infile>>data; - return file; - } -}; - -#endif //UBFILEINPUTASCII_H - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.cpp b/src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.cpp deleted file mode 100644 index 051986c48..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include <basics/utilities/UbFileInputBinary.h> -//#include <C:\Users\Sonja\sources\viflui\trunk\source\basics\utilities\UbFileInputBinary.h> - -//#include <C:/Users/Sonja/sources/viflui/trunk/source/basics/utilities/UbFileInputBinary.cpp> -//#include <C:\Users\Sonja\sources\viflui\trunk\source\basics\utilities\UbFileInputBinary.h > -#include <cstring> -//#include <Windows.h> - -using namespace std; - -/*==========================================================*/ -UbFileInputBinary::UbFileInputBinary(string filename) -{ - this->filename = filename; - infile.open(filename.c_str(), ios::in | ios::binary); -} -/*==========================================================*/ -bool UbFileInputBinary::open(string filename) -{ - infile.close(); - infile.clear(); //setzt flags zurueck - - this->filename = filename; - infile.open(this->filename.c_str(), ios::in | ios::binary); - - return infile.is_open(); -} -/*==========================================================*/ -int UbFileInputBinary::readInteger() -{ - int dummy; - infile.read((char*)&dummy,sizeof(int)); - return dummy; -} -/*==========================================================*/ -unsigned short UbFileInputBinary::readUnsignedInteger() -{ - unsigned short dummy; - infile.read((char*)&dummy,sizeof(unsigned short)); - return dummy; -} -/*==========================================================*/ -long long UbFileInputBinary::readLongLong() -{ - long long dummy; - infile.read((char*)&dummy,sizeof(long long)); - return dummy; -} -/*==========================================================*/ -long UbFileInputBinary::readLong() -{ - long dummy; - infile.read((char*)&dummy,sizeof(long)); - return dummy; -} -/*==========================================================*/ -std::size_t UbFileInputBinary::readSize_t() -{ - std::size_t dummy; - infile.read((char*)&dummy,sizeof(std::size_t)); - return dummy; -} -/*==========================================================*/ -double UbFileInputBinary::readDouble() -{ - double dummy; - infile.read((char*)&dummy,sizeof(double)); - return dummy; -} -/*==========================================================*/ -float UbFileInputBinary::readFloat() -{ - float dummy; - infile.read((char*)&dummy,sizeof(float)); - return dummy; -} -/*==========================================================*/ -char UbFileInputBinary::readChar() -{ - char dummy; - infile.read((char*)&dummy,sizeof(char)); - return dummy; -} -/*==========================================================*/ -string UbFileInputBinary::readString() -{ - char c; - infile.read(&c,sizeof(char)); - while(c==' ' || c=='\t') infile.read(&c,sizeof(char)); - - string dummy; - dummy+=c; - - infile.read(&c,sizeof(char)); - while(c!='\0' && c!=' ' && c!='\t' && c!='\n') - { - dummy+=c; - infile.read(&c,sizeof(char)); - } - return dummy; -} -/*==========================================================*/ -bool UbFileInputBinary::readBool() -{ - bool dummy; - infile.read((char*)&dummy,sizeof(bool)); - return dummy; -} -/*==========================================================*/ -void UbFileInputBinary::skipLine() -{ - char c; - do{ - infile.read(&c,sizeof(char)); - }while(c!='\n'); -} -/*==========================================================*/ -void UbFileInputBinary::readLine() -{ - char c; - infile.read(&c,sizeof(char)); - while(c!='\n') infile.read(&c,sizeof(char)); -} -/*==========================================================*/ -string UbFileInputBinary::readStringLine() -{ - char c; - string dummy; - infile.read(&c,sizeof(char)); - while(c!='\n') - { - dummy+=c; - infile.read(&c,sizeof(char)); - } - return dummy; -} -/*==========================================================*/ -string UbFileInputBinary::readLineTill(char stop) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -string UbFileInputBinary::parseString() -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -bool UbFileInputBinary::containsString(const string& var) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -void UbFileInputBinary::setPosAfterLineWithString(const string& var) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -int UbFileInputBinary::readIntegerAfterString(const string& var) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -double UbFileInputBinary::readDoubleAfterString(const string& var) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -string UbFileInputBinary::readStringAfterString(const string& var) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} -/*==========================================================*/ -bool UbFileInputBinary::readBoolAfterString(const string& var) -{ - throw UbException(UB_EXARGS,"method makes no sense for binary streams"); -} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.h b/src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.h deleted file mode 100644 index 787c7cf1f..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileInputBinary.h +++ /dev/null @@ -1,75 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUTBINARY_H -#define UBFILEINPUTBINARY_H - -#include <fstream> -#include <iostream> -#include <string> -//#include <Windows.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -/*=========================================================================*/ -/* UbFileInputBinary */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileInputBinary : public UbFileInput -{ -public: - UbFileInputBinary() : UbFileInput() { } - UbFileInputBinary(std::string filename); - - bool open(std::string filename); - - void skipLine(); // Springt zur naechsten Zeile - void readLine(); - std::string readStringLine(); - std::size_t readSize_t(); - int readInteger(); // Liest einen int-Wert ein - unsigned short readUnsignedInteger(); - long readLong(); // Liest einen long-Wert ein - long long readLongLong(); // Liest einen long long-Wert ein - double readDouble(); // Liest einen double-Wert ein - float readFloat(); // Liest einen float-Wert ein - bool readBool(); // Liest einen bool-Wert ein - char readChar(); // Liest einen char-Wert ein - std::string readString(); // Liest ein Wort ein - std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - std::string parseString(); // Liest - - bool containsString(const std::string& var); - void setPosAfterLineWithString(const std::string& var); - int readIntegerAfterString(const std::string& var); - double readDoubleAfterString(const std::string& var); - bool readBoolAfterString(const std::string& var); - std::string readStringAfterString(const std::string& var); - - FILETYPE getFileType() { return BINARY; } - - template< typename T > - friend inline UbFileInputBinary& operator>>(UbFileInputBinary& file, T& data) - { - file.infile.read((char*)&data,sizeof(T)); - return file; - } -}; - -#endif - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileOutput.h b/src/VirtualFluids_GPU/basics/utilities/UbFileOutput.h deleted file mode 100644 index b40b93aeb..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileOutput.h +++ /dev/null @@ -1,98 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUT_H -#define UBFILEOUTPUT_H - -#include <iomanip> -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> -#define NOMINMAX -/*=========================================================================*/ -/* UbFileOutput */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileOutput -{ -public: - enum CREATEOPTION {OUTFILE=0, INANDOUTFILE=1, APPENDFILE=2}; - enum FILETYPE {ASCII, BINARY}; - -public: - UbFileOutput() : filename(""), commentindicator('C') { } - UbFileOutput(const std::string& filename) : filename(filename), commentindicator('C') { } - virtual ~UbFileOutput() { outfile.flush();outfile.close(); } - - virtual bool open(const std::string& filename, CREATEOPTION opt=OUTFILE) = 0; - - virtual bool operator!() { return !(outfile); } - virtual bool isOpen() { return !(!(outfile)); } - - virtual void flush() { outfile.flush(); } - virtual void close() { outfile.close(); } - - std::fstream::pos_type tellp() { return outfile.tellp(); } - void seekp(std::fstream::off_type offset, std::ios::seekdir origin=std::ios::beg) { outfile.seekp(offset,origin); } - - virtual void writeInteger(const int& value, const int& width=0)=0; - virtual void writeLong(const long& value, const int& width=0)=0; - virtual void writeLongLong(const long long& value, const int& width=0)=0; - virtual void writeDouble(const double& value, const int& width=0)=0; - virtual void writeFloat(const float& value, const int& width=0)=0; - virtual void writeBool(const bool& value, const int& width=0)=0; - virtual void writeSize_t(const std::size_t& value, const int& width=0)=0; - virtual void writeChar(const char& value, const int& width=0)=0; - virtual void writeString(const std::string& value, const int& width=0)=0; - virtual void writeStringOnly(const std::string& value)=0; - virtual void writeLine(const std::string& value, const int& width=0)=0; - virtual void writeLine()=0; - - virtual void writeCommentLine(const std::string& line)=0; - virtual void writeCommentLine(char indicator, const std::string& line)=0; - virtual void writeCopyOfFile(const std::string& filename)=0; - - virtual void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} - - virtual void setPrecision(const int& precision)=0; - virtual int getPrecision()=0; - - //returns "ASCII", "BINARY" - virtual FILETYPE getFileType()=0; - - //returns file extension: - //e.g. "./../test/ich.inp" -> "inp", "./../test/ich" -> "" - virtual std::string getFileExtension() - { - std::size_t pos1 = filename.rfind("/"); - if(pos1==std::string::npos) pos1 = 0; - std::size_t pos2 = filename.rfind("."); - if(pos2!=std::string::npos && pos2>pos1) - return filename.substr(pos2+1); - - return ""; - } - - virtual std::string getFileName() {return this->filename;} -protected: - std::ofstream outfile; - std::string filename; - char commentindicator; -}; - -#endif //UBFILEOUTPUT_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.cpp b/src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.cpp deleted file mode 100644 index 8c1e6965b..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbInfinity.h> -#include <basics/utilities/UbMath.h> -#include <cstring> - -using namespace std; - -UbFileOutputASCII::UbFileOutputASCII(const string& filename, const bool& createPath, const int& precision) - : UbFileOutput(filename) -{ - this->commentindicator = 'C'; - this->setPrecision(20); - - outfile.open(filename.c_str(),ios::out); - - if(!outfile && createPath) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) - { - UbSystem::makeDirectory(path); - outfile.open(filename.c_str(),ios::out); - } - } - - if(!outfile) throw UbException(UB_EXARGS,"couldn't open file:\n "+filename); -} -/*==========================================================*/ -UbFileOutputASCII::UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath, const int& precision) - : UbFileOutput(filename) -{ - this->commentindicator = 'C'; - this->setPrecision(precision); - - if(!this->open(filename,opt) && createPath) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) UbSystem::makeDirectory(path); - - this->open(filename,opt); - } - - if(!outfile) throw UbException(UB_EXARGS,"couldn't open file:\n "+filename); -} -/*==========================================================*/ -bool UbFileOutputASCII::open(const std::string& filename, CREATEOPTION opt) -{ - outfile.close(); - outfile.clear(); //setzt flags zurueck - this->filename = filename; - - if (opt==UbFileOutput::OUTFILE ) outfile.open(this->filename.c_str(),ios::out); - else if(opt==UbFileOutput::INANDOUTFILE ) outfile.open(this->filename.c_str(),ios::out | ios::in); - else if(opt==UbFileOutput::APPENDFILE ) outfile.open(this->filename.c_str(),ios::app); - else throw UbException(UB_EXARGS,"undefined CREATEOPTION"); - - return outfile.is_open(); -} -/*==========================================================*/ -void UbFileOutputASCII::writeBool(const bool& value, const int& width) -{ - outfile.width(width); - if(value) outfile<<"true "; - else outfile<<"false "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeDouble(const double& value, const int& width) -{ - outfile.width(width); - //Problem: Ub::inf wird gerundet - // -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus - // -> max Laenge darstellen und gut ist - if(UbMath::equal(value, (double)Ub::inf) ) - { - ios_base::fmtflags flags = outfile.flags(); - outfile<<setprecision(std::numeric_limits<double>::digits10+2); - outfile<<value<<" "; - outfile.flags(flags); - return; - } - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeFloat(const float& value, const int& width) -{ - outfile.width(width); - //Problem: Ub::inf wird gerundet - // -> beim Einlesen ist der Wert evtl zu gross und es kommt murks raus - // -> max Laenge darstellen und gut ist - if(UbMath::equal(value, (float)Ub::inf) ) - { - ios_base::fmtflags flags = outfile.flags(); - outfile<<setprecision(std::numeric_limits<float>::digits10+2); - outfile<<value<<" "; - outfile.flags(flags); - return; - } - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::setPrecision(const int& precision) -{ - outfile<<setprecision(precision); -} -/*==========================================================*/ -void UbFileOutputASCII::writeInteger(const int& value, const int& width) -{ - outfile.width(width); - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeLong(const long& value, const int& width) -{ - outfile.width(width); - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeLongLong(const long long& value, const int& width) -{ - outfile.width(width); - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeSize_t(const std::size_t& value, const int& width) -{ - outfile.width(width); - outfile<<value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeChar(const char& value, const int& width) -{ - outfile.width(width); - outfile<<(int)value<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeString(const string& value, const int& width) -{ - outfile.width(width); - outfile<<value.c_str()<<" "; -} -/*==========================================================*/ -void UbFileOutputASCII::writeStringOnly(const string& value) -{ - outfile<<value.c_str(); -} - -/*==========================================================*/ -void UbFileOutputASCII::writeLine(const string& value, const int& width) -{ - outfile.width(width); - outfile<<value.c_str()<<endl; -} -/*==========================================================*/ -void UbFileOutputASCII::writeLine() -{ - outfile<<endl; -} -/*==========================================================*/ -void UbFileOutputASCII::writeCommentLine(const string& line) -{ - this->writeCommentLine(this->commentindicator, line); -} -/*==========================================================*/ -void UbFileOutputASCII::writeCommentLine(char indicator, const string& line) -{ - this->outfile<<indicator<<line<<endl; -} -/*==========================================================*/ -void UbFileOutputASCII::writeCopyOfFile(const string& filename) -{ - ifstream infile(filename.c_str()); - if(!infile) throw UbException(UB_EXARGS,"couldn't open file:\n "+filename); - - try - { - char c; - while(infile.get(c)) - { - outfile.put(c); //=out<<c; - } - outfile.flush(); - infile.close(); - } - catch(std::exception& e) { throw UbException(UB_EXARGS,"catched std::exception, error: "+(std::string)e.what()); } - catch(...) { throw UbException(UB_EXARGS,"unknown error"); } -} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.h b/src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.h deleted file mode 100644 index e44522cf6..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputASCII.h +++ /dev/null @@ -1,74 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUTASCII_H -#define UBFILEOUTPUTASCII_H - -#include <iomanip> -#include <fstream> -#include <iostream> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileOutput.h> -#define NOMINMAX -/*=========================================================================*/ -/* UbFileOutputASCII */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileOutputASCII : public UbFileOutput -{ -public: - UbFileOutputASCII() : UbFileOutput() {} - UbFileOutputASCII(const std::string& filename, const bool& createPath=true, const int& precision=15); - UbFileOutputASCII(const std::string& filename, CREATEOPTION opt, const bool& createPath=true, const int& precision=15); - - bool open(const std::string& filename, CREATEOPTION opt=OUTFILE); - - void writeBool(const bool& value, const int& width=0); - void writeDouble(const double& value, const int& width=0); - void writeFloat(const float& value, const int& width=0); - void writeInteger(const int& value, const int& width=0); - void writeLong(const long& value, const int& width=0); - void writeLongLong(const long long& value, const int& width=0); - void writeSize_t(const std::size_t& value, const int& width=0); - void writeChar(const char& value, const int& width=0); - void writeString(const std::string& value, const int& width=0); - void writeStringOnly(const std::string& value); - void writeLine(const std::string& value, const int& width=0); - void writeLine(); - - void setPrecision(const int& precision); - int getPrecision() { return (int)outfile.precision(); } - - void setCommentIndicator(char commentindicator) {this->commentindicator = commentindicator;} - - void writeCommentLine(const std::string& line); - void writeCommentLine(char indicator, const std::string& line); - void writeCopyOfFile(const std::string& filename); - - FILETYPE getFileType() { return ASCII; } - - template< typename T > - friend inline UbFileOutputASCII& operator<<(UbFileOutputASCII& file, const T& data) - { - file.outfile<<data; - return file; - } -}; - -#endif - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.cpp b/src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.cpp deleted file mode 100644 index e00282a73..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include <basics/utilities/UbFileOutputBinary.h> -#include <basics/utilities/UbSystem.h> -#include <cstring> - -using namespace std; - -/*==========================================================*/ -UbFileOutputBinary::UbFileOutputBinary(const string& filename, const bool& createPath) -{ - this->filename = filename; - this->commentindicator = 'C'; - - outfile.open(filename.c_str(),ios::out | ios::binary); - - if(!outfile && createPath) - { - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - UbSystem::makeDirectory(path); - outfile.open(filename.c_str(),ios::out | ios::binary); - } - } - - if(!outfile) throw UbException(UB_EXARGS,"couldn't open file:\n "+filename); - -} -/*==========================================================*/ -UbFileOutputBinary::UbFileOutputBinary(const string& filename,UbFileOutput::CREATEOPTION opt, const bool& createPath) -{ - this->filename = filename; - this->commentindicator = 'C'; - - this->open(filename,opt); - - if(!this->open(filename,opt) && createPath) - { - string path = UbSystem::getPathFromString(filename); - if(path.size()>0) - { - outfile.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - UbSystem::makeDirectory(path,20); - - this->open(filename,opt); - } - } - - if(!outfile) throw UbException(UB_EXARGS,"couldn't open file:\n "+filename); -} -/*==========================================================*/ -bool UbFileOutputBinary::open(const string& filename, UbFileOutput::CREATEOPTION opt) -{ - outfile.close(); - outfile.clear(); //setzt flags zurueck - - this->filename = filename; - - if (opt==UbFileOutput::OUTFILE ) outfile.open(this->filename.c_str(),ios::out | ios::binary); - else if(opt==UbFileOutput::APPENDFILE ) outfile.open(this->filename.c_str(),ios::app | ios::binary); - else if(opt==UbFileOutput::INANDOUTFILE) throw UbException(UB_EXARGS,"undefined CREATEOPTION - INANDOUTFILE not possible for BINARY files"); - else throw UbException(UB_EXARGS,"undefined CREATEOPTION"); - - return outfile.is_open(); -} -/*==========================================================*/ -void UbFileOutputBinary::writeBool(const bool& value, const int& width) -{ - outfile.write((char*)&value,sizeof(bool)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeDouble(const double& value, const int& width) -{ - outfile.write((char*)&value,sizeof(double)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeFloat(const float& value, const int& width) -{ - outfile.write((char*)&value,sizeof(float)); -} -/*==========================================================*/ -void UbFileOutputBinary::setPrecision(const int& precision) -{ - throw UbException(UB_EXARGS,"no way"); -} -/*==========================================================*/ -int UbFileOutputBinary::getPrecision() -{ - throw UbException(UB_EXARGS,"no way"); -} -/*==========================================================*/ -void UbFileOutputBinary::writeInteger(const int& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeLong(const long& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeLongLong(const long long& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeSize_t(const std::size_t& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeChar(const char& value, const int& width) -{ - outfile.write((char*)&value,sizeof(value)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeString(const string& value, const int& width) -{ - char c='\0'; - unsigned int length = (unsigned)value.length(); - - unsigned pos; - //whitespaces und tabs am stringanfang uebergehen - for(pos=0; pos<length; pos++) - if( value[pos]!=' ' && value[pos]!='\t' ) break; - - while(pos<length) - { - while(pos<length && value[pos]!=' ' && value[pos]!='\t' && value[pos]!='\0') - { - outfile.write((char*)&(value[pos++]),sizeof(char)); - } - - outfile.write(&c,sizeof(char)); - pos++; - - while(pos<length && (value[pos]==' ' || value[pos]=='\t' || value[pos]=='\0') ) - { - pos++; - } - } -} -/*==========================================================*/ -void UbFileOutputBinary::writeStringOnly(const string& value) -{ - UbException(UB_EXARGS,"no way... causes to many errors"); -} -/*==========================================================*/ -void UbFileOutputBinary::writeLine(const std::string& value, const int& width) -{ - this->writeString(value); - char c='\n'; - outfile.write(&c,sizeof(char)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeLine() -{ - char c='\n'; - outfile.write(&c,sizeof(char)); -} -/*==========================================================*/ -void UbFileOutputBinary::writeCommentLine(const string& line) -{ - try { this->writeCommentLine(this->commentindicator, line); } - catch(...) { throw UbException(UB_EXARGS,"unknown error"); } -} -/*==========================================================*/ -void UbFileOutputBinary::writeCommentLine(char indicator, const string& line) -{ - string dummy = indicator + line; - this->writeLine(dummy); -} -/*==========================================================*/ -void UbFileOutputBinary::writeCopyOfFile(const string& filename) -{ - ifstream infile(filename.c_str(),ios::in | ios::binary); - if(!infile) throw UbException(UB_EXARGS,"couldn't open file:\n "+filename); - - try - { - char c; - while(infile.get(c)) - { - outfile.put(c); //=out<<c; - } - outfile.flush(); - infile.close(); - } - catch(...) {throw UbException(UB_EXARGS,"unknown error");} -} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.h b/src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.h deleted file mode 100644 index cea0bcdbc..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbFileOutputBinary.h +++ /dev/null @@ -1,72 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUTBINARY_H -#define UBFILEOUTPUTBINARY_H - -#include <iomanip> -#include <fstream> -#include <iostream> - - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileOutput.h> - -/*=========================================================================*/ -/* UbFileOutputBinary */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class UbFileOutputBinary : public UbFileOutput -{ -public: - UbFileOutputBinary() : UbFileOutput() {} - UbFileOutputBinary(const std::string& filename, const bool& createPath=true); - UbFileOutputBinary(const std::string& filename, UbFileOutput::CREATEOPTION opt, const bool& createPath); - - bool open(const std::string& filename, UbFileOutput::CREATEOPTION opt=OUTFILE); - - void writeInteger(const int& value, const int& width=0); - void writeLong(const long& value, const int& width=0); - void writeLongLong(const long long& value, const int& width=0); - void writeDouble(const double& value, const int& width=0); - void writeFloat(const float& value, const int& width=0); - void writeBool(const bool& value, const int& width=0); - void writeChar(const char& value, const int& width=0); - void writeSize_t(const std::size_t& value, const int& width=0); - void writeString(const std::string& value, const int& width=0); - void writeStringOnly(const std::string& value); - void writeLine(const std::string& value, const int& width=0); - void writeLine(); - void writeCommentLine(const std::string& line); - void writeCommentLine(char indicator, const std::string& line); - void writeCopyOfFile(const std::string& filename); - - void setPrecision(const int& precision); - int getPrecision(); - - FILETYPE getFileType() { return BINARY; } - - template< typename T > - friend inline UbFileOutputBinary& operator<<(UbFileOutputBinary& file, const T& data) - { - file.outfile.write((char*)&data,sizeof(T)); - return file; - } -}; - -#endif - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbInfinity.h b/src/VirtualFluids_GPU/basics/utilities/UbInfinity.h deleted file mode 100644 index 5c889c894..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbInfinity.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef UB_INFINITY_H -#define UB_INFINITY_H -#include <limits> - -#include <basics/utilities/UbLimits.h> -#include <basics/utilities/UbSystem.h> - - -////////////////////////////////////////////////////////////////////////// -// -// UbNegInfinity -// Anm: keine template klasse, da man am Ende eine Instanz "inf" verwendet -// die in "verschiedene"(!!!) Typen konvertiert werden kann und nicht -// nur in den template Typ! -// Note: The UbNegInfinity class cannot be instantiated on its own, but works -// as a base class for the Infinity class. -////////////////////////////////////////////////////////////////////////// -class UbNegInfinity -{ - public: - //name Conversion operators - inline operator signed char() const { return UbLimits<signed char>::ninf(); } - inline operator char() const { return UbLimits<char>::ninf(); } - inline operator wchar_t() const { return UbLimits<wchar_t>::ninf(); } - inline operator short() const { return UbLimits<short>::ninf(); } - inline operator int() const { return UbLimits<int>::ninf(); } - inline operator long() const { return UbLimits<long>::ninf(); } - inline operator float() const { return UbLimits<float>::ninf(); } - inline operator double() const { return UbLimits<double>::ninf(); } - inline operator long double() const { return UbLimits<long double>::ninf(); } - - // This function compares built-in data types with their largest possible value. The function - // only works for built-in data types. The attempt to compare user-defined class types will - // result in a compile time error. - template< typename T > - inline bool equal( const T& rhs ) const - { - UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized ); - return UbLimits<T>::ninf() == rhs; - } - protected: - inline UbNegInfinity() {} - - private: - UbNegInfinity( const UbNegInfinity& ninf ); //copy constructor (private & undefined) - UbNegInfinity& operator=( const UbNegInfinity& ninf ); //copy assignment operator (private & undefined) - void* operator&() const; //address operator (private & undefined) -}; - -//================================================================================================= -// -// GLOBAL OPERATORS -// -//================================================================================================= -template< typename T > -inline bool operator==( const UbNegInfinity& lhs, const T& rhs ) -{ - return lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator==( const T& lhs, const UbNegInfinity& rhs ) -{ - return rhs.equal( lhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const UbNegInfinity& lhs, const T& rhs ) -{ - return !lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const T& lhs, const UbNegInfinity& rhs ) -{ - return !rhs.equal( lhs ); -} - -////////////////////////////////////////////////////////////////////////// -// -// UbInfinity -// -////////////////////////////////////////////////////////////////////////// -class UbInfinity : public UbNegInfinity //um später -UbInfinity leichter zu implementieren!!! -{ - public: - inline UbInfinity() - : UbNegInfinity() - {} - - inline operator unsigned char() const { return UbLimits<unsigned char>::inf(); } - inline operator signed char() const { return UbLimits<signed char>::inf(); } - inline operator char() const { return UbLimits<char>::inf(); } - inline operator wchar_t() const { return UbLimits<wchar_t>::inf(); } - inline operator unsigned short() const { return UbLimits<unsigned short>::inf(); } - inline operator short() const { return UbLimits<short>::inf(); } - inline operator unsigned int() const { return UbLimits<unsigned int>::inf(); } - inline operator int() const { return UbLimits<int>::inf(); } - inline operator unsigned long() const { return UbLimits<unsigned long>::inf(); } - inline operator long() const { return UbLimits<long>::inf(); } - inline operator float() const { return UbLimits<float>::inf(); } - inline operator double() const { return UbLimits<double>::inf(); } - inline operator long double() const { return UbLimits<long double>::inf(); } - - inline const UbNegInfinity& operator-() const { return static_cast<const UbNegInfinity&>( *this ); } - - /*==========================================================*/ - template< typename T > - inline bool equal( const T& rhs ) const - { - UB_STATIC_ASSERT( std::numeric_limits<T>::is_specialized ); - return UbLimits<T>::inf() == rhs; - } - - private: - UbInfinity( const UbInfinity& inf ); //Copy constructor (private & undefined) - UbInfinity& operator=( const UbInfinity& inf ); //Copy assignment operator (private & undefined) - void* operator&() const; //Address operator (private & undefined) -}; - -////////////////////////////////////////////////////////////////////////// -// GLOBAL OPERATORS -////////////////////////////////////////////////////////////////////////// -template< typename T > -inline bool operator==( const UbInfinity& lhs, const T& rhs ); - -template< typename T > -inline bool operator==( const T& lhs, const UbInfinity& rhs ); - -template< typename T > -inline bool operator!=( const UbInfinity& lhs, const T& rhs ); - -template< typename T > -inline bool operator!=( const T& lhs, const UbInfinity& rhs ); -//@} -//************************************************************************************************* - - -//************************************************************************************************* -/*!\brief Equality comparison between an Infinity object and a built-in data type. -// \ingroup util -// -// This operator works only for built-in data types. The attempt to compare user-defined class -// types will result in a compile time error. -*/ -template< typename T > -inline bool operator==( const UbInfinity& lhs, const T& rhs ) -{ - return lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator==( const T& lhs, const UbInfinity& rhs ) -{ - return rhs.equal( lhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const UbInfinity& lhs, const T& rhs ) -{ - return !lhs.equal( rhs ); -} -//************************************************************************************************* -template< typename T > -inline bool operator!=( const T& lhs, const UbInfinity& rhs ) -{ - return !rhs.equal( lhs ); -} -//************************************************************************************************* - -////////////////////////////////////////////////////////////////////////// -// GLOBAL INFINITY VALUE -////////////////////////////////////////////////////////////////////////// -namespace Ub -{ - //e.g. double x = UbSystem::inf; float x = -Ub::inf; - const UbInfinity inf; -} - -#endif //UB_INFINITY_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbKeys.h b/src/VirtualFluids_GPU/basics/utilities/UbKeys.h deleted file mode 100644 index 9e5b6fd50..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbKeys.h +++ /dev/null @@ -1,294 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBKEYS_H -#define UBKEYS_H - -#include <iostream> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -/*=========================================================================*/ -/* UbKeys */ -/* */ -/** -namespace for global Keys (e.g. for STL-maps) -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.08.07 -*/ - -/* -usage: ... -*/ - -namespace UbKeys -{ - //nested class - template< typename T1, typename T2 = T1 > - class Key2 - { - public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - Key2(const T1& t1, const T2& t2) - : t1(t1), t2(t2) - { - } - /*==========================================================*/ - Key2& operator=(const Key2& srcKey) - { - if(this == &srcKey ) return *this; - - t1 = srcKey.t1; - t2 = srcKey.t2; - - return *this; - } - /*==========================================================*/ - T1 getT1() const { return t1; } - T2 getT2() const { return t2; } - - //for hash_maps - inline operator std::size_t() const { return ( (t1 & 0x00007FFF) - | ( (t2 & 0x00007FFF) << 15 ) ); } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const Key2& lhsKey,const Key2& rhsKey) - { - if( lhsKey.t1 < rhsKey.t1 ) return true; - if( lhsKey.t1 > rhsKey.t1 ) return false; - if( lhsKey.t2 < rhsKey.t2 ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const Key2& lhsKey, const Key2& rhsKey) - { - if(lhsKey.t1 != rhsKey.t1 ) return false; - if(lhsKey.t2 != rhsKey.t2 ) return false; - - return true; - } - //ueberladene Operatoren - friend inline bool operator!=(const Key2& lhsKey, const Key2& rhsKey) - { - return !(lhsKey == rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const Key2& key) - { - os<<"Key2<"<<typeid(T1).name()<<","<<typeid(T2).name()<<">,("<<key.t1<<","<<key.t2<<")"; - return os; - } - /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & t1; - ar & t2; - } - #endif //CAB_RCF - - private: - ////////////////////////////////////////////////////////////////////////// - //private Member - T1 t1; - T2 t2; - }; - - ////////////////////////////////////////////////////////////////////////// - // - ////////////////////////////////////////////////////////////////////////// - template< typename T1, typename T2 = T1, typename T3 = T1 > - class Key3 - { - public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - Key3(const T1& t1, const T2& t2, const T3& t3) - : t1(t1), t2(t2), t3(t3) - { - } - /*==========================================================*/ - T1 getT1() const { return t1; } - T2 getT2() const { return t2; } - T3 getT3() const { return t3; } - /*==========================================================*/ - Key3& operator=(const Key3& srcKey) - { - if(this == &srcKey ) return *this; - - t1 = srcKey.t1; - t2 = srcKey.t2; - t3 = srcKey.t3; - - return *this; - } - - //for hash_maps - inline operator std::size_t() const { return ( ( t1 & 0x000003FF ) - | ( ( t2 & 0x000003FF ) << 10 ) - | ( ( t3 & 0x000003FF ) << 20 ) ); } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const Key3& lhsKey,const Key3& rhsKey) - { - if( lhsKey.t1 < rhsKey.t1 ) return true; - if( lhsKey.t1 > rhsKey.t1 ) return false; - if( lhsKey.t2 < rhsKey.t2 ) return true; - if( lhsKey.t2 > rhsKey.t2 ) return false; - if( lhsKey.t3 < rhsKey.t3 ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const Key3& lhsKey,const Key3& rhsKey) - { - if(lhsKey.t1 != rhsKey.t1 ) return false; - if(lhsKey.t2 != rhsKey.t2 ) return false; - if(lhsKey.t3 != rhsKey.t3 ) return false; - - return true; - } - /*==========================================================*/ - //ueberladene Operatoren - friend inline bool operator!=(const Key3& lhsKey, const Key3& rhsKey) - { - return !(lhsKey == rhsKey); - } - - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const Key3& key) - { - os<<"Key3<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name(); - os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<")"; - return os; - } - /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & t1; - ar & t2; - ar & t3; - } - #endif //CAB_RCF - - private: - ////////////////////////////////////////////////////////////////////////// - //private Member - T1 t1; - T2 t2; - T3 t3; - }; - - ////////////////////////////////////////////////////////////////////////// - // - ////////////////////////////////////////////////////////////////////////// - template< typename T1, typename T2 = T1, typename T3 = T1, typename T4 = T1 > - class Key4 - { - public: - ////////////////////////////////////////////////////////////////////////// - //Konstruktoren - Key4(const T1& t1, const T2& t2, const T3& t3, const T4& t4) - : t1(t1), t2(t2), t3(t3), t4(t4) - { - } - /*==========================================================*/ - T1 getT1() const { return t1; } - T2 getT2() const { return t2; } - T3 getT3() const { return t3; } - T4 getT4() const { return t4; } - /*==========================================================*/ - Key4& operator=(const Key4& srcKey) - { - if(this == &srcKey ) return *this; - - t1 = srcKey.t1; - t2 = srcKey.t2; - t3 = srcKey.t3; - t4 = srcKey.t4; - - return *this; - } - - //for hash_maps - inline operator std::size_t() const { return ( ( t1 & 0x000003FF ) - | ( ( t2 & 0x000003FF ) << 8 ) - | ( ( t3 & 0x000003FF ) << 8) - | ( ( t4 & 0x000003FF ) << 8 ) ); } - - ////////////////////////////////////////////////////////////////////////// - //global ueberladene Operatoren - friend inline bool operator<(const Key4& lhsKey,const Key4& rhsKey) - { - if( lhsKey.t1 < rhsKey.t1 ) return true; - if( lhsKey.t1 > rhsKey.t1 ) return false; - if( lhsKey.t2 < rhsKey.t2 ) return true; - if( lhsKey.t2 > rhsKey.t2 ) return false; - if( lhsKey.t3 < rhsKey.t3 ) return true; - if( lhsKey.t3 > rhsKey.t3 ) return false; - if( lhsKey.t4 < rhsKey.t4 ) return true; - - return false; - } - /*==========================================================*/ - friend inline bool operator==(const Key4& lhsKey,const Key4& rhsKey) - { - if(lhsKey.t1 != rhsKey.t1 ) return false; - if(lhsKey.t2 != rhsKey.t2 ) return false; - if(lhsKey.t3 != rhsKey.t3 ) return false; - if(lhsKey.t4 != rhsKey.t4 ) return false; - - return true; - } - - //ueberladene Operatoren - friend inline bool operator!=(const Key4& lhsKey, const Key4& rhsKey) - { - return !(lhsKey == rhsKey); - } - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const Key4& key) - { - os<<"Key4<"<<typeid(T1).name()<<","<<typeid(T2).name()<<","<<typeid(T3).name()<<","<<typeid(T4).name(); - os<<">,("<<key.t1<<","<<key.t2<<","<<key.t3<<","<<key.t4<<")"; - return os; - } - /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & t1; - ar & t2; - ar & t3; - ar & t4; - } - #endif //CAB_RCF - - private: - ////////////////////////////////////////////////////////////////////////// - //private Member - T1 t1; - T2 t2; - T3 t3; - T4 t4; - }; -} - -#endif //UBKEYS_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbLimits.h b/src/VirtualFluids_GPU/basics/utilities/UbLimits.h deleted file mode 100644 index a1aeb550c..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbLimits.h +++ /dev/null @@ -1,141 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UB_LIMITS_H -#define UB_LIMITS_H - -#define NOMINMAX -#undef max -#undef min -//************************************************************************************************* -// Includes -//************************************************************************************************* - -#include <limits> - -////////////////////////////////////////////////////////////////////////// -// CLASS DEFINITION -////////////////////////////////////////////////////////////////////////// -template< typename T > -struct UbLimits {}; - -////////////////////////////////////////////////////////////////////////// -// SPECIALIZATIONS -////////////////////////////////////////////////////////////////////////// -template<> -struct UbLimits<unsigned char> -{ - //return the largest possible positive unsigned char value - static inline unsigned char inf() { return std::numeric_limits<unsigned char>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<char> -{ - //return the largest possible positive char value. */ - static inline char inf () { return std::numeric_limits<char>::max(); } - //return the largest possible negative char value - static inline char ninf() { return std::numeric_limits<char>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<signed char> -{ - //return the largest possible positive signed char value - static inline signed char inf () { return std::numeric_limits<signed char>::max(); } - - //return The largest possible negative signed char value - static inline signed char ninf() { return std::numeric_limits<signed char>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<wchar_t> -{ - //return The largest possible positive wchar_t value - static inline wchar_t inf () { return std::numeric_limits<wchar_t>::max(); } - //return The largest possible negative wchar_t value - static inline wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<unsigned short> -{ - //return The largest possible positive unsigned short value - static inline unsigned short inf() { return std::numeric_limits<unsigned short>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<short> -{ - //return The largest possible positive short value - static inline short inf () { return std::numeric_limits<short>::max(); } - //return The largest possible negative short value - static inline short ninf() { return std::numeric_limits<short>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<unsigned int> -{ - //return The largest possible positive unsigned int value - static inline unsigned int inf() { return std::numeric_limits<unsigned int>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<int> -{ - //return The largest possible positive int value - static inline int inf () { return std::numeric_limits<int>::max(); } - - //return The largest possible negative int value - static inline int ninf() { return std::numeric_limits<int>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<unsigned long> -{ - //return The largest possible positive unsigned long value - static inline unsigned long inf() { return std::numeric_limits<unsigned long>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<long> -{ - //return The largest possible positive long value - static inline long inf () { return std::numeric_limits<long>::max(); } - - //return The largest possible negative long value - static inline long ninf() { return std::numeric_limits<long>::min(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<float> -{ - //return The largest possible positive float value - static inline float inf () { return std::numeric_limits<float>::max(); } - - //return The largest possible negative float value - static inline float ninf() { return -std::numeric_limits<float>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<double> -{ - //return The largest possible positive double value - static inline double inf () { return std::numeric_limits<double>::max(); } - //return The largest possible negative double value - static inline double ninf() { return -std::numeric_limits<double>::max(); } -}; -//************************************************************************************************* -template<> -struct UbLimits<long double> -{ - //return The largest possible positive long double value - static inline long double inf () { return std::numeric_limits<long double>::max(); } - //return The largest possible negative long double value - static inline long double ninf() { return -std::numeric_limits<long double>::max(); } -}; - -#endif //UB_LIMITS_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbLogger.cpp b/src/VirtualFluids_GPU/basics/utilities/UbLogger.cpp deleted file mode 100644 index 3c433a130..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbLogger.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include <basics/utilities/UbLogger.h> - -#if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING) - -boost::mutex Output2Stream::mtx; - -#endif // CAB_BOOST - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbLogger.h b/src/VirtualFluids_GPU/basics/utilities/UbLogger.h deleted file mode 100644 index 0373c7ced..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbLogger.h +++ /dev/null @@ -1,360 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBLOGGER_H -#define UBLOGGER_H - -#include <sstream> -#include <string> -#include <iostream> -#include <fstream> -#include <iomanip> -#include <memory> - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) - #include <windows.h> -#else - #include <sys/time.h> -#endif - -#if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING) - #include <boost/thread.hpp> -#endif // CAB_BOOST && !NO_THREADSAFE_LOGGING - -////////////////////////////////////////////////////////////////////////// -// UbLogger -// C++ Logger -// Funktionsweise: -// pro Logeintrag wird ein UbLogger-Objekt erstellt, der logstring uebergeben und beim "zerstroeren" -// wird der logstring mittels der entsprechenden policy (=template paramter) z.B. in eine Datei -// oder auf dem Bildschirm ausgegeben. Es werden verschiedene LogLevel unterstuetzt -// -// Hilfsmakro: UBLOG -// Bsp1: UBLOG(logINFO) << "Klasse::foo entered"; //endl wir nicht benötigt -// --> Eintrag: -// -// Bsp2: siehe Dateiende! -// -//Idee basierend auf: -//Artikel von Dr. Dobbs Portal -//September 05, 2007 -//Logging In C++ -// -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@version 1.0 - 12.10.2008 - -enum LogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5}; - -////////////////////////////////////////////////////////////////////////// -// template <typename OutputPolicy> class Log - declaration -////////////////////////////////////////////////////////////////////////// -template <typename OutputPolicy> -class UbLogger -{ -public: - typedef OutputPolicy output_policy; -public: - UbLogger(); - virtual ~UbLogger(); - std::ostringstream& get(const LogLevel& level = logINFO); -public: - //static, weil man so später die ObjErstellunge ersparen kann, - //falls level kleiner als Level - static LogLevel& reportingLevel(); - static void setReportingLevel(const LogLevel& level) { UbLogger::reportingLevel()=level; } - - static std::string logLevelToString(const LogLevel& level); - static LogLevel logLevelFromString(const std::string& level); - - static std::string logTimeString(); - -protected: - std::ostringstream os; - -private: - UbLogger(const UbLogger&); - UbLogger& operator =(const UbLogger&); -}; - -////////////////////////////////////////////////////////////////////////// -// template <typename OutputPolicy> class Log - implementation -////////////////////////////////////////////////////////////////////////// -template <typename OutputPolicy> -UbLogger<OutputPolicy>::UbLogger() -{ -} -/*==========================================================*/ -template <typename OutputPolicy> -std::ostringstream& UbLogger<OutputPolicy>::get(const LogLevel& level) -{ - os << logTimeString() << " " - << std::setw(8) << std::left << UbLogger<OutputPolicy>::logLevelToString(level) << ": " - << std::string(level > logDEBUG ? 3*(level - logDEBUG) : 0, ' '); //<baumartiger output :D - - return os; -} -/*==========================================================*/ -template <typename OutputPolicy> -UbLogger<OutputPolicy>::~UbLogger() -{ - os << std::endl; - OutputPolicy::output(os.str()); -} -/*==========================================================*/ -template <typename OutputPolicy> -LogLevel& UbLogger<OutputPolicy>::reportingLevel() -{ - static LogLevel reportLevel = logINFO; - return reportLevel; -} -/*==========================================================*/ -template <typename OutputPolicy> -std::string UbLogger<OutputPolicy>::logLevelToString(const LogLevel& level) -{ - static std::string const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4", "DEBUG5"}; - return buffer[level]; -} -/*==========================================================*/ -template <typename OutputPolicy> -LogLevel UbLogger<OutputPolicy>::logLevelFromString(const std::string& level) -{ - if (level == "DEBUG5" ) return logDEBUG5; - if (level == "DEBUG4" ) return logDEBUG4; - if (level == "DEBUG3" ) return logDEBUG3; - if (level == "DEBUG2" ) return logDEBUG2; - if (level == "DEBUG1" ) return logDEBUG1; - if (level == "DEBUG" ) return logDEBUG; - if (level == "INFO" ) return logINFO; - if (level == "WARNING") return logWARNING; - if (level == "ERROR" ) return logERROR; - - UbLogger<OutputPolicy>().get(logWARNING) << "UbLogger<OutputPolicy>::logLevelFromString(level) - unknown logging level '" << level << "'. Using INFO level as default."; - return logINFO; -} - -////////////////////////////////////////////////////////////////////////// -// logTimeString -////////////////////////////////////////////////////////////////////////// -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) -template <typename OutputPolicy> -inline std::string UbLogger<OutputPolicy>::logTimeString() -{ - const int MAX_LEN = 200; - char buffer[MAX_LEN]; - if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0, "HH':'mm':'ss", buffer, MAX_LEN) == 0 ) - { - return "Error in std::string UbLogger<OutputPolicy>::logTimeString()"; - } - - char result[100] = {0}; - static DWORD first = GetTickCount(); - std::sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000); - return result; -} -#else -template <typename OutputPolicy> -inline std::string UbLogger<OutputPolicy>::logTimeString() -{ - char buffer[11]; - time_t t; - time(&t); - tm r = {0}; - strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r)); - struct timeval tv; - gettimeofday(&tv, 0); - char result[100] = {0}; - std::sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000); - return result; -} -#endif - - -////////////////////////////////////////////////////////////////////////// -// Output2Stream (=implementation of OutputPolicy) -////////////////////////////////////////////////////////////////////////// -//Anm: die erste Version mit auto_ptr fuer den stream fuehrte zu -// exceptions bei Verwedung vom Logger in dtors stat. globaler -// Objekte. Aber auch die Pointer-Lsg. ist noch nicht die -// optimale Lösung -class Output2Stream // implementation of OutputPolicy -{ -public: - static std::ostream*& getStream(); - static void output(const std::string& msg); - - //creates output-file-stream (of file opening fails -> stream is set to std::cerr) - static void setStream(const std::string& filename); - - //direct set outputstream, gcControl = true -> object will be deleted by Output2Stream - static void setStream(std::ostream* pStream, const bool& gcControl = false); - -protected: -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - static boost::mutex mtx; -#endif -}; -/*==========================================================*/ -inline std::ostream*& Output2Stream::getStream() -{ - static std::ostream* pStream = &std::clog; - return pStream; -} -/*==========================================================*/ -inline void Output2Stream::setStream(std::ostream* pFile, const bool& gcControl) -{ -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - boost::mutex::scoped_lock lock(mtx); -#endif - static bool s_gcControl = false; - - if( s_gcControl && Output2Stream::getStream() ) - { - delete Output2Stream::getStream(); - } - - s_gcControl = gcControl; - - Output2Stream::getStream() = pFile; -} -/*==========================================================*/ -inline void Output2Stream::setStream(const std::string& filename) -{ - std::ofstream* file = new std::ofstream( filename.c_str() ); - if( !(*file) ) - { - delete file; - Output2Stream::setStream(&std::cerr, false); - UbLogger<Output2Stream>().get(logERROR) << " Output2Stream::setStream(const std::string& filename) could not open file " - << filename << " -> std::cerr is used instead " << std::endl; - return; - } - std::cout<<"UbLog writes to "<<filename<<std::endl; - Output2Stream::setStream(file,true); -} -/*==========================================================*/ -inline void Output2Stream::output(const std::string& msg) -{ -#if defined(CAB_BOOST) && !defined(NO_MT_LOGGING) - boost::mutex::scoped_lock lock(mtx); -#endif - std::ostream* pStream = getStream(); - if (!pStream) return; - (*pStream) << msg << std::flush; -} - -////////////////////////////////////////////////////////////////////////// -// UbLog -////////////////////////////////////////////////////////////////////////// -class UbLog : public UbLogger< Output2Stream > -{ -public: - typedef Output2Stream output_policy; -}; - -//Makro um compilerseitig maxLevel zu beschränken -#ifndef UBLOG_MAX_LEVEL - #define UBLOG_MAX_LEVEL logDEBUG5 -#endif - -////////////////////////////////////////////////////////////////////////// -//Hauptmakro fuers Loggen -// example UBLOG(logINFO) << "das ist ein log eintrag"; -////////////////////////////////////////////////////////////////////////// -#define UBLOG(level, logtext) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else UbLog().get(level) << logtext; - -//wieso dieses Macro (was der der scheaeaeaesss???) -// z.B. UBLOG(logDEBUG2) << "Ich bin sooo toll " << username; -//also, was macht der praeprozessor draus?: -// if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; -// else // Log().Get(logINFO) << "Ich bin sooo toll " << username; -//Ergo: das prinzip des logging beruht auf: Log-Objekt erstellen und rauschreiben beim zerstoeren -// -> ist der zu loggende Level < als der im UBLOG angegebene erspart man sich hier die -// Objekt erstellung -> optimale Performance -> laut Petru Marginean (dem Verfasser des -// Ursprungslogger ist der Performance Unterschied kaum messbar, wenn NICHT geloggt wird! - -////////////////////////////////////////////////////////////////////////// -//makro 2 fuer korrekten MultiLineOutput (teuer!!) -// example1: UBLOGML(logINFO, "line1"<<endl<<"line2"<<endl<<"line3" ) -// example2: UBLOGML(logINFO, "line1\nline2\nendl\nline3" ) -////////////////////////////////////////////////////////////////////////// -#define UBLOGML(level, multiline) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else \ - { \ - std::ostringstream output; \ - output << multiline; \ - std::istringstream input( output.str() ); \ - while(!input.eof()) \ - { \ - std::string dummy; \ - getline(input,dummy,'\n'); \ - UbLog().get(level) << dummy; \ - } \ - } -////////////////////////////////////////////////////////////////////////// -//makro3, falls auch bildschirmausgabe erwünscht -// -> es wird sowohl ins logfile als auch auf den "stream" geschrieben -// wenn reporting level und level passen :D -//example1: UBLOG2ML(logINFO, std::cout, "line1"<<endl<<"line2"<<endl<<"line3" ) -//example2: UBLOG2ML(logINFO, std::cout, "line1\nline2\nendl\nline3" ) -////////////////////////////////////////////////////////////////////////// -#define UBLOG2(level, stream, text ) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else { stream << text <<std::endl; UbLog().get(level) << text; } - -////////////////////////////////////////////////////////////////////////// -//makro4, wie 3 nur mit multiline -//example: UBLOG2(logINFO, std::cout, "test" ) -////////////////////////////////////////////////////////////////////////// -#define UBLOG2ML(level, stream, multiline ) \ - if(level > UBLOG_MAX_LEVEL || level > UbLog::reportingLevel() || !Output2Stream::getStream()) ; \ - else \ - { \ - stream << multiline << std::endl; \ - std::ostringstream output; \ - output << multiline; \ - std::istringstream input( output.str() ); \ - while(!input.eof()) \ - { \ - std::string dummy; \ - getline(input,dummy,'\n'); \ - UbLog().get(level) << dummy; \ - } \ - } - -////////////////////////////////////////////////////////////////////////// -// example 2 -////////////////////////////////////////////////////////////////////////// -// try -// { -// UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG3"); -// //UbLog::output_policy::setStream(&std::cerr); //<- clog ist stdandard -// UbLog::output_policy::setStream("c:/temp/out.txt"); //kann man diese nicht oeffnen -> fehlermeldung -> Log wird in cerr ausgegben -// -// int count = 3; -// UBLOG(logINFO, "A loop with " << count << " iterations"); -// for (int i = 0; i != count; ++i) -// { -// UBLOG(logERROR , "error - the counter i = " << i ); -// UBLOG(logDEBUG1, "debug1 - the counter i = " << i ); -// UBLOG(logDEBUG2, "debug2 - the counter i = " << i ); -// UBLOG(logDEBUG3, "debug3 - the counter i = " << i ); -// //fuer MultiLine Eintraege: --> koerrekte formatierung im logfile -// UBLOGML(logDEBUG3, "debug3 - the counter i = "<<endl<<" 2 zeile "<< "3. Zeile" << i); -// UBLOGML(logDEBUG3, "debug3 - the counter i = "<<endl<<" 2 zeile "<< "3. Zeile" << i); -// UBLOG2ML(logDEBUG3,std:cout,"debug3 - the counter i = "<<endl<<" 2 zeile "<< "3. Zeile" << i); -// } -// return 0; -// } -// catch(const std::exception& e) -// { -// UBLOG(logERROR) << e.what(); -// } - - -#endif //UBLOGGER_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbMath.cpp b/src/VirtualFluids_GPU/basics/utilities/UbMath.cpp deleted file mode 100644 index faaa0fe85..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbMath.cpp +++ /dev/null @@ -1,614 +0,0 @@ -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbInfinity.h> -#include <cstring> //for memcmp - -// namespace UbMath -// { -//double UbMath::EPSILON = 1.0E-10; -const double UbMath::PI = 4.0* std::atan(1.0); //3.1415926535897932384626433832795 -//} -namespace UbMath{ - -////////////////////////////////////////////////////////////////////////// -const Vector3D Vector3D::ZERO(0.0,0.0,0.0); -const Vector3D Vector3D::UNIT_X1(1.0,0.0,0.0); -const Vector3D Vector3D::UNIT_X2(0.0,1.0,0.0); -const Vector3D Vector3D::UNIT_X3(0.0,0.0,1.0); - -/*=======================================================*/ -Vector3D::Vector3D() -{ - m_afTuple[0] = 0.0; - m_afTuple[1] = 0.0; - m_afTuple[2] = 0.0; -} -/*=======================================================*/ -Vector3D::Vector3D(const double& fX, const double& fY, const double& fZ) -{ - m_afTuple[0] = fX; - m_afTuple[1] = fY; - m_afTuple[2] = fZ; -} -/*=======================================================*/ -Vector3D::Vector3D (const Vector3D& rkV) -{ - m_afTuple[0] = rkV.m_afTuple[0]; - m_afTuple[1] = rkV.m_afTuple[1]; - m_afTuple[2] = rkV.m_afTuple[2]; -} -/*=======================================================*/ -std::string Vector3D::toString() const -{ - std::stringstream os; - os<< "Vector3D["<<m_afTuple[0]<<","<<m_afTuple[1]<<","<<m_afTuple[2]<<"]"; - return os.str(); -} -/*=======================================================*/ -Vector3D::operator const double*() const -{ - return m_afTuple; -} -/*=======================================================*/ -Vector3D::operator double*() -{ - return m_afTuple; -} -/*=======================================================*/ -double Vector3D::operator[](const int& i) const -{ - assert( i >= 0 && i <= 2 ); - return m_afTuple[i]; -} -/*=======================================================*/ -double& Vector3D::operator[](const int& i) -{ - assert( i >= 0 && i <= 2 ); - return m_afTuple[i]; -} -/*=======================================================*/ -double Vector3D::X1() const -{ - return m_afTuple[0]; -} -/*=======================================================*/ -double& Vector3D::X1() -{ - return m_afTuple[0]; -} -/*=======================================================*/ -double Vector3D::X2() const -{ - return m_afTuple[1]; -} -/*=======================================================*/ -double& Vector3D::X2() -{ - return m_afTuple[1]; -} -/*=======================================================*/ -double Vector3D::X3() const -{ - return m_afTuple[2]; -} -/*=======================================================*/ -double& Vector3D::X3() -{ - return m_afTuple[2]; -} -/*=======================================================*/ -Vector3D& Vector3D::operator=(const Vector3D& rkV) -{ - m_afTuple[0] = rkV.m_afTuple[0]; - m_afTuple[1] = rkV.m_afTuple[1]; - m_afTuple[2] = rkV.m_afTuple[2]; - return *this; -} -/*=======================================================*/ -int Vector3D::CompareArrays(const Vector3D& rkV) const -{ - return memcmp(m_afTuple,rkV.m_afTuple,3*sizeof(double)); -} -/*=======================================================*/ -bool Vector3D::operator==(const Vector3D& rkV) const -{ - return CompareArrays(rkV) == 0; -} -/*=======================================================*/ -bool Vector3D::operator!=(const Vector3D& rkV) const -{ - return CompareArrays(rkV) != 0; -} -/*=======================================================*/ -bool Vector3D::operator<(const Vector3D& rkV) const -{ - return CompareArrays(rkV) < 0; -} -/*=======================================================*/ -bool Vector3D::operator<=(const Vector3D& rkV) const -{ - return CompareArrays(rkV) <= 0; -} -/*=======================================================*/ -bool Vector3D::operator> (const Vector3D& rkV) const -{ - return CompareArrays(rkV) > 0; -} -/*=======================================================*/ -bool Vector3D::operator>=(const Vector3D& rkV) const -{ - return CompareArrays(rkV) >= 0; -} -/*=======================================================*/ -Vector3D Vector3D::operator+(const Vector3D& rkV) const -{ - return Vector3D( m_afTuple[0]+rkV.m_afTuple[0], - m_afTuple[1]+rkV.m_afTuple[1], - m_afTuple[2]+rkV.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::Add(Vector3D& vector) -{ - return Vector3D( m_afTuple[0]+vector.m_afTuple[0], - m_afTuple[1]+vector.m_afTuple[1], - m_afTuple[2]+vector.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::operator- (const Vector3D& rkV) const -{ - return Vector3D( m_afTuple[0]-rkV.m_afTuple[0], - m_afTuple[1]-rkV.m_afTuple[1], - m_afTuple[2]-rkV.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::Subtract(Vector3D& vector) -{ - return Vector3D( m_afTuple[0]-vector.m_afTuple[0], - m_afTuple[1]-vector.m_afTuple[1], - m_afTuple[2]-vector.m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::operator*(const double& fScalar) const -{ - return Vector3D( fScalar*m_afTuple[0], - fScalar*m_afTuple[1], - fScalar*m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D Vector3D::operator/(const double& fScalar) const -{ - Vector3D kQuot; - - if ( fScalar != 0.0 ) - { - double fInvScalar = 1.0/fScalar; - kQuot.m_afTuple[0] = fInvScalar*m_afTuple[0]; - kQuot.m_afTuple[1] = fInvScalar*m_afTuple[1]; - kQuot.m_afTuple[2] = fInvScalar*m_afTuple[2]; - } - else - { - kQuot.m_afTuple[0] = Ub::inf; - kQuot.m_afTuple[1] = Ub::inf; - kQuot.m_afTuple[2] = Ub::inf; - } - - return kQuot; -} -/*=======================================================*/ -Vector3D Vector3D::operator-() const -{ - return Vector3D( -m_afTuple[0], - -m_afTuple[1], - -m_afTuple[2] ); -} -/*=======================================================*/ -Vector3D& Vector3D::operator+=(const Vector3D& rkV) -{ - m_afTuple[0] += rkV.m_afTuple[0]; - m_afTuple[1] += rkV.m_afTuple[1]; - m_afTuple[2] += rkV.m_afTuple[2]; - return *this; -} -/*=======================================================*/ -Vector3D& Vector3D::operator-=(const Vector3D& rkV) -{ - m_afTuple[0] -= rkV.m_afTuple[0]; - m_afTuple[1] -= rkV.m_afTuple[1]; - m_afTuple[2] -= rkV.m_afTuple[2]; - return *this; -} -/*=======================================================*/ -Vector3D& Vector3D::operator*=(const double& fScalar) -{ - m_afTuple[0] *= fScalar; - m_afTuple[1] *= fScalar; - m_afTuple[2] *= fScalar; - return *this; -} -/*=======================================================*/ -Vector3D& Vector3D::operator/=(const double& fScalar) -{ - if ( !zero(fScalar) ) - { - double fInvScalar = 1.0/fScalar; - m_afTuple[0] *= fInvScalar; - m_afTuple[1] *= fInvScalar; - m_afTuple[2] *= fInvScalar; - } - else - { - m_afTuple[0] = Ub::inf; - m_afTuple[1] = Ub::inf; - m_afTuple[2] = Ub::inf; - } - - return *this; -} -/*=======================================================*/ -Vector3D Vector3D::Scale(const double& x) -{ - Vector3D PointA(0.0,0.0,0.0); - PointA.m_afTuple[0] = x * m_afTuple[0]; - PointA.m_afTuple[1] = x * m_afTuple[1]; - PointA.m_afTuple[2] = x * m_afTuple[2]; - return PointA; -} -/*=======================================================*/ -double Vector3D::Length() const -{ - return std::sqrt( m_afTuple[0]*m_afTuple[0] + - m_afTuple[1]*m_afTuple[1] + - m_afTuple[2]*m_afTuple[2] ); -} -/*=======================================================*/ -double Vector3D::SquaredLength() const -{ - return m_afTuple[0]*m_afTuple[0] + - m_afTuple[1]*m_afTuple[1] + - m_afTuple[2]*m_afTuple[2]; -} -/*=======================================================*/ -double Vector3D::Dot(const Vector3D& rkV) const -{ - return m_afTuple[0]*rkV.m_afTuple[0] + - m_afTuple[1]*rkV.m_afTuple[1] + - m_afTuple[2]*rkV.m_afTuple[2]; -} -/*=======================================================*/ -double Vector3D::Normalize() -{ - double fLength = Length(); - - if( !zero(fLength) ) - { - double fInvLength = 1.0/fLength; - m_afTuple[0] *= fInvLength; - m_afTuple[1] *= fInvLength; - m_afTuple[2] *= fInvLength; - } - else - { - fLength = 0.0; - m_afTuple[0] = 0.0; - m_afTuple[1] = 0.0; - m_afTuple[2] = 0.0; - } - - return fLength; -} -/*=======================================================*/ -Vector3D Vector3D::Cross(const Vector3D& rkV) const -{ - return Vector3D( m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1], - m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2], - m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0] ); -} -/*=======================================================*/ -Vector3D Vector3D::UnitCross(const Vector3D& rkV) const -{ - Vector3D kCross( m_afTuple[1]*rkV.m_afTuple[2] - m_afTuple[2]*rkV.m_afTuple[1], - m_afTuple[2]*rkV.m_afTuple[0] - m_afTuple[0]*rkV.m_afTuple[2], - m_afTuple[0]*rkV.m_afTuple[1] - m_afTuple[1]*rkV.m_afTuple[0] ); - kCross.Normalize(); - return kCross; -} -/*=======================================================*/ -void Vector3D::GetBarycentrics(const Vector3D& rkV0,const Vector3D& rkV1, const Vector3D& rkV2,const Vector3D& rkV3, double afBary[4]) const -{ - // compute the vectors relative to V3 of the tetrahedron - Vector3D akDiff[4] = { rkV0 - rkV3, - rkV1 - rkV3, - rkV2 - rkV3, - *this - rkV3 }; - - // If the vertices have large magnitude, the linear system of - // equations for computing barycentric coordinates can be - // ill-conditioned. To avoid this, uniformly scale the tetrahedron - // edges to be of order 1. The scaling of all differences does not - // change the barycentric coordinates. - double fMax = 0.0,fValue=0.0; - for(int i=0; i<3; i++) - for (int j=0; j<3; j++) - { - fValue = std::fabs(akDiff[i][j]); - if ( fValue > fMax ) fMax = fValue; - } - - // scale down only large data - if( greater(fMax,1.0) ) - { - double fInvMax = ((double)1.0)/fMax; - for( int i=0; i<4; i++) - akDiff[i] *= fInvMax; - } - - double fDet = akDiff[0].Dot(akDiff[1].Cross(akDiff[2])); - Vector3D kE1cE2 = akDiff[1].Cross(akDiff[2]); - Vector3D kE2cE0 = akDiff[2].Cross(akDiff[0]); - Vector3D kE0cE1 = akDiff[0].Cross(akDiff[1]); - - if( !zero( fDet ) ) - { - double fInvDet = 1.0/fDet; - afBary[0] = akDiff[3].Dot(kE1cE2)*fInvDet; - afBary[1] = akDiff[3].Dot(kE2cE0)*fInvDet; - afBary[2] = akDiff[3].Dot(kE0cE1)*fInvDet; - afBary[3] = 1.0 - afBary[0] - afBary[1] - afBary[2]; - } - else - { - // The tetrahedron is potentially flat. Determine the face of - // maximum area and compute barycentric coordinates with respect - // to that face. - Vector3D kE02 = rkV0 - rkV2; - Vector3D kE12 = rkV1 - rkV2; - Vector3D kE02cE12 = kE02.Cross(kE12); - double fMaxSqrArea = kE02cE12.SquaredLength(); - int iMaxIndex = 3; - double fSqrArea = kE0cE1.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 0; - fMaxSqrArea = fSqrArea; - } - fSqrArea = kE1cE2.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 1; - fMaxSqrArea = fSqrArea; - } - fSqrArea = kE2cE0.SquaredLength(); - if ( fSqrArea > fMaxSqrArea ) - { - iMaxIndex = 2; - fMaxSqrArea = fSqrArea; - } - - if ( greater(fMaxSqrArea,0.0) ) - { - double fInvSqrArea = 1.0/fMaxSqrArea; - Vector3D kTmp; - if( iMaxIndex==0 ) - { - kTmp = akDiff[3].Cross(akDiff[1]); - afBary[0] = kE0cE1.Dot(kTmp)*fInvSqrArea; - kTmp = akDiff[0].Cross(akDiff[3]); - afBary[1] = kE0cE1.Dot(kTmp)*fInvSqrArea; - afBary[2] = 0.0; - afBary[3] = 1.0 - afBary[0] - afBary[1]; - } - else if( iMaxIndex == 1 ) - { - afBary[0] = 0.0; - kTmp = akDiff[3].Cross(akDiff[2]); - afBary[1] = kE1cE2.Dot(kTmp)*fInvSqrArea; - kTmp = akDiff[1].Cross(akDiff[3]); - afBary[2] = kE1cE2.Dot(kTmp)*fInvSqrArea; - afBary[3] = 1.0 - afBary[1] - afBary[2]; - } - else if( iMaxIndex == 2 ) - { - kTmp = akDiff[2].Cross(akDiff[3]); - afBary[0] = kE2cE0.Dot(kTmp)*fInvSqrArea; - afBary[1] = 0.0; - kTmp = akDiff[3].Cross(akDiff[0]); - afBary[2] = kE2cE0.Dot(kTmp)*fInvSqrArea; - afBary[3] = 1.0 - afBary[0] - afBary[2]; - } - else - { - akDiff[3] = *this - rkV2; - kTmp = akDiff[3].Cross(kE12); - afBary[0] = kE02cE12.Dot(kTmp)*fInvSqrArea; - kTmp = kE02.Cross(akDiff[3]); - afBary[1] = kE02cE12.Dot(kTmp)*fInvSqrArea; - afBary[2] = 1.0 - afBary[0] - afBary[1]; - afBary[3] = 0.0; - } - } - else - { - // The tetrahedron is potentially a sliver. Determine the edge of - // maximum length and compute barycentric coordinates with respect - // to that edge. - double fMaxSqrLength = akDiff[0].SquaredLength(); - iMaxIndex = 0; // <V0,V3> - double fSqrLength = akDiff[1].SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 1; // <V1,V3> - fMaxSqrLength = fSqrLength; - } - fSqrLength = akDiff[2].SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 2; // <V2,V3> - fMaxSqrLength = fSqrLength; - } - fSqrLength = kE02.SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 3; // <V0,V2> - fMaxSqrLength = fSqrLength; - } - fSqrLength = kE12.SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 4; // <V1,V2> - fMaxSqrLength = fSqrLength; - } - - Vector3D kE01 = rkV0 - rkV1; - fSqrLength = kE01.SquaredLength(); - - if( fSqrLength > fMaxSqrLength ) - { - iMaxIndex = 5; // <V0,V1> - fMaxSqrLength = fSqrLength; - } - - if( greater(fMaxSqrLength, 0.0) ) - { - double fInvSqrLength = 1.0/fMaxSqrLength; - if( iMaxIndex == 0 ) - { - // P-V3 = t*(V0-V3) - afBary[0] = akDiff[3].Dot(akDiff[0])*fInvSqrLength; - afBary[1] = 0.0; - afBary[2] = 0.0; - afBary[3] = 1.0 - afBary[0]; - } - else if( iMaxIndex == 1 ) - { - // P-V3 = t*(V1-V3) - afBary[0] = 0.0; - afBary[1] = akDiff[3].Dot(akDiff[1])*fInvSqrLength; - afBary[2] = 0.0; - afBary[3] = 1.0 - afBary[1]; - } - else if( iMaxIndex == 2 ) - { - // P-V3 = t*(V2-V3) - afBary[0] = 0.0; - afBary[1] = 0.0; - afBary[2] = akDiff[3].Dot(akDiff[2])*fInvSqrLength; - afBary[3] = 1.0 - afBary[2]; - } - else if( iMaxIndex == 3 ) - { - // P-V2 = t*(V0-V2) - akDiff[3] = *this - rkV2; - afBary[0] = akDiff[3].Dot(kE02)*fInvSqrLength; - afBary[1] = 0.0; - afBary[2] = 1.0 - afBary[0]; - afBary[3] = 0.0; - } - else if( iMaxIndex == 4 ) - { - // P-V2 = t*(V1-V2) - akDiff[3] = *this - rkV2; - afBary[0] = 0.0; - afBary[1] = akDiff[3].Dot(kE12)*fInvSqrLength; - afBary[2] = 1.0 - afBary[1]; - afBary[3] = 0.0; - } - else - { - // P-V1 = t*(V0-V1) - akDiff[3] = *this - rkV1; - afBary[0] = akDiff[3].Dot(kE01)*fInvSqrLength; - afBary[1] = 1.0 - afBary[0]; - afBary[2] = 0.0; - afBary[3] = 0.0; - } - } - else - { - // tetrahedron is a nearly a point, just return equal weights - afBary[0] = 0.25; - afBary[1] = afBary[0]; - afBary[2] = afBary[0]; - afBary[3] = afBary[0]; - } - } - } -} -/*=======================================================*/ -void Vector3D::Orthonormalize(Vector3D& rkU, Vector3D& rkV, Vector3D& rkW) -{ - // If the input vectors are v0, v1, and v2, then the Gram-Schmidt - // orthonormalization produces vectors u0, u1, and u2 as follows, - // - // u0 = v0/|v0| - // u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0| - // u2 = (v2-(u0*v2)u0-(u1*v2)u1)/|v2-(u0*v2)u0-(u1*v2)u1| - // - // where |A| indicates length of vector A and A*B indicates dot - // product of vectors A and B. - - // compute u0 - rkU.Normalize(); - - // compute u1 - double fDot0 = rkU.Dot(rkV); - rkV -= fDot0*rkU; - rkV.Normalize(); - - // compute u2 - double fDot1 = rkV.Dot(rkW); - fDot0 = rkU.Dot(rkW); - rkW -= fDot0*rkU + fDot1*rkV; - rkW.Normalize(); -} -/*=======================================================*/ -void Vector3D::Orthonormalize(Vector3D* akV) -{ - Orthonormalize(akV[0],akV[1],akV[2]); -} -/*=======================================================*/ -void Vector3D::GenerateOrthonormalBasis(Vector3D& rkU, Vector3D& rkV,Vector3D& rkW, bool bUnitLengthW) -{ - if ( !bUnitLengthW ) - rkW.Normalize(); - - double fInvLength; - - if ( greaterEqual( std::fabs(rkW.m_afTuple[0]),std::fabs(rkW.m_afTuple[1]) ) ) - { - // W.x or W.z is the largest magnitude component, swap them - fInvLength = UbMath::invSqrt(rkW.m_afTuple[0]*rkW.m_afTuple[0] + rkW.m_afTuple[2]*rkW.m_afTuple[2]); - rkU.m_afTuple[0] = -rkW.m_afTuple[2]*fInvLength; - rkU.m_afTuple[1] = (double)0.0; - rkU.m_afTuple[2] = +rkW.m_afTuple[0]*fInvLength; - } - else - { - // W.y or W.z is the largest magnitude component, swap them - fInvLength = UbMath::invSqrt(rkW.m_afTuple[1]*rkW.m_afTuple[1] + rkW.m_afTuple[2]*rkW.m_afTuple[2]); - rkU.m_afTuple[0] = (double)0.0; - rkU.m_afTuple[1] = +rkW.m_afTuple[2]*fInvLength; - rkU.m_afTuple[2] = -rkW.m_afTuple[1]*fInvLength; - } - - rkV = rkW.Cross(rkU); -} -/*=======================================================*/ -//globaler operator* -Vector3D operator*(const double& fScalar, const Vector3D& rkV) -{ - return Vector3D( fScalar*rkV[0], - fScalar*rkV[1], - fScalar*rkV[2] ); -} -/*=======================================================*/ -std::ostream& operator* (std::ostream& os, const Vector3D& rkV) -{ - os<<rkV.toString(); - return os; -} -} //end namespace UbMath - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbMath.h b/src/VirtualFluids_GPU/basics/utilities/UbMath.h deleted file mode 100644 index 6856fe8ac..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbMath.h +++ /dev/null @@ -1,543 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBMATH_H -#define UBMATH_H - -#include <cmath> -#include <limits> -#include <iostream> -#include <cassert> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbEqual.h> - -#define NOMINMAX -#undef max -#undef min -/*=========================================================================*/ -/* UbMath */ -/* */ -/** -namespace for global math-functions -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.4 - 04.10.07 -*/ - -/* -usage: ... -*/ - -namespace UbMath -{ - extern const double PI; - - - ////////////////////////////////////////////////////////////////////////// - //Hilfsfunktion fuer Genauigkeit - template< typename T > - struct Epsilon { }; - - ////////////////////////////////////////////////////////////////////////// - // SPECIALIZATIONS von Epsilon - ////////////////////////////////////////////////////////////////////////// - template<> - struct Epsilon<double> { static inline double val() { return 1.0E-11; } }; - template<> - struct Epsilon<float> { static inline float val() { return 1.0E-7f; } }; - template<> - struct Epsilon<long double> { static inline long double val() { return 1.0E-15; } }; - template<> - struct Epsilon<int> { static inline int val() { return 0; } }; - - /*=======================================================*/ - // ------------------------------------------------------------------------------------------------- - // Funktion berechnet den Logarithmus einer Zahl z bzgl. der Basis b - // ------------------------------------------------------------------------------------------------- - template<typename T> - inline T log(const T& z, const T& base) - { - if( ::log(base)==0 ) return 1.0f; - return ::log(z) / ::log(base); - } - /*=======================================================*/ - //double x = UbMath::getNegativeInfinity<double>(); - template<typename T> - inline T getNegativeInfinity() - { - //assert(std::numeric_limits<T>::has_infinity); - UB_STATIC_ASSERT(std::numeric_limits<T>::has_infinity); - return -std::numeric_limits<T>::infinity(); - } - /*=======================================================*/ - //double x = UbMath::getPositiveInfinity<double>(); - template<typename T> - inline T getPositiveInfinity() - { - //assert(std::numeric_limits<T>::has_infinity); - UB_STATIC_ASSERT(std::numeric_limits<T>::has_infinity); - return std::numeric_limits<T>::infinity(); - } - /*=======================================================*/ - //double x; bool b = UbMath::isInfinity(x); - template<typename T> - inline bool isInfinity(const T& value) - { - if(value==getNegativeInfinity<T>()) return true; - if(value==getPositiveInfinity<T>()) return true; - return false; - } - /*=======================================================*/ - //double x = UbMath::getNaN<double>(x); - template<typename T> - inline T getNaN() - { - UB_STATIC_ASSERT(std::numeric_limits<T>::has_quiet_NaN); - return std::numeric_limits<T>::quiet_NaN(); - } - /*=======================================================*/ - //double x; bool b = UbMath::isNaN(x); - // x!=x liefert bei #QNAN "true"! - template<typename T> - inline bool isNaN(const T& x) - { - UB_STATIC_ASSERT(std::numeric_limits<T>::has_quiet_NaN); - return (x != x); - } - /*=======================================================*/ - template<typename T> - inline T getEqualityEpsilon() - { - return Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool zero(const T& value) - { - return std::fabs( value ) < Epsilon<T>::val(); - //return value >= -UbMath::EPSILON && value <= UbMath::EPSILON; - } - /*=======================================================*/ - //spezialisierung fuer ints - template<> - inline bool zero(const int& value) - { - return value == 0; - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool zero(const T1& value1, const T2& value2) - { - return !(!UbMath::zero(value1) || !UbMath::zero(value2)); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool zero(const T1& value1, const T2& value2, const T3& value3) - { - return !(!UbMath::zero(value1) || !UbMath::zero(value2,value3)); - } - /*=======================================================*/ - template<typename T> - inline bool negative(const T& value) - { - return value < -Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool nonPositive(const T& value) - { - return value <= Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool positive(const T& value) - { - return value > +Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T> - inline bool nonNegative(const T& value) - { - return value >= -Epsilon<T>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool equal(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return std::fabs(value-reference) < Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool equal(const T1& val1, const T2& val2, const T3& val3) - { - return ( UbMath::equal(val1,val2) && UbMath::equal(val1,val3) ); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool less(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value < reference - Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool lessEqual(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value <= reference + Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool greater(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value > reference + Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T1, typename T2> - inline bool greaterEqual(const T1& value, const T2& reference) - { - typedef typename UbEqualTrait<T1,T2>::High High; - return value >= reference - Epsilon<High>::val(); - } - /*=======================================================*/ - template<typename T> - inline T round(const T& value, const int& decimalPlaces) - { - return static_cast<T>(floor(value * pow( 10.0, decimalPlaces) + 0.5 ) * pow(10.0, -decimalPlaces)); - } - /*=======================================================*/ - template<typename T> - inline int integerRounding(const T& value) - { - return static_cast<int>( UbMath::zero(value) ? 0 : ( (value<0.0) ? (value-0.5) : (value+0.5) ) ); - } - /*=======================================================*/ - template<typename T> - inline T getRad(const T& degrees) - { - return degrees*static_cast<T>(UbMath::PI/180.0); - } - /*=======================================================*/ - template<typename T> - inline T getDegrees(const T& rad) - { - return rad*static_cast<T>(UbMath::PI/180.0); - } - /*=======================================================*/ - //aus wildmagic - template<typename T> - inline T ACos (const T& fValue) - { - if ( -1.0 < fValue ) - { - if ( fValue < 1.0 ) return static_cast<T>( acos(fValue) ); - else return static_cast<T>( 0.0 ); - } - else return static_cast<T>( PI ); - } - /*=======================================================*/ - template<typename T> - inline T ASin(const T& fValue) - { - double HALF_PI = 0.5*UbMath::PI; - if ( -1.0 < fValue ) - { - if ( fValue < 1.0 ) return static_cast<T>( asin(fValue) ); - else return static_cast<T>( HALF_PI ); - } - else return -static_cast<T>( HALF_PI ); - } - /*=======================================================*/ - template<typename T> - inline T invSqrt(const T& fValue) - { - return static_cast<T>(1.0/sqrt(fValue)); - } - - /*=======================================================*/ - /** - * Returns true, if specified values a and b are less both values c and d. - * @param a the first value to check - * @param b the second value to check - * @param c the first value to check against - * @param d the second value to check against - * @return true, if specified values a and b are less both values c and d - **/ - template<typename T1, typename T2, typename T3, typename T4> - inline bool less2(const T1& value1, const T2& value2, T3 toBeLessAs1, T4 toBeLessAs2) - { - return ( less(value1,toBeLessAs1) - && less(value1,toBeLessAs2) - && less(value2,toBeLessAs1) - && less(value2,toBeLessAs2) ); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3, typename T4> - inline bool greater2(const T1& value1, const T2& value2, T3 toBeGreaterAs1, T4 toBeGreaterAs2) - { - return ( greater(value1,toBeGreaterAs1) - && greater(value1,toBeGreaterAs2) - && greater(value2,toBeGreaterAs1) - && greater(value2,toBeGreaterAs2) ); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool inClosedInterval(const T1& value, const T2& threshold1, const T3& threshold2) - { - if(threshold1 < threshold2) - { - return ( greaterEqual( value, threshold1) && lessEqual( value, threshold2) ); - } - - return ( greaterEqual( value, threshold2) && lessEqual( value, threshold1) ); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline bool inOpenInterval(const T1& value, const T2& threshold1, const T3& threshold2) - { - if(threshold1 < threshold2) - { - return (greater( value, threshold1) && less( value, threshold2)); - } - - return (greater( value, threshold2) && less( value, threshold1)); - } - /*=======================================================*/ - template<typename T1, typename T2, typename T3> - inline double adaptToClosedInterval(const T1& value, const T2& threshold1, const T3& threshold2) - { - if(threshold1 < threshold2) - { - if ( less( value, threshold1) ) return threshold1; - else if( greater(value, threshold2) ) return threshold2; - } - else - { - if ( less( value, threshold2) ) return threshold2; - else if( greater(value, threshold1) ) return threshold1; - } - return value; - } - /*=======================================================*/ - // ------------------------------------------------------------------------------------------------- - // Funktion berechnet den groessten gemeinsamen Teiler zweier Zahlen (MK) - // ------------------------------------------------------------------------------------------------- - /*=======================================================*/ - inline int calcGgt(int val1, int val2) - { - if( val1 < val2 ) std::swap(val1,val2); - int ggt=val2; - while(ggt > 1) - { - if( (val1%ggt)==0 && (val2%ggt)==0 ) break; - - ggt -=1; - } - return ggt; - } - /*=======================================================*/ - // ------------------------------------------------------------------------------------------------- - // Funktion berechnet den groessten gemeinsamen Teiler von drei Zahlen (MK) - // ------------------------------------------------------------------------------------------------- - inline int calcGgt(int val1, const int& val2, int val3) - { - return UbMath::calcGgt( UbMath::calcGgt(val1, val2), val3 ); - } - /*=======================================================*/ - //returns the max of two values - //to avoid errors at mixed argument-types use: double myMax = max<double>(2,2.3); - template< typename T > - inline const T& max(const T& a1, const T& a2) - { - return (a1<a2) ? a2 : a1; - } - /*=======================================================*/ - template< typename T > - inline const T& max(const T& a1, const T& a2, const T& a3) - { - return max(max(a1,a2),a3); - } - /*=======================================================*/ - template< typename T > - inline const T& max(const T& a1, const T& a2, const T& a3, const T& a4) - { - return max(max(max(a1,a2),a3),a4); - } - /*=======================================================*/ - template< typename T > - inline const T& min(const T& a1,const T& a2) - { - return (a1<a2) ? a1 : a2; - } - /*=======================================================*/ - template< typename T > - inline const T& min(const T& a1, const T& a2, const T& a3) - { - return min(min(a1,a2),a3); - } - /*=======================================================*/ - template< typename T > - inline const T& min(const T& a1, const T& a2, const T& a3, const T& a4) - { - return min(min(min(a1,a2),a3),a4); - -// double tmp = a1; -// if(tmp>a2) tmp=a2; -// if(tmp>a3) tmp=a3; -// if(tmp>a4) tmp=a4; -// return tmp; - } - /*=======================================================*/ - - class Vector3D - { - public: - // construction - Vector3D(); - Vector3D(const double& fX1, const double& fX2, const double& fX3); - Vector3D(const Vector3D& rkV); - - std::string toString() const; - - // coordinate access - operator const double*() const; - operator double*(); - double operator[](const int& i) const; - double& operator[](const int& i); - double X1() const; - double& X1(); - double X2() const; - double& X2(); - double X3() const; - double& X3(); - - // assignment - Vector3D& operator=(const Vector3D& rkV); - - // comparison - bool operator==(const Vector3D& rkV) const; - bool operator!=(const Vector3D& rkV) const; - bool operator< (const Vector3D& rkV) const; - bool operator<=(const Vector3D& rkV) const; - bool operator> (const Vector3D& rkV) const; - bool operator>=(const Vector3D& rkV) const; - - // arithmetic operations - Vector3D operator+(const Vector3D& rkV) const; - Vector3D operator-(const Vector3D& rkV) const; - Vector3D operator*(const double& fScalar) const; - Vector3D operator/(const double& fScalar) const; - Vector3D operator-() const; - - // arithmetic updates - Vector3D& operator+= (const Vector3D& rkV); - Vector3D& operator-= (const Vector3D& rkV); - Vector3D& operator*= (const double& fScalar); - Vector3D& operator/= (const double& fScalar); - - Vector3D Add(Vector3D& vector); - Vector3D Subtract(Vector3D& vector); - Vector3D Scale(const double& x); - - // vector operations - double Length () const; - double SquaredLength () const; - double Dot (const Vector3D& rkV) const; - double Normalize (); - - // The cross products are computed using the right-handed rule. Be aware - // that some graphics APIs use a left-handed rule. If you have to compute - // a cross product with these functions and send the result to the API - // that expects left-handed, you will need to change sign on the vector - // (replace each component value c by -c). - Vector3D Cross (const Vector3D& rkV) const; - Vector3D UnitCross (const Vector3D& rkV) const; - - // Compute the barycentric coordinates of the point with respect to the - // tetrahedron <V0,V1,V2,V3>, P = b0*V0 + b1*V1 + b2*V2 + b3*V3, where - // b0 + b1 + b2 + b3 = 1. - void GetBarycentrics (const Vector3D& rkV0, const Vector3D& rkV1, const Vector3D& rkV2, const Vector3D& rkV3, double afBary[4]) const; - - // Gram-Schmidt orthonormalization. Take linearly independent vectors - // U, V, and W and compute an orthonormal set (unit length, mutually - // perpendicular). - static void Orthonormalize (Vector3D& rkU, Vector3D& rkV, Vector3D& rkW); - static void Orthonormalize (Vector3D* akV); - - // Input W must be initialized to a nonzero vector, output is {U,V,W}, - // an orthonormal basis. A hint is provided about whether or not W - // is already unit length. - static void GenerateOrthonormalBasis (Vector3D& rkU, Vector3D& rkV, Vector3D& rkW, bool bUnitLengthW); - - // special vectors - static const Vector3D ZERO; - static const Vector3D UNIT_X1; - static const Vector3D UNIT_X2; - static const Vector3D UNIT_X3; - - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & m_afTuple; - } - #endif //CAB_RCF - - protected: - // support for comparisons - int CompareArrays (const Vector3D& rkV) const; - - double m_afTuple[3]; - }; - - //globaler multiplaktor mit skalar - Vector3D operator*(const double& fScalar, const Vector3D& rkV); - std::ostream& operator<<(std::ostream& os, const Vector3D& rkV); - - ////////////////////////////////////////////////////////////////////////// - // - //constants - // - ////////////////////////////////////////////////////////////////////////// - static const double c1o72 = 1./72.; //0.01388888 - static const double c1o36 = 1./36.; //0.02777777 - static const double c1o48 = 1./48.; //0.02083333 - static const double c1o32 = 1./32.; //0.03125 - static const double c1o24 = 1./24.; //0.04166666 - static const double c1o20 = 1./20.; //0.05 - static const double c1o18 = 1./18.; //0.05555555 - static const double c1o16 = 1./16.; //0.0625 - static const double c1o12 = 1./12.; //0.08333333 - static const double c1o9 = 1./9.; //0.11111111 - static const double c1o8 = 1./8.; //0.125 - static const double c1o6 = 1./6.; //0.16666666 - static const double c1o5 = 1./5.; //0.2 - static const double c1o4 = 1./4.; //0.25 - static const double c5o16 = 5./16.; //0.3125 - static const double c1o3 = 1./3.; //0.33333333 - static const double c3o8 = 3./8.; //0.375 - static const double c4o9 = 4./9.; //0.44444444 - static const double c1o2 = 1./2.; //0.5 - static const double c9o16 = 9./16.; //0.5625 - static const double c2o3 = 2./3.; //0.66666666 - static const double c3o4 = 3./4.; //0.75 - static const double c4o3 = 4./3.; //1.33333333 - static const double c5o3 = 5./3.; //1.66666666 - static const double c9o5 = 9./5.; //1.8 - static const double c2o9 = 2./9.; //0.22222222 - static const double c8o27 = 8./27.; - static const double c2o27 = 2./27.; - static const double c1o54 = 1./54.; - static const double c1o216 = 1./216.; - static const double one_over_sqrt2 = 1.0/sqrt(2.0); //0.707106781 - static const double one_over_sqrt3 = 1.0/sqrt(3.0); //0.577350269 - static const double sqrt2 = sqrt(2.0); //1.4142135 - static const double sqrt3 = sqrt(3.0); //1.7320508 -} - -#endif diff --git a/src/VirtualFluids_GPU/basics/utilities/UbNupsTimer.h b/src/VirtualFluids_GPU/basics/utilities/UbNupsTimer.h deleted file mode 100644 index cd99df78e..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbNupsTimer.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef UBNUPSTIMER_H -#define UBNUPSTIMER_H - -#include <basics/utilities/UbTiming.h> -#include <sstream> -#include <vector> - - -/*=========================================================================*/ -/* UbNupsTimer */ -/* */ -/** -This Class provides the base for ... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 01.11.04 -*/ -class UbNupsTimer : public UbTiming -{ -public: - UbNupsTimer() : UbTiming() - { - mTempNodes = 0.0; - mNofNodes.resize(0); - mDurations.resize(0); - } - /*==========================================================*/ - UbNupsTimer(std::string name) : UbTiming(name) - { - mNofNodes.resize(0); - mDurations.resize(0); - mTempNodes = 0.0; - } - /*==========================================================*/ - void initTiming() - { - UbTiming::initTiming(); - mNofNodes.resize(0); - mDurations.resize(0); - mTempNodes = 0.0; - } - /*==========================================================*/ - void startTiming(double nofNodes) - { - mTempNodes=nofNodes; - UbTiming::startTiming(); - } - /*==========================================================*/ - void endTiming() - { - UbTiming::endTiming(); - //save #node and time informations - mNofNodes.push_back(mTempNodes); - mDurations.push_back(UbTiming::getDuration()); - //reset internal timecounter - UbTiming::initTiming(); - } - /*==========================================================*/ - double getAverageNups() - { - double averageNups = 0.0; - for(int i=0;i<(int)mNofNodes.size();i++) - averageNups+=mNofNodes.at(i)/mDurations.at(i); - - return averageNups/(double)mNofNodes.size(); - } - /*==========================================================*/ - double getSumOfDuration() - { - double duration = 0.0; - for(int i=0;i<(int)mDurations.size();i++) duration+=mDurations.at(i); - return duration; - } - /*==========================================================*/ - std::string getNupsString() - { - std::stringstream ss; - ss<<"saved nups informations"<<std::endl; - for(int i=0;i<(int)mNofNodes.size();i++) - ss<<mNofNodes.at(i)<<"nodes/"<<mDurations.at(i)<<"sec="<<mNofNodes.at(i)/mDurations.at(i)<<"nups\n"; - return ss.str(); - } - -protected: - -private: - std::vector<double> mNofNodes; - std::vector<double> mDurations; - - double mTempNodes; -}; - -#endif diff --git a/src/VirtualFluids_GPU/basics/utilities/UbObservable.h b/src/VirtualFluids_GPU/basics/utilities/UbObservable.h deleted file mode 100644 index 79948dd36..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbObservable.h +++ /dev/null @@ -1,259 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBOBSERVABLE_H -#define UBOBSERVABLE_H - -#include <list> -#include <iostream> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <basics/utilities/UbObserver.h> - -class UbObserver; - -/*=========================================================================*/ -/* Beobachtbares Objekt */ -/* */ -/** - This class provides Observables. The Observeres which observe this - Observable are stored in an observerlist. - IMPORTANT: objectWillBeDeleted is called at UbObserver::~UbObserver - this destructor is called AFTER the destructor of the - child classes. if you down_cast the pointer sent with the - objectWillBeDeleted(UbObserver* objpointer) then have to go this: - - if(dynamic_cast<UbObserver*>(observedObj)==objpointer) - (e.g.) observedObj=NULL; - example: see end of file - - a copy of an UbservableObject will NOT copy the observerList - <UL> - <LI><B>Extending:</B> This UbObservable is the observable object itself. Extending should be used - where object types can be extended from UbObservable. - <LI><B>Associating:</B> Initialization is done via the constructor <tt>UbObservable(ObservableObject)</tt>. - Associating may be used, where object types to be observed could not be extended from UbObservable. - </UL> - <BR><BR><HR> - @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> - @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> - @version 1.2 - 13.07.05 - @see UbObserver -*/ - -class UbObservable -{ -protected: - /*======================================================================*/ - /* Konstruktoren */ - /* */ - /** - Creates a UbObservable itself to be the object to be observed. - Usually this constructor is used in extended classes. - */ - UbObservable() - { - } - - UbObservable(const UbObservable& src) - { - //no copy of observers !!! - } - - //falls irgendein schlaumeier den =operator von UbObservable aufrufen sollte, - //dann macht diesr auch keine kopie! (Allg: zuweisungsoperatoren werden nie vererbt - UbObservable& operator=(const UbObservable& src) - { - return *this; - } - - // /** - // Creates a UbObservable for the specified Object to be observed. - // Usually this constructor is used in associating UbObservable. - // @param object Object to be observed - // */ -public: - /*======================================================================*/ - /* Destruktor */ - /* */ - /** - */ - virtual ~UbObservable() - { - this->notifyObserversObjectWillBeDeleted(); - } - - /*======================================================================*/ - /* methods */ - /* */ - - /** - Adds an UbObserver to the observerlist. - @param observer the observer to add to this observable (note that an observer may observe one observable more than once) - */ - virtual void addObserver(UbObserver* observer) - { - if(!observer) return; - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos) - { - if(*pos == observer) return; - } - this->mObserverList.push_back(observer); - } - /** - Deletes an UbObserver from the observerlist. - @param observer the observer to remove from this observable (note that all observers identical are deleted) - ( delete means delete Heap... but here we're only removing a pointer) - */ - virtual void removeObserver(UbObserver* observer) - { - if(!observer) return; - this->mObserverList.remove(observer); - - } - /** - Deletes all Observers from the observerlist. - ( delete means delete Heap... but here we're only removing a pointer) - */ - virtual void removeAllObservers() - { - this->mObserverList.clear(); - } - - /** - Checks whether the specified UbObserver observes this observable. - @param observer the observer to remove from this observable (note that all observers identical are deleted) - @return true if the specified observer observes this observable - */ - virtual bool isObservedBy(UbObserver* observer) - { - if(!observer) return false; - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();++pos) - { - if(*pos == observer) return true; - } - return false; - } - /** - Notifies all of its observers that something happened. Does nothing, if the observed object is null. - Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter. - The Method UbObserver.objectChanged(Object) must be defined - by each class implementing the interface TiObserver - */ - virtual void notifyObserversObjectChanged() - { - std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend - //objectChanged() removed wird... - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();) - { - //cout<<"in notifyObserversObjectChanged\n"; - //cout<<this->mObserverList.size()<<endl; - - tmp_pos = pos++; // erst tmp_pos=pos und dann pos++ - (*tmp_pos)->objectChanged(this); - } - } - - std::list<UbObserver*>* getObserverList() { return &mObserverList;} - - virtual std::string toString() { return "UbObservable - toString()"; } - -#ifdef CAB_RCF - template<typename Archive> - void SF_SERIALIZE(Archive & ar) - { - //do nothing! - } -#endif //CAB_RCF - -private: - /** - Notifies all of its observers that something happened. Does nothing, if the observed object is null. - Calls the Method UbObserver.objectChanged(Object) with the object of this observable as parameter. - The Method UbObserver.objectChanged(Object) must be defined - by each class implementing the interface TiObserver - */ - virtual void notifyObserversObjectWillBeDeleted() - { - std::list<UbObserver*>::iterator tmp_pos; //es kann sein, dass der aktuelle observer waehrend - //objectWillBeDeleted() removed wird... - for(std::list<UbObserver*>::iterator pos=mObserverList.begin();pos!=mObserverList.end();) - { - //cout<<"in notifyObserversObjectWillBeDeleted\n"; - //cout<<this->mObserverList.size()<<endl; - - tmp_pos = pos++; - (*tmp_pos)->objectWillBeDeleted(this); - } - } - - std::list<UbObserver*> mObserverList; -}; -/*=========================================================================*/ - - -#ifdef RCF_USE_SF_SERIALIZATION - SF_NO_CTOR(UbObservable); -#endif //RCF_USE_SF_SERIALIZATION - -#endif - -//// E X A M P L E -////=================== -//class Point : public UbObservable -//{ -//public: -// Point(){x=y=0;} -// ~Point(){} -// void setXCorrdinates(int x,int y) -// { -// this->x = x; this->y = y; -// this->notifyObserverObjectChanged(); -// } -//private: -// int x,y; -//}; -//class VisPoint : public UbObserver -//{ -//public: -// VisPoint(Point* point) -// { -// this->point = point; -// this->point->addObserver(this); -// } -// ~VisPoint() -// { -// if(this->point) point->removeObserver(this); -// } -// void update() { /* do some actualisation stuff */ } -// void objectChanged(UbObservable* changedObject) -// { -// Point* point = dynamic_cast<Point*>(changedObject); -// if( !this->point || this->point != point ) return; -// this->repaint(); -// } -// void objectWillBeDeleted(UbObservable* objectForDeletion) -// { -// if(!this->point) return; -// UbObservable* obsobjet = dynamic_cast<UbObservable*>(this->point); -// if(obsobjet == objectForDeletion) this->point = NULL; -// /////////////////////////////////////////////////////////////////// -// //*********************************************************************// -// //INGEGEN erster annahmen nicht verwenden, da es nicht immer funktioniert -// //z.B. bei mehrfachvererbung haut es nicht hin! -// //// Point* point = reinterpret_cast<point*>(objectForDeletion); -// ////if(!this->point || objectForDeletion != this->point) return; -// ////this->point = NULL; -// //*********************************************************************// -// //was hingegen immer moeglich sein sollte: -// //if(dynamic_cast<void*>(objectForDeletion)==dynamic_cast<void*>(this->point)) -// } -//private: -// Point* point; -//}; diff --git a/src/VirtualFluids_GPU/basics/utilities/UbObserver.h b/src/VirtualFluids_GPU/basics/utilities/UbObserver.h deleted file mode 100644 index 601e2993a..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbObserver.h +++ /dev/null @@ -1,55 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBOBSERVER_H -#define UBOBSERVER_H - -class UbObservable; -/*=========================================================================*/ -/* Observer */ -/* */ -/** -This interface must be implemented by classes which want to -observe other objects. -IMPORTANT: if you delete an observer, ensure to remove Observer from - all his oberved observable objects before!!! -example: see end of UbObservable.h-file -<BR><BR><HR> -@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.1 - 20.11.04 -*/ - -class UbObserver -{ -protected: - - UbObserver(){} - -public: - - virtual ~UbObserver(){} - - /*======================================================================*/ - /* Methoden */ - /* */ - /** - This function is called when the observable indicated that an object - has changed. - @param changedObject Object which has changed - */ - virtual void objectChanged(UbObservable* changedObject)=0; - /** - This function is called when the observable indicated that an object - should be deleted. - @param objectForDeletion Object which should be deleted - */ - virtual void objectWillBeDeleted(UbObservable* objectForDeletion)=0; -}; - -#endif - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbPointerWrapper.h b/src/VirtualFluids_GPU/basics/utilities/UbPointerWrapper.h deleted file mode 100644 index 0d5bf13e7..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbPointerWrapper.h +++ /dev/null @@ -1,36 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBPOINTERWRAPPER_H -#define UBPOINTERWRAPPER_H - -//kappselt dynamische Objekte zur remote uebetragung -//bei RCF werden z.B. aufgrund GC alle lokalen Objekte und -//"nackte" Pointer die automatisch als shared_ptr initialisert -//werde nach Methoden-Aufruf zerstoert -//hierfuer kann man dann den UbPointerWrapper verwenden - -template<typename T> -class UbPointerWrapper -{ -public: - UbPointerWrapper() : pointer(NULL) {} - - UbPointerWrapper(T* pointer) : pointer(pointer) {} - - T* get() { return pointer; } - - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & pointer; - } - -private: - T* pointer; -}; - -#endif //UBPOINTERWRAPPER_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbRandom.h b/src/VirtualFluids_GPU/basics/utilities/UbRandom.h deleted file mode 100644 index dd3b4671e..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbRandom.h +++ /dev/null @@ -1,60 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBRANDOM_H -#define UBRANDOM_H - -#include <cstdlib> -#include <ctime> -#include <cassert> -#include <cmath> - -/*=========================================================================*/ -/* UbRandom */ -/* */ -/** -generates a random number -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 04.10.2007 -*/ -/* -usage: - int main() - { - char* hand[] = {"Schere", "Stein", "Papier"}; - for (unsigned u = 0; u < 20; u++) - { - cout << hand[UbRandom::rand(0, 2, 1)] << endl; - } - - return 0; - } -*/ - -class UbRandom -{ -private: - UbRandom() { std::srand(static_cast<int>(std::time(NULL))); } - -public: - //returns arbitrary int value element of [min ; max] - static inline int rand(const int& min, const int& max) - { - static UbRandom dummy; - assert(max - min < RAND_MAX); - return ( min + std::rand() % (max - min + 1) ); - } - //returns arbitrary float value element of "( (max - min) / gran ) * [min ; max]" - //with other words: val = min+n*(max-min)/gran, n=0..gran-1 - static inline double rand(const double& min, const double& max, const double& gran) - { - static UbRandom dummy; - return (min + std::floor( std::rand() / (1.0 + RAND_MAX) * gran)* (max - min) / gran); - } -}; - -#endif //UBRANDOM_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbScheduler.h b/src/VirtualFluids_GPU/basics/utilities/UbScheduler.h deleted file mode 100644 index bd0b2b72c..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbScheduler.h +++ /dev/null @@ -1,411 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSCHEDULER_H -#define UBSCHEDULER_H - -#include <iostream> -#include <string> -#include <limits> -#include <cassert> -#include <sstream> -#include <iomanip> -#include <algorithm> - -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbInfinity.h> -#include <basics/utilities/UbComparators.h> -#include <basics/utilities/UbFileOutput.h> -#include <basics/utilities/UbFileInput.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - -/*=========================================================================*/ -/* UbScheduler */ -/* */ -/** -namespace for global system-functions -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@author <A HREF="mailto:hegewald@cab.bau.tu-bs.de">J. Hegewald</A> -@version 1.0 - 06.09.06 -@version 1.1 - 09.09.06 -@version 1.2 - 03.07.08 - nun auch isDue(t) mehrmals fuer dasselbe t moeglich - isDue(t) auch fuer t < lastUsedT - bug entfernt, der bei Schedule (5,0,500) auch 505 als Due zurückgibt! -*/ - -/* -usage: ... -*/ - -// this class is not thread save -// - -class UbScheduler -{ -public: - class UbSchedule - { - friend class UbScheduler; - public: - UbSchedule() : step(Ub::inf), begin(Ub::inf), end(Ub::inf) { } - UbSchedule(const double& step, const double& begin=0.0, const double& end=Ub::inf) - : step(step), begin(begin), end(end) - { - } - double getStep() const { return this->step; } - double getBegin() const { return this->begin; } - double getEnd() const { return this->end; } - - /*==========================================================*/ - std::string toString() { std::stringstream text; text<<*this; return text.str(); } - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const UbSchedule& schedule) - { - os<<"Schedule[start,end,step]=["<<schedule.begin<<", "<<schedule.end<<", "<<schedule.step<<"]"; - return os; - } - - //------------- implements CAB serialization ----- start - virtual void write(UbFileOutput* out) - { - out->writeDouble( begin ); - out->writeDouble( end ); - out->writeDouble( step ); - } - virtual void read(UbFileInput* in) - { - begin = in->readDouble(); - end = in->readDouble(); - step = in->readDouble(); - } - //------------- implements CAB serialization ----- end - - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & begin; ar & end; ar & step; - } - #endif //CAB_RCF - - private: - double step, begin, end; - }; - -public: - UbScheduler() - { - this->initVals(); - } - /*==========================================================*/ - UbScheduler(const double& step,const double& begin=0, const double& end=Ub::inf ) - { - this->initVals(); - this->addSchedule(step,begin,end); - } - /*==========================================================*/ - UbScheduler(const UbSchedule& schedule) - { - this->initVals(); - this->addSchedule(schedule); - } - /*==========================================================*/ - virtual ~UbScheduler() {} - /*==========================================================*/ - inline void addSchedule(const UbSchedule& schedule) - { - this->addSchedule(schedule.step, schedule.begin, schedule.end); - } - /*==========================================================*/ - bool addSchedule(const double& step, const double& begin, double end) - { - if( UbMath::zero(step) || begin>end ) - { - std::cerr<<"UbScheduler::addSchedule - invalid Schedule:\n\t"<<UbSchedule(step, begin, end)<<std::endl; - return false; - } - - if( UbMath::less( end, (double)Ub::inf ) ) - { - //es kann vorkommen, dass man mit dem intervall nicht genau auf den letzten wert kommt - //(z.B. step=2; start=0; end=9; -> ende wird angepasst) - //also wenn end-begin>Ub::inf ist, dann geht es halt nicht.. ein cast in long double half hier nichts - double multiplier=0.0; - double fractpart = modf( (end-begin)/step, &multiplier); - if( !UbMath::zero(fractpart) ) - { - //tmp-speicherung (fuer cerr) - fractpart = end; - //neues ende - end = begin+multiplier*step; - - std::cerr<<"Warning: UbScheduler::addSchedule - " - <<"end of schedule was adapted to intervall \n\t" - <<"from "<< UbSchedule(step, begin, fractpart) <<" to "<< UbSchedule(step, begin, end) <<std::endl; - } - } - - //nu aber: - schedules.push_back(UbSchedule(step, begin, end)); - - if( end>maxT ) maxT = end; - - double potentialDueTime; - if( calcNextDueTimeForSchedule(schedules.back(), lastUsedT, potentialDueTime) - && potentialDueTime < nextDueTime ) - { - nextDueTime = potentialDueTime; - } - - return true; - } - /*==========================================================*/ - //returns true if scheduler contains schedules - bool hasSchedules() const { return !schedules.empty(); } - /*==========================================================*/ - //time bei dem das letzte mal isDue(time) true war - double getLastDueTime() const { return lastDueTime; } - /*==========================================================*/ - //time bei dem das naechste mal isDue(time) true ergibt - double getNextDueTime() const { return nextDueTime; } - /*==========================================================*/ - //maxDueTime (maxTime der Schedules! - double getMaxDueTime() const { return this->maxT; } - /*==========================================================*/ - bool isDue(const double& t) - { - lastUsedT = t; - if( UbMath::greaterEqual(t,nextDueTime) ) - { - //groesser maxT is nicht - if( UbMath::greater(t,maxT) ) return false; - - //temp var - double actDueTime = nextDueTime; - - //um Suche nach nextDueTime bei "Zukunfts-t" zu optimieren, setzt man die "start"-suchzeit auf "t-1": - nextDueTime = t-1; //t-1 deshlab, damit falls z.B. while Schleife nicht durchlaufen wird - //die folgende if Abfrage nicht faelschlicher Weise true ist! - while( UbMath::greaterEqual(t,nextDueTime) && !UbMath::equal(nextDueTime, maxT) ) - { - double tmpNextDueTime = maxT, potentialDueTime=-1.0; - for(std::size_t i=0; i<schedules.size(); i++) - { - if( calcNextDueTimeForSchedule(schedules[i], nextDueTime, potentialDueTime) - && potentialDueTime < tmpNextDueTime ) - { - assert( nextDueTime < potentialDueTime ); - tmpNextDueTime = potentialDueTime; - } - } - actDueTime = nextDueTime; - nextDueTime = tmpNextDueTime; - } - - //wenn t = der aktuuellen oder gar schon der nächstmöglichen ist (hierbei wurde - //zuvor actDueTime und nextDueTime ggf. angepasst) - //Bsp.: nextDuTime war 5, aber für t=400 gilt andere schedule -> Bsp actDue=350 und nextDue 405 - if( UbMath::equal(t,actDueTime) - || UbMath::equal(t,nextDueTime) ) - { - lastDueTime = t; - return true; - } - } - else if( UbMath::lessEqual(t, lastDueTime) ) - { - if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man für dasselbe t isDue(t) aufruft - else - { - //Fall: Zeit liegt faktisch in der Vergangenheit -> neu initialsisieren - double tmpNextDueTime = maxT, potentialDueTime=-1.0; - for(size_t i=0; i<schedules.size(); i++) - { - if( calcNextDueTimeForSchedule(schedules[i], t-1, potentialDueTime) - && potentialDueTime < tmpNextDueTime ) - { - tmpNextDueTime = potentialDueTime; - } - } - nextDueTime = tmpNextDueTime; - - return UbMath::equal(t, nextDueTime); - } - } - - return false; - } - /*==========================================================*/ - inline double getMinBegin( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin(); - } - /*==========================================================*/ - inline double getMaxBegin( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getBegin) )->getBegin(); - } - /*==========================================================*/ - inline double getMinEnd( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd(); - } - /*==========================================================*/ - inline double getMaxEnd( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getEnd) )->getEnd(); - } - /*==========================================================*/ - inline double getMinStep( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::min_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep(); - } - /*==========================================================*/ - inline double getMaxStep( ) const - { - if( schedules.empty() ) return Ub::inf; - return std::max_element(schedules.begin(), schedules.end(),UbComparators::membercomp(&UbSchedule::getStep) )->getStep(); - } - /*==========================================================*/ - inline std::string toString() const - { - std::stringstream text; - text<<*this; - return text.str(); - } - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const UbScheduler& scheduler) - { - os<<"UbScheduler\n"; - os<<"Schedule | start | end | intervall "<<std::endl; - for(std::size_t i=0; i<scheduler.schedules.size(); i++) - os<<std::setw(9)<<i<<"|" - <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|" - <<std::setw(19)<<scheduler.schedules[i].getEnd() <<"|" - <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl; - return os; - } - - //------------- implements CAB serialization ----- start - virtual void write(UbFileOutput* out) - { - out->writeSize_t( schedules.size() ); - - for(std::size_t i=0; i<schedules.size(); i++) - schedules[i].write(out); - } - virtual void read(UbFileInput* in) - { - this->initVals(); - - std::size_t nofSchedules = in->readSize_t(); - for(std::size_t i=0; i<nofSchedules; i++) - { - UbSchedule schedule; - schedule.read(in); - this->addSchedule(schedule); - } - } - //------------- implements CAB serialization ----- end - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & lastUsedT; - ar & lastDueTime; - ar & nextDueTime; - ar & maxT; - ar & schedules; - } -#endif //CAB_RCF - - -protected: - /*==========================================================*/ - void initVals() - { - lastUsedT = -Ub::inf; - lastDueTime = -Ub::inf; - nextDueTime = Ub::inf; - maxT = -Ub::inf; - } - /*==========================================================*/ - // calculates next due time for a schedule - // with nextDueTime > searchStart - bool calcNextDueTimeForSchedule(const UbSchedule& schedule, const double& searchStart, double& nextDueTime ) - { - if ( UbMath::greater(searchStart, schedule.end ) ) return false; - else if( UbMath::less( searchStart, schedule.begin) ) nextDueTime = schedule.begin; - else - { - nextDueTime = schedule.begin + ((int)((searchStart-schedule.begin)/schedule.step)+1)*schedule.step; - if( UbMath::less( nextDueTime, searchStart ) - || UbMath::greater(nextDueTime, schedule.end) ) - { - return false; - } - } - return true; - } - -protected: - double lastUsedT; - double lastDueTime; - double nextDueTime; - double maxT; - - std::vector<UbSchedule> schedules; -}; - -typedef UbScheduler::UbSchedule UbSchedule; -// inline std::ostream& operator<<( std::ostream& os, const UbScheduler& scheduler ) -// { -// os<<"UbScheduler\n"; -// os<<"Schedule | start | end | intervall "<<std::endl; -// for(std::size_t i=0; i<scheduler.schedules.size(); i++) -// os<<std::setw(9)<<i<<"|" -// <<std::setw(19)<<scheduler.schedules[i].getBegin()<<"|" -// <<std::setw(19)<<scheduler.schedules[i].getEnd() <<"|" -// <<std::setw(19)<<scheduler.schedules[i].getStep() <<std::endl; -// return os; -// } - -#endif //UBSCHEDULER_H - - - -//int main(int argc, char** argv) -//{ -// UbScheduler writeSchedule; -//// writeSchedule.addSchedule(0,2000,100); -//// writeSchedule.addSchedule(3005,4500,300); -//// writeSchedule.addSchedule(0,10,1); -//// writeSchedule.addSchedule(0,100001,100); -// writeSchedule.addSchedule(0,2,1); -// writeSchedule.addSchedule(0,100001,200); -// -// for(int t = 0; t < 1001; t++) -// { -// if(writeSchedule.isDue(t)) -// { -// cout<<"due@ "<<t<<endl; -// } -// } -// return 0; -//} - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.cpp b/src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.cpp deleted file mode 100644 index b68cc5ba1..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include <basics/utilities/UbStaticPathMap.h> - -UbStaticPathMap::PathMap UbStaticPathMap::pathMap; -const std::string UbStaticPathMap::GLOBAL = "UbStaticPathMap::GLOBAL"; diff --git a/src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.h b/src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.h deleted file mode 100644 index 1900f83c0..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbStaticPathMap.h +++ /dev/null @@ -1,80 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSTATICPATHMAP_H -#define UBSTATICPATHMAP_H - -#include <iostream> -#include <string> -#include <map> - -#include <basics/utilities/UbSystem.h> - -#define NOMINMAX -#undef max -#undef min -/*=========================================================================*/ -/* UbStaticPathMap */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 12.10.2007 -*/ - -/* -stores pathnames for pathIDs (e.g. on different processes different paths with same pathID) -adding an path autom. changes "\" to "/" and removed last "/" if exists - -*/ - -class UbStaticPathMap -{ - typedef std::map< std::string, std::string > PathMap; -public: - static const std::string GLOBAL; -public: - - static std::string addAndMakePath(const std::string& id, const std::string& path) - { - std::string tmpPath = UbStaticPathMap::addPath(id,path); - if( !tmpPath.empty() ) - { - if( !UbSystem::makeDirectory(tmpPath,20) ) - { - throw UbException(UB_EXARGS, "could not create "+tmpPath); - } - } - return tmpPath; - } - static std::string addPath(const std::string& id, const std::string& path) - { - std::string tmpPath = UbSystem::replaceInString(path,"\\","/"); - if(tmpPath.rfind("/") == tmpPath.size()-1) tmpPath.resize(tmpPath.size()-1); - pathMap[id] = tmpPath; - return tmpPath; - } - static std::string getPath(const std::string& id) - { - PathMap::iterator it = pathMap.find(id); - if(it == pathMap.end()) return ""; - return it->second; - } - static void removePath(const std::string& id) - { - pathMap.erase(id); - } - -protected: - static PathMap pathMap; - -private: - UbStaticPathMap() {} - UbStaticPathMap(const UbStaticPathMap&) {} -}; - -#endif //UBSTATICPATHMAP_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.cpp b/src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.cpp deleted file mode 100644 index 61b91e814..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include <basics/utilities/UbStringInputASCII.h> -#include <cstring> - -using namespace std; - - -UbStringInputASCII::UbStringInputASCII(string inputString) : UbFileInputASCII("") -{ - instream.str(inputString); - - -// this->filename = filename; -// this->commentindicator = 'C'; -// -// infile.open(filename.c_str()); - -} -/*==========================================================*/ -int UbStringInputASCII::readInteger() -{ - int dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -std::size_t UbStringInputASCII::readSize_t() -{ - std::size_t dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -long UbStringInputASCII::readLong() -{ - long dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::getFileName() -{ - return this->filename; -} - -/*==========================================================*/ -void UbStringInputASCII::skipLine() -{ - string dummy; - getline(instream, dummy); -} -/*==========================================================*/ -void UbStringInputASCII::readLine() -{ - string dummy; - getline(instream, dummy); -} -/*==========================================================*/ -string UbStringInputASCII::readStringLine() -{ - string dummy; - getline(instream, dummy); - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::readLineTill(char stop) -{ - string dummy; - getline(instream, dummy, stop); - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::parseString() -{ - string dummy; - getline(instream, dummy, ' '); - return dummy; -} -/*==========================================================*/ -double UbStringInputASCII::readDouble() -{ - double dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -float UbStringInputASCII::readFloat() -{ - float dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -char UbStringInputASCII::readChar() -{ - char dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -string UbStringInputASCII::readString() -{ - string dummy; - instream>>dummy; - return dummy; -} -/*==========================================================*/ -bool UbStringInputASCII::containsString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - instream.getline(line,512); - if(instream.eof()) return false; - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - return true; -} -/*==========================================================*/ -void UbStringInputASCII::setPosAfterLineWithString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - char line[512]; - do - { - instream.getline(line,512); - if(instream.eof()) throw UbException(UB_EXARGS,var+" wasn't found in "+this->filename); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt -} -/*==========================================================*/ -int UbStringInputASCII::readIntegerAfterString(string var) -// last change [10.3.2004] at [9:46] -//suchts in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. timesteps 9 -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - instream.getline(line,512); - if(instream.eof()) throw UbException(UB_EXARGS,var+" wasn't found in "+this->filename); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return(atoi(line)); // Umwandlung in int -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -double UbStringInputASCII::readDoubleAfterString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - - do - { - instream.getline(line,512); - if(instream.eof()) throw UbException(UB_EXARGS,var+" wasn't found in "+this->filename); - }while (/*!strncmp(varname,line,sizeof(varname))==0*/strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - return (atof(line)); // Umwandlung in double -} -/*==========================================================*/ -// [9.9.2002] -// liefert sring-Wert der hinter dem uebergebenen char feld in der datei instream steht -// zudem wird der wert in die uebergebene variable value uebertragen (falls man das ergebniss als char benoetig) -string UbStringInputASCII::readStringAfterString(string var) -{ - instream.seekg(0L, ios::beg); //Positionszeiger der Datei auf den Anfang setzen - - char line[512]; - //string line_copy[512]; - - do{ - instream.getline(line,512); - if(instream.eof()) throw UbException(UB_EXARGS,var+" wasn't found in "+this->filename); - }while (strstr(line,var.c_str()) != line); // Ende Schleife, wenn varname ganz in zeile vorkommt - - strcpy (line, (line+strlen(var.c_str()))); // zeile um "varname" kuerzen - while ((line[0] == ' ') || (line[0] == '\t')) strcpy (line, (line+1)); // Whitespaces entfernen - - char *p; - p=strtok(line," "); //schneidet alles "ab und inklusive space " nach namen ab - p=strtok(line,"\t");//schneidet alles "ab und inklusive tab " nach namen ab - - return (string)p; // Umwandlung in string -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbStringInputASCII::readBoolAfterString(string var) -{ - if(this->readStringAfterString(var.c_str()) == "true" ) return true; - else if(this->readStringAfterString(var.c_str()) == "false") return false; - else throw UbException(UB_EXARGS,var+" is not equal to 'true' or 'false' in "+this->filename); -} -/*==========================================================*/ -// last change [10.3.2004] at [9:46] -//sucht in einer Datei nach varname und gibt den dahinter stehenden int-Wert zurueck -//z.B. nue 9.5 -bool UbStringInputASCII::readBool() -{ - string tmp = this->readString(); - if( tmp == "true" ) return true; - else if(tmp == "false") return false; - else throw UbException(UB_EXARGS,"expression is not equal to 'true' or 'false' in "+this->filename); -} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.h b/src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.h deleted file mode 100644 index 98f968b38..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbStringInputASCII.h +++ /dev/null @@ -1,56 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSTRINGINPUTASCII_H -#define UBSTRINGINPUTASCII_H - -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -#include <basics/utilities/UbFileInputASCII.h> - -class UbStringInputASCII : public UbFileInputASCII -{ -public: - UbStringInputASCII(std::string inputString); - - std::string getFileName(); - void skipLine(); // Springt zur naechsten Zeile - - void readLine(); - std::string readStringLine(); - std::size_t readSize_t(); - int readInteger(); // Liest einen int-Wert ein - long readLong(); // Liest einen long-Wert ein - double readDouble(); // Liest einen double-Wert ein - float readFloat(); // Liest einen float-Wert ein - bool readBool(); // Liest einen bool-Wert ein - char readChar(); // Liest einen char-Wert ein - std::string readString(); // Liest ein Wort ein - std::string readLineTill(char stop); // Liest gesamte Zeile ein bis zu einem bestimmten Zeichen - std::string parseString(); - - bool containsString(std::string var); - void setPosAfterLineWithString(std::string var); - int readIntegerAfterString(std::string var); - double readDoubleAfterString(std::string var); - bool readBoolAfterString(std::string var); - std::string readStringAfterString(std::string var); - - FILETYPE getFileType() { return ASCII; } - -private: - std::istringstream instream; -}; - - -#endif - - diff --git a/src/VirtualFluids_GPU/basics/utilities/UbSystem.h b/src/VirtualFluids_GPU/basics/utilities/UbSystem.h deleted file mode 100644 index 0ce19325a..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbSystem.h +++ /dev/null @@ -1,510 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSYSTEM_H -#define UBSYSTEM_H - -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <algorithm> -#include <typeinfo> -#include <cctype> //for toupper -#include <ctime> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbLogger.h> - -#define NOMINMAX -#undef max -#undef min - -#if defined(CAB_BOOST) - #include <boost/thread.hpp> - #include <boost/filesystem.hpp> -#endif // CAB_BOOST - -#if defined(_WIN32) || defined(_WIN64) - #define UBSYSTEM_WINDOWS - #include <process.h> - #include <io.h> - #include <direct.h> - #ifndef _WINSOCKAPI_ //ansonsten gibt es mecker bei #include "Windows.h" und ::Sleep() - #define _WINSOCKAPI_ - #endif - #include <windows.h> -#elif defined(__APPLE__) - #define UBSYSTEM_APPLE - #include "dirent.h" - #include "sys/stat.h" - #include <sys/syscall.h> - #include <sys/stat.h> -#elif defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__) - #define UBSYSTEM_LINUX - #include <unistd.h> - #include "dirent.h" - #include "sys/stat.h" - #include <sys/syscall.h> - #include <sys/stat.h> -#else - #error "UbSystem::UnknownMachine" -#endif - - -#if defined(min) || defined(max) //daruch kann man sich spaeter #undef min; #undef max erparen -# error add NOMINMAX to preprocessor defines -#endif - -//allg.: -//const int * C1 -> C1 is variable pointer to a constant integer -//int const * C2 -> C2 is variable pointer to a constant integer (same as above) -//int * const C3 -> C3 is constant pointer to a variable integer -//int const * const C4 -> C4 is constant pointer to a constant integer - -//DEFINE TO STRING -//e.g. #define FOO hallo -// -> QUOTEME(FOO) == "hallo" -#define _QUOTEME(x) #x -#define QUOTEME(x) _QUOTEME(x) - -////////////////////////////////////////////////////////////////////////// -//UbSystem -////////////////////////////////////////////////////////////////////////// -namespace UbSystem -{ - template<bool> struct ub_static_assert; //deklaration (ub_xxx da static_assert in C++0x ein keyword werden wird) - template<> struct ub_static_assert<true>{}; //deklaration + definition der spezialisierung fuer "true" - //ub_static_assert<false> fuehrt zu compiler fehler, da dafuer - //keine implementierung vorhanden! //UB_STATIC_ASSERT(false) - - /*==========================================================*/ - inline void sleepMs(const unsigned int& msec) - { - #if defined UBSYSTEM_WINDOWS - ::Sleep( (msec==0) ? 1 : msec ); // +1 here causes a context switch if SleepMSec(0) is called - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - ::usleep(1000*msec); - #else - #error "UbSystem::sleepMSec - UnknownMachine" - #endif - } - /*==========================================================*/ - inline void sleepS(const unsigned int& sec) - { - #if defined UBSYSTEM_WINDOWS - ::Sleep( (sec==0) ? 1 : sec*1000 ); // +1 here causes a context switch if sleepS(0) is called - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - ::sleep(sec); - #else - #error "UbSystem::sleepS - UnknownMachine" - #endif - } - /*==========================================================*/ - //checks if the bits of bitmask are set in value - template<typename T> - inline bool bitCheck(const T& value, const T& bitmask) - { - return ( (value & bitmask) == bitmask); - } - /*==========================================================*/ - //checks if the bits of bitmask are set in value - template<typename T> - inline void setBit(T& value, const T& bitmask) - { - value |= bitmask; - } - /*==========================================================*/ - template<typename T> - inline void unsetBit(T& value, const T& bitmask) - { - value &= ~bitmask; - } - /*==========================================================*/ - //returns bitmask as string e.g. 0001 0100 1101 - template<typename T> - inline std::string getBitString(const T& value) - { - std::stringstream text; - for(int i=sizeof(value)*8-1/*8 bits per byte*/; i>=0; i--) - { - text<<(char) ( ((value>>i) & 1) + '0'); - if(i%4 == 0 && i>0) text<<' '; - } - return text.str(); - } - /*==========================================================*/ - //converts string to type T - // usage: int x = stringTo<int>("123"); - template<typename T> - inline T stringTo(const std::string& s) - { - std::istringstream iss(s); - T x; - iss >> x; - if(!iss) - throw UbException(UB_EXARGS," cannot convert \""+s+"\" to type <"+static_cast<std::string>(typeid(x).name())+">"); - - return x; - } - /*==========================================================*/ - // usage: string s = toString(x); - template<typename T> - inline std::string toString(const T& x, int precision=15) - { - std::ostringstream oss; - oss<<std::setprecision(precision); - oss<<x; - return oss.str(); - } - /*==========================================================*/ - //e.g. str="iHcsnW" -> "IHCSNW" - inline std::string toUpperString(const std::string& str) - { - std::string tmp(str); - std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::toupper)); - - return tmp; - } - /*==========================================================*/ - //e.g. str="iHcsnW" -> "ihcsnw" - inline std::string toLowerString(const std::string& str) - { - std::string tmp(str); - std::transform(tmp.begin(),tmp.end(),tmp.begin(), static_cast<int (*)(int)>(std::tolower)); - - return tmp; - } - /*==========================================================*/ - // usage: std::string s = replaceInString(str,"\\","/"); - // std::string s = replaceInString(str,"ich","du"); - static std::string replaceInString(std::string original, const std::string& replace, const std::string& replaceWith ) - { - size_t pos=0; - while( (pos=original.find(replace,pos))!=std::string::npos ) - { - original.replace(pos,replace.size(),replaceWith); - pos+=replaceWith.size(); - } - return original; - } - /*==========================================================*/ - //returns content of an enviroment variable - inline std::string getEnv(const std::string& var) - { - char* str = getenv( var.c_str()); - if( str == NULL ) - { - return std::string(""); - } - - return static_cast<std::string>( str ); - } - /*==========================================================*/ - inline bool isDirectory(const std::string& dir, const unsigned& attemptions = 3) - { - if( dir.empty() ) - throw UbException(UB_EXARGS,"dir is empty"); - - std::string path = UbSystem::replaceInString(dir,"\\","/"); - - #if defined UBSYSTEM_WINDOWS - #ifndef _UNICODE - if( _access(path.c_str(), 0 ) == -1 ) return false; - #else - if( _waccess(path.c_str(), 0 ) == -1 ) return false; - #endif - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - struct stat stFileInfo; - if( stat(path.c_str(),&stFileInfo) != 0) - { - return false; - } - #endif - - return true; - } - /*==========================================================*/ - // usage: makeDirectory("c:/temp"); - // makeDirectory("c:/temp/"); - // return: true -> successful - // false -> failed - #if defined(CAB_BOOST) - static boost::mutex mtx_makeDirectory; - #endif - inline bool makeDirectory(const std::string& dir, const unsigned& attemptions = 3) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory - start, dir="<<dir<<" #attemptions="<<attemptions); - - if( dir.empty() ) throw UbException(UB_EXARGS,"dir is empty"); - std::string path = UbSystem::replaceInString(dir,"\\","/"); - - bool dirCreated = true; - - #ifdef CAB_BOOST - dirCreated = boost::filesystem::exists( dir ) ; - if(!dirCreated) dirCreated = boost::filesystem::create_directories( dir ); - #elif defined UBSYSTEM_WINDOWS - path = UbSystem::replaceInString(dir,"//","\\\\"); - if(path[path.size()-1] != '/') path+="/"; - size_t pos = 0; - //check for networkdrive - if(path.size()>1 && path[0]=='\\' && path[1]=='\\' ) - { - pos=path.find("/",pos); //_access-check always fails check with network drives - pos=path.find("/",pos); //einfach netzlaufwerksnamen überspringen - } - - while( ( pos=path.find("/",pos+1) ) != std::string::npos ) - { - std::string tmpdir = path.substr(0,pos); - #if defined(CAB_BOOST) - boost::mutex::scoped_lock lock(mtx_makeDirectory); - #endif - if( - #ifndef _UNICODE - _access(tmpdir.c_str(), 0 ) == -1 && _mkdir(tmpdir.c_str() ) == -1 - #else - _waccess(tmpdir.c_str(), 0) == -1 && _wmkdir(tmpdir.c_str()) == -1 - #endif - ) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory- dir=\""<<tmpdir<<"\" doesn't exist or makedir failed"); - dirCreated = false; - break; - } - } - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - std::string command = "mkdir -p \""+path+"\""; - { - #if defined(CAB_BOOST) - boost::mutex::scoped_lock lock(mtx_makeDirectory); - #endif - if(system(command.c_str())!=0) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory- dir=\""<<path<<"\" doesn't exit or makedir failed"); - dirCreated = false; - } - } - #else - #error "UbSystem::makeDirectory - UnknownMachine" - #endif - - if(!dirCreated && attemptions > 1) - { - UBLOG(logDEBUG5,"UbSystem::makeDirectory - internal call of UbSystem::makeDirectory"); - UbSystem::sleepMs(500); - dirCreated = UbSystem::makeDirectory(path, attemptions-1); - } - - UBLOG(logDEBUG5,"UbSystem::makeDirectory - end (success="<<dirCreated<<", attemptions = "<<attemptions<<")"); - return dirCreated; - } - /*==========================================================*/ -#if defined(CAB_BOOST) - static boost::mutex mtx_removeDirectory; -#endif - inline int removeDirectory(const std::string& dir) - { - #if defined(CAB_BOOST) - boost::mutex::scoped_lock lock(mtx_removeDirectory); - #endif - std::string command = "rmdir \""+dir+"\""; - return std::system(command.c_str()); - } - /*==========================================================*/ - // usage : getPathFromString("c:/temp/foo.txt"); - //returns: "c:/temp" - // usage : getPathFromString("c:\\temp\\foo.txt"); - //returns: "c:/temp" - // usage : getPathFromString("foo.txt"); - // returns: "" - inline std::string getPathFromString(const std::string& fileStringWithPath) - { - std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/"); - std::size_t last = tmp.rfind("/"); - if(last!=std::string::npos) tmp.resize(last); - else tmp = ""; - return tmp; - } - /*==========================================================*/ - // usage : getFilenameFromString("c:/temp/foo.txt"); - // returns: "foo.txt" - // usage : getFilenameFromString("c:/temp/foo.txt",false); - // returns: "foo" - // usage : getFilenameFromString("c:/temp/"); - // returns: "" - inline std::string getFilenameFromString(const std::string& fileStringWithPath, bool withExtension = true) - { - std::string tmp = UbSystem::replaceInString(fileStringWithPath,"\\","/"); - - //remove path - std::size_t last = tmp.rfind("/"); - if(last!=std::string::npos && (last+1)<tmp.size()) tmp.erase(0,last+1); - - //remove extension - if(!withExtension) - { - last = tmp.rfind("."); - if(last!=std::string::npos) tmp.erase(last); - } - - return tmp; - } - /*==========================================================*/ - inline int getProcessID() - { - #if defined UBSYSTEM_WINDOWS - return _getpid(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - return getpid(); - #else - #error "int UbSystem::getProcessID() - UnknownMachine" - #endif - } - /*==========================================================*/ - inline unsigned long getCurrentThreadID() - { - #if defined UBSYSTEM_WINDOWS - return (unsigned long)GetCurrentThreadId(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) - return (unsigned long)syscall(SYS_gettid); - #else - #error "unsigned long UbSystem::getCurrentThreadID() - UnknownMachine" - #endif - } - /*==========================================================*/ - inline bool isBigEndian() - { - short word = 0x4321; - if((*(char*)& word) != 0x21 ) return true; - else return false; - } - /*==========================================================*/ - inline bool isLittleEndian() - { - return !isBigEndian(); - } - /*==========================================================*/ - inline std::string getTimeStamp() - { - time_t t = time(NULL); - tm* localTime = localtime(&t); - - std::stringstream tmp; - tmp.fill('0'); - - tmp << localTime->tm_year+1900 - << "." << std::setw(2) <<localTime->tm_mon+1 - << "." << std::setw(2) << localTime->tm_mday - << "@" << std::setw(2) << localTime->tm_hour - << "." << std::setw(2) << localTime->tm_min - << "." << std::setw(2) << localTime->tm_sec ; - - return tmp.str(); - } - /*==========================================================*/ - //swap Byte Order - //usage: int test = 8; - // swapByteOrder((unsigned char*)& test, sizeof(int)) - //#define ByteSwap5(x) ByteSwap((unsigned char *) &x,sizeof(x)) - inline void swapByteOrder(unsigned char* toSwap, int length) - { - register int i = 0; - register int j = length-1; - while(i<j) - { - std::swap(toSwap[i], toSwap[j]); - i++, j--; - } - } - ////////////////////////////////////////////////////////////////////////// - // generic IfThenElse - start - ////////////////////////////////////////////////////////////////////////// - // primary template: yield second or third argument depending on first argument - template<bool C, typename Ta, typename Tb> - class IfThenElse; - - // partial specialization: true yields second argument - template<typename Ta, typename Tb> - class IfThenElse<true, Ta, Tb> { - public: - typedef Ta ResultT; - }; - - // partial specialization: false yields third argument - template<typename Ta, typename Tb> - class IfThenElse<false, Ta, Tb> { - public: - typedef Tb ResultT; - }; - ////////////////////////////////////////////////////////////////////////// - // generic IfThenElse - end - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - //help struct for overloading methods in template classes for specific types - ////////////////////////////////////////////////////////////////////////// - template< typename T> - struct type2type - { - typedef T type; - }; - - - ////////////////////////////////////////////////////////////////////////// - // pair selector - ////////////////////////////////////////////////////////////////////////// - template <typename Pair> - struct select1st - { - typedef Pair argument_type ; - typedef typename Pair::first_type result_type ; - - const result_type& operator()(const argument_type &p) const - { - return p.first ; - } - }; - - template <typename Pair> - struct select2nd - { - typedef Pair argument_type ; - typedef typename Pair::second_type result_type ; - - const result_type& operator()(const argument_type &p) const - { - return p.second ; - } - }; - - -}; - -#define UB_STATIC_ASSERT(expr) static_cast<void>(sizeof( UbSystem::ub_static_assert<expr> )); -//zum ueberpruefen von STATISCHEN ausdruecken waehrend der compile-zeit -//--> Ausdruecke muessen schon ZUR compilerzeit auswertbar sein !!! -//Anwendung z.B. zur Ueberpruefung von Funktionalitaeten, wie z.B. bei UbMath::getNegativeInfinity<double>(); -// -//Grund fuer macro ist einfach, dass es besser anzuwenden ist in der praxis! -//ansonsten würde es so aussehen: -// UbSystem::ub_static_assert< aaa == 1 > test(); -// da ist UB_STATIC_ASSERT(aaa == 1); schoener -// -//um das zu vermeiden machtman hier diesen static_cast<void>(sizeof(...) ) -//Code-Snippet: -// struct Test { static const bool m_const_bool = true; bool m_bool; }; -// int main() { -// UB_STATIC_ASSERT( Test::m_const_bool == true ); -// --> okay, assert bestanden -// UB_STATIC_ASSERT( Test::m_const_bool == false); //: -// --> assert nicht bestanden z.B. error C2027: use of undefined type 'UbSystem::ub_static_assert<__formal> with __formal = false --> funzt nicht. fehler im code -// UB_STATIC_ASSERT( Test::m_bool == true ); -// --> nicht erlaubt, da m_bool nicht statisch und nicht const ist. -//} - -#endif //UBSYSTEM_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbTableModel.cpp b/src/VirtualFluids_GPU/basics/utilities/UbTableModel.cpp deleted file mode 100644 index 12e69b068..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbTableModel.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <basics/utilities/UbTableModel.h> - -UbTableModel::UbTableModel() -{ -} - -UbTableModel::~UbTableModel() -{ - //this->notifyObserversObjectWillBeDeleted(); -} - -//void UbTableModel::objectChanged(UbObservable* changedObject) -//{ -// this->notifyObserversObjectChanged(); -//} -// -//void UbTableModel::objectWillBeDeleted(UbObservable* objectForDeletion) -//{ -// objectForDeletion->removeObserver(this); -//} diff --git a/src/VirtualFluids_GPU/basics/utilities/UbTableModel.h b/src/VirtualFluids_GPU/basics/utilities/UbTableModel.h deleted file mode 100644 index 148d4ea16..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbTableModel.h +++ /dev/null @@ -1,37 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTABLEMODEL_H -#define UBTABLEMODEL_H - -#include <iostream> - -class UbTableModel -{ -public: - static const int COL_TYPE_STRING = 1; - static const int COL_TYPE_BOOL = 2; - static const int COL_TYPE_INTEGER = 3; - static const int COL_TYPE_DOUBLE = 4; - - UbTableModel(); - virtual ~UbTableModel(); - - ////////////////////////////////////////////////////////////////////////// - //void objectChanged(UbObservable*); - //void objectWillBeDeleted(UbObservable*); - - virtual int getColumnNumber() = 0; - virtual int getRowNumber() = 0; - virtual std::string getColumnLabel(int column) = 0; - virtual int getColumnType(int column) = 0; - virtual std::string getStringValue(int row, int col) = 0; - virtual void setStringValue(int row, int col, std::string str) = 0; - virtual int getSelectedRowIndex() = 0; - //virtual bool GetBoolValue(int row, int col) = 0; -}; - -#endif //UBTABLEMODEL_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbTiming.h b/src/VirtualFluids_GPU/basics/utilities/UbTiming.h deleted file mode 100644 index 8ca16d22a..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbTiming.h +++ /dev/null @@ -1,429 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTIMING_H -#define UBTIMING_H - -#include <string> -#include <limits> -#include <iostream> -#include <sstream> -#include <vector> -#include <ctime> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#ifdef CAB_MPI - #include <mpi.h> - #include <basics/parallel/PbMpi.h> -#endif //CAB_MPI - -/*=========================================================================*/ -// UbTiming - Time Measuring -// -// -// -//This Class provides the base for ... -//<BR><BR> -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> -//@version 1.1 - 14.02.06 -// - -class UbTiming -{ -public: - UbTiming() - { - this->duration = 0.0; - this->deltaT = 0.0; - this->startTime = 0; - this->name = "noname"; - } - /*==========================================================*/ - UbTiming(const std::string& name) - { - this->duration = 0.0; - this->deltaT = 0.0; - this->startTime = 0; - this->name = name; - } - /*==========================================================*/ - virtual ~UbTiming() {} - /*==========================================================*/ - virtual void initTiming() - { - this->duration = 0.0; - } - /*==========================================================*/ - virtual void startTiming() - { - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #else - this->startTime = (double)clock(); - #endif //CAB_MPI - } - /*==========================================================*/ - virtual void initAndStartTiming() - { - this->initTiming(); - this->startTiming(); - } - /*==========================================================*/ - virtual void endTiming() - { - this->stopTiming(); - } - /*==========================================================*/ - virtual void stopTiming() - { - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->deltaT = PbMpi::Wtime()-this->startTime; - #else - this->deltaT = ((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //CAB_MPI - - this->duration += this->deltaT; - } - /*==========================================================*/ - virtual double getDuration() const - { - return this->duration; - } - /*==========================================================*/ - virtual void setName(const std::string& name) - { - this->name = name; - } - /*==========================================================*/ - virtual std::string getName() const - { - return this->name; - } - /*==========================================================*/ - void start() - { - this->duration = 0.0; - - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #else - this->startTime = (double)clock(); - #endif //CAB_MPI - } - /*==========================================================*/ - void pause() - { - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->duration += PbMpi::Wtime()-this->startTime; - #else - this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //CAB_MPI - } - /*==========================================================*/ - void unpause() - { - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #else - this->startTime = (double)clock(); - #endif //CAB_MPI - } - /*==========================================================*/ - void stop() - { - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->duration += PbMpi::Wtime()-this->startTime; - #else - this->duration +=((double)clock()-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //CAB_MPI - } - /*==========================================================*/ - double getTicks() const - { - #if defined(CAB_MPI) && !defined(CAB_RUBY) - return PbMpi::Wtick(); - #else - return double(1.0)/double(CLOCKS_PER_SEC); - #endif //CAB_MPI - } - -protected: - std::string name; - - double startTime; - double duration; - double deltaT; -}; - -/*=========================================================================*/ -// UbTimer - Time Measuring -// -// -// -//This Class provides the base for ... -//<BR><BR> -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@version 1.0 - 16.08.2007 -// -#include <basics/utilities/UbSystem.h> //for definitons of system/OS type - -#ifdef UBSYSTEM_APPLE //Apple hack - #include <mach/mach_time.h> - #include <time.h> - #include <stdio.h> - inline void mach_absolute_difference(const uint64_t& end, const uint64_t& start, struct timespec *tp) - { - uint64_t difference = end - start; - static mach_timebase_info_data_t info = {0,0}; - - if (info.denom == 0) - mach_timebase_info(&info); - - uint64_t elapsednano = difference * (info.numer / info.denom); - - tp->tv_sec = elapsednano * 1e-9; - tp->tv_nsec = elapsednano - (tp->tv_sec * 1e9); - } -#elif defined(UBSYSTEM_LINUX) - #include <ctime> - #include <unistd.h> // for sysconf - #include <pthread.h> -#endif - -//example: -//t=0 start -//t=1 -//t=2 stop -> return 2; getLapTime=2; getTotalTime 2; getLapTimes: 2 -//t=3 -//t=4 -//t=5 stop -> return 3; getLapTime=3; getTotalTime 5; getLapTimes: 2,3 -//t=6 stop -> return 1; getLapTime=1; getTotalTime 6; getLapTimes: 2,3,1 -//t=7 -//t=8 start ->no consideration of time 7 and 8 -//t=9 -//t=10 stop -> return 2; getLapTime=2; getTotalTime 8; getLapTimes: 2,3,1,2 -//t=11 resetAndStart timer wird zurueckgestellt und neu gestaret -//t=12 -//t=13 -//t=14 stop -> return 3; getLapTime=3; getTotalTime 3; getLapTimes: 3 - -class UbTimer -{ -public: - UbTimer(const bool& storeLapTimes = false) - : name("unamed"), isMeasuring(false), storeLapTimes(storeLapTimes) - , startTime(0.0), totalTime(0.0), lapTime(0.0) - { - - } - /*==========================================================*/ - UbTimer(const std::string& name, const bool& storeLapTimes = false) - : name(name), isMeasuring(false), storeLapTimes(storeLapTimes) - , startTime(0.0), totalTime(0.0), lapTime(0.0) - { - - } - /*==========================================================*/ - virtual ~UbTimer() {} - /*==========================================================*/ - double getLapTime() const { return this->lapTime; } - std::vector<double> getLapTimes() const { return this->lapTimes; } - void setName(const std::string& name) { this->name = name; } - std::string getName() const { return this->name; } - bool isRunning() const { return isMeasuring; } - bool isStoringLapTimes() const { return storeLapTimes; } - /*==========================================================*/ - void setStoreLapTimes(const bool& storeLapTimes) { this->storeLapTimes = storeLapTimes; } - /*==========================================================*/ - void start() - { - this->isMeasuring = true; - - #if defined(CAB_MPI) && !defined(CAB_RUBY) - this->startTime = PbMpi::Wtime(); - #elif defined(UBSYSTEM_APPLE) - this->startTime = mach_absolute_time(); - #elif defined(UBSYSTEM_LINUX) - timespec tp; - clock_gettime(CLOCK_REALTIME,&tp); - this->startTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec); - #else - this->startTime = (double)clock(); - #endif //CAB_MPI - } - /*==========================================================*/ - void resetAndStart() { this->reset(); this->start(); } - /*==========================================================*/ - //stop: - stops the calculation and returns the time elapsed since last start/stop - // - timing continues - double stop() - { - //if start() was never activated before: - if(!isMeasuring) return 0.0; - - #if defined(CAB_MPI) && !defined(CAB_RUBY) - double actTime = PbMpi::Wtime(); - this->lapTime = actTime-this->startTime; - #elif defined(UBSYSTEM_APPLE) - double actTime = mach_absolute_time(); - timespec tp; - mach_absolute_difference(actTime, this->startTime, &tp); - this->lapTime = tp.tv_sec + tp.tv_nsec*1e-9; - #elif defined(UBSYSTEM_LINUX) - timespec tp; - clock_gettime(CLOCK_REALTIME,&tp); - double actTime = (double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec); - this->lapTime = (actTime-this->startTime)*1.0e-9; - #else - double actTime = (double)clock(); - this->lapTime = (actTime-this->startTime)/(double)CLOCKS_PER_SEC; - #endif //CAB_MPI - - this->startTime = actTime; - this->totalTime += this->lapTime; - if(storeLapTimes) lapTimes.push_back(this->lapTime); - - return lapTime; - } - /*==========================================================*/ - void reset() - { - this->isMeasuring = false; - - this->startTime = 0.0; - this->totalTime = 0.0; - this->lapTime = 0.0; - - lapTimes.resize(0); - } - /*==========================================================*/ - double getCurrentLapTime() const - { - //if start() was never activated before: - if(!isMeasuring) return 0.0; - - #if defined(CAB_MPI) && !defined(CAB_RUBY) - return PbMpi::Wtime() - this->startTime; - #elif defined(UBSYSTEM_APPLE) - timespec tp; - mach_absolute_difference(mach_absolute_time(), this->startTime, &tp); - return tp.tv_sec + tp.tv_nsec*1e-9; - #elif defined(UBSYSTEM_LINUX) - timespec tp; - clock_gettime(CLOCK_REALTIME,&tp); - return ((double)(tp.tv_sec)*1.0e9 + (double)(tp.tv_nsec) - this->startTime)*1.0e-9; - #else - return ( (double)clock() - this->startTime ) / (double)CLOCKS_PER_SEC; - #endif //CAB_MPI - - } - /*==========================================================*/ - double getTotalTime() const - { - return this->totalTime; - } - /*==========================================================*/ - std::string toString() - { - std::stringstream text; - text<<*this; - return text.str(); - } - - //ueberladene Operatoren - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, const UbTimer& timer) - { - os<<"UbTimer[totalTime="<<timer.totalTime<<"sec, lapTimes("; - for(std::size_t i=0; i<timer.lapTimes.size(); i++) os<<timer.lapTimes[i]<<","; - os<<")]"; - return os; - } - - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & name; - ar & isMeasuring; - ar & startTime; - ar & totalTime; - ar & lapTime; - ar & lapTimes; - ar & storeLapTimes; - } -#endif //CAB_RCF - -protected: - std::string name; - bool isMeasuring; - bool storeLapTimes; - - double startTime; - double totalTime; - double lapTime; - - std::vector<double> lapTimes; -}; - - -/*=========================================================================*/ -// UbProgressTimer - Time Measuring -// -// -// -//UbProressTimer misst die Zeit von seiner Instantiierung bis zur Zerstörung -//und gib die verstrichene Zeit auf "os" in [s] aus -//example: -// { -// UbProgressTimer timer; -// UbSystem::sleepS(10); -// } //--> 10s -//<BR><BR> -//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -//@version 1.0 - 10.03.2008 -// -class UbProgressTimer : public UbTimer -{ -private: - UbProgressTimer(const UbProgressTimer& rhs); -public: - explicit UbProgressTimer( std::ostream & os = std::cout ) - : UbTimer(),os(os) - { - this->start(); - } - /*==========================================================*/ - ~UbProgressTimer() - { - // A) Throwing an exception from a destructor is a Bad Thing. - // B) The progress_timer destructor does output which may throw. - // C) A progress_timer is usually not critical to the application. - // Therefore, wrap the I/O in a try block, catch and ignore all exceptions. - try - { - // use istream instead of ios_base to workaround GNU problem (Greg Chicares) - std::istream::fmtflags old_flags = os.setf( std::istream::fixed, - std::istream::floatfield ); - std::streamsize old_prec = os.precision( 2 ); - os << stop() << " s" << std::endl; - os.flags( old_flags ); - os.precision( old_prec ); - } - catch (...) {} // eat any exceptions - } - -private: - std::ostream & os; -}; - - -#endif //UBTIMING_H diff --git a/src/VirtualFluids_GPU/basics/utilities/UbTuple.h b/src/VirtualFluids_GPU/basics/utilities/UbTuple.h deleted file mode 100644 index 6036f6734..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/UbTuple.h +++ /dev/null @@ -1,1144 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTUPLE_H -#define UBTUPLE_H - -#include <iostream> -#include <string> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -/*=========================================================================*/ -/* UbTuple */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.10.06 -*/ - -/* -usage: ... -////Advanced UbTuple -//Bsp: -//// create and use tuple with only one field -//UbTuple<int,int,int,int,int> t1; -//val<1>(t1) += 42; -//std::cout << t1.v1() << std::endl; - -//// create and use duo -//UbTuple<bool,int> t2; -//std::cout << val<1>(t2) << ", "; -//std::cout << t2.v1() << std::endl; - -//// create and use triple -//UbTuple<bool,int,double> t3; -//val<1>(t3) = true; // new values via: val< pos >(triple) = ... -//val<2>(t3) = 42; -//val<3>(t3) = 0.2; -//t3 = makeUbTuple(false, 23, 13.13); - -//std::cout << val<1>(t3) << ", "; -//std::cout << val<2>(t3) << ", "; -//std::cout << val<3>(t3) << std::endl; - -//// create and use quadruple -//UbType<bool,int,float,double> t4(true,42,13,1.95583); -//std::cout << val<4>(t4) << std::endl; //<- option 2 (std) -//std::cout << t4.v2().v2().v2() << std::endl; //<- option 2 -*/ - -//typeop.h -// primary template -/********************************** -* typeop1.hpp: -**********************************/ -template <typename T> -class UbTypeOp // primary template -{ -public: - typedef T ArgT; - typedef T BareT; - typedef T const ConstT; - typedef T & RefT; - typedef T & RefBareT; - typedef T const & RefConstT; -}; -/**** end of typeop1.hpp ****/ - -// partial specialization for const -/********************************** -* typeop2.hpp: -**********************************/ -template <typename T> -class UbTypeOp <T const> // partial specialization for const types -{ - public: - typedef T const ArgT; - typedef T BareT; - typedef T const ConstT; - typedef T const & RefT; - typedef T & RefBareT; - typedef T const & RefConstT; -}; -/**** end of typeop2.hpp ****/ - -// partial specialization for references -/********************************** -* typeop3.hpp: -**********************************/ -template <typename T> -class UbTypeOp <T&> // partial specialization for references -{ -public: - typedef T & ArgT; - typedef typename UbTypeOp<T>::BareT BareT; - typedef T const ConstT; - typedef T & RefT; - typedef typename UbTypeOp<T>::BareT & RefBareT; - typedef T const & RefConstT; -}; -/**** end of typeop3.hpp ****/ - -// full specialization for void -/********************************** -* typeop4.hpp: -**********************************/ -template<> -class UbTypeOp <void> // full specialization for void -{ -public: - typedef void ArgT; - typedef void BareT; - typedef void const ConstT; - typedef void RefT; - typedef void RefBareT; - typedef void RefConstT; -}; -/**** end of typeop4.hpp ****/ - -//duo1.hpp -template <typename T1, typename T2> -class UbDuo -{ -public: - typedef T1 Type1; // type of first field - typedef T2 Type2; // type of second field - enum { N = 2 }; // number of fields - -public: - // constructors - UbDuo() : value1(), value2() { } - UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } - - // for implicit type conversion during construction - template <typename U1, typename U2> - UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } - - // for implicit type conversion during assignments - template <typename U1, typename U2> - UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) - { - value1 = d.v1();//value1; - value2 = d.v2();//value2; - return *this; - } - - // field access - T1& v1() { return value1; } - T1 const& v1() const { return value1; } - - T2& v2() { return value2; } - T2 const& v2() const { return value2; } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & value1; - ar & value2; - } -#endif //CAB_RCF - -private: - T1 value1; // value of first field - T2 value2; // value of second field -}; - -// comparison operators (allow mixed types): -template <typename T1, typename T2,typename U1, typename U2> -inline bool operator == (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -{ - return d1.v1()==d2.v1() && d1.v2()==d2.v2(); -} - -template <typename T1, typename T2,typename U1, typename U2> -inline bool operator != (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -{ - return !(d1==d2); -} - -template <typename T1, typename T2,typename U1, typename U2> -inline bool operator < (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -{ - if (d1.v1() < d2.v1() ) return true; - else if(d1.v1() == d2.v1() ) return d1.v2() < d2.v2(); - - return false; -} - -// convenience function for creation and initialization -template <typename T1, typename T2> -inline UbDuo<T1,T2> makeUbDuo(T1 const & a, T2 const & b) -{ - return UbDuo<T1,T2>(a,b); -} - -//duo2.hpp -template <typename A, typename B, typename C> -class UbDuo<A, UbDuo<B,C> > -{ -public: - typedef A T1; // type of first field - typedef UbDuo<B,C> T2; // type of second field - enum { N = UbDuo<B,C>::N + 1 }; // number of fields - -public: - // constructors - UbDuo() : value1(), value2() { } - UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } - - // for implicit type conversion during construction - template <typename U1, typename U2> - UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } - - // for implicit type conversion during assignments - template <typename U1, typename U2> - UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) - { - value1 = d.v1();//value1; - value2 = d.v2();//value2; - return *this; - } - - // field access - T1& v1() { return value1; } - T1 const& v1() const { return value1; } - - T2& v2() { return value2; } - T2 const& v2() const { return value2; } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & value1; - ar & value2; - } -#endif //CAB_RCF - -private: - T1 value1; // value of first field - T2 value2; // value of second field -}; - -//duo3.hpp -// primary template for type of Nth field of (duo) T -template <int N, typename T> -class UbDuoT -{ -public: - typedef void ResultT; // in general, the result type is void -}; - -// specialization for 1st field of a plain duo -template <typename A, typename B> -class UbDuoT<1, UbDuo<A,B> > -{ -public: - typedef A ResultT; -}; - -// specialization for 2nd field of a plain duo -template <typename A, typename B> -class UbDuoT<2, UbDuo<A,B> > -{ -public: - typedef B ResultT; -}; - -// specialization for Nth field of a recursive duo -template <int N, typename A, typename B, typename C> -class UbDuoT<N, UbDuo<A, UbDuo<B,C> > > -{ -public: - typedef typename UbDuoT<N-1, UbDuo<B,C> >::ResultT ResultT; -}; - -// specialization for 1st field of a recursive duo -template <typename A, typename B, typename C> -class UbDuoT<1, UbDuo<A, UbDuo<B,C> > > -{ -public: - typedef A ResultT; -}; - -// specialization for 2nd field of a recursive duo -template <typename A, typename B, typename C> -class UbDuoT<2, UbDuo<A, UbDuo<B,C> > > -{ -public: - typedef B ResultT; -}; - -//duo4.hpp -// primary template for value of Nth field of (duo) T -template <int N, typename T> -class DuoValue -{ -public: - static void get(T&) { } // in general, we have no value - static void get(T const&) { } -}; - -// specialization for 1st field of a plain duo -template <typename A, typename B> -class DuoValue<1, UbDuo<A, B> > -{ -public: - static A& get(UbDuo<A, B> &d) { return d.v1(); } - static A const& get(UbDuo<A, B> const &d) { return d.v1(); } -}; - -// specialization for 2nd field of a plain duo -template <typename A, typename B> -class DuoValue<2, UbDuo<A, B> > -{ -public: - static B& get(UbDuo<A, B> &d) { return d.v2(); } - static B const& get(UbDuo<A, B> const &d) { return d.v2(); } -}; - -// specialization for Nth field of recursive duo -template <int N, typename A, typename B, typename C> -struct DuoValue<N, UbDuo<A, UbDuo<B,C> > > -{ - static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefT get(UbDuo<A, UbDuo<B,C> > &d) - { - return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); - } - static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefConstT get(UbDuo<A, UbDuo<B,C> > const &d) - { - return DuoValue<N-1, UbDuo<B,C> >::get(d.v2()); - } -}; - -// specialization for 1st field of recursive duo -template <typename A, typename B, typename C> -class DuoValue<1, UbDuo<A, UbDuo<B,C> > > -{ -public: - static A& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v1(); } - static A const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v1(); } -}; - -// specialization for 2nd field of recursive duo -template <typename A, typename B, typename C> -class DuoValue<2, UbDuo<A, UbDuo<B,C> > > -{ -public: - static B& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v2().v1(); } - static B const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v2().v1(); } -}; - -//duo5.hpp -// return Nth value of variable duo -template <int N, typename A, typename B> -inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefT val(UbDuo<A, B>& d) -{ - return DuoValue<N, UbDuo<A, B> >::get(d); -} - -// return Nth value of constant duo -template <int N, typename A, typename B> -inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT val(UbDuo<A, B> const& d) -{ - return DuoValue<N, UbDuo<A, B> >::get(d); -} - -//duo6.hpp -// partial specialization for UbDuo<> with only one field -template <typename A> -struct UbDuo<A,void> -{ -public: - typedef A T1; // type of first field - typedef void T2; // type of second field - enum { N = 1 }; // number of fields - -private: - T1 value1; // value of first field - -public: - // constructors - UbDuo() : value1() { } - UbDuo (T1 const & a) : value1(a) { } - - // field access - T1& v1() { return value1; } - T1 const& v1() const { return value1; } - - void v2() { } - void v2() const { } - - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & value1; - } - #endif -}; - -//tupel1.hpp -// type that represents unused type parameters -class UbNullT -{ -}; - -// UbTuple<> in general derives from UbTuple<> with one more UbNullT -template <typename P1, - typename P2 = UbNullT, - typename P3 = UbNullT, - typename P4 = UbNullT, - typename P5 = UbNullT, - typename P6 = UbNullT, - typename P7 = UbNullT, - typename P8 = UbNullT > -class UbTuple : public UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT> -{ -public: - typedef UbDuo<P1, typename UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>::BaseT> BaseT; - - // constructor: - UbTuple() {} - UbTuple( typename UbTypeOp<P1>::RefConstT a1, - typename UbTypeOp<P2>::RefConstT a2, - typename UbTypeOp<P3>::RefConstT a3 = UbNullT(), - typename UbTypeOp<P4>::RefConstT a4 = UbNullT(), - typename UbTypeOp<P5>::RefConstT a5 = UbNullT(), - typename UbTypeOp<P6>::RefConstT a6 = UbNullT(), - typename UbTypeOp<P7>::RefConstT a7 = UbNullT(), - typename UbTypeOp<P8>::RefConstT a8 = UbNullT() ) - : BaseT(a1, UbTuple<P2,P3,P4,P5,P6,P7,P8,UbNullT>(a2,a3,a4,a5,a6,a7,a8)) - { - } - - // for implicit type conversion during assignments - template <typename U1,typename U2, typename U3, typename U4, typename U5, typename U6, typename U7, typename U8 > - UbTuple<P1,P2,P3,P4,P5,P6,P7,P8>& operator = ( const UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>& rhs) - { - this->BaseT::operator=( typename UbTuple<U1,U2,U3,U4,U5,U6,U7,U8>::BaseT(rhs) ); - return *this; - } - -}; - -// specialization to end deriving recursion -template <typename P1, typename P2> -class UbTuple<P1,P2,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,P2> { -public: - typedef UbDuo<P1,P2> BaseT; - - // constructor: - UbTuple() {} - UbTuple( typename UbTypeOp<P1>::RefConstT a1, - typename UbTypeOp<P2>::RefConstT a2, - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) - : BaseT(a1, a2) - { - } - - // for implicit type conversion during assignments - template <typename U1,typename U2 > - UbTuple<P1,P2>& operator = ( const UbTuple<U1,U2>& rhs) - { - this->BaseT::operator=( typename UbTuple<U1,U2>::BaseT(rhs) ); - return *this; - } - -}; - -// specialization for singletons -template <typename P1> -class UbTuple<P1,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,void> -{ -public: - typedef UbDuo<P1,void> BaseT; - - // constructor: - UbTuple() {} - UbTuple( typename UbTypeOp<P1>::RefConstT a1, - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), - typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) - : BaseT(a1) - { - } - - // for implicit type conversion during assignments - template <typename U1 > - UbTuple<P1>& operator = ( const UbTuple<U1>& rhs) - { - this->v1() = rhs.v1(); - return *this; - } - -}; - -// convenience function for 1 argument -template <typename T1> -inline UbTuple<T1> makeUbTuple(T1 const &a1) -{ - return UbTuple<T1>(a1); -} - -// convenience function for 2 arguments -template <typename T1, typename T2> -inline UbTuple<T1,T2> makeUbTuple(T1 const &a1, T2 const &a2) -{ - return UbTuple<T1,T2>(a1,a2); -} - -// convenience function for 3 arguments -template <typename T1, typename T2, typename T3> -inline UbTuple<T1,T2,T3> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3) -{ - return UbTuple<T1,T2,T3>(a1,a2,a3); -} - -// convenience function for 4 arguments -template <typename T1, typename T2, typename T3, typename T4> -inline UbTuple<T1,T2,T3,T4> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4) -{ - return UbTuple<T1,T2,T3,T4>(a1,a2,a3,a4); -} - -// convenience function for 5 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5> -inline UbTuple<T1,T2,T3,T4,T5> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4,T5 const &a5) -{ - return UbTuple<T1,T2,T3,T4,T5>(a1,a2,a3,a4,a5); -} - -// convenience function for 6 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> -inline UbTuple<T1,T2,T3,T4,T5,T6> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6) -{ - return UbTuple<T1,T2,T3,T4,T5,T6>(a1,a2,a3,a4,a5,a6); -} - -// convenience function for 7 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> -inline UbTuple<T1,T2,T3,T4,T5,T6,T7> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4, T5 const &a5, T6 const &a6, T7 const &a7) -{ - return UbTuple<T1,T2,T3,T4,T5,T6,T7>(a1,a2,a3,a4,a5,a6,a7); -} - -// convenience function for 8 arguments -template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> -inline UbTuple<T1,T2,T3,T4,T5,T6,T7,T8> makeUbTuple(T1 const &a1, T2 const &a2,T3 const &a3, T4 const &a4,T5 const &a5, T6 const &a6,T7 const &a7, T8 const &a8 ) -{ - return UbTuple<T1,T2,T3,T4,T5,T6,T7,T8>(a1,a2,a3,a4,a5,a6,a7,a8); -} - -//some typedefs -typedef UbTuple<float,float> UbTupleFloat2; -typedef UbTuple<float,float,float> UbTupleFloat3; -typedef UbTuple<float,float,float,float,float,float> UbTupleFloat6; -typedef UbTuple<int,int> UbTupleInt2; -typedef UbTuple<int,int,int> UbTupleInt3; -typedef UbTuple<int,int,int,int> UbTupleInt4; -typedef UbTuple<int,int,int,int,int> UbTupleInt5; -typedef UbTuple<int,int,int,int,int,int> UbTupleInt6; -typedef UbTuple<int,int,int,int,int,int,int> UbTupleInt7; -typedef UbTuple<int,int,int,int,int,int,int,int> UbTupleInt8; -typedef UbTuple<unsigned int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int> UbTupleUInt8; -typedef UbTuple<long,long,long,long,long,long,long,long> UbTupleLong8; -typedef UbTuple<long long,long long,long long,long long,long long,long long,long long,long long> UbTupleLongLong8; -typedef UbTuple<double,double> UbTupleDouble2; -typedef UbTuple<double,double,double> UbTupleDouble3; -typedef UbTuple<double,double,double,double> UbTupleDouble4; -typedef UbTuple<double,double,double,double,double,double> UbTupleDouble6; -typedef UbTuple<double,double,double,double,double,double,double> UbTupleDouble7; -typedef UbTuple<std::string,double,double> UbTupleStringDouble2; -typedef UbTuple<std::string,double,double,double> UbTupleStringDouble3; -typedef UbTuple<std::string,int,int,int> UbTupleStringInt3; -typedef UbTuple<short,short,short,short> UbTupleShort4; -typedef UbTuple<bool,bool,bool> UbTupleBool3; -typedef UbTuple<int,double,double> UbTupleIntDouble2; -typedef UbTuple<int, bool> UbTupleIntBool; - - -// class UbTupleWrapper -// { -// public: -// UbTuple<int, int> a; -// -// #ifdef CAB_RCF -// template<class Archive> -// void SF_SERIALIZE(Archive & ar) -// { -// ar & a; -// } -// void tuWas() -// { -// std::cout<<val<1>(a)<<std::endl; -// -// std::cout<<val<2>(a)<<std::endl; -// } -// -// #endif -// -// }; - - -#endif //UBTUPLE_H - - -//#ifndef AAAAAAAAAAAAAAAAAAAAAAAAAAAAA //UBTUPLE_H -//#define AAAAAAAAAAAAAAAAAAAAAAAAAAAAA //UBTUPLE_H -//class UbTuble; -//#include <iostream> -//#include <string> -//#include <algorithm> -// -// -//// a helper traits to make the make_tuple functions shorter (Vesa Karvonen's suggestion) -//struct UbNullType{}; -// -//template < class T0 = UbNullType, class T1 = UbNullType, class T2 = UbNullType, -//class T3 = UbNullType, class T4 = UbNullType, class T5 = UbNullType, -//class T6 = UbNullType, class T7 = UbNullType, class T8 = UbNullType > -//class UbSimpleTuple -//{ -//public: -// UbSimpleTuple() {} -// UbSimpleTuple(T0 t0) {} -// UbSimpleTuple( const T0& t0) -// : t0(t0) {} -// UbSimpleTuple( const T0& t0, const T1& t1) -// : t0(t0), t1(t1){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2) -// : t0(t0), t1(t1), t2(t2) {} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3) -// : t0(t0), t1(t1), t2(t2), t3(t3){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5), t6(t6){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5), t6(t6), t7(t7){} -// UbSimpleTuple( const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) -// : t0(t0), t1(t1), t2(t2), t3(t3), t4(t4), t5(t5), t6(t6), t7(t7), t8(t8){} -// -// T0 t0; -// T1 t1; -// T2 t2; -// T3 t3; -// T4 t4; -// T5 t5; -// T6 t6; -// T7 t7; -// T8 t8; -//}; -// -// -//UbSimpleTuple<> -//inline makeUbSimpleTuple() { return UbSimpleTuple<>(); } -// -//template<class T0> -//inline UbSimpleTuple<T0> makeUbSimpleTuple(const T0& t0) { return UbSimpleTuple<T0>(t0); } -// -//template<class T0, class T1> -//inline UbSimpleTuple<T0,T1> makeUbSimpleTuple(const T0& t0, const T1& t1) { return UbSimpleTuple<T0,T1>(t0,t1); } -// -//template<class T0, class T1, class T2> -//inline UbSimpleTuple<T0,T1,T2> makeUbSimpleTuple(const T0& t0, const T1& t1, const T2& t2) { return UbSimpleTuple<T0,T1,T2>(t0,t1,t2); } -// -//template<class T0, class T1, class T2, class T3> -//inline UbSimpleTuple<T0,T1,T2,T3> makeUbSimpleTuple(const T0& t0, const T1& t1, const T2& t2, const T3& t3) { return UbSimpleTuple<T0,T1,T2,T3>(t0,t1,t2,t2); } -// -//////////////////////////////////////////////////////////////////////////// -////Advanced UbTuple -////Bsp: -// //// create and use tuple with only one field -// //UbTuple<int,int,int,int,int> t1; -// //val<1>(t1) += 42; -// //std::cout << t1.v1() << std::endl; -// -// //UbTuple<int,double,double> ttt3; -// //val<3>(t3); -// // -// //// create and use duo -// //UbType<bool,int> t2; -// //std::cout << val<1>(t2) << ", "; -// //std::cout << t2.v1() << std::endl; -// -// //// create and use triple -// //UbType<bool,int,double> t3; -// //val<1>(t3) = true; -// //val<2>(t3) = 42; -// //val<3>(t3) = 0.2; -// -// //std::cout << val<1>(t3) << ", "; -// //std::cout << val<2>(t3) << ", "; -// //std::cout << val<3>(t3) << std::endl; -// -// //t3 = make_tuple(false, 23, 13.13); -// -// //std::cout << val<1>(t3) << ", "; -// //std::cout << val<2>(t3) << ", "; -// //std::cout << val<3>(t3) << std::endl; -// -// //// create and use quadruple -// //UbType<bool,int,float,double> t4(true,42,13,1.95583); -// //std::cout << val<4>(t4) << std::endl; -// //std::cout << t4.v2().v2().v2() << std::endl; -// -////typeop.hpp -//// primary template -///********************************** -//* typeop1.hpp: -//**********************************/ -//template <typename T> -//class UbTypeOp // primary template -//{ -//public: -// typedef T ArgT; -// typedef T BareT; -// typedef T const ConstT; -// typedef T & RefT; -// typedef T & RefBareT; -// typedef T const & RefConstT; -//}; -///**** end of typeop1.hpp ****/ -// -//// partial specialization for const -///********************************** -//* typeop2.hpp: -//**********************************/ -//template <typename T> -//class UbTypeOp <T const> // partial specialization for const types -//{ -// public: -// typedef T const ArgT; -// typedef T BareT; -// typedef T const ConstT; -// typedef T const & RefT; -// typedef T & RefBareT; -// typedef T const & RefConstT; -//}; -///**** end of typeop2.hpp ****/ -// -//// partial specialization for references -///********************************** -//* typeop3.hpp: -//**********************************/ -//template <typename T> -//class UbTypeOp <T&> // partial specialization for references -//{ -//public: -// typedef T & ArgT; -// typedef typename UbTypeOp<T>::BareT BareT; -// typedef T const ConstT; -// typedef T & RefT; -// typedef typename UbTypeOp<T>::BareT & RefBareT; -// typedef T const & RefConstT; -//}; -///**** end of typeop3.hpp ****/ -// -//// full specialization for void -///********************************** -//* typeop4.hpp: -//**********************************/ -//template<> -//class UbTypeOp <void> // full specialization for void -//{ -//public: -// typedef void ArgT; -// typedef void BareT; -// typedef void const ConstT; -// typedef void RefT; -// typedef void RefBareT; -// typedef void RefConstT; -//}; -///**** end of typeop4.hpp ****/ -// -////duo1.hpp -//template <typename T1, typename T2> -//class UbDuo -//{ -//public: -// typedef T1 Type1; // type of first field -// typedef T2 Type2; // type of second field -// enum { N = 2 }; // number of fields -// -//private: -// T1 value1; // value of first field -// T2 value2; // value of second field -// -//public: -// // constructors -// UbDuo() : value1(), value2() { } -// UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } -// -// // for implicit type conversion during construction -// template <typename U1, typename U2> -// UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } -// -// // for implicit type conversion during assignments -// template <typename U1, typename U2> -// UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) -// { -// value1 = d.value1; -// value2 = d.value2; -// return *this; -// } -// -// // field access -// T1& v1() { return value1; } -// T1 const& v1() const { return value1; } -// -// T2& v2() { return value2; } -// T2 const& v2() const { return value2; } -//}; -// -//// comparison operators (allow mixed types): -//template <typename T1, typename T2, -//typename U1, typename U2> -//inline bool operator == (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -//{ -// return d1.v1()==d2.v1() && d1.v2()==d2.v2(); -//} -// -//template <typename T1, typename T2, -//typename U1, typename U2> -//inline bool operator != (UbDuo<T1,T2> const& d1, UbDuo<U1,U2> const& d2) -//{ -// return !(d1==d2); -//} -// -//// convenience function for creation and initialization -//template <typename T1, typename T2> -//inline UbDuo<T1,T2> makeUbDuo(T1 const & a, T2 const & b) -//{ -// return UbDuo<T1,T2>(a,b); -//} -// -////duo2.hpp -//template <typename A, typename B, typename C> -//class UbDuo<A, UbDuo<B,C> > -//{ -//public: -// typedef A T1; // type of first field -// typedef UbDuo<B,C> T2; // type of second field -// enum { N = UbDuo<B,C>::N + 1 }; // number of fields -// -//private: -// T1 value1; // value of first field -// T2 value2; // value of second field -// -//public: -// // constructors -// UbDuo() : value1(), value2() {} -// UbDuo (T1 const & a, T2 const & b) : value1(a), value2(b) { } -// -// // for implicit type conversion during construction -// template <typename U1, typename U2> -// UbDuo (UbDuo<U1,U2> const & d) : value1(d.v1()), value2(d.v2()) { } -// -// // for implicit type conversion during assignments -// template <typename U1, typename U2> -// UbDuo<T1, T2>& operator = (UbDuo<U1,U2> const & d) -// { -// value1 = d.value1; -// value2 = d.value2; -// return *this; -// } -// -// // field access -// T1& v1() { return value1; } -// T1 const& v1() const { return value1; } -// -// T2& v2() { return value2; } -// T2 const& v2() const { return value2; } -//}; -// -////duo3.hpp -//// primary template for type of Nth field of (duo) T -//template <int N, typename T> -//class UbDuoT -//{ -//public: -// typedef void ResultT; // in general, the result type is void -//}; -// -//// specialization for 1st field of a plain duo -//template <typename A, typename B> -//class UbDuoT<1, UbDuo<A,B> > -//{ -//public: -// typedef A ResultT; -//}; -// -//// specialization for 2nd field of a plain duo -//template <typename A, typename B> -//class UbDuoT<2, UbDuo<A,B> > -//{ -//public: -// typedef B ResultT; -//}; -// -//// specialization for Nth field of a recursive duo -//template <int N, typename A, typename B, typename C> -//class UbDuoT<N, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// typedef typename UbDuoT<N-1, UbDuo<B,C> >::ResultT ResultT; -//}; -// -//// specialization for 1st field of a recursive duo -//template <typename A, typename B, typename C> -//class UbDuoT<1, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// typedef A ResultT; -//}; -// -//// specialization for 2nd field of a recursive duo -//template <typename A, typename B, typename C> -//class UbDuoT<2, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// typedef B ResultT; -//}; -// -////duo4.hpp -//// primary template for value of Nth field of (duo) T -//template <int N, typename T> -//class UbDuoValue -//{ -//public: -// static void get(T&) { } // in general, we have no value -// static void get(T const&) { } -//}; -// -//// specialization for 1st field of a plain duo -//template <typename A, typename B> -//class UbDuoValue<1, UbDuo<A, B> > -//{ -//public: -// static A& get(UbDuo<A, B> &d) { return d.v1(); } -// static A const& get(UbDuo<A, B> const &d) { return d.v1();} -//}; -// -//// specialization for 2nd field of a plain duo -//template <typename A, typename B> -//class UbDuoValue<2, UbDuo<A, B> > -//{ -//public: -// static B& get(UbDuo<A, B> &d) -// { -// return d.v2(); -// } -// static B const& get(UbDuo<A, B> const &d) { return d.v2(); } -//}; -// -//// specialization for Nth field of recursive duo -//template <int N, typename A, typename B, typename C> -//struct UbDuoValue<N, UbDuo<A, UbDuo<B,C> > > -//{ -// static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefT -// get(UbDuo<A, UbDuo<B,C> > &d) { return UbDuoValue<N-1, UbDuo<B,C> >::get(d.v2()); } -// -// static typename UbTypeOp<typename UbDuoT<N-1, UbDuo<B,C> >::ResultT>::RefConstT -// get(UbDuo<A, UbDuo<B,C> > const &d) { return UbDuoValue<N-1, UbDuo<B,C> >::get(d.v2()); } -//}; -// -//// specialization for 1st field of recursive duo -//template <typename A, typename B, typename C> -//class UbDuoValue<1, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// static A& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v1(); } -// static A const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v1(); } -//}; -// -//// specialization for 2nd field of recursive duo -//template <typename A, typename B, typename C> -//class UbDuoValue<2, UbDuo<A, UbDuo<B,C> > > -//{ -//public: -// static B& get(UbDuo<A, UbDuo<B,C> > &d) { return d.v2().v1(); } -// static B const& get(UbDuo<A, UbDuo<B,C> > const &d) { return d.v2().v1(); } -//}; -// -////duo5.hpp -//// return Nth value of variable duo -//template <int N, typename A, typename B> -//inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefT -//val(UbDuo<A, B>& d) -//{ -// return UbDuoValue<N, UbDuo<A, B> >::get(d); -//} -// -//// return Nth value of constant duo -//template <int N, typename A, typename B> -//inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT -//val(UbDuo<A, B> const& d) -//{ -// return UbDuoValue<N, UbDuo<A, B> >::get(d); -//} -// -////duo6.hpp -//// partial specialization for UbDuo<> with only one field -//template <typename A> -//struct UbDuo<A,void> -//{ -//public: -// typedef A T1; // type of first field -// typedef void T2; // type of second field -// enum { N = 1 }; // number of fields -// -//private: -// T1 value1; // value of first field -// -//public: -// // constructors -// UbDuo() : value1() { } -// UbDuo (T1 const & a) : value1(a) { } -// -// // field access -// T1& v1() { return value1; } -// T1 const& v1() const { return value1; } -// -// void v2() { } -// void v2() const { } -// //... -//}; -// -////tuple1.hpp -//// a helper traits to make the make_tuple functions shorter (Vesa Karvonen's suggestion) -//struct UbNullT{}; -// -//// UbType<> in general derives from UbType<> with one more UbNullT -//template <typename P1, -// typename P2 = UbNullT, -// typename P3 = UbNullT, -// typename P4 = UbNullT, -// typename P5 = UbNullT> -//class UbType : public UbDuo<P1, typename UbType<P2,P3,P4,P5,UbNullT>::BaseT> -//{ -//public: -// typedef UbDuo<P1, typename UbType<P2,P3,P4,P5,UbNullT>::BaseT> BaseT; -// -// // constructors: -// UbType() {} -// UbType(typename UbTypeOp<P1>::RefConstT a1, -// typename UbTypeOp<P2>::RefConstT a2, -// typename UbTypeOp<P3>::RefConstT a3 = UbNullT(), -// typename UbTypeOp<P4>::RefConstT a4 = UbNullT(), -// typename UbTypeOp<P5>::RefConstT a5 = UbNullT() ) : BaseT(a1, UbType<P2,P3,P4,P5,UbNullT>(a2,a3,a4,a5)) -// { -// } -//}; -// -//// specialization to end deriving recursion -//template <typename P1, typename P2> -//class UbType<P1,P2,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,P2> -//{ -//public: -// typedef UbDuo<P1,P2> BaseT; -// UbType() {} -// UbType(typename UbTypeOp<P1>::RefConstT a1, -// typename UbTypeOp<P2>::RefConstT a2, -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) : BaseT(a1, a2) -// { -// } -//}; -// -//// specialization for singletons -//template <typename P1> -//class UbType<P1,UbNullT,UbNullT,UbNullT,UbNullT> : public UbDuo<P1,void> -//{ -//public: -// typedef UbDuo<P1,void> BaseT; -// UbType() {} -// UbType(typename UbTypeOp<P1>::RefConstT a1, -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT(), -// typename UbTypeOp<UbNullT>::RefConstT = UbNullT() ) : BaseT(a1) -// { -// } -//}; -// -//// convenience function for 1 argument -//template <typename T1> -//inline UbType<T1> makeUbTuple(T1 const &a1) -//{ -// return UbType<T1>(a1); -//} -// -//// convenience function for 2 arguments -//template <typename T1, typename T2> -//inline UbType<T1,T2> makeUbTuple(T1 const &a1, T2 const &a2) -//{ -// return UbType<T1,T2>(a1,a2); -//} -// -//// convenience function for 3 arguments -//template <typename T1, typename T2, typename T3> -//inline UbType<T1,T2,T3> makeUbTuple(T1 const &a1, T2 const &a2, T3 const &a3) -//{ -// return UbType<T1,T2,T3>(a1,a2,a3); -//} -// -//// convenience function for 4 arguments -//template <typename T1, typename T2, typename T3, typename T4> -//inline UbType<T1,T2,T3,T4> make_tuple(T1 const &a1, T2 const &a2, T3 const &a3, T4 const &a4) -//{ -// return UbType<T1,T2,T3,T4>(a1,a2,a3,a4); -//} -// -//// convenience function for 5 arguments -//template <typename T1, typename T2, typename T3, -//typename T4, typename T5> -//inline UbType<T1,T2,T3,T4,T5> make_tuple(T1 const &a1, T2 const &a2,T3 const &a3, T4 const &a4,T5 const &a5) -//{ -// return UbType<T1,T2,T3,T4,T5>(a1,a2,a3,a4,a5); -//} -// -//#endif - diff --git a/src/VirtualFluids_GPU/basics/utilities/email/composer.cpp b/src/VirtualFluids_GPU/basics/utilities/email/composer.cpp deleted file mode 100644 index 9bb2a5ff2..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/composer.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** $Id: qt/composer.cpp 3.3.1 edited May 27 2003 $ -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of an example program for Qt. This example -** program may be used, distributed and modified without limitation. -** -*****************************************************************************/ - -#include "composer.h" -#include "smtp.h" - -#include <qlineedit.h> -#include <qmultilineedit.h> -#include <qpushbutton.h> -#include <qlabel.h> -#include <qlayout.h> - -Composer::Composer( QWidget *parent ) : QWidget( parent ) -{ - outStandigEmails = 0; - QGridLayout * layout = new QGridLayout( this, 1, 1, 6 ); - - layout->addWidget( new QLabel( tr( "From:" ), this ), 0, 0 ); - from = new QLineEdit( this ); - layout->addWidget( from, 0, 1 ); - - layout->addWidget( new QLabel( tr( "To:" ), this ), 1, 0 ); - to = new QLineEdit( this ); - layout->addWidget( to, 1, 1 ); - - layout->addWidget( new QLabel( tr( "Subject:" ), this ), 2, 0 ); - subject = new QLineEdit( this ); - layout->addWidget( subject, 2, 1 ); - - message = new QMultiLineEdit( this ); - layout->addMultiCellWidget( message, 3, 3, 0, 1 ); - - send = new QPushButton( tr( "&Send" ), this ); - layout->addWidget( send, 4, 0 ); - connect( send, SIGNAL( clicked() ), this, SLOT( sendMessage() ) ); - - sendStatus = new QLabel( this ); - layout->addWidget( sendStatus,4, 1 ); -} -void Composer::sendMessage(const QString &from, const QString &to,const QString &subject,const QString &body) -{ - outStandigEmails++; - - Smtp *smtp = new Smtp( from,to, subject,body ); - connect( smtp, SIGNAL(status(const QString &)),this, SLOT(coutText(const QString &)) ); - connect( smtp, SIGNAL(destroyed()),this, SLOT(reduceEmailCounter()) ); -} -void Composer::sendMessage(const QString &from, const QString &to,const QString &subject,const QString &body,const QString &smtpServer) -{ - outStandigEmails++; - - Smtp *smtp = new Smtp( from,to, subject,body,smtpServer ); - connect( smtp, SIGNAL(status(const QString &)),this, SLOT(coutText(const QString &)) ); - connect( smtp, SIGNAL(destroyed()),this, SLOT(reduceEmailCounter()) ); -} - -void Composer::sendMessage() -{ - send->setEnabled( FALSE ); - sendStatus->setText( tr( "Looking up mail servers" ) ); - - outStandigEmails++; - Smtp *smtp = new Smtp(from->text(), to->text(),subject->text(),message->text()); - connect( smtp, SIGNAL(status(const QString &)),sendStatus, SLOT(setText(const QString &)) ); - connect( smtp, SIGNAL(destroyed()),this, SLOT(reduceEmailCounter()) ); - connect( smtp, SIGNAL(destroyed()),this, SLOT(enableSend()) ); -} - -void Composer::enableSend() -{ - send->setEnabled( TRUE ); -} - -void Composer::coutText(const QString& text) -{ - cout<<text<<endl; -} - -void Composer::reduceEmailCounter() -{ - outStandigEmails--; - cout<<"outstanding Emails : "<<outStandigEmails<<endl; -} diff --git a/src/VirtualFluids_GPU/basics/utilities/email/composer.h b/src/VirtualFluids_GPU/basics/utilities/email/composer.h deleted file mode 100644 index f49e37b90..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/composer.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef COMPOSER_H -#define COMPOSER_H - -#include <iostream> -using namespace std; - -#include <qwidget.h> - -class QLineEdit; -class QMultiLineEdit; -class QLabel; -class QPushButton; - - -class Composer : public QWidget -{ - Q_OBJECT -public: - Composer( QWidget *parent = 0 ); - void sendMessage(const QString &from, const QString &to,const QString &subject,const QString &body); - void sendMessage(const QString &from, const QString &to,const QString &subject,const QString &body,const QString &smtpServer); - -private slots: - void sendMessage(); - void enableSend(); - void coutText(const QString& text); - void reduceEmailCounter(); - -private: - int outStandigEmails; - QLineEdit *from, *to, *subject; - QMultiLineEdit *message; - QLabel * sendStatus; - QPushButton * send; -}; - - -#endif diff --git a/src/VirtualFluids_GPU/basics/utilities/email/main.cpp b/src/VirtualFluids_GPU/basics/utilities/email/main.cpp deleted file mode 100644 index 64d12afc1..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <qapplication.h> -#include <qsocket.h> -#include <qstring.h> - -#include "composer.h" -#include "smtp.h" -#include <iostream> -using namespace std; - - -int main( int argc, char **argv ) -{ - QApplication a( argc, argv ); - - - Composer *c = new Composer(); - //a.setMainWidget(c); - //c->show(); - //return a.exec(); - - QString from = "muffmolch@gmx.de"; - QString to = "muffmolch@gmx.de"; - QString subject = "Kaffeeautomat-Reinigung die "; - QString body = "Danke für den Gratis-Kaffee"; - - int j=1; - for(int i=0;i<2;i++) - { - QString subject2; - subject2= subject+QString::number(j++)+"."; - c->sendMessage(from,to,subject2,body,"mail.irmb.bau.tu-bs.de"); - } - - return a.exec(); -} diff --git a/src/VirtualFluids_GPU/basics/utilities/email/moc_composer.cpp b/src/VirtualFluids_GPU/basics/utilities/email/moc_composer.cpp deleted file mode 100644 index 97e104c5f..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/moc_composer.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** Composer meta object code from reading C++ file 'composer.h' -** -** Created: Mo 22. Nov 19:37:52 2004 -** by: The Qt MOC ($Id: $) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#undef QT_NO_COMPAT -#include "./composer.h" -#include <qmetaobject.h> -#include <qapplication.h> - -#include <private/qucomextra_p.h> -#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26) -#error "This file was generated using the moc from 3.3.1. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -const char *Composer::className() const -{ - return "Composer"; -} - -QMetaObject *Composer::metaObj = 0; -static QMetaObjectCleanUp cleanUp_Composer( "Composer", &Composer::staticMetaObject ); - -#ifndef QT_NO_TRANSLATION -QString Composer::tr( const char *s, const char *c ) -{ - if ( qApp ) - return qApp->translate( "Composer", s, c, QApplication::DefaultCodec ); - else - return QString::fromLatin1( s ); -} -#ifndef QT_NO_TRANSLATION_UTF8 -QString Composer::trUtf8( const char *s, const char *c ) -{ - if ( qApp ) - return qApp->translate( "Composer", s, c, QApplication::UnicodeUTF8 ); - else - return QString::fromUtf8( s ); -} -#endif // QT_NO_TRANSLATION_UTF8 - -#endif // QT_NO_TRANSLATION - -QMetaObject* Composer::staticMetaObject() -{ - if ( metaObj ) - return metaObj; - QMetaObject* parentObject = QWidget::staticMetaObject(); - static const QUMethod slot_0 = {"sendMessage", 0, 0 }; - static const QUMethod slot_1 = {"enableSend", 0, 0 }; - static const QUParameter param_slot_2[] = { - { "text", &static_QUType_QString, 0, QUParameter::In } - }; - static const QUMethod slot_2 = {"coutText", 1, param_slot_2 }; - static const QUMethod slot_3 = {"reduceEmailCounter", 0, 0 }; - static const QMetaData slot_tbl[] = { - { "sendMessage()", &slot_0, QMetaData::Private }, - { "enableSend()", &slot_1, QMetaData::Private }, - { "coutText(const QString&)", &slot_2, QMetaData::Private }, - { "reduceEmailCounter()", &slot_3, QMetaData::Private } - }; - metaObj = QMetaObject::new_metaobject( - "Composer", parentObject, - slot_tbl, 4, - 0, 0, -#ifndef QT_NO_PROPERTIES - 0, 0, - 0, 0, -#endif // QT_NO_PROPERTIES - 0, 0 ); - cleanUp_Composer.setMetaObject( metaObj ); - return metaObj; -} - -void* Composer::qt_cast( const char* clname ) -{ - if ( !qstrcmp( clname, "Composer" ) ) - return this; - return QWidget::qt_cast( clname ); -} - -bool Composer::qt_invoke( int _id, QUObject* _o ) -{ - switch ( _id - staticMetaObject()->slotOffset() ) { - case 0: sendMessage(); break; - case 1: enableSend(); break; - case 2: coutText((const QString&)static_QUType_QString.get(_o+1)); break; - case 3: reduceEmailCounter(); break; - default: - return QWidget::qt_invoke( _id, _o ); - } - return TRUE; -} - -bool Composer::qt_emit( int _id, QUObject* _o ) -{ - return QWidget::qt_emit(_id,_o); -} -#ifndef QT_NO_PROPERTIES - -bool Composer::qt_property( int id, int f, QVariant* v) -{ - return QWidget::qt_property( id, f, v); -} - -bool Composer::qt_static_property( QObject* , int , int , QVariant* ){ return FALSE; } -#endif // QT_NO_PROPERTIES diff --git a/src/VirtualFluids_GPU/basics/utilities/email/moc_smtp.cpp b/src/VirtualFluids_GPU/basics/utilities/email/moc_smtp.cpp deleted file mode 100644 index 386515bf2..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/moc_smtp.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** Smtp meta object code from reading C++ file 'smtp.h' -** -** Created: Mo 22. Nov 19:16:09 2004 -** by: The Qt MOC ($Id: $) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#undef QT_NO_COMPAT -#include "./smtp.h" -#include <qmetaobject.h> -#include <qapplication.h> - -#include <private/qucomextra_p.h> -#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26) -#error "This file was generated using the moc from 3.3.1. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -const char *Smtp::className() const -{ - return "Smtp"; -} - -QMetaObject *Smtp::metaObj = 0; -static QMetaObjectCleanUp cleanUp_Smtp( "Smtp", &Smtp::staticMetaObject ); - -#ifndef QT_NO_TRANSLATION -QString Smtp::tr( const char *s, const char *c ) -{ - if ( qApp ) - return qApp->translate( "Smtp", s, c, QApplication::DefaultCodec ); - else - return QString::fromLatin1( s ); -} -#ifndef QT_NO_TRANSLATION_UTF8 -QString Smtp::trUtf8( const char *s, const char *c ) -{ - if ( qApp ) - return qApp->translate( "Smtp", s, c, QApplication::UnicodeUTF8 ); - else - return QString::fromUtf8( s ); -} -#endif // QT_NO_TRANSLATION_UTF8 - -#endif // QT_NO_TRANSLATION - -QMetaObject* Smtp::staticMetaObject() -{ - if ( metaObj ) - return metaObj; - QMetaObject* parentObject = QObject::staticMetaObject(); - static const QUMethod slot_0 = {"dnsLookupHelper", 0, 0 }; - static const QUMethod slot_1 = {"readyRead", 0, 0 }; - static const QUMethod slot_2 = {"connected", 0, 0 }; - static const QMetaData slot_tbl[] = { - { "dnsLookupHelper()", &slot_0, QMetaData::Private }, - { "readyRead()", &slot_1, QMetaData::Private }, - { "connected()", &slot_2, QMetaData::Private } - }; - static const QUParameter param_signal_0[] = { - { 0, &static_QUType_QString, 0, QUParameter::In } - }; - static const QUMethod signal_0 = {"status", 1, param_signal_0 }; - static const QMetaData signal_tbl[] = { - { "status(const QString&)", &signal_0, QMetaData::Public } - }; - metaObj = QMetaObject::new_metaobject( - "Smtp", parentObject, - slot_tbl, 3, - signal_tbl, 1, -#ifndef QT_NO_PROPERTIES - 0, 0, - 0, 0, -#endif // QT_NO_PROPERTIES - 0, 0 ); - cleanUp_Smtp.setMetaObject( metaObj ); - return metaObj; -} - -void* Smtp::qt_cast( const char* clname ) -{ - if ( !qstrcmp( clname, "Smtp" ) ) - return this; - return QObject::qt_cast( clname ); -} - -// SIGNAL status -void Smtp::status( const QString& t0 ) -{ - activate_signal( staticMetaObject()->signalOffset() + 0, t0 ); -} - -bool Smtp::qt_invoke( int _id, QUObject* _o ) -{ - switch ( _id - staticMetaObject()->slotOffset() ) { - case 0: dnsLookupHelper(); break; - case 1: readyRead(); break; - case 2: connected(); break; - default: - return QObject::qt_invoke( _id, _o ); - } - return TRUE; -} - -bool Smtp::qt_emit( int _id, QUObject* _o ) -{ - switch ( _id - staticMetaObject()->signalOffset() ) { - case 0: status((const QString&)static_QUType_QString.get(_o+1)); break; - default: - return QObject::qt_emit(_id,_o); - } - return TRUE; -} -#ifndef QT_NO_PROPERTIES - -bool Smtp::qt_property( int id, int f, QVariant* v) -{ - return QObject::qt_property( id, f, v); -} - -bool Smtp::qt_static_property( QObject* , int , int , QVariant* ){ return FALSE; } -#endif // QT_NO_PROPERTIES diff --git a/src/VirtualFluids_GPU/basics/utilities/email/smtp.cpp b/src/VirtualFluids_GPU/basics/utilities/email/smtp.cpp deleted file mode 100644 index 5048fdf8a..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/smtp.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include "smtp.h" - -#include <qtextstream.h> -#include <qsocket.h> -#include <qdns.h> -#include <qtimer.h> -#include <qapplication.h> -#include <qmessagebox.h> -#include <qregexp.h> - -#include <iostream> -using namespace std; - -Smtp::Smtp( const QString &from, const QString &to,const QString &subject,const QString &body ) -{ - mSocket = new QSocket(this); - connect ( mSocket, SIGNAL( readyRead() ),this, SLOT( readyRead() ) ); - connect ( mSocket, SIGNAL( connected() ),this, SLOT( connected() ) ); - - mTextStream = new QTextStream(mSocket); - - //wenn man es nicht über autom. ermittlung machen möchte - mMxLookup = new QDns( from.mid( from.find( '@' )+1 ), QDns::Mx ); - connect( mMxLookup, SIGNAL(resultsReady()),this, SLOT(dnsLookupHelper()) ); - - mFrom = from; - mTo = to; - mSubject = subject; - mBody = body; - - state = Init; -} - -Smtp::Smtp( const QString &from, const QString &to,const QString &subject,const QString &body,const QString &smtpServer ) -{ - mSocket = new QSocket(this); - connect ( mSocket, SIGNAL( readyRead() ),this, SLOT( readyRead() ) ); - connect ( mSocket, SIGNAL( connected() ),this, SLOT( connected() ) ); - - mTextStream = new QTextStream(mSocket); - emit status( tr( "Connecting to " + smtpServer ) ); - mSocket->connectToHost(smtpServer,25); - - mFrom = from; - mTo = to; - mSubject = subject; - mBody = body; - - state = Init; -} - -Smtp::~Smtp() -{ - delete mTextStream; - delete mSocket; -} - -void Smtp::dnsLookupHelper() -{ - QValueList<QDns::MailServer> s = mMxLookup->mailServers(); - - if ( s.isEmpty() ) - { - if ( !mMxLookup->isWorking() ) emit status( tr( "Smtp::dnsLookupHelper() Error in MX record lookup" ) ); - return; - } - - emit status( tr( "Connecting to %1" ).arg( s.first().name ) ); - mSocket->connectToHost( s.first().name, 25 ); -} - - -void Smtp::connected() -{ - emit status( tr( "Connected to %1" ).arg( mSocket->peerName() ) ); -} - -void Smtp::readyRead() -{ - // SMTP is line-oriented - if ( !mSocket->canReadLine() ) return; - - QString responseLine; - QString response; - - do - { - responseLine = mSocket->readLine(); - response += responseLine; - } while( mSocket->canReadLine() && responseLine[3] != ' ' ); - - responseLine.truncate( 3 ); - - if ( state == Init && responseLine[0] == '2' ) - { - // banner was okay, let's go on - *mTextStream << "HELO there\r\n"; - state = Mail; - } - else if ( state == Mail && responseLine[0] == '2' ) - { - // HELO response was okay (well, it has to be) - *mTextStream<<"MAIL FROM: <"<<mFrom<<">\r\n"; - state = Rcpt; - } - else if ( state == Rcpt && responseLine[0] == '2' ) - { - *mTextStream << "RCPT TO: <" << mTo << ">\r\n"; - state = Data; - } - else if ( state == Data && responseLine[0] == '2' ) - { - *mTextStream << "DATA\r\n"; - state = Body; - } - else if ( state == Body && responseLine[0] == '3' ) - { - QString message = QString::fromLatin1( "From: " ) + mFrom + - QString::fromLatin1( "\nTo: " ) + mTo + - QString::fromLatin1( "\nSubject: " ) + mSubject + - QString::fromLatin1( "\n\n" ) + mBody + "\n"; - message.replace( QString::fromLatin1( "\n" ),QString::fromLatin1( "\r\n" ) ); - message.replace( QString::fromLatin1( "\r\n.\r\n" ),QString::fromLatin1( "\r\n..\r\n" ) ); - - *mTextStream << message << ".\r\n"; - state = Quit; - } - else if ( state == Quit && responseLine[0] == '2' ) - { - *mTextStream << "QUIT\r\n"; - // here, we just close. - state = Close; - emit status( tr( "Smtp::readyRead()::Message sent" ) ); - } - else if ( state == Close ) - { - deleteLater(); - return; - } - else - { - // something broke. - QMessageBox::warning( qApp->activeWindow(),tr( "Qt Mail Example" ), - tr( "Unexpected reply from SMTP server:\n\n" ) +response ); - - state = Close; - } -} diff --git a/src/VirtualFluids_GPU/basics/utilities/email/smtp.h b/src/VirtualFluids_GPU/basics/utilities/email/smtp.h deleted file mode 100644 index 0a8909d96..000000000 --- a/src/VirtualFluids_GPU/basics/utilities/email/smtp.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** $Id: qt/smtp.h 3.3.1 edited May 27 2003 $ -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part of an example program for Qt. This example -** program may be used, distributed and modified without limitation. -** -*****************************************************************************/ - -#ifndef SMTP_H -#define SMTP_H - -#include <qobject.h> -#include <qstring.h> - -class QSocket; -class QTextStream; -class QDns; - -class Smtp : public QObject -{ - Q_OBJECT - -public: - Smtp( const QString &from, const QString &to,const QString &subject, const QString &body ); - Smtp( const QString &from, const QString &to,const QString &subject, const QString &body,const QString &smtpServer ); - ~Smtp(); - -signals: - void status( const QString & ); - -private slots: - void dnsLookupHelper(); - void readyRead(); - void connected(); - -private: - enum State {Init,Mail,Rcpt,Data,Body,Quit,Close}; - int state; - - QString mFrom; - QString mTo; - QString mSubject; - QString mBody; - - QSocket* mSocket; - QTextStream* mTextStream; - QDns* mMxLookup; -}; - -#endif diff --git a/src/VirtualFluids_GPU/basics/utilities/package.include b/src/VirtualFluids_GPU/basics/utilities/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriter.h b/src/VirtualFluids_GPU/basics/writer/WbWriter.h deleted file mode 100644 index 305128eeb..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriter.h +++ /dev/null @@ -1,180 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITER_H -#define WBWRITER_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - -#define NOMINMAX - -#include <vector> -#include <string> -#include <fstream> -#include <sstream> -#include <iostream> -#include <map> - - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbPointerWrapper.h> -#include <basics/utilities/UbAutoRun.hpp> -#include <basics/objects/ObFactory.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class WbWriter; -typedef VFSharedPtr<WbWriter> WbWriterPtr; - - -class WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT(WbWriter) - #endif - - ////////////////////////////////////////////////////////////////////////// - virtual ~WbWriter() - { - - } - - ////////////////////////////////////////////////////////////////////////// - //rein virtuelle Methoden - virtual std::string getFileExtension() = 0; - - ////////////////////////////////////////////////////////////////////////// - //nodes - std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - virtual std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0 === 1 - //nodenumbering must start with 0! - virtual std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //quads - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - virtual std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, - std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, - std::vector< std::vector< double > >& celldata ){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata){ throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } -}; - - -#ifdef CAB_RCF -//serialize von singletons muss hier etwas anders erfolgen ;-) -template<class Archive> -inline bool serializeWbWriter(Archive &ar, WbWriter*& writer) -{ - std::string writerID; - - if( ArchiveTools::isReading(ar) ) - { - ar & writerID; - if(writerID!="no_WbWriter") writer = ObFactory<WbWriter>::getInstance()->createObject(writerID); - else writer = NULL; - } - else /* if (ar.isWrite())) if(Archive::is_saving())*/ - { - if(writer) writerID = writer->getClassObjectTypeID(); - else writerID = "no_WbWriter"; - ar & writerID; - } - return true; -} -////////////////// -template<class Archive, class STL_container> -inline bool serializeWbWriter(Archive &ar, STL_container& writers) -{ - int nofCounter; - std::string writerID; - WbWriter* dummy; - - if( ArchiveTools::isReading(ar) ) - { - ar & nofCounter; - for(int i=0; i<nofCounter; i++) - { - serializeWbWriter(ar, dummy); - writers.push_back(dummy); - } - } - else - { - nofCounter = (int)writers.size(); - ar & nofCounter; - typename STL_container::iterator pos; - for(pos=writers.begin(); pos!=writers.end(); ++pos) - serializeWbWriter(ar, *pos); - } - - return true; -} -////////////////////////////////////////////////////////////////////////// -// Spezialisierung des UbPointerWrappers fuer WbWriter... -// da man bei singletons keine serializemethode einbauen kann... -template< > -class UbPointerWrapper< WbWriter > -{ -public: - UbPointerWrapper() : pointer(NULL) {} - - UbPointerWrapper(WbWriter* pointer) : pointer(pointer) {} - - WbWriter* get() { return pointer; } - - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - serializeWbWriter(ar, pointer); - } - -private: - WbWriter* pointer; -}; - - -#endif //CAB_RCF - - -#endif //WBWRITER_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.cpp deleted file mode 100644 index 44c1889d8..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.cpp +++ /dev/null @@ -1,642 +0,0 @@ -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterAvsASCII::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+avsfilename); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuads to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOcts to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(), ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - out << "# UCD file created by WbWriterAvsASCII::writeQuadsWithNodeData" << endl; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - int nofNodeData = (int)datanames.size(); - - out << nofNodes << " " << nofCells << " " << nofNodeData << " 0 0 " << endl; - - //coords - for(int n=0; n<nofNodes; n++) - out << n+1 << " " << val<1>(nodes[n]) << " " << val<2>(nodes[n]) << " " << val<3>(nodes[n]) << " " << endl; - - //cells - for(int c=0; c<nofCells; c++) - out << c+1 << " 0 quad " << val<1>(cells[c])+1 << " " - << val<2>(cells[c])+1 << " " - << val<3>(cells[c])+1 << " " - << val<4>(cells[c])+1 << " " << endl; - - //NODE DATA - out << nofNodeData; - for(int d=0; d<nofNodeData; ++d) - out << " 1"; - out << endl; - for(int d=0; d<nofNodeData; ++d) - out << datanames[d].c_str() << ", no_unit" << endl; - - for(int n=0; n<nofNodes; n++) - { - out << n+1 << " "; - for(size_t d=0; d<nodedata.size(); d++) - out << nodedata[d][n] << " "; - - out << endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(), ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - out << "# UCD file created by WbWriterAvsASCII::writeQuadsWithCellData" << endl; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - int nofCellData = (int)datanames.size(); - - out << nofNodes << " " << nofCells << " 0 " << nofCellData << " 0 " << endl; - - //coords - for(int n=0; n<nofNodes; n++) - out << n+1 << " " << val<1>(nodes[n]) << " " << val<2>(nodes[n]) << " " << val<3>(nodes[n]) << " " << endl; - - //cells - for(int c=0; c<nofCells; c++) - out << c+1 << " 0 quad " << val<1>(cells[c])+1 << " " - << val<2>(cells[c])+1 << " " - << val<3>(cells[c])+1 << " " - << val<4>(cells[c])+1 << " " - << endl; - - //cell data - out << nofCellData; - for(int d=0; d<nofCellData; ++d) - out << " 1"; - out << endl; - for(int d=0; d<nofCellData; ++d) - out << datanames[d].c_str() << ", no_unit" << endl; - - for(int n=0; n<nofCells; n++) - { - out << n+1 << " "; - for(size_t d=0; d<celldata.size(); d++) - out << celldata[d][n] << " "; - - out << endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)nodedatanames.size(); - int nofCellData = (int)celldatanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char nodelabels[1024]; - char nodeunits[1024]; - strcpy(nodelabels, ""); - strcpy(nodeunits, ""); - - for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); } - strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit."); - strcat(nodeunits, "no_unit"); - - out.write((char*)&nodelabels,sizeof(nodelabels)); - out.write((char*)&nodeunits,sizeof(nodeunits)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //CELL DATA - char celllabels[1024]; - char cellunits[1024]; - strcpy(celllabels, ""); - strcpy(cellunits, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); } - strcat(celllabels, celldatanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit."); - strcat(cellunits, "no_unit"); - - out.write((char*)&celllabels,sizeof(celllabels)); - out.write((char*)&cellunits,sizeof(cellunits)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - out<<"# UCD-File created by WbWriterAvsASCII\n"; - out<<nofNodes<<" "<<nofLines<<" 0 0 0 "<<endl; - - for(int n=0; n<nofNodes; n++) - out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - - for(int l=0; l<nofLines; l++) - out<<l+1<<" 2 line "<< val<1>(lines[l])+1 <<" "<< val<2>(lines[l])+1 <<" "<<endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeLines to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden "+avsfilename); - } - - int nofNodes = (int)nodes.size(); - int nofTrian = (int)triangles.size(); - - out<<"# UCD-File created by WbWriterAvsASCII\n"; - out<<nofNodes<<" "<<nofTrian<<" 0 0 0 "<<endl; - - for(int n=0; n<nofNodes; n++) - out<<n+1<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - - for(int l=0; l<nofTrian; l++) - out<<l+1<<" 2 tri "<< val<1>(triangles[l])+1 <<" "<< val<2>(triangles[l])+1 <<" "<< val<3>(triangles[l])+1 <<" "<<endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTriangles to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end"); - - ofstream out(avsfilename.c_str(), ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - out << "# UCD file created by WbWriterAvsASCII::writeTrianglesWithNodeData" << endl; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - int nofNodeData = (int)datanames.size(); - - out << nofNodes << " " << nofCells << " " << nofNodeData << " 0 0 " << endl; - - //coords - for(int n=0; n<nofNodes; n++) - out << n+1 << " " << val<1>(nodes[n]) << " " << val<2>(nodes[n]) << " " << val<3>(nodes[n]) << " " << endl; - - //cells - for(int c=0; c<nofCells; c++) - out << c+1 << " 0 tri " << val<1>(cells[c])+1 << " " << val<2>(cells[c])+1 << " " << val<3>(cells[c])+1 << " " << endl; - - //NODE DATA - out << nofNodeData; - for(int d=0; d<nofNodeData; ++d) - out << " 1"; - out << endl; - for(int d=0; d<nofNodeData; ++d) - out << datanames[d].c_str() << ", no_unit" << endl; - - for(int n=0; n<nofNodes; n++) - { - out << n+1 << " "; - for(size_t d=0; d<nodedata.size(); d++) - out << nodedata[d][n] << " "; - - out << endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeTrianglesWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(), ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - out << "# UCD file created by WbWriterAvsASCII::writeOctsWithCellData" << endl; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - int nofCellData = (int)datanames.size(); - - out << nofNodes << " " << nofCells << " 0 " << nofCellData << " 0 " << endl; - - //coords - for(int n=0; n<nofNodes; n++) - out << n+1 << " " << val<1>(nodes[n]) << " " << val<2>(nodes[n]) << " " << val<3>(nodes[n]) << " " << endl; - - //cells - for(int c=0; c<nofCells; c++) - out << c+1 << " 0 hex " << val<1>(cells[c])+1 << " " - << val<2>(cells[c])+1 << " " - << val<3>(cells[c])+1 << " " - << val<4>(cells[c])+1 << " " - << val<5>(cells[c])+1 << " " - << val<6>(cells[c])+1 << " " - << val<7>(cells[c])+1 << " " - << val<8>(cells[c])+1 << " " - << endl; - - //cell data - out << nofCellData; - for(int d=0; d<nofCellData; ++d) - out << " 1"; - out << endl; - for(int d=0; d<nofCellData; ++d) - out << datanames[d].c_str() << ", no_unit" << endl; - - for(int n=0; n<nofCells; n++) - { - out << n+1 << " "; - for(size_t d=0; d<celldata.size(); d++) - out << celldata[d][n] << " "; - - out << endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; - } -/*===============================================================================*/ -std::string WbWriterAvsASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(), ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - - out << "# UCD file created by WbWriterAvsASCII::writeOctsWithNodeData" << endl; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - int nofNodeData = (int)datanames.size(); - - out << nofNodes << " " << nofCells << " " << nofNodeData << " 0 0 " << endl; - - //coords - for(int n=0; n<nofNodes; n++) - out << n+1 << " " << val<1>(nodes[n]) << " " << val<2>(nodes[n]) << " " << val<3>(nodes[n]) << " " << endl; - - //cells - for(int c=0; c<nofCells; c++) - out << c+1 << " 0 hex " << val<1>(cells[c])+1 << " " - << val<2>(cells[c])+1 << " " - << val<3>(cells[c])+1 << " " - << val<4>(cells[c])+1 << " " - << val<5>(cells[c])+1 << " " - << val<6>(cells[c])+1 << " " - << val<7>(cells[c])+1 << " " - << val<8>(cells[c])+1 << " " << endl; - - //NODE DATA - out << nofNodeData; - for(int d=0; d<nofNodeData; ++d) - out << " 1"; - out << endl; - for(int d=0; d<nofNodeData; ++d) - out << datanames[d].c_str() << ", no_unit" << endl; - - for(int n=0; n<nofNodes; n++) - { - out << n+1 << " "; - for(size_t d=0; d<nodedata.size(); d++) - out << nodedata[d][n] << " "; - - out << endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; - } diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.h b/src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.h deleted file mode 100644 index e09c77838..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsASCII.h +++ /dev/null @@ -1,80 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERAVSASCII_H -#define WBWRITERAVSASCII_H - -#include <basics/writer/WbWriter.h> - -class WbWriterAvsASCII : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterAvsASCII ) - #endif - - static WbWriterAvsASCII* getInstance() - { - static WbWriterAvsASCII instance; - return &instance; - } - -private: - WbWriterAvsASCII() : WbWriter() {} - WbWriterAvsASCII( const WbWriterAvsASCII& ); //no copy allowed - const WbWriterAvsASCII& operator=( const WbWriterAvsASCII& ); //no copy allowed - -public: - std::string getFileExtension() { return ".ascii.inp"; } - - ///////////////////virtual std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) = 0; - /////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //quads - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - std::string writeQuadsWithNodeData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - std::string writeQuadsWithCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeQuadsWithNodeAndCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >& celldata); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsWithCellData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata); -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsASCII ,WbWriter>::getInstance()), CAB_WbWriterAvsASCII); -#endif - -#endif //WBWRITERAVSASCII_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.cpp deleted file mode 100644 index 27b5a16b3..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.cpp +++ /dev/null @@ -1,975 +0,0 @@ -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterAvsBinary::writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){ UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary); } - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)lines.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 1; //line - int nofNodesPerCell = 2; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(lines[c])+1; out.write((char*)&idummy,sizeof(int)); - - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeLines to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)triangles.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 2; //triangle - int nofNodesPerCell = 3; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(triangles[c])+1; out.write((char*)&idummy,sizeof(int)); - - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTriangles to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuads to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOcts to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 2; //triangle - int nofNodesPerCell = 3; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeTrianglesWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"write_OutputFile-UCD File "+avsfilename+" konnte nicht geschrieben werden"); - } - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = (int)datanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - fdummy=0.0; - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //CELL DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, vector< vector< double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,avsfilename+" konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)nodedatanames.size(); - int nofCellData = (int)celldatanames.size(); - int nofModelData = 0; - int cellType = 3; //=quad - int nofNodesPerCell = 4; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //NODE DATA - char nodelabels[1024]; - char nodeunits[1024]; - strcpy(nodelabels, ""); - strcpy(nodeunits, ""); - - for(int d=0; d<nofNodeData-1; ++d) { strcat(nodelabels, nodedatanames[d].c_str() ); strcat(nodelabels,"."); } - strcat(nodelabels, nodedatanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(nodeunits, "no_unit."); - strcat(nodeunits, "no_unit"); - - out.write((char*)&nodelabels,sizeof(nodelabels)); - out.write((char*)&nodeunits,sizeof(nodeunits)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //CELL DATA - char celllabels[1024]; - char cellunits[1024]; - strcpy(celllabels, ""); - strcpy(cellunits, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(celllabels, celldatanames[d].c_str() ); strcat(celllabels,"."); } - strcat(celllabels, celldatanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(cellunits, "no_unit."); - strcat(cellunits, "no_unit"); - - out.write((char*)&celllabels,sizeof(celllabels)); - out.write((char*)&cellunits,sizeof(cellunits)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeQuadsWithNodeAndCellData to "<<avsfilename<<" - end"); - - return avsfilename; -} -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = 0; - int nofCellData = (int)datanames.size(); - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //out<<"\n"; - - //CELL DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofCellData-1; ++d) { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofCellData-1].c_str()); - - for(int d=0; d<nofCellData-1; ++d) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofCellData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofCellData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofCellData; ++d) - for(int n=0; n<(int)celldata[d].size(); n++) - { fdummy=(float)celldata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofCellData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithCellData to "<<avsfilename<<" - end"); - - return avsfilename; - } -/*===============================================================================*/ -std::string WbWriterAvsBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string avsfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - start"); - - ofstream out(avsfilename.c_str(),ios::out|ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(avsfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(avsfilename.c_str(),ios::out|ios::binary);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - if((int)nodedata.size()==0) throw UbException(UB_EXARGS,"no nodedata!!!"); - if(nodes.size()!=nodedata[0].size()) throw UbException(UB_EXARGS,"nodedata != nofNodes!!!"); - - char magic = (char)7; - int idummy; - float fdummy; - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int nofNodeData = (int)datanames.size(); - int nofCellData = 0; - int nofModelData = 0; - int cellType = 7; //=hex - int nofNodesPerCell = 8; - - out.write((char*)&magic,sizeof(char)); - out.write((char*)&nofNodes,sizeof(int)); - out.write((char*)&nofCells,sizeof(int)); - out.write((char*)&nofNodeData,sizeof(int)); - out.write((char*)&nofCellData,sizeof(int)); - out.write((char*)&nofModelData,sizeof(int)); - - idummy = (int)nofCells*nofNodesPerCell; - out.write((char*)&idummy,sizeof(int)); //(nof nodes) * (nodes per cell) - for(int c=0; c<nofCells; c++) - { - idummy=c+1; out.write((char*)&idummy,sizeof(int)); //cell id - idummy=1; out.write((char*)&idummy,sizeof(int)); //mat - idummy=nofNodesPerCell; out.write((char*)&idummy,sizeof(int)); //nodes per cell - idummy=cellType; out.write((char*)&idummy,sizeof(int)); //cell type - } - //knotennummern der einzelnen zellen - for(int c=0; c<nofCells; c++) - { - idummy = val<1>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<2>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<3>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<4>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<5>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<6>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<7>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - idummy = val<8>(cells[c])+1; out.write((char*)&idummy,sizeof(int)); - } - - //coords - //x1-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<1>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x2-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<2>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - //x3-coords - for(int n=0; n<nofNodes; n++) - { fdummy = (float)( val<3>(nodes[n]) ); out.write((char*)&fdummy ,sizeof(float)); } - - //NODE DATA - char labels[1024]; - char units[1024]; - strcpy(labels, ""); - strcpy(units, ""); - - for(int d=0; d<nofNodeData-1; ++d) - { strcat(labels, datanames[d].c_str() ); strcat(labels,"."); } - strcat(labels, datanames[nofNodeData-1].c_str()); - - for(int i=0;i<(nofNodeData-1);i++) strcat(units, "no_unit."); - strcat(units, "no_unit"); - - out.write((char*)&labels,sizeof(labels)); - out.write((char*)&units,sizeof(units)); - - //nof and type of data - idummy = nofNodeData; - out.write((char*)&idummy,sizeof(int)); //Datentypen pro knoten (hier = nof_node_data, da NUR skalare) - - idummy = 1; - for(int i=0;i<nofNodeData;i++) out.write((char*)&idummy,sizeof(int)); //jeder Datentyp ist ein skalarer Wert - - //min and max of data - fdummy = 0.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //min Wert pro Datentyp - fdummy = 1.0; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - //daten ins file schreiben - for(int d=0; d<nofNodeData; ++d) - for(int n=0; n<(int)nodedata[d].size(); n++) - { fdummy=(float)nodedata[d][n]; out.write((char*)&fdummy,sizeof(float)); } - - fdummy = 1.; - for(int i=0;i<nofNodeData;i++) out.write((char*)&fdummy,sizeof(float)); //max Wert pro Datentyp - - out.close(); - UBLOG(logDEBUG1,"WbWriterAvsBinary::writeOctsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; - } diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.h b/src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.h deleted file mode 100644 index 72a360831..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterAvsBinary.h +++ /dev/null @@ -1,78 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERAVSBINARY_H -#define WBWRITERAVSBINARY_H - -#include <basics/writer/WbWriter.h> - -class WbWriterAvsBinary : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterAvsBinary ) - #endif - - static WbWriterAvsBinary* getInstance() - { - static WbWriterAvsBinary instance; - return &instance; - } -private: - WbWriterAvsBinary() : WbWriter() {} - WbWriterAvsBinary( const WbWriterAvsBinary& ); //no copy allowed - const WbWriterAvsBinary& operator=( const WbWriterAvsBinary& ); //no copy allowed - -public: - std::string getFileExtension() { return ".bin.inp"; } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTuple<int,int,int> >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //quads - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - std::string writeQuadsWithNodeData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - std::string writeQuadsWithCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeQuadsWithNodeAndCellData(const std::string& filename, std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, std::vector< std::vector< double > >& celldata); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsWithCellData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata); -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsBinary ,WbWriter>::getInstance()), CAB_WbWriterAvsBinary); -#endif - -#endif //WBWRITERAVSBINARY_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.cpp deleted file mode 100644 index fa88708b2..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifdef CAB_ZLIB - #include <basics/writer/WbWriterBOBJ.h> - #include <basics/utilities/UbLogger.h> - #include <cstring> - - #include <zlib.h> - - - using namespace std; - /*===============================================================================*/ - std::string WbWriterBOBJ::writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles) - { - string bobjFilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - start"); - - gzFile gzf = gzopen( bobjFilename.c_str(), "wb1" ); - - size_t nofNodes = nodes.size(); - size_t nofTriangles = triangles.size(); - - //write to file - size_t numVerts; - //double v[3]; - if(sizeof(numVerts)!=4) { throw UbException(UB_EXARGS,"danger..."); } - numVerts = nofNodes; - gzwrite(gzf, &numVerts, sizeof(numVerts)); - - for(size_t k=0; k<nofNodes; k++) { - float vertp = val<1>(nodes[k]); - gzwrite(gzf, &vertp, sizeof(vertp)); - vertp = val<2>(nodes[k]); - gzwrite(gzf, &vertp, sizeof(vertp)); - vertp = val<3>(nodes[k]); - gzwrite(gzf, &vertp, sizeof(vertp)); - } - - //NORMAL VECTOR - //double n[3]; - gzwrite(gzf, &numVerts, sizeof(numVerts)); - for(size_t k=0; k<nofNodes; k++) { - //poly->GetPointData()->GetNormals()->GetTuple(k, n); - float normp = 0.0;//n[0]; - gzwrite(gzf, &normp, sizeof(normp)); - normp = 0.0;//n[1]; - gzwrite(gzf, &normp, sizeof(normp)); - normp = 0.0;//n[2]; - gzwrite(gzf, &normp, sizeof(normp)); - } - - //vtkIdType npts = 3; - //vtkIdType* pts; - size_t numTris = nofTriangles; - gzwrite(gzf, &numTris, sizeof(numTris)); - for(size_t k=0; k<nofTriangles/*(size_t)poly->GetNumberOfPolys()*/; k++) { - //poly->GetPolys()->GetNextCell(npts, pts); - //int triIndex = *pts; - //gzwrite(gzf, &triIndex, sizeof(triIndex)); - //triIndex = *(pts+1); - //gzwrite(gzf, &triIndex, sizeof(triIndex)); - //triIndex = *(pts+2); - //gzwrite(gzf, &triIndex, sizeof(triIndex)); - //poly->GetPolys()->GetNextCell(npts, pts); - int triIndex = val<1>(triangles[k]);//*pts; - gzwrite(gzf, &triIndex, sizeof(triIndex)); - triIndex = val<2>(triangles[k]);//*(pts+1); - gzwrite(gzf, &triIndex, sizeof(triIndex)); - triIndex = val<3>(triangles[k]);//*(pts+2); - gzwrite(gzf, &triIndex, sizeof(triIndex)); - } - - gzclose( gzf ); - - UBLOG(logDEBUG1,"WbWriterBOBJ::writeTriangles to "<<bobjFilename<<" - end"); - - return bobjFilename; - } - /*===============================================================================*/ - -#endif //CAB_ZLIB diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.h b/src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.h deleted file mode 100644 index 291ab9d9d..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterBOBJ.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifdef CAB_ZLIB - #ifndef WBWRITERBOBJ_H - #define WBWRITERBOBJ_H - - #include <string> - #include <basics/writer/WbWriter.h> - - class WbWriterBOBJ : public WbWriter - { - public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterBOBJ ) - #endif - - static WbWriterBOBJ* getInstance() - { - static WbWriterBOBJ instance; - return &instance; - } - private: - WbWriterBOBJ() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterBOBJ( const WbWriterBOBJ& ); //no copy allowed - const WbWriterBOBJ& operator=( const WbWriterBOBJ& ); //no copy allowed - - static std::string pvdEndTag; - - public: - std::string getFileExtension() { return "BOBJ.gz"; } - - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); - }; - - UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterBOBJ ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII); - - #endif //WBWRITERBOBJ_H - -#endif //CAB_ZLIB diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.cpp deleted file mode 100644 index 6adbc274a..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include <basics/writer/WbWriterSunflow.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -/*===============================================================================*/ -std::string WbWriterSunflow::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string sunflowFilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - start"); - - std::ofstream out(sunflowFilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(sunflowFilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(sunflowFilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+sunflowFilename); - } - - // General part - - // Image details - out<<"image {" <<endl; - out<<" resolution 640 480"<<endl; - out<<" aa 0 1" <<endl; - out<<" filter mitchell" <<endl; - out<<"}" <<endl<<endl; - - // Camera position - out<<"camera {" <<endl; - out<<" type pinhole" <<endl; - out<<" eye -0.25 -0.3 0.13"<<endl; - out<<" target -0.1 0.1 0.13" <<endl; - out<<" up 0 0 1" <<endl; - out<<" fov 60" <<endl; - out<<" aspect 1.333333" <<endl; - out<<"}" <<endl<<endl; - - // Light - out<<"light {" <<endl; - out<<" type ibl" <<endl; - out<<" image sky_small.hdr" <<endl; - out<<" center 0 -1 0" <<endl; - out<<" up 0 0 1" <<endl; - out<<" lock true" <<endl; - out<<" samples 200" <<endl; - out<<"}" <<endl<<endl; - - // Shaders - out<<"shader {" <<endl; - out<<" name default-shader" <<endl; - out<<" type diffuse" <<endl; - out<<" diff 0.25 0.25 0.25" <<endl; - out<<"}" <<endl<<endl; - - out<<"shader {" <<endl; - out<<" name Glass" <<endl; - out<<" type glass" <<endl; - out<<" eta 1.333" <<endl; - out<<" color 0.1 0.3 0.8" <<endl; - out<<"}" <<endl<<endl; - - out<<"shader {" <<endl; - out<<" name Mirror" <<endl; - out<<" type mirror" <<endl; - out<<" refl 0.7 0.7 0.7" <<endl; - out<<"}" <<endl<<endl; - - // Objects - // a) Ground plane - out<<"object {" <<endl; - out<<" shader default-shader" <<endl; - out<<" type plane" <<endl; - out<<" p 0 0 0" <<endl; - out<<" n 0 0 1" <<endl; - out<<"}" <<endl<<endl; - - // b) Mesh - out<<"object {" <<endl; - out<<" shader Glass" <<endl; - out<<" transform {" <<endl; - out<<" rotatey 270.0" <<endl; - out<<" }" <<endl; - out<<" type generic-mesh" <<endl; - out<<" name polySurfac" <<endl<<endl; - - - // POINTS SECTION - int nofNodes = (int)nodes.size(); - out<<" points "<<nofNodes<<endl; - for(int n=0; n<nofNodes; n++) - out<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl; - - // TRIANGLES SECTION - int nofTriangles= (int)triangles.size(); - out<<" triangles "<<nofTriangles<<endl; - for(int c=0; c<nofTriangles; c++) - out<<" "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl; - - // FOOTER - out<<" normals none" << endl; - out<<" uvs none" << endl; - out<<"}" << endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterSunflow::writeTriangles to "<<sunflowFilename<<" - end"); - - return sunflowFilename; -} -/*===============================================================================*/ diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.h b/src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.h deleted file mode 100644 index a14461b06..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterSunflow.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef WbWriterSunflow_H -#define WbWriterSunflow_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterSunflow : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterSunflow ) - - static WbWriterSunflow* getInstance() - { - static WbWriterSunflow instance; - return &instance; - } -private: - WbWriterSunflow() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterSunflow( const WbWriterSunflow& ); //no copy allowed - const WbWriterSunflow& operator=( const WbWriterSunflow& ); //no copy allowed - - static std::string pvdEndTag; - -public: - std::string getFileExtension() { return "ascii.sunflow"; } - - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterSunflow ,WbWriter>::getInstance()), CAB_WbWriterSunflow); - -#endif //WbWriterSunflow_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.cpp deleted file mode 100644 index 5e2ef86b4..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include <basics/writer/WbWriterTecPlotASCII.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/*===============================================================================*/ -string WbWriterTecPlotASCII::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string tecplotfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - start"); - - ofstream out(tecplotfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(tecplotfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(tecplotfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+tecplotfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"TITLE = VirtualFluids OctGrid from "<<UbSystem::getTimeStamp()<<endl; - - out<<"VARIABLES = \"X\", \"Y\", \"Z\""; - for(size_t d=0; d<datanames.size(); d++) - out<<", \""<<datanames[d]<<"\""; - out<<endl; - - out<<"ZONE NODES="<<nofNodes<<", ELEMENTS="<<nofCells<<", DATAPACKING=POINT, ZONETYPE=FEBRICK"<<endl; - for(size_t n=0; n<nodes.size(); n++) - { - UbTupleFloat3& coords = nodes[n]; - out<<val<1>(coords)<<" " - <<val<2>(coords)<<" " - <<val<3>(coords); - for(size_t d=0; d<datanames.size(); d++) - out<<" "<<nodedata[d][n]; - out<<endl; - } - - for(size_t c=0; c<cells.size(); c++) - { - UbTupleInt8& cell = cells[c]; - out<<val<1>(cell)<<" " - <<val<2>(cell)<<" " - <<val<3>(cell)<<" " - <<val<4>(cell)<<" " - <<val<5>(cell)<<" " - <<val<6>(cell)<<" " - <<val<7>(cell)<<" " - <<val<8>(cell)<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterTecPlotASCII::writeOctsWithNodeData to "<<tecplotfilename<<" - end"); - - return tecplotfilename; -} -/*===============================================================================*/ -string WbWriterTecPlotASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - vector<string > datanames; - vector<vector<double > > nodedata; - return writeOctsWithNodeData(filename,nodes,cells,datanames,nodedata); -} -/*===============================================================================*/ diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.h b/src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.h deleted file mode 100644 index 01b067557..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterTecPlotASCII.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef WBWRITERTECPLOTASCII_H -#define WBWRITERTECPLOTASCII_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterTecPlotASCII : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterTecPlotASCII ) - #endif - - static WbWriterTecPlotASCII* getInstance() - { - static WbWriterTecPlotASCII instance; - return &instance; - } -private: - WbWriterTecPlotASCII() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"machine error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"machine error float type mismatch"); - } - - WbWriterTecPlotASCII( const WbWriterTecPlotASCII& ); //no copy allowed - const WbWriterTecPlotASCII& operator=( const WbWriterTecPlotASCII& ); //no copy allowed - - static std::string pvdEndTag; -public: - std::string getFileExtension() { return ".ascii.dat"; } - - //write a metafile -// std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); -// std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); -// std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames); - - ////////////////////////////////////////////////////////////////////////// - //nodes -// std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes); -// std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! -// std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); -// std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); -// - ////////////////////////////////////////////////////////////////////////// - //triangles - // 2 - // - // 0---1 - //nodenumbering must start with 0! -// std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); -// std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - -// std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); -// std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); -// std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); -// std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, -// std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, -// std::vector< std::vector< double > >& celldata ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - //std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterTecPlotASCII ,WbWriter>::getInstance()), CAB_WbWriterTecPlotASCII); -#endif - -#endif //WBWRITERTECPLOTASCII_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.cpp deleted file mode 100644 index 0c0309ede..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.cpp +++ /dev/null @@ -1,602 +0,0 @@ -#include <basics/writer/WbWriterVtkASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterVtkASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuads to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"8"<<endl; - out<<endl; - - //write node data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)nodedatanames.size(); ++s) - { - out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - //write cell data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)celldatanames.size(); ++s) - { - out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofLines<<" "<<3*nofLines<<"\n"; - int nr = 0; - for(int l=0; l<nofLines; l++) - { - int el = nr+1; - out<<"2 "<< val<1>(lines[l]) <<" "<< val<2>(lines[l]) <<" "<<endl; - nr=el+1; - } - out<<"\n"; - - out<<"CELL_TYPES "<<nofLines<<"\n"; - for(int l=0; l<nofLines; l++) out<<"3"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeLines to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofTriangles = (int)triangles.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n])<<" \n"; - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofTriangles<<" "<<4*nofTriangles<<"\n"; - int nr = 0; - for(int t=0; t<nofTriangles; t++) - { - int el = nr+1; - out<<"3 "<< val<1>(triangles[t]) <<" "<< val<2>(triangles[t]) <<" "<< val<3>(triangles[t]) <<" "<<endl; - nr=el+1; - } - out<<"\n"; - - out<<"CELL_TYPES "<<nofTriangles<<"\n"; - for(int l=0; l<nofTriangles; l++) out<<"5"<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTriangles to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<4*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"3 "<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"5"<<endl; - out<<endl; - - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -std::string WbWriterVtkASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<5*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - out<<"4 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<7>(cells[c]) <<" " - << val<8>(cells[c]) <<" \n"; - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"11 "<<endl; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - { out<<"8 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" \n"; - } - - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"11 "<<endl; - out<<endl; - - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //write geo - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VtkASCII FILE - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"GeoFile"<<"\n"; - out<<"ASCII"<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" \n"; - - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<9*nofCells<<"\n"; - for(int c=0; c<(int)cells.size(); c++) - { out<<"8 " - << val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" \n"; - } - out<<"\n"; - - out<<"CELL_TYPES "<<nofCells<<"\n"; - for(int i=0; i<nofCells; i++) out<<"11"<<endl; - out<<endl; - - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<"\n"; - - out<<endl; - } - - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.h b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.h deleted file mode 100644 index 2620552d3..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkASCII.h +++ /dev/null @@ -1,86 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERVTKASCII_H -#define WBWRITERVTKASCII_H - -#include <basics/writer/WbWriter.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class WbWriterVtkASCII; -typedef VFSharedPtr<WbWriterVtkASCII> WbWriterVtkASCIIPtr; - - -class WbWriterVtkASCII : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterVtkASCII ) - #endif - - static WbWriterVtkASCII* getInstance() - { - static WbWriterVtkASCII instance; - return &instance; - } -private: - WbWriterVtkASCII() : WbWriter() {} - WbWriterVtkASCII( const WbWriterVtkASCII& ); //no copy allowed - const WbWriterVtkASCII& operator=( const WbWriterVtkASCII& ); //no copy allowed - -public: - std::string getFileExtension() { return ".ascii.vtk"; } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, - std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, - std::vector< std::vector< double > >& celldata ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkASCII,WbWriter>::getInstance()), CAB_WbWriterVtkASCII); -#endif - -#endif //WBWRITERVTKASCII_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.cpp deleted file mode 100644 index 233587236..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.cpp +++ /dev/null @@ -1,747 +0,0 @@ -#include <basics/writer/WbWriterVtkBinary.h> -#include <basics/writer/WbWriterVtkASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -std::string WbWriterVtkBinary::writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines) -{ - return WbWriterVtkASCII::getInstance()->writeLines(filename,nodes,lines); -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells) -{ - return WbWriterVtkASCII::getInstance()->writeTriangles(filename,nodes,cells); -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - return WbWriterVtkASCII::getInstance()->writeTrianglesWithNodeData(filename,nodes,cells,datanames,nodedata); -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D2Q9MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuads to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D2Q9MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //DATA SECTION - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - { - float dummy = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - //HEADER-SECTION - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D2Q9MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //DATA SECTION - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - { - float dummy = (float)celldata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"D2Q9MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*5<<"\n"; - - int nodesPerCellDummy = 4; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int SW = val<1>(cells[c]); - int SE = val<2>(cells[c]); - int NE = val<3>(cells[c]); - int NW = val<4>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&SW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&SE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&NE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&SW,sizeof(int)); - out.write((char*)&SE,sizeof(int)); - out.write((char*)&NW,sizeof(int)); - out.write((char*)&NE,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 8; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //NODE DATA SECTION - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)nodedatanames.size(); ++s) - { - if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<nodedatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - { - float dummy = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - - //CELL DATA SECTION - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)celldatanames.size(); ++s) - { - if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<celldatanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - { - float dummy = (float)celldata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"CellD3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = (float)val<1>(nodes[n]); - float x2 = (float)val<2>(nodes[n]); - float x3 = (float)val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n"; - - int nodesPerCellDummy = 8; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int BSW = val<1>(cells[c]); int TSW = val<5>(cells[c]); - int BSE = val<2>(cells[c]); int TSE = val<6>(cells[c]); - int BNW = val<3>(cells[c]); int TNW = val<7>(cells[c]); - int BNE = val<4>(cells[c]); int TNE = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&BSW,sizeof(int)); - out.write((char*)&BSE,sizeof(int)); - out.write((char*)&BNE,sizeof(int)); - out.write((char*)&BNW,sizeof(int)); - out.write((char*)&TSW,sizeof(int)); - out.write((char*)&TSE,sizeof(int)); - out.write((char*)&TNE,sizeof(int)); - out.write((char*)&TNW,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 11; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //CELL DATA SECTION - //write data section - out<<"CELL_DATA "<<nofCells<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)celldata[s].size() != nofCells) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)celldata[s].size(); d++) - { - float dummy = (float)celldata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithCellData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - //HEADER-SECTION - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"CellD3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = val<1>(nodes[n]); - float x2 = val<2>(nodes[n]); - float x3 = val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n"; - - int nodesPerCellDummy = 8; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int BSW = val<1>(cells[c]); int TSW = val<5>(cells[c]); - int BSE = val<2>(cells[c]); int TSE = val<6>(cells[c]); - int BNW = val<3>(cells[c]); int TNW = val<7>(cells[c]); - int BNE = val<4>(cells[c]); int TNE = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&BSW,sizeof(int)); - out.write((char*)&BSE,sizeof(int)); - out.write((char*)&BNE,sizeof(int)); - out.write((char*)&BNW,sizeof(int)); - out.write((char*)&TSW,sizeof(int)); - out.write((char*)&TSE,sizeof(int)); - out.write((char*)&TNE,sizeof(int)); - out.write((char*)&TNW,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 11; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - - //NODE DATA SECTION - //write data section - out<<"POINT_DATA "<<nofNodes<<"\n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - if((int)nodedata[s].size() != nofNodes) throw UbException(UB_EXARGS,"datasetsize must be equal to nofNodes"); - out<<"SCALARS "<<datanames[s]<<" float 1 \n LOOKUP_TABLE default \n"; - for(int d=0; d<(int)nodedata[s].size(); d++) - { - float dummy = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&dummy,sizeof(float)); - out.write((const char*)&dummy,sizeof(float)); - } - out<<endl; - } - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename = filename + getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ofstream::out | ofstream::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //HEADER-SECTION - //WRITE BIGENDIAN VtkBinary FILE - bool swapByte = UbSystem::isLittleEndian(); - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - out<<"# vtk DataFile Version 4.0"<<"\n"; - out<<"CellD3Q19MasterNodeGrid"<<"\n"; - out<<""<<"\n"; - - //POINTS SECTION - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - out<<"POINTS "<<nofNodes<<" float"<<"\n"; - for(int n=0; n<nofNodes; n++) - { - float x1 = val<1>(nodes[n]); - float x2 = val<2>(nodes[n]); - float x3 = val<3>(nodes[n]); - - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&x1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&x3,sizeof(float)); - } - - out.write((char*)&x1,sizeof(float)); - out.write((char*)&x2,sizeof(float)); - out.write((char*)&x3,sizeof(float)); - } - out<<"\n"; - - //CELLS SECTION - out<<"CELLS "<<nofCells<<" "<<nofCells*9<<"\n"; - - int nodesPerCellDummy = 8; //nofNodesPerCell - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&nodesPerCellDummy,sizeof(int)); - for(int c=0; c<(int)cells.size(); c++) - { - int BSW = val<1>(cells[c]); int TSW = val<5>(cells[c]); - int BSE = val<2>(cells[c]); int TSE = val<6>(cells[c]); - int BNW = val<3>(cells[c]); int TNW = val<7>(cells[c]); - int BNE = val<4>(cells[c]); int TNE = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&BSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&BNE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TSE,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNW,sizeof(int)); - UbSystem::swapByteOrder((unsigned char*)&TNE,sizeof(int)); - } - - out.write((char*)&nodesPerCellDummy,sizeof(int)); - out.write((char*)&BSW,sizeof(int)); - out.write((char*)&BSE,sizeof(int)); - out.write((char*)&BNE,sizeof(int)); - out.write((char*)&BNW,sizeof(int)); - out.write((char*)&TSW,sizeof(int)); - out.write((char*)&TSE,sizeof(int)); - out.write((char*)&TNE,sizeof(int)); - out.write((char*)&TNW,sizeof(int)); - } - out<<"\n"; - - out<<"CELL_TYPES "<<(int)cells.size()<<"\n"; - int celltype = 11; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&celltype,sizeof(int)); - for(int c=0; c<nofCells; c++) - out.write((char*)&celltype,sizeof(int)); - - out<<endl; - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkBinary::writeOcts to "<<vtkfilename<<" - end"); - return vtkfilename; -} - diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.h b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.h deleted file mode 100644 index dd63d061a..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkBinary.h +++ /dev/null @@ -1,86 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERVTKBINARY_H -#define WBWRITERVTKBINARY_H - -#include <basics/writer/WbWriter.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class WbWriterVtkBinary; -typedef VFSharedPtr<WbWriterVtkBinary> WbWriterVtkBinaryPtr; - - -class WbWriterVtkBinary : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterVtkBinary ) - #endif - - static WbWriterVtkBinary* getInstance() - { - static WbWriterVtkBinary instance; - return &instance; - } -private: - WbWriterVtkBinary() : WbWriter() {} - WbWriterVtkBinary( const WbWriterVtkBinary& ); //no copy allowed - const WbWriterVtkBinary& operator=( const WbWriterVtkBinary& ); //no copy allowed - -public: - std::string getFileExtension() { return ".bin.vtk"; } - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - ////////////////////////////////////////////////////////////////////////// - //triangles - //cell numbering: - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, - std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, - std::vector< std::vector< double > >& celldata ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkBinary); -#endif - -#endif //WBWRITERVTKBINARY_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.cpp deleted file mode 100644 index 9b9041917..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.cpp +++ /dev/null @@ -1,1105 +0,0 @@ -#include <basics/writer/WbWriterVtkXmlASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::pvdEndTag =" </Collection>\n</VTKFile>"; -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups) -{ - std::string vtkfilename=filename+".pvd"; - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - std::string endian; - if(UbSystem::isLittleEndian()) endian = "LittleEndian"; - else endian = "BigEndian"; - out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >"<<endl; - out<<" <Collection>"<<endl; - - int group = 0, part=0; - for(std::size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>"<<endl; - if(sepGroups) group++; - else part++; - } - out<<pvdEndTag; - out.close(); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timeStep, const bool& sepGroups) -{ - std::string vtkfilename=filename; - std::fstream test(vtkfilename.c_str(), ios::in); - if(!test) - { - test.clear(); - vtkfilename += ".pvd"; - test.open(vtkfilename.c_str(), ios::in); - if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups); - } - - std::fstream out(vtkfilename.c_str(), ios::in | ios::out); - out.seekp(-(int)pvdEndTag.size()-1, ios_base::end); - - int group = 0; - for(std::size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>"<<endl; - if(sepGroups) group++; - } - out<<pvdEndTag; - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames) -{ - string vtkfilename=filename+".pvtu"; - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //VTK FILE - out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<"\t<PUnstructuredGrid GhostLevel=\"0\">"<<"\n"; - out<<"\t\t<PPoints>\n"; - out<<"\t\t\t<PDataArray type=\"Float32\" NumberOfComponents=\"3\" />\n "; - out<<"\t\t</PPoints>\n"; - out<<"\t\t<PPointData Scalars=\"PScalars\"> \n"; - for(size_t s=0; s<pointDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\" /> \n"; - - out<<"\t\t</PPointData>\n"; - out<<"\t\t<PCellData Scalars=\"PScalars\"> \n"; - for(size_t s=0; s<cellDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\" /> \n"; - - out<<" </PCellData>\n"; - for(size_t s=0; s<pieceSources.size(); s++) - out<<"<Piece Source=\""<<pieceSources[s]<<"\" /> \n"; - out<<"</PUnstructuredGrid> \n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeParallelFile to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuads to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <CellData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </CellData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*4<<" " ; - - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"8 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write PointData section - out<<" <PointData Scalars=\"PScalars\"> \n"; - for(int s=0; s<(int)nodedatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - - //write celldata section - out<<" <CellData Scalars=\"CScalars\"> \n"; - for(int s=0; s<(int)celldatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </CellData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofLines<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<=nofLines; c++) - out<<c*2<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<<"3 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofLines = (int)lines.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofLines<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<< val<1>(lines[c]) <<" "<< val<2>(lines[c])<<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<=nofLines; c++) - out<<c*2<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofLines; c++) - out<<"3 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLinesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofTriangles= (int)triangles.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofTriangles<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - - for(int c=0; c<nofTriangles; c++) - out<< val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int c=1; c<nofTriangles+1; c++) - out<<c*3<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int c=0; c<nofTriangles; c++) - out<<"5 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTriangles to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" "<< val<2>(cells[c]) <<" "<< val<3>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*3<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"5 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeTrianglesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*8<<" " ; - - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"11 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - - //write data section - out<<" <CellData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)celldata[s].size(); d++) - out<<celldata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </CellData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleUInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - unsigned int nofNodes = (unsigned int)nodes.size(); - unsigned int nofCells = (unsigned int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(unsigned int n=0; n<nofNodes; n++) - out<<val<1>(nodes[n])<<" "<<val<2>(nodes[n])<<" "<<val<3>(nodes[n])<<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"UInt32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(unsigned int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"UInt32\" Name=\"offsets\" format=\"ascii\">\n "; - for(unsigned int c=1; c<nofCells+1; c++) - out<<c*8<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(unsigned int c=0; c<nofCells; c++) - out<<"11 "; - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write PointData section - out<<" <PointData Scalars=\"PScalars\"> \n"; - for(unsigned int s=0; s<(unsigned int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\">"; - - for(unsigned int d=0; d<(unsigned int)nodedata[s].size(); d++) - { - //out<<base64_encode((unsigned char*)(&nodedata[s][d]),sizeof(float)); - //out.write((char*)&nodedata[s][d],sizeof(float)); - out<<nodedata[s][d]<<" "; - } - out<<"</DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<< val<1>(cells[c]) <<" " - << val<2>(cells[c]) <<" " - << val<4>(cells[c]) <<" " - << val<3>(cells[c]) <<" " - << val<5>(cells[c]) <<" " - << val<6>(cells[c]) <<" " - << val<8>(cells[c]) <<" " - << val<7>(cells[c]) <<" "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofCells+1; c++) - out<<c*8<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - - for(int c=0; c<nofCells; c++) - out<<"11 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOcts to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlASCII::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n"; - for(int n=0; n<nofNodes; n++) - out<< n << " "; - out<<"\n"; - - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n"; - for(int n=1; n<=nofNodes; n++) - out << n << " "; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"; - - for(int n=0; n<nofNodes; n++) - out<<"1 "; - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Cells>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeLines to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlASCII::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) -{ - string vtkfilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - start"); - - std::ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - //VTK FILE - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\"> \n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n "; - for(int n=0; n<nofNodes; n++) - out<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<" "; - - out<<"\n"; - out<<" </DataArray>\n"; - out<<" </Points>\n"; - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n "; - - for(int c=0; c<nofNodes; c++) - out << c <<" "; - out<<"\n"; - - out<<" </DataArray>\n"; - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n "; - for(int c=1; c<nofNodes+1; c++) - out<<c<<" " ; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n "; - for(int c=0; c<nofNodes; c++) - out<<"1 "; - - out<<"\n"; - out<<" </DataArray>\n"; - - out<<" </Cells>\n"; - - //write data section - out<<" <PointData Scalars=\"Scalars\"> \n"; - for(int s=0; s<(int)datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"ascii\"> \n"; - - for(int d=0; d<(int)nodedata[s].size(); d++) - out<<nodedata[s][d]<<" "; - - out<<"\n </DataArray>\n"; - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeNodesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.h b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.h deleted file mode 100644 index 66590cff0..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlASCII.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef WBWRITERVTKXMLASCII_H -#define WBWRITERVTKXMLASCII_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class WbWriterVtkXmlASCII; -typedef VFSharedPtr<WbWriterVtkXmlASCII> WbWriterVtkXmlASCIIPtr; - - -class WbWriterVtkXmlASCII : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterVtkXmlASCII ) - #endif - - static WbWriterVtkXmlASCII* getInstance() - { - static WbWriterVtkXmlASCII instance; - return &instance; - } -private: - WbWriterVtkXmlASCII() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterVtkXmlASCII( const WbWriterVtkXmlASCII& ); //no copy allowed - const WbWriterVtkXmlASCII& operator=( const WbWriterVtkXmlASCII& ); //no copy allowed - - static std::string pvdEndTag; - -public: - std::string getFileExtension() { return ".ascii.vtu"; } - - //write a metafile - std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timesteps, const bool& sepGroups);//std::vector<double>& groups, std::vector<double>& parts); - std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); - std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames); - - ////////////////////////////////////////////////////////////////////////// - //nodes - std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes); - std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //triangles - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, - std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, - std::vector< std::vector< double > >& celldata ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleUInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlASCII ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII); -#endif - -#endif //WBWRITERVTKXMLASCII_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.cpp deleted file mode 100644 index a057f3729..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.cpp +++ /dev/null @@ -1,1686 +0,0 @@ -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> - -using namespace std; - -/*===============================================================================*/ -string WbWriterVtkXmlBinary::pvdEndTag =" </Collection>\n</VTKFile>"; -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups) -{ - string vtkfilename=filename+".pvd"; - ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - string endian; - if(UbSystem::isLittleEndian()) endian = "LittleEndian"; - else endian = "BigEndian"; - out<<"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\""<<endian<<"\" >"<<endl; - out<<" <Collection>"<<endl; - - int group = 0, part=0; - for(size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<part<<"\" file=\""<<filenames[i]<<"\"/>"<<endl; - if(sepGroups) group++; - else part++; - } - out<<pvdEndTag; - out.close(); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::addFilesToCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups) -{ - string vtkfilename=filename; - fstream test(vtkfilename.c_str(), ios::in); - if(!test) - { - test.clear(); - vtkfilename += ".pvd"; - test.open(vtkfilename.c_str(), ios::in); - if(!test) return this->writeCollection(filename,filenames,timeStep,sepGroups); - } - - fstream out(vtkfilename.c_str(), ios::in | ios::out); - out.seekp(-(int)pvdEndTag.size()-1, ios_base::end); - - int group = 0; - for(size_t i=0; i<filenames.size(); i++) - { - out<<" <DataSet timestep=\""<<timeStep<<"\" group=\""<<group<<"\" part=\""<<i<<"\" file=\""<<filenames[i]<<"\"/>"<<endl; - if(sepGroups) group++; - } - out<<pvdEndTag; - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeParallelFile(const string& filename,vector<string>& pieceSources, vector<string>& pointDataNames, vector<string>& cellDataNames) -{ - string vtkfilename=filename+".pvtu"; - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - //VTK FILE - out<<"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<"\t<PUnstructuredGrid GhostLevel=\"0\">"<<"\n"; - out<<"\t\t<PPoints>\n"; - out<<"\t\t\t<PDataArray type=\"Float32\" NumberOfComponents=\"3\" />\n "; - out<<"\t\t</PPoints>\n"; - out<<"\t\t<PPointData Scalars=\"PScalars\"> \n"; - for(size_t s=0; s<pointDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< pointDataNames[s] <<"\" /> \n"; - - out<<"\t\t</PPointData>\n"; - out<<"\t\t<PCellData Scalars=\"PScalars\"> \n"; - for(size_t s=0; s<cellDataNames.size(); s++) - out<< " <PDataArray type=\"Float32\" Name=\""<< cellDataNames[s] <<"\" /> \n"; - - out<<" </PCellData>\n"; - for(size_t s=0; s<pieceSources.size(); s++) - out<<"<Piece Source=\""<<pieceSources[s]<<"\" /> \n"; - out<<"</PUnstructuredGrid> \n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeParallelFile to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeLines(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)lines.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 2 /*nodes per line */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per line */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of line */ * nofCells * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(lines[c]), sizeof(int) ); - out.write( (char*)&val<2>(lines[c]), sizeof(int) ); - - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 2 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 3; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLines to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -std::string WbWriterVtkXmlBinary::writeLinesWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)lines.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 2 /*nodes per line */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per line */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of line */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(lines[c]), sizeof(int) ); - out.write( (char*)&val<2>(lines[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 3 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 5; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeLinesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; - -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - - int nofNodes = (int)nodes.size(); - int nofCells = (int)triangles.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3-coord */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 3 /*nodes per triangle */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per triangle */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of triangle */ * nofCells * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(triangles[c]), sizeof(int) ); - out.write( (char*)&val<2>(triangles[c]), sizeof(int) ); - out.write( (char*)&val<3>(triangles[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 3 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 5; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out<<flush; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTriangles to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeTrianglesWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt3 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 3 /*nodes per tri */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per tri */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of tri */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 3 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 5; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeTrianglesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuads(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out<<flush; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuads to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuadsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuadsWithCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, vector< string >& datanames, vector< vector< double > >& celldata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofCells * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <CellData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </CellData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<celldata[s].size(); ++d) - { - //loake kopie machen, da in celldata "doubles" sind - float tmp = (float)celldata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - - out<<"\n</AppendedData>\n"; - - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt4 >& cells, - vector< string >& nodedatanames, vector< vector< double > >& nodedata, vector< string >& celldatanames, - vector< vector< double > >& celldata ) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 4 /*nodes per quad */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per quad */ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of quad */ * nofCells * sizeof(unsigned char); - int bytesScalarDataPoint = 1 /*scalar */ * nofNodes * sizeof(float); - int bytesScalarDataCell = 1 /*scalar */ * nofCells * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - // Point DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<nodedatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< nodedatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarDataPoint); - } - out<<" </PointData>\n"; - - - // Cell DATA SECTION - out<<" <CellData>\n"; - for(size_t s=0; s<celldatanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< celldatanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarDataCell); - } - out<<" </CellData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 4 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 8; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //Point DATA SECTION - //scalarData - for(size_t s=0; s<nodedatanames.size(); ++s) - { - out.write((char*)&bytesScalarDataPoint,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - //Cell DATA SECTION - //scalarData - for(size_t s=0; s<celldatanames.size(); ++s) - { - out.write((char*)&bytesScalarDataCell,bytesPerByteVal); - for(size_t d=0; d<celldata[s].size(); ++d) - { - //loake kopie machen, da in celldata "doubles" sind - float tmp = (float)celldata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeQuadsWithNodeAndCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& celldata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per oct*/ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofCells * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofCells * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <CellData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </CellData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - out.write( (char*)&val<5>(cells[c]), sizeof(int) ); - out.write( (char*)&val<6>(cells[c]), sizeof(int) ); - out.write( (char*)&val<8>(cells[c]), sizeof(int) ); - out.write( (char*)&val<7>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 8 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 11; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<celldata[s].size(); ++d) - { - //loake kopie machen, da in celldata "doubles" sind - float tmp = (float)celldata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithCellData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleUInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - unsigned int nofNodes = (unsigned int)nodes.size(); - unsigned int nofCells = (unsigned int)cells.size(); - - unsigned int bytesPerByteVal = 4; //==sizeof(int) - unsigned int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - unsigned int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(unsigned int ); - unsigned int bytesCellOffsets = 1 /*offset per oct*/ * nofCells * sizeof(unsigned int ); - unsigned int bytesCellTypes = 1 /*type of oct */ * nofCells * sizeof(unsigned char); - unsigned int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - unsigned int offset = 0; - //VTK FILE - out<<"<?xml version=\"0.1\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"UInt32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"UInt32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(unsigned int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(unsigned int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<5>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<6>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<8>(cells[c]), sizeof(unsigned int) ); - out.write( (char*)&val<7>(cells[c]), sizeof(unsigned int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - unsigned int itmp; - for(unsigned int c=1; c<=nofCells; c++) - { - itmp = 8 * c; - out.write( (char*)&itmp, sizeof(unsigned int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 11; - for(unsigned int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOctsWithNodeDataMS(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleUInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); - ////////////////////////////////////////////////////////////////////////// - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - ////////////////////////////////////////////////////////////////////////// - unsigned int nofNodes = (size_t)nodes.size(); - unsigned int nofCells = (size_t)cells.size(); - unsigned int pointsCell = 8; - unsigned int nFaceVerts = (1+pointsCell)*nofCells; - bool swapByte = UbSystem::isLittleEndian(); - float p1, p2, p3; - unsigned int c1, c2, c3, c4, c5, c6, c7, c8; - ////////////////////////////////////////////////////////////////////////// - //VTK FILE - out<<"# vtk DataFile Version 3.0\n"; - out<< filename <<"\n"; - out<<"BINARY\n"; - out<<"DATASET UNSTRUCTURED_GRID"<<"\n"; - ////////////////////////////////////////////////////////////////////////// - //POINTS SECTION - out<<"POINTS "<< nofNodes <<" float\n"; - for(unsigned int n=0; n<nofNodes; n++) - { - p1 = val<1>(nodes[n]); - p2 = val<2>(nodes[n]); - p3 = val<3>(nodes[n]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&p1,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&p2,sizeof(float)); - UbSystem::swapByteOrder((unsigned char*)&p3,sizeof(float)); - } - out.write((char*)&p1,sizeof(float)); - out.write((char*)&p2,sizeof(float)); - out.write((char*)&p3,sizeof(float)); - } - ////////////////////////////////////////////////////////////////////////// - //CELLS SECTION - out<<"\nCELLS "<< nofCells << " " << nFaceVerts <<"\n"; - for(unsigned int c=0; c<nofCells; c++) - { - c1 = val<1>(cells[c]); - c2 = val<2>(cells[c]); - c3 = val<3>(cells[c]); - c4 = val<4>(cells[c]); - c5 = val<5>(cells[c]); - c6 = val<6>(cells[c]); - c7 = val<7>(cells[c]); - c8 = val<8>(cells[c]); - if(swapByte) - { - UbSystem::swapByteOrder((unsigned char*)&c1,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c2,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c3,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c4,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c5,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c6,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c7,sizeof(unsigned int)); - UbSystem::swapByteOrder((unsigned char*)&c8,sizeof(unsigned int)); - } - out.write( (char*)&c1, sizeof(unsigned int) ); - out.write( (char*)&c2, sizeof(unsigned int) ); - out.write( (char*)&c3, sizeof(unsigned int) ); - out.write( (char*)&c4, sizeof(unsigned int) ); - out.write( (char*)&c5, sizeof(unsigned int) ); - out.write( (char*)&c6, sizeof(unsigned int) ); - out.write( (char*)&c7, sizeof(unsigned int) ); - out.write( (char*)&c8, sizeof(unsigned int) ); - } - ////////////////////////////////////////////////////////////////////////// - //cellTypes - out<<"\nCELL_TYPES "<< nofCells <<"\n"; - unsigned char vtkCellType = 12; //12 - for(unsigned int c=0; c<nofCells; c++) - { - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&vtkCellType,sizeof(unsigned char)); - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - ////////////////////////////////////////////////////////////////////////// - //DATA SECTION - out<<"\nPOINT_DATA "<< nofNodes << "\n" << "FIELD attributes " << datanames.size() << "\n"; - for(unsigned int s=0; s<datanames.size(); ++s) - { - out<< datanames[s] << " " << nodedata[s].size() << " float\n"; - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //local copy -> nodedata is "double" - float tmp = (float)nodedata[s][d]; - if(swapByte) UbSystem::swapByteOrder((unsigned char*)&tmp,sizeof(unsigned char)); - out.write((char*)&tmp,sizeof(float)); - } - } - ////////////////////////////////////////////////////////////////////////// - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - end"); - ////////////////////////////////////////////////////////////////////////// - return vtkfilename; -} -/*===============================================================================*/ -string WbWriterVtkXmlBinary::writeOcts(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - int nofCells = (int)cells.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 8 /*nodes per oct */ * nofCells * sizeof(int ); - int bytesCellOffsets = 1 /*offset per oct*/ * nofCells * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofCells * sizeof(unsigned char); - //int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&val<1>(cells[c]), sizeof(int) ); - out.write( (char*)&val<2>(cells[c]), sizeof(int) ); - out.write( (char*)&val<4>(cells[c]), sizeof(int) ); - out.write( (char*)&val<3>(cells[c]), sizeof(int) ); - out.write( (char*)&val<5>(cells[c]), sizeof(int) ); - out.write( (char*)&val<6>(cells[c]), sizeof(int) ); - out.write( (char*)&val<8>(cells[c]), sizeof(int) ); - out.write( (char*)&val<7>(cells[c]), sizeof(int) ); - } - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - int itmp; - for(int c=1; c<=nofCells; c++) - { - itmp = 8 * c; - out.write( (char*)&itmp, sizeof(int) ); - } - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 11; - for(int c=0; c<nofCells; c++) - { - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOcts to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlBinary::writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 1 /*nodes per cell */ * nofNodes * sizeof(int ); - int bytesCellOffsets = 1 /*offset per cell */ * nofNodes * sizeof(int ); - int bytesCellTypes = 1 /*type of line */ * nofNodes * sizeof(unsigned char); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - for(int c=1; c<=nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 1; - for(int c=0; c<nofNodes; c++) - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodes to "<<vtkfilename<<" - end"); - - return vtkfilename; -} -std::string WbWriterVtkXmlBinary::writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata) -{ - string vtkfilename = filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - start"); - - ofstream out(vtkfilename.c_str(),ios::out | ios::binary); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(vtkfilename); - if(path.size()>0){ UbSystem::makeDirectory(path); out.open(vtkfilename.c_str(),ios::out | ios::binary);} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+vtkfilename); - } - - int nofNodes = (int)nodes.size(); - - int bytesPerByteVal = 4; //==sizeof(int) - int bytesPoints = 3 /*x1/x2/x3 */ * nofNodes * sizeof(float); - int bytesCellConnectivty = 1 /*nodes per cell */ * nofNodes * sizeof(int ); - int bytesCellOffsets = 1 /*offset per cell*/ * nofNodes * sizeof(int ); - int bytesCellTypes = 1 /*type of oct */ * nofNodes * sizeof(unsigned char); - int bytesScalarData = 1 /*scalar */ * nofNodes * sizeof(float); - - int offset = 0; - //VTK FILE - out<<"<?xml version=\"1.0\"?>\n"; - out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; - out<<" <UnstructuredGrid>"<<"\n"; - out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofNodes<<"\">\n"; - - //POINTS SECTION - out<<" <Points>\n"; - out<<" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - out<<" </Points>\n"; - offset += (bytesPerByteVal + bytesPoints); - - //CELLS SECTION - out<<" <Cells>\n"; - out<<" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellConnectivty); - out<<" <DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\""<< offset <<"\" />\n"; - offset += (bytesPerByteVal + bytesCellOffsets); - out<<" <DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\""<< offset <<"\" />\n "; - offset += (bytesPerByteVal + bytesCellTypes); - out<<" </Cells>\n"; - - //DATA SECTION - out<<" <PointData>\n"; - for(size_t s=0; s<datanames.size(); ++s) - { - out<< " <DataArray type=\"Float32\" Name=\""<< datanames[s] <<"\" format=\"appended\" offset=\""<< offset <<"\" /> \n"; - offset += (bytesPerByteVal + bytesScalarData); - } - out<<" </PointData>\n"; - - out<<" </Piece>\n"; - out<<" </UnstructuredGrid>\n"; - - // AppendedData SECTION - out<<" <AppendedData encoding=\"raw\">\n"; - out<<"_"; - - //POINTS SECTION - out.write((char*)&bytesPoints,bytesPerByteVal); - for(int n=0; n<nofNodes; n++) - { - out.write((char*)&val<1>(nodes[n]),sizeof(float)); - out.write((char*)&val<2>(nodes[n]),sizeof(float)); - out.write((char*)&val<3>(nodes[n]),sizeof(float)); - } - - //CELLS SECTION - //cellConnectivity - out.write( (char*)&bytesCellConnectivty, bytesPerByteVal ); - for(int c=0; c<nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellOffsets - out.write( (char*)&bytesCellOffsets, bytesPerByteVal ); - for(int c=1; c<=nofNodes; c++) - out.write( (char*)&c, sizeof(int) ); - - //cellTypes - out.write( (char*)&bytesCellTypes, bytesPerByteVal ); - unsigned char vtkCellType = 1; - for(int c=0; c<nofNodes; c++) - out.write( (char*)&vtkCellType, sizeof(unsigned char) ); - - //DATA SECTION - //scalarData - for(size_t s=0; s<datanames.size(); ++s) - { - out.write((char*)&bytesScalarData,bytesPerByteVal); - for(size_t d=0; d<nodedata[s].size(); ++d) - { - //loake kopie machen, da in nodedata "doubles" sind - float tmp = (float)nodedata[s][d]; - out.write((char*)&tmp,sizeof(float)); - } - } - out<<"\n</AppendedData>\n"; - out<<"</VTKFile>"; - out<<endl; - out.close(); - UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeNodesWithNodeData to "<<vtkfilename<<" - end"); - - return vtkfilename; - -} diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.h b/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.h deleted file mode 100644 index 6ba2f7562..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterVtkXmlBinary.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef WBWRITERVTKXMLBINARY_H -#define WBWRITERVTKXMLBINARY_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -#include <basics/memory/MbSharedPointerDefines.h> -class WbWriterVtkXmlBinary; -typedef VFSharedPtr<WbWriterVtkXmlBinary> WbWriterVtkXmlBinaryPtr; - - -class WbWriterVtkXmlBinary : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterVtkXmlBinary ) - #endif - - static WbWriterVtkXmlBinary* getInstance() - { - static WbWriterVtkXmlBinary instance; - return &instance; - } -private: - WbWriterVtkXmlBinary() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"machine error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"machine error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"machine error float type mismatch"); - } - - WbWriterVtkXmlBinary( const WbWriterVtkXmlBinary& ); //no copy allowed - const WbWriterVtkXmlBinary& operator=( const WbWriterVtkXmlBinary& ); //no copy allowed - - static std::string pvdEndTag; -public: - std::string getFileExtension() { return ".bin.vtu"; } - - //write a metafile - std::string writeCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); - std::string addFilesToCollection(const std::string& filename, const std::vector<std::string>& filenames, const double& timestep, const bool& sepGroups); - std::string writeParallelFile(const std::string& filename,std::vector<std::string>& pieceSources, std::vector<std::string>& pointDataNames, std::vector<std::string>& cellDataNames); - - ////////////////////////////////////////////////////////////////////////// - //nodes - std::string writeNodes(const std::string& filename,std::vector< UbTupleFloat3 >& nodes); - std::string writeNodesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //lines - // 0 ---- 1 - //nodenumbering must start with 0! - std::string writeLines(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - std::string writeLinesWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //triangles - // 2 - // - // 0---1 - //nodenumbering must start with 0! - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); - std::string writeTrianglesWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt3 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - - ////////////////////////////////////////////////////////////////////////// - //2D - //cell numbering: - // 3---2 - // | | - // 0---1 - //nodenumbering must start with 0! - - std::string writeQuads(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells); - std::string writeQuadsWithNodeData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); - std::string writeQuadsWithCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& celldata); - std::string writeQuadsWithNodeAndCellData(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt4 >& cells, - std::vector< std::string >& nodedatanames, std::vector< std::vector< double > >& nodedata, std::vector< std::string >& celldatanames, - std::vector< std::vector< double > >& celldata ); - - ////////////////////////////////////////////////////////////////////////// - //octs - // 7 ---- 6 - // /| /| - // 4 +--- 5 | - // | | | | - // | 3 ---+ 2 - // |/ |/ - // 0 ---- 1 - std::string writeOcts(const std::string& filename,std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells); - std::string writeOctsWithCellData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata); - std::string writeOctsWithNodeData(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleUInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - std::string writeOctsWithNodeDataMS(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleUInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlBinary); -#endif - -#endif //WBWRITERVTKXMLBINARY_H diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterX3D.cpp b/src/VirtualFluids_GPU/basics/writer/WbWriterX3D.cpp deleted file mode 100644 index 14d1b3741..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterX3D.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include <basics/writer/WbWriterX3D.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/*===============================================================================*/ -std::string WbWriterX3D::writeTriangles(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt3 >& triangles) -{ - string X3DFilename=filename+getFileExtension(); - UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - start"); - - std::ofstream out(X3DFilename.c_str()); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - string path = UbSystem::getPathFromString(X3DFilename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(X3DFilename.c_str());} - if(!out) throw UbException(UB_EXARGS,"couldn't open file "+X3DFilename); - } - - // General part - - //Root Element - out<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" <<endl; - out<<"<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.1//EN\" \"http://www.web3d.org/specifications/x3d-3.1.dtd\">" <<endl; - out<<"<X3D profile='Interchange' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>"<<endl<<endl; - - //Head - out<<"<head>" <<endl; - out<<"<meta content='Simple X3D Writer for blender'/>"<<endl; - out<<"</head>" <<endl<<endl; - - //Scene, Shape beginn - out<<"<Scene>" <<endl; - out<<"<Shape>" <<endl; - - //IndexedFaceSet => Polylinien der Dreiecke - out<<"<IndexedFaceSet coordIndex=\""<<endl; - - // TRIANGLES Ponits SECTION - int nofTriangles= (int)triangles.size(); - //out<<" triangles "<<nofTriangles<<endl; - for(int c=0; c<nofTriangles; c++) - out<<" "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<" -1"<<endl; - out<<"\">" <<endl; - - //Coordinates - out<<"<Coordinate point=\"" <<endl; - - // Coordinates SECTION - int nofNodes = (int)nodes.size(); - //out<<" points "<<nofNodes<<endl; - for(int n=0; n<nofNodes; n++) - out<<" "<< val<1>(nodes[n]) <<", "<< val<2>(nodes[n]) <<", "<< val<3>(nodes[n])<<", "<<endl; - out<<"\"/>" <<endl; - - //Footer - out<<"</IndexedFaceSet>"<< endl; - out<<"</Shape>" << endl; - out<<"</Scene>" << endl; - out<<"</X3D>" << endl; - - - //// Image details - //out<<"image {" <<endl; - //out<<" resolution 640 480"<<endl; - //out<<" aa 0 1" <<endl; - //out<<" filter mitchell" <<endl; - //out<<"}" <<endl<<endl; - - //// Camera position - //out<<"camera {" <<endl; - //out<<" type pinhole" <<endl; - //out<<" eye -0.25 -0.3 0.13"<<endl; - //out<<" target -0.1 0.1 0.13" <<endl; - //out<<" up 0 0 1" <<endl; - //out<<" fov 60" <<endl; - //out<<" aspect 1.333333" <<endl; - //out<<"}" <<endl<<endl; - - //// Light - //out<<"light {" <<endl; - //out<<" type ibl" <<endl; - //out<<" image sky_small.hdr" <<endl; - //out<<" center 0 -1 0" <<endl; - //out<<" up 0 0 1" <<endl; - //out<<" lock true" <<endl; - //out<<" samples 200" <<endl; - //out<<"}" <<endl<<endl; - - //// Shaders - //out<<"shader {" <<endl; - //out<<" name default-shader" <<endl; - //out<<" type diffuse" <<endl; - //out<<" diff 0.25 0.25 0.25" <<endl; - //out<<"}" <<endl<<endl; - - //out<<"shader {" <<endl; - //out<<" name Glass" <<endl; - //out<<" type glass" <<endl; - //out<<" eta 1.333" <<endl; - //out<<" color 0.1 0.3 0.8" <<endl; - //out<<"}" <<endl<<endl; - // - //out<<"shader {" <<endl; - //out<<" name Mirror" <<endl; - //out<<" type mirror" <<endl; - //out<<" refl 0.7 0.7 0.7" <<endl; - //out<<"}" <<endl<<endl; - - //// Objects - //// a) Ground plane - //out<<"object {" <<endl; - //out<<" shader default-shader" <<endl; - //out<<" type plane" <<endl; - //out<<" p 0 0 0" <<endl; - //out<<" n 0 0 1" <<endl; - //out<<"}" <<endl<<endl; - - //// b) Mesh - //out<<"object {" <<endl; - //out<<" shader Glass" <<endl; - //out<<" transform {" <<endl; - //out<<" rotatey 270.0" <<endl; - //out<<" }" <<endl; - //out<<" type generic-mesh" <<endl; - //out<<" name polySurfac" <<endl<<endl; - - - //// POINTS SECTION - //int nofNodes = (int)nodes.size(); - //out<<" points "<<nofNodes<<endl; - //for(int n=0; n<nofNodes; n++) - // out<<" "<< val<1>(nodes[n]) <<" "<< val<2>(nodes[n]) <<" "<< val<3>(nodes[n]) <<endl; - - //// TRIANGLES SECTION - //int nofTriangles= (int)triangles.size(); - //out<<" triangles "<<nofTriangles<<endl; - //for(int c=0; c<nofTriangles; c++) - // out<<" "<<val<1>(triangles[c]) <<" "<< val<2>(triangles[c])<<" "<< val<3>(triangles[c])<<endl; - - //// FOOTER - //out<<" normals none" << endl; - //out<<" uvs none" << endl; - //out<<"}" << endl; - - out.close(); - UBLOG(logDEBUG1,"WbWriterX3D::writeTriangles to "<<X3DFilename<<" - end"); - - return X3DFilename; -} -/*===============================================================================*/ diff --git a/src/VirtualFluids_GPU/basics/writer/WbWriterX3D.h b/src/VirtualFluids_GPU/basics/writer/WbWriterX3D.h deleted file mode 100644 index 9bb123261..000000000 --- a/src/VirtualFluids_GPU/basics/writer/WbWriterX3D.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef WbWriterX3D_H -#define WbWriterX3D_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterX3D : public WbWriter -{ -public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterX3D ) - #endif - - - static WbWriterX3D* getInstance() - { - static WbWriterX3D instance; - return &instance; - } -private: - WbWriterX3D() : WbWriter() - { - if(sizeof(unsigned char)!=1) throw UbException(UB_EXARGS,"error char type mismatch"); - if(sizeof(int) !=4) throw UbException(UB_EXARGS,"error int type mismatch"); - if(sizeof(float) !=4) throw UbException(UB_EXARGS,"error float type mismatch"); - } - WbWriterX3D( const WbWriterX3D& ); //no copy allowed - const WbWriterX3D& operator=( const WbWriterX3D& ); //no copy allowed - - static std::string pvdEndTag; - -public: - std::string getFileExtension() { return "ascii.X3D"; } - - std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterX3D ,WbWriter>::getInstance()), CAB_WbWriterX3D); -#endif - -#endif //WbWriterX3D_H diff --git a/src/VirtualFluids_GPU/basics/writer/package.include b/src/VirtualFluids_GPU/basics/writer/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/targets/libs/GridGenerator/3rdPartyLinking.cmake b/targets/libs/GridGenerator/3rdPartyLinking.cmake index 62533fc27..492eee0f5 100644 --- a/targets/libs/GridGenerator/3rdPartyLinking.cmake +++ b/targets/libs/GridGenerator/3rdPartyLinking.cmake @@ -1,8 +1,8 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -linkMetis(${targetName}) +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) +linkCuda(${targetName}) include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) linkMPI(${targetName}) include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Boost/Link.cmake) -linkBoost(${targetName} "Serialization") -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) \ No newline at end of file +linkBoost(${targetName} "serialization") +include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) +linkMetis(${targetName}) \ No newline at end of file diff --git a/targets/libs/VirtualFluids_GPU/CMakePackage.cmake b/targets/libs/VirtualFluids_GPU/CMakePackage.cmake index 6d4845ba0..7ec316fe0 100644 --- a/targets/libs/VirtualFluids_GPU/CMakePackage.cmake +++ b/targets/libs/VirtualFluids_GPU/CMakePackage.cmake @@ -2,7 +2,7 @@ resetFileEndingsToCollect() addCAndCPPFileTypes() - #GLOB SOURCE FILES IN MY_SRCS unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_SOURCE_DIR}/src/${targetName}) \ No newline at end of file +includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) +includeRecursiveProductionFilesFrom(${targetName} ${CMAKE_SOURCE_DIR}/src/${targetName}) \ No newline at end of file -- GitLab