Skip to content

Commit

Permalink
one ghost layer -> two ghost layers
Browse files Browse the repository at this point in the history
  • Loading branch information
sorush-khajepor committed Jun 14, 2018
1 parent 04c07d6 commit d4386a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
16 changes: 9 additions & 7 deletions domainDecomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class DomainDecomposition{
class StructuredDecomposition :public DomainDecomposition {

protected:
// Origin is placed on (1,1[,1])
const intND origin=1;
// Raw whole domain dimensions (before considering ghosts)
// Origin is placed on (2,2[,2])
const intND origin=2;
// Raw whole domain dimensions/number of nodes along (X-Y-z) before considering ghosts
intND dim;
// Number of Blocks in the whole domain along each (X-Y-Z) direction
intND nBlock;
Expand All @@ -40,6 +40,7 @@ class StructuredDecomposition :public DomainDecomposition {
const intND& getNBlock() const{
return nBlock;
}

const int& getDim(const int& iD) const{
return dim[iD];
}
Expand All @@ -54,16 +55,17 @@ class StructuredDecomposition :public DomainDecomposition {

for (int iD=0;iD<lattice::nD;++iD){
int remainder = dim[iD]%nBlock[iD];
// Dimension of the block along XYZ axes including 2 ghost layers
blockDim[iD]= (dim[iD]+nBlock[iD]-blockCartIndex[iD] -1)/nBlock[iD]+2;
// Origin of the block starts from the ghost layer.
blockOrigin[iD] = dim[iD]/nBlock[iD]*blockCartIndex[iD]+std::min(blockCartIndex[iD],remainder)-1 + origin[iD];
// Dimension of the block along XYZ axes including 4 ghost layers
blockDim[iD]= (dim[iD]+nBlock[iD]-blockCartIndex[iD] -1)/nBlock[iD]+4;
// Origin of the block starts from the outer ghost layer.
blockOrigin[iD] = dim[iD]/nBlock[iD]*blockCartIndex[iD]+std::min(blockCartIndex[iD],remainder)-2 + origin[iD];
}


BlockNeighborIndex=computeNeighborIndex();

}

// Finding block neighbors
intNQ computeNeighborIndex() const {
intNQ iNei;
Expand Down
24 changes: 12 additions & 12 deletions test_domainDecomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ int main() {

StructuredDecomposition s2d(dim,periodic);

// cout<<"\n nBlock,Dim, rank="<<mpiTools.getRank()<<s2d.getNBlock()<<s2d.getDim()<<endl;
// cout<<"\n nBlock,Dim, rank="<<mpiTools.getRank()<<s2d.getNBlock()<<s2d.getDim()<<endl;

intND bci=s2d.computeBlockCartIndex(mpiTools.getRank());
// cout<<"\n CartIndex,SingleIndex, rank="<<mpiTools.getRank()<<bci<<"single Index="<<s2d.computeBlockSingleIndex(bci)<<endl;

cout<<"\n Neighbor Index, rank="<<mpiTools.getRank()<<s2d.computeNeighborIndex();
// cout<<"\n Neighbor Index, rank="<<mpiTools.getRank()<<s2d.computeNeighborIndex();

intND blockOrigin;
intND blockDim;
intND blockCartIndex;
intNQ BlockNeighborIndex;
s2d.computeBlockGeometry(blockOrigin,blockDim,blockCartIndex,BlockNeighborIndex);
// cout<<"Origin, Dim, iBlockCart, Neighbors rank = "<<mpiTools.getRank()<<blockOrigin<<blockDim<<blockCartIndex<<BlockNeighborIndex<<endl;
cout<<"Origin, Dim, iBlockCart, Neighbors rank = "<<mpiTools.getRank()<<blockOrigin<<blockDim<<blockCartIndex<<BlockNeighborIndex<<endl;
MPI_Finalize();


Expand All @@ -31,37 +31,37 @@ int main() {
MPI n = 9
Domain = 16x16 = (6x5x5) x (6x5x5)
Domain = 16x16 = (6+5+5) x (6+5+5)
block(with ghosts) = 8x7x7
Domain with ghosts = (10+9+9)*(10+9+9)
8 7 7
10 9 9
+---------------+-------------------+------------------+
| | | |
| (0,2) | (1,2) | (2,2) |
7 | 2 | 5 | 8 |
9 | 2 | 5 | 8 |
| | | |
| | | |
| | | |
+------------------------------------------------------+
| (0,1) | (1,1) | (2,1) |
| | | |
| 1 | 4 | 7 |
7 | | | |
9 | | | |
| | | |
| | | |
+------------------------------------------------------+
| | | |
| (0,0) | (1,0) | (2,0) |
| | | |
8 | 0 | 3 | 6 |
10 | 0 | 3 | 6 |
| | | |
| | | 12 13 14 15 16 | 17*
| 6*| 7 8 9 10 11 | 12* |
| | 11* 12*| 13 14 15 16 17| 18* 19*
| 6*7*|8 9 10 11 12 | 13* 14* |
+-----------------------------------+------------------+
0* 1 2 3 4 5 6 7*
0* 1* 2 3 4 5 6 7 8* 9*
Origin -> (0,0) (6,0) (11,0) *=Ghost node
Expand Down

0 comments on commit d4386a7

Please sign in to comment.