<p><b>dwj07@fsu.edu</b> 2013-02-12 16:03:42 -0700 (Tue, 12 Feb 2013)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Adding python script to help create hirearchical decompositions.<br>
        This should be helpful in runs with multiple blocks.<br>
</p><hr noshade><pre><font color="gray">Added: branches/tools/python_scripts/processor_decompositions/README
===================================================================
--- branches/tools/python_scripts/processor_decompositions/README                                (rev 0)
+++ branches/tools/python_scripts/processor_decompositions/README        2013-02-12 23:03:42 UTC (rev 2464)
@@ -0,0 +1,25 @@
+Author: Doug Jacobsen
+Date: 02/12/13
+
+Usage: make_block_graph.py [options]
+
+Options:
+  -h, --help            show this help message and exit
+  -f FILE, --file=FILE  Path to grid file
+  -g FILE, --graph=FILE
+                        Path to graph file
+
+
+About:
+        This script is intended to take in a grid.nc and graph.info.partn.N file
+        where N is the number of blocks a simulation is intended to run with.
+
+        On output, it generates a block.graph.info file, which provides a graph
+        file for blocks.
+
+        This block.graph.info file currently can be passed into metis to generate a
+        block.graph.info.part.M file, where M is the number of processors a run
+        is intended to be run with.
+
+        The block.graph.info.part.M file can be used in tandem with the
+        graph.info.part.N file to improve performance in runs with multiple blocks.

Added: branches/tools/python_scripts/processor_decompositions/make_block_graph.py
===================================================================
--- branches/tools/python_scripts/processor_decompositions/make_block_graph.py                                (rev 0)
+++ branches/tools/python_scripts/processor_decompositions/make_block_graph.py        2013-02-12 23:03:42 UTC (rev 2464)
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+import sys, os, glob, shutil, numpy, math
+
+from collections import defaultdict
+
+from netCDF4 import *
+from netCDF4 import Dataset as NetCDFFile
+from pylab import *
+
+import matplotlib
+import matplotlib.pyplot as plt
+
+from optparse import OptionParser
+
+parser = OptionParser()
+parser.add_option(&quot;-f&quot;, &quot;--file&quot;, dest=&quot;filename&quot;, help=&quot;Path to grid file&quot;, metavar=&quot;FILE&quot;)
+parser.add_option(&quot;-g&quot;, &quot;--graph&quot;, dest=&quot;graphfile&quot;, help=&quot;Path to graph file&quot;, metavar=&quot;FILE&quot;)
+
+options, args = parser.parse_args()
+
+if not options.filename:
+        parser.error(&quot;A grid file is required.&quot;)
+
+if not options.graphfile:
+        parser.error(&quot;A graph file is required.&quot;)
+
+grid = NetCDFFile(options.filename, 'r')
+
+nCells = len(grid.dimensions['nCells'])
+
+nEdgesOnCell = grid.variables['nEdgesOnCell'][:]
+cellsOnCell = grid.variables['cellsOnCell'][:] - 1
+grid.close()
+
+num_blocks = 0
+owning_block = [0] * nCells
+
+graph = open(options.graphfile, 'r')
+
+i = -1
+for block in iter(lambda: graph.readline(), &quot;&quot;):
+        if i &gt;= 0:
+                block_arr = block.split()
+                owning_block[i] = int(block_arr[0])+1
+                num_blocks = max(num_blocks, owning_block[i])
+
+        i = i + 1
+
+graph.close()
+
+blocksOnBlock = defaultdict(list)
+nEdges = 0
+
+for i in np.arange(0, nCells):
+        for j in np.arange(0, nEdgesOnCell[i]):
+                iCell = cellsOnCell[i][j]
+                try:
+                        can_add = True
+                        for block in blocksOnBlock[owning_block[i]]:
+                                if block == owning_block[iCell]:
+                                        can_add = False
+                except:
+                        can_add = True
+
+                if iCell == -1:
+                        can_add = False
+
+                if owning_block[iCell] == owning_block[i]:
+                        can_add = False
+
+                if owning_block[iCell] &lt;= 0:
+                        can_add = False
+
+                if owning_block[i] &lt;= 0:
+                        can_add = False
+
+                if can_add:
+                        nEdges = nEdges + 1
+                        blocksOnBlock[owning_block[i]].append(owning_block[iCell])
+
+del blocksOnBlock[0]
+
+block_graph = open('block.graph.info', 'w+')
+block_graph.write('%s %s</font>
<font color="blue">'%(int(num_blocks), int(nEdges/2)))
+for i in np.arange(1, num_blocks+1):
+        for block in blocksOnBlock[i]:
+                block_graph.write('%s '%int(block))
+        block_graph.write('</font>
<font color="blue">')
+
+block_graph.close()


Property changes on: branches/tools/python_scripts/processor_decompositions/make_block_graph.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
</font>
</pre>