Edit me

This section provides DAFoam configurations for verifying the accuracy of adjoint derivative computation (DAFoam achieves machine precision accurate adjoint). Here we compared the derivatives between the forward mode AD (reference) and the JacobianFree adjoint method. The configuration files are available from here.

To run a case, we need to first generate the mesh by running:

./preProcessing.sh

To compute the adjoint derivatives, run:

mpirun -np 4 python runScript.py

To compute the reference derivatives using the forward mode AD for a specific design variable, run:

mpirun -np 4 python runScript.py --task=runForwardAD --dvName="shape" --seedIndex=0

The above command will run the primal solver with the forward mode AD, and print out the derivative for the 0th “shape” design variable to the screen during the computation. One can follow a similar syntax for other design variables and indices.

NOTE: we have to use meshWaveFrozen for wallDist in fvSchemes because the original meshWave method is not properly AD in OpenFOAM-v1812-AD. The meshWaveFrozen method is similar to meshWave, except that the wall distance will be computed only once (in the beginning of the optimization), and it will NOT be recomputed as the geometry changes during the optimization. We expect this has very little impact on the optimization results because IDWarp deforms the mesh based on the inverse-distance weighting method. The near wall mesh will deform as much as the wall, so the wall distance should remain the same.