Example #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
Example #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)
Example #3
0
 def set_data_name(self, name):
     OcTreeReader.set_data_name(self, name)
Example #4
0
 def set_use_filename(self, flag):
     OcTreeReader.set_use_filename(self, flag)
Example #5
0
 def get_time_step_values(self):
     """This is critical for registering the timesteps"""
     return OcTreeReader.get_time_step_values(self)
Example #6
0
 def set_time_delta(self, dt):
     OcTreeReader.set_time_delta(self, dt)
Example #7
0
 def add_model_file_name(self, filename):
     """Use to set the file names for the reader. Handles singlt string or list of strings."""
     OcTreeReader.add_model_file_name(self, filename)
Example #8
0
 def set_mesh_filename(self, filename):
     OcTreeReader.set_mesh_filename(self, filename)
Example #9
0
 def __init__(self):
     OcTreeReader.__init__(self)
Example #10
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