Ejemplo n.º 1
0
def rank():
    # No idea what to do with firedrake here, so I assume one of them will fix it!
    try:
        # DOLFIN 1.4 and onwards
        return backend.MPI.rank(backend.mpi_comm_world())
    except AttributeError:
        # Will be removed in DOLFIN 1.5:
        return backend.MPI.process_number()
Ejemplo n.º 2
0
    def read(var):
        filename = str(var)
        filename = filename.replace(":","-")
        suffix = "h5"

        V = adjglobals.checkpoint_fs[filename]
        v = backend.Function(V)
        file = backend.HDF5File(backend.mpi_comm_world(), filename+".%s" % suffix, "r")
        file.read(v, filename)
        file.close()

        return Vector(v)
Ejemplo n.º 3
0
    def write(self, var):
        filename = str(var)
        suffix = "h5"

        # Change naming scheme for compatibility with HDF5File routines
        filename = filename.replace(":","-")

        #if not os.path.isfile(filename+".%s" % suffix):
        #  backend.info_red("Warning: Overwriting checkpoint file "+filename+"."+suffix)
        file = backend.HDF5File(backend.mpi_comm_world(), filename+".%s" % suffix, "w")
        file.write(self.data, filename)
        file.close()

        # Save the function space into adjglobals.checkpoint_fs. It will be needed when reading the variable back in.
        adjglobals.checkpoint_fs[filename] = self.data.function_space()