Skip to content

Commit

Permalink
Added the deactivate calls for all AD funcs and updated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
friedenhe committed Jul 20, 2023
1 parent 453e5b5 commit f33075a
Show file tree
Hide file tree
Showing 10 changed files with 864 additions and 504 deletions.
954 changes: 654 additions & 300 deletions src/adjoint/DASolver/DASolver.C

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions src/adjoint/DASolver/DASolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ public:
const word designVarName,
Vec dFdBC);

/// assign the BC val to OF var
void setBCToOFVars(
const dictionary& dvSubDict,
const scalar& BC);

/// get the BC val from OF var
void getBCFromOFVars(
const dictionary& dvSubDict,
scalar& BC);

/// compute dRdBCAD
void calcdRdBCTPsiAD(
const Vec xvVec,
Expand Down Expand Up @@ -538,11 +548,19 @@ public:
/// register all state variables as the input for reverse-mode AD
void registerStateVariableInput4AD(const label oldTimeLevel = 0);

/// deactivate all state variables as the input for reverse-mode AD
void deactivateStateVariableInput4AD();

/// register field variables as the input for reverse-mode AD
void registerFieldVariableInput4AD(
const word fieldName,
const word fieldType);

/// deactivate the field variables for reverse-mode AD
void deactivateFieldVariableInput4AD(
const word fieldName,
const word fieldType);

/// register all residuals as the output for reverse-mode AD
void registerResidualOutput4AD();

Expand Down Expand Up @@ -904,7 +922,7 @@ public:
void updateBoundaryConditions(
const word fieldName,
const word fieldType);

/// update the boundary conditions for all states and intermediate variables
void updateStateBoundaryConditions();

Expand Down Expand Up @@ -997,7 +1015,7 @@ public:

/// initialize tensorflow functions and interfaces for callback
void initTensorFlowFuncs(
pyComputeInterface computeInterface,
pyComputeInterface computeInterface,
void* compute,
pyJacVecProdInterface jacVecProdInterface,
void* jacVecProd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Dictionary Key: FI
Dictionary Key: alpha
@value 0 0.0001 1e-06
Dictionary Key: alphaPorosity
@value 7667.002672988612 0.0001 1e-06
@value 7662.95674760256 0.0001 1e-06
Dictionary Key: beta
@value 252.4756985454485 0.0001 1e-06
Dictionary Key: fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Dictionary Key: alphaPorosity
Dictionary Key: beta
@value 63.62415240726151 0.0001 1e-06
Dictionary Key: fvSource
@value 1806.201838099202 0.0001 1e-06
@value 1810.517315729984 0.0001 1e-06
Dictionary Key: fail
@value 0 0.0001 1e-06
29 changes: 6 additions & 23 deletions tests/refs/DAFoam_Test_MphysAeroFieldRef.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
Dictionary Key: CL
@value 0.2992762848982257 1e-06 1e-08
Dictionary Key: CL
Dictionary Key: alpha
@value 0.6405997854447981 0.0001 1e-06
@value 0.435012393483863 0.0001 1e-06
Dictionary Key: aoa
@value 0.000959052564689386 0.0001 1e-06
Dictionary Key: shape
@value -1.359174005645564 0.0001 1e-06
@value -0.6692178532758711 0.0001 1e-06
@value -0.2149441233470428 0.0001 1e-06
@value -0.01334827639681135 0.0001 1e-06
@value 1.666569177875879 0.0001 1e-06
@value 1.11477785597916 0.0001 1e-06
@value 1.624331137829298 0.0001 1e-06
@value 0.4017427848906134 0.0001 1e-06
@value 0.2919486313792322 0.0001 1e-06
@value 0.04132164500265292 0.0001 1e-06
@value 0.9052707541190427 0.0001 1e-06
@value 0.4881671535089137 0.0001 1e-06
@value 1.280749801412769 0.0001 1e-06
@value 1.203706208898332 0.0001 1e-06
@value 1.276188815028655 0.0001 1e-06
@value 1.160544344322793 0.0001 1e-06
@value -2.227350578087959 0.0001 1e-06
@value -2.199728454741364 0.0001 1e-06
@value -2.400190424831512 0.0001 1e-06
@value -2.371364593921126 0.0001 1e-06
@value 0.09767145516644697 0.0001 1e-06
Dictionary Key: twist
@value 0.09790920083964022 0.0001 1e-06
4 changes: 2 additions & 2 deletions tests/refs/DAFoam_Test_MphysAeroOptRef.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Dictionary Key: cruise.aero_post.CD
@value 0.03919004721810314 1e-06 1e-08
@value 0.03918787297431089 1e-06 1e-08
Dictionary Key: cruise.aero_post.CL
@value 0.2999950298843596 1e-06 1e-08
@value 0.2999891179061076 1e-06 1e-08
148 changes: 74 additions & 74 deletions tests/refs/DAFoam_Test_MphysAeroPropCoupledRef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,85 +8,85 @@ Dictionary Key: thrust
@value 0.3611900799886527 1e-06 1e-10
Dictionary Key: force_balance
Dictionary Key: prop_shape
@value 40.56645432033733 0.0001 1e-06
@value -558.1380598187881 0.0001 1e-06
@value 467.7734184945811 0.0001 1e-06
@value -158.9914676337573 0.0001 1e-06
@value -85.02618895954103 0.0001 1e-06
@value -627.9557803116626 0.0001 1e-06
@value 140.3194131387392 0.0001 1e-06
@value -0.1713762746667271 0.0001 1e-06
@value -508.127288548224 0.0001 1e-06
@value -540.6253032464376 0.0001 1e-06
@value -104.7456081289921 0.0001 1e-06
@value -161.1842756558842 0.0001 1e-06
@value 60.59671558598635 0.0001 1e-06
@value 116.2388390235131 0.0001 1e-06
@value 354.5260914116756 0.0001 1e-06
@value 336.3699829029644 0.0001 1e-06
@value -347.2898519131134 0.0001 1e-06
@value -130.0392459478966 0.0001 1e-06
@value 525.1168387426317 0.0001 1e-06
@value 298.6611927164653 0.0001 1e-06
@value -108.9449106018517 0.0001 1e-06
@value -62.29976349182109 0.0001 1e-06
@value 341.6203318732158 0.0001 1e-06
@value 263.7148977578634 0.0001 1e-06
@value 40.57011447892199 0.0001 1e-06
@value -558.1394156909686 0.0001 1e-06
@value 467.7771921270105 0.0001 1e-06
@value -158.9944668735331 0.0001 1e-06
@value -85.02737008055752 0.0001 1e-06
@value -627.9548778289284 0.0001 1e-06
@value 140.318474446663 0.0001 1e-06
@value -0.1694117259289669 0.0001 1e-06
@value -508.1280147631104 0.0001 1e-06
@value -540.6248952272629 0.0001 1e-06
@value -104.74310426356 0.0001 1e-06
@value -161.184229377824 0.0001 1e-06
@value 60.59491524505091 0.0001 1e-06
@value 116.2393332241295 0.0001 1e-06
@value 354.5286978848217 0.0001 1e-06
@value 336.3699874842462 0.0001 1e-06
@value -347.2930367286646 0.0001 1e-06
@value -130.0372517970196 0.0001 1e-06
@value 525.1221596957737 0.0001 1e-06
@value 298.6593247134094 0.0001 1e-06
@value -108.9467995921807 0.0001 1e-06
@value -62.29917598906 0.0001 1e-06
@value 341.6238879060646 0.0001 1e-06
@value 263.7148030220755 0.0001 1e-06
Dictionary Key: wing_twist
@value -0.5910416434157874 0.0001 1e-06
@value -0.6212205045129653 0.0001 1e-06
Dictionary Key: lift
Dictionary Key: prop_shape
@value 7.494632028196025 0.0001 1e-06
@value -2.691981732712854 0.0001 1e-06
@value 6.893016044036441 0.0001 1e-06
@value -5.991053822821106 0.0001 1e-06
@value -5.739115722020717 0.0001 1e-06
@value 5.47681875189604 0.0001 1e-06
@value -4.164352933049335 0.0001 1e-06
@value 13.88196713361107 0.0001 1e-06
@value -2.235091169101973 0.0001 1e-06
@value -3.081434681823781 0.0001 1e-06
@value 6.324731236348367 0.0001 1e-06
@value 9.840864367457241 0.0001 1e-06
@value -7.31659760544235 0.0001 1e-06
@value -10.80796786398239 0.0001 1e-06
@value 5.802828854432147 0.0001 1e-06
@value 8.951835560847094 0.0001 1e-06
@value -6.078515425622227 0.0001 1e-06
@value 14.28172057520801 0.0001 1e-06
@value 10.48958602037796 0.0001 1e-06
@value -9.564279220170844 0.0001 1e-06
@value -6.627024939462579 0.0001 1e-06
@value -9.842049987973438 0.0001 1e-06
@value 9.34366016427688 0.0001 1e-06
@value 14.36183778196542 0.0001 1e-06
@value 7.37755063863561 0.0001 1e-06
@value -2.650727700451313 0.0001 1e-06
@value 6.790617938688313 0.0001 1e-06
@value -5.891499618985533 0.0001 1e-06
@value -5.600939745650626 0.0001 1e-06
@value 5.342123399123075 0.0001 1e-06
@value -4.066653677004293 0.0001 1e-06
@value 13.5383549122466 0.0001 1e-06
@value -2.179837392617058 0.0001 1e-06
@value -2.993058240139202 0.0001 1e-06
@value 6.178084688158777 0.0001 1e-06
@value 9.576108764718612 0.0001 1e-06
@value -7.134496985715375 0.0001 1e-06
@value -10.51253550147928 0.0001 1e-06
@value 5.669359902494561 0.0001 1e-06
@value 8.708170216943536 0.0001 1e-06
@value -5.982348335297536 0.0001 1e-06
@value 13.92869912246976 0.0001 1e-06
@value 10.3269883748625 0.0001 1e-06
@value -9.332879662044292 0.0001 1e-06
@value -6.462275830980414 0.0001 1e-06
@value -9.569477213299155 0.0001 1e-06
@value 9.1247009816325 0.0001 1e-06
@value 13.97371605464054 0.0001 1e-06
Dictionary Key: wing_twist
@value 67.6593267198632 0.0001 1e-06
@value 66.712745267288 0.0001 1e-06
Dictionary Key: power
Dictionary Key: prop_shape
@value 21.64495476036015 0.0001 1e-06
@value 9.726766089966382 0.0001 1e-06
@value -16.4582865984792 0.0001 1e-06
@value -66.37785975292292 0.0001 1e-06
@value 11.59301925605034 0.0001 1e-06
@value 29.13037119474476 0.0001 1e-06
@value -29.55344784858206 0.0001 1e-06
@value -4.154484479118967 0.0001 1e-06
@value 22.22860938531955 0.0001 1e-06
@value 25.97576332452039 0.0001 1e-06
@value 19.6348794304481 0.0001 1e-06
@value 19.12141987741848 0.0001 1e-06
@value -50.03884470681318 0.0001 1e-06
@value -32.61146584587635 0.0001 1e-06
@value -32.06312274498524 0.0001 1e-06
@value -38.1047911573768 0.0001 1e-06
@value 0.5725780768975435 0.0001 1e-06
@value 23.22195308385148 0.0001 1e-06
@value 33.42823149513347 0.0001 1e-06
@value 10.06960227413743 0.0001 1e-06
@value 13.88047090531864 0.0001 1e-06
@value 16.78764894295167 0.0001 1e-06
@value 27.70306167537909 0.0001 1e-06
@value 24.33006926407132 0.0001 1e-06
@value 21.64495476035998 0.0001 1e-06
@value 9.726766089966594 0.0001 1e-06
@value -16.45828659847884 0.0001 1e-06
@value -66.37785975292272 0.0001 1e-06
@value 11.59301925605003 0.0001 1e-06
@value 29.13037119474438 0.0001 1e-06
@value -29.55344784858185 0.0001 1e-06
@value -4.154484479118828 0.0001 1e-06
@value 22.22860938531966 0.0001 1e-06
@value 25.97576332452035 0.0001 1e-06
@value 19.63487943044795 0.0001 1e-06
@value 19.12141987741839 0.0001 1e-06
@value -50.03884470681285 0.0001 1e-06
@value -32.61146584587608 0.0001 1e-06
@value -32.06312274498497 0.0001 1e-06
@value -38.10479115737638 0.0001 1e-06
@value 0.5725780768974928 0.0001 1e-06
@value 23.2219530838513 0.0001 1e-06
@value 33.4282314951332 0.0001 1e-06
@value 10.06960227413714 0.0001 1e-06
@value 13.88047090531867 0.0001 1e-06
@value 16.78764894295168 0.0001 1e-06
@value 27.70306167537875 0.0001 1e-06
@value 24.33006926407115 0.0001 1e-06
Dictionary Key: wing_twist
@value -0 0.0001 1e-06
Loading

0 comments on commit f33075a

Please sign in to comment.