From 6841bf47b9cc95c02fbef85228d10c73fa6470a6 Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Wed, 19 Aug 2020 11:35:58 +0200 Subject: [PATCH] Removed unused basic source code. Moved numers/geomtry3d to /geometry3d. --- src/basics/Core/LbmOrGks.h | 14 - src/basics/basics/container/CMakePackage.txt | 4 + src/basics/basics/container/CbArray2D.h | 83 +- src/basics/basics/container/CbArray3D.h | 85 +- src/basics/basics/container/CbArray4D.h | 87 +- src/basics/basics/container/CbVector.h | 148 +-- src/basics/basics/container/CbVectorPool.h | 465 --------- .../examples/CbVectorPool/CMakeLists.txt | 30 - .../examples/CbVectorPool/functions.h | 190 ---- .../container/examples/CbVectorPool/main.cpp | 277 ----- src/basics/basics/memory/MbChessMemPool2D.h | 519 ---------- src/basics/basics/memory/MbChessMemPool3D.h | 537 ---------- src/basics/basics/memory/MbMemPool.h | 87 -- .../basics/memory/MbSharedPointerDefines.h | 22 - src/basics/basics/memory/MbSmartPtr.h | 147 --- src/basics/basics/memory/MbSmartPtrBase.cpp | 44 - src/basics/basics/memory/MbSmartPtrBase.h | 50 - src/basics/basics/objects/CMakePackage.txt | 2 + src/basics/basics/objects/ObCreator.h | 112 -- src/basics/basics/objects/ObFactory.h | 174 ---- src/basics/basics/objects/ObObject.cpp | 10 - src/basics/basics/objects/ObObject.h | 61 +- src/basics/basics/objects/ObObjectCreator.h | 58 -- src/basics/basics/objects/ObObjectFactory.cpp | 54 - src/basics/basics/objects/ObObjectFactory.h | 42 - src/basics/basics/objects/ObObjectManager.cpp | 216 ---- src/basics/basics/objects/ObObjectManager.h | 79 -- src/basics/basics/objects/package.include | 0 src/basics/basics/parallel/PbMpi.h | 454 -------- src/basics/basics/parallel/PbMpiTools.h | 303 ------ .../examples/simpleMPI/CMakeLists.txt | 64 -- .../parallel/examples/simpleMPI/functions.h | 193 ---- .../parallel/examples/simpleMPI/main.cpp | 101 -- src/basics/basics/relation/RbAggregation.h | 70 -- src/basics/basics/transmitter/TbTransmitter.h | 68 -- .../basics/transmitter/TbTransmitterLocal.h | 129 --- .../basics/transmitter/TbTransmitterMpiPool.h | 536 ---------- src/basics/basics/transmitter/package.include | 0 src/basics/basics/utilities/CMakePackage.txt | 21 + src/basics/basics/utilities/UbAutoRun.hpp | 58 -- src/basics/basics/utilities/UbComparators.h | 41 +- src/basics/basics/utilities/UbConverter.cpp | 96 -- src/basics/basics/utilities/UbConverter.h | 49 - src/basics/basics/utilities/UbEqual.h | 61 +- src/basics/basics/utilities/UbException.h | 64 +- src/basics/basics/utilities/UbFileInput.h | 97 -- .../basics/utilities/UbFileInputASCII.cpp | 234 ----- .../basics/utilities/UbFileInputASCII.h | 78 -- .../basics/utilities/UbFileInputBinary.cpp | 150 --- .../basics/utilities/UbFileInputBinary.h | 82 -- src/basics/basics/utilities/UbFileOutput.h | 93 -- .../basics/utilities/UbFileOutputASCII.cpp | 177 ---- .../basics/utilities/UbFileOutputASCII.h | 74 -- .../basics/utilities/UbFileOutputBinary.cpp | 180 ---- .../basics/utilities/UbFileOutputBinary.h | 80 -- src/basics/basics/utilities/UbInfinity.h | 52 +- src/basics/basics/utilities/UbKeys.h | 56 +- src/basics/basics/utilities/UbLimits.h | 36 +- src/basics/basics/utilities/UbLogger.cpp | 32 + src/basics/basics/utilities/UbLogger.h | 136 ++- src/basics/basics/utilities/UbMath.cpp | 32 + src/basics/basics/utilities/UbMath.h | 96 +- src/basics/basics/utilities/UbNupsTimer.h | 93 -- src/basics/basics/utilities/UbObservable.h | 103 +- src/basics/basics/utilities/UbObserver.h | 71 +- .../basics/utilities/UbPointerWrapper.h | 36 - src/basics/basics/utilities/UbRandom.h | 60 -- src/basics/basics/utilities/UbScheduler.h | 120 +-- .../basics/utilities/UbStaticPathMap.cpp | 4 - src/basics/basics/utilities/UbStaticPathMap.h | 71 -- src/basics/basics/utilities/UbString.h | 24 - .../basics/utilities/UbStringInputASCII.cpp | 211 ---- .../basics/utilities/UbStringInputASCII.h | 55 - src/basics/basics/utilities/UbSystem.h | 71 +- src/basics/basics/utilities/UbTableModel.cpp | 20 - src/basics/basics/utilities/UbTableModel.h | 37 - src/basics/basics/utilities/UbTiming.h | 139 ++- src/basics/basics/utilities/UbTuple.cpp | 2 - src/basics/basics/utilities/UbTuple.h | 190 ++-- src/basics/basics/utilities/Vector3D.cpp | 32 + src/basics/basics/utilities/Vector3D.h | 61 +- src/basics/basics/utilities/Vector3DTest.cpp | 156 --- src/basics/basics/utilities/package.include | 0 src/basics/basics/writer/CMakePackage.txt | 3 + src/basics/basics/writer/WbWriter.h | 134 +-- src/basics/basics/writer/WbWriterAvsASCII.cpp | 897 ---------------- src/basics/basics/writer/WbWriterAvsASCII.h | 76 -- .../basics/writer/WbWriterAvsBinary.cpp | 977 ------------------ src/basics/basics/writer/WbWriterAvsBinary.h | 74 -- src/basics/basics/writer/WbWriterBOBJ.cpp | 79 -- src/basics/basics/writer/WbWriterBOBJ.h | 40 - src/basics/basics/writer/WbWriterSunflow.cpp | 112 -- src/basics/basics/writer/WbWriterSunflow.h | 38 - .../basics/writer/WbWriterTecPlotASCII.cpp | 68 -- .../basics/writer/WbWriterTecPlotASCII.h | 95 -- src/basics/basics/writer/WbWriterVtkASCII.cpp | 601 ----------- src/basics/basics/writer/WbWriterVtkASCII.h | 78 -- .../basics/writer/WbWriterVtkBinary.cpp | 747 ------------- src/basics/basics/writer/WbWriterVtkBinary.h | 77 -- .../basics/writer/WbWriterVtkXmlASCII.cpp | 34 +- .../basics/writer/WbWriterVtkXmlASCII.h | 42 +- .../basics/writer/WbWriterVtkXmlBinary.cpp | 75 +- .../basics/writer/WbWriterVtkXmlBinary.h | 48 +- src/basics/basics/writer/WbWriterX3D.cpp | 152 --- src/basics/basics/writer/WbWriterX3D.h | 38 - src/basics/basics/writer/package.include | 0 .../geometry3d/CoordinateTransformation3D.cpp | 0 .../geometry3d/CoordinateTransformation3D.h | 0 .../{numerics => }/geometry3d/GbCuboid3D.cpp | 0 .../{numerics => }/geometry3d/GbCuboid3D.h | 0 .../geometry3d/GbCylinder3D.cpp | 0 .../{numerics => }/geometry3d/GbCylinder3D.h | 0 .../geometry3d/GbHalfSpace3D.cpp | 0 .../{numerics => }/geometry3d/GbHalfSpace3D.h | 0 .../geometry3d/GbHalfSpaceKrischan3D.cpp | 0 .../geometry3d/GbHalfSpaceKrischan3D.h | 0 .../{numerics => }/geometry3d/GbLine3D.cpp | 0 .../{numerics => }/geometry3d/GbLine3D.h | 0 .../{numerics => }/geometry3d/GbMeshTools3D.h | 0 .../{numerics => }/geometry3d/GbObject3D.cpp | 0 .../{numerics => }/geometry3d/GbObject3D.h | 0 .../geometry3d/GbObject3DManager.cpp | 0 .../geometry3d/GbObject3DManager.h | 0 .../geometry3d/GbObjectGroup3D.cpp | 0 .../geometry3d/GbObjectGroup3D.h | 0 .../{numerics => }/geometry3d/GbPoint3D.cpp | 0 .../{numerics => }/geometry3d/GbPoint3D.h | 0 .../{numerics => }/geometry3d/GbPolygon3D.cpp | 0 .../{numerics => }/geometry3d/GbPolygon3D.h | 0 .../geometry3d/GbQuadFaceMesh3D.cpp | 0 .../geometry3d/GbQuadFaceMesh3D.h | 0 .../{numerics => }/geometry3d/GbSphere3D.cpp | 0 .../{numerics => }/geometry3d/GbSphere3D.h | 0 .../{numerics => }/geometry3d/GbSystem3D.cpp | 0 .../{numerics => }/geometry3d/GbSystem3D.h | 0 .../geometry3d/GbTriFaceMesh3D.cpp | 0 .../geometry3d/GbTriFaceMesh3D.h | 0 .../geometry3d/GbTriangle3D.cpp | 0 .../{numerics => }/geometry3d/GbTriangle3D.h | 0 .../geometry3d/GbTriangularMesh3D.cpp | 0 .../geometry3d/GbTriangularMesh3D.h | 0 .../{numerics => }/geometry3d/GbVector3D.cpp | 0 .../{numerics => }/geometry3d/GbVector3D.h | 0 .../geometry3d/GbVoxelMatrix3D.cpp | 0 .../geometry3d/GbVoxelMatrix3D.h | 0 .../{numerics => }/geometry3d/KdTree/KdNode.h | 0 .../{numerics => }/geometry3d/KdTree/KdRay.h | 0 .../geometry3d/KdTree/KdSplitCandidate.h | 0 .../KdTree/KdSplitCandidateManager.h | 0 .../{numerics => }/geometry3d/KdTree/KdTree.h | 0 .../geometry3d/KdTree/KdUtilities.cpp | 0 .../geometry3d/KdTree/KdUtilities.h | 0 .../examples/AdvancedPIOTests/CMakeLists.txt | 0 .../KdTree/examples/AdvancedPIOTests/main.cpp | 0 .../KdTree/examples/PIOTests/CMakeLists.txt | 0 .../KdTree/examples/PIOTests/main.cpp | 0 .../KdCountLineIntersectionHandler.h | 0 .../KdCountRayIntersectionHandler.h | 0 .../KdLineIntersectionHandler.h | 0 .../KdRayIntersectionHandler.h | 0 .../KdTree}/package.include | 0 .../KdTree/splitalgorithms/KdSAHSplit.cpp | 0 .../KdTree/splitalgorithms/KdSAHSplit.h | 0 .../splitalgorithms/KdSpatiallMedianSplit.h | 0 .../KdTree/splitalgorithms/KdSplitAlgorithm.h | 0 .../geometry3d/creator/GbCuboid3DCreator.h | 0 .../geometry3d/creator/GbCylinder3DCreator.h | 0 .../geometry3d/creator/GbLine3DCreator.h | 0 .../geometry3d/creator/GbObject3DCreator.h | 0 .../geometry3d/creator/GbObject3DFactory.cpp | 0 .../geometry3d/creator/GbObject3DFactory.h | 0 .../geometry3d/creator/GbPoint3DCreator.h | 0 .../geometry3d/creator/GbPolygon3DCreator.h | 0 .../creator/GbQuadFaceMesh3DCreator.cpp | 0 .../creator/GbQuadFaceMesh3DCreator.h | 0 .../geometry3d/creator/GbSphere3DCreator.h | 0 .../creator/GbTriFaceMesh3DCreator.cpp | 0 .../creator/GbTriFaceMesh3DCreator.h | 0 .../geometry3d/creator/GbTriangle3DCreator.h | 0 .../creator/GbTriangularMesh3DCreator.cpp | 0 .../creator/GbTriangularMesh3DCreator.h | 0 .../creator/GbVoxelMatrix3DCreator.cpp | 0 .../creator/GbVoxelMatrix3DCreator.h | 0 .../creator}/package.include | 0 .../insideOutsideTests/CMakeLists.txt | 0 .../examples/insideOutsideTests/main.cpp | 0 .../examples/stl2inp/CMakeLists.txt | 0 .../examples/stl2inp/QDefineUniformMesh.cpp | 0 .../examples/stl2inp/QDefineUniformMesh.h | 0 .../examples/stl2inp/QDefineUniformMesh.ui | 0 .../geometry3d/examples/stl2inp/main.cpp | 0 .../geometry3d/examples/stl2inp/stl2inp.cpp | 0 .../geometry3d/examples/stl2inp/stl2inp.h | 0 .../geometry3d/examples/stl2inp/stl2inp.ui | 0 .../geometry3d/fem/FeAdhocTriFaceMesh3D.cpp | 0 .../geometry3d/fem/FeAdhocTriFaceMesh3D.h | 0 .../geometry3d/fem/FeHalfDisc3D.cpp | 0 .../geometry3d/fem/FeHalfDisc3D.h | 0 .../fem/FePlateTriangularMesh3D.cpp | 0 .../geometry3d/fem/FePlateTriangularMesh3D.h | 0 .../{numerics => }/geometry3d/fem/FePoint3D.h | 0 .../geometry3d/fem/FeRing3D.cpp | 0 .../{numerics => }/geometry3d/fem/FeRing3D.h | 0 .../geometry3d/fem/FeTriFaceMesh3D.cpp | 0 .../geometry3d/fem/FeTriFaceMesh3D.h | 0 .../fem/creator/FeTriFaceMesh3DCreator.cpp | 0 .../fem/creator/FeTriFaceMesh3DCreator.h | 0 .../memory => geometry3d}/package.include | 0 .../presentation/QGbCuboid3DInstrument.cpp | 0 .../presentation/QGbCuboid3DInstrument.h | 0 .../presentation/QGbCuboid3DInstrument.ui | 0 .../presentation/QGbCylinder3DInstrument.cpp | 0 .../presentation/QGbCylinder3DInstrument.h | 0 .../presentation/QGbCylinder3DInstrument.ui | 0 .../presentation/QGbObject3DInstrument.cpp | 0 .../presentation/QGbObject3DInstrument.h | 0 .../presentation/QGbObject3DInstrument.ui | 0 .../presentation/QGbSphere3DInstrument.cpp | 0 .../presentation/QGbSphere3DInstrument.h | 0 .../presentation/QGbSphere3DInstrument.ui | 0 .../presentation/QVTKGbObject3DViewer.cpp | 0 .../presentation/QVTKGbObject3DViewer.h | 0 .../geometry3d/presentation/vtkGbCuboid3D.cpp | 0 .../geometry3d/presentation/vtkGbCuboid3D.h | 0 .../presentation/vtkGbCylinder3D.cpp | 0 .../geometry3d/presentation/vtkGbCylinder3D.h | 0 .../geometry3d/presentation/vtkGbSphere3D.cpp | 0 .../geometry3d/presentation/vtkGbSphere3D.h | 0 .../presentation/vtkGbTriangularMesh3D.cpp | 0 .../presentation/vtkGbTriangularMesh3D.h | 0 .../geometry3d/KdTree/package.include | 0 .../geometry3d/creator/package.include | 0 .../numerics/geometry3d/package.include | 0 233 files changed, 1265 insertions(+), 12366 deletions(-) delete mode 100644 src/basics/Core/LbmOrGks.h create mode 100644 src/basics/basics/container/CMakePackage.txt delete mode 100644 src/basics/basics/container/CbVectorPool.h delete mode 100644 src/basics/basics/container/examples/CbVectorPool/CMakeLists.txt delete mode 100644 src/basics/basics/container/examples/CbVectorPool/functions.h delete mode 100644 src/basics/basics/container/examples/CbVectorPool/main.cpp delete mode 100644 src/basics/basics/memory/MbChessMemPool2D.h delete mode 100644 src/basics/basics/memory/MbChessMemPool3D.h delete mode 100644 src/basics/basics/memory/MbMemPool.h delete mode 100644 src/basics/basics/memory/MbSharedPointerDefines.h delete mode 100644 src/basics/basics/memory/MbSmartPtr.h delete mode 100644 src/basics/basics/memory/MbSmartPtrBase.cpp delete mode 100644 src/basics/basics/memory/MbSmartPtrBase.h create mode 100644 src/basics/basics/objects/CMakePackage.txt delete mode 100644 src/basics/basics/objects/ObCreator.h delete mode 100644 src/basics/basics/objects/ObFactory.h delete mode 100644 src/basics/basics/objects/ObObject.cpp delete mode 100644 src/basics/basics/objects/ObObjectCreator.h delete mode 100644 src/basics/basics/objects/ObObjectFactory.cpp delete mode 100644 src/basics/basics/objects/ObObjectFactory.h delete mode 100644 src/basics/basics/objects/ObObjectManager.cpp delete mode 100644 src/basics/basics/objects/ObObjectManager.h delete mode 100644 src/basics/basics/objects/package.include delete mode 100644 src/basics/basics/parallel/PbMpi.h delete mode 100644 src/basics/basics/parallel/PbMpiTools.h delete mode 100644 src/basics/basics/parallel/examples/simpleMPI/CMakeLists.txt delete mode 100644 src/basics/basics/parallel/examples/simpleMPI/functions.h delete mode 100644 src/basics/basics/parallel/examples/simpleMPI/main.cpp delete mode 100644 src/basics/basics/relation/RbAggregation.h delete mode 100644 src/basics/basics/transmitter/TbTransmitter.h delete mode 100644 src/basics/basics/transmitter/TbTransmitterLocal.h delete mode 100644 src/basics/basics/transmitter/TbTransmitterMpiPool.h delete mode 100644 src/basics/basics/transmitter/package.include create mode 100644 src/basics/basics/utilities/CMakePackage.txt delete mode 100644 src/basics/basics/utilities/UbAutoRun.hpp delete mode 100644 src/basics/basics/utilities/UbConverter.cpp delete mode 100644 src/basics/basics/utilities/UbConverter.h delete mode 100644 src/basics/basics/utilities/UbFileInput.h delete mode 100644 src/basics/basics/utilities/UbFileInputASCII.cpp delete mode 100644 src/basics/basics/utilities/UbFileInputASCII.h delete mode 100644 src/basics/basics/utilities/UbFileInputBinary.cpp delete mode 100644 src/basics/basics/utilities/UbFileInputBinary.h delete mode 100644 src/basics/basics/utilities/UbFileOutput.h delete mode 100644 src/basics/basics/utilities/UbFileOutputASCII.cpp delete mode 100644 src/basics/basics/utilities/UbFileOutputASCII.h delete mode 100644 src/basics/basics/utilities/UbFileOutputBinary.cpp delete mode 100644 src/basics/basics/utilities/UbFileOutputBinary.h delete mode 100644 src/basics/basics/utilities/UbNupsTimer.h delete mode 100644 src/basics/basics/utilities/UbPointerWrapper.h delete mode 100644 src/basics/basics/utilities/UbRandom.h delete mode 100644 src/basics/basics/utilities/UbStaticPathMap.cpp delete mode 100644 src/basics/basics/utilities/UbStaticPathMap.h delete mode 100644 src/basics/basics/utilities/UbString.h delete mode 100644 src/basics/basics/utilities/UbStringInputASCII.cpp delete mode 100644 src/basics/basics/utilities/UbStringInputASCII.h delete mode 100644 src/basics/basics/utilities/UbTableModel.cpp delete mode 100644 src/basics/basics/utilities/UbTableModel.h delete mode 100644 src/basics/basics/utilities/UbTuple.cpp delete mode 100644 src/basics/basics/utilities/Vector3DTest.cpp delete mode 100644 src/basics/basics/utilities/package.include create mode 100644 src/basics/basics/writer/CMakePackage.txt delete mode 100644 src/basics/basics/writer/WbWriterAvsASCII.cpp delete mode 100644 src/basics/basics/writer/WbWriterAvsASCII.h delete mode 100644 src/basics/basics/writer/WbWriterAvsBinary.cpp delete mode 100644 src/basics/basics/writer/WbWriterAvsBinary.h delete mode 100644 src/basics/basics/writer/WbWriterBOBJ.cpp delete mode 100644 src/basics/basics/writer/WbWriterBOBJ.h delete mode 100644 src/basics/basics/writer/WbWriterSunflow.cpp delete mode 100644 src/basics/basics/writer/WbWriterSunflow.h delete mode 100644 src/basics/basics/writer/WbWriterTecPlotASCII.cpp delete mode 100644 src/basics/basics/writer/WbWriterTecPlotASCII.h delete mode 100644 src/basics/basics/writer/WbWriterVtkASCII.cpp delete mode 100644 src/basics/basics/writer/WbWriterVtkASCII.h delete mode 100644 src/basics/basics/writer/WbWriterVtkBinary.cpp delete mode 100644 src/basics/basics/writer/WbWriterVtkBinary.h delete mode 100644 src/basics/basics/writer/WbWriterX3D.cpp delete mode 100644 src/basics/basics/writer/WbWriterX3D.h delete mode 100644 src/basics/basics/writer/package.include rename src/basics/{numerics => }/geometry3d/CoordinateTransformation3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/CoordinateTransformation3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbCuboid3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbCuboid3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbCylinder3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbCylinder3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbHalfSpace3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbHalfSpace3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbHalfSpaceKrischan3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbHalfSpaceKrischan3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbLine3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbLine3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbMeshTools3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbObject3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbObject3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbObject3DManager.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbObject3DManager.h (100%) rename src/basics/{numerics => }/geometry3d/GbObjectGroup3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbObjectGroup3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbPoint3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbPoint3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbPolygon3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbPolygon3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbQuadFaceMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbQuadFaceMesh3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbSphere3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbSphere3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbSystem3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbSystem3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbTriFaceMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbTriFaceMesh3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbTriangle3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbTriangle3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbTriangularMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbTriangularMesh3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbVector3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbVector3D.h (100%) rename src/basics/{numerics => }/geometry3d/GbVoxelMatrix3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/GbVoxelMatrix3D.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdNode.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdRay.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdSplitCandidate.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdSplitCandidateManager.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdTree.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdUtilities.cpp (100%) rename src/basics/{numerics => }/geometry3d/KdTree/KdUtilities.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt (100%) rename src/basics/{numerics => }/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp (100%) rename src/basics/{numerics => }/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt (100%) rename src/basics/{numerics => }/geometry3d/KdTree/examples/PIOTests/main.cpp (100%) rename src/basics/{numerics => }/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h (100%) rename src/basics/{Core => geometry3d/KdTree}/package.include (100%) rename src/basics/{numerics => }/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp (100%) rename src/basics/{numerics => }/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h (100%) rename src/basics/{numerics => }/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbCuboid3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbCylinder3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbLine3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbObject3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbObject3DFactory.cpp (100%) rename src/basics/{numerics => }/geometry3d/creator/GbObject3DFactory.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbPoint3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbPolygon3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp (100%) rename src/basics/{numerics => }/geometry3d/creator/GbQuadFaceMesh3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbSphere3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbTriFaceMesh3DCreator.cpp (100%) rename src/basics/{numerics => }/geometry3d/creator/GbTriFaceMesh3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbTriangle3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbTriangularMesh3DCreator.cpp (100%) rename src/basics/{numerics => }/geometry3d/creator/GbTriangularMesh3DCreator.h (100%) rename src/basics/{numerics => }/geometry3d/creator/GbVoxelMatrix3DCreator.cpp (100%) rename src/basics/{numerics => }/geometry3d/creator/GbVoxelMatrix3DCreator.h (100%) rename src/basics/{basics/container => geometry3d/creator}/package.include (100%) rename src/basics/{numerics => }/geometry3d/examples/insideOutsideTests/CMakeLists.txt (100%) rename src/basics/{numerics => }/geometry3d/examples/insideOutsideTests/main.cpp (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/CMakeLists.txt (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/QDefineUniformMesh.h (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/QDefineUniformMesh.ui (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/main.cpp (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/stl2inp.cpp (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/stl2inp.h (100%) rename src/basics/{numerics => }/geometry3d/examples/stl2inp/stl2inp.ui (100%) rename src/basics/{numerics => }/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/fem/FeAdhocTriFaceMesh3D.h (100%) rename src/basics/{numerics => }/geometry3d/fem/FeHalfDisc3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/fem/FeHalfDisc3D.h (100%) rename src/basics/{numerics => }/geometry3d/fem/FePlateTriangularMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/fem/FePlateTriangularMesh3D.h (100%) rename src/basics/{numerics => }/geometry3d/fem/FePoint3D.h (100%) rename src/basics/{numerics => }/geometry3d/fem/FeRing3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/fem/FeRing3D.h (100%) rename src/basics/{numerics => }/geometry3d/fem/FeTriFaceMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/fem/FeTriFaceMesh3D.h (100%) rename src/basics/{numerics => }/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp (100%) rename src/basics/{numerics => }/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h (100%) rename src/basics/{basics/memory => geometry3d}/package.include (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbCuboid3DInstrument.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbCuboid3DInstrument.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbCuboid3DInstrument.ui (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbCylinder3DInstrument.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbCylinder3DInstrument.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbCylinder3DInstrument.ui (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbObject3DInstrument.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbObject3DInstrument.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbObject3DInstrument.ui (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbSphere3DInstrument.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbSphere3DInstrument.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/QGbSphere3DInstrument.ui (100%) rename src/basics/{numerics => }/geometry3d/presentation/QVTKGbObject3DViewer.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/QVTKGbObject3DViewer.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbCuboid3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbCuboid3D.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbCylinder3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbCylinder3D.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbSphere3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbSphere3D.h (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbTriangularMesh3D.cpp (100%) rename src/basics/{numerics => }/geometry3d/presentation/vtkGbTriangularMesh3D.h (100%) delete mode 100644 src/basics/numerics/geometry3d/KdTree/package.include delete mode 100644 src/basics/numerics/geometry3d/creator/package.include delete mode 100644 src/basics/numerics/geometry3d/package.include diff --git a/src/basics/Core/LbmOrGks.h b/src/basics/Core/LbmOrGks.h deleted file mode 100644 index bd9a55ae1..000000000 --- a/src/basics/Core/LbmOrGks.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -* Author: St. Lenz -* mail: lenz@irmb.tu-bs.de -*/ -#ifndef LBMORGKS_H -#define LBMORGKS_H - -enum LbmOrGks -{ - LBM, - GKS -}; - -#endif diff --git a/src/basics/basics/container/CMakePackage.txt b/src/basics/basics/container/CMakePackage.txt new file mode 100644 index 000000000..b2d974b49 --- /dev/null +++ b/src/basics/basics/container/CMakePackage.txt @@ -0,0 +1,4 @@ +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) + + diff --git a/src/basics/basics/container/CbArray2D.h b/src/basics/basics/container/CbArray2D.h index 54df75401..575ef2f54 100644 --- a/src/basics/basics/container/CbArray2D.h +++ b/src/basics/basics/container/CbArray2D.h @@ -1,34 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CbArray2D.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBARRAY2D_H #define CBARRAY2D_H -////////////////////////////////////////////////////////////////////////// -// 4D Array -// die Daten werden in einem Vector gehalten -// -// Ver 1.2 -// Nov. 2003 muffmolch@gmx.de -// Ver 1.3 -// Aug. 2006 - Kosmetik -// Ver 1.4 -// Sep. 2006 - indexer eingefuehrt -// Ver 1.5 -// Jul. 2006 - size_t + range check bei getIndex -// Ver 1.6 -// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class -// assigmetcomparison between Matrices with different value_type and/or index-class -// Oct. 2008 - +isEmpty() -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -////////////////////////////////////////////////////////////////////////// - #include <iomanip> #include <basics/utilities/UbException.h> @@ -36,10 +40,6 @@ #include <algorithm> #include <typeinfo> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // IndexClasses @@ -90,7 +90,16 @@ public: ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // CbArray2D - +////////////////////////////////////////////////////////////////////////// +//! \brief 2D Array +//! \details the data is stored in a vector +//! +//! Rangecheck active, if: +//! +//! -debug : not defined "NO_CB_RANGECHECK" +//! +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +////////////////////////////////////////////////////////////////////////// template<typename T, typename IndexClass = IndexerX2X1> class CbArray2D { @@ -372,16 +381,6 @@ public: return indexer.getIndex(x1,x2,nx1,nx2); } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & data; - } -#endif //CAB_RCF - protected: /*=======================================================================*/ //success -> true diff --git a/src/basics/basics/container/CbArray3D.h b/src/basics/basics/container/CbArray3D.h index 2ec0306c4..575b0cb84 100644 --- a/src/basics/basics/container/CbArray3D.h +++ b/src/basics/basics/container/CbArray3D.h @@ -1,34 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CbArray3D.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBARRAY3D_H #define CBARRAY3D_H -////////////////////////////////////////////////////////////////////////// -// 3D Array -// die Daten werden in einem Vector gehalten -// -// Ver 1.2 -// Nov. 2003 muffmolch@gmx.de -// Ver 1.3 -// Aug. 2006 - Kosmetik -// Ver 1.4 -// Sep. 2006 - indexer eingefuehrt -// Ver 1.5 -// Jul. 2006 - size_t + range check bei getIndex -// Ver 1.2 -// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class -// assigmetcomparison between Matrices with different value_type and/or index-class -// Oct. 2008 - +isEmpty() -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -////////////////////////////////////////////////////////////////////////// - #include <iomanip> #include <basics/utilities/UbException.h> @@ -37,10 +41,6 @@ #include <typeinfo> #include "PointerDefinitions.h" -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // IndexClasses @@ -122,6 +122,16 @@ public: ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // CbArray3D +////////////////////////////////////////////////////////////////////////// +//! \brief 3D Array +//! \details The data is stored in a vector +//! +//! Rangecheck active, if: +//! +//! -debug : not defined "NO_CB_RANGECHECK" +//! +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +////////////////////////////////////////////////////////////////////////// template<typename T, typename IndexClass = IndexerX3X2X1> class CbArray3D { @@ -161,7 +171,7 @@ public: this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); } /*=======================================================================*/ - //�bernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschlie�end leer, da swap verwendet wird) + //übernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird) CbArray3D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3) { assert( (nx1*nx2*nx3)==vec.size() ); @@ -422,17 +432,6 @@ public: return indexer.getIndex(x1,x2,x3,nx1,nx2,nx3); } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & nx3; - ar & data; - } -#endif //CAB_RCF - /*=======================================================================*/ //success -> true diff --git a/src/basics/basics/container/CbArray4D.h b/src/basics/basics/container/CbArray4D.h index aa91844d0..b72a13f0e 100644 --- a/src/basics/basics/container/CbArray4D.h +++ b/src/basics/basics/container/CbArray4D.h @@ -1,29 +1,39 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CbArray4D.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBARRAY4D_H #define CBARRAY4D_H -////////////////////////////////////////////////////////////////////////// -// 4D Array -// die Daten werden in einem Vector gehalten -// -// Ver 1.0 -// Sept. 2006 muffmolch@gmx.de -// Ver 1.1 -// Jul. 2006 - size_t + range check bei getIndex -// Ver 1.2 -// Mrz. 2008 - typedefs, new index checks, NO_CB_RANGECHECK, no base class -// assigmetcomparison between Matrices with different value_type and/or index-class -// Oct. 2008 - +isEmpty() -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -////////////////////////////////////////////////////////////////////////// + #include <iomanip> #include <basics/utilities/UbException.h> @@ -32,13 +42,6 @@ #include <typeinfo> #include "PointerDefinitions.h" -#include "basics_export.h" - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // IndexClasses @@ -50,7 +53,7 @@ // for(alle X2) // for(alle X3) // for(alle X4) -class BASICS_EXPORT IndexerX1X2X3X4 +class IndexerX1X2X3X4 { public: typedef int size_type; @@ -93,8 +96,16 @@ public: } }; ////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// // CbArray4D +//! \brief 4D Array +//! \details The data is stored in a vector +//! +//! Rangecheck active, if: +//! +//! -debug : not defined "NO_CB_RANGECHECK" +//! +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +////////////////////////////////////////////////////////////////////////// template<typename T, typename IndexClass = IndexerX4X3X2X1> class CbArray4D { @@ -134,7 +145,7 @@ public: this->resize(uniformDimensionSize,uniformDimensionSize,uniformDimensionSize,uniformDimensionSize); } /*=======================================================================*/ - //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschlie�end leer, da swap verwendet wird) + //ubernimmt vector als daten vector! (erstellt KEINE kopie!!!, vec ist anschließend leer, da swap verwendet wird) CbArray4D(std::vector<value_type>& vec, const size_type& nx1,const size_type& nx2, const size_type& nx3, const size_type& nx4) { assert( (nx1*nx2*nx3*nx4)==vec.size() ); @@ -403,18 +414,6 @@ public: return indexer.getIndex(x1,x2,x3,x4,nx1,nx2,nx3,nx4); } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & nx1; - ar & nx2; - ar & nx3; - ar & nx4; - ar & data; - } -#endif //CAB_RCF - protected: /*=======================================================================*/ //success -> true diff --git a/src/basics/basics/container/CbVector.h b/src/basics/basics/container/CbVector.h index bd7174da9..b33ad1a44 100644 --- a/src/basics/basics/container/CbVector.h +++ b/src/basics/basics/container/CbVector.h @@ -1,17 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CbVector.h +//! \ingroup container +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef CBVECTOR_H #define CBVECTOR_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> - #include <RCF/ByteBuffer.hpp> -#endif - #include <vector> #include <algorithm> //for std::swap #include <typeinfo> //for typeid @@ -20,36 +41,23 @@ #include <basics/utilities/UbSystem.h> #include <basics/utilities/UbEqual.h> -/*=========================================================================*/ -/* CbVector */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -@version 1.1 - 09.02.08 -@version 1.2 - 23.04.08 - swap added -@version 1.3 - 08.05.08 - boosting up serialization performance! -*/ - -/* -usage: ... -Da es Voraussetzun bei doeser Klasse war, dass lediglich der Typ als -template-parameter miteingeht, muss der allcocator eine abstrakte klasse sein -ansonsten h�tte sich hier der allokator als zweites argument -wie beim STL vector angeboten, womit man auch keinen pointer speichern muesste. -Im letzteren Fall w�rde aber jeweils ein bestimmeter Klassentyp in Abhaengigkeit -des allokators zur compilezeit erzeugt. Problem wir wollen ein und denselben -typ benutzen und nur der allokator innerhalb der klasse soll sich unterscheiden -// -// Rangecheck aktiv, wenn: -// -debug : not defined "NO_CB_RANGECHECK" -// -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" -*/ - template< typename T > class CbVectorAllocator; template< typename T > class CbVectorAllocatorStd; +//========================================================================= +//! \brief A class implements a container like a vector +//! \details +//! For this class it was required to ave only the type as template argument. +//! Hence, the allocator must be an abstract class. With out this requirement, +//! an allocator as second template argument would have been possible, as in the +//! STL vector. This would lead to the compiler generating two different classes +//! for the same data type with different allocators during compile time. Here it +//! is required that the same class can have different allocators. +//! +//! Rangecheck active, if: +//! -debug : not defined "NO_CB_RANGECHECK" +//! -release: not defined "NO_CB_RANGECHECK" && defined "CB_RANGECHECK" +//========================================================================= ////////////////////////////////////////////////////////////////////////// template< typename T > class CbVector @@ -194,43 +202,6 @@ public: /*==========================================================*/ CbVectorAllocator<value_type>* getAllocator() const { return allocator; } /*==========================================================*/ - #ifdef CAB_RCF - template<typename Archive> - void serialize(Archive & ar, const unsigned int version) - { - if( ArchiveTools::isWriting(ar) ) - { - ar & allocator; - ar & dataSize; //!!!erst hier - - //old: - //for(size_type i=0; i<dataSize; i++) - // ar & ptrData[i]; - - //new and boosting to the sky: - RCF::ByteBuffer byteBuffer( (char*) &ptrData[0], dataSize*sizeof(value_type) ); - ar & byteBuffer; - } - else - { - CbVectorAllocator<value_type>* tmpCbVectorAllocator(NULL); - size_type tmpInteger; - ar & tmpCbVectorAllocator; - ar & tmpInteger; - this->setAllocator(tmpCbVectorAllocator); - allocator->resize(*this,tmpInteger); - - //old: - //for(size_type i=0; i<dataSize; i++) - // ar & ptrData[i]; - - //new and boosting to the sky: - RCF::ByteBuffer byteBuffer; - ar & byteBuffer; - memcpy( (char*)ptrData, byteBuffer.getPtr(), byteBuffer.getLength() ); - } - } - #endif //CAB_RCF private: value_type* ptrData; @@ -258,13 +229,6 @@ public: virtual bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) = 0; virtual bool dealloc(CbVector< value_type >& vec) = 0; -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - } -#endif //CAB_RCF - protected: //folgende Methoden ersparen eine friend Deklaierung aller moeglichen Allocatoren //denn durch diese beiden Methoden haben sie exklusive Zugriffsrechte! @@ -282,12 +246,6 @@ protected: } }; -#ifdef RCF_USE_SF_SERIALIZATION -SF_NO_CTOR(CbVectorAllocator<double>); -SF_NO_CTOR(CbVectorAllocator<float>); -#endif //RCF_USE_SF_SERIALIZATION - - ////////////////////////////////////////////////////////////////////////// // CbVectorAllocatorStd ////////////////////////////////////////////////////////////////////////// @@ -342,24 +300,8 @@ public: return true; } /*==========================================================*/ - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - serializeParent< CbVectorAllocator<value_type> >(ar, *this); - } - #endif //CAB_RCF private: }; - -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType< CbVectorAllocatorStd<double> >(" CbVectorAllocatorStd<double> ") , SF_CbVectorAllocatorStd_double ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<double>, CbVectorAllocatorStd<double> >() ), SF_CbVectorAllocatorStd_double_BD1 ); - - UB_AUTO_RUN_NAMED( SF::registerType< CbVectorAllocatorStd<float> >(" CbVectorAllocatorStd<float> " ) , SF_CbVectorAllocatorStd_float ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< CbVectorAllocator<float> , CbVectorAllocatorStd<float> >() ), SF_CbVectorAllocatorStd_float_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif //CBVECTOR_H diff --git a/src/basics/basics/container/CbVectorPool.h b/src/basics/basics/container/CbVectorPool.h deleted file mode 100644 index e3978e2a1..000000000 --- a/src/basics/basics/container/CbVectorPool.h +++ /dev/null @@ -1,465 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef CBVECTORPOOL_H -#define CBVECTORPOOL_H - -#include <iostream> -#include <sstream> -#include <vector> -#include <map> -#include <limits> -#include <typeinfo> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbLogger.h> -#include <basics/container/CbVector.h> - -//#include "MPICommunicator.h" -// -//#include <execinfo.h> -//#include <stdio.h> -//#include <stdlib.h> -//#include <unistd.h> - -/*=========================================================================*/ -/* CbVectorPool */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -@version 1.1 - 09.02.08 -*/ - -/* -Durch Verwendung eines CbVectors in Verbindung mit einem CbVectorAllocatorPool -wird der Datenvector nicht direkt im CbVector gehalten, sondern ist ein Teil -des Datenvectors des �bergabe-CbVectorPools. -Die Methoden der von CbVectors funktionieren fehlerfrei -Es mss einem jedoch bewu�t sein, dass die "resize"-Methoden l�nger ben�tigen, da -u.U. viele Elemente im Speicher verschoeben werden muessen. -Der Poolvector enthaelt KEINE gaps, so dass er z.B. gut zur �bertragung via MPI -geeignet ist... - -Verhaltensweise bei Zerst�ren des Pools: -wird der Pool zerst�rt bevor man die CbVectoren zerst�rt, so wird beim n�chsten -Datenzugriffsversuch eine entsprechende Exception geworfen, denn alle DatenElemente -des CbVEctors werden restet und der Pool dort zu NULL gesetzt. - -Verhaltensweise bei Zerst�ren eines CbVectors: -hier ganz normal der Datenspeicher wieder freigegen und der Poolvektor verk�rzt -*/ - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - - -template<typename T> class CbVectorAllocatorPool; - -/*==================================================================*/ -template<typename T> -class CbVectorPool -{ -public: - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef std::string CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - -public: - ////////////////////////////////////////////////////////////////////////// - CbVectorPool( const size_type& startPoolSize = 20000) //startPoolSize*sizeof(T)/1024/1024 [MB] - : poolStartAdress(NULL) - , nextCbVectorStartIndexInPool(0) - , nextCbVectorKey() - { - pool.reserve(startPoolSize); - } - /*==================================================================*/ - virtual ~CbVectorPool() - { - //hier werden lediglich ihre datenvektoren "resetet" - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& vec = *it->second; - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - //FIXME: //if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //allocator daten reseten - allocator.ptrVectorPool = NULL; - allocator.key = CbVectorKey(); - allocator.startIndexInPool = 0; - - //Datenzeiger/-groessen reseten - allocator.ptrDataOf(vec) = NULL; - allocator.dataSizeOf(vec) = 0; - } - } - /*==========================================================*/ - CbVectorKey getNextCbVectorKey() const - { - return this->nextCbVectorKey; - } - /*==================================================================*/ - bool allocVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() ) - { - //pool-allocator holen - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //alloc nur wenn cbVector noch kein Element von Pool! - if( cbVectorMap.find(allocator.key)==cbVectorMap.end() ) - { - return this->allocData(allocator, vec, dataSize, value ); - } - - UB_THROW( UbException(UB_EXARGS,"vector-key="+UbSystem::toString(allocator.key)+" bereits vergeben!") ); - } - /*==================================================================*/ - bool resizeVectorData(CbVector<value_type>& vec, const size_type& dataSize, const value_type& value=value_type() ) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //cbVector noch nicht in map? - CbVectorMapIter pos = cbVectorMap.find(allocator.key); - - if( pos!=cbVectorMap.end() ) //cbVector vorhanden - { - //wenn bei alloc keine Laenge zugewiesen wurde, so erfolgt das nun - if( allocator.startIndexInPool==0 && allocator.ptrDataOf(vec)==NULL ) - return this->allocData(allocator, vec, dataSize, value ) ; - else - return this->resizeData(allocator, vec, dataSize, value ); - } - - UB_THROW( UbException(UB_EXARGS,"vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?") ); - } - /*==================================================================*/ - bool deallocVectorData(CbVector<value_type>& vec) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - if(allocator.ptrVectorPool != this) UB_THROW( UbException(UB_EXARGS,"CbVectorAllocator is part of different Pool") ); - - //nur wenn vector auch teil des - if( cbVectorMap.erase(allocator.key) > 0 ) - { - if( this->resizeData(allocator,vec,0,0) ) - { - allocator.ptrVectorPool = NULL; - allocator.key = CbVectorKey(); - allocator.startIndexInPool = 0; - - //das Datenzeiger/-groessen reseten wird bereits in resize durchgefuehrt - return true; - } - else UB_THROW( UbException(UB_EXARGS,"unknown error") ); - } - - - //SPtr<Communicator> comm = MPICommunicator::getInstance(); - //int myid = comm->getProcessID(); - -// // Get the name of the processor -// char machinename[MPI_MAX_PROCESSOR_NAME]; -// int name_len; -// MPI_Get_processor_name(machinename, &name_len); -// UBLOG(logINFO, "PID = " << myid << " host name: " << machinename); -// -// int j, nptrs; -//#define SIZE 100 -// void *buffer[100]; -// char **strings; -// -// nptrs = backtrace(buffer, SIZE); -// printf("backtrace() returned %d addresses\n", nptrs); -// -// /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) -// would produce similar output to the following: */ -// -// strings = backtrace_symbols(buffer, nptrs); -// if (strings == NULL) -// { -// perror("backtrace_symbols"); -// exit(EXIT_FAILURE); -// } -// -// for (j = 0; j < nptrs; j++) -// printf("%s\n", strings[j]); -// -// free(strings); - - UB_THROW(UbException(UB_EXARGS, "vector gehoert laut allocator zum pool aber den key gibt s nicht... wie kann das sein?")); - } - /*==================================================================*/ - friend std::ostream& operator<<(std::ostream& os, const CbVectorPool& cbPool) - { - os<<"map"<<std::endl; - for(CbVectorMapIter pos=cbPool.cbVectorMap.begin(); pos!=cbPool.cbVectorMap.end(); ++pos) - { - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*pos->second->getAllocator()); - os<<"vector-size="<<pos->second->size()<<"vector-Adress="<<tmpAllocator->ptrDataOf(*pos->second)<<", allocator(key="<<tmpAllocator.key<<", startIndex="<<tmpAllocator.startIndexInPool<<")"<<std::endl; - for(size_type i=0; i<pos->second->size(); i++) os<<(*pos->second)[i]<<","; - os<<std::endl; - } - os<<"pool"<<std::endl; - for(size_type i=0; i<cbPool.pool.size(); i++) - os<<cbPool.pool[i]<<","; os<<std::endl; - - return os; - } - /*==================================================================*/ - typename CbVectorMap::size_type getNofStoredVectors() const - { - return this->cbVectorMap.size(); - } - /*==================================================================*/ - typename Pool::size_type getPoolSize() const - { - return this->pool.size(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - bool consistencyCheck() - { - std::vector<int> pool2(pool.size(),0); - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator()); - for(size_type i=tmpAllocator.startIndexInPool; i<tmpAllocator.startIndexInPool+tmpVec.size(); ++i) - { - pool2.at(i)++; - } - } - for( size_type i=0; i<pool2.size(); ++i ) - { - if(pool2.at(i) > 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 1"); return false; } - if(pool2.at(i) < 1 ) { UBLOG(logERROR,UB_FUNCTION<<" - test failed typo 2"); return false; } - } - return true; - } -protected: - /*==================================================================*/ - inline bool allocData(CbVectorAllocatorPool< value_type >& allocator, CbVector< value_type >& vec, const size_type& dataSize, const value_type& value ) - { - //safety checks - if( allocator.startIndexInPool!=0 - || allocator.ptrDataOf(vec)!=NULL - || allocator.dataSizeOf(vec)!=0 ) - { - UB_THROW( UbException(UB_EXARGS,"zu allokierender vector ist nicht ganz sauber!!") ); - } - - //poolVector vergroessern - if( dataSize>0 ) - { - pool.resize( pool.size() + dataSize, value ); - - //Zeiger der vorhandenen CbVectoren neu setzen, wenn Pool im Speicher verschoben wurde - if( poolStartAdress != &pool.front() ) - { - poolStartAdress = &pool.front(); - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*tmpVec.getAllocator()); - - if( !tmpAllocator.ptrDataOf(tmpVec) ) continue; //Fall: CbVector hat noch keinen Datenbereich (data zeigt auf NULL) - tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool]; - } - //std::cout<<"CbVectorPoolMpi::allocVectorData vector wurde im speicher verschoben - adressen angepasst!!!"<<std::endl; - } - - //aktuellem element adresse zuweisen (wurde evtl schon inder schleife zuvor gemacht) - allocator.ptrDataOf(vec) = &pool.at(nextCbVectorStartIndexInPool); - allocator.startIndexInPool = nextCbVectorStartIndexInPool; - - //neuen StartIndex fuer naechstes Element berechnen - nextCbVectorStartIndexInPool += dataSize; - if(nextCbVectorStartIndexInPool!=pool.size()) - UB_THROW( UbException(UB_EXARGS,"index Problem... Annahme falsch?") ); - } - - //vector zu map hinzuf�gen (speicher wird dann anschliessend zugwiesen) - cbVectorMap.insert( std::make_pair( allocator.key, &vec ) ); // ist angeblich performanter als cbVectorMap[ allocator.key ] = cbVector; //aus Effective STL von Scott Meyer - allocator.dataSizeOf(vec) = dataSize; - - //dummDoof nextKey-Generung... - if( allocator.key >= this->nextCbVectorKey ) this->nextCbVectorKey = allocator.key + "1"; - - return true; - } - /*==========================================================*/ - bool resizeData(CbVectorAllocatorPool< value_type >& allocator, CbVector<value_type>& vec, const size_type& dataSize, const value_type& value ) - { - //datenvector verlaengern/-kuerzen - typename Pool::iterator startPos = pool.begin()+allocator.startIndexInPool; //startPosition der cbVector-Daten im Pool - if( vec.size() > dataSize ) pool.erase( startPos+dataSize, startPos+vec.size()); - else pool.insert( startPos+vec.size(), dataSize-vec.size(), value ); - - ////////////////////////////////////////////////////////////////////////// - //adressen und laengen der einzelnen vectoren anpassen - if( !pool.empty() ) - { - bool poolMoved = ( poolStartAdress != &pool.front() ); - poolStartAdress = &pool.front(); - - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - - if( tmpVec.size()>0 ) - { - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator()); - //liegt CbVector VOR ver�ndertem CbVector? - if( tmpAllocator.startIndexInPool <= allocator.startIndexInPool ) //ja: anpassung NUR wenn pool verschoben wurde! - { - if(poolMoved && tmpVec.size()>0 ) tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool]; - } - else //nein: -> Adresse + Index MUSS immer angepasst werden - { - tmpAllocator.startIndexInPool += dataSize-vec.size(); - tmpAllocator.ptrDataOf(tmpVec) = &pool[ tmpAllocator.startIndexInPool ]; - } - } - } - } - else //Sonderfall: alle Elemente haben Laenge 0 -> kein pool -> alle Feld-Adressen auf NULL setzen! - { - poolStartAdress = NULL; - for(CbVectorMapIter it=cbVectorMap.begin(); it!=cbVectorMap.end(); ++it) - { - CbVector< value_type >& tmpVec = *it->second; - CbVectorAllocatorPool< value_type >& tmpAllocator = dynamic_cast< CbVectorAllocatorPool<value_type>& >(*tmpVec.getAllocator()); - tmpAllocator.startIndexInPool = 0; - } - - } - - //restliche Daten von cbVector + allocator aktualisieren - allocator.dataSizeOf(vec) = dataSize; - if(dataSize==0) - { - allocator.ptrDataOf(vec) = NULL; - allocator.startIndexInPool = 0; - } - - nextCbVectorStartIndexInPool = pool.size(); - - return true; - } - -protected: - /*==================================================================*/ - void getCbVectorData(const CbVector< value_type >& vec, CbVectorKey& vectorKey, size_type& startIndexInPool, size_type& dataSize ) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - - startIndexInPool = allocator.startIndexInPool; - vectorKey = allocator.key; - dataSize = vec.size(); - } - /*==================================================================*/ - void setCbVectorData(CbVector< value_type >& vec, const CbVectorKey& vectorKey, const size_type& startIndexInPool, const size_type& dataSize ) - { - CbVectorAllocatorPool< value_type >& allocator = dynamic_cast< CbVectorAllocatorPool< value_type >& >(*vec.getAllocator() ); - - allocator.startIndexInPool = startIndexInPool; - allocator.key = vectorKey; - allocator.dataSizeOf(vec) = dataSize; - allocator.ptrDataOf(vec) = &this->pool[ startIndexInPool ]; - } - /*==================================================================*/ - - CbVectorMap cbVectorMap; //informationsmap fuer MPIData und zugewiesener vector - - Pool pool; //globaler Datenvector - typename Pool::pointer poolStartAdress; //StartAdresse des aktuellen Datenvektors - typename Pool::size_type nextCbVectorStartIndexInPool; //StartIndex fuer den naechsten CbVector - - //key - erstmal dummdoof - CbVectorKey nextCbVectorKey; -}; - - -////////////////////////////////////////////////////////////////////////// -// CbVectorAllocatorPool -////////////////////////////////////////////////////////////////////////// -template< typename T > -class CbVectorAllocatorPool : public CbVectorAllocator<T> -{ -public: - //typedefs wiederholen, da Basisklasse = template -> "Dependent-Base"-Problem - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<value_type>::size_type size_type; - - friend class CbVectorPool< value_type >; - -public: - /*==========================================================*/ - CbVectorAllocatorPool(const typename CbVectorPool< value_type >::CbVectorKey& key, CbVectorPool<value_type>* const& ptrVectorPool) - : CbVectorAllocator<value_type>() - , key(key) - , startIndexInPool(0) - , ptrVectorPool(ptrVectorPool) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") ); - } - /*==========================================================*/ - //hier wird der key automatisch erzeugt! - CbVectorAllocatorPool(CbVectorPool<value_type>* const& ptrVectorPool) - : CbVectorAllocator<value_type>() - , startIndexInPool(0) - , ptrVectorPool(ptrVectorPool) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"ptrVectorPool==NULL") ); - key = ptrVectorPool->getNextCbVectorKey(); - } - /*==========================================================*/ - bool alloc(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") ); - return ptrVectorPool->allocVectorData(vec, dataSize, value); - } - /*==========================================================*/ - bool resize(CbVector< value_type >& vec, const size_type& dataSize, const value_type& value=value_type()) - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") ); - return ptrVectorPool->resizeVectorData(vec, dataSize, value); - } - /*==========================================================*/ - bool dealloc(CbVector< value_type >& vec) - { - if(ptrVectorPool) return this->ptrVectorPool->deallocVectorData(vec); - //wenn kein ptrVectorPool -> wurde bereits deallokiert - return true; - } - /*==========================================================*/ - const CbVectorPool< value_type >& getCbVectorPool() - { - if(!ptrVectorPool) UB_THROW( UbException(UB_EXARGS,"vectorPool seems to be destroyed, ptrVectorPool==NULL") ); - return *ptrVectorPool; - } - /*==========================================================*/ - -private: - typename CbVectorPool< value_type >::CbVectorKey key; - typename CbVectorPool< value_type >::Pool::size_type startIndexInPool; - - CbVectorPool< value_type >* ptrVectorPool; - - CbVectorAllocatorPool( const CbVectorAllocatorPool& ); //no copy allowed - const CbVectorAllocatorPool& operator=( const CbVectorAllocatorPool& );//no copy allowed -}; - - -#endif //CBVECTORPOOL_H diff --git a/src/basics/basics/container/examples/CbVectorPool/CMakeLists.txt b/src/basics/basics/container/examples/CbVectorPool/CMakeLists.txt deleted file mode 100644 index a5113c6e7..000000000 --- a/src/basics/basics/container/examples/CbVectorPool/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(CbVectorPoolTests) - -################################################################# -# MACHINE_SPECIFIC CMAKE_CONFIG_FILE -################################################################# -INCLUDE("../../../../../../../CMake/CMakeCABMacros.txt") - -################################################################# -### PACKAGES ### -################################################################# -INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -FILE(GLOB SPECIFIC_FILES ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.h - ${SOURCE_ROOT}/basics/container/examples/CbVectorPool/*.cpp ) - -SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) -SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES}) - -################################################################# -### PROJECT ERSTELLEN ### -################################################################# -CREATE_CAB_PROJECT() diff --git a/src/basics/basics/container/examples/CbVectorPool/functions.h b/src/basics/basics/container/examples/CbVectorPool/functions.h deleted file mode 100644 index c9a49cdf5..000000000 --- a/src/basics/basics/container/examples/CbVectorPool/functions.h +++ /dev/null @@ -1,190 +0,0 @@ -#include <iostream> -#include <stdlib.h> -#include <stdio.h> -#include <string> -#include <fstream> - -#include <basics/utilities/UbTuple.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbTiming.h> - -#include <basics/memory/MbSmartPtr.h> - -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -using std::cout; -using std::cerr; -using std::endl; -using std::vector; - -typedef long double value_type; -typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr; -typedef MbSmartPtr<vector< value_type > > StlVectorPtr; - -/*==========================================================*/ -template<typename T> -inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("setValues - sizeCheck failed") ); - } - static value_type stlVal = 1; - static value_type cbVal = 1; - static value_type cbPoolVal = 1; - - for(size_t i=0; i<cbvec.size(); i++) stlvec[i] = stlVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbvec[i] = cbVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++; -} -/*==========================================================*/ -template<typename T> -inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - throw UB_THROW( UbException("setValues glob - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val) -{ - stlvec.resize(size,val); - cbvec.resize(size,val); - cbpoolvec.resize(size,val); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - throw UB_THROW( UbException("resize glob - sizeCheck failed") ); - } - - if(timed) - { - UbTimer timer; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val); if(timed) cout<<"stl-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val); if(timed) cout<<"cbStd-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl; - } - else - { - for(size_t i=0; i<cbvecs.size(); i++) - resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val); - } -} -/*==========================================================*/ -inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool)))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; - - for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back()); -} -/*==========================================================*/ -inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; -} -/*==========================================================*/ -template<typename T> -inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - bool check=true; - for(size_t i=0; i<cbvec.size(); i++) - if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i] ) - check=false; - - if(!check) - { - cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" "; cout<<endl; - cerr<< "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" "; cout<<endl; - cerr<< "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl; - throw UB_THROW( UbException("equalCheck - equalCheck failed") ); - } -} -/*==========================================================*/ -template<typename T> -void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - throw UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - { - //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1; - equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); - //cout<<" passed"<<endl; - } -} -/*==========================================================*/ -void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - UbTimer timer; - timer.start(); - for(size_t i=0; i<stlvecs.size(); i++) - { - vector<value_type>& vec = *stlvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"stl-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbvecs.size(); i++) - { - CbVector<value_type>& vec = *cbvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbStd-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbpoolvecs.size(); i++) - { - CbVector<value_type>& vec = *cbpoolvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbPool-accessCheck in "<<timer.stop()<<"s"<<endl; -} diff --git a/src/basics/basics/container/examples/CbVectorPool/main.cpp b/src/basics/basics/container/examples/CbVectorPool/main.cpp deleted file mode 100644 index ede778c94..000000000 --- a/src/basics/basics/container/examples/CbVectorPool/main.cpp +++ /dev/null @@ -1,277 +0,0 @@ -#include "./functions.h" - -using namespace std; - -////////////////////////////////////////////////////////////////////////// -int main(int argc, char** argv) -{ - try - { - { - CbVectorPool<float>* floatPool = new CbVectorPool<float>(0); - CbVector<float> v1,v2,v3; - CbVector<float> v0(new CbVectorAllocatorPool<float>(104,floatPool) ); - v0.resize(20); - v0[3] = 60000; - v0.resize(40); - v0[3] = 90000; - v1.setAllocator( new CbVectorAllocatorPool<float>(100,floatPool) ); - v2.setAllocator( new CbVectorAllocatorPool<float>(101,floatPool) ); - v3.setAllocator( new CbVectorAllocatorPool<float>(102,floatPool) ); - v1.resize(20, 0.0); - v1.resize(30, 0.0); - v2.resize(0); - v2.resize(40, 0.0); - v3.resize(30, 0.0); - v3.resize(50, 0.0); - - for(CbVector<float>::size_type i=v1.size()-1; i>=15; i--) - v1[i] = (CbVector<float>::value_type)i; - for(CbVector<float>::size_type i=v2.size()-1; i>=35; i--) - v2[i] = (CbVector<float>::value_type)i; - for(CbVector<float>::size_type i=v3.size()-1; i>=10; i--) - v3[i] = (CbVector<float>::value_type)i; - v1.size(); - v2.size(); - v3.size(); - for(CbVector<float>::size_type i=0; i<v1.size(); i++) v1[i]; - v1.size(); - v2.size(); - v3.size(); - for(CbVector<float>::size_type i=0; i<v2.size(); i++) v2[i]; - v1.size(); - v2.size(); - v3.size(); - for(CbVector<float>::size_type i=0; i<v3.size(); i++) v3[i]; - } - - CbVectorPool<value_type>* vectorPool = new CbVectorPool<value_type>(0); - - vector< StlVectorPtr > stlVecs; - vector< CbVectorPtr > cbVecs; - vector< CbVectorPtr > cbPoolVecs; - - cout<<"check"<<__LINE__<<endl; - createVecs(10,12,0,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,0,2); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,3,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - createVecs(8,5,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,7); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,0,7); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,0,7); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - //dealloc check - stlVecs.resize(5); - cbVecs.resize(5); - cbPoolVecs.resize(5); - - cout<<"check"<<__LINE__<<endl; - createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - createVecs(4,3,stlVecs,cbVecs,cbPoolVecs,vectorPool); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - - //operator= check - CbVector<value_type> testPool1(10, new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testPool2(1 , new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testPool3(8 , new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testPool4(8 , new CbVectorAllocatorPool<value_type>(vectorPool)); - CbVector<value_type> testStd1(10); - - for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ ) - testStd1[i] = (value_type)i*10; - - testPool1 = testStd1; - testPool4 = testStd1; - testPool3 = testPool4; - testPool2 = testPool3; - - for(CbVector<value_type>::size_type i=0; i<testStd1.size(); i++ ) - cout<<testStd1[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool1.size(); i++ ) - cout<<testPool1[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool2.size(); i++ ) - cout<<testPool2[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool3.size(); i++ ) - cout<<testPool3[i]<<" "; cout<<endl; - for(CbVector<value_type>::size_type i=0; i<testPool4.size(); i++ ) - cout<<testPool4[i]<<" "; cout<<endl; - ///end - - - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// access test - start"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"check"<<__LINE__<<endl; - createVecs(1000,1000,stlVecs,cbVecs,cbPoolVecs,vectorPool,true); - - CbVectorPool<value_type>* pool2 = new CbVectorPool<value_type>(1); - vector< StlVectorPtr > stlVecs2; - vector< CbVectorPtr > cbVecs2; - vector< CbVectorPtr > cbPoolVecs2; - createVecs(1000,1000,stlVecs2,cbVecs2,cbPoolVecs2,pool2,true); - - cout<<"access check\n"; - //accessCheck(1000,stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - setValues(stlVecs,cbVecs,cbPoolVecs); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"check"<<__LINE__<<endl; - resize(stlVecs,cbVecs,cbPoolVecs,120,3,true); - equalCheck(stlVecs,cbVecs,cbPoolVecs); - - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// access test - end"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// EXCEPTION TEST - start"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - delete vectorPool; - vectorPool = NULL; - try - { - resize(stlVecs,cbVecs,cbPoolVecs,20,3); - } - catch(UbException& e) - { - cout<<"if exception tells something about \"vectorPool==NULL\" -> test successfully passed:"<<endl; - cout<<e<<endl; - } - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - cout<<"// EXCEPTION TEST - end"<<endl; - cout<<"//////////////////////////////////////////////////////////////////////////"<<endl; - - cout<<"\n\n\nALL TESTS PASSED\n"; - } - catch(UbException& e) - { - std::cerr<<e<<std::endl; - } - catch(const std::exception &e) - { - std::cerr << "Caught exception:\n"; - std::cerr << "Type: " << typeid(e).name() << "\n"; - std::cerr << "What: " << e.what() << "\n"; - } - catch(...) - { - std::cerr<<" ** Verdammte Scheisse - mal wieder Mist gebaut! **"<<endl; - } - return 0; -} - -// #include <functional> -// #include <iostream> -// #include <vector> -// #include <algorithm> -// #include <typeinfo> -// -// struct bar -// { -// bar() -// : data(0) -// {} -// -// void foo(const std::size_t value) { std::cout << "data = " << value << " (old: " << data << ");" << std::endl; data = value; } -// -// private: -// std::size_t data; -// }; -// -// int main() -// { -// std::vector<bar> data(10); -// -// /* operator[] => Indexoperator */ -// for (std::size_t i(0); i < data.size(); ++i) -// data[i].foo(2); -// -// /* begin(), end() => Iterator */ -// const std::vector<bar>::iterator it_end(data.end()); -// for (std::vector<bar>::iterator it(data.begin()); it != it_end; ++it) -// it->foo(3); -// -// /* for_each => Algorithm | Iterator */ -// std::for_each(data.begin(), data.end(), std::bind2nd(std::mem_fun_ref(&bar::foo), 2)); -// } diff --git a/src/basics/basics/memory/MbChessMemPool2D.h b/src/basics/basics/memory/MbChessMemPool2D.h deleted file mode 100644 index 3ae46d2a5..000000000 --- a/src/basics/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) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==true) UB_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) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==false) UB_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 - const static 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"; - UB_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()) UB_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()) - UB_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) UB_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) UB_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!!! - //UB_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/basics/basics/memory/MbChessMemPool3D.h b/src/basics/basics/memory/MbChessMemPool3D.h deleted file mode 100644 index ffc74a8d6..000000000 --- a/src/basics/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) UB_THROW( UbException(UB_EXARGS,"out of memeory!") ); - mFlagVector = new bool[arrayLength]; - if(!mFlagVector) UB_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) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==true) UB_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) UB_THROW( UbException(UB_EXARGS,"index out of range") ); - #endif - - if(mFlagVector[arrayIndex]==false) UB_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 - const static 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"; - UB_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()) UB_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()) - UB_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(...){UB_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) UB_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) UB_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!!! - // //UB_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/basics/basics/memory/MbMemPool.h b/src/basics/basics/memory/MbMemPool.h deleted file mode 100644 index e2482caa7..000000000 --- a/src/basics/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/basics/basics/memory/MbSharedPointerDefines.h b/src/basics/basics/memory/MbSharedPointerDefines.h deleted file mode 100644 index 5d959e5ef..000000000 --- a/src/basics/basics/memory/MbSharedPointerDefines.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef MBSHAREDPOINTERDEFINES_H -#define MBSHAREDPOINTERDEFINES_H - - -#include <PointerDefinitions.h> - -//#define VFSharedFromThis std::enable_shared_from_this -//#define VFSharedPtr std::shared_ptr -//#define VFWeakPtr std::weak_ptr -//#define VFDynamicPtrCast std::dynamic_pointer_cast -// -//template<typename T> -//class VFPtrDeleter -//{ -//public: -// void operator()(T* p) { delete p; } -//}; - - - -#endif diff --git a/src/basics/basics/memory/MbSmartPtr.h b/src/basics/basics/memory/MbSmartPtr.h deleted file mode 100644 index 4321a8e1a..000000000 --- a/src/basics/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 serialize(Archive & ar, const unsigned int version) - { - 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/basics/basics/memory/MbSmartPtrBase.cpp b/src/basics/basics/memory/MbSmartPtrBase.cpp deleted file mode 100644 index d0e07fa95..000000000 --- a/src/basics/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/basics/basics/memory/MbSmartPtrBase.h b/src/basics/basics/memory/MbSmartPtrBase.h deleted file mode 100644 index bd8af5909..000000000 --- a/src/basics/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/basics/basics/objects/CMakePackage.txt b/src/basics/basics/objects/CMakePackage.txt new file mode 100644 index 000000000..1b8416f01 --- /dev/null +++ b/src/basics/basics/objects/CMakePackage.txt @@ -0,0 +1,2 @@ +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/basics/basics/objects/ObCreator.h b/src/basics/basics/objects/ObCreator.h deleted file mode 100644 index 8b9ef047c..000000000 --- a/src/basics/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/basics/basics/objects/ObFactory.h b/src/basics/basics/objects/ObFactory.h deleted file mode 100644 index aa522ec5c..000000000 --- a/src/basics/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<Base,Derived>::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) - { - UB_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/basics/basics/objects/ObObject.cpp b/src/basics/basics/objects/ObObject.cpp deleted file mode 100644 index e7774e916..000000000 --- a/src/basics/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/basics/basics/objects/ObObject.h b/src/basics/basics/objects/ObObject.h index addf7e134..3fee35065 100644 --- a/src/basics/basics/objects/ObObject.h +++ b/src/basics/basics/objects/ObObject.h @@ -1,24 +1,42 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ObObject.h +//! \ingroup objects +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #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: @@ -28,33 +46,16 @@ public: 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/basics/basics/objects/ObObjectCreator.h b/src/basics/basics/objects/ObObjectCreator.h deleted file mode 100644 index 3224466dc..000000000 --- a/src/basics/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/basics/basics/objects/ObObjectFactory.cpp b/src/basics/basics/objects/ObObjectFactory.cpp deleted file mode 100644 index 49bf03fe3..000000000 --- a/src/basics/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) -{ - UB_THROW( UbException(UB_EXARGS,"not implemented") ); -} -/*======================================================================*/ -ObObjectCreator* ObObjectFactory::getCreator(string objectType) -{ - std::map<string, ObObjectCreator*>::iterator creatorIterator = creatorSet.find(objectType); - if(creatorIterator == creatorSet.end()) UB_THROW( UbException(UB_EXARGS,"factory has no creator for "+objectType) ); - ObObjectCreator *creator = creatorIterator->second; - if(!creator) UB_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/basics/basics/objects/ObObjectFactory.h b/src/basics/basics/objects/ObObjectFactory.h deleted file mode 100644 index 2af7458cd..000000000 --- a/src/basics/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/basics/basics/objects/ObObjectManager.cpp b/src/basics/basics/objects/ObObjectManager.cpp deleted file mode 100644 index d84f49fc1..000000000 --- a/src/basics/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() -{ - UB_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/basics/basics/objects/ObObjectManager.h b/src/basics/basics/objects/ObObjectManager.h deleted file mode 100644 index 9d5b42df9..000000000 --- a/src/basics/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/basics/basics/objects/package.include b/src/basics/basics/objects/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/basics/parallel/PbMpi.h b/src/basics/basics/parallel/PbMpi.h deleted file mode 100644 index 76011d613..000000000 --- a/src/basics/basics/parallel/PbMpi.h +++ /dev/null @@ -1,454 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef PbMpi_H -#define PbMpi_H - -#include <vector> -#include <sstream> - -#ifndef VF_MPI -# error VF_MPI has to be defined -#endif - -//#undef SEEK_SET -//#undef SEEK_CUR -//#undef SEEK_END -#include <mpi.h> - -#include <basics/utilities/UbException.h> - -#ifdef USE_MPI_CXX_SYNTAX - #define PbMpi_COMM_WORLD MPI::COMM_WORLD - #define PbMpi_INT MPI::INT - #define PbMpi_CHAR MPI::CHAR - #define PbMpi_SHORT MPI::SHORT - #define PbMpi_FLOAT MPI::FLOAT - #define PbMpi_DOUBLE MPI::DOUBLE - #define PbMpi_COMM_NULL MPI::COMM_NULL - - -namespace PbMpi -{ - typedef MPI::Intracomm Comm; - typedef MPI::Group Group; - typedef MPI::Request Request; - typedef MPI::Status Status; - - inline void Init( ) - { - MPI::Init(); - MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); - } - inline void Init(int& argc, char** argv ) - { - MPI::Init(argc, argv); - MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); - } - inline void Finalize() { MPI::Finalize(); } - - inline int GetCommSize( const Comm& comm ) { return comm.Get_size(); } - inline int GetCommRank( const Comm& comm ) { return comm.Get_rank(); } - inline void Barrier( const Comm& comm ) { comm.Barrier(); } - - inline double Wtime() { return MPI::Wtime(); } - inline double Wtick() { return MPI::Wtick(); } - - inline void Wait( Request& request, Status* outStatus=NULL) - { - if(outStatus) request.Wait(*outStatus); - else request.Wait(); - } - - inline Group GetCommGroup(Comm& comm) { return comm.Get_group(); } - inline Group GetGroupIncl( Group& group, const int& n, int* ranks ) { return group.Incl(n, ranks); } - inline Comm CommCreateComm( Comm& comm, Group& group ) { return comm.Create(group); } - - inline void Alltoall( Comm& comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype) - { - comm.Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype); - } - inline void Bcast(Comm& comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank ) - { - comm.Bcast(data, n, datatype, srcRank); - } - inline void Send(Comm& comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - try - { - comm.Send(data, length, dataType, destRank, tag); - } - catch(MPI::Exception& e) - { - std::stringstream ss; - ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str()); - } - catch(...) - { - throw UbException(UB_EXARGS,"unknown exception"); - } - } - inline void Recv(Comm& comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag) - { - try - { - comm.Recv(const_cast<void*>(data), length, dataType, srcRank, tag); - } - catch(MPI::Exception& e) - { - std::stringstream ss; - ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - throw UbException(UB_EXARGS,"MPI:Exception catched \n"+ss.str()); - } - catch(...) - { - throw UbException(UB_EXARGS,"unknown exception"); - } - } - - inline void Irecv(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest) - { - outRequest = comm.Irecv(const_cast<void*>(data), length, dataType, srcRank, tag); - } - inline void Ssend(Comm& comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - try - { - comm.Ssend(data, length, dataType, destRank, tag); - } - catch(MPI::Exception& e) - { - std::stringstream ss; - ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - throw UbException(UB_EXARGS,"MPI:Exception catched\n"+ss.str()); - } - catch(...) - { - throw UbException(UB_EXARGS,"unknown exception"); - } - } - -} -#else ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // C-Syntax - ////////////////////////////////////////////////////////////////////////// - namespace PbMpi - { - typedef MPI_Comm Comm; - typedef MPI_Group Group; - typedef MPI_Request Request; - typedef MPI_Status Status; - } - - #define PbMpi_COMM_WORLD ((PbMpi::Comm)MPI_COMM_WORLD) - #define PbMpi_INT MPI_INT - #define PbMpi_CHAR MPI_CHAR - #define PbMpi_SHORT MPI_SHORT - #define PbMpi_FLOAT MPI_FLOAT - #define PbMpi_DOUBLE MPI_DOUBLE - #define PbMpi_COMM_NULL MPI_COMM_NULL - -namespace PbMpi -{ - inline void Init( ) - { - int argc = 1; - char** argv = new char*[1]; - argv[0] = new char[1]; - argv[0][0] = 'n'; - MPI_Init(&argc, &argv); - } - inline void Init(int& argc, char** argv ) { MPI_Init(&argc, &argv); } - inline void Finalize( ) { MPI_Finalize(); } - inline int GetCommSize( Comm comm ) { int tmp; MPI_Comm_size(comm, &tmp); return tmp; } - inline int GetCommRank( Comm comm ) { int tmp; MPI_Comm_rank(comm, &tmp); return tmp; } - inline void Barrier( Comm comm ) { MPI_Barrier( comm ); } - inline double Wtime() { return MPI_Wtime(); } - inline double Wtick() { return MPI_Wtick(); } - inline void Wait( Request& request, Status* outStatus=NULL) { MPI_Wait( &request, outStatus); } - - inline Group GetCommGroup(Comm comm) { Group out; MPI_Comm_group(comm, &out); return out; } - inline Group GetGroupIncl( Group group, const int& n, int* ranks ) { Group out; MPI_Group_incl(group, n, ranks, &out); return out; } - inline Comm CommCreateComm( Comm comm, Group& group ) { Comm out; MPI_Comm_create(comm, group, &out); return out; } - - inline void Alltoall( Comm comm, void* sendBuffer, const int& sn, const MPI_Datatype& sdatatype, void* recvBuffer, const int& rn, const MPI_Datatype& rdatatype) - { - MPI_Alltoall(sendBuffer, sn, sdatatype, recvBuffer, rn, rdatatype, comm); - } - inline void Bcast(Comm comm, void* data, const int& n, const MPI_Datatype& datatype , const int& srcRank ) - { - MPI_Bcast(data, n, datatype, srcRank, comm); - } - inline void Send(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - MPI_Send(const_cast<void*>(data), length, dataType, destRank, tag, comm); - } - inline void Recv(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag) - { - MPI_Recv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, MPI_STATUS_IGNORE); - } - inline void Ssend(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& destRank, const int& tag) - { - MPI_Ssend(const_cast<void*>(data), length, dataType, destRank, tag, comm); - } - inline void Irecv(Comm comm, const void* data, const int& length, const MPI_Datatype& dataType, const int& srcRank, const int& tag, Request& outRequest) - { - MPI_Irecv(const_cast<void*>(data), length, dataType, srcRank, tag, comm, &outRequest); - } - -} -#endif - -namespace PbMpi -{ - /*======================================================================*/ - // send a single value "value" of MPI_Datatype - template <class T> - inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives a single value "value" of MPI_Datatype - template <class T> - inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives and returns a single value of MPI_Datatype - // expample: int value = PbMpi::receiveSingleValue<int>(MPI::INT,0,10,comm); - template <class T> - inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline bool receiveBoolValue(int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline std::string receiveStringValue(int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // send a vector of MPI_Datatype - template <class T> - inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receive a std::vector of MPI_Datatype - template <class T> - inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // receive a vector of MPI_Datatype and adds this vector to existing vector - // ans returns number of received elements - template <class T> - inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // send a std::vector of strings - inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm); - - /*======================================================================*/ - // send a vector of strings - inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm); -}; - -/*======================================================================*/ -// send a single value of MPI_Datatype -template <class T> -void PbMpi::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm) -{ - PbMpi::Send(comm, &value, 1, datatype, dest, tag); - //comm.Send(&value, 1, datatype, dest, tag); -} -/*======================================================================*/ -template <class T> -void PbMpi::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - PbMpi::Recv(comm, &value, 1, datatype, source, tag); - //comm.Recv(&value, 1, datatype, source, tag); -} -/*======================================================================*/ -template <class T> -T PbMpi::receiveSingleValue(MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - T value; - PbMpi::Recv(comm, &value, 1, datatype, source, tag); - //comm.Recv(&value, 1, datatype, source, tag); - - return value; -} -/*======================================================================*/ -// send a bool value (bool doesn't work with template, why ever) -void PbMpi::sendBoolValue(const bool& value,int dest, int tag, PbMpi::Comm comm) -{ - short dummy; - if(value) dummy=1; - else dummy=0; - - PbMpi::Send(comm, &dummy, 1, PbMpi_SHORT, dest, tag); - //comm.Send(&dummy, 1, MPI::SHORT, dest, tag); -} -/*======================================================================*/ -bool PbMpi::receiveBoolValue(int source, int tag, PbMpi::Comm comm) -{ - short dummy; - PbMpi::Recv(comm, &dummy, 1, PbMpi_SHORT, source, tag); - //comm.Recv(&dummy, 1, MPI::SHORT, source, tag); - - return (dummy==1); -} -/*======================================================================*/ -// sends bool value (doesn't work with template, why ever... stupid MPI) -void PbMpi::sendStringValue(const std::string& value,int dest, int tag, PbMpi::Comm comm) -{ - std::vector<char> vec; - for(std::size_t i=0; i<value.size(); i++) - vec.push_back(value[i]); - - PbMpi::sendVector(vec,PbMpi_CHAR,dest,tag,comm); -} - -/*======================================================================*/ -// receives bool value (doesn't work with template, why ever... stupid MPI) -std::string PbMpi::receiveStringValue(int source, int tag, PbMpi::Comm comm) -{ - std::vector<char> vec; - PbMpi::receiveVector(vec,PbMpi_CHAR,source,tag,comm); - - std::string str; - for(std::size_t i=0; i<vec.size(); i++) - str+=vec[i]; - - return str; -} -/*======================================================================*/ -// send a vector of MPI_Datatype -template <class T> -void PbMpi::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, PbMpi::Comm comm) -{ - // send size - int size = (int)v.size(); - - PbMpi::Send(comm, &size, 1, PbMpi_INT, dest, tag); - //comm.Send(&size, 1, MPI::INT, dest, tag); - - if(size>0) - { - PbMpi::Send(comm, &v[0], size, datatype, dest, tag); - //comm.Send(&v[0], size, datatype, dest, tag); - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype -template <class T> -void PbMpi::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - int size; - - PbMpi::Recv(comm, &size, 1, PbMpi_INT, source, tag); - //comm.Recv(&size, 1, MPI::INT, source, tag); - - v.resize(size); - - if( size>0 ) - { - PbMpi::Recv(comm, &v[0], size, datatype, source, tag); - //comm.Recv(&v[0], size, datatype, source, tag); - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype and adds this vector to existing vector -// return value is size of received elements -template <class T> -int PbMpi::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, PbMpi::Comm comm) -{ - int incommingSize; - - PbMpi::Recv(comm, &incommingSize, 1, PbMpi_INT, source, tag); - //comm.Recv(&incommingSize, 1, MPI::INT, source, tag); - - int oldSize = (int)v.size(); - v.resize(oldSize+incommingSize); - - if( incommingSize>0 ) - { - PbMpi::Recv(comm, &v[oldSize], incommingSize, datatype, source, tag); - //comm.Recv(&v[oldSize], incommingSize, datatype, source, tag); - } - - return incommingSize; -} -/*======================================================================*/ -// send a vector of strings -void PbMpi::sendStringVector(const std::vector<std::string>& v, int dest, int tag, PbMpi::Comm comm) -{ - // send size - int stringVectorSize = (int)v.size(); - - PbMpi::Send(comm, &stringVectorSize, 1, PbMpi_INT, dest, tag); - //comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - int nofChars = 0; - for(int i=0; i<stringVectorSize; i++) - nofChars += singleStringSizes[i] = (int)v[i].length(); - singleStringSizes[stringVectorSize] = nofChars; - - PbMpi::Send(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, dest, tag); - - std::vector<char> charVector(nofChars); - int pos = 0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - charVector[pos++] = v[i][j]; - - PbMpi::Send(comm, &charVector[0], nofChars, PbMpi_CHAR, dest, tag); - //comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); - } -} -/*======================================================================*/ -// send a vector of strings -void PbMpi::receiveStringVector(std::vector<std::string>& v, int source, int tag, PbMpi::Comm comm) -{ - // send size - int stringVectorSize; - PbMpi::Recv(comm, &stringVectorSize, 1, PbMpi_INT, source, tag); - //comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); - - v.clear(); - v.resize(stringVectorSize); - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - - PbMpi::Recv(comm, &singleStringSizes[0], stringVectorSize+1, PbMpi_INT, source, tag); - //comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); - - int nofChars = singleStringSizes[stringVectorSize]; - std::vector<char> charVector(nofChars); - - PbMpi::Recv(comm, &charVector[0], nofChars, PbMpi_CHAR, source, tag); - //comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); - - int pos=0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - v[i].push_back(charVector[pos++]); - } -} - -#endif //PbMpi_H diff --git a/src/basics/basics/parallel/PbMpiTools.h b/src/basics/basics/parallel/PbMpiTools.h deleted file mode 100644 index 07ea52881..000000000 --- a/src/basics/basics/parallel/PbMpiTools.h +++ /dev/null @@ -1,303 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef PBMPITOOLS_H -#define PBMPITOOLS_H - -#include <vector> -#include <sstream> - -//#undef SEEK_SET -//#undef SEEK_CUR -//#undef SEEK_END -#include <mpi.h> -#include <basics/utilities/UbException.h> - -#ifdef USE_MPI_CXX_SYNTAX - -namespace PbMpiTools -{ - /*======================================================================*/ - // send a single value "value" of MPI_Datatype - template <class T> - inline void sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives a single value "value" of MPI_Datatype - template <class T> - inline void receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives and returns a single value of MPI_Datatype - // expample: int value = PbMpiTools::receiveSingleValue<int>(MPI::INT,0,10,comm); - template <class T> - inline T receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline bool receiveBoolValue(int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // sends bool value (doesn't work with template, why ever... stupid MPI) - inline void sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receives bool value (doesn't work with template, why ever... stupid MPI) - inline std::string receiveStringValue(int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // send a vector of MPI_Datatype - template <class T> - inline void sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receive a std::vector of MPI_Datatype - template <class T> - inline void receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // receive a vector of MPI_Datatype and adds this vector to existing vector - // ans returns number of received elements - template <class T> - inline int receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // send a std::vector of strings - inline void sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm); - - /*======================================================================*/ - // send a vector of strings - inline void receiveStringVector(std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm); -}; - -/*======================================================================*/ -// send a single value of MPI_Datatype -template <class T> -void PbMpiTools::sendSingleValue(const T& value, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm) -{ - try{ comm.Send(&value, 1, datatype, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } -} -/*======================================================================*/ -template <class T> -void PbMpiTools::receiveSingleValue(T& value, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - try { comm.Recv(&value, 1, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } -} -/*======================================================================*/ -template <class T> -T PbMpiTools::receiveSingleValue(MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - T value; - try { comm.Recv(&value, 1, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - return value; -} -/*======================================================================*/ -// send a bool value (bool doesn't work with template, why ever) -void PbMpiTools::sendBoolValue(const bool& value,int dest, int tag, MPI::Intracomm comm) -{ - short dummy; - if(value) dummy=1; - else dummy=0; - - try{ comm.Send(&dummy, 1, MPI::SHORT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } -} -/*======================================================================*/ -bool PbMpiTools::receiveBoolValue(int source, int tag, MPI::Intracomm comm) -{ - short dummy; - try { comm.Recv(&dummy, 1, MPI::SHORT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - return (dummy==1); -} -/*======================================================================*/ -// sends bool value (doesn't work with template, why ever... stupid MPI) -void PbMpiTools::sendStringValue(const std::string& value,int dest, int tag, MPI::Intracomm comm) -{ - std::vector<char> vec; - for(std::size_t i=0; i<value.size(); i++) - vec.push_back(value[i]); - PbMpiTools::sendVector(vec,MPI::CHAR,dest,tag,comm); -} - -/*======================================================================*/ -// receives bool value (doesn't work with template, why ever... stupid MPI) -std::string PbMpiTools::receiveStringValue(int source, int tag, MPI::Intracomm comm) -{ - std::vector<char> vec; - PbMpiTools::receiveVector(vec,MPI::CHAR,source,tag,comm); - std::string str; - for(std::size_t i=0; i<vec.size(); i++) - str+=vec[i]; - - return str; -} -/*======================================================================*/ -// send a vector of MPI_Datatype -template <class T> -void PbMpiTools::sendVector(const std::vector<T>& v, MPI_Datatype datatype, int dest, int tag, MPI::Intracomm comm) -{ - // send size - int size = (int)v.size(); - - try{ comm.Send(&size, 1, MPI::INT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } - - if(size>0) - { - try{ comm.Send(&v[0], size, datatype, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype -template <class T> -void PbMpiTools::receiveVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - int size; - - try { comm.Recv(&size, 1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - v.resize(size); - - if( size>0 ) - { - try{ comm.Recv(&v[0], size, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); } - } -} -/*======================================================================*/ -// receive a vector of MPI_Datatype and adds this vector to existing vector -// return value is size of received elements -template <class T> -int PbMpiTools::receiveVectorAndAddToVector(std::vector<T>& v, MPI_Datatype datatype, int source, int tag, MPI::Intracomm comm) -{ - int incommingSize; - - try { comm.Recv(&incommingSize, 1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss;ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive size\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive size") ); } - - int oldSize = (int)v.size(); - v.resize(oldSize+incommingSize); - - if( incommingSize>0 ) - { - try{ comm.Recv(&v[oldSize], incommingSize, datatype, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at receive vector\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at receive vector") ); } - } - - return incommingSize; -} -/*======================================================================*/ -// send a vector of strings -void PbMpiTools::sendStringVector(const std::vector<std::string>& v, int dest, int tag, MPI::Intracomm comm) -{ - // send size - int stringVectorSize = (int)v.size(); - - try{ comm.Send(&stringVectorSize, 1, MPI::INT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - int nofChars = 0; - for(int i=0; i<stringVectorSize; i++) - nofChars += singleStringSizes[i] = (int)v[i].length(); - singleStringSizes[stringVectorSize] = nofChars; - - try{ comm.Send(&singleStringSizes[0], stringVectorSize+1, MPI::INT, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - - std::vector<char> charVector(nofChars); - int pos = 0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - charVector[pos++] = v[i][j]; - - try{ comm.Send(&charVector[0], nofChars, MPI::CHAR, dest, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - } -} -/*======================================================================*/ -// send a vector of strings -void PbMpiTools::receiveStringVector(std::vector<std::string>& v, int source, int tag, MPI::Intracomm comm) -{ - // send size - int stringVectorSize; - try { comm.Recv(&stringVectorSize, 1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send size\n"+ss.str()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send size") ); } - - v.clear(); - v.resize(stringVectorSize); - - if(stringVectorSize>0) - { - std::vector<int> singleStringSizes(stringVectorSize+1); - - try{ comm.Recv(&singleStringSizes[0], stringVectorSize+1, MPI::INT, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - - int nofChars = singleStringSizes[stringVectorSize]; - std::vector<char> charVector(nofChars); - - try{ comm.Recv(&charVector[0], nofChars, MPI::CHAR, source, tag); } - catch(MPI::Exception& e){ std::stringstream ss; ss<<"MPI::Exception error_string="<<e.Get_error_string()<<std::endl; - UB_THROW( UbException(UB_EXARGS,"MPI:Exception catched with info at send vector<T>\n"+ss.str()) );} - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown exception at send vector<T>") ); } - - int pos=0; - for(int i=0; i<stringVectorSize; i++) - for(int j=0; j<singleStringSizes[i]; j++) - v[i].push_back(charVector[pos++]); - } -} - -#endif - -#endif //PBMPITOOLS_H diff --git a/src/basics/basics/parallel/examples/simpleMPI/CMakeLists.txt b/src/basics/basics/parallel/examples/simpleMPI/CMakeLists.txt deleted file mode 100644 index a44b5c76e..000000000 --- a/src/basics/basics/parallel/examples/simpleMPI/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -INCLUDE("../../../../CMakeCABMacros.txt") -INCLUDE("../../../../CMakeSetCompilerFlags.txt") - -CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN") -SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake") - -PROJECT(simpleMPI) - -#erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben) -INCLUDE(${CMAKE_CONFIG_FILE}) - -SET(EXECUTABLE_NAME simpleMPI) - -################################################################ -## PACKAGES ### -################################################################ -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/parallel/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -SET(ALL_SOURCES ${ALL_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) - -SOURCE_GROUP(main FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) - -ADD_CXX_FLAGS("/wd4996") #deprecated strcpy... - -################################################################# -### MPI ### -################################################################# -SET_MPI_STUFF(CAB_MACHINE) -SET(EXECUTABLE_NAME ${EXECUTABLE_NAME}_mpi) - -################################################################# -### EXCECUTABLE ### -################################################################# -ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} ) - -################################################################# -### ADDITIONAL LINK LIBRARIES ### -################################################################# -IF(ADDITIONAL_LINK_LIBRARIES) - TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${ADDITIONAL_LINK_LIBRARIES}) -ENDIF(ADDITIONAL_LINK_LIBRARIES) - -################################################################# -### ADDITIONAL LINK PROPERTIES ### -################################################################# -IF(ADDITIONAL_LINK_PROPS) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${ADDITIONAL_LINK_PROPS}) -ENDIF(ADDITIONAL_LINK_PROPS) -IF(ADDITIONAL_LINK_PROPS_DEBUG) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_DEBUG ${ADDITIONAL_LINK_PROPS_DEBUG}) -ENDIF(ADDITIONAL_LINK_PROPS_DEBUG) -IF(ADDITIONAL_LINK_PROPS_RELEASE) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS_RELEASE ${ADDITIONAL_LINK_PROPS_RELEASE}) -ENDIF(ADDITIONAL_LINK_PROPS_RELEASE) - - - diff --git a/src/basics/basics/parallel/examples/simpleMPI/functions.h b/src/basics/basics/parallel/examples/simpleMPI/functions.h deleted file mode 100644 index 38005eca5..000000000 --- a/src/basics/basics/parallel/examples/simpleMPI/functions.h +++ /dev/null @@ -1,193 +0,0 @@ -#include <iostream> -#include <stdlib.h> -#include <stdio.h> -#include <string> -#include <fstream> - -#include <basics/utilities/UbTuple.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbTiming.h> - -#include <basics/memory/MbSmartPtr.h> - -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -using std::cout; -using std::cerr; -using std::endl; -using std::vector; - -typedef long double value_type; -typedef MbSmartPtr<CbVector< value_type > > CbVectorPtr; -typedef MbSmartPtr<vector< value_type > > StlVectorPtr; - -/*==========================================================*/ -template<typename T> -inline void setValues(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("setValues - sizeCheck failed") ); - } - static value_type stlVal = 1; - static value_type cbVal = 1; - static value_type cbPoolVal = 1; - - for(size_t i=0; i<cbvec.size(); i++) stlvec[i] = stlVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbvec[i] = cbVal ++; - for(size_t i=0; i<cbvec.size(); i++) cbpoolvec[i] = cbPoolVal++; -} -/*==========================================================*/ -template<typename T> -inline void setValues(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - UB_THROW( UbException("setValues glob - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - setValues(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec, std::size_t size, const T& val) -{ - stlvec.resize(size,val); - cbvec.resize(size,val); - cbpoolvec.resize(size,val); -} -/*==========================================================*/ -template<typename T> -inline void resize(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, std::size_t size, const value_type& val, bool timed=false) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - UB_THROW( UbException("resize glob - sizeCheck failed") ); - } - - if(timed) - { - UbTimer timer; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) stlvecs[i]->resize(size,val); if(timed) cout<<"stl-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbvecs[i]->resize(size,val); if(timed) cout<<"cbStd-resize in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<cbvecs.size(); i++) cbpoolvecs[i]->resize(size,val); if(timed) cout<<"cbPool-resize in "<<timer.stop()<<"s"<<endl; - } - else - { - for(size_t i=0; i<cbvecs.size(); i++) - resize(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i],size,val); - } -} -/*==========================================================*/ -template<typename T> -inline void createVecs(size_t number, int size,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool)))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; - - for(size_t i=0; i<cbvecs.size(); i++) setValues(*stlvecs.back(),*cbvecs.back(),*cbpoolvecs.back()); -} -/*==========================================================*/ -template<typename T> -inline void createVecs(size_t number, size_t size, const value_type& val,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs, CbVectorPool<value_type>*& pool, bool timed=false) -{ - UbTimer timer; - timer.start(); for(size_t i=0; i<number; i++) stlvecs.push_back(StlVectorPtr(new vector<value_type>(size,val))); if(timed) cout<<"stl-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorStd<value_type>(),val))); if(timed) cout<<"cbStd-createVecs in "<<timer.stop()<<"s"<<endl; - timer.start(); for(size_t i=0; i<number; i++) cbpoolvecs.push_back(CbVectorPtr(new CbVector<value_type>(size,new CbVectorAllocatorPool<value_type>(pool),val))); if(timed) cout<<"cbPool-createVecs in "<<timer.stop()<<"s"<<endl; -} -/*==========================================================*/ -template<typename T> -inline void equalCheck(vector<T>& stlvec, CbVector<T>& cbvec, CbVector<T>& cbpoolvec) -{ - if(stlvec.size() != cbvec.size() || stlvec.size() != cbpoolvec.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvec.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvec.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvec.size()<<endl; - throw UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - bool check=true; - for(size_t i=0; i<cbvec.size(); i++) - if(stlvec[i] != cbvec[i] || stlvec[i] != cbpoolvec[i] ) - check=false; - - if(!check) - { - cerr<<"\nstl - "; for(size_t i=0; i<cbvec.size(); i++) cout<<stlvec[i]<<" "; cout<<endl; - cerr<< "cbv - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbvec[i]<<" "; cout<<endl; - cerr<< "cbp - "; for(size_t i=0; i<cbvec.size(); i++) cout<<cbpoolvec[i]<<" "; cout<<endl; - throw UB_THROW( UbException("equalCheck - equalCheck failed") ); - } -} -/*==========================================================*/ -template<typename T> -void equalCheck(vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - if(stlvecs.size() != cbvecs.size() || stlvecs.size() != cbpoolvecs.size() ) - { - cerr<<"sizes:"<<endl; - cerr<<"stlvec... = "<<(int)stlvecs.size()<<endl; - cerr<<"cbvec.... = "<<(int)cbvecs.size()<<endl; - cerr<<"cbpoolvec = "<<(int)cbpoolvecs.size()<<endl; - UB_THROW( UbException("equalCheck - sizeCheck failed") ); - } - - for(size_t i=0; i<cbvecs.size(); i++) - { - //cout<<"equalCheck i="<<i<<"/"<<cbvecs.size()-1; - equalCheck(*stlvecs[i],*cbvecs[i],*cbpoolvecs[i]); - //cout<<" passed"<<endl; - } -} -/*==========================================================*/ -template<typename T> -void accessCheck(int times,vector< StlVectorPtr >& stlvecs, vector< CbVectorPtr >& cbvecs, vector< CbVectorPtr >& cbpoolvecs) -{ - UbTimer timer; - timer.start(); - for(size_t i=0; i<stlvecs.size(); i++) - { - vector<value_type>& vec = *stlvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"stl-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbvecs.size(); i++) - { - CbVector<value_type>& vec = *cbvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbStd-accessCheck in "<<timer.stop()<<"s"<<endl; - timer.start(); - for(size_t i=0; i<cbpoolvecs.size(); i++) - { - CbVector<value_type>& vec = *cbpoolvecs[i]; - for(int m=0; m<times; m++) - for(vector<value_type>::size_type k=0; k<vec.size(); k++) vec[k] = k; - } - cout<<"cbPool-accessCheck in "<<timer.stop()<<"s"<<endl; -} diff --git a/src/basics/basics/parallel/examples/simpleMPI/main.cpp b/src/basics/basics/parallel/examples/simpleMPI/main.cpp deleted file mode 100644 index 18c2769e0..000000000 --- a/src/basics/basics/parallel/examples/simpleMPI/main.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include <iostream> -#include <vector> -#include <algorithm> -#include <mpi.h> - -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -int randomNumber () { return (rand()%100); } - -struct RankSetter{ - RankSetter(int rank) : rank(rank) {} - - int operator()() - { - return rank; - } - - int rank; -} /*rankSetter*/; - - -////////////////////////////////////////////////////////////////////////// -int main(int argc, char** argv) -{ - MPI::Init(argc, argv); - MPI::COMM_WORLD.Set_errhandler(MPI::ERRORS_THROW_EXCEPTIONS); - - try - { - MPI::Intracomm comm = MPI::COMM_WORLD; - - int rank = comm.Get_rank(); - - vector<int> sendData(1000,0); - generate(sendData.begin(), sendData.end(), RankSetter(rank+1) ); - - vector<int> recvData(1000,0); - - if(rank==0) - { - UBLOG(logINFO,"rank="<<rank<<" - recv request"); - MPI::Request request = comm.Irecv(&recvData[0], (int)recvData.size(), MPI::INT, 1, 100); - UBLOG(logINFO,"rank="<<rank<<" - sendData"); - comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 1, 100); - sendData.back() = 999; - - UBLOG(logINFO,"rank="<<rank<<" - Wait"); - request.Wait(); - UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back()); - } - else if(rank == 1) - { - UbSystem::sleepS(5); - UBLOG(logINFO,"rank="<<rank<<" - recv request"); - MPI::Request request = comm.Irecv(&recvData[0],(int)recvData.size(), MPI::INT, 0, 100); - - request.Wait(); - UBLOG(logINFO,"rank="<<rank<<" - all data received, last = "<<recvData.back()); - - UbSystem::sleepS(5); - UBLOG(logINFO,"rank="<<rank<<" - sendData"); - comm.Ssend(&sendData[0],(int)sendData.size(), MPI::INT, 0, 100); - sendData.back() = 999; - UBLOG(logINFO,"rank="<<rank<<" - data sent"); - } - else - { - throw UB_THROW( UbException(UB_EXARGS,"only two ranks allwoed") ); - } - - UBLOG(logINFO,"rank="<<rank<<" barrier start"); - MPI::COMM_WORLD.Barrier(); - UBLOG(logINFO,"rank="<<rank<<" barrier done "); - - } - catch(const std::exception& e) - { - UBLOG2( logERROR,std::cerr, "caught exception:" ); - UBLOG2( logERROR,std::cerr, "type: " << typeid(e).name() ); - UBLOG2ML(logERROR,std::cerr, "what: " << e.what() ); - } - catch(MPI::Exception e) - { - UBLOG2ML(logERROR,std::cerr, "caught exception:" << e.Get_error_string()); - - MPI::COMM_WORLD.Abort(99); - } - catch(...) - { - UBLOG2(logERROR,std::cerr,"Verdammte Scheisse - mal wieder Mist gebaut!"); - } - - MPI::Finalize(); - - return 0; -} - diff --git a/src/basics/basics/relation/RbAggregation.h b/src/basics/basics/relation/RbAggregation.h deleted file mode 100644 index c86c07fdd..000000000 --- a/src/basics/basics/relation/RbAggregation.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef RBAGGREGATION_H -#define RBAGGREGATION_H - -#include <sstream> -#include <iostream> -#include <map> - -using namespace std; - -template <class T1, class T2> -class RbAggregation -{ -private: - string name; - std::multimap<T1,T2> obj1Map; - std::multimap<T2,T1> obj2Map; - -public: - RbAggregation(string name) - { - this->name = name; - } - /*=========================================================================*/ - void insertPair(T1& to1, T2& to2) - { - obj1Map.insert(pair<T1,T2>(to1,to2)); - obj2Map.insert(pair<T2,T1>(to2,to1)); - } - /*=========================================================================*/ - int countObj2forObj1(T1& to1) - { - return((int)obj1Map.count(to1)); - } - - /*=========================================================================*/ - int countObj1forObj2(T2& to2) - { - return((int)obj2Map.count(to2)); - } - /*=========================================================================*/ - vector<T2> getObj2vectorForObj1(T1& to1) - { - vector<T2> obj2vector; - unsigned number = (unsigned)obj1Map.count(to1); - typedef std::multimap<T1, T2>::iterator obj1MapIterator = obj1Map.find(to1); - for(unsigned u =0; u<number; u++) - { - obj2vector.push_back(obj1MapIterator->second); - obj1MapIterator++; - } - return obj2vector; - } - ///*=========================================================================*/ - vector<T1> getObj1vectorForObj2(T2& to2) - { - vector<T1> obj1vector; - unsigned number = (unsigned)obj2Map.count(to2); - typedef std::multimap<T2, T1>::iterator obj2MapIterator = obj2Map.find(to2); - for(unsigned u =0; u<number; u++) - { - obj1vector.push_back(obj2MapIterator->second); - obj2MapIterator++; - } - return obj1vector; - } -}; -/*=========================================================================*/ -#endif - - diff --git a/src/basics/basics/transmitter/TbTransmitter.h b/src/basics/basics/transmitter/TbTransmitter.h deleted file mode 100644 index b5bb087df..000000000 --- a/src/basics/basics/transmitter/TbTransmitter.h +++ /dev/null @@ -1,68 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTER_H -#define TBTRANSMITTER_H - -#include <string> - -/*================================================================================*/ -/* TbTransmitter */ -/* */ -/** -This Class provides the base for sending and receiving of data. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -*/ - -/* -usage: ... -*/ - -////////////////////////////////////////////////////////////////////////// -// Transmitter -// macht nichts ausser daten senden und empfangen -template<typename T> -class TbTransmitter -{ -public: - typedef T value_type; - -public: - TbTransmitter() {} - virtual ~TbTransmitter() { /*std::cout<<typeid(*this).name()<<" dtor"<<std::endl;*/ } - - virtual bool isLocalTransmitter() const = 0; - virtual bool isRemoteTransmitter() const = 0; - - //preprocess (e.g. synchronizing send-/receive-buffer) - virtual void sendDataSize() = 0; - virtual void receiveDataSize()= 0; - - //calculation - virtual void prepareForSend() {} - virtual void sendData()=0; - virtual void prepareForReceive() {} - virtual value_type& receiveData()=0; - - //data-access - inline value_type& getData() { return this->data; } - inline const value_type& getData() const { return this->data; } - - //info-section (usable for remote transmitter) - virtual int getSendToRank() const { return -1; } - virtual int getSendToTag() const { return -1; } - virtual int getRecvFromRank() const { return -1; } - virtual int getRecvFromTag() const { return -1; } - - virtual std::string toString() const = 0; - -protected: - value_type data; -}; - -#endif //TBTRANSMITTER_H diff --git a/src/basics/basics/transmitter/TbTransmitterLocal.h b/src/basics/basics/transmitter/TbTransmitterLocal.h deleted file mode 100644 index fba8f150c..000000000 --- a/src/basics/basics/transmitter/TbTransmitterLocal.h +++ /dev/null @@ -1,129 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TOTRANSMITTERLOCAL_H -#define TOTRANSMITTERLOCAL_H - -#include <basics/utilities/UbException.h> -#include <basics/transmitter/TbTransmitter.h> -#include <PointerDefinitions.h> - -/*================================================================================*/ -/* TbLocalTransmitter, TbVectorSenderLocal, TbVectorReceiverLocal */ -/* */ -/** -This Class provides the base for exception handling. -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 08.11.07 -*/ - -/* -usage: ... -*/ - -////////////////////////////////////////////////////////////////////////// -// LocalTransmitter lokalen Datenaustausch -// data = send- und zugleich receive-buffer -template<typename T> -class TbLocalTransmitter : public TbTransmitter<T> -{ -public: - typedef SPtr< TbLocalTransmitter<T> > TbLocalTransmitterPtr; - - typedef T value_type; - -public: - TbLocalTransmitter() : TbTransmitter<T>() - { - - } - - bool isLocalTransmitter() const { return true; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - //send buffer wird autom resized - void sendDataSize() { } - //reiceive braucht nichts machen, da send==receive buffer ;-) - void receiveDataSize() { } - - void sendData() { } - value_type& receiveData() { return this->data; } - - std::string toString() const { return "TbLocalTransmitter"+(std::string)typeid(T).name(); } -}; - -////////////////////////////////////////////////////////////////////////// -// TbVectorSender/ReceiverLocal lokalen Datenaustausch ueber ZWEI vektoren -template<typename T> -class TbVectorReceiverLocal : public TbTransmitter<T> -{ -public: - typedef T value_type; - -public: - TbVectorReceiverLocal() : TbTransmitter<value_type>() - { - - } - //virtual ~TbVectorReceiverLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl; } - - bool isLocalTransmitter() const { return true; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - //send buffer wird autom resized - void sendDataSize() { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); } - //reiceive braucht nichts machen, das macht der sender :-) - void receiveDataSize() { } - - void sendData() { UB_THROW( UbException(UB_EXARGS,"empfaengt nur") ); } - value_type& receiveData() { return this->data; } - - std::string toString() const { return "TbVectorReceiverLocal<"+(std::string)typeid(T).name()+">"; } -}; - -template<typename T> -class TbVectorSenderLocal : public TbTransmitter<T> -{ -public: - typedef T value_type; - -public: - TbVectorSenderLocal(SPtr< TbVectorReceiverLocal< value_type > > receiver) - : TbTransmitter< value_type >(), receiver(receiver) - { - - } - //virtual ~TbVectorSenderLocal() { std::cout<<typeid(*this).name()<<" tot"<<std::endl; } - - bool isLocalTransmitter() const { return true; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - //send buffer wird autom resized - void sendDataSize() - { - assert(receiver!=NULL); - receiver->getData().resize( this->data.size() ); - } - //reiceive braucht nichts machen, da send==receive buffer ;-) - void receiveDataSize() { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); } - - void sendData() - { - assert( this->data.size() == receiver->getData().size() ); - receiver->getData() = this->data; -// for(int i=(int)this->data.size()-1; i>=0; --i) -// receiver->getData()[i]= this->data[i]; - } - value_type& receiveData() { UB_THROW( UbException(UB_EXARGS,"sendet nur") ); } - - std::string toString() const { return "TbVectorSenderLocal<"+(std::string)typeid(T).name()+">"; } - -protected: - SPtr< TbVectorReceiverLocal< value_type > > receiver; -}; - -#endif //TOTRANSMITTERLOCAL_H diff --git a/src/basics/basics/transmitter/TbTransmitterMpiPool.h b/src/basics/basics/transmitter/TbTransmitterMpiPool.h deleted file mode 100644 index 78decb50c..000000000 --- a/src/basics/basics/transmitter/TbTransmitterMpiPool.h +++ /dev/null @@ -1,536 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef TBTRANSMITTERMPIPOOL_H -#define TBTRANSMITTERMPIPOOL_H - -#ifdef VF_MPI - -#include <iostream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <map> - -#include <mpi.h> - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/container/CbVector.h> -#include <basics/container/CbVectorPool.h> - -#include <PointerDefinitions.h> -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -//TbCbVectorMpiPoolSender/Receiver -//diese verschicken immer einen VectorPool. Letztlich einen langen vector, -//der eigentlich aus vielen kleinen besteht -//jeder MpiPoolVector hat einen pointer auf die startadresse in diesem vector -//die informationen werden im TbMpiVectorPool verwaltet -//MpiPoolVector verhaelt sich nach aussen hin mit einschraenkungen wie ein std::vector -//und kann somit bei den vector connector verwendet werden -//man kann die klassen theoretisch verallgemeinern. - -template<typename T> class TbCbVectorSenderMpiPool; -template<typename T> class TbCbVectorReceiverMpiPool; - -/*==================================================================*/ -template<typename T> -class TbCbVectorMpiPool : public CbVectorPool<T> -{ -public: - typedef SPtr< TbCbVectorMpiPool< T > > MpiPoolPtr; - - ////////////////////////////////////////////////////////////////////////// - typedef std::map<std::string, MpiPoolPtr > MpiPoolPtrMap; - typedef typename MpiPoolPtrMap::iterator MpiPoolPtrMapIter; - - //da BasisKlasse templateKlasse ist MUSS man hier die typedefs nochmal wiederholen! - typedef typename CbVector<T>::value_type value_type; - typedef typename CbVector<T>::size_type size_type; - typedef std::vector< value_type > Pool; - - typedef std::string CbVectorKey; - typedef std::map< CbVectorKey, CbVector< value_type >* /*ptrVector*/ > CbVectorMap; - typedef typename CbVectorMap::iterator CbVectorMapIter; - - ////////////////////////////////////////////////////////////////////////// - friend class TbCbVectorSenderMpiPool< T >; - friend class TbCbVectorReceiverMpiPool< T >; - -protected: - ////////////////////////////////////////////////////////////////////////// - static MpiPoolPtrMap poolMap; -public: - ////////////////////////////////////////////////////////////////////////// - //STATIC MEMBERS - ////////////////////////////////////////////////////////////////////////// - //createTbCbVectorMpiPool: - // poolKey : Schluessel fuer eindeutige Indizierung in Map - // mpiRemoteRank: mpi-rank des Empfaengers/Senders - // mpiTag : mpi-tag mit dem empfangen/gesendet wird - static MpiPoolPtr createTbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize = 20000 ) //startPoolSize*sizeof(T)/1024/1024 [MB] - - { - if( poolMap.find(poolKey)!=poolMap.end() ) - { - throw UbException(UB_EXARGS,"es ist bereits ein Pool mit dem key vorhanden!!!"); - } - - //pool erstellen - MpiPoolPtr mpiPool(new TbCbVectorMpiPool<T>(poolKey, mpiRemoteRank, mpiTag, comm, startPoolSize) ); - - //pool "speichern" - TbCbVectorMpiPool< value_type >::poolMap[poolKey] = mpiPool; - - return mpiPool; - } - static void deleteTbCbVectorMpiPool(CbVectorKey poolKey) - { - MpiPoolPtrMapIter it = TbCbVectorMpiPool< value_type >::poolMap.find(poolKey); - if( it==poolMap.end() ) - { - throw UbException(UB_EXARGS,"kein Pool mit dem key vorhanden"); - } - TbCbVectorMpiPool< value_type >::poolMap.erase(it); - } - /*==================================================================*/ - static MpiPoolPtr getTbCbVectorMpiPool(CbVectorKey poolKey) - { - MpiPoolPtrMapIter it; - if( (it=TbCbVectorMpiPool< T >::poolMap.find(poolKey))!=TbCbVectorMpiPool< T >::poolMap.end() ) - { - return it->second; - } - return MpiPoolPtr(); - } - /*==================================================================*/ - static std::string getInfoString() - { - std::stringstream out; - out<<"TbCbVectorMpiPool<"<< typeid( T ).name() << ") - Info:"<<std::endl; - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - out<<"pool with key(" <<std::setw(15)<<it->first<<") " - <<"stores " <<std::setw(12)<<it->second->getNofStoredVectors() <<" vectors " - <<", elements to transfer = "<<std::setw(15)<<it->second->getPoolSize() - <<" ( "<< it->second->getPoolSize()*sizeof( T ) / ( 1024.0 * 1024.0 ) << " MB )" <<std::endl; - return out.str(); - } - /*==================================================================*/ - // checks if all vectors have one to one pool-entries - static bool consistencyCheck() - { - for(MpiPoolPtrMapIter it=poolMap.begin(); it!=poolMap.end(); ++it) - { - if( !it->second-> CbVectorPool<T>::consistencyCheck() ) - { - return false; - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static void eraseMap() - { - poolMap.clear(); - } -protected: - ////////////////////////////////////////////////////////////////////////// - TbCbVectorMpiPool(CbVectorKey poolKey, int mpiRemoteRank, int mpiTag, MPI_Comm comm, size_type startPoolSize ) - : CbVectorPool< value_type >( startPoolSize ) - , poolKey(poolKey) - , nofStoredVectors(0) //=Anzahl an Vectoren im Pool, wird bei send/receiveDataOrder gesetzt - , counterPrepareReceiveDataOrder(0) - , counterSendDataOrder(0) - , counterReceiveDataOrder(0) - , counterPrepareForReceive(0) - , counterReceive(0) - , counterPrepareForSend(0) - , counterSend(0) - , comm(comm) - , receiveRequest(MPI_REQUEST_NULL) - //, sendRequest(MPI_REQUEST_NULL) - , mpiRemoteRank(mpiRemoteRank) - , mpiTag(mpiTag) - { - if ( (std::string)typeid(value_type).name()==(std::string)typeid(double).name() ) mpiDataType = MPI_DOUBLE; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(float).name() ) mpiDataType = MPI_FLOAT; - else if( (std::string)typeid(value_type).name()==(std::string)typeid(int).name() ) mpiDataType = MPI_INT; - else throw UbException(UB_EXARGS,"no MpiDataType for T"+(std::string)typeid(T).name()); - - for (int i = 0; i < 3; i++) - { - sendRequest[i] = MPI_REQUEST_NULL; - } - } - -public: - /*==================================================================*/ - //returns key of Pool in MpiPoolMap - CbVectorKey getPoolKey() const { return this->poolKey; } - /*==================================================================*/ - //returns rank of process pool data will be send to/received from - int getRemoteRank() const { return this->mpiRemoteRank; } - /*==================================================================*/ - //returns tag of process pool data will be send to/received from - int getRemoteTag() const { return this->mpiTag; } - -protected: - /*==================================================================*/ - void sendDataOrder() - { - counterSendDataOrder++; - if(counterSendDataOrder==this->cbVectorMap.size()) - { - //allg.: bei MPI muss man darauf achten, dass bei unblocked operationen die puffer (aus dem oder in den - //geschrieben wird auch noch vorhanden sind!!! wuerde man hier z.B. einen lokalen vector mit Isend() los- - //schicken, dann wurde der scope verlassen werden und der vector evtl geloescht werden, bevor mpi den - //vorgang abgeschlossen hat!!! -> tmpOrderVec ist class-member!!! - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; - tmpSendOrderVec.resize(nofElements);//std::vector< unsigned > vec(nofElements); - unsigned index = 0; - tmpSendOrderVec[index++] = (unsigned)this->pool.size(); //= laenge des vectors - if(this->nextCbVectorStartIndexInPool != this->pool.size()) throw UbException(UB_EXARGS,"an dieser Stelle sollten nextStartIndex und pool.size() identisch sein!!!"); - for(CbVectorMapIter it = this->cbVectorMap.begin(); it!=this->cbVectorMap.end(); ++it) - { - CbVectorKey vectorKey; - size_type dataSize=0, startIndexInPool=0; - this->getCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - if(it->first != vectorKey) throw UbException(UB_EXARGS,"key mismatch!"); - - tmpSendOrderKeyVec += vectorKey; //vectorKey == allocator.getAllocatorKey() - tmpSendOrderVec[index++] = (unsigned)vectorKey.length(); - tmpSendOrderVec[index++] = (unsigned)startIndexInPool; //startIndex in poolVector - tmpSendOrderVec[index++] = (unsigned)dataSize; //dataSize - } - - MPI_Isend(&tmpSendOrderVec[0],(int)tmpSendOrderVec.size(), MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest[0]); - - tmpSendOrderKeyVecLength = (unsigned)tmpSendOrderKeyVec.length(); - MPI_Isend(&tmpSendOrderKeyVecLength,1, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, &sendRequest[1]); - MPI_Isend((char *)tmpSendOrderKeyVec.c_str(),tmpSendOrderKeyVecLength, MPI_CHAR, mpiRemoteRank, mpiTag, comm, &sendRequest[2]); - - - counterSendDataOrder=0; - - nofStoredVectors = this->cbVectorMap.size(); - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - -#ifdef _DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void receiveDataOrder() - { - counterReceiveDataOrder++; - if(counterReceiveDataOrder==this->cbVectorMap.size()) - { - //receiveRequest.Wait(); - unsigned nofElements = (unsigned)this->cbVectorMap.size()*3+1; //map MUSS auf beiden seiten gleich gross sein, sonst hat man ein grundsaetzliches problem ;-) - - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveDataOrder()"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - std::vector< unsigned > tmpRecvOrderVec; - tmpRecvOrderVec.resize(nofElements); - - std::vector<char> tmpRecvOrderKeyVec; - - //MPI_Status status; - MPI_Recv(&tmpRecvOrderVec[0], nofElements, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); - - unsigned rcount; - MPI_Recv(&rcount, 1, MPI_UNSIGNED, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); - tmpRecvOrderKeyVec.resize(rcount); - MPI_Recv(&tmpRecvOrderKeyVec[0], rcount, MPI_CHAR, mpiRemoteRank, mpiTag, comm, MPI_STATUS_IGNORE); - - if(nofElements!=(unsigned)tmpRecvOrderVec.size()) - throw UbException(UB_EXARGS,"error... vec size stimmt nicht"); - - unsigned index = 0; - size_type index2 = 0; - this->nextCbVectorStartIndexInPool = tmpRecvOrderVec[index++]; //= laenge des vectors - this->pool.resize(this->nextCbVectorStartIndexInPool); - CbVectorMapIter it = this->cbVectorMap.begin(); - for(/*index*/; index<nofElements; index+=3, ++it) - { - size_type vectorKeyLength = (size_type)tmpRecvOrderVec.at(index ); - size_type startIndexInPool = (size_type)tmpRecvOrderVec.at(index+1); - size_type dataSize = (size_type)tmpRecvOrderVec.at(index+2); - CbVectorKey vectorKey = CbVectorKey(&tmpRecvOrderKeyVec[index2], vectorKeyLength); - index2 += vectorKeyLength; - - //if(it==this->cbVectorMap.end() || it->first != vectorKey ) - //throw UbException(UB_EXARGS, "entweder hat map nicht die gleiche reihenfolge oder vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden"); - if (it==this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"map ist leer"); - else if (it->first != vectorKey) - throw UbException(UB_EXARGS, "vectorKey = "+UbSystem::toString(vectorKey)+" nicht vorhanden it->first =" + UbSystem::toString(it->first)); - - this->setCbVectorData(*it->second/*vec*/, vectorKey, startIndexInPool, dataSize ); - - } - if(it!=this->cbVectorMap.end()) - throw UbException(UB_EXARGS,"error... in der map sind scheinbar noch weiter elemente vorhanden, die es auf der send seite nicht gibt..."); - - counterReceiveDataOrder = 0; - nofStoredVectors = this->cbVectorMap.size(); - -#ifdef _DEBUG - orgPoolVectorStartPointer = &this->pool[0]; -#endif - } - } - /*==================================================================*/ - void prepareForSendData() - { - //da sendDataOrder einen request verwendet muss man hier immer abfragen - if(counterPrepareForSend==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - //if(sendRequest != MPI_REQUEST_NULL) MPI_Wait(&sendRequest, MPI_STATUS_IGNORE); - if(sendRequest[2] != MPI_REQUEST_NULL) MPI_Waitall(3, sendRequest, MPI_STATUS_IGNORE); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForSendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - - counterPrepareForSend++; - - if(counterPrepareForSend==nofStoredVectors) - { - counterPrepareForSend=0; - } - - - //A - non blocking - ////der ERSTE is entscheidend - ////Grund: wenn man - //// for(all trans) { trans->prepare(); trans->fillBuffer(); } - //// aufruft, dann wuerde u.U. der Buffer neu beschrieben werden obwohl noch nicht versendet wurde!!! - //counterPrepareForSend++; - //if(counterPrepareForSend==1) - //{ - // if(sendRequest != MPI::REQUEST_NULL) sendRequest.Wait(); - //} - // - //if(counterPrepareForSend==nofStoredVectors) - // counterPrepareForSend=0; - } - /*==================================================================*/ - void sendData() - { - //A - non blocking - //der LETZTE is entscheidend - //counterSend++; - //if(counterSend==nofStoredVectors) - //{ - // //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - // sendRequest = comm.Isend(&pool[0],(int)nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - // counterSend=0; - //} - //B - blocking - //der LETZTE is entscheidend - counterSend++; - if(counterSend==nofStoredVectors) - { - //std::cout<<"Isend von "<<(int)nextStartIndex<<"elementen von "<<mpiRemoteRank<<" mit tag="<<mpiTag<<std::endl; - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - - //synchronous send - //comm.Ssend(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); -#ifdef _DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - - //standard send - MPI_Send(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::sendData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -//////////////////////////////////////////////////////////////////////////////////////////// -//DEBUG/////////////////////////////////////// - //int irank; - //MPI_Comm_rank(MPI_COMM_WORLD, &irank); - //std::cout << "MPI_Send: " << irank << " " << mpiRemoteRank << " " <<mpiTag<<std::endl; -/////////////////////////////////////////////////// - counterSend=0; - } - } - /*==================================================================*/ - void prepareForReceiveData() - { - //A - non blocking - //sobald der Letzte kann man den den request holen. - //andernfalls kann nicht gewaehrleistet werden, dass evtl noch mit dem buffer gearbeitet wird!!! - counterPrepareForReceive++; - if(counterPrepareForReceive==this->nofStoredVectors) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); -#ifdef _DEBUG - if(this->orgPoolVectorStartPointer != &this->pool[0] ) throw UbException(UB_EXARGS, "ups, pool array adress changed - unknown behavoir"); -#endif - MPI_Irecv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag, comm, &receiveRequest); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::prepareForReceiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - counterPrepareForReceive=0; - } - } - /*==================================================================*/ - void receiveData() - { - //A - non blocking - //sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - //denn erst anschliessend stehen die empfangenen daten zur verfuegung - if(counterReceive==0) - { - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():start"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - MPI_Wait(&receiveRequest, MPI_STATUS_IGNORE); - UBLOG(logDEBUG5, "TbCbVectorMpiPool::receiveData():end"<<" mpiRemoteRank="<<mpiRemoteRank<<" mpiTag="<<mpiTag); - } - counterReceive++; - if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - { - counterReceive=0; - } - - ////B - blocking - ////sobald der ERSTE reinkommt muss man warten, bis received wurde!!! - ////denn erst anschliessend stehen die empfangenen daten zur verfuegung - //if(counterReceive==0) - //{ - // comm.Recv(&this->pool[0],(int)this->nextCbVectorStartIndexInPool, mpiDataType, mpiRemoteRank, mpiTag); - //} - //counterReceive++; - //if(counterReceive==this->nofStoredVectors) //alle receiver waren hier - // counterReceive=0; - } - -protected: - CbVectorKey poolKey; //eindeutiger schluessel fuer pool - size_type nofStoredVectors; - - size_type counterPrepareReceiveDataOrder; - size_type counterSendDataOrder; - size_type counterReceiveDataOrder; - size_type counterPrepareForReceive; - size_type counterReceive; - size_type counterPrepareForSend; - size_type counterSend; - - std::vector< unsigned > tmpSendOrderVec; //wird zur temp speicherung der anordnung benoetigt - std::string tmpSendOrderKeyVec; - unsigned tmpSendOrderKeyVecLength; - - MPI_Comm comm; - MPI_Request receiveRequest; - //MPI_Request sendRequest; - MPI_Request sendRequest[3]; - //MPI_Status sendStatus; - //MPI_Status receiveStatus; - MPI_Datatype mpiDataType; - - int mpiRemoteRank, mpiTag; - -#ifdef _DEBUG - T* orgPoolVectorStartPointer; -#endif -}; - -template<typename T> -typename TbCbVectorMpiPool<T>::MpiPoolPtrMap TbCbVectorMpiPool<T>::poolMap; - -////////////////////////////////////////////////////////////////////////// -// TbSenderMpiPool -////////////////////////////////////////////////////////////////////////// -template<typename T> -class TbCbVectorSenderMpiPool : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorSenderMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey,this->mpiVectorPool) ); - } - ~TbCbVectorSenderMpiPool() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { this->mpiVectorPool->sendDataOrder(); } - void receiveDataSize() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - CbVector< T >& receiveData() { throw UbException(UB_EXARGS,"TbMpiPoolSender sends only"); } - void prepareForSend() { this->mpiVectorPool->prepareForSendData(); } - void sendData() { this->mpiVectorPool->sendData(); } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getSendTbTag() const { return this->mpiVectorPool->getRemoteTag(); } - int getRecvFromRank() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - int getRecvFromTag() const { throw UbException(UB_EXARGS,"TbCbVectorSenderMpiPool sends only"); } - - std::string toString() const { return "TbCbVectorSenderMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getSendTbRank())+"("+UbSystem::toString(getSendTbTag())+")"; } - -protected: - TbCbVectorMpiPool<T>* mpiVectorPool; -}; - - -/*==================================================================*/ -template<typename T> -class TbCbVectorReceiverMpiPool : public TbTransmitter< CbVector< T > > -{ -public: - typedef CbVector< T > value_type; - -public: - TbCbVectorReceiverMpiPool(std::string cbVectorKey, TbCbVectorMpiPool< T >* mpiVectorPool) - : mpiVectorPool(mpiVectorPool) - { - this->getData().setAllocator( new CbVectorAllocatorPool<T>(cbVectorKey, this->mpiVectorPool) ); - } - ~TbCbVectorReceiverMpiPool() - { - if( this->mpiVectorPool->getNofStoredVectors()==1 ) //last entry! - { - TbCbVectorMpiPool< T >::deleteTbCbVectorMpiPool(this->mpiVectorPool->getPoolKey()); - } - } - bool isLocalTransmitter() const { return false; } - bool isRemoteTransmitter() const { return !this->isLocalTransmitter(); } - - void sendDataSize() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void receiveDataSize() { this->mpiVectorPool->receiveDataOrder(); } - void sendData() { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - void prepareForReceive() { this->mpiVectorPool->prepareForReceiveData(); } - CbVector< T >& receiveData() - { - this->mpiVectorPool->receiveData(); - return this->getData(); - } - - //info-section (usable for remote transmitter) - int getSendTbRank() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getSendTbTag() const { throw UbException(UB_EXARGS,"TbCbVectorReceiverMpiPool receives only"); } - int getRecvFromRank() const { return this->mpiVectorPool->getRemoteRank(); } - int getRecvFromTag() const { return this->mpiVectorPool->getRemoteTag(); } - - std::string toString() const { return "TbCbVectorReceiverMpiPool<"+(std::string)typeid(T).name()+" to rank (tag)"+UbSystem::toString(getRecvFromRank())+"("+UbSystem::toString(getRecvFromTag())+")"; } - -protected: - TbCbVectorMpiPool<T>* mpiVectorPool; -}; - -#endif //VF_MPI - -#endif //TBTRANSMITTERMPIPOOL_H - diff --git a/src/basics/basics/transmitter/package.include b/src/basics/basics/transmitter/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/basics/utilities/CMakePackage.txt b/src/basics/basics/utilities/CMakePackage.txt new file mode 100644 index 000000000..0127c6fb7 --- /dev/null +++ b/src/basics/basics/utilities/CMakePackage.txt @@ -0,0 +1,21 @@ +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES outOption) + +IF(${outOption}) + IF(WIN32) + ADD_DEFINITIONS( -DNOMINMAX ) + ENDIF(WIN32) + + IF(BOOST_VERSION) + OPTION(USE_THREADSAFE_LOGGER "ON=thread safe, OFF=not thread safe" ON) + IF(NOT ${outOption}) + ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING) + ELSE() + SET(NECESSARY_BOOST_LIBS ${NECESSARY_BOOST_LIBS} thread) + ENDIF() + ELSE() + #um die thread safe zu machen benoetigt man boost + ADD_DEFINITIONS( -DNO_THREADSAFE_LOGGING) + ENDIF() + +ENDIF() \ No newline at end of file diff --git a/src/basics/basics/utilities/UbAutoRun.hpp b/src/basics/basics/utilities/UbAutoRun.hpp deleted file mode 100644 index 50fcf37b6..000000000 --- a/src/basics/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/basics/basics/utilities/UbComparators.h b/src/basics/basics/utilities/UbComparators.h index ee809cf1c..11f85e18b 100644 --- a/src/basics/basics/utilities/UbComparators.h +++ b/src/basics/basics/utilities/UbComparators.h @@ -1,17 +1,40 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbComparators.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #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 diff --git a/src/basics/basics/utilities/UbConverter.cpp b/src/basics/basics/utilities/UbConverter.cpp deleted file mode 100644 index dcdf17f5d..000000000 --- a/src/basics/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/basics/basics/utilities/UbConverter.h b/src/basics/basics/utilities/UbConverter.h deleted file mode 100644 index 7fd99c689..000000000 --- a/src/basics/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/basics/basics/utilities/UbEqual.h b/src/basics/basics/utilities/UbEqual.h index 8c01318af..483e50a79 100644 --- a/src/basics/basics/utilities/UbEqual.h +++ b/src/basics/basics/utilities/UbEqual.h @@ -1,30 +1,55 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbEqual.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #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; } // +//! \brief isUbEqual<T1,T2>(a,b) +//! Compares the equality of values a and b. +//! +//! By default operator== is used for this. +//! +//! Execption: floating-point variables +//! In these cases the type with higher precision is casted to the type of lower precision +//! and then the two values are compared. +//! e.g.: double d=1.2; int i=1; bool check = isUbEqual(d,i); -> true +//! +//! For classes operator== must be implemented for const objects! +//! 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: diff --git a/src/basics/basics/utilities/UbException.h b/src/basics/basics/utilities/UbException.h index 45b013d11..cb8550c1e 100644 --- a/src/basics/basics/utilities/UbException.h +++ b/src/basics/basics/utilities/UbException.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbException.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBEXCEPTION_H #define UBEXCEPTION_H @@ -15,25 +41,15 @@ #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: UB_THROW( UbException("error message") ); - UB_THROW( UbException(__FILE__, __LINE__,"error message") ); - UB_THROW( UbException(__FILE__, __LINE__,UB_FUNCTION,"error message") ); - UB_THROW( UbException(UB_EXARGS,"error") ); //same as above -*/ +//========================================================================= +// +//! \brief UbException +//! usage: UB_THROW( UbException("error message") ); +//! UB_THROW( UbException(__FILE__, __LINE__,"error message") ); +//! UB_THROW( UbException(__FILE__, __LINE__,UB_FUNCTION,"error message") ); +//! UB_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)) diff --git a/src/basics/basics/utilities/UbFileInput.h b/src/basics/basics/utilities/UbFileInput.h deleted file mode 100644 index 2c57b175f..000000000 --- a/src/basics/basics/utilities/UbFileInput.h +++ /dev/null @@ -1,97 +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(); } - - 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 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/basics/basics/utilities/UbFileInputASCII.cpp b/src/basics/basics/utilities/UbFileInputASCII.cpp deleted file mode 100644 index 84a6ff490..000000000 --- a/src/basics/basics/utilities/UbFileInputASCII.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include <basics/utilities/UbFileInputASCII.h> -#include <cstring> - -using namespace std; - -UbFileInputASCII::UbFileInputASCII(string filename) -{ - this->filename = filename; - this->commentindicator = 'C'; - - infile.open(filename.c_str()); - - //if(!infile) UB_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; -} -/*==========================================================*/ -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()) UB_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()) UB_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()) UB_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()) UB_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 UB_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 UB_THROW( UbException(UB_EXARGS,"error at reading in file \""+filename+"\" -> expression=\""+tmp+"\" is not equal to 'true' or 'false' in "+this->filename) ); -} diff --git a/src/basics/basics/utilities/UbFileInputASCII.h b/src/basics/basics/utilities/UbFileInputASCII.h deleted file mode 100644 index e999500a9..000000000 --- a/src/basics/basics/utilities/UbFileInputASCII.h +++ /dev/null @@ -1,78 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUTASCII_H -#define UBFILEINPUTASCII_H - -#include <fstream> -#include <iostream> -#include <string> - -#include "basics_export.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 BASICS_EXPORT 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 - 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; } - - template< typename T > - friend inline UbFileInputASCII& operator>>(UbFileInputASCII& file, T& data) - { - file.infile>>data; - return file; - } -}; - -#endif //UBFILEINPUTASCII_H - - diff --git a/src/basics/basics/utilities/UbFileInputBinary.cpp b/src/basics/basics/utilities/UbFileInputBinary.cpp deleted file mode 100644 index a7071b367..000000000 --- a/src/basics/basics/utilities/UbFileInputBinary.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include <basics/utilities/UbFileInputBinary.h> -#include <cstring> - -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; -} -/*==========================================================*/ -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) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -string UbFileInputBinary::parseString() -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -bool UbFileInputBinary::containsString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -void UbFileInputBinary::setPosAfterLineWithString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -int UbFileInputBinary::readIntegerAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -double UbFileInputBinary::readDoubleAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -string UbFileInputBinary::readStringAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} -/*==========================================================*/ -bool UbFileInputBinary::readBoolAfterString(const string& var) -{ - UB_THROW( UbException(UB_EXARGS,"method makes no sense for binary streams") ); -} diff --git a/src/basics/basics/utilities/UbFileInputBinary.h b/src/basics/basics/utilities/UbFileInputBinary.h deleted file mode 100644 index c410c822f..000000000 --- a/src/basics/basics/utilities/UbFileInputBinary.h +++ /dev/null @@ -1,82 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEINPUTBINARY_H -#define UBFILEINPUTBINARY_H - -#include <fstream> -#include <iostream> -#include <string> - -#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 - 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; - } - - template< typename T> - void readVector(std::vector<T>& v) - { - size_t size = v.size(); - if (size > 0) - { - infile.read((char*)&v[0], sizeof(T)*size); - } - } - -}; - -#endif - - diff --git a/src/basics/basics/utilities/UbFileOutput.h b/src/basics/basics/utilities/UbFileOutput.h deleted file mode 100644 index 2ee5ac92f..000000000 --- a/src/basics/basics/utilities/UbFileOutput.h +++ /dev/null @@ -1,93 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUT_H -#define UBFILEOUTPUT_H - -#include <iomanip> -#include <fstream> -#include <iostream> -#include <string> - -#include <basics/utilities/UbException.h> - -/*=========================================================================*/ -/* 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(); } - - virtual void writeInteger(const int& 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/basics/basics/utilities/UbFileOutputASCII.cpp b/src/basics/basics/utilities/UbFileOutputASCII.cpp deleted file mode 100644 index a195f9616..000000000 --- a/src/basics/basics/utilities/UbFileOutputASCII.cpp +++ /dev/null @@ -1,177 +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) UB_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) UB_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 UB_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::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) UB_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) { UB_THROW( UbException(UB_EXARGS,"catched std::exception, error: "+(std::string)e.what()) ); } - catch(...) { UB_THROW( UbException(UB_EXARGS,"unknown error") ); } -} diff --git a/src/basics/basics/utilities/UbFileOutputASCII.h b/src/basics/basics/utilities/UbFileOutputASCII.h deleted file mode 100644 index cfe68b699..000000000 --- a/src/basics/basics/utilities/UbFileOutputASCII.h +++ /dev/null @@ -1,74 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBFILEOUTPUTASCII_H -#define UBFILEOUTPUTASCII_H - -#include <iomanip> -#include <fstream> -#include <iostream> - -#include "basics_export.h" - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileOutput.h> - -/*=========================================================================*/ -/* UbFileOutputASCII */ -/* */ -/** -... -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 23.11.04 -*/ - -/* -usage: ... -*/ - -class BASICS_EXPORT 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 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/basics/basics/utilities/UbFileOutputBinary.cpp b/src/basics/basics/utilities/UbFileOutputBinary.cpp deleted file mode 100644 index bc0cbad66..000000000 --- a/src/basics/basics/utilities/UbFileOutputBinary.cpp +++ /dev/null @@ -1,180 +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) UB_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) UB_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) UB_THROW( UbException(UB_EXARGS,"undefined CREATEOPTION - INANDOUTFILE not possible for BINARY files") ); - else UB_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) -{ - UB_THROW( UbException(UB_EXARGS,"no way") ); -} -/*==========================================================*/ -int UbFileOutputBinary::getPrecision() -{ - UB_THROW( UbException(UB_EXARGS,"no way") ); -} -/*==========================================================*/ -void UbFileOutputBinary::writeInteger(const int& 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(...) { UB_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) UB_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(...) {UB_THROW( UbException(UB_EXARGS,"unknown error") );} -} diff --git a/src/basics/basics/utilities/UbFileOutputBinary.h b/src/basics/basics/utilities/UbFileOutputBinary.h deleted file mode 100644 index 76c502467..000000000 --- a/src/basics/basics/utilities/UbFileOutputBinary.h +++ /dev/null @@ -1,80 +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 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; - } - - template< typename T> - void writeVector(std::vector<T>& v) - { - size_t size = v.size(); - if (size > 0) - { - outfile.write((char*)&v[0],sizeof(T)*size); - } - } -}; - -#endif - - diff --git a/src/basics/basics/utilities/UbInfinity.h b/src/basics/basics/utilities/UbInfinity.h index 5c889c894..eebaf1416 100644 --- a/src/basics/basics/utilities/UbInfinity.h +++ b/src/basics/basics/utilities/UbInfinity.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbInfinity.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UB_INFINITY_H #define UB_INFINITY_H #include <limits> @@ -5,16 +37,14 @@ #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. +//! +//! \brief UbNegInfinity +//! \details Note: The UbNegInfinity class cannot be instantiated on its own, but works +//! as a base class for the Infinity class. +//! ////////////////////////////////////////////////////////////////////////// + class UbNegInfinity { public: @@ -29,9 +59,9 @@ class UbNegInfinity 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. + //! 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 { diff --git a/src/basics/basics/utilities/UbKeys.h b/src/basics/basics/utilities/UbKeys.h index 609c08dbe..1ee578150 100644 --- a/src/basics/basics/utilities/UbKeys.h +++ b/src/basics/basics/utilities/UbKeys.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbKeys.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBKEYS_H #define UBKEYS_H @@ -14,19 +40,12 @@ #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: ... -*/ +////////////////////////////////////////////////////////////////////////// +//! +//! \brief +//! namespace for global Keys (e.g. for STL-maps) +//! +////////////////////////////////////////////////////////////////////////// namespace UbKeys { @@ -189,7 +208,6 @@ namespace UbKeys T1 t1; T2 t2; T3 t3; - }; ////////////////////////////////////////////////////////////////////////// diff --git a/src/basics/basics/utilities/UbLimits.h b/src/basics/basics/utilities/UbLimits.h index 30b03f2d9..6a2aa9cdb 100644 --- a/src/basics/basics/utilities/UbLimits.h +++ b/src/basics/basics/utilities/UbLimits.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbLimits.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UB_LIMITS_H #define UB_LIMITS_H diff --git a/src/basics/basics/utilities/UbLogger.cpp b/src/basics/basics/utilities/UbLogger.cpp index 3c433a130..a02a1aa15 100644 --- a/src/basics/basics/utilities/UbLogger.cpp +++ b/src/basics/basics/utilities/UbLogger.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbLogger.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbLogger.h> #if defined(CAB_BOOST) && !defined(NO_THREADSAFE_LOGGING) diff --git a/src/basics/basics/utilities/UbLogger.h b/src/basics/basics/utilities/UbLogger.h index b239621eb..266ac1f6b 100644 --- a/src/basics/basics/utilities/UbLogger.h +++ b/src/basics/basics/utilities/UbLogger.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbLogger.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBLOGGER_H #define UBLOGGER_H @@ -12,6 +38,7 @@ #include <iostream> #include <fstream> #include <iomanip> + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) #include <windows.h> #else @@ -22,33 +49,63 @@ #include <boost/thread.hpp> #endif // CAB_BOOST -////////////////////////////////////////////////////////////////////////// -// 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 ////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +//! +//! \brief +//! C++ Logger +//! \details Functionality: +//! Per logentry an object of type UbLogger is generated, the log string is passed to this object and +//! upon destruction of the object the string is written to a file or the screen depending on +//! the policy (=template paramter). Multiple log level are supported. +//! +//! helpermakro: UBLOG +//! +//! Example 1: +//! \code +//! UBLOG(logINFO) << "Klasse::foo entered"; //endl is not required +//! \endcode +//! +//! Example 2: +//! \code +//! try +//! { +//! UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG3"); +//! //UbLog::output_policy::setStream(&std::cerr); //<- clog is stdandard +//! UbLog::output_policy::setStream("c:/temp/out.txt"); //you can not open these -> error message -> log is output in cerr +//! +//! 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 ); +//! //for MultiLine entries: -> formatting in 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(); +//! } +//! \endcode +//! Idee based on: +//! Paper by Dr. Dobbs Portal, +//! September 05, 2007, +//! Logging In C++ +//! +////////////////////////////////////////////////////////////////////////// template <typename OutputPolicy> class UbLogger { @@ -59,7 +116,7 @@ public: virtual ~UbLogger(); std::ostringstream& get(const LogLevel& level = logINFO); public: - //static, weil man so sp�ter die ObjErstellunge ersparen kann, + //static, weil man so später die ObjErstellunge ersparen kann, //falls level kleiner als Level static LogLevel& reportingLevel(); @@ -173,22 +230,18 @@ inline std::string UbLogger<OutputPolicy>::logTimeString() ////////////////////////////////////////////////////////////////////////// -// Output2Stream (=implementation of OutputPolicy) +//! 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) + //!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 + //!direct set outputstream, gcControl = true -> object will be deleted by Output2Stream static void setStream(std::ostream* pStream, const bool& gcControl = false); protected: @@ -253,29 +306,18 @@ class UbLog : public UbLogger< Output2Stream > }; -//Makro um compilerseitig maxLevel zu beschr�nken +//Macro to limit compiler-side maxLevel #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" ) @@ -296,7 +338,7 @@ class UbLog : public UbLogger< Output2Stream > } \ } ////////////////////////////////////////////////////////////////////////// -//makro3, falls auch bildschirmausgabe erw�nscht +//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" ) diff --git a/src/basics/basics/utilities/UbMath.cpp b/src/basics/basics/utilities/UbMath.cpp index aabcbb9ac..938360645 100644 --- a/src/basics/basics/utilities/UbMath.cpp +++ b/src/basics/basics/utilities/UbMath.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbMath.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/UbMath.h> #include <basics/utilities/UbInfinity.h> #include <cstring> //for memcmp diff --git a/src/basics/basics/utilities/UbMath.h b/src/basics/basics/utilities/UbMath.h index 98034171b..026125628 100644 --- a/src/basics/basics/utilities/UbMath.h +++ b/src/basics/basics/utilities/UbMath.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbMath.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBMATH_H #define UBMATH_H @@ -14,20 +40,6 @@ #include <basics/utilities/UbSystem.h> #include <basics/utilities/UbEqual.h> -/*=========================================================================*/ -/* 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; @@ -346,7 +358,7 @@ namespace UbMath return UbMath::calcGgt( UbMath::calcGgt(val1, val2), val3 ); } /*=======================================================*/ - //returns the max of two values + //returns the max of c2 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) @@ -399,7 +411,8 @@ namespace UbMath static const double c2o27 = 2. / 27.; static const double c1o54 = 1. / 54.; static const double c1o216 = 1. / 216.; - static const double c9o2 = 9. / 2.; + static const double c9o2 = 9. / 2.; //4.5 + static const double c9o4 = 9. / 4.; //2.25 static const double c3o9 = 3. / 9.; static const double c3o54 = 3. / 54.; static const double c3o216 = 3. / 216.; @@ -420,6 +433,7 @@ namespace UbMath 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 c1o100 = 1. / 100.; static const double c5o16 = 5. / 16.; //0.3125 static const double c1o3 = 1. / 3.; //0.33333333 static const double c3o8 = 3. / 8.; //0.375 @@ -438,25 +452,27 @@ namespace UbMath static const double sqrt2 = sqrt(2.0); //1.4142135 static const double sqrt3 = sqrt(3.0); //1.7320508 static const double zeroReal = 0.0; - static const double one = 1.0; - static const double two = 2.0; - static const double three = 3.0; - static const double four = 4.0; - static const double five = 5.0; - static const double six = 6.0; - static const double seven = 7.0; - static const double eight = 8.0; - static const double nine = 9.0; - static const double fourteen = 14.0; - static const double fiveteen = 15.0; - static const double sixteen = 16.0; - static const double twentyone = 21.0; - static const double twentyfour = 24.0; - static const double twentyeight = 28.0; - static const double twentynine = 29.0; - static const double fourtyeight = 48.0; - static const double fifty = 50.0; - static const double fiftysix = 56.0; + static const double c1 = 1.0; + static const double c2 = 2.0; + static const double c3 = 3.0; + static const double c4 = 4.0; + static const double c5 = 5.0; + static const double c6 = 6.0; + static const double c7 = 7.0; + static const double c8 = 8.0; + static const double c9 = 9.0; + static const double c14 = 14.0; + static const double c15 = 15.0; + static const double c16 = 16.0; + static const double c18 = 18.0; + static const double c21 = 21.0; + static const double c24 = 24.0; + static const double c28 = 28.0; + static const double c29 = 29.0; + static const double c36 = 36.0; + static const double c48 = 48.0; + static const double c50 = 50.0; + static const double c56 = 56.0; static const double c152 = 152.0; static const double c130 = 130.0; } diff --git a/src/basics/basics/utilities/UbNupsTimer.h b/src/basics/basics/utilities/UbNupsTimer.h deleted file mode 100644 index cd99df78e..000000000 --- a/src/basics/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/basics/basics/utilities/UbObservable.h b/src/basics/basics/utilities/UbObservable.h index 050860767..37cb954dd 100644 --- a/src/basics/basics/utilities/UbObservable.h +++ b/src/basics/basics/utilities/UbObservable.h @@ -1,51 +1,70 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbObservable.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #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 -*/ +////////////////////////////////////////////////////////////////////////// +//! +//! \brief Observable object +//! \details 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> +//! +//! see UbObserver +//! +////////////////////////////////////////////////////////////////////////// class UbObservable { @@ -95,7 +114,7 @@ public: /** 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) + @param observer the observer to add to this observable (note that an observer may observe c1 observable more than once) */ virtual void addObserver(UbObserver* observer) { @@ -164,14 +183,6 @@ public: virtual std::string toString() { return "UbObservable - toString()"; } -#ifdef CAB_RCF - template<typename Archive> - void serialize(Archive & ar, const unsigned int version) - { - //do nothing! - } -#endif //CAB_RCF - private: /** Notifies all of its observers that something happened. Does nothing, if the observed object is null. diff --git a/src/basics/basics/utilities/UbObserver.h b/src/basics/basics/utilities/UbObserver.h index 601e2993a..6aff49a39 100644 --- a/src/basics/basics/utilities/UbObserver.h +++ b/src/basics/basics/utilities/UbObserver.h @@ -1,27 +1,50 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbObserver.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #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 -*/ + +////////////////////////////////////////////////////////////////////////// +//! +//! \brief Observer +//! \details 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 observed observable objects before!!! +//! example: see end of UbObservable.h-file +//! +////////////////////////////////////////////////////////////////////////// class UbObserver { @@ -34,18 +57,18 @@ public: virtual ~UbObserver(){} /*======================================================================*/ - /* Methoden */ + /* Methods */ /* */ - /** + /*! This function is called when the observable indicated that an object has changed. - @param changedObject Object which 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 + \param objectForDeletion Object which should be deleted */ virtual void objectWillBeDeleted(UbObservable* objectForDeletion)=0; }; diff --git a/src/basics/basics/utilities/UbPointerWrapper.h b/src/basics/basics/utilities/UbPointerWrapper.h deleted file mode 100644 index dbb65d39f..000000000 --- a/src/basics/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 serialize(Archive& ar, const unsigned int version) - { - ar & pointer; - } - -private: - T* pointer; -}; - -#endif //UBPOINTERWRAPPER_H diff --git a/src/basics/basics/utilities/UbRandom.h b/src/basics/basics/utilities/UbRandom.h deleted file mode 100644 index dd3b4671e..000000000 --- a/src/basics/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/basics/basics/utilities/UbScheduler.h b/src/basics/basics/utilities/UbScheduler.h index f132f9528..1bb41a942 100644 --- a/src/basics/basics/utilities/UbScheduler.h +++ b/src/basics/basics/utilities/UbScheduler.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbScheduler.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller, Jan Hegewald +//======================================================================================= #ifndef UBSCHEDULER_H #define UBSCHEDULER_H @@ -19,33 +45,13 @@ #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> - -/*=========================================================================*/ -/* 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; -typedef std::shared_ptr<UbScheduler> UbSchedulerPtr; +////////////////////////////////////////////////////////////////////////// +//! +//! \brief A class implements scheduling. +//! \details This class is not thread save. +//! +////////////////////////////////////////////////////////////////////////// class UbScheduler { @@ -72,20 +78,6 @@ public: 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(); - } - private: double step, begin, end; }; @@ -200,9 +192,9 @@ public: nextDueTime = tmpNextDueTime; } - //wenn t = der aktuuellen oder gar schon der n�chstm�glichen ist (hierbei wurde + //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 + //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) ) { @@ -212,7 +204,7 @@ public: } else if( UbMath::lessEqual(t, lastDueTime) ) { - if(UbMath::equal(t, lastDueTime) ) return true; //braucht man, wenn man f�r dasselbe t isDue(t) aufruft + 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 @@ -289,27 +281,6 @@ public: 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); - } - } - protected: /*==========================================================*/ void initVals() @@ -348,17 +319,6 @@ protected: }; 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 diff --git a/src/basics/basics/utilities/UbStaticPathMap.cpp b/src/basics/basics/utilities/UbStaticPathMap.cpp deleted file mode 100644 index b68cc5ba1..000000000 --- a/src/basics/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/basics/basics/utilities/UbStaticPathMap.h b/src/basics/basics/utilities/UbStaticPathMap.h deleted file mode 100644 index a188843c3..000000000 --- a/src/basics/basics/utilities/UbStaticPathMap.h +++ /dev/null @@ -1,71 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBSTATICPATHMAP_H -#define UBSTATICPATHMAP_H - -#include <iostream> -#include <string> -#include <map> - -#include <basics/utilities/UbSystem.h> - -/*=========================================================================*/ -/* 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() ) UbSystem::makeDirectory(tmpPath,20); - 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/basics/basics/utilities/UbString.h b/src/basics/basics/utilities/UbString.h deleted file mode 100644 index f93fe7ae6..000000000 --- a/src/basics/basics/utilities/UbString.h +++ /dev/null @@ -1,24 +0,0 @@ -//unnoetig: UbSystem::toString() verwenden,... andere Richtung: stringTo... oder am besten boost::lexical_cast - - -//#ifndef UBSTRING_H -//#define UBSTRING_H -//#include <string> -//#include <sstream> -// -//using namespace std; -// -//class UbString -//{ -//public: -// static void IntToString(int i, string& res) -// { -// ostringstream temp; -// temp << i; -// res = temp.str(); -// } -//protected: -//private: -//}; -// -//#endif //end UBSTRING_H diff --git a/src/basics/basics/utilities/UbStringInputASCII.cpp b/src/basics/basics/utilities/UbStringInputASCII.cpp deleted file mode 100644 index 094b6a5b8..000000000 --- a/src/basics/basics/utilities/UbStringInputASCII.cpp +++ /dev/null @@ -1,211 +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; -} -/*==========================================================*/ -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()) UB_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()) UB_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()) UB_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()) UB_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 UB_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 UB_THROW( UbException(UB_EXARGS,"expression is not equal to 'true' or 'false' in "+this->filename) ); -} diff --git a/src/basics/basics/utilities/UbStringInputASCII.h b/src/basics/basics/utilities/UbStringInputASCII.h deleted file mode 100644 index 06db6d68c..000000000 --- a/src/basics/basics/utilities/UbStringInputASCII.h +++ /dev/null @@ -1,55 +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 - 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/basics/basics/utilities/UbSystem.h b/src/basics/basics/utilities/UbSystem.h index 797140a08..2102bc52a 100644 --- a/src/basics/basics/utilities/UbSystem.h +++ b/src/basics/basics/utilities/UbSystem.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbSystem.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBSYSTEM_H #define UBSYSTEM_H @@ -26,13 +52,12 @@ #include <sys/syscall.h> #include <sys/stat.h> #include <unistd.h> -#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) +#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__)) && !defined(__AIX__) #define UBSYSTEM_LINUX #include "dirent.h" - #include "sys/stat.h" - #include <sys/syscall.h> #include <sys/stat.h> #include <unistd.h> + #include <string.h> #elif defined(__AIX__) #define UBSYSTEM_AIX #include "dirent.h" @@ -43,7 +68,12 @@ #error "UbSystem::UnknownMachine" #endif - +#if defined(__unix__) && defined(__CYGWIN__) + #define UBSYSTEM_CYGWIN + #include <windows.h> +#else + #include <sys/syscall.h> +#endif #if defined(min) || defined(max) //daruch kann man sich spaeter #undef min; #undef max erparen # error add NOMINMAX to preprocessor defines @@ -58,7 +88,6 @@ #include <typeinfo> #include <cctype> //for toupper #include <ctime> -#include <cstring> #include <basics/utilities/UbException.h> #include <basics/utilities/UbLogger.h> @@ -92,10 +121,12 @@ namespace UbSystem /*==========================================================*/ inline void sleepMs(const unsigned int& msec) { - #if defined UBSYSTEM_WINDOWS + #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) || defined(UBSYSTEM_AIX) + #elif (defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)) && !defined(UBSYSTEM_CYGWIN) ::usleep(1000*msec); + #elif defined(UBSYSTEM_CYGWIN) + ::Sleep( (msec==0) ? 1 : msec ); #else #error "UbSystem::sleepMSec - UnknownMachine" #endif @@ -103,9 +134,9 @@ namespace UbSystem /*==========================================================*/ inline void sleepS(const unsigned int& sec) { - #if defined UBSYSTEM_WINDOWS + #if defined(UBSYSTEM_WINDOWS) && defined(UBSYSTEM_CYGWIN) ::Sleep( (sec==0) ? 1 : sec*1000 ); // +1 here causes a context switch if sleepS(0) is called - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) + #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX) && !defined(UBSYSTEM_CYGWIN) ::sleep(sec); #else #error "UbSystem::sleepS - UnknownMachine" @@ -230,7 +261,7 @@ namespace UbSystem if( stat(path.c_str(),&stFileInfo) != 0) { return false; - } + } #endif return true; @@ -366,8 +397,10 @@ namespace UbSystem { #if defined UBSYSTEM_WINDOWS return (unsigned long)GetCurrentThreadId(); - #elif defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) + #elif (defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE)) && !defined(UBSYSTEM_CYGWIN) return (unsigned long)syscall(SYS_gettid); + #elif defined(UBSYSTEM_CYGWIN) + return (unsigned long)GetCurrentThreadId(); #elif defined(UBSYSTEM_AIX) return (unsigned long) getpid(); //WORKAROUND for IBM (for get thread id is another function necessary) #else @@ -426,7 +459,7 @@ namespace UbSystem char Name[150]; int i = 0; -#ifdef UBSYSTEM_WINDOWS +#if defined(UBSYSTEM_WINDOWS) && defined(UBSYSTEM_CYGWIN) TCHAR infoBuf[150]; DWORD bufCharCount = 150; memset(Name, 0, 150); @@ -441,7 +474,7 @@ namespace UbSystem { strcpy(Name, "Unknown_Host_Name"); } -#else +#elif (defined(UBSYSTEM_LINUX) || defined(UBSYSTEM_APPLE) || defined(UBSYSTEM_AIX)) && !defined(UBSYSTEM_CYGWIN) memset(Name, 0, 150); gethostname(Name, 150); #endif @@ -517,7 +550,7 @@ namespace UbSystem //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 wuerde es so aussehen: +//ansonsten w�rde es so aussehen: // UbSystem::ub_static_assert< aaa == 1 > test(); // da ist UB_STATIC_ASSERT(aaa == 1); schoener // diff --git a/src/basics/basics/utilities/UbTableModel.cpp b/src/basics/basics/utilities/UbTableModel.cpp deleted file mode 100644 index 12e69b068..000000000 --- a/src/basics/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/basics/basics/utilities/UbTableModel.h b/src/basics/basics/utilities/UbTableModel.h deleted file mode 100644 index 957201a51..000000000 --- a/src/basics/basics/utilities/UbTableModel.h +++ /dev/null @@ -1,37 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef UBTABLEMODEL_H -#define UBTABLEMODEL_H - -#include <iostream> - -class UbTableModel -{ -public: - const static int COL_TYPE_STRING = 1; - const static int COL_TYPE_BOOL = 2; - const static int COL_TYPE_INTEGER = 3; - const static 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/basics/basics/utilities/UbTiming.h b/src/basics/basics/utilities/UbTiming.h index 2ba786b97..d683d0705 100644 --- a/src/basics/basics/utilities/UbTiming.h +++ b/src/basics/basics/utilities/UbTiming.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbTiming.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBTIMING_H #define UBTIMING_H @@ -14,27 +40,11 @@ #include <vector> #include <ctime> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #ifdef VF_MPI #include <mpi.h> #include <basics/parallel/PbMpi.h> #endif //VF_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: @@ -162,16 +172,6 @@ protected: 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 @@ -197,22 +197,27 @@ protected: #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 +/*=========================================================================*/ +//! \brief Time Measuring +//! \details +//! example: +//! \code +//! 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 is reset and restarted +//! t=12 +//! t=13 +//! t=14 stop -> return 3; getLapTime=3; getTotalTime 3; getLapTimes: 3 +//! \endcode class UbTimer { @@ -348,20 +353,6 @@ public: } -#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; @@ -376,21 +367,17 @@ protected: /*=========================================================================*/ -// UbProgressTimer - Time Measuring -// -// -// -//UbProressTimer misst die Zeit von seiner Instantiierung bis zur Zerstoerung -//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 -// +//! \brief Time Measuring +//! +//! \details UbProressTimer measures the time from its instantiation to destruction and spend the elapsed time on "os" in [s] +//! example: +//! \code +//! { +//! UbProgressTimer timer; +//! UbSystem::sleepS(10); +//! } //--> 10s +//! \endcode + class UbProgressTimer : public UbTimer { private: diff --git a/src/basics/basics/utilities/UbTuple.cpp b/src/basics/basics/utilities/UbTuple.cpp deleted file mode 100644 index f778fc71a..000000000 --- a/src/basics/basics/utilities/UbTuple.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "UbTuple.h" - diff --git a/src/basics/basics/utilities/UbTuple.h b/src/basics/basics/utilities/UbTuple.h index 710aed4df..621b378e1 100644 --- a/src/basics/basics/utilities/UbTuple.h +++ b/src/basics/basics/utilities/UbTuple.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbTupel.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef UBTUPLE_H #define UBTUPLE_H @@ -11,56 +37,43 @@ #include <string> #include <ostream> -#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: -**********************************/ +////////////////////////////////////////////////////////////////////////// +//! \brief A class implements a tuple +//! \details +//! usage: ...<BR> +//! Advanced UbTuple +//! Example: +//! create and use tuple with only c1 field +//! \code +//! UbTuple<int,int,int,int,int> t1; +//! val<1>(t1) += 42; +//! std::cout << t1.v1() << std::endl; +//! \endcode +//! create and use duo: +//! \code +//! UbTuple<bool,int> t2; +//! std::cout << val<1>(t2) << ", "; +//! std::cout << t2.v1() << std::endl; +//! \endcode +//! create and use triple: +//! \code +//! 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; +//! \endcode +//! create and use quadruple: +//! \code +//! 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 +//! \endcode + template <typename T> class UbTypeOp // primary template { @@ -165,15 +178,6 @@ public: T2& v2() { return value2; } T2 const& v2() const { return value2; } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive& ar, const unsigned int version) - { - ar & value1; - ar & value2; - } -#endif //CAB_RCF - private: T1 value1; // value of first field T2 value2; // value of second field @@ -249,15 +253,6 @@ public: T2& v2() { return value2; } T2 const& v2() const { return value2; } -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & value1; - ar & value2; - } -#endif //CAB_RCF - private: T1 value1; // value of first field T2 value2; // value of second field @@ -388,7 +383,7 @@ inline typename UbTypeOp<typename UbDuoT<N, UbDuo<A, B> >::ResultT>::RefConstT v } //duo6.hpp -// partial specialization for UbDuo<> with only one field +// partial specialization for UbDuo<> with only c1 field template <typename A> struct UbDuo<A,void> { @@ -412,13 +407,6 @@ public: void v2() { } void v2() const { } - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & value1; - } - #endif }; //tupel1.hpp @@ -427,7 +415,44 @@ class UbNullT { }; -// UbTuple<> in general derives from UbTuple<> with one more UbNullT +////////////////////////////////////////////////////////////////////////// +//! \brief A class implements a tuple +//! \details +//! usage: ...<BR> +//! Advanced UbTuple +//! Example: +//! create and use tuple with only c1 field +//! \code +//! UbTuple<int,int,int,int,int> t1; +//! val<1>(t1) += 42; +//! std::cout << t1.v1() << std::endl; +//! \endcode +//! create and use duo: +//! \code +//! UbTuple<bool,int> t2; +//! std::cout << val<1>(t2) << ", "; +//! std::cout << t2.v1() << std::endl; +//! \endcode +//! create and use triple: +//! \code +//! 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; +//! \endcode +//! create and use quadruple: +//! \code +//! 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 +//! \endcode + +// UbTuple<> in general derives from UbTuple<> with c1 more UbNullT template <typename P1, typename P2 = UbNullT, typename P3 = UbNullT, @@ -591,7 +616,6 @@ 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/basics/basics/utilities/Vector3D.cpp b/src/basics/basics/utilities/Vector3D.cpp index 34074babd..6b39ee8a4 100644 --- a/src/basics/basics/utilities/Vector3D.cpp +++ b/src/basics/basics/utilities/Vector3D.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbVector3D.cpp +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/utilities/Vector3D.h> #include <cassert> diff --git a/src/basics/basics/utilities/Vector3D.h b/src/basics/basics/utilities/Vector3D.h index 27d48d2e8..1e1d5178b 100644 --- a/src/basics/basics/utilities/Vector3D.h +++ b/src/basics/basics/utilities/Vector3D.h @@ -1,30 +1,41 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file UbVector3D.h +//! \ingroup utilities +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef VECTOR_3D_H #define VECTOR_3D_H #include <string> -/*=========================================================================*/ -/* Vector3D */ -/* */ -/** -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.4 - 04.10.07 -*/ - -/* -usage: ... -*/ -#include "basics_export.h" - - - class BASICS_EXPORT Vector3D + class Vector3D { public: // construction @@ -110,14 +121,6 @@ usage: ... static const Vector3D UNIT_X2; static const Vector3D UNIT_X3; - #ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & m_afTuple; - } - #endif //CAB_RCF - protected: // support for comparisons int CompareArrays (const Vector3D& rkV) const; diff --git a/src/basics/basics/utilities/Vector3DTest.cpp b/src/basics/basics/utilities/Vector3DTest.cpp deleted file mode 100644 index e13f1fa2e..000000000 --- a/src/basics/basics/utilities/Vector3DTest.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include "gmock/gmock.h" -#include "Vector3D.h" - -#include <cmath> - -using namespace testing; - -class Vector3DTest : public Test -{ -public: - Vector3D vec1; - Vector3D vec2; - - void SetUp() - { - vec1[0] = vec1[1] = vec1[2] = 4.0f; - vec2[0] = 0.0f; vec2[0] = 2.4f; vec2[0] = -1.3f; - } -}; - -TEST_F(Vector3DTest, overloadMinusOperator) -{ - Vector3D vec3; - vec3[0] = vec2[0] - vec1[0]; - vec3[1] = vec2[1] - vec1[1]; - vec3[2] = vec2[2] - vec1[2]; - - Vector3D v4 = vec2 - vec1; - ASSERT_THAT((double)v4[0], DoubleEq(vec3[0])); - ASSERT_THAT((double)v4[1], DoubleEq(vec3[1])); - ASSERT_THAT((double)v4[2], DoubleEq(vec3[2])); -} - -TEST_F(Vector3DTest, overloadPlusOperator) -{ - Vector3D vec3; - vec3[0] = vec2[0] + vec1[0]; - vec3[1] = vec2[1] + vec1[1]; - vec3[2] = vec2[2] + vec1[2]; - - Vector3D v4 = vec2 + vec1; - ASSERT_THAT((double)v4[0], DoubleEq(vec3[0])); - ASSERT_THAT((double)v4[1], DoubleEq(vec3[1])); - ASSERT_THAT((double)v4[2], DoubleEq(vec3[2])); -} - -TEST_F(Vector3DTest, overloadTimesOperatorWithSkalarProduct) -{ - double skalar = vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2]; - ASSERT_THAT(vec1.Dot(vec2), DoubleEq(skalar)); -} - -TEST_F(Vector3DTest, overloadTimesOperatorWithSkalarMultiplication) -{ - double skalar = 1.0f / 3.0f; - Vector3D vec3; - vec3[0] = skalar * vec1[0]; - vec3[1] = skalar * vec1[1]; - vec3[2] = skalar * vec1[2]; - - Vector3D v4 = vec1 * skalar; - - ASSERT_THAT((double)v4[0], DoubleEq(vec3[0])); - ASSERT_THAT((double)v4[1], DoubleEq(vec3[1])); - ASSERT_THAT((double)v4[2], DoubleEq(vec3[2])); -} - -TEST_F(Vector3DTest, getLengthFromVector) -{ - Vector3D v; - v[0] = 4.0; - v[1] = 3.0; - v[2] = -1.0; - - double expected = std::sqrt(16.0 + 9.0 + 1.0); - ASSERT_THAT(v.Length(), testing::DoubleEq(expected)); -} - -TEST_F(Vector3DTest, compareTwoVectors) -{ - Vector3D v; - v[0] = vec1[0]; - v[1] = vec1[1]; - v[2] = vec1[2]; - ASSERT_TRUE(v == vec1); -} -// -//TEST_F(Vector3DTest, checkEuclideanDistance) -//{ -// Vector3D v = Vector3D(3, 3, 3); -// -// ASSERT_FLOAT_EQ(v.getEuclideanDistanceTo(vec1), (float)sqrt(3)); -//} -// -//TEST_F(Vector3DTest, checkEuclideanDistanceWithNullVector_ExpectNull) -//{ -// Vector3D v1 = Vector3D(0.0, 0.0, 0.0); -// Vector3D v2 = Vector3D(0.0, 0.0, 0.0); -// -// ASSERT_THAT((double)v1.getEuclideanDistanceTo(v2), DoubleEq(0.0)); -//} -// -//TEST(Vector3DAngleTest, checkInnerAngleBetweenToVectors_ExpectRightAngle) -//{ -// Vector3D v1 = Vector3D(1.0, 4.0, -2.0); -// Vector3D v2 = Vector3D(-3.0, 3.0, 1); -// -// ASSERT_THAT((int)floor(v1.getInnerAngle(v2)), Eq(69)); -//} -// -//TEST(Vector3DAngleTest, checkInnerAngleBetweenSameVectors_ExpectNull) -//{ -// Vector3D v1 = Vector3D(1.0, 4.0, -2.0); -// Vector3D v2 = Vector3D(1.0, 4.0, -2.0); -// -// ASSERT_THAT((int)floor(v1.getInnerAngle(v2)), Eq(0.0)); -//} -// -//TEST(Vector3DAngleTest, checkInnerAngleBetweenNullVectors_ExpectNull) -//{ -// Vector3D v1 = Vector3D(0.0, 0.0, 0.0); -// Vector3D v2 = Vector3D(0.0, 0.0, 0.0); -// -// ASSERT_THAT((int)floor(v1.getInnerAngle(v2)), Eq(0.0)); -//} -// -// -//TEST(Vector3DAngleTest, checkInnerAngleBetweenSecondNullVectors_ExpectNull) -//{ -// Vector3D v1 = Vector3D(1.0, 0.0, 0.0); -// Vector3D v2 = Vector3D(0.0, 0.0, 0.0); -// -// ASSERT_THAT((int)floor(v1.getInnerAngle(v2)), Eq(0.0)); -//} -// -//TEST(Vector3DAngleTest, checkInnerAngleBetweenFirstNullVectors_ExpectNull) -//{ -// Vector3D v1 = Vector3D(0.0, 0.0, 0.0); -// Vector3D v2 = Vector3D(2.0, 0.0, 0.0); -// -// ASSERT_THAT((int)floor(v1.getInnerAngle(v2)), Eq(0.0)); -//} - - -TEST_F(Vector3DTest, crossProductBetweenTwoVectors) -{ - Vector3D v1 = Vector3D(-5.0, -5.0, 0.0); - Vector3D v2 = Vector3D(5.0, 0.0, 10); - - Vector3D crossProd = Vector3D(-50.0, 50.0, 25.0); - Vector3D testCrossProduct = v1.Cross(v2); - - EXPECT_THAT(testCrossProduct[0], DoubleEq(crossProd[0])); - EXPECT_THAT(testCrossProduct[1], DoubleEq(crossProd[1])); - EXPECT_THAT(testCrossProduct[2], DoubleEq(crossProd[2])); -} diff --git a/src/basics/basics/utilities/package.include b/src/basics/basics/utilities/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/basics/writer/CMakePackage.txt b/src/basics/basics/writer/CMakePackage.txt new file mode 100644 index 000000000..6ef17942b --- /dev/null +++ b/src/basics/basics/writer/CMakePackage.txt @@ -0,0 +1,3 @@ +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) + diff --git a/src/basics/basics/writer/WbWriter.h b/src/basics/basics/writer/WbWriter.h index 2bea860d8..c6793c5ae 100644 --- a/src/basics/basics/writer/WbWriter.h +++ b/src/basics/basics/writer/WbWriter.h @@ -1,19 +1,38 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriter.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITER_H #define WBWRITER_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif - -#include "basics_export.h" - - #include <vector> #include <string> #include <fstream> @@ -21,19 +40,14 @@ #include <iostream> #include <map> -#include <basics/utilities/UbSystem.h> #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> -class BASICS_EXPORT WbWriter +class WbWriter { public: - OBCREATOR_EXT(WbWriter) - ////////////////////////////////////////////////////////////////////////// virtual ~WbWriter() { @@ -78,8 +92,7 @@ public: 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() ); } + 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 @@ -92,87 +105,10 @@ 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<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() ); } + 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() ); } private: }; - -#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 serialize(Archive& ar, const unsigned int version) - { - serializeWbWriter(ar, pointer); - } - -private: - WbWriter* pointer; -}; - - -#endif //CAB_RCF - - #endif //WBWRITER_H diff --git a/src/basics/basics/writer/WbWriterAvsASCII.cpp b/src/basics/basics/writer/WbWriterAvsASCII.cpp deleted file mode 100644 index 388feecb9..000000000 --- a/src/basics/basics/writer/WbWriterAvsASCII.cpp +++ /dev/null @@ -1,897 +0,0 @@ -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/utilities/UbLogger.h> -#include <cstring> -#include <basics/utilities/UbSystem.h> - -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|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 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,"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|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 = 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,"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|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,"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|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 = (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,"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|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); - } - - 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,"WbWriterAvsASCII::writeOctsWithNodeData to "<<avsfilename<<" - end"); - - return avsfilename; - } diff --git a/src/basics/basics/writer/WbWriterAvsASCII.h b/src/basics/basics/writer/WbWriterAvsASCII.h deleted file mode 100644 index 8f7f97a75..000000000 --- a/src/basics/basics/writer/WbWriterAvsASCII.h +++ /dev/null @@ -1,76 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERAVSASCII_H -#define WBWRITERAVSASCII_H - -#include <basics/writer/WbWriter.h> - -class WbWriterAvsASCII : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterAvsASCII ) - - 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); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsASCII ,WbWriter>::getInstance()), CAB_WbWriterAvsASCII); - -#endif //WBWRITERAVSASCII_H diff --git a/src/basics/basics/writer/WbWriterAvsBinary.cpp b/src/basics/basics/writer/WbWriterAvsBinary.cpp deleted file mode 100644 index 2d0ad38c5..000000000 --- a/src/basics/basics/writer/WbWriterAvsBinary.cpp +++ /dev/null @@ -1,977 +0,0 @@ -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbSystem.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/basics/basics/writer/WbWriterAvsBinary.h b/src/basics/basics/writer/WbWriterAvsBinary.h deleted file mode 100644 index 2ba0e7842..000000000 --- a/src/basics/basics/writer/WbWriterAvsBinary.h +++ /dev/null @@ -1,74 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERAVSBINARY_H -#define WBWRITERAVSBINARY_H - -#include <basics/writer/WbWriter.h> - -class WbWriterAvsBinary : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterAvsBinary ) - - 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); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsBinary ,WbWriter>::getInstance()), CAB_WbWriterAvsBinary); - -#endif //WBWRITERAVSBINARY_H diff --git a/src/basics/basics/writer/WbWriterBOBJ.cpp b/src/basics/basics/writer/WbWriterBOBJ.cpp deleted file mode 100644 index fa88708b2..000000000 --- a/src/basics/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/basics/basics/writer/WbWriterBOBJ.h b/src/basics/basics/writer/WbWriterBOBJ.h deleted file mode 100644 index 1d033c952..000000000 --- a/src/basics/basics/writer/WbWriterBOBJ.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifdef CAB_ZLIB - #ifndef WBWRITERBOBJ_H - #define WBWRITERBOBJ_H - - #include <string> - #include <basics/writer/WbWriter.h> - - class WbWriterBOBJ : public WbWriter - { - public: - OBCREATOR_EXT( WbWriterBOBJ ) - - 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/basics/basics/writer/WbWriterSunflow.cpp b/src/basics/basics/writer/WbWriterSunflow.cpp deleted file mode 100644 index 6adbc274a..000000000 --- a/src/basics/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/basics/basics/writer/WbWriterSunflow.h b/src/basics/basics/writer/WbWriterSunflow.h deleted file mode 100644 index a14461b06..000000000 --- a/src/basics/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/basics/basics/writer/WbWriterTecPlotASCII.cpp b/src/basics/basics/writer/WbWriterTecPlotASCII.cpp deleted file mode 100644 index 5e2ef86b4..000000000 --- a/src/basics/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/basics/basics/writer/WbWriterTecPlotASCII.h b/src/basics/basics/writer/WbWriterTecPlotASCII.h deleted file mode 100644 index 01b067557..000000000 --- a/src/basics/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/basics/basics/writer/WbWriterVtkASCII.cpp b/src/basics/basics/writer/WbWriterVtkASCII.cpp deleted file mode 100644 index e88bbf3b4..000000000 --- a/src/basics/basics/writer/WbWriterVtkASCII.cpp +++ /dev/null @@ -1,601 +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::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; -} -/*===============================================================================*/ -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<<" "<<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; - - out.close(); - - UBLOG(logDEBUG1,"WbWriterVtkASCII::writeOcts to "<<vtkfilename<<" - end"); - return vtkfilename; -} diff --git a/src/basics/basics/writer/WbWriterVtkASCII.h b/src/basics/basics/writer/WbWriterVtkASCII.h deleted file mode 100644 index aaa1f563c..000000000 --- a/src/basics/basics/writer/WbWriterVtkASCII.h +++ /dev/null @@ -1,78 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERVTKASCII_H -#define WBWRITERVTKASCII_H - -#include <basics/writer/WbWriter.h> - -class WbWriterVtkASCII : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterVtkASCII ) - - 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 writeOctsBinary(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); - -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkASCII,WbWriter>::getInstance()), CAB_WbWriterVtkASCII); - -#endif //WBWRITERVTKASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkBinary.cpp b/src/basics/basics/writer/WbWriterVtkBinary.cpp deleted file mode 100644 index 8925a9b03..000000000 --- a/src/basics/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<<"D3Q19MasterNodeGrid"<<"\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<<"D3Q19MasterNodeGrid"<<"\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<<"D3Q19MasterNodeGrid"<<"\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<<"D3Q19MasterNodeGrid"<<"\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<<"D3Q19MasterNodeGrid"<<"\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<<"D3Q19MasterNodeGrid"<<"\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<<"D3Q19MasterNodeGrid"<<"\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/basics/basics/writer/WbWriterVtkBinary.h b/src/basics/basics/writer/WbWriterVtkBinary.h deleted file mode 100644 index c67666c2c..000000000 --- a/src/basics/basics/writer/WbWriterVtkBinary.h +++ /dev/null @@ -1,77 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef WBWRITERVTKBINARY_H -#define WBWRITERVTKBINARY_H - -#include <basics/writer/WbWriter.h> - -class WbWriterVtkBinary : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterVtkBinary ) - - 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); - -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkBinary); - -#endif //WBWRITERVTKBINARY_H diff --git a/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp b/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp index edf5efea9..42b7defd6 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp +++ b/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkXmlASCII.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/utilities/UbLogger.h> #include <cstring> @@ -807,7 +839,7 @@ std::string WbWriterVtkXmlASCII::writeOctsWithCellData(const string& filename,ve return vtkfilename; } /*===============================================================================*/ -std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleUInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) +std::string WbWriterVtkXmlASCII::writeOctsWithNodeData(const string& filename,vector< UbTupleFloat3 >& nodes, vector< UbTupleInt8 >& cells, vector< string >& datanames, vector< vector< double > >& nodedata) { string vtkfilename=filename+getFileExtension(); UBLOG(logDEBUG1,"WbWriterVtkXmlASCII::writeOctsWithNodeData to "<<vtkfilename<<" - start"); diff --git a/src/basics/basics/writer/WbWriterVtkXmlASCII.h b/src/basics/basics/writer/WbWriterVtkXmlASCII.h index 1d451d8e0..ea76ed3b9 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlASCII.h +++ b/src/basics/basics/writer/WbWriterVtkXmlASCII.h @@ -1,17 +1,45 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkXmlASCII.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERVTKXMLASCII_H #define WBWRITERVTKXMLASCII_H #include <string> -#include "basics_export.h" - #include <basics/writer/WbWriter.h> -class BASICS_EXPORT WbWriterVtkXmlASCII : public WbWriter +class WbWriterVtkXmlASCII : public WbWriter { public: - OBCREATOR_EXT( WbWriterVtkXmlASCII ) - static WbWriterVtkXmlASCII* getInstance() { static WbWriterVtkXmlASCII instance; @@ -85,12 +113,10 @@ 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< UbTupleUInt8 >& 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< UbTupleInt8 >& cells, std::vector< std::string >& datanames, std::vector< std::vector< double > >& nodedata); private: }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlASCII ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlASCII); - #endif //WBWRITERVTKXMLASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp b/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp index b44943302..67bd1f563 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp +++ b/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp @@ -1,49 +1,44 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkXmlBinary.cpp +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #include <basics/writer/WbWriterVtkXmlBinary.h> #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbSystem.h> - -#include "buildInfo.h" #include <cstring> using namespace std; /*===============================================================================*/ string WbWriterVtkXmlBinary::pvdEndTag =" </Collection>\n</VTKFile>"; - -std::string WbWriterVtkXmlBinary::getHeaderTag() -{ - std::string header = "<!--- \n"; - - header += "git-commit-hash=\""; - header += buildInfo::gitCommitHash(); - header += "\" \n"; - - header += "git-branch=\""; - header += buildInfo::gitBranch(); - header += "\" \n"; - - header += "compiler-flag=\""; - header += buildInfo::compilerFlags(); - header += "\" \n"; - - header += "buildMachine=\""; - header += buildInfo::buildMachine(); - header += "\" \n"; - - header += "ProjectDir=\""; - header += buildInfo::projectDir(); - header += "\" \n"; - - header += "binaryDir=\""; - header += buildInfo::binaryDir(); - header += "\" \n"; - - - header += "-->\n"; - return header; -} - /*===============================================================================*/ string WbWriterVtkXmlBinary::writeCollection(const string& filename, const vector<string>& filenames, const double& timeStep, const bool& sepGroups) { @@ -1195,8 +1190,7 @@ string WbWriterVtkXmlBinary::writeOctsWithCellData(const string& filename,vector return vtkfilename; } /*===============================================================================*/ - -string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleUInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) +string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector<UbTupleFloat3 >& nodes, vector<UbTupleInt8 >& cells, vector<string >& datanames, vector<vector<double > >& nodedata) { string vtkfilename = filename+getFileExtension(); UBLOG(logDEBUG1,"WbWriterVtkXmlBinary::writeOctsWithNodeData to "<<vtkfilename<<" - start"); @@ -1223,7 +1217,6 @@ string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector unsigned long long offset = 0; //VTK FILE out<<"<?xml version=\"2.0\"?>\n"; - out<< getHeaderTag(); out<<"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" >"<<"\n"; out<<" <UnstructuredGrid>"<<"\n"; out<<" <Piece NumberOfPoints=\""<<nofNodes<<"\" NumberOfCells=\""<<nofCells<<"\">\n"; @@ -1312,7 +1305,7 @@ string WbWriterVtkXmlBinary::writeOctsWithNodeData(const string& filename,vector //float tmp = (float)nodedata[s][d]; //out.write((char*)&tmp,sizeof(float)); double tmp = nodedata[s][d]; - out.write((char*)&tmp,sizeof(double)); + out.write((char*)&tmp,sizeof(double)); } } out<<"\n</AppendedData>\n"; diff --git a/src/basics/basics/writer/WbWriterVtkXmlBinary.h b/src/basics/basics/writer/WbWriterVtkXmlBinary.h index 81c0a3aea..cd0182c26 100644 --- a/src/basics/basics/writer/WbWriterVtkXmlBinary.h +++ b/src/basics/basics/writer/WbWriterVtkXmlBinary.h @@ -1,19 +1,45 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WbWriterVtkXmlBinary.h +//! \ingroup writer +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef WBWRITERVTKXMLBINARY_H #define WBWRITERVTKXMLBINARY_H #include <string> -#include "basics_export.h" - #include <basics/writer/WbWriter.h> -class BASICS_EXPORT WbWriterVtkXmlBinary : public WbWriter +class WbWriterVtkXmlBinary : public WbWriter { public: -#ifndef SWIG - OBCREATOR_EXT( WbWriterVtkXmlBinary ) -#endif - static WbWriterVtkXmlBinary* getInstance() { static WbWriterVtkXmlBinary instance; @@ -34,8 +60,6 @@ private: public: std::string getFileExtension() { return ".bin.vtu"; } - std::string getHeaderTag(); - //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); @@ -88,14 +112,10 @@ 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<UbTupleUInt8 >& 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<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& nodedata); private: }; -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkXmlBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkXmlBinary); -#endif - #endif //WBWRITERVTKXMLBINARY_H diff --git a/src/basics/basics/writer/WbWriterX3D.cpp b/src/basics/basics/writer/WbWriterX3D.cpp deleted file mode 100644 index 14d1b3741..000000000 --- a/src/basics/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/basics/basics/writer/WbWriterX3D.h b/src/basics/basics/writer/WbWriterX3D.h deleted file mode 100644 index 6bb503f1c..000000000 --- a/src/basics/basics/writer/WbWriterX3D.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef WBWRITERX3D_H -#define WBWRITERX3D_H - -#include <string> - -#include <basics/writer/WbWriter.h> - -class WbWriterX3D : public WbWriter -{ -public: - OBCREATOR_EXT( WbWriterX3D ) - - 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); -}; - -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterX3D ,WbWriter>::getInstance()), CAB_WbWriterX3D); - -#endif //WBWRITERX3D_H diff --git a/src/basics/basics/writer/package.include b/src/basics/basics/writer/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/numerics/geometry3d/CoordinateTransformation3D.cpp b/src/basics/geometry3d/CoordinateTransformation3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/CoordinateTransformation3D.cpp rename to src/basics/geometry3d/CoordinateTransformation3D.cpp diff --git a/src/basics/numerics/geometry3d/CoordinateTransformation3D.h b/src/basics/geometry3d/CoordinateTransformation3D.h similarity index 100% rename from src/basics/numerics/geometry3d/CoordinateTransformation3D.h rename to src/basics/geometry3d/CoordinateTransformation3D.h diff --git a/src/basics/numerics/geometry3d/GbCuboid3D.cpp b/src/basics/geometry3d/GbCuboid3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbCuboid3D.cpp rename to src/basics/geometry3d/GbCuboid3D.cpp diff --git a/src/basics/numerics/geometry3d/GbCuboid3D.h b/src/basics/geometry3d/GbCuboid3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbCuboid3D.h rename to src/basics/geometry3d/GbCuboid3D.h diff --git a/src/basics/numerics/geometry3d/GbCylinder3D.cpp b/src/basics/geometry3d/GbCylinder3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbCylinder3D.cpp rename to src/basics/geometry3d/GbCylinder3D.cpp diff --git a/src/basics/numerics/geometry3d/GbCylinder3D.h b/src/basics/geometry3d/GbCylinder3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbCylinder3D.h rename to src/basics/geometry3d/GbCylinder3D.h diff --git a/src/basics/numerics/geometry3d/GbHalfSpace3D.cpp b/src/basics/geometry3d/GbHalfSpace3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbHalfSpace3D.cpp rename to src/basics/geometry3d/GbHalfSpace3D.cpp diff --git a/src/basics/numerics/geometry3d/GbHalfSpace3D.h b/src/basics/geometry3d/GbHalfSpace3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbHalfSpace3D.h rename to src/basics/geometry3d/GbHalfSpace3D.h diff --git a/src/basics/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp b/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbHalfSpaceKrischan3D.cpp rename to src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp diff --git a/src/basics/numerics/geometry3d/GbHalfSpaceKrischan3D.h b/src/basics/geometry3d/GbHalfSpaceKrischan3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbHalfSpaceKrischan3D.h rename to src/basics/geometry3d/GbHalfSpaceKrischan3D.h diff --git a/src/basics/numerics/geometry3d/GbLine3D.cpp b/src/basics/geometry3d/GbLine3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbLine3D.cpp rename to src/basics/geometry3d/GbLine3D.cpp diff --git a/src/basics/numerics/geometry3d/GbLine3D.h b/src/basics/geometry3d/GbLine3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbLine3D.h rename to src/basics/geometry3d/GbLine3D.h diff --git a/src/basics/numerics/geometry3d/GbMeshTools3D.h b/src/basics/geometry3d/GbMeshTools3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbMeshTools3D.h rename to src/basics/geometry3d/GbMeshTools3D.h diff --git a/src/basics/numerics/geometry3d/GbObject3D.cpp b/src/basics/geometry3d/GbObject3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbObject3D.cpp rename to src/basics/geometry3d/GbObject3D.cpp diff --git a/src/basics/numerics/geometry3d/GbObject3D.h b/src/basics/geometry3d/GbObject3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbObject3D.h rename to src/basics/geometry3d/GbObject3D.h diff --git a/src/basics/numerics/geometry3d/GbObject3DManager.cpp b/src/basics/geometry3d/GbObject3DManager.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbObject3DManager.cpp rename to src/basics/geometry3d/GbObject3DManager.cpp diff --git a/src/basics/numerics/geometry3d/GbObject3DManager.h b/src/basics/geometry3d/GbObject3DManager.h similarity index 100% rename from src/basics/numerics/geometry3d/GbObject3DManager.h rename to src/basics/geometry3d/GbObject3DManager.h diff --git a/src/basics/numerics/geometry3d/GbObjectGroup3D.cpp b/src/basics/geometry3d/GbObjectGroup3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbObjectGroup3D.cpp rename to src/basics/geometry3d/GbObjectGroup3D.cpp diff --git a/src/basics/numerics/geometry3d/GbObjectGroup3D.h b/src/basics/geometry3d/GbObjectGroup3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbObjectGroup3D.h rename to src/basics/geometry3d/GbObjectGroup3D.h diff --git a/src/basics/numerics/geometry3d/GbPoint3D.cpp b/src/basics/geometry3d/GbPoint3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbPoint3D.cpp rename to src/basics/geometry3d/GbPoint3D.cpp diff --git a/src/basics/numerics/geometry3d/GbPoint3D.h b/src/basics/geometry3d/GbPoint3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbPoint3D.h rename to src/basics/geometry3d/GbPoint3D.h diff --git a/src/basics/numerics/geometry3d/GbPolygon3D.cpp b/src/basics/geometry3d/GbPolygon3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbPolygon3D.cpp rename to src/basics/geometry3d/GbPolygon3D.cpp diff --git a/src/basics/numerics/geometry3d/GbPolygon3D.h b/src/basics/geometry3d/GbPolygon3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbPolygon3D.h rename to src/basics/geometry3d/GbPolygon3D.h diff --git a/src/basics/numerics/geometry3d/GbQuadFaceMesh3D.cpp b/src/basics/geometry3d/GbQuadFaceMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbQuadFaceMesh3D.cpp rename to src/basics/geometry3d/GbQuadFaceMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/GbQuadFaceMesh3D.h b/src/basics/geometry3d/GbQuadFaceMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbQuadFaceMesh3D.h rename to src/basics/geometry3d/GbQuadFaceMesh3D.h diff --git a/src/basics/numerics/geometry3d/GbSphere3D.cpp b/src/basics/geometry3d/GbSphere3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbSphere3D.cpp rename to src/basics/geometry3d/GbSphere3D.cpp diff --git a/src/basics/numerics/geometry3d/GbSphere3D.h b/src/basics/geometry3d/GbSphere3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbSphere3D.h rename to src/basics/geometry3d/GbSphere3D.h diff --git a/src/basics/numerics/geometry3d/GbSystem3D.cpp b/src/basics/geometry3d/GbSystem3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbSystem3D.cpp rename to src/basics/geometry3d/GbSystem3D.cpp diff --git a/src/basics/numerics/geometry3d/GbSystem3D.h b/src/basics/geometry3d/GbSystem3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbSystem3D.h rename to src/basics/geometry3d/GbSystem3D.h diff --git a/src/basics/numerics/geometry3d/GbTriFaceMesh3D.cpp b/src/basics/geometry3d/GbTriFaceMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbTriFaceMesh3D.cpp rename to src/basics/geometry3d/GbTriFaceMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/GbTriFaceMesh3D.h b/src/basics/geometry3d/GbTriFaceMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbTriFaceMesh3D.h rename to src/basics/geometry3d/GbTriFaceMesh3D.h diff --git a/src/basics/numerics/geometry3d/GbTriangle3D.cpp b/src/basics/geometry3d/GbTriangle3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbTriangle3D.cpp rename to src/basics/geometry3d/GbTriangle3D.cpp diff --git a/src/basics/numerics/geometry3d/GbTriangle3D.h b/src/basics/geometry3d/GbTriangle3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbTriangle3D.h rename to src/basics/geometry3d/GbTriangle3D.h diff --git a/src/basics/numerics/geometry3d/GbTriangularMesh3D.cpp b/src/basics/geometry3d/GbTriangularMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbTriangularMesh3D.cpp rename to src/basics/geometry3d/GbTriangularMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/GbTriangularMesh3D.h b/src/basics/geometry3d/GbTriangularMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbTriangularMesh3D.h rename to src/basics/geometry3d/GbTriangularMesh3D.h diff --git a/src/basics/numerics/geometry3d/GbVector3D.cpp b/src/basics/geometry3d/GbVector3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbVector3D.cpp rename to src/basics/geometry3d/GbVector3D.cpp diff --git a/src/basics/numerics/geometry3d/GbVector3D.h b/src/basics/geometry3d/GbVector3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbVector3D.h rename to src/basics/geometry3d/GbVector3D.h diff --git a/src/basics/numerics/geometry3d/GbVoxelMatrix3D.cpp b/src/basics/geometry3d/GbVoxelMatrix3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/GbVoxelMatrix3D.cpp rename to src/basics/geometry3d/GbVoxelMatrix3D.cpp diff --git a/src/basics/numerics/geometry3d/GbVoxelMatrix3D.h b/src/basics/geometry3d/GbVoxelMatrix3D.h similarity index 100% rename from src/basics/numerics/geometry3d/GbVoxelMatrix3D.h rename to src/basics/geometry3d/GbVoxelMatrix3D.h diff --git a/src/basics/numerics/geometry3d/KdTree/KdNode.h b/src/basics/geometry3d/KdTree/KdNode.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdNode.h rename to src/basics/geometry3d/KdTree/KdNode.h diff --git a/src/basics/numerics/geometry3d/KdTree/KdRay.h b/src/basics/geometry3d/KdTree/KdRay.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdRay.h rename to src/basics/geometry3d/KdTree/KdRay.h diff --git a/src/basics/numerics/geometry3d/KdTree/KdSplitCandidate.h b/src/basics/geometry3d/KdTree/KdSplitCandidate.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdSplitCandidate.h rename to src/basics/geometry3d/KdTree/KdSplitCandidate.h diff --git a/src/basics/numerics/geometry3d/KdTree/KdSplitCandidateManager.h b/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdSplitCandidateManager.h rename to src/basics/geometry3d/KdTree/KdSplitCandidateManager.h diff --git a/src/basics/numerics/geometry3d/KdTree/KdTree.h b/src/basics/geometry3d/KdTree/KdTree.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdTree.h rename to src/basics/geometry3d/KdTree/KdTree.h diff --git a/src/basics/numerics/geometry3d/KdTree/KdUtilities.cpp b/src/basics/geometry3d/KdTree/KdUtilities.cpp similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdUtilities.cpp rename to src/basics/geometry3d/KdTree/KdUtilities.cpp diff --git a/src/basics/numerics/geometry3d/KdTree/KdUtilities.h b/src/basics/geometry3d/KdTree/KdUtilities.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/KdUtilities.h rename to src/basics/geometry3d/KdTree/KdUtilities.h diff --git a/src/basics/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt b/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt rename to src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt diff --git a/src/basics/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp b/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp rename to src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp diff --git a/src/basics/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt b/src/basics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt rename to src/basics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt diff --git a/src/basics/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp b/src/basics/geometry3d/KdTree/examples/PIOTests/main.cpp similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/examples/PIOTests/main.cpp rename to src/basics/geometry3d/KdTree/examples/PIOTests/main.cpp diff --git a/src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h rename to src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h diff --git a/src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h rename to src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h diff --git a/src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h rename to src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h diff --git a/src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h rename to src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h diff --git a/src/basics/Core/package.include b/src/basics/geometry3d/KdTree/package.include similarity index 100% rename from src/basics/Core/package.include rename to src/basics/geometry3d/KdTree/package.include diff --git a/src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp rename to src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp diff --git a/src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h rename to src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h diff --git a/src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h rename to src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h diff --git a/src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h similarity index 100% rename from src/basics/numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h rename to src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h diff --git a/src/basics/numerics/geometry3d/creator/GbCuboid3DCreator.h b/src/basics/geometry3d/creator/GbCuboid3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbCuboid3DCreator.h rename to src/basics/geometry3d/creator/GbCuboid3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbCylinder3DCreator.h b/src/basics/geometry3d/creator/GbCylinder3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbCylinder3DCreator.h rename to src/basics/geometry3d/creator/GbCylinder3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbLine3DCreator.h b/src/basics/geometry3d/creator/GbLine3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbLine3DCreator.h rename to src/basics/geometry3d/creator/GbLine3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbObject3DCreator.h b/src/basics/geometry3d/creator/GbObject3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbObject3DCreator.h rename to src/basics/geometry3d/creator/GbObject3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbObject3DFactory.cpp b/src/basics/geometry3d/creator/GbObject3DFactory.cpp similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbObject3DFactory.cpp rename to src/basics/geometry3d/creator/GbObject3DFactory.cpp diff --git a/src/basics/numerics/geometry3d/creator/GbObject3DFactory.h b/src/basics/geometry3d/creator/GbObject3DFactory.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbObject3DFactory.h rename to src/basics/geometry3d/creator/GbObject3DFactory.h diff --git a/src/basics/numerics/geometry3d/creator/GbPoint3DCreator.h b/src/basics/geometry3d/creator/GbPoint3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbPoint3DCreator.h rename to src/basics/geometry3d/creator/GbPoint3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbPolygon3DCreator.h b/src/basics/geometry3d/creator/GbPolygon3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbPolygon3DCreator.h rename to src/basics/geometry3d/creator/GbPolygon3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp rename to src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp diff --git a/src/basics/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h b/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h rename to src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbSphere3DCreator.h b/src/basics/geometry3d/creator/GbSphere3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbSphere3DCreator.h rename to src/basics/geometry3d/creator/GbSphere3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp rename to src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp diff --git a/src/basics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h b/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h rename to src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbTriangle3DCreator.h b/src/basics/geometry3d/creator/GbTriangle3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbTriangle3DCreator.h rename to src/basics/geometry3d/creator/GbTriangle3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbTriangularMesh3DCreator.cpp rename to src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp diff --git a/src/basics/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h b/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h rename to src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h diff --git a/src/basics/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp b/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp rename to src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp diff --git a/src/basics/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h b/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h rename to src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h diff --git a/src/basics/basics/container/package.include b/src/basics/geometry3d/creator/package.include similarity index 100% rename from src/basics/basics/container/package.include rename to src/basics/geometry3d/creator/package.include diff --git a/src/basics/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt b/src/basics/geometry3d/examples/insideOutsideTests/CMakeLists.txt similarity index 100% rename from src/basics/numerics/geometry3d/examples/insideOutsideTests/CMakeLists.txt rename to src/basics/geometry3d/examples/insideOutsideTests/CMakeLists.txt diff --git a/src/basics/numerics/geometry3d/examples/insideOutsideTests/main.cpp b/src/basics/geometry3d/examples/insideOutsideTests/main.cpp similarity index 100% rename from src/basics/numerics/geometry3d/examples/insideOutsideTests/main.cpp rename to src/basics/geometry3d/examples/insideOutsideTests/main.cpp diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/CMakeLists.txt b/src/basics/geometry3d/examples/stl2inp/CMakeLists.txt similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/CMakeLists.txt rename to src/basics/geometry3d/examples/stl2inp/CMakeLists.txt diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp b/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp rename to src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h b/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.h similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.h rename to src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.h diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui b/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui rename to src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/main.cpp b/src/basics/geometry3d/examples/stl2inp/main.cpp similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/main.cpp rename to src/basics/geometry3d/examples/stl2inp/main.cpp diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/stl2inp.cpp b/src/basics/geometry3d/examples/stl2inp/stl2inp.cpp similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/stl2inp.cpp rename to src/basics/geometry3d/examples/stl2inp/stl2inp.cpp diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/stl2inp.h b/src/basics/geometry3d/examples/stl2inp/stl2inp.h similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/stl2inp.h rename to src/basics/geometry3d/examples/stl2inp/stl2inp.h diff --git a/src/basics/numerics/geometry3d/examples/stl2inp/stl2inp.ui b/src/basics/geometry3d/examples/stl2inp/stl2inp.ui similarity index 100% rename from src/basics/numerics/geometry3d/examples/stl2inp/stl2inp.ui rename to src/basics/geometry3d/examples/stl2inp/stl2inp.ui diff --git a/src/basics/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp b/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp rename to src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h b/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeAdhocTriFaceMesh3D.h rename to src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.h diff --git a/src/basics/numerics/geometry3d/fem/FeHalfDisc3D.cpp b/src/basics/geometry3d/fem/FeHalfDisc3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeHalfDisc3D.cpp rename to src/basics/geometry3d/fem/FeHalfDisc3D.cpp diff --git a/src/basics/numerics/geometry3d/fem/FeHalfDisc3D.h b/src/basics/geometry3d/fem/FeHalfDisc3D.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeHalfDisc3D.h rename to src/basics/geometry3d/fem/FeHalfDisc3D.h diff --git a/src/basics/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp b/src/basics/geometry3d/fem/FePlateTriangularMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/fem/FePlateTriangularMesh3D.cpp rename to src/basics/geometry3d/fem/FePlateTriangularMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/fem/FePlateTriangularMesh3D.h b/src/basics/geometry3d/fem/FePlateTriangularMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/FePlateTriangularMesh3D.h rename to src/basics/geometry3d/fem/FePlateTriangularMesh3D.h diff --git a/src/basics/numerics/geometry3d/fem/FePoint3D.h b/src/basics/geometry3d/fem/FePoint3D.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/FePoint3D.h rename to src/basics/geometry3d/fem/FePoint3D.h diff --git a/src/basics/numerics/geometry3d/fem/FeRing3D.cpp b/src/basics/geometry3d/fem/FeRing3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeRing3D.cpp rename to src/basics/geometry3d/fem/FeRing3D.cpp diff --git a/src/basics/numerics/geometry3d/fem/FeRing3D.h b/src/basics/geometry3d/fem/FeRing3D.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeRing3D.h rename to src/basics/geometry3d/fem/FeRing3D.h diff --git a/src/basics/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp b/src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeTriFaceMesh3D.cpp rename to src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/fem/FeTriFaceMesh3D.h b/src/basics/geometry3d/fem/FeTriFaceMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/FeTriFaceMesh3D.h rename to src/basics/geometry3d/fem/FeTriFaceMesh3D.h diff --git a/src/basics/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp b/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp similarity index 100% rename from src/basics/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp rename to src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp diff --git a/src/basics/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h b/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h similarity index 100% rename from src/basics/numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h rename to src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h diff --git a/src/basics/basics/memory/package.include b/src/basics/geometry3d/package.include similarity index 100% rename from src/basics/basics/memory/package.include rename to src/basics/geometry3d/package.include diff --git a/src/basics/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbCuboid3DInstrument.cpp rename to src/basics/geometry3d/presentation/QGbCuboid3DInstrument.cpp diff --git a/src/basics/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h b/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbCuboid3DInstrument.h rename to src/basics/geometry3d/presentation/QGbCuboid3DInstrument.h diff --git a/src/basics/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui b/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.ui similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbCuboid3DInstrument.ui rename to src/basics/geometry3d/presentation/QGbCuboid3DInstrument.ui diff --git a/src/basics/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbCylinder3DInstrument.cpp rename to src/basics/geometry3d/presentation/QGbCylinder3DInstrument.cpp diff --git a/src/basics/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h b/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbCylinder3DInstrument.h rename to src/basics/geometry3d/presentation/QGbCylinder3DInstrument.h diff --git a/src/basics/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui b/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.ui similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbCylinder3DInstrument.ui rename to src/basics/geometry3d/presentation/QGbCylinder3DInstrument.ui diff --git a/src/basics/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbObject3DInstrument.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbObject3DInstrument.cpp rename to src/basics/geometry3d/presentation/QGbObject3DInstrument.cpp diff --git a/src/basics/numerics/geometry3d/presentation/QGbObject3DInstrument.h b/src/basics/geometry3d/presentation/QGbObject3DInstrument.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbObject3DInstrument.h rename to src/basics/geometry3d/presentation/QGbObject3DInstrument.h diff --git a/src/basics/numerics/geometry3d/presentation/QGbObject3DInstrument.ui b/src/basics/geometry3d/presentation/QGbObject3DInstrument.ui similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbObject3DInstrument.ui rename to src/basics/geometry3d/presentation/QGbObject3DInstrument.ui diff --git a/src/basics/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbSphere3DInstrument.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbSphere3DInstrument.cpp rename to src/basics/geometry3d/presentation/QGbSphere3DInstrument.cpp diff --git a/src/basics/numerics/geometry3d/presentation/QGbSphere3DInstrument.h b/src/basics/geometry3d/presentation/QGbSphere3DInstrument.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbSphere3DInstrument.h rename to src/basics/geometry3d/presentation/QGbSphere3DInstrument.h diff --git a/src/basics/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui b/src/basics/geometry3d/presentation/QGbSphere3DInstrument.ui similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QGbSphere3DInstrument.ui rename to src/basics/geometry3d/presentation/QGbSphere3DInstrument.ui diff --git a/src/basics/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp b/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QVTKGbObject3DViewer.cpp rename to src/basics/geometry3d/presentation/QVTKGbObject3DViewer.cpp diff --git a/src/basics/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h b/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/QVTKGbObject3DViewer.h rename to src/basics/geometry3d/presentation/QVTKGbObject3DViewer.h diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp b/src/basics/geometry3d/presentation/vtkGbCuboid3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbCuboid3D.cpp rename to src/basics/geometry3d/presentation/vtkGbCuboid3D.cpp diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbCuboid3D.h b/src/basics/geometry3d/presentation/vtkGbCuboid3D.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbCuboid3D.h rename to src/basics/geometry3d/presentation/vtkGbCuboid3D.h diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp b/src/basics/geometry3d/presentation/vtkGbCylinder3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbCylinder3D.cpp rename to src/basics/geometry3d/presentation/vtkGbCylinder3D.cpp diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbCylinder3D.h b/src/basics/geometry3d/presentation/vtkGbCylinder3D.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbCylinder3D.h rename to src/basics/geometry3d/presentation/vtkGbCylinder3D.h diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbSphere3D.cpp b/src/basics/geometry3d/presentation/vtkGbSphere3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbSphere3D.cpp rename to src/basics/geometry3d/presentation/vtkGbSphere3D.cpp diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbSphere3D.h b/src/basics/geometry3d/presentation/vtkGbSphere3D.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbSphere3D.h rename to src/basics/geometry3d/presentation/vtkGbSphere3D.h diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp b/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp rename to src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp diff --git a/src/basics/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h b/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.h similarity index 100% rename from src/basics/numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h rename to src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.h diff --git a/src/basics/numerics/geometry3d/KdTree/package.include b/src/basics/numerics/geometry3d/KdTree/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/numerics/geometry3d/creator/package.include b/src/basics/numerics/geometry3d/creator/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/numerics/geometry3d/package.include b/src/basics/numerics/geometry3d/package.include deleted file mode 100644 index e69de29bb..000000000 -- GitLab