Skip to content

Commit

Permalink
Merge branch 'master' into conv_pics
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Anibal authored Feb 11, 2022
2 parents 9b05646 + 9bfbeb2 commit bbdf017
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
15 changes: 10 additions & 5 deletions adflow/pyADflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3405,11 +3405,16 @@ def solveAdjoint(self, aeroProblem, objective, forcePoints=None, structAdjoint=N
# on this AP, there is no point in solving the reset, so continue
# with psi set as zero
if not (self.curAP.adjointFailed and self.getOption("skipafterfailedadjoint")):
# Extract the psi:
psi = self.curAP.adflowData.adjoints[objective]

# Actually Solve the adjoint system...psi is updated with the
# new solution.
if self.getOption("restartAdjoint"):
# Use the previous solution as the initial guess
psi = self.curAP.adflowData.adjoints[objective]
else:
# Use a zero initial guess
psi = numpy.zeros_like(self.curAP.adflowData.adjoints[objective])

# Actually solve the adjoint system
# psi is updated with the new solution
self.adflow.adjointapi.solveadjoint(RHS, psi, True)

# Now set the flags and possibly reset adjoint
Expand Down Expand Up @@ -5303,7 +5308,6 @@ def _getOptionMap(self):
"viscpc": ["adjoint", "viscpc"],
"frozenturbulence": ["adjoint", "frozenturbulence"],
"usediagtspc": ["adjoint", "usediagtspc"],
"restartadjoint": ["adjoint", "restartadjoint"],
"adjointsolver": {
"gmres": "gmres",
"tfqmr": "tfqmr",
Expand Down Expand Up @@ -5371,6 +5375,7 @@ def _getSpecialOptionLists(self):
"outputsurfacefamily",
"cutcallback",
"infchangecorrection",
"restartadjoint",
"skipafterfailedadjoint",
"useexternaldynamicmesh",
}
Expand Down
10 changes: 4 additions & 6 deletions src/f2py/adflow.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -677,17 +677,17 @@ python module libadflow
integer(kind=inttype) dimension(:,:) :: bcdatafamlists
logical intent(in) :: bcvarsempty
end subroutine computematrixfreeproductbwd


subroutine computematrixfreeproductbwdfast(dwbar, wbar, statesize)! in :test:adjointapi.f90:adjointapi
real(kind=realtype) dimension(:),intent(in) :: dwbar
real(kind=realtype) dimension(statesize),intent(out),depend(statesize) :: wbar
integer(kind=inttype) intent(in) :: statesize
end subroutine computematrixfreeproductbwdfast
end subroutine computematrixfreeproductbwdfast
#endif
end module adjointapi
module adjointdebug

#ifndef USE_COMPLEX
subroutine computematrixfreeproductfwdfd(xvdot,extradot,wdot,bcdatavaluesdot,usespatial,usestate,famlists,bcdatanames,bcdatavalues,bcdatafamlists,bcvarsempty,dwdot,funcsdot,fdot,costsize,fsize,ntime,h) ! in :test:adjointAPI.F90:adjointdebug
real(kind=realtype) dimension(:),intent(in) :: xvdot
Expand Down Expand Up @@ -1220,7 +1220,6 @@ python module libadflow
logical :: viscpc
logical :: frozenturbulence
logical :: usediagtspc
logical :: restartadjoint
logical :: setmonitor
logical :: printtiming
logical :: firstrun
Expand Down Expand Up @@ -1310,7 +1309,6 @@ python module libadflow
logical :: showcpu
logical :: monmasssliding
logical :: monmassfamilies
integer :: nitercur
real(kind=realtype) allocatable,dimension(:,:,:) :: convarray
integer(kind=inttype) :: ntimestepsrestart
integer(kind=inttype) :: timestepunsteady
Expand Down
4 changes: 1 addition & 3 deletions src/modules/inputParam.F90
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,9 @@ module inputADjoint
! viscPC : Whether or not to keep cross derivative terms
! in viscous preconditioner.
! FrozenTurbulence: Whether to use frozen turbulence assumption
! restartADjoint: Whether or not we want to restart the adjoint
! from the previous solution
! useDiagTSPC : Whether or not the off time instance terms are
! included in the TS preconditioner.
logical :: setMonitor, ApproxPC, restartADjoint, useDiagTSPC
logical :: setMonitor, ApproxPC, useDiagTSPC
logical :: frozenTurbulence, viscPC, ADPC

! ADjointSolverType: Type of linear solver for the ADjoint
Expand Down
5 changes: 0 additions & 5 deletions src/modules/monitor.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ module monitor
!
! Variables to store the convergence info.
!
! nIterCur: Current number of iterations. Also niterCur is an
! integer, because of cgns.

integer :: nIterCur

! convArray(0:nIterMax,nsps,nmon): 3D array to store the
! convergence histories.

Expand Down
11 changes: 6 additions & 5 deletions src/output/writeCGNSVolume.F90
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ subroutine writeCGNSConvInfo
!
use inputIO
use inputPhysics
use monitor
use monitor, only : nMon, monNames, convArray
use iteration, only : iterTot
use su_cgns
use outputMod
use utils, only : terminate
Expand All @@ -510,9 +511,9 @@ subroutine writeCGNSConvInfo
if(.not. storeConvInnerIter) return

! Store the number of iterations to be written in nn.
! This is nIterCur + 1, because the array starts at 0.
! This is iterTot + 1, because the array starts at 0.

nn = nIterCur + 1
nn = iterTot + 1

! Depending on the input option, set the CGNS type and allocate
! the memory for either buf4 or buf8.
Expand All @@ -521,7 +522,7 @@ subroutine writeCGNSConvInfo
! that's what Tecplot needs

realTypeCGNS = RealDouble
allocate(buf8(0:nIterCur), stat=ierr)
allocate(buf8(0:iterTot), stat=ierr)


if(ierr /= 0) &
Expand Down Expand Up @@ -585,7 +586,7 @@ subroutine writeCGNSConvInfo

! Copy the convergence info to either buf4 or buf8 and write
! it to file.
do mm=0,nIterCur
do mm=0,iterTot
buf8(mm) = convArray(mm,conv,i)
enddo

Expand Down
4 changes: 2 additions & 2 deletions src/solver/solvers.F90
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ subroutine solveState
nMGCycles = nCycles
if(groundLevel > 1) nMGCycles = nCyclesCoarse

! Allocate (or reallocate) the convergence arry for this solveState.
! Allocate (or reallocate) the convergence array for this solveState.
call allocConvArrays(nMGCycles)

! Allocate space for storing hisotry of function evaluations for NK
Expand Down Expand Up @@ -1297,7 +1297,7 @@ subroutine convergenceInfo
! Determine whether or not the iterations must be written.

writeIterations = .true.
if(equationMode == unsteady .and. &
if(equationMode == unsteady .and. &
timeIntegrationScheme == explicitRK) writeIterations = .false.

! Initializations
Expand Down

0 comments on commit bbdf017

Please sign in to comment.