[cig-commits] r22973 - seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib
emanuele at geodynamics.org
emanuele at geodynamics.org
Thu Oct 31 06:08:54 PDT 2013
Author: emanuele
Date: 2013-10-31 06:08:54 -0700 (Thu, 31 Oct 2013)
New Revision: 22973
Modified:
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/exportlib.py
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/local_volume.py
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/read_parameter_cfg.py
seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/volumes.py
Log:
update geocubit before moving to github
Modified: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/exportlib.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/exportlib.py 2013-10-31 13:08:23 UTC (rev 22972)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/exportlib.py 2013-10-31 13:08:54 UTC (rev 22973)
@@ -559,13 +559,22 @@
block=1001
add_sea_layer(block=block)
+ outdir2='/'.join(x for x in outfilename.split('/')[:-1])
+ if outdir2 == '':
+ outdir2=outdir+'/'
+ else:
+ outdir2=outdir+'/'+outdir2+'/'
+ import os
+ try:
+ os.makedirs(outdir2)
+ except OSError:
+ pass
+
cubit.cmd('compress all')
- command="export mesh '"+outfilename+".e' block all overwrite xml '"+outfilename+".xml'"
+ command="export mesh '"+outdir2+outfilename+".e' block all overwrite xml '"+outdir2+outfilename+".xml'"
cubit.cmd(command)
- outdir2='/'.join(x for x in outfilename.split('/')[:-1])
- if outdir2 == '': outdir2='.'
- f=open(outdir2+'/'+'blocks.dat','w')
+ f=open(outdir2+'blocks.dat','w')
blocks=cubit.get_block_id_list()
#
for block in blocks:
@@ -583,7 +592,7 @@
cubit.silent_cmd(cmd)
cubit.cmd('set info echo journ on')
#
- command = "save as '"+outfilename+".cub' overwrite"
+ command = "save as '"+outdir2+outfilename+".cub' overwrite"
cubit.cmd(command)
#
print 'end meshing'
@@ -592,7 +601,7 @@
if qlog:
print '\n\nQUALITY CHECK.... ***************\n\n'
import quality_log
- tq=open(outfilename+'.quality','w')
+ tq=open(outdir2+outfilename+'.quality','w')
max_skewness,min_length=quality_log.quality_log(tq)
#
#
Modified: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/local_volume.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/local_volume.py 2013-10-31 13:08:23 UTC (rev 22972)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/local_volume.py 2013-10-31 13:08:54 UTC (rev 22973)
@@ -217,7 +217,7 @@
grdfilename=cfg.filename[inz-bottomsurface]
if cfg.irregulargridded_surf:
- coordx,coordy,elev_1=process_irregular_surfacefiles(iproc,nx,ny,cfg.xmin,cfg.xmax,cfg.ymin,cfg.ymax,xstep,ystep,grdfile)
+ coordx,coordy,elev_1=process_irregular_surfacefiles(iproc,nx,ny,cfg.xmin,cfg.xmax,cfg.ymin,cfg.ymax,xstep,ystep,grdfilename)
else:
coordx,coordy,elev_1=process_surfacefiles(iproc,nx,ny,nstep,grdfilename,cfg.unit,cfg.lat_orientation)
elev[:,:,inz]=elev_1[:,:]
Modified: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/read_parameter_cfg.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/read_parameter_cfg.py 2013-10-31 13:08:23 UTC (rev 22972)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/read_parameter_cfg.py 2013-10-31 13:08:54 UTC (rev 22973)
@@ -172,7 +172,13 @@
dcfg['smoothing']=False
dcfg['ntripl']=0
+ if float(dcfg['version_cubit']) >= 13.1:
+ dcfg['volumecreation_method']=None
+ else:
+ dcfg['volumecreation_method']='loft'
+
+
dcfg['nsurf'] = None
if cfgname:
config.read(cfgname)
Modified: seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/volumes.py
===================================================================
--- seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/volumes.py 2013-10-31 13:08:23 UTC (rev 22972)
+++ seismo/3D/SPECFEM3D/trunk/CUBIT_GEOCUBIT/geocubitlib/volumes.py 2013-10-31 13:08:54 UTC (rev 22973)
@@ -44,13 +44,53 @@
elif cfg.volume_type == 'layercake_volume_fromacis_mpiregularmap':
layercake_volume_fromacis_mpiregularmap(filename=filename)
elif cfg.volume_type == 'verticalsandwich_volume_ascii_regulargrid_mpiregularmap':
- verticalsandwich_volume_ascii_regulargrid_mpiregularmap(filename=None)
+ layercake_volume_ascii_regulargrid_mpiregularmap(filename=filename,verticalsandwich=True)
+def ordering_surfaces(list_surfaces):
+ list_z=[]
+ for s in list_surfaces:
+ _,_,z=cubit.get_center_point("surface",s)
+ list_z.append(z)
+ ord_list_surfaces=[s for s,z in sorted(zip(list_surfaces,list_z),key=lambda x: (x[1]))]
+ return ord_list_surfaces
+def onlyvolumes():
+ list_surfaces=cubit.parse_cubit_list("surface","all")
+ ord_list_surfaces=ordering_surfaces(list_surfaces)
+ for s1,s2 in zip(ord_list_surfaces[:-1],ord_list_surfaces[1:]):
+ create_volume(s1,s2,method=None)
+ cubitcommand= 'del surface all'
+ cubit.cmd(cubitcommand)
+ list_vol=cubit.parse_cubit_list("volume","all")
+ if len(list_vol) > 1:
+ cubitcommand= 'imprint volume all'
+ cubit.cmd(cubitcommand)
+ cubitcommand= 'merge all'
+ cubit.cmd(cubitcommand)
-def layercake_volume_ascii_regulargrid_mpiregularmap(filename=None,verticalsandwich=False):
+def surfaces(filename=None):
+ """create the volumes"""
+ import start as start
+ print'volume'
+ cfg = start.start_cfg(filename=filename)
+ print cfg
+ if cfg.volume_type == 'layercake_volume_ascii_regulargrid_regularmap':
+ layercake_volume_ascii_regulargrid_mpiregularmap(filename=filename,onlysurface=True)
+ elif cfg.volume_type == 'layercake_volume_fromacis_mpiregularmap':
+ layercake_volume_fromacis_mpiregularmap(filename=filename,onlysurface=True)
+ elif cfg.volume_type == 'verticalsandwich_volume_ascii_regulargrid_mpiregularmap':
+ layercake_volume_ascii_regulargrid_mpiregularmap(filename=filename,verticalsandwich=True,onlysurface=True)
+
+
+
+
+
+
+
+
+def layercake_volume_ascii_regulargrid_mpiregularmap(filename=None,verticalsandwich=False,onlysurface=False):
import sys
import start as start
#
@@ -334,22 +374,19 @@
#
#
#!create volume
- if not cfg.debugsurface:
- if cfg.osystem == 'macosx':
- pass
- elif cfg.osystem == 'linux':
- if cfg.nz == 1:
- nsurface=2
- else:
- nsurface=cfg.nz
- for inz in range(1,nsurface):
- ner=cubit.get_error_count()
- cubitcommand= 'create volume loft surface '+ str( inz+1 )+' '+str( inz )
- cubit.cmd(cubitcommand)
- ner2=cubit.get_error_count()
- isurf=isurf+6
- if ner == ner2:
- cubitcommand= 'del surface 1 to '+ str( cfg.nz )
+ if not onlysurface:
+ if cfg.nz == 1:
+ nsurface=2
+ else:
+ nsurface=cfg.nz
+ for inz in range(1,nsurface):
+ ner=cubit.get_error_count()
+ create_volume(inz,inz+1,method=cfg.volumecreation_method)
+ ner2=cubit.get_error_count()
+ #if ner == ner2 and not cfg.debug_geometry:
+ if ner == ner2:
+ #cubitcommand= 'del surface 1 to '+ str( cfg.nz )
+ cubitcommand= 'del surface all'
cubit.cmd(cubitcommand)
list_vol=cubit.parse_cubit_list("volume","all")
if len(list_vol) > 1:
@@ -357,7 +394,7 @@
cubit.cmd(cubitcommand)
cubitcommand= 'merge all'
cubit.cmd(cubitcommand)
- ner=cubit.get_error_count()
+ #ner=cubit.get_error_count()
#cubitcommand= 'composite create curve in vol all'
#cubit.cmd(cubitcommand)
savegeometry(iproc,filename=filename)
@@ -491,8 +528,9 @@
#lofting the volume
for i,j in zip(list_surf,list_surf[1:]):
ner=cubit.get_error_count()
- cubitcommand= 'create volume loft surface '+ str(i)+' '+str(j)
- cubit.cmd(cubitcommand)
+ create_volume(i,j,method=cfg.volumecreation_method)
+ #cubitcommand= 'create volume loft surface '+ str(i)+' '+str(j)
+ #cubit.cmd(cubitcommand)
ner2=cubit.get_error_count()
#
translate2original(xmin,ymin)
@@ -521,7 +559,54 @@
# imprint_topography_with_geological_outline(curvesname,outdir)
+def hor_distance(c1,c2):
+ p1=cubit.get_center_point("curve", c1)
+ p2=cubit.get_center_point("curve", c2)
+ d=(p1[0]-p2[0])**2+(p1[1]-p2[1])**2
+ return d
+
+
+def coupling_curve(lcurve1,lcurve2):
+ """get the couple of curve that we use to get the skin surface"""
+ import operator
+ couples=[]
+ for c1 in lcurve1:
+ distance=[]
+ for c2 in lcurve2:
+ d=hor_distance(c1,c2)
+ distance.append(d)
+ min_index, min_value = min(enumerate(distance), key=operator.itemgetter(1))
+ couples.append((c1,lcurve2[min_index]))
+ return couples
+
+def create_volume(surf1,surf2,method='loft'):
+ if method == 'loft':
+ cmd='create volume loft surface '+str(surf1)+' '+str(surf2)
+ cubit.cmd(cmd)
+ else:
+ lcurve1=cubit.get_relatives("surface",surf1,"curve")
+ lcurve2=cubit.get_relatives("surface",surf2,"curve")
+ couples=coupling_curve(lcurve1,lcurve2)
+ is_start=cubit.get_last_id('surface')+1
+ for cs in couples:
+ cmd='create surface skin curve '+str(cs[1])+' '+str(cs[0])
+ cubit.cmd(cmd)
+ is_stop=cubit.get_last_id('surface')
+ cmd="create volume surface "+str(surf1)+' '+str(surf2)+' '+str(is_start)+' to '+str(is_stop)+" heal keep"
+ cubit.cmd(cmd)
+
+
+
+
+
+
+
+
+
+
+
+
#def imprint_topography_with_geological_outline(curvesname,outdir='.'):
# import sys,os
# from sets import Set
More information about the CIG-COMMITS
mailing list