Пример #1
0
def curver_bias_desc(Cdesc, dx, biasfactor, direction='l'):
    if type(Cdesc) is int:
        curver_bias(cubit.curve(Cdesc), dx, biasfactor, direction)
    elif type(Cdesc) is str:
        curver_bias(cubit.curve(cubit.get_id_from_name(Cdesc)), dx, biasfactor,
                    direction)
    return None
Пример #2
0
def split(Ca, Cb, Ca1name='_1', Ca2name='_2'):
    # Ca : crossing curve (the cutted one)
    # Cb : crossed curve (the unchanged one)
    # Ca & Cb are objects
    # If Ca[1/2]name starts with a underscore, we keep the original name as a prefix
    #SPLIT
    Caname = Ca.entity_name()
    command = 'split curve ' + str(Ca.id()) + ' crossing curve ' + str(Cb.id())
    print command
    cubit.cmd(command)
    # GET IDs
    lastID2 = cubit.get_last_id('curve')
    lastID1 = lastID2 - 1
    Ca1 = cubit.curve(lastID1)
    # RENAMING
    if Ca1name[0] == '_':
        #        Ca1.entity_name(Caname + Ca1name)
        command = 'curve ' + str(
            lastID1) + ' rename "' + Caname + Ca1name + '"'
    else:
        #        Ca1.entity_name(Ca1name)
        command = 'curve ' + str(lastID1) + ' rename "' + Ca1name + '"'
    cubit.cmd(command)
    Ca2 = cubit.curve(lastID2)
    if Ca2name[0] == '_':
        #        Ca2.entity_name(Caname + Ca2name)
        command = 'curve ' + str(
            lastID2) + ' rename "' + Caname + Ca2name + '"'
    else:
        #        Ca2.entity_name(Ca2name)
        command = 'curve ' + str(lastID2) + ' rename "' + Ca2name + '"'
    cubit.cmd(command)
    return Ca1, Ca2
Пример #3
0
def curver_start_end_desc(Cdesc, dx1, dx2, direction='l'):
    if type(Cdesc) is int:
        curver_start_end(cubit.curve(Cdesc), dx1, dx2, direction)
    elif type(Cdesc) is str:
        curver_start_end(cubit.curve(cubit.get_id_from_name(Cdesc)), dx1, dx2,
                         direction)
    return None
Пример #4
0
def split(Ca,Cb,Ca1name='_1',Ca2name='_2'):
    # Ca : crossing curve (the cutted one) 
    # Cb : crossed curve (the unchanged one)
    # Ca & Cb are objects
    # If Ca[1/2]name starts with a underscore, we keep the original name as a prefix
    #SPLIT
    Caname = Ca.entity_name()
    command = 'split curve ' + str(Ca.id()) + ' crossing curve ' + str(Cb.id())
    print command 
    cubit.cmd(command)
    # GET IDs
    lastID2 = cubit.get_last_id('curve')
    lastID1 = lastID2 - 1
    Ca1 = cubit.curve(lastID1)
    # RENAMING
    if Ca1name[0] == '_':
#        Ca1.entity_name(Caname + Ca1name)
        command = 'curve ' + str(lastID1) + ' rename "' + Caname + Ca1name +'"'        
    else:
#        Ca1.entity_name(Ca1name)
        command = 'curve ' + str(lastID1) + ' rename "' + Ca1name +'"'        
    cubit.cmd(command)    
    Ca2 = cubit.curve(lastID2)
    if Ca2name[0] == '_':
#        Ca2.entity_name(Caname + Ca2name)
        command = 'curve ' + str(lastID2) + ' rename "' + Caname + Ca2name +'"'        
    else:
#        Ca2.entity_name(Ca2name)
        command = 'curve ' + str(lastID2) + ' rename "' + Ca2name +'"'     
    cubit.cmd(command)    
    return Ca1,Ca2
Пример #5
0
def create_surface_desc(Dlist, name=''):
    # Dlist : liste des DESCRIPTEURS des courbes qui composent la future surface ([int] ou [str])
    OKlist = []
    if type(Dlist[0]) is int:
        for d in Dlist:
            OKlist.append(cubit.curve(d))
    elif type(Dlist[0]) is str:
        for d in Dlist:
            OKlist.append(cubit.curve(cubit.get_id_from_name(d)))
    S = cubit.create_surface(OKlist)
    if name != '':
        S.entity_name(name)
    return S
Пример #6
0
def create_surface_desc(Dlist,name=''):
    # Dlist : liste des DESCRIPTEURS des courbes qui composent la future surface ([int] ou [str])
    OKlist = []
    if type(Dlist[0]) is int:
        for d in Dlist:
            OKlist.append(cubit.curve(d))
    elif type(Dlist[0]) is str:
        for d in Dlist:
            OKlist.append(cubit.curve(cubit.get_id_from_name(d)))
    S = cubit.create_surface(OKlist)
    if name != '':
        S.entity_name(name)
    return S
Пример #7
0
def double_split_desc(Ca,
                      Cb,
                      Ca1name='_1',
                      Ca2name='_2',
                      Cb1name='_1',
                      Cb2name='_2'):
    if type(Ca) is int:
        Ca1, Ca2, Cb1, Cb2 = double_split(cubit.curve(Ca), cubit.curve(Cb),
                                          Ca1name, Ca2name, Cb1name, Cb2name)
    elif type(Ca) is str:
        Ca1, Ca2, Cb1, Cb2 = double_split(
            cubit.curve(cubit.get_id_from_name(Ca)),
            cubit.curve(cubit.get_id_from_name(Cb)), Ca1name, Ca2name, Cb1name,
            Cb2name)
    return Ca1, Ca2, Cb1, Cb2
Пример #8
0
def computeNonlinearConstraint(x, y):
    nlcon = numpy.zeros(len(x))
    target_surface = cubit.surface(1)
    vertex_on_surface = [False for i in range(0, len(x))]
    # First, determine whether the nonlinear constraint is satisfied
    for i in range(0, len(x)):
        vertex_on_surface[i] = target_surface.point_containment(
            [x[i], y[i], 0.])
    # Second, determine the magnitude of the nonlinear constraint value
    #         which is the distance of the point to the closest curve
    cid = cubit.get_entities("Curve")
    for i in range(0, len(x)):
        dist = numpy.zeros(len(cid))
        pXYZ = numpy.array([x[i], y[i], 0.])
        for c in range(0, 1):
            C = cubit.curve(cid[c])
            cpXYZ = numpy.array(C.closest_point(pXYZ))
            dist[c] = numpy.linalg.norm(cpXYZ - pXYZ)
        if vertex_on_surface[i] == True:
            # Nonlinear constraint is satisfied
            nlcon[i] = -1. * numpy.min(dist)
        else:
            # Nonlinear constraint not satisfied
            nlcon[i] = +1. * numpy.min(dist)
    return nlcon
Пример #9
0
def list_2_curve(X,Y,name='',unit='*km'):
    Vlist = list_2_listofvertices(X,Y,unit)
    finalcmd = "create curve spline from vertex " + str(Vlist[0].id()) + " to " + str(Vlist[-1].id())
    cubit.silent_cmd(finalcmd)
    C = cubit.curve(cubit.get_last_id('curve'))
    if name != '':
        C.entity_name(name)
    return C
Пример #10
0
def list_2_curve(X, Y, name='', unit='*km'):
    Vlist = list_2_listofvertices(X, Y, unit)
    finalcmd = "create curve spline from vertex " + str(
        Vlist[0].id()) + " to " + str(Vlist[-1].id())
    cubit.silent_cmd(finalcmd)
    C = cubit.curve(cubit.get_last_id('curve'))
    if name != '':
        C.entity_name(name)
    return C
Пример #11
0
def read_file_2_curve(path,name=''):
    Vlist = read_file_2_listofvertices(path)
    finalcmd = "create curve spline from vertex " + str(Vlist[0].id()) + " to " + str(Vlist[-1].id())
    cubit.silent_cmd(finalcmd)
    C = cubit.curve(cubit.get_last_id('curve'))
    if name == '':
        C.entity_name(os.path.basename(path))
    else:
        C.entity_name(name)
    return C
Пример #12
0
def read_file_2_curve(path, name=''):
    Vlist = read_file_2_listofvertices(path)
    finalcmd = "create curve spline from vertex " + str(
        Vlist[0].id()) + " to " + str(Vlist[-1].id())
    cubit.silent_cmd(finalcmd)
    C = cubit.curve(cubit.get_last_id('curve'))
    if name == '':
        C.entity_name(os.path.basename(path))
    else:
        C.entity_name(name)
    return C
Пример #13
0
def geom_cubit_solo(configfile):
    if not os.path.isfile(configfile):
        raise Exception("ERR: CONFIG FILE DON'T EXIST !!!")
    #  READ CONFIGFILE
    cf = ConfigParser.ConfigParser()
    cf.optionxform = str
    cf.read(configfile)
    bathyfile = cf.get('Input', 'bathyfile')
    slabfile = cf.get('Input', 'slabfile')
    left_extension = cf.getfloat('Parameters',
                                 'left_extension')  # (always positive)
    right_extension = cf.getfloat('Parameters', 'right_extension')
    down_limit = cf.getfloat('Parameters', 'down_limit')  # (always positive)
    EET_OP = cf.getfloat('Parameters', 'eet_op')  #  Thickness of the OP Litho
    EET_DP = cf.getfloat('Parameters', 'eet_dp')  #  Thickness of the DP Litho
    #    backstop_bool=cf.getboolean('Parameters','backstop_bool') # True or False
    x_backstop = cf.getfloat('Parameters', 'backstop_distance')
    dip_backstop = cf.getfloat('Parameters', 'backstop_angle')
    output_path = cf.get('Output', 'output_path')
    output_file_prefix = cf.get('Output', 'output_prefix')
    output_file_suffix = cf.get('Output', 'output_suffix')
    output_pathfile = output_path + '/' + output_file_prefix + '_' + output_file_suffix + '.exo'
    dx1 = cf.getfloat('Parameters', 'dx_fine')
    dx2 = cf.getfloat('Parameters', 'dx_coarse')
    # =======================================================================
    #  PRIOR DESIGN
    # =======================================================================
    # Loading the BATHY and SLAB files
    XYbathy = np.loadtxt(bathyfile)
    XYslab = np.loadtxt(slabfile)
    # Creating the bottom of the slab
    XslabBot, YslabBot, _ = rcl.shift_thickness(XYslab[:, 0], XYslab[:, 1],
                                                EET_DP)
    # Creating the bounding points in a dictionnary
    outpts = rcl.make_bounding_points(XYbathy[:, 0], XYbathy[:, 1], XYslab[:,
                                                                           0],
                                      XYslab[:, 1], EET_OP, EET_DP, down_limit,
                                      left_extension, right_extension)
    # Creating the backstop
    Xbackstop, Ybackstop = rcl.make_backstop(XYbathy[:, 0],
                                             XYbathy[:, 1],
                                             XYslab[:, 0],
                                             XYslab[:, 1],
                                             x_backstop,
                                             dip_backstop,
                                             dupdown=150)
    # Adding the 'Bottom_Litho_DP' point to the Litho_DP Bottom
    rcl.add_point_in_list(XslabBot, YslabBot, outpts['vBottom_Litho_DP'])
    # Changing the description concept : Bathy & Slab ==> OP & DP
    Xop, Yop, Xdp, Ydp = rcl.bathyslab_2_OPDPtop(XYbathy[:, 0], XYbathy[:, 1],
                                                 XYslab[:, 0], XYslab[:, 1])
    # Adding the limit points of OP & DP
    Xop, Yop = rcl.add_point_in_list(Xop, Yop, outpts['vBathy_OP'])
    Xdp, Ydp = rcl.add_point_in_list(Xdp, Ydp, outpts['vBathy_DP'])
    # PLOT FOR SECURITY
    #plt.clf()
    #plt.axis('equal')
    #plt.plot(XYbathy[:,0],XYbathy[:,1],'+b')
    #plt.plot(XYslab[:,0],XYslab[:,1],'r+-')
    #plt.plot(XslabBot,YslabBot,'k+-')
    #plt.plot(Xbackstop,Ybackstop,'*-y')
    #for p in outpts.viewvalues():
    #    plt.plot(p[0],p[1],'*k')
    #plt.plot(Xop,Yop,'b-')
    #plt.plot(Xdp,Ydp,'r-')
    # =======================================================================
    #  CUBIT MESHING
    # =======================================================================
    # Initalisation
    cubit.cmd('reset')
    cubit.cmd("#{Units('si')}")
    # Chargement des courbes
    rcl.list_2_curve(Xop, Yop, 'Top_Litho_OP')
    rcl.list_2_curve(Xdp, Ydp, 'Top_Litho_limit_DP')
    rcl.list_2_curve(XslabBot, YslabBot, 'Bottom_Litho_DP')
    rcl.list_2_curve(Xbackstop, Ybackstop, 'Backstop')
    # Chargement des Points Isoles
    rcl.dico_2_listofvertices(outpts)
    ## fabrication de "courbes-segments" a partir de vertex
    v_Bottom_Litho_OP = cubit.vertex(
        cubit.get_id_from_name('vBottom_Litho_OP'))
    v_Bathy_DP = rcl.find_extrema(
        cubit.curve(cubit.get_id_from_name("Top_Litho_limit_DP")), 'r')
    v_Bathy_OP = rcl.find_extrema(
        cubit.curve(cubit.get_id_from_name('Top_Litho_OP')), 'l')
    v_Bottom_Litho_DP = rcl.find_extrema(
        cubit.curve(cubit.get_id_from_name("Bottom_Litho_DP")), 'r')
    v_scratch = cubit.vertex(cubit.get_id_from_name('vscratch'))
    v_Bottom_Astheno_OP = cubit.vertex(
        cubit.get_id_from_name('vBottom_Astheno_OP'))
    v_Bottom_Astheno_DP = cubit.vertex(
        cubit.get_id_from_name('vBottom_Astheno_DP'))
    #
    rcl.vertices_2_curve(v_Bottom_Litho_OP, v_Bottom_Astheno_OP,
                         'Edge_Astheno_OP')
    rcl.vertices_2_curve(v_Bottom_Litho_OP, v_scratch, 'Bottom_Litho_OP_PROTO')
    rcl.vertices_2_curve(v_Bottom_Litho_OP, v_Bathy_OP, 'Edge_Litho_OP')
    rcl.vertices_2_curve(v_Bottom_Astheno_OP, v_Bottom_Astheno_DP,
                         'Bottom_PROTO')
    rcl.vertices_2_curve(v_Bathy_DP, v_Bottom_Litho_DP, 'Edge_Litho_DP')
    rcl.vertices_2_curve(v_Bottom_Litho_DP, v_Bottom_Astheno_DP,
                         'Edge_Astheno_DP')
    ## Split des courbes
    rcl.double_split_desc('Bottom_Litho_OP_PROTO', 'Top_Litho_limit_DP')
    rcl.double_split_desc("Bottom_PROTO", "Top_Litho_limit_DP_1")
    rcl.double_split_desc("Bottom_PROTO_2", "Bottom_Litho_DP")
    rcl.double_split_desc("Backstop", "Top_Litho_limit_DP_2")
    rcl.double_split_desc("Top_Litho_OP", "Backstop_1")
    rcl.double_split_desc("Top_Litho_limit_DP_2_2", "Top_Litho_OP_2")
    if True:
        #    ## suppression des petits morceaux
        rcl.destroy_curve_desc("Top_Litho_limit_DP_1_1")
        rcl.destroy_curve_desc("Bottom_Litho_DP_1")
        rcl.destroy_curve_desc("Backstop_2")
        rcl.destroy_curve_desc("Bottom_Litho_OP_PROTO_2")
        rcl.destroy_curve_desc("Backstop_1_1")
        #    ## renommage des courbes
        rcl.rename_curve_desc(7, 'Edge_Litho_OP')
        rcl.rename_curve_desc(5, 'Edge_Astheno_OP')
        rcl.rename_curve_desc(9, 'Edge_Litho_DP')
        rcl.rename_curve_desc(10, 'Edge_Astheno_DP')
        rcl.rename_curve_desc("Top_Litho_limit_DP_2_1", 'Contact_OP_DP')
        rcl.rename_curve_desc("Top_Litho_limit_DP_2_2_1", 'Contact_Prism_DP')
        rcl.rename_curve_desc("Backstop_1_2", 'Contact_Prism_OP')
        rcl.rename_curve_desc("Top_Litho_OP_2_1", 'Top_Litho_DP')
        rcl.rename_curve_desc("Top_Litho_OP_2_2", 'Top_Prism')
        rcl.rename_curve_desc("Top_Litho_OP_1", 'Top_Litho_OP')
        rcl.rename_curve_desc("Bottom_PROTO_2_2", 'Bottom_Astheno_DP')
        rcl.rename_curve_desc("Bottom_Litho_DP_2", 'Bottom_Litho_DP')
        rcl.rename_curve_desc("Bottom_PROTO_1", 'Bottom_Astheno_OP')
        rcl.rename_curve_desc("Bottom_Litho_OP_PROTO_1", 'Bottom_Litho_OP')
        rcl.rename_curve_desc("Bottom_PROTO_2_1", 'Front_Litho_DP')
        rcl.rename_curve_desc("Top_Litho_limit_DP_1_2",
                              'Astheno_Litho_Contact')
        #    # creation des surfaces
        rcl.create_surface_desc(
            ["Edge_Astheno_DP", "Bottom_Astheno_DP", "Bottom_Litho_DP"])
        rcl.create_surface_desc([
            "Front_Litho_DP", "Bottom_Litho_DP", "Edge_Litho_DP",
            "Top_Litho_DP", "Contact_Prism_DP", "Contact_OP_DP",
            "Astheno_Litho_Contact"
        ])
        rcl.create_surface_desc([
            "Bottom_Astheno_OP", "Astheno_Litho_Contact", "Bottom_Litho_OP",
            "Edge_Astheno_OP"
        ])
        rcl.create_surface_desc([
            "Bottom_Litho_OP", "Edge_Litho_OP", "Top_Litho_OP",
            "Contact_Prism_OP", "Contact_OP_DP"
        ])
        rcl.create_surface_desc(
            ["Top_Prism", "Contact_Prism_DP", "Contact_Prism_OP"])
        #    # renomage des surfaces
        cubit.surface(1).entity_name('Astheno_DP')
        cubit.surface(2).entity_name('Litho_DP')
        cubit.surface(3).entity_name('Astheno_OP')
        cubit.surface(4).entity_name('Litho_OP')
        cubit.surface(5).entity_name('Prisme')
        # Fusion des surfaces
        cubit.cmd('delete vertex all')
        cubit.cmd('imprint all')
        cubit.cmd('merge all')
        cubit.cmd('stitch volume all')
        rcl.rename_curve_desc(45, 'Astheno_Litho_Contact')
        cubit.cmd('surface all scheme trimesh')
        cubit.cmd('curve all scheme default')
        cubit.cmd('surface all sizing function none')
        # nouveau decoupage des courbes
        rcl.curver_desc("Contact_Prism_DP", dx1)
        rcl.curver_desc("Contact_Prism_OP", dx1)
        rcl.curver_desc("Top_Prism", dx1)
        rcl.curver_desc("Bottom_Litho_DP", dx2)
        rcl.curver_desc("Bottom_Astheno_OP", dx2)
        rcl.curver_desc("Front_Litho_DP", dx2)
        rcl.curver_desc("Bottom_Astheno_DP", dx2)
        rcl.curver_desc("Edge_Astheno_OP", dx2)
        rcl.curver_desc("Edge_Litho_OP", dx2)
        rcl.curver_desc("Edge_Astheno_DP", dx2)
        rcl.curver_desc("Edge_Litho_DP", dx2)
        rcl.curver_desc("Contact_OP_DP", dx1)
        rcl.curver_start_end_desc("Bottom_Litho_OP", dx1, dx2, 'l')
        rcl.curver_start_end_desc("Top_Litho_OP", dx1, dx2, 'l')
        rcl.curver_start_end_desc("Top_Litho_DP", dx1, dx2, 'r')
        rcl.curver_start_end_desc("Astheno_Litho_Contact", dx1, dx2, 'l')
        # fabrication du mesh
        cubit.cmd('mesh surface all')
        cubit.cmd('surface all smooth scheme condition number beta 1.7 cpu 10')
        cubit.cmd('smooth surface all')
        cubit.cmd('surface 1 size auto factor 5')
        ## Fabrication de groupe et de nodeset
        for i, s in enumerate(cubit.get_entities("surface")):
            S = cubit.surface(s)
            cubit.cmd('block ' + str(i + 1) + ' surface ' + S.entity_name())
            cubit.cmd('block ' + str(i + 1) + ' name "' + S.entity_name() +
                      ' "')
        rcl.create_group_nodeset_desc(
            ['Astheno_Litho_Contact', 'Contact_OP_DP', 'Contact_Prism_DP'],
            "fault_top", 20)
        rcl.create_group_nodeset_desc(
            ['Top_Litho_OP', 'Top_Prism', 'Top_Litho_DP'], "ground_surface",
            20)
        rcl.create_group_nodeset_desc(['Bottom_Litho_OP'], "bottom_litho_OP",
                                      20)
        rcl.create_group_nodeset_desc(['Bottom_Litho_DP'], "bottom_litho_DP",
                                      20)
        rcl.create_group_nodeset_desc(['Edge_Litho_OP'], "edge_litho_OP", 20)
        rcl.create_group_nodeset_desc(['Edge_Litho_DP'], "edge_litho_DP", 20)
        rcl.create_group_nodeset_desc(['Front_Litho_DP'], "front_litho_DP", 20)
        rcl.create_group_nodeset_desc(['Contact_Prism_OP'], "contact_prism_OP",
                                      20, ['fault_top'])
        print 'ca chie'
        rcl.create_group_nodeset_desc(
            ['Bottom_Astheno_DP', 'Bottom_Astheno_OP'], "bottom_astheno", 20,
            ['front_litho_DP'])
        print 'ca chie 2'
        rcl.create_group_nodeset_desc(['Edge_Astheno_DP'], "edge_astheno_DP",
                                      20, ['edge_litho_DP'])
        rcl.create_group_nodeset_desc(['Edge_Astheno_OP'], "edge_astheno_OP",
                                      20, ['edge_litho_OP'])
        # ecriture fichier final
        cubit.cmd('export mesh "' + output_pathfile +
                  '" dimension 2 overwrite')
    return None
Пример #14
0
def rename_curve_desc(Cdesc, newname):
    if type(Cdesc) is int:
        rename_curve(cubit.curve(Cdesc), newname)
    elif type(Cdesc) is str:
        rename_curve(cubit.curve(cubit.get_id_from_name(Cdesc)), newname)
    return None
Пример #15
0
def destroy_curve_desc(Cdesc):
    if type(Cdesc) is int:
        destroy_curve(cubit.curve(Cdesc))
    elif type(Cdesc) is str:
        destroy_curve(cubit.curve(cubit.get_id_from_name(Cdesc)))
    return None
Пример #16
0
def double_split_desc(Ca,Cb,Ca1name='_1',Ca2name='_2',Cb1name='_1',Cb2name='_2'):
    if type(Ca) is int:
        Ca1,Ca2,Cb1,Cb2 = double_split(cubit.curve(Ca),cubit.curve(Cb),Ca1name,Ca2name,Cb1name,Cb2name)
    elif type(Ca) is str:
        Ca1,Ca2,Cb1,Cb2 = double_split(cubit.curve(cubit.get_id_from_name(Ca)),cubit.curve(cubit.get_id_from_name(Cb)),Ca1name,Ca2name,Cb1name,Cb2name)
    return Ca1,Ca2,Cb1,Cb2  
Пример #17
0
def curver_bias_desc(Cdesc,dx,biasfactor,direction='l'):
    if type(Cdesc) is int:
        curver_bias(cubit.curve(Cdesc),dx,biasfactor,direction)
    elif type(Cdesc) is str:
        curver_bias(cubit.curve(cubit.get_id_from_name(Cdesc)),dx,biasfactor,direction)
    return None
Пример #18
0
def curver_start_end_desc(Cdesc,dx1,dx2,direction='l'):
    if type(Cdesc) is int:
        curver_start_end(cubit.curve(Cdesc),dx1,dx2,direction)
    elif type(Cdesc) is str:
        curver_start_end(cubit.curve(cubit.get_id_from_name(Cdesc)),dx1,dx2,direction)
    return None    
Пример #19
0
def destroy_curve_desc(Cdesc):
    if type(Cdesc) is int:
        destroy_curve(cubit.curve(Cdesc))
    elif type(Cdesc) is str:
        destroy_curve(cubit.curve(cubit.get_id_from_name(Cdesc)))
    return None   
Пример #20
0
def rename_curve_desc(Cdesc,newname):
    if type(Cdesc) is int:
        rename_curve(cubit.curve(Cdesc),newname)
    elif type(Cdesc) is str:
        rename_curve(cubit.curve(cubit.get_id_from_name(Cdesc)),newname)
    return None
def geom_cubit_main(configfile):
    if not os.path.isfile(configfile) :
        raise Exception("ERR: CONFIG FILE DON'T EXIST !!!")
    #  READ CONFIGFILE
    cf = ConfigParser.ConfigParser()
    cf.read(configfile)
    experience_name = cf.get('Input','experience_name')
    bathyfile = cf.get('Input','bathyfile')
    slabfile = cf.get('Input','slabfile')
    left_extension=cf.getfloat('Parameters','left_extension') # (always positive)
    right_extension=cf.getfloat('Parameters','right_extension')
    down_limit=cf.getfloat('Parameters','down_limit') # (always positive)
    EET_OP=cf.getfloat('Parameters','EET_OP') #  Thickness of the OP Litho
    EET_DP=cf.getfloat('Parameters','EET_DP') #  Thickness of the DP Litho
    backstop_bool=cf.getboolean('Parameters','backstop_bool') # True or False
    x_backstop=cf.getfloat('Parameters','x_backstop')
    dip_backstop=cf.getfloat('Parameters','dip_backstop')
    output_path=cf.get('Output','output_path')
    output_file_prefix=cf.get('Output','output_file_prefix')
    output_pathfile = output_path + '/'  + output_file_prefix + '_'  + experience_name + '.exo'
    # =======================================================================
    #  PRIOR DESIGN
    # =======================================================================
    # Loading the BATHY and SLAB files
    XYbathy = np.loadtxt(bathyfile)
    XYslab = np.loadtxt(slabfile)
    # Creating the bottom of the slab
    XslabBot,YslabBot,_ = gcl.shift_thickness(XYslab[:,0],XYslab[:,1],EET_DP)
    # Creating the bounding points in a dictionnary
    outpts = gcl.make_bounding_points(XYbathy[:,0],XYbathy[:,1],XYslab[:,0],XYslab[:,1],EET_OP,EET_DP,down_limit,left_extension,right_extension)
    # Creating the backstop
    Xbackstop,Ybackstop = gcl.make_backstop(XYbathy[:,0],XYbathy[:,1],XYslab[:,0],XYslab[:,1],x_backstop,dip_backstop,dupdown=150)
    # Adding the 'Bottom_Litho_DP' point to the Litho_DP Bottom
    gcl.add_point_in_list(XslabBot,YslabBot,outpts['vBottom_Litho_DP'])
    # Changing the description concept : Bathy & Slab ==> OP & DP
    Xop,Yop,Xdp,Ydp = gcl.bathyslab_2_OPDPtop(XYbathy[:,0],XYbathy[:,1],XYslab[:,0],XYslab[:,1])
    # Adding the limit points of OP & DP
    Xop,Yop = gcl.add_point_in_list(Xop,Yop,outpts['vBathy_OP'])
    Xdp,Ydp = gcl.add_point_in_list(Xdp,Ydp,outpts['vBathy_DP'])
    # PLOT FOR SECURITY
    #plt.clf()
    #plt.axis('equal')
    #plt.plot(XYbathy[:,0],XYbathy[:,1],'+b')
    #plt.plot(XYslab[:,0],XYslab[:,1],'r+-')
    #plt.plot(XslabBot,YslabBot,'k+-')
    #plt.plot(Xbackstop,Ybackstop,'*-y')
    #for p in outpts.viewvalues():
    #    plt.plot(p[0],p[1],'*k')
    #plt.plot(Xop,Yop,'b-')
    #plt.plot(Xdp,Ydp,'r-')
    # =======================================================================
    #  CUBIT MESHING
    # =======================================================================
    # Initalisation
    cubit.cmd('reset')  
    cubit.cmd("#{Units('si')}")  
    # Chargement des courbes
    gcl.list_2_curve(Xop,Yop,'Top_Litho_OP')
    gcl.list_2_curve(Xdp,Ydp,'Top_Litho_limit_DP')
    gcl.list_2_curve(XslabBot,YslabBot,'Bottom_Litho_DP')
    gcl.list_2_curve(Xbackstop,Ybackstop,'Backstop')
    # Chargement des Points Isolés
    gcl.dico_2_listofvertices(outpts)
    ## fabrication de "courbes-segments" a partir de vertex
    v_Bottom_Litho_OP = cubit.vertex(cubit.get_id_from_name('vBottom_Litho_OP'))
    v_Bathy_DP = gcl.find_extrema(cubit.curve(cubit.get_id_from_name("Top_Litho_limit_DP")),'r')
    v_Bathy_OP = gcl.find_extrema(cubit.curve(cubit.get_id_from_name('Top_Litho_OP')),'l')
    v_Bottom_Litho_DP = gcl.find_extrema(cubit.curve(cubit.get_id_from_name("Bottom_Litho_DP")),'r')
    v_scratch = cubit.vertex(cubit.get_id_from_name('vscratch'))
    v_Bottom_Astheno_OP = cubit.vertex(cubit.get_id_from_name('vBottom_Astheno_OP'))
    v_Bottom_Astheno_DP = cubit.vertex(cubit.get_id_from_name('vBottom_Astheno_DP'))
    # 
    gcl.vertices_2_curve(v_Bottom_Litho_OP,v_Bottom_Astheno_OP,'Edge_Astheno_OP')
    gcl.vertices_2_curve(v_Bottom_Litho_OP,v_scratch,'Bottom_Litho_OP_PROTO')
    gcl.vertices_2_curve(v_Bottom_Litho_OP,v_Bathy_OP,'Edge_Litho_OP')
    gcl.vertices_2_curve(v_Bottom_Astheno_OP,v_Bottom_Astheno_DP,'Bottom_PROTO')
    gcl.vertices_2_curve(v_Bathy_DP,v_Bottom_Litho_DP,'Edge_Litho_DP')
    gcl.vertices_2_curve(v_Bottom_Litho_DP,v_Bottom_Astheno_DP,'Edge_Astheno_DP') 
    ## Split des courbes
    gcl.double_split_desc(2,6)
    gcl.double_split_desc(8,11)
    gcl.double_split_desc(16,3)
    gcl.double_split_desc(4,12)
    gcl.double_split_desc(1,23)
    gcl.double_split_desc(26,28)
    ## suppression des petits morceaux
    gcl.destroy_curve(cubit.curve(14))
    gcl.destroy_curve(cubit.curve(24))
    gcl.destroy_curve(cubit.curve(17))
    gcl.destroy_curve(cubit.curve(21))
    gcl.destroy_curve(cubit.curve(29))
    ## renommage des courbes
    gcl.rename_curve_desc(7,'Edge_Litho_OP')
    gcl.rename_curve_desc(5,'Edge_Astheno_OP')
    gcl.rename_curve_desc(9,'Edge_Litho_DP')
    gcl.rename_curve_desc(10,'Edge_Astheno_DP')
    gcl.rename_curve_desc(25,'Contact_OP_DP')
    gcl.rename_curve_desc(31,'Contact_Prism_DP')
    gcl.rename_curve_desc(30,'Contact_Prism_OP')
    gcl.rename_curve_desc(32,'Top_Litho_DP')
    gcl.rename_curve_desc(33,'Top_Prism')
    gcl.rename_curve_desc(27,'Top_Litho_OP')
    gcl.rename_curve_desc(20,'Bottom_Astheno_DP')
    gcl.rename_curve_desc(22,'Bottom_Litho_DP')
    gcl.rename_curve_desc(15,'Bottom_Astheno_OP')
    gcl.rename_curve_desc(13,'Bottom_Litho_OP')
    gcl.rename_curve_desc(19,'Front_Litho_DP')
    gcl.rename_curve_desc(18,'Astheno_Litho_Contact')
    # creation des surfaces
    gcl.create_surface_desc([10,20,22])
    gcl.create_surface_desc([19,18,25,31,32,9,22])
    gcl.create_surface_desc([13,18,15,5])
    gcl.create_surface_desc([13,7,27,30,25])
    gcl.create_surface_desc([30,31,33])
    # renomage des surfaces
    cubit.surface(1).entity_name('Astheno_DP')
    cubit.surface(2).entity_name('Litho_DP')
    cubit.surface(3).entity_name('Astheno_OP')
    cubit.surface(4).entity_name('Litho_OP')
    cubit.surface(5).entity_name('Prisme')
    # Fusion des surfaces
    cubit.cmd('delete vertex all')
    cubit.cmd('imprint all')
    cubit.cmd('merge all')
    cubit.cmd('stitch volume all')
    cubit.cmd('surface all scheme trimesh')
    cubit.cmd('curve all scheme default')
    cubit.cmd('surface all sizing function none')
    # nouveau decoupage des courbes
    dx1 = 4.0
    dx2 = 25.0
    dx3 = 8
    b1=1.1
    gcl.curver_desc("Contact_Prism_DP",dx1)
    gcl.curver_desc("Contact_Prism_OP",dx1)
    gcl.curver_desc("Top_Prism",dx1)
    gcl.curver_desc("Bottom_Litho_DP",dx2)
    gcl.curver_desc("Bottom_Astheno_OP",dx2)
    gcl.curver_desc("Front_Litho_DP",dx2)
    gcl.curver_desc("Bottom_Astheno_DP",dx2)
    gcl.curver_desc("Edge_Astheno_OP",dx2)
    gcl.curver_desc("Edge_Litho_OP",dx2)
    gcl.curver_desc("Edge_Astheno_DP",dx2)
    gcl.curver_desc("Edge_Litho_DP",dx2)
    gcl.curver_desc("Contact_OP_DP",dx1)
    gcl.curver_start_end_desc("Bottom_Litho_OP",dx1,dx2,'l')
    gcl.curver_start_end_desc("Top_Litho_OP",dx1,dx2,'l')
    gcl.curver_start_end_desc("Top_Litho_DP",dx1,dx2,'r')
    gcl.curver_start_end_desc("Astheno_Litho_Contact",dx1,dx2,'l')  
    # fabrication du mesh
    cubit.cmd('mesh surface all')
    cubit.cmd('surface all smooth scheme condition number beta 1.7 cpu 10')
    cubit.cmd('smooth surface all')
    cubit.cmd('surface 1 size auto factor 5')
    ## Fabrication de groupe et de nodeset
    for i,s in enumerate(cubit.get_entities("surface")):
        S = cubit.surface(s)
        cubit.cmd('block ' + str(i+1) + ' surface ' + S.entity_name())
        cubit.cmd('block ' + str(i+1) + ' name "' + S.entity_name() + ' "' )
    gcl.create_group_nodeset_desc(['Astheno_Litho_Contact','Contact_OP_DP','Contact_Prism_DP'],"fault_top",20)     
    gcl.create_group_nodeset_desc(['Top_Litho_OP','Top_Prism','Top_Litho_DP'],"ground_surface",20)     
    gcl.create_group_nodeset_desc(['Bottom_Litho_OP'],"bottom_litho_OP",20)     
    gcl.create_group_nodeset_desc(['Bottom_Litho_DP'],"bottom_litho_DP",20)     
    gcl.create_group_nodeset_desc(['Bottom_Astheno_DP','Bottom_Astheno_OP'],"bottom_astheno",20) 
    gcl.create_group_nodeset_desc(['Edge_Litho_OP'],"edge_litho_OP",20) 
    gcl.create_group_nodeset_desc(['Edge_Litho_DP'],"edge_litho_DP",20) 
    gcl.create_group_nodeset_desc(['Edge_Astheno_OP'],"edge_astheno_OP",20) 
    gcl.create_group_nodeset_desc(['Edge_Astheno_DP'],"edge_astheno_DP",20) 
    gcl.create_group_nodeset_desc(['Front_Litho_DP'],"front_litho_DP",20) 
    gcl.create_group_nodeset_desc(['Contact_Prism_OP'],"contact_prism_OP",20)
    # ecriture fichier final
    cubit.cmd('export mesh "' + output_pathfile + '" dimension 2 overwrite')
    return None