Example #1
0
    def __get_isovol(self, lbound, ubound, i):
        """Gets the volume selection for isovolume and export just the
        outer surface of the volume as STL.

        Input:
        ------
            lbound: float, lower boundary value for the isovolume
            ubound: float, upper boundary value for the isovolume
            i: int, surface number
        """
        # generate isovolume
        v.AddOperator("Isovolume")
        att = v.IsovolumeAttributes()
        att.lbound = lbound
        att.ubound = ubound
        v.SetOperatorOptions(att)

        # set operator setting to only get surfaces meshes
        v.AddOperator("ExternalSurface")

        # draw plot
        v.DrawPlots()

        # export current volume to folder
        e = v.ExportDBAttributes()
        e.dirname = self.db + "/vols/"
        e.db_type = "STL"
        e.filename = str(i)
        e.variables = self.data
        export_res = v.ExportDatabase(e)

        # check if exporting was successful or not and adjust values
        if export_res == 0:
            # export not successful because there was no data
            # get new upper bound
            warn_message = "Warning: no data to export between " \
                + "{} and {}.\n".format(lbound, ubound) \
                + "Increasing upper bound to next selected level."
            warnings.warn(warn_message)
            if ubound == max(self.levels):
                # already at max so do not need to export more levels
                self.levels.remove(ubound)
                export_res = 1
            else:
                # update to next level to try again
                index = self.levels.index(ubound)
                ubound_old = ubound
                ubound = self.levels[index + 1]
                self.levels.remove(ubound_old)
        # delete the operators
        v.RemoveAllOperators()

        return export_res, ubound
Example #2
0
    def _get_isovol(self, lbound, ubound, i):
        """Gets the volume selection for isovolume and export just the
        outer surface of the volume as STL.

        Input:
        ------
            lbound: float, lower boundary value for the isovolume
            ubound: float, upper boundary value for the isovolume
            i: int, surface number
        """

        # generate isovolume
        v.AddOperator("Isovolume")
        att = v.IsovolumeAttributes()
        att.lbound = lbound
        att.ubound = ubound
        v.SetOperatorOptions(att)

        # set operator setting to only get surfaces meshes
        v.AddOperator("ExternalSurface")

        # draw plot
        draw_res = v.DrawPlots()
        if draw_res == 0:
            sys.exit("Error with producing isovolume")

        # export current volume to folder
        e = v.ExportDBAttributes()
        e.dirname = self.db + "/vols/"
        e.db_type = "STL"
        e.filename = str(i)
        e.variables = self.data
        export_res = v.ExportDatabase(e)

        if export_res == 0:
            # export not successful because there was no data
            # get new upper bound
            warn_message = "Warning: no data to export between {} and {}.\n".format(lbound, ubound) \
                + "Increasing upper bound to next selected level."
            print(warn_message)
            if ubound in self.levels:
                self._update_levels(ubound)
            else:
                # it is the arbitrary upper level set and is not needed
                self._update_levels(self.levels[-1])

        # delete the operators
        v.RemoveAllOperators()

        return export_res, ubound
Example #3
0
 def export(self, format, obase, vnames=None, seq_id=None):
     ts = self.ts
     if not seq_id is None:
         ts = seq_id
     prev_lvl = visit.SuppressMessages(2)
     if vnames is None:
         vnames = ("default", )
     obase = os.path.abspath(obase)
     odir, ofile = os.path.split(obase)
     if not ts is None:
         ofile = "%s%04d" % (ofile, ts)
     stargs = (format, str(vnames), odir, ofile)
     print "[exporting format: %s vars: %s path: %s/%s ]" % stargs
     eatts = visit.ExportDBAttributes()
     eatts.db_type = format
     eatts.filename = ofile
     eatts.dirname = odir
     eatts.variables = tuple(vnames)
     visit.ExportDatabase(eatts)
     visit.SuppressMessages(prev_lvl)
Example #4
0
            timestep = str(aux[-1]).zfill(6)

            visit.OpenDatabase(db)

            for variable in variables:

                i = 0

                for location in locations:

                    i += 1

                    LineoutAtts = visit.LineoutAttributes()
                    LineoutAtts.point1 = location[0]
                    LineoutAtts.point2 = location[1]
                    LineoutAtts.samplingOn = 1
                    LineoutAtts.numberOfSamplePoints = 1000

                    visit.AddPlot("Curve", "operators/Lineout/" + variable)
                    visit.SetOperatorOptions(LineoutAtts, 1)
                    visit.DrawPlots()
                    e = visit.ExportDBAttributes()
                    e.filename = sim + '_' + case + '_' + timestep + '_' + variable
                    e.dirname = output_folder
                    e.db_type = "Curve2D"
                    visit.ExportDatabase(e)

                    visit.DeleteAllPlots()

            visit.CloseDatabase(db)