Clean up the partitioner for the FEM solver. by vdweide · Pull Request #2443 · su2code/SU2
switch (nCornerPoints) {
case 2: {
/* Element is a line. Check if the node numbering must be swapped. If so
also the element information must be swapped, because element 0 is to
the left of the face and element 1 to the right. */
if (cornerPoints[1] < cornerPoints[0]) {
swap(cornerPoints[0], cornerPoints[1]);
swapElements = true;
}
break;
}
case 3: { /* Element is a triangle. The vertices are sorted in increasing order. If the sequence of the new numbering is opposite to the current numbering, the element information must be exchanged, because element 0 is to the left of the face and element 1 to the right. */ unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2]}; unsigned short ind = 0; if (nn[1] < nn[ind]) ind = 1; if (nn[2] < nn[ind]) ind = 2;
unsigned short indm1 = ind == 0 ? 2 : ind - 1; // Next lower index. unsigned short indp1 = ind == 2 ? 0 : ind + 1; // Next upper index.
if (nn[indp1] < nn[indm1]) { /* The orientation of the triangle remains the same. Store the new sorted node numbering. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indp1]; cornerPoints[2] = nn[indm1]; } else { /* The orientation of the triangle changes. Store the new sorted node numbering and set swapElements to true. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indm1]; cornerPoints[2] = nn[indp1]; swapElements = true; }
break; }
case 4: { /* Element is a quadrilateral. The vertices are sorted in increasing order under the condition neighboring vertices remain neighbors. If the sequence of the new numbering is opposite to the current numbering, the element information must be exchanged, because element 0 is to the left of the face and element 1 to the right. */ unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2], cornerPoints[3]}; unsigned short ind = 0; if (nn[1] < nn[ind]) ind = 1; if (nn[2] < nn[ind]) ind = 2; if (nn[3] < nn[ind]) ind = 3;
unsigned short indm1 = ind == 0 ? 3 : ind - 1; // Next lower index. unsigned short indp1 = ind == 3 ? 0 : ind + 1; // Next upper index. unsigned short indp2 = ind >= 2 ? ind - 2 : ind + 2; // Opposite index.
if (nn[indp1] < nn[indm1]) { /* The orientation of the quadrilateral remains the same. Store the new sorted node numbering. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indp1]; cornerPoints[2] = nn[indp2]; cornerPoints[3] = nn[indm1]; } else { /* The orientation of the quadrilateral changes. Store the new sorted node numbering and set swapElements to true. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indm1]; cornerPoints[2] = nn[indp2]; cornerPoints[3] = nn[indp1]; swapElements = true; }
break; }
default: { ostringstream message; message << "Unknown surface element type with " << nCornerPoints << " corners." << endl; SU2_MPI::Error(message.str(), CURRENT_FUNCTION); } }
case 3: { /* Element is a triangle. The vertices are sorted in increasing order. If the sequence of the new numbering is opposite to the current numbering, the element information must be exchanged, because element 0 is to the left of the face and element 1 to the right. */ unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2]}; unsigned short ind = 0; if (nn[1] < nn[ind]) ind = 1; if (nn[2] < nn[ind]) ind = 2;
unsigned short indm1 = ind == 0 ? 2 : ind - 1; // Next lower index. unsigned short indp1 = ind == 2 ? 0 : ind + 1; // Next upper index.
if (nn[indp1] < nn[indm1]) { /* The orientation of the triangle remains the same. Store the new sorted node numbering. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indp1]; cornerPoints[2] = nn[indm1]; } else { /* The orientation of the triangle changes. Store the new sorted node numbering and set swapElements to true. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indm1]; cornerPoints[2] = nn[indp1]; swapElements = true; }
break; }
case 4: { /* Element is a quadrilateral. The vertices are sorted in increasing order under the condition neighboring vertices remain neighbors. If the sequence of the new numbering is opposite to the current numbering, the element information must be exchanged, because element 0 is to the left of the face and element 1 to the right. */ unsigned long nn[] = {cornerPoints[0], cornerPoints[1], cornerPoints[2], cornerPoints[3]}; unsigned short ind = 0; if (nn[1] < nn[ind]) ind = 1; if (nn[2] < nn[ind]) ind = 2; if (nn[3] < nn[ind]) ind = 3;
unsigned short indm1 = ind == 0 ? 3 : ind - 1; // Next lower index. unsigned short indp1 = ind == 3 ? 0 : ind + 1; // Next upper index. unsigned short indp2 = ind >= 2 ? ind - 2 : ind + 2; // Opposite index.
if (nn[indp1] < nn[indm1]) { /* The orientation of the quadrilateral remains the same. Store the new sorted node numbering. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indp1]; cornerPoints[2] = nn[indp2]; cornerPoints[3] = nn[indm1]; } else { /* The orientation of the quadrilateral changes. Store the new sorted node numbering and set swapElements to true. */ cornerPoints[0] = nn[ind]; cornerPoints[1] = nn[indm1]; cornerPoints[2] = nn[indp2]; cornerPoints[3] = nn[indp1]; swapElements = true; }
break; }
default: { ostringstream message; message << "Unknown surface element type with " << nCornerPoints << " corners." << endl; SU2_MPI::Error(message.str(), CURRENT_FUNCTION); } }