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

percygalvez at geodynamics.org percygalvez at geodynamics.org
Mon Nov 5 05:48:38 PST 2012


Author: percygalvez
Date: 2012-11-05 05:48:38 -0800 (Mon, 05 Nov 2012)
New Revision: 20987

Modified:
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/absorbing_boundary.py
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/boundary_definition.py
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py
Log:
adding parallel absorbing boundaries to absorxxx.py routine

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/absorbing_boundary.py
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/absorbing_boundary.py	2012-11-05 13:44:56 UTC (rev 20986)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/absorbing_boundary.py	2012-11-05 13:48:38 UTC (rev 20987)
@@ -17,6 +17,104 @@
        self.ymin = ymin
        self.ymax = ymax
 
+class abs_surface_topo:
+   def __init__(self,xmin,xmax,ymin,ymax,bottom,topo): 
+       self.xmin = xmin
+       self.xmax = xmax
+       self.ymin = ymin
+       self.ymax = ymax
+       self.bottom = bottom
+       self.topo = topo
+ 
+# Emmanuele Cassarotti function for Parallel absorbing boundaries.
+# WARNING : absorbing.surf deleted due to CUBIT 13.0 does not allow elements beloging to diferent blocks.
+
+def define_parallel_absorbing_surf():
+    """
+    define the absorbing surfaces for a layered topological box where boundary are surfaces parallel to the axis.
+    it returns absorbing_surf,absorbing_surf_xmin,absorbing_surf_xmax,absorbing_surf_ymin,absorbing_surf_ymax,absorbing_surf_bottom,topo_surf
+    where
+    absorbing_surf is the list of all the absorbing boundary surf
+    absorbing_surf_xmin is the list of the absorbing boundary surfaces that correnspond to x=xmin
+    ...
+    absorbing_surf_bottom is the list of the absorbing boundary surfaces that correspond to z=zmin
+    """
+    try:
+        cubit.cmd('comment')
+    except:
+        try:
+            import cubit
+            cubit.init([""])
+        except:
+            print 'error importing cubit'
+            import sys
+            sys.exit()
+    absorbing_surf_xmin=[]
+    absorbing_surf_xmax=[]
+    absorbing_surf_ymin=[]
+    absorbing_surf_ymax=[]
+    absorbing_surf_bottom=[]
+    top_surf=[]
+    
+    
+    list_vol=cubit.parse_cubit_list("volume","all")
+    init_n_vol=len(list_vol)
+    zmax_box=cubit.get_total_bounding_box("volume",list_vol)[7]
+    zmin_box=cubit.get_total_bounding_box("volume",list_vol)[6] #it is the z_min of the box ... box= xmin,xmax,d,ymin,ymax,d,zmin...    
+    xmin_box=cubit.get_total_bounding_box("volume",list_vol)[0]
+    xmax_box=cubit.get_total_bounding_box("volume",list_vol)[1]
+    ymin_box=cubit.get_total_bounding_box("volume",list_vol)[3]
+    ymax_box=cubit.get_total_bounding_box("volume",list_vol)[4]
+    list_surf=cubit.parse_cubit_list("surface","all")
+    print '##boundary box: '
+    print '##  x min: ' + str(xmin_box)
+    print '##  y min: ' + str(ymin_box)
+    print '##  z min: ' + str(zmin_box)
+    print '##  x max: ' + str(xmax_box)
+    print '##  y max: ' + str(ymax_box)
+    print '##  z max: ' + str(zmax_box)
+
+    #box lengths
+    x_len = abs( xmax_box - xmin_box)
+    y_len = abs( ymax_box - ymin_box)
+    z_len = abs( zmax_box - zmin_box)
+    
+    print '##boundary box: '
+    print '##  x length: ' + str(x_len)
+    print '##  y length: ' + str(y_len)
+    print '##  z length: ' + str(z_len)
+    
+    # tolerance parameters 
+    absorbing_surface_distance_tolerance=0.005
+    topographic_surface_distance_tolerance=0.001
+    topographic_surface_normal_tolerance=0.2
+        
+    for k in list_surf:
+        center_point = cubit.get_center_point("surface", k)
+        if abs((center_point[0] - xmin_box)/x_len) <= absorbing_surface_distance_tolerance:
+             absorbing_surf_xmin.append(k)
+        elif abs((center_point[0] - xmax_box)/x_len) <= absorbing_surface_distance_tolerance:
+             absorbing_surf_xmax.append(k)
+        elif abs((center_point[1] - ymin_box)/y_len) <= absorbing_surface_distance_tolerance:
+             absorbing_surf_ymin.append(k)
+        elif abs((center_point[1] - ymax_box)/y_len) <= absorbing_surface_distance_tolerance:
+             absorbing_surf_ymax.append(k)
+        elif abs((center_point[2] - zmin_box)/z_len) <= absorbing_surface_distance_tolerance:
+             print 'center_point[2]' + str(center_point[2])
+             print 'kz:' + str(k)
+             absorbing_surf_bottom.append(k)
+                       
+        else:
+            sbox=cubit.get_bounding_box('surface',k)
+            dz=abs((sbox[7] - zmax_box)/z_len)
+            normal=cubit.get_surface_normal(k)
+            zn=normal[2]
+            dn=abs(zn-1)
+            if dz <= topographic_surface_distance_tolerance and dn < topographic_surface_normal_tolerance:
+                top_surf.append(k)
+
+    return absorbing_surf_xmin,absorbing_surf_xmax,absorbing_surf_ymin,absorbing_surf_ymax,absorbing_surf_bottom,top_surf
+
 def define_top_bottom_absorbing_surf(zmin_box,zmax_box):
     """
       absorbing_surf_bottom is the list of the absorbing boundary surfaces that correspond to z=zmin
@@ -147,7 +245,6 @@
                 sys.exit()
     id_nodeset=cubit.get_next_nodeset_id()
     id_block=cubit.get_next_block_id()
-
     
     if obj == 'hex':
         txt='hex in node in surface'
@@ -194,10 +291,35 @@
          build_block_side(bottom,entity+'_abs_bottom',obj=entity)
          build_block_side(topo,entity+'_topo',obj=entity)
 
+def define_parallel_bc(entities):
+     xmax = []
+     ymin = []
+     ymax = []
+     zmin = []
+     zmax = []
+     #Extracting parallel surfaces.
+     xmin,xmax,ymin,ymax,bottom,topo=define_parallel_absorbing_surf()
+     v_list,name_list=define_block()
+     build_block(v_list,name_list)
+     print entities
+     for entity in entities:
+         print "##entity: "+str(entity)
+         build_block_side(xmin,entity+'_abs_xmin',obj=entity)
+         build_block_side(xmax,entity+'_abs_xmax',obj=entity)
+         build_block_side(ymin,entity+'_abs_ymin',obj=entity)
+         build_block_side(ymax,entity+'_abs_ymax',obj=entity)
+         build_block_side(bottom,entity+'_abs_bottom',obj=entity)
+         build_block_side(topo,entity+'_topo',obj=entity)
 
-def define_boundaries(entities,xmin,xmax,ymin,ymax,zmin,zmax):
-     bottom=zmin
-     topo=zmax
+
+def define_bc_topo(entities,self):
+     # Temporal : Variable zmin should be obtained automatically. 
+     xmin = self.xmin
+     xmax = self.xmax
+     ymin = self.ymin
+     ymax = self.ymax
+     bottom = self.bottom
+     topo = self.topo
      v_list,name_list=define_block()
      build_block(v_list,name_list)
      print entities

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/boundary_definition.py
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/boundary_definition.py	2012-11-05 13:44:56 UTC (rev 20986)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/boundary_definition.py	2012-11-05 13:48:38 UTC (rev 20987)
@@ -60,7 +60,6 @@
     ymin_box=cubit.get_total_bounding_box("volume",list_vol)[3]
     ymax_box=cubit.get_total_bounding_box("volume",list_vol)[4]
     list_surf=cubit.parse_cubit_list("surface","all")
-   
     print '##boundary box: '
     print '##  x min: ' + str(xmin_box)
     print '##  y min: ' + str(ymin_box)
@@ -68,10 +67,7 @@
     print '##  x max: ' + str(xmax_box)
     print '##  y max: ' + str(ymax_box)
     print '##  z max: ' + str(zmax_box)
-   
 
-    
-
 #    for k in list_surf:
 #        center_point = cubit.get_center_point("surface", k)
 #        if abs((center_point[0] - xmin_box)/xmin_box) <= 0.005:
@@ -327,18 +323,18 @@
     closed=keys.get('closed',False)
     if not closed:
         print "##open region"
-
         if parallel:
+            print 'Parallel absorbing boundaries'
             surf,xmin,xmax,ymin,ymax,bottom,topo=define_absorbing_surf()
         else:
+            print 'Not parallel absorbing' 
             surf,topo=define_absorbing_surf_nopar()
         v_list,name_list=define_block()
         build_block(v_list,name_list)
         entities=args[0]
         print entities
         for entity in entities:
-            print "##entity: "+str(entity)
-            
+            print "##entity: "+str(entity) 
             build_block_side(topo,entity+'_topo',obj=entity)
             build_block_side(surf,entity+'_abs',obj=entity)
             if parallel: 

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py	2012-11-05 13:44:56 UTC (rev 20986)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/CUBIT/functions.py	2012-11-05 13:48:38 UTC (rev 20987)
@@ -93,13 +93,6 @@
     fsided.close()
     return
 
-# INPUTS :
-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 = '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 # WARNING: Make sure that this delta is smaller than FAULT_GAP_TOLERANCE 
             # defined in decompose_mesh_SCOTH/fault_scotch.f90 (usually FAULT_GAP_TOLERANCE=1.0d0)
@@ -129,15 +122,18 @@
     os.system('mv nodes_coords_file_m MESH/nodes_coords_file') 
     return
 
-
-
 # Runing functions ####
+#m2km()
 
-m2km()
-
+# INPUTS :
+#file_nodes_coord = 'MESH/nodes_coords_file'
+#fault_file =       'MESH/fault_file_1.dat'
+# OUTPUTS :
+#name_out = 'MESH/nodes_coords_file_open_fault'
+#fsideu   = 'MESH/fault_sideu.dat'
+#fsided   = 'MESH/fault_sided.dat'
 #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