def e2SEM(files=False,listblock=None,listflag=None,outdir='.',cpml=False,cpml_size=False,top_absorbing=False,hex27=False): import glob if files: filenames=glob.glob(files) for f in filenames: print f extension=f.split('.')[-1] if extension == 'cub': cubit.cmd('open "'+f+'"') elif extension== 'e': cubit.cmd('import mesh "'+f+'" no_geom') else: print extension if listblock and listflag: pass else: listblock=[] listflag=[] block_list=list(cubit.get_block_id_list()) for block in block_list: ty=cubit.get_block_element_type(block) if 'HEX' in ty: listblock.append(block) #listflag.append(block) listflag=range(1,len(block_list)+1) # for ib,iflag in zip(listblock,listflag): cubit.cmd("block "+str(ib)+" attribute count 1") cubit.cmd("block "+str(ib)+" attribute index 1 "+ str(iflag) ) # import cubit2specfem3d cubit2specfem3d.export2SPECFEM3D(outdir,cpml=cpml,cpml_size=cpml_size,top_absorbing=top_absorbing,hex27=hex27)
def e2SEM(files=False, listblock=None, listflag=None, outdir='.', cpml=False, cpml_size=False, top_absorbing=False, hex27=False): import glob if files: filenames = glob.glob(files) for f in filenames: print f extension = f.split('.')[-1] if extension == 'cub': cubit.cmd('open "' + f + '"') elif extension == 'e': cubit.cmd('import mesh "' + f + '" no_geom') else: print extension if listblock and listflag: pass else: listblock = [] listflag = [] block_list = list(cubit.get_block_id_list()) for block in block_list: ty = cubit.get_block_element_type(block) if 'HEX' in ty: listblock.append(block) #listflag.append(block) listflag = range(1, len(block_list) + 1) # for ib, iflag in zip(listblock, listflag): cubit.cmd("block " + str(ib) + " attribute count 1") cubit.cmd("block " + str(ib) + " attribute index 1 " + str(iflag)) # import cubit2specfem3d print "#e2SEM: output dir = ", outdir cubit2specfem3d.export2SPECFEM3D(outdir, cpml=cpml, cpml_size=cpml_size, top_absorbing=top_absorbing, hex27=hex27)
boundary_definition.define_bc(boundary_definition.entities,parallel=True) #### Define material properties for the 3 volumes ################ cubit.cmd('#### DEFINE MATERIAL PROPERTIES #######################') cubit.cmd('block 1 name "elastic 1" ') # elastic material region cubit.cmd('block 1 attribute count 6') cubit.cmd('block 1 attribute index 1 1') # flag for material: 1 for 1. material cubit.cmd('block 1 attribute index 2 2800') # vp cubit.cmd('block 1 attribute index 3 1500') # vs cubit.cmd('block 1 attribute index 4 2300') # rho cubit.cmd('block 1 attribute index 5 150.0') # Qmu cubit.cmd('block 1 attribute index 6 0 ') # anisotropy_flag # optional saves backups cubit.cmd('export mesh "top.e" dimension 3 overwrite') cubit.cmd('save as "meshing.cub" overwrite') # cleanup os.system('rm -f topo_brick.stl topo_vol.stl topo_vol2.stl') #### Export to SPECFEM3D format using cubit2specfem3d.py of GEOCUBIT os.system('mkdir -p MESH') cubit2specfem3d.export2SPECFEM3D('MESH') # all files needed by SCOTCH are now in directory MESH # time stamp print "#" + time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
cubit.cmd('block 4 attribute index 1 1') # flag for fault side 1 cubit.cmd('block 4 attribute index 2 6000') # vp cubit.cmd('block 4 attribute index 3 3464') # vs cubit.cmd('block 4 attribute index 4 2670') # rho cubit.cmd('block 4 attribute index 5 13' ) # Q flag (see constants.h: IATTENUATION_ ... ) cubit.cmd('block 5 name "elastic 5" ') # material region cubit.cmd('block 5 attribute count 5') cubit.cmd('block 5 attribute index 1 1') # flag for fault side 1 cubit.cmd('block 5 attribute index 2 6000') # vp cubit.cmd('block 5 attribute index 3 3464') # vs cubit.cmd('block 5 attribute index 4 2670') # rho cubit.cmd('block 5 attribute index 5 13' ) # Q flag (see constants.h: IATTENUATION_ ... ) cubit.cmd('block 6 name "elastic 6" ') # material region cubit.cmd('block 6 attribute count 5') cubit.cmd('block 6 attribute index 1 1') # flag for fault side 1 cubit.cmd('block 6 attribute index 2 6000') # vp cubit.cmd('block 6 attribute index 3 3464') # vs cubit.cmd('block 6 attribute index 4 2670') # rho cubit.cmd('block 6 attribute index 5 13' ) # Q flag (see constants.h: IATTENUATION_ ... ) #### Export to SPECFEM3D format using cubit2specfem3d.py of GEOCUBIT cubit2specfem3d.export2SPECFEM3D('MESH') # all files needed by SCOTCH are now in directory MESH
define_boundaries(entities, xmin, xmax, ymin, ymax, zmin, zmax) #### Define material properties for the 2 volumes ################ cubit.cmd('#### DEFINE MATERIAL PROPERTIES #######################') for iblock in range(1, 11, 1): export_block(nb=iblock, vp=6000, vs=3464, rho=2670) # Material properties in concordance with tpv5 benchmark. #cubit.cmd('block 1 name "elastic 1" ') # material region #cubit.cmd('block 1 attribute count 6') #cubit.cmd('block 1 attribute index 1 1') # flag for fault side 1 #cubit.cmd('block 1 attribute index 2 6000') # vp #cubit.cmd('block 1 attribute index 3 3464') # vs #cubit.cmd('block 1 attribute index 4 2670') # rho #cubit.cmd('block 1 attribute index 5 13') # Q flag (see constants.h: #IATTENUATION_ ... ) # #cubit.cmd('block 2 name "elastic 2" ') # material region #cubit.cmd('block 2 attribute count 6') #cubit.cmd('block 2 attribute index 1 1') # flag for fault domain 2 #cubit.cmd('block 2 attribute index 2 6000') # vp #cubit.cmd('block 2 attribute index 3 3464') # vs #cubit.cmd('block 2 attribute index 4 2670') # rho #cubit.cmd('block 2 attribute index 5 13') # Q flag (see constants.h: #IATTENUATION_ ... ) # Q flag (see constants.h: #IATTENUATION_ ... ) cubit2specfem3d.export2SPECFEM3D('MESH', hex27=True) faultA = fault_input(1, Au, Ad) # all files needed by SCOTCH are now in directory MESH
#### Define material properties for the 2 volumes ################ cubit.cmd('#### DEFINE MATERIAL PROPERTIES #######################') for iblock in range(1,11,1): export_block(nb = iblock,vp=6000,vs=3464,rho=2670) # Material properties in concordance with tpv5 benchmark. #cubit.cmd('block 1 name "elastic 1" ') # material region #cubit.cmd('block 1 attribute count 6') #cubit.cmd('block 1 attribute index 1 1') # flag for fault side 1 #cubit.cmd('block 1 attribute index 2 6000') # vp #cubit.cmd('block 1 attribute index 3 3464') # vs #cubit.cmd('block 1 attribute index 4 2670') # rho #cubit.cmd('block 1 attribute index 5 13') # Q flag (see constants.h: #IATTENUATION_ ... ) # #cubit.cmd('block 2 name "elastic 2" ') # material region #cubit.cmd('block 2 attribute count 6') #cubit.cmd('block 2 attribute index 1 1') # flag for fault domain 2 #cubit.cmd('block 2 attribute index 2 6000') # vp #cubit.cmd('block 2 attribute index 3 3464') # vs #cubit.cmd('block 2 attribute index 4 2670') # rho #cubit.cmd('block 2 attribute index 5 13') # Q flag (see constants.h: #IATTENUATION_ ... ) # Q flag (see constants.h: #IATTENUATION_ ... ) cubit2specfem3d.export2SPECFEM3D('MESH',hex27=True) faultA = fault_input(1,Au,Ad) # all files needed by SCOTCH are now in directory MESH
# FOR THE BULK (Seismic wave propagation part for SPECFEM3D) ###### This is boundary_definition.py of GEOCUBIT # ..... which extracts the bounding faces and defines them into blocks # boundary_definition.entities=['face'] # this is a deprecated boundary definition function # boundary_definition.define_bc(boundary_definition.entities,parallel=True) entities = ["face"] define_parallel_bc(entities) # in absorbing_boundary.py #### Define material properties for the 2 volumes ################ cubit.cmd("#### DEFINE MATERIAL PROPERTIES #######################") # Material properties in concordance with tpv5 benchmark. cubit.cmd('block 1 name "elastic 1" ') # material region cubit.cmd("block 1 attribute count 6") cubit.cmd("block 1 attribute index 1 1") # flag for fault side 1 cubit.cmd("block 1 attribute index 2 6000") # vp cubit.cmd("block 1 attribute index 3 3464") # vs cubit.cmd("block 1 attribute index 4 2670") # rho cubit.cmd("block 1 attribute index 5 13") # q flag (see constants.h: iattenuation_ ... ) cubit.cmd("block 1 attribute index 6 0") # q flag (see constants.h: iattenuation_ ... ) #### Export to SPECFEM3D format using cubit2specfem3d.py of GEOCUBIT cubit2specfem3d.export2SPECFEM3D("MESH") # all files needed by SCOTCH are now in directory MESH
#!python #!/usr/bin/env python import cubit import boundary_definition import cubit2specfem3d import os import sys ###### This is boundary_definition.py of GEOCUBIT # ..... which extracts the bounding faces and defines them into blocks # reload(boundary_definition) # boundary_definition.entities=['face'] # boundary_definition.define_bc(boundary_definition.entities,parallel=True) #### Export to SESAME format using cubit2specfem3d.py of GEOCUBIT os.system("mkdir -p MESH") reload(cubit2specfem3d) cubit2specfem3d.export2SPECFEM3D(path, hex27=True) # all files needed by SCOTCH are now in directory MESH
#### Define material properties for the 2 volumes ################ cubit.cmd("#### DEFINE MATERIAL PROPERTIES #######################") for iblock in range(1, 11, 1): export_block(nb=iblock, vp=6000, vs=3464, rho=2670) # Material properties in concordance with tpv5 benchmark. # cubit.cmd('block 1 name "elastic 1" ') # material region # cubit.cmd('block 1 attribute count 6') # cubit.cmd('block 1 attribute index 1 1') # flag for fault side 1 # cubit.cmd('block 1 attribute index 2 6000') # vp # cubit.cmd('block 1 attribute index 3 3464') # vs # cubit.cmd('block 1 attribute index 4 2670') # rho # cubit.cmd('block 1 attribute index 5 13') # Q flag (see constants.h: #IATTENUATION_ ... ) # # cubit.cmd('block 2 name "elastic 2" ') # material region # cubit.cmd('block 2 attribute count 6') # cubit.cmd('block 2 attribute index 1 1') # flag for fault domain 2 # cubit.cmd('block 2 attribute index 2 6000') # vp # cubit.cmd('block 2 attribute index 3 3464') # vs # cubit.cmd('block 2 attribute index 4 2670') # rho # cubit.cmd('block 2 attribute index 5 13') # Q flag (see constants.h: #IATTENUATION_ ... ) # Q flag (see constants.h: #IATTENUATION_ ... ) cubit2specfem3d.export2SPECFEM3D("MESH", hex27=True) faultA = fault_input(1, Au, Ad) # all files needed by SCOTCH are now in directory MESH
cubit.cmd('block 3 attribute index 7 0 ') # anisotropy_flag cubit.cmd('block 4 name "elastic 1" ') # elastic material region cubit.cmd('block 4 attribute count 7') cubit.cmd('block 4 attribute index 1 4 ') # material 4 cubit.cmd('block 4 attribute index 2 3399 ') # vp cubit.cmd('block 4 attribute index 3 1963 ') # vs cubit.cmd('block 4 attribute index 4 3200 ') # rho cubit.cmd('block 4 attribute index 5 9999.0') # Q_kappa cubit.cmd('block 4 attribute index 6 9999.0') # Q_mu cubit.cmd('block 4 attribute index 7 0 ') # anisotropy_flag # backup cubit mesh file cubit.cmd('save as "' + outputdir + '/cubit_mesh.cub" overwrite') #### Export to SPECFEM3D format using cubit2specfem3d.py of GEOCUBIT cubit2specfem3d.export2SPECFEM3D(outputdir) # screen shot # (could crash version < 16.4 if version_major >= 16 and version_minor >= 4: cubit.cmd('view top') # needs to have a window -> only works when running this script from within Trelis/Cubit cubit.cmd('hardcopy "' + outputdir + '/cubit_mesh.png" png') # all files needed by SCOTCH are now in directory MESH