Exemplo n.º 1
0
def plot_over_line(file_in, file_out, pts, resolution=5000, fields=None):

    if file_in.lower().endswith(".pvd"):
        # create a new 'PVD Reader'
        sol = pv.PVDReader(FileName=file_in)
    elif file_in.lower().endswith(".vtu"):
        # create a new 'XML Unstructured Grid Reader'
        sol = pv.XMLUnstructuredGridReader(FileName=file_in)
    else:
        raise ValueError("file format not yet supported")

    # create a new 'Plot Over Line'
    pol = pv.PlotOverLine(Input=sol, Source="High Resolution Line Source")

    # Properties modified on plotOverLine1.Source
    pol.Source.Point1 = pts[0]
    pol.Source.Point2 = pts[1]
    pol.Source.Resolution = resolution

    # save data
    pv.SaveData(file_out, proxy=pol, Precision=15)
    if fields is not None:
        if not isinstance(fields, list):
            fields = list(fields)
        data = pd.read_csv(file_out)
        data = data[fields]
        data.to_csv(file_out)
Exemplo n.º 2
0
    def loadData(self, datafile):
        """Load a data file. The argument is a path relative to the DataPath
        pointing to the dataset to load.

        Returns True if the dataset was loaded successfully, otherwise returns
        False.

        If the dataset is loaded, this methods setups the visualization
        pipelines for interactive probing all loaded datasets.
        """

        datafile = os.path.join(_DataProber.DataPath, datafile)
        log.msg("Loading data-file", datafile, logLevel=logging.DEBUG)
        reader = simple.OpenDataFile(datafile)
        if not reader:
            return False
        rep = simple.Show(reader, Representation="Wireframe")
        probe = simple.PlotOverLine(Source="High Resolution Line Source")

        item = {}
        item["Reader"] = reader
        item["ReaderRepresentation"] = rep
        item["Probe"] = probe
        item["name"] = os.path.split(datafile)[1]
        _DataProber.PipelineObjects.append(item)
Exemplo n.º 3
0
    def line(self, variable, line, npoints=100, only_inside=True):
        """Return a list of the variable values along the line.

        Args:
            variable (str): Name of the variable.
                See :py:meth:`DataSource.probe` for details.
            line (tuple): Tuple (point1, point2), where point1 and point2 are
                three-float tuples representing the coordinates of the start
                and end point of the line.
            npoints (int): Number of points along the line.
            only_inside (bool): True if the values outside of the defined data
                should be excluded. Otherwise, return NaN for these points.
                If True, length of the returned array could differ from npoints.

        Returns:
            numpy.ndarray: Variable values or None, if the variable
                does not exist.
        """
        pvs.SetActiveSource(self.reader)
        pol = pvs.PlotOverLine(Source="High Resolution Line Source")
        pol.Source.Resolution = npoints - 1
        pol.Source.Point1 = line[0]
        pol.Source.Point2 = line[1]

        array = _get_variable_array(pol, variable, only_inside)
        return array
Exemplo n.º 4
0
def extractParaviewLineData(caseDir, varList, coords, calcDict, csvOutputVar,
                            time):
    try:
        reader = ps.OpenFOAMReader(FileName=caseDir + '/case.foam')
    except:
        ps.Connect()
        reader = ps.OpenFOAMReader(FileName=caseDir + '/case.foam')

    try:
        reader.CellArrays = varList
    except:
        print("Variables {} were not found in results. Exiting ...".format(
            varList))

    reader.MeshRegions = ['internalMesh']

    if (time in reader.TimestepValues):
        reader.SMProxy.UpdatePipeline(time)
        reader.UpdatePipelineInformation()
        #view = ps.CreateRenderView()
        #view.ViewTime = time
    else:
        print("Time-directory {} does not exist. Exiting ...".format(time))
        sys.exit(1)

    if (calcDict):
        calc = ps.Calculator(reader)
        calc.Function = calcDict["Function"]
        calc.ResultArrayName = calcDict["ResultArrayName"]

    plotLine = ps.PlotOverLine(Source="High Resolution Line Source")
    plotLine.Source.Resolution = 450
    plotLine.Source.Point1 = coords[0]  # [0.0, 0.0008, 0.0]
    plotLine.Source.Point2 = coords[1]  # [0.59, 0.0008, 0.0]

    filePath = caseDir + "/tmp.csv"
    writer = ps.CreateWriter(filePath, plotLine)
    writer.WriteAllTimeSteps = False
    writer.UseScientificNotation = 1
    #print("Writing file tmp.csv ... ")
    writer.UpdatePipeline()
    #print("Done!")
    ps.Delete(reader)
    ps.Delete(calc)  #; ps.Delete(writer)
    ps.Delete(plotLine)
    reader = None
    del reader
    calc = None
    del calc
    plotLine = None
    del plotLine
    del writer

    if (np.mod((100. * time), 1) == 0):
        print("Disconnecting ... ")
        ps.Disconnect()  # Clear memory occasionally.

    data = extractFromCSV("tmp.csv", csvOutputVar)
    return data
Exemplo n.º 5
0
def Extract_PV_data_over_line_to_txt_file(inputFileName, outputFileName,
                                           point1, point2,
                                           resolution
                                           ):
    pvs._DisableFirstRenderCameraReset()
    data_vtu = pvs.XMLUnstructuredGridReader(FileName=[inputFileName])
    PlotOverLine1 = pvs.PlotOverLine(Source="High Resolution Line Source"
                                     )
    PlotOverLine1.Source.Point1 = point1
    PlotOverLine1.Source.Point2 = point2
    PlotOverLine1.Source.Resolution = resolution
    writer = pvs.CreateWriter(outputFileName, PlotOverLine1)
    writer.FieldAssociation = "Points"  # or "Cells"
    writer.UpdatePipeline()
Exemplo n.º 6
0
def plot_over_line(file_in, file_out, pts, resolution=2000):

    if file_in.lower().endswith('.pvd'):
        # create a new 'PVD Reader'
        sol = pv.PVDReader(FileName=file_in)
    elif file_in.lower().endswith('.vtu'):
        # create a new 'XML Unstructured Grid Reader'
        sol = pv.XMLUnstructuredGridReader(FileName=file_in)
    else:
        raise ValueError, "file format not yet supported"

    # create a new 'Plot Over Line'
    pol = pv.PlotOverLine(Input=sol, Source='High Resolution Line Source')

    # Properties modified on plotOverLine1.Source
    pol.Source.Point1 = pts[0]
    pol.Source.Point2 = pts[1]
    pol.Source.Resolution = resolution

    # save data
    pv.SaveData(file_out, proxy=pol, Precision=15)
Exemplo n.º 7
0
PATH = ['/home/jmake/z2014/Alya/Runner/Couplings/TUBES03/GRAETZ01/xxx/xxx_0_0.vtu']
#
#InputData = Simple.XMLUnstructuredGridReader( 
#                        guiName="xxxx_0_0.vtu", 
#                        PointArrayStatus=['TEMPE', 'TU'], 
#                        FileName=PATH)
#
PATH = '/home/jmake/z2014/Alya/Runner/Couplings/TUBES03/GRAETZ01/internal01.ensi.case'
InputData = Simple.EnSightReader( 
                       guiName="internal01.ensi.case", 
                       PointArrays=['TEMPE', 'VELOC', "HEATF"], 
                       CaseFileName=PATH)
#-------------------------------------------------------------------------||---#

#-------------------------------------------------------------------------||---#
PlotOverLine02 = Simple.PlotOverLine( guiName="PlotOverLine02", Source="High Resolution Line Source" )
PlotOverLine02.Source.Resolution = 100
PlotOverLine02.Source.Point2 = [0.99, 0.0, 20.0]
PlotOverLine02.Source.Point1 = [0.99, 0.0, 0.0]
#
PF = Simple.ProgrammableFilter()
PF.Script = Script00
Simple.Show(PF)
#-------------------------------------------------------------------------||---#

#-------------------------------------------------------------------------||---#
PlotOverLine01 = Simple.PlotOverLine( guiName="PlotOverLine01", Source="High Resolution Line Source" )
PlotOverLine01.Source.Resolution = 100
PlotOverLine01.Source.Point2 = [0.00, 0.0, 20.0]
PlotOverLine01.Source.Point1 = [0.00, 0.0, 0.0]
#