def read_triangle(f, layers=None):
    # Read nodes
    with open(f + '.node') as h:
        num_nodes = int(h.readline().split(' ')[0])
        node_values = np.zeros((num_nodes, 2), dtype=np.float64)
        for line in h:
            if line[0] == '#':
                continue
            node, x, y = line.split()[:3]
            node_values[int(node) - 1, :] = [float(x), float(y)]

    nodes = op2.Set(num_nodes, "nodes")
    coords = op2.Dat(nodes ** 2, node_values, name="coords")

    # Read elements
    with open(f + '.ele') as h:
        num_tri, nodes_per_tri, num_attrs = [int(col) for col in h.readline().split()]
        map_values = np.zeros((num_tri, nodes_per_tri), dtype=np.int32)
        for line in h:
            if line[0] == '#':
                continue
            vals = [int(v) - 1 for v in line.split()]
            map_values[vals[0], :] = vals[1:nodes_per_tri + 1]

    if layers is not None:
        elements = op2.ExtrudedSet(op2.Set(num_tri, "elements"), layers=layers)
    else:
        elements = op2.Set(num_tri, "elements")
    elem_node = op2.Map(elements, nodes, nodes_per_tri, map_values, "elem_node")

    return nodes, coords, elements, elem_node
Read the triangle file with prefix f into OP2 data strctures. Presently
dataset/ETHPy150Open OP2/PyOP2/demo/triangle_reader.py/read_triangle