diff --git a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h index 7626a9492703f4796527e621dfa1deed2424b58b..c4f9afac77d78a8d4242b7258bcf932d08b07ec3 100644 --- a/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h +++ b/src/gpu/GridGenerator/grid/BoundaryConditions/BoundaryCondition.h @@ -46,7 +46,6 @@ enum class SideType; namespace gg { - class BoundaryCondition { public: @@ -98,6 +97,45 @@ public: ////////////////////////////////////////////////////////////////////////// +class SlipBoundaryCondition : public gg::BoundaryCondition +{ +public: + static SPtr<SlipBoundaryCondition> make(real normalX, real normalY, real normalZ) + { + return SPtr<SlipBoundaryCondition>(new SlipBoundaryCondition(normalX, normalY, normalZ)); + } + + real normalX, normalY, normalZ; + std::vector<real> normalXList, normalYList, normalZList; +protected: + SlipBoundaryCondition(real normalX, real normalY, real normalZ) : normalX(normalX), normalY(normalY), normalZ(normalZ) { } + +public: + virtual char getType() const override + { + return BC_SLIP; + } + + void fillSlipNormalLists() + { + for (uint index : this->indices) { + this->normalXList.push_back(normalX); + this->normalYList.push_back(normalY); + this->normalZList.push_back(normalZ); + } + } + + real getNormalx() { return this->normalX; } + real getNormaly() { return this->normalY; } + real getNormalz() { return this->normalZ; } + + real getNormalx(uint index) { return this->normalXList[index]; } + real getNormaly(uint index) { return this->normalYList[index]; } + real getNormalz(uint index) { return this->normalZList[index]; } +}; + +////////////////////////////////////////////////////////////////////////// + class VelocityBoundaryCondition : public gg ::BoundaryCondition { public: diff --git a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h index f398e89a0936e0e03261c7b75f22e7311d96e161..63ea9b188cc5559e55cf7e7bddb611e6672004dd 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h @@ -92,6 +92,10 @@ public: virtual void getOffsetFC(real* xOffCf, real* yOffCf, real* zOffCf, int level) = 0; virtual void getOffsetCF(real* xOffFc, real* yOffFc, real* zOffFc, int level) = 0; + virtual uint getSlipSize(int level) const = 0; + virtual void getSlipValues(real *normalX, real *normalY, real *normalZ, int *indices, int level) const = 0; + virtual void getSlipQs(real* qs[27], int level) const = 0; + virtual uint getVelocitySize(int level) const = 0; virtual void getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const = 0; virtual void getVelocityQs(real* qs[27], int level) const = 0; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index 552c2578585b86fadf98ea0b8505b81fbd7475ff..8911bcf67b3988c4cfe9bfc846b8c2030cfef496 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -57,6 +57,22 @@ std::shared_ptr<LevelGridBuilder> LevelGridBuilder::makeShared(Device device, co return SPtr<LevelGridBuilder>(new LevelGridBuilder(device, d3qxx)); } +void LevelGridBuilder::setSlipBoundaryCondition(SideType sideType, real nomalX, real normalY, real normalZ) +{ + SPtr<SlipBoundaryCondition> slipBoundaryCondition = SlipBoundaryCondition::make(nomalX, normalY, normalZ); + + auto side = SideFactory::make(sideType); + + slipBoundaryCondition->side = side; + slipBoundaryCondition->side->addIndices(grids, 0, slipBoundaryCondition); + + slipBoundaryCondition->fillSlipNormalLists(); + + boundaryConditions[0]->slipBoundaryConditions.push_back(slipBoundaryCondition); + + *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Slip BC on level " << 0 << " with " << (int)slipBoundaryCondition->indices.size() << "\n"; +} + void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz) { SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz); @@ -185,6 +201,49 @@ void LevelGridBuilder::getNodeValues(real *xCoords, real *yCoords, real *zCoords } +uint LevelGridBuilder::getSlipSize(int level) const +{ + uint size = 0; + for (auto boundaryCondition : boundaryConditions[level]->slipBoundaryConditions) + { + size += uint(boundaryCondition->indices.size()); + } + return size; +} + +void LevelGridBuilder::getSlipValues(real* normalX, real* normalY, real* normalZ, int* indices, int level) const +{ + int allIndicesCounter = 0; + for (auto boundaryCondition : boundaryConditions[level]->slipBoundaryConditions) + { + for (int i = 0; i < boundaryCondition->indices.size(); i++) + { + indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1; + + normalX[allIndicesCounter] = boundaryCondition->getNormalx(i); + normalY[allIndicesCounter] = boundaryCondition->getNormaly(i); + normalZ[allIndicesCounter] = boundaryCondition->getNormalz(i); + allIndicesCounter++; + } + } +} + +void LevelGridBuilder::getSlipQs(real* qs[27], int level) const +{ + int allIndicesCounter = 0; + for (auto boundaryCondition : boundaryConditions[level]->slipBoundaryConditions) + { + for (uint index = 0; index < boundaryCondition->indices.size(); index++) + { + for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) + { + qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir]; + } + allIndicesCounter++; + } + } +} + uint LevelGridBuilder::getVelocitySize(int level) const { uint size = 0; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h index 44af40b0a1d2e7575663d202788c7e760b83fe9e..8e0f79a7aa833af59b0eb5e74a70aaaefdd5a7aa 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h @@ -52,6 +52,7 @@ enum class Device; class Side; class VelocityBoundaryCondition; +class SlipBoundaryCondition; enum class SideType; @@ -68,6 +69,7 @@ public: GRIDGENERATOR_EXPORT virtual ~LevelGridBuilder(); + GRIDGENERATOR_EXPORT void setSlipBoundaryCondition(SideType sideType, real nomalX, real normalY, real normalZ); GRIDGENERATOR_EXPORT void setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz); GRIDGENERATOR_EXPORT void setPeriodicBoundaryCondition(bool periodic_X, bool periodic_Y, bool periodic_Z); GRIDGENERATOR_EXPORT void setNoSlipBoundaryCondition(SideType sideType); @@ -83,6 +85,10 @@ public: GRIDGENERATOR_EXPORT virtual void getDimensions(int &nx, int &ny, int &nz, const int level) const override; + GRIDGENERATOR_EXPORT uint getSlipSize(int level) const override; + GRIDGENERATOR_EXPORT virtual void getSlipValues(real* normalX, real* normalY, real* normalZ, int* indices, int level) const override; + GRIDGENERATOR_EXPORT virtual void getSlipQs(real* qs[27], int level) const override; + GRIDGENERATOR_EXPORT uint getVelocitySize(int level) const override; GRIDGENERATOR_EXPORT virtual void getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const override; GRIDGENERATOR_EXPORT virtual void getVelocityQs(real* qs[27], int level) const override; @@ -96,7 +102,9 @@ protected: { BoundaryConditions() {} - std::vector<SPtr<VelocityBoundaryCondition> > velocityBoundaryConditions; + std::vector<SPtr<SlipBoundaryCondition>> slipBoundaryConditions; + + std::vector<SPtr<VelocityBoundaryCondition>> velocityBoundaryConditions; std::vector<SPtr<VelocityBoundaryCondition> > noSlipBoundaryConditions; };