Exemplo n.º 1
0
    def __read_element(self, node_dic):
        i_file = open(self.__filename, "r")
        elem_dic = {}
        read_element = False
        for line in i_file:
            line = line[0:-1]
            # Coments and line does not exist
            if len(line) == 0:
                continue
            elif len(line) >= 2:
                if line[0:1] == "**":
                    continue

            # Stop reading
            if line[0] == "*":
                read_element = False

            if read_element:
                words = line.split(", ")
                first_word = True
                node_list = []
                for word in words:
                    if first_word:
                        elem_id = int(word)
                        first_word = False
                    else:
                        node_list.append(node_dic[int(word)])
                elem_dic[elem_id] = FEM.Element(elem_id, node_list)

            # Check if node key is found and not *NODE PRINT ...

            if "*ELEMENT" in line.upper():
                words = line.split(",")
                for word in words:
                    new_word = word.split(" ")
                    for word_no_space in new_word:
                        if word_no_space.upper() == "*ELEMENT":
                            read_element = True
        return elem_dic
Exemplo n.º 2
0
def UNV2412Reader(f, fem):
    SpecialElemTypes = [11] # types of elements which are defined on 3 lines
    while True:
        line1 = f.readline()
        line2 = f.readline().strip()
        if len(line2) and not line1.startswith(FLAG):
            dataline = Line2Int(line1)
            etype = dataline[1]
            nnodes = dataline[-1]
            if etype < 33:
                # 1D elements have an additionnal line in definition
                nodes = Line2Int(f.readline())
            else:
                # Standard elements have connectivities on secnd line
                nodes = Line2Int(line2)
                while nnodes > 8:
                    nodes.extend(Line2Int(f.readline()))
                    nnodes -= 8
            e = FEM.Element(dataline[0], etype, nodes)
            fem.elements.append(e)
        else:
            break
    logging.info('{} elements'.format(len(fem.elements)))
    return fem