[cig-commits] r20659 - seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT

percygalvez at geodynamics.org percygalvez at geodynamics.org
Sat Sep 1 12:23:28 PDT 2012


Author: percygalvez
Date: 2012-09-01 12:23:27 -0700 (Sat, 01 Sep 2012)
New Revision: 20659

Modified:
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py
Log:
fixing m2km

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py	2012-09-01 17:17:55 UTC (rev 20658)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py	2012-09-01 19:23:27 UTC (rev 20659)
@@ -1,5 +1,11 @@
 #!python
 
+# Pg , functions Read_fault_nodes and nodes_coords_fault_open has been modified
+#  to read properly fault_file_xxx.dat .
+# Convention : Side up   = side 2   (+)
+#            : Side down = side 1 (-)
+import os
+
 def read_nodes_coord_file(filein):
     file = open(filein,'r')
     nnodes = file.readline()
@@ -20,18 +26,11 @@
 def read_fault_nodes(filein):
     file = open(filein,'r')
     nodes_side1_side2 = file.readline()
-    nside_ud = nodes_side1_side2.split()
-    nnodes_u = int(nside_ud[0])
-    nnodes_d = int(nside_ud[1])
+    nside_du = nodes_side1_side2.split()
+    nnodes_d = int(nside_du[0])
+    nnodes_u = int(nside_du[1])
     nodes_u=[]
     nodes_d=[]
-    for i in range(nnodes_u):
-        hnodes = file.readline()
-        hnodesplit = hnodes.split()
-        nodes_u.append(int(hnodesplit[1]))
-        nodes_u.append(int(hnodesplit[2]))
-        nodes_u.append(int(hnodesplit[3]))
-        nodes_u.append(int(hnodesplit[4]))
    
     for i in range(nnodes_d):
         hnodes = file.readline()
@@ -41,6 +40,14 @@
         nodes_d.append(int(hnodesplit[3]))
         nodes_d.append(int(hnodesplit[4]))
 
+    for i in range(nnodes_u):
+        hnodes = file.readline()
+        hnodesplit = hnodes.split()
+        nodes_u.append(int(hnodesplit[1]))
+        nodes_u.append(int(hnodesplit[2]))
+        nodes_u.append(int(hnodesplit[3]))
+        nodes_u.append(int(hnodesplit[4]))
+
     nodes_d  = set(nodes_d)     # save unique fault nodes side u
     nodes_u  = set(nodes_u)     # save unique fault nodes side d
     ncommond = nodes_u&nodes_d  # glue nodes . 
@@ -49,7 +56,7 @@
     file.close()
     return nodes_u,nodes_d
 
-def nodes_coords_fault_open(file_nodes_coord,fault_file,name_out,fside1,fside2,delta): 
+def nodes_coords_fault_open(file_nodes_coord,fault_file,name_out,fsideUP,fsideDW,delta): 
     x=[]
     y=[]
     z=[]
@@ -59,8 +66,8 @@
     txt = ''
     txt_fault = ''
     output_file = open(name_out,'w')
-    fsideu = open(fside1,'w')
-    fsided = open(fside2,'w')
+    fsideu = open(fsideUP,'w')
+    fsided = open(fsideDW,'w')
     node,x,y,z = read_nodes_coord_file(file_nodes_coord)
     output_file.write('%10i\n' % len(node))
     node_u,node_d = read_fault_nodes(fault_file)
@@ -87,21 +94,24 @@
     return
 
 # INPUTS :
-file_nodes_coord = 'MESH/nodes_coords_file'
-fault_file ='MESH/fault_file_1.dat'
+file_nodes_coord = 'MESH_tohoku_break_double_surface/nodes_coords_file'
+fault_file =       'MESH_tohoku_break_double_surface/fault_file_1.dat'
 # OUTPUTS :
-name_out = 'nodes_coords_file_open_fault'
-fsideu = 'fault_sideu.dat'
-fsided = 'fault_sided.dat'
+name_out = 'MESH_tohoku_break_double_surface/nodes_coords_file_open_fault'
+fsideu   = 'MESH_tohoku_break_double_surface/fault_sideu.dat'
+fsided   = 'MESH_tohoku_break_double_surface/fault_sided.dat'
 
+
 delta = 0.5 # Make sure that this delta is in coorcondance with 
             # FAULT_GAP_TOLERANCE which is normally set up to 1.0d0 but can be changed 
             # in decompose_mesh_SCOTH/fault_scotch.f90, and higher
-            # than constants.h/SMALLVAL_TOL = 1.d-10 used by the routine get_global.f90 
+            # than constants.h/SMALLVAL_TOL used by the routine get_global.f90.
+            # SMALLVALTOL = 1.d-10 * dabs(UTM_X_MAX - UTM_X_MIN)
 
-nodes_coords_fault_open(file_nodes_coord,fault_file,name_out,fsideu,fsided,delta)
 
-def m2km(name_in,name_out):
+def m2km():
+    name_in = 'MESH/nodes_coords_file'
+    name_out = 'nodes_coords_file_m'
     txt =''
     km = 1000
     input_file  = open(name_in,'r')
@@ -119,16 +129,19 @@
         z= float(nodes[3])*km
         txt=('%10i %20f %20f %20f\n') % (node_id,x,y,z)
         output_file.write(txt)
-
     output_file.close()
+    os.system('mv nodes_coords_file_m MESH/nodes_coords_file') 
     return
 
 
-#name_in = 'MESH/nodes_coords_file_km'
-#name_out= 'nodes_coords_file'
-#m2km(name_in,name_out)
 
+# Runing functions ####
 
+m2km()
+
+#nodes_coords_fault_open(file_nodes_coord,fault_file,name_out,fsideu,fsided,delta)
+
+
 #import numpy as np
 #def find_nearest(array,value):
 #    idx=(np.abs(array-value)).argmin()



More information about the CIG-COMMITS mailing list