Skip to content

Make primal residual for adjoint like normal screen output.#1371

Merged
TobiKattmann merged 12 commits intodevelopfrom
feature_directres
Sep 16, 2021
Merged

Make primal residual for adjoint like normal screen output.#1371
TobiKattmann merged 12 commits intodevelopfrom
feature_directres

Conversation

@TobiKattmann
Copy link
Copy Markdown
Contributor

@TobiKattmann TobiKattmann commented Sep 14, 2021

Hi all,

lately I was fixing restarts. Making sure the adjoint also has a correct primal restart is somewhat annoying due to the way the residuals are printed to screen

I want to change that to look like a normal screen output of all residuals. Here the old variant on top and the new below (field names need to be adapted to usual screen output)
image

The code as of today only changes this for single zone and does not use the usual output routines (and is a bit hacky). I want to add multizone and use the output routines instead of this handwritten PrintDirectResidual routine. I'll look into both

Let me know if there are reasons against this or any other comments

Related Work

The printing tool box of Tim

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.

So far only for SingleZoneDriver. Using the PrintingToolbox.
Multizone should be adapted as well.
Prob it is best to use the normal output routines but this is just a
first step.
@TobiKattmann TobiKattmann marked this pull request as draft September 14, 2021 11:57
@TobiKattmann TobiKattmann changed the title Make primal residual for adjoint like normal screen output. [WIP] Make primal residual for adjoint like normal screen output. Sep 14, 2021
Copy link
Copy Markdown
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

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

👍 I think with some tweaks it would be no worse code-wise and much better for functionality.

Essentially addressing review comments. Still, only SingleZoneDriver was
changed.
TobiKattmann and others added 2 commits September 15, 2021 12:42
Similar to the SingleZone version this also prints the direct residuals
using the Table Printer. And now all residuals instead of just the first
of each solver.
config_container, iZone, INST_0);
AD::Push_TapePosition(); /// leave_zone
}
Print_DirectResidual(kind_recording);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made that bit a function for Multizone just as there is for SingleZone. Using the same function for both is maybe possible without to much effort. But I did not do that for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did that, see latest commit af7d12c

Comment on lines +708 to +711
/*--- Helper lambda func to return lenghty [iVar][iZone] string. ---*/
auto iVar_iZone2string = [](unsigned short ivar, unsigned short izone) {
return "[" + std::to_string(ivar) + "][" + std::to_string(izone) + "]";
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here one would need to have the iZone part only for GetMultizoneProblem()

Comment on lines +712 to +728
case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES:
cout << " Zone " << iZone << " (flow) - log10[U(0)] : "
<< log10(solvers[FLOW_SOL]->GetRes_RMS(0)) << endl;
if (config_container[iZone]->AddRadiation()) {
for (unsigned short iZone = 0; iZone < nZone; iZone++) {

cout << " Zone " << iZone << " (radiation) - log10[Rad(0)] : "
<< log10(solvers[RAD_SOL]->GetRes_RMS(0)) << endl;
}
break;
auto solvers = solver_container[iZone][INST_0][MESH_0];
auto configs = config_container[iZone];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure whether one can easily swap those containers for singlezone and Multizone on this level

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well I guess this works out as is ...

Comment on lines -711 to -718
case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES:
case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES:
cout << " Zone " << iZone << " (flow) - log10[U(0)] : "
<< log10(solvers[FLOW_SOL]->GetRes_RMS(0)) << endl;
if (config_container[iZone]->AddRadiation()) {
for (unsigned short iZone = 0; iZone < nZone; iZone++) {

cout << " Zone " << iZone << " (radiation) - log10[Rad(0)] : "
<< log10(solvers[RAD_SOL]->GetRes_RMS(0)) << endl;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure why there is this separation of the laminar and turbulence cases, i.e. having the same stuff for flow and radiation twice. So did that together like in the singlezone

if (rank == MASTER_NODE && kind_recording == RECORDING::SOLUTION_VARIABLES) {

auto solvers = solver_container[iZone][INST_0][MESH_0];
const unsigned short fieldWidth = 15;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately I had to increase to a min of 14 to fit e.g. rms_Flow[0][0] into the table. The fixed screen output size for the primal is currently 12... that is not ideal but better than before imo

Namely the Single and Multizone version are now consolidated in CDriver
which has to use minor specific things to accomodate for both.
The function is protected.
@TobiKattmann TobiKattmann marked this pull request as ready for review September 15, 2021 13:22
@pr-triage pr-triage bot removed the PR: draft label Sep 15, 2021
@TobiKattmann TobiKattmann changed the title [WIP] Make primal residual for adjoint like normal screen output. Make primal residual for adjoint like normal screen output. Sep 15, 2021
It might be double (only the screen output) for multizone for the
secondaries.
And not in PrintDirectRes. This is consistent with the multizone driver.
Comment on lines +247 to +258
if (rank == MASTER_NODE) {
cout << "\n-------------------------------------------------------------------------\n";
switch(kind_recording) {
case RECORDING::CLEAR_INDICES: cout << "Clearing the computational graph." << endl; break;
case RECORDING::MESH_COORDS: cout << "Storing computational graph wrt MESH COORDINATES." << endl; break;
case RECORDING::SOLUTION_VARIABLES:
cout << "Direct iteration to store the primal computational graph." << endl;
cout << "Compute residuals to check the convergence of the direct problem." << endl; break;
default: break;
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is now consistent/similar with the handling in the CDiscAdjMultizoneDriver. This allows the early return in Print_DirectResiduals

Comment on lines +2657 to +2659
void CDriver::Print_DirectResidual(RECORDING kind_recording) {

if (!(rank == MASTER_NODE && kind_recording == RECORDING::SOLUTION_VARIABLES)) return;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There it is

@TobiKattmann
Copy link
Copy Markdown
Contributor Author

Thanks for the review and the helpful comments @pcarruscag .

@TobiKattmann TobiKattmann merged commit 68e8de1 into develop Sep 16, 2021
@TobiKattmann TobiKattmann deleted the feature_directres branch September 16, 2021 07:24
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.

2 participants