@@ -3292,12 +3292,39 @@ void CSurfaceMovement::SetParametricCoord(CGeometry *geometry, CConfig *config,
32923292
32933293 ParamCoord = FFDBox->GetParametricCoord_Iterative (iPoint, CartCoord, ParamCoordGuess, config);
32943294
3295+ /* --- Compute the cartesian coordinates using the parametric coordinates
3296+ to check that everything is correct ---*/
3297+
3298+ CartCoordNew = FFDBox->EvalCartesianCoord (ParamCoord);
3299+
3300+ /* --- Compute max difference between original value and the recomputed value ---*/
3301+
3302+ Diff = 0.0 ;
3303+ for (iDim = 0 ; iDim < nDim; iDim++)
3304+ Diff += (CartCoordNew[iDim]-CartCoord[iDim])*(CartCoordNew[iDim]-CartCoord[iDim]);
3305+ Diff = sqrt (Diff);
3306+ my_MaxDiff = max (my_MaxDiff, Diff);
3307+
32953308 /* --- If the parametric coordinates are in (0,1) the point belongs to the FFDBox, using the input tolerance ---*/
32963309
32973310 if (((ParamCoord[0 ] >= - config->GetFFD_Tol ()) && (ParamCoord[0 ] <= 1.0 + config->GetFFD_Tol ())) &&
32983311 ((ParamCoord[1 ] >= - config->GetFFD_Tol ()) && (ParamCoord[1 ] <= 1.0 + config->GetFFD_Tol ())) &&
32993312 ((ParamCoord[2 ] >= - config->GetFFD_Tol ()) && (ParamCoord[2 ] <= 1.0 + config->GetFFD_Tol ()))) {
33003313
3314+
3315+ /* --- Rectification of the initial tolerance (we have detected situations
3316+ where 0.0 and 1.0 doesn't work properly ---*/
3317+
3318+ su2double lower_limit = config->GetFFD_Tol ();
3319+ su2double upper_limit = 1.0 -config->GetFFD_Tol ();
3320+
3321+ if (ParamCoord[0 ] < lower_limit) ParamCoord[0 ] = lower_limit;
3322+ if (ParamCoord[1 ] < lower_limit) ParamCoord[1 ] = lower_limit;
3323+ if (ParamCoord[2 ] < lower_limit) ParamCoord[2 ] = lower_limit;
3324+ if (ParamCoord[0 ] > upper_limit) ParamCoord[0 ] = upper_limit;
3325+ if (ParamCoord[1 ] > upper_limit) ParamCoord[1 ] = upper_limit;
3326+ if (ParamCoord[2 ] > upper_limit) ParamCoord[2 ] = upper_limit;
3327+
33013328 /* --- Set the value of the parametric coordinate ---*/
33023329
33033330 FFDBox->Set_MarkerIndex (iMarker);
@@ -3306,40 +3333,19 @@ void CSurfaceMovement::SetParametricCoord(CGeometry *geometry, CConfig *config,
33063333 FFDBox->Set_ParametricCoord (ParamCoord);
33073334 FFDBox->Set_CartesianCoord (CartCoord);
33083335
3309- /* --- Compute the cartesian coordinates using the parametric coordinates
3310- to check that everithing is right ---*/
3311-
3312- CartCoordNew = FFDBox->EvalCartesianCoord (ParamCoord);
3313-
3314- /* --- Compute max difference between original value and the recomputed value ---*/
3315-
3316- Diff = 0.0 ;
3317- for (iDim = 0 ; iDim < nDim; iDim++)
3318- Diff += (CartCoordNew[iDim]-CartCoord[iDim])*(CartCoordNew[iDim]-CartCoord[iDim]);
3319- Diff = sqrt (Diff);
3320- my_MaxDiff = max (my_MaxDiff, Diff);
3321-
33223336 ParamCoordGuess[0 ] = ParamCoord[0 ]; ParamCoordGuess[1 ] = ParamCoord[1 ]; ParamCoordGuess[2 ] = ParamCoord[2 ];
33233337
3338+ if (Diff >= config->GetFFD_Tol ()) {
3339+ cout << " Please check this point: Local (" << ParamCoord[0 ] <<" " << ParamCoord[1 ] <<" " << ParamCoord[2 ] <<" ) <-> Global ("
3340+ << CartCoord[0 ] <<" " << CartCoord[1 ] <<" " << CartCoord[2 ] <<" ) <-> Error " << Diff <<" vs " << config->GetFFD_Tol () <<" ." << endl;
3341+ }
3342+
33243343 }
33253344 else {
33263345
3327- /* --- Compute the cartesian coordinates using the parametric coordinates
3328- to check that everithing is right ---*/
3329-
3330- CartCoordNew = FFDBox->EvalCartesianCoord (ParamCoord);
3331-
3332- /* --- Compute max difference between original value and the recomputed value ---*/
3333-
3334- Diff = 0.0 ;
3335- for (iDim = 0 ; iDim < nDim; iDim++)
3336- Diff += (CartCoordNew[iDim]-CartCoord[iDim])*(CartCoordNew[iDim]-CartCoord[iDim]);
3337- Diff = sqrt (Diff);
3338- my_MaxDiff = max (my_MaxDiff, Diff);
3339-
33403346 if (Diff >= config->GetFFD_Tol ()) {
33413347 cout << " Please check this point: Local (" << ParamCoord[0 ] <<" " << ParamCoord[1 ] <<" " << ParamCoord[2 ] <<" ) <-> Global ("
3342- << CartCoord[0 ] <<" " << CartCoord[1 ] <<" " << CartCoord[2 ] <<" ) <-> Error " << Diff <<" ." <<endl;
3348+ << CartCoord[0 ] <<" " << CartCoord[1 ] <<" " << CartCoord[2 ] <<" ) <-> Error " << Diff <<" vs " << config-> GetFFD_Tol () << " ." << endl;
33433349 }
33443350
33453351 }
@@ -3348,7 +3354,7 @@ void CSurfaceMovement::SetParametricCoord(CGeometry *geometry, CConfig *config,
33483354 }
33493355 }
33503356 }
3351-
3357+
33523358#ifdef HAVE_MPI
33533359 SU2_MPI::Barrier (MPI_COMM_WORLD);
33543360 SU2_MPI::Allreduce (&my_MaxDiff, &MaxDiff, 1 , MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
@@ -3882,7 +3888,7 @@ void CSurfaceMovement::UpdateParametricCoord(CGeometry *geometry, CConfig *confi
38823888 FFDBox->Set_ParametricCoord (ParamCoord, iSurfacePoints);
38833889
38843890 /* --- Compute the cartesian coordinates using the parametric coordinates
3885- to check that everithing is right ---*/
3891+ to check that everything is correct ---*/
38863892
38873893 CartCoordNew = FFDBox->EvalCartesianCoord (ParamCoord);
38883894
@@ -8660,22 +8666,22 @@ void CFreeFormDefBox::GetFFDHessian(su2double *uvw, su2double *xyz, su2double **
86608666su2double *CFreeFormDefBox::GetParametricCoord_Iterative (unsigned long iPoint, su2double *xyz, su2double *ParamCoordGuess, CConfig *config) {
86618667
86628668 su2double *IndepTerm, SOR_Factor = 1.0 , MinNormError, NormError, Determinant, AdjHessian[3 ][3 ], Temp[3 ] = {0.0 ,0.0 ,0.0 };
8663- unsigned short iDim, jDim, RandonCounter;
8664- unsigned long iter;
8669+ unsigned short iDim, jDim, RandonCounter;
8670+ unsigned long iter;
86658671
8666- su2double tol = config->GetFFD_Tol ();
8672+ su2double tol = config->GetFFD_Tol ()* 1E-3 ;
86678673 unsigned short it_max = config->GetnFFD_Iter ();
86688674 unsigned short Random_Trials = 500 ;
8669-
8675+
86708676 /* --- Allocate the Hessian ---*/
86718677
8672- Hessian = new su2double* [nDim];
8678+ Hessian = new su2double* [nDim];
86738679 IndepTerm = new su2double [nDim];
8674- for (iDim = 0 ; iDim < nDim; iDim++) {
8675- Hessian[iDim] = new su2double[nDim];
8676- ParamCoord[iDim] = ParamCoordGuess[iDim];
8677- IndepTerm [iDim] = 0.0 ;
8678- }
8680+ for (iDim = 0 ; iDim < nDim; iDim++) {
8681+ Hessian[iDim] = new su2double[nDim];
8682+ ParamCoord[iDim] = ParamCoordGuess[iDim];
8683+ IndepTerm [iDim] = 0.0 ;
8684+ }
86798685
86808686 RandonCounter = 0 ; MinNormError = 1E6 ;
86818687
0 commit comments