Ejemplo n.º 1
0
    def test_WriteEntitiesMdpa_multiple_elements(self):
        mp = ModelPart()
        for i in range(6):
            mp.CreateNewNode(i + 1, 0.0, 0.0,
                             0.0)  # coordinates do not matter here

        props_1 = mp.CreateNewProperties(1)
        props_2 = mp.CreateNewProperties(15)

        for i in range(10):
            if i % 3 == 0:
                props = props_2
            else:
                props = props_1

            mp.CreateNewElement("CustomElement", i + 1, [i % 3 + 1, i % 6 + 1],
                                props)

        for i in range(10, 15):
            mp.CreateNewElement("ShellElement", i + 1,
                                [i % 3 + 1, i % 6 + 1, i % 4 + 1, i % 5 + 1],
                                props_1)

        for i in range(15, 23):
            mp.CreateNewElement("TriangleSolidElement", i + 1,
                                [i % 6 + 1, i % 4 + 1, i % 5 + 1], props_2)

        file_name = "multiple_elements.mdpa"
        with open(file_name, 'w') as mdpa_file:
            write_mdpa._WriteEntitiesMdpa(mp.Elements, "Element", mdpa_file)

        CompareMdpaWithReferenceFile(file_name, self)
Ejemplo n.º 2
0
    def test_WriteEntityDataMdpa_elements(self):
        mp = ModelPart()
        mp.CreateNewNode(1, 0.0, 0.0, 0.0)  # coordinates do not matter here

        props = mp.CreateNewProperties(1)

        for i in range(10):
            elem = mp.CreateNewElement("CustomElement", i + 1, [1], props)
            elem.SetValue("Mulz", 1.66**i)
            elem.SetValue("AAbbCC", 1.336 * 10**i)
            if i % 2 == 0:
                elem.SetValue("YOUNG", 2397 - 10.369 * i)

        file_name = "entity_data_elements.mdpa"
        with open(file_name, 'w') as mdpa_file:
            write_mdpa._WriteEntityDataMdpa(mp.Elements, "Element", mdpa_file)

        CompareMdpaWithReferenceFile(file_name, self)