Example #1
0
    def testAdaptivity(self):
        """
        Test that adaptive timestep files load correctly.
        """
        reader = chigger.exodus.ExodusReader(self.multiple)
        reader.update()

        # Times
        self.assertEqual(reader.getTimes(), [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5])

        # Time
        reader.setOptions(timestep=None, time=1.01)
        if reader.needsUpdate():
            reader.update()
        tdata = reader.getTimeData()
        self.assertAlmostEqual(tdata.time, 1)
        self.assertEqual(tdata.timestep, 2)
        self.assertEqual(tdata.index, 0)
        self.assertEqual(tdata.filename, self.multiple + '-s002')

        # Wait and the "update" the first few files
        time.sleep(1.5)
        for i in range(6):
            mooseutils.touch(self.testfiles[i])

        reader.setOptions(time=None, timestep=-1)
        if reader.needsUpdate():
            reader.update()
        tdata = reader.getTimeData()
        self.assertEqual(reader.getTimes(), [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0])
        self.assertAlmostEqual(tdata.time, 3.0)
        self.assertEqual(tdata.timestep, 6)
        self.assertEqual(tdata.index, 0)
        self.assertEqual(tdata.filename, self.multiple + '-s006')
    def testUpdate(self):
        """
        Test that updating the files updates the active list.
        """

        # Wait and the "update" the first few files
        time.sleep(1.5)
        for i in range(5):
            print self.testfiles[i]
            mooseutils.touch(self.testfiles[i])

        active = chigger.utils.get_active_filenames(self.basename + '.e', self.basename + '.e-s*')
        self.assertEqual(len(active), 5)
        self.assertEqual(active[0][0], self.basename + '.e')
        self.assertEqual(active[-1][0], self.basename + '.e-s005')
    def testUpdate(self):
        """
        Test that updating the files updates the active list.
        """

        # Wait and the "update" the first few files
        time.sleep(1.5)
        for i in range(5):
            print self.testfiles[i]
            mooseutils.touch(self.testfiles[i])

        active = chigger.utils.get_active_filenames(self.basename + '.e', self.basename + '.e-s*')
        self.assertEqual(len(active), 5)
        self.assertEqual(active[0][0], self.basename + '.e')
        self.assertEqual(active[-1][0], self.basename + '.e-s005')
    def testOldData(self):
        """
        Test that old data is not loaded
        """

        # Load the files
        self.copyfiles()
        data = mooseutils.VectorPostprocessorReader('vpp_*.csv')
        self.assertTrue(data)
        self.assertEqual(data.data.shape, (3,6,3))

        # Make the last file old
        time.sleep(2) # wait so new files have newer modified times
        mooseutils.touch('vpp_000.csv')
        mooseutils.touch('vpp_001.csv')

        # Update and make certain data structure is smaller
        data.update()
        self.assertTrue(data)
        self.assertEqual(data.data.shape, (2,6,3))
        self.assertEqual(list(data.data.keys().values), [1,3])

        # Test data
        y = data['y']
        self.assertEqual(y[3][4], 8)

        # Touch 3 so that, it should show up then
        time.sleep(1)
        mooseutils.touch('vpp_002.csv')
        data.update()
        self.assertTrue(data)
        self.assertEqual(data.data.shape, (3,6,3))
    def testOldData(self):
        """
        Test that old data is not loaded
        """

        # Load the files
        self.copyfiles()
        data = mooseutils.VectorPostprocessorReader('vpp_*.csv')
        self.assertTrue(data)
        self.assertEqual(data.data.shape, (3, 6, 3))

        # Make the last file old
        time.sleep(2)  # wait so new files have newer modified times
        mooseutils.touch('vpp_000.csv')
        mooseutils.touch('vpp_001.csv')

        # Update and make certain data structure is smaller
        data.update()
        self.assertTrue(data)
        self.assertEqual(data.data.shape, (2, 6, 3))
        self.assertEqual(list(data.data.keys().values), [1, 3])

        # Test data
        y = data['y']
        self.assertEqual(y[3][4], 8)

        # Touch 3 so that, it should show up then
        time.sleep(1)
        mooseutils.touch('vpp_002.csv')
        data.update()
        self.assertTrue(data)
        self.assertEqual(data.data.shape, (3, 6, 3))
Example #6
0
    def testAdaptivity(self):
        """
        Test that adaptive timestep files load correctly.
        """
        reader = chigger.exodus.ExodusReader(self.multiple)
        reader.update()

        # Times
        self.assertEqual(reader.getTimes(),
                         [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5])

        # Time
        reader.setOptions(timestep=None, time=1.01)
        if reader.needsUpdate():
            reader.update()
        tdata = reader.getTimeData()
        self.assertAlmostEqual(tdata.time, 1)
        self.assertEqual(tdata.timestep, 2)
        self.assertEqual(tdata.index, 0)
        self.assertEqual(tdata.filename, self.multiple + '-s002')

        # Wait and the "update" the first few files
        time.sleep(1.5)
        for i in range(6):
            mooseutils.touch(self.testfiles[i])

        reader.setOptions(time=None, timestep=-1)
        if reader.needsUpdate():
            reader.update()
        tdata = reader.getTimeData()
        self.assertEqual(reader.getTimes(),
                         [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0])
        self.assertAlmostEqual(tdata.time, 3.0)
        self.assertEqual(tdata.timestep, 6)
        self.assertEqual(tdata.index, 0)
        self.assertEqual(tdata.filename, self.multiple + '-s006')