@@ -2986,19 +2986,25 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, const CConfig *config){
29862986 {
29872987 su2double obj_fun_local = 0.0 ;
29882988
2989- SU2_OMP_FOR_STAT (omp_chunk_size)
2990- for (unsigned long iPoint = 0 ; iPoint < nPointDomain; iPoint++) {
2991-
2992- for (unsigned short iVar = 0 ; iVar < nVar; iVar++) {
2993-
2994- /* --- Retrieve the value of the reference geometry ---*/
2995- su2double reference_geometry = nodes->GetReference_Geometry (iPoint,iVar);
2996-
2997- /* --- Retrieve the value of the current solution ---*/
2998- su2double current_solution = nodes->GetSolution (iPoint,iVar);
2999-
3000- /* --- The objective function is the sum of the difference between solution and difference, squared ---*/
3001- obj_fun_local += pow (current_solution - reference_geometry, 2 );
2989+ if (!config->GetRefGeomSurf ()) {
2990+ SU2_OMP_FOR_STAT (omp_chunk_size)
2991+ for (unsigned long iPoint = 0 ; iPoint < nPointDomain; iPoint++) {
2992+ obj_fun_local += SquaredDistance (nVar, nodes->GetReference_Geometry (iPoint), nodes->GetSolution (iPoint));
2993+ }
2994+ }
2995+ else {
2996+ for (unsigned short iMarker = 0 ; iMarker < config->GetnMarker_All (); iMarker++) {
2997+ if ((config->GetMarker_All_KindBC (iMarker) == LOAD_BOUNDARY) ||
2998+ (config->GetMarker_All_KindBC (iMarker) == LOAD_DIR_BOUNDARY) ||
2999+ (config->GetMarker_All_KindBC (iMarker) == FLOWLOAD_BOUNDARY)) {
3000+ SU2_OMP_FOR_STAT (OMP_MIN_SIZE)
3001+ for (unsigned long iVertex = 0 ; iVertex < geometry->GetnVertex (iMarker); ++iVertex) {
3002+ auto iPoint = geometry->vertex [iMarker][iVertex]->GetNode ();
3003+
3004+ if (geometry->nodes ->GetDomain (iPoint))
3005+ obj_fun_local += SquaredDistance (nVar, nodes->GetReference_Geometry (iPoint), nodes->GetSolution (iPoint));
3006+ }
3007+ }
30023008 }
30033009 }
30043010 atomicAdd (obj_fun_local, objective_function);
0 commit comments