Exemple #1
0
    def test_mergeHistory(self):
        self.makeHistory()

        # put some big data in an HDF5 attribute. This will exercise the code that pulls
        # such attributes into a formal dataset and a reference.
        self.r.p.cycle = 1
        self.r.p.timeNode = 0
        tnGroup = self.db.getH5Group(self.r)
        database3._writeAttrs(
            tnGroup["layout/serialNum"],
            tnGroup,
            {
                "fakeBigData": numpy.eye(6400),
                "someString": "this isn't a reference to another dataset",
            },
        )

        db2 = database3.Database3("restartDB.h5", "w")
        with db2:
            db2.mergeHistory(self.db, 2, 2)
            self.r.p.cycle = 1
            self.r.p.timeNode = 0
            tnGroup = db2.getH5Group(self.r)

            # this test is a little bit implementation-specific, but nice to be explicit
            self.assertEqual(
                tnGroup["layout/serialNum"].attrs["fakeBigData"],
                "@/c01n00/attrs/0_fakeBigData",
            )

            # actually exercise the _resolveAttrs function
            attrs = database3._resolveAttrs(tnGroup["layout/serialNum"].attrs, tnGroup)
            self.assertTrue(numpy.array_equal(attrs["fakeBigData"], numpy.eye(6400)))
Exemple #2
0
    def __enter__(self):
        """
        Prepare to write states.

        The dumper keeps track of ``<Grid>`` tags that need to be written into a
        Collection at the end. This also opens an auxiliary HDF5 file for writing meshes
        at each time step.
        """
        self._meshH5 = h5py.File(self._baseName + "_mesh.h5", "w")

        if self._inputName is None:
            # we could handle the case where the database wasnt passed by pumping state
            # into a new h5 file, but why?
            raise ValueError("Input database needed to generate XDMF output!")

        self._inputDb = database3.Database3(self._inputName, "r")
        with self._inputDb as db:
            dbVersion = db.version

        if math.floor(float(dbVersion)) != 3:
            raise ValueError(
                "XDMF output requires Database version 3. Got version `{}`".
                format(dbVersion))

        self._times = []
        self._blockGrids = []
        self._assemGrids = []
Exemple #3
0
 def setUp(self):
     self.o, self.r = test_reactors.loadTestReactor(TEST_ROOT)
     self.db = database.Database3(self._testMethodName + ".h5", "w")
     self.db.open()
     self.stateRetainer = self.r.retainState().__enter__()
Exemple #4
0
 def setUp(self):
     self.db = database.Database3(self._testMethodName + ".h5", "w")
     self.db.open()
     print(self.db._fullPath)
     self.stateRetainer = self.r.retainState().__enter__()