5 print 'script requires name of log file'
8 logfilename
= sys
.argv
[1]
9 print 'Reading file', logfilename
12 UpRegex
=r
"([A-Z,a-z]*):*.*Solving for Up, Initial residual = \(([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\), Final residual = \(([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\), No Iterations ([0-9]*)"
13 kepsilonRegex
=r
"([A-Z,a-z]*):*.*Solving for kEpsilon, Initial residual = \(([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\), Final residual = \(([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\), No Iterations ([0-9]*)"
14 komegaRegex
=r
"([A-Z,a-z]*):*.*Solving for kOmega, Initial residual = \(([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\), Final residual = \(([0-9.Ee\-+]*)\s([0-9.Ee\-+]*)\), No Iterations ([0-9]*)"
33 #HJ take name of log file as script argument
34 pipefile
=open(logfilename
,'r')
35 lines
= pipefile
.readlines()
38 matchUp
=re
.search(UpRegex
,line
)
42 Ux
.append(float(matchUp
.group(2)))
43 Uy
.append(float(matchUp
.group(3)))
44 Uz
.append(float(matchUp
.group(4)))
45 p
.append(float(matchUp
.group(5)))
46 matchkepsilon
=re
.search(kepsilonRegex
,line
)
48 ikepsilon
= ikepsilon
+ 1
49 tkepsilon
.append(ikepsilon
)
50 k
.append(float(matchkepsilon
.group(2)))
51 epsilon
.append(float(matchkepsilon
.group(3)))
52 matchkomega
=re
.search(komegaRegex
,line
)
55 tkomega
.append(ikomega
)
56 k
.append(float(matchkomega
.group(2)))
57 omega
.append(float(matchkomega
.group(3)))
59 outfile
=open('residual.dat','w')
62 for data
in zip(tUp
,Ux
,Uy
,Uz
,p
,k
,omega
):
63 outfile
.write(' '.join([str(d
) for d
in data
])+'\n')
65 for data
in zip(tUp
,Ux
,Uy
,Uz
,p
,k
,epsilon
):
66 outfile
.write(' '.join([str(d
) for d
in data
])+'\n')
68 for data
in zip(tUp
,Ux
,Uy
,Uz
,p
):
69 outfile
.write(' '.join([str(d
) for d
in data
])+'\n')
75 pylab
.xlabel('iteration')
76 pylab
.ylabel('residual')
81 pylab
.semilogy(tUp
,Ux
,'-',label
="Ux")
82 pylab
.semilogy(tUp
,Uy
,'-',label
="Uy")
83 pylab
.semilogy(tUp
,Uz
,'-',label
="Uz")
84 pylab
.semilogy(tUp
,p
,'-',label
="p")
87 pylab
.semilogy(tkepsilon
,k
,'-',label
="k")
88 pylab
.semilogy(tkepsilon
,epsilon
,'-',label
="epsilon")
91 pylab
.semilogy(tkomega
,k
,'-',label
="k")
92 pylab
.semilogy(tkomega
,omega
,'-',label
="omega")