Commit 7064d01c authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Finalise scripts for processing cells dumps so that the edges of partitions can be studied

parent 34ea1f6b
......@@ -33,6 +33,16 @@ import numpy as np
import sys
import pandas
xcol = 0
ycol = 1
zcol = 2
xwcol = 3
ywcol = 4
zwcol = 5
localcol = 18
supercol = 15
activecol = 16
# Command-line arguments.
if len(sys.argv) < 5:
print "usage: ", sys.argv[0], " nx ny nz cell1.dat cell2.dat ..."
......@@ -48,28 +58,27 @@ tcount = 0
for i in range(4, len(sys.argv)):
# Read the file.
#data = pl.loadtxt(sys.argv[i])
data = pandas.read_csv(sys.argv[i], sep="\s+").values
data = pl.loadtxt(sys.argv[i])
#print data
# Select cells that are on the current rank and are top-level.
rdata = data[data[:,16] == 1]
tdata = rdata[rdata[:,9] == 0]
# Select cells that are on the current rank and are super cells.
rdata = data[data[:,localcol] == 1]
tdata = rdata[rdata[:,supercol] == 1]
# Separation of the cells is in data.
xwidth = tdata[0,3]
ywidth = tdata[0,4]
zwidth = tdata[0,5]
xwidth = tdata[0,xwcol]
ywidth = tdata[0,ywcol]
zwidth = tdata[0,zwcol]
# Fill space nx, ny,n nz with all toplevel cells and flag their active
# state.
space = np.zeros((nx,ny,nz))
actives = []
for line in tdata:
ix = int(np.rint(line[0] / xwidth))
iy = int(np.rint(line[1] / ywidth))
iz = int(np.rint(line[2] / zwidth))
active = int(line[14])
ix = int(np.rint(line[xcol] / xwidth))
iy = int(np.rint(line[ycol] / ywidth))
iz = int(np.rint(line[zcol] / zwidth))
active = int(line[activecol])
space[ix,iy,iz] = 1 + active
tcount = tcount + 1
if active == 1:
......@@ -110,8 +119,6 @@ for i in range(4, len(sys.argv)):
allactives.extend(actives)
print "# top cells: ", tcount, " active: ", len(allactives), " on edge: ", onedge
sys.exit(0)
......
#!/bin/bash
#
# Usage:
# process_cells nprocess
# process_cells nx ny nz nprocess
#
# Description:
# Process all the cell dumps in the current directory
# Process all the cell dumps in the current directory.
# Outputs file per rank with the active cells identified and marked as to
# whether they are near an edge or not. Note requires the numbers of cells
# per dimension of the space.
#
# Outputs file per rank with the active cells identified and marked
# as to whether they are near an edge or not.
# Also outputs a graphic showing the fraction of active cells on edges
# for each step.
# Handle command-line
if test "$1" = ""; then
echo "Usage: $0 nprocess"
if test "$4" = ""; then
echo "Usage: $0 nx ny nz nprocess"
exit 1
fi
NPROCS=$1
NX=$1
NY=$2
NZ=$3
NPROCS=$4
# Locate script.
SCRIPTHOME=$(dirname "$0")
......@@ -33,19 +40,25 @@ echo "Number of ranks = $ranks"
# Now construct a list of files ordered by rank, not step.
files=$(ls cells_*.dat | sort -t "_" -k 3,3 -n | xargs -n 4)
# Need number of steps.
nfiles=$(echo $files| wc -w)
echo "Number of files = $nfiles"
steps=$(( $nfiles / $ranks + 1 ))
echo "Number of steps = $steps"
# And process them,
echo "Processing cell dumps files..."
echo $files | xargs -P $NPROCS -n 4 /bin/bash -c "${SCRIPTHOME}/process_cells_helper 20 20 20 \$0 \$1 \$2 \$3"
#echo $files | xargs -P $NPROCS -n 4 /bin/bash -c "${SCRIPTHOME}/process_cells_helper $NX $NY $NZ \$0 \$1 \$2 \$3"
# Create summary.
grep "top cells" step*-active-cells.dat | sort -h > active_cells.log
# And plot of active cells to edge cells.
stilts plot2plane ifmt=ascii in=active_cells.log xmin=-0.1 xmax=1.1 ymin=-100 ymax=2200 grid=1 \
stilts plot2plane ifmt=ascii in=active_cells.log xmin=-0.1 xmax=1.1 ymin=0 ymax=$steps grid=1 \
legend=false xpix=600 ypix=500 xlabel="Edge cells/Active cells" ylabel="Step" \
layer1=mark x1="col9/1.0/col6" y1="index*7" size1=3 shading1=aux auxmap=rainbow \
layer1=mark x1="col9/1.0/col6" y1="index" size1=3 shading1=aux auxmap=rainbow \
aux=col6 auxfunc=log auxlabel="Active cells" layer2=histogram x2="col9/1.0/col6" \
color2=grey binsize2=0.01 phase2=0.5 barform2=semi_steps weight2=30 thick2=1 \
color2=grey binsize2=0.01 phase2=0.5 barform2=semi_steps thick2=1 \
out=active_cells.png
exit
......@@ -6,6 +6,7 @@
SCRIPTHOME=$(dirname "$0")
step=$(echo $4|sed 's,cells_\(.*\)_\(.*\).dat,\2,')
echo "${SCRIPTHOME}/analyse_dump_cells.py $* > step${step}-active-cells.dat"
${SCRIPTHOME}/analyse_dump_cells.py $* > step${step}-active-cells.dat
exit
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment