示例#1
0
    def test_get_dofs_by_nodeids(self):
        mapping = StandardMapping()
        mapping.update_mapping(self.fields, self.nodeids, self.connectivity, self.dofs_by_element, self.callbacks,
                               self.callbackargs)
        nodal2global = pd.DataFrame({'ux': {1: 0, 5: 3, 10: 6, 20: 9}, 'uy': {1: 1, 5: 4, 10: 7, 20: 10},
                                     'T': {1: 2, 5: 5, 10: 8, 20: -1}})
        mapping.nodal2global = nodal2global

        self.assertEqual(mapping.get_dofs_by_nodeids(5, 'uy'), 4)
        self.assertEqual(mapping.get_dofs_by_nodeids(20, 'T'), -1)
示例#2
0
 def test_setter_and_getter(self):
     mapping = StandardMapping()
     mapping.update_mapping(self.fields, self.nodeids, self.connectivity, self.dofs_by_element, self.callbacks,
                            self.callbackargs)
     nodal2global_desired = pd.DataFrame({'ux': {1: 0, 5: 3, 10: 6, 20: 9}, 'uy': {1: 1, 5: 4, 10: 7, 20: 10},
                                  'T': {1: 2, 5: 5, 10: 8, 20: -1}})
     mapping.nodal2global = nodal2global_desired
     assert_frame_equal(mapping.nodal2global, nodal2global_desired)
     elements2global_desired = [np.array([10, 1, 2,
                                          30, 4, 5,
                                          60, 7, 8], dtype=int),
                                np.array([31, 4,
                                          91, 10,
                                          61, 7], dtype=int)]
     dataframe = pd.DataFrame({'global_dofs': elements2global_desired}, index=[1, 5])
     mapping.elements2global = dataframe
     for actual, desired in zip(mapping.elements2global, elements2global_desired):
         assert_array_equal(actual, desired)