[cig-commits] [commit] devel: adds pythonic indents to create_mesh.py (2c88025)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Tue Dec 23 15:35:36 PST 2014
Repository : https://github.com/geodynamics/specfem3d
On branch : devel
Link : https://github.com/geodynamics/specfem3d/compare/9d3bd7538f7fce31e575efb67ada184321dcd807...2c88025773127e1007f771ff49d5062cf66582f1
>---------------------------------------------------------------
commit 2c88025773127e1007f771ff49d5062cf66582f1
Author: daniel peter <peterda at ethz.ch>
Date: Wed Dec 24 00:22:50 2014 +0100
adds pythonic indents to create_mesh.py
>---------------------------------------------------------------
2c88025773127e1007f771ff49d5062cf66582f1
.../create_mesh.py | 140 ++++++++++-----------
1 file changed, 70 insertions(+), 70 deletions(-)
diff --git a/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_mesh.py b/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_mesh.py
index fc88a72..bccde1d 100755
--- a/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_mesh.py
+++ b/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_mesh.py
@@ -15,17 +15,17 @@ import sys
#sys.path.append('/opt/Trelis-15.0/bin/')
try:
- import cubit
+ import cubit
except ImportError:
- print "Error: Importing cubit as python module failed"
- print "could not import cubit, please check your PYTHONPATH settings..."
- print ""
- print "current path: "
- print sys.path
- print ""
- print "try to include path to directory which includes file cubit.py, e.g. /opt/Trelis-15.0/bin/"
- print ""
- sys.exit("Import cubit failed")
+ print "Error: Importing cubit as python module failed"
+ print "could not import cubit, please check your PYTHONPATH settings..."
+ print ""
+ print "current path: "
+ print sys.path
+ print ""
+ print "try to include path to directory which includes file cubit.py, e.g. /opt/Trelis-15.0/bin/"
+ print ""
+ sys.exit("Import cubit failed")
cubit.init([""])
@@ -76,67 +76,67 @@ os.system('mkdir -p MESH')
use_explicit=0
if use_explicit == 1:
- from geocubitlib import cubit2specfem3d
- print ""
- print "material properties: assigned as block attributes"
- print ""
- # sets the id of the volume block
- # (volume block starts at id 4)
- id_block = 4
- print "cubit block:"
- print " volume block id = " + str(id_block)
- print ""
- # Define material properties
- print "#### DEFINE MATERIAL PROPERTIES #######################"
- # elastic material
- cubit.cmd('block '+str(id_block)+' name "elastic 1" ') # elastic material region
- cubit.cmd('block '+str(id_block)+' attribute count 7')
- cubit.cmd('block '+str(id_block)+' attribute index 1 1') # flag for material: 1 for 1. material
- cubit.cmd('block '+str(id_block)+' attribute index 2 2800') # vp
- cubit.cmd('block '+str(id_block)+' attribute index 3 1500') # vs
- cubit.cmd('block '+str(id_block)+' attribute index 4 2300') # rho
- cubit.cmd('block '+str(id_block)+' attribute index 5 9999.0') # Qkappa
- cubit.cmd('block '+str(id_block)+' attribute index 6 9000.0') # Qmu
- cubit.cmd('block '+str(id_block)+' attribute index 7 0') # anisotropy_flag
- # acoustic material
- #cubit.cmd('block '+str(id_block)+' name "acoustic 1" ') # acoustic material region
- #cubit.cmd('block '+str(id_block)+' attribute count 4')
- #cubit.cmd('block '+str(id_block)+' attribute index 1 1 ') # material 1
- #cubit.cmd('block '+str(id_block)+' attribute index 2 1480 ') # vp
- #cubit.cmd('block '+str(id_block)+' attribute index 3 0 ') # vs
- #cubit.cmd('block '+str(id_block)+' attribute index 4 1028 ') # rho (ocean salt water density:
- print ""
- print "exporting to SPECFEM3D-format:"
- print ""
- # Export to SPECFEM3D format
- cubit2specfem3d.export2SPECFEM3D('MESH/')
+ from geocubitlib import cubit2specfem3d
+ print ""
+ print "material properties: assigned as block attributes"
+ print ""
+ # sets the id of the volume block
+ # (volume block starts at id 4)
+ id_block = 4
+ print "cubit block:"
+ print " volume block id = " + str(id_block)
+ print ""
+ # Define material properties
+ print "#### DEFINE MATERIAL PROPERTIES #######################"
+ # elastic material
+ cubit.cmd('block '+str(id_block)+' name "elastic 1" ') # elastic material region
+ cubit.cmd('block '+str(id_block)+' attribute count 7')
+ cubit.cmd('block '+str(id_block)+' attribute index 1 1') # flag for material: 1 for 1. material
+ cubit.cmd('block '+str(id_block)+' attribute index 2 2800') # vp
+ cubit.cmd('block '+str(id_block)+' attribute index 3 1500') # vs
+ cubit.cmd('block '+str(id_block)+' attribute index 4 2300') # rho
+ cubit.cmd('block '+str(id_block)+' attribute index 5 9999.0') # Qkappa
+ cubit.cmd('block '+str(id_block)+' attribute index 6 9000.0') # Qmu
+ cubit.cmd('block '+str(id_block)+' attribute index 7 0') # anisotropy_flag
+ # acoustic material
+ #cubit.cmd('block '+str(id_block)+' name "acoustic 1" ') # acoustic material region
+ #cubit.cmd('block '+str(id_block)+' attribute count 4')
+ #cubit.cmd('block '+str(id_block)+' attribute index 1 1 ') # material 1
+ #cubit.cmd('block '+str(id_block)+' attribute index 2 1480 ') # vp
+ #cubit.cmd('block '+str(id_block)+' attribute index 3 0 ') # vs
+ #cubit.cmd('block '+str(id_block)+' attribute index 4 1028 ') # rho (ocean salt water density:
+ print ""
+ print "exporting to SPECFEM3D-format:"
+ print ""
+ # Export to SPECFEM3D format
+ cubit2specfem3d.export2SPECFEM3D('MESH/')
else:
- from geocubitlib import exportlib
- print ""
- print "exporting to SPECFEM3D-format:"
- print ""
- # Export to SPECFEM3D format
- # note: exportlib-commands will overwrite material properties
- exportlib.collect(outdir='MESH/')
- # Define material properties
- print "#### DEFINE MATERIAL PROPERTIES #######################"
- # elastic material
- material_cfg=[{'material region':'2','id_block':'1','vp':'2800','vs':'1500','rho':'2300','Qkappa':'9990.0','Qmu':'9000.0','anisotropy_flag':'0'}]
- # modifies material file
- nummaterial_velocity_file='MESH/nummaterial_velocity_file'
- f=open(nummaterial_velocity_file,'w')
- for block in material_cfg:
- print block
- s=block['material region']+' '
- s=s+block['id_block']+' '
- s=s+block['rho']+' '
- s=s+block['vp']+' '
- s=s+block['vs']+' '
- s=s+block['Qkappa']+' '
- s=s+block['Qmu']+' '
- s=s+block['anisotropy_flag']
- f.write(s+'\n')
- f.close()
+ from geocubitlib import exportlib
+ print ""
+ print "exporting to SPECFEM3D-format:"
+ print ""
+ # Export to SPECFEM3D format
+ # note: exportlib-commands will overwrite material properties
+ exportlib.collect(outdir='MESH/')
+ # Define material properties
+ print "#### DEFINE MATERIAL PROPERTIES #######################"
+ # elastic material
+ material_cfg=[{'material region':'2','id_block':'1','vp':'2800','vs':'1500','rho':'2300','Qkappa':'9990.0','Qmu':'9000.0','anisotropy_flag':'0'}]
+ # modifies material file
+ nummaterial_velocity_file='MESH/nummaterial_velocity_file'
+ f=open(nummaterial_velocity_file,'w')
+ for block in material_cfg:
+ print block
+ s=block['material region']+' '
+ s=s+block['id_block']+' '
+ s=s+block['rho']+' '
+ s=s+block['vp']+' '
+ s=s+block['vs']+' '
+ s=s+block['Qkappa']+' '
+ s=s+block['Qmu']+' '
+ s=s+block['anisotropy_flag']
+ f.write(s+'\n')
+ f.close()
# backup cubit
cubit.cmd('export mesh "MESH/top.e" dimension 3 overwrite')
More information about the CIG-COMMITS
mailing list