Beispiel #1
0
def nodedupl_recursion(elein, edgein, nodeid, boundary_id):
    global copy_eles, copy_edges, copy_nodes, debug, copy_surface_ids, copy_surface_id, copy_surfaceowner_ids, copy_region_ids

    next_edgein = triangle.get_partner_edge(edgein, nodeid, boundary_id)

    if next_edgein == None:
        print "Reached one end of the surface boundary."
        return
    if debug > 1:
        print "Lets loop around nodeid", nodeid, " starting with ele", elein + 1, " with boundary edge ", edgein + 1, " until we reach the next surface edge with id ", next_edgein + 1
    next_elein_list = triangle.get_eles_on_ele_side(elein, nodeid, edgein,
                                                    boundary_id)

    if debug > 1:
        print "Duplicate edge ", next_edgein + 1
    copy_edges.append(triangle.edges[next_edgein])
    copy_surface_ids.append(new_surface_id)
    copy_surfaceowner_ids.append(
        next_elein_list[len(next_elein_list) - 1] +
        1)  # update copy_surfaceowner_ids for the new edge
    # update copy_surfaceowner_ids for the old edge
    if triangle.ele_with_edgeids(next_edgein)[0] == next_elein_list[
            len(next_elein_list) - 1]:
        copy_surfaceowner_ids[next_edgein] = triangle.ele_with_edgeids(
            next_edgein)[1] + 1
    else:
        copy_surfaceowner_ids[next_edgein] = triangle.ele_with_edgeids(
            next_edgein)[0] + 1

    if (triangle.edges[next_edgein][0] == nodeid):
        next_nodeid = triangle.edges[next_edgein][1]
    else:
        next_nodeid = triangle.edges[next_edgein][0]
    nodedupl_recursion(next_elein_list[len(next_elein_list) - 1], next_edgein,
                       next_nodeid, boundary_id)
def nodedupl_recursion(elein, edgein, nodeid, boundary_id):
     global copy_eles, copy_edges, copy_nodes, debug, copy_surface_ids, copy_surface_id, copy_surfaceowner_ids, copy_region_ids

     next_edgein=triangle.get_partner_edge(edgein, nodeid, boundary_id)

     if next_edgein==None:
        print "Reached one end of the surface boundary."
        return
     if debug>1: 
        print "Lets loop around nodeid", nodeid, " starting with ele", elein+1, " with boundary edge ", edgein+1, " until we reach the next surface edge with id ", next_edgein+1
     next_elein_list=triangle.get_eles_on_ele_side(elein, nodeid, edgein, boundary_id)

     if debug>1: 
             print "Duplicate edge ", next_edgein +1
     copy_edges.append(triangle.edges[next_edgein])
     copy_surface_ids.append(new_surface_id)
     copy_surfaceowner_ids.append(next_elein_list[len(next_elein_list)-1]+1) # update copy_surfaceowner_ids for the new edge
     # update copy_surfaceowner_ids for the old edge
     if triangle.ele_with_edgeids(next_edgein)[0]==next_elein_list[len(next_elein_list)-1]:
        copy_surfaceowner_ids[next_edgein]=triangle.ele_with_edgeids(next_edgein)[1]+1
     else:
        copy_surfaceowner_ids[next_edgein]=triangle.ele_with_edgeids(next_edgein)[0]+1

     if (triangle.edges[next_edgein][0]==nodeid):
        next_nodeid=triangle.edges[next_edgein][1]
     else:
        next_nodeid=triangle.edges[next_edgein][0]
     nodedupl_recursion(next_elein_list[len(next_elein_list)-1], next_edgein, next_nodeid, boundary_id)
Beispiel #3
0
triangle.read_elefile(filename + '.ele')

copy_eles = copy.deepcopy(triangle.eles)
copy_region_ids = copy.deepcopy(triangle.region_ids)
copy_edges = copy.deepcopy(triangle.edges)
copy_surface_ids = copy.deepcopy(triangle.surface_ids)
copy_surfaceowner_ids = [-1 for i in range(0, len(triangle.surface_ids))
                         ]  # Will store the elemed id for each surface edge
copy_nodes = copy.deepcopy(triangle.nodes)

# Now assign the surfaceowner_id to the external boundaries
for e in range(0, len(copy_surfaceowner_ids)):
    if copy_surfaceowner_ids[e] >= 0:
        print "Internal Error. Ask [email protected]!"
        exit()
    if len(triangle.ele_with_edgeids(e)) != 1:
        print "Error Found internal boundary!"
        exit()
    copy_surfaceowner_ids[e] = triangle.ele_with_edgeids(e)[0] + 1

if debug > 0:
    print "save node file as ", filename, "_edgow.node"
triangle.save_nodefile(copy_nodes, 2, filename + "_edgow.node")
if debug > 0:
    print "save ele file as ", filename, "_edgow.ele"
triangle.save_elefile(copy_eles, copy_region_ids, filename + "_edgow.ele")
if debug > 0:
    print "save edge file as ", filename, "_edgow.edge"
triangle.save_edgefile2(copy_edges, copy_surface_ids, copy_surfaceowner_ids,
                        filename + "_edgow.edge")
triangle.read_edgefile(filename+'.edge')
triangle.read_elefile(filename+'.ele')

copy_eles=copy.deepcopy(triangle.eles)
copy_region_ids=copy.deepcopy(triangle.region_ids)
copy_edges=copy.deepcopy(triangle.edges)
copy_surface_ids=copy.deepcopy(triangle.surface_ids)
copy_surfaceowner_ids=[-1 for i in range(0,len(triangle.surface_ids))] # Will store the elemed id for each surface edge
copy_nodes=copy.deepcopy(triangle.nodes)

# Now assign the surfaceowner_id to the external boundaries
for e in range(0,len(copy_surfaceowner_ids)):
        if copy_surfaceowner_ids[e]>=0:
                print "Internal Error. Ask [email protected]!"
                exit()                 
        if len(triangle.ele_with_edgeids(e))!=1:
                print "Error Found internal boundary!"
                exit()
        copy_surfaceowner_ids[e]=triangle.ele_with_edgeids(e)[0]+1

if debug>0: 
        print "save node file as ", filename, "_edgow.node"
triangle.save_nodefile(copy_nodes, 2, filename+"_edgow.node")
if debug>0: 
        print "save ele file as ", filename, "_edgow.ele"
triangle.save_elefile(copy_eles, copy_region_ids, filename+"_edgow.ele")
if debug>0: 
        print "save edge file as ", filename, "_edgow.edge"
triangle.save_edgefile2(copy_edges, copy_surface_ids, copy_surfaceowner_ids, filename+"_edgow.edge")