Skip to content

Commit ce27533

Browse files
committed
restore original normalneighbor
1 parent 087a12c commit ce27533

File tree

1 file changed

+19
-56
lines changed

1 file changed

+19
-56
lines changed

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8089,81 +8089,44 @@ void CPhysicalGeometry::ComputeMeshQualityStatistics(const CConfig* config) {
80898089
}
80908090
}
80918091

8092-
/*--- Note that we do not find the real normal neighbor here, since it usually does not exist.
8093-
Instead, we determine the interior node that is closest to the wall node. If there is no
8094-
interior node, we have to take the closest wall node. ---*/
80958092
void CPhysicalGeometry::FindNormal_Neighbor(const CConfig* config) {
8096-
su2double dist_min;
8093+
su2double cos_max, scalar_prod, norm_vect, norm_Normal, cos_alpha, diff_coord, *Normal;
80978094
unsigned long Point_Normal, jPoint;
8098-
unsigned short iNeigh, iMarker, jNeigh;
8099-
unsigned long iPoint, kPoint, iVertex;
8100-
// did we find an interiornode?
8101-
bool interiorNode;
8095+
unsigned short iNeigh, iMarker, iDim;
8096+
unsigned long iPoint, iVertex;
81028097

81038098
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
81048099
if (config->GetMarker_All_KindBC(iMarker) != SEND_RECEIVE &&
81058100
config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY &&
81068101
config->GetMarker_All_KindBC(iMarker) != NEARFIELD_BOUNDARY) {
81078102
for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) {
81088103
iPoint = vertex[iMarker][iVertex]->GetNode();
8109-
const su2double* Coord_i = nodes->GetCoord(iPoint);
8104+
Normal = vertex[iMarker][iVertex]->GetNormal();
81108105

81118106
/*--- Compute closest normal neighbor, note that the normal are oriented inwards ---*/
81128107
Point_Normal = 0;
8113-
// we use distance
8114-
dist_min = 1.0e10;
8115-
interiorNode = false;
8108+
cos_max = -1.0;
81168109
for (iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); iNeigh++) {
81178110
jPoint = nodes->GetPoint(iPoint, iNeigh);
8118-
const su2double* Coord_j = nodes->GetCoord(jPoint);
8119-
8120-
su2double distance = 0.0;
8121-
vector<su2double> edgeVector(nDim);
8122-
for (unsigned short iDim = 0; iDim < nDim; iDim++) {
8123-
edgeVector[iDim] = Coord_j[iDim] - Coord_i[iDim];
8124-
// squared distance
8125-
distance += edgeVector[iDim] * edgeVector[iDim];
8111+
scalar_prod = 0.0;
8112+
norm_vect = 0.0;
8113+
norm_Normal = 0.0;
8114+
for (iDim = 0; iDim < nDim; iDim++) {
8115+
diff_coord = nodes->GetCoord(jPoint, iDim) - nodes->GetCoord(iPoint, iDim);
8116+
scalar_prod += diff_coord * Normal[iDim];
8117+
norm_vect += diff_coord * diff_coord;
8118+
norm_Normal += Normal[iDim] * Normal[iDim];
81268119
}
8120+
norm_vect = sqrt(norm_vect);
8121+
norm_Normal = sqrt(norm_Normal);
8122+
cos_alpha = scalar_prod / (norm_vect * norm_Normal);
81278123

8128-
// Take the interior node that is closest to the wall node.
8129-
if ((nodes->GetViscousBoundary(jPoint) == false) && (distance < dist_min)) {
8124+
/*--- Get maximum cosine ---*/
8125+
if (cos_alpha >= cos_max) {
81308126
Point_Normal = jPoint;
8131-
dist_min = distance;
8132-
interiorNode = true;
8133-
}
8134-
}
8135-
8136-
// if we did not find a normal neighbor, then loop over the cells that are connected to the point
8137-
if (interiorNode == false) {
8138-
// find neighbor nodes to i.
8139-
for (iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); iNeigh++) {
8140-
jPoint = nodes->GetPoint(iPoint, iNeigh);
8141-
// now loop over the nodes of the neighbors
8142-
for (jNeigh = 0; jNeigh < nodes->GetnPoint(jPoint); jNeigh++) {
8143-
kPoint = nodes->GetPoint(jPoint, jNeigh);
8144-
8145-
if (kPoint == iPoint) continue;
8146-
8147-
const su2double* Coord_k = nodes->GetCoord(kPoint);
8148-
// now find the distance from ipoint to kpoint
8149-
su2double distance = 0.0;
8150-
vector<su2double> edgeVector(nDim);
8151-
for (unsigned short iDim = 0; iDim < nDim; iDim++) {
8152-
edgeVector[iDim] = Coord_k[iDim] - Coord_i[iDim];
8153-
// squared distance
8154-
distance += edgeVector[iDim] * edgeVector[iDim];
8155-
}
8156-
8157-
// Take the interior node that is closest to the wall node.
8158-
if ((nodes->GetViscousBoundary(kPoint) == false) && (distance < dist_min)) {
8159-
Point_Normal = kPoint;
8160-
dist_min = distance;
8161-
interiorNode = true;
8127+
cos_max = cos_alpha;
81628128
}
81638129
}
8164-
}
8165-
}
8166-
81678130
vertex[iMarker][iVertex]->SetNormal_Neighbor(Point_Normal);
81688131
}
81698132
}

0 commit comments

Comments
 (0)