Post on 30-Apr-2022
Applications of differentiated CAD kernel inindustrial shape optimisation
Mladen Banovic, Orest Mykhaskiv, Salvatore AuriemmaAndrea Walther, Jens-Dominik Müller, Herve Legrand
mladen.banovic@math.uni-paderborn.de
16th February, 2017AD workshop, INRIA, France
CAD-based shape optimisation
CAD-based shape optimisation
Given a CAD-model with design parameters α
Gradient-based optimisationminα
J(U(Xs(α)),Xs(α), α) (1)
R(U(Xs(α)),Xs(α)) = 0 (2)
dJdα
=dJ
dXS
dXS
dα(3)
I CFD sensitivity dJdXS
: Adjoint method (efficiency)
I CAD sensitivity dXSdα : Forward and Reverse Automatic
Differentiation
Mladen Banovic 1 / 23 16.02.2017
OpenCASCADE Technology
OpenCASCADE Technology
OpenCASCADE Technology (OCCT) is an open source C++ library,consisting of thousands of classes and providing solutions in theareas of:
I Surface and solid modelling: to model any type of object,I 3D and 2D visualization: to display and animate objects,I Data exchange (import and export standard CAD formats) and
tree-like data model.
Mladen Banovic 2 / 23 16.02.2017
U-bend
Test-case 1: U-bend
Mladen Banovic 3 / 23 16.02.2017
TUB Stator
Test-case 2: TU Berlin TurboLab Stator
Mladen Banovic 4 / 23 16.02.2017
CAD sensitivities
Calculating the CAD sensitivities
In order to calculate the shape derivatives w.r.t. design parameters,OCCT has been differentiated by integrating the AD tool ADOL-C.
Automatic Differentiation by OverLoading in C++ADOL-C uses operator overloading concept to compute first andhigher derivatives of vector functions that are written in C or C++.
Options Differentiation modes Integrated to OCCTtrace-based forward, reverse In progress
traceless forward X
Mladen Banovic 5 / 23 16.02.2017
CAD sensitivities - examples
CAD sensitivities on U-bend
Mladen Banovic 6 / 23 16.02.2017
Performance tests
Run-time ratios - Traceless forward mode
0 8 16 24 32 40 48 56 64 72 80 88 96Number of directions (p)
0
20
40
60
80
100
120
140
160R
un-t
ime r
ati
o
1 + 1.5p1 + 1pg++ v4.8.5clang++ v3.7.0
Mladen Banovic 7 / 23 16.02.2017
Memory requirements
Memory req. - Traceless forward mode
0 8 16 24 32 40 48 56 64 72 80 88 96Number of directions
0
50
100
150
200
250
300
350Tota
l m
em
ory
consu
mpti
on [
MB
]
Mladen Banovic 8 / 23 16.02.2017
Reverse mode of AD - validation
Optimisation example that validates thereverse mode differentiation of OCCT
1. Construct two U-bends: original and perturbed one.2. Sample final B-Spline surfaces with 12K pairs of (u, v )
parametric coordinates.3. Define a cost function as the sum of squared distances of all (x,
y, z) point pairs.4. Declare the original design parameters as independent variables
of the system.5. Minimise the cost function by using the L-BFGS-B optimisation
algorithm.6. Run the whole optimisation twice to compare two versions of
differentiated OCCT kernel.
Mladen Banovic 9 / 23 16.02.2017
Reverse mode of AD - validation
Optimisation example that validates thereverse mode differentiation of OCCT
Mladen Banovic 10 / 23 16.02.2017
Reverse mode of AD - validation
Results - Traceless forward vs Reversemode of AD
0 10 20 30 40 50 60 70 80
Number of iterations
10−15
10−13
10−11
10−9
10−7
10−5
10−3
10−1
101
Cos
t-fu
ncti
onva
lue
Traceless Forward modeTrace-based Reverse modeAbs. difference
0 20 40 60 80 100
Gradient index
−1.5
−1.0
−0.5
0.0
0.5
1.0
1.5
Differen
ce
×10−10
Iteration_0Iteration_1Iteration_2Iteration_3Iteration_4
Differentiation mode Average duration (sec)Traceless forward 13.7
Reverse 6.2
Improved efficiency with the reverse mode: 55%
Mladen Banovic 11 / 23 16.02.2017
Complete design chain
CAD, set α
Mesh on CAD
Run primal CFD
Run adjoint CFD
CFD Sensitivity
CAD sensitivity
dJdα = dJ
dXS
dXSdα
FINAL CAD
α(n+1) =A(α(n), dJ
dα (α(n)))
Update CAD αn+1,Surface Movement
Update SurfaceMesh, αn+1
Volume MeshPerturbation
STAMPS solverCFD Solver from QMULDiscrete Adjoint ADSpring/Elasticity AnalogyMesh Perturbation
OCCT ADBuild Shapes (α)Find Mesh on CADParametric Mesh (u, v)Sensitivities in (u, v)
Optimiser
Steepest Descent
Mladen Banovic 12 / 23 16.02.2017
Evaluating the total gradient
Evaluating the total gradient dJ/dα
1. Compute the CAD sensitivity independently by using the OCCTkernel differentiated in the forward traceless mode and couple itwith the CFD sensitivity.
2. Use the reverse mode of AD inside OCCT, thus having a fullreverse mode differentiation of the complete differentiated designchain.
Mladen Banovic 13 / 23 16.02.2017
Evaluating the total gradient
Traceless forward vector modevector<adouble> designParameters = ...; //init the values//put the derivative seedsfor(int i = 0; i < nParams; ++i)designParameters[i].setADValue(i, 1.);
//construct the CAD modelHandle(Geom_BSplineSurface) finalSurf = ConstructGeometry(designParameters);//calculate the surface points derivatives w.r.t. design parametersvector<double> cadSens;for(double u = 0.; u <= 1.; u+=step){for(double v = 0.; v <= 1.; v+=step){gp_Pnt aPnt;finalSurf->D0(u, v, aPnt);for(int i = 0; i < nParams; ++i){cadSens.push_back(aPnt.X().getADValue(i));cadSens.push_back(aPnt.Y().getADValue(i));cadSens.push_back(aPnt.Z().getADValue(i));
}}
}// ... cadSens x cfdSens ... => total gradient
Mladen Banovic 14 / 23 16.02.2017
Evaluating the total gradient
Reverse mode using ADOL-C trace (I)Generating the tracevector<double> designParameters = ...; //init the valuesadouble* adParameters = new adouble[nParams];//start tracing, set the independentstrace_on(1);for(int i = 0; i < nParams; ++i)adParameters[i] <<= designParameters[i];
//construct the CAD model and evaluate the surface pointsHandle(Geom_BSplineSurface) finalSurf = ConstructGeometry(designParameters);for(double u = 0.; u <= 1.; u+=step){for(double v = 0.; v <= 1.; v+=step){gp_Pnt aPnt;finalSurf->D0(u, v, aPnt);aPnt.X() >>= output; //marking the dependentsaPnt.Y() >>= output; //marking the dependentsaPnt.Z() >>= output; //marking the dependents
}}//end tracingtrace_off();
Mladen Banovic 15 / 23 16.02.2017
Evaluating the total gradient
Reverse mode using ADOL-C trace (II)
Evaluating trace - calculating the gradientdouble *independent = new double[nParams];
for(int i = 0; i < nParams; ++i)independent[i] = designParameters[i];
double *cfdSens = GetCfdSensitivities1dArray();
double *gradient = new double[nParams];
//use the vector jacobian product to evaluate the total gradientvec_jac(1, sizeOfCfdSens, nParams, 0, independent, cfdSens, gradient);
Mladen Banovic 16 / 23 16.02.2017
Latest U-bend results
Parametric U-bend optimisation results withthe STAMPS flow solver (I)
Mladen Banovic 17 / 23 16.02.2017
Latest U-bend results
Parametric U-bend optimisation results withthe STAMPS flow solver (II)
Mladen Banovic 18 / 23 16.02.2017
Latest U-bend results
Parametric U-bend optimisation results withthe STAMPS flow solver (III)
Reduction of the total pressure loss = 17.9%.
0 5 10 15 20 25
Number of iterations
2.8
2.9
3.0
3.1
3.2
3.3
3.4
3.5
Cos
t-fu
ncti
onva
lue
Reverse mode of AD
Mladen Banovic 19 / 23 16.02.2017
Latest TUB Stator results
TUB Stator optimisation results with theSTAMPS flow solver (I)
Mladen Banovic 20 / 23 16.02.2017
Latest TUB Stator results
TUB Stator optimisation results with theSTAMPS flow solver (II)
Total Pressure, Pa
18%
Mladen Banovic 21 / 23 16.02.2017
Conclusions
Conclusions
Current statusX Differentiated full CAD-systemX Coupled with adjoint CFD - complete differentiated design chain.X Reverse mode differentiation of OCCT validated for U-bend.
Further workI Validate reverse mode differentiation of OCCT on TU Berlin
TurboLab Stator.
Mladen Banovic 22 / 23 16.02.2017
Acknowledgements
Research is conducted within IODA1 projectIndustrial Optimal Design using Adjoint CFD
1http://ioda.sems.qmul.ac.uk/ Grant Agreement No. 642959.
Mladen Banovic 23 / 23 16.02.2017