Skip to content

Commit

Permalink
Updated MG
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Palacios committed Nov 6, 2014
1 parent cb44f15 commit 72226a8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 52 deletions.
Binary file not shown.
139 changes: 87 additions & 52 deletions src/geometry_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5439,9 +5439,95 @@ CMultiGridGeometry::CMultiGridGeometry(CGeometry **geometry, CConfig *config_con

nPoint = Index_CoarseCV;

/*--- Console output with the summary of the agglomeration ---*/
/*--- Check that there are no hanging nodes ---*/

unsigned long iFinePoint, iFinePoint_Neighbor, iCoarsePoint, iCoarsePoint_Complete;
unsigned short iChildren;

/*--- Find the point surrounding a point ---*/

for (iCoarsePoint = 0; iCoarsePoint < nPointDomain; iCoarsePoint ++) {
for (iChildren = 0; iChildren < node[iCoarsePoint]->GetnChildren_CV(); iChildren ++) {
iFinePoint = node[iCoarsePoint]->GetChildren_CV(iChildren);
for (iNode = 0; iNode < fine_grid->node[iFinePoint]->GetnPoint(); iNode ++) {
iFinePoint_Neighbor = fine_grid->node[iFinePoint]->GetPoint(iNode);
iParent = fine_grid->node[iFinePoint_Neighbor]->GetParent_CV();
if (iParent != iCoarsePoint) node[iCoarsePoint]->SetPoint(iParent);
}
}
}

/*--- Detect isolated points and merge them with its correct neighbor ---*/

for (iCoarsePoint = 0; iCoarsePoint < nPointDomain; iCoarsePoint ++) {

if (node[iCoarsePoint]->GetnPoint() == 1) {

/*--- Find the neighbor of the isolated point. This neighbor is the right control volume ---*/

iCoarsePoint_Complete = node[iCoarsePoint]->GetPoint(0);

/*--- Add the children to the connected control volume (and modify it parent indexing).
Identify the child CV from the finest grid and added to the correct control volume.
Set the parent CV of iFinePoint. Instead of using the original
(iCoarsePoint) one use the new one (iCoarsePoint_Complete) ---*/

nChildren = node[iCoarsePoint_Complete]->GetnChildren_CV();

for (iChildren = 0; iChildren < node[iCoarsePoint]->GetnChildren_CV(); iChildren ++) {
iFinePoint = node[iCoarsePoint]->GetChildren_CV(iChildren);
node[iCoarsePoint_Complete]->SetChildren_CV(nChildren, iFinePoint);
nChildren++;
fine_grid->node[iFinePoint]->SetParent_CV(iCoarsePoint_Complete);
}

/*--- Update the number of children control volumes ---*/

node[iCoarsePoint_Complete]->SetnChildren_CV(nChildren);
node[iCoarsePoint]->SetnChildren_CV(0);

}
}

// unsigned long iPointFree = nPointDomain-1;
// iCoarsePoint = 0;
//
// do {
//
// if (node[iCoarsePoint]->GetnChildren_CV() == 0) {
//
// while (node[iPointFree]->GetnChildren_CV() == 0) {
// Index_CoarseCV--;
// iPointFree--;
// }
//
// nChildren = node[iPointFree]->GetnChildren_CV();
// for (iChildren = 0; iChildren < nChildren; iChildren ++) {
// iFinePoint = node[iPointFree]->GetChildren_CV(iChildren);
// node[iCoarsePoint]->SetChildren_CV(iChildren, iFinePoint);
// fine_grid->node[iFinePoint]->SetParent_CV(iCoarsePoint);
// }
// node[iCoarsePoint]->SetnChildren_CV(nChildren);
// node[iPointFree]->SetnChildren_CV(0);
//
// Index_CoarseCV--;
// iPointFree--;
//
// }
//
// iCoarsePoint++;
//
// } while ((iCoarsePoint-1) < Index_CoarseCV);
//
// nPointDomain = Index_CoarseCV;

/*--- Reset the point surrounding a point ---*/

for (iCoarsePoint = 0; iCoarsePoint < nPointDomain; iCoarsePoint ++) {
node[iCoarsePoint]->ResetPoint();
}

/*--- Console output with the summary of the agglomeration ---*/

Local_nPointCoarse = nPoint;
Local_nPointFine = fine_grid->GetnPoint();
Expand Down Expand Up @@ -5738,57 +5824,6 @@ void CMultiGridGeometry::SetPoint_Connectivity(CGeometry *fine_grid) {
}
}

/*--- Detect isolated points and merge them with its correct neighbor ---*/

for (iCoarsePoint = 0; iCoarsePoint < nPointDomain; iCoarsePoint ++) {

if (node[iCoarsePoint]->GetnPoint() == 1) {

/*--- Find the neighbor of the isolated point. This neighbor is the right control volume ---*/

iCoarsePoint_Complete = node[iCoarsePoint]->GetPoint(0);

/*--- Add the children to the connected control volume (and modify it parent indexing) ---*/

nChildren = node[iCoarsePoint_Complete]->GetnChildren_CV();

for (iChildren = 0; iChildren < node[iCoarsePoint]->GetnChildren_CV(); iChildren ++) {

/*--- Identify the child CV from the finest grid and added to the correct control volume ---*/

iFinePoint = node[iCoarsePoint]->GetChildren_CV(iChildren);
node[iCoarsePoint_Complete]->SetChildren_CV(nChildren, iFinePoint);
nChildren++;

/*--- Set the parent CV of iFinePoint. Instead of using the original
(iCoarsePoint) one use the new one (iCoarsePoint_Complete) ---*/

fine_grid->node[iFinePoint]->SetParent_CV(iCoarsePoint_Complete);


}

/*--- Update the number of children control volumes ---*/

node[iCoarsePoint_Complete]->SetnChildren_CV(nChildren);
node[iCoarsePoint]->SetnChildren_CV(0);

/*--- Reset the point surrounding a point and recompute ---*/

node[iCoarsePoint]->ResetPoint();
node[iCoarsePoint_Complete]->ResetPoint();
for (iChildren = 0; iChildren < node[iCoarsePoint_Complete]->GetnChildren_CV(); iChildren ++) {
iFinePoint = node[iCoarsePoint_Complete]->GetChildren_CV(iChildren);
for (iNode = 0; iNode < fine_grid->node[iFinePoint]->GetnPoint(); iNode ++) {
iFinePoint_Neighbor = fine_grid->node[iFinePoint]->GetPoint(iNode);
iParent = fine_grid->node[iFinePoint_Neighbor]->GetParent_CV();
if (iParent != iCoarsePoint_Complete) node[iCoarsePoint_Complete]->SetPoint(iParent);
}
}

}
}

/*--- Set the number of neighbors variable, this is
important for JST and multigrid in parallel ---*/

Expand Down

0 comments on commit 72226a8

Please sign in to comment.