[cig-commits] [commit] master: Add ability to combine "heating" output (7ca37a6)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Feb 14 14:32:41 PST 2014
Repository : ssh://geoshell/citcoms
On branch : master
Link : https://github.com/geodynamics/citcoms/compare/c770f8e2897398470734bc655d8a155819f81c57...fb1839e7e93bc56eb542afd64b3db70f2df6a5d8
>---------------------------------------------------------------
commit 7ca37a6c25611762a837e3dc34223e283d66aaac
Author: karredondo <karredondo at ucdavis.edu>
Date: Fri Feb 14 14:30:31 2014 -0800
Add ability to combine "heating" output
Katrina Arredondo
Heating output is in terms of elements instead of nodes. The data is
placed in a third combine file "ele" aside from "cap" and "opt."
>---------------------------------------------------------------
7ca37a6c25611762a837e3dc34223e283d66aaac
visual/autocombine.py | 27 ++++++++++++++++++++++++++-
visual/batchcombine.py | 2 +-
visual/combine.py | 46 +++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/visual/autocombine.py b/visual/autocombine.py
old mode 100755
new mode 100644
index 9f3ad20..604e544
--- a/visual/autocombine.py
+++ b/visual/autocombine.py
@@ -34,6 +34,7 @@ usage: autocombine.py machinefile inputfile step1 [step2 [...] ]
# default values for CitcomS input
defaults = {'output_format': 'ascii',
'output_optional': 'surf,botm',
+ 'output_optional_EL': 'heating',
'buoy_type': 1,
'tracer_flavors': 2,
'nprocx': 1,
@@ -53,12 +54,26 @@ def normalize_optional(output_optional):
opt = opt.strip()
## retain fields that are node-based
- if opt in ('pressure', 'stress', 'comp_nd'):
+ if opt in ('pressure', 'stress', 'comp_nd','phase'):
fields.append(opt)
return ','.join(fields)
+def normalize_optional_EL(output_optional_EL):
+ fields = []
+
+ for opt_EL in output_optional_EL.split(','):
+ ## remove the leading/trailing whitespaces
+ opt_EL = opt_EL.strip()
+
+ ## retain fields that are node-based
+ if opt_EL in ('heating'):
+ fields.append(opt_EL)
+
+
+ return ','.join(fields)
+
if __name__ == '__main__':
@@ -91,6 +106,9 @@ if __name__ == '__main__':
output_optional = parser.getstr('output_optional')
optional_fields = normalize_optional(output_optional)
+ output_optional_EL = parser.getstr('output_optional_EL')
+ optional_fields_EL = normalize_optional_EL(output_optional_EL)
+
buoy_type = parser.getint('buoy_type')
nflavors = parser.getint('tracer_flavors')
if buoy_type == 0:
@@ -129,6 +147,13 @@ if __name__ == '__main__':
ncap, nprocx, nprocy, nprocz,
optional_fields, ncompositions)
+ # combining optional fields (based on element number), if necessary
+ if optional_fields_EL:
+ bc.batchcombine(nodelist, datadir, datafile, timestep,
+ (nodex - 1), (nodey-1), (nodez-1),
+ ncap, (nprocx - 0), (nprocy-0), (nprocz - 0),
+ optional_fields_EL, ncompositions)
+
# version
diff --git a/visual/batchcombine.py b/visual/batchcombine.py
old mode 100755
new mode 100644
index 280488f..9bfb847
--- a/visual/batchcombine.py
+++ b/visual/batchcombine.py
@@ -81,7 +81,7 @@ def batchpaste(datadir, datafile, fields, timestep, nodes):
cwd = os.getcwd()
for rank, node in enumerate(nodes):
- if node == 'localhost' or node == '-' or node == hostname:
+ if node == 'localhost' or node == hostname:
# local paste
import pasteCitcomData
pasteCitcomData.run(datadir, datafile, fields, rank, timestep, cwd)
diff --git a/visual/combine.py b/visual/combine.py
index 232a3fe..a159856 100755
--- a/visual/combine.py
+++ b/visual/combine.py
@@ -101,6 +101,45 @@ class Combine(object):
+ def join_EL(self, data, me):
+ # processor geometry
+ nprocx = self.nprocx
+ nprocy = self.nprocy
+ nprocz = self.nprocz
+
+ mylocz = me % nprocz
+ mylocx = ((me - mylocz) / nprocz) % nprocx
+ mylocy = (((me - mylocz) / nprocz - mylocx) / nprocx) % nprocy
+
+ # mesh geometry
+ nodex = self.nodex
+ nodey = self.nodey
+ nodez = self.nodez
+
+ mynodex = 1 + (nodex-nprocx)/nprocx
+ mynodey = 1 + (nodey-nprocy)/nprocy
+ mynodez = 1 + (nodez-nprocz)/nprocz
+
+ if not len(data) == mynodex * mynodey * mynodez:
+ raise ValueError, "incorrect data size"
+
+
+ mynxs = (mynodex - 0) * mylocx
+ mynys = (mynodey - 0) * mylocy
+ mynzs = (mynodez - 0) * mylocz
+
+ n = 0
+ for i in range(mynys, mynys+mynodey):
+ for j in range(mynxs, mynxs + mynodex):
+ for k in range(mynzs, mynzs + mynodez):
+ m = k + j * nodez + i * nodex * nodez
+ self.saved[m] = data[n]
+ n += 1
+
+ return
+
+
+
def write(self, filename):
fp = file(filename, 'w')
header = '%d x %d x %d\n' % (self.nodex, self.nodey, self.nodez)
@@ -124,10 +163,15 @@ def combine(prefix, opts, step, nodex, nodey, nodez,
filename = '%s.%s.%d.%d.pasted' % (prefix, opts, n, step)
print 'reading', filename
data = cb.readData(filename, 0)
- cb.join(data, n)
+ if opts == 'heating':
+ cb.join_EL(data, n)
+ else:
+ cb.join(data, n)
if opts == 'coord,velo,visc':
filename = '%s.cap%02d.%d' % (prefix, i, step)
+ elif opts == 'heating':
+ filename = '%s.ele%02d.%d' % (prefix, i, step)
else:
filename = '%s.opt%02d.%d' % (prefix, i, step)
More information about the CIG-COMMITS
mailing list