-
Notifications
You must be signed in to change notification settings - Fork 918
Discrete adjoint for dynamic FSI using multizone driver #1260
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
Conversation
…ng time iteration
Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com>
|
A regression test is now added in the TestCases repo. Can we please merge the TestCase PR #62 first? Then we can uncomment the new test in parallel_regression_AD.py to include it in the checks. |
TobiKattmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I guess this PR is ready to merge then :) Lets go 🥳
| * \param[in] force_writing - Force file output. | ||
| */ | ||
| void EvaluateSensitivities(unsigned long Iter, bool StopCalc); | ||
| void EvaluateSensitivities(unsigned long Iter, bool force_writing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 StopCalc is a visible class boolean so it shouldn't be used as a member var in the same class anyway
| iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, | ||
| solver_container, numerics_container, config_container, | ||
| surface_movement, grid_movement, FFDBox, iZone, INST_0); | ||
| iteration_container[iZone][INST_0]->IterateDiscAdj(geometry_container, solver_container, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "IterateDiscAdj" when its the Iterate of a discrete adjoint iteration class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Citing @pcarruscag from his first review above. I also think it is reasonable to have this changed.
Maybe it would make sense to give CIteration an "Iterate" specific for adjoints, because the list of arguments is pretty long and CrossTerm does not mean much for primal solvers, and numerics, surface_movement, FFD and so on also do not make much sense for adjoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make more evident which "Iterate" should be used, and I thought it would be safer to have a new "Iterate" instead of an overload (which could be silently used somewhere else by mistake).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ..
Agreed with the function arguments (though we could distinguish them just by different arguments). In my mind, the name indicates a discrete adjoint of the discrete adjoint. It's just a name though, if it's done very intentionally, I'm good with it.
| void CMeshVariable::Register_MeshCoord() { | ||
| for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) | ||
| for (unsigned long iDim = 0; iDim < nDim; iDim++) | ||
| AD::RegisterInput(Mesh_Coord(iPoint,iDim)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just being curious, how come that neither indices of updated mesh coordinates nor displacements (see above) are needed? I thought their adjoints must be initialised through at least one of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are only used as inputs, but in #1284 I also changed this to store the input indices (just for consistency).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. :) Right, I didn't think of the discrete adjoint FEA solver for a second where the adjoint sweep goes through. I think I've worked out the precise initialize/extract logic for FSI couplings in one of your PR's one day but it's a while ago already...
|
|
||
| unsigned long wrt_sol_freq = 9999; | ||
| const auto nOuterIter = driver_config->GetnOuter_Iter(); | ||
| void CDiscAdjMultizoneDriver::KrylovInnerIters(unsigned short iZone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good to have this moved to a function, in this case.
Proposed Changes
The multizone discrete adjoint driver is extended for dynamic problems.
A time loop is added to the multizone DA driver, with additional handling for the external container to store the intermediate values and cumulative sensitivities per time step.
@TobiKattmann - the changes to the DA multizone driver have been kept generic, they should be transferrable for CHT problems.
Adjoint gradients for both dynamic FSI and dynamic CHT have been verified against finite differences.
Dynamic adjoint test case has been added similar to an existing steady FSI test.
Related Work
#1259 (time averaged history output)
#1174 (velocity transfer at FSI boundary)
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.