Skip to content

Implement Adjoint for custom meshes#63

Merged
joanibal merged 59 commits into
joanibal:mainfrom
sabakhshi:bakhshi_patch7
Mar 5, 2026
Merged

Implement Adjoint for custom meshes#63
joanibal merged 59 commits into
joanibal:mainfrom
sabakhshi:bakhshi_patch7

Conversation

@sabakhshi

@sabakhshi sabakhshi commented Feb 23, 2026

Copy link
Copy Markdown
Collaborator

This pull request implements the AD partials and adjoint for the direct mesh assignment features.
The new subroutines for the direct mesh assignment in amake.f have been differentiated in both forward and reverse mode with Tapenade. The necessary common block variables have been added to AVL_ad_seeds.inc to accommodate the AD.

In the python layer we have added the necessary routines to set, get, and clear the AD seeds for the mesh. Note the the mesh seed routines and variables are being treated separately from the geom ones. The justification for this is that meshes will use a different computational pathway through amake.f, amake_d.f, and amake_b.f than the AVL geometry variables and hence this separation should draw a clean line here.

The main workhorse routines for getting the Jacobian vector product in both the forward and reverse mode have been updated to support the mesh seeds. The forward routine also supports computing the mesh derivatives with finite difference. Lastly, the execute_run_sensitivities function will return the mesh derivatives alongside the geometric derivatives associated with each surface (this will make it intuitive to retrieve them).

I have also implemented two new test files that will test both the partial and total derivatives. These roughly follow all the other partial and total derivative test implemented for OptVL so far. However, the partial derivative tests exclusively focus on testing the mesh derivatives to avoid redundancy. The standard derivative tests use input files however input dictionaries are required to use a mesh so these test input files were converted to dictionary format as closely as possible(I can't match AVLs panel spacing in some cases). I have decided to store these dictionaries and meshes in .pkl format for convenience (the input dict test won't use these due to how extensive that test is). I have also included the scripts used to generate the .pkl files.

By itself this PR doesn't do much unless one is content with using the surface mesh coordinates as design variables in an optimization problem. However, it does set the groundwork for the upcoming PR which will include support for pyGeo and the OM wrapper allowing users to formulate more practical design optimization problem with custom meshes.

sabakhshi and others added 30 commits October 15, 2025 16:55
… fixed scale and translate of custom meshes not working
…fortran layer indexing bugs. runtime mesh updating still needs to be implemented
@sabakhshi sabakhshi marked this pull request as ready for review March 1, 2026 23:55
@sabakhshi sabakhshi requested a review from joanibal March 1, 2026 23:55
@joanibal

joanibal commented Mar 4, 2026

Copy link
Copy Markdown
Owner

I have decided to store these dictionaries and meshes in .pkl format for convenience (the input dict test won't use these due to how extensive that test is). I have also included the scripts used to generate the .pkl files.

Hey this is looking good.

I'm just going to change the .pkl files to just plain dictionaries that we can import. I don't like saving binary data to the repo since it makes it hard to track changes and the dictionaries have a very natural text representation.

@joanibal joanibal merged commit 5d4413d into joanibal:main Mar 5, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants