@@ -317,6 +317,8 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi
317317
318318 if (!config->GetMultizone_Problem ()) nodes->Set_OldSolution ();
319319
320+ AD::BeginUseAdjoints ();
321+
320322 SU2_OMP_FOR_STAT (omp_chunk_size)
321323 for (auto iPoint = 0ul ; iPoint < nPoint; iPoint++) {
322324
@@ -339,6 +341,8 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi
339341 }
340342 END_SU2_OMP_FOR
341343
344+ AD::EndUseAdjoints ();
345+
342346 direct_solver->ExtractAdjoint_SolutionExtra (nodes->GetSolutionExtra (), config);
343347
344348 /* --- Residuals and time_n terms are not needed when evaluating multizone cross terms. ---*/
@@ -355,24 +359,32 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi
355359
356360 /* --- Extract and store the adjoint of the primal solution at time n ---*/
357361 if (time_n_needed) {
362+ AD::BeginUseAdjoints ();
363+
358364 SU2_OMP_FOR_STAT (omp_chunk_size)
359365 for (auto iPoint = 0ul ; iPoint < nPoint; iPoint++) {
360366 su2double Solution[MAXNVAR] = {0.0 };
361367 direct_solver->GetNodes ()->GetAdjointSolution_time_n (iPoint,Solution);
362368 nodes->Set_Solution_time_n (iPoint,Solution);
363369 }
364370 END_SU2_OMP_FOR
371+
372+ AD::EndUseAdjoints ();
365373 }
366374
367375 /* --- Extract and store the adjoint of the primal solution at time n-1 ---*/
368376 if (time_n1_needed) {
377+ AD::BeginUseAdjoints ();
378+
369379 SU2_OMP_FOR_STAT (omp_chunk_size)
370380 for (auto iPoint = 0ul ; iPoint < nPoint; iPoint++) {
371381 su2double Solution[MAXNVAR] = {0.0 };
372382 direct_solver->GetNodes ()->GetAdjointSolution_time_n1 (iPoint,Solution);
373383 nodes->Set_Solution_time_n1 (iPoint,Solution);
374384 }
375385 END_SU2_OMP_FOR
386+
387+ AD::EndUseAdjoints ();
376388 }
377389
378390}
@@ -477,6 +489,8 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) {
477489
478490void CDiscAdjSolver::SetSensitivity (CGeometry *geometry, CConfig *config, CSolver*) {
479491
492+ AD::BeginUseAdjoints ();
493+
480494 SU2_OMP_PARALLEL {
481495
482496 const bool time_stepping = (config->GetTime_Marching () != TIME_MARCHING::STEADY);
@@ -510,6 +524,8 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolve
510524
511525 }
512526 END_SU2_OMP_PARALLEL
527+
528+ AD::EndUseAdjoints ();
513529}
514530
515531void CDiscAdjSolver::SetSurface_Sensitivity (CGeometry *geometry, CConfig *config) {
0 commit comments