[cig-commits] r22817 - in seismo/3D/SPECFEM3D/trunk: CUBIT_GEOCUBIT CUBIT_GEOCUBIT/geocubitlib examples/fault_examples/tpv15 examples/fault_examples/tpv5
dkomati1 at geodynamics.org
dkomati1 at geodynamics.org
Fri Sep 20 11:56:31 PDT 2013
Author: dkomati1
Date: 2013-09-20 11:56:30 -0700 (Fri, 20 Sep 2013)
New Revision: 22817
Added:
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py
Modified:
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_boundary_definition.py
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_cubit2specfem3d.py
seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv15/save_fault_nodes_elements.py
seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv5/save_fault_nodes_elements.py
Log:
fixed links to save_fault_nodes_elements.py
Added: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py (rev 0)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py 2013-09-20 18:56:30 UTC (rev 22817)
@@ -0,0 +1,84 @@
+#!python
+# Opening fault cracks
+# Input : surface up and down.
+import cubit
+
+class fault_input:
+ def __init__(self,id,surface_u,surface_d):
+ self.id = id
+ self.surface_u = surface_u
+ self.surface_d = surface_d
+ self.name = 'MESH/fault_file_'+str(id)+'.dat'
+
+ quads_Aup,quads_Adp = save_cracks(self.name,self.surface_u,self.surface_d)
+ #Unpacking list.
+ quads_Au=unpack_list(quads_Aup)
+ quads_Ad=unpack_list(quads_Adp)
+
+ print 'len(Au):',len(quads_Au)
+ print 'len(Ad):',len(quads_Ad)
+
+ if not (len(quads_Au)==len(quads_Ad)):
+ print 'Number of elements for each fauld side up and down do not concide'
+ sys.exit('goodbye')
+
+ save_elements_nodes(self.name,quads_Au,quads_Ad)
+
+
+def save_cracks(name,list_surface_up,list_surface_down):
+ quads_fault_up = []
+ quads_fault_down = []
+ for surface in list_surface_up :
+ quads_fault = cubit.get_surface_quads(surface)
+ quads_fault_up.append(quads_fault)
+ for surface in list_surface_down :
+ quads_fault = cubit.get_surface_quads(surface)
+ quads_fault_down.append(quads_fault)
+ # TO DO : stop python properly in case fault nodes at both sides
+ # do not match.
+ # if len(quads_fault_u) != len(quads_fault_d): stop
+ #
+ # SAVING FAULT ELEMENTS AND NODES
+ return quads_fault_up,quads_fault_down
+
+def unpack_list(fault_list):
+ list_fault = []
+ for i in range(0,len(fault_list)):
+ el=list(fault_list[i])
+ for j in el:
+ list_fault.append(j)
+ return list_fault
+
+def save_elements_nodes(name,quads_fault_u,quads_fault_d):
+ fault_file = open(name,'w')
+ txt =''
+ list_hex=cubit.parse_cubit_list('hex','all')
+ txt='%10i %10i\n' % (len(quads_fault_u),len(quads_fault_d))
+ fault_file.write(txt)
+
+ dic_quads_fault_u = dict(zip(quads_fault_u,quads_fault_u))
+ dic_quads_fault_d = dict(zip(quads_fault_d,quads_fault_d))
+
+ # FAULT SIDE DOWN
+ for h in list_hex:
+ faces = cubit.get_sub_elements('hex',h,2)
+ for f in faces:
+ if dic_quads_fault_d.has_key(f):
+ nodes=cubit.get_connectivity('Face',f)
+ # print 'h,fault nodes side down :',h,nodes[0],nodes[1],nodes[2],nodes[3]
+ txt='%10i %10i %10i %10i %10i\n' % (h,nodes[0],\
+ nodes[1],nodes[2],nodes[3])
+ fault_file.write(txt)
+
+ # FAULT SIDE UP
+ for h in list_hex:
+ faces = cubit.get_sub_elements('hex',h,2)
+ for f in faces:
+ if dic_quads_fault_u.has_key(f):
+ nodes=cubit.get_connectivity('Face',f)
+ # print 'h,fault nodes side up :',h,nodes[0],nodes[1],nodes[2],nodes[3]
+ txt='%10i %10i %10i %10i %10i\n' % (h,nodes[0],\
+ nodes[1],nodes[2],nodes[3])
+ fault_file.write(txt)
+
+ fault_file.close()
Modified: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_boundary_definition.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_boundary_definition.py 2013-09-20 18:48:08 UTC (rev 22816)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_boundary_definition.py 2013-09-20 18:56:30 UTC (rev 22817)
@@ -1,18 +1,30 @@
-#!python
#!/usr/bin/env python
-import cubit
import boundary_definition
-import cubit2specfem3d
-
+#import cubit2specfem3d
import os
import sys
+# put the path to your installation of the "bin" directory of the CUBIT package here
+sys.path.append("/home/komatits/bin/cubit/bin")
+import cubit
+# let us also add the local GEOCUBIT library
+sys.path.append("./geocubitlib")
+
+# define the name of the CUBIT file to convert to SPECFEM format in the line below
+#cubit.cmd('open "large_test_cpml.cub"')
+cubit.cmd('open "test_cmpl_2layers.cub"')
+
+
###### This is boundary_definition.py of GEOCUBIT
#..... which extracts the bounding faces and defines them into blocks
-reload(boundary_definition)
+#reload(boundary_definition)
+
+# for CUBIT version 14 and higher (now called TRELIS) you may have to change 'face' to 'Face' in the line below
boundary_definition.entities=['face']
-boundary_definition.define_bc(boundary_definition.entities,parallel=True)
+# this command can run in parallel or not
+#boundary_definition.define_bc(boundary_definition.entities,parallel=True)
+boundary_definition.define_bc(boundary_definition.entities,parallel=False)
Modified: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_cubit2specfem3d.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_cubit2specfem3d.py 2013-09-20 18:48:08 UTC (rev 22816)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/run_cubit2specfem3d.py 2013-09-20 18:56:30 UTC (rev 22817)
@@ -17,11 +17,9 @@
cubit.cmd('open "test_cmpl_2layers.cub"')
###### This is boundary_definition.py of GEOCUBIT
-
#..... which extracts the bounding faces and defines them into blocks
+#reload(boundary_definition)
-reload(boundary_definition)
-
# for CUBIT version 14 and higher (now called TRELIS) you may have to change 'face' to 'Face' in the line below
boundary_definition.entities=['face']
@@ -32,9 +30,7 @@
#### Export to SPECFEM3D format using cubit2specfem3d.py of GEOCUBIT
os.system('mkdir -p MESH')
-
-reload(cubit2specfem3d)
-
+#reload(cubit2specfem3d)
cubit2specfem3d.export2SPECFEM3D('MESH')
# all files needed by SCOTCH are now in directory MESH...
Modified: seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv15/save_fault_nodes_elements.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv15/save_fault_nodes_elements.py 2013-09-20 18:48:08 UTC (rev 22816)
+++ seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv15/save_fault_nodes_elements.py 2013-09-20 18:56:30 UTC (rev 22817)
@@ -1 +1 @@
-link ../../../CUBIT/save_fault_nodes_elements.py
\ No newline at end of file
+link ../../../CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py
\ No newline at end of file
Modified: seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv5/save_fault_nodes_elements.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv5/save_fault_nodes_elements.py 2013-09-20 18:48:08 UTC (rev 22816)
+++ seismo/3D/SPECFEM3D/trunk/examples/fault_examples/tpv5/save_fault_nodes_elements.py 2013-09-20 18:56:30 UTC (rev 22817)
@@ -1 +1 @@
-link ../../../CUBIT/save_fault_nodes_elements.py
\ No newline at end of file
+link ../../../CUBIT_GEOCUBIT/geocubitlib/save_fault_nodes_elements.py
\ No newline at end of file
More information about the CIG-COMMITS
mailing list