Beispiel #1
0
def ReadMesh(nodesname, triname, griddata={}):
    meshfile = None
    #@effis-begin "mesh"->"mesh"
    io = adios.DeclareIO("mesh")
    engine = io.Open(meshfile, adios2.Mode.Read)
    engine.BeginStep()

    NodesVar = io.InquireVariable(nodesname)
    dtype = kittie_common.GetType(NodesVar)
    dims = NodesVar.Shape()
    griddata[nodesname] = np.zeros(tuple(dims), dtype=dtype)
    NodesVar.SetSelection([[0] * len(dims), list(dims)])
    engine.Get(NodesVar, griddata[nodesname])

    TriVar = io.InquireVariable(triname)
    dtype = kittie_common.GetType(TriVar)
    dims = TriVar.Shape()
    griddata[triname] = np.zeros(tuple(dims), dtype=dtype)
    TriVar.SetSelection([[0] * len(dims), list(dims)])
    engine.Get(TriVar, griddata[triname])

    engine.EndStep()
    #@effis-end

    return griddata
Beispiel #2
0
    def _GetMatching(self, exclude=[], only=[], xomit=False):
        vx = self.io.InquireVariable(self.DimInfo['xname'])
        shape = vx.Shape()
        if len(shape) == 0:
            raise ValueError(
                "Using this with a scalar for the x-axis doesn't makes sense")
        self.DimInfo['xType'] = kittie_common.GetType(vx)

        variables = self.io.AvailableVariables()
        if len(only) == 0:
            only = variables.keys()
        if (self.DimInfo['xname'] not in only) and (not xomit):
            only += [self.DimInfo['xname']]

        size = self._InitByCommSize()
        index = 0

        for name in only:
            if (name in exclude) or ((name == self.DimInfo['xname'])
                                     and xomit):
                continue

            varid = self.io.InquireVariable(name)
            TestShape = varid.Shape()
            if shape == TestShape:
                i = index % size
                self.DimInfo['UserMatches'][i] += [name]
                dtype = kittie_common.GetType(varid)
                self.DimInfo['UserTypes'][i] += [dtype]
                index += 1

        return shape
Beispiel #3
0
    def ReadMesh(self, nodesname="rz", triname="nd_connect_list"):
        meshfile = None
        #@effis-begin "mesh"->"mesh"
        io = adios.DeclareIO("mesh")
        engine = io.Open(meshfile, adios2.Mode.Read)
        engine.BeginStep()

        NodesVar = io.InquireVariable(nodesname)
        dtype = kittie_common.GetType(NodesVar)
        dims = NodesVar.Shape()
        self.nodes = np.zeros(tuple(dims), dtype=dtype)
        NodesVar.SetSelection([[0]*len(dims), list(dims)])
        engine.Get(NodesVar, self.nodes)

        TriVar = io.InquireVariable(triname)
        dtype = kittie_common.GetType(TriVar)
        dims = TriVar.Shape()
        self.triangles = np.zeros(tuple(dims), dtype=dtype)
        TriVar.SetSelection([[0]*len(dims), list(dims)])
        engine.Get(TriVar, self.triangles)

        engine.EndStep()
        #@effis-end

        self.triang = tri.Triangulation(self.nodes[:, 0], self.nodes[:, 1], triangles=self.triangles)
Beispiel #4
0
    def FindPlotData(self, re_pattern, stepname):
        self.io = kittie.Kittie.adios.AtIO("plotter")
        found_names = None

        if self.rank == 0:
            size = self.comm.Get_size()
            found_names = [[]] * size
            variables = self.io.AvailableVariables()
            varnames = variables.keys()
            if stepname in variables:
                for i, varname in enumerate(varnames):
                    index = i % size
                    pattern = re.compile(re_pattern)
                    result = pattern.search(varname)
                    if result is not None:
                        varid = self.io.InquireVariable(varname)
                        found_names[index] += [varname]

        AddStep = False
        found_names = self.comm.scatter(found_names, root=0)
        if (len(found_names) > 0) and (stepname not in found_names):
            found_names += [stepname]
            AddStep = True

        self.data = {}
        for i, varname in enumerate(found_names):
            varid = self.io.InquireVariable(varname)
            dtype = kittie_common.GetType(varid)
            if (varname == stepname) and AddStep:
                count = np.ones(1, dtype=np.int64)
                start = np.zeros(1, dtype=np.int64)
            else:
                count = np.array(varid.Shape(), dtype=np.int64)
                start = np.zeros(count.shape[0], dtype=np.int64)
            self.data[varname] = np.zeros(tuple(count), dtype=dtype)
            varid.SetSelection([start, count])
            self.engine.Get(varid, self.data[varname])

        #@effis-begin self.engine--->"plotter"
        self.engine.EndStep()
        #@effis-end

        if stepname in self.data:
            self.StepNumber = int(self.data[stepname][0])

            if self.rank == 0:
                self.LastFoundData[0] = self.StepNumber
                self.outdir = os.path.join("images",
                                           "{0}".format(self.StepNumber),
                                           self.config['plotter']['plots'])
                if not os.path.exists(self.outdir):
                    os.makedirs(self.outdir)

        self.comm.Barrier()

        if len(found_names) == 0:
            return False
        else:
            return True
Beispiel #5
0
 def _GetExplicit(self, xaxis, y):
     xsel, xname = self._xParse(xaxis, getname=True)
     ysel, yname = self._xParse(y, getname=True)
     size = self._InitByCommSize()
     index = 0
     for name in [xname, yname]:
         i = index % size
         varid = self.io.InquireVariable(name)
         if name == xname:
             xShape = varid.Shape()
             xtype = kittie_common.GetType(varid)
             self.DimInfo['xname'] = xname
             self.DimInfo['xType'] = xtype
         else:
             yShape = varid.Shape()
             ytype = kittie_common.GetType(varid)
             self.DimInfo['UserMatches'][i] += [name]
             self.DimInfo['UserTypes'][i] += [ytype]
         index += 1
     xstart, xcount = ShapeParse(xShape, xsel)
     ystart, ycount = ShapeParse(yShape, ysel)
     return xstart, xcount, xname, xtype, ystart, ycount, yname, ytype
Beispiel #6
0
    def init(self, xaxis, yexpr, comm, xkind):
        self.xaxis = xaxis
        self.yexpr = yexpr
        self.comm = comm
        self.xkind = xkind

        self.rank = self.comm.Get_rank() 
        self.size = self.comm.Get_size()
        self.starts = None
        self.counts = None

        #@effis-begin "data"->"data"
        self.io = adios.DeclareIO("data")
        self.engine = self.io.Open("", adios2.Mode.Read, self.comm)

        if self.rank == 0:
            
            xvar = self.io.InquireVariable(self.xaxis)
            print(self.xaxis, xvar)
            if xvar is None:
                error = self.comm.bcast(1, root=0)
                raise ValueError("variable={0} was not found in data. Exiting.".format(self.xaxis))
            xshape = xvar.Shape()

            ynames = []
            ytypes = []
            pattern = re.compile(self.yexpr)
            variables = self.io.AvailableVariables()
            for name in variables.keys():
                match = pattern.search(name)
                if match is not None:
                    yvar = self.io.InquireVariable(name)
                    if yvar.Shape() != xshape:
                        print("{0} matches regular expression {1}, but does not match {2} in shape. Cannot plot it.".format(name, self.yexpr, self.xaxis))
                    elif name != self.xaxis:
                        ynames += [name]
                        ytypes += [kittie_common.GetType(yvar)]
                    elif self.xkind == "scatter":
                        ynames += [self.xaxis]
                        ytypes += [kittie_common.GetType(xvar)]

            if len(ynames) < 1:
                error = self.comm.bcast(1, root=0)
                raise RuntimeError("No matching axes with the same dimensions as {0} were found for regular exprssion {1}. Exiting".format(self.xaxis, self.yexpr))
            else:
                error = self.comm.bcast(None, root=0)

        else:
            error = self.comm.bcast(None, root=0)

        if error is not None:
            sys.exit()


        if self.rank == 0:
            yvars = [ [] ] * self.size
            ydts  = [ [] ] * self.size
            for i, name in enumerate(ynames):
                yvars[i%self.size] += [ynames[i]]
                ydts[i%self.size]  += [ytypes[i]]
            self.ynames = self.comm.scatter(yvars, root=0)
            self.ytypes = self.comm.scatter(ydts,  root=0)
            self.shape = self.comm.bcast(xshape, root=0)
            if self.xkind == "bcast":
                self.xtype = self.comm.bcast(kittie_common.GetType(xvar), root=0)
        else:
            self.ynames = self.comm.scatter(None, root=0)
            self.ytypes = self.comm.scatter(None, root=0)
            self.shape = self.comm.bcast(None, root=0)
            if self.xkind == "bcast":
                self.xtype = self.comm.bcast(None, root=0)


        if len(yvars) < 1:
            self.subcomm = self.comm.Split(1, self.rank)
            self.engine.Close()
            sys.exit(0)
        else:
            self.subcomm = self.comm.Split(0, self.rank)