Skip to content

Commit

Permalink
Add explicit locks for AD::GetDerivative() call trees.
Browse files Browse the repository at this point in the history
  • Loading branch information
jblueh committed Nov 2, 2023
1 parent 07e4856 commit 47b3007
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,16 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co

/*--- Extract and store the adjoint solution ---*/

AD::BeginUseAdjoints();

for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
su2double Solution[MAXNVAR] = {0.0};
direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution);
nodes->SetSolution(iPoint,Solution);
}

AD::EndUseAdjoints();

if (CrossTerm) return;

/*--- Extract and store the adjoint solution at time n (including accel. and velocity) ---*/
Expand Down Expand Up @@ -358,6 +362,8 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo

/*--- Extract the geometric sensitivities ---*/

AD::BeginUseAdjoints();

for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) {

auto Coord = geometry->nodes->GetCoord(iPoint);
Expand All @@ -375,6 +381,8 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo
}
}

AD::EndUseAdjoints();

}

void CDiscAdjFEASolver::ReadDV(const CConfig *config) {
Expand Down
8 changes: 8 additions & 0 deletions SU2_CFD/src/solvers/CDiscAdjSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi

if (!config->GetMultizone_Problem()) nodes->Set_OldSolution();

AD::BeginUseAdjoints();

SU2_OMP_FOR_STAT(omp_chunk_size)
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {

Expand All @@ -339,6 +341,8 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi
}
END_SU2_OMP_FOR

AD::EndUseAdjoints();

direct_solver->ExtractAdjoint_SolutionExtra(nodes->GetSolutionExtra(), config);

/*--- Residuals and time_n terms are not needed when evaluating multizone cross terms. ---*/
Expand Down Expand Up @@ -477,6 +481,8 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) {

void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolver*) {

AD::BeginUseAdjoints();

SU2_OMP_PARALLEL {

const bool time_stepping = (config->GetTime_Marching() != TIME_MARCHING::STEADY);
Expand Down Expand Up @@ -510,6 +516,8 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolve

}
END_SU2_OMP_PARALLEL

AD::EndUseAdjoints();
}

void CDiscAdjSolver::SetSurface_Sensitivity(CGeometry *geometry, CConfig *config) {
Expand Down

0 comments on commit 47b3007

Please sign in to comment.