Exemplo n.º 1
0
def list_2_listofvertices(X,Y,unit='*km'):
    Vlis_out = []
    for x,y in zip(X,Y):
        komand = "create vertex x { "+str(x)+ unit + "} y { "+str(y) + unit + "}"
        cubit.silent_cmd(komand)
        v = cubit.vertex(cubit.get_last_id('vertex'))
        Vlis_out.append(v)  
    return Vlis_out 
Exemplo n.º 2
0
def list_2_listofvertices(X, Y, unit='*km'):
    Vlis_out = []
    for x, y in zip(X, Y):
        komand = "create vertex x { " + str(x) + unit + "} y { " + str(
            y) + unit + "}"
        cubit.silent_cmd(komand)
        v = cubit.vertex(cubit.get_last_id('vertex'))
        Vlis_out.append(v)
    return Vlis_out
Exemplo n.º 3
0
def dico_2_listofvertices(dico,unit='*km'):
    Vlis_out = []
    for name , xy in dico.iteritems():
        komand = "create vertex x { "+str(xy[0])+ unit + "} y { "+str(xy[1]) + unit + "}"
        cubit.silent_cmd(komand)
        v = cubit.vertex(cubit.get_last_id('vertex'))
        v.entity_name(name)
        Vlis_out.append(v)  
    return Vlis_out 
Exemplo n.º 4
0
def dico_2_listofvertices(dico, unit='*km'):
    Vlis_out = []
    for name, xy in dico.iteritems():
        komand = "create vertex x { " + str(xy[0]) + unit + "} y { " + str(
            xy[1]) + unit + "}"
        cubit.silent_cmd(komand)
        v = cubit.vertex(cubit.get_last_id('vertex'))
        v.entity_name(name)
        Vlis_out.append(v)
    return Vlis_out
Exemplo n.º 5
0
def read_file_2_listofvertices(path,unit='*km'):
    filein = open(path)
    Vlis_out = []
    for line in filein:
        fields = line.split()
#        v = cubit.create_vertex(float(fields[0]),float(fields[1]),0)    
        komand = "create vertex x { "+str(float(fields[0]))+ unit + "} y { "+str(float(fields[1])) + unit + "}"
        cubit.silent_cmd(komand)
        v = cubit.vertex(cubit.get_last_id('vertex'))
        Vlis_out.append(v)  
    return Vlis_out 
Exemplo n.º 6
0
def read_file_2_listofvertices(path, unit='*km'):
    filein = open(path)
    Vlis_out = []
    for line in filein:
        fields = line.split()
        #        v = cubit.create_vertex(float(fields[0]),float(fields[1]),0)
        komand = "create vertex x { " + str(float(
            fields[0])) + unit + "} y { " + str(float(fields[1])) + unit + "}"
        cubit.silent_cmd(komand)
        v = cubit.vertex(cubit.get_last_id('vertex'))
        Vlis_out.append(v)
    return Vlis_out
Exemplo n.º 7
0
def curver_start_end(C,dxstrt,dxend,direct='l',unit='*km'):
    Vtup = cubit.get_relatives("curve", C.id(), "vertex")
    if cubit.vertex(Vtup[1]).coordinates()[0] > cubit.vertex(Vtup[0]).coordinates()[0]:
        vr = cubit.vertex(Vtup[1])
        vl = cubit.vertex(Vtup[0])
    else:
        vr = cubit.vertex(Vtup[0])
        vl = cubit.vertex(Vtup[1])
    if direct == 'l':
        vstart = vr
    elif direct == 'r':
        vstart = vl       
    komand = "curve " + str(C.id()) + " scheme bias fine size {" + str(dxstrt) + unit + "} coarse size  {" + str(dxend) + unit + "} start vertex " + str(vstart.id())
    print komand
    cubit.silent_cmd(komand)
    return None
Exemplo n.º 8
0
def curver_start_end(C, dxstrt, dxend, direct='l', unit='*km'):
    Vtup = cubit.get_relatives("curve", C.id(), "vertex")
    if cubit.vertex(Vtup[1]).coordinates()[0] > cubit.vertex(
            Vtup[0]).coordinates()[0]:
        vr = cubit.vertex(Vtup[1])
        vl = cubit.vertex(Vtup[0])
    else:
        vr = cubit.vertex(Vtup[0])
        vl = cubit.vertex(Vtup[1])
    if direct == 'l':
        vstart = vr
    elif direct == 'r':
        vstart = vl
    komand = "curve " + str(C.id()) + " scheme bias fine size {" + str(
        dxstrt) + unit + "} coarse size  {" + str(
            dxend) + unit + "} start vertex " + str(vstart.id())
    print komand
    cubit.silent_cmd(komand)
    return None
Exemplo n.º 9
0
cubit.cmd('webcut volume all with cylinder radius  1.8 axis z center 0,0,0')

for icurve in cubit.get_entities('curve'):
    l = cubit.get_curve_length(icurve)
    r1 = 2 * math.pi * 1.8
    r2 = 2 * math.pi * 2.0
    r3 = 2 * math.pi * 20.0
    if cubit.get_relatives('curve', icurve, 'volume') > 36:
        if np.abs(l - r1) < 0.01 or np.abs(l - r2) < 0.01 or np.abs(l -
                                                                    r3) < 0.01:
            cubit.cmd('curve %i interval 6' % icurve)

for ivol in cubit.get_entities('volume'):
    for icurve in cubit.get_relatives('volume', ivol, 'curve'):
        v = [
            cubit.vertex(ivertex)
            for ivertex in cubit.get_relatives('curve', icurve, 'vertex')
        ]
        if len(v) == 2:
            x0, y0, z0 = v[0].coordinates()
            x1, y1, z1 = v[1].coordinates()
            if np.abs(x0 - x1) < 0.01 and np.abs(y0 - y1) < 0.01:
                z = 0.5 * (z0 + z1)
                if z < -7:
                    intv = 3
                    bias = 0.95
                    if z0 > z1:
                        cubit.cmd('curve %i interval %i scheme bias {1/%f}' %
                                  (icurve, intv, bias))
                    else:
                        cubit.cmd('curve %i interval %i scheme bias %f' %
Exemplo n.º 10
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
Exemplo n.º 11
0
    def genSons(self, branch):
        ipr = self.points[branch.initialPoint]
        fpr = self.points[branch.finalPoint]
        fp = self.points[branch.son1.finalPoint]
        fp2 = self.points[branch.son2.finalPoint]
        lenght = geo.distance(ipr, fpr)
        t=(lenght-branch.radius)/lenght
        ref = [(1-t)*ipr[0]+t*fpr[0],((1-t)*ipr[1]+t*fpr[1]),((1-t)*ipr[2]+t*fpr[2])]
        t2=(lenght+branch.radius)/lenght
        ref2 = [(1-t2)*ipr[0]+t2*fpr[0],((1-t2)*ipr[1]+t2*fpr[1]),((1-t2)*ipr[2]+t2*fpr[2])]
        u_0 = [fp[0]-fpr[0],fp[1]-fpr[1],fp[2]-fpr[2]]
        u_1 = [fp2[0]-fpr[0],fp2[1]-fpr[1],fp2[2]-fpr[2]]
        u_2 = [ref[0]-fp2[0],ref[1]-fp2[1],ref[2]-fp2[2]]
        u1 = geo2.crossProduct(u_0, u_1)
        u1 = geo2.getVector4_3(u1)
        geo2.normalizeVector(u1)
        u2 = geo2.crossProduct(u_0, u_2)
        u2 = geo2.getVector4_3(u2)
        geo2.normalizeVector(u2)
        coords = geo2.rotateByAxis(geo2.getVector4_3(ref), geo2.getVector4_3(fpr), u1, -90)
        vAux1 = geo.createVertex(coords[0],coords[1],coords[2])
        vAP = geo.createVertex(ref2[0],ref2[1],ref2[2])
#         
        circleAux = geo.createCircleNormal2(branch.finalPoint+1,vAux1,vAux1,branch.radius,branch.index)
        v1 = geo.createVertexOnCurveFraction(circleAux, 0.25)
        v2 = geo.createVertexOnCurveFraction(circleAux, 0.75)
        geo.deleteCurve(circleAux)
        arc1 = geo.createCircleNormal2(branch.finalPoint+1, v1, v2, branch.radius, branch.index)
        arc2 = geo.createCircleNormal2(branch.finalPoint+1, v2, v1, branch.radius, branch.index)
        vts1 = cubit.get_relatives("curve", arc1, "vertex")
        vts2 = cubit.get_relatives("curve", arc2, "vertex")
        l1 = geo.createLine(vts1[0], vts1[1])
        #l2 = geo.createLine(vts2[0], vts2[1])
        t=(lenght-branch.radius*1)/lenght
        u_3 = [cubit.vertex(vts1[0]).coordinates()[0]-cubit.vertex(vts1[1]).coordinates()[0],cubit.vertex(vts1[0]).coordinates()[1]-cubit.vertex(vts1[1]).coordinates()[1],cubit.vertex(vts1[0]).coordinates()[2]-cubit.vertex(vts1[1]).coordinates()[2]]
        u3 = geo2.getVector4_3(u_3)
        geo2.normalizeVector(u3)
        refE1 = [(1-t)*ipr[0]+t*fpr[0],((1-t)*ipr[1]+t*fpr[1]),((1-t)*ipr[2]+t*fpr[2])]
        coords = geo2.rotateByAxis(geo2.getVector4_3(refE1), geo2.getVector4_3(fpr), u3, 90)
        vE = geo.createVertex(coords[0],coords[1],coords[2])
        mid = geo.createVertexOnCurveFraction(l1, 0.5)
        eli = geo.createEllipseFull(vts1[0], vE, mid)
        eli1 = geo.splitCurve2(eli, vts1[0], vts1[1])
        eli2 = eli1-1
        
        e1 = geo.createEllipse(vts1[0], vAP, branch.finalPoint+1)
        e2 = geo.createEllipse(vts1[1], vAP, branch.finalPoint+1)
        e3 = geo.createCombineCurve([e1,e2])
        #e3 = geo.createSpline(vts1[0], vAP, vts1[1])
        
        circleI = branch.circleF
        
        uaux = cubit.vertex(v1).coordinates() 
        uaux2 = cubit.vertex(v2).coordinates() 
        u = [uaux2[0]-uaux[0],uaux2[1]-uaux[1],uaux2[2]-uaux[2]]
        u = geo2.getVector4_3(u)
        geo2.normalizeVector(u)
        ip = self.points[branch.son1.initialPoint]
        fp = self.points[branch.son1.finalPoint]
        fps = self.points[branch.son1.son1.finalPoint]
        lenght = geo.distance(ip, fp)
        t=(lenght-branch.son1.radius)/lenght
        ref = [(1-t)*ip[0]+t*fp[0],((1-t)*ip[1]+t*fp[1]),((1-t)*ip[2]+t*fp[2])]
        arcsf1 = self.genArc2(branch.son1, branch.son1.finalPoint+1,ref,u1,branch.son1.radius,1)
        branch.son1.circleI = circleI
        branch.son1.circleF = arcsf1[2]
        branch.son1.link = arcsf1[2]
        branch.son1.tube = Tube([arc1,e3], arcsf1)
        branch.son1.tube.line = l1
        
        ip = self.points[branch.son2.initialPoint]
        fp = self.points[branch.son2.finalPoint]
        fps = self.points[branch.son2.son1.finalPoint]
        lenght = geo.distance(ip, fp)
        t=(lenght-branch.son2.radius)/lenght
        ref = [(1-t)*ip[0]+t*fp[0],((1-t)*ip[1]+t*fp[1]),((1-t)*ip[2]+t*fp[2])]
        arcsf2 = self.genArc2(branch.son2, branch.son2.finalPoint+1,ref,u1,branch.son2.radius,2)
        branch.son2.circleI = circleI
        branch.son2.circleF = arcsf2[2]
        branch.son2.link = arcsf2[2]
        branch.son2.tube = Tube([arc2,e3], arcsf2)
        branch.son2.tube.line = l1
Exemplo n.º 12
0
    def smoth(self):
        heap = [self.root]
        while not (len(heap) == 0):
            atual = heap.pop()
            if atual.son1 is not None and atual.son2 is not None:
                rSon1 = atual.son1.son1  
                r1i = self.points[atual.son1.initialPoint] 
                r1f = self.points[atual.son1.finalPoint]
                f1i = self.points[rSon1.initialPoint]
                f1f = self.points[rSon1.finalPoint]
                v1 = geo.createVertex(r1i[0], r1i[1], r1i[2])
                v2 = geo.createVertex(f1i[0], f1i[1], f1i[2])
                v3 = geo.createVertex(f1f[0], f1f[1], f1f[2])
                spAux = geo.createSpline(v1, v2, v3)
                sp = geo.splitCurve(spAux, v2)
                newV = geo.createVertexOnCurveFraction(sp, 0.9)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon1, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.75)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon1, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.6)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon1, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.45)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon1, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.3)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon1, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.15)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon1, newPoint)
                
                rSon2 = atual.son2.son1
                r2i = self.points[atual.son2.initialPoint] 
                r2f = self.points[atual.son2.finalPoint]
                f2i = self.points[rSon2.initialPoint]
                f2f = self.points[rSon2.finalPoint]
#                 t = 0.9
#                 ref = [(1-t)*f2i[0]+t*f2f[0],((1-t)*f2i[1]+t*f2f[1]),((1-t)*f2i[2]+t*f2f[2])]
#                 self.splitBranch(rSon2, ref)
#                 f2f = self.points[rSon2.finalPoint]
                v1 = geo.createVertex(r2i[0], r2i[1], r2i[2])
                v2 = geo.createVertex(f2i[0], f2i[1], f2i[2])
                v3 = geo.createVertex(f2f[0], f2f[1], f2f[2])
                spAux = geo.createSpline(v1, v2, v3)
                sp = geo.splitCurve(spAux, v2)
                newV = geo.createVertexOnCurveFraction(sp, 0.9)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon2, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.75)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon2, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.6)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon2, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.45)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon2, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.3)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon2, newPoint)
                newV = geo.createVertexOnCurveFraction(sp, 0.15)
                newPoint = cubit.vertex(newV).coordinates()
                newPoint = [newPoint[0],newPoint[1],newPoint[2]]
                self.points.append(newPoint)
                self.splitBranch(rSon2, newPoint)
                
                heap.append(rSon1)
                heap.append(rSon2)
            else:
                if atual.son1 is not None:
                    heap.append(atual.son1)
                if atual.son2 is not None:
                    heap.append(atual.son2) 
        self.sort() 
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