From 2d661a46532072ad30bf398ed101fe8500974c4c Mon Sep 17 00:00:00 2001 From: "LEGOLAS\\lenz" <lenz@irmb.tu-bs.de> Date: Mon, 1 Oct 2018 12:46:03 +0200 Subject: [PATCH] fixes simulation file writer --- .../grid/BoundaryConditions/Side.cpp | 2 +- .../SimulationFileNames.cpp | 4 + .../SimulationFileNames.h | 4 + .../SimulationFileWriter.cpp | 101 +++- .../SimulationFileWriter.h | 9 + targets/apps/HULC/main.cpp | 543 +++++++++--------- 6 files changed, 374 insertions(+), 289 deletions(-) diff --git a/src/GridGenerator/grid/BoundaryConditions/Side.cpp b/src/GridGenerator/grid/BoundaryConditions/Side.cpp index 518201830..79607cb38 100644 --- a/src/GridGenerator/grid/BoundaryConditions/Side.cpp +++ b/src/GridGenerator/grid/BoundaryConditions/Side.cpp @@ -122,7 +122,7 @@ void Geometry::addIndices(std::vector<SPtr<Grid> > grids, uint level, SPtr<Bound uint neighborIndex = grids[level]->transCoordToIndex( x, y, z ); - if( grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID_BOUNDARY ) + if( qNode[dir] < -0.5 && grids[level]->getFieldEntry(neighborIndex) == STOPPER_OUT_OF_GRID_BOUNDARY ) qNode[dir] = 0.5; } diff --git a/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp b/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp index 2cef7f597..7cf2412a3 100644 --- a/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp +++ b/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.cpp @@ -8,6 +8,7 @@ const std::string simulationFileNames::coordZ = "coordZ" + fileEnding; const std::string simulationFileNames::neighborX = "neighborX" + fileEnding; const std::string simulationFileNames::neighborY = "neighborY" + fileEnding; const std::string simulationFileNames::neighborZ = "neighborZ" + fileEnding; +const std::string simulationFileNames::neighborWSB = "neighborWSB" + fileEnding; const std::string simulationFileNames::geoVec = "geoVec" + fileEnding; const std::string simulationFileNames::scaleCFC = "scaleCFC" + fileEnding; @@ -39,3 +40,6 @@ const std::string simulationFileNames::inletBoundaryValues = "inletBoundaryValue const std::string simulationFileNames::outletBoundaryQ = "outletBoundaryQs" + fileEnding; const std::string simulationFileNames::outletBoundaryValues = "outletBoundaryValues" + fileEnding; +const std::string simulationFileNames::numberNodes = "numberNodes" + fileEnding; +const std::string simulationFileNames::LBMvsSI = "LBMvsSI" + fileEnding; + diff --git a/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h b/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h index 733d87a11..3507cbc0a 100644 --- a/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h +++ b/src/GridGenerator/io/SimulationFileWriter/SimulationFileNames.h @@ -13,6 +13,7 @@ struct VF_PUBLIC simulationFileNames static const std::string neighborX; static const std::string neighborY; static const std::string neighborZ; + static const std::string neighborWSB; static const std::string geoVec; static const std::string scaleCFC; @@ -43,6 +44,9 @@ struct VF_PUBLIC simulationFileNames static const std::string outletBoundaryQ; static const std::string outletBoundaryValues; + + static const std::string numberNodes; + static const std::string LBMvsSI; }; diff --git a/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp b/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp index d84caa60f..968e0ff64 100644 --- a/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp +++ b/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp @@ -6,6 +6,8 @@ #include <omp.h> #include "stdint.h" +#include "VirtualFluidsBasics/utilities/logger/Logger.h" + #include "SimulationFileNames.h" #include <GridGenerator/grid/NodeValues.h> @@ -47,6 +49,9 @@ void SimulationFileWriter::write(SPtr<GridBuilder> builder, FILEFORMAT format) for (uint level = 0; level < numberOfLevel; level++) { + writeNumberNodes(builder, level); + writeLBMvsSI(builder, level); + writeLevelSize(builder->getNumberOfNodes(level)); writeCoordFiles(builder, level, format); @@ -65,13 +70,14 @@ void SimulationFileWriter::write(SPtr<GridBuilder> builder, FILEFORMAT format) void SimulationFileWriter::openFiles() { std::string path = folder; - xCoordFile.open((path + simulationFileNames::coordX).c_str(), std::ios::out | std::ios::binary); - yCoordFile.open((path + simulationFileNames::coordY).c_str(), std::ios::out | std::ios::binary); - zCoordFile.open((path + simulationFileNames::coordZ).c_str(), std::ios::out | std::ios::binary); - xNeighborFile.open((path + simulationFileNames::neighborX).c_str(), std::ios::out | std::ios::binary); - yNeighborFile.open((path + simulationFileNames::neighborY).c_str(), std::ios::out | std::ios::binary); - zNeighborFile.open((path + simulationFileNames::neighborZ).c_str(), std::ios::out | std::ios::binary); - geoVecFile.open((path + simulationFileNames::geoVec).c_str(), std::ios::out | std::ios::binary); + xCoordFile.open(( path + simulationFileNames::coordX).c_str(), std::ios::out | std::ios::binary); + yCoordFile.open(( path + simulationFileNames::coordY).c_str(), std::ios::out | std::ios::binary); + zCoordFile.open(( path + simulationFileNames::coordZ).c_str(), std::ios::out | std::ios::binary); + xNeighborFile.open(( path + simulationFileNames::neighborX).c_str(), std::ios::out | std::ios::binary); + yNeighborFile.open(( path + simulationFileNames::neighborY).c_str(), std::ios::out | std::ios::binary); + zNeighborFile.open(( path + simulationFileNames::neighborZ).c_str(), std::ios::out | std::ios::binary); + wsbNeighborFile.open(( path + simulationFileNames::neighborWSB).c_str(), std::ios::out | std::ios::binary); + geoVecFile.open(( path + simulationFileNames::geoVec).c_str(), std::ios::out | std::ios::binary); scaleCF_coarse_File.open((path + simulationFileNames::scaleCFC).c_str(), std::ios::out | std::ios::binary); scaleCF_fine_File.open((path + simulationFileNames::scaleCFF).c_str(), std::ios::out | std::ios::binary); @@ -109,6 +115,34 @@ void SimulationFileWriter::openFiles() outV->open(valueNames[i].c_str(), std::ios::out | std::ios::binary); valueStreams.push_back(outV); } + + numberNodes_File.open((path + simulationFileNames::numberNodes).c_str(), std::ios::out | std::ios::binary); + LBMvsSI_File.open((path + simulationFileNames::LBMvsSI).c_str(), std::ios::out | std::ios::binary); +} + +void SimulationFileWriter::writeNumberNodes(SPtr<GridBuilder> builder, uint level) +{ + SPtr<Grid> grid = builder->getGrid(level); + numberNodes_File << level << '\n'; + + numberNodes_File << grid->getNumberOfNodesX() << ' '; + numberNodes_File << grid->getNumberOfNodesY() << ' '; + numberNodes_File << grid->getNumberOfNodesZ() << ' '; + numberNodes_File << '\n'; +} + +void SimulationFileWriter::writeLBMvsSI(SPtr<GridBuilder> builder, uint level) +{ + SPtr<Grid> grid = builder->getGrid(level); + + LBMvsSI_File << grid->getStartX() << ' '; + LBMvsSI_File << grid->getStartY() << ' '; + LBMvsSI_File << grid->getStartZ() << ' '; + + LBMvsSI_File << grid->getEndX() << ' '; + LBMvsSI_File << grid->getEndY() << ' '; + LBMvsSI_File << grid->getEndZ() << ' '; + LBMvsSI_File << '\n'; } void SimulationFileWriter::writeLevel(uint numberOfLevels) @@ -121,6 +155,7 @@ void SimulationFileWriter::writeLevel(uint numberOfLevels) xNeighborFile << level << "\n"; yNeighborFile << level << "\n"; zNeighborFile << level << "\n"; + wsbNeighborFile << level << "\n"; geoVecFile << level << "\n"; scaleCF_coarse_File << level << "\n"; @@ -150,6 +185,7 @@ void SimulationFileWriter::writeLevelSize(uint numberOfNodes) xNeighborFile << numberOfNodes << "\n" << zeroIndex; yNeighborFile << numberOfNodes << "\n" << zeroIndex; zNeighborFile << numberOfNodes << "\n" << zeroIndex; + wsbNeighborFile << numberOfNodes << "\n" << zeroIndex; geoVecFile << numberOfNodes << "\n" << zeroGeo; //const std::string geoRB = "noSlip\n"; @@ -173,8 +209,9 @@ void SimulationFileWriter::writeLevelSizeGridInterface(uint sizeCF, uint sizeFC) void SimulationFileWriter::writeCoordFiles(SPtr<GridBuilder> builder, uint level, FILEFORMAT format) { - for (uint index = 0; index < builder->getNumberOfNodes(level); index++) + for (uint index = 0; index < builder->getGrid(level)->getSize(); index++){ writeCoordsNeighborsGeo(builder, index, level, format); + } xCoordFile << "\n"; yCoordFile << "\n"; @@ -183,6 +220,7 @@ void SimulationFileWriter::writeCoordFiles(SPtr<GridBuilder> builder, uint level xNeighborFile << "\n"; yNeighborFile << "\n"; zNeighborFile << "\n"; + wsbNeighborFile << "\n"; geoVecFile << "\n"; } @@ -216,21 +254,23 @@ void SimulationFileWriter::writeCoordsNeighborsGeo(SPtr<GridBuilder> builder, in xNeighborFile.write((char*)(&grid->getNeighborsX()[index] + 1), sizeof(unsigned int)); yNeighborFile.write((char*)(&grid->getNeighborsY()[index] + 1), sizeof(unsigned int)); zNeighborFile.write((char*)(&grid->getNeighborsZ()[index] + 1), sizeof(unsigned int)); + wsbNeighborFile.write((char*)(&grid->getNeighborsNegative()[index] + 1), sizeof(unsigned int)); geoVecFile.write((char*)&type, sizeof(unsigned int)); } else { - xCoordFile << x << " "; - yCoordFile << y << " "; - zCoordFile << z << " "; + xCoordFile << x << "\n"; + yCoordFile << y << "\n"; + zCoordFile << z << "\n"; // + 1 for numbering shift between GridGenerator and VF_GPU - xNeighborFile << (grid->getNeighborsX()[index] + 1) << " "; - yNeighborFile << (grid->getNeighborsY()[index] + 1) << " "; - zNeighborFile << (grid->getNeighborsZ()[index] + 1) << " "; + xNeighborFile << (grid->getNeighborsX()[index] + 1) << "\n"; + yNeighborFile << (grid->getNeighborsY()[index] + 1) << "\n"; + zNeighborFile << (grid->getNeighborsZ()[index] + 1) << "\n"; + wsbNeighborFile << (grid->getNeighborsNegative()[index] + 1) << "\n"; - geoVecFile << type << " "; + geoVecFile << type << "\n"; } } @@ -282,7 +322,7 @@ void SimulationFileWriter::writeGridInterfaceToFile(SPtr<GridBuilder> builder, u if (numberOfNodesFC > 0) { - writeGridInterfaceOffsetToFile(numberOfNodesCF, offsetVecFC_File, fc_offset_X, fc_offset_Y, fc_offset_Z); + writeGridInterfaceOffsetToFile(numberOfNodesFC, offsetVecFC_File, fc_offset_X, fc_offset_Y, fc_offset_Z); } delete[] cf_offset_X; @@ -429,7 +469,11 @@ void SimulationFileWriter::writeBoundaryQsFile(SPtr<GridBuilder> builder) auto bc = builder->getBoundaryCondition( sides[side], level ); - if( !bc ) continue; + if( !bc ){ + *valueStreams[side] << "noSlip\n" << "0\n" << "0\n"; + *qStreams[side] << "0\n" << "0\n"; + continue; + } if( level == 0 ){ @@ -521,25 +565,26 @@ void SimulationFileWriter::writeBoundaryShort(SPtr<Grid> grid, SPtr<BoundaryCond auto bcPressure = dynamic_cast< PressureBoundaryCondition* >( boundaryCondition.get() ); *valueStreams[side] << bcPressure->getRho() << " "; - *valueStreams[side] << bcPressure->neighborIndices[index] << " "; + // + 1 for numbering shift between GridGenerator and VF_GPU + *valueStreams[side] << grid->getSparseIndex( bcPressure->neighborIndices[index] ) + 1 << " "; } if( boundaryCondition->getType() == BC_VELOCITY ) { auto bcVelocity = dynamic_cast< VelocityBoundaryCondition* >( boundaryCondition.get() ); - *valueStreams[side] << bcVelocity->getVx() << " "; - *valueStreams[side] << bcVelocity->getVy() << " "; - *valueStreams[side] << bcVelocity->getVz() << " "; + *valueStreams[side] << bcVelocity->getVx(index) << " "; + *valueStreams[side] << bcVelocity->getVy(index) << " "; + *valueStreams[side] << bcVelocity->getVz(index) << " "; } if( boundaryCondition->getType() == BC_SOLID ) { auto bcGeometry = dynamic_cast< GeometryBoundaryCondition* >( boundaryCondition.get() ); - *valueStreams[side] << bcGeometry->getVx() << " "; - *valueStreams[side] << bcGeometry->getVy() << " "; - *valueStreams[side] << bcGeometry->getVz() << " "; + *valueStreams[side] << bcGeometry->getVx(index) << " "; + *valueStreams[side] << bcGeometry->getVy(index) << " "; + *valueStreams[side] << bcGeometry->getVz(index) << " "; } *valueStreams[side] << "\n"; @@ -555,6 +600,7 @@ void SimulationFileWriter::closeFiles() xNeighborFile.close(); yNeighborFile.close(); zNeighborFile.close(); + wsbNeighborFile.close(); geoVecFile.close(); scaleCF_coarse_File.close(); @@ -569,6 +615,9 @@ void SimulationFileWriter::closeFiles() qStreams[rb]->close(); valueStreams[rb]->close(); } + + numberNodes_File.close(); + LBMvsSI_File.close(); } @@ -584,6 +633,7 @@ std::ofstream SimulationFileWriter::zCoordFile; std::ofstream SimulationFileWriter::xNeighborFile; std::ofstream SimulationFileWriter::yNeighborFile; std::ofstream SimulationFileWriter::zNeighborFile; +std::ofstream SimulationFileWriter::wsbNeighborFile; std::ofstream SimulationFileWriter::geoVecFile; std::string SimulationFileWriter::folder; @@ -594,3 +644,6 @@ std::ofstream SimulationFileWriter::scaleFC_fine_File; std::ofstream SimulationFileWriter::offsetVecCF_File; std::ofstream SimulationFileWriter::offsetVecFC_File; + +std::ofstream SimulationFileWriter::numberNodes_File; +std::ofstream SimulationFileWriter::LBMvsSI_File; diff --git a/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h b/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h index 8027a54de..82b948ecc 100644 --- a/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h +++ b/src/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h @@ -30,6 +30,10 @@ public: private: static void write(SPtr<GridBuilder> builder, FILEFORMAT format); static void openFiles(); + + static void writeNumberNodes(SPtr<GridBuilder> builder, uint level); + static void writeLBMvsSI(SPtr<GridBuilder> builder, uint level); + static void writeLevel(uint numberOfLevels); static void writeLevelSize(uint numberOfNodes); static void writeCoordFiles(SPtr<GridBuilder> builder, uint level, FILEFORMAT format); @@ -57,6 +61,7 @@ private: static std::ofstream xNeighborFile; static std::ofstream yNeighborFile; static std::ofstream zNeighborFile; + static std::ofstream wsbNeighborFile; static std::ofstream geoVecFile; static std::ofstream scaleCF_coarse_File; @@ -72,6 +77,10 @@ private: static std::vector<std::ofstream> qFiles; static std::vector<std::ofstream> valueFiles; + + static std::ofstream numberNodes_File; + static std::ofstream LBMvsSI_File; + static std::string folder; }; diff --git a/targets/apps/HULC/main.cpp b/targets/apps/HULC/main.cpp index 0f2dfbb76..b9e9892e5 100644 --- a/targets/apps/HULC/main.cpp +++ b/targets/apps/HULC/main.cpp @@ -44,7 +44,7 @@ #include "io/STLReaderWriter/STLReader.h" #include "io/STLReaderWriter/STLWriter.h" #include "Output/FileWriter.h" -//#include "DataStructureInitializer/GridReaderFiles/GridReader.h" +#include "DataStructureInitializer/GridReaderFiles/GridReader.h" #include "utilities/math/Math.h" @@ -270,365 +270,373 @@ void multipleLevel(const std::string& configPath) //gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_UNDER_TRIANGLE); auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // DrivAer - ////////////////////////////////////////////////////////////////////////// + SPtr<Parameter> para = Parameter::make(); + SPtr<GridProvider> gridGenerator; - real dx = 0.2; - real vx = 0.05; + if(false){ - TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_Fastback_Coarse.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_Coarse.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_NoSTLGroups.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_Fastback_Coarse_200k.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_NoSTLGroups.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_Coarse.stl"); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - real z0 = 0.318+0.5*dx; + ////////////////////////////////////////////////////////////////////////// + // DrivAer + ////////////////////////////////////////////////////////////////////////// - gridBuilder->addCoarseGrid(- 5.0, -5.0, 0.0 - z0, - 15.0, 5.0, 5.0 - z0, dx); // DrivAer - //gridBuilder->addGrid(new Cuboid(-1.5, -1.2, -1.5, 6.5, 1.5, 1.5), 2); - //gridBuilder->addGrid(triangularMesh, 3); // DrivAer + //real dx = 0.2; + //real vx = 0.05; - Object* floorBox = new Cuboid( -0.3, -1, -1, 4.0, 1, 0.2 ); - Object* wakeBox = new Cuboid( 3.5, -1, -1, 5.5, 1, 0.8 ); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_Fastback_Coarse.stl"); + ////TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_Coarse.stl"); + ////TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_NoSTLGroups.stl"); + ////TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DrivAer_Fastback_Coarse_200k.stl"); + ////TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_NoSTLGroups.stl"); + ////TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_Coarse.stl"); - Conglomerate* refRegion = new Conglomerate(); + // real z0 = 0.318+0.5*dx; - refRegion->add(floorBox); - refRegion->add(wakeBox); - refRegion->add(triangularMesh); + //gridBuilder->addCoarseGrid(- 5.0, -5.0, 0.0 - z0, + // 15.0, 5.0, 5.0 - z0, dx); // DrivAer + // //gridBuilder->addGrid(new Cuboid(-1.5, -1.2, -1.5, 6.5, 1.5, 1.5), 2); + // //gridBuilder->addGrid(triangularMesh, 3); // DrivAer - gridBuilder->setNumberOfLayers(15,8); - gridBuilder->addGrid(refRegion, 4); - - //gridBuilder->setNumberOfLayers(10,8); - //gridBuilder->addGrid(triangularMesh, 5); + // Object* floorBox = new Cuboid( -0.3, -1, -1, 4.0, 1, 0.2 ); + // Object* wakeBox = new Cuboid( 3.5, -1, -1, 5.5, 1, 0.8 ); - gridBuilder->addGeometry(triangularMesh); - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // DLC - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Conglomerate* refRegion = new Conglomerate(); - //real dx = 0.2; - //real vx = 0.02; + // refRegion->add(floorBox); + // refRegion->add(wakeBox); + // refRegion->add(triangularMesh); - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/VW370_SERIE_NO_GROUPS.stl"); - //gridBuilder->addCoarseGrid(-5, -5, -0.4, 15, 5, 5, dx); // DrivAer - // //gridBuilder->addGrid(new Cuboid(-1.5, -1.2, -1.5, 6.5, 1.5, 1.5), 2); - // //gridBuilder->addGrid(triangularMesh, 3); // DrivAer + // gridBuilder->setNumberOfLayers(15,8); + // gridBuilder->addGrid(refRegion, 4); + // + // //gridBuilder->setNumberOfLayers(10,8); + // //gridBuilder->addGrid(triangularMesh, 5); - // Object* floorBox = new Cuboid( -0.3, -1, -1, 4.0, 1, 0.2 ); - // Object* wakeBox = new Cuboid( 3.5, -1, -1, 5.5, 1, 0.8 ); + //gridBuilder->addGeometry(triangularMesh); - // Conglomerate* refRegion = new Conglomerate(); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // DLC + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // //refRegion->add(floorBox); - // //refRegion->add(wakeBox); - // //refRegion->add(triangularMesh); + //real dx = 0.2; + //real vx = 0.02; - // //gridBuilder->setNumberOfLayers(15,8); - // //gridBuilder->addGrid(refRegion, 2); - // - // gridBuilder->setNumberOfLayers(10,8); - // gridBuilder->addGrid(triangularMesh, 4); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/VW370_SERIE_NO_GROUPS.stl"); + //gridBuilder->addCoarseGrid(-5, -5, -0.4, 15, 5, 5, dx); // DrivAer + // //gridBuilder->addGrid(new Cuboid(-1.5, -1.2, -1.5, 6.5, 1.5, 1.5), 2); + // //gridBuilder->addGrid(triangularMesh, 3); // DrivAer - //gridBuilder->addGeometry(triangularMesh); + // Object* floorBox = new Cuboid( -0.3, -1, -1, 4.0, 1, 0.2 ); + // Object* wakeBox = new Cuboid( 3.5, -1, -1, 5.5, 1, 0.8 ); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Wall Mounted Cube - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Conglomerate* refRegion = new Conglomerate(); - // real dx = 0.2; - //real vx = 0.02; + // //refRegion->add(floorBox); + // //refRegion->add(wakeBox); + // //refRegion->add(triangularMesh); - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/Box_2.00.stl"); - //gridBuilder->addCoarseGrid(-5, -5, -1-dx/2.0, 15, 5, 5-dx/2.0, dx); - //gridBuilder->addGrid(new Cuboid(-3, -2, -2, 5, 2, 2), 1); - //gridBuilder->addGeometry(triangularMesh); + // //gridBuilder->setNumberOfLayers(15,8); + // //gridBuilder->addGrid(refRegion, 2); + // + // gridBuilder->setNumberOfLayers(10,8); + // gridBuilder->addGrid(triangularMesh, 4); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Testing layer refinement - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //gridBuilder->addGeometry(triangularMesh); - //real dx = 0.25; - //real vx = 0.02; + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Wall Mounted Cube + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/Box_2.00.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/STL_Group_Test.stl"); + // real dx = 0.2; + //real vx = 0.02; - //gridBuilder->addCoarseGrid(-6, -4, -4, - // 6, 12, 4, dx); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/Box_2.00.stl"); + //gridBuilder->addCoarseGrid(-5, -5, -1-dx/2.0, 15, 5, 5-dx/2.0, dx); + //gridBuilder->addGrid(new Cuboid(-3, -2, -2, 5, 2, 2), 1); + //gridBuilder->addGeometry(triangularMesh); - //gridBuilder->setNumberOfLayers(15, 8); // this must come before the grids are added!!! - // - //gridBuilder->addGrid(triangularMesh, 2); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Testing layer refinement + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //gridBuilder->addGeometry(triangularMesh); + real dx = 0.125; + real vx = 0.02; - //gridBuilder->addGrid( new Sphere( 0, 0, 0, 0.0005 ), 12 ); - //gridBuilder->addGrid( new Cuboid( -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 ), 3 ); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/Box_2.00.stl"); + TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/STL_Group_Test.stl"); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Testing NeedleCells - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + gridBuilder->addCoarseGrid(-4, -4, -4, + 12, 4, 4, dx); - //real dx = 0.005; - //real vx = 0.02; + gridBuilder->setNumberOfLayers(15, 8); // this must come before the grids are added!!! - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/NeedleCells2.stl"); - // - //gridBuilder->addCoarseGrid(-0.5, -0.2, -0.3, - // 1.0, 0.2, 0.3, dx); + gridBuilder->addGrid(triangularMesh, 2); - //gridBuilder->addGeometry( triangularMesh ); + //gridBuilder->addGrid( new Sphere( 0, 0, 0, 0.0005 ), 12 ); + //gridBuilder->addGrid( new Cuboid( -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 ), 3 ); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Testing Thin Wall - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + gridBuilder->addGeometry(triangularMesh); - //real dx = 0.0125; - //real vx = 0.05; + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Testing NeedleCells + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/ThinWallTest2.stl"); + //real dx = 0.005; + //real vx = 0.02; - //gridBuilder->addCoarseGrid(-2, -1.5, -0.5, 4, 1.5, 0.5, dx); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/NeedleCells2.stl"); + // + //gridBuilder->addCoarseGrid(-0.5, -0.2, -0.3, + // 1.0, 0.2, 0.3, dx); - //gridBuilder->addGeometry( triangularMesh ); + //gridBuilder->addGeometry( triangularMesh ); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Testing Thin Box - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Testing Thin Wall + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //real dx = 0.0125/4; - //real vx = 0.05; + //real dx = 0.0125; + //real vx = 0.05; - //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/ThinWallBox_rotated.stl"); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/ThinWallTest2.stl"); - //gridBuilder->addCoarseGrid(-0.4-0.5*dx, -0.4-0.5*dx, -0.4-0.5*dx, - // 1.0-0.5*dx, 0.4-0.5*dx, 0.4-0.5*dx, dx); + //gridBuilder->addCoarseGrid(-2, -1.5, -0.5, 4, 1.5, 0.5, dx); - //gridBuilder->addGeometry( triangularMesh ); + //gridBuilder->addGeometry( triangularMesh ); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Testing Paper Plane - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Testing Thin Box + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //real dx = 0.005; - //real vx = 0.05; + //real dx = 0.0125/4; + //real vx = 0.05; - //TriangularMesh* paperPlaneSTL = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/PaperPlane_1.stl"); + //TriangularMesh* triangularMesh = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/ThinWallBox_rotated.stl"); - //TriangularMesh* paperPlaneRefSTL = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/PaperPlane_1_ref.stl"); - // - //Object* wakeBox = new Cuboid( 0.3, -0.11, -0.06, 0.6, 0.11, -0.02 ); + //gridBuilder->addCoarseGrid(-0.4-0.5*dx, -0.4-0.5*dx, -0.4-0.5*dx, + // 1.0-0.5*dx, 0.4-0.5*dx, 0.4-0.5*dx, dx); - //Conglomerate* paperPlaneRefSTL_coarse = new Conglomerate(); - //paperPlaneRefSTL_coarse->add(wakeBox); - //paperPlaneRefSTL_coarse->add(paperPlaneRefSTL); + //gridBuilder->addGeometry( triangularMesh ); - //// x y z x y z - //gridBuilder->addCoarseGrid(-0.1, -0.2, -0.1, 1.0, 0.2, 0.1, dx); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Testing Paper Plane + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //gridBuilder->setNumberOfLayers(10,8); + //real dx = 0.005; + //real vx = 0.05; - //gridBuilder->addGrid(paperPlaneRefSTL_coarse, 2); + //TriangularMesh* paperPlaneSTL = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/PaperPlane_1.stl"); - //gridBuilder->setNumberOfLayers(2,8); + //TriangularMesh* paperPlaneRefSTL = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/PaperPlane_1_ref.stl"); + // + //Object* wakeBox = new Cuboid( 0.3, -0.11, -0.06, 0.6, 0.11, -0.02 ); - //gridBuilder->addGrid(paperPlaneRefSTL, 3); + //Conglomerate* paperPlaneRefSTL_coarse = new Conglomerate(); + //paperPlaneRefSTL_coarse->add(wakeBox); + //paperPlaneRefSTL_coarse->add(paperPlaneRefSTL); - //gridBuilder->addGeometry( paperPlaneSTL ); + //// x y z x y z + //gridBuilder->addCoarseGrid(-0.1, -0.2, -0.1, 1.0, 0.2, 0.1, dx); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // other tests - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //gridBuilder->setNumberOfLayers(10,8); - //TriangleOffsetSurfaceGeneration::createOffsetTriangularMesh(triangularMesh, 5); + //gridBuilder->addGrid(paperPlaneRefSTL_coarse, 2); - //TriangularMesh* sphere = TriangularMesh::make("D:/GRIDGENERATION/STL/GTI.stl", DiscretizationMethod::RAYCASTING); - //TransformatorImp trans(1.0, Vertex(5.5, 1, 12)); - //trans.transformWorldToGrid(*sphere); - //STLWriter::writeSTL(sphere->triangleVec, "D:/GRIDGENERATION/STL/GTI2.stl", false); + //gridBuilder->setNumberOfLayers(2,8); - //real size = 0.02; - //gridBuilder->addGrid(new Sphere( 0, 0, 0, 2.5), 1); - //gridBuilder->addGrid(new VerticalCylinder( 0, 0, 0, 3, 60), 2); - //gridBuilder->addGrid(new Sphere(0, 0, 19.5, 1), 6);//until level 7 works + //gridBuilder->addGrid(paperPlaneRefSTL, 3); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //gridBuilder->addGeometry( paperPlaneSTL ); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // other tests + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - gridBuilder->setPeriodicBoundaryCondition(false, false, false); + //TriangleOffsetSurfaceGeneration::createOffsetTriangularMesh(triangularMesh, 5); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + //TriangularMesh* sphere = TriangularMesh::make("D:/GRIDGENERATION/STL/GTI.stl", DiscretizationMethod::RAYCASTING); + //TransformatorImp trans(1.0, Vertex(5.5, 1, 12)); + //trans.transformWorldToGrid(*sphere); + //STLWriter::writeSTL(sphere->triangleVec, "D:/GRIDGENERATION/STL/GTI2.stl", false); + //real size = 0.02; + //gridBuilder->addGrid(new Sphere( 0, 0, 0, 2.5), 1); + //gridBuilder->addGrid(new VerticalCylinder( 0, 0, 0, 3, 60), 2); + //gridBuilder->addGrid(new Sphere(0, 0, 19.5, 1), 6);//until level 7 works - /////////////////////////////////////////////////////////////////////////// - //BCs - //gridBuilder->setVelocityBoundaryCondition(SideType::PX, 0.0, 0.0, 0.0); - //gridBuilder->setVelocityBoundaryCondition(SideType::MX, 0.0, 0.0, 0.0); - gridBuilder->setVelocityBoundaryCondition(SideType::PY, 0.0, vx, 0.0); - gridBuilder->setVelocityBoundaryCondition(SideType::MY, 0.0, vx, 0.0); - gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.0, vx, 0.0); - gridBuilder->setVelocityBoundaryCondition(SideType::MZ, 0.0, vx, 0.0); + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); - gridBuilder->setVelocityBoundaryCondition(SideType::MX, 0.0, vx , 0.0); - //////////////////////////////////////////////////////////////////////////// + gridBuilder->setPeriodicBoundaryCondition(false, false, false); - //gridBuilder->setNoSlipBoundaryCondition(SideType::MY); - //gridBuilder->setNoSlipBoundaryCondition(SideType::PY); - // gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); - // gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! - gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); + /////////////////////////////////////////////////////////////////////////// + //BCs + //gridBuilder->setVelocityBoundaryCondition(SideType::PX, 0.0, 0.0, 0.0); + //gridBuilder->setVelocityBoundaryCondition(SideType::MX, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PY, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::MY, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.0, 0.0, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::MZ, 0.0, 0.0, 0.0); - { - //gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setVelocityForPatch(0, vx, 0.0, 0.0); + gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0); + gridBuilder->setVelocityBoundaryCondition(SideType::MX, vx, 0.0, 0.0); - SPtr<Grid> grid = gridBuilder->getGrid(gridBuilder->getNumberOfLevels() - 1); + //////////////////////////////////////////////////////////////////////////// - // Walze: - //gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setTangentialVelocityForPatch( grid, 1, 0.0, -1.0, 0.0, - // 0.0, 1.0, 0.0, -5.0 * vx, 1.0); + //gridBuilder->setNoSlipBoundaryCondition(SideType::MY); + //gridBuilder->setNoSlipBoundaryCondition(SideType::PY); + // gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + // gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); - // DrivAer - gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setTangentialVelocityForPatch( grid, 4, 0.0075, -2.0, 0.0, - 0.0075, 2.0, 0.0, -vx, 0.318); - gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setTangentialVelocityForPatch( grid, 3, 2.793 , -2.0, 0.0, - 2.793 , 2.0, 0.0, -vx, 0.318); - } - //gridBuilder->setVelocityBoundaryCondition(SideType::PX, 0.001, 0.0, 0.0); - //gridBuilder->setVelocityBoundaryCondition(SideType::MY, 0.001, 0.0, 0.0); - //gridBuilder->setVelocityBoundaryCondition(SideType::PY, 0.001, 0.0, 0.0); - //gridBuilder->setVelocityBoundaryCondition(SideType::MZ, 0.001, 0.0, 0.0); - //gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.001, 0.0, 0.0); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); - //gridBuilder->writeGridsToVtk("M:/TestGridGeneration/results/ConcaveTest_"); - gridBuilder->writeGridsToVtk("C:/Users/lenz/Desktop/Work/gridGenerator/out/Test_"); + { + //gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setVelocityForPatch(0, vx, 0.0, 0.0); - //gridBuilder->writeGridsToVtk("M:/TestGridGeneration/results/CylinderTest_"); - gridBuilder->writeArrows ("C:/Users/lenz/Desktop/Work/gridGenerator/out/Test_Arrow"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + SPtr<Grid> grid = gridBuilder->getGrid(gridBuilder->getNumberOfLevels() - 1); + // Walze: + //gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setTangentialVelocityForPatch(grid, 1, 0.0, -1.0, 0.0, + // 0.0, 1.0, 0.0, -5.0 * vx, 1.0); - //{ - // SPtr<Grid> grid = gridBuilder->getGrid(2); + // DrivAer + //gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setTangentialVelocityForPatch( grid, 4, 0.0075, -2.0, 0.0, + // 0.0075, 2.0, 0.0, -vx, 0.318); + //gridBuilder->getGeometryBoundaryCondition(gridBuilder->getNumberOfLevels() - 1)->setTangentialVelocityForPatch( grid, 3, 2.793 , -2.0, 0.0, + // 2.793 , 2.0, 0.0, -vx, 0.318); + } - // uint counter = 0; - // for (uint gridIdx = 0; gridIdx < grid->getSize(); gridIdx++) { + //gridBuilder->setVelocityBoundaryCondition(SideType::PX, 0.001, 0.0, 0.0); + //gridBuilder->setVelocityBoundaryCondition(SideType::MY, 0.001, 0.0, 0.0); + //gridBuilder->setVelocityBoundaryCondition(SideType::PY, 0.001, 0.0, 0.0); + //gridBuilder->setVelocityBoundaryCondition(SideType::MZ, 0.001, 0.0, 0.0); + //gridBuilder->setVelocityBoundaryCondition(SideType::PZ, 0.001, 0.0, 0.0); - // if (grid->getFieldEntry(gridIdx) == BC_GEOMETRY) { - // real x, y, z; - // grid->transIndexToCoords(gridIdx, x, y, z); - // if (fabs(z) > dx) continue; - // std::cout << x << " " << y << " " << z << std::endl; - // for (uint fIdx = 0; fIdx < 27; fIdx++) { - // if (!vf::Math::equal(grid->getDistribution()[fIdx * grid->getSize() + gridIdx], 0.0)) { - // std::cout << fIdx << "\t" << grid->getDistribution()[fIdx * grid->getSize() + gridIdx] << std::endl; - // } - // } - // counter++; - // if (counter > 10) break; - // } - // } - //} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //debug information - //{ - // uint level = 0; + //gridBuilder->writeGridsToVtk("M:/TestGridGeneration/results/ConcaveTest_"); + gridBuilder->writeGridsToVtk("C:/Users/lenz/Desktop/Work/gridGenerator/out/Test_"); - // SPtr<Grid> grid = gridBuilder->getGrid(level); + //gridBuilder->writeGridsToVtk("M:/TestGridGeneration/results/CylinderTest_"); + gridBuilder->writeArrows("C:/Users/lenz/Desktop/Work/gridGenerator/out/Test_Arrow"); - // real* xCoords = new real [ grid->getSparseSize() ]; - // real* yCoords = new real [ grid->getSparseSize() ]; - // real* zCoords = new real [ grid->getSparseSize() ]; - // uint* xNeighbor = new uint [ grid->getSparseSize() ]; - // uint* yNeighbor = new uint [ grid->getSparseSize() ]; - // uint* zNeighbor = new uint [ grid->getSparseSize() ]; - // uint* geo = new uint [ grid->getSparseSize() ]; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // gridBuilder->getNodeValues(xCoords, yCoords, zCoords, xNeighbor, yNeighbor, zNeighbor, geo, level); - // uint counter = 0; - // for (uint gridIdx = 0; gridIdx < grid->getSize(); gridIdx++) { + //{ + // SPtr<Grid> grid = gridBuilder->getGrid(2); + + // uint counter = 0; + // for (uint gridIdx = 0; gridIdx < grid->getSize(); gridIdx++) { + + // if (grid->getFieldEntry(gridIdx) == BC_GEOMETRY) { + // real x, y, z; + // grid->transIndexToCoords(gridIdx, x, y, z); + // if (fabs(z) > dx) continue; + // std::cout << x << " " << y << " " << z << std::endl; + // for (uint fIdx = 0; fIdx < 27; fIdx++) { + // if (!vf::Math::equal(grid->getDistribution()[fIdx * grid->getSize() + gridIdx], 0.0)) { + // std::cout << fIdx << "\t" << grid->getDistribution()[fIdx * grid->getSize() + gridIdx] << std::endl; + // } + // } + // counter++; + // if (counter > 10) break; + // } + // } + //} - // //////////////////////////////////////////////////////////////////////////// - // if (grid->getFieldEntry(gridIdx) != FLUID_CFC) continue; + //debug information + //{ + // uint level = 0; - // real x, y, z; - // grid->transIndexToCoords(gridIdx, x, y, z); - // - // if(level == 0) if ( !vf::Math::equal(y, 4.5 ) && !vf::Math::equal(y, -4.5)) continue; - // if(level == 1) if ( !vf::Math::equal(y, 4.625 ) ) continue; - // if(level == 2) if ( !vf::Math::equal(y, 4.8125/*4.6875*/) ) continue; + // SPtr<Grid> grid = gridBuilder->getGrid(level); - // if( grid->getSparseIndex( gridIdx ) == -1 ) continue; + // real* xCoords = new real [ grid->getSparseSize() ]; + // real* yCoords = new real [ grid->getSparseSize() ]; + // real* zCoords = new real [ grid->getSparseSize() ]; + // uint* xNeighbor = new uint [ grid->getSparseSize() ]; + // uint* yNeighbor = new uint [ grid->getSparseSize() ]; + // uint* zNeighbor = new uint [ grid->getSparseSize() ]; + // uint* geo = new uint [ grid->getSparseSize() ]; - // std::cout << int( grid->getFieldEntry(gridIdx) ) << " "; + // gridBuilder->getNodeValues(xCoords, yCoords, zCoords, xNeighbor, yNeighbor, zNeighbor, geo, level); - // std::cout << grid->getSparseIndex( gridIdx ) << " (" << x << " " << y << " " << z << ") --> "; + // uint counter = 0; + // for (uint gridIdx = 0; gridIdx < grid->getSize(); gridIdx++) { - // uint neighborIndex = grid->getNeighborsZ()[ gridIdx ]; + // //////////////////////////////////////////////////////////////////////////// + // if (grid->getFieldEntry(gridIdx) != FLUID_CFC) continue; - // std::cout << neighborIndex << " (" << xCoords[neighborIndex + 1] << " " - // << yCoords[neighborIndex + 1] << " " - // << zCoords[neighborIndex + 1] << ")" << std::endl; + // real x, y, z; + // grid->transIndexToCoords(gridIdx, x, y, z); + // + // if(level == 0) if ( !vf::Math::equal(y, 4.5 ) && !vf::Math::equal(y, -4.5)) continue; + // if(level == 1) if ( !vf::Math::equal(y, 4.625 ) ) continue; + // if(level == 2) if ( !vf::Math::equal(y, 4.8125/*4.6875*/) ) continue; - // counter++; - // ////if (counter > 1000) break; - // ////////////////////////////////////////////////////////////////////////////// - // //real x, y, z; - // //grid->transIndexToCoords(gridIdx, x, y, z); + // if( grid->getSparseIndex( gridIdx ) == -1 ) continue; - // ////one interesting stopper node - // //int stopperOfInterest = 17528; - // //if ((grid->getNeighborsX()[gridIdx] == stopperOfInterest) || - // // (grid->getNeighborsY()[gridIdx] == stopperOfInterest) || - // // (grid->getNeighborsZ()[gridIdx] == stopperOfInterest)) - // //{ - // // std::cout << int(grid->getFieldEntry(gridIdx)) << " "; + // std::cout << int( grid->getFieldEntry(gridIdx) ) << " "; - // // std::cout << grid->getSparseIndex(gridIdx) << " (" << x << " " << y << " " << z << ") --> "; + // std::cout << grid->getSparseIndex( gridIdx ) << " (" << x << " " << y << " " << z << ") --> "; + // uint neighborIndex = grid->getNeighborsZ()[ gridIdx ]; - // // std::cout << stopperOfInterest << " (" << xCoords[stopperOfInterest + 1] << " " - // // << yCoords[stopperOfInterest + 1] << " " - // // << zCoords[stopperOfInterest + 1] << ")" << std::endl; - // //} + // std::cout << neighborIndex << " (" << xCoords[neighborIndex + 1] << " " + // << yCoords[neighborIndex + 1] << " " + // << zCoords[neighborIndex + 1] << ")" << std::endl; - // //////////////////////////////////////////////////////////////////////////// - // } - //} + // counter++; + // ////if (counter > 1000) break; + // ////////////////////////////////////////////////////////////////////////////// + // //real x, y, z; + // //grid->transIndexToCoords(gridIdx, x, y, z); - //SimulationFileWriter::write("D:/GRIDGENERATION/files/", gridBuilder, FILEFORMAT::ASCII); - //SimulationFileWriter::write("C:/Users/lenz/Desktop/Work/gridGenerator/grid/", gridBuilder, FILEFORMAT::ASCII); + // ////one interesting stopper node + // //int stopperOfInterest = 17528; + // //if ((grid->getNeighborsX()[gridIdx] == stopperOfInterest) || + // // (grid->getNeighborsY()[gridIdx] == stopperOfInterest) || + // // (grid->getNeighborsZ()[gridIdx] == stopperOfInterest)) + // //{ + // // std::cout << int(grid->getFieldEntry(gridIdx)) << " "; - //return; + // // std::cout << grid->getSparseIndex(gridIdx) << " (" << x << " " << y << " " << z << ") --> "; + + + // // std::cout << stopperOfInterest << " (" << xCoords[stopperOfInterest + 1] << " " + // // << yCoords[stopperOfInterest + 1] << " " + // // << zCoords[stopperOfInterest + 1] << ")" << std::endl; + // //} + + // //////////////////////////////////////////////////////////////////////////// + // } + //} + + //SimulationFileWriter::write("D:/GRIDGENERATION/files/", gridBuilder, FILEFORMAT::ASCII); + SimulationFileWriter::write("C:/Users/lenz/Desktop/Work/gridGenerator/grid/", gridBuilder, FILEFORMAT::ASCII); + + gridGenerator = GridGenerator::make(gridBuilder, para); + } + else + { + //gridGenerator = GridReader::make(FileFormat::BINARY, para); + gridGenerator = GridReader::make(FileFormat::ASCII, para); + } - SPtr<Parameter> para = Parameter::make(); - SPtr<GridProvider> gridGenerator = GridGenerator::make(gridBuilder, para); - //SPtr<GridProvider> gridGenerator = GridReader::make(FileFormat::BINARY, para); std::ifstream stream; stream.open(configPath.c_str(), std::ios::in); @@ -679,17 +687,24 @@ int main( int argc, char* argv[]) catch (const std::exception e) { - *logging::out << logging::Logger::ERROR << e.what(); + *logging::out << logging::Logger::ERROR << e.what() << '\n'; + //std::cout << e.what() << std::flush; + //MPI_Abort(MPI_COMM_WORLD, -1); + } + catch (const std::bad_alloc e) + { + + *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << '\n'; //std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::ERROR << "Unknown exception!"; + *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; //std::cout << "unknown exeption" << std::endl; } - std::cout << "Configuration file must be set!: lbmgm <config file>" << std::endl << std::flush; + std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } } -- GitLab