Skip to content

Commit 0077056

Browse files
committed
Fix that finite_differences script pulls solution files for restarted run.
1 parent d2b80e0 commit 0077056

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

SU2_PY/SU2/eval/gradients.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,14 @@ def findiff( config, state=None ):
838838
name = su2io.expand_time(name,config)
839839
link.extend(name)
840840

841+
# files: restart solution for dual-time stepping first and second order
842+
if 'RESTART_FILE_1' in files:
843+
name = files['RESTART_FILE_1']
844+
pull.append(name)
845+
if 'RESTART_FILE_2' in files:
846+
name = files['RESTART_FILE_2']
847+
pull.append(name)
848+
841849
# files: target equivarea distribution
842850
if 'EQUIV_AREA' in special_cases and 'TARGET_EA' in files:
843851
pull.append(files['TARGET_EA'])

SU2_PY/finite_differences.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ def finite_differences( filename ,
7777
# State
7878
state = SU2.io.State()
7979
state.find_files(config)
80+
81+
# add restart files to state.FILES
82+
if config.get('TIME_DOMAIN', 'NO') == 'YES' and config.get('RESTART_SOL', 'NO') == 'YES':
83+
restart_name = config['RESTART_FILENAME'].split('.')[0]
84+
restart_filename = restart_name + '_' + str(int(config['RESTART_ITER'])-1).zfill(5) + '.dat'
85+
if not os.path.isfile(restart_filename): # throw, if restart files does not exist
86+
sys.exit("Error: Restart file <" + restart_filename + "> not found.")
87+
state['FILES']['RESTART_FILE_1'] = restart_filename
88+
89+
# use only, if time integration is second order
90+
if config.get('TIME_MARCHING', 'NO') == 'DUAL_TIME_STEPPING-2ND_ORDER':
91+
restart_filename = restart_name + '_' + str(int(config['RESTART_ITER'])-2).zfill(5) + '.dat'
92+
if not os.path.isfile(restart_filename): # throw, if restart files does not exist
93+
sys.exit("Error: Restart file <" + restart_filename + "> not found.")
94+
state['FILES']['RESTART_FILE_2'] =restart_filename
8095

8196
# Finite Difference Gradients
8297
SU2.eval.gradients.findiff(config,state)

0 commit comments

Comments
 (0)