コード例 #1
0
    def test_WriteEntityDataMdpa_nodes(self):
        mp = ModelPart()
        for i in range(8):
            node = mp.CreateNewNode(i + 1, i**1.1, i * 2.2, 2.6)
            node.SetValue("simple", 15.336 + i)

        file_name = "entity_data_nodes.mdpa"
        with open(file_name, 'w') as mdpa_file:
            write_mdpa._WriteEntityDataMdpa(mp.Nodes, "Nod", mdpa_file)

        CompareMdpaWithReferenceFile(file_name, self)
コード例 #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)
コード例 #3
0
    def test_WriteEntityDataMdpa_nodes_multiple_data(self):
        mp = ModelPart()
        for i in range(8):
            node = mp.CreateNewNode(i+1, 0.0, 0.0, 0.0) # coordinates do not matter here
            node.SetValue("Card", 15.336*i)
            if i%2==1:
                node.SetValue("kMui", [2, 3.3, -78.1, i+2]) # vector
            if i%4==3:
                node.SetValue("SomeMatrix", [[2, i+2, 3.3], [i+2, 5.3, 7.456]]) # matrix
                node.SetValue("TheString", "SmallDisp"+str(i))
            if i==6 or i==7:
                node.SetValue("CustomDisp", 5*i)
                node.SetValue("REACTION_X", -2*i)

        file_name = "multiple_entity_data_nodes.mdpa"
        with open(file_name, 'w') as mdpa_file:
            write_mdpa._WriteEntityDataMdpa(mp.Nodes, "Nod", mdpa_file)

        CompareMdpaWithReferenceFile(file_name, self)
コード例 #4
0
    def test_WriteEntityDataMdpa_conditions(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(14):
            cond = mp.CreateNewCondition("OneCondition", i+1, [1], props)
            cond.SetValue("Mwwz", 1+i*3)
            cond.SetValue("AAbqbCC", 1.336E6*i)
            if i%3==0:
                cond.SetValue("SomeMatrix", [[2, i+2, 3.3], [i+2, 5.3, 7.456]]) # matrix
            if i%4==0:
                cond.SetValue("YOUNG", 2397+5*i)

        file_name = "entity_data_conditions.mdpa"
        with open(file_name, 'w') as mdpa_file:
            write_mdpa._WriteEntityDataMdpa(mp.Conditions, "Condition", mdpa_file)

        CompareMdpaWithReferenceFile(file_name, self)