Skip to content
Snippets Groups Projects
Commit 637fd38c authored by schoen's avatar schoen
Browse files

added infrastructure for slip BC

parent 9a969a68
No related branches found
No related tags found
1 merge request!51Open source
...@@ -46,7 +46,6 @@ enum class SideType; ...@@ -46,7 +46,6 @@ enum class SideType;
namespace gg namespace gg
{ {
class BoundaryCondition class BoundaryCondition
{ {
public: public:
...@@ -98,6 +97,45 @@ 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 class VelocityBoundaryCondition : public gg ::BoundaryCondition
{ {
public: public:
......
...@@ -92,6 +92,10 @@ public: ...@@ -92,6 +92,10 @@ public:
virtual void getOffsetFC(real* xOffCf, real* yOffCf, real* zOffCf, int level) = 0; 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 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 uint getVelocitySize(int level) const = 0;
virtual void getVelocityValues(real* vx, real* vy, real* vz, int* indices, 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; virtual void getVelocityQs(real* qs[27], int level) const = 0;
......
...@@ -57,6 +57,22 @@ std::shared_ptr<LevelGridBuilder> LevelGridBuilder::makeShared(Device device, co ...@@ -57,6 +57,22 @@ std::shared_ptr<LevelGridBuilder> LevelGridBuilder::makeShared(Device device, co
return SPtr<LevelGridBuilder>(new LevelGridBuilder(device, d3qxx)); 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) void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz)
{ {
SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz); SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz);
...@@ -185,6 +201,49 @@ void LevelGridBuilder::getNodeValues(real *xCoords, real *yCoords, real *zCoords ...@@ -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 LevelGridBuilder::getVelocitySize(int level) const
{ {
uint size = 0; uint size = 0;
......
...@@ -52,6 +52,7 @@ enum class Device; ...@@ -52,6 +52,7 @@ enum class Device;
class Side; class Side;
class VelocityBoundaryCondition; class VelocityBoundaryCondition;
class SlipBoundaryCondition;
enum class SideType; enum class SideType;
...@@ -68,6 +69,7 @@ public: ...@@ -68,6 +69,7 @@ public:
GRIDGENERATOR_EXPORT virtual ~LevelGridBuilder(); 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 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 setPeriodicBoundaryCondition(bool periodic_X, bool periodic_Y, bool periodic_Z);
GRIDGENERATOR_EXPORT void setNoSlipBoundaryCondition(SideType sideType); GRIDGENERATOR_EXPORT void setNoSlipBoundaryCondition(SideType sideType);
...@@ -83,6 +85,10 @@ public: ...@@ -83,6 +85,10 @@ public:
GRIDGENERATOR_EXPORT virtual void getDimensions(int &nx, int &ny, int &nz, const int level) const override; 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 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 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; GRIDGENERATOR_EXPORT virtual void getVelocityQs(real* qs[27], int level) const override;
...@@ -96,7 +102,9 @@ protected: ...@@ -96,7 +102,9 @@ protected:
{ {
BoundaryConditions() {} BoundaryConditions() {}
std::vector<SPtr<VelocityBoundaryCondition> > velocityBoundaryConditions; std::vector<SPtr<SlipBoundaryCondition>> slipBoundaryConditions;
std::vector<SPtr<VelocityBoundaryCondition>> velocityBoundaryConditions;
std::vector<SPtr<VelocityBoundaryCondition> > noSlipBoundaryConditions; std::vector<SPtr<VelocityBoundaryCondition> > noSlipBoundaryConditions;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment