# Create the solver CFDSolver = ADFLOW(options=options, debug=False) # res = CFDSolver.getResidual(ap) # CFDSolver.callMasterRoutine(ap) # CFDSolver(ap) # # Create a common set of seeds wDot = CFDSolver.getStatePerturbation(314) xVDot = CFDSolver.getSpatialPerturbation(314) dwBar = CFDSolver.getStatePerturbation(314) fBar = CFDSolver.getSurfacePerturbation(314) hfBar = CFDSolver.getSurfacePerturbation(314)[:, 1].reshape((len(fBar), 1)) # wBar = CFDSolver.computeJacobianVectorProductBwd(resBar=dwBar, wDeriv=True) # CFDSolver.computeDotProductTest(fBar=True, xVDot=True) # CFDSolver.computeDotProductTest(hfBar=True, xVDot=True) # CFDSolver.computeDotProductTest(hfBar=True, wDot=True) # quit() # dwDot1, fDot1, hfDot1 = CFDSolver.computeJacobianVectorProductFwd( # wDot=wDot, fDeriv=True, hfDeriv=True, residualDeriv=True) # dwDot2, fDot2, hfDot2 = CFDSolver.computeJacobianVectorProductFwd( # wDot=wDot, fDeriv=True, hfDeriv=True, residualDeriv=True, mode='FD', h=1e-8) # print(np.real(dwDot2), np.real(fDot2), np.real(hfDot2))
# reducedSum = MPI.COMM_WORLD.reduce(numpy.sum(res**2)) # print(reducedSum) # res = CFDSolver.getResidual(ap) CFDSolver.callMasterRoutine(ap) # CFDSolver(ap) print('# ---------------------------------------------------#') print('# Dot product Tests #') print('# ---------------------------------------------------#') # Create a common set of seeds wDot = CFDSolver.getStatePerturbation(314) xVDot = CFDSolver.getSpatialPerturbation(314) dwBar = CFDSolver.getStatePerturbation(314) fBar = CFDSolver.getSurfacePerturbation(314) hfBar = CFDSolver.getSurfacePerturbation(314)[:, 1] print('Dot product test for w -> R') dwDot = CFDSolver.computeJacobianVectorProductFwd(wDot=wDot, residualDeriv=True) wBar = CFDSolver.computeJacobianVectorProductBwd(resBar=dwBar, wDeriv=True) dotLocal1 = numpy.sum(dwDot * dwBar) dotLocal2 = numpy.sum(wDot * wBar) reg_par_write_sum(dotLocal1, 1e-10, 1e-10) reg_par_write_sum(dotLocal2, 1e-10, 1e-10) print('Dot product test for Xv -> R')