Skip to content
Snippets Groups Projects
Commit cdb1ec19 authored by Konstantin Kutscher's avatar Konstantin Kutscher
Browse files

optimized same level connectors

parent 3f0166a6
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,6 @@ public:
virtual void sendData()=0;
virtual void prepareForReceive() {}
virtual value_type& receiveData()=0;
virtual void saveData() {}
//data-access
inline value_type& getData() { return this->data; }
......
#include "D3Q27ETFullVectorConnector.h"
#include "D3Q27EsoTwist3DSplittedVector.h"
#include "LBMKernelETD3Q27.h"
//////////////////////////////////////////////////////////////////////////
D3Q27ETFullVectorConnector::D3Q27ETFullVectorConnector(Block3DPtr block
......@@ -9,13 +11,16 @@ D3Q27ETFullVectorConnector::D3Q27ETFullVectorConnector(Block3DPtr block
{
if (!block || !sender || !receiver)
UB_THROW(UbException(UB_EXARGS, "sender or receiver == NULL!!"));
}
//////////////////////////////////////////////////////////////////////////
void D3Q27ETFullVectorConnector::init()
{
int maxX1 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1()-1;
int maxX2 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2()-1;
int maxX3 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3()-1;
maxX1 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1() - 1;
maxX2 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2() - 1;
maxX3 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3() - 1;
fDis = boost::dynamic_pointer_cast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getFdistributions());
int anz = 27;
switch (sendDir)
......@@ -58,434 +63,406 @@ void D3Q27ETFullVectorConnector::init()
//////////////////////////////////////////////////////////////////////////
void D3Q27ETFullVectorConnector::fillSendVectors()
{
EsoTwist3DPtr fFrom = boost::dynamic_pointer_cast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getFdistributions());
int maxX1 = (int)fFrom->getNX1()-1;
int maxX2 = (int)fFrom->getNX2()-1;
int maxX3 = (int)fFrom->getNX3()-1;
localDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getLocalDistributions();
nonLocalDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getNonLocalDistributions();
zeroDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getZeroDistributions();
int sendDirForEdge[3];
vector_type& sdata = sender->getData();
int index = 0;
//EAST
if (sendDir==D3Q27System::E)
if (sendDir == D3Q27System::E)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
fillData(fFrom, index, maxX1-1, x2, x3);
fillData(sdata, index, maxX1 - 1, x2, x3);
}
}
}
//WEST
else if (sendDir==D3Q27System::W)
else if (sendDir == D3Q27System::W)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
fillData(fFrom, index, 1, x2, x3);
fillData(sdata, index, 1, x2, x3);
}
}
}
//NORTH
else if (sendDir==D3Q27System::N)
else if (sendDir == D3Q27System::N)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
fillData(fFrom, index, x1, maxX2-1, x3);
fillData(sdata, index, x1, maxX2 - 1, x3);
}
}
}
//SOUTH
else if (sendDir==D3Q27System::S)
else if (sendDir == D3Q27System::S)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
fillData(fFrom, index, x1, 1, x3);
fillData(sdata, index, x1, 1, x3);
}
}
}
//TOP
else if (sendDir==D3Q27System::T)
else if (sendDir == D3Q27System::T)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
fillData(fFrom, index, x1, x2, maxX3-1);
fillData(sdata, index, x1, x2, maxX3 - 1);
}
}
}
//BOTTOM
else if (sendDir==D3Q27System::B)
else if (sendDir == D3Q27System::B)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
fillData(fFrom, index, x1, x2, 1);
fillData(sdata, index, x1, x2, 1);
}
}
}
//NE NW SW SE
else if (sendDir==D3Q27System::NE || sendDir==D3Q27System::NW || sendDir==D3Q27System::SW || sendDir==D3Q27System::SE)
else if (sendDir == D3Q27System::NE || sendDir == D3Q27System::NW || sendDir == D3Q27System::SW || sendDir == D3Q27System::SE)
{
int x1 = 0;
int x2 = 0;
switch (sendDir)
{
case D3Q27System::NE: x1 = maxX1-1; x2 = maxX2-1;
sendDirForEdge[0] = D3Q27System::NE;
sendDirForEdge[1] = D3Q27System::TNE;
sendDirForEdge[2] = D3Q27System::BNE;
break;
case D3Q27System::NW: x1 = 1; x2 = maxX2-1;
sendDirForEdge[0] = D3Q27System::NW;
sendDirForEdge[1] = D3Q27System::TNW;
sendDirForEdge[2] = D3Q27System::BNW;
break;
case D3Q27System::SW: x1 = 1; x2 = 1;
sendDirForEdge[0] = D3Q27System::SW;
sendDirForEdge[1] = D3Q27System::TSW;
sendDirForEdge[2] = D3Q27System::BSW;
break;
case D3Q27System::SE: x1 = maxX1-1; x2 = 1;
sendDirForEdge[0] = D3Q27System::SE;
sendDirForEdge[1] = D3Q27System::TSE;
sendDirForEdge[2] = D3Q27System::BSE;
case D3Q27System::NE:
x1 = maxX1 - 1;
x2 = maxX2 - 1;
break;
case D3Q27System::NW:
x1 = 1;
x2 = maxX2 - 1;
break;
case D3Q27System::SW:
x1 = 1;
x2 = 1;
break;
case D3Q27System::SE:
x1 = maxX1 - 1;
x2 = 1;
break;
}
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
fillData(fFrom, index, x1, x2, x3);
fillData(sdata, index, x1, x2, x3);
}
}
//TE TW BW BE
else if (sendDir==D3Q27System::TE || sendDir==D3Q27System::TW || sendDir==D3Q27System::BW || sendDir==D3Q27System::BE)
else if (sendDir == D3Q27System::TE || sendDir == D3Q27System::TW || sendDir == D3Q27System::BW || sendDir == D3Q27System::BE)
{
int x1 = 0;
int x3 = 0;
switch (sendDir)
{
case D3Q27System::TE: x1 = maxX1-1; x3 = maxX3-1;
sendDirForEdge[0] = D3Q27System::TE;
sendDirForEdge[1] = D3Q27System::TNE;
sendDirForEdge[2] = D3Q27System::TSE;
break;
case D3Q27System::TW: x1 = 1; x3 = maxX3-1;
sendDirForEdge[0] = D3Q27System::TW;
sendDirForEdge[1] = D3Q27System::TNW;
sendDirForEdge[2] = D3Q27System::TSW;
break;
case D3Q27System::BW: x1 = 1; x3 = 1;
sendDirForEdge[0] = D3Q27System::BW;
sendDirForEdge[1] = D3Q27System::BNW;
sendDirForEdge[2] = D3Q27System::BSW;
break;
case D3Q27System::BE: x1 = maxX1-1; x3 = 1;
sendDirForEdge[0] = D3Q27System::BE;
sendDirForEdge[1] = D3Q27System::BNE;
sendDirForEdge[2] = D3Q27System::BSE;
case D3Q27System::TE:
x1 = maxX1 - 1;
x3 = maxX3 - 1;
break;
case D3Q27System::TW:
x1 = 1;
x3 = maxX3 - 1;
break;
case D3Q27System::BW:
x1 = 1;
x3 = 1;
break;
case D3Q27System::BE:
x1 = maxX1 - 1;
x3 = 1;
break;
}
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
fillData(fFrom, index, x1, x2, x3);
fillData(sdata, index, x1, x2, x3);
}
}
//TN BN BS TS
else if (sendDir==D3Q27System::TN || sendDir==D3Q27System::BN || sendDir==D3Q27System::BS || sendDir==D3Q27System::TS)
else if (sendDir == D3Q27System::TN || sendDir == D3Q27System::BN || sendDir == D3Q27System::BS || sendDir == D3Q27System::TS)
{
int x2 = 0;
int x3 = 0;
switch (sendDir)
{
case D3Q27System::TN: x3 = maxX3-1; x2 = maxX2-1;
sendDirForEdge[0] = D3Q27System::TN;
sendDirForEdge[1] = D3Q27System::TNE;
sendDirForEdge[2] = D3Q27System::TNW;
break;
case D3Q27System::BN: x3 = 1; x2 = maxX2-1;
sendDirForEdge[0] = D3Q27System::BN;
sendDirForEdge[1] = D3Q27System::BNE;
sendDirForEdge[2] = D3Q27System::BNW;
break;
case D3Q27System::BS: x3 = 1; x2 = 1;
sendDirForEdge[0] = D3Q27System::BS;
sendDirForEdge[1] = D3Q27System::BSE;
sendDirForEdge[2] = D3Q27System::BSW;
break;
case D3Q27System::TS: x3 = maxX3-1; x2 = 1;
sendDirForEdge[0] = D3Q27System::TS;
sendDirForEdge[1] = D3Q27System::TSE;
sendDirForEdge[2] = D3Q27System::TSW;
case D3Q27System::TN:
x3 = maxX3 - 1;
x2 = maxX2 - 1;
break;
case D3Q27System::BN:
x3 = 1;
x2 = maxX2 - 1;
break;
case D3Q27System::BS:
x3 = 1;
x2 = 1;
break;
case D3Q27System::TS:
x3 = maxX3 - 1;
x2 = 1;
break;
}
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
fillData(fFrom, index, x1, x2, x3);
fillData(sdata, index, x1, x2, x3);
}
}
//TNE TNW TSW TSE BNE BNW BSW BSE
else if (sendDir==D3Q27System::TNE || sendDir==D3Q27System::TNW || sendDir==D3Q27System::TSW || sendDir==D3Q27System::TSE
|| sendDir==D3Q27System::BNE || sendDir==D3Q27System::BNW || sendDir==D3Q27System::BSW || sendDir==D3Q27System::BSE)
else if (sendDir == D3Q27System::TNE || sendDir == D3Q27System::TNW || sendDir == D3Q27System::TSW || sendDir == D3Q27System::TSE
|| sendDir == D3Q27System::BNE || sendDir == D3Q27System::BNW || sendDir == D3Q27System::BSW || sendDir == D3Q27System::BSE)
{
int x1 = 0;
int x2 = 0;
int x3 = 0;
switch (sendDir)
{
case D3Q27System::TNE: x1 = maxX1-1; x2 = maxX2-1; x3 = maxX3-1; break;
case D3Q27System::TNW: x1 = 1; x2 = maxX2-1; x3 = maxX3-1; break;
case D3Q27System::TSW: x1 = 1; x2 = 1; x3 = maxX3-1; break;
case D3Q27System::TSE: x1 = maxX1-1; x2 = 1; x3 = maxX3-1; break;
case D3Q27System::BNE: x1 = maxX1-1; x2 = maxX2-1; x3 = 1; break;
case D3Q27System::BNW: x1 = 1; x2 = maxX2-1; x3 = 1; break;
case D3Q27System::TNE: x1 = maxX1 - 1; x2 = maxX2 - 1; x3 = maxX3 - 1; break;
case D3Q27System::TNW: x1 = 1; x2 = maxX2 - 1; x3 = maxX3 - 1; break;
case D3Q27System::TSW: x1 = 1; x2 = 1; x3 = maxX3 - 1; break;
case D3Q27System::TSE: x1 = maxX1 - 1; x2 = 1; x3 = maxX3 - 1; break;
case D3Q27System::BNE: x1 = maxX1 - 1; x2 = maxX2 - 1; x3 = 1; break;
case D3Q27System::BNW: x1 = 1; x2 = maxX2 - 1; x3 = 1; break;
case D3Q27System::BSW: x1 = 1; x2 = 1; x3 = 1; break;
case D3Q27System::BSE: x1 = maxX1-1; x2 = 1; x3 = 1; break;
case D3Q27System::BSE: x1 = maxX1 - 1; x2 = 1; x3 = 1; break;
}
fillData(fFrom, index, x1, x2, x3);
fillData(sdata, index, x1, x2, x3);
}
else UB_THROW(UbException(UB_EXARGS, "unknown dir"));
}
////////////////////////////////////////////////////////////////////////
void D3Q27ETFullVectorConnector::distributeReceiveVectors()
{
receiver->saveData();
/*e.g. connector sendet nach EAST --> empfaengt daten aus WEST ;-)*/
EsoTwist3DPtr fTo = boost::dynamic_pointer_cast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getFdistributions());
int maxX1 = (int)fTo->getNX1()-1;
int maxX2 = (int)fTo->getNX2()-1;
int maxX3 = (int)fTo->getNX3()-1;
localDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getLocalDistributions();
nonLocalDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getNonLocalDistributions();
zeroDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getZeroDistributions();
vector_type& rdata = receiver->getData();
int index = 0;
int sendDirForEdge[3];
if (sendDir==D3Q27System::W)
if (sendDir == D3Q27System::W)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
distributeData(fTo, index, 0, x2, x3);
distributeData(rdata, index, 0, x2, x3);
}
}
}
else if (sendDir==D3Q27System::E)
else if (sendDir == D3Q27System::E)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
distributeData(fTo, index, maxX1, x2, x3);
distributeData(rdata, index, maxX1, x2, x3);
}
}
}
else if (sendDir==D3Q27System::S)
else if (sendDir == D3Q27System::S)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
distributeData(fTo, index, x1, 0, x3);
distributeData(rdata, index, x1, 0, x3);
}
}
}
else if (sendDir==D3Q27System::N)
else if (sendDir == D3Q27System::N)
{
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
distributeData(fTo, index, x1, maxX2, x3);
distributeData(rdata, index, x1, maxX2, x3);
}
}
}
else if (sendDir==D3Q27System::B)
else if (sendDir == D3Q27System::B)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
distributeData(fTo, index, x1, x2, 0);
distributeData(rdata, index, x1, x2, 0);
}
}
}
else if (sendDir==D3Q27System::T)
else if (sendDir == D3Q27System::T)
{
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
distributeData(fTo, index, x1, x2, maxX3);
distributeData(rdata, index, x1, x2, maxX3);
}
}
}
//NE NW SW SE
else if (sendDir==D3Q27System::NE || sendDir==D3Q27System::NW || sendDir==D3Q27System::SW || sendDir==D3Q27System::SE)
else if (sendDir == D3Q27System::NE || sendDir == D3Q27System::NW || sendDir == D3Q27System::SW || sendDir == D3Q27System::SE)
{
int inversDir = D3Q27System::getInvertDirection(sendDir);
int x1 = 0;
int x2 = 0;
switch (sendDir) //wenn sendir NE dann kommen werte von SW
{
case D3Q27System::NE: x1 = maxX1; x2 = maxX2;
sendDirForEdge[0] = D3Q27System::SW;
sendDirForEdge[1] = D3Q27System::TSW;
sendDirForEdge[2] = D3Q27System::BSW;
break;
case D3Q27System::NW: x1 = 0; x2 = maxX2;
sendDirForEdge[0] = D3Q27System::SE;
sendDirForEdge[1] = D3Q27System::TSE;
sendDirForEdge[2] = D3Q27System::BSE;
break;
case D3Q27System::SW: x1 = 0; x2 = 0;
sendDirForEdge[0] = D3Q27System::NE;
sendDirForEdge[1] = D3Q27System::TNE;
sendDirForEdge[2] = D3Q27System::BNE;
break;
case D3Q27System::SE: x1 = maxX1; x2 = 0;
sendDirForEdge[0] = D3Q27System::NW;
sendDirForEdge[1] = D3Q27System::TNW;
sendDirForEdge[2] = D3Q27System::BNW;
case D3Q27System::NE:
x1 = maxX1;
x2 = maxX2;
break;
case D3Q27System::NW:
x1 = 0;
x2 = maxX2;
break;
case D3Q27System::SW:
x1 = 0;
x2 = 0;
break;
case D3Q27System::SE:
x1 = maxX1;
x2 = 0;
break;
}
for (int x3 = 1; x3<maxX3; x3++)
for (int x3 = 1; x3 < maxX3; x3++)
{
distributeData(fTo, index, x1, x2, x3);
distributeData(rdata, index, x1, x2, x3);
}
}
//TE TW BW BE
else if (sendDir==D3Q27System::TE || sendDir==D3Q27System::TW || sendDir==D3Q27System::BW || sendDir==D3Q27System::BE)
else if (sendDir == D3Q27System::TE || sendDir == D3Q27System::TW || sendDir == D3Q27System::BW || sendDir == D3Q27System::BE)
{
int inversDir = D3Q27System::getInvertDirection(sendDir);
int x1 = 0;
int x3 = 0;
switch (sendDir) //wenn sendir NE dann kommen werte von SW
{
case D3Q27System::TE: x1 = maxX1; x3 = maxX3;
sendDirForEdge[0] = D3Q27System::BW;
sendDirForEdge[1] = D3Q27System::BNW;
sendDirForEdge[2] = D3Q27System::BSW;
break;
case D3Q27System::TW: x1 = 0; x3 = maxX3;
sendDirForEdge[0] = D3Q27System::BE;
sendDirForEdge[1] = D3Q27System::BNE;
sendDirForEdge[2] = D3Q27System::BSE;
break;
case D3Q27System::BW: x1 = 0; x3 = 0;
sendDirForEdge[0] = D3Q27System::TE;
sendDirForEdge[1] = D3Q27System::TNE;
sendDirForEdge[2] = D3Q27System::TSE;
break;
case D3Q27System::BE: x1 = maxX1; x3 = 0;
sendDirForEdge[0] = D3Q27System::TW;
sendDirForEdge[1] = D3Q27System::TNW;
sendDirForEdge[2] = D3Q27System::TSW;
case D3Q27System::TE:
x1 = maxX1;
x3 = maxX3;
break;
case D3Q27System::TW:
x1 = 0;
x3 = maxX3;
break;
case D3Q27System::BW:
x1 = 0;
x3 = 0;
break;
case D3Q27System::BE:
x1 = maxX1;
x3 = 0;
break;
}
for (int x2 = 1; x2<maxX2; x2++)
for (int x2 = 1; x2 < maxX2; x2++)
{
distributeData(fTo, index, x1, x2, x3);
distributeData(rdata, index, x1, x2, x3);
}
}
//TN BN BS TS
else if (sendDir==D3Q27System::TN || sendDir==D3Q27System::BN || sendDir==D3Q27System::BS || sendDir==D3Q27System::TS)
else if (sendDir == D3Q27System::TN || sendDir == D3Q27System::BN || sendDir == D3Q27System::BS || sendDir == D3Q27System::TS)
{
int inversDir = D3Q27System::getInvertDirection(sendDir);
int x2 = 0;
int x3 = 0;
switch (sendDir)
{
case D3Q27System::TN: x3 = maxX3; x2 = maxX2;
sendDirForEdge[0] = D3Q27System::BS;
sendDirForEdge[1] = D3Q27System::BSE;
sendDirForEdge[2] = D3Q27System::BSW;
break;
case D3Q27System::BN: x3 = 0; x2 = maxX2;
sendDirForEdge[0] = D3Q27System::TS;
sendDirForEdge[1] = D3Q27System::TSE;
sendDirForEdge[2] = D3Q27System::TSW;
break;
case D3Q27System::BS: x3 = 0; x2 = 0;
sendDirForEdge[0] = D3Q27System::TN;
sendDirForEdge[1] = D3Q27System::TNE;
sendDirForEdge[2] = D3Q27System::TNW;
break;
case D3Q27System::TS: x3 = maxX3; x2 = 0;
sendDirForEdge[0] = D3Q27System::BN;
sendDirForEdge[1] = D3Q27System::BNE;
sendDirForEdge[2] = D3Q27System::BNW;
case D3Q27System::TN:
x3 = maxX3;
x2 = maxX2;
break;
case D3Q27System::BN:
x3 = 0;
x2 = maxX2;
break;
case D3Q27System::BS:
x3 = 0;
x2 = 0;
break;
case D3Q27System::TS:
x3 = maxX3;
x2 = 0;
break;
}
for (int x1 = 1; x1<maxX1; x1++)
for (int x1 = 1; x1 < maxX1; x1++)
{
distributeData(fTo, index, x1, x2, x3);
distributeData(rdata, index, x1, x2, x3);
}
}
//TNE TNW TSW TSE BNE BNW BSW BSE
else if (sendDir==D3Q27System::TNE || sendDir==D3Q27System::TNW || sendDir==D3Q27System::TSW || sendDir==D3Q27System::TSE
|| sendDir==D3Q27System::BNE || sendDir==D3Q27System::BNW || sendDir==D3Q27System::BSW || sendDir==D3Q27System::BSE)
else if (sendDir == D3Q27System::TNE || sendDir == D3Q27System::TNW || sendDir == D3Q27System::TSW || sendDir == D3Q27System::TSE
|| sendDir == D3Q27System::BNE || sendDir == D3Q27System::BNW || sendDir == D3Q27System::BSW || sendDir == D3Q27System::BSE)
{
int inversDir = D3Q27System::getInvertDirection(sendDir);
int x1 = 0;
int x2 = 0;
int x3 = 0;
unsigned long int etDir = 0;
switch (sendDir)
{
case D3Q27System::TNE: x1 = maxX1; x2 = maxX2; x3 = maxX3; etDir = EsoTwistD3Q27System::etTNE; break;
case D3Q27System::TNW: x1 = 0; x2 = maxX2; x3 = maxX3; etDir = EsoTwistD3Q27System::etTNW; break;
case D3Q27System::TSW: x1 = 0; x2 = 0; x3 = maxX3; etDir = EsoTwistD3Q27System::etTSW; break;
case D3Q27System::TSE: x1 = maxX1; x2 = 0; x3 = maxX3; etDir = EsoTwistD3Q27System::etTSE; break;
case D3Q27System::BNE: x1 = maxX1; x2 = maxX2; x3 = 0; etDir = EsoTwistD3Q27System::etBNE; break;
case D3Q27System::BNW: x1 = 0; x2 = maxX2; x3 = 0; etDir = EsoTwistD3Q27System::etBNW; break;
case D3Q27System::BSW: x1 = 0; x2 = 0; x3 = 0; etDir = EsoTwistD3Q27System::etBSW; break;
case D3Q27System::BSE: x1 = maxX1; x2 = 0; x3 = 0; etDir = EsoTwistD3Q27System::etBSE; break;
case D3Q27System::TNE:
x1 = maxX1;
x2 = maxX2;
x3 = maxX3;
break;
case D3Q27System::TNW:
x1 = 0;
x2 = maxX2;
x3 = maxX3;
break;
case D3Q27System::TSW:
x1 = 0;
x2 = 0;
x3 = maxX3;
break;
case D3Q27System::TSE:
x1 = maxX1;
x2 = 0;
x3 = maxX3;
break;
case D3Q27System::BNE:
x1 = maxX1;
x2 = maxX2;
x3 = 0;
break;
case D3Q27System::BNW:
x1 = 0;
x2 = maxX2;
x3 = 0;
break;
case D3Q27System::BSW:
x1 = 0;
x2 = 0;
x3 = 0;
break;
case D3Q27System::BSE:
x1 = maxX1;
x2 = 0;
x3 = 0;
break;
}
distributeData(fTo, index, x1, x2, x3);
distributeData(rdata, index, x1, x2, x3);
}
else UB_THROW(UbException(UB_EXARGS, "unknown dir"));
}
//////////////////////////////////////////////////////////////////////////
void D3Q27ETFullVectorConnector::fillData(EsoTwist3DPtr fFrom, int& index, const int& x1, const int& x2, const int& x3)
{
LBMReal f[D3Q27System::ENDF+1];
vector_type& data = sender->getData();
if (!invStep)
fFrom->getDistributionInv(f, x1, x2, x3);
else
fFrom->getDistribution(f, x1, x2, x3);
for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++)
data[index++] = f[i];
}
//////////////////////////////////////////////////////////////////////////
void D3Q27ETFullVectorConnector::distributeData(EsoTwist3DPtr fTo, int& index, const int& x1, const int& x2, const int& x3)
{
vector_type& data = receiver->getData();
if (!invStep)
{
for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++)
fTo->setDistributionForDirection(data[index++], x1, x2, x3, i);
}
else
{
for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++)
fTo->setDistributionInvForDirection(data[index++], x1, x2, x3, i);
}
}
//////////////////////////////////////////////////////////////////////////
......@@ -8,6 +8,8 @@
#include "Block3D.h"
#include "LBMKernelETD3Q27.h"
#include "EsoTwistD3Q27System.h"
#include "basics/container/CbArray3D.h"
#include "basics/container/CbArray4D.h"
//daten werden in einen vector (dieser befindet sich im transmitter) kopiert
......@@ -17,10 +19,10 @@
class D3Q27ETFullVectorConnector : public RemoteBlock3DConnector
{
public:
D3Q27ETFullVectorConnector( Block3DPtr block
D3Q27ETFullVectorConnector(Block3DPtr block
, VectorTransmitterPtr sender
, VectorTransmitterPtr receiver
, int sendDir);
, int sendDir);
void init();
......@@ -28,11 +30,91 @@ public:
void distributeReceiveVectors();
protected:
void fillData(EsoTwist3DPtr fFrom, int& index, const int& x1, const int& x2, const int& x3);
void distributeData(EsoTwist3DPtr fTo, int& index, const int& x1, const int& x2, const int& x3);
inline void fillData(vector_type& sdata, int& index, int x1, int x2, int x3);
inline void distributeData(vector_type& rdata, int& index, int x1, int x2, int x3);
private:
int maxX1;
int maxX2;
int maxX3;
CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions;
CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions;
CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions;
EsoTwist3DPtr fDis;
};
//////////////////////////////////////////////////////////////////////////
inline void D3Q27ETFullVectorConnector::fillData(vector_type& sdata, int& index, int x1, int x2, int x3)
{
//vector_type& sdata = sender->getData();
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3);
sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1);
sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1);
sdata[index++] = (*this->zeroDistributions)(x1, x2, x3);
}
//////////////////////////////////////////////////////////////////////////
inline void D3Q27ETFullVectorConnector::distributeData(vector_type& rdata, int& index, int x1, int x2, int x3)
{
//vector_type& rdata = receiver->getData();
(*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++];
(*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++];
(*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++];
(*this->zeroDistributions)(x1, x2, x3) = rdata[index++];
}
#endif //D3Q27VECTORCONNECTOR_H
......
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