Skip to content

Commit

Permalink
Merge pull request #12 from anilyil/master
Browse files Browse the repository at this point in the history
Zipper fix and some other modifications
  • Loading branch information
camader authored Oct 4, 2019
2 parents 714b782 + 2e8868a commit 54f1a93
Show file tree
Hide file tree
Showing 22 changed files with 1,268 additions and 760 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ python/reg_tests/adflow_test*_reg
python/reg_tests/adflow_reg.ref
python/reg_tests/adflow_reg
src/build/importTest.py

#reg test aux files:
python/reg_tests/*.cgns
python/reg_tests/*.dat
python/reg_tests/*.txt
python/reg_tests/*.zipper
python/inputFiles.tar.gz

# optimization reports from intel compilers
*.optrpt

# for mac users
*.DS_Store
6 changes: 3 additions & 3 deletions config/defaults/config.OSX_GFORTRAN.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ include ${PETSC_DIR}/lib/petsc/conf/variables # PETSc 3.6
PETSC_INCLUDE_FLAGS=${PETSC_CC_INCLUDES} -I$(PETSC_DIR)
PETSC_LINKER_FLAGS=${PETSC_LIB}

# Combine flags from above -- don't modify here
FF90_FLAGS = $(FF90_GEN_FLAGS) $(FF90_OPT_FLAGS) $(FF90_DEBUG_FLAGS)
CC_FLAGS = $(CC_GEN_FLAGS) $(CC_OPT_FLAGS) $(CC_DEBUG_FLAGS)
# # Combine flags from above -- don't modify here
# FF90_FLAGS = $(FF90_GEN_FLAGS) $(FF90_OPT_FLAGS) $(FF90_DEBUG_FLAGS)
# CC_FLAGS = $(CC_GEN_FLAGS) $(CC_OPT_FLAGS) $(CC_DEBUG_FLAGS)
FF90_PRECISION_FLAGS = $(FF90_INTEGER_PRECISION_FLAG)$(FF90_REAL_PRECISION_FLAG)
CC_PRECISION_FLAGS = $(CC_INTEGER_PRECISION_FLAG) $(CC_REAL_PRECISION_FLAG)

Expand Down
2 changes: 2 additions & 0 deletions python/om_func_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
'mdot': 'kg/s',
'mavgptot': 'Pa',
'mavgps': 'Pa',
'aavgptot': 'Pa',
'aavgps': 'Pa',
'mavgttot': 'degK',
'mavgvx':'m/s',
'mavgvy':'m/s',
Expand Down
60 changes: 46 additions & 14 deletions python/om_states_comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def setup(self):
ap = self.options['ap']
geo = self.options['dvgeo']

# flag to keep track of clean restarts. We need this because sometimes
# the current solution fails even if it already was a clean restart because
# the previous one also failed. In these cases, we dont want to retry
# with a clean restart because there is no point.
self.cleanRestart = True

self.ap_vars,_ = get_dvs_and_cons(ap=ap)
self.geo_vars,_ = get_dvs_and_cons(geo=geo)

Expand Down Expand Up @@ -127,30 +133,56 @@ def solve_nonlinear(self, inputs, outputs):
if ap.fatalFail:
if self.comm.rank == 0:
print('###############################################################')
print('#Solve Fatal Fail. Analysis Error')
print('# Solve Fatal Fail. Analysis Error')
print('###############################################################')

raise AnalysisError('ADFLOW Solver Fatal Fail')


if ap.solveFailed: # the mesh was fine, but it didn't converge
if self.comm.rank == 0:
print('###############################################################')
print('#Solve Failed, attempting a clean restart!')
# if the previous iteration was already a clean restart, dont try again
if self.cleanRestart:
print('###############################################################')

ap.solveFailed = False
ap.fatalFail = False
solver.resetFlow(ap)
solver(ap)

if ap.solveFailed or ap.fatalFail: # we tried, but there was no saving it
print('# This was a clean restart. Will not try another one.')
print('###############################################################')
print('#Clean Restart failed. There is no saving this one!')
print('###############################################################')

solver.resetFlow(ap)
self.cleanRestart = True
raise AnalysisError('ADFLOW Solver Fatal Fail')

# the previous iteration restarted from another solution, so we can try again
# with a re-set flowfield for the initial guess.
else:
if self.comm.rank == 0:
print('###############################################################')
print('# Solve Failed, attempting a clean restart!')
print('###############################################################')

ap.solveFailed = False
ap.fatalFail = False
solver.resetFlow(ap)
solver(ap)

if ap.solveFailed or ap.fatalFail: # we tried, but there was no saving it
print('###############################################################')
print('# Clean Restart failed. There is no saving this one!')
print('###############################################################')

# re-set the flow for the next iteration:
solver.resetFlow(ap)
# set the reset flow flag
self.cleanRestart = True
raise AnalysisError('ADFLOW Solver Fatal Fail')

# see comment for the same flag below
else:
self.cleanRestart = False

# solve did not fail, therefore we will re-use this converged flowfield for the next iteration.
# change the flag so that if the next iteration fails with current initial guess, it can retry
# with a clean restart
else:
self.cleanRestart = False


outputs['states'] = solver.getStates()

Expand Down
4 changes: 3 additions & 1 deletion python/pyADflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ def setTargetCp(self, CpTargets, groupName=None, TS=0):
# using mapVector.
npts, ncell = self._getSurfaceSize(self.allWallsGroup)
fullCpTarget = numpy.atleast_2d(self.adflow.getcptargets(npts, TS+1))

# Now map new values in and set.
fullCpTarget = self.mapVector(numpy.atleast_2d(CpTargets).T, groupName, self.allWallsGroup, fullCpTarget.T)
fullCpTarget = fullCpTarget.T
Expand Down Expand Up @@ -5048,6 +5048,8 @@ def _getObjectivesAndDVs(self):
'cavitation':self.adflow.constants.costfunccavitation,
'mdot':self.adflow.constants.costfuncmdot,
'mavgptot':self.adflow.constants.costfuncmavgptot,
'aavgptot':self.adflow.constants.costfuncaavgptot,
'aavgps':self.adflow.constants.costfuncaavgps,
'mavgttot':self.adflow.constants.costfuncmavgttot,
'mavgps':self.adflow.constants.costfuncmavgps,
'mavgmn':self.adflow.constants.costfuncmavgmn,
Expand Down
Loading

0 comments on commit 54f1a93

Please sign in to comment.