For now we only know Element types 1 (line) and 2 (triangle)

def get_header(mesh):
    """
    For now we only know Element types 1 (line) and 2 (triangle)
    """
    nr_all_nodes = len(mesh['nodes'])
    nr_types = 1  # triangles

    # compute bandwidth
    bandwidth = -1
    for triangle in mesh['elements']['2']:
        diff1 = abs(triangle[0] - triangle[1])
        diff2 = abs(triangle[0] - triangle[2])
        diff3 = abs(triangle[1] - triangle[2])
        diffm = max(diff1, diff2, diff3)
        if(diffm > bandwidth):
            bandwidth = diffm

    el_infos = []
    # triangles
    for element in ('2',):
        el = mesh['elements'][element]
        if(element == '2'):
            el_type = 3
        elif(element == '1'):
            el_type = 12  # Neumann
        nr = len(el)
        nr_nodes = len(el[0])
        el_infos.append((el_type, nr, nr_nodes))

    # boundary elements
    for btype in ('12', '11'):
        if(btype in mesh['boundaries']):
            el_type = int(btype)
            nr = len(mesh['boundaries'][btype])
            nr_nodes = 2
            if(nr > 0):
                nr_types += 1
                el_infos.append((el_type, nr, nr_nodes))

    # now convert to string
    str_header = ''
    for a, b, c in [(nr_all_nodes, nr_types, bandwidth), ] + el_infos:
        str_header = str_header + '{0}  {1} {2}\n'.format(a, b, c)
    return str_header