[cig-commits] commit: fix MADDs4 run/*.py files...jobs now run and visualize

Mercurial hg at geodynamics.org
Wed Dec 9 20:51:16 PST 2009


changeset:   101:2948dd95016b
user:        Marc Spiegelman <mspieg at ldeo.columbia.edu>
date:        Sun Dec 06 00:13:27 2009 -0500
files:       MADDs-4/run/MADDs-4tovtk.py MADDs-4/run/initSolitaryWave.py MADDs-4/run/runMADDs-4.py
description:
fix MADDs4 run/*.py files...jobs now run and visualize


diff -r 4d3585d24e75 -r 2948dd95016b MADDs-4/run/MADDs-4tovtk.py
--- a/MADDs-4/run/MADDs-4tovtk.py	Sun Dec 06 00:12:54 2009 -0500
+++ b/MADDs-4/run/MADDs-4tovtk.py	Sun Dec 06 00:13:27 2009 -0500
@@ -8,10 +8,12 @@ from glob import glob
 from glob import glob
 from optparse import OptionParser
 
-# import vtk utility functions
-sys.path[0] += "/../../python"
+#import vtk utility functions
+REPOHOME = subprocess.Popen(["hg","root"],stdout=subprocess.PIPE).communicate()[0]
+REPOHOME = REPOHOME.replace("\n","")
+sys.path.insert(0,REPOHOME+"/python")
+
 from vtkutils import *
-
 
 usage = "Usage: %prog output_directory"
 parser = OptionParser(usage=usage)
@@ -33,8 +35,7 @@ else:
 # get arguments from directory name and input file
 
 # determine if using P1 or P2 elements by parsing the directory name 
-ONAME = os.path.basename(ODIR)
-use_P2 = ONAME.find('P2') >= 0
+use_P2 = ODIR.find('P2') >= 0
 
 # get the mesh file
 iFile = open("input.options","r")
@@ -52,41 +53,45 @@ N = int(s.replace('.xml.gz','')) # get t
 N = int(s.replace('.xml.gz','')) # get the leading string and convert to N
 
 #if using quadratic elements make a new finer mesh for P1
+P2 = FunctionSpace(mesh,"CG",2);
+P1 = FunctionSpace(mesh,"CG",1);
 if use_P2:
-    P2 = FunctionSpace(mesh,"CG",2);
     fine_mesh = Mesh(mesh)
     fine_mesh.refine()
-    P1 = FunctionSpace(fine_mesh, "CG",1)
-    V = P1  # this isn't correct but it will work
+    P1f = FunctionSpace(fine_mesh, "CG",1)
+    V = P1f  
 else:
-    P1 = FunctionSpace(mesh, "CG",1)
     V = P1
 
 # need a check for this
-M = V + V;
+M1 = V + V;
+M2 = P2 + P2;
 
 # get output file names (and compress if necessary)
 vector_files =  glob("u_vector*.xml")
+vector_files.sort()
 if len(vector_files) > 0:
     print 'compressing .xml files'
     subprocess.call(['gzip','-fv']+vector_files)
 
 vector_files =  glob("u_vector*.xml.gz")
+vector_files.sort()
 if len(vector_files) == 0:
     print 'Error: no compressed vector files'
     exit()
 
 pvd_file = "PressurePorosity.pvd"
-ufile = File(pvd_file)
+ufile = File(pvd_file,"compressed")
 for i in vector_files[:]:
-    u = Function(M,i) # this really shouldn't work but I'm hacking at the moment
-#     if use_P2:
-#         #u_out = interpolate(u_in,M1)
-#         ufile << u
-#     else:
-#         ufile << u
-    ufile << u
-
+    if use_P2:
+        u = Function(M2,i) # this really shouldn't work but I'm hacking at the moment
+        u_out = Function(M1)
+        u_out.interpolate(u);
+        ufile << u_out
+    else:
+        u = Function(M1,i)
+        ufile << u
+        
 # get list of times
 t = []
 for i in vector_files[:]:
diff -r 4d3585d24e75 -r 2948dd95016b MADDs-4/run/initSolitaryWave.py
--- a/MADDs-4/run/initSolitaryWave.py	Sun Dec 06 00:12:54 2009 -0500
+++ b/MADDs-4/run/initSolitaryWave.py	Sun Dec 06 00:13:27 2009 -0500
@@ -71,7 +71,7 @@ P2 = FunctionSpace(mesh, "CG", 2)
 
 print "\nRadial function: " + str 
 
-fP2 = Function(P2, str) # define radial function on quadratic elements
+fP2 = Expression(str, degree=2) # define radial function on quadratic elements
 
 if P == 1:
     if use_projection:
@@ -126,13 +126,14 @@ subprocess.call(["/usr/bin/gzip","-vf",f
 subprocess.call(["/usr/bin/gzip","-vf",filename]);
 
 if P == 1:
-    M = P1 + P1 # mixed element (pressure, porosity)
+    ME = P1 + P1 # mixed element (pressure, porosity)
 elif P == 2:
-    M = P2 + P2
+    ME = P2 + P2
 else:
     print "P=P%d only supporting P1 and P2 elements (at the moment)" % P
 
-u = Function(M,"0.")
+u = Function(ME)
+u.vector().zero();
 
 fx = f.vector()
 ux = u.vector()
diff -r 4d3585d24e75 -r 2948dd95016b MADDs-4/run/runMADDs-4.py
--- a/MADDs-4/run/runMADDs-4.py	Sun Dec 06 00:12:54 2009 -0500
+++ b/MADDs-4/run/runMADDs-4.py	Sun Dec 06 00:13:27 2009 -0500
@@ -99,7 +99,9 @@ str = ' '.join(s);
 # add some quotes around the alternate arguments if -a available
 n = str.find('-a')
 if n > 0:
-    str = str[0:n+2]+' \"'+options.extra_options+'\"\n'
+    str = str[0:n+2]+' \"'+options.extra_options+'\"'
+str += "\n"
+
 logfile.write(str)
 logfile.close()
 



More information about the CIG-COMMITS mailing list