2828#include " ../../include/grid_movement/CFreeFormDefBox.hpp"
2929#include " ../../include/grid_movement/CBezierBlending.hpp"
3030#include " ../../include/grid_movement/CBSplineBlending.hpp"
31+ #include " ../../include/toolboxes/geometry_toolbox.hpp"
3132
3233CFreeFormDefBox::CFreeFormDefBox () : CGridMovement() {}
3334
@@ -1014,13 +1015,8 @@ su2double* CFreeFormDefBox::GetParametricCoord_Iterative(unsigned long iPoint, s
10141015 return ParamCoord;
10151016}
10161017
1017- bool CFreeFormDefBox::GetPointFFD (CGeometry* geometry, CConfig* config, unsigned long iPoint) const {
1018- bool Inside = true ;
1019- bool cylindrical = (config->GetFFD_CoordSystem () == CYLINDRICAL);
1020- bool spherical = (config->GetFFD_CoordSystem () == SPHERICAL);
1021- bool polar = (config->GetFFD_CoordSystem () == POLAR);
1022-
1023- /* --- indices of the FFD box. Note that the front face is labelled 0,1,2,3 and the back face is 4,5,6,7 ---*/
1018+ bool CFreeFormDefBox::CheckPointInsideFFD (const su2double* coord) const {
1019+ /* --- Indices of the FFD box. Note that the front face is labelled 0,1,2,3 and the back face is 4,5,6,7 ---*/
10241020
10251021 unsigned short Index[6 ][5 ] = {{0 , 1 , 2 , 3 , 0 }, // front side
10261022 {1 , 5 , 6 , 2 , 1 }, // right side
@@ -1029,76 +1025,34 @@ bool CFreeFormDefBox::GetPointFFD(CGeometry* geometry, CConfig* config, unsigned
10291025 {4 , 5 , 1 , 0 , 4 }, // bottom side
10301026 {4 , 7 , 6 , 5 , 4 }}; // back side
10311027
1032- /* --- The current approach is to subdivide each of the 6 faces of the hexahedral FFD box into 4 triangles
1033- by defining a supporting middle point. This allows nonplanar FFD boxes.
1034- Note that the definition of the FFD box is as follows: the FFD box is a 6-sided die and we are looking at the side
1035- "1". The opposite side is side "6". If we are looking at side "1", we define the nodes counterclockwise. If we are
1036- looking at side "6", we define the face clockwise ---*/
1037-
1038- unsigned short nDim = geometry->GetnDim ();
1039-
1040- su2double Coord[3 ] = {0.0 , 0.0 , 0.0 };
1041- for (unsigned short iDim = 0 ; iDim < nDim; iDim++) Coord[iDim] = geometry->nodes ->GetCoord (iPoint, iDim);
1042-
1043- su2double X_0, Y_0, Z_0, Xbar, Ybar, Zbar;
1044-
1045- if (cylindrical) {
1046- X_0 = config->GetFFD_Axis (0 );
1047- Y_0 = config->GetFFD_Axis (1 );
1048- Z_0 = config->GetFFD_Axis (2 );
1049-
1050- Xbar = Coord[0 ] - X_0;
1051- Ybar = Coord[1 ] - Y_0;
1052- Zbar = Coord[2 ] - Z_0;
1053-
1054- Coord[0 ] = sqrt (Ybar * Ybar + Zbar * Zbar);
1055- Coord[1 ] = atan2 (Zbar, Ybar);
1056- if (Coord[1 ] > PI_NUMBER / 2.0 ) Coord[1 ] -= 2.0 * PI_NUMBER;
1057- Coord[2 ] = Xbar;
1028+ /* --- The current approach is to subdivide each of the 6 faces of the hexahedral FFD box into 4 triangles by defining
1029+ a supporting middle point. This allows nonplanar FFD boxes. Note that the definition of the FFD box is as follows:
1030+ the FFD box is a 6-sided die and we are looking at the side "1". The opposite side is side "6". If we are looking at
1031+ side "1", we define the nodes counterclockwise. If we are looking at side "6", we define the face clockwise. ---*/
10581032
1059- }
1060-
1061- else if (spherical || polar) {
1062- X_0 = config->GetFFD_Axis (0 );
1063- Y_0 = config->GetFFD_Axis (1 );
1064- Z_0 = config->GetFFD_Axis (2 );
1065-
1066- Xbar = Coord[0 ] - X_0;
1067- Ybar = Coord[1 ] - Y_0;
1068- Zbar = Coord[2 ] - Z_0;
1069-
1070- Coord[0 ] = sqrt (Xbar * Xbar + Ybar * Ybar + Zbar * Zbar);
1071- Coord[1 ] = atan2 (Zbar, Ybar);
1072- if (Coord[1 ] > PI_NUMBER / 2.0 ) Coord[1 ] -= 2.0 * PI_NUMBER;
1073- Coord[2 ] = acos (Xbar / Coord[0 ]);
1074- }
1033+ /* --- Loop over the faces of the FFD box. ---*/
10751034
1076- /* --- loop over the faces of the FFD box ---*/
1035+ for (unsigned short iFace = 0 ; iFace < 6 ; iFace++) {
1036+ /* --- Every face needs an interpolated middle point for the triangles. ---*/
10771037
1078- for (unsigned short iVar = 0 ; iVar < 6 ; iVar++) {
10791038 su2double P[3 ] = {0.0 , 0.0 , 0.0 };
1080-
1081- /* --- every face needs an interpolated middle point for the triangles ---*/
1082-
10831039 for (int p = 0 ; p < 4 ; p++) {
1084- P[0 ] += 0.25 * Coord_Corner_Points[Index[iVar ][p]][0 ];
1085- P[1 ] += 0.25 * Coord_Corner_Points[Index[iVar ][p]][1 ];
1086- P[2 ] += 0.25 * Coord_Corner_Points[Index[iVar ][p]][2 ];
1040+ P[0 ] += 0.25 * Coord_Corner_Points[Index[iFace ][p]][0 ];
1041+ P[1 ] += 0.25 * Coord_Corner_Points[Index[iFace ][p]][1 ];
1042+ P[2 ] += 0.25 * Coord_Corner_Points[Index[iFace ][p]][2 ];
10871043 }
10881044
1089- /* --- loop over the 4 triangles making up the FFD box. The sign is equal for all distances ---*/
1045+ /* --- Loop over the 4 triangles making up the FFD box. The sign should be equal for all distances. ---*/
10901046
1091- for (unsigned short jVar = 0 ; jVar < 4 ; jVar++) {
1092- su2double Distance_Point = geometry->Point2Plane_Distance (Coord, Coord_Corner_Points[Index[iVar][jVar]],
1093- Coord_Corner_Points[Index[iVar][jVar + 1 ]], P);
1094- if (Distance_Point < 0 ) {
1095- Inside = false ;
1096- return Inside;
1047+ for (int iNode = 0 ; iNode < 4 ; iNode++) {
1048+ const su2double* plane[] = {P, Coord_Corner_Points[Index[iFace][iNode]],
1049+ Coord_Corner_Points[Index[iFace][iNode + 1 ]]};
1050+ if (GeometryToolbox::PointToPlaneDistance (plane, coord) < 0 ) {
1051+ return false ;
10971052 }
10981053 }
10991054 }
1100-
1101- return Inside;
1055+ return true ;
11021056}
11031057
11041058su2double CFreeFormDefBox::GetDerivative1 (su2double* uvw, unsigned short val_diff, unsigned short * ijk,
0 commit comments