Example #1
0
def plane(cfg):
    import sys,os
    from math import sqrt
    from utilities import geo2utm
    import start as start
    #
    #
    cubit                   = start.start_cubit()
    #
    #
    command = "reset"
    cubit.cmd(command)
    #
    #
    for p in [cfg.x1,cfg.x2,cfg.x3,cfg.x4]:
        x_current,y_current=geo2utm(p[0],p[1],cfg.unit)
        cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( p[2] )
        cubit.cmd(cubitcommand)
    #
    cubitcommand= 'create surface vertex 1 2 3 4'
    cubit.cmd(cubitcommand)
    command = "del vertex all"
    cubit.cmd(command)
    command = "save as 'plane.cub' overwrite"
    cubit.cmd(command)
    #
    #
    #        
    cubit.cmd("set info "+cfg.cubit_info)
    cubit.cmd("set echo "+cfg.echo_info)
    cubit.cmd("set journal "+cfg.jou_info)
Example #2
0
 def runimport(geometryfile, iproc, filename=None):
     import start as start
     cubit = start.start_cubit()
     cfg = start.start_cfg(filename=filename)
     file1 = cfg.output_dir + '/' + geometryfile
     cubitcommand = 'open "' + file1 + '"  '
     cubit.cmd(cubitcommand)
Example #3
0
 def runimport(geometryfile, iproc, filename=None):
     import start as start
     cubit = start.start_cubit()
     cfg = start.start_cfg(filename=filename)
     file1 = cfg.output_dir + '/' + geometryfile
     cubitcommand = 'open "' + file1 + '"  '
     cubit.cmd(cubitcommand)
Example #4
0
 def runsave(geometryfile,iproc,filename=None):
     import start as start
     cubit                   = start.start_cubit()
     cfg                         = start.start_cfg(filename=filename)
     flag=[0]
     ner=cubit.get_error_count()
     cubitcommand= 'save as "'+ cfg.output_dir+'/'+geometryfile+ '"  overwrite' 
     cubit.cmd(cubitcommand)                                                    
     ner2=cubit.get_error_count()                                             
     if ner == ner2:
         flag=[1]
     return flag
Example #5
0
 def runsave(geometryfile, iproc, filename=None):
     import start as start
     cubit = start.start_cubit()
     cfg = start.start_cfg(filename=filename)
     flag = [0]
     ner = cubit.get_error_count()
     cubitcommand = 'save as "' + cfg.output_dir + '/' + geometryfile + '"  overwrite'
     cubit.cmd(cubitcommand)
     ner2 = cubit.get_error_count()
     if ner == ner2:
         flag = [1]
     return flag
Example #6
0
 def runsave(meshfile,iproc,filename=None):
     import start as start
     cubit                   = start.start_cubit()
     cfg                         = start.start_cfg(filename=filename)
     flag=0
     ner=cubit.get_error_count()
     cubitcommand= 'save as "'+ cfg.output_dir+'/'+meshfile+'.cub'+ '" overwrite' 
     cubit.cmd(cubitcommand)
     ner2=cubit.get_error_count()
     if ner == ner2:
         cubitcommand= 'export mesh "'+ cfg.output_dir+'/'+meshfile+'.e'+ '" dimension 3 block all overwrite' 
         cubit.cmd(cubitcommand)
         ner2=cubit.get_error_count()                                                    
     if ner == ner2:
         flag=1
     return flag
Example #7
0
 def runsave(meshfile, iproc, filename=None):
     import start as start
     cubit = start.start_cubit()
     cfg = start.start_cfg(filename=filename)
     flag = 0
     ner = cubit.get_error_count()
     cubitcommand = 'save as "' + cfg.output_dir + '/' + meshfile + '.cub' + '" overwrite'
     cubit.cmd(cubitcommand)
     ner2 = cubit.get_error_count()
     if ner == ner2:
         cubitcommand = 'export mesh "' + cfg.output_dir + '/' + meshfile + '.e' + '" dimension 3 block all overwrite'
         cubit.cmd(cubitcommand)
         ner2 = cubit.get_error_count()
     if ner == ner2:
         flag = 1
     return flag
# it under the terms of the GNU General Public License as published by      #
# the Free Software Foundation, either version 3 of the License, or         #
# (at your option) any later version.                                       #
#                                                                           #
# GEOCUBIT is distributed in the hope that it will be useful,               #
# but WITHOUT ANY WARRANTY; without even the implied warranty of            #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
# GNU General Public License for more details.                              #
#                                                                           #
# You should have received a copy of the GNU General Public License         #
# along with GEOCUBIT.  If not, see <http://www.gnu.org/licenses/>.         #
#                                                                           #
#############################################################################
try:
    import start as start
    cubit                   = start.start_cubit()
except:
    try:
        import cubit
    except:
        print 'error importing cubit, check if cubit is installed'
        pass

numpy                       = start.start_numpy()

def check_orientation(grdfileNAME):

    try:
         grdfile = open(grdfileNAME, 'r')
         print 'reading ',grdfileNAME
    except:
Example #9
0
# the Free Software Foundation; either version 2 of the License, or         #
# (at your option) any later version.                                       #
#                                                                           #
# This program is distributed in the hope that it will be useful,           #
# but WITHOUT ANY WARRANTY; without even the implied warranty of            #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
# GNU General Public License for more details.                              #
#                                                                           #
# You should have received a copy of the GNU General Public License along   #
# with this program; if not, write to the Free Software Foundation, Inc.,   #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.               #
#                                                                           #
#############################################################################
try:
    import start as start
    cubit = start.start_cubit()
except:
    try:
        import cubit
    except:
        print 'error importing cubit, check if cubit is installed'
        pass

from utilities import list2str


def map_boundary(cpuxmin=0, cpuxmax=1, cpuymin=0, cpuymax=1, cpux=1, cpuy=1):
    ymin = []
    xmax = []
    xmin = []
    ymax = []
Example #10
0
def surface_skin(isurface=0,cfgname=None):
    """
    create an acis surface interpolating no-intersecting lines
    """
    import sys,os
    from math import sqrt
    from utilities import geo2utm
    import start as start
    #
    #
    cubit                   = start.start_cubit()
    cfg                     = start.start_cfg(cfgname)
    #
    def define_next_line(directionx,directiony,n,data):
        ndata=len(data)
        command=''
        ind=n
        try:
            record=data[ind]
        except:
            return False,False
        try:
            x,y,z=map(float,record.split())
        except:
            return False,False
        txt=' Position ' +   record
        command=command+txt
        x_store,y_store,z_store = x,y,z
        icount=1
        while True:
                    ind+=1
                    if ind >= ndata: return ind,command
                    record=data[ind]
                    try:
                        x,y,z=map(float,record.split())
                    except:
                        return ind,command
                    dx,dy = x-x_store,y-y_store        
                    if  directionx == 0 and dy/abs(dy) * directiony >= 0:
                        txt=' Position ' +   record
                        command=command+txt
                        icount+=1
                        x_store,y_store,z_store = x,y,z
                    elif  directiony == 0 and dx/abs(dx) == directionx :
                        txt=' Position ' +   record
                        command=command+txt
                        icount+=1
                        x_store,y_store,z_store = x,y,z
                    else:
                        if icount==1:
                           x,y,z=x_store+1e-4*directionx,y_store+1e-4*directiony,z_store
                           txt=' Position ' +str(x)+ ' '+str(y)+ ' '+str(z)
                           command=command+txt
                        return ind,command    
    def create_line(position):
        if position:
            last_curve_store=cubit.get_last_id("curve")
            command='create curve spline '+position
            cubit.silent_cmd(command)
            last_curve=cubit.get_last_id("curve")
            if last_curve != last_curve_store:
                return last_curve
            else:
                return False
        else:
            return False
                        
    command = "reset"
    cubit.cmd(command)
    #
    position=True
    #
    try:
         grdfile = open(cfg.surface_name[isurface], 'r')
    except:
         raise NameError, 'No such file or directory: '+  str( cfg.surface_name[isurface] )
    #
    directionx=cfg.directionx[isurface]
    directiony=cfg.directiony[isurface]
    step=cfg.step[isurface]
    position=True
    curveskin=[]
    count_line=0
    data=grdfile.read().split('\n')
    ndata=len(data)
    n=0
    #
    #
    command = "set echo off"
    cubit.cmd(command)
    command = "set journal off"
    cubit.cmd(command)
    command = "set info off"
    cubit.cmd(command)         
    #
    while position:
          index,position=define_next_line(directionx,directiony,n,data)
          if n%step == 0:
              curve=create_line(position)
              if curve: curveskin.append(curve)
          elif n%step != 0 and not position:
              curve=create_line(position)
              if curve: curveskin.append(curve)
          n=index
    umax=max(curveskin)
    umin=min(curveskin)
    print 'create surface skin curve '+ str( umin )+' to '+str( umax )
    cubitcommand= 'create surface skin curve '+ str( umin )+' to '+str( umax )
    cubit.cmd(cubitcommand)
    command = "del curve all"
    cubit.cmd(command)
    last_surface=cubit.get_last_id("surface")
    command = "regularize surf "+str(last_surface)
    cubit.cmd(command)
    #
    suff=cfg.surface_name[isurface].split('/')
    command = "save as '"+cfg.working_dir+"/surf_"+suff[-1]+".cub' overwrite"
    cubit.cmd(command)
    #
    #
    #        
    cubit.cmd("set info "+cfg.cubit_info)
    cubit.cmd("set echo "+cfg.echo_info)
    cubit.cmd("set journal "+cfg.jou_info)