Untitled
unknown
plain_text
a year ago
2.3 kB
4
Indexable
Never
with open('rsls_output.txt') as f: lines = f.readlines() results = {} i=0 while i < len(lines): if lines[i][:7]== 'Running': # start problem execution problem_description = lines[i].split(' ')[2].split('-') solver_used = problem_description[-1].replace('...\n','') grid_size = problem_description[2] node_amount = problem_description[1] while lines[i].startswith("errors") != True: i+=1 snes_vals = [] ksp_main = [] while 'SNES' in lines[i]: snes_value = float(lines[i].split(' ')[-2]) snes_vals.append(snes_value) i+=1 ksp_vals = [] while 'KSP' in lines[i]: if lines[i].split(' ')[-2] == '<': ksp_value = float(lines[i].split(' ')[-1].replace('\n','')) else: ksp_value = float(lines[i].split(' ')[-2]) ksp_vals.append(ksp_value) i+=1 if len(ksp_vals)>0: ksp_main.append(ksp_vals) error_results = lines[i].split(' ') u_exact = float(error_results[11].replace(',','')) u_exact_inf = float(error_results[-1].replace('\n','')) print("grid size?? ", grid_size) if solver_used in results.keys(): results[solver_used].update({ grid_size : { "node_amount" : node_amount, "snes_values" : snes_vals, "ksp_values" : ksp_main } }) else: results.update({solver_used : { grid_size : { "node_amount" : node_amount, "snes_values" : snes_vals, "ksp_values" : ksp_main } }}) i+=1 while lines[i].startswith('Time (sec):') == False: i+=1 execution_time = float(lines[i].split(' ')[-1]) results[solver_used][grid_size].update({"time" : execution_time}) else: i+=1 # print(results) print(results)