# Path: phon/mesh_objects/element_side_set.py
# class ElementSideSet:
# 
#     """ Represents a set of element sides """
# 
#     def __init__(self, name):
#         """
#         :param name: Name of the set.
#         :type name: str
#         """
#         self.name = name
#         self.sides = []
# 
#         # Specific properties assigned to the set, e.g. material properties.
#         self.set_properties = {}
# 
#     def __str__(self):
#         """
#         Returns a string representation of the element set.
# 
#         :return: The string representation
#         :rtype: str
# 
#         """
#         return ("Element side set with name {0} containing elements with the "
#                 "following ids {1}".format(self.name, self.sides))
# 
# Path: phon/mesh_objects/element_side_set.py
# class ElementSide:
# 
#     def __init__(self, elemnum, sidenum):
#         self.elem = elemnum
#         self.side = sidenum
# 
#     def __str__(self):
#         return "Side {} of element {}".format(self.side, self.elem)


from phon.mesh_objects.element_side_set import ElementSideSet
from phon.mesh_objects.element_side_set import ElementSide
        set_type_interface = "edge"
    else:
        raise UnsupportedDimensionError

    element_to_grain = [0] * len(mesh.elements)
    node_to_elements = [list() for n in range(0, len(mesh.nodes))]
    for element_set_name, element_set in mesh.element_sets.iteritems():
        if not element_set_name.startswith(set_type_bulk):
            continue
        grain = int(element_set_name[4:])
        for el_num in element_set.ids:
            element_to_grain[el_num - 1] = grain
            for n in mesh.elements[el_num].vertices:
                node_to_elements[n - 1].append(el_num)

    mesh.element_side_sets["outer"] = ElementSideSet("outer")
    for element_set_name, face_set in mesh.element_sets.iteritems():
        if not element_set_name[0:4] == set_type_interface:
            continue

        # We should create a proper element-side-set out of this "face-set", we'll just give it the same name though
        for face_id in face_set.ids:
            connected_tets = []
            face = mesh.elements[face_id]
            for element_id in node_to_elements[face.vertices[0] - 1]:
                element = mesh.elements[element_id]

                if mesh_dimension == 3:
                    # Need to determine which of the faces of the tet are active
                    if set(face.vertices) == {element.vertices[0], element.vertices[1], element.vertices[3]}:

# Path: phon/mesh_objects/element_side_set.py
# class ElementSideSet:
# 
#     """ Represents a set of element sides """
# 
#     def __init__(self, name):
#         """
#         :param name: Name of the set.
#         :type name: str
#         """
#         self.name = name
#         self.sides = []
# 
#         # Specific properties assigned to the set, e.g. material properties.
#         self.set_properties = {}
# 
#     def __str__(self):
#         """
#         Returns a string representation of the element set.
# 
#         :return: The string representation
#         :rtype: str
# 
#         """
#         return ("Element side set with name {0} containing elements with the "
#                 "following ids {1}".format(self.name, self.sides))
# 
# Path: phon/mesh_objects/element_side_set.py
# class ElementSide:
# 
#     def __init__(self, elemnum, sidenum):
#         self.elem = elemnum
#         self.side = sidenum
# 
#     def __str__(self):
#         return "Side {} of element {}".format(self.side, self.elem)


# Path: phon/mesh_tools/create_element_sides.py
from phon.mesh_objects.element_side_set import ElementSideSet
from phon.mesh_objects.element_side_set import ElementSide

        set_type_interface = "edge"
    else:
        raise UnsupportedDimensionError

    element_to_grain = [0] * len(mesh.elements)
    node_to_elements = [list() for n in range(0, len(mesh.nodes))]
    for element_set_name, element_set in mesh.element_sets.iteritems():
        if not element_set_name.startswith(set_type_bulk):
            continue
        grain = int(element_set_name[4:])
        for el_num in element_set.ids:
            element_to_grain[el_num - 1] = grain
            for n in mesh.elements[el_num].vertices:
                node_to_elements[n - 1].append(el_num)

    mesh.element_side_sets["outer"] = ElementSideSet("outer")
    for element_set_name, face_set in mesh.element_sets.iteritems():
        if not element_set_name[0:4] == set_type_interface:
            continue

        # We should create a proper element-side-set out of this "face-set", we'll just give it the same name though
        for face_id in face_set.ids:
            connected_tets = []
            face = mesh.elements[face_id]
            for element_id in node_to_elements[face.vertices[0] - 1]:
                element = mesh.elements[element_id]

                if mesh_dimension == 3:
                    # Need to determine which of the faces of the tet are active
                    if set(face.vertices) == {element.vertices[0], element.vertices[1], element.vertices[3]}:

                        connected_tets.append(ElementSide(element_id, 1))