Esempio n. 1
0
        def test_model_appender(self):
            """`OcTreeAppender` 2D: Data array name"""
            # Creat a tree mesh to append
            reader = OcTreeReader()
            reader.set_mesh_filename(self.meshFileName)
            reader.add_model_file_name(self.modelFileNames[0])
            reader.set_data_name('Initial Data')
            reader.Update()
            tree = reader.GetOutput()
            self.assertIsNotNone(tree)
            self.assertEqual(tree.GetNumberOfCells(), 29)
            self.assertEqual(tree.GetNumberOfPoints(), 84)

            # Now use the model appender
            f = OcTreeAppender()
            f.SetInputDataObject(tree)
            f.add_model_file_name(self.modelFileNames[1::])
            f.set_data_name('Appended Data')
            f.Update()

            output = f.GetOutput()
            # remember that 2 arrays is added by the reader
            self.assertEqual(output.GetCellData().GetNumberOfArrays(), 4)
            self.assertEqual(output.GetCellData().GetArrayName(3), os.path.basename(self.modelFileNames[1])) # use file as name
            self.assertEqual(len(f.get_time_step_values()), self.nt-1)
            return
Esempio n. 2
0
        def test_simple_octree(self):
            """`OcTreeReader`: simple octree mesh file"""
            reader = OcTreeReader()
            reader.set_mesh_filename(self.meshFileName)

            reader.Update()

            tree = reader.GetOutput()
            self.assertIsNotNone(tree)
            self.assertEqual(tree.GetNumberOfCells(), 29)
            self.assertEqual(tree.GetNumberOfPoints(), 84)
Esempio n. 3
0
        def test_simple_octree_models(self):
            """`OcTreeReader`: simple octree mesh with models"""
            reader = OcTreeReader()
            reader.set_mesh_filename(self.meshFileName)
            reader.add_model_file_name(self.modelFileNames)
            reader.set_data_name('foo')

            reader.Update() # Check that normal update works

            tree = reader.GetOutputDataObject(0)
            self.assertIsNotNone(tree)
            self.assertEqual(tree.GetNumberOfCells(), 29)
            self.assertEqual(tree.GetNumberOfPoints(), 84)

            self.reshapeArrs(tree)

            wtree = dsa.WrapDataObject(tree)
            # Now check time series
            for i in range(self.nt):
                reader.UpdateTimeStep(i)
                arr = wtree.CellData['foo']
                self.assertTrue(np.allclose(arr, self.arrs[i], rtol=RTOL))

            return