@@ -8089,45 +8089,82 @@ 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. ---*/
80928095void CPhysicalGeometry::FindNormal_Neighbor (const CConfig* config) {
8093- su2double cos_max, scalar_prod, norm_vect, norm_Normal, cos_alpha, diff_coord, *Normal ;
8096+ su2double dist_min ;
80948097 unsigned long Point_Normal, jPoint;
8095- unsigned short iNeigh, iMarker, iDim;
8096- unsigned long iPoint, iVertex;
8098+ unsigned short iNeigh, iMarker, jNeigh;
8099+ unsigned long iPoint, kPoint , iVertex;
8100+ // did we find an interiornode?
8101+ bool interiorNode;
80978102
80988103 for (iMarker = 0 ; iMarker < config->GetnMarker_All (); iMarker++) {
80998104 if (config->GetMarker_All_KindBC (iMarker) != SEND_RECEIVE &&
81008105 config->GetMarker_All_KindBC (iMarker) != INTERNAL_BOUNDARY &&
81018106 config->GetMarker_All_KindBC (iMarker) != NEARFIELD_BOUNDARY) {
81028107 for (iVertex = 0 ; iVertex < nVertex[iMarker]; iVertex++) {
81038108 iPoint = vertex[iMarker][iVertex]->GetNode ();
8104- Normal = vertex[iMarker][iVertex]-> GetNormal ( );
8109+ const su2double* Coord_i = nodes-> GetCoord (iPoint );
81058110
81068111 /* --- Compute closest normal neighbor, note that the normal are oriented inwards ---*/
81078112 Point_Normal = 0 ;
8108- cos_max = -2.0 ;
8113+ // we use distance
8114+ dist_min = 1.0e10 ;
8115+ interiorNode = false ;
81098116 for (iNeigh = 0 ; iNeigh < nodes->GetnPoint (iPoint); iNeigh++) {
81108117 jPoint = nodes->GetPoint (iPoint, iNeigh);
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];
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];
81198126 }
8120- norm_vect = sqrt (norm_vect);
8121- norm_Normal = sqrt (norm_Normal);
8122- cos_alpha = scalar_prod / (norm_vect * norm_Normal);
81238127
8124- /* --- Get maximum cosine ---*/
8125- if (cos_alpha >= cos_max) {
8126- if ((!nodes->GetViscousBoundary (iPoint)) || ((nodes->GetViscousBoundary (iPoint)) && (cos_max < -1.0 )))
8128+ // Take the interior node that is closest to the wall node.
8129+ if ((nodes->GetViscousBoundary (jPoint) == false ) && (distance < dist_min) ) {
81278130 Point_Normal = jPoint;
8128- if (!nodes->GetViscousBoundary (iPoint)) cos_max = cos_alpha;
8131+ dist_min = distance;
8132+ interiorNode = true ;
81298133 }
8134+
81308135 }
8136+
8137+ // if we did not find a normal neighbor, then loop over the cells that are connected to the point
8138+ if (interiorNode == false ) {
8139+ // find neighbor nodes to i.
8140+ for (iNeigh = 0 ; iNeigh < nodes->GetnPoint (iPoint); iNeigh++) {
8141+ jPoint = nodes->GetPoint (iPoint, iNeigh);
8142+ // now loop over the nodes of the neighbors
8143+ for (jNeigh = 0 ; jNeigh < nodes->GetnPoint (jPoint); jNeigh++) {
8144+ kPoint = nodes->GetPoint (jPoint, jNeigh);
8145+
8146+ if (kPoint == iPoint) continue ;
8147+
8148+ const su2double* Coord_k = nodes->GetCoord (kPoint );
8149+ // now find the distance from ipoint to kpoint
8150+ su2double distance = 0.0 ;
8151+ vector<su2double> edgeVector (nDim);
8152+ for (unsigned short iDim = 0 ; iDim < nDim; iDim++) {
8153+ edgeVector[iDim] = Coord_k[iDim] - Coord_i[iDim];
8154+ // squared distance
8155+ distance += edgeVector[iDim] * edgeVector[iDim];
8156+ }
8157+
8158+ // Take the interior node that is closest to the wall node.
8159+ if ((nodes->GetViscousBoundary (kPoint ) == false ) && (distance < dist_min) ) {
8160+ Point_Normal = kPoint ;
8161+ dist_min = distance;
8162+ interiorNode = true ;
8163+ }
8164+ }
8165+ }
8166+ }
8167+
81318168 vertex[iMarker][iVertex]->SetNormal_Neighbor (Point_Normal);
81328169 }
81338170 }
0 commit comments