Skip to content

Commit

Permalink
Add MPI box count tools (#15)
Browse files Browse the repository at this point in the history
* Add MPI box count tools

* Minor typo

* Fixed typo in processing.sh so that any number of levels is read correctly. Put into directory Boxcounter with README

Co-authored-by: Amelia Drew <[email protected]>
  • Loading branch information
amelialdrew and Amelia Drew authored Jun 3, 2021
1 parent a85a8f7 commit fa2af5b
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PythonTools/Boxcounter/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The bash script processing.sh takes a pout.0 from a run and parses it so that it is in a format that reads 'level, time, boxes on this proc, total boxes'. Run using './processing.sh' in the same directory as the pout.0 and it outputs pout.0_parsed

This pout.0_parsed can then be processed by running 'python extractboxes.py' to plot the total number of boxes per refinement level. Must manually set max refinement level to plot in L16. Outputs a graph for each level i which includes all levels < i, easily modifiable.
38 changes: 38 additions & 0 deletions PythonTools/Boxcounter/extractboxes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import csv
import matplotlib.pyplot as plt

'''Run processing.sh with pout.0 - outputs level, time, boxes on proc 0, total boxes'''
'''Only works on output with verbosity 0'''

i=0

data = open('pout.0_parsed')
with data as csvfile:
filereader = csv.reader(csvfile, delimiter=',')
timelist = [] #col 1
totalboxlist = [] #col 3

'''Hardcoded max level to plot'''
while i < 10:
for row in filereader:
if int(row[0]) == i:
'''Can input max time'''
# if float(row[1]) < 300:
timelist.append(float(row[1]))
totalboxlist.append(int(row[3]))

plt.plot(timelist, totalboxlist, label='%s' % i)
plt.legend()
plt.savefig('boxplot_level_%s.png' % i)

timelist.clear()
totalboxlist.clear()

'''Resets file loop'''
data.seek(0)

i+=1

print('%s' % i)


9 changes: 9 additions & 0 deletions PythonTools/Boxcounter/processing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

sed -n '/GRAMRLevel::/,$p' ./pout.0 > ./pout.0_temp
sed -e 's!GRAMRLevel::advance level !!' ./pout.0_temp > ./pout.0_temp2
sed -r 's/\s+/, /' ./pout.0_temp2 > ./pout.0_temp
sed -e 's!at time !!' ./pout.0_temp > ./pout.0_temp2
sed -e 's/ (.*:/,/' ./pout.0_temp2 > ./pout.0_temp
sed -e 's/ \//,/' ./pout.0_temp > ./pout.0_parsed
rm ./pout.0_temp ./pout.0_temp2
38 changes: 38 additions & 0 deletions PythonTools/extractboxes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import csv
import matplotlib.pyplot as plt

'''Run processing.sh with pout.0 - outputs level, time, boxes on proc 0, total boxes'''
'''Only works on output with verbosity 0'''

i=0

data = open('pout.0_parsed')
with data as csvfile:
filereader = csv.reader(csvfile, delimiter=',')
timelist = [] #col 1
totalboxlist = [] #col 3

'''Hardcoded max level to plot'''
while i < 10:
for row in filereader:
if int(row[0]) == i:
'''Can input max time'''
# if float(row[1]) < 300:
timelist.append(float(row[1]))
totalboxlist.append(int(row[3]))

plt.plot(timelist, totalboxlist, label='%s' % i)
plt.legend()
plt.savefig('boxplot_level_%s.png' % i)

timelist.clear()
totalboxlist.clear()

'''Resets file loop'''
data.seek(0)

i+=1

print('%s' % i)


9 changes: 9 additions & 0 deletions PythonTools/processing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

sed -n '/GRAMRLevel::/,$p' ./pout.0 > ./pout.0_temp
sed -e 's!GRAMRLevel::advance level !!' ./pout.0_temp > ./pout.0_temp2
sed -r 's/\s+/, /' ./pout.0_temp2 > ./pout.0_temp
sed -e 's!at time !!' ./pout.0_temp > ./pout.0_temp2
sed -e 's/ (.*:/,/' ./pout.0_temp2 > ./pout.0_temp
sed -e 's/ \//,/' ./pout.0_temp > ./pout.0_parsed
rm ./pout.0_temp ./pout.0_temp2

0 comments on commit fa2af5b

Please sign in to comment.