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 kRegex
=r
"([A-Z,a-z]*):*.*Solving for k, Initial residual = ([0-9.Ee\-+]*), Final residual = ([0-9.Ee\-+]*), No Iterations ([0-9]*)"
14 omegaRegex
=r
"([A-Z,a-z]*):*.*Solving for omega, Initial residual = ([0-9.Ee\-+]*), Final residual = ([0-9.Ee\-+]*), No Iterations ([0-9]*)"
15 epsilonRegex
=r
"([A-Z,a-z]*):*.*Solving for epsilon, Initial residual = ([0-9.Ee\-+]*), Final residual = ([0-9.Ee\-+]*), No Iterations ([0-9]*)"
36 #HJ take name of log file as script argument
37 pipefile
=open(logfilename
,'r')
38 lines
= pipefile
.readlines()
41 matchUp
=re
.search(UpRegex
,line
)
45 Ux
.append(float(matchUp
.group(2)))
46 Uy
.append(float(matchUp
.group(3)))
47 Uz
.append(float(matchUp
.group(4)))
48 p
.append(float(matchUp
.group(5)))
49 matchk
=re
.search(kRegex
,line
)
53 k
.append(float(matchk
.group(2)))
54 matchomega
=re
.search(omegaRegex
,line
)
58 omega
.append(float(matchomega
.group(2)))
59 matchepsilon
=re
.search(epsilonRegex
,line
)
61 iepsilon
= iepsilon
+ 1
62 tepsilon
.append(iepsilon
)
63 epsilon
.append(float(matchepsilon
.group(2)))
65 outfile
=open('residual.dat','w')
68 for data
in zip(tUp
,Ux
,Uy
,Uz
,p
,k
,omega
):
69 outfile
.write(' '.join([str(d
) for d
in data
])+'\n')
71 for data
in zip(tUp
,Ux
,Uy
,Uz
,p
,k
,epsilon
):
72 outfile
.write(' '.join([str(d
) for d
in data
])+'\n')
74 for data
in zip(tUp
,Ux
,Uy
,Uz
,p
):
75 outfile
.write(' '.join([str(d
) for d
in data
])+'\n')
81 pylab
.xlabel('iteration')
82 pylab
.ylabel('residual')
87 pylab
.semilogy(tUp
,Ux
,'-',label
="Ux")
88 pylab
.semilogy(tUp
,Uy
,'-',label
="Uy")
89 pylab
.semilogy(tUp
,Uz
,'-',label
="Uz")
90 pylab
.semilogy(tUp
,p
,'-',label
="p")
93 pylab
.semilogy(tk
,k
,'-',label
="k")
96 pylab
.semilogy(tomega
,omega
,'-',label
="omega")
99 pylab
.semilogy(tepsilon
,epsilon
,'-',label
="epsilon")