diff --git a/src/GridGenerator/grid/BoundaryConditions/Side.cpp b/src/GridGenerator/grid/BoundaryConditions/Side.cpp index d69cf285fcfdb5c2740d43dc1780d5636961d758..ec9053f5666e4705063ec5e20d7e03895314d8c5 100644 --- a/src/GridGenerator/grid/BoundaryConditions/Side.cpp +++ b/src/GridGenerator/grid/BoundaryConditions/Side.cpp @@ -105,7 +105,10 @@ void MX::addIndices(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition) real startOuter = grid->getStartZ(); real endOuter = grid->getEndZ(); - Side::addIndices(grid, boundaryCondition, "x", grid->getStartX() + grid->getDelta(), startInner, + real coords[3] = { grid->getStartX(), grid->getStartY() + (grid->getEndY() - grid->getStartY()) / 2.0, grid->getStartZ() + (grid->getEndZ() - grid->getStartZ()) / 2.0 }; + real startCoord = grid->getFirstFluidNode(coords, 0, grid->getStartX()); + + Side::addIndices(grid, boundaryCondition, "x", startCoord, startInner, endInner, startOuter, endOuter); } @@ -119,7 +122,10 @@ void PX::addIndices(SPtr<Grid> grid, SPtr<BoundaryCondition> boundaryCondition) real startOuter = grid->getStartZ(); real endOuter = grid->getEndZ(); - Side::addIndices(grid, boundaryCondition, "x", grid->getEndX() - grid->getDelta(), startInner, + real coords[3] = { grid->getEndX(), grid->getStartY() + (grid->getEndY() - grid->getStartY()) / 2.0, grid->getStartZ() + (grid->getEndZ() - grid->getStartZ()) / 2.0 }; + real startCoord = grid->getLastFluidNode(coords, 0, grid->getEndX()); + + Side::addIndices(grid, boundaryCondition, "x", startCoord, startInner, endInner, startOuter, endOuter); } diff --git a/src/GridGenerator/grid/Field.cu b/src/GridGenerator/grid/Field.cu index d03b51954ee88aa9e45f525a302f065ec7266c93..05949cef4571d28153a34dfa01dc53fb55d5d226 100644 --- a/src/GridGenerator/grid/Field.cu +++ b/src/GridGenerator/grid/Field.cu @@ -63,7 +63,7 @@ HOSTDEVICE bool Field::isFineToCoarseNode(uint index) const HOSTDEVICE bool Field::isFluid(uint index) const { const char type = field[index]; - return type == FLUID || type == FLUID_CFC || type == FLUID_CFF || type == FLUID_FCC || type == FLUID_FCF || type == Q; + return type == FLUID || type == FLUID_CFC || type == FLUID_CFF || type == FLUID_FCC || type == FLUID_FCF || isRb(index); } HOSTDEVICE bool Field::isSolid(uint index) const @@ -103,7 +103,7 @@ HOSTDEVICE bool Field::isQ(uint index) const HOSTDEVICE bool Field::isRb(uint index) const { - return field[index] == SOLID; + return field[index] == BC_GEOMETRY || field[index] == BC_OUTFLOW || field[index] == BC_VELOCITY || field[index] == BC_PRESSURE || field[index] == BC_SLIP; } // --------------------------------------------------------- // diff --git a/src/GridGenerator/grid/Grid.h b/src/GridGenerator/grid/Grid.h index cd71e64e65c026ecad1d5608b890356052e663eb..7ac05f91159327f287ac2786a76c49e843e48d90 100644 --- a/src/GridGenerator/grid/Grid.h +++ b/src/GridGenerator/grid/Grid.h @@ -85,7 +85,8 @@ public: HOST virtual void findSparseIndices(SPtr<Grid> fineGrid) = 0; - + HOSTDEVICE virtual real getFirstFluidNode(real coords[3], int direction, real startCoord) const = 0; + HOSTDEVICE virtual real getLastFluidNode(real coords[3], int direction, real startCoord) const = 0; }; #endif diff --git a/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index b0a3fb184a42ccaa6b0cb2faff2c42344f01c065..d8d164ed9d9c0e3a5b919ac588d682740a874086 100644 --- a/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -62,14 +62,15 @@ void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, setVelocityGeometryBoundaryCondition(vx, vy, vz); else { - SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz); auto side = SideFactory::make(sideType); velocityBoundaryConditions.push_back(velocityBoundaryCondition); velocityBoundaryCondition->side = side; + velocityBoundaryCondition->side->addIndices(grids[0], velocityBoundaryCondition); } + } void LevelGridBuilder::setVelocityGeometryBoundaryCondition(real vx, real vy, real vz) @@ -78,6 +79,7 @@ void LevelGridBuilder::setVelocityGeometryBoundaryCondition(real vx, real vy, re geometryBoundaryCondition->vx = vx; geometryBoundaryCondition->vy = vy; geometryBoundaryCondition->vz = vz; + geometryBoundaryCondition->side->addIndices(grids[0], geometryBoundaryCondition); } void LevelGridBuilder::setPressureBoundaryCondition(SideType sideType, real rho) @@ -88,6 +90,7 @@ void LevelGridBuilder::setPressureBoundaryCondition(SideType sideType, real rho) pressureBoundaryConditions.push_back(pressureBoundaryCondition); pressureBoundaryCondition->side = side; + pressureBoundaryCondition->side->addIndices(grids[0], pressureBoundaryCondition); } void LevelGridBuilder::setPeriodicBoundaryCondition(bool periodic_X, bool periodic_Y, bool periodic_Z) @@ -103,6 +106,8 @@ void LevelGridBuilder::setNoSlipBoundaryCondition(SideType sideType) noSlipBoundaryConditions.push_back(noSlipBoundaryCondition); noSlipBoundaryCondition->side = side; + noSlipBoundaryCondition->side->addIndices(grids[0], noSlipBoundaryCondition); + } diff --git a/src/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp b/src/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp index 0034b71fec368e98655b128ac6095159c12c464f..51fefe703d15f87fc5297ad0aeca0f494b1ed4e2 100644 --- a/src/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp +++ b/src/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp @@ -271,23 +271,23 @@ void MultipleGridBuilder::buildGrids() - for(auto velocityBC : velocityBoundaryConditions) - { - velocityBC->side->addIndices(grids[0], velocityBC); - } - - for (auto pressureBC : pressureBoundaryConditions) - { - pressureBC->side->addIndices(grids[0], pressureBC); - } - - for (auto noSlipBC : noSlipBoundaryConditions) - { - noSlipBC->side->addIndices(grids[0], noSlipBC); - } - - if(geometryBoundaryCondition) - geometryBoundaryCondition->side->addIndices(grids[0], geometryBoundaryCondition); + //for(auto velocityBC : velocityBoundaryConditions) + //{ + // velocityBC->side->addIndices(grids[0], velocityBC); + //} + + //for (auto pressureBC : pressureBoundaryConditions) + //{ + // pressureBC->side->addIndices(grids[0], pressureBC); + //} + + //for (auto noSlipBC : noSlipBoundaryConditions) + //{ + // noSlipBC->side->addIndices(grids[0], noSlipBC); + //} + + //if(geometryBoundaryCondition) + // geometryBoundaryCondition->side->addIndices(grids[0], geometryBoundaryCondition); } diff --git a/src/GridGenerator/grid/GridImp.cu b/src/GridGenerator/grid/GridImp.cu index 43f600853d8e55a14b171b545a21181ddbedbfba..c44b21000cff88a54ba68b9b8e4e5b525f0b3d33 100644 --- a/src/GridGenerator/grid/GridImp.cu +++ b/src/GridGenerator/grid/GridImp.cu @@ -501,6 +501,19 @@ HOSTDEVICE real GridImp::getNeighborCoord(bool periodicity, real startCoord, rea return coords[direction] + delta; } + +HOSTDEVICE real GridImp::getLastFluidNode(real coords[3], int direction, real startCoord) const +{ + coords[direction] = startCoord; + int index = this->transCoordToIndex(coords[0], coords[1], coords[2]); + while (!field.isFluid(index)) + { + coords[direction] -= delta; + index = this->transCoordToIndex(coords[0], coords[1], coords[2]); + } + return coords[direction]; +} + HOSTDEVICE real GridImp::getFirstFluidNode(real coords[3], int direction, real startCoord) const { coords[direction] = startCoord; diff --git a/src/GridGenerator/grid/GridImp.h b/src/GridGenerator/grid/GridImp.h index dee4aeccc42b62366f0381585500a952a515b222..411886e3b7025dc455dbb92b402a072576f7cfe7 100644 --- a/src/GridGenerator/grid/GridImp.h +++ b/src/GridGenerator/grid/GridImp.h @@ -159,12 +159,14 @@ public: HOST void updateSparseIndices(); HOSTDEVICE void setNeighborIndices(uint index); - + HOSTDEVICE real getFirstFluidNode(real coords[3], int direction, real startCoord) const; + HOSTDEVICE real getLastFluidNode(real coords[3], int direction, real startCoord) const; private: HOSTDEVICE void setStopperNeighborCoords(uint index); HOSTDEVICE void getNeighborCoords(real &neighborX, real &neighborY, real &neighborZ, real x, real y, real z) const; HOSTDEVICE real getNeighborCoord(bool periodicity, real endCoord, real coords[3], int direction) const; - HOSTDEVICE real getFirstFluidNode(real coords[3], int direction, real startCoord) const; + + HOSTDEVICE int getSparseIndex(const real &expectedX, const real &expectedY, const real &expectedZ) const; HOSTDEVICE static real getMinimumOnNodes(const real& minExact, const real& decimalStart, const real& delta); diff --git a/src/GridGenerator/grid/GridMocks.h b/src/GridGenerator/grid/GridMocks.h index 07e1cc6c6b822b0d9278eaa60b948e0d25404b43..0229958add6f2300548a4c031228ee9b55e9e40d 100644 --- a/src/GridGenerator/grid/GridMocks.h +++ b/src/GridGenerator/grid/GridMocks.h @@ -72,6 +72,8 @@ public: void setPeriodicityZ(bool periodicity) override {} void findQs(Object* object) override {} void setFieldEntry(uint matrixIndex, char type) override {} + real getFirstFluidNode(real coords[3], int direction, real startCoord) const override { return 0.0; } + real getLastFluidNode(real coords[3], int direction, real startCoord) const override { return 0.0; } }; class GridStub : public GridDummy diff --git a/targets/apps/HULC/main.cpp b/targets/apps/HULC/main.cpp index 3ca046c6226473485855b06501366ee3c6895f4f..5cc779f5e70398c01ab4724d47ebbaaaa6e87c2e 100644 --- a/targets/apps/HULC/main.cpp +++ b/targets/apps/HULC/main.cpp @@ -281,6 +281,10 @@ void multipleLevel(const std::string& configPath) gridBuilder->addGeometry(triangularMesh); + + gridBuilder->buildGrids(); // buildGrids() has to be called before setting the BCs!!!! + + gridBuilder->setVelocityBoundaryCondition(SideType::MX, 0.001, 0.0, 0.0); gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.001); @@ -319,11 +323,10 @@ void multipleLevel(const std::string& configPath) //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_2", 2); - gridBuilder->buildGrids(); //SimulationFileWriter::write("D:/GRIDGENERATION/files/", gridBuilder, FILEFORMAT::ASCII); - //gridBuilder->writeGridsToVtk("D:/GRIDGENERATION/"); - //gridBuilder->writeArrows("D:/arrows"); + gridBuilder->writeGridsToVtk("D:/GRIDGENERATION/"); + gridBuilder->writeArrows("D:/arrows"); SPtr<Parameter> para = Parameter::make();