9def parse_residuals( file_name,
14 Parse residuals from input stream
16 @param file_name: String
17 We will open the file through ```open( file_name, "r").
19 @param solver_name: String
20 We have to know which solver to search for, as MGHyPE simulations might
21 host multiple solvers.
23 @return [Float], [Float], [Float]
24 Returns three sequences, all of the same size. The first sequence is the
25 development of the residuals in the max norm, the second in the 2 norm,
26 and the third one hosts the residuals in the h norm.
33 pattern =
r"([-+]?\d*\.?\d+(?:e[-+]?\d+)?)"
34 full_pattern = rf
"\|r\|\_max={pattern},\s*\|r\|\_2={pattern},\s*\|r\|\_h={pattern}"
35 with open(file_name,
'r')
as file:
36 for line
in file.readlines():
37 norms = re.search(full_pattern, line)
38 if "endMeshSweep()" in line
and solver_name
in line
and norms!=
None:
39 r_max, r_2, r_h = map(float, norms.groups())
44 return res_max, res_2, res_h
47def parse_solution_updates( file_name,
52 Parse residuals from input stream
54 @param file_name: String
55 We will open the file through ```open( file_name, "r").
57 @param solver_name: String
58 We have to know which solver to search for, as MGHyPE simulations might
59 host multiple solvers.
61 @return [Float], [Float], [Float]
62 Returns three sequences, all of the same size. The first sequence is the
63 development of the solution updates in the max norm, the second in the 2 norm,
64 and the third one hosts the deltas in the h norm.
71 pattern =
r"([-+]?\d*\.?\d+(?:e[-+]?\d+)?)"
72 full_pattern = rf
"\|du\|\_max={pattern},\s*\|du\|\_2={pattern},\s*\|du\|\_h={pattern}"
73 with open(file_name,
'r')
as file:
74 for line
in file.readlines():
75 norms = re.search(full_pattern, line)
76 if "endMeshSweep()" in line
and solver_name
in line
and norms!=
None:
77 du_max, du_2, du_h = map(float, norms.groups())
78 result_max.append(du_max)
82 return result_max, result_2, result_h