Пример #1
0
    def test_geometry(self):
        geometry_full_path = "VMAP/GEOMETRY/1"
        with vmap.VMAPImport(self._export.file_name) as import_actual:
            geometry_actual = import_actual.try_get_vmap_object(
                geometry_full_path)
            assert geometry_actual is not None
            geometry_expected = self._import_expected.try_get_vmap_object(
                geometry_full_path)
            assert geometry_expected is not None

            elements_actual = import_actual.try_get_vmap_object(
                "%s/ELEMENTS" % geometry_full_path)
            assert elements_actual is not None
            elements_expected = self._import_expected.try_get_vmap_object(
                "%s/ELEMENTS" % geometry_full_path)
            assert elements_expected is not None

            self.assert_group_attrs_equal(elements_expected, elements_actual)

            points_actual = import_actual.try_get_vmap_object(
                "%s/POINTS" % geometry_full_path)
            assert points_actual is not None
            points_expected = self._import_expected.try_get_vmap_object(
                "%s/POINTS" % geometry_full_path)
            assert points_expected is not None

            self.assert_group_attrs_equal(points_expected, points_actual)
Пример #2
0
 def test_add_variable(self):
     state_name = 'STATE-2'
     state_full_path = 'VMAP/VARIABLES/%s' % state_name
     geometry_name = '1'
     variable_name = 'DISPLACEMENT'
     variable_full_path = '%s/%s/%s' % (state_full_path, geometry_name,
                                        variable_name)
     self._export.add_variable(state_name, geometry_name, variable_name,
                               self._mesh)
     with vmap.VMAPImport(self._export.file_name) as import_actual:
         variable_group_expected = self._import_expected.try_get_vmap_object(
             variable_full_path)
         assert variable_group_expected is not None
         variable_group_actual = import_actual.try_get_vmap_object(
             variable_full_path)
         assert variable_group_expected is not None
         self.assert_group_attrs_equal(variable_group_expected,
                                       variable_group_actual,
                                       'MYIDENTIFIER', 'MYTIMEVALUE',
                                       'MYVARIABLEDESCRIPTION')
         mesh_actual = (import_actual.make_mesh(
             geometry_name,
             state_name).join_variable(variable_name).to_frame())
     mesh_expected = self._mesh[self._export.variable_column_names(
         variable_name)]
     pd.testing.assert_frame_equal(mesh_expected.sort_index(),
                                   mesh_actual.sort_index())
Пример #3
0
    def test_fundamental_groups(self):
        with vmap.VMAPImport(self._export.file_name) as import_actual:
            vmap_group = import_actual.try_get_vmap_object('VMAP')
            assert vmap_group is not None
            assert len(vmap_group) == 4

            geometry_group = import_actual.try_get_vmap_object('VMAP/GEOMETRY')
            assert geometry_group is not None
            assert len(geometry_group) == 1

            material_group = import_actual.try_get_vmap_object('VMAP/MATERIAL')
            assert material_group is not None
            assert len(material_group) == 0

            system_group = import_actual.try_get_vmap_object('VMAP/SYSTEM')
            assert system_group is not None
            assert len(system_group) == 5
            self.assert_dataset_correct(system_group['ELEMENTTYPES'],
                                        self._export._element_types)
            self.assert_dataset_correct(system_group['METADATA'],
                                        self._export._metadata, False)
            self.assert_dataset_correct(system_group['SECTION'],
                                        self._export._sections)
            self.assert_dataset_correct(system_group['UNITSYSTEM'],
                                        self._export._unit_system)
            self.assert_dataset_correct(system_group['COORDINATESYSTEM'],
                                        self._export._coordinate_systems)

            variables_group = import_actual.try_get_vmap_object(
                'VMAP/VARIABLES')
            assert variables_group is not None
            assert len(variables_group) == 0
Пример #4
0
    def test_add_element_set(self):
        geometry_name = '1'
        geometry_set_name_expected = '000003'
        geometry_set_name_actual = '000000'
        geometry_set_full_path_expected = 'VMAP/GEOMETRY/%s/GEOMETRYSETS/%s' % (
            geometry_name, geometry_set_name_expected)
        geometry_set_full_path_actual = 'VMAP/GEOMETRY/%s/GEOMETRYSETS/%s' % (
            geometry_name, geometry_set_name_actual)
        geometry_set_expected = self._import_expected.try_get_geometry_set(
            geometry_name, geometry_set_name_expected)
        assert geometry_set_expected is not None
        self._export.add_element_set(geometry_name, geometry_set_expected,
                                     self._mesh, 'ALL')
        with vmap.VMAPImport(self._export.file_name) as import_actual:
            geometry_set_group_expected = self._import_expected.try_get_vmap_object(
                geometry_set_full_path_expected)
            assert geometry_set_group_expected is not None
            geometry_set_group_actual = import_actual.try_get_vmap_object(
                geometry_set_full_path_actual)
            assert geometry_set_group_actual is not None
            self.assert_group_attrs_equal(geometry_set_group_expected,
                                          geometry_set_group_actual,
                                          'MYIDENTIFIER')

            geometry_set_actual = import_actual.try_get_geometry_set(
                geometry_name, geometry_set_name_actual)
            assert geometry_set_actual is not None
            assert geometry_set_expected.shape == geometry_set_actual.shape
            assert geometry_set_expected.size == geometry_set_actual.size
            assert geometry_set_expected.dtype == geometry_set_actual.dtype
            assert (geometry_set_expected == geometry_set_actual).all()
Пример #5
0
 def test_add_dataset(self):
     self._export.add_integration_types(RD.integration_type_content)
     dataset_name = 'INTEGRATIONTYPES'
     with vmap.VMAPImport(self._export.file_name) as import_actual:
         dataset = import_actual.try_get_vmap_object('VMAP/SYSTEM/%s' %
                                                     dataset_name)
         assert dataset is not None
         self.assert_dataset_correct(dataset, RD.integration_type_content)
Пример #6
0
def test_join_variable_unsupported_location():
    vm = vmap.VMAPImport(
        'tests/vmap/testfiles/beam_at_integration_points.vmap').make_mesh('1')
    with pytest.raises(
            vmap.FeatureNotSupportedError,
            match=
            "Unsupported value location, sorry\nSupported: NODE, ELEMENT, ELEMENT NODAL"
    ):
        vm.join_variable('STRESS_CAUCHY', 'STATE-2')
Пример #7
0
    def test_add_geometry_invalid(self):
        geometry_name = '2'
        with self.assertRaises(Exception):
            self._export.add_geometry(geometry_name, 5)

        with vmap.VMAPImport(self._export.file_name) as import_actual:
            geometry = import_actual.try_get_vmap_object('VMAP/GEOMETRY/%s' %
                                                         geometry_name)
            assert geometry is None
Пример #8
0
 def test_add_geometry(self):
     geometry_name = '2'
     self._export.add_geometry(geometry_name, self._mesh)
     mesh_expected = self._mesh[['x', 'y', 'z']]
     with vmap.VMAPImport(self._export.file_name) as import_actual:
         mesh_actual = (import_actual.make_mesh(
             geometry_name).join_coordinates().to_frame())
         pd.testing.assert_frame_equal(mesh_expected.sort_index(),
                                       mesh_actual.sort_index())
Пример #9
0
 def setUp(self):
     self._tmp_dir = tempfile.mkdtemp()
     self._export = vmap.VMAPExport(os.path.join(self._tmp_dir,
                                                 'test.vmap'))
     self._import_expected = vmap.VMAPImport(
         'tests/vmap/testfiles/beam_2d_squ_lin.vmap')
     self._mesh = (self._import_expected.make_mesh(
         '1', 'STATE-2').join_coordinates().join_variable(
             'DISPLACEMENT').to_frame())
     self._export.add_geometry('1', self._mesh)
Пример #10
0
def test_export_import_round_robin(tmpdir, filename):
    filename = os.path.join('tests/vmap/testfiles/', filename)
    import_expected = vmap.VMAPImport(filename)
    mesh = (import_expected.make_mesh(
        '1', 'STATE-2').join_coordinates().join_variable('STRESS_CAUCHY').
            join_variable('DISPLACEMENT').join_variable('E').to_frame())

    export_filename = os.path.join(tmpdir, 'export.vmap')
    (vmap.VMAPExport(export_filename).add_geometry('1', mesh).add_variable(
        'STATE-2', '1', 'STRESS_CAUCHY',
        mesh).add_variable('STATE-2', '1', 'DISPLACEMENT',
                           mesh).add_variable('STATE-2', '1', 'E', mesh))

    reimport = vmap.VMAPImport(export_filename)
    reimported_mesh = (
        reimport.make_mesh(
            '1', 'STATE-2').join_coordinates().join_variable('STRESS_CAUCHY').
        join_variable('DISPLACEMENT').join_variable('E').to_frame())

    pd.testing.assert_frame_equal(mesh, reimported_mesh)
Пример #11
0
 def test_add_variable_invalid_location(self):
     state_name = 'STATE-2'
     geometry_name = '1'
     variable_name = 'DISPLACEMENT'
     with self.assertRaises(Exception):
         self._export.add_variable(state_name,
                                   geometry_name,
                                   variable_name,
                                   self._mesh,
                                   column_names=['dx', 'dy', 'dz'],
                                   location=4)
     with vmap.VMAPImport(self._export.file_name) as import_actual:
         variable = import_actual.try_get_vmap_object(
             'VMAP/VARIABLES/%s/%s/%s' %
             (state_name, geometry_name, variable_name))
         assert variable is None
Пример #12
0
 def test_add_variable_not_present_in_mesh(self):
     state_name = 'STATE-2'
     geometry_name = '1'
     variable_name = 'FORCE_REACTION'
     with self.assertRaises(Exception):
         self._export.add_variable(
             state_name,
             geometry_name,
             variable_name,
             self._mesh,
             column_names=['RF1'],
             location=structures.VariableLocations.NODE)
     with vmap.VMAPImport(self._export.file_name) as import_actual:
         variable = import_actual.try_get_vmap_object(
             'VMAP/VARIABLES/%s/%s/%s' %
             (state_name, geometry_name, variable_name))
         assert variable is None
Пример #13
0
 def test_add_variable_unknown_column_name(self):
     state_name = 'STATE-2'
     geometry_name = '1'
     variable_name = 'FORCE_REACTION'
     mesh_expected = (self._import_expected.make_mesh(
         geometry_name,
         state_name).join_variable(variable_name,
                                   column_names=['RF1', 'RF2',
                                                 'RF3']).to_frame())
     self._export.add_variable(state_name,
                               geometry_name,
                               'RF1',
                               mesh_expected,
                               column_names=['RF1'],
                               location=structures.VariableLocations.NODE)
     with vmap.VMAPImport(self._export.file_name) as import_actual:
         mesh_actual = (import_actual.make_mesh(
             geometry_name,
             state_name).join_variable('RF1',
                                       column_names=['RF1']).to_frame())
         pd.testing.assert_series_equal(mesh_actual['RF1'],
                                        mesh_expected['RF1'])
Пример #14
0
def rotsym_quad():
    return vmap.VMAPImport('tests/vmap/testfiles/rotsym_quad_lin.vmap')
Пример #15
0
def beam_3d_hex():
    return vmap.VMAPImport('tests/vmap/testfiles/beam_3d_hex_lin.vmap')
Пример #16
0
def beam_2d_squ():
    return vmap.VMAPImport('tests/vmap/testfiles/beam_2d_squ_lin.vmap')