Skip to content
Snippets Groups Projects
Commit 811e344b authored by TESLA03\Master's avatar TESLA03\Master
Browse files

Fix BoundaryQs for velocity

before only one channel side could have a velocity boundary condition (bc). When setting a bc at a second side, the first bc was overwritten.
Velocity bcs were fied in the previous commit (bda2c544271657adfabb63e9ae974e77692566a6). This commit fixes the boundaryQs for velocity.
parent daa787a3
No related branches found
No related tags found
1 merge request!104Add Communication Hiding to GPU version
...@@ -166,13 +166,26 @@ unsigned int BoundaryQs::getLevel() ...@@ -166,13 +166,26 @@ unsigned int BoundaryQs::getLevel()
} }
void BoundaryQs::setValues(real** q27, unsigned int level) const void BoundaryQs::setValuesInVector(std::vector<std::vector<std::vector<real>>> &q27, unsigned int level) const
{
for (std::size_t column = 0; column < values[level].size(); column++)
for (std::size_t index = 0; index < values[level][column].size(); index++)
q27[level][column].push_back(values[level][column][index]);
}
void BoundaryQs::setValues(real **q27, unsigned int level) const
{ {
for (std::size_t column = 0; column < values[level].size(); column++) for (std::size_t column = 0; column < values[level].size(); column++)
for (std::size_t index = 0; index < values[level][column].size(); index++) for (std::size_t index = 0; index < values[level][column].size(); index++)
q27[column][index] = values[level][column][index]; q27[column][index] = values[level][column][index];
} }
void BoundaryQs::setIndexInVector(std::vector<std::vector<int>> &data, unsigned int level) const
{
for (std::size_t index = 0; index < indices[level].size(); index++)
data[level].push_back(indices[level][index]);
}
void BoundaryQs::setIndex(int *data, unsigned int level) const void BoundaryQs::setIndex(int *data, unsigned int level) const
{ {
for (std::size_t index = 0; index < indices[level].size(); index++) for (std::size_t index = 0; index < indices[level].size(); index++)
......
...@@ -32,7 +32,9 @@ private: ...@@ -32,7 +32,9 @@ private:
void init_Binary(); void init_Binary();
public: public:
void setIndex(int *indices, unsigned int level) const; void setIndexInVector(std::vector<std::vector<int>> &data, unsigned int level) const;
void setValuesInVector(std::vector<std::vector<std::vector<real>>> &q27, unsigned int level) const;
void setIndex(int *indices, unsigned int level) const;
void setValues(real** q27, unsigned int level) const; void setValues(real** q27, unsigned int level) const;
void getQs(std::vector<std::vector<std::vector<real> > > &qs); void getQs(std::vector<std::vector<std::vector<real> > > &qs);
void getIndices(std::vector<std::vector<uint> > &indices); void getIndices(std::vector<std::vector<uint> > &indices);
......
...@@ -119,6 +119,11 @@ void GridReader::allocArrays_BoundaryValues() ...@@ -119,6 +119,11 @@ void GridReader::allocArrays_BoundaryValues()
velocityX_BCvalues.push_back(std::vector<real>()); velocityX_BCvalues.push_back(std::vector<real>());
velocityY_BCvalues.push_back(std::vector<real>()); velocityY_BCvalues.push_back(std::vector<real>());
velocityZ_BCvalues.push_back(std::vector<real>()); velocityZ_BCvalues.push_back(std::vector<real>());
velocityQs.push_back(std::vector<std::vector<real>>());
velocityIndex.push_back(std::vector<int>());
for (size_t j = 0; j < para->getD3Qxx(); j++) {
velocityQs[i].push_back(std::vector<real>());
}
} }
for (uint i = 0; i < channelBoundaryConditions.size(); i++) for (uint i = 0; i < channelBoundaryConditions.size(); i++)
...@@ -547,14 +552,15 @@ void GridReader::allocArrays_BoundaryQs() ...@@ -547,14 +552,15 @@ void GridReader::allocArrays_BoundaryQs()
for (std::size_t i = 0; i < channelBoundaryConditions.size(); i++) for (std::size_t i = 0; i < channelBoundaryConditions.size(); i++)
{ {
if (this->channelBoundaryConditions[i] == "noSlip") { setNoSlipQs(BC_Qs[i]); } if ( this->channelBoundaryConditions[i] == "noSlip" ) { setNoSlipQs(BC_Qs[i]); }
else if (this->channelBoundaryConditions[i] == "velocity") { setVelocityQs(BC_Qs[i]); } else if (this->channelBoundaryConditions[i] == "velocity") { setVelocityQs(BC_Qs[i]); }
else if (this->channelBoundaryConditions[i] == "pressure") { setPressQs(BC_Qs[i]); } else if (this->channelBoundaryConditions[i] == "pressure") { setPressQs(BC_Qs[i]); }
else if (this->channelBoundaryConditions[i] == "outflow") { setOutflowQs(BC_Qs[i]); } else if (this->channelBoundaryConditions[i] == "outflow" ) { setOutflowQs(BC_Qs[i]); }
} }
for (size_t lev = 0; lev < velocityIndex.size(); lev++) { for (size_t lev = 0; lev < velocityIndex.size(); lev++) {
if (velocityIndex[lev].size() > 1) { if (velocityIndex[lev].size() > 1) {
copyVectorsToQStruct(velocityQs[lev], velocityIndex[lev], para->getParH(lev)->Qinflow);
cudaMemoryManager->cudaCopyVeloBC(lev); cudaMemoryManager->cudaCopyVeloBC(lev);
} }
} }
...@@ -583,15 +589,14 @@ void GridReader::setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const ...@@ -583,15 +589,14 @@ void GridReader::setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const
} }
} }
void GridReader::setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ) const void GridReader::setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ)
{ {
for (unsigned int level = 0; level <= boundaryQ->getLevel(); level++) for (unsigned int level = 0; level <= boundaryQ->getLevel(); level++)
{ {
if (hasQs(boundaryQ, level)) if (hasQs(boundaryQ, level))
{ {
this->printQSize("velocity", boundaryQ, level); this->printQSize("velocity", boundaryQ, level);
this->initalQStruct(para->getParH(level)->Qinflow, boundaryQ, level); this->initalVectorForQStruct(velocityQs, velocityIndex, boundaryQ, level);
cudaMemoryManager->cudaCopyVeloBC(level);
} }
} }
} }
...@@ -652,7 +657,34 @@ void GridReader::modifyQElement(std::shared_ptr<BoundaryQs> boundaryQ, unsigned ...@@ -652,7 +657,34 @@ void GridReader::modifyQElement(std::shared_ptr<BoundaryQs> boundaryQ, unsigned
/*------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------*/
/*---------------------------------------private q methods----------------------------------------*/ /*---------------------------------------private q methods----------------------------------------*/
/*------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------*/
void GridReader::initalQStruct(QforBoundaryConditions& Q, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const void GridReader::initalVectorForQStruct(std::vector<std::vector<std::vector<real>>> &Qs, std::vector<std::vector<int>> &index,
std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const
{
boundaryQ->setValuesInVector(Qs, level);
boundaryQ->setIndexInVector(index, level);
}
void GridReader::copyVectorsToQStruct(std::vector<std::vector<real>> &Qs,
std::vector<int> &index, QforBoundaryConditions &Q) const
{
QforBoundaryConditions qTemp;
this->setQ27Size(qTemp, Q.q27[0], Q.kQ);
uint sizeOfValues = index.size();
for (size_t direction = 0; direction < para->getD3Qxx(); direction++) {
for (size_t indexQ = 0; indexQ < sizeOfValues; indexQ++) {
qTemp.q27[direction][indexQ] = Qs[direction][indexQ];
}
}
for (size_t indexQ = 0; indexQ < sizeOfValues; indexQ++) {
Q.k[indexQ] = index[indexQ];
}
}
void GridReader::initalQStruct(QforBoundaryConditions &Q, std::shared_ptr<BoundaryQs> boundaryQ,
unsigned int level) const
{ {
QforBoundaryConditions qTemp; QforBoundaryConditions qTemp;
this->setQ27Size(qTemp, Q.q27[0], Q.kQ); this->setQ27Size(qTemp, Q.q27[0], Q.kQ);
......
...@@ -25,7 +25,9 @@ private: ...@@ -25,7 +25,9 @@ private:
std::vector<std::string> channelBoundaryConditions; std::vector<std::string> channelBoundaryConditions;
std::shared_ptr<CoordNeighborGeoV> neighX, neighY, neighZ, neighWSB; std::shared_ptr<CoordNeighborGeoV> neighX, neighY, neighZ, neighWSB;
std::vector<std::shared_ptr<BoundaryValues> > BC_Values; std::vector<std::shared_ptr<BoundaryValues> > BC_Values;
std::vector<std::vector<real>> velocityX_BCvalues, velocityY_BCvalues, velocityZ_BCvalues; std::vector<std::vector<real>> velocityX_BCvalues, velocityY_BCvalues, velocityZ_BCvalues;
std::vector<std::vector<std::vector<real>>> velocityQs;
std::vector<std::vector<int>> velocityIndex; std::vector<std::vector<int>> velocityIndex;
std::vector<std::vector<real>> pressureBCvalues; std::vector<std::vector<real>> pressureBCvalues;
...@@ -63,14 +65,19 @@ private: ...@@ -63,14 +65,19 @@ private:
void setOutflow(int level, int sizePerLevel, int channelSide) const; void setOutflow(int level, int sizePerLevel, int channelSide) const;
void setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const; //void fillVelocityQVectors(int channelSide);
void setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void setPressQs(std::shared_ptr<BoundaryQs> boundaryQ) const;
void setVelocityQs(std::shared_ptr<BoundaryQs> boundaryQ);
void setOutflowQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void setOutflowQs(std::shared_ptr<BoundaryQs> boundaryQ) const;
void setNoSlipQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void setNoSlipQs(std::shared_ptr<BoundaryQs> boundaryQ) const;
void setGeoQs(std::shared_ptr<BoundaryQs> boundaryQ) const; void setGeoQs(std::shared_ptr<BoundaryQs> boundaryQ) const;
void modifyQElement(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void modifyQElement(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const;
void initalQStruct(QforBoundaryConditions& Q, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void initalVectorForQStruct(std::vector<std::vector<std::vector<real>>> &Qs, std::vector<std::vector<int>> &index,
std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const;
void copyVectorsToQStruct(std::vector<std::vector<real>> &Qs, std::vector<int> &index,
QforBoundaryConditions &Q) const;
void initalQStruct(QforBoundaryConditions &Q, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const;
void printQSize(std::string bc, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void printQSize(std::string bc, std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const;
void setSizeNoSlip(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void setSizeNoSlip(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const;
void setSizeGeoQs(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const; void setSizeGeoQs(std::shared_ptr<BoundaryQs> boundaryQ, unsigned int level) const;
......
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