Skip to content

Commit 82677ba

Browse files
committed
Add Myles' second fix to WA interface
1 parent 3c9f9bb commit 82677ba

1 file changed

Lines changed: 34 additions & 28 deletions

File tree

Common/src/interface_interpolation/CSlidingMesh.cpp

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,9 @@ int CSlidingMesh::Build_DualElement(const unsigned long *map, const unsigned lon
854854
/*--- Returns the number of points included in the element ---*/
855855

856856
unsigned long iNode, jNode, kNode, ElementIndex, iPoint, jPoint, kPoint, nOuterNodes, nTriNodes;
857-
unsigned short nDim = 3, iDim, nTmp;
858-
const unsigned long *OuterNodes, *ptr;
859-
int NodeIndex;
857+
unsigned short nDim = 3, iDim, niPointNeighbours;
858+
const unsigned long *OuterNodes, *iPointNeighbours;
859+
int LocalElementIndex;
860860
unsigned long **DualElement;
861861

862862
nTriNodes = 3;
@@ -885,38 +885,44 @@ int CSlidingMesh::Build_DualElement(const unsigned long *map, const unsigned lon
885885
}
886886
}
887887

888-
NodeIndex = 0;
888+
LocalElementIndex = 0;
889889

890890
/* --- Build and order tri segments of a hexa dual element --- */
891-
while ((nOuterNodes - NodeIndex) > 0) {
892891

893-
for (iNode = 0; iNode < nOuterNodes && ((nOuterNodes - NodeIndex) > 0); iNode++) {
892+
bool isFound = false;
893+
894+
while ((nOuterNodes - LocalElementIndex) > 0) {
895+
896+
for (iNode = 0; iNode < nOuterNodes && ((nOuterNodes - LocalElementIndex) > 0); iNode++) {
894897
iPoint = OuterNodes[iNode];
895-
ptr = &map[startIndex[iPoint]];
896-
nTmp = nNeighbor[iPoint];
898+
iPointNeighbours = &map[startIndex[iPoint]];
899+
niPointNeighbours = nNeighbor[iPoint];
900+
isFound = false;
897901

898-
for (jNode = 0; jNode < nTmp && ((nOuterNodes - NodeIndex) > 0); jNode++) {
899-
jPoint = ptr[jNode];
902+
for (jNode = 0; jNode < niPointNeighbours && !isFound; jNode++) {
903+
jPoint = iPointNeighbours[jNode];
900904

901-
for (kNode = 0; kNode < nOuterNodes && ((nOuterNodes - NodeIndex) > 0); kNode++) {
905+
for (kNode = 0; kNode < nOuterNodes; kNode++) {
902906
kPoint = OuterNodes[kNode];
903907

904908
/*--- Find the shared outer nodes in order ---*/
905909
if (jPoint == kPoint) {
906910

907-
if (NodeIndex == 0) {
908-
DualElement[NodeIndex][0] = centralNode;
909-
DualElement[NodeIndex][1] = iPoint;
910-
DualElement[NodeIndex][2] = jPoint;
911-
NodeIndex++;
911+
if (LocalElementIndex == 0) {
912+
DualElement[LocalElementIndex][0] = centralNode;
913+
DualElement[LocalElementIndex][1] = iPoint;
914+
DualElement[LocalElementIndex][2] = jPoint;
915+
LocalElementIndex++;
916+
isFound = true;
912917
break;
913918
}
914919

915-
if (iPoint == DualElement[NodeIndex - 1][2] && jPoint != DualElement[NodeIndex - 1][1]) {
916-
DualElement[NodeIndex][0] = centralNode;
917-
DualElement[NodeIndex][1] = iPoint;
918-
DualElement[NodeIndex][2] = jPoint;
919-
NodeIndex++;
920+
if (iPoint == DualElement[LocalElementIndex - 1][2] && jPoint != DualElement[LocalElementIndex - 1][1]) {
921+
DualElement[LocalElementIndex][0] = centralNode;
922+
DualElement[LocalElementIndex][1] = iPoint;
923+
DualElement[LocalElementIndex][2] = jPoint;
924+
LocalElementIndex++;
925+
isFound = true;
920926
break;
921927
}
922928

@@ -926,26 +932,26 @@ int CSlidingMesh::Build_DualElement(const unsigned long *map, const unsigned lon
926932
}
927933
}
928934

929-
NodeIndex = 0;
935+
LocalElementIndex = 0;
930936
ElementIndex = 1;
931937

932938
/* --- Build array containing the quad dual element by finding the mid point of each edge and the baricenter of each face.
933939
* Each quad is split through its diagonal connecting the central node, baricenter and 4th node. --- */
934-
while ((nOuterNodes - NodeIndex) > 0) {
940+
while ((nOuterNodes - LocalElementIndex) > 0) {
935941
for (iDim = 0; iDim < nDim; iDim++) {
936-
element[ElementIndex][iDim] = (element[0][iDim] + coord[DualElement[NodeIndex][1] * nDim + iDim]) / 2;
942+
element[ElementIndex][iDim] = (element[0][iDim] + coord[DualElement[LocalElementIndex][1] * nDim + iDim]) / 2;
937943
}
938944
ElementIndex++;
939945

940946
for (iDim = 0; iDim < nDim; iDim++) {
941-
element[ElementIndex][iDim] = (element[0][iDim] + coord[DualElement[NodeIndex][1] * nDim + iDim] + coord[DualElement[NodeIndex][2] * nDim + iDim]) / 3;
947+
element[ElementIndex][iDim] = (element[0][iDim] + coord[DualElement[LocalElementIndex][1] * nDim + iDim] + coord[DualElement[LocalElementIndex][2] * nDim + iDim]) / 3;
942948
}
943949
ElementIndex++;
944-
NodeIndex++;
950+
LocalElementIndex++;
945951
}
946952

947953
// This is a closed element, so add again element 1 to the end of the structure, useful later
948-
if(DualElement[NodeIndex - 1][2] == DualElement[0][1]){
954+
if(DualElement[LocalElementIndex - 1][2] == DualElement[0][1]){
949955

950956
for (iDim = 0; iDim < nDim; iDim++) {
951957
element[ElementIndex][iDim] = element[1][iDim];
@@ -954,7 +960,7 @@ int CSlidingMesh::Build_DualElement(const unsigned long *map, const unsigned lon
954960
}
955961
else {
956962
for (iDim = 0; iDim < nDim; iDim++) {
957-
element[ElementIndex][iDim] = (element[0][iDim] + coord[DualElement[NodeIndex - 1][2] * nDim + iDim]) / 2;
963+
element[ElementIndex][iDim] = (element[0][iDim] + coord[DualElement[LocalElementIndex - 1][2] * nDim + iDim]) / 2;
958964
}
959965
ElementIndex++;
960966
}

0 commit comments

Comments
 (0)