Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore in discrete adjoint bits #1257

Merged
merged 38 commits into from
May 6, 2021
Merged

Chore in discrete adjoint bits #1257

merged 38 commits into from
May 6, 2021

Conversation

TobiKattmann
Copy link
Contributor

@TobiKattmann TobiKattmann commented Apr 7, 2021

Hi all,

As I am stepping through DA cases with my debugger I am cleaning some things left and right. No major changes.

  • making local vars const when possible
  • moving the config->GetBool directly to the conditional instead of making it a var and using it 1 time
  • removing dead code
  • adding some comments
  • some typos fixed

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with the '-Wall -Wextra -Wno-unused-parameter -Wno-empty-body' compiler flags, or simply --warnlevel=2 when using meson).
  • My contribution is commented and consistent with SU2 style.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp) , if necessary.

@pr-triage pr-triage bot added the PR: draft label Apr 7, 2021
@@ -376,7 +371,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi

if (time_n_needed) {
SU2_OMP_FOR_STAT(omp_chunk_size)
for (auto iPoint = 0u; iPoint < nPoint; iPoint++) {
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this iPoint change from 0u to 0ul is less of a necessity then rather a consistency thing

Comment on lines -695 to -698
StopCalc = FinalTimeReached || MaxIterationsReached;
return (FinalTimeReached || MaxIterationsReached);
}

return StopCalc;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StopCalc is class data and was returned to itself, so I made the function to not use that var

@TobiKattmann TobiKattmann changed the title [WIP] Chore in discrete adjoint bits Chore in discrete adjoint bits May 5, 2021
@TobiKattmann TobiKattmann marked this pull request as ready for review May 5, 2021 21:04
Comment on lines -245 to -248
/*--- Read the target pressure for inverse design. ---------------------------------------------*/
/*--- TODO: This routine should be taken out of output, and made general for multiple zones. ---*/
// if (config_container[iZone]->GetInvDesign_Cp() == YES)
// output[iZone]->SetCp_InverseDesign(solver_container[iZone][INST_0][MESH_0][FLOW_SOL],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all the inverse design stuff that was commented out in multiple places


/*--- For the unsteady adjoint, load direct solutions from restart files. ---*/

if (config[val_iZone]->GetTime_Marching() != TIME_MARCHING::STEADY) {
Direct_Iter = SU2_TYPE::Int(config[val_iZone]->GetUnst_AdjointIter()) - SU2_TYPE::Int(TimeIter) - 2;
const int Direct_Iter = SU2_TYPE::Int(config[val_iZone]->GetUnst_AdjointIter()) - SU2_TYPE::Int(TimeIter) - 2 + dual_time;
Copy link
Contributor Author

@TobiKattmann TobiKattmann May 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now consistent with CDiscAdjFluidIteration.cpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact, SU2_TYPE::Int implies a cast to su2double, followed cast to int, yeyy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are those casts via SU2_TYPE methods even for

@TobiKattmann
Copy link
Contributor Author

@cvencro Merging this will most likely result in some conflicts with #1260 which are hopefully easy to resolve as it is mostly stylistic stuff without any real changes to the code. @pcarruscag I reverted CDiscADjVariable.hpp/cpp and will readd the briefs in #1260

Comment on lines 293 to 292
MDOFs += (su2double)DOFsPerPoint*(su2double)geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPoint()/(1.0e6);
MDOFsDomain += (su2double)DOFsPerPoint*(su2double)geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPointDomain()/(1.0e6);
Mpoints += static_cast<su2double>(geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPoint())/(1.0e6);
MpointsDomain += static_cast<su2double>(geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPointDomain())/(1.0e6);
MDOFs += static_cast<su2double>(DOFsPerPoint)*static_cast<su2double>(geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPoint())/(1.0e6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The casts are not really needed.

if (dual_time) {
for (auto iVar = 0u; iVar < nVar; iVar++) {
Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar);
}
}

/*--- Set the adjoint values of the primal (TK::??) solution. ---*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

dTdn = -(nodes->GetSolution(Point_Normal,0) - Twall)/dist_ij;
dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 46 to 47
const int Direct_Iter = SU2_TYPE::Int(config[val_iZone]->GetUnst_AdjointIter()) - SU2_TYPE::Int(TimeIter) - 2 + dual_time;
const int Direct_Iter = static_cast<int>(config[val_iZone]->GetUnst_AdjointIter()) - static_cast<int>(TimeIter) - 2 + dual_time;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@TobiKattmann TobiKattmann merged commit 2782983 into develop May 6, 2021
@TobiKattmann TobiKattmann deleted the chore_discrete_adjoint branch May 6, 2021 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants